|
1 | 1 | package de.srendi.advancedperipherals.common.blocks.blockentities; |
2 | 2 |
|
3 | 3 | import de.srendi.advancedperipherals.common.addons.computercraft.peripheral.DistanceDetectorPeripheral; |
| 4 | +import de.srendi.advancedperipherals.common.blocks.base.BaseBlock; |
4 | 5 | import de.srendi.advancedperipherals.common.blocks.base.PeripheralBlockEntity; |
5 | 6 | import de.srendi.advancedperipherals.common.configuration.APConfig; |
6 | 7 | import de.srendi.advancedperipherals.common.setup.APBlockEntityTypes; |
7 | 8 | import net.minecraft.core.BlockPos; |
| 9 | +import net.minecraft.core.Direction; |
8 | 10 | import net.minecraft.nbt.CompoundTag; |
9 | 11 | import net.minecraft.network.protocol.game.ClientboundBlockEntityDataPacket; |
10 | 12 | import net.minecraft.util.Mth; |
11 | 13 | import net.minecraft.world.level.Level; |
12 | 14 | import net.minecraft.world.level.block.entity.BlockEntity; |
13 | 15 | import net.minecraft.world.level.block.entity.BlockEntityType; |
14 | 16 | import net.minecraft.world.level.block.state.BlockState; |
| 17 | +import net.minecraft.world.phys.AABB; |
| 18 | +import net.minecraft.world.phys.Vec3; |
15 | 19 | import org.jetbrains.annotations.NotNull; |
16 | 20 |
|
17 | 21 | public class DistanceDetectorEntity extends PeripheralBlockEntity<DistanceDetectorPeripheral> { |
@@ -99,4 +103,16 @@ public <U extends BlockEntity> void handleTick(Level level, BlockState state, Bl |
99 | 103 | this.currentDistanceLerped = Mth.lerp(dt, this.currentDistanceLerped, distance == -1 ? this.getMaxRange() : distance); |
100 | 104 | } |
101 | 105 | } |
| 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 | + } |
102 | 118 | } |
0 commit comments