aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/common/tileentities/TE_BeamTransmitter.java
blob: 74cb845fc47bffb2c1092b9dfa07387cbffdd288 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package common.tileentities;

import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.AxisAlignedBB;
import org.joml.Vector3i;
import org.joml.Vector3ic;

public class TE_BeamTransmitter extends TileEntity {

    private final Vector3ic position;

    private Vector3ic target = new Vector3i(10, 20, 10);
    private double distanceCache;
    private boolean distanceCacheValid = false;

    public TE_BeamTransmitter() {
        position = new Vector3i(super.xCoord, super.yCoord, super.zCoord);
    }

    public Vector3ic getTargetPosition() {
        return target;
    }

    public double getDistanceFromTarget() {
        if (!distanceCacheValid) {
            distanceCache = position.distance(target);
            distanceCacheValid = true;
        }
        return distanceCache;
    }

    @SideOnly(Side.CLIENT)
    @Override
    public double getMaxRenderDistanceSquared() {
        // 4k is standard, 65k is what the vanilla beacon uses
        return 65536.0D;
    }

    @Override
    @SideOnly(Side.CLIENT)
    public AxisAlignedBB getRenderBoundingBox() {
        // Make it so the beam is still rendered even when the source block is out of sight
        return INFINITE_EXTENT_AABB;
    }
}