diff options
author | Andrew Ardill <andrew.ardill@gmail.com> | 2011-01-23 23:23:13 +1100 |
---|---|---|
committer | Andrew Ardill <andrew.ardill@gmail.com> | 2011-01-23 23:23:13 +1100 |
commit | a809e4e6e32e194c288723ceb2e1534bbddea174 (patch) | |
tree | ceebf1bdff232e048d8d9b669e267a6598d2af13 /src/main/java/net/minecraft/server/ItemMinecart.java | |
parent | 9cd81ddd6d78d625bab88ee0ab0bc6080447fc96 (diff) | |
download | craftbukkit-a809e4e6e32e194c288723ceb2e1534bbddea174.tar craftbukkit-a809e4e6e32e194c288723ceb2e1534bbddea174.tar.gz craftbukkit-a809e4e6e32e194c288723ceb2e1534bbddea174.tar.lz craftbukkit-a809e4e6e32e194c288723ceb2e1534bbddea174.tar.xz craftbukkit-a809e4e6e32e194c288723ceb2e1534bbddea174.zip |
removed all instances of new CraftEntity* where appropriate.
Entity.getBukkitEntity() is now used instead.
Diffstat (limited to 'src/main/java/net/minecraft/server/ItemMinecart.java')
-rw-r--r-- | src/main/java/net/minecraft/server/ItemMinecart.java | 28 |
1 files changed, 19 insertions, 9 deletions
diff --git a/src/main/java/net/minecraft/server/ItemMinecart.java b/src/main/java/net/minecraft/server/ItemMinecart.java index 35bbe4ee..7d97e6fc 100644 --- a/src/main/java/net/minecraft/server/ItemMinecart.java +++ b/src/main/java/net/minecraft/server/ItemMinecart.java @@ -1,9 +1,12 @@ package net.minecraft.server; // CraftBukkit start +import org.bukkit.block.BlockFace; +import org.bukkit.craftbukkit.CraftServer; +import org.bukkit.craftbukkit.CraftWorld; import org.bukkit.craftbukkit.block.CraftBlock; import org.bukkit.craftbukkit.inventory.CraftItemStack; -import org.bukkit.craftbukkit.entity.CraftPlayer; +import org.bukkit.entity.Player; import org.bukkit.event.Event.Type; import org.bukkit.event.player.PlayerItemEvent; // CraftBukkit end @@ -23,14 +26,21 @@ public class ItemMinecart extends Item { if (i1 == Block.aG.bi) { // CraftBukkit start - Minecarts - CraftBlock blockClicked = (CraftBlock) ((WorldServer) world).getWorld().getBlockAt(i, j, k); - CraftItemStack itemInHand = new CraftItemStack(itemstack); - CraftPlayer thePlayer = new CraftPlayer(((WorldServer) world).getServer(), (EntityPlayerMP) entityplayer); - PlayerItemEvent pie = new PlayerItemEvent(Type.PLAYER_ITEM, thePlayer, itemInHand, blockClicked, CraftBlock.notchToBlockFace(l)); - - ((WorldServer) world).getServer().getPluginManager().callEvent(pie); - - if (pie.isCancelled()) return false; + CraftWorld craftWorld = ((WorldServer) world).getWorld(); + CraftServer craftServer = ((WorldServer) world).getServer(); + + Type eventType = Type.PLAYER_ITEM; + Player who = (entityplayer == null)?null:(Player)entityplayer.getBukkitEntity(); + org.bukkit.inventory.ItemStack itemInHand = new CraftItemStack(itemstack); + org.bukkit.block.Block blockClicked = craftWorld.getBlockAt(i, j, k); + BlockFace blockFace = CraftBlock.notchToBlockFace(1); + + PlayerItemEvent pie = new PlayerItemEvent(eventType, who, itemInHand, blockClicked, blockFace); + craftServer.getPluginManager().callEvent(pie); + + if (pie.isCancelled()) { + return false; + } // CraftBukkit end if (!world.z) { |