mirror of
https://github.com/EngineHub/WorldGuard.git
synced 2025-02-03 05:51:35 +01:00
Don't try dropping items from falling blocks that won't drop one.
To quote myself from the adjacent commit almost exactly one year ago, "some plugins do weird things with falling blocks." Fixes #1624.
This commit is contained in:
parent
58eaf31879
commit
f677af566f
@ -323,18 +323,22 @@ public void onEntityChangeBlock(EntityChangeBlockEvent event) {
|
|||||||
Events.fireToCancel(event, new PlaceBlockEvent(event, cause, block.getLocation(), toType));
|
Events.fireToCancel(event, new PlaceBlockEvent(event, cause, block.getLocation(), toType));
|
||||||
|
|
||||||
if (entity instanceof FallingBlock) {
|
if (entity instanceof FallingBlock) {
|
||||||
if (event.isCancelled() && !wasCancelled) {
|
try {
|
||||||
FallingBlock fallingBlock = (FallingBlock) entity;
|
if (event.isCancelled() && !wasCancelled) {
|
||||||
final Material material = fallingBlock.getBlockData().getMaterial();
|
FallingBlock fallingBlock = (FallingBlock) entity;
|
||||||
if (!material.isItem()) return;
|
if (!fallingBlock.getDropItem()) return;
|
||||||
ItemStack itemStack = new ItemStack(material, 1);
|
final Material material = fallingBlock.getBlockData().getMaterial();
|
||||||
Item item = block.getWorld().dropItem(fallingBlock.getLocation(), itemStack);
|
if (!material.isItem()) return;
|
||||||
item.setVelocity(new Vector());
|
ItemStack itemStack = new ItemStack(material, 1);
|
||||||
if (Events.fireAndTestCancel(new SpawnEntityEvent(event, create(block, entity), item))) {
|
Item item = block.getWorld().dropItem(fallingBlock.getLocation(), itemStack);
|
||||||
item.remove();
|
item.setVelocity(new Vector());
|
||||||
|
if (Events.fireAndTestCancel(new SpawnEntityEvent(event, create(block, entity), item))) {
|
||||||
|
item.remove();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
} finally {
|
||||||
|
Cause.untrackParentCause(entity);
|
||||||
}
|
}
|
||||||
Cause.untrackParentCause(entity);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user