Search in sources :

Example 1 with FluidGaugeWidget

use of mods.railcraft.common.gui.widgets.FluidGaugeWidget in project Railcraft by Railcraft.

the class ContainerTank method createGauge.

public FluidGaugeWidget createGauge(StandardTank tank, int x, int y, int u, int v, int w, int h) {
    if (logicContainer.getLogic(WaterGeneratorLogic.class).isPresent())
        return new FluidGaugeWidget(tank, x, y, u, v, w, h) {

            GeneratorStatus status = new GeneratorStatus();

            ToolTip toolTip = new ToolTip() {

                @Override
                public void refresh() {
                    clear();
                    ToolTip tankToolTip = tank.getToolTip();
                    tankToolTip.refresh();
                    addAll(tankToolTip);
                    get(0).format = TextFormatting.BLUE;
                    newline();
                    add(new ToolTipLine(LocalizationPlugin.format("gui.railcraft.tank.sky", status.canSeeSky), TextFormatting.DARK_GRAY));
                    add(new ToolTipLine(LocalizationPlugin.format("gui.railcraft.tank.base", status.baseRate() * status.canSeeSky), TextFormatting.DARK_GRAY));
                    add(new ToolTipLine(LocalizationPlugin.format("gui.railcraft.tank.humidity", status.humidityMultiplier), TextFormatting.DARK_GRAY));
                    add(new ToolTipLine(LocalizationPlugin.format("gui.railcraft.tank.precipitation", status.precipitationMultiplier), TextFormatting.DARK_GRAY));
                    add(new ToolTipLine(LocalizationPlugin.format("gui.railcraft.tank.temp", -status.tempPenalty), TextFormatting.DARK_GRAY));
                    add(new ToolTipLine(LocalizationPlugin.format("gui.railcraft.tank.final", (status.baseRate() * status.canSeeSky * status.humidityMultiplier * status.precipitationMultiplier) - status.tempPenalty), TextFormatting.DARK_GRAY));
                }
            };

            @Override
            public void writeServerSyncData(IContainerListener listener, RailcraftOutputStream data) throws IOException {
                super.writeServerSyncData(listener, data);
                GeneratorStatus temp = new GeneratorStatus();
                temp.precipitationMultiplier = 0.0;
                temp.humidityMultiplier = 0.0;
                logicContainer.getLogic(StructureLogic.class).ifPresent(struct -> {
                    struct.getComponents().stream().map(t -> t.getLogic(WaterGeneratorLogic.class)).flatMap(Streams.unwrap()).map(l -> l.status).forEach(s -> {
                        temp.canSeeSky += s.canSeeSky;
                        if (s.canSeeSky > 0) {
                            temp.humidityMultiplier += s.humidityMultiplier;
                            temp.precipitationMultiplier += s.precipitationMultiplier;
                            temp.tempPenalty += s.tempPenalty;
                        }
                    });
                });
                if (temp.canSeeSky > 0) {
                    temp.humidityMultiplier /= temp.canSeeSky;
                    temp.precipitationMultiplier /= temp.canSeeSky;
                }
                temp.writeData(data);
            }

            @Override
            public void readServerSyncData(RailcraftInputStream data) throws IOException {
                super.readServerSyncData(data);
                status.readData(data);
            }

            @Override
            public ToolTip getToolTip() {
                return toolTip;
            }
        };
    return new FluidGaugeWidget(tank, x, y, u, v, w, h);
}
Also used : ToolTip(mods.railcraft.common.gui.tooltips.ToolTip) ToolTipLine(mods.railcraft.common.gui.tooltips.ToolTipLine) ILogicContainer(mods.railcraft.common.blocks.logic.ILogicContainer) ToolTip(mods.railcraft.common.gui.tooltips.ToolTip) FluidGaugeWidget(mods.railcraft.common.gui.widgets.FluidGaugeWidget) TextFormatting(net.minecraft.util.text.TextFormatting) Streams(mods.railcraft.common.util.collections.Streams) IInventoryImplementor(mods.railcraft.common.util.inventory.IInventoryImplementor) IOException(java.io.IOException) InventoryPlayer(net.minecraft.entity.player.InventoryPlayer) StructureLogic(mods.railcraft.common.blocks.logic.StructureLogic) GeneratorStatus(mods.railcraft.common.blocks.logic.WaterGeneratorLogic.GeneratorStatus) RailcraftInputStream(mods.railcraft.common.util.network.RailcraftInputStream) LocalizationPlugin(mods.railcraft.common.plugins.forge.LocalizationPlugin) RailcraftOutputStream(mods.railcraft.common.util.network.RailcraftOutputStream) IContainerListener(net.minecraft.inventory.IContainerListener) WaterGeneratorLogic(mods.railcraft.common.blocks.logic.WaterGeneratorLogic) SlotOutput(mods.railcraft.common.gui.slots.SlotOutput) FluidLogic(mods.railcraft.common.blocks.logic.FluidLogic) StandardTank(mods.railcraft.common.fluids.tanks.StandardTank) SlotRailcraft(mods.railcraft.common.gui.slots.SlotRailcraft) RailcraftInputStream(mods.railcraft.common.util.network.RailcraftInputStream) GeneratorStatus(mods.railcraft.common.blocks.logic.WaterGeneratorLogic.GeneratorStatus) ToolTipLine(mods.railcraft.common.gui.tooltips.ToolTipLine) WaterGeneratorLogic(mods.railcraft.common.blocks.logic.WaterGeneratorLogic) RailcraftOutputStream(mods.railcraft.common.util.network.RailcraftOutputStream) FluidGaugeWidget(mods.railcraft.common.gui.widgets.FluidGaugeWidget) IContainerListener(net.minecraft.inventory.IContainerListener) IOException(java.io.IOException)

Example 2 with FluidGaugeWidget

use of mods.railcraft.common.gui.widgets.FluidGaugeWidget in project Railcraft by Railcraft.

the class ContainerLocomotiveSteamSolid method defineSlotsAndWidgets.

@Override
public void defineSlotsAndWidgets() {
    addWidget(new FluidGaugeWidget(loco.getTankManager().get(0), 53, 23, 176, 0, 16, 47));
    addWidget(new FluidGaugeWidget(loco.getTankManager().get(1), 17, 23, 176, 0, 16, 47));
    addWidget(new IndicatorWidget(loco.boiler.heatIndicator, 40, 25, 176, 61, 6, 43));
    addSlot(new SlotWaterLimited(loco, 0, 152, 20));
    addSlot(new SlotOutput(loco, 1, 152, 56));
    addSlot(new SlotOutput(loco, 2, 116, 56));
    // Burn
    addSlot(new SlotRailcraft(loco, 3, 116, 20));
    // Fuel
    addSlot(new SlotRailcraft(loco, 4, 80, 20));
    // Fuel
    addSlot(new SlotRailcraft(loco, 5, 80, 38));
    // Fuel
    addSlot(new SlotRailcraft(loco, 6, 80, 56));
}
Also used : SlotWaterLimited(mods.railcraft.common.gui.slots.SlotWaterLimited) FluidGaugeWidget(mods.railcraft.common.gui.widgets.FluidGaugeWidget) IndicatorWidget(mods.railcraft.common.gui.widgets.IndicatorWidget) SlotOutput(mods.railcraft.common.gui.slots.SlotOutput) SlotRailcraft(mods.railcraft.common.gui.slots.SlotRailcraft)

Aggregations

SlotOutput (mods.railcraft.common.gui.slots.SlotOutput)2 SlotRailcraft (mods.railcraft.common.gui.slots.SlotRailcraft)2 FluidGaugeWidget (mods.railcraft.common.gui.widgets.FluidGaugeWidget)2 IOException (java.io.IOException)1 FluidLogic (mods.railcraft.common.blocks.logic.FluidLogic)1 ILogicContainer (mods.railcraft.common.blocks.logic.ILogicContainer)1 StructureLogic (mods.railcraft.common.blocks.logic.StructureLogic)1 WaterGeneratorLogic (mods.railcraft.common.blocks.logic.WaterGeneratorLogic)1 GeneratorStatus (mods.railcraft.common.blocks.logic.WaterGeneratorLogic.GeneratorStatus)1 StandardTank (mods.railcraft.common.fluids.tanks.StandardTank)1 SlotWaterLimited (mods.railcraft.common.gui.slots.SlotWaterLimited)1 ToolTip (mods.railcraft.common.gui.tooltips.ToolTip)1 ToolTipLine (mods.railcraft.common.gui.tooltips.ToolTipLine)1 IndicatorWidget (mods.railcraft.common.gui.widgets.IndicatorWidget)1 LocalizationPlugin (mods.railcraft.common.plugins.forge.LocalizationPlugin)1 Streams (mods.railcraft.common.util.collections.Streams)1 IInventoryImplementor (mods.railcraft.common.util.inventory.IInventoryImplementor)1 RailcraftInputStream (mods.railcraft.common.util.network.RailcraftInputStream)1 RailcraftOutputStream (mods.railcraft.common.util.network.RailcraftOutputStream)1 InventoryPlayer (net.minecraft.entity.player.InventoryPlayer)1