Skip to content

Commit 6afab04

Browse files
committed
Slight improvement for recursive block checks
1 parent f7af489 commit 6afab04

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/main/java/twilightforest/TFTeleporter.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -261,10 +261,9 @@ private Set<BlockPos> getBoundaryPositions(BlockPos start) {
261261
private void checkAdjacent(BlockPos pos, Set<BlockPos> checked, Set<BlockPos> result) {
262262
for (EnumFacing facing : EnumFacing.Plane.HORIZONTAL) {
263263
BlockPos offset = pos.offset(facing);
264+
if (!checked.add(offset)) continue;
264265
if (isBlockPortal(world, offset)) {
265-
if (checked.add(offset)) {
266-
checkAdjacent(offset, checked, result);
267-
}
266+
checkAdjacent(offset, checked, result);
268267
} else {
269268
result.add(offset);
270269
}

src/main/java/twilightforest/block/BlockTFTowerDevice.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,12 +166,13 @@ private static boolean areBlocksLocked(IBlockAccess world, BlockPos pos) {
166166
private static boolean areBlocksLocked(IBlockAccess world, BlockPos pos, Set<BlockPos> checked) {
167167
for (EnumFacing facing : EnumFacing.values()) {
168168
BlockPos offset = pos.offset(facing);
169+
if (!checked.add(offset)) continue;
169170
IBlockState state = world.getBlockState(offset);
170171
if (state.getBlock() == TFBlocks.tower_device) {
171172
if (state.getValue(VARIANT) == TowerDeviceVariant.VANISH_LOCKED) {
172173
return true;
173174
}
174-
if (checked.add(offset) && areBlocksLocked(world, offset, checked)) {
175+
if (areBlocksLocked(world, offset, checked)) {
175176
return true;
176177
}
177178
}

0 commit comments

Comments
 (0)