geforkt von Mirrors/Paper
Made steps fire a BlockPlace event. Fixes BUKKIT-394
Dieser Commit ist enthalten in:
Ursprung
6abd178ea7
Commit
10ab7b96ed
@ -58,29 +58,18 @@ public class ItemBlock extends Item {
|
||||
return false;
|
||||
} else if (j == world.height - 1 && Block.byId[this.id].material.isBuildable()) {
|
||||
return false;
|
||||
} else if (world.mayPlace(this.id, i, j, k, false, l)) {
|
||||
Block block = Block.byId[this.id];
|
||||
}
|
||||
// CraftBukkit start
|
||||
int id = (l == -1 && itemstack.getItem() instanceof ItemStep) ? Block.DOUBLE_STEP.id : this.id;
|
||||
if (id != this.id || world.mayPlace(this.id, i, j, k, false, l)) {
|
||||
Block block = Block.byId[id];
|
||||
|
||||
// CraftBukkit start - This executes the placement of the block
|
||||
CraftBlockState replacedBlockState = CraftBlockState.getBlockState(world, i, j, k);
|
||||
|
||||
// There are like 30 combinations you can mix and match steps and double steps
|
||||
// of different materials, so there are a lot of different cases of what
|
||||
// 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;
|
||||
}
|
||||
|
||||
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);
|
||||
int id = world.getTypeId(i, j, k);
|
||||
world.setTypeIdAndData(i, j, k, id, this.filterData(itemstack.getData()));
|
||||
BlockPlaceEvent event = CraftEventFactory.callBlockPlaceEvent(world, entityhuman, replacedBlockState, clickedX, clickedY, clickedZ, block);
|
||||
id = world.getTypeId(i, j, k);
|
||||
int data = world.getData(i, j, k);
|
||||
replacedBlockState.update(true);
|
||||
world.suppressPhysics = false;
|
||||
|
@ -36,12 +36,15 @@ public class ItemStep extends ItemBlock {
|
||||
int j1 = world.getData(i, j, k);
|
||||
|
||||
if (l == 1 && i1 == Block.STEP.id && j1 == itemstack.getData()) {
|
||||
// CraftBukkit start - handle this in super
|
||||
/*
|
||||
if (world.setTypeIdAndData(i, j, k, Block.DOUBLE_STEP.id, j1)) {
|
||||
world.makeSound((double) ((float) i + 0.5F), (double) ((float) j + 0.5F), (double) ((float) k + 0.5F), Block.DOUBLE_STEP.stepSound.getName(), (Block.DOUBLE_STEP.stepSound.getVolume1() + 1.0F) / 2.0F, Block.DOUBLE_STEP.stepSound.getVolume2() * 0.8F);
|
||||
--itemstack.count;
|
||||
}
|
||||
|
||||
return true;
|
||||
*/
|
||||
return super.a(itemstack, entityhuman, world, i, j, k, -1);
|
||||
// CraftBukkit end
|
||||
} else {
|
||||
return super.a(itemstack, entityhuman, world, i, j, k, l);
|
||||
}
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren