This commit is contained in:
TheCrunchy committed 2023-07-03 19:07:15 +01:00
1 parent 129839368b
commit c7587c7ea8
8 files changed
+99 -26

No files matched your search

+3 -1
View File
@@ -1,11 +1,13 @@
package CrunchProjectiles;
import org.bukkit.Location;
import org.bukkit.Particle;
import org.bukkit.Sound;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
public interface CrunchProjectile {
public void Shoot(Player player, Entity entity, Location loc, Float velocity);
}
+42 -12
View File
@@ -1,6 +1,8 @@
package CrunchProjectiles;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Particle;
import org.bukkit.Sound;
import org.bukkit.World;
import org.bukkit.entity.Arrow;
@@ -16,25 +18,53 @@ public class EntityProjectile implements CrunchProjectile{
public int EntityCount = 20;
public int ArrowOnlyDamage = 6;
public Boolean DelayedFire = false;
public int DelayTime = 6;
public EntityType EntityTyp = EntityType.ARROW;
public float Inaccuracy = 0.2f;
public Particle ParticleType = Particle.EXPLOSION_LARGE;
public Sound SoundType = Sound.ENTITY_GENERIC_EXPLODE;
@Override
public void Shoot(Player player, Entity entity, Location loc, Float velocity) {
int baseDelay = 0;
for (int i = 0; i < EntityCount; i++) {
World world = entity.getLocation().getWorld();
Entity arrow = world.spawnEntity(loc, EntityTyp);
arrow.setVelocity(loc.getDirection().multiply(velocity).add(new Vector(CrunchSiegeCore.random.nextDouble(), CrunchSiegeCore.random.nextDouble(), CrunchSiegeCore.random.nextDouble())
.subtract(new Vector(CrunchSiegeCore.random.nextDouble(), CrunchSiegeCore.random.nextDouble(), CrunchSiegeCore.random.nextDouble()))));
if (arrow instanceof Arrow) {
Arrow arr = (Arrow) arrow;
arr.setDamage(8);
if (DelayedFire) {
baseDelay += DelayTime;
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(CrunchSiegeCore.plugin, () -> {
CreateEntity(entity, loc, velocity);
}, (long) baseDelay);
}
// MiscDisguise miscDisguise = new MiscDisguise(DisguiseType.DROPPED_ITEM, Material.IRON_NUGGET);
// DisguiseAPI.disguiseEntity(arrow, miscDisguise);
world.playSound(entity.getLocation(), Sound.ITEM_CROSSBOW_SHOOT, 20, 2);
else {
CreateEntity(entity, loc, velocity);
}
// }
}
}
private void CreateEntity(Entity entity, Location loc, Float velocity) {
World world = entity.getLocation().getWorld();
Entity arrow = world.spawnEntity(loc, EntityTyp);
if (Inaccuracy != 0f) {
arrow.setVelocity(loc.getDirection().multiply(velocity).add(Randomise())
.subtract(Randomise()));
}
else {
arrow.setVelocity(loc.getDirection().multiply(velocity));
}
if (arrow instanceof Arrow) {
Arrow arr = (Arrow) arrow;
arr.setDamage(8);
}
// MiscDisguise miscDisguise = new MiscDisguise(DisguiseType.DROPPED_ITEM, Material.IRON_NUGGET);
// DisguiseAPI.disguiseEntity(arrow, miscDisguise);
world.playSound(loc, this.SoundType, 20, 2);
world.spawnParticle(this.ParticleType, loc.getX(), loc.getY(), loc.getZ(), 0);
}
private Vector Randomise() {
return new Vector(CrunchSiegeCore.random.nextFloat() * (Inaccuracy - (Inaccuracy * -1)) + (Inaccuracy * -1),CrunchSiegeCore.random.nextFloat() * (Inaccuracy - (Inaccuracy * -1)) + (Inaccuracy * -1),CrunchSiegeCore.random.nextFloat() * (Inaccuracy - (Inaccuracy * -1)) + (Inaccuracy * -1));
}
}
+38 -11
View File
@@ -1,5 +1,6 @@
package CrunchProjectiles;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Particle;
@@ -9,6 +10,7 @@ import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.util.Vector;
import siegeCore.ClickHandler;
import siegeCore.CrunchSiegeCore;
@@ -16,24 +18,49 @@ import siegeCore.CrunchSiegeCore;
public class ExplosiveProjectile implements CrunchProjectile {
public int Radius = 2;
public float Inaccuracy = 3.0f;
public float Inaccuracy = 0.4f;
public int ProjectilesCount = 1;
public Boolean DelayedFire = false;
public int DelayTime = 6;
public Particle ParticleType = Particle.EXPLOSION_LARGE;
public Sound SoundType = Sound.ENTITY_GENERIC_EXPLODE;
@Override
public void Shoot(Player player, Entity entity, Location loc, Float velocity) {
int baseDelay = 0;
for (int i = 0; i < ProjectilesCount; i++) {
if (Inaccuracy > 0) {
float randomVar = CrunchSiegeCore.random.nextFloat() * (Inaccuracy - (Inaccuracy * -1)) + (Inaccuracy * -1);
loc.setYaw(loc.getYaw() + randomVar);
if (DelayedFire) {
baseDelay += DelayTime;
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(CrunchSiegeCore.plugin, () -> {
CreateEntity(entity, loc, velocity);
}, (long) baseDelay);
}
World world = entity.getLocation().getWorld();
Entity tnt = world.spawnEntity(loc, EntityType.SNOWBALL);
ClickHandler.projectiles.put(tnt.getUniqueId(), this);
tnt.setVelocity(loc.getDirection().multiply(velocity));
world.playSound(loc, Sound.ENTITY_GENERIC_EXPLODE, 20, 2);
world.spawnParticle(Particle.EXPLOSION_LARGE, loc.getX(), loc.getY(), loc.getZ(), 0);
else {
CreateEntity(entity, loc, velocity);
}
// }
}
}
private void CreateEntity(Entity entity, Location loc, Float velocity) {
World world = entity.getLocation().getWorld();
Entity tnt = world.spawnEntity(loc, EntityType.SNOWBALL);
ClickHandler.projectiles.put(tnt.getUniqueId(), this);
if (Inaccuracy != 0f) {
tnt.setVelocity(loc.getDirection().multiply(velocity).add(Randomise())
.subtract(Randomise()));
}
else {
tnt.setVelocity(loc.getDirection().multiply(velocity));
}
world.playSound(loc, this.SoundType, 20, 2);
world.spawnParticle(this.ParticleType, loc.getX(), loc.getY(), loc.getZ(), 0);
}
private Vector Randomise() {
return new Vector(CrunchSiegeCore.random.nextFloat() * (Inaccuracy - (Inaccuracy * -1)) + (Inaccuracy * -1),CrunchSiegeCore.random.nextFloat() * (Inaccuracy - (Inaccuracy * -1)) + (Inaccuracy * -1),CrunchSiegeCore.random.nextFloat() * (Inaccuracy - (Inaccuracy * -1)) + (Inaccuracy * -1));
}
}