mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-24 03:25:15 +01:00
Allow plugins to change ID and Data during BlockPlace event.
Fixes BUKKIT-674
This commit is contained in:
parent
1bb011a543
commit
14bb771957
@ -80,28 +80,21 @@ public class ItemBlock extends Item {
|
|||||||
world.suppressPhysics = true;
|
world.suppressPhysics = true;
|
||||||
world.setTypeIdAndData(i, j, k, this.id, this.filterData(itemstack.getData()));
|
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);
|
||||||
|
int id = world.getTypeId(i, j, k);
|
||||||
|
int data = world.getData(i, j, k);
|
||||||
replacedBlockState.update(true);
|
replacedBlockState.update(true);
|
||||||
world.suppressPhysics = false;
|
world.suppressPhysics = false;
|
||||||
|
|
||||||
if (event.isCancelled() || !event.canBuild()) {
|
if (event.isCancelled() || !event.canBuild()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* @see net.minecraft.server.World#setTypeIdAndData(int i, int j, int k, int l, int i1)
|
if (world.setTypeIdAndData(i, j, k, id, data)) {
|
||||||
*
|
if (Block.byId[id] != null) {
|
||||||
* This replaces world.setTypeIdAndData(IIIII), we're doing this because we need to
|
Block.byId[id].postPlace(world, i, j, k, l);
|
||||||
* hook between the 'placement' and the informing to 'world' so we can
|
Block.byId[id].postPlace(world, i, j, k, entityhuman);
|
||||||
* sanely undo this.
|
|
||||||
*
|
|
||||||
* Whenever the call to 'world.setTypeIdAndData' changes we need to figure out again what to
|
|
||||||
* replace this with.
|
|
||||||
*/
|
|
||||||
if (world.setTypeIdAndData(i, j, k, this.id, this.filterData(itemstack.getData()))) { // <-- world.setTypeIdAndData does this to place the block
|
|
||||||
// CraftBukkit end
|
|
||||||
if (world.getTypeId(i, j, k) == this.id) {
|
|
||||||
Block.byId[this.id].postPlace(world, i, j, k, l);
|
|
||||||
Block.byId[this.id].postPlace(world, i, j, k, entityhuman);
|
|
||||||
}
|
}
|
||||||
|
// CraftBukkit end
|
||||||
|
|
||||||
world.makeSound((double) ((float) i + 0.5F), (double) ((float) j + 0.5F), (double) ((float) k + 0.5F), block.stepSound.getName(), (block.stepSound.getVolume1() + 1.0F) / 2.0F, block.stepSound.getVolume2() * 0.8F);
|
world.makeSound((double) ((float) i + 0.5F), (double) ((float) j + 0.5F), (double) ((float) k + 0.5F), block.stepSound.getName(), (block.stepSound.getVolume1() + 1.0F) / 2.0F, block.stepSound.getVolume2() * 0.8F);
|
||||||
--itemstack.count;
|
--itemstack.count;
|
||||||
|
Loading…
Reference in New Issue
Block a user