Fixes Chests Closing Bug.

Trying to run Chest animation in unloaded chunks closed the inventory.
This commit is contained in:
jameslfc19 2020-07-16 19:57:23 +01:00
parent 1732bac5f2
commit 3a3b0bd780

View File

@ -26,8 +26,14 @@ public class Utils {
//Check if all chests should perform open animation.
if(Settings.isShouldAnimateAllChests()) {
storage.getLocations().forEach(locationInfo -> {
if (locationInfo.getLocation() != null) {
chestOpenAnimation(storage.getInventory(), locationInfo.getLocation());
int chunkX = locationInfo.getLocation().getBlockX() >> 4;
int chunkZ = locationInfo.getLocation().getBlockZ() >> 4;
Location location = locationInfo.getLocation();
if (location != null) {
World world = location.getWorld();
if (world != null && world.isChunkLoaded(chunkX, chunkZ)) {
chestOpenAnimation(storage.getInventory(), locationInfo.getLocation());
}
}
});
} else {