Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions src/main/java/twilightforest/block/VanishingBlock.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ private static boolean areBlocksLocked(BlockGetter getter, BlockPos start) {
Deque<BlockPos> queue = new ArrayDeque<>();
Set<BlockPos> checked = new HashSet<>();
queue.offer(start);
checked.add(start);

for (int iter = 0; !queue.isEmpty() && iter < limit; iter++) {
BlockPos cur = queue.pop();
Expand All @@ -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);
}
}
Expand Down Expand Up @@ -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());
}

Expand Down Expand Up @@ -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));
Expand Down