Skip to content

Commit

Permalink
RE-186 Fixed Double Chest Protection Ignored from Hoppers (getLocatio…
Browse files Browse the repository at this point in the history
…n gives not back Block XYZ)
  • Loading branch information
Relluem94 committed Apr 20, 2024
1 parent c631a3d commit 04193ee
Showing 1 changed file with 24 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ public void onWaterMove(BlockFromToEvent e) {

private boolean handleMoveItemEvent(Inventory inventory, ItemStack is, boolean isSource) {
Location location;
Location locationOtherSide = null;
InventoryHolder holder;
if(inventory != null){
holder = inventory.getHolder();
Expand All @@ -122,18 +123,37 @@ private boolean handleMoveItemEvent(Inventory inventory, ItemStack is, boolean i
try {
if (holder instanceof BlockState) {
location = ((BlockState)holder).getLocation();
} else if (holder instanceof DoubleChest) {
location = ((DoubleChest)holder).getLocation();
} else if (holder instanceof DoubleChest doubleChest) {
location = Objects.requireNonNull(doubleChest.getRightSide()).getInventory().getLocation().getBlock().getLocation();
locationOtherSide = Objects.requireNonNull(doubleChest.getLeftSide()).getInventory().getLocation().getBlock().getLocation();
} else {
return false;
}
} catch (Exception e) {
return false;
}
}

ProtectionEntry protection = RelluEssentials.getInstance().getProtectionAPI().getProtectionEntry(location);

if (protection == null){
return false;
if(locationOtherSide == null){
return false;
}
else{
protection = RelluEssentials.getInstance().getProtectionAPI().getProtectionEntry(locationOtherSide);
}

if (protection == null){
return false;
}
else{
if(isSource){
return !ProtectionHelper.hasFlag(protection, ProtectionFlags.ALLOW_HOPPER);
}
else{
return true;
}
}
}
else{
return !ProtectionHelper.hasFlag(protection, ProtectionFlags.ALLOW_HOPPER);
Expand Down

0 comments on commit 04193ee

Please sign in to comment.