Permalink
Browse files

Fix error spamming when hoppers are attached to invalid multichests (…

…triple+).

The extra chests might be unprotected, but this shouldn't be possible in vanilla.
  • Loading branch information...
wizjany committed May 22, 2017
1 parent 85693b9 commit 4cb29796c1ef189565ad3f8f763b5a3ce993b62d
@@ -963,8 +963,14 @@ public void onBlockDispense(BlockDispenseEvent event) {
} else if (holder instanceof BlockState) {
Events.fireToCancel(originalEvent, new UseBlockEvent(originalEvent, cause, ((BlockState) holder).getBlock()));
} else if (holder instanceof DoubleChest) {
Events.fireToCancel(originalEvent, new UseBlockEvent(originalEvent, cause, (((Chest) ((DoubleChest) holder).getLeftSide()).getBlock())));
Events.fireToCancel(originalEvent, new UseBlockEvent(originalEvent, cause, (((Chest) ((DoubleChest) holder).getRightSide()).getBlock())));
InventoryHolder left = ((DoubleChest) holder).getLeftSide();
InventoryHolder right = ((DoubleChest) holder).getRightSide();
if (left instanceof Chest) {
Events.fireToCancel(originalEvent, new UseBlockEvent(originalEvent, cause, ((Chest) left).getBlock()));
}
if (right instanceof Chest) {
Events.fireToCancel(originalEvent, new UseBlockEvent(originalEvent, cause, ((Chest) right).getBlock()));
}
}
}
@@ -53,7 +53,12 @@ private Object transform(InventoryHolder holder) {
if (holder instanceof BlockState) {
return new BlockMaterialKey(((BlockState) holder).getBlock());
} else if (holder instanceof DoubleChest) {
return new BlockMaterialKey((((Chest) ((DoubleChest) holder).getLeftSide())).getBlock());
InventoryHolder left = ((DoubleChest) holder).getLeftSide();
if (left instanceof Chest) {
return new BlockMaterialKey(((Chest) left).getBlock());
} else {
return holder;
}
} else {
return holder;
}

0 comments on commit 4cb2979

Please sign in to comment.