Don't break the repair anvil more than twice

This commit is contained in:
cnr 2016-04-15 12:17:35 -05:00
parent 91d5851628
commit 77b6515387

View File

@ -874,12 +874,18 @@ public class Gameplay extends MiniPlugin
UtilInv.Update(player); UtilInv.Update(player);
// Break // Break
if (Math.random() > 0.85) event.getClickedBlock().setData((byte) (event.getClickedBlock().getData() + 4)); if (Math.random() > 0.85)
{
if (event.getClickedBlock().getData() >= 12) byte data = event.getClickedBlock().getData();
if (data >= 8) // Anvil has already been damaged twice
{ {
player.getWorld().playEffect(event.getClickedBlock().getLocation(), Effect.STEP_SOUND, 145); player.getWorld().playEffect(event.getClickedBlock().getLocation(), Effect.STEP_SOUND, 145);
event.getClickedBlock().setTypeIdAndData(0, (byte) 0, true); event.getClickedBlock().setType(Material.AIR);
}
else
{
event.getClickedBlock().setData((byte)(data + 4));
}
} }
// Record // Record