fixed siege weapon base

This commit is contained in:
NewGarbo 2016-02-03 10:53:53 +00:00
parent 9086188280
commit 95741e3029
4 changed files with 74 additions and 42 deletions

View File

@ -528,7 +528,7 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
// 0 is set aside for active build so we just dupe build to this row
// whenever we update it.
activeBuild.CustomBuildNumber = 0;
activeBuild.CustomBuildNumber = Integer.valueOf(0);
_classManager.GetRepository().SaveCustomBuild(activeBuild);
}
}

View File

@ -47,7 +47,7 @@ public class BarrierCollisionBox implements Listener
{
this();
UtilBlock.getInBoundingBox(start, end, false).forEach(block -> _collisionBlocks.add(block.getLocation()));
UtilBlock.getInBoundingBox(start.getBlock().getLocation(), end.getBlock().getLocation(), false).forEach(block -> _collisionBlocks.add(block.getLocation()));
}
public void Construct()
@ -124,7 +124,17 @@ public class BarrierCollisionBox implements Listener
public boolean isInBox(Location location)
{
return _collisionBlocks.contains(location);
for (Location other : _collisionBlocks)
{
System.out.println(other + " : " + location);
if (other.equals(location))
{
return true;
}
}
return false;
}
@EventHandler
@ -252,6 +262,6 @@ public class BarrierCollisionBox implements Listener
public static BarrierCollisionBox single(Location location)
{
return new BarrierCollisionBox(new ArrayList<>(Arrays.asList(location)));
return new BarrierCollisionBox(new ArrayList<>(Arrays.asList(location.getBlock().getLocation())));
}
}

View File

@ -43,34 +43,7 @@ public class Cannon extends SiegeWeapon
setStateInfo("Unloaded", new WeaponStateInfo(Material.SPONGE, (byte) 1));
setStateInfo("Loaded", new WeaponStateInfo(Material.SPONGE, (byte) 0));
Slime slime = location.getWorld().spawn(location, Slime.class);
Slime slime2 = location.getWorld().spawn(location, Slime.class);
UtilEnt.silence(slime, true);
UtilEnt.silence(slime2, true);
UtilEnt.Vegetate(slime);
UtilEnt.Vegetate(slime2);
slime.setSize(-1);
slime2.setSize(-1);
slime.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, 99999999, 1, true, false));
slime2.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, 99999999, 1, true, false));
ArmorStand armorStand = location.getWorld().spawn(location, ArmorStand.class);
UtilEnt.setFakeHead(armorStand, true);
armorStand.teleport(location);
armorStand.setVisible(false);
armorStand.setGravity(false);
armorStand.setPassenger(slime);
slime.setPassenger(slime2);
addEntity(slime, "Slime1");
addEntity(slime2, "PLAYERMOUNT");
addEntity(armorStand, "WEAPON");
setState("Unloaded");
loadEntities();
setFirepowerType(Material.SULPHUR);
setAmmunitionType(Material.TNT);
@ -125,6 +98,41 @@ public class Cannon extends SiegeWeapon
System.out.println("Cannon initialized.");
}
private void loadEntities()
{
Slime slime = _location.getWorld().spawn(_location, Slime.class);
UtilEnt.silence(slime, true);
UtilEnt.Vegetate(slime);
slime.setSize(-1);
slime.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, 99999999, 1, true, false));
addEntity(slime, "Filler");
slime = _location.getWorld().spawn(_location, Slime.class);
UtilEnt.silence(slime, true);
UtilEnt.Vegetate(slime);
slime.setSize(-1);
slime.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, 99999999, 1, true, false));
getEntity("Filler").setPassenger(slime);
addEntity(slime, "PLAYERMOUNT");
ArmorStand armorStand = _location.getWorld().spawn(_location, ArmorStand.class);
UtilEnt.setFakeHead(armorStand, true);
armorStand.teleport(_location);
armorStand.setVisible(false);
armorStand.setGravity(false);
armorStand.setPassenger(getEntity("Filler"));
addEntity(armorStand, "WEAPON");
}
@Override
public void Fire(WeaponProjectile projectile)
{

View File

@ -10,9 +10,12 @@ import org.bukkit.entity.ArmorStand;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.HandlerList;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.EntityDeathEvent;
import org.bukkit.event.inventory.InventoryCloseEvent;
import org.bukkit.event.player.PlayerArmorStandManipulateEvent;
import org.bukkit.event.player.PlayerInteractAtEntityEvent;
@ -52,7 +55,7 @@ public abstract class SiegeWeapon implements Listener
private Hologram _infoHologram;
private BarrierCollisionBox _collisionBox;
private Location _location;
protected final Location _location;
private final Map<String, WeaponStateInfo> _registeredStates;
private String _currentState;
@ -405,16 +408,11 @@ public abstract class SiegeWeapon implements Listener
// Entity Management
protected final boolean addEntity(Entity entity, String uniqueName)
protected final void addEntity(Entity entity, String uniqueName)
{
boolean success = _comprisedOf.add(entity);
_comprisedOf.add(entity);
if (success)
{
_entityMapping.put(uniqueName, _comprisedOf.size() - 1);
}
return success;
_entityMapping.put(uniqueName, _comprisedOf.size() - 1);
}
protected final Entity getEntity(String uniqueName)
@ -464,6 +462,8 @@ public abstract class SiegeWeapon implements Listener
System.out.println("Updating siege weapon state");
((ArmorStand) getEntity("WEAPON")).setHelmet(new ItemStack(_registeredStates.get(state).getType(), 1, (short) 0, (byte) _registeredStates.get(state).getData()));
_currentState = state;
UpdateState(state);
@ -532,7 +532,7 @@ public abstract class SiegeWeapon implements Listener
}
}
}
else if (_firepowerSlots.contains(slot))
else if (_firepowerSlots.contains(Integer.valueOf(slot)))
{
if (item.getType() != _firepowerType)
{
@ -591,6 +591,20 @@ public abstract class SiegeWeapon implements Listener
}
}
@EventHandler(priority = EventPriority.HIGHEST)
public void onDmg(EntityDamageByEntityEvent event)
{
if (!_comprisedOf.contains(event.getEntity()))
{
return;
}
if (event.getDamager() instanceof Player)
{
handleLeftClick((Player) event.getDamager());
}
}
@EventHandler
public void onCloseInv(InventoryCloseEvent event)
{