Fixes placement cancellation of single-step blocks, such as in protected areas like the spawn area.

The first line edited fixes it so other blocks placed on a single-step block aren't considered (only single-step blocks), and so that they're only considered when placed on the top face of the existing single-step block.
The second section of changed code keeps the final world.setTypeIdAndData() call from being incorrectly applied if it was indeed a single-block placed on an existing single-block.

Best way to test before and after is to put a bunch of single-step blocks in the spawn area as an Op, then de-Op yourself and try placing more blocks (single-step and otherwise, for example I also tested dirt blocks) on the sides and tops of the ones which you previously added as an Op.
This commit is contained in:
Brettflan 2011-02-03 06:35:36 -06:00 committed by VictorD
parent dde3f5b474
commit 2f2bc28915

View File

@ -68,7 +68,7 @@ public class ItemBlock extends Item {
/* We store the old data so we can undo it. Snow(78) and half-steps(44) are special in that they replace the block itself,
* rather than the block touching the face we clicked on.
*/
org.bukkit.block.Block replacedBlock = (blockClicked.getTypeId() == Block.SNOW.id || blockClicked.getTypeId() == Block.STEP.id) ? blockClicked:blockClicked.getFace(faceClicked);
org.bukkit.block.Block replacedBlock = ( blockClicked.getTypeId() == Block.SNOW.id || (blockClicked.getTypeId() == Block.STEP.id && itemstack.id == Block.STEP.id && faceClicked == BlockFace.UP) ) ? blockClicked : blockClicked.getFace(faceClicked);
final BlockState replacedBlockState = new CraftBlockState(replacedBlock);
// CraftBukkit end
@ -103,15 +103,20 @@ public class ItemBlock extends Item {
if (event.isCancelled() || !event.canBuild()) {
// CraftBukkit Undo!
if (this.a == block.ICE.id) {
// Ice will explode if we set straight to 0
world.setTypeId(i, j, k, 20);
} else if ((this.a == Block.STEP.id) && (world.getTypeId(i, j - 1, k) == Block.DOUBLE_STEP.id) && (world.getTypeId(i, j, k) == 0)) {
if ((this.a == Block.STEP.id) && (world.getTypeId(i, j - 1, k) == Block.DOUBLE_STEP.id) && (world.getTypeId(i, j, k) == 0)) {
// Half steps automatically set the block below to a double
world.setTypeId(i, j - 1, k, 44);
} else {
if (this.a == block.ICE.id) {
// Ice will explode if we set straight to 0
world.setTypeId(i, j, k, 20);
}
world.setTypeIdAndData(i, j, k, replacedBlockState.getTypeId(), replacedBlockState.getData().getData());
}
world.setTypeIdAndData(i, j, k, replacedBlockState.getTypeId(), replacedBlockState.getData().getData());
} else {
world.f(i, j, k, a); // <-- world.b does this on success (tell the world)