make sure chests are in the same world

fixes #14
This commit is contained in:
hyperdefined
2022-06-18 17:09:12 -04:00
parent 63d508fded
commit 5eebcb9ff4

View File

@@ -65,9 +65,11 @@ public class GenerateLoot implements Listener {
// if the distance is less than 1, it's the same chest // if the distance is less than 1, it's the same chest
for (Block chest : toolStats.playerInteract.openedChests.keySet()) { for (Block chest : toolStats.playerInteract.openedChests.keySet()) {
Location chestLocation = chest.getLocation(); Location chestLocation = chest.getLocation();
double distance = lootLocation.distance(chestLocation); if (chest.getWorld() == lootLocation.getWorld()) {
if (distance <= 1.0) { double distance = lootLocation.distance(chestLocation);
openedChest = chest; if (distance <= 1.0) {
openedChest = chest;
}
} }
} }
// ignore if the chest is not in the same location // ignore if the chest is not in the same location