From d4c790c3a9222df7ae0eb9e3abbafd7679a430f2 Mon Sep 17 00:00:00 2001 From: OmerBenGera Date: Sat, 27 Mar 2021 01:15:18 +0300 Subject: [PATCH] Added a check to make sure the loader still exists when it's ticking (#9) --- .../wildloaders/nms/NMSAdapter_v1_10_R1.java | 5 ++++- .../wildloaders/nms/NMSAdapter_v1_11_R1.java | 5 ++++- .../wildloaders/nms/NMSAdapter_v1_12_R1.java | 5 ++++- .../wildloaders/nms/NMSAdapter_v1_13_R1.java | 5 ++++- .../wildloaders/nms/NMSAdapter_v1_13_R2.java | 5 ++++- .../wildloaders/nms/NMSAdapter_v1_14_R1.java | 6 +++++- .../wildloaders/nms/NMSAdapter_v1_15_R1.java | 6 +++++- .../wildloaders/nms/NMSAdapter_v1_16_R1.java | 6 +++++- .../wildloaders/nms/NMSAdapter_v1_16_R2.java | 6 +++++- .../wildloaders/nms/NMSAdapter_v1_16_R3.java | 6 +++++- .../wildloaders/nms/NMSAdapter_v1_7_R3.java | 11 +++++++---- .../wildloaders/nms/NMSAdapter_v1_7_R4.java | 11 +++++++---- .../wildloaders/nms/NMSAdapter_v1_8_R1.java | 5 ++++- .../wildloaders/nms/NMSAdapter_v1_8_R2.java | 5 ++++- .../wildloaders/nms/NMSAdapter_v1_8_R3.java | 5 ++++- .../wildloaders/nms/NMSAdapter_v1_9_R1.java | 5 ++++- .../wildloaders/nms/NMSAdapter_v1_9_R2.java | 5 ++++- 17 files changed, 79 insertions(+), 23 deletions(-) diff --git a/v1_10_R1/src/main/java/com/bgsoftware/wildloaders/nms/NMSAdapter_v1_10_R1.java b/v1_10_R1/src/main/java/com/bgsoftware/wildloaders/nms/NMSAdapter_v1_10_R1.java index efc61eb..4cae479 100644 --- a/v1_10_R1/src/main/java/com/bgsoftware/wildloaders/nms/NMSAdapter_v1_10_R1.java +++ b/v1_10_R1/src/main/java/com/bgsoftware/wildloaders/nms/NMSAdapter_v1_10_R1.java @@ -184,6 +184,7 @@ public final class NMSAdapter_v1_10_R1 implements NMSAdapter { private final List holograms = new ArrayList<>(); private final WChunkLoader chunkLoader; + private final Block loaderBlock; private short currentTick = 20; private short daysAmount, hoursAmount = 0, minutesAmount = 0, secondsAmount = 0; @@ -195,6 +196,8 @@ public final class NMSAdapter_v1_10_R1 implements NMSAdapter { setPosition(blockPosition); a(world); + loaderBlock = world.getType(blockPosition).getBlock(); + if(!this.chunkLoader.isInfinite()) { long timeLeft = chunkLoader.getTimeLeft(); @@ -231,7 +234,7 @@ public final class NMSAdapter_v1_10_R1 implements NMSAdapter { currentTick = 0; - if(chunkLoader.isNotActive()){ + if(chunkLoader.isNotActive() || world.getType(position).getBlock() != loaderBlock){ chunkLoader.remove(); return; } diff --git a/v1_11_R1/src/main/java/com/bgsoftware/wildloaders/nms/NMSAdapter_v1_11_R1.java b/v1_11_R1/src/main/java/com/bgsoftware/wildloaders/nms/NMSAdapter_v1_11_R1.java index 2adf559..456845f 100644 --- a/v1_11_R1/src/main/java/com/bgsoftware/wildloaders/nms/NMSAdapter_v1_11_R1.java +++ b/v1_11_R1/src/main/java/com/bgsoftware/wildloaders/nms/NMSAdapter_v1_11_R1.java @@ -184,6 +184,7 @@ public final class NMSAdapter_v1_11_R1 implements NMSAdapter { private final List holograms = new ArrayList<>(); private final WChunkLoader chunkLoader; + private final Block loaderBlock; private short currentTick = 20; private short daysAmount, hoursAmount, minutesAmount, secondsAmount; @@ -195,6 +196,8 @@ public final class NMSAdapter_v1_11_R1 implements NMSAdapter { setPosition(blockPosition); a(world); + loaderBlock = world.getType(blockPosition).getBlock(); + if(!this.chunkLoader.isInfinite()) { long timeLeft = chunkLoader.getTimeLeft(); @@ -231,7 +234,7 @@ public final class NMSAdapter_v1_11_R1 implements NMSAdapter { currentTick = 0; - if(chunkLoader.isNotActive()){ + if(chunkLoader.isNotActive() || world.getType(position).getBlock() != loaderBlock){ chunkLoader.remove(); return; } diff --git a/v1_12_R1/src/main/java/com/bgsoftware/wildloaders/nms/NMSAdapter_v1_12_R1.java b/v1_12_R1/src/main/java/com/bgsoftware/wildloaders/nms/NMSAdapter_v1_12_R1.java index b46fb64..7a3db0e 100644 --- a/v1_12_R1/src/main/java/com/bgsoftware/wildloaders/nms/NMSAdapter_v1_12_R1.java +++ b/v1_12_R1/src/main/java/com/bgsoftware/wildloaders/nms/NMSAdapter_v1_12_R1.java @@ -207,6 +207,7 @@ public final class NMSAdapter_v1_12_R1 implements NMSAdapter { private final List holograms = new ArrayList<>(); private final WChunkLoader chunkLoader; + private final Block loaderBlock; private short currentTick = 20; private short daysAmount, hoursAmount, minutesAmount, secondsAmount; @@ -218,6 +219,8 @@ public final class NMSAdapter_v1_12_R1 implements NMSAdapter { setPosition(blockPosition); a(world); + loaderBlock = world.getType(blockPosition).getBlock(); + if(!this.chunkLoader.isInfinite()) { long timeLeft = chunkLoader.getTimeLeft(); @@ -254,7 +257,7 @@ public final class NMSAdapter_v1_12_R1 implements NMSAdapter { currentTick = 0; - if(chunkLoader.isNotActive()){ + if(chunkLoader.isNotActive() || world.getType(position).getBlock() != loaderBlock){ chunkLoader.remove(); return; } diff --git a/v1_13_R1/src/main/java/com/bgsoftware/wildloaders/nms/NMSAdapter_v1_13_R1.java b/v1_13_R1/src/main/java/com/bgsoftware/wildloaders/nms/NMSAdapter_v1_13_R1.java index 656ace5..7926fc9 100644 --- a/v1_13_R1/src/main/java/com/bgsoftware/wildloaders/nms/NMSAdapter_v1_13_R1.java +++ b/v1_13_R1/src/main/java/com/bgsoftware/wildloaders/nms/NMSAdapter_v1_13_R1.java @@ -177,6 +177,7 @@ public final class NMSAdapter_v1_13_R1 implements NMSAdapter { private final List holograms = new ArrayList<>(); private final WChunkLoader chunkLoader; + private final Block loaderBlock; private short currentTick = 20; private short daysAmount, hoursAmount, minutesAmount, secondsAmount; @@ -190,6 +191,8 @@ public final class NMSAdapter_v1_13_R1 implements NMSAdapter { setPosition(blockPosition); setWorld(world); + loaderBlock = world.getType(blockPosition).getBlock(); + if(!this.chunkLoader.isInfinite()) { long timeLeft = chunkLoader.getTimeLeft(); @@ -226,7 +229,7 @@ public final class NMSAdapter_v1_13_R1 implements NMSAdapter { currentTick = 0; - if(chunkLoader.isNotActive()){ + if(chunkLoader.isNotActive() || world.getType(position).getBlock() != loaderBlock){ chunkLoader.remove(); return; } diff --git a/v1_13_R2/src/main/java/com/bgsoftware/wildloaders/nms/NMSAdapter_v1_13_R2.java b/v1_13_R2/src/main/java/com/bgsoftware/wildloaders/nms/NMSAdapter_v1_13_R2.java index 68ca8b5..840fe08 100644 --- a/v1_13_R2/src/main/java/com/bgsoftware/wildloaders/nms/NMSAdapter_v1_13_R2.java +++ b/v1_13_R2/src/main/java/com/bgsoftware/wildloaders/nms/NMSAdapter_v1_13_R2.java @@ -177,6 +177,7 @@ public final class NMSAdapter_v1_13_R2 implements NMSAdapter { private final List holograms = new ArrayList<>(); private final WChunkLoader chunkLoader; + private final Block loaderBlock; private short currentTick = 20; private short daysAmount, hoursAmount, minutesAmount, secondsAmount; @@ -190,6 +191,8 @@ public final class NMSAdapter_v1_13_R2 implements NMSAdapter { setPosition(blockPosition); setWorld(world); + loaderBlock = world.getType(blockPosition).getBlock(); + if(!this.chunkLoader.isInfinite()) { long timeLeft = chunkLoader.getTimeLeft(); @@ -226,7 +229,7 @@ public final class NMSAdapter_v1_13_R2 implements NMSAdapter { currentTick = 0; - if(chunkLoader.isNotActive()){ + if(chunkLoader.isNotActive() || world.getType(position).getBlock() != loaderBlock){ chunkLoader.remove(); return; } diff --git a/v1_14_R1/src/main/java/com/bgsoftware/wildloaders/nms/NMSAdapter_v1_14_R1.java b/v1_14_R1/src/main/java/com/bgsoftware/wildloaders/nms/NMSAdapter_v1_14_R1.java index 3495c46..c733ac3 100644 --- a/v1_14_R1/src/main/java/com/bgsoftware/wildloaders/nms/NMSAdapter_v1_14_R1.java +++ b/v1_14_R1/src/main/java/com/bgsoftware/wildloaders/nms/NMSAdapter_v1_14_R1.java @@ -185,6 +185,7 @@ public final class NMSAdapter_v1_14_R1 implements NMSAdapter { private final List holograms = new ArrayList<>(); private final WChunkLoader chunkLoader; + private final Block loaderBlock; private short currentTick = 20; private short daysAmount, hoursAmount, minutesAmount, secondsAmount; @@ -198,6 +199,8 @@ public final class NMSAdapter_v1_14_R1 implements NMSAdapter { setPosition(blockPosition); setWorld(world); + loaderBlock = world.getType(blockPosition).getBlock(); + try { // Not a method of Spigot - fixes https://github.com/OmerBenGera/WildLoaders/issues/2 setCurrentChunk(world.getChunkAtWorldCoords(blockPosition)); @@ -244,7 +247,8 @@ public final class NMSAdapter_v1_14_R1 implements NMSAdapter { currentTick = 0; - if(chunkLoader.isNotActive()){ + assert world != null; + if(chunkLoader.isNotActive() || world.getType(position).getBlock() != loaderBlock){ chunkLoader.remove(); return; } diff --git a/v1_15_R1/src/main/java/com/bgsoftware/wildloaders/nms/NMSAdapter_v1_15_R1.java b/v1_15_R1/src/main/java/com/bgsoftware/wildloaders/nms/NMSAdapter_v1_15_R1.java index 87c45a0..4c84d73 100644 --- a/v1_15_R1/src/main/java/com/bgsoftware/wildloaders/nms/NMSAdapter_v1_15_R1.java +++ b/v1_15_R1/src/main/java/com/bgsoftware/wildloaders/nms/NMSAdapter_v1_15_R1.java @@ -185,6 +185,7 @@ public final class NMSAdapter_v1_15_R1 implements NMSAdapter { private final List holograms = new ArrayList<>(); private final WChunkLoader chunkLoader; + private final Block loaderBlock; private short currentTick = 20; private short daysAmount, hoursAmount, minutesAmount, secondsAmount; @@ -197,6 +198,8 @@ public final class NMSAdapter_v1_15_R1 implements NMSAdapter { setLocation(world, blockPosition); + loaderBlock = world.getType(blockPosition).getBlock(); + try { // Not a method of Spigot - fixes https://github.com/OmerBenGera/WildLoaders/issues/2 setCurrentChunk(world.getChunkAtWorldCoords(blockPosition)); @@ -243,7 +246,8 @@ public final class NMSAdapter_v1_15_R1 implements NMSAdapter { currentTick = 0; - if(chunkLoader.isNotActive()){ + assert world != null; + if(chunkLoader.isNotActive() || world.getType(position).getBlock() != loaderBlock){ chunkLoader.remove(); return; } diff --git a/v1_16_R1/src/main/java/com/bgsoftware/wildloaders/nms/NMSAdapter_v1_16_R1.java b/v1_16_R1/src/main/java/com/bgsoftware/wildloaders/nms/NMSAdapter_v1_16_R1.java index 48ebd60..650c217 100644 --- a/v1_16_R1/src/main/java/com/bgsoftware/wildloaders/nms/NMSAdapter_v1_16_R1.java +++ b/v1_16_R1/src/main/java/com/bgsoftware/wildloaders/nms/NMSAdapter_v1_16_R1.java @@ -187,6 +187,7 @@ public final class NMSAdapter_v1_16_R1 implements NMSAdapter { private final List holograms = new ArrayList<>(); private final WChunkLoader chunkLoader; + private final Block loaderBlock; private short currentTick = 20; private short daysAmount, hoursAmount, minutesAmount, secondsAmount; @@ -199,6 +200,8 @@ public final class NMSAdapter_v1_16_R1 implements NMSAdapter { setLocation(world, blockPosition); + loaderBlock = world.getType(blockPosition).getBlock(); + try { // Not a method of Spigot - fixes https://github.com/OmerBenGera/WildLoaders/issues/2 setCurrentChunk(world.getChunkAtWorldCoords(blockPosition)); @@ -245,7 +248,8 @@ public final class NMSAdapter_v1_16_R1 implements NMSAdapter { currentTick = 0; - if(chunkLoader.isNotActive()){ + assert world != null; + if(chunkLoader.isNotActive() || world.getType(position).getBlock() != loaderBlock){ chunkLoader.remove(); return; } diff --git a/v1_16_R2/src/main/java/com/bgsoftware/wildloaders/nms/NMSAdapter_v1_16_R2.java b/v1_16_R2/src/main/java/com/bgsoftware/wildloaders/nms/NMSAdapter_v1_16_R2.java index 0b39bbe..21a1589 100644 --- a/v1_16_R2/src/main/java/com/bgsoftware/wildloaders/nms/NMSAdapter_v1_16_R2.java +++ b/v1_16_R2/src/main/java/com/bgsoftware/wildloaders/nms/NMSAdapter_v1_16_R2.java @@ -187,6 +187,7 @@ public final class NMSAdapter_v1_16_R2 implements NMSAdapter { private final List holograms = new ArrayList<>(); private final WChunkLoader chunkLoader; + private final Block loaderBlock; private short currentTick = 20; private short daysAmount, hoursAmount, minutesAmount, secondsAmount; @@ -199,6 +200,8 @@ public final class NMSAdapter_v1_16_R2 implements NMSAdapter { setLocation(world, blockPosition); + loaderBlock = world.getType(blockPosition).getBlock(); + try { // Not a method of Spigot - fixes https://github.com/OmerBenGera/WildLoaders/issues/2 setCurrentChunk(world.getChunkAtWorldCoords(blockPosition)); @@ -245,7 +248,8 @@ public final class NMSAdapter_v1_16_R2 implements NMSAdapter { currentTick = 0; - if(chunkLoader.isNotActive()){ + assert world != null; + if(chunkLoader.isNotActive() || world.getType(position).getBlock() != loaderBlock){ chunkLoader.remove(); return; } diff --git a/v1_16_R3/src/main/java/com/bgsoftware/wildloaders/nms/NMSAdapter_v1_16_R3.java b/v1_16_R3/src/main/java/com/bgsoftware/wildloaders/nms/NMSAdapter_v1_16_R3.java index 94af52e..a6afae9 100644 --- a/v1_16_R3/src/main/java/com/bgsoftware/wildloaders/nms/NMSAdapter_v1_16_R3.java +++ b/v1_16_R3/src/main/java/com/bgsoftware/wildloaders/nms/NMSAdapter_v1_16_R3.java @@ -187,6 +187,7 @@ public final class NMSAdapter_v1_16_R3 implements NMSAdapter { private final List holograms = new ArrayList<>(); private final WChunkLoader chunkLoader; + private final Block loaderBlock; private short currentTick = 20; private short daysAmount, hoursAmount, minutesAmount, secondsAmount; @@ -199,6 +200,8 @@ public final class NMSAdapter_v1_16_R3 implements NMSAdapter { setLocation(world, blockPosition); + loaderBlock = world.getType(blockPosition).getBlock(); + try { // Not a method of Spigot - fixes https://github.com/OmerBenGera/WildLoaders/issues/2 setCurrentChunk(world.getChunkAtWorldCoords(blockPosition)); @@ -245,7 +248,8 @@ public final class NMSAdapter_v1_16_R3 implements NMSAdapter { currentTick = 0; - if(chunkLoader.isNotActive()){ + assert world != null; + if(chunkLoader.isNotActive() || world.getType(position).getBlock() != loaderBlock){ chunkLoader.remove(); return; } diff --git a/v1_7_R3/src/main/java/com/bgsoftware/wildloaders/nms/NMSAdapter_v1_7_R3.java b/v1_7_R3/src/main/java/com/bgsoftware/wildloaders/nms/NMSAdapter_v1_7_R3.java index 15e90d3..f019325 100644 --- a/v1_7_R3/src/main/java/com/bgsoftware/wildloaders/nms/NMSAdapter_v1_7_R3.java +++ b/v1_7_R3/src/main/java/com/bgsoftware/wildloaders/nms/NMSAdapter_v1_7_R3.java @@ -183,19 +183,22 @@ public final class NMSAdapter_v1_7_R3 implements NMSAdapter { private static final Map tileEntityChunkLoaderMap = new HashMap<>(); - private final ChunkLoader chunkLoader; + private final WChunkLoader chunkLoader; + private final Block loaderBlock; private short currentTick = 20; private boolean removed = false; TileEntityChunkLoader(ChunkLoader chunkLoader, World world, int x, int y, int z){ - this.chunkLoader = chunkLoader; + this.chunkLoader = (WChunkLoader) chunkLoader; this.x = x; this.y = y; this.z = z; a(world); + loaderBlock = world.getType(x, y, z); + tileEntityChunkLoaderMap.put(LongHash.toLong(x >> 4, z >> 4), this); } @@ -206,12 +209,12 @@ public final class NMSAdapter_v1_7_R3 implements NMSAdapter { currentTick = 0; - if(((WChunkLoader) chunkLoader).isNotActive()){ + if(chunkLoader.isNotActive() || world.getType(x, y, z) != loaderBlock){ chunkLoader.remove(); return; } - ((WChunkLoader) chunkLoader).tick(); + chunkLoader.tick(); } @Override diff --git a/v1_7_R4/src/main/java/com/bgsoftware/wildloaders/nms/NMSAdapter_v1_7_R4.java b/v1_7_R4/src/main/java/com/bgsoftware/wildloaders/nms/NMSAdapter_v1_7_R4.java index ca26b70..370a428 100644 --- a/v1_7_R4/src/main/java/com/bgsoftware/wildloaders/nms/NMSAdapter_v1_7_R4.java +++ b/v1_7_R4/src/main/java/com/bgsoftware/wildloaders/nms/NMSAdapter_v1_7_R4.java @@ -183,19 +183,22 @@ public final class NMSAdapter_v1_7_R4 implements NMSAdapter { private static final Map tileEntityChunkLoaderMap = new HashMap<>(); - private final ChunkLoader chunkLoader; + private final WChunkLoader chunkLoader; + private final Block loaderBlock; private short currentTick = 20; private boolean removed = false; TileEntityChunkLoader(ChunkLoader chunkLoader, World world, int x, int y, int z){ - this.chunkLoader = chunkLoader; + this.chunkLoader = (WChunkLoader) chunkLoader; this.x = x; this.y = y; this.z = z; a(world); + loaderBlock = world.getType(x, y, z); + tileEntityChunkLoaderMap.put(LongHash.toLong(x >> 4, z >> 4), this); } @@ -206,12 +209,12 @@ public final class NMSAdapter_v1_7_R4 implements NMSAdapter { currentTick = 0; - if(((WChunkLoader) chunkLoader).isNotActive()){ + if(chunkLoader.isNotActive() || world.getType(x, y, z) != loaderBlock){ chunkLoader.remove(); return; } - ((WChunkLoader) chunkLoader).tick(); + chunkLoader.tick(); } @Override diff --git a/v1_8_R1/src/main/java/com/bgsoftware/wildloaders/nms/NMSAdapter_v1_8_R1.java b/v1_8_R1/src/main/java/com/bgsoftware/wildloaders/nms/NMSAdapter_v1_8_R1.java index 77cfa44..817059b 100644 --- a/v1_8_R1/src/main/java/com/bgsoftware/wildloaders/nms/NMSAdapter_v1_8_R1.java +++ b/v1_8_R1/src/main/java/com/bgsoftware/wildloaders/nms/NMSAdapter_v1_8_R1.java @@ -187,6 +187,7 @@ public final class NMSAdapter_v1_8_R1 implements NMSAdapter { private final List holograms = new ArrayList<>(); private final WChunkLoader chunkLoader; + private final Block loaderBlock; private short currentTick = 20; private short daysAmount, hoursAmount, minutesAmount, secondsAmount; @@ -198,6 +199,8 @@ public final class NMSAdapter_v1_8_R1 implements NMSAdapter { a(blockPosition); a(world); + loaderBlock = world.getType(blockPosition).getBlock(); + if(!this.chunkLoader.isInfinite()) { long timeLeft = chunkLoader.getTimeLeft(); @@ -234,7 +237,7 @@ public final class NMSAdapter_v1_8_R1 implements NMSAdapter { currentTick = 0; - if(chunkLoader.isNotActive()){ + if(chunkLoader.isNotActive() || world.getType(position).getBlock() != loaderBlock){ chunkLoader.remove(); return; } diff --git a/v1_8_R2/src/main/java/com/bgsoftware/wildloaders/nms/NMSAdapter_v1_8_R2.java b/v1_8_R2/src/main/java/com/bgsoftware/wildloaders/nms/NMSAdapter_v1_8_R2.java index 2e4cacb..062caf9 100644 --- a/v1_8_R2/src/main/java/com/bgsoftware/wildloaders/nms/NMSAdapter_v1_8_R2.java +++ b/v1_8_R2/src/main/java/com/bgsoftware/wildloaders/nms/NMSAdapter_v1_8_R2.java @@ -184,6 +184,7 @@ public final class NMSAdapter_v1_8_R2 implements NMSAdapter { private final List holograms = new ArrayList<>(); private final WChunkLoader chunkLoader; + private final Block loaderBlock; private short currentTick = 20; private short daysAmount, hoursAmount, minutesAmount, secondsAmount; @@ -195,6 +196,8 @@ public final class NMSAdapter_v1_8_R2 implements NMSAdapter { a(blockPosition); a(world); + loaderBlock = world.getType(blockPosition).getBlock(); + if(!this.chunkLoader.isInfinite()) { long timeLeft = chunkLoader.getTimeLeft(); @@ -231,7 +234,7 @@ public final class NMSAdapter_v1_8_R2 implements NMSAdapter { currentTick = 0; - if(chunkLoader.isNotActive()){ + if(chunkLoader.isNotActive() || world.getType(position).getBlock() != loaderBlock){ chunkLoader.remove(); return; } diff --git a/v1_8_R3/src/main/java/com/bgsoftware/wildloaders/nms/NMSAdapter_v1_8_R3.java b/v1_8_R3/src/main/java/com/bgsoftware/wildloaders/nms/NMSAdapter_v1_8_R3.java index 17f08b1..b8f2214 100644 --- a/v1_8_R3/src/main/java/com/bgsoftware/wildloaders/nms/NMSAdapter_v1_8_R3.java +++ b/v1_8_R3/src/main/java/com/bgsoftware/wildloaders/nms/NMSAdapter_v1_8_R3.java @@ -184,6 +184,7 @@ public final class NMSAdapter_v1_8_R3 implements NMSAdapter { private final List holograms = new ArrayList<>(); private final WChunkLoader chunkLoader; + private final Block loaderBlock; private short currentTick = 20; private short daysAmount, hoursAmount, minutesAmount, secondsAmount; @@ -195,6 +196,8 @@ public final class NMSAdapter_v1_8_R3 implements NMSAdapter { a(blockPosition); a(world); + loaderBlock = world.getType(blockPosition).getBlock(); + if(!this.chunkLoader.isInfinite()) { long timeLeft = chunkLoader.getTimeLeft(); @@ -231,7 +234,7 @@ public final class NMSAdapter_v1_8_R3 implements NMSAdapter { currentTick = 0; - if(chunkLoader.isNotActive()){ + if(chunkLoader.isNotActive() || world.getType(position).getBlock() != loaderBlock){ chunkLoader.remove(); return; } diff --git a/v1_9_R1/src/main/java/com/bgsoftware/wildloaders/nms/NMSAdapter_v1_9_R1.java b/v1_9_R1/src/main/java/com/bgsoftware/wildloaders/nms/NMSAdapter_v1_9_R1.java index 15f0210..9cdd1b7 100644 --- a/v1_9_R1/src/main/java/com/bgsoftware/wildloaders/nms/NMSAdapter_v1_9_R1.java +++ b/v1_9_R1/src/main/java/com/bgsoftware/wildloaders/nms/NMSAdapter_v1_9_R1.java @@ -184,6 +184,7 @@ public final class NMSAdapter_v1_9_R1 implements NMSAdapter { private final List holograms = new ArrayList<>(); private final WChunkLoader chunkLoader; + private final Block loaderBlock; private short currentTick = 20; private short daysAmount, hoursAmount, minutesAmount, secondsAmount; @@ -195,6 +196,8 @@ public final class NMSAdapter_v1_9_R1 implements NMSAdapter { a(blockPosition); a(world); + loaderBlock = world.getType(blockPosition).getBlock(); + if(!this.chunkLoader.isInfinite()) { long timeLeft = chunkLoader.getTimeLeft(); @@ -231,7 +234,7 @@ public final class NMSAdapter_v1_9_R1 implements NMSAdapter { currentTick = 0; - if(chunkLoader.isNotActive()){ + if(chunkLoader.isNotActive() || world.getType(position).getBlock() != loaderBlock){ chunkLoader.remove(); return; } diff --git a/v1_9_R2/src/main/java/com/bgsoftware/wildloaders/nms/NMSAdapter_v1_9_R2.java b/v1_9_R2/src/main/java/com/bgsoftware/wildloaders/nms/NMSAdapter_v1_9_R2.java index af04228..5673071 100644 --- a/v1_9_R2/src/main/java/com/bgsoftware/wildloaders/nms/NMSAdapter_v1_9_R2.java +++ b/v1_9_R2/src/main/java/com/bgsoftware/wildloaders/nms/NMSAdapter_v1_9_R2.java @@ -184,6 +184,7 @@ public final class NMSAdapter_v1_9_R2 implements NMSAdapter { private final List holograms = new ArrayList<>(); private final WChunkLoader chunkLoader; + private final Block loaderBlock; private short currentTick = 20; private short daysAmount, hoursAmount, minutesAmount, secondsAmount; @@ -195,6 +196,8 @@ public final class NMSAdapter_v1_9_R2 implements NMSAdapter { a(blockPosition); a(world); + loaderBlock = world.getType(blockPosition).getBlock(); + if(!this.chunkLoader.isInfinite()) { long timeLeft = chunkLoader.getTimeLeft(); @@ -231,7 +234,7 @@ public final class NMSAdapter_v1_9_R2 implements NMSAdapter { currentTick = 0; - if(chunkLoader.isNotActive()){ + if(chunkLoader.isNotActive() || world.getType(position).getBlock() != loaderBlock){ chunkLoader.remove(); return; }