From 3ce5794d590be60be5869f8da14b88675f7aefd8 Mon Sep 17 00:00:00 2001 From: MrTroble Date: Fri, 6 Aug 2021 08:58:04 +0200 Subject: [PATCH] Fixed issue with chunk --- changelog.md | 3 ++ .../tile/TileRedstoneEmitter.java | 45 ++++--------------- 2 files changed, 11 insertions(+), 37 deletions(-) diff --git a/changelog.md b/changelog.md index 19c893a..6135d70 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,8 @@ # Changelog +## [Fix] 1.14.4 - 08.06.2021 - 1 +* Fixed issue with unneeded chunkloading + ## [Fix] 1.13.2 - 08.05.2021 - 2 * Fixed issue with language keys not working diff --git a/src/main/java/eu/gir/gircredstone/tile/TileRedstoneEmitter.java b/src/main/java/eu/gir/gircredstone/tile/TileRedstoneEmitter.java index 6590059..cb56a4d 100644 --- a/src/main/java/eu/gir/gircredstone/tile/TileRedstoneEmitter.java +++ b/src/main/java/eu/gir/gircredstone/tile/TileRedstoneEmitter.java @@ -1,7 +1,5 @@ package eu.gir.gircredstone.tile; -import java.util.concurrent.ExecutionException; - import eu.gir.gircredstone.block.BlockRedstoneAcceptor; import eu.gir.gircredstone.init.GIRCInit; import eu.gir.gircredstone.item.Linkingtool; @@ -9,8 +7,6 @@ import net.minecraft.nbt.CompoundNBT; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.math.BlockPos; -import net.minecraft.world.chunk.Chunk; -import net.minecraft.world.server.ServerChunkProvider; public class TileRedstoneEmitter extends TileEntity { @@ -19,7 +15,7 @@ public TileRedstoneEmitter() { } private BlockPos linkedpos = null; - + @Override public CompoundNBT write(CompoundNBT compound) { Linkingtool.writeBlockPosToNBT(linkedpos, compound); @@ -33,54 +29,29 @@ public void read(CompoundNBT compound) { } public boolean link(final BlockPos pos) { - if(pos == null) + if (pos == null) return false; this.linkedpos = pos; return true; } - + public boolean unlink() { - if(this.linkedpos == null) + if (this.linkedpos == null) return false; this.linkedpos = null; return true; } - + public BlockPos getLinkedPos() { return this.linkedpos; } - - public void accept(final boolean enabled) { - final BlockState state = world.getBlockState(linkedpos); - if (state.getBlock() instanceof BlockRedstoneAcceptor) { - world.setBlockState(linkedpos, state.with(BlockRedstoneAcceptor.POWER, enabled)); - } - } - @SuppressWarnings("deprecation") public void redstoneUpdate(final boolean enabled) { if (linkedpos != null) { - final boolean flag = !world.isBlockLoaded(linkedpos); - if(flag) { - final Chunk chunk = world.getChunkAt(linkedpos); - final ServerChunkProvider provider = (ServerChunkProvider) world.getChunkProvider(); - try { - provider.chunkManager.func_219188_b(chunk.getPos()).get().ifLeft(ch -> { - accept(enabled); - try { - provider.chunkManager.func_222973_a(chunk).get(); - } catch (InterruptedException | ExecutionException e) { - e.printStackTrace(); - } - }); - } catch (InterruptedException e) { - e.printStackTrace(); - } catch (ExecutionException e) { - e.printStackTrace(); - } - return; + final BlockState state = world.getBlockState(linkedpos); + if (state.getBlock() instanceof BlockRedstoneAcceptor) { + world.setBlockState(linkedpos, state.with(BlockRedstoneAcceptor.POWER, enabled)); } - accept(enabled); } }