Skip to content

Commit

Permalink
修复激光循环问题
Browse files Browse the repository at this point in the history
  • Loading branch information
dmzz-yyhyy committed Dec 20, 2024
1 parent cf0e964 commit db52dea
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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
Expand Down

0 comments on commit db52dea

Please sign in to comment.