Search in sources :

Example 1 with TileLauncherBase

use of icbm.classic.content.blocks.launcher.base.TileLauncherBase in project ICBM-Classic by BuiltBrokenModding.

the class TileLauncherScreen method update.

@Override
public void update() {
    super.update();
    if (this.launcherBase == null || this.launcherBase.isInvalid()) {
        this.launcherBase = null;
        for (EnumFacing rotation : EnumFacing.HORIZONTALS) {
            final Pos position = new Pos((IPos3D) this).add(rotation);
            final TileEntity tileEntity = position.getTileEntity(world);
            if (tileEntity != null) {
                if (tileEntity instanceof TileLauncherBase) {
                    this.launcherBase = (TileLauncherBase) tileEntity;
                    if (isServer()) {
                        setRotation(rotation.getOpposite());
                        updateClient = true;
                    }
                }
            }
        }
    }
    if (isServer()) {
        // Delay launch, basically acts as a reload time
        if (launchDelay > 0) {
            launchDelay--;
        } else // Only launch if redstone
        if (// TODO replace with countdown
        ticks % 10 == 0 && world.getRedstonePowerFromNeighbors(getPos()) > 0) {
            this.launch();
        }
        // Update packet TODO see if this is needed
        if (ticks % 3 == 0) {
            sendDescPacket();
        }
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) IPos3D(com.builtbroken.jlib.data.vector.IPos3D) Pos(icbm.classic.lib.transform.vector.Pos) EnumFacing(net.minecraft.util.EnumFacing) TileLauncherBase(icbm.classic.content.blocks.launcher.base.TileLauncherBase)

Aggregations

IPos3D (com.builtbroken.jlib.data.vector.IPos3D)1 TileLauncherBase (icbm.classic.content.blocks.launcher.base.TileLauncherBase)1 Pos (icbm.classic.lib.transform.vector.Pos)1 TileEntity (net.minecraft.tileentity.TileEntity)1 EnumFacing (net.minecraft.util.EnumFacing)1