From 9c9abed991edd1e346faf68b8ca2a31cfd408517 Mon Sep 17 00:00:00 2001 From: screret <68943070+screret@users.noreply.github.com> Date: Sun, 31 Mar 2024 15:43:25 +0300 Subject: [PATCH] fix error on client when opening multiblock UI for the first time --- CHANGELOG.md | 19 ++----------------- .../feature/multiblock/IDisplayUIMachine.java | 1 + .../WorkableElectricMultiblockMachine.java | 8 ++++---- 3 files changed, 7 insertions(+), 21 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e34af40d54..1054244661 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,25 +1,10 @@ # ChangeLog -Version: 1.1.4.a +Version: 1.1.4.b ### ADDITIONS: -- added more wiremill recipes for different wire sizes -- made rubber saplings & leaves compostable -- made spray paint able to paint multiple blocks in a chain if crouching -- added ability to use block/fluid tags in multiblock patterns ### FIXES: -- fix AMD driver error in LDlib -- fixed bucket model -- fixed PA accepting multiblock machines -- fixed fluid pipes crashing when connected to other mods' blocks -- fixed large DT outputs not being ordered -- fixed wooden brick form disappearing after use -- fixed pyrolyse oven not getting bonuses if recipe didn't overclock -- fixed shovels crashing if somehow used to path air -- fixed full spray paint cans rendering the bar as empty +- fixed client error when opening multiblock UI for the first time ### CHANGES: -- ported multi-amp energy hatches not giving overclocks. You now always need 2 energy hatches for an overclock. -- made dynamic data- and resourcepacks appear in the pack list(s) -- Use a grid-based UI for the multiblock part switcher diff --git a/src/main/java/com/gregtechceu/gtceu/api/machine/feature/multiblock/IDisplayUIMachine.java b/src/main/java/com/gregtechceu/gtceu/api/machine/feature/multiblock/IDisplayUIMachine.java index cf3477ebfc..522ba3afb5 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/machine/feature/multiblock/IDisplayUIMachine.java +++ b/src/main/java/com/gregtechceu/gtceu/api/machine/feature/multiblock/IDisplayUIMachine.java @@ -41,6 +41,7 @@ default ModularUI createUI(Player entityPlayer) { var screen = new DraggableScrollableWidgetGroup(7, 4, 162, 121).setBackground(getScreenTexture()); screen.addWidget(new LabelWidget(4, 5, self().getBlockState().getBlock().getDescriptionId())); screen.addWidget(new ComponentPanelWidget(4, 17, this::addDisplayText) + .textSupplier(this.self().getLevel().isClientSide ? null : this::addDisplayText) .setMaxWidthLimit(150) .clickHandler(this::handleDisplayClick)); return new ModularUI(176, 216, this, entityPlayer) diff --git a/src/main/java/com/gregtechceu/gtceu/api/machine/multiblock/WorkableElectricMultiblockMachine.java b/src/main/java/com/gregtechceu/gtceu/api/machine/multiblock/WorkableElectricMultiblockMachine.java index 5c227a2455..32c6db6642 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/machine/multiblock/WorkableElectricMultiblockMachine.java +++ b/src/main/java/com/gregtechceu/gtceu/api/machine/multiblock/WorkableElectricMultiblockMachine.java @@ -20,10 +20,8 @@ import com.gregtechceu.gtceu.utils.GTUtil; import com.lowdragmc.lowdraglib.gui.modular.ModularUI; import com.lowdragmc.lowdraglib.gui.widget.*; -import net.minecraft.ChatFormatting; import net.minecraft.MethodsReturnNonnullByDefault; import net.minecraft.network.chat.Component; -import net.minecraft.network.chat.Style; import net.minecraft.world.entity.player.Player; import javax.annotation.ParametersAreNonnullByDefault; @@ -97,6 +95,7 @@ public Widget createUIWidget() { group.addWidget(new DraggableScrollableWidgetGroup(4, 4, 182, 117).setBackground(getScreenTexture()) .addWidget(new LabelWidget(4, 5, self().getBlockState().getBlock().getDescriptionId())) .addWidget(new ComponentPanelWidget(4, 17, this::addDisplayText) + .textSupplier(this.getLevel().isClientSide ? null : this::addDisplayText) .setMaxWidthLimit(150) .clickHandler(this::handleDisplayClick))); group.setBackground(GuiTextures.BACKGROUND_INVERSE); @@ -146,7 +145,9 @@ public void setOverclockTier(int tier) { @Override public long getOverclockVoltage() { - IEnergyContainer energyContainer = this.energyContainer; + if (this.energyContainer == null) { + this.energyContainer = getEnergyContainer(); + } if (energyContainer instanceof EnergyContainerList) { long voltage; long amperage; @@ -208,7 +209,6 @@ public IEnergyContainer getEnergyContainer() { } public long getMaxVoltage() { - IEnergyContainer energyContainer = this.energyContainer; if (this.energyContainer == null) { this.energyContainer = getEnergyContainer(); }