From 899b9c17cc469851cbc42c5a326869e97b492de4 Mon Sep 17 00:00:00 2001 From: feildmaster Date: Sun, 27 Jan 2013 10:44:32 -0600 Subject: [PATCH] Direct all BlockPlaceEvents to a singular location. Fixes BUKKIT-3438 By having a single function to process BlockPlacement logic, we make it so that there is consistent behavior throughout all BlockPlace events. This should allow for easier troubleshooting and less diffs in source. This also fixes BUKKIT-3463 by including the correct coordinates that were clicked to the event. --- .../net/minecraft/server/BlockMushroom.java | 7 +--- .../java/net/minecraft/server/ItemBed.java | 7 ++-- .../java/net/minecraft/server/ItemBlock.java | 7 ++-- .../java/net/minecraft/server/ItemDoor.java | 9 ++--- .../java/net/minecraft/server/ItemHoe.java | 13 ++------ .../net/minecraft/server/ItemRedstone.java | 21 +++--------- .../java/net/minecraft/server/ItemReed.java | 33 ++++--------------- .../net/minecraft/server/ItemSeedFood.java | 15 +++------ .../java/net/minecraft/server/ItemSeeds.java | 13 ++------ .../java/net/minecraft/server/ItemSign.java | 29 +++++----------- .../java/net/minecraft/server/ItemSkull.java | 3 +- .../java/net/minecraft/server/ItemStep.java | 28 ++++++---------- .../net/minecraft/server/ItemWaterLily.java | 13 ++------ 13 files changed, 57 insertions(+), 141 deletions(-) diff --git a/src/main/java/net/minecraft/server/BlockMushroom.java b/src/main/java/net/minecraft/server/BlockMushroom.java index 38fac4cfb4..db9087492c 100644 --- a/src/main/java/net/minecraft/server/BlockMushroom.java +++ b/src/main/java/net/minecraft/server/BlockMushroom.java @@ -23,6 +23,7 @@ public class BlockMushroom extends BlockFlower { } public void b(World world, int i, int j, int k, Random random) { + final int sourceX = i, sourceY = j, sourceZ = k; // CraftBukkit if (random.nextInt(25) == 0) { byte b0 = 4; int l = 5; @@ -48,12 +49,6 @@ public class BlockMushroom extends BlockFlower { j1 = j + random.nextInt(2) - random.nextInt(2); k1 = k + random.nextInt(3) - 1; - // CraftBukkit start - preserve source block coordinates - int sourceX = i; - int sourceY = j; - int sourceZ = k; - // CraftBukkit end - for (int l1 = 0; l1 < 4; ++l1) { if (world.isEmpty(i1, j1, k1) && this.d(world, i1, j1, k1)) { i = i1; diff --git a/src/main/java/net/minecraft/server/ItemBed.java b/src/main/java/net/minecraft/server/ItemBed.java index ca7dc3f8fb..15207f628d 100644 --- a/src/main/java/net/minecraft/server/ItemBed.java +++ b/src/main/java/net/minecraft/server/ItemBed.java @@ -1,7 +1,5 @@ package net.minecraft.server; -import org.bukkit.craftbukkit.block.CraftBlockState; // CraftBukkit - public class ItemBed extends Item { public ItemBed(int i) { @@ -10,6 +8,7 @@ public class ItemBed extends Item { } public boolean interactWith(ItemStack itemstack, EntityHuman entityhuman, World world, int i, int j, int k, int l, float f, float f1, float f2) { + final int clickedX = i, clickedY = j, clickedZ = k; // CraftBukkit if (world.isStatic) { return true; } else if (l != 1) { @@ -40,8 +39,8 @@ public class ItemBed extends Item { if (entityhuman.a(i, j, k, l, itemstack) && entityhuman.a(i + b0, j, k + b1, l, itemstack)) { if (world.isEmpty(i, j, k) && world.isEmpty(i + b0, j, k + b1) && world.v(i, j - 1, k) && world.v(i + b0, j - 1, k + b1)) { // CraftBukkit start - //world.setTypeIdAndData(i, j, k, blockbed.id, i1); - if (!ItemBlock.processBlockPlace(world, entityhuman, null, i, j, k, blockbed.id, i1)) { + // world.setTypeIdAndData(i, j, k, blockbed.id, i1); + if (!ItemBlock.processBlockPlace(world, entityhuman, null, i, j, k, blockbed.id, i1, clickedX, clickedY, clickedZ)) { return false; } // CraftBukkit end diff --git a/src/main/java/net/minecraft/server/ItemBlock.java b/src/main/java/net/minecraft/server/ItemBlock.java index e6d54bb105..b335b15125 100644 --- a/src/main/java/net/minecraft/server/ItemBlock.java +++ b/src/main/java/net/minecraft/server/ItemBlock.java @@ -15,6 +15,7 @@ public class ItemBlock extends Item { } public boolean interactWith(ItemStack itemstack, EntityHuman entityhuman, World world, int i, int j, int k, int l, float f, float f1, float f2) { + final int clickedX = i, clickedY = j, clickedZ = k; int i1 = world.getTypeId(i, j, k); if (i1 == Block.SNOW.id) { @@ -68,7 +69,7 @@ public class ItemBlock extends Item { --itemstack.count; } */ - return processBlockPlace(world, entityhuman, itemstack, i, j, k, this.id, k1); + return processBlockPlace(world, entityhuman, itemstack, i, j, k, this.id, k1, clickedX, clickedY, clickedZ); // CraftBukkit end } else { return false; @@ -76,14 +77,14 @@ public class ItemBlock extends Item { } // CraftBukkit start - add method to process block placement - static boolean processBlockPlace(final World world, final EntityHuman entityhuman, final ItemStack itemstack, final int x, final int y, final int z, final int id, final int data) { + static boolean processBlockPlace(final World world, final EntityHuman entityhuman, final ItemStack itemstack, final int x, final int y, final int z, final int id, final int data, final int clickedX, final int clickedY, final int clickedZ) { org.bukkit.block.BlockState blockstate = org.bukkit.craftbukkit.block.CraftBlockState.getBlockState(world, x, y, z); world.suppressPhysics = true; world.callingPlaceEvent = true; world.setRawTypeIdAndData(x, y, z, id, data); - org.bukkit.event.block.BlockPlaceEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callBlockPlaceEvent(world, entityhuman, blockstate, x, y, z); + org.bukkit.event.block.BlockPlaceEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callBlockPlaceEvent(world, entityhuman, blockstate, clickedX, clickedY, clickedZ); if (event.isCancelled() || !event.canBuild()) { blockstate.update(true); world.suppressPhysics = false; diff --git a/src/main/java/net/minecraft/server/ItemDoor.java b/src/main/java/net/minecraft/server/ItemDoor.java index 4cbe26b561..ea19a3abad 100644 --- a/src/main/java/net/minecraft/server/ItemDoor.java +++ b/src/main/java/net/minecraft/server/ItemDoor.java @@ -12,6 +12,7 @@ public class ItemDoor extends Item { } public boolean interactWith(ItemStack itemstack, EntityHuman entityhuman, World world, int i, int j, int k, int l, float f, float f1, float f2) { + final int clickedX = i, clickedY = j, clickedZ = k; // CraftBukkit if (l != 1) { return false; } else { @@ -31,7 +32,7 @@ public class ItemDoor extends Item { int i1 = MathHelper.floor((double) ((entityhuman.yaw + 180.0F) * 4.0F / 360.0F) - 0.5D) & 3; // CraftBukkit start - if (!place(world, i, j, k, i1, block, entityhuman)) { + if (!place(world, i, j, k, i1, block, entityhuman, clickedX, clickedY, clickedZ)) { return false; } // CraftBukkit end @@ -47,10 +48,10 @@ public class ItemDoor extends Item { public static void place(World world, int i, int j, int k, int l, Block block) { // CraftBukkit start - place(world, i, j, k, l, block, null); + place(world, i, j, k, l, block, null, i, j, k); } - public static boolean place(World world, int i, int j, int k, int l, Block block, EntityHuman entityhuman) { + public static boolean place(World world, int i, int j, int k, int l, Block block, EntityHuman entityhuman, int clickedX, int clickedY, int clickedZ) { // CraftBukkit end byte b0 = 0; byte b1 = 0; @@ -86,7 +87,7 @@ public class ItemDoor extends Item { world.suppressPhysics = true; // CraftBukkit start if (entityhuman != null) { - if(!ItemBlock.processBlockPlace(world, entityhuman, null, i, j, k, block.id, l)) { + if(!ItemBlock.processBlockPlace(world, entityhuman, null, i, j, k, block.id, l, clickedX, clickedY, clickedZ)) { ((EntityPlayer) entityhuman).playerConnection.sendPacket(new Packet53BlockChange(i, j + 1, k, world)); return false; } diff --git a/src/main/java/net/minecraft/server/ItemHoe.java b/src/main/java/net/minecraft/server/ItemHoe.java index 68756fbaa7..f64db5c274 100644 --- a/src/main/java/net/minecraft/server/ItemHoe.java +++ b/src/main/java/net/minecraft/server/ItemHoe.java @@ -1,7 +1,5 @@ package net.minecraft.server; -import org.bukkit.craftbukkit.block.CraftBlockState; // CraftBukkit - public class ItemHoe extends Item { protected EnumToolMaterial a; @@ -15,6 +13,7 @@ public class ItemHoe extends Item { } public boolean interactWith(ItemStack itemstack, EntityHuman entityhuman, World world, int i, int j, int k, int l, float f, float f1, float f2) { + final int clickedX = i, clickedY = j, clickedZ = k; // CraftBukkit if (!entityhuman.a(i, j, k, l, itemstack)) { return false; } else { @@ -30,15 +29,9 @@ public class ItemHoe extends Item { if (world.isStatic) { return true; } else { - CraftBlockState blockState = CraftBlockState.getBlockState(world, i, j, k); // CraftBukkit - - world.setTypeId(i, j, k, block.id); - // CraftBukkit start - Hoes - blockface -1 for 'SELF' - org.bukkit.event.block.BlockPlaceEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callBlockPlaceEvent(world, entityhuman, blockState, i, j, k); - - if (event.isCancelled() || !event.canBuild()) { - event.getBlockPlaced().setTypeId(blockState.getTypeId()); + // world.setTypeId(i, j, k, block.id); + if (!ItemBlock.processBlockPlace(world, entityhuman, null, i, j, k, block.id, 0, clickedX, clickedY, clickedZ)) { return false; } // CraftBukkit end diff --git a/src/main/java/net/minecraft/server/ItemRedstone.java b/src/main/java/net/minecraft/server/ItemRedstone.java index c9f91dae36..dee5f0d11c 100644 --- a/src/main/java/net/minecraft/server/ItemRedstone.java +++ b/src/main/java/net/minecraft/server/ItemRedstone.java @@ -1,7 +1,5 @@ package net.minecraft.server; -import org.bukkit.craftbukkit.block.CraftBlockState; // CraftBukkit - public class ItemRedstone extends Item { public ItemRedstone(int i) { @@ -10,8 +8,7 @@ public class ItemRedstone extends Item { } public boolean interactWith(ItemStack itemstack, EntityHuman entityhuman, World world, int i, int j, int k, int l, float f, float f1, float f2) { - int clickedX = i, clickedY = j, clickedZ = k; // CraftBukkit - + final int clickedX = i, clickedY = j, clickedZ = k; // CraftBukkit if (world.getTypeId(i, j, k) != Block.SNOW.id) { if (l == 0) { --j; @@ -47,22 +44,12 @@ public class ItemRedstone extends Item { } else { if (Block.REDSTONE_WIRE.canPlace(world, i, j, k)) { // CraftBukkit start - CraftBlockState blockState = CraftBlockState.getBlockState(world, i, j, k); - - world.suppressPhysics = true; - world.setRawTypeId(i, j, k, Block.REDSTONE_WIRE.id); // We update after the event - - org.bukkit.event.block.BlockPlaceEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callBlockPlaceEvent(world, entityhuman, blockState, clickedX, clickedY, clickedZ); - blockState.update(true); - - world.suppressPhysics = false; - if (event.isCancelled() || !event.canBuild()) { + // --itemstack.count; + // world.setTypeId(i, j, k, Block.REDSTONE_WIRE.id); + if (!ItemBlock.processBlockPlace(world, entityhuman, itemstack, i, j, k, Block.REDSTONE_WIRE.id, 0, clickedX, clickedY, clickedZ)) { return false; } // CraftBukkit end - - --itemstack.count; - world.setTypeId(i, j, k, Block.REDSTONE_WIRE.id); } return true; diff --git a/src/main/java/net/minecraft/server/ItemReed.java b/src/main/java/net/minecraft/server/ItemReed.java index 97a9fb6485..ab8164c7a1 100644 --- a/src/main/java/net/minecraft/server/ItemReed.java +++ b/src/main/java/net/minecraft/server/ItemReed.java @@ -1,7 +1,5 @@ package net.minecraft.server; -import org.bukkit.craftbukkit.block.CraftBlockState; // CraftBukkit - public class ItemReed extends Item { private int id; @@ -12,7 +10,7 @@ public class ItemReed extends Item { } public boolean interactWith(ItemStack itemstack, EntityHuman entityhuman, World world, int i, int j, int k, int l, float f, float f1, float f2) { - int clickedX = i, clickedY = j, clickedZ = k; // CraftBukkit + final int clickedX = i, clickedY = j, clickedZ = k; // CraftBukkit int i1 = world.getTypeId(i, j, k); if (i1 == Block.SNOW.id) { @@ -52,31 +50,10 @@ public class ItemReed extends Item { Block block = Block.byId[this.id]; int j1 = block.getPlacedData(world, i, j, k, l, f, f1, f2, 0); - // CraftBukkit start - This executes the placement of the block - CraftBlockState replacedBlockState = CraftBlockState.getBlockState(world, i, j, k); // CraftBukkit + // CraftBukkit start - redirect to common handler + ItemBlock.processBlockPlace(world, entityhuman, itemstack, i, j, k, this.id, j1, clickedX, clickedY, clickedZ); /* - * @see net.minecraft.server.World#setTypeId(int i, int j, int k, int l) - * - * This replaces world.setTypeId(IIII), we're doing this because we need to - * hook between the 'placement' and the informing to 'world' so we can - * sanely undo this. - * - * Whenever the call to 'world.setTypeId' changes we need to figure out again what to - * replace this with. - */ - if (world.setRawTypeIdAndData(i, j, k, this.id, j1)) { // <-- world.e does this to place the block - org.bukkit.event.block.BlockPlaceEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callBlockPlaceEvent(world, entityhuman, replacedBlockState, clickedX, clickedY, clickedZ); - - if (event.isCancelled() || !event.canBuild()) { - // CraftBukkit - undo; this only has reed, repeater and pie blocks - world.setTypeIdAndData(i, j, k, replacedBlockState.getTypeId(), replacedBlockState.getRawData()); - - return true; - } - - world.update(i, j, k, this.id); // <-- world.setTypeId does this on success (tell the world) - // CraftBukkit end - + if (world.setTypeIdAndData(i, j, k, this.id, j1)) { if (world.getTypeId(i, j, k) == this.id) { Block.byId[this.id].postPlace(world, i, j, k, entityhuman); Block.byId[this.id].postPlace(world, i, j, k, j1); @@ -85,6 +62,8 @@ public class ItemReed extends Item { world.makeSound((double) ((float) i + 0.5F), (double) ((float) j + 0.5F), (double) ((float) k + 0.5F), block.stepSound.getPlaceSound(), (block.stepSound.getVolume1() + 1.0F) / 2.0F, block.stepSound.getVolume2() * 0.8F); --itemstack.count; } + */ + // CraftBukkit end } return true; diff --git a/src/main/java/net/minecraft/server/ItemSeedFood.java b/src/main/java/net/minecraft/server/ItemSeedFood.java index 7e56763f39..e14f407b22 100644 --- a/src/main/java/net/minecraft/server/ItemSeedFood.java +++ b/src/main/java/net/minecraft/server/ItemSeedFood.java @@ -1,7 +1,5 @@ package net.minecraft.server; -import org.bukkit.craftbukkit.block.CraftBlockState; // CraftBukkit - public class ItemSeedFood extends ItemFood { private int b; @@ -14,21 +12,16 @@ public class ItemSeedFood extends ItemFood { } public boolean interactWith(ItemStack itemstack, EntityHuman entityhuman, World world, int i, int j, int k, int l, float f, float f1, float f2) { + final int clickedX = i, clickedY = j, clickedZ = k; // CraftBukkit if (l != 1) { return false; } else if (entityhuman.a(i, j, k, l, itemstack) && entityhuman.a(i, j + 1, k, l, itemstack)) { int i1 = world.getTypeId(i, j, k); if (i1 == this.c && world.isEmpty(i, j + 1, k)) { - CraftBlockState blockState = CraftBlockState.getBlockState(world, i, j + 1, k); // CraftBukkit - - world.setTypeId(i, j + 1, k, this.b); - - // CraftBukkit start - seeds - org.bukkit.event.block.BlockPlaceEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callBlockPlaceEvent(world, entityhuman, blockState, i, j, k); - - if (event.isCancelled() || !event.canBuild()) { - event.getBlockPlaced().setTypeId(0); + // CraftBukkit start + // world.setTypeId(i, j + 1, k, this.b); + if (!ItemBlock.processBlockPlace(world, entityhuman, null, i, j + 1, k, this.b, 0, clickedX, clickedY, clickedZ)) { return false; } // CraftBukkit end diff --git a/src/main/java/net/minecraft/server/ItemSeeds.java b/src/main/java/net/minecraft/server/ItemSeeds.java index 82e6cf4e88..258613e064 100644 --- a/src/main/java/net/minecraft/server/ItemSeeds.java +++ b/src/main/java/net/minecraft/server/ItemSeeds.java @@ -1,7 +1,5 @@ package net.minecraft.server; -import org.bukkit.craftbukkit.block.CraftBlockState; // CraftBukkit - public class ItemSeeds extends Item { private int id; @@ -15,21 +13,16 @@ public class ItemSeeds extends Item { } public boolean interactWith(ItemStack itemstack, EntityHuman entityhuman, World world, int i, int j, int k, int l, float f, float f1, float f2) { + final int clickedX = i, clickedY = j, clickedZ = k; // CraftBukkit if (l != 1) { return false; } else if (entityhuman.e(i, j, k) && entityhuman.e(i, j + 1, k)) { int i1 = world.getTypeId(i, j, k); if (i1 == this.b && world.isEmpty(i, j + 1, k)) { - CraftBlockState blockState = CraftBlockState.getBlockState(world, i, j + 1, k); // CraftBukkit - - world.setTypeId(i, j + 1, k, this.id); - // CraftBukkit start - seeds - org.bukkit.event.block.BlockPlaceEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callBlockPlaceEvent(world, entityhuman, blockState, i, j, k); - - if (event.isCancelled() || !event.canBuild()) { - event.getBlockPlaced().setTypeId(0); + // world.setTypeId(i, j + 1, k, this.id); + if (!ItemBlock.processBlockPlace(world, entityhuman, null, i, j + 1, k, this.id, 0, clickedX, clickedY, clickedZ)) { return false; } // CraftBukkit end diff --git a/src/main/java/net/minecraft/server/ItemSign.java b/src/main/java/net/minecraft/server/ItemSign.java index f4717e1ec4..6fa75a3eca 100644 --- a/src/main/java/net/minecraft/server/ItemSign.java +++ b/src/main/java/net/minecraft/server/ItemSign.java @@ -1,7 +1,5 @@ package net.minecraft.server; -import org.bukkit.craftbukkit.block.CraftBlockState; // CraftBukkit - public class ItemSign extends Item { public ItemSign(int i) { @@ -11,13 +9,12 @@ public class ItemSign extends Item { } public boolean interactWith(ItemStack itemstack, EntityHuman entityhuman, World world, int i, int j, int k, int l, float f, float f1, float f2) { + final int clickedX = i, clickedY = j, clickedZ = k; // CraftBukkit if (l == 0) { return false; } else if (!world.getMaterial(i, j, k).isBuildable()) { return false; } else { - int clickedX = i, clickedY = j, clickedZ = k; // CraftBukkit - if (l == 1) { ++j; } @@ -43,28 +40,20 @@ public class ItemSign extends Item { } else if (!Block.SIGN_POST.canPlace(world, i, j, k)) { return false; } else { - CraftBlockState blockState = CraftBlockState.getBlockState(world, i, j, k); // CraftBukkit - + // CraftBukkit start + final Block block; if (l == 1) { int i1 = MathHelper.floor((double) ((entityhuman.yaw + 180.0F) * 16.0F / 360.0F) + 0.5D) & 15; - // CraftBukkit start - sign - world.setRawTypeIdAndData(i, j, k, Block.SIGN_POST.id, i1); + // world.setTypeIdAndData(i, j, k, Block.SIGN_POST.id, i1); + block = Block.SIGN_POST; + l = i1; } else { - world.setRawTypeIdAndData(i, j, k, Block.WALL_SIGN.id, l); + // world.setTypeIdAndData(i, j, k, Block.WALL_SIGN.id, l); + block = Block.WALL_SIGN; } - - org.bukkit.event.block.BlockPlaceEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callBlockPlaceEvent(world, entityhuman, blockState, clickedX, clickedY, clickedZ); - - if (event.isCancelled() || !event.canBuild()) { - event.getBlockPlaced().setTypeIdAndData(blockState.getTypeId(), blockState.getRawData(), false); + if (!ItemBlock.processBlockPlace(world, entityhuman, null, i, j, k, block.id, l, clickedX, clickedY, clickedZ)) { return false; - } else { - if (l == 1) { - world.update(i, j, k, Block.SIGN_POST.id); - } else { - world.update(i, j, k, Block.WALL_SIGN.id); - } } // CraftBukkit end diff --git a/src/main/java/net/minecraft/server/ItemSkull.java b/src/main/java/net/minecraft/server/ItemSkull.java index bf2cd4f300..bd2fe45695 100644 --- a/src/main/java/net/minecraft/server/ItemSkull.java +++ b/src/main/java/net/minecraft/server/ItemSkull.java @@ -13,6 +13,7 @@ public class ItemSkull extends Item { } public boolean interactWith(ItemStack itemstack, EntityHuman entityhuman, World world, int i, int j, int k, int l, float f, float f1, float f2) { + final int clickedX = i, clickedY = j, clickedZ = k; // CraftBukkit if (l == 0) { return false; } else if (!world.getMaterial(i, j, k).isBuildable()) { @@ -45,7 +46,7 @@ public class ItemSkull extends Item { } else { // CraftBukkit start - handle in ItemBlock // world.setTypeIdAndData(i, j, k, Block.SKULL.id, l); - if (!ItemBlock.processBlockPlace(world, entityhuman, null, i, j, k, Block.SKULL.id, l)) { + if (!ItemBlock.processBlockPlace(world, entityhuman, null, i, j, k, Block.SKULL.id, l, clickedX, clickedY, clickedZ)) { return false; } l = world.getData(i, j, k); diff --git a/src/main/java/net/minecraft/server/ItemStep.java b/src/main/java/net/minecraft/server/ItemStep.java index 7ef9a81382..6c51282f20 100644 --- a/src/main/java/net/minecraft/server/ItemStep.java +++ b/src/main/java/net/minecraft/server/ItemStep.java @@ -24,6 +24,7 @@ public class ItemStep extends ItemBlock { } public boolean interactWith(ItemStack itemstack, EntityHuman entityhuman, World world, int i, int j, int k, int l, float f, float f1, float f2) { + final int clickedX = i, clickedY = j, clickedZ = k; // CraftBukkit if (this.a) { return super.interactWith(itemstack, entityhuman, world, i, j, k, l, f, f1, f2); } else if (itemstack.count == 0) { @@ -37,17 +38,12 @@ public class ItemStep extends ItemBlock { boolean flag = (j1 & 8) != 0; if ((l == 1 && !flag || l == 0 && flag) && i1 == this.b.id && k1 == itemstack.getData()) { - // CraftBukkit start - handle in processBlockPlace() - /* - if (world.b(this.c.e(world, i, j, k)) && world.setTypeIdAndData(i, j, k, this.c.id, k1)) { - world.makeSound((double) ((float) i + 0.5F), (double) ((float) j + 0.5F), (double) ((float) k + 0.5F), this.c.stepSound.getPlaceSound(), (this.c.stepSound.getVolume1() + 1.0F) / 2.0F, this.c.stepSound.getVolume2() * 0.8F); + // CraftBukkit start - world.setTypeIdAndData -> processBlockPlace() + if (world.b(this.c.e(world, i, j, k)) && processBlockPlace(world, entityhuman, null, i, j, k, this.c.id, k1, clickedX, clickedY, clickedZ)) { + // world.makeSound((double) ((float) i + 0.5F), (double) ((float) j + 0.5F), (double) ((float) k + 0.5F), this.c.stepSound.getPlaceSound(), (this.c.stepSound.getVolume1() + 1.0F) / 2.0F, this.c.stepSound.getVolume2() * 0.8F); + // CraftBukkit end --itemstack.count; } - */ - if (world.b(this.c.e(world, i, j, k))) { - processBlockPlace(world, entityhuman, itemstack, i, j, k, this.c.id, k1); - } - // CraftBukkit end return true; } else { return this.a(itemstack, entityhuman, world, i, j, k, l) ? true : super.interactWith(itemstack, entityhuman, world, i, j, k, l, f, f1, f2); @@ -56,6 +52,7 @@ public class ItemStep extends ItemBlock { } private boolean a(ItemStack itemstack, EntityHuman entityhuman, World world, int i, int j, int k, int l) { + final int clickedX = i, clickedY = j, clickedZ = k; // CraftBukkit if (l == 0) { --j; } @@ -85,17 +82,12 @@ public class ItemStep extends ItemBlock { int k1 = j1 & 7; if (i1 == this.b.id && k1 == itemstack.getData()) { - // CraftBukkit start - handle in processBlockPlace() - /* - if (world.b(this.c.e(world, i, j, k)) && world.setTypeIdAndData(i, j, k, this.c.id, k1)) { - world.makeSound((double) ((float) i + 0.5F), (double) ((float) j + 0.5F), (double) ((float) k + 0.5F), this.c.stepSound.getPlaceSound(), (this.c.stepSound.getVolume1() + 1.0F) / 2.0F, this.c.stepSound.getVolume2() * 0.8F); + // CraftBukkit start - world.setTypeIdAndData -> processBlockPlace() + if (world.b(this.c.e(world, i, j, k)) && processBlockPlace(world, entityhuman, null, i, j, k, this.c.id, k1, clickedX, clickedY, clickedZ)) { + // world.makeSound((double) ((float) i + 0.5F), (double) ((float) j + 0.5F), (double) ((float) k + 0.5F, this.c.stepSound.getPlaceSound(), (this.c.stepSound.getVolume1() + 1.0F) / 2.0F, this.c.stepSound.getVolume2() * 0.8F); + // CraftBukkit end --itemstack.count; } - */ - if (world.b(this.c.e(world, i, j, k))) { - processBlockPlace(world, entityhuman, itemstack, i, j, k, this.c.id, k1); - } - // CraftBukkit end return true; } else { return false; diff --git a/src/main/java/net/minecraft/server/ItemWaterLily.java b/src/main/java/net/minecraft/server/ItemWaterLily.java index b1c43e805d..07c5708284 100644 --- a/src/main/java/net/minecraft/server/ItemWaterLily.java +++ b/src/main/java/net/minecraft/server/ItemWaterLily.java @@ -1,7 +1,5 @@ package net.minecraft.server; -import org.bukkit.craftbukkit.block.CraftBlockState; // CraftBukkit - public class ItemWaterLily extends ItemWithAuxData { public ItemWaterLily(int i) { @@ -18,6 +16,7 @@ public class ItemWaterLily extends ItemWithAuxData { int i = movingobjectposition.b; int j = movingobjectposition.c; int k = movingobjectposition.d; + final int clickedX = i, clickedY = j, clickedZ = k; // CraftBukkit if (!world.a(entityhuman, i, j, k)) { return itemstack; @@ -28,15 +27,9 @@ public class ItemWaterLily extends ItemWithAuxData { } if (world.getMaterial(i, j, k) == Material.WATER && world.getData(i, j, k) == 0 && world.isEmpty(i, j + 1, k)) { - CraftBlockState blockState = CraftBlockState.getBlockState(world, i, j + 1, k); // CraftBukkit - - world.setTypeId(i, j + 1, k, Block.WATER_LILY.id); - // CraftBukkit start - waterlily - org.bukkit.event.block.BlockPlaceEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callBlockPlaceEvent(world, entityhuman, blockState, i, j, k); - - if (event.isCancelled() || !event.canBuild()) { - event.getBlockPlaced().setTypeId(0); + // world.setTypeId(i, j + 1, k, Block.WATER_LILY.id); + if (!processBlockPlace(world, entityhuman, null, i, j + 1, k, Block.WATER_LILY.id, 0, clickedX, clickedY, clickedZ)) { return itemstack; } // CraftBukkit end