mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-09 19:49:35 +01:00
Fix ItemStack state during BlockPlaceEvent. Fixes BUKKIT-5632
This commit is contained in:
parent
e080bafa58
commit
3fbf4d3b5f
2 changed files with 15 additions and 5 deletions
|
@ -34,8 +34,7 @@ public class BlockSapling extends BlockPlant implements IBlockFragilePlantElemen
|
||||||
this.grow(world, i, j, k, random);
|
this.grow(world, i, j, k, random);
|
||||||
// CraftBukkit start
|
// CraftBukkit start
|
||||||
world.captureTreeGeneration = false;
|
world.captureTreeGeneration = false;
|
||||||
if (world.capturedBlockStates.size() > 0)
|
if (world.capturedBlockStates.size() > 0) {
|
||||||
{
|
|
||||||
TreeType treeType = BlockSapling.treeType;
|
TreeType treeType = BlockSapling.treeType;
|
||||||
BlockSapling.treeType = null;
|
BlockSapling.treeType = null;
|
||||||
Location location = new Location(world.getWorld(), i, j, k);
|
Location location = new Location(world.getWorld(), i, j, k);
|
||||||
|
|
|
@ -100,6 +100,10 @@ public final class ItemStack {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
boolean flag = this.getItem().interactWith(this, entityhuman, world, i, j, k, l, f, f1, f2);
|
boolean flag = this.getItem().interactWith(this, entityhuman, world, i, j, k, l, f, f1, f2);
|
||||||
|
int newData = this.getData();
|
||||||
|
int newCount = this.count;
|
||||||
|
this.count = count;
|
||||||
|
this.setData(data);
|
||||||
world.captureBlockStates = false;
|
world.captureBlockStates = false;
|
||||||
if (flag && world.captureTreeGeneration && world.capturedBlockStates.size() > 0) {
|
if (flag && world.captureTreeGeneration && world.capturedBlockStates.size() > 0) {
|
||||||
world.captureTreeGeneration = false;
|
world.captureTreeGeneration = false;
|
||||||
|
@ -114,6 +118,11 @@ public final class ItemStack {
|
||||||
org.bukkit.Bukkit.getPluginManager().callEvent(event);
|
org.bukkit.Bukkit.getPluginManager().callEvent(event);
|
||||||
}
|
}
|
||||||
if (event == null || !event.isCancelled()) {
|
if (event == null || !event.isCancelled()) {
|
||||||
|
// Change the stack to its new contents if it hasn't been tampered with.
|
||||||
|
if (this.count == count && this.getData() == data) {
|
||||||
|
this.setData(newData);
|
||||||
|
this.count = newCount;
|
||||||
|
}
|
||||||
for (BlockState blockstate : blocks) {
|
for (BlockState blockstate : blocks) {
|
||||||
blockstate.update(true);
|
blockstate.update(true);
|
||||||
}
|
}
|
||||||
|
@ -139,10 +148,12 @@ public final class ItemStack {
|
||||||
for (BlockState blockstate : blocks) {
|
for (BlockState blockstate : blocks) {
|
||||||
blockstate.update(true, false);
|
blockstate.update(true, false);
|
||||||
}
|
}
|
||||||
// make sure to restore stack after cancel
|
|
||||||
this.setData(data);
|
|
||||||
this.count = count;
|
|
||||||
} else {
|
} else {
|
||||||
|
// Change the stack to its new contents if it hasn't been tampered with.
|
||||||
|
if (this.count == count && this.getData() == data) {
|
||||||
|
this.setData(newData);
|
||||||
|
this.count = newCount;
|
||||||
|
}
|
||||||
for (BlockState blockstate : blocks) {
|
for (BlockState blockstate : blocks) {
|
||||||
int x = blockstate.getX();
|
int x = blockstate.getX();
|
||||||
int y = blockstate.getY();
|
int y = blockstate.getY();
|
||||||
|
|
Loading…
Reference in a new issue