Skip to content

Commit 1fce1fc

Browse files
committed
fix distance detector render culling
1 parent 2a28fd3 commit 1fce1fc

2 files changed

Lines changed: 16 additions & 12 deletions

File tree

‎src/main/java/de/srendi/advancedperipherals/client/renderer/DistanceDetectorRenderer.java‎

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -45,18 +45,6 @@ public int getViewDistance() {
4545
return 256;
4646
}
4747

48-
// @Override
49-
// public AABB getRenderBoundingBox(DistanceDetectorEntity be) {
50-
// float currentDistance = be.getCurrentDistance();
51-
// if (currentDistance == -1) {
52-
// currentDistance = be.getMaxRange();
53-
// }
54-
// currentDistance += 1.5f;
55-
// Direction direction = be.getBlockState().getValue(BaseBlock.ORIENTATION).front();
56-
// Vec3 blockPos = Vec3.atCenterOf(be.getBlockPos());
57-
// return new AABB(blockPos, blockPos.add(direction.getStepX() * currentDistance, direction.getStepY() * currentDistance, direction.getStepZ() * currentDistance));
58-
// }
59-
6048
@Override
6149
public boolean shouldRender(@NotNull DistanceDetectorEntity pBlockEntity, @NotNull Vec3 pCameraPos) {
6250
return true;

‎src/main/java/de/srendi/advancedperipherals/common/blocks/blockentities/DistanceDetectorEntity.java‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,21 @@
11
package de.srendi.advancedperipherals.common.blocks.blockentities;
22

33
import de.srendi.advancedperipherals.common.addons.computercraft.peripheral.DistanceDetectorPeripheral;
4+
import de.srendi.advancedperipherals.common.blocks.base.BaseBlock;
45
import de.srendi.advancedperipherals.common.blocks.base.PeripheralBlockEntity;
56
import de.srendi.advancedperipherals.common.configuration.APConfig;
67
import de.srendi.advancedperipherals.common.setup.APBlockEntityTypes;
78
import net.minecraft.core.BlockPos;
9+
import net.minecraft.core.Direction;
810
import net.minecraft.nbt.CompoundTag;
911
import net.minecraft.network.protocol.game.ClientboundBlockEntityDataPacket;
1012
import net.minecraft.util.Mth;
1113
import net.minecraft.world.level.Level;
1214
import net.minecraft.world.level.block.entity.BlockEntity;
1315
import net.minecraft.world.level.block.entity.BlockEntityType;
1416
import net.minecraft.world.level.block.state.BlockState;
17+
import net.minecraft.world.phys.AABB;
18+
import net.minecraft.world.phys.Vec3;
1519
import org.jetbrains.annotations.NotNull;
1620

1721
public class DistanceDetectorEntity extends PeripheralBlockEntity<DistanceDetectorPeripheral> {
@@ -99,4 +103,16 @@ public <U extends BlockEntity> void handleTick(Level level, BlockState state, Bl
99103
this.currentDistanceLerped = Mth.lerp(dt, this.currentDistanceLerped, distance == -1 ? this.getMaxRange() : distance);
100104
}
101105
}
106+
107+
@Override
108+
public AABB getRenderBoundingBox() {
109+
float currentDistance = this.getCurrentDistance();
110+
if (currentDistance == -1) {
111+
currentDistance = this.getMaxRange();
112+
}
113+
currentDistance += 1.5f;
114+
Direction direction = this.getBlockState().getValue(BaseBlock.ORIENTATION).front();
115+
Vec3 blockPos = Vec3.atCenterOf(this.getBlockPos());
116+
return new AABB(blockPos, blockPos.add(direction.getStepX() * currentDistance, direction.getStepY() * currentDistance, direction.getStepZ() * currentDistance));
117+
}
102118
}

0 commit comments

Comments
 (0)