Fix for chunk loading and type mismatch issues

This commit is contained in:
Brianna 2019-06-15 06:20:29 -04:00
parent b647083937
commit d6b10ddf31
3 changed files with 17 additions and 8 deletions

View File

@ -4,7 +4,7 @@ stages:
variables:
name: "EpicFurnaces"
path: "/builds/$CI_PROJECT_PATH"
version: "4.3"
version: "4.3.1"
build:
stage: build

View File

@ -4,7 +4,7 @@ import com.songoda.epicfurnaces.EpicFurnaces;
import com.songoda.epicfurnaces.furnace.Furnace;
import com.songoda.epicfurnaces.utils.Methods;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.BlockState;
import java.util.ArrayList;
@ -52,7 +52,16 @@ public abstract class Hologram {
private void format(Furnace furnace, Action action) {
org.bukkit.block.Furnace furnaceBlock = ((org.bukkit.block.Furnace) furnace.getLocation().getBlock().getState());
Location location = furnace.getLocation();
if (!location.getWorld().isChunkLoaded(location.getBlockX() >> 4, location.getBlockZ() >> 4))
return;
BlockState state = furnace.getLocation().getBlock().getState();
if (!(state instanceof org.bukkit.block.Furnace)) return;
org.bukkit.block.Furnace furnaceBlock = ((org.bukkit.block.Furnace) state);
int performance = (furnaceBlock.getCookTime() - furnace.getPerformanceTotal()) <= 0 ? 0 : furnace.getPerformanceTotal();
@ -90,8 +99,6 @@ public abstract class Hologram {
lines.add(progress);
lines.add(stats);
Location location = furnace.getLocation();
switch (action) {
case UPDATE:
update(location, lines);

View File

@ -8,6 +8,7 @@ import org.bukkit.Material;
import org.bukkit.Particle;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.block.BlockState;
import org.bukkit.scheduler.BukkitRunnable;
import java.util.concurrent.ThreadLocalRandom;
@ -50,10 +51,11 @@ public class FurnaceTask extends BukkitRunnable {
continue;
}
if (!furnace.getLocation().getBlock().getType().name().contains("FURNACE"))
continue;
BlockState state = furnace.getLocation().getBlock().getState();
if (((org.bukkit.block.Furnace) furnaceLocation.getBlock().getState()).getBurnTime() == 0) continue;
if (!(state instanceof org.bukkit.block.Furnace)) return;
if (((org.bukkit.block.Furnace) state).getBurnTime() == 0) continue;
if (furnace.getLevel().getOverheat() != 0) {
overheat(furnace);