geforkt von Mirrors/Paper
Refactor processBlockPlace logic. Fixes BUKKIT-3406 and BUKKIT-3454
The previous logic was faulty since it lost the logic of "placing" the block. It was also taking into account data that could have been changed outside of the processing of this event, which is irrelevant to the processing of this event.
Dieser Commit ist enthalten in:
Ursprung
6a499c8589
Commit
9ba0ddc292
@ -40,7 +40,6 @@ public class BlockPumpkin extends BlockDirectional {
|
|||||||
|
|
||||||
public void onPlace(World world, int i, int j, int k) {
|
public void onPlace(World world, int i, int j, int k) {
|
||||||
super.onPlace(world, i, j, k);
|
super.onPlace(world, i, j, k);
|
||||||
if (world.suppressPhysics) return; // CraftBukkit
|
|
||||||
if (world.getTypeId(i, j - 1, k) == Block.SNOW_BLOCK.id && world.getTypeId(i, j - 2, k) == Block.SNOW_BLOCK.id) {
|
if (world.getTypeId(i, j - 1, k) == Block.SNOW_BLOCK.id && world.getTypeId(i, j - 2, k) == Block.SNOW_BLOCK.id) {
|
||||||
if (!world.isStatic) {
|
if (!world.isStatic) {
|
||||||
// CraftBukkit start - use BlockStateListPopulator
|
// CraftBukkit start - use BlockStateListPopulator
|
||||||
|
@ -196,7 +196,6 @@ 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.l(world, i, j, k);
|
this.l(world, i, j, k);
|
||||||
|
@ -429,8 +429,8 @@ public class Chunk {
|
|||||||
|
|
||||||
if (l != 0) {
|
if (l != 0) {
|
||||||
if (!this.world.isStatic) {
|
if (!this.world.isStatic) {
|
||||||
// CraftBukkit start - Don't extend piston until data is set
|
// CraftBukkit start - Don't extend piston until data is set, don't "place" if we're processing the event
|
||||||
if (!(Block.byId[l] instanceof BlockPiston) || i2 != 0) {
|
if (!this.world.suppressPhysics && (!(Block.byId[l] instanceof BlockPiston) || i2 != 0)) {
|
||||||
Block.byId[l].onPlace(this.world, j2, j, k2);
|
Block.byId[l].onPlace(this.world, j2, j, k2);
|
||||||
}
|
}
|
||||||
// CraftBukkit end
|
// CraftBukkit end
|
||||||
|
@ -80,7 +80,7 @@ public class ItemBlock extends Item {
|
|||||||
org.bukkit.block.BlockState blockstate = org.bukkit.craftbukkit.block.CraftBlockState.getBlockState(world, x, y, z);
|
org.bukkit.block.BlockState blockstate = org.bukkit.craftbukkit.block.CraftBlockState.getBlockState(world, x, y, z);
|
||||||
|
|
||||||
world.suppressPhysics = true;
|
world.suppressPhysics = true;
|
||||||
world.setTypeIdAndData(x, y, z, id, data);
|
world.setRawTypeIdAndData(x, y, z, id, data);
|
||||||
|
|
||||||
org.bukkit.event.block.BlockPlaceEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callBlockPlaceEvent(world, entityhuman, blockstate, x, y, z);
|
org.bukkit.event.block.BlockPlaceEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callBlockPlaceEvent(world, entityhuman, blockstate, x, y, z);
|
||||||
if (event.isCancelled() || !event.canBuild()) {
|
if (event.isCancelled() || !event.canBuild()) {
|
||||||
@ -90,12 +90,20 @@ public class ItemBlock extends Item {
|
|||||||
}
|
}
|
||||||
|
|
||||||
world.suppressPhysics = false;
|
world.suppressPhysics = false;
|
||||||
world.applyPhysics(x, y, z, world.getTypeId(x, y, z));
|
|
||||||
|
|
||||||
Block block = Block.byId[world.getTypeId(x, y, z)];
|
int newId = world.getTypeId(x, y, z);
|
||||||
|
int newData = world.getData(x, y, z);
|
||||||
|
|
||||||
|
Block block = Block.byId[newId];
|
||||||
|
if (block != null) {
|
||||||
|
block.onPlace(world, x, y, z);
|
||||||
|
}
|
||||||
|
|
||||||
|
world.update(x, y, z, newId);
|
||||||
|
|
||||||
if (block != null) {
|
if (block != null) {
|
||||||
block.postPlace(world, x, y, z, entityhuman);
|
block.postPlace(world, x, y, z, entityhuman);
|
||||||
block.postPlace(world, x, y, z, world.getData(x, y, z));
|
block.postPlace(world, x, y, z, newData);
|
||||||
|
|
||||||
world.makeSound((double) ((float) x + 0.5F), (double) ((float) y + 0.5F), (double) ((float) z + 0.5F), block.stepSound.getPlaceSound(), (block.stepSound.getVolume1() + 1.0F) / 2.0F, block.stepSound.getVolume2() * 0.8F);
|
world.makeSound((double) ((float) x + 0.5F), (double) ((float) y + 0.5F), (double) ((float) z + 0.5F), block.stepSound.getPlaceSound(), (block.stepSound.getVolume1() + 1.0F) / 2.0F, block.stepSound.getVolume2() * 0.8F);
|
||||||
}
|
}
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren