diff options
author | Feildmaster <admin@feildmaster.com> | 2012-02-18 09:14:44 -0600 |
---|---|---|
committer | EvilSeph <evilseph@gmail.com> | 2012-02-23 18:27:22 -0500 |
commit | d7f6d2d929b1ec1d0da53e5262756e0e1ee85977 (patch) | |
tree | 568007abdf540939b18d76d987e80b11a08d73f5 /src/main | |
parent | 70c5f06425f81470406329473ffb55e9c8cc60c5 (diff) | |
download | craftbukkit-d7f6d2d929b1ec1d0da53e5262756e0e1ee85977.tar craftbukkit-d7f6d2d929b1ec1d0da53e5262756e0e1ee85977.tar.gz craftbukkit-d7f6d2d929b1ec1d0da53e5262756e0e1ee85977.tar.lz craftbukkit-d7f6d2d929b1ec1d0da53e5262756e0e1ee85977.tar.xz craftbukkit-d7f6d2d929b1ec1d0da53e5262756e0e1ee85977.zip |
[Bleeding] Use player.getItemInHand(), instead of a new ItemStack. Addresses BUKKIT-767
Diffstat (limited to 'src/main')
11 files changed, 12 insertions, 21 deletions
diff --git a/src/main/java/net/minecraft/server/ItemBed.java b/src/main/java/net/minecraft/server/ItemBed.java index d0d284b9..86363814 100644 --- a/src/main/java/net/minecraft/server/ItemBed.java +++ b/src/main/java/net/minecraft/server/ItemBed.java @@ -47,7 +47,7 @@ public class ItemBed extends Item { world.setTypeIdAndData(i, j, k, blockbed.id, i1); // CraftBukkit start - bed - BlockPlaceEvent event = CraftEventFactory.callBlockPlaceEvent(world, entityhuman, blockState, clickedX, clickedY, clickedZ, blockbed); + BlockPlaceEvent event = CraftEventFactory.callBlockPlaceEvent(world, entityhuman, blockState, clickedX, clickedY, clickedZ); if (event.isCancelled() || !event.canBuild()) { event.getBlockPlaced().setTypeIdAndData(blockState.getTypeId(), blockState.getRawData(), false); diff --git a/src/main/java/net/minecraft/server/ItemBlock.java b/src/main/java/net/minecraft/server/ItemBlock.java index 1f65bf73..bf9af158 100644 --- a/src/main/java/net/minecraft/server/ItemBlock.java +++ b/src/main/java/net/minecraft/server/ItemBlock.java @@ -68,7 +68,7 @@ public class ItemBlock extends Item { world.suppressPhysics = true; world.setTypeIdAndData(i, j, k, id, this.filterData(itemstack.getData())); - BlockPlaceEvent event = CraftEventFactory.callBlockPlaceEvent(world, entityhuman, replacedBlockState, clickedX, clickedY, clickedZ, block); + BlockPlaceEvent event = CraftEventFactory.callBlockPlaceEvent(world, entityhuman, replacedBlockState, clickedX, clickedY, clickedZ); id = world.getTypeId(i, j, k); int data = world.getData(i, j, k); replacedBlockState.update(true); diff --git a/src/main/java/net/minecraft/server/ItemDoor.java b/src/main/java/net/minecraft/server/ItemDoor.java index 640482c0..3517def9 100644 --- a/src/main/java/net/minecraft/server/ItemDoor.java +++ b/src/main/java/net/minecraft/server/ItemDoor.java @@ -97,7 +97,7 @@ public class ItemDoor extends Item { world.setTypeIdAndData(i, j, k, block.id, l); // CraftBukkit start if (entityhuman != null) { - BlockPlaceEvent event = CraftEventFactory.callBlockPlaceEvent(world, entityhuman, blockState, i, j, k, block); + BlockPlaceEvent event = CraftEventFactory.callBlockPlaceEvent(world, entityhuman, blockState, i, j, k); if (event.isCancelled() || !event.canBuild()) { event.getBlockPlaced().setTypeIdAndData(blockState.getTypeId(), blockState.getRawData(), false); diff --git a/src/main/java/net/minecraft/server/ItemFlintAndSteel.java b/src/main/java/net/minecraft/server/ItemFlintAndSteel.java index 50dbd3a3..5253e803 100644 --- a/src/main/java/net/minecraft/server/ItemFlintAndSteel.java +++ b/src/main/java/net/minecraft/server/ItemFlintAndSteel.java @@ -68,7 +68,7 @@ public class ItemFlintAndSteel extends Item { world.setTypeId(i, j, k, Block.FIRE.id); // CraftBukkit start - BlockPlaceEvent placeEvent = CraftEventFactory.callBlockPlaceEvent(world, entityhuman, blockState, clickedX, clickedY, clickedZ, Block.FIRE.id); + BlockPlaceEvent placeEvent = CraftEventFactory.callBlockPlaceEvent(world, entityhuman, blockState, clickedX, clickedY, clickedZ); if (placeEvent.isCancelled() || !placeEvent.canBuild()) { placeEvent.getBlockPlaced().setTypeIdAndData(0, (byte) 0, false); diff --git a/src/main/java/net/minecraft/server/ItemHoe.java b/src/main/java/net/minecraft/server/ItemHoe.java index b29105e7..6eedfd64 100644 --- a/src/main/java/net/minecraft/server/ItemHoe.java +++ b/src/main/java/net/minecraft/server/ItemHoe.java @@ -35,7 +35,7 @@ public class ItemHoe extends Item { world.setTypeId(i, j, k, block.id); // CraftBukkit start - Hoes - blockface -1 for 'SELF' - BlockPlaceEvent event = CraftEventFactory.callBlockPlaceEvent(world, entityhuman, blockState, i, j, k, block); + BlockPlaceEvent event = CraftEventFactory.callBlockPlaceEvent(world, entityhuman, blockState, i, j, k); if (event.isCancelled() || !event.canBuild()) { event.getBlockPlaced().setTypeId(blockState.getTypeId()); diff --git a/src/main/java/net/minecraft/server/ItemRedstone.java b/src/main/java/net/minecraft/server/ItemRedstone.java index 813c95ef..55630ac2 100644 --- a/src/main/java/net/minecraft/server/ItemRedstone.java +++ b/src/main/java/net/minecraft/server/ItemRedstone.java @@ -55,7 +55,7 @@ public class ItemRedstone extends Item { world.suppressPhysics = true; world.setRawTypeId(i, j, k, Block.REDSTONE_WIRE.id); // We update after the event - BlockPlaceEvent event = CraftEventFactory.callBlockPlaceEvent(world, entityhuman, blockState, clickedX, clickedY, clickedZ, Block.REDSTONE_WIRE); + BlockPlaceEvent event = CraftEventFactory.callBlockPlaceEvent(world, entityhuman, blockState, clickedX, clickedY, clickedZ); blockState.update(true); if (event.isCancelled() || !event.canBuild()) { diff --git a/src/main/java/net/minecraft/server/ItemReed.java b/src/main/java/net/minecraft/server/ItemReed.java index ea17b25e..c31128d9 100644 --- a/src/main/java/net/minecraft/server/ItemReed.java +++ b/src/main/java/net/minecraft/server/ItemReed.java @@ -68,7 +68,7 @@ public class ItemReed extends Item { * replace this with. */ if (world.setRawTypeId(i, j, k, this.id)) { // <-- world.e does this to place the block - BlockPlaceEvent event = CraftEventFactory.callBlockPlaceEvent(world, entityhuman, replacedBlockState, clickedX, clickedY, clickedZ, block); + BlockPlaceEvent event = CraftEventFactory.callBlockPlaceEvent(world, entityhuman, replacedBlockState, clickedX, clickedY, clickedZ); if (event.isCancelled() || !event.canBuild()) { // CraftBukkit - undo; this only has reed, repeater and pie blocks diff --git a/src/main/java/net/minecraft/server/ItemSeeds.java b/src/main/java/net/minecraft/server/ItemSeeds.java index 8033d6d0..f3afa9ca 100644 --- a/src/main/java/net/minecraft/server/ItemSeeds.java +++ b/src/main/java/net/minecraft/server/ItemSeeds.java @@ -29,7 +29,7 @@ public class ItemSeeds extends Item { world.setTypeId(i, j + 1, k, this.id); // CraftBukkit start - seeds - BlockPlaceEvent event = CraftEventFactory.callBlockPlaceEvent(world, entityhuman, blockState, i, j, k, this.id); + BlockPlaceEvent event = CraftEventFactory.callBlockPlaceEvent(world, entityhuman, blockState, i, j, k); if (event.isCancelled() || !event.canBuild()) { event.getBlockPlaced().setTypeId(0); diff --git a/src/main/java/net/minecraft/server/ItemSign.java b/src/main/java/net/minecraft/server/ItemSign.java index fc603c11..cab00f7e 100644 --- a/src/main/java/net/minecraft/server/ItemSign.java +++ b/src/main/java/net/minecraft/server/ItemSign.java @@ -57,7 +57,7 @@ public class ItemSign extends Item { } // CraftBukkit start - sign - BlockPlaceEvent event = CraftEventFactory.callBlockPlaceEvent(world, entityhuman, blockState, clickedX, clickedY, clickedZ, l == 1 ? Block.SIGN_POST : Block.WALL_SIGN); + BlockPlaceEvent event = CraftEventFactory.callBlockPlaceEvent(world, entityhuman, blockState, clickedX, clickedY, clickedZ); if (event.isCancelled() || !event.canBuild()) { event.getBlockPlaced().setTypeIdAndData(blockState.getTypeId(), blockState.getRawData(), false); diff --git a/src/main/java/net/minecraft/server/ItemWaterLily.java b/src/main/java/net/minecraft/server/ItemWaterLily.java index 694c74f5..0665f650 100644 --- a/src/main/java/net/minecraft/server/ItemWaterLily.java +++ b/src/main/java/net/minecraft/server/ItemWaterLily.java @@ -37,7 +37,7 @@ public class ItemWaterLily extends ItemColoredBlock { world.setTypeId(i, j + 1, k, Block.WATER_LILY.id);
// CraftBukkit start - waterlily
- BlockPlaceEvent event = CraftEventFactory.callBlockPlaceEvent(world, entityhuman, blockState, i, j, k, Block.WATER_LILY.id);
+ BlockPlaceEvent event = CraftEventFactory.callBlockPlaceEvent(world, entityhuman, blockState, i, j, k);
if (event.isCancelled() || !event.canBuild()) {
event.getBlockPlaced().setTypeId(0);
diff --git a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java index b06db0f0..767499c6 100644 --- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java +++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java @@ -64,27 +64,18 @@ public class CraftEventFactory { /** * Block place methods */ - public static BlockPlaceEvent callBlockPlaceEvent(World world, EntityHuman who, BlockState replacedBlockState, int clickedX, int clickedY, int clickedZ, int type) { - return callBlockPlaceEvent(world, who, replacedBlockState, clickedX, clickedY, clickedZ, net.minecraft.server.Block.byId[type]); - } - - public static BlockPlaceEvent callBlockPlaceEvent(World world, EntityHuman who, BlockState replacedBlockState, int clickedX, int clickedY, int clickedZ, net.minecraft.server.Block block) { - return callBlockPlaceEvent(world, who, replacedBlockState, clickedX, clickedY, clickedZ, new ItemStack(block)); - } - - public static BlockPlaceEvent callBlockPlaceEvent(World world, EntityHuman who, BlockState replacedBlockState, int clickedX, int clickedY, int clickedZ, ItemStack itemstack) { + public static BlockPlaceEvent callBlockPlaceEvent(World world, EntityHuman who, BlockState replacedBlockState, int clickedX, int clickedY, int clickedZ) { CraftWorld craftWorld = ((WorldServer) world).getWorld(); CraftServer craftServer = ((WorldServer) world).getServer(); Player player = (who == null) ? null : (Player) who.getBukkitEntity(); - CraftItemStack itemInHand = new CraftItemStack(itemstack); Block blockClicked = craftWorld.getBlockAt(clickedX, clickedY, clickedZ); Block placedBlock = replacedBlockState.getBlock(); boolean canBuild = canBuild(craftWorld, player, placedBlock.getX(), placedBlock.getZ()); - BlockPlaceEvent event = new BlockPlaceEvent(placedBlock, replacedBlockState, blockClicked, itemInHand, player, canBuild); + BlockPlaceEvent event = new BlockPlaceEvent(placedBlock, replacedBlockState, blockClicked, player.getItemInHand(), player, canBuild); craftServer.getPluginManager().callEvent(event); return event; |