mirror of
https://github.com/DieReicheErethons/Brewery.git
synced 2025-01-06 18:47:44 +01:00
Reduce random chunk loads
This commit is contained in:
parent
ad58d7b609
commit
e123f32728
@ -36,7 +36,7 @@ public class BCauldron {
|
|||||||
|
|
||||||
public void onUpdate() {
|
public void onUpdate() {
|
||||||
// Check if fire still alive
|
// 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
|
// add a minute to cooking time
|
||||||
state++;
|
state++;
|
||||||
if (someRemoved) {
|
if (someRemoved) {
|
||||||
|
@ -691,7 +691,7 @@ public class Barrel implements InventoryHolder {
|
|||||||
// the barrel needs to be formed correctly
|
// the barrel needs to be formed correctly
|
||||||
// flag force to also check if chunk is not loaded
|
// flag force to also check if chunk is not loaded
|
||||||
public Block getBrokenBlock(boolean force) {
|
public Block getBrokenBlock(boolean force) {
|
||||||
if (force || spigot.getChunk().isLoaded()) {
|
if (force || Util.isChunkLoaded(spigot)) {
|
||||||
spigot = getSpigotOfSign(spigot);
|
spigot = getSpigotOfSign(spigot);
|
||||||
if (LegacyUtil.isSign(spigot.getType())) {
|
if (LegacyUtil.isSign(spigot.getType())) {
|
||||||
return checkSBarrel();
|
return checkSBarrel();
|
||||||
|
12
src/com/dre/brewery/Util.java
Normal file
12
src/com/dre/brewery/Util.java
Normal 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);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user