mirror of
https://github.com/darksaid98/SiegeEngines.git
synced 2026-12-01 22:22:10 +00:00
refactors
This commit is contained in:
1 parent
61c4963bb1
commit
129839368b
15 files changed
+184
-96
No files matched your search
@@ -20,6 +20,8 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import CrunchProjectiles.CrunchProjectile;
|
||||
import CrunchProjectiles.ExplosiveProjectile;
|
||||
import me.libraryaddict.disguise.DisguiseAPI;
|
||||
import me.libraryaddict.disguise.disguisetypes.DisguiseType;
|
||||
import me.libraryaddict.disguise.disguisetypes.MiscDisguise;
|
||||
@@ -36,8 +38,8 @@ public class SiegeEquipment implements Cloneable {
|
||||
|
||||
public ItemStack ItemToPlace;
|
||||
|
||||
public HashMap<Material, SiegeProjectile> Projectiles = new HashMap<Material, SiegeProjectile>() ;
|
||||
|
||||
public HashMap<Material, CrunchProjectile> Projectiles = new HashMap<Material, CrunchProjectile>() ;
|
||||
|
||||
public String ItemToUseForModel;
|
||||
|
||||
public String WorldName;
|
||||
@@ -46,7 +48,7 @@ public class SiegeEquipment implements Cloneable {
|
||||
public int YOffset = 0;
|
||||
public int MaxFuel = 5;
|
||||
public float VelocityPerFuel = 0.75f;
|
||||
public Material FuelMaterial = Material.GUNPOWDER;
|
||||
public Material FuelMaterial = Material.GUNPOWDER;
|
||||
public int FuseTime;
|
||||
public long NextShotTime = System.currentTimeMillis();
|
||||
|
||||
@@ -97,7 +99,7 @@ public class SiegeEquipment implements Cloneable {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
@@ -114,11 +116,11 @@ public class SiegeEquipment implements Cloneable {
|
||||
}
|
||||
float loadedFuel = this.AmmoHolder.LoadedFuel;
|
||||
Material LoadedProjectile = this.AmmoHolder.MaterialName;
|
||||
|
||||
|
||||
this.AmmoHolder.LoadedFuel = 0;
|
||||
this.AmmoHolder.LoadedProjectile = 0;
|
||||
this.AmmoHolder.MaterialName = Material.BEDROCK;
|
||||
|
||||
|
||||
LivingEntity living = (LivingEntity) Entity;
|
||||
if (living.getEquipment() == null || living.getEquipment().getHelmet() == null || living.getEquipment().getHelmet().getItemMeta() == null) {
|
||||
return;
|
||||
@@ -127,12 +129,12 @@ public class SiegeEquipment implements Cloneable {
|
||||
return;
|
||||
}
|
||||
this.WorldName = Entity.getWorld().getName();
|
||||
this.NextShotTime = System.currentTimeMillis() + 6000;
|
||||
this.NextShotTime = System.currentTimeMillis() + 1000;
|
||||
if (this.CycleThroughModelsBeforeFiring) {
|
||||
|
||||
|
||||
this.TaskNumber = Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(CrunchSiegeCore.plugin, () -> {
|
||||
|
||||
|
||||
Location loc = living.getEyeLocation();
|
||||
Vector direction = Entity.getLocation().getDirection().multiply(XOffset);
|
||||
Random random = new Random();
|
||||
@@ -140,8 +142,8 @@ public class SiegeEquipment implements Cloneable {
|
||||
loc.add(direction.multiply(randomVar));
|
||||
loc.setYaw(loc.getYaw() + randomVar);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
this.NextModelNumber = 0;
|
||||
this.location = loc;
|
||||
|
||||
@@ -182,7 +184,7 @@ public class SiegeEquipment implements Cloneable {
|
||||
// player.sendMessage("" + modelData);
|
||||
CrunchSiegeCore.UpdateEntityIdModel(this.Entity, modelData, this.WorldName);
|
||||
if (modelData == this.ModelNumberToFireAt) {
|
||||
Shoot(loc, loadedFuel, LoadedProjectile);
|
||||
Projectiles.get(LoadedProjectile).Shoot(player, this.Entity, loc, loadedFuel * this.VelocityPerFuel);
|
||||
}
|
||||
this.NextModelNumber += 1;
|
||||
|
||||
@@ -200,77 +202,68 @@ public class SiegeEquipment implements Cloneable {
|
||||
|
||||
Location loc = living.getEyeLocation();
|
||||
Vector direction = Entity.getLocation().getDirection().multiply(XOffset);
|
||||
|
||||
|
||||
loc.add(direction);
|
||||
|
||||
|
||||
this.NextModelNumber = 0;
|
||||
this.location = loc;
|
||||
|
||||
// player.sendMessage("Cannot fire for another " + CrunchSiegeCore.convertTime(this.NextShotTime - System.currentTimeMillis()));
|
||||
|
||||
Shoot(loc, loadedFuel, LoadedProjectile);
|
||||
|
||||
Projectiles.get(LoadedProjectile).Shoot(player, this.Entity, loc, loadedFuel * this.VelocityPerFuel);
|
||||
}, (long) delay);
|
||||
|
||||
}
|
||||
}
|
||||
public static Random random = new Random();
|
||||
|
||||
public void Shoot(Location loc, float loadedFuel, Material LoadedProjectile) {
|
||||
|
||||
switch (LoadedProjectile) {
|
||||
|
||||
case COBBLESTONE:
|
||||
case COPPER_BLOCK:
|
||||
{
|
||||
float randomVar = random.nextFloat() * (6 - -6) + -6;
|
||||
loc.setYaw(loc.getYaw() + randomVar);
|
||||
Entity tnt = Bukkit.getServer().getWorld(this.WorldName).spawnEntity(loc, EntityType.SNOWBALL);
|
||||
ClickHandler.projectiles.put(tnt.getUniqueId(), Projectiles.get(LoadedProjectile));
|
||||
tnt.setVelocity(loc.getDirection().multiply(loadedFuel * this.VelocityPerFuel));
|
||||
Bukkit.getServer().getWorld(this.WorldName).playSound(this.location, Sound.ENTITY_GENERIC_EXPLODE, 20, 2);
|
||||
Bukkit.getServer().getWorld(this.WorldName).spawnParticle(Particle.EXPLOSION_LARGE, loc.getX(), loc.getY(), loc.getZ(), 0);
|
||||
}
|
||||
break;
|
||||
case GRAVEL:
|
||||
{
|
||||
for (int i = 0; i < 20; i++) {
|
||||
Entity arrow = Bukkit.getServer().getWorld(this.WorldName).spawnEntity(loc, EntityType.ARROW);
|
||||
arrow.setVelocity(loc.getDirection().multiply(loadedFuel * this.VelocityPerFuel / 2).add(new Vector(random.nextDouble(), random.nextDouble(), random.nextDouble())
|
||||
.subtract(new Vector(random.nextDouble(), random.nextDouble(), random.nextDouble()))));
|
||||
Arrow arr = (Arrow) arrow;
|
||||
arr.setDamage(3 * loadedFuel);
|
||||
// MiscDisguise miscDisguise = new MiscDisguise(DisguiseType.DROPPED_ITEM, Material.IRON_NUGGET);
|
||||
// DisguiseAPI.disguiseEntity(arrow, miscDisguise);
|
||||
Bukkit.getServer().getWorld(this.WorldName).playSound(this.location, Sound.ITEM_CROSSBOW_SHOOT, 20, 2);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case TNT:
|
||||
{
|
||||
for (int i = 0; i < 5; i++) {
|
||||
//float randomVar = random.nextFloat() * (15 - -15) + -15;
|
||||
Entity tnt = Bukkit.getServer().getWorld(this.WorldName).spawnEntity(loc, EntityType.SNOWBALL);
|
||||
ClickHandler.projectiles.put(tnt.getUniqueId(), Projectiles.get(LoadedProjectile));
|
||||
tnt.setVelocity(loc.getDirection().multiply(loadedFuel * this.VelocityPerFuel).add(new Vector(random.nextDouble(), random.nextDouble(), random.nextDouble())
|
||||
.subtract(new Vector(random.nextDouble(), random.nextDouble(), random.nextDouble()))));
|
||||
Bukkit.getServer().getWorld(this.WorldName).playSound(this.location, Sound.ENTITY_GENERIC_EXPLODE, 20, 2);
|
||||
Bukkit.getServer().getWorld(this.WorldName).spawnParticle(Particle.EXPLOSION_LARGE, loc.getX(), loc.getY(), loc.getZ(), 0);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case FIREWORK_STAR:
|
||||
{
|
||||
for (int i = 0; i < 4; i++) {
|
||||
Entity arrow = Bukkit.getServer().getWorld(this.WorldName).spawnEntity(loc, EntityType.SMALL_FIREBALL);
|
||||
arrow.setVelocity(loc.getDirection().multiply(loadedFuel * this.VelocityPerFuel).add(new Vector(random.nextDouble(), random.nextDouble(), random.nextDouble())
|
||||
.subtract(new Vector(random.nextDouble(), random.nextDouble(), random.nextDouble()))));
|
||||
Bukkit.getServer().getWorld(this.WorldName).playSound(this.location, Sound.ITEM_CROSSBOW_SHOOT, 20, 2);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
//
|
||||
// public void Shoot(Location loc, float loadedFuel, Material LoadedProjectile) {
|
||||
//
|
||||
// switch (LoadedProjectile) {
|
||||
//
|
||||
// case COBBLESTONE:
|
||||
// case COPPER_BLOCK:
|
||||
// {
|
||||
// float randomVar = random.nextFloat() * (6 - -6) + -6;
|
||||
// loc.setYaw(loc.getYaw() + randomVar);
|
||||
// Entity tnt = Bukkit.getServer().getWorld(this.WorldName).spawnEntity(loc, EntityType.SNOWBALL);
|
||||
// ClickHandler.projectiles.put(tnt.getUniqueId(), );
|
||||
// tnt.setVelocity(loc.getDirection().multiply(loadedFuel * this.VelocityPerFuel));
|
||||
// Bukkit.getServer().getWorld(this.WorldName).playSound(this.location, Sound.ENTITY_GENERIC_EXPLODE, 20, 2);
|
||||
// Bukkit.getServer().getWorld(this.WorldName).spawnParticle(Particle.EXPLOSION_LARGE, loc.getX(), loc.getY(), loc.getZ(), 0);
|
||||
// }
|
||||
// break;
|
||||
// case GRAVEL:
|
||||
// {
|
||||
|
||||
// }
|
||||
// break;
|
||||
// case TNT:
|
||||
// {
|
||||
// for (int i = 0; i < 5; i++) {
|
||||
// //float randomVar = random.nextFloat() * (15 - -15) + -15;
|
||||
// Entity tnt = Bukkit.getServer().getWorld(this.WorldName).spawnEntity(loc, EntityType.SNOWBALL);
|
||||
// ClickHandler.projectiles.put(tnt.getUniqueId(), Projectiles.get(LoadedProjectile));
|
||||
// tnt.setVelocity(loc.getDirection().multiply(loadedFuel * this.VelocityPerFuel).add(new Vector(random.nextDouble(), random.nextDouble(), random.nextDouble())
|
||||
// .subtract(new Vector(random.nextDouble(), random.nextDouble(), random.nextDouble()))));
|
||||
// Bukkit.getServer().getWorld(this.WorldName).playSound(this.location, Sound.ENTITY_GENERIC_EXPLODE, 20, 2);
|
||||
// Bukkit.getServer().getWorld(this.WorldName).spawnParticle(Particle.EXPLOSION_LARGE, loc.getX(), loc.getY(), loc.getZ(), 0);
|
||||
// }
|
||||
// }
|
||||
// break;
|
||||
// case FIREWORK_STAR:
|
||||
// {
|
||||
// for (int i = 0; i < 4; i++) {
|
||||
// Entity arrow = Bukkit.getServer().getWorld(this.WorldName).spawnEntity(loc, EntityType.SMALL_FIREBALL);
|
||||
// arrow.setVelocity(loc.getDirection().multiply(loadedFuel * this.VelocityPerFuel).add(new Vector(random.nextDouble(), random.nextDouble(), random.nextDouble())
|
||||
// .subtract(new Vector(random.nextDouble(), random.nextDouble(), random.nextDouble()))));
|
||||
// Bukkit.getServer().getWorld(this.WorldName).playSound(this.location, Sound.ITEM_CROSSBOW_SHOOT, 20, 2);
|
||||
// }
|
||||
// }
|
||||
// break;
|
||||
// }
|
||||
//
|
||||
//
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user