From 77e71498aff6dafd7560dd16840aadb00aaeae7a Mon Sep 17 00:00:00 2001 From: FireflyHotaruC <2925509431@qq.com> Date: Sat, 9 May 2026 13:45:03 +0800 Subject: [PATCH] fix Vanishing Block lock check --- .../java/twilightforest/block/VanishingBlock.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/main/java/twilightforest/block/VanishingBlock.java b/src/main/java/twilightforest/block/VanishingBlock.java index 1525acddd2..b053e89843 100644 --- a/src/main/java/twilightforest/block/VanishingBlock.java +++ b/src/main/java/twilightforest/block/VanishingBlock.java @@ -54,6 +54,7 @@ private static boolean areBlocksLocked(BlockGetter getter, BlockPos start) { Deque queue = new ArrayDeque<>(); Set checked = new HashSet<>(); queue.offer(start); + checked.add(start); for (int iter = 0; !queue.isEmpty() && iter < limit; iter++) { BlockPos cur = queue.pop(); @@ -62,12 +63,11 @@ private static boolean areBlocksLocked(BlockGetter getter, BlockPos start) { return true; } - checked.add(cur); - if (state.getBlock() instanceof VanishingBlock) { for (Direction facing : Direction.values()) { BlockPos neighbor = cur.relative(facing); if (!checked.contains(neighbor)) { + checked.add(neighbor); queue.offer(neighbor); } } @@ -99,11 +99,7 @@ public VoxelShape getCollisionShape(BlockState state, BlockGetter getter, BlockP @Override protected InteractionResult useWithoutItem(BlockState state, Level level, BlockPos pos, Player player, BlockHitResult hit) { if (!this.isVanished(state) && !state.getValue(ACTIVE)) { - if (areBlocksLocked(level, pos)) { - level.playSound(null, pos, TFSounds.LOCKED_VANISHING_BLOCK.get(), SoundSource.BLOCKS, 1.0F, 0.3F); - } else { - this.activate(level, pos); - } + this.activate(level, pos); return InteractionResult.sidedSuccess(level.isClientSide()); } @@ -188,6 +184,10 @@ public void sparkle(Level level, BlockPos pos) { } private void activate(Level level, BlockPos pos) { + if (areBlocksLocked(level, pos)) { + level.playSound(null, pos, TFSounds.LOCKED_VANISHING_BLOCK.get(), SoundSource.BLOCKS, 1.0F, 0.3F); + return; + } BlockState state = level.getBlockState(pos); if (state.getBlock() instanceof VanishingBlock && !isVanished(state) && !state.getValue(ACTIVE)) { level.setBlockAndUpdate(pos, state.setValue(ACTIVE, true));