Search in sources :

Example 1 with SignalAspect

use of mods.railcraft.api.signals.SignalAspect in project Railcraft by Railcraft.

the class TileBoxAnalog method readFromNBT.

@Override
public void readFromNBT(NBTTagCompound data) {
    super.readFromNBT(data);
    strongestSignal = data.getInteger("strongestSignal");
    try {
        for (Map.Entry<SignalAspect, BitSet> entry : aspects.entrySet()) {
            String n = entry.getKey().name();
            byte[] bytes = data.getByteArray("aspect_" + n);
            BitSet bitSet = entry.getValue();
            bitSet.clear();
            bitSet.or(BitSet.valueOf(bytes));
        }
    } catch (Exception ignored) {
    }
    controller.readFromNBT(data);
    // Legacy Support Code - remove in the future
    for (Map.Entry<SignalAspect, BitSet> entry : aspects.entrySet()) {
        String n = entry.getKey().toString();
        boolean on = data.getBoolean("mode" + n);
        if (on) {
            int low = data.getInteger("low" + n);
            int high = data.getInteger("high" + n);
            entry.getValue().set(low, high);
        }
    }
}
Also used : SignalAspect(mods.railcraft.api.signals.SignalAspect) BitSet(java.util.BitSet) EnumMap(java.util.EnumMap) Map(java.util.Map) IOException(java.io.IOException)

Example 2 with SignalAspect

use of mods.railcraft.api.signals.SignalAspect in project Railcraft by Railcraft.

the class TileBoxAnalog method update.

@Override
public void update() {
    super.update();
    if (Game.isClient(worldObj)) {
        controller.tickClient();
        return;
    }
    controller.tickServer();
    SignalAspect prevAspect = controller.getAspect();
    if (controller.isBeingPaired())
        controller.setAspect(SignalAspect.BLINK_YELLOW);
    else if (controller.isPaired())
        controller.setAspect(determineAspect());
    else
        controller.setAspect(SignalAspect.BLINK_RED);
    if (prevAspect != controller.getAspect())
        sendUpdateToClient();
}
Also used : SignalAspect(mods.railcraft.api.signals.SignalAspect)

Example 3 with SignalAspect

use of mods.railcraft.api.signals.SignalAspect in project Railcraft by Railcraft.

the class TileBoxController method determineAspect.

private SignalAspect determineAspect() {
    SignalAspect newAspect = powered ? poweredAspect : defaultAspect;
    for (int side = 2; side < 6; side++) {
        EnumFacing forgeSide = EnumFacing.VALUES[side];
        TileEntity t = tileCache.getTileOnSide(forgeSide);
        if (t instanceof TileBoxBase) {
            TileBoxBase tile = (TileBoxBase) t;
            if (tile.canTransferAspect())
                newAspect = SignalAspect.mostRestrictive(newAspect, tile.getBoxSignalAspect(forgeSide.getOpposite()));
        }
    }
    return newAspect;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) SignalAspect(mods.railcraft.api.signals.SignalAspect) EnumFacing(net.minecraft.util.EnumFacing)

Example 4 with SignalAspect

use of mods.railcraft.api.signals.SignalAspect in project Railcraft by Railcraft.

the class GuiBoxAnalogController method onGuiClosed.

@Override
public void onGuiClosed() {
    if (Game.isClient(tile.getWorld())) {
        for (Map.Entry<SignalAspect, BitSet> entry : aspects.entrySet()) {
            parseRegex(textBox.get(entry.getKey()).getText(), entry.getValue());
        }
        tile.aspects = aspects;
        PacketGuiReturn pkt = new PacketGuiReturn(tile);
        PacketDispatcher.sendToServer(pkt);
    }
}
Also used : SignalAspect(mods.railcraft.api.signals.SignalAspect) BitSet(java.util.BitSet) EnumMap(java.util.EnumMap) Map(java.util.Map) PacketGuiReturn(mods.railcraft.common.util.network.PacketGuiReturn)

Example 5 with SignalAspect

use of mods.railcraft.api.signals.SignalAspect in project Railcraft by Railcraft.

the class TESRSignalLampDual method renderTileEntityAt.

@Override
public void renderTileEntityAt(TileSignalBase te, double x, double y, double z, float partialTicks, int destroyStage) {
    super.renderTileEntityAt(te, x, y, z, partialTicks, destroyStage);
    if (!(te instanceof IDualHeadSignal)) {
        return;
    }
    IDualHeadSignal tile = (IDualHeadSignal) te;
    EnumFacing facing = tile.getFacing();
    SignalAspect aspect = tile.getSignalAspect(DualLamp.TOP).getDisplayAspect();
    lampInfo.setTexture(facing, tile.getLampTexture(DualLamp.TOP, aspect));
    lampInfo.lightSource = aspect.getTextureBrightness();
    doRenderAspect(x, y, z);
    lampInfo.resetSidesAndLight();
    aspect = tile.getSignalAspect(DualLamp.BOTTOM).getDisplayAspect();
    lampInfo.setTexture(facing, tile.getLampTexture(DualLamp.BOTTOM, aspect));
    lampInfo.lightSource = aspect.getTextureBrightness();
    doRenderAspect(x, y, z);
}
Also used : SignalAspect(mods.railcraft.api.signals.SignalAspect) IDualHeadSignal(mods.railcraft.common.blocks.wayobjects.IDualHeadSignal) EnumFacing(net.minecraft.util.EnumFacing)

Aggregations

SignalAspect (mods.railcraft.api.signals.SignalAspect)14 EnumFacing (net.minecraft.util.EnumFacing)5 BitSet (java.util.BitSet)4 EnumMap (java.util.EnumMap)4 Map (java.util.Map)4 TileEntity (net.minecraft.tileentity.TileEntity)3 IDualHeadSignal (mods.railcraft.common.blocks.wayobjects.IDualHeadSignal)2 TextureAtlasSprite (net.minecraft.client.renderer.texture.TextureAtlasSprite)2 IOException (java.io.IOException)1 List (java.util.List)1 IOwnable (mods.railcraft.api.core.IOwnable)1 TileMultiBlock (mods.railcraft.common.blocks.machine.TileMultiBlock)1 MultiBlockStateReturn (mods.railcraft.common.blocks.machine.TileMultiBlock.MultiBlockStateReturn)1 TileSignalBase (mods.railcraft.common.blocks.wayobjects.TileSignalBase)1 PacketGuiReturn (mods.railcraft.common.util.network.PacketGuiReturn)1 GuiTextField (net.minecraft.client.gui.GuiTextField)1 EnumActionResult (net.minecraft.util.EnumActionResult)1