use of mods.railcraft.common.blocks.logic.WaterGeneratorLogic.GeneratorStatus 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);
}
Aggregations