use of mods.railcraft.api.signals.SignalAspect in project Railcraft by Railcraft.
the class TileBoxAnalog method readGuiData.
@Override
public void readGuiData(RailcraftInputStream data, @Nullable EntityPlayer sender) throws IOException {
for (Map.Entry<SignalAspect, BitSet> entry : aspects.entrySet()) {
BitSet bitSet = entry.getValue();
bitSet.clear();
bitSet.or(data.readBitSet());
}
}
use of mods.railcraft.api.signals.SignalAspect in project Railcraft by Railcraft.
the class TileBoxCapacitor method update.
@Override
public void update() {
super.update();
if (Game.isClient(worldObj))
return;
if (ticksPowered > 0) {
ticksPowered--;
if (Objects.equals(stateModeController.getButtonState(), EnumStateMode.FALLING_EDGE)) {
//new behavior
SignalAspect tmpaspect = SignalAspect.GREEN;
Boolean hasInput = false;
if (PowerPlugin.isBlockBeingPoweredByRepeater(worldObj, getPos()))
hasInput = true;
for (int side = 2; side < 6; side++) {
//get most restrictive aspect from adjacent (active) boxes
EnumFacing forgeSide = EnumFacing.VALUES[side];
TileEntity tile = tileCache.getTileOnSide(forgeSide);
if (tile instanceof TileBoxBase) {
TileBoxBase box = (TileBoxBase) tile;
if (box.isEmittingRedstone(forgeSide.getOpposite())) {
hasInput = true;
tmpaspect = SignalAspect.mostRestrictive(tmpaspect, box.getBoxSignalAspect(forgeSide.getOpposite()));
}
}
}
if (hasInput) {
//undo any previous decrements
ticksPowered = ticksToPower;
if (!Objects.equals(aspect, tmpaspect)) {
//change to the most restrictive aspect found above.
aspect = tmpaspect;
updateNeighbors();
}
}
}
//in all cases:
if (ticksPowered <= 0)
updateNeighbors();
}
}
use of mods.railcraft.api.signals.SignalAspect in project Railcraft by Railcraft.
the class GuiBoxAnalogController method initGui.
@Override
public void initGui() {
if (tile == null)
return;
int w = (width - xSize) / 2;
int h = (height - ySize) / 2;
for (Map.Entry<SignalAspect, BitSet> entry : aspects.entrySet()) {
GuiTextField textField = new GuiTextField(entry.getKey().ordinal(), fontRendererObj, w + 72, h + getYPosFromIndex(entry.getKey().ordinal()), 95, 10);
textField.setMaxStringLength(37);
textField.setText(rangeToString(entry.getValue()));
textBox.put(entry.getKey(), textField);
}
}
use of mods.railcraft.api.signals.SignalAspect in project Railcraft by Railcraft.
the class ItemMagnifyingGlass method onItemUseFirst.
@Override
public EnumActionResult onItemUseFirst(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ, EnumHand hand) {
if (Game.isClient(world))
return EnumActionResult.PASS;
TileEntity t = world.getTileEntity(pos);
EnumActionResult returnValue = EnumActionResult.PASS;
if (t instanceof IOwnable) {
IOwnable ownable = (IOwnable) t;
ChatPlugin.sendLocalizedChatFromServer(player, "gui.railcraft.mag.glass.placedby", ownable.getDisplayName(), ownable.getOwner());
returnValue = EnumActionResult.SUCCESS;
}
if (t instanceof TileMultiBlock) {
TileMultiBlock tile = (TileMultiBlock) t;
if (tile.isStructureValid())
ChatPlugin.sendLocalizedChatFromServer(player, "railcraft.multiblock.state.valid");
else
for (MultiBlockStateReturn returnState : EnumSet.complementOf(EnumSet.of(MultiBlockStateReturn.VALID))) {
List<Integer> pats = tile.patternStates.get(returnState);
if (!pats.isEmpty())
ChatPlugin.sendLocalizedChatFromServer(player, returnState.message, pats.toString());
}
returnValue = EnumActionResult.SUCCESS;
}
if (t instanceof IDualHeadSignal) {
IDualHeadSignal signal = (IDualHeadSignal) t;
SignalAspect top = signal.getSignalAspect(DualLamp.TOP);
SignalAspect bottom = signal.getSignalAspect(DualLamp.BOTTOM);
ChatPlugin.sendLocalizedChatFromServer(player, "gui.railcraft.mag.glass.aspect.dual", top.getLocalizationTag(), bottom.getLocalizationTag());
returnValue = EnumActionResult.SUCCESS;
} else if (t instanceof TileSignalBase) {
ChatPlugin.sendLocalizedChatFromServer(player, "gui.railcraft.mag.glass.aspect", ((TileSignalBase) t).getSignalAspect().getLocalizationTag());
returnValue = EnumActionResult.SUCCESS;
}
return returnValue;
}
Aggregations