From db52dea749e86c5e3bbcf5912a794ced66681343 Mon Sep 17 00:00:00 2001 From: NightFish <101402767+dmzz-yyhyy@users.noreply.github.com> Date: Sat, 21 Dec 2024 00:55:37 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=BF=80=E5=85=89=E5=BE=AA?= =?UTF-8?q?=E7=8E=AF=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../anvilcraft/block/entity/BaseLaserBlockEntity.java | 11 +++-------- .../anvilcraft/block/entity/RubyPrismBlockEntity.java | 7 ++----- 2 files changed, 5 insertions(+), 13 deletions(-) diff --git a/src/main/java/dev/dubhe/anvilcraft/block/entity/BaseLaserBlockEntity.java b/src/main/java/dev/dubhe/anvilcraft/block/entity/BaseLaserBlockEntity.java index c75618d13..4efbe2dd1 100644 --- a/src/main/java/dev/dubhe/anvilcraft/block/entity/BaseLaserBlockEntity.java +++ b/src/main/java/dev/dubhe/anvilcraft/block/entity/BaseLaserBlockEntity.java @@ -77,19 +77,14 @@ private boolean canPassThrough(Direction direction, BlockPos blockPos) { } public void updateIrradiateBlockPos(BlockPos newPos) { - if (newPos == irradiateBlockPos) return; if (irradiateBlockPos == null) { + if (newPos != null) + markChanged(); irradiateBlockPos = newPos; - markChanged(); return; } - if (newPos == null) { - irradiateBlockPos = null; + if (!irradiateBlockPos.equals(newPos)) markChanged(); - return; - } - if (irradiateBlockPos.equals(newPos)) return; - markChanged(); irradiateBlockPos = newPos; } diff --git a/src/main/java/dev/dubhe/anvilcraft/block/entity/RubyPrismBlockEntity.java b/src/main/java/dev/dubhe/anvilcraft/block/entity/RubyPrismBlockEntity.java index 57fe65da7..b20084017 100644 --- a/src/main/java/dev/dubhe/anvilcraft/block/entity/RubyPrismBlockEntity.java +++ b/src/main/java/dev/dubhe/anvilcraft/block/entity/RubyPrismBlockEntity.java @@ -11,7 +11,6 @@ import org.jetbrains.annotations.NotNull; public class RubyPrismBlockEntity extends BaseLaserBlockEntity { - private boolean enabledLastTick = false; private boolean enabled = false; private RubyPrismBlockEntity(BlockEntityType type, BlockPos pos, BlockState blockState) { @@ -27,16 +26,14 @@ private RubyPrismBlockEntity(BlockEntityType type, BlockPos pos, BlockState b } public void tick(@NotNull Level level) { - resetState(); - if (enabled || enabledLastTick) { + if (enabled) { emitLaser(getFacing()); } - enabledLastTick = enabled; if (laserLevel == 0) { enabled = false; - enabledLastTick = false; } super.tick(level); + resetState(); } @Override