Block spawn eggs properly.

This commit is contained in:
sk89q 2014-08-24 16:26:15 -07:00
parent 5e9ffe9e29
commit e8cd1cc253

View File

@ -105,6 +105,7 @@
import org.bukkit.inventory.ItemStack;
import org.bukkit.material.Dispenser;
import org.bukkit.material.MaterialData;
import org.bukkit.material.SpawnEgg;
import org.bukkit.util.Vector;
import javax.annotation.Nullable;
@ -738,6 +739,14 @@ private static <T extends Event & Cancellable> void handleBlockRightClick(T even
Events.fireToCancel(event, new SpawnEntityEvent(event, cause, placed.getLocation().add(0.5, 0, 0.5), EntityType.MINECART));
}
// Handle created spawn eggs
if (item != null && item.getType() == Material.MONSTER_EGG) {
MaterialData data = item.getData();
if (data instanceof SpawnEgg) {
Events.fireToCancel(event, new SpawnEntityEvent(event, cause, placed.getLocation().add(0.5, 0, 0.5), ((SpawnEgg) data).getSpawnedType()));
}
}
// Handle cocoa beans
if (item != null && item.getType() == Material.INK_SACK && Materials.isDyeColor(item.getData(), DyeColor.BROWN)) {
// CraftBukkit doesn't or didn't throw a clicked place for this