Restore original blocks when Sneaky Assassin power-up beacon is removed

This commit is contained in:
CoderTim 2014-07-23 15:41:47 -04:00
parent a6a274069c
commit fe356add41

View File

@ -16,6 +16,8 @@ public abstract class PowerUp
private final Location _location;
private Location _effectLocation;
private Block _beaconBlock;
private BlockState _originalBeaconBlock;
private BlockState[][] _originalBeaconBase = new BlockState[3][3];
private Item _item;
public PowerUp(PowerUpManager powerUpManager, PowerUpType powerUpType, Location location)
@ -39,12 +41,21 @@ public abstract class PowerUp
public void activate()
{
_beaconBlock = getLocation().getBlock();
_beaconBlock = getLocation().getBlock().getRelative(BlockFace.DOWN);
_originalBeaconBlock = _beaconBlock.getState();
_beaconBlock.setType(Material.BEACON);
for (int x = -1; x <= 1; x++)
for (int z = -1; z <= 1; z++)
_beaconBlock.getRelative(x, -1, z).setType(Material.IRON_BLOCK);
for (int x = 0; x < 3; x++)
{
for (int z = 0; z < 3; z++)
{
Block beaconBaseBlock = _beaconBlock.getRelative(x-1, -1, z-1);
_originalBeaconBase[x][z] = beaconBaseBlock.getState();
beaconBaseBlock.setType(Material.IRON_BLOCK);
}
}
}
public void onUpdate(UpdateEvent event)
@ -103,7 +114,11 @@ public abstract class PowerUp
_item = null;
}
_beaconBlock.setType(Material.AIR);
_originalBeaconBlock.update(true, false);
for (int x = 0; x < _originalBeaconBase.length; x++)
for (int z = 0; z < _originalBeaconBase[0].length; z++)
_originalBeaconBase[x][z].update(true, false);
getPowerUpManager().removePowerUp(this);
}