mirror of
https://github.com/Thorfusion/Mekanism-Community-Edition.git
synced 2026-11-26 14:52:58 +00:00
some turbine nullable fluidstack fixes. Closes #5485
This commit is contained in:
1 parent
959f7e994f
commit
65ed1cf062
5 files changed
+37
-25
No files matched your search
@@ -2,6 +2,7 @@ package mekanism.common.tile;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import mekanism.api.Coord4D;
|
||||
import mekanism.api.Range4D;
|
||||
import mekanism.api.TileNetworkList;
|
||||
@@ -33,6 +34,7 @@ public abstract class TileEntityMultiblock<T extends SynchronizedData<T>> extend
|
||||
/**
|
||||
* The multiblock data for this structure.
|
||||
*/
|
||||
@Nullable
|
||||
public T structure;
|
||||
|
||||
/**
|
||||
@@ -63,6 +65,7 @@ public abstract class TileEntityMultiblock<T extends SynchronizedData<T>> extend
|
||||
/**
|
||||
* This multiblock segment's cached inventory ID
|
||||
*/
|
||||
@Nullable
|
||||
public String cachedID = null;
|
||||
|
||||
public TileEntityMultiblock(String name) {
|
||||
|
||||
@@ -66,23 +66,25 @@ public class GuiIndustrialTurbine extends GuiEmbeddedGaugeTile<TileEntityTurbine
|
||||
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) {
|
||||
fontRenderer.drawString(LangUtils.localize("container.inventory"), 8, (ySize - 96) + 4, 0x404040);
|
||||
fontRenderer.drawString(tileEntity.getName(), (xSize / 2) - (fontRenderer.getStringWidth(tileEntity.getName()) / 2), 5, 0x404040);
|
||||
double energyMultiplier = (MekanismConfig.current().general.maxEnergyPerSteam.val() / TurbineUpdateProtocol.MAX_BLADES) *
|
||||
Math.min(tileEntity.structure.blades, tileEntity.structure.coils * MekanismConfig.current().generators.turbineBladesPerCoil.val());
|
||||
double rate = tileEntity.structure.lowerVolume * (tileEntity.structure.clientDispersers * MekanismConfig.current().generators.turbineDisperserGasFlow.val());
|
||||
rate = Math.min(rate, tileEntity.structure.vents * MekanismConfig.current().generators.turbineVentGasFlow.val());
|
||||
renderScaledText(LangUtils.localize("gui.production") + ": " +
|
||||
MekanismUtils.getEnergyDisplay(tileEntity.structure.clientFlow * energyMultiplier), 53, 26, 0x00CD00, 106);
|
||||
renderScaledText(LangUtils.localize("gui.flowRate") + ": " + tileEntity.structure.clientFlow + " mB/t", 53, 35, 0x00CD00, 106);
|
||||
renderScaledText(LangUtils.localize("gui.capacity") + ": " + tileEntity.structure.getFluidCapacity() + " mB", 53, 44, 0x00CD00, 106);
|
||||
renderScaledText(LangUtils.localize("gui.maxFlow") + ": " + rate + " mB/t", 53, 53, 0x00CD00, 106);
|
||||
String name = chooseByMode(tileEntity.structure.dumpMode, LangUtils.localize("gui.idle"), LangUtils.localize("gui.dumping"), LangUtils.localize("gui.dumping_excess"));
|
||||
renderScaledText(name, 156 - (int) (fontRenderer.getStringWidth(name) * getNeededScale(name, 66)), 73, 0x404040, 66);
|
||||
int xAxis = mouseX - (width - xSize) / 2;
|
||||
int yAxis = mouseY - (height - ySize) / 2;
|
||||
if (xAxis >= 7 && xAxis <= 39 && yAxis >= 14 && yAxis <= 72) {
|
||||
drawHoveringText(tileEntity.structure.fluidStored != null
|
||||
? LangUtils.localizeFluidStack(tileEntity.structure.fluidStored) + ": " + tileEntity.structure.fluidStored.amount + "mB"
|
||||
: LangUtils.localize("gui.empty"), xAxis, yAxis);
|
||||
if (tileEntity.structure != null) {
|
||||
double energyMultiplier = (MekanismConfig.current().general.maxEnergyPerSteam.val() / TurbineUpdateProtocol.MAX_BLADES) *
|
||||
Math.min(tileEntity.structure.blades, tileEntity.structure.coils * MekanismConfig.current().generators.turbineBladesPerCoil.val());
|
||||
double rate = tileEntity.structure.lowerVolume * (tileEntity.structure.clientDispersers * MekanismConfig.current().generators.turbineDisperserGasFlow.val());
|
||||
rate = Math.min(rate, tileEntity.structure.vents * MekanismConfig.current().generators.turbineVentGasFlow.val());
|
||||
renderScaledText(LangUtils.localize("gui.production") + ": " +
|
||||
MekanismUtils.getEnergyDisplay(tileEntity.structure.clientFlow * energyMultiplier), 53, 26, 0x00CD00, 106);
|
||||
renderScaledText(LangUtils.localize("gui.flowRate") + ": " + tileEntity.structure.clientFlow + " mB/t", 53, 35, 0x00CD00, 106);
|
||||
renderScaledText(LangUtils.localize("gui.capacity") + ": " + tileEntity.structure.getFluidCapacity() + " mB", 53, 44, 0x00CD00, 106);
|
||||
renderScaledText(LangUtils.localize("gui.maxFlow") + ": " + rate + " mB/t", 53, 53, 0x00CD00, 106);
|
||||
String name = chooseByMode(tileEntity.structure.dumpMode, LangUtils.localize("gui.idle"), LangUtils.localize("gui.dumping"), LangUtils.localize("gui.dumping_excess"));
|
||||
renderScaledText(name, 156 - (int) (fontRenderer.getStringWidth(name) * getNeededScale(name, 66)), 73, 0x404040, 66);
|
||||
int xAxis = mouseX - (width - xSize) / 2;
|
||||
int yAxis = mouseY - (height - ySize) / 2;
|
||||
if (xAxis >= 7 && xAxis <= 39 && yAxis >= 14 && yAxis <= 72) {
|
||||
drawHoveringText(tileEntity.structure.fluidStored != null
|
||||
? LangUtils.localizeFluidStack(tileEntity.structure.fluidStored) + ": " + tileEntity.structure.fluidStored.amount + "mB"
|
||||
: LangUtils.localize("gui.empty"), xAxis, yAxis);
|
||||
}
|
||||
}
|
||||
super.drawGuiContainerForegroundLayer(mouseX, mouseY);
|
||||
}
|
||||
@@ -94,12 +96,14 @@ public class GuiIndustrialTurbine extends GuiEmbeddedGaugeTile<TileEntityTurbine
|
||||
int guiWidth = (width - xSize) / 2;
|
||||
int guiHeight = (height - ySize) / 2;
|
||||
drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize);
|
||||
int displayInt = chooseByMode(tileEntity.structure.dumpMode, 142, 150, 158);
|
||||
drawTexturedModalRect(guiWidth + 160, guiHeight + 73, 176, displayInt, 8, 8);
|
||||
int scaledFluidLevel = tileEntity.getScaledFluidLevel(58);
|
||||
if (scaledFluidLevel > 0) {
|
||||
displayGauge(7, 14, scaledFluidLevel, tileEntity.structure.fluidStored, 0);
|
||||
displayGauge(23, 14, scaledFluidLevel, tileEntity.structure.fluidStored, 1);
|
||||
if (tileEntity.structure != null) {
|
||||
int displayInt = chooseByMode(tileEntity.structure.dumpMode, 142, 150, 158);
|
||||
drawTexturedModalRect(guiWidth + 160, guiHeight + 73, 176, displayInt, 8, 8);
|
||||
int scaledFluidLevel = tileEntity.getScaledFluidLevel(58);
|
||||
if (scaledFluidLevel > 0) {
|
||||
displayGauge(7, 14, scaledFluidLevel, tileEntity.structure.fluidStored, 0);
|
||||
displayGauge(23, 14, scaledFluidLevel, tileEntity.structure.fluidStored, 1);
|
||||
}
|
||||
}
|
||||
super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY);
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package mekanism.generators.common.content.turbine;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import javax.annotation.Nullable;
|
||||
import mekanism.api.Coord4D;
|
||||
import mekanism.common.multiblock.SynchronizedData;
|
||||
import mekanism.common.tile.TileEntityGasTank.GasMode;
|
||||
@@ -11,6 +12,8 @@ public class SynchronizedTurbineData extends SynchronizedData<SynchronizedTurbin
|
||||
|
||||
public static final float ROTATION_THRESHOLD = 0.001F;
|
||||
public static Map<String, Float> clientRotationMap = new HashMap<>();
|
||||
|
||||
@Nullable
|
||||
public FluidStack fluidStored;
|
||||
|
||||
public FluidStack prevFluid;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package mekanism.generators.common.content.turbine;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import mekanism.common.util.MekanismUtils;
|
||||
import mekanism.generators.common.tile.turbine.TileEntityTurbineCasing;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
@@ -15,6 +16,7 @@ public class TurbineFluidTank implements IFluidTank {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public FluidStack getFluid() {
|
||||
return turbine.structure != null ? turbine.structure.fluidStored : null;
|
||||
}
|
||||
@@ -109,7 +111,7 @@ public class TurbineFluidTank implements IFluidTank {
|
||||
|
||||
@Override
|
||||
public int getFluidAmount() {
|
||||
if (turbine.structure != null) {
|
||||
if (turbine.structure != null && turbine.structure.fluidStored != null) {
|
||||
return turbine.structure.fluidStored.amount;
|
||||
}
|
||||
return 0;
|
||||
|
||||
@@ -140,7 +140,7 @@ public class TileEntityTurbineCasing extends TileEntityMultiblock<SynchronizedTu
|
||||
}
|
||||
|
||||
public int getScaledFluidLevel(long i) {
|
||||
if (structure.getFluidCapacity() == 0 || structure.fluidStored == null) {
|
||||
if (structure == null || structure.getFluidCapacity() == 0 || structure.fluidStored == null) {
|
||||
return 0;
|
||||
}
|
||||
return (int) (structure.fluidStored.amount * i / structure.getFluidCapacity());
|
||||
|
||||
Reference in new issue
Block a user