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);
}
}
}
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();
}
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;
}
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);
}
}
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);
}
Aggregations