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:
feildmaster
2013-01-27 10:44:32 -06:00
parent 528bbbdcd8
commit 899b9c17cc
13 changed files with 57 additions and 141 deletions

View File

@@ -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