3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-12-20 21:40:06 +01:00

Fixed BlockPlace event. Fixes BUKKIT-663

Dieser Commit ist enthalten in:
Tahg 2012-01-30 02:19:22 -05:00 committet von EvilSeph
Ursprung 875219e28c
Commit 69e766c5f3
3 geänderte Dateien mit 12 neuen und 4 gelöschten Zeilen

Datei anzeigen

@ -196,6 +196,7 @@ public class BlockRedstoneWire extends Block {
} }
public void onPlace(World world, int i, int j, int k) { public void onPlace(World world, int i, int j, int k) {
if (world.suppressPhysics) return; // CraftBukkit
super.onPlace(world, i, j, k); super.onPlace(world, i, j, k);
if (!world.isStatic) { if (!world.isStatic) {
this.g(world, i, j, k); this.g(world, i, j, k);

Datei anzeigen

@ -77,7 +77,11 @@ public class ItemBlock extends Item {
eventUseBlockBelow = itemstack.id == Block.STEP.id && blockStateBelow.getTypeId() == Block.STEP.id; eventUseBlockBelow = itemstack.id == Block.STEP.id && blockStateBelow.getTypeId() == Block.STEP.id;
} }
world.suppressPhysics = true;
world.setTypeIdAndData(i, j, k, this.id, this.filterData(itemstack.getData()));
BlockPlaceEvent event = CraftEventFactory.callBlockPlaceEvent(world, entityhuman, eventUseBlockBelow ? blockStateBelow : replacedBlockState, clickedX, clickedY, clickedZ, block); BlockPlaceEvent event = CraftEventFactory.callBlockPlaceEvent(world, entityhuman, eventUseBlockBelow ? blockStateBelow : replacedBlockState, clickedX, clickedY, clickedZ, block);
replacedBlockState.update(true);
world.suppressPhysics = false;
if (event.isCancelled() || !event.canBuild()) { if (event.isCancelled() || !event.canBuild()) {
return true; return true;

Datei anzeigen

@ -49,18 +49,21 @@ public class ItemRedstone extends Item {
return false; return false;
} else { } else {
if (Block.REDSTONE_WIRE.canPlace(world, i, j, k)) { if (Block.REDSTONE_WIRE.canPlace(world, i, j, k)) {
CraftBlockState blockState = CraftBlockState.getBlockState(world, i, j, k); // CraftBukkit // CraftBukkit start
CraftBlockState blockState = CraftBlockState.getBlockState(world, i, j, k);
world.setRawTypeId(i, j, k, Block.REDSTONE_WIRE.id); // CraftBukkit - We update after the event world.suppressPhysics = true;
world.setRawTypeId(i, j, k, Block.REDSTONE_WIRE.id); // We update after the event
// CraftBukkit start - redstone
BlockPlaceEvent event = CraftEventFactory.callBlockPlaceEvent(world, entityhuman, blockState, clickedX, clickedY, clickedZ, Block.REDSTONE_WIRE); BlockPlaceEvent event = CraftEventFactory.callBlockPlaceEvent(world, entityhuman, blockState, clickedX, clickedY, clickedZ, Block.REDSTONE_WIRE);
blockState.update(true);
if (event.isCancelled() || !event.canBuild()) { if (event.isCancelled() || !event.canBuild()) {
event.getBlockPlaced().setTypeIdAndData(blockState.getTypeId(), blockState.getRawData(), false);
return false; return false;
} }
world.suppressPhysics = false;
world.setTypeId(i, j, k, Block.REDSTONE_WIRE.id);
world.update(i, j, k, Block.REDSTONE_WIRE.id); // Must take place after BlockPlaceEvent, we need to update all other blocks. world.update(i, j, k, Block.REDSTONE_WIRE.id); // Must take place after BlockPlaceEvent, we need to update all other blocks.
// CraftBukkit end // CraftBukkit end