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.
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user