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

Fixed BlockPlace event for doublesteps. Thanks DiddiZ!

Dieser Commit ist enthalten in:
EvilSeph 2011-07-28 01:05:07 -04:00
Ursprung a8df829a8b
Commit 57e0a106fe

Datei anzeigen

@ -62,9 +62,13 @@ public class ItemBlock extends Item {
// would happen if you place x step onto another y step, so let's just keep
// track of the entire state
CraftBlockState blockStateBelow = null;
// Toggles whether the normal or the block below is used for the place event
boolean eventUseBlockBelow = false;
if ((world.getTypeId(i, j - 1, k) == Block.STEP.id || world.getTypeId(i, j - 1, k) == Block.DOUBLE_STEP.id)
&& (itemstack.id == Block.DOUBLE_STEP.id || itemstack.id == Block.STEP.id)) {
blockStateBelow = CraftBlockState.getBlockState(world, i, j - 1, k);
// Step is placed on step, forms a doublestep replacing the original step, so we need the lower block
eventUseBlockBelow = itemstack.id == Block.STEP.id && blockStateBelow.getTypeId() == Block.STEP.id;
}
/**
@ -78,7 +82,7 @@ public class ItemBlock extends Item {
* replace this with.
*/
if (world.setRawTypeIdAndData(i, j, k, this.id, this.filterData(itemstack.getData()))) { // <-- world.setTypeIdAndData does this to place the block
BlockPlaceEvent event = CraftEventFactory.callBlockPlaceEvent(world, entityhuman, replacedBlockState, clickedX, clickedY, clickedZ, block);
BlockPlaceEvent event = CraftEventFactory.callBlockPlaceEvent(world, entityhuman, eventUseBlockBelow ? blockStateBelow : replacedBlockState, clickedX, clickedY, clickedZ, block);
if (event.isCancelled() || !event.canBuild()) {
if (blockStateBelow != null) { // Used for steps