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/ItemRedstone.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/ItemRedstone.java')
-rw-r--r-- | src/main/java/net/minecraft/server/ItemRedstone.java | 29 |
1 files changed, 19 insertions, 10 deletions
diff --git a/src/main/java/net/minecraft/server/ItemRedstone.java b/src/main/java/net/minecraft/server/ItemRedstone.java index c5630faa..2119012d 100644 --- a/src/main/java/net/minecraft/server/ItemRedstone.java +++ b/src/main/java/net/minecraft/server/ItemRedstone.java @@ -1,9 +1,13 @@ 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 @@ -15,9 +19,6 @@ public class ItemRedstone extends Item { } public boolean a(ItemStack itemstack, EntityPlayer entityplayer, World world, int i, int j, int k, int l) { - // CraftBukkit - get the clicked block - CraftBlock blockClicked = (CraftBlock) ((WorldServer) world).getWorld().getBlockAt(i, j, k); - if (l == 0) { j--; } @@ -41,13 +42,21 @@ public class ItemRedstone extends Item { } if (Block.av.a(world, i, j, k)) { // CraftBukkit start - Redstone - 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 itemstack.a--; |