diff --git a/.classpath b/.classpath
index d0b45a5..728d38d 100644
--- a/.classpath
+++ b/.classpath
@@ -3,5 +3,7 @@
+
+
diff --git a/bin/siegeCore/ClickHandler.class b/bin/siegeCore/ClickHandler.class
index 6a06e31..17a948d 100644
Binary files a/bin/siegeCore/ClickHandler.class and b/bin/siegeCore/ClickHandler.class differ
diff --git a/bin/siegeCore/CrunchSiegeCore.class b/bin/siegeCore/CrunchSiegeCore.class
index 17b3843..83c2756 100644
Binary files a/bin/siegeCore/CrunchSiegeCore.class and b/bin/siegeCore/CrunchSiegeCore.class differ
diff --git a/bin/siegeCore/SiegeEquipment.class b/bin/siegeCore/SiegeEquipment.class
index 293848e..00401d9 100644
Binary files a/bin/siegeCore/SiegeEquipment.class and b/bin/siegeCore/SiegeEquipment.class differ
diff --git a/src/siegeCore/ClickHandler.java b/src/siegeCore/ClickHandler.java
index 2d3fc43..e530c5c 100644
--- a/src/siegeCore/ClickHandler.java
+++ b/src/siegeCore/ClickHandler.java
@@ -165,6 +165,7 @@ public class ClickHandler implements Listener {
}
else {
equip = CrunchSiegeCore.CreateClone(living.getEquipment().getHelmet().getItemMeta().getCustomModelData());
+
equip.AmmoHolder = new EquipmentMagazine();
equip.Entity = entity;
equip.EntityId = entity.getUniqueId();
@@ -277,16 +278,18 @@ public class ClickHandler implements Listener {
}
if(sign.getLine(0).equalsIgnoreCase( "[Cannon]")){
+ if (event.getAction() == Action.LEFT_CLICK_BLOCK) {
+ CrunchSiegeCore.TrackedStands.remove(player.getUniqueId());
+ player.sendMessage("Releasing the cannons!");
+ return;
+ }
+
if(event.getAction() == Action.RIGHT_CLICK_BLOCK){
if (player.isSneaking()) {
SaveCannons(player, event.getClickedBlock());
return;
}
- if (event.getAction() == Action.LEFT_CLICK_BLOCK) {
- CrunchSiegeCore.TrackedStands.remove(player.getUniqueId());
- player.sendMessage("Releasing the cannons!");
- return;
- }
+
NamespacedKey key = new NamespacedKey(CrunchSiegeCore.plugin, "cannons");
TileState state = (TileState) sign.getBlock().getState();
CrunchSiegeCore.TrackedStands.remove(player.getUniqueId());
@@ -343,7 +346,7 @@ public class ClickHandler implements Listener {
return;
}
- if (equipment.Projectiles.containsKey(itemInHand.getType()) && !equipment.isLoaded()){
+ if (equipment.Projectiles.containsKey(itemInHand.getType()) && equipment.AmmoHolder.LoadedProjectile == 0){
equipment.AmmoHolder.LoadedProjectile = 1;
equipment.AmmoHolder.MaterialName = (Material) itemInHand.getType();
player.sendMessage("Adding projectile to cannon");
diff --git a/src/siegeCore/CrunchSiegeCore.java b/src/siegeCore/CrunchSiegeCore.java
index 727ccba..3a956db 100644
--- a/src/siegeCore/CrunchSiegeCore.java
+++ b/src/siegeCore/CrunchSiegeCore.java
@@ -115,7 +115,11 @@ public class CrunchSiegeCore extends JavaPlugin {
public static void AddDefined() {
SiegeEquipment equip = new SiegeEquipment();
- equip.Projectiles.put(Material.COBBLESTONE, new SiegeProjectile(2, false));
+ equip.Projectiles.put(Material.COBBLESTONE, new SiegeProjectile(1, false));
+ equip.Projectiles.put(Material.TNT, new SiegeProjectile(1, false));
+ equip.Projectiles.put(Material.COPPER_BLOCK, new SiegeProjectile(4, false));
+ equip.Projectiles.put(Material.GRAVEL, new SiegeProjectile(1, false));
+ equip.Projectiles.put(Material.FIREWORK_STAR, new SiegeProjectile(1, false));
ItemStack item = new ItemStack(Material.CARVED_PUMPKIN);
equip.ReadyModelNumber = 122;
equip.ModelNumberToFireAt = 135;
diff --git a/src/siegeCore/SiegeEquipment.java b/src/siegeCore/SiegeEquipment.java
index f9bc9ec..57e50dd 100644
--- a/src/siegeCore/SiegeEquipment.java
+++ b/src/siegeCore/SiegeEquipment.java
@@ -11,13 +11,19 @@ import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Particle;
import org.bukkit.Sound;
+import org.bukkit.entity.Arrow;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
+import org.bukkit.entity.Firework;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.util.Vector;
+import me.libraryaddict.disguise.DisguiseAPI;
+import me.libraryaddict.disguise.disguisetypes.DisguiseType;
+import me.libraryaddict.disguise.disguisetypes.MiscDisguise;
+
public class SiegeEquipment implements Cloneable {
@Override
@@ -51,7 +57,7 @@ public class SiegeEquipment implements Cloneable {
public Location location;
public int ModelNumberToFireAt;
public Boolean CycleThroughModelsBeforeFiring = false;
- public Boolean RotateSideways = false;
+ public Boolean RotateSideways = true;
public Boolean RotateUpDown = true;
public Boolean HasFired = false;
@@ -176,11 +182,7 @@ public class SiegeEquipment implements Cloneable {
// player.sendMessage("" + modelData);
CrunchSiegeCore.UpdateEntityIdModel(this.Entity, modelData, this.WorldName);
if (modelData == this.ModelNumberToFireAt) {
- 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_BAT_DEATH, 20, 2);
+ Shoot(loc, loadedFuel, LoadedProjectile);
}
this.NextModelNumber += 1;
@@ -198,23 +200,77 @@ public class SiegeEquipment implements Cloneable {
Location loc = living.getEyeLocation();
Vector direction = Entity.getLocation().getDirection().multiply(XOffset);
- Random random = new Random();
- float randomVar = random.nextFloat() * (6 - -6) + -6;
+
loc.add(direction);
- loc.setYaw(loc.getYaw() + randomVar);
+
this.NextModelNumber = 0;
this.location = loc;
// player.sendMessage("Cannot fire for another " + CrunchSiegeCore.convertTime(this.NextShotTime - System.currentTimeMillis()));
- 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);
-
+
+ Shoot(loc, loadedFuel, LoadedProjectile);
}, (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;
+ }
+
+
+ }
+
}