Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ dependencies {
implementation("com.github.GTNewHorizons:NotEnoughItems:2.8.105-GTNH:dev")
compileOnly("com.github.GTNewHorizons:Hodgepodge:2.7.165:dev") { transitive = false }

devOnlyNonPublishable("com.github.GTNewHorizons:GT5-Unofficial:5.09.53.07:dev") {
devOnlyNonPublishable("com.github.GTNewHorizons:GT5-Unofficial:5.09.54.27:dev") {
exclude group: 'com.github.GTNewHorizons', module: 'ModularUI2'
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
import java.nio.charset.StandardCharsets;
import java.util.function.Consumer;

import gregtech.api.util.GTUtility;

public class NetworkUtils {

public static final Consumer<PacketBuffer> EMPTY_PACKET = buffer -> {};
Expand Down Expand Up @@ -91,6 +93,7 @@ public static FluidStack readFluidStack(PacketBuffer buffer) {
return null;
}
try {
if (ModularUI.Mods.GT5U.isLoaded()) return GTUtility.loadFluid(buffer.readNBTTagCompoundFromBuffer());
return FluidStack.loadFluidStackFromNBT(buffer.readNBTTagCompoundFromBuffer());
} catch (IOException e) {
ModularUI.LOGGER.catching(e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public void draw(ModularGuiContext context, WidgetThemeEntry<?> widgetTheme) {
int h = getArea().height - this.contentPadding.vertical();
float c = getCapacity();
if (c > 0 && fluid.amount > 0) {
int newH = (int) MathUtils.rescaleLinear(fluid.amount, 0, c, 1, h);
int newH = (int) MathUtils.rescaleLinear(getFluidAmountLong(), 0, c, 1, h);
// 1.12 has a method called isLighterThanAir(), using isGaseous() as a replacement here
if (!this.flipLighterThanAir || !fluid.getFluid().isGaseous()) y += h - newH;
h = newH;
Expand All @@ -61,7 +61,7 @@ public void drawOverlay(ModularGuiContext context, WidgetThemeEntry<?> widgetThe
super.drawOverlay(context, widgetTheme);
FluidStack fluid = getFluidStack();
if (fluid != null && displayAmountText()) {
String s = NumberFormat.format(getBaseUnitAmount(fluid.amount), NumberFormat.AMOUNT_TEXT) + getBaseUnit();
String s = NumberFormat.format(getBaseUnitAmount(getFluidAmountLong()), NumberFormat.AMOUNT_TEXT) + getBaseUnit();
// mc doesn't consider the 1px border in item slots for amount text, but it looks weird when it touches the left border, so
// we only apply padding there
GuiDraw.drawScaledAlignedTextInBox(s, this.contentPadding.getLeft(), 0, getArea().width - this.contentPadding.getLeft(), getArea().height, Alignment.BottomRight);
Expand All @@ -73,6 +73,14 @@ public void drawOverlay(ModularGuiContext context, WidgetThemeEntry<?> widgetThe
@Nullable
protected abstract FluidStack getFluidStack();

protected long getFluidAmountLong() {
FluidStack stack = getFluidStack();
if (stack == null) return 0;

if (ModularUI.Mods.GT5U.isLoaded()) return GTUtility.getFluidAmount(stack);
return stack.amount;
};

@Override
public @Nullable ItemStack getStackForRecipeViewer() {
if (ModularUI.Mods.GT5U.isLoaded()) {
Expand Down
Loading