Reduce random chunk loads

This commit is contained in:
Sn0wStorm 2019-08-15 17:44:26 +02:00
parent ad58d7b609
commit e123f32728
3 changed files with 14 additions and 2 deletions

View File

@ -36,7 +36,7 @@ public class BCauldron {
public void onUpdate() {
// Check if fire still alive
if (!block.getChunk().isLoaded() || block.getRelative(BlockFace.DOWN).getType() == Material.FIRE || LegacyUtil.isLava(block.getRelative(BlockFace.DOWN).getType())) {
if (!Util.isChunkLoaded(block) || block.getRelative(BlockFace.DOWN).getType() == Material.FIRE || LegacyUtil.isLava(block.getRelative(BlockFace.DOWN).getType())) {
// add a minute to cooking time
state++;
if (someRemoved) {

View File

@ -691,7 +691,7 @@ public class Barrel implements InventoryHolder {
// the barrel needs to be formed correctly
// flag force to also check if chunk is not loaded
public Block getBrokenBlock(boolean force) {
if (force || spigot.getChunk().isLoaded()) {
if (force || Util.isChunkLoaded(spigot)) {
spigot = getSpigotOfSign(spigot);
if (LegacyUtil.isSign(spigot.getType())) {
return checkSBarrel();

View File

@ -0,0 +1,12 @@
package com.dre.brewery;
import org.bukkit.block.Block;
public class Util {
// Check if the Chunk of a Block is loaded !without loading it in the process!
public static boolean isChunkLoaded(Block block) {
return block.getWorld().isChunkLoaded(block.getX() >> 4, block.getZ() >> 4);
}
}