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:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user