diff --git a/.gitignore b/.gitignore index c2fb66e1e33..3b2f04a46c0 100644 --- a/.gitignore +++ b/.gitignore @@ -74,6 +74,7 @@ local.properties /classes/ /out/ /build/ +.run/ # Linux *~ diff --git a/dependencies.gradle b/dependencies.gradle index 6a45ca2165f..112c8e2d2c9 100644 --- a/dependencies.gradle +++ b/dependencies.gradle @@ -40,9 +40,10 @@ dependencies { // Published dependencies api("codechicken:codechickenlib:3.2.3.358") - api("com.cleanroommc:modularui:2.5.0-rc4") { transitive = false } + api("com.cleanroommc:modularui:3.0.4") { transitive = false } api("com.cleanroommc:groovyscript:1.2.0-hotfix1") { transitive = false } - api("curse.maven:inventory-bogosorter-632327:4951607-deobf-4951608-sources-4951609") + api("curse.maven:inventory-bogosorter-632327:7102721-deobf-6717233-sources-6717234") // Inventory BogoSorter − v1.5.0 + api("curse.maven:key-binding-patch-928895:5951859") // Key Binding Patch v1.3.3.3, needed by Inventory BogoSorter v1.5.0+ api("CraftTweaker2:CraftTweaker2-MC1120-Main:1.12-4.1.20.700") api("appeng:ae2-uel:v0.56.4") { transitive = false } api rfg.deobf("curse.maven:ctm-267602:2915363") // CTM 1.0.2.31 diff --git a/src/main/java/gregtech/GregTechMod.java b/src/main/java/gregtech/GregTechMod.java index 5334d5afe13..4ae0d0745c2 100644 --- a/src/main/java/gregtech/GregTechMod.java +++ b/src/main/java/gregtech/GregTechMod.java @@ -31,7 +31,7 @@ acceptedMinecraftVersions = "[1.12.2,1.13)", version = GTInternalTags.VERSION, dependencies = "required:forge@[14.23.5.2847,);" + "required-after:codechickenlib@[3.2.3,);" + - "required-after:modularui@[2.5.0-rc,);" + "required-after:mixinbooter@[8.0,);" + + "required-after:modularui@[3.0.4,);" + "required-after:mixinbooter@[8.0,);" + "after:appliedenergistics2;" + "after:forestry;" + "after:extrabees;" + "after:extratrees;" + "after:genetics;" + "after:magicbees;" + "after:jei@[4.15.0,);" + "after:crafttweaker@[4.1.20,);" + "after:groovyscript@[1.2.0,);" + diff --git a/src/main/java/gregtech/api/cover/CoverWithUI.java b/src/main/java/gregtech/api/cover/CoverWithUI.java index 6c288e08137..8802f23fc2f 100644 --- a/src/main/java/gregtech/api/cover/CoverWithUI.java +++ b/src/main/java/gregtech/api/cover/CoverWithUI.java @@ -21,6 +21,7 @@ import com.cleanroommc.modularui.factory.SidedPosGuiData; import com.cleanroommc.modularui.screen.ModularPanel; import com.cleanroommc.modularui.screen.ModularScreen; +import com.cleanroommc.modularui.screen.UISettings; import com.cleanroommc.modularui.utils.Alignment; import com.cleanroommc.modularui.utils.Color; import com.cleanroommc.modularui.utils.MouseData; @@ -65,7 +66,7 @@ default GTGuiTheme getUITheme() { } @Override - default ModularPanel buildUI(SidedPosGuiData guiData, PanelSyncManager guiSyncManager) { + default ModularPanel buildUI(SidedPosGuiData guiData, PanelSyncManager guiSyncManager, UISettings settings) { return null; } diff --git a/src/main/java/gregtech/api/items/gui/ItemUIFactory.java b/src/main/java/gregtech/api/items/gui/ItemUIFactory.java index 6633e96bb8b..f1444152f5f 100644 --- a/src/main/java/gregtech/api/items/gui/ItemUIFactory.java +++ b/src/main/java/gregtech/api/items/gui/ItemUIFactory.java @@ -13,6 +13,7 @@ import com.cleanroommc.modularui.factory.HandGuiData; import com.cleanroommc.modularui.screen.ModularPanel; import com.cleanroommc.modularui.screen.ModularScreen; +import com.cleanroommc.modularui.screen.UISettings; import com.cleanroommc.modularui.value.sync.PanelSyncManager; import org.jetbrains.annotations.ApiStatus; @@ -39,7 +40,7 @@ default GTGuiTheme getUITheme() { } @Override - default ModularPanel buildUI(HandGuiData guiData, PanelSyncManager guiSyncManager) { + default ModularPanel buildUI(HandGuiData guiData, PanelSyncManager guiSyncManager, UISettings settings) { return null; } } diff --git a/src/main/java/gregtech/api/items/toolitem/IGTTool.java b/src/main/java/gregtech/api/items/toolitem/IGTTool.java index 679b22118b3..d37e8ec3643 100644 --- a/src/main/java/gregtech/api/items/toolitem/IGTTool.java +++ b/src/main/java/gregtech/api/items/toolitem/IGTTool.java @@ -72,11 +72,11 @@ import com.cleanroommc.modularui.factory.HandGuiData; import com.cleanroommc.modularui.factory.ItemGuiFactory; import com.cleanroommc.modularui.screen.ModularPanel; +import com.cleanroommc.modularui.screen.UISettings; import com.cleanroommc.modularui.utils.Alignment; import com.cleanroommc.modularui.value.sync.IntSyncValue; import com.cleanroommc.modularui.value.sync.PanelSyncManager; import com.cleanroommc.modularui.widgets.ButtonWidget; -import com.cleanroommc.modularui.widgets.TextWidget; import com.cleanroommc.modularui.widgets.layout.Flow; import com.enderio.core.common.interfaces.IOverlayRenderAware; import com.google.common.collect.HashMultimap; @@ -947,7 +947,7 @@ default void playSound(EntityPlayer player) { } @Override - default ModularPanel buildUI(HandGuiData guiData, PanelSyncManager manager) { + default ModularPanel buildUI(HandGuiData guiData, PanelSyncManager manager, UISettings settings) { final var usedStack = guiData.getUsedItemStack(); final var behaviorsTag = getBehaviorsTag(usedStack); final var defaultDefinition = getMaxAoEDefinition(usedStack); @@ -1006,14 +1006,15 @@ default Flow createColumn(IntSyncValue syncValue, String lang, boolean shouldDou return Flow.column() .coverChildren() - .child(new TextWidget(IKey.lang("item.gt.tool.aoe." + lang)) + .child(IKey.lang("item.gt.tool.aoe." + lang) + .asWidget() .marginBottom(5)) .child(Flow.row() .coverChildren() .marginBottom(5) .child(increaseButton) .child(decreaseButton)) - .child(new TextWidget(display) + .child(display.asWidget() .alignment(Alignment.Center) .widthRel(1f)); } diff --git a/src/main/java/gregtech/api/items/toolitem/ItemGTToolbelt.java b/src/main/java/gregtech/api/items/toolitem/ItemGTToolbelt.java index 6d28d550b2f..6f0fd069c92 100644 --- a/src/main/java/gregtech/api/items/toolitem/ItemGTToolbelt.java +++ b/src/main/java/gregtech/api/items/toolitem/ItemGTToolbelt.java @@ -51,10 +51,11 @@ import com.cleanroommc.modularui.api.drawable.IKey; import com.cleanroommc.modularui.factory.HandGuiData; import com.cleanroommc.modularui.screen.ModularPanel; +import com.cleanroommc.modularui.screen.UISettings; import com.cleanroommc.modularui.value.sync.PanelSyncManager; import com.cleanroommc.modularui.value.sync.SyncHandlers; -import com.cleanroommc.modularui.widgets.ItemSlot; import com.cleanroommc.modularui.widgets.layout.Grid; +import com.cleanroommc.modularui.widgets.slot.ItemSlot; import com.cleanroommc.modularui.widgets.slot.SlotGroup; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Multimap; @@ -106,12 +107,12 @@ public ItemStack getToolInSlot(@NotNull ItemStack toolbelt, int slot) { } @Override - public ModularPanel buildUI(HandGuiData guiData, PanelSyncManager guiSyncManager) { + public ModularPanel buildUI(HandGuiData guiData, PanelSyncManager guiSyncManager, UISettings settings) { final var usedStack = guiData.getUsedItemStack(); final var handler = getHandler(usedStack); final var selected = handler.getSelectedStack(); if (!selected.isEmpty() && selected.getItem() instanceof ItemUIFactory factory) { - return factory.buildUI(guiData, guiSyncManager); + return factory.buildUI(guiData, guiSyncManager, settings); } int heightBonus = (handler.getSlots() / 9) * 18; diff --git a/src/main/java/gregtech/api/metatileentity/MetaTileEntity.java b/src/main/java/gregtech/api/metatileentity/MetaTileEntity.java index e4d93026f8f..e3ca9cab534 100644 --- a/src/main/java/gregtech/api/metatileentity/MetaTileEntity.java +++ b/src/main/java/gregtech/api/metatileentity/MetaTileEntity.java @@ -94,6 +94,7 @@ import com.cleanroommc.modularui.factory.PosGuiData; import com.cleanroommc.modularui.screen.ModularPanel; import com.cleanroommc.modularui.screen.ModularScreen; +import com.cleanroommc.modularui.screen.UISettings; import com.cleanroommc.modularui.value.sync.PanelSyncManager; import com.google.common.base.Preconditions; import it.unimi.dsi.fastutil.ints.Int2ObjectMap; @@ -493,7 +494,7 @@ public GTGuiTheme getUITheme() { } @Override - public ModularPanel buildUI(PosGuiData guiData, PanelSyncManager panelSyncManager) { + public ModularPanel buildUI(PosGuiData guiData, PanelSyncManager panelSyncManager, UISettings settings) { return null; } diff --git a/src/main/java/gregtech/api/metatileentity/multiblock/MultiblockWithDisplayBase.java b/src/main/java/gregtech/api/metatileentity/multiblock/MultiblockWithDisplayBase.java index 1f31dce42a0..165e2ca69df 100644 --- a/src/main/java/gregtech/api/metatileentity/multiblock/MultiblockWithDisplayBase.java +++ b/src/main/java/gregtech/api/metatileentity/multiblock/MultiblockWithDisplayBase.java @@ -25,6 +25,7 @@ import com.cleanroommc.modularui.factory.PosGuiData; import com.cleanroommc.modularui.screen.ModularPanel; +import com.cleanroommc.modularui.screen.UISettings; import com.cleanroommc.modularui.value.sync.PanelSyncManager; import org.jetbrains.annotations.NotNull; @@ -394,7 +395,7 @@ protected MultiblockUIFactory createUIFactory() { } @Override - public final ModularPanel buildUI(PosGuiData guiData, PanelSyncManager panelSyncManager) { + public final ModularPanel buildUI(PosGuiData guiData, PanelSyncManager panelSyncManager, UISettings settings) { if (uiFactory == null) uiFactory = createUIFactory(); return this.uiFactory.buildUI(guiData, panelSyncManager); } diff --git a/src/main/java/gregtech/api/metatileentity/multiblock/ui/MultiblockUIBuilder.java b/src/main/java/gregtech/api/metatileentity/multiblock/ui/MultiblockUIBuilder.java index 2dd58a00df4..535d1460519 100644 --- a/src/main/java/gregtech/api/metatileentity/multiblock/ui/MultiblockUIBuilder.java +++ b/src/main/java/gregtech/api/metatileentity/multiblock/ui/MultiblockUIBuilder.java @@ -108,7 +108,7 @@ public MultiblockUIBuilder structureFormed(boolean structureFormed) { } public MultiblockUIBuilder title(String lang) { - addKey(KeyUtil.lang(TextFormatting.WHITE, lang)); + addOperation(Operation.addLine(KeyUtil.lang(TextFormatting.WHITE, lang)).spaceLine(2)); return this; } diff --git a/src/main/java/gregtech/api/metatileentity/multiblock/ui/MultiblockUIFactory.java b/src/main/java/gregtech/api/metatileentity/multiblock/ui/MultiblockUIFactory.java index 495a80a8aa8..bdd21a36b27 100644 --- a/src/main/java/gregtech/api/metatileentity/multiblock/ui/MultiblockUIFactory.java +++ b/src/main/java/gregtech/api/metatileentity/multiblock/ui/MultiblockUIFactory.java @@ -247,7 +247,7 @@ public MultiblockUIFactory addScreenChildren(ScreenFunction function) { this.screenFunction.addWidgets(panel, panelSyncManager); } - var playerInv = SlotGroupWidget.playerInventory(0); + var playerInv = SlotGroupWidget.playerInventory(false); if (disableButtons) { playerInv.alignX(0.5f); } else { @@ -360,7 +360,7 @@ protected Widget createScreen(PanelSyncManager syncManager) { .debugName("display_text") .sizeRel(1f) .alignment(Alignment.TopLeft) - .margin(4, 4) + .margin(4) .autoUpdate(true) .textBuilder(display::build)); } diff --git a/src/main/java/gregtech/api/metatileentity/multiblock/ui/Operation.java b/src/main/java/gregtech/api/metatileentity/multiblock/ui/Operation.java index 48736198a35..3ea3178b358 100644 --- a/src/main/java/gregtech/api/metatileentity/multiblock/ui/Operation.java +++ b/src/main/java/gregtech/api/metatileentity/multiblock/ui/Operation.java @@ -20,7 +20,7 @@ static Operation add(IDrawable drawable) { } static Operation addLineSpace(IDrawable drawable) { - return addLine(drawable).spaceLine(2); + return addLine(drawable).spaceLine(1); } @Override diff --git a/src/main/java/gregtech/api/metatileentity/multiblock/ui/UISyncer.java b/src/main/java/gregtech/api/metatileentity/multiblock/ui/UISyncer.java index dd90d7cd367..d539904eae2 100644 --- a/src/main/java/gregtech/api/metatileentity/multiblock/ui/UISyncer.java +++ b/src/main/java/gregtech/api/metatileentity/multiblock/ui/UISyncer.java @@ -102,7 +102,7 @@ default float syncFloat(float initial) { } default BigInteger syncBigInt(BigInteger initial) { - return syncObject(initial, GTByteBufAdapters.BIG_INT); + return syncObject(initial, ByteBufAdapters.BIG_INT); } default T syncObject(T initial, IByteBufSerializer serializer, IByteBufDeserializer deserializer) { diff --git a/src/main/java/gregtech/api/mui/GTByteBufAdapters.java b/src/main/java/gregtech/api/mui/GTByteBufAdapters.java index 8ace8f6a5f3..8f286097c98 100644 --- a/src/main/java/gregtech/api/mui/GTByteBufAdapters.java +++ b/src/main/java/gregtech/api/mui/GTByteBufAdapters.java @@ -11,7 +11,6 @@ import org.jetbrains.annotations.NotNull; import java.io.IOException; -import java.math.BigInteger; import java.util.Objects; public class GTByteBufAdapters { @@ -22,10 +21,6 @@ public class GTByteBufAdapters { public static final IByteBufAdapter CHANCED_FLUID_OUTPUT = makeAdapter( ChancedFluidOutput::fromBuffer, ChancedFluidOutput::toBuffer); - public static final IByteBufAdapter BIG_INT = makeAdapter( - buffer -> new BigInteger(buffer.readByteArray()), - (buffer, value) -> buffer.writeByteArray(value.toByteArray())); - public static final IByteBufAdapter FLUID = makeAdapter(NetworkUtil::readFluid, NetworkUtil::writeFluid); public static IByteBufAdapter makeAdapter(@NotNull IByteBufDeserializer deserializer, diff --git a/src/main/java/gregtech/api/mui/GTGuiTextures.java b/src/main/java/gregtech/api/mui/GTGuiTextures.java index 3249bee06df..998ad9c1d03 100644 --- a/src/main/java/gregtech/api/mui/GTGuiTextures.java +++ b/src/main/java/gregtech/api/mui/GTGuiTextures.java @@ -4,11 +4,13 @@ import com.cleanroommc.modularui.api.drawable.IDrawable; import com.cleanroommc.modularui.api.drawable.IKey; +import com.cleanroommc.modularui.drawable.ColorType; import com.cleanroommc.modularui.drawable.UITexture; import com.cleanroommc.modularui.screen.viewport.GuiContext; import com.cleanroommc.modularui.theme.WidgetTheme; import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * GT MUI textures.
@@ -58,11 +60,9 @@ private static String id(String path) { public static final UITexture GREGTECH_LOGO_XMAS = fullImage("textures/gui/icon/gregtech_logo_xmas.png"); public static final UITexture GREGTECH_LOGO_DARK = fullImage("textures/gui/icon/gregtech_logo_dark.png"); public static final IDrawable GREGTECH_LOGO_BLINKING_YELLOW = animated( - "textures/gui/icon/gregtech_logo_blinking_yellow.png", - 17, 34, false, 60); + "textures/gui/icon/gregtech_logo_blinking_yellow.png", 17, 34, 60); public static final IDrawable GREGTECH_LOGO_BLINKING_RED = animated( - "textures/gui/icon/gregtech_logo_blinking_red.png", - 17, 34, false, 36); + "textures/gui/icon/gregtech_logo_blinking_red.png", 17, 34, 36); public static final UITexture INDICATOR_NO_ENERGY = fullImage("textures/gui/base/indicator_no_energy.png"); public static final UITexture INDICATOR_NO_STEAM_BRONZE = fullImage( @@ -209,18 +209,18 @@ private static String id(String path) { "textures/gui/widget/hpca/damaged_computation_component.png"); public static final UITexture[] BUTTON_BLACKLIST = slice("textures/gui/widget/button_blacklist.png", - 16, 32, 16, 16, true); + 16, 32, 16, 16, ColorType.DEFAULT); public static final UITexture[] BUTTON_IGNORE_DAMAGE = slice("textures/gui/widget/button_filter_damage.png", - 16, 32, 16, 16, true); + 16, 32, 16, 16, ColorType.DEFAULT); public static final UITexture[] BUTTON_IGNORE_NBT = slice("textures/gui/widget/button_filter_nbt.png", - 16, 32, 16, 16, true); + 16, 32, 16, 16, ColorType.DEFAULT); public static final UITexture[] BUTTON_CASE_SENSITIVE = slice( "textures/gui/widget/ore_filter/button_case_sensitive.png", - 16, 32, 16, 16, true); + 16, 32, 16, 16, ColorType.DEFAULT); public static final UITexture[] BUTTON_MATCH_ALL = slice("textures/gui/widget/ore_filter/button_match_all.png", - 16, 32, 16, 16, true); + 16, 32, 16, 16, ColorType.DEFAULT); public static final UITexture BUTTON_LOCK = fullImage("textures/gui/widget/button_lock.png"); public static final UITexture OREDICT_ERROR = fullImage("textures/gui/widget/ore_filter/error.png"); @@ -235,34 +235,34 @@ private static String id(String path) { public static final IDrawable MINUS = IKey.str("-").asIcon().marginLeft(1); public static final UITexture[] MANUAL_IO_OVERLAY_IN = slice("textures/gui/overlay/manual_io_overlay_in.png", - 18, 18 * 3, 18, 18, true); + 18, 18 * 3, 18, 18, ColorType.DEFAULT); public static final UITexture[] MANUAL_IO_OVERLAY_OUT = slice("textures/gui/overlay/manual_io_overlay_out.png", - 18, 18 * 3, 18, 18, true); + 18, 18 * 3, 18, 18, ColorType.DEFAULT); public static final UITexture[] CONVEYOR_MODE_OVERLAY = slice("textures/gui/overlay/conveyor_mode_overlay.png", - 18, 18 * 2, 18, 18, true); + 18, 18 * 2, 18, 18, ColorType.DEFAULT); public static final UITexture[] TRANSFER_MODE_OVERLAY = slice("textures/gui/overlay/transfer_mode_overlay.png", - 18, 18 * 3, 18, 18, true); + 18, 18 * 3, 18, 18, ColorType.DEFAULT); public static final UITexture[] FLUID_TRANSFER_MODE_OVERLAY = slice( "textures/gui/overlay/fluid_transfer_mode_overlay.png", - 18, 18 * 3, 18, 18, true); + 18, 18 * 3, 18, 18, ColorType.DEFAULT); public static final UITexture[] DISTRIBUTION_MODE_OVERLAY = slice( "textures/gui/widget/button_distribution_mode.png", - 16, 48, 16, 16, true); + 16, 48, 16, 16, ColorType.DEFAULT); public static final UITexture[] VOIDING_MODE_OVERLAY = slice( "textures/gui/overlay/voiding_mode_overlay.png", - 16, 32, 16, 16, true); + 16, 32, 16, 16, ColorType.DEFAULT); public static final UITexture[] FILTER_MODE_OVERLAY = slice( "textures/gui/overlay/filter_mode_overlay.png", - 16, 48, 16, 16, true); + 16, 48, 16, 16, ColorType.DEFAULT); public static final UITexture[] PRIVATE_MODE_BUTTON = slice( "textures/gui/widget/button_public_private.png", - 18, 36, 18, 18, true); + 18, 36, 18, 18, ColorType.DEFAULT); public static final UITexture MENU_OVERLAY = fullImage("textures/gui/overlay/menu_overlay.png"); @@ -283,118 +283,180 @@ private static String id(String path) { public static final UITexture PRIMITIVE_BLAST_FURNACE_PROGRESS_BAR = fullImage( "textures/gui/primitive/progress_bar_primitive_blast_furnace.png"); - public static final UITexture FLUID_VOID_OVERLAY = fullImage("textures/gui/widget/button_fluid_void.png", true); - public static final UITexture ITEM_VOID_OVERLAY = fullImage("textures/gui/widget/button_item_void.png", true); - public static final UITexture FLUID_LOCK_OVERLAY = fullImage("textures/gui/widget/button_lock.png", true); + public static final UITexture FLUID_VOID_OVERLAY = fullImage("textures/gui/widget/button_fluid_void.png", + ColorType.DEFAULT); + public static final UITexture ITEM_VOID_OVERLAY = fullImage("textures/gui/widget/button_item_void.png", + ColorType.DEFAULT); + public static final UITexture FLUID_LOCK_OVERLAY = fullImage("textures/gui/widget/button_lock.png", + ColorType.DEFAULT); // todo bronze/steel/primitive fluid slots? // SLOT OVERLAYS - public static final UITexture ATOMIC_OVERLAY_1 = fullImage("textures/gui/overlay/atomic_overlay_1.png", true); - public static final UITexture ATOMIC_OVERLAY_2 = fullImage("textures/gui/overlay/atomic_overlay_2.png", true); - public static final UITexture ARROW_INPUT_OVERLAY = fullImage("textures/gui/overlay/arrow_input_overlay.png", true); + public static final UITexture ATOMIC_OVERLAY_1 = fullImage("textures/gui/overlay/atomic_overlay_1.png", + ColorType.DEFAULT); + public static final UITexture ATOMIC_OVERLAY_2 = fullImage("textures/gui/overlay/atomic_overlay_2.png", + ColorType.DEFAULT); + public static final UITexture ARROW_INPUT_OVERLAY = fullImage("textures/gui/overlay/arrow_input_overlay.png", + ColorType.DEFAULT); public static final UITexture ARROW_OUTPUT_OVERLAY = fullImage("textures/gui/overlay/arrow_output_overlay.png", - true); - public static final UITexture BATTERY_OVERLAY = fullImage("textures/gui/overlay/battery_overlay.png", true); - public static final UITexture BEAKER_OVERLAY_1 = fullImage("textures/gui/overlay/beaker_overlay_1.png", true); - public static final UITexture BEAKER_OVERLAY_2 = fullImage("textures/gui/overlay/beaker_overlay_2.png", true); - public static final UITexture BEAKER_OVERLAY_3 = fullImage("textures/gui/overlay/beaker_overlay_3.png", true); - public static final UITexture BEAKER_OVERLAY_4 = fullImage("textures/gui/overlay/beaker_overlay_4.png", true); - public static final UITexture BENDER_OVERLAY = fullImage("textures/gui/overlay/bender_overlay.png", true); - public static final UITexture BOX_OVERLAY = fullImage("textures/gui/overlay/box_overlay.png", true); - public static final UITexture BOXED_OVERLAY = fullImage("textures/gui/overlay/boxed_overlay.png", true); - public static final UITexture BREWER_OVERLAY = fullImage("textures/gui/overlay/brewer_overlay.png", true); - public static final UITexture CANNER_OVERLAY = fullImage("textures/gui/overlay/canner_overlay.png", true); - public static final UITexture CHARGER_OVERLAY = fullImage("textures/gui/overlay/charger_slot_overlay.png", true); - public static final UITexture CANISTER_OVERLAY = fullImage("textures/gui/overlay/canister_overlay.png", true); + ColorType.DEFAULT); + public static final UITexture BATTERY_OVERLAY = fullImage("textures/gui/overlay/battery_overlay.png", + ColorType.DEFAULT); + public static final UITexture BEAKER_OVERLAY_1 = fullImage("textures/gui/overlay/beaker_overlay_1.png", + ColorType.DEFAULT); + public static final UITexture BEAKER_OVERLAY_2 = fullImage("textures/gui/overlay/beaker_overlay_2.png", + ColorType.DEFAULT); + public static final UITexture BEAKER_OVERLAY_3 = fullImage("textures/gui/overlay/beaker_overlay_3.png", + ColorType.DEFAULT); + public static final UITexture BEAKER_OVERLAY_4 = fullImage("textures/gui/overlay/beaker_overlay_4.png", + ColorType.DEFAULT); + public static final UITexture BENDER_OVERLAY = fullImage("textures/gui/overlay/bender_overlay.png", + ColorType.DEFAULT); + public static final UITexture BOX_OVERLAY = fullImage("textures/gui/overlay/box_overlay.png", ColorType.DEFAULT); + public static final UITexture BOXED_OVERLAY = fullImage("textures/gui/overlay/boxed_overlay.png", + ColorType.DEFAULT); + public static final UITexture BREWER_OVERLAY = fullImage("textures/gui/overlay/brewer_overlay.png", + ColorType.DEFAULT); + public static final UITexture CANNER_OVERLAY = fullImage("textures/gui/overlay/canner_overlay.png", + ColorType.DEFAULT); + public static final UITexture CHARGER_OVERLAY = fullImage("textures/gui/overlay/charger_slot_overlay.png", + ColorType.DEFAULT); + public static final UITexture CANISTER_OVERLAY = fullImage("textures/gui/overlay/canister_overlay.png", + ColorType.DEFAULT); public static final UITexture CANISTER_OVERLAY_BRONZE = fullImage( "textures/gui/overlay/canister_overlay_bronze.png"); public static final UITexture CANISTER_OVERLAY_STEEL = fullImage("textures/gui/overlay/canister_overlay_steel.png"); - public static final UITexture CENTRIFUGE_OVERLAY = fullImage("textures/gui/overlay/centrifuge_overlay.png", true); - public static final UITexture CIRCUIT_OVERLAY = fullImage("textures/gui/overlay/circuit_overlay.png", true); + public static final UITexture CENTRIFUGE_OVERLAY = fullImage("textures/gui/overlay/centrifuge_overlay.png", + ColorType.DEFAULT); + public static final UITexture CIRCUIT_OVERLAY = fullImage("textures/gui/overlay/circuit_overlay.png", + ColorType.DEFAULT); public static final UITexture COAL_OVERLAY_BRONZE = fullImage("textures/gui/overlay/coal_overlay_bronze.png"); public static final UITexture COAL_OVERLAY_STEEL = fullImage("textures/gui/overlay/coal_overlay_steel.png"); - public static final UITexture COMPRESSOR_OVERLAY = fullImage("textures/gui/overlay/compressor_overlay.png", true); + public static final UITexture COMPRESSOR_OVERLAY = fullImage("textures/gui/overlay/compressor_overlay.png", + ColorType.DEFAULT); public static final UITexture COMPRESSOR_OVERLAY_BRONZE = fullImage( "textures/gui/overlay/compressor_overlay_bronze.png"); public static final UITexture COMPRESSOR_OVERLAY_STEEL = fullImage( "textures/gui/overlay/compressor_overlay_steel.png"); - public static final UITexture CRACKING_OVERLAY_1 = fullImage("textures/gui/overlay/cracking_overlay_1.png", true); - public static final UITexture CRACKING_OVERLAY_2 = fullImage("textures/gui/overlay/cracking_overlay_2.png", true); - public static final UITexture CRUSHED_ORE_OVERLAY = fullImage("textures/gui/overlay/crushed_ore_overlay.png", true); + public static final UITexture CRACKING_OVERLAY_1 = fullImage("textures/gui/overlay/cracking_overlay_1.png", + ColorType.DEFAULT); + public static final UITexture CRACKING_OVERLAY_2 = fullImage("textures/gui/overlay/cracking_overlay_2.png", + ColorType.DEFAULT); + public static final UITexture CRUSHED_ORE_OVERLAY = fullImage("textures/gui/overlay/crushed_ore_overlay.png", + ColorType.DEFAULT); public static final UITexture CRUSHED_ORE_OVERLAY_BRONZE = fullImage( "textures/gui/overlay/crushed_ore_overlay_bronze.png"); public static final UITexture CRUSHED_ORE_OVERLAY_STEEL = fullImage( "textures/gui/overlay/crushed_ore_overlay_steel.png"); - public static final UITexture CRYSTAL_OVERLAY = fullImage("textures/gui/overlay/crystal_overlay.png", true); - public static final UITexture CUTTER_OVERLAY = fullImage("textures/gui/overlay/cutter_overlay.png", true); + public static final UITexture CRYSTAL_OVERLAY = fullImage("textures/gui/overlay/crystal_overlay.png", + ColorType.DEFAULT); + public static final UITexture CUTTER_OVERLAY = fullImage("textures/gui/overlay/cutter_overlay.png", + ColorType.DEFAULT); public static final UITexture DARK_CANISTER_OVERLAY = fullImage("textures/gui/overlay/dark_canister_overlay.png", - true); - public static final UITexture DUST_OVERLAY = fullImage("textures/gui/overlay/dust_overlay.png", true); + ColorType.DEFAULT); + public static final UITexture DUST_OVERLAY = fullImage("textures/gui/overlay/dust_overlay.png", ColorType.DEFAULT); public static final UITexture DUST_OVERLAY_BRONZE = fullImage("textures/gui/overlay/dust_overlay_bronze.png"); public static final UITexture DUST_OVERLAY_STEEL = fullImage("textures/gui/overlay/dust_overlay_steel.png"); - public static final UITexture EXTRACTOR_OVERLAY = fullImage("textures/gui/overlay/extractor_overlay.png", true); + public static final UITexture EXTRACTOR_OVERLAY = fullImage("textures/gui/overlay/extractor_overlay.png", + ColorType.DEFAULT); public static final UITexture EXTRACTOR_OVERLAY_BRONZE = fullImage( "textures/gui/overlay/extractor_overlay_bronze.png"); public static final UITexture EXTRACTOR_OVERLAY_STEEL = fullImage( "textures/gui/overlay/extractor_overlay_steel.png"); - public static final UITexture FILTER_SLOT_OVERLAY = fullImage("textures/gui/overlay/filter_slot_overlay.png", true); + public static final UITexture FILTER_SLOT_OVERLAY = fullImage("textures/gui/overlay/filter_slot_overlay.png", + ColorType.DEFAULT); public static final UITexture FILTER_SETTINGS_OVERLAY = fullImage( "textures/gui/overlay/filter_settings_overlay.png"); - public static final UITexture FURNACE_OVERLAY_1 = fullImage("textures/gui/overlay/furnace_overlay_1.png", true); - public static final UITexture FURNACE_OVERLAY_2 = fullImage("textures/gui/overlay/furnace_overlay_2.png", true); + public static final UITexture FURNACE_OVERLAY_1 = fullImage("textures/gui/overlay/furnace_overlay_1.png", + ColorType.DEFAULT); + public static final UITexture FURNACE_OVERLAY_2 = fullImage("textures/gui/overlay/furnace_overlay_2.png", + ColorType.DEFAULT); public static final UITexture FURNACE_OVERLAY_BRONZE = fullImage("textures/gui/overlay/furnace_overlay_bronze.png"); public static final UITexture FURNACE_OVERLAY_STEEL = fullImage("textures/gui/overlay/furnace_overlay_steel.png"); - public static final UITexture HAMMER_OVERLAY = fullImage("textures/gui/overlay/hammer_overlay.png", true); + public static final UITexture HAMMER_OVERLAY = fullImage("textures/gui/overlay/hammer_overlay.png", + ColorType.DEFAULT); public static final UITexture HAMMER_OVERLAY_BRONZE = fullImage("textures/gui/overlay/hammer_overlay_bronze.png"); public static final UITexture HAMMER_OVERLAY_STEEL = fullImage("textures/gui/overlay/hammer_overlay_steel.png"); - public static final UITexture HEATING_OVERLAY_1 = fullImage("textures/gui/overlay/heating_overlay_1.png", true); - public static final UITexture HEATING_OVERLAY_2 = fullImage("textures/gui/overlay/heating_overlay_2.png", true); - public static final UITexture IMPLOSION_OVERLAY_1 = fullImage("textures/gui/overlay/implosion_overlay_1.png", true); - public static final UITexture IMPLOSION_OVERLAY_2 = fullImage("textures/gui/overlay/implosion_overlay_2.png", true); - public static final UITexture IN_SLOT_OVERLAY = fullImage("textures/gui/overlay/in_slot_overlay.png", true); + public static final UITexture HEATING_OVERLAY_1 = fullImage("textures/gui/overlay/heating_overlay_1.png", + ColorType.DEFAULT); + public static final UITexture HEATING_OVERLAY_2 = fullImage("textures/gui/overlay/heating_overlay_2.png", + ColorType.DEFAULT); + public static final UITexture IMPLOSION_OVERLAY_1 = fullImage("textures/gui/overlay/implosion_overlay_1.png", + ColorType.DEFAULT); + public static final UITexture IMPLOSION_OVERLAY_2 = fullImage("textures/gui/overlay/implosion_overlay_2.png", + ColorType.DEFAULT); + public static final UITexture IN_SLOT_OVERLAY = fullImage("textures/gui/overlay/in_slot_overlay.png", + ColorType.DEFAULT); public static final UITexture IN_SLOT_OVERLAY_BRONZE = fullImage("textures/gui/overlay/in_slot_overlay_bronze.png"); public static final UITexture IN_SLOT_OVERLAY_STEEL = fullImage("textures/gui/overlay/in_slot_overlay_steel.png"); - public static final UITexture INGOT_OVERLAY = fullImage("textures/gui/overlay/ingot_overlay.png", true); - public static final UITexture INT_CIRCUIT_OVERLAY = fullImage("textures/gui/overlay/int_circuit_overlay.png", true); - public static final UITexture LENS_OVERLAY = fullImage("textures/gui/overlay/lens_overlay.png", true); - public static final UITexture LIGHTNING_OVERLAY_1 = fullImage("textures/gui/overlay/lightning_overlay_1.png", true); - public static final UITexture LIGHTNING_OVERLAY_2 = fullImage("textures/gui/overlay/lightning_overlay_2.png", true); - public static final UITexture MOLD_OVERLAY = fullImage("textures/gui/overlay/mold_overlay.png", true); - public static final UITexture MOLECULAR_OVERLAY_1 = fullImage("textures/gui/overlay/molecular_overlay_1.png", true); - public static final UITexture MOLECULAR_OVERLAY_2 = fullImage("textures/gui/overlay/molecular_overlay_2.png", true); - public static final UITexture MOLECULAR_OVERLAY_3 = fullImage("textures/gui/overlay/molecular_overlay_3.png", true); - public static final UITexture MOLECULAR_OVERLAY_4 = fullImage("textures/gui/overlay/molecular_overlay_4.png", true); - public static final UITexture OUT_SLOT_OVERLAY = fullImage("textures/gui/overlay/out_slot_overlay.png", true); + public static final UITexture INGOT_OVERLAY = fullImage("textures/gui/overlay/ingot_overlay.png", + ColorType.DEFAULT); + public static final UITexture INT_CIRCUIT_OVERLAY = fullImage("textures/gui/overlay/int_circuit_overlay.png", + ColorType.DEFAULT); + public static final UITexture LENS_OVERLAY = fullImage("textures/gui/overlay/lens_overlay.png", ColorType.DEFAULT); + public static final UITexture LIGHTNING_OVERLAY_1 = fullImage("textures/gui/overlay/lightning_overlay_1.png", + ColorType.DEFAULT); + public static final UITexture LIGHTNING_OVERLAY_2 = fullImage("textures/gui/overlay/lightning_overlay_2.png", + ColorType.DEFAULT); + public static final UITexture MOLD_OVERLAY = fullImage("textures/gui/overlay/mold_overlay.png", ColorType.DEFAULT); + public static final UITexture MOLECULAR_OVERLAY_1 = fullImage("textures/gui/overlay/molecular_overlay_1.png", + ColorType.DEFAULT); + public static final UITexture MOLECULAR_OVERLAY_2 = fullImage("textures/gui/overlay/molecular_overlay_2.png", + ColorType.DEFAULT); + public static final UITexture MOLECULAR_OVERLAY_3 = fullImage("textures/gui/overlay/molecular_overlay_3.png", + ColorType.DEFAULT); + public static final UITexture MOLECULAR_OVERLAY_4 = fullImage("textures/gui/overlay/molecular_overlay_4.png", + ColorType.DEFAULT); + public static final UITexture OUT_SLOT_OVERLAY = fullImage("textures/gui/overlay/out_slot_overlay.png", + ColorType.DEFAULT); public static final UITexture OUT_SLOT_OVERLAY_BRONZE = fullImage( "textures/gui/overlay/out_slot_overlay_bronze.png"); public static final UITexture OUT_SLOT_OVERLAY_STEEL = fullImage("textures/gui/overlay/out_slot_overlay_steel.png"); - public static final UITexture PAPER_OVERLAY = fullImage("textures/gui/overlay/paper_overlay.png", true); + public static final UITexture PAPER_OVERLAY = fullImage("textures/gui/overlay/paper_overlay.png", + ColorType.DEFAULT); public static final UITexture PRINTED_PAPER_OVERLAY = fullImage("textures/gui/overlay/printed_paper_overlay.png", - true); - public static final UITexture PIPE_OVERLAY_2 = fullImage("textures/gui/overlay/pipe_overlay_2.png", true); - public static final UITexture PIPE_OVERLAY_1 = fullImage("textures/gui/overlay/pipe_overlay_1.png", true); - public static final UITexture PRESS_OVERLAY_1 = fullImage("textures/gui/overlay/press_overlay_1.png", true); - public static final UITexture PRESS_OVERLAY_2 = fullImage("textures/gui/overlay/press_overlay_2.png", true); - public static final UITexture PRESS_OVERLAY_3 = fullImage("textures/gui/overlay/press_overlay_3.png", true); - public static final UITexture PRESS_OVERLAY_4 = fullImage("textures/gui/overlay/press_overlay_4.png", true); - public static final UITexture SAWBLADE_OVERLAY = fullImage("textures/gui/overlay/sawblade_overlay.png", true); - public static final UITexture SOLIDIFIER_OVERLAY = fullImage("textures/gui/overlay/solidifier_overlay.png", true); - public static final UITexture STRING_SLOT_OVERLAY = fullImage("textures/gui/overlay/string_slot_overlay.png", true); - public static final UITexture TOOL_SLOT_OVERLAY = fullImage("textures/gui/overlay/tool_slot_overlay.png", true); - public static final UITexture TURBINE_OVERLAY = fullImage("textures/gui/overlay/turbine_overlay.png", true); - public static final UITexture VIAL_OVERLAY_1 = fullImage("textures/gui/overlay/vial_overlay_1.png", true); - public static final UITexture VIAL_OVERLAY_2 = fullImage("textures/gui/overlay/vial_overlay_2.png", true); - public static final UITexture WIREMILL_OVERLAY = fullImage("textures/gui/overlay/wiremill_overlay.png", true); + ColorType.DEFAULT); + public static final UITexture PIPE_OVERLAY_2 = fullImage("textures/gui/overlay/pipe_overlay_2.png", + ColorType.DEFAULT); + public static final UITexture PIPE_OVERLAY_1 = fullImage("textures/gui/overlay/pipe_overlay_1.png", + ColorType.DEFAULT); + public static final UITexture PRESS_OVERLAY_1 = fullImage("textures/gui/overlay/press_overlay_1.png", + ColorType.DEFAULT); + public static final UITexture PRESS_OVERLAY_2 = fullImage("textures/gui/overlay/press_overlay_2.png", + ColorType.DEFAULT); + public static final UITexture PRESS_OVERLAY_3 = fullImage("textures/gui/overlay/press_overlay_3.png", + ColorType.DEFAULT); + public static final UITexture PRESS_OVERLAY_4 = fullImage("textures/gui/overlay/press_overlay_4.png", + ColorType.DEFAULT); + public static final UITexture SAWBLADE_OVERLAY = fullImage("textures/gui/overlay/sawblade_overlay.png", + ColorType.DEFAULT); + public static final UITexture SOLIDIFIER_OVERLAY = fullImage("textures/gui/overlay/solidifier_overlay.png", + ColorType.DEFAULT); + public static final UITexture STRING_SLOT_OVERLAY = fullImage("textures/gui/overlay/string_slot_overlay.png", + ColorType.DEFAULT); + public static final UITexture TOOL_SLOT_OVERLAY = fullImage("textures/gui/overlay/tool_slot_overlay.png", + ColorType.DEFAULT); + public static final UITexture TURBINE_OVERLAY = fullImage("textures/gui/overlay/turbine_overlay.png", + ColorType.DEFAULT); + public static final UITexture VIAL_OVERLAY_1 = fullImage("textures/gui/overlay/vial_overlay_1.png", + ColorType.DEFAULT); + public static final UITexture VIAL_OVERLAY_2 = fullImage("textures/gui/overlay/vial_overlay_2.png", + ColorType.DEFAULT); + public static final UITexture WIREMILL_OVERLAY = fullImage("textures/gui/overlay/wiremill_overlay.png", + ColorType.DEFAULT); public static final UITexture POSITIVE_MATTER_OVERLAY = fullImage( - "textures/gui/overlay/positive_matter_overlay.png", true); + "textures/gui/overlay/positive_matter_overlay.png", ColorType.DEFAULT); public static final UITexture NEUTRAL_MATTER_OVERLAY = fullImage("textures/gui/overlay/neutral_matter_overlay.png", - true); - public static final UITexture DATA_ORB_OVERLAY = fullImage("textures/gui/overlay/data_orb_overlay.png", true); - public static final UITexture SCANNER_OVERLAY = fullImage("textures/gui/overlay/scanner_overlay.png", true); - public static final UITexture DUCT_TAPE_OVERLAY = fullImage("textures/gui/overlay/duct_tape_overlay.png", true); + ColorType.DEFAULT); + public static final UITexture DATA_ORB_OVERLAY = fullImage("textures/gui/overlay/data_orb_overlay.png", + ColorType.DEFAULT); + public static final UITexture SCANNER_OVERLAY = fullImage("textures/gui/overlay/scanner_overlay.png", + ColorType.DEFAULT); + public static final UITexture DUCT_TAPE_OVERLAY = fullImage("textures/gui/overlay/duct_tape_overlay.png", + ColorType.DEFAULT); public static final UITexture RESEARCH_STATION_OVERLAY = fullImage( - "textures/gui/overlay/research_station_overlay.png", true); + "textures/gui/overlay/research_station_overlay.png", ColorType.DEFAULT); // BUTTONS @@ -409,7 +471,7 @@ private static String id(String path) { public static final UITexture BUTTON_BRONZE = new UITexture.Builder() .location(GTValues.MODID, "textures/gui/widget/buttons.png") .imageSize(54, 36) - .uv(18, 0, 18, 18) + .xy(18, 0, 18, 18) .adaptable(2) .name(IDs.BRONZE_BUTTON) .build(); @@ -417,7 +479,7 @@ private static String id(String path) { public static final UITexture BUTTON_BRONZE_SELECTED = new UITexture.Builder() .location(GTValues.MODID, "textures/gui/widget/buttons.png") .imageSize(54, 36) - .uv(18, 18, 18, 18) + .xy(18, 18, 18, 18) .adaptable(2) .name(IDs.BRONZE_BUTTON_SELECTED) .build(); @@ -425,7 +487,7 @@ private static String id(String path) { public static final UITexture BUTTON_STEEL = new UITexture.Builder() .location(GTValues.MODID, "textures/gui/widget/buttons.png") .imageSize(54, 36) - .uv(36, 0, 18, 18) + .xy(36, 0, 18, 18) .adaptable(2) .name(IDs.STEEL_BUTTON) .build(); @@ -433,7 +495,7 @@ private static String id(String path) { public static final UITexture BUTTON_STEEL_SELECTED = new UITexture.Builder() .location(GTValues.MODID, "textures/gui/widget/buttons.png") .imageSize(54, 36) - .uv(36, 18, 18, 18) + .xy(36, 18, 18, 18) .adaptable(2) .name(IDs.STEEL_BUTTON_SELECTED) .build(); @@ -458,8 +520,9 @@ private static String id(String path) { "textures/gui/widget/button_fluid_output_overlay.png"); public static final UITexture BUTTON_AUTO_COLLAPSE = fullImage( "textures/gui/widget/button_auto_collapse_overlay.png"); - public static final UITexture BUTTON_X = fullImage("textures/gui/widget/button_x_overlay.png", true); - public static final UITexture BUTTON_CLEAR_GRID = fullImage("textures/gui/widget/button_clear_grid.png", false); + public static final UITexture BUTTON_X = fullImage("textures/gui/widget/button_x_overlay.png", ColorType.DEFAULT); + public static final UITexture BUTTON_CLEAR_GRID = fullImage("textures/gui/widget/button_clear_grid.png", + ColorType.DEFAULT); public static final UITexture BUTTON_CROSS = fullImage("textures/gui/widget/button_cross.png"); public static final UITexture BUTTON_REDSTONE_ON = fullImage("textures/gui/widget/button_redstone_on.png"); @@ -469,8 +532,8 @@ private static String id(String path) { * 0 = OFF
* 1 = ON
*/ - public static final UITexture[] BUTTON_POWER = slice("textures/gui/widget/button_power.png", - 18, 36, 18, 18, false); + public static final UITexture[] BUTTON_POWER = slice("textures/gui/widget/button_power.png", 18, 36, 18, 18, + ColorType.DEFAULT); public static final UITexture BUTTON_POWER_DETAIL = fullImage("textures/gui/widget/button_power_detail.png"); @@ -480,8 +543,8 @@ private static String id(String path) { * 2 = FLUID VOID
* 3 = VOID BOTH
**/ - public static final UITexture[] MULTIBLOCK_VOID = slice("textures/gui/widget/button_void_multiblock.png", - 18, 72, 18, 18, false); + public static final UITexture[] MULTIBLOCK_VOID = slice("textures/gui/widget/button_void_multiblock.png", 18, 72, + 18, 18, ColorType.DEFAULT); public static final UITexture OVERLAY_VOID_NONE = fullImage("textures/gui/widget/button_void_none.png"); @@ -489,104 +552,102 @@ private static String id(String path) { * 0 = DISABLED
* 1 = ENABLED
*/ - public static final UITexture[] OVERLAY_DISTINCT_BUSES = slice("textures/gui/widget/button_distinct_buses.png", - 18, 36, 18, 18, false); + public static final UITexture[] OVERLAY_DISTINCT_BUSES = slice("textures/gui/widget/button_distinct_buses.png", 18, + 36, 18, 18); - public static final UITexture OVERLAY_NO_FLEX = fullImage("textures/gui/widget/button_no_flex.png", false); - public static final UITexture BUTTON_MULTI_MAP = fullImage("textures/gui/widget/button_multi_map.png", true); - public static final UITexture BUTTON_MINER_MODES = fullImage("textures/gui/widget/button_miner_modes.png", true); - public static final UITexture BUTTON_THROTTLE_MINUS = fullImage("textures/gui/widget/button_throttle_minus.png", - true); // TODO new texture - public static final UITexture BUTTON_THROTTLE_PLUS = fullImage("textures/gui/widget/button_throttle_plus.png", - true); // TODO remove this + public static final UITexture OVERLAY_NO_FLEX = fullImage("textures/gui/widget/button_no_flex.png"); + public static final UITexture BUTTON_MULTI_MAP = fullImage("textures/gui/widget/button_multi_map.png", + ColorType.DEFAULT); + public static final UITexture BUTTON_MINER_MODES = fullImage("textures/gui/widget/button_miner_modes.png", + ColorType.DEFAULT); // PROGRESS BARS public static final UITexture PROGRESS_BAR_ARC_FURNACE = progressBar( - "textures/gui/progress_bar/progress_bar_arc_furnace.png", true); + "textures/gui/progress_bar/progress_bar_arc_furnace.png", ColorType.DEFAULT); public static final UITexture PROGRESS_BAR_ARROW = progressBar("textures/gui/progress_bar/progress_bar_arrow.png", - true); + ColorType.DEFAULT); public static final UITexture PROGRESS_BAR_ARROW_BRONZE = progressBar( "textures/gui/progress_bar/progress_bar_arrow_bronze.png"); public static final UITexture PROGRESS_BAR_ARROW_STEEL = progressBar( "textures/gui/progress_bar/progress_bar_arrow_steel.png"); public static final UITexture PROGRESS_BAR_ARROW_MULTIPLE = progressBar( - "textures/gui/progress_bar/progress_bar_arrow_multiple.png", true); + "textures/gui/progress_bar/progress_bar_arrow_multiple.png", ColorType.DEFAULT); public static final UITexture PROGRESS_BAR_BATH = progressBar("textures/gui/progress_bar/progress_bar_bath.png", - true); + ColorType.DEFAULT); public static final UITexture PROGRESS_BAR_BENDING = progressBar( - "textures/gui/progress_bar/progress_bar_bending.png", true); + "textures/gui/progress_bar/progress_bar_bending.png", ColorType.DEFAULT); public static final UITexture PROGRESS_BAR_CANNER = progressBar("textures/gui/progress_bar/progress_bar_canner.png", - true); + ColorType.DEFAULT); public static final UITexture PROGRESS_BAR_CIRCUIT = progressBar( - "textures/gui/progress_bar/progress_bar_circuit.png", true); + "textures/gui/progress_bar/progress_bar_circuit.png", ColorType.DEFAULT); public static final UITexture PROGRESS_BAR_CIRCUIT_ASSEMBLER = progressBar( - "textures/gui/progress_bar/progress_bar_circuit_assembler.png", true); + "textures/gui/progress_bar/progress_bar_circuit_assembler.png", ColorType.DEFAULT); public static final UITexture PROGRESS_BAR_COMPRESS = progressBar( - "textures/gui/progress_bar/progress_bar_compress.png", true); + "textures/gui/progress_bar/progress_bar_compress.png", ColorType.DEFAULT); public static final UITexture PROGRESS_BAR_COMPRESS_BRONZE = progressBar( "textures/gui/progress_bar/progress_bar_compress_bronze.png"); public static final UITexture PROGRESS_BAR_COMPRESS_STEEL = progressBar( "textures/gui/progress_bar/progress_bar_compress_steel.png"); public static final UITexture PROGRESS_BAR_CRACKING = progressBar( - "textures/gui/progress_bar/progress_bar_cracking.png", true); + "textures/gui/progress_bar/progress_bar_cracking.png", ColorType.DEFAULT); public static final UITexture PROGRESS_BAR_CRACKING_INPUT = progressBar( - "textures/gui/progress_bar/progress_bar_cracking_2.png", 21, 38, true); + "textures/gui/progress_bar/progress_bar_cracking_2.png", 21, 38, ColorType.DEFAULT); public static final UITexture PROGRESS_BAR_CRYSTALLIZATION = progressBar( - "textures/gui/progress_bar/progress_bar_crystallization.png", true); + "textures/gui/progress_bar/progress_bar_crystallization.png", ColorType.DEFAULT); public static final UITexture PROGRESS_BAR_EXTRACT = progressBar( - "textures/gui/progress_bar/progress_bar_extract.png", true); + "textures/gui/progress_bar/progress_bar_extract.png", ColorType.DEFAULT); public static final UITexture PROGRESS_BAR_EXTRACT_BRONZE = progressBar( "textures/gui/progress_bar/progress_bar_extract_bronze.png"); public static final UITexture PROGRESS_BAR_EXTRACT_STEEL = progressBar( "textures/gui/progress_bar/progress_bar_extract_steel.png"); public static final UITexture PROGRESS_BAR_EXTRUDER = progressBar( - "textures/gui/progress_bar/progress_bar_extruder.png", true); + "textures/gui/progress_bar/progress_bar_extruder.png", ColorType.DEFAULT); public static final UITexture PROGRESS_BAR_FUSION = progressBar("textures/gui/progress_bar/progress_bar_fusion.png", - true); + ColorType.DEFAULT); public static final UITexture PROGRESS_BAR_GAS_COLLECTOR = progressBar( - "textures/gui/progress_bar/progress_bar_gas_collector.png", true); + "textures/gui/progress_bar/progress_bar_gas_collector.png", ColorType.DEFAULT); public static final UITexture PROGRESS_BAR_HAMMER = progressBar("textures/gui/progress_bar/progress_bar_hammer.png", - true); + ColorType.DEFAULT); public static final UITexture PROGRESS_BAR_HAMMER_BRONZE = progressBar( "textures/gui/progress_bar/progress_bar_hammer_bronze.png"); public static final UITexture PROGRESS_BAR_HAMMER_STEEL = progressBar( "textures/gui/progress_bar/progress_bar_hammer_steel.png"); public static final UITexture PROGRESS_BAR_HAMMER_BASE = fullImage( - "textures/gui/progress_bar/progress_bar_hammer_base.png", true); + "textures/gui/progress_bar/progress_bar_hammer_base.png", ColorType.DEFAULT); public static final UITexture PROGRESS_BAR_HAMMER_BASE_BRONZE = fullImage( "textures/gui/progress_bar/progress_bar_hammer_base_bronze.png"); public static final UITexture PROGRESS_BAR_HAMMER_BASE_STEEL = fullImage( "textures/gui/progress_bar/progress_bar_hammer_base_steel.png"); public static final UITexture PROGRESS_BAR_LATHE = progressBar("textures/gui/progress_bar/progress_bar_lathe.png", - true); + ColorType.DEFAULT); public static final UITexture PROGRESS_BAR_LATHE_BASE = fullImage( - "textures/gui/progress_bar/progress_bar_lathe_base.png", true); + "textures/gui/progress_bar/progress_bar_lathe_base.png", ColorType.DEFAULT); public static final UITexture PROGRESS_BAR_MACERATE = progressBar( - "textures/gui/progress_bar/progress_bar_macerate.png", true); + "textures/gui/progress_bar/progress_bar_macerate.png", ColorType.DEFAULT); public static final UITexture PROGRESS_BAR_MACERATE_BRONZE = progressBar( "textures/gui/progress_bar/progress_bar_macerate_bronze.png"); public static final UITexture PROGRESS_BAR_MACERATE_STEEL = progressBar( "textures/gui/progress_bar/progress_bar_macerate_steel.png"); public static final UITexture PROGRESS_BAR_MAGNET = progressBar("textures/gui/progress_bar/progress_bar_magnet.png", - true); + ColorType.DEFAULT); public static final UITexture PROGRESS_BAR_MASS_FAB = progressBar( - "textures/gui/progress_bar/progress_bar_mass_fab.png", true); + "textures/gui/progress_bar/progress_bar_mass_fab.png", ColorType.DEFAULT); public static final UITexture PROGRESS_BAR_MIXER = progressBar("textures/gui/progress_bar/progress_bar_mixer.png", - true); + ColorType.DEFAULT); public static final UITexture PROGRESS_BAR_PACKER = progressBar("textures/gui/progress_bar/progress_bar_packer.png", - true); + ColorType.DEFAULT); public static final UITexture PROGRESS_BAR_RECYCLER = progressBar( - "textures/gui/progress_bar/progress_bar_recycler.png", true); + "textures/gui/progress_bar/progress_bar_recycler.png", ColorType.DEFAULT); public static final UITexture PROGRESS_BAR_REPLICATOR = progressBar( - "textures/gui/progress_bar/progress_bar_replicator.png", true); + "textures/gui/progress_bar/progress_bar_replicator.png", ColorType.DEFAULT); public static final UITexture PROGRESS_BAR_SIFT = progressBar("textures/gui/progress_bar/progress_bar_sift.png", - true); + ColorType.DEFAULT); public static final UITexture PROGRESS_BAR_SLICE = progressBar("textures/gui/progress_bar/progress_bar_slice.png", - true); + ColorType.DEFAULT); public static final UITexture PROGRESS_BAR_UNPACKER = progressBar( - "textures/gui/progress_bar/progress_bar_unpacker.png", true); + "textures/gui/progress_bar/progress_bar_unpacker.png", ColorType.DEFAULT); public static final UITexture PROGRESS_BAR_WIREMILL = progressBar( - "textures/gui/progress_bar/progress_bar_wiremill.png", true); + "textures/gui/progress_bar/progress_bar_wiremill.png", ColorType.DEFAULT); // more custom progress bars // MULTIBLOCK BARS @@ -651,16 +712,21 @@ private static String id(String path) { public static void init() {/**/} private static UITexture fullImage(String path) { - return fullImage(path, false); + return fullImage(path, null); } - private static UITexture fullImage(String path, boolean canApplyTheme) { - return UITexture.fullImage(GTValues.MODID, path, canApplyTheme); + private static UITexture fullImage(String path, @Nullable ColorType colorType) { + return UITexture.fullImage(GTValues.MODID, path, colorType); + } + + @SuppressWarnings("SameParameterValue") + private static UITexture[] slice(String path, int imageWidth, int imageHeight, int sliceWidth, int sliceHeight) { + return slice(path, imageWidth, imageHeight, sliceWidth, sliceHeight, null); } @SuppressWarnings("SameParameterValue") private static UITexture[] slice(String path, int imageWidth, int imageHeight, int sliceWidth, int sliceHeight, - boolean canApplyTheme) { + @Nullable ColorType colorType) { if (imageWidth % sliceWidth != 0 || imageHeight % sliceHeight != 0) throw new IllegalArgumentException("Slice height and slice width must divide the image evenly!"); @@ -672,42 +738,51 @@ private static UITexture[] slice(String path, int imageWidth, int imageHeight, i for (int indexY = 0; indexY < countY; indexY++) { slices[(indexX * countX) + indexY] = UITexture.builder() .location(GTValues.MODID, path) - .canApplyTheme(canApplyTheme) + .colorType(colorType) .imageSize(imageWidth, imageHeight) - .uv(indexX * sliceWidth, indexY * sliceHeight, sliceWidth, sliceHeight) + .xy(indexX * sliceWidth, indexY * sliceHeight, sliceWidth, sliceHeight) .build(); } } return slices; } - private static UITexture[] slice(String path, int imageWidth, int imageHeight, boolean canApplyTheme) { + private static UITexture[] slice(String path, int imageWidth, int imageHeight) { + return slice(path, imageWidth, imageHeight, null); + } + + private static UITexture[] slice(String path, int imageWidth, int imageHeight, @Nullable ColorType colorType) { int sliceSize = Math.min(imageWidth, imageHeight); - return slice(path, imageWidth, imageHeight, sliceSize, sliceSize, canApplyTheme); + return slice(path, imageWidth, imageHeight, sliceSize, sliceSize, colorType); + } + + private static IDrawable animated(String path, int imageWidth, int imageHeight, int rate) { + return dynamic(slice(path, imageWidth, imageHeight, null), rate); } - private static IDrawable animated(String path, int imageWidth, int imageHeight, boolean canApplyTheme, int rate) { - return dynamic(slice(path, imageWidth, imageHeight, canApplyTheme), rate); + private static IDrawable animated(String path, int imageWidth, int imageHeight, @Nullable ColorType colorType, + int rate) { + return dynamic(slice(path, imageWidth, imageHeight, colorType), rate); } private static UITexture progressBar(String path) { - return progressBar(path, 20, 40, false); + return progressBar(path, 20, 40); } - private static UITexture progressBar(String path, boolean canApplyTheme) { - return progressBar(path, 20, 40, canApplyTheme); + private static UITexture progressBar(String path, @Nullable ColorType colorType) { + return progressBar(path, 20, 40, colorType); } private static UITexture progressBar(String path, int width, int height) { - return progressBar(path, width, height, false); + return progressBar(path, width, height, null); } - private static UITexture progressBar(String path, int width, int height, boolean canApplyTheme) { - UITexture.Builder builder = new UITexture.Builder() + private static UITexture progressBar(String path, int width, int height, @Nullable ColorType colorType) { + return new UITexture.Builder() .location(GTValues.MODID, path) - .imageSize(width, height); - if (canApplyTheme) builder.canApplyTheme(); - return builder.build(); + .imageSize(width, height) + .colorType(colorType) + .build(); } // todo steam logos? multi indicator blinking logos? diff --git a/src/main/java/gregtech/api/mui/GTGuis.java b/src/main/java/gregtech/api/mui/GTGuis.java index f955cd922f8..a8301981eaa 100644 --- a/src/main/java/gregtech/api/mui/GTGuis.java +++ b/src/main/java/gregtech/api/mui/GTGuis.java @@ -108,7 +108,7 @@ private PopupPanel(@NotNull String name) { child(ButtonWidget.panelCloseButton().top(5).right(5) .onMousePressed(mouseButton -> { if (mouseButton == 0 || mouseButton == 1) { - this.closeIfOpen(true); + this.closeIfOpen(); return true; } return false; diff --git a/src/main/java/gregtech/api/mui/IconAcessor.java b/src/main/java/gregtech/api/mui/IconAcessor.java deleted file mode 100644 index 2bf4218904f..00000000000 --- a/src/main/java/gregtech/api/mui/IconAcessor.java +++ /dev/null @@ -1,8 +0,0 @@ -package gregtech.api.mui; - -import com.cleanroommc.modularui.api.drawable.IDrawable; - -public interface IconAcessor { - - IDrawable gregTech$getDrawable(); -} diff --git a/src/main/java/gregtech/api/mui/drawable/GTObjectDrawable.java b/src/main/java/gregtech/api/mui/drawable/GTObjectDrawable.java index 2a562ae63b0..def024b35bf 100644 --- a/src/main/java/gregtech/api/mui/drawable/GTObjectDrawable.java +++ b/src/main/java/gregtech/api/mui/drawable/GTObjectDrawable.java @@ -11,25 +11,29 @@ import com.cleanroommc.modularui.drawable.GuiDraw; import com.cleanroommc.modularui.drawable.Icon; import com.cleanroommc.modularui.drawable.text.TextRenderer; -import com.cleanroommc.modularui.integration.jei.JeiIngredientProvider; +import com.cleanroommc.modularui.integration.recipeviewer.RecipeViewerIngredientProvider; import com.cleanroommc.modularui.screen.viewport.GuiContext; import com.cleanroommc.modularui.screen.viewport.ModularGuiContext; -import com.cleanroommc.modularui.theme.WidgetSlotTheme; +import com.cleanroommc.modularui.theme.SlotTheme; import com.cleanroommc.modularui.theme.WidgetTheme; import com.cleanroommc.modularui.utils.Alignment; import com.cleanroommc.modularui.utils.Color; import com.cleanroommc.modularui.widget.Widget; +import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.util.function.Function; +import java.util.function.Predicate; -public class GTObjectDrawable implements IDrawable, JeiIngredientProvider { +public class GTObjectDrawable implements IDrawable, RecipeViewerIngredientProvider { private static final TextRenderer renderer = new TextRenderer(); private final Object object; private final long amount; private Function, Integer> boostFunction; + @NotNull + private Predicate drawBackground = $ -> true; public GTObjectDrawable(Object object, long amount) { this.object = object; @@ -41,6 +45,10 @@ public GTObjectDrawable setBoostFunction(Function, Integ return this; } + public void setDrawBackground(@NotNull Predicate drawBackground) { + this.drawBackground = drawBackground; + } + static { renderer.setScale(0.5f); renderer.setShadow(true); @@ -62,16 +70,20 @@ public void draw(GuiContext context, int x, int y, int width, int height, Widget private void drawObject(Object object, ModularGuiContext context, int x, int y, int width, int height) { if (object instanceof ItemStack stack) { - WidgetSlotTheme theme = context.getTheme().getItemSlotTheme(); + SlotTheme theme = context.getTheme().getItemSlotTheme().getTheme(); IDrawable background = theme.getBackground(); - if (background == null) background = GTGuiTextures.SLOT; - background.draw(context, x, y, width, height, theme); - GuiDraw.drawItem(stack, x + 1, y + 1, width - 2, height - 2); + if (drawBackground.test(object)) { + if (background == null) background = GTGuiTextures.SLOT; + background.draw(context, x, y, width, height, theme); + } + GuiDraw.drawItem(stack, x + 1, y + 1, width - 2, height - 2, 100); } else if (object instanceof FluidStack stack) { - WidgetSlotTheme theme = context.getTheme().getFluidSlotTheme(); - IDrawable slot = theme.getBackground(); - if (slot == null) slot = GTGuiTextures.FLUID_SLOT; - slot.draw(context, x, y, width, height, theme); + SlotTheme theme = context.getTheme().getFluidSlotTheme().getTheme(); + IDrawable background = theme.getBackground(); + if (drawBackground.test(object)) { + if (background == null) background = GTGuiTextures.FLUID_SLOT; + background.draw(context, x, y, width, height, theme); + } GuiDraw.drawFluidTexture(stack, x + 1, y + 1, width - 2, height - 2, 0); } else if (object instanceof BoostableChanceEntryentry) { drawObject(entry.getIngredient(), context, x, y, width, height); diff --git a/src/main/java/gregtech/api/mui/sync/BigIntegerSyncValue.java b/src/main/java/gregtech/api/mui/sync/BigIntegerSyncValue.java deleted file mode 100644 index 5a4a397f9b8..00000000000 --- a/src/main/java/gregtech/api/mui/sync/BigIntegerSyncValue.java +++ /dev/null @@ -1,92 +0,0 @@ -package gregtech.api.mui.sync; - -import net.minecraft.network.PacketBuffer; - -import com.cleanroommc.modularui.api.value.sync.IStringSyncValue; -import com.cleanroommc.modularui.network.NetworkUtils; -import com.cleanroommc.modularui.value.sync.ValueSyncHandler; -import org.jetbrains.annotations.Contract; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -import java.io.IOException; -import java.math.BigInteger; -import java.util.Objects; -import java.util.function.Consumer; -import java.util.function.Supplier; - -public class BigIntegerSyncValue extends ValueSyncHandler implements IStringSyncValue { - - private BigInteger cache = BigInteger.ZERO; - private final Supplier getter; - private final @Nullable Consumer setter; - - public BigIntegerSyncValue(@NotNull Supplier<@NotNull BigInteger> getter, - @Nullable Consumer<@NotNull BigInteger> setter) { - this.getter = getter; - this.setter = setter; - } - - @Contract("null, _, null, _ -> fail") - public BigIntegerSyncValue(@Nullable Supplier<@NotNull BigInteger> clientGetter, - @Nullable Consumer<@NotNull BigInteger> clientSetter, - @Nullable Supplier<@NotNull BigInteger> serverGetter, - @Nullable Consumer<@NotNull BigInteger> serverSetter) { - if (clientGetter == null && serverGetter == null) { - throw new NullPointerException("Client or server getter must not be null!"); - } - if (NetworkUtils.isClient()) { - this.getter = clientGetter != null ? clientGetter : serverGetter; - this.setter = clientSetter != null ? clientSetter : serverSetter; - } else { - this.getter = serverGetter != null ? serverGetter : clientGetter; - this.setter = serverSetter != null ? serverSetter : clientSetter; - } - this.cache = this.getter.get(); - } - - @Override - public void setStringValue(String value, boolean setSource, boolean sync) { - setValue(new BigInteger(value), setSource, sync); - } - - @Override - public String getStringValue() { - return cache.toString(); - } - - @Override - public void setValue(BigInteger value, boolean setSource, boolean sync) { - this.cache = value; - if (setSource && this.setter != null) { - this.setter.accept(value); - } - if (sync) { - sync(0, this::write); - } - } - - @Override - public boolean updateCacheFromSource(boolean isFirstSync) { - if (this.getter != null && (isFirstSync || !Objects.equals(this.getter.get(), this.cache))) { - setValue(this.getter.get(), false, false); - return true; - } - return false; - } - - @Override - public void write(@NotNull PacketBuffer buffer) throws IOException { - buffer.writeByteArray(getValue().toByteArray()); - } - - @Override - public void read(@NotNull PacketBuffer buffer) throws IOException { - setValue(new BigInteger(buffer.readByteArray()), true, false); - } - - @Override - public BigInteger getValue() { - return this.cache; - } -} diff --git a/src/main/java/gregtech/api/mui/sync/GTFluidSyncHandler.java b/src/main/java/gregtech/api/mui/sync/GTFluidSyncHandler.java index e5cdd2b33b4..bccbfd49be0 100644 --- a/src/main/java/gregtech/api/mui/sync/GTFluidSyncHandler.java +++ b/src/main/java/gregtech/api/mui/sync/GTFluidSyncHandler.java @@ -17,6 +17,7 @@ import net.minecraftforge.fluids.IFluidTank; import net.minecraftforge.fluids.capability.IFluidHandlerItem; +import com.cleanroommc.modularui.api.MCHelper; import com.cleanroommc.modularui.api.drawable.IKey; import com.cleanroommc.modularui.network.NetworkUtils; import com.cleanroommc.modularui.screen.RichTooltip; @@ -26,6 +27,7 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import java.util.Objects; import java.util.function.BooleanSupplier; import java.util.function.Consumer; import java.util.function.Supplier; @@ -78,8 +80,9 @@ public void detectAndSendChanges(boolean init) { } public void lockFluid(FluidStack stack) { - if (!canLockFluid()) return; - this.jeiHandler.accept(stack); + if (canLockFluid() && GTUtility.isEmpty(getLockedFluid())) { + this.jeiHandler.accept(stack); + } } public void lockFluid(boolean locked) { @@ -245,31 +248,25 @@ public int getFluidAmount() { } public void handleTooltip(@NotNull RichTooltip tooltip) { - IKey nameKey = getFluidNameKey(); - - if (nameKey != IKey.EMPTY) { - tooltip.addLine(nameKey); - } - - if (showAmountInTooltip()) { - tooltip.addLine(IKey.lang("gregtech.fluid.amount", getFluidAmount(), getCapacity())); - } - - if (isPhantom() && showAmountInTooltip()) { - tooltip.addLine(IKey.lang("modularui.fluid.phantom.control")); - } - FluidStack tankFluid = getFluid(); - if (tankFluid == null) { + if (GTUtility.isEmpty(tankFluid)) { tankFluid = getLockedFluid(); } - if (tankFluid != null) { + if (!GTUtility.isEmpty(tankFluid)) { + tooltip.addLine(KeyUtil.fluid(tankFluid)); + FluidTooltipUtil.handleFluidTooltip(tooltip, tankFluid); if (showAmountInTooltip()) { FluidTooltipUtil.addIngotMolFluidTooltip(tooltip, tankFluid); } + + tooltip.addLine(MCHelper.getFluidModName(tankFluid)); + + if (isPhantom() && showAmountInTooltip()) { + tooltip.addLine(IKey.lang("modularui.fluid.phantom.control")); + } } } @@ -426,16 +423,22 @@ public ItemStack tryClickContainer(boolean tryFillAll) { return ItemStack.EMPTY; ItemStack useStack = GTUtility.copy(1, playerHeldStack); - var fluidHandlerItem = FluidUtil.getFluidHandler(useStack); - if (fluidHandlerItem == null) return ItemStack.EMPTY; - + IFluidHandlerItem fluidHandlerItem = FluidUtil.getFluidHandler(useStack); + FluidStack heldFluid = FluidUtil.getFluidContained(playerHeldStack); FluidStack tankFluid = tank.getFluid(); - FluidStack heldFluid = fluidHandlerItem.drain(Integer.MAX_VALUE, false); - // nothing to do, return - if (tankFluid == null && heldFluid == null) + if (fluidHandlerItem == null || heldFluid == tankFluid) return ItemStack.EMPTY; + if (canLockFluid() && isLocked.getAsBoolean()) { + FluidStack lockedFluid = getLockedFluid(); + if (lockedFluid == null && heldFluid != null) { + lockFluid(heldFluid); + } else if (!Objects.equals(heldFluid, lockedFluid)) { + return ItemStack.EMPTY; + } + } + ItemStack returnable = ItemStack.EMPTY; // tank is empty, try to fill tank @@ -588,11 +591,13 @@ public boolean canLockFluid() { } public void toggleLockFluid() { - var cursorItem = getSyncManager().getCursorItem(); + ItemStack cursorItem = getSyncManager().getCursorItem(); + FluidStack fluidStack = FluidUtil.getFluidContained(cursorItem); FluidStack stack; - if (GTUtility.isEmpty(getLockedFluid()) && !cursorItem.isEmpty()) { - var fluidStack = FluidUtil.getFluidContained(cursorItem); - stack = !GTUtility.isEmpty(fluidStack) ? fluidStack.copy() : null; + if (GTUtility.isEmpty(getLockedFluid()) && !GTUtility.isEmpty(fluidStack)) { + stack = fluidStack.copy(); + } else if (!GTUtility.isEmpty(getLockedFluid()) && !Objects.equals(getLockedFluid(), fluidStack)) { + return; } else { stack = null; } diff --git a/src/main/java/gregtech/api/mui/widget/GhostCircuitSlotWidget.java b/src/main/java/gregtech/api/mui/widget/GhostCircuitSlotWidget.java index 5a498360404..c914a0f4f87 100644 --- a/src/main/java/gregtech/api/mui/widget/GhostCircuitSlotWidget.java +++ b/src/main/java/gregtech/api/mui/widget/GhostCircuitSlotWidget.java @@ -8,37 +8,46 @@ import net.minecraft.item.ItemStack; import net.minecraft.network.PacketBuffer; -import net.minecraftforge.items.IItemHandler; +import net.minecraftforge.items.IItemHandlerModifiable; import com.cleanroommc.modularui.api.IPanelHandler; +import com.cleanroommc.modularui.api.UpOrDown; import com.cleanroommc.modularui.api.drawable.IKey; import com.cleanroommc.modularui.api.widget.Interactable; import com.cleanroommc.modularui.drawable.ItemDrawable; -import com.cleanroommc.modularui.screen.ModularScreen; +import com.cleanroommc.modularui.integration.recipeviewer.RecipeViewerIngredientProvider; import com.cleanroommc.modularui.screen.RichTooltip; +import com.cleanroommc.modularui.utils.Alignment; import com.cleanroommc.modularui.utils.MouseData; -import com.cleanroommc.modularui.value.sync.ItemSlotSH; import com.cleanroommc.modularui.value.sync.SyncHandler; import com.cleanroommc.modularui.widget.Widget; import com.cleanroommc.modularui.widgets.ButtonWidget; -import com.cleanroommc.modularui.widgets.ItemSlot; import com.cleanroommc.modularui.widgets.layout.Grid; -import com.cleanroommc.modularui.widgets.slot.ModularSlot; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.io.IOException; -public class GhostCircuitSlotWidget extends ItemSlot { +public class GhostCircuitSlotWidget extends Widget implements Interactable, + RecipeViewerIngredientProvider { private static final int SYNC_CIRCUIT_INDEX = 10; + private static final int SYNC_SCROLL = 3; + private static final int SYNC_CLICK = 2; + private static final int SYNC_CIRCUIT = 1; + @Nullable private IPanelHandler selectorPanel; private GhostCircuitSyncHandler syncHandler; public GhostCircuitSlotWidget() { - super(); + tooltipAutoUpdate(true); tooltipBuilder(this::getCircuitSlotTooltip); + size(18); + background(GTGuiTextures.SLOT, GTGuiTextures.INT_CIRCUIT_OVERLAY); + ItemDrawable stack = new ItemDrawable(); + overlay(stack.asIcon().alignment(Alignment.Center)); + onUpdateListener(w -> stack.setItem(syncHandler.getCircuitStack())); } @Override @@ -48,30 +57,28 @@ public GhostCircuitSlotWidget() { this.getSelectorPanel().openPanel(); } else { MouseData mouseData = MouseData.create(mouseButton); - getSyncHandler().syncToServer(2, mouseData::writeToPacket); + getSyncHandler().syncToServer(SYNC_CLICK, mouseData::writeToPacket); } } return Result.SUCCESS; } @Override - public boolean onMouseScroll(ModularScreen.UpOrDown scrollDirection, int amount) { + public boolean onMouseScroll(UpOrDown scrollDirection, int amount) { if (isSelectorPanelOpen()) return true; MouseData mouseData = MouseData.create(scrollDirection.modifier); - getSyncHandler().syncToServer(3, mouseData::writeToPacket); + getSyncHandler().syncToServer(SYNC_SCROLL, mouseData::writeToPacket); return true; } @Override public boolean isValidSyncHandler(SyncHandler syncHandler) { this.syncHandler = castIfTypeElseNull(syncHandler, GhostCircuitSyncHandler.class); - if (this.syncHandler == null) return false; - return super.isValidSyncHandler(syncHandler); + return this.syncHandler != null; } - @Override - public ItemSlot slot(ModularSlot slot) { - this.syncHandler = new GhostCircuitSyncHandler(slot); + public GhostCircuitSlotWidget slot(IItemHandlerModifiable handlerModifiable, int index) { + this.syncHandler = new GhostCircuitSyncHandler(handlerModifiable, index); isValidSyncHandler(this.syncHandler); setSyncHandler(this.syncHandler); return this; @@ -89,9 +96,6 @@ protected void getCircuitSlotTooltip(@NotNull RichTooltip tooltip) { tooltip.addLine(IKey.lang("gregtech.gui.configurator_slot.tooltip", configString)); } - @Override - public void onMouseDrag(int mouseButton, long timeSinceClick) {} - @Override public boolean onMouseRelease(int mouseButton) { return true; @@ -135,13 +139,32 @@ private IPanelHandler getSelectorPanel() { return this.selectorPanel; } - private static class GhostCircuitSyncHandler extends ItemSlotSH { + @Override + public @Nullable Object getIngredient() { + return this.syncHandler.getCircuitStack(); + } - public GhostCircuitSyncHandler(ModularSlot slot) { - super(slot); + private static class GhostCircuitSyncHandler extends SyncHandler { + + private final IItemHandlerModifiable handler; + private final int index; + + public GhostCircuitSyncHandler(IItemHandlerModifiable handler, int index) { + if (!(handler instanceof GhostCircuitItemStackHandler)) { + throw new IllegalArgumentException( + "GhostCircuitSyncHandler has IItemHandler that is not GhostCircuitItemStackHandler"); + } + this.handler = handler; + this.index = index; } @Override + public void detectAndSendChanges(boolean init) { + if (init) { + syncToClient(SYNC_CIRCUIT, buffer -> buffer.writeItemStack(getCircuitStack())); + } + } + protected void phantomClick(MouseData mouseData) { if (mouseData.mouseButton == 0) { // increment on left-click @@ -155,7 +178,6 @@ protected void phantomClick(MouseData mouseData) { } } - @Override protected void phantomScroll(MouseData mouseData) { setCircuitValue(getNextCircuitValue(mouseData.mouseButton)); } @@ -164,11 +186,7 @@ private void setCircuitValue(int value) { GhostCircuitItemStackHandler handler = getGhostCircuitHandler(); if (handler.getCircuitValue() != value) { handler.setCircuitValue(value); - syncToClient(1, buf -> { - buf.writeBoolean(false); - buf.writeItemStack(handler.getStackInSlot(0)); - buf.writeBoolean(false); - }); + syncToClient(SYNC_CIRCUIT, buf -> buf.writeItemStack(getCircuitStack())); } } @@ -177,15 +195,24 @@ public int getCircuitValue() { } public ItemStack getCircuitStack() { - return getSlot().getStack(); + return this.handler.getStackInSlot(this.index); + } + + @Override + public void readOnClient(int id, PacketBuffer buf) throws IOException { + if (id == SYNC_CIRCUIT) { + this.handler.setStackInSlot(this.index, buf.readItemStack()); + } } @Override public void readOnServer(int id, PacketBuffer buf) throws IOException { if (id == SYNC_CIRCUIT_INDEX) { setCircuitValue(buf.readShort()); - } else { - super.readOnServer(id, buf); + } else if (id == SYNC_CLICK) { + phantomClick(MouseData.readPacket(buf)); + } else if (id == SYNC_SCROLL) { + phantomScroll(MouseData.readPacket(buf)); } } @@ -209,12 +236,7 @@ private int getNextCircuitValue(int delta) { } public GhostCircuitItemStackHandler getGhostCircuitHandler() { - IItemHandler handler = getSlot().getItemHandler(); - if (!(handler instanceof GhostCircuitItemStackHandler ghostHandler)) { - throw new IllegalStateException( - "GhostCircuitSyncHandler has IItemHandler that is not GhostCircuitItemStackHandler"); - } - return ghostHandler; + return (GhostCircuitItemStackHandler) this.handler; } } } diff --git a/src/main/java/gregtech/api/util/FluidTooltipUtil.java b/src/main/java/gregtech/api/util/FluidTooltipUtil.java index a4afad4796f..37607a28bf5 100644 --- a/src/main/java/gregtech/api/util/FluidTooltipUtil.java +++ b/src/main/java/gregtech/api/util/FluidTooltipUtil.java @@ -142,7 +142,7 @@ public static void addIngotMolFluidTooltip(@NotNull RichTooltip tooltip, @NotNul if (extra != 0) { fluidAmount += String.format(" + %d L", extra); } - tooltip.add(TextFormatting.GRAY + LocalizationUtils.format("gregtech.gui.amount_raw") + fluidAmount); + tooltip.addLine(TextFormatting.GRAY + LocalizationUtils.format("gregtech.gui.amount_raw") + fluidAmount); } } } diff --git a/src/main/java/gregtech/api/util/JEIUtil.java b/src/main/java/gregtech/api/util/JEIUtil.java index 08077c0a462..64729686dbf 100644 --- a/src/main/java/gregtech/api/util/JEIUtil.java +++ b/src/main/java/gregtech/api/util/JEIUtil.java @@ -1,10 +1,11 @@ package gregtech.api.util; -import net.minecraft.enchantment.EnchantmentData; +import gregtech.integration.jei.JustEnoughItemsModule; + +import net.minecraft.item.ItemStack; -import com.cleanroommc.modularui.integration.jei.JeiGhostIngredientSlot; import com.cleanroommc.modularui.integration.jei.ModularUIJeiPlugin; -import mezz.jei.Internal; +import com.cleanroommc.modularui.integration.recipeviewer.RecipeViewerGhostIngredientSlot; public class JEIUtil { @@ -12,18 +13,15 @@ public class JEIUtil { * Check if the player is currently hovering over a valid ingredient for this slot.
* Will always return false is JEI is not installed. */ - public static boolean hoveringOverIngredient(JeiGhostIngredientSlot jeiGhostIngredientSlot) { + public static boolean hoveringOverIngredient(RecipeViewerGhostIngredientSlot jeiGhostIngredientSlot) { if (!Mods.JustEnoughItems.isModLoaded()) return false; return ModularUIJeiPlugin.hoveringOverIngredient(jeiGhostIngredientSlot); } - public static Object getBookStackIfEnchantment(Object ingredient) { - if (ingredient instanceof EnchantmentData enchantmentData) { - return Internal.getIngredientRegistry() - .getIngredientHelper(enchantmentData) - .getCheatItemStack(enchantmentData); - } - - return ingredient; + public static ItemStack getActualStack(Object ingredient) { + if (!Mods.JustEnoughItems.isModLoaded()) return ItemStack.EMPTY; + return JustEnoughItemsModule.ingredientRegistry + .getIngredientHelper(ingredient) + .getCheatItemStack(ingredient); } } diff --git a/src/main/java/gregtech/client/utils/RenderUtil.java b/src/main/java/gregtech/client/utils/RenderUtil.java index 644966ea6f2..7ad7228b23a 100644 --- a/src/main/java/gregtech/client/utils/RenderUtil.java +++ b/src/main/java/gregtech/client/utils/RenderUtil.java @@ -29,9 +29,9 @@ import codechicken.lib.vec.Matrix4; import com.cleanroommc.modularui.api.widget.IWidget; import com.cleanroommc.modularui.drawable.GuiDraw; -import com.cleanroommc.modularui.integration.jei.JeiGhostIngredientSlot; -import com.cleanroommc.modularui.theme.WidgetSlotTheme; -import com.cleanroommc.modularui.theme.WidgetTheme; +import com.cleanroommc.modularui.integration.recipeviewer.RecipeViewerGhostIngredientSlot; +import com.cleanroommc.modularui.theme.SlotTheme; +import com.cleanroommc.modularui.theme.WidgetThemeEntry; import com.cleanroommc.modularui.utils.Color; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -706,36 +706,18 @@ public void put(int element, float @NotNull... data) { public static void drawItemStack(ItemStack itemStack, int x, int y, boolean drawCount) { int cache = itemStack.getCount(); if (!drawCount) itemStack.setCount(1); - drawItemStack(itemStack, x, y, null); + drawItemStack(itemStack, x, y); if (!drawCount) itemStack.setCount(cache); } @SideOnly(Side.CLIENT) - public static void drawItemStack(ItemStack itemStack, int x, int y, @Nullable String altTxt) { - drawItemStack(itemStack, x, y, 16, 16, altTxt); + public static void drawItemStack(ItemStack itemStack, int x, int y) { + drawItemStack(itemStack, x, y, 16, 16); } @SideOnly(Side.CLIENT) - public static void drawItemStack(ItemStack itemStack, int x, int y, int w, int h, @Nullable String altTxt) { - GlStateManager.pushMatrix(); - GlStateManager.translate(0.0F, 0.0F, 32.0F); - GlStateManager.scale(w / 16F, h / 16F, 1); - GlStateManager.color(1F, 1F, 1F, 1F); - GlStateManager.enableDepth(); - GlStateManager.enableRescaleNormal(); - GlStateManager.enableLighting(); - RenderHelper.enableGUIStandardItemLighting(); - OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 240.0f, 240.0f); - Minecraft mc = Minecraft.getMinecraft(); - RenderItem itemRender = mc.getRenderItem(); - itemRender.renderItemAndEffectIntoGUI(itemStack, x, y); - itemRender.renderItemOverlayIntoGUI(mc.fontRenderer, itemStack, x, y, altTxt); - GlStateManager.disableRescaleNormal(); - GlStateManager.disableLighting(); - GlStateManager.color(1F, 1F, 1F, 1F); - GlStateManager.popMatrix(); - GlStateManager.enableBlend(); - GlStateManager.disableDepth(); + public static void drawItemStack(ItemStack itemStack, int x, int y, int w, int h) { + GuiDraw.drawItem(itemStack, x, y, w, h, 0); } public static void drawSlotOverlay(@NotNull IWidget slot, int overlayColor) { @@ -744,33 +726,37 @@ public static void drawSlotOverlay(@NotNull IWidget slot, int overlayColor) { GlStateManager.colorMask(true, true, true, true); } - public static void drawSlotOverlay(@NotNull IWidget slot, WidgetTheme widgetTheme) { - drawSlotOverlay(slot, widgetTheme instanceof WidgetSlotTheme slotTheme ? slotTheme.getSlotHoverColor() : - defaultSlotHoverColor); + public static void drawSlotOverlay(@NotNull IWidget slot, SlotTheme theme) { + drawSlotOverlay(slot, theme.getSlotHoverColor()); } - public static void handleSlotOverlay(@NotNull IWidget slot, @NotNull WidgetTheme widgetTheme) { + public static void handleSlotOverlay(@NotNull IWidget slot, @NotNull WidgetThemeEntry themeEntry) { if (slot.isHovering()) { - drawSlotOverlay(slot, widgetTheme); + if (themeEntry.getTheme() instanceof SlotTheme slotTheme) { + drawSlotOverlay(slot, slotTheme); + } else { + drawSlotOverlay(slot, defaultSlotHoverColor); + } } } public static < - T extends IWidget & JeiGhostIngredientSlot> void drawJEIGhostSlotOverlay(@NotNull T jeiGhostIngredientSlot) { + T extends IWidget & RecipeViewerGhostIngredientSlot> void drawJEIGhostSlotOverlay(@NotNull T jeiGhostIngredientSlot) { GlStateManager.colorMask(true, true, true, false); jeiGhostIngredientSlot.drawHighlight(jeiGhostIngredientSlot.getArea(), jeiGhostIngredientSlot.isHovering()); GlStateManager.colorMask(true, true, true, true); } + @SuppressWarnings("UnusedReturnValue") public static < - T extends IWidget & JeiGhostIngredientSlot> boolean handleJEIGhostSlotOverlay(@NotNull T jeiGhostIngredientSlot, - @NotNull WidgetTheme widgetTheme) { + T extends IWidget & RecipeViewerGhostIngredientSlot> boolean handleJEIGhostSlotOverlay(@NotNull T jeiGhostIngredientSlot, + @NotNull WidgetThemeEntry themeEntry) { if (JEIUtil.hoveringOverIngredient(jeiGhostIngredientSlot)) { drawJEIGhostSlotOverlay(jeiGhostIngredientSlot); return true; } - handleSlotOverlay(jeiGhostIngredientSlot, widgetTheme); + handleSlotOverlay(jeiGhostIngredientSlot, themeEntry); return false; } } diff --git a/src/main/java/gregtech/common/covers/CoverConveyor.java b/src/main/java/gregtech/common/covers/CoverConveyor.java index b037492f993..8e10e7a0cc2 100644 --- a/src/main/java/gregtech/common/covers/CoverConveyor.java +++ b/src/main/java/gregtech/common/covers/CoverConveyor.java @@ -47,6 +47,7 @@ import com.cleanroommc.modularui.factory.GuiData; import com.cleanroommc.modularui.factory.SidedPosGuiData; import com.cleanroommc.modularui.screen.ModularPanel; +import com.cleanroommc.modularui.screen.UISettings; import com.cleanroommc.modularui.utils.Color; import com.cleanroommc.modularui.utils.MouseData; import com.cleanroommc.modularui.value.sync.EnumSyncValue; @@ -503,7 +504,7 @@ public boolean usesMui2() { } @Override - public ModularPanel buildUI(SidedPosGuiData guiData, PanelSyncManager guiSyncManager) { + public ModularPanel buildUI(SidedPosGuiData guiData, PanelSyncManager guiSyncManager, UISettings settings) { var panel = GTGuis.createPanel(this, 176, 192 + 18); getItemFilterContainer().setMaxTransferSize(getMaxStackSize()); diff --git a/src/main/java/gregtech/common/covers/CoverFluidFilter.java b/src/main/java/gregtech/common/covers/CoverFluidFilter.java index a0b6585ebd7..e178b0441de 100644 --- a/src/main/java/gregtech/common/covers/CoverFluidFilter.java +++ b/src/main/java/gregtech/common/covers/CoverFluidFilter.java @@ -36,6 +36,7 @@ import com.cleanroommc.modularui.drawable.Rectangle; import com.cleanroommc.modularui.factory.SidedPosGuiData; import com.cleanroommc.modularui.screen.ModularPanel; +import com.cleanroommc.modularui.screen.UISettings; import com.cleanroommc.modularui.utils.Alignment; import com.cleanroommc.modularui.utils.Color; import com.cleanroommc.modularui.value.sync.BooleanSyncValue; @@ -144,7 +145,7 @@ public boolean usesMui2() { } @Override - public ModularPanel buildUI(SidedPosGuiData guiData, PanelSyncManager guiSyncManager) { + public ModularPanel buildUI(SidedPosGuiData guiData, PanelSyncManager guiSyncManager, UISettings settings) { var filteringMode = new EnumSyncValue<>(FluidFilterMode.class, this::getFilterMode, this::setFilterMode); guiSyncManager.syncValue("filtering_mode", filteringMode); @@ -180,7 +181,7 @@ public ModularPanel buildUI(SidedPosGuiData guiData, PanelSyncManager guiSyncMan .child(new Rectangle().setColor(UI_TEXT_COLOR).asWidget() .height(1).widthRel(0.95f).margin(0, 4)) .child(getFilter().createWidgets(guiSyncManager))) - .child(SlotGroupWidget.playerInventory().bottom(7).left(7)); + .child(SlotGroupWidget.playerInventory(false).bottom(7).left(7)); } @Override diff --git a/src/main/java/gregtech/common/covers/CoverFluidRegulator.java b/src/main/java/gregtech/common/covers/CoverFluidRegulator.java index 141b51e0552..a3cf6bcbf96 100644 --- a/src/main/java/gregtech/common/covers/CoverFluidRegulator.java +++ b/src/main/java/gregtech/common/covers/CoverFluidRegulator.java @@ -23,6 +23,7 @@ import com.cleanroommc.modularui.factory.GuiData; import com.cleanroommc.modularui.factory.SidedPosGuiData; import com.cleanroommc.modularui.screen.ModularPanel; +import com.cleanroommc.modularui.screen.UISettings; import com.cleanroommc.modularui.utils.Color; import com.cleanroommc.modularui.value.sync.EnumSyncValue; import com.cleanroommc.modularui.value.sync.PanelSyncManager; @@ -243,8 +244,8 @@ private boolean shouldDisplayAmountSlider() { } @Override - public ModularPanel buildUI(SidedPosGuiData guiData, PanelSyncManager guiSyncManager) { - return super.buildUI(guiData, guiSyncManager).height(192 + 36); + public ModularPanel buildUI(SidedPosGuiData guiData, PanelSyncManager guiSyncManager, UISettings settings) { + return super.buildUI(guiData, guiSyncManager, settings).height(192 + 36); } @Override diff --git a/src/main/java/gregtech/common/covers/CoverFluidVoiding.java b/src/main/java/gregtech/common/covers/CoverFluidVoiding.java index 4bd8472b55f..750a97de15f 100644 --- a/src/main/java/gregtech/common/covers/CoverFluidVoiding.java +++ b/src/main/java/gregtech/common/covers/CoverFluidVoiding.java @@ -28,6 +28,7 @@ import com.cleanroommc.modularui.factory.GuiData; import com.cleanroommc.modularui.factory.SidedPosGuiData; import com.cleanroommc.modularui.screen.ModularPanel; +import com.cleanroommc.modularui.screen.UISettings; import com.cleanroommc.modularui.utils.Color; import com.cleanroommc.modularui.value.sync.BooleanSyncValue; import com.cleanroommc.modularui.value.sync.PanelSyncManager; @@ -72,8 +73,8 @@ public void renderCover(@NotNull CCRenderState renderState, @NotNull Matrix4 tra } @Override - public ModularPanel buildUI(SidedPosGuiData guiData, PanelSyncManager guiSyncManager) { - return super.buildUI(guiData, guiSyncManager).height(192 - 22); + public ModularPanel buildUI(SidedPosGuiData guiData, PanelSyncManager guiSyncManager, UISettings settings) { + return super.buildUI(guiData, guiSyncManager, settings).height(192 - 22); } @Override diff --git a/src/main/java/gregtech/common/covers/CoverFluidVoidingAdvanced.java b/src/main/java/gregtech/common/covers/CoverFluidVoidingAdvanced.java index b6a9e1cd1e5..84f722c39c6 100644 --- a/src/main/java/gregtech/common/covers/CoverFluidVoidingAdvanced.java +++ b/src/main/java/gregtech/common/covers/CoverFluidVoidingAdvanced.java @@ -23,6 +23,7 @@ import com.cleanroommc.modularui.factory.GuiData; import com.cleanroommc.modularui.factory.SidedPosGuiData; import com.cleanroommc.modularui.screen.ModularPanel; +import com.cleanroommc.modularui.screen.UISettings; import com.cleanroommc.modularui.utils.Color; import com.cleanroommc.modularui.value.sync.EnumSyncValue; import com.cleanroommc.modularui.value.sync.PanelSyncManager; @@ -101,8 +102,8 @@ public VoidingMode getVoidingMode() { } @Override - public ModularPanel buildUI(SidedPosGuiData guiData, PanelSyncManager guiSyncManager) { - return super.buildUI(guiData, guiSyncManager).height(192 + 20); + public ModularPanel buildUI(SidedPosGuiData guiData, PanelSyncManager guiSyncManager, UISettings settings) { + return super.buildUI(guiData, guiSyncManager, settings).height(192 + 20); } @Override diff --git a/src/main/java/gregtech/common/covers/CoverItemFilter.java b/src/main/java/gregtech/common/covers/CoverItemFilter.java index 8c667ad8ce7..35a418d50cd 100644 --- a/src/main/java/gregtech/common/covers/CoverItemFilter.java +++ b/src/main/java/gregtech/common/covers/CoverItemFilter.java @@ -35,6 +35,7 @@ import com.cleanroommc.modularui.drawable.Rectangle; import com.cleanroommc.modularui.factory.SidedPosGuiData; import com.cleanroommc.modularui.screen.ModularPanel; +import com.cleanroommc.modularui.screen.UISettings; import com.cleanroommc.modularui.utils.Alignment; import com.cleanroommc.modularui.utils.Color; import com.cleanroommc.modularui.value.sync.BooleanSyncValue; @@ -147,7 +148,7 @@ public boolean usesMui2() { } @Override - public ModularPanel buildUI(SidedPosGuiData guiData, PanelSyncManager guiSyncManager) { + public ModularPanel buildUI(SidedPosGuiData guiData, PanelSyncManager guiSyncManager, UISettings settings) { var filteringMode = new EnumSyncValue<>(ItemFilterMode.class, this::getFilterMode, this::setFilterMode); guiSyncManager.syncValue("filtering_mode", filteringMode); @@ -182,7 +183,7 @@ public ModularPanel buildUI(SidedPosGuiData guiData, PanelSyncManager guiSyncMan .child(new Rectangle().setColor(UI_TEXT_COLOR).asWidget() .height(1).widthRel(0.95f).margin(0, 4)) .child(getFilter().createWidgets(guiSyncManager).left(0))) - .child(SlotGroupWidget.playerInventory().bottom(7).left(7)); + .child(SlotGroupWidget.playerInventory(false).bottom(7).left(7)); } @Override diff --git a/src/main/java/gregtech/common/covers/CoverItemVoiding.java b/src/main/java/gregtech/common/covers/CoverItemVoiding.java index e8129ec11f3..234ebb70fcc 100644 --- a/src/main/java/gregtech/common/covers/CoverItemVoiding.java +++ b/src/main/java/gregtech/common/covers/CoverItemVoiding.java @@ -25,6 +25,7 @@ import com.cleanroommc.modularui.factory.GuiData; import com.cleanroommc.modularui.factory.SidedPosGuiData; import com.cleanroommc.modularui.screen.ModularPanel; +import com.cleanroommc.modularui.screen.UISettings; import com.cleanroommc.modularui.utils.Color; import com.cleanroommc.modularui.value.sync.BooleanSyncValue; import com.cleanroommc.modularui.value.sync.PanelSyncManager; @@ -73,8 +74,8 @@ void voidAny(IItemHandler myItemHandler) { } @Override - public ModularPanel buildUI(SidedPosGuiData guiData, PanelSyncManager guiSyncManager) { - return super.buildUI(guiData, guiSyncManager).height(192 - 22); + public ModularPanel buildUI(SidedPosGuiData guiData, PanelSyncManager guiSyncManager, UISettings settings) { + return super.buildUI(guiData, guiSyncManager, settings).height(192 - 22); } @Override diff --git a/src/main/java/gregtech/common/covers/CoverItemVoidingAdvanced.java b/src/main/java/gregtech/common/covers/CoverItemVoidingAdvanced.java index b739e7e6e1f..1a716509505 100644 --- a/src/main/java/gregtech/common/covers/CoverItemVoidingAdvanced.java +++ b/src/main/java/gregtech/common/covers/CoverItemVoidingAdvanced.java @@ -20,6 +20,7 @@ import com.cleanroommc.modularui.factory.GuiData; import com.cleanroommc.modularui.factory.SidedPosGuiData; import com.cleanroommc.modularui.screen.ModularPanel; +import com.cleanroommc.modularui.screen.UISettings; import com.cleanroommc.modularui.utils.Color; import com.cleanroommc.modularui.value.sync.EnumSyncValue; import com.cleanroommc.modularui.value.sync.PanelSyncManager; @@ -89,8 +90,8 @@ protected void voidOverflow(IItemHandler myItemHandler) { } @Override - public ModularPanel buildUI(SidedPosGuiData guiData, PanelSyncManager guiSyncManager) { - return super.buildUI(guiData, guiSyncManager).height(192 + 18); + public ModularPanel buildUI(SidedPosGuiData guiData, PanelSyncManager guiSyncManager, UISettings settings) { + return super.buildUI(guiData, guiSyncManager, settings).height(192 + 18); } @Override diff --git a/src/main/java/gregtech/common/covers/CoverMachineController.java b/src/main/java/gregtech/common/covers/CoverMachineController.java index 545f3cde52e..3a97582a9bc 100644 --- a/src/main/java/gregtech/common/covers/CoverMachineController.java +++ b/src/main/java/gregtech/common/covers/CoverMachineController.java @@ -25,6 +25,7 @@ import com.cleanroommc.modularui.drawable.Rectangle; import com.cleanroommc.modularui.factory.SidedPosGuiData; import com.cleanroommc.modularui.screen.ModularPanel; +import com.cleanroommc.modularui.screen.UISettings; import com.cleanroommc.modularui.utils.Alignment; import com.cleanroommc.modularui.value.BoolValue; import com.cleanroommc.modularui.value.sync.BooleanSyncValue; @@ -111,7 +112,7 @@ public boolean usesMui2() { } @Override - public ModularPanel buildUI(SidedPosGuiData guiData, PanelSyncManager guiSyncManager) { + public ModularPanel buildUI(SidedPosGuiData guiData, PanelSyncManager guiSyncManager, UISettings settings) { EnumSyncValue controllerModeValue = new EnumSyncValue<>(ControllerMode.class, this::getControllerMode, this::setControllerMode); BooleanSyncValue invertedValue = new BooleanSyncValue(this::isInverted, this::setInverted); diff --git a/src/main/java/gregtech/common/covers/CoverPump.java b/src/main/java/gregtech/common/covers/CoverPump.java index 659b916e80b..29bf0b2b52c 100644 --- a/src/main/java/gregtech/common/covers/CoverPump.java +++ b/src/main/java/gregtech/common/covers/CoverPump.java @@ -45,6 +45,7 @@ import com.cleanroommc.modularui.factory.GuiData; import com.cleanroommc.modularui.factory.SidedPosGuiData; import com.cleanroommc.modularui.screen.ModularPanel; +import com.cleanroommc.modularui.screen.UISettings; import com.cleanroommc.modularui.utils.Color; import com.cleanroommc.modularui.utils.MouseData; import com.cleanroommc.modularui.value.sync.EnumSyncValue; @@ -189,7 +190,7 @@ public boolean usesMui2() { } @Override - public ModularPanel buildUI(SidedPosGuiData guiData, PanelSyncManager guiSyncManager) { + public ModularPanel buildUI(SidedPosGuiData guiData, PanelSyncManager guiSyncManager, UISettings settings) { var panel = GTGuis.createPanel(this, 176, 192); getFluidFilterContainer().setMaxTransferSize(getMaxTransferRate()); diff --git a/src/main/java/gregtech/common/covers/CoverRoboticArm.java b/src/main/java/gregtech/common/covers/CoverRoboticArm.java index b1b99657adf..31918dbcaac 100644 --- a/src/main/java/gregtech/common/covers/CoverRoboticArm.java +++ b/src/main/java/gregtech/common/covers/CoverRoboticArm.java @@ -22,6 +22,7 @@ import com.cleanroommc.modularui.factory.GuiData; import com.cleanroommc.modularui.factory.SidedPosGuiData; import com.cleanroommc.modularui.screen.ModularPanel; +import com.cleanroommc.modularui.screen.UISettings; import com.cleanroommc.modularui.utils.Color; import com.cleanroommc.modularui.value.sync.EnumSyncValue; import com.cleanroommc.modularui.value.sync.PanelSyncManager; @@ -192,8 +193,8 @@ private boolean shouldDisplayAmountSlider() { } @Override - public ModularPanel buildUI(SidedPosGuiData guiData, PanelSyncManager guiSyncManager) { - return super.buildUI(guiData, guiSyncManager).height(192 + 36 + 18 + 2); + public ModularPanel buildUI(SidedPosGuiData guiData, PanelSyncManager guiSyncManager, UISettings settings) { + return super.buildUI(guiData, guiSyncManager, settings).height(192 + 36 + 18 + 2); } @Override diff --git a/src/main/java/gregtech/common/covers/CoverStorage.java b/src/main/java/gregtech/common/covers/CoverStorage.java index 4d4f35a5ec1..addf992cd3b 100644 --- a/src/main/java/gregtech/common/covers/CoverStorage.java +++ b/src/main/java/gregtech/common/covers/CoverStorage.java @@ -25,10 +25,11 @@ import com.cleanroommc.modularui.api.widget.IWidget; import com.cleanroommc.modularui.factory.SidedPosGuiData; import com.cleanroommc.modularui.screen.ModularPanel; +import com.cleanroommc.modularui.screen.UISettings; import com.cleanroommc.modularui.value.sync.PanelSyncManager; import com.cleanroommc.modularui.value.sync.SyncHandlers; -import com.cleanroommc.modularui.widgets.ItemSlot; import com.cleanroommc.modularui.widgets.layout.Grid; +import com.cleanroommc.modularui.widgets.slot.ItemSlot; import org.jetbrains.annotations.NotNull; import java.util.ArrayList; @@ -86,7 +87,7 @@ public boolean usesMui2() { } @Override - public ModularPanel buildUI(SidedPosGuiData guiData, PanelSyncManager guiSyncManager) { + public ModularPanel buildUI(SidedPosGuiData guiData, PanelSyncManager guiSyncManager, UISettings settings) { guiSyncManager.registerSlotGroup("item_inv", this.storageHandler.getSlots()); int rowSize = this.storageHandler.getSlots(); diff --git a/src/main/java/gregtech/common/covers/ender/CoverAbstractEnderLink.java b/src/main/java/gregtech/common/covers/ender/CoverAbstractEnderLink.java index 29e7e9a0b9a..f37a17d39fd 100644 --- a/src/main/java/gregtech/common/covers/ender/CoverAbstractEnderLink.java +++ b/src/main/java/gregtech/common/covers/ender/CoverAbstractEnderLink.java @@ -33,6 +33,7 @@ import com.cleanroommc.modularui.factory.SidedPosGuiData; import com.cleanroommc.modularui.network.NetworkUtils; import com.cleanroommc.modularui.screen.ModularPanel; +import com.cleanroommc.modularui.screen.UISettings; import com.cleanroommc.modularui.utils.Color; import com.cleanroommc.modularui.value.sync.BooleanSyncValue; import com.cleanroommc.modularui.value.sync.PanelSyncHandler; @@ -136,7 +137,7 @@ public boolean usesMui2() { } @Override - public ModularPanel buildUI(SidedPosGuiData guiData, PanelSyncManager guiSyncManager) { + public ModularPanel buildUI(SidedPosGuiData guiData, PanelSyncManager guiSyncManager, UISettings settings) { var panel = GTGuis.createPanel(this, 176, 192); this.playerUUID = guiData.getPlayer().getUniqueID(); @@ -362,7 +363,7 @@ protected IWidget createRow(final String name, final PanelSyncManager syncManage .background(GTGuiTextures.SLOT.asIcon().size(18)) .top(1)) .child(new InteractableText<>(entry, this::updateColor) - .tooltip(tooltip -> tooltip.setAutoUpdate(true)) + .tooltipAutoUpdate(true) .tooltipBuilder(tooltip -> { String desc = entry.getDescription(); if (!desc.isEmpty()) tooltip.add(desc); diff --git a/src/main/java/gregtech/common/covers/filter/BaseFilter.java b/src/main/java/gregtech/common/covers/filter/BaseFilter.java index b0a312b6e1e..1bc6bc8f2d6 100644 --- a/src/main/java/gregtech/common/covers/filter/BaseFilter.java +++ b/src/main/java/gregtech/common/covers/filter/BaseFilter.java @@ -21,7 +21,6 @@ import com.cleanroommc.modularui.widget.Widget; import com.cleanroommc.modularui.widgets.CycleButtonWidget; import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; public abstract class BaseFilter implements IFilter { @@ -64,14 +63,14 @@ public final ItemStack getContainerStack() { return this.getFilterReader().getContainer(); } - public static @Nullable BaseFilter getFilterFromStack(ItemStack stack) { + public static @NotNull BaseFilter getFilterFromStack(ItemStack stack) { if (stack.getItem() instanceof MetaItemmetaItem) { var metaValueItem = metaItem.getItem(stack); var factory = metaValueItem == null ? null : metaValueItem.getFilterFactory(); if (factory != null) return factory.create(stack); } - return null; + return ERROR_FILTER; } public final void setBlacklistFilter(boolean blacklistFilter) { diff --git a/src/main/java/gregtech/common/covers/filter/BaseFilterContainer.java b/src/main/java/gregtech/common/covers/filter/BaseFilterContainer.java index d1c2fe60e7b..b2a08d4f580 100644 --- a/src/main/java/gregtech/common/covers/filter/BaseFilterContainer.java +++ b/src/main/java/gregtech/common/covers/filter/BaseFilterContainer.java @@ -20,8 +20,8 @@ import com.cleanroommc.modularui.value.sync.PanelSyncManager; import com.cleanroommc.modularui.value.sync.SyncHandlers; import com.cleanroommc.modularui.widgets.ButtonWidget; -import com.cleanroommc.modularui.widgets.ItemSlot; import com.cleanroommc.modularui.widgets.layout.Flow; +import com.cleanroommc.modularui.widgets.slot.ItemSlot; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -213,9 +213,10 @@ public void handleLegacyNBT(NBTTagCompound nbt) { /** Uses Cleanroom MUI */ public IWidget initUI(GuiData data, PanelSyncManager manager) { IPanelHandler panel = manager.panel("filter_panel", (syncManager, syncHandler) -> { - var filter = hasFilter() ? getFilter() : BaseFilter.ERROR_FILTER; - filter.setMaxTransferSize(getMaxTransferSize()); - return filter.createPopupPanel(syncManager); + if (hasFilter()) { + return getFilter().createPopupPanel(syncManager); + } + return BaseFilter.ERROR_FILTER.createPopupPanel(syncManager); }, true); return Flow.row().coverChildrenHeight() @@ -225,7 +226,7 @@ public IWidget initUI(GuiData data, PanelSyncManager manager) { .filter(this::isItemValid) .singletonSlotGroup(101) .changeListener((newItem, onlyAmountChanged, client, init) -> { - if (!isItemValid(newItem) && panel.isPanelOpen()) { + if (!isItemValid(newItem) || (newItem.isEmpty() && panel.isPanelOpen())) { panel.closePanel(); } })) @@ -238,6 +239,7 @@ public IWidget initUI(GuiData data, PanelSyncManager manager) { .setEnabledIf(w -> hasFilter()) .onMousePressed(i -> { if (!panel.isPanelOpen()) { + setMaxTransferSize(getMaxTransferSize()); panel.openPanel(); } else { panel.closePanel(); diff --git a/src/main/java/gregtech/common/covers/filter/FluidFilterContainer.java b/src/main/java/gregtech/common/covers/filter/FluidFilterContainer.java index 635854a9ab8..7dee10a1032 100644 --- a/src/main/java/gregtech/common/covers/filter/FluidFilterContainer.java +++ b/src/main/java/gregtech/common/covers/filter/FluidFilterContainer.java @@ -53,7 +53,7 @@ public void blacklistUI(int y, Consumer widgetGroup, Bo @Override protected boolean isItemValid(ItemStack stack) { var filter = BaseFilter.getFilterFromStack(stack); - return filter != null && filter.getType() == IFilter.FilterType.FLUID; + return filter != BaseFilter.ERROR_FILTER && filter.getType() == IFilter.FilterType.FLUID; } @Override diff --git a/src/main/java/gregtech/common/covers/filter/ItemFilterContainer.java b/src/main/java/gregtech/common/covers/filter/ItemFilterContainer.java index 2cc171b62ce..514d3d80e31 100644 --- a/src/main/java/gregtech/common/covers/filter/ItemFilterContainer.java +++ b/src/main/java/gregtech/common/covers/filter/ItemFilterContainer.java @@ -54,7 +54,7 @@ public void blacklistUI(int y, Consumer widgetGroup, Bo @Override protected boolean isItemValid(ItemStack stack) { var filter = BaseFilter.getFilterFromStack(stack); - return filter != null && filter.getType() == IFilter.FilterType.ITEM; + return filter != BaseFilter.ERROR_FILTER && filter.getType() == IFilter.FilterType.ITEM; } @Override diff --git a/src/main/java/gregtech/common/covers/filter/SimpleItemFilter.java b/src/main/java/gregtech/common/covers/filter/SimpleItemFilter.java index dbeabae9c0b..abd858833a5 100644 --- a/src/main/java/gregtech/common/covers/filter/SimpleItemFilter.java +++ b/src/main/java/gregtech/common/covers/filter/SimpleItemFilter.java @@ -24,9 +24,9 @@ import com.cleanroommc.modularui.value.sync.SyncHandlers; import com.cleanroommc.modularui.widget.Widget; import com.cleanroommc.modularui.widgets.CycleButtonWidget; -import com.cleanroommc.modularui.widgets.ItemSlot; import com.cleanroommc.modularui.widgets.SlotGroupWidget; import com.cleanroommc.modularui.widgets.layout.Flow; +import com.cleanroommc.modularui.widgets.slot.PhantomItemSlot; import com.cleanroommc.modularui.widgets.slot.SlotGroup; import org.jetbrains.annotations.NotNull; @@ -118,32 +118,31 @@ public void initUI(Consumer widgetGroup) { .matrix("XXX", "XXX", "XXX") - .key('X', index -> new ItemSlot() - .tooltip(tooltip -> { - tooltip.setAutoUpdate(true); - tooltip.textColor(Color.GREY.main); - }) + .key('X', index -> new PhantomItemSlot() + .slot(SyncHandlers.itemSlot(this.filterReader, index) + .ignoreMaxStackSize(true) + .slotGroup(filterInventory) + .changeListener((newItem, onlyAmountChanged, client, init) -> { + if (onlyAmountChanged && !init) { + markDirty(); + } + })) + .tooltipAutoUpdate(true) + .tooltipTextColor(Color.GREY.main) .tooltipBuilder(tooltip -> { if (dirtyNotifiable instanceof CoverRoboticArm coverArm && coverArm.getTransferMode() != TransferMode.TRANSFER_ANY || dirtyNotifiable instanceof CoverItemVoidingAdvanced coverItem && coverItem.getVoidingMode() != VoidingMode.VOID_ANY) { - tooltip.addLine(IKey.lang("cover.item_filter.config_amount")); int count = this.filterReader.getTagAt(index) .getInteger(SimpleItemFilterReader.COUNT); - if (count > 0) + if (count > 0) { + tooltip.addLine(IKey.lang("cover.item_filter.config_amount")); tooltip.addLine( IKey.str("Count: %s", TextFormattingUtil.formatNumbers(count))); + } } - }) - .slot(SyncHandlers.phantomItemSlot(this.filterReader, index) - .ignoreMaxStackSize(true) - .slotGroup(filterInventory) - .changeListener((newItem, onlyAmountChanged, client, init) -> { - if (onlyAmountChanged && !init) { - markDirty(); - } - }))) + })) .build().marginRight(4)) .child(Flow.column().width(18).coverChildren() .child(createBlacklistUI()) diff --git a/src/main/java/gregtech/common/gui/widget/appeng/slot/AEItemConfigSlot.java b/src/main/java/gregtech/common/gui/widget/appeng/slot/AEItemConfigSlot.java index cdfbf73b28b..aa66bdf9412 100644 --- a/src/main/java/gregtech/common/gui/widget/appeng/slot/AEItemConfigSlot.java +++ b/src/main/java/gregtech/common/gui/widget/appeng/slot/AEItemConfigSlot.java @@ -54,7 +54,7 @@ public void drawInBackground(int mouseX, int mouseY, float partialTicks, IRender if (config != null) { ItemStack stack = config.createItemStack(); stack.setCount(1); - RenderUtil.drawItemStack(stack, stackX, stackY, null); + RenderUtil.drawItemStack(stack, stackX, stackY); // Only draw the config amount if not stocking, as its meaningless when stocking if (!pw.isStocking()) { @@ -65,7 +65,7 @@ public void drawInBackground(int mouseX, int mouseY, float partialTicks, IRender if (stock != null) { ItemStack stack = stock.createItemStack(); stack.setCount(1); - RenderUtil.drawItemStack(stack, stackX + DISPLAY_X_OFFSET, stackY, null); + RenderUtil.drawItemStack(stack, stackX + DISPLAY_X_OFFSET, stackY); String amountStr = TextFormattingUtil.formatLongToCompactString(stock.getStackSize(), 4); drawStringFixedCorner(amountStr, stackX + DISPLAY_X_OFFSET + 17, stackY + 17, 16777215, true, 0.5f); } diff --git a/src/main/java/gregtech/common/gui/widget/appeng/slot/AEItemDisplayWidget.java b/src/main/java/gregtech/common/gui/widget/appeng/slot/AEItemDisplayWidget.java index 5bea8547e41..8ccc48590a4 100644 --- a/src/main/java/gregtech/common/gui/widget/appeng/slot/AEItemDisplayWidget.java +++ b/src/main/java/gregtech/common/gui/widget/appeng/slot/AEItemDisplayWidget.java @@ -40,7 +40,7 @@ public void drawInBackground(int mouseX, int mouseY, float partialTicks, IRender if (item != null) { ItemStack realStack = item.createItemStack(); realStack.setCount(1); - RenderUtil.drawItemStack(realStack, stackX, stackY, null); + RenderUtil.drawItemStack(realStack, stackX, stackY); String amountStr = String.format("x%,d", item.getStackSize()); drawText(amountStr, stackX + 20, stackY + 5, 1, 0xFFFFFFFF); } diff --git a/src/main/java/gregtech/common/items/behaviors/IntCircuitBehaviour.java b/src/main/java/gregtech/common/items/behaviors/IntCircuitBehaviour.java index f7523d976d1..8677fcfe582 100644 --- a/src/main/java/gregtech/common/items/behaviors/IntCircuitBehaviour.java +++ b/src/main/java/gregtech/common/items/behaviors/IntCircuitBehaviour.java @@ -25,6 +25,7 @@ import com.cleanroommc.modularui.drawable.ItemDrawable; import com.cleanroommc.modularui.factory.HandGuiData; import com.cleanroommc.modularui.screen.ModularPanel; +import com.cleanroommc.modularui.screen.UISettings; import com.cleanroommc.modularui.value.sync.InteractionSyncHandler; import com.cleanroommc.modularui.value.sync.PanelSyncManager; import com.cleanroommc.modularui.widgets.ButtonWidget; @@ -65,7 +66,7 @@ public ActionResult onItemRightClick(World world, EntityPlayer player } @Override - public ModularPanel buildUI(HandGuiData guiData, PanelSyncManager guiSyncManager) { + public ModularPanel buildUI(HandGuiData guiData, PanelSyncManager guiSyncManager, UISettings settings) { var panel = GTGuis.createPanel(guiData.getUsedItemStack(), 176, 120); ItemDrawable circuitPreview = new ItemDrawable(guiData.getUsedItemStack()); for (int i = 0; i <= 32; i++) { diff --git a/src/main/java/gregtech/common/items/behaviors/filter/BaseFilterUIManager.java b/src/main/java/gregtech/common/items/behaviors/filter/BaseFilterUIManager.java index cbddb18d305..91161663700 100644 --- a/src/main/java/gregtech/common/items/behaviors/filter/BaseFilterUIManager.java +++ b/src/main/java/gregtech/common/items/behaviors/filter/BaseFilterUIManager.java @@ -17,6 +17,7 @@ import com.cleanroommc.modularui.factory.HandGuiData; import com.cleanroommc.modularui.screen.ModularPanel; +import com.cleanroommc.modularui.screen.UISettings; import com.cleanroommc.modularui.value.sync.PanelSyncManager; import java.util.List; @@ -36,7 +37,7 @@ public final ActionResult onItemRightClick(World world, EntityPlayer } @Override - public abstract ModularPanel buildUI(HandGuiData guiData, PanelSyncManager guiSyncManager); + public abstract ModularPanel buildUI(HandGuiData guiData, PanelSyncManager guiSyncManager, UISettings settings); protected final ModularPanel createBasePanel(ItemStack stack) { return GTGuis.createPanel(stack, 176, 188) diff --git a/src/main/java/gregtech/common/items/behaviors/filter/OreDictFilterUIManager.java b/src/main/java/gregtech/common/items/behaviors/filter/OreDictFilterUIManager.java index f38182f9f5c..08e19f607cf 100644 --- a/src/main/java/gregtech/common/items/behaviors/filter/OreDictFilterUIManager.java +++ b/src/main/java/gregtech/common/items/behaviors/filter/OreDictFilterUIManager.java @@ -4,16 +4,17 @@ import com.cleanroommc.modularui.factory.HandGuiData; import com.cleanroommc.modularui.screen.ModularPanel; +import com.cleanroommc.modularui.screen.UISettings; import com.cleanroommc.modularui.value.sync.PanelSyncManager; import com.cleanroommc.modularui.widgets.SlotGroupWidget; public class OreDictFilterUIManager extends BaseFilterUIManager { @Override - public ModularPanel buildUI(HandGuiData guiData, PanelSyncManager guiSyncManager) { + public ModularPanel buildUI(HandGuiData guiData, PanelSyncManager guiSyncManager, UISettings settings) { var filter = BaseFilter.getFilterFromStack(guiData.getUsedItemStack()); return createBasePanel(filter.getContainerStack()).height(160) .child(filter.createWidgets(guiSyncManager).top(22).margin(7, 0)) - .child(SlotGroupWidget.playerInventory().bottom(7).left(7)); + .child(SlotGroupWidget.playerInventory(true)); } } diff --git a/src/main/java/gregtech/common/items/behaviors/filter/SimpleFilterUIManager.java b/src/main/java/gregtech/common/items/behaviors/filter/SimpleFilterUIManager.java index ee8062618a4..eb33ca66fcb 100644 --- a/src/main/java/gregtech/common/items/behaviors/filter/SimpleFilterUIManager.java +++ b/src/main/java/gregtech/common/items/behaviors/filter/SimpleFilterUIManager.java @@ -4,16 +4,20 @@ import com.cleanroommc.modularui.factory.HandGuiData; import com.cleanroommc.modularui.screen.ModularPanel; +import com.cleanroommc.modularui.screen.UISettings; import com.cleanroommc.modularui.value.sync.PanelSyncManager; import com.cleanroommc.modularui.widgets.SlotGroupWidget; public class SimpleFilterUIManager extends BaseFilterUIManager { @Override - public ModularPanel buildUI(HandGuiData guiData, PanelSyncManager guiSyncManager) { + public ModularPanel buildUI(HandGuiData guiData, PanelSyncManager guiSyncManager, UISettings settings) { var filter = BaseFilter.getFilterFromStack(guiData.getUsedItemStack()); - return createBasePanel(filter.getContainerStack()).padding(4).height(166) - .child(filter.createWidgets(guiSyncManager).top(22).left(7)) - .child(SlotGroupWidget.playerInventory().left(7)); + return createBasePanel(filter.getContainerStack()) + .height(166) + .child(filter.createWidgets(guiSyncManager) + .top(22) + .left(7)) + .child(SlotGroupWidget.playerInventory(true)); } } diff --git a/src/main/java/gregtech/common/items/behaviors/filter/SimpleFluidFilterUIManager.java b/src/main/java/gregtech/common/items/behaviors/filter/SimpleFluidFilterUIManager.java index 64164c932fd..915746faacd 100644 --- a/src/main/java/gregtech/common/items/behaviors/filter/SimpleFluidFilterUIManager.java +++ b/src/main/java/gregtech/common/items/behaviors/filter/SimpleFluidFilterUIManager.java @@ -4,16 +4,20 @@ import com.cleanroommc.modularui.factory.HandGuiData; import com.cleanroommc.modularui.screen.ModularPanel; +import com.cleanroommc.modularui.screen.UISettings; import com.cleanroommc.modularui.value.sync.PanelSyncManager; import com.cleanroommc.modularui.widgets.SlotGroupWidget; public class SimpleFluidFilterUIManager extends BaseFilterUIManager { @Override - public ModularPanel buildUI(HandGuiData guiData, PanelSyncManager guiSyncManager) { + public ModularPanel buildUI(HandGuiData guiData, PanelSyncManager guiSyncManager, UISettings settings) { var filter = BaseFilter.getFilterFromStack(guiData.getUsedItemStack()); - return createBasePanel(filter.getContainerStack()).padding(4).height(166) - .child(filter.createWidgets(guiSyncManager).top(22).left(7)) - .child(SlotGroupWidget.playerInventory().left(7)); + return createBasePanel(filter.getContainerStack()) + .height(166) + .child(filter.createWidgets(guiSyncManager) + .top(22) + .left(7)) + .child(SlotGroupWidget.playerInventory(true)); } } diff --git a/src/main/java/gregtech/common/items/behaviors/filter/SmartFilterUIManager.java b/src/main/java/gregtech/common/items/behaviors/filter/SmartFilterUIManager.java index 3fc047deae6..0f8f96ed76a 100644 --- a/src/main/java/gregtech/common/items/behaviors/filter/SmartFilterUIManager.java +++ b/src/main/java/gregtech/common/items/behaviors/filter/SmartFilterUIManager.java @@ -4,16 +4,17 @@ import com.cleanroommc.modularui.factory.HandGuiData; import com.cleanroommc.modularui.screen.ModularPanel; +import com.cleanroommc.modularui.screen.UISettings; import com.cleanroommc.modularui.value.sync.PanelSyncManager; import com.cleanroommc.modularui.widgets.SlotGroupWidget; public class SmartFilterUIManager extends BaseFilterUIManager { @Override - public ModularPanel buildUI(HandGuiData guiData, PanelSyncManager guiSyncManager) { + public ModularPanel buildUI(HandGuiData guiData, PanelSyncManager guiSyncManager, UISettings settings) { var filter = BaseFilter.getFilterFromStack(guiData.getUsedItemStack()); return createBasePanel(filter.getContainerStack()).height(166) .child(filter.createWidgets(guiSyncManager).left(7).top(22)) - .child(SlotGroupWidget.playerInventory().bottom(7).left(7)); + .child(SlotGroupWidget.playerInventory(true)); } } diff --git a/src/main/java/gregtech/common/metatileentities/electric/MetaTileEntityBatteryBuffer.java b/src/main/java/gregtech/common/metatileentities/electric/MetaTileEntityBatteryBuffer.java index 88caa0adc19..ca26c1cba5c 100644 --- a/src/main/java/gregtech/common/metatileentities/electric/MetaTileEntityBatteryBuffer.java +++ b/src/main/java/gregtech/common/metatileentities/electric/MetaTileEntityBatteryBuffer.java @@ -38,11 +38,12 @@ import com.cleanroommc.modularui.api.widget.IWidget; import com.cleanroommc.modularui.factory.PosGuiData; import com.cleanroommc.modularui.screen.ModularPanel; +import com.cleanroommc.modularui.screen.UISettings; import com.cleanroommc.modularui.value.sync.PanelSyncManager; import com.cleanroommc.modularui.value.sync.SyncHandlers; -import com.cleanroommc.modularui.widgets.ItemSlot; import com.cleanroommc.modularui.widgets.SlotGroupWidget; import com.cleanroommc.modularui.widgets.layout.Grid; +import com.cleanroommc.modularui.widgets.slot.ItemSlot; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -148,7 +149,7 @@ public boolean usesMui2() { } @Override - public ModularPanel buildUI(PosGuiData guiData, PanelSyncManager guiSyncManager) { + public ModularPanel buildUI(PosGuiData guiData, PanelSyncManager guiSyncManager, UISettings settings) { int rowSize = (int) Math.sqrt(inventorySize); int colSize = rowSize; if (inventorySize == 8) { @@ -172,7 +173,7 @@ public ModularPanel buildUI(PosGuiData guiData, PanelSyncManager guiSyncManager) // TODO: Change the position of the name when it's standardized. return GTGuis.createPanel(this, 176, 18 + 18 * colSize + 94) .child(IKey.lang(getMetaFullName()).asWidget().pos(5, 5)) - .child(SlotGroupWidget.playerInventory().left(7).bottom(7)) + .child(SlotGroupWidget.playerInventory(false).left(7).bottom(7)) .child(new Grid() .top(18).height(colSize * 18).width(rowSize * 18) .minElementMargin(0, 0) diff --git a/src/main/java/gregtech/common/metatileentities/electric/MetaTileEntityBlockBreaker.java b/src/main/java/gregtech/common/metatileentities/electric/MetaTileEntityBlockBreaker.java index 5d574ef1668..65e4e3a76fb 100644 --- a/src/main/java/gregtech/common/metatileentities/electric/MetaTileEntityBlockBreaker.java +++ b/src/main/java/gregtech/common/metatileentities/electric/MetaTileEntityBlockBreaker.java @@ -44,11 +44,12 @@ import com.cleanroommc.modularui.api.widget.IWidget; import com.cleanroommc.modularui.factory.PosGuiData; import com.cleanroommc.modularui.screen.ModularPanel; +import com.cleanroommc.modularui.screen.UISettings; import com.cleanroommc.modularui.value.sync.PanelSyncManager; import com.cleanroommc.modularui.value.sync.SyncHandlers; -import com.cleanroommc.modularui.widgets.ItemSlot; import com.cleanroommc.modularui.widgets.SlotGroupWidget; import com.cleanroommc.modularui.widgets.layout.Grid; +import com.cleanroommc.modularui.widgets.slot.ItemSlot; import it.unimi.dsi.fastutil.objects.ObjectArrayList; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -321,7 +322,7 @@ public boolean usesMui2() { } @Override - public ModularPanel buildUI(PosGuiData guiData, PanelSyncManager guiSyncManager) { + public ModularPanel buildUI(PosGuiData guiData, PanelSyncManager guiSyncManager, UISettings settings) { int rowSize = (int) Math.sqrt(getInventorySize()); guiSyncManager.registerSlotGroup("item_inv", rowSize); @@ -337,7 +338,7 @@ public ModularPanel buildUI(PosGuiData guiData, PanelSyncManager guiSyncManager) return GTGuis.createPanel(this, 176, 18 + 18 * rowSize + 94) .child(IKey.lang(getMetaFullName()).asWidget().pos(5, 5)) - .child(SlotGroupWidget.playerInventory().left(7).bottom(7)) + .child(SlotGroupWidget.playerInventory(false).left(7).bottom(7)) .child(new Grid() .top(18).height(rowSize * 18) .minElementMargin(0, 0) diff --git a/src/main/java/gregtech/common/metatileentities/electric/MetaTileEntityFisher.java b/src/main/java/gregtech/common/metatileentities/electric/MetaTileEntityFisher.java index c32f2ce65a2..44c55e814cf 100644 --- a/src/main/java/gregtech/common/metatileentities/electric/MetaTileEntityFisher.java +++ b/src/main/java/gregtech/common/metatileentities/electric/MetaTileEntityFisher.java @@ -32,11 +32,12 @@ import com.cleanroommc.modularui.api.widget.IWidget; import com.cleanroommc.modularui.factory.PosGuiData; import com.cleanroommc.modularui.screen.ModularPanel; +import com.cleanroommc.modularui.screen.UISettings; import com.cleanroommc.modularui.value.sync.PanelSyncManager; import com.cleanroommc.modularui.value.sync.SyncHandlers; -import com.cleanroommc.modularui.widgets.ItemSlot; import com.cleanroommc.modularui.widgets.SlotGroupWidget; import com.cleanroommc.modularui.widgets.layout.Grid; +import com.cleanroommc.modularui.widgets.slot.ItemSlot; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -70,7 +71,7 @@ public boolean usesMui2() { } @Override - public ModularPanel buildUI(PosGuiData guiData, PanelSyncManager guiSyncManager) { + public ModularPanel buildUI(PosGuiData guiData, PanelSyncManager guiSyncManager, UISettings settings) { int rowSize = (int) Math.sqrt(inventorySize); guiSyncManager.registerSlotGroup("item_in", 1); guiSyncManager.registerSlotGroup("item_out", rowSize); @@ -89,7 +90,7 @@ public ModularPanel buildUI(PosGuiData guiData, PanelSyncManager guiSyncManager) return GTGuis.createPanel(this, 176, 18 + 18 * rowSize + 94) .child(IKey.lang(getMetaFullName()).asWidget().pos(5, 5)) - .child(SlotGroupWidget.playerInventory().left(7).bottom(7)) + .child(SlotGroupWidget.playerInventory(false).left(7).bottom(7)) .child(new ItemSlot().slot(SyncHandlers.itemSlot(importItems, 0) .slotGroup("item_in")) .background(GTGuiTextures.SLOT, GTGuiTextures.STRING_SLOT_OVERLAY) diff --git a/src/main/java/gregtech/common/metatileentities/multi/MetaTileEntityCokeOven.java b/src/main/java/gregtech/common/metatileentities/multi/MetaTileEntityCokeOven.java index e63d6a6b6e4..f9b0c35313c 100644 --- a/src/main/java/gregtech/common/metatileentities/multi/MetaTileEntityCokeOven.java +++ b/src/main/java/gregtech/common/metatileentities/multi/MetaTileEntityCokeOven.java @@ -40,8 +40,8 @@ import com.cleanroommc.modularui.api.drawable.IKey; import com.cleanroommc.modularui.utils.Alignment; import com.cleanroommc.modularui.value.sync.DoubleSyncValue; -import com.cleanroommc.modularui.widgets.ItemSlot; import com.cleanroommc.modularui.widgets.ProgressWidget; +import com.cleanroommc.modularui.widgets.slot.ItemSlot; import com.cleanroommc.modularui.widgets.slot.ModularSlot; import org.jetbrains.annotations.NotNull; diff --git a/src/main/java/gregtech/common/metatileentities/multi/MetaTileEntityMultiblockTank.java b/src/main/java/gregtech/common/metatileentities/multi/MetaTileEntityMultiblockTank.java index 8bb43d653f9..4a0a6e7adee 100644 --- a/src/main/java/gregtech/common/metatileentities/multi/MetaTileEntityMultiblockTank.java +++ b/src/main/java/gregtech/common/metatileentities/multi/MetaTileEntityMultiblockTank.java @@ -40,7 +40,6 @@ import codechicken.lib.vec.Matrix4; import com.cleanroommc.modularui.api.drawable.IKey; import com.cleanroommc.modularui.utils.Alignment; -import com.cleanroommc.modularui.widgets.TextWidget; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -145,7 +144,8 @@ protected MultiblockUIFactory createUIFactory() { .disableDisplay() .disableButtons() .addScreenChildren((parent, syncManager) -> { - parent.child(new TextWidget(IKey.lang(getMetaFullName())) + parent.child(IKey.lang(getMetaFullName()) + .asWidget() .pos(5, 5)); parent.child(new GTFluidSlot() .pos(52, 18) diff --git a/src/main/java/gregtech/common/metatileentities/multi/MetaTileEntityPrimitiveBlastFurnace.java b/src/main/java/gregtech/common/metatileentities/multi/MetaTileEntityPrimitiveBlastFurnace.java index abc1e11b3cc..032ff3a9ddf 100644 --- a/src/main/java/gregtech/common/metatileentities/multi/MetaTileEntityPrimitiveBlastFurnace.java +++ b/src/main/java/gregtech/common/metatileentities/multi/MetaTileEntityPrimitiveBlastFurnace.java @@ -43,9 +43,10 @@ import com.cleanroommc.modularui.drawable.UITexture; import com.cleanroommc.modularui.utils.Alignment; import com.cleanroommc.modularui.value.sync.DoubleSyncValue; -import com.cleanroommc.modularui.widgets.ItemSlot; +import com.cleanroommc.modularui.widgets.ProgressWidget; import com.cleanroommc.modularui.widgets.layout.Flow; import com.cleanroommc.modularui.widgets.layout.Grid; +import com.cleanroommc.modularui.widgets.slot.ItemSlot; import com.cleanroommc.modularui.widgets.slot.ModularSlot; import com.cleanroommc.modularui.widgets.slot.SlotGroup; import org.apache.commons.lang3.ArrayUtils; @@ -111,7 +112,6 @@ protected MultiblockUIFactory createUIFactory() { .child(Flow.row() .top(20) .alignX(0.5f) - // .pos(52, 20) .crossAxisAlignment(Alignment.CrossAxis.CENTER) .coverChildren() .child(new Grid() @@ -121,15 +121,13 @@ protected MultiblockUIFactory createUIFactory() { .slot(new ModularSlot(importItems, value) .slotGroup(importGroup))) .marginRight(6)) - .child(new com.cleanroommc.modularui.widgets.ProgressWidget() - // .pos(77, 39) + .child(new ProgressWidget() .size(20, 15) .marginRight(6) .texture(GTGuiTextures.PRIMITIVE_BLAST_FURNACE_PROGRESS_BAR, 20) .value(new DoubleSyncValue(recipeMapWorkable::getProgressPercent))) .child(new Grid() .coverChildren() - // .pos(104, 38) .mapTo(3, 3, value -> new ItemSlot() .background(GTGuiTextures.SLOT_PRIMITIVE, exportOverlays[value]) .slot(new ModularSlot(exportItems, value) diff --git a/src/main/java/gregtech/common/metatileentities/multi/MetaTileEntityPumpHatch.java b/src/main/java/gregtech/common/metatileentities/multi/MetaTileEntityPumpHatch.java index 0537a814d37..4d841dc6582 100644 --- a/src/main/java/gregtech/common/metatileentities/multi/MetaTileEntityPumpHatch.java +++ b/src/main/java/gregtech/common/metatileentities/multi/MetaTileEntityPumpHatch.java @@ -36,13 +36,14 @@ import com.cleanroommc.modularui.api.drawable.IKey; import com.cleanroommc.modularui.factory.PosGuiData; import com.cleanroommc.modularui.screen.ModularPanel; +import com.cleanroommc.modularui.screen.UISettings; import com.cleanroommc.modularui.utils.Alignment; import com.cleanroommc.modularui.utils.Color; import com.cleanroommc.modularui.value.sync.PanelSyncManager; import com.cleanroommc.modularui.value.sync.SyncHandlers; -import com.cleanroommc.modularui.widgets.ItemSlot; import com.cleanroommc.modularui.widgets.RichTextWidget; import com.cleanroommc.modularui.widgets.SlotGroupWidget; +import com.cleanroommc.modularui.widgets.slot.ItemSlot; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -125,7 +126,7 @@ public boolean usesMui2() { } @Override - public ModularPanel buildUI(PosGuiData guiData, PanelSyncManager guiSyncManager) { + public ModularPanel buildUI(PosGuiData guiData, PanelSyncManager guiSyncManager, UISettings settings) { guiSyncManager.registerSlotGroup("item_inv", 2); GTFluidSyncHandler tankSyncHandler = GTFluidSlot.sync(this.exportFluids.getTankAt(0)) @@ -135,7 +136,7 @@ public ModularPanel buildUI(PosGuiData guiData, PanelSyncManager guiSyncManager) // TODO: Change the position of the name when it's standardized. return GTGuis.createPanel(this, 176, 166) .child(IKey.lang(getMetaFullName()).asWidget().pos(5, 5)) - .child(SlotGroupWidget.playerInventory().left(7).bottom(7)) + .child(SlotGroupWidget.playerInventory(false).left(7).bottom(7)) .child(GTGuiTextures.DISPLAY.asWidget() .left(7).top(16) .size(81, 55)) diff --git a/src/main/java/gregtech/common/metatileentities/multi/electric/MetaTileEntityPowerSubstation.java b/src/main/java/gregtech/common/metatileentities/multi/electric/MetaTileEntityPowerSubstation.java index 96a6121b8c9..c3fdd2b18b6 100644 --- a/src/main/java/gregtech/common/metatileentities/multi/electric/MetaTileEntityPowerSubstation.java +++ b/src/main/java/gregtech/common/metatileentities/multi/electric/MetaTileEntityPowerSubstation.java @@ -17,7 +17,6 @@ import gregtech.api.metatileentity.multiblock.ui.MultiblockUIBuilder; import gregtech.api.metatileentity.multiblock.ui.TemplateBarBuilder; import gregtech.api.mui.GTGuiTextures; -import gregtech.api.mui.sync.BigIntegerSyncValue; import gregtech.api.pattern.BlockPattern; import gregtech.api.pattern.FactoryBlockPattern; import gregtech.api.pattern.MultiblockShapeInfo; @@ -54,6 +53,7 @@ import codechicken.lib.render.pipeline.IVertexOperation; import codechicken.lib.vec.Matrix4; import com.cleanroommc.modularui.api.drawable.IKey; +import com.cleanroommc.modularui.value.sync.BigIntSyncValue; import com.cleanroommc.modularui.value.sync.PanelSyncManager; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -579,16 +579,17 @@ public int getProgressBarCount() { @Override public void registerBars(List> bars, PanelSyncManager syncManager) { - BigIntegerSyncValue energyStoredValue = new BigIntegerSyncValue( + BigIntSyncValue energyStoredValue = new BigIntSyncValue( () -> energyBank == null ? BigInteger.ZERO : energyBank.getStored(), null); - BigIntegerSyncValue energyCapacityValue = new BigIntegerSyncValue( + BigIntSyncValue energyCapacityValue = new BigIntSyncValue( () -> energyBank == null ? BigInteger.ZERO : energyBank.getCapacity(), null); syncManager.syncValue("energy_stored", energyStoredValue); syncManager.syncValue("energy_capacity", energyCapacityValue); - bars.add(b -> b - .progress( - () -> energyStoredValue.getValue().doubleValue() / energyCapacityValue.getValue().doubleValue()) + bars.add(b -> b.progress(() -> { + if (energyCapacityValue.getValue().equals(BigInteger.ZERO)) return 0; + return energyStoredValue.getValue().divide(energyCapacityValue.getValue()).doubleValue(); + }) .texture(GTGuiTextures.PROGRESS_BAR_MULTI_ENERGY_YELLOW) .tooltipBuilder(t -> { if (isStructureFormed()) { diff --git a/src/main/java/gregtech/common/metatileentities/multi/multiblockpart/MetaTileEntityFluidHatch.java b/src/main/java/gregtech/common/metatileentities/multi/multiblockpart/MetaTileEntityFluidHatch.java index bbcd10e4897..a1e6ab43a3c 100644 --- a/src/main/java/gregtech/common/metatileentities/multi/multiblockpart/MetaTileEntityFluidHatch.java +++ b/src/main/java/gregtech/common/metatileentities/multi/multiblockpart/MetaTileEntityFluidHatch.java @@ -47,13 +47,14 @@ import com.cleanroommc.modularui.factory.PosGuiData; import com.cleanroommc.modularui.network.NetworkUtils; import com.cleanroommc.modularui.screen.ModularPanel; +import com.cleanroommc.modularui.screen.UISettings; import com.cleanroommc.modularui.utils.Alignment; import com.cleanroommc.modularui.utils.Color; import com.cleanroommc.modularui.value.sync.BooleanSyncValue; import com.cleanroommc.modularui.value.sync.PanelSyncManager; -import com.cleanroommc.modularui.widgets.ItemSlot; import com.cleanroommc.modularui.widgets.RichTextWidget; import com.cleanroommc.modularui.widgets.ToggleButton; +import com.cleanroommc.modularui.widgets.slot.ItemSlot; import com.cleanroommc.modularui.widgets.slot.ModularSlot; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -281,7 +282,7 @@ public boolean usesMui2() { } @Override - public ModularPanel buildUI(PosGuiData guiData, PanelSyncManager guiSyncManager) { + public ModularPanel buildUI(PosGuiData guiData, PanelSyncManager guiSyncManager, UISettings settings) { var fluidSyncHandler = GTFluidSlot.sync(fluidTank) .showAmountOnSlot(false) .accessibility(true, !isExportHatch); @@ -326,6 +327,7 @@ public ModularPanel buildUI(PosGuiData guiData, PanelSyncManager guiSyncManager) .pos(124, 62)) // common ui + // todo split up these lines into their own widgets and use a scrolling text widget for the name .child(new RichTextWidget() .size(81 - 6, (isExportHatch ? 46 : 55) - 8) // .padding(3, 4) diff --git a/src/main/java/gregtech/common/metatileentities/multi/multiblockpart/MetaTileEntityItemBus.java b/src/main/java/gregtech/common/metatileentities/multi/multiblockpart/MetaTileEntityItemBus.java index c3dae2f0e06..127977cb343 100644 --- a/src/main/java/gregtech/common/metatileentities/multi/multiblockpart/MetaTileEntityItemBus.java +++ b/src/main/java/gregtech/common/metatileentities/multi/multiblockpart/MetaTileEntityItemBus.java @@ -40,15 +40,16 @@ import com.cleanroommc.modularui.api.drawable.IKey; import com.cleanroommc.modularui.factory.PosGuiData; import com.cleanroommc.modularui.screen.ModularPanel; +import com.cleanroommc.modularui.screen.UISettings; import com.cleanroommc.modularui.value.sync.BooleanSyncValue; import com.cleanroommc.modularui.value.sync.PanelSyncManager; import com.cleanroommc.modularui.value.sync.SyncHandlers; import com.cleanroommc.modularui.widget.Widget; -import com.cleanroommc.modularui.widgets.ItemSlot; import com.cleanroommc.modularui.widgets.SlotGroupWidget; import com.cleanroommc.modularui.widgets.ToggleButton; import com.cleanroommc.modularui.widgets.layout.Flow; import com.cleanroommc.modularui.widgets.layout.Grid; +import com.cleanroommc.modularui.widgets.slot.ItemSlot; import it.unimi.dsi.fastutil.objects.Object2IntMap; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -265,7 +266,7 @@ public boolean usesMui2() { } @Override - public ModularPanel buildUI(PosGuiData guiData, PanelSyncManager panelSyncManager) { + public ModularPanel buildUI(PosGuiData guiData, PanelSyncManager panelSyncManager, UISettings settings) { int rowSize = (int) Math.sqrt(getInventorySize()); panelSyncManager.registerSlotGroup("item_inv", rowSize); @@ -282,7 +283,7 @@ public ModularPanel buildUI(PosGuiData guiData, PanelSyncManager panelSyncManage return GTGuis.createPanel(this, backgroundWidth, backgroundHeight) .child(IKey.lang(getMetaFullName()).asWidget().pos(5, 5)) - .child(SlotGroupWidget.playerInventory().left(7).bottom(7)) + .child(SlotGroupWidget.playerInventory(false).left(7).bottom(7)) .child(new Grid() .top(18).height(rowSize * 18) .minElementMargin(0, 0) @@ -323,7 +324,7 @@ public ModularPanel buildUI(PosGuiData guiData, PanelSyncManager panelSyncManage IKey.lang("gregtech.gui.item_auto_collapse.tooltip.enabled") : IKey.lang("gregtech.gui.item_auto_collapse.tooltip.disabled")))) .childIf(hasGhostCircuit, new GhostCircuitSlotWidget() - .slot(SyncHandlers.itemSlot(circuitInventory, 0)) + .slot(circuitInventory, 0) .background(GTGuiTextures.SLOT, GTGuiTextures.INT_CIRCUIT_OVERLAY)) .childIf(!hasGhostCircuit, new Widget<>() .background(GTGuiTextures.SLOT, GTGuiTextures.BUTTON_X) diff --git a/src/main/java/gregtech/common/metatileentities/multi/multiblockpart/MetaTileEntityMachineHatch.java b/src/main/java/gregtech/common/metatileentities/multi/multiblockpart/MetaTileEntityMachineHatch.java index ba324cf1dff..31511ae2cb6 100644 --- a/src/main/java/gregtech/common/metatileentities/multi/multiblockpart/MetaTileEntityMachineHatch.java +++ b/src/main/java/gregtech/common/metatileentities/multi/multiblockpart/MetaTileEntityMachineHatch.java @@ -28,10 +28,11 @@ import com.cleanroommc.modularui.factory.PosGuiData; import com.cleanroommc.modularui.screen.ModularPanel; import com.cleanroommc.modularui.screen.RichTooltip; +import com.cleanroommc.modularui.screen.UISettings; import com.cleanroommc.modularui.value.sync.PanelSyncManager; import com.cleanroommc.modularui.value.sync.SyncHandlers; -import com.cleanroommc.modularui.widgets.ItemSlot; import com.cleanroommc.modularui.widgets.SlotGroupWidget; +import com.cleanroommc.modularui.widgets.slot.ItemSlot; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -74,13 +75,13 @@ public boolean usesMui2() { } @Override - public ModularPanel buildUI(PosGuiData guiData, PanelSyncManager guiSyncManager) { + public ModularPanel buildUI(PosGuiData guiData, PanelSyncManager guiSyncManager, UISettings settings) { guiSyncManager.registerSlotGroup("item_inv", 1); // TODO: Change the position of the name when it's standardized. return GTGuis.createPanel(this, 176, 18 + 18 + 94) .child(IKey.lang(getMetaFullName()).asWidget().pos(5, 5)) - .child(SlotGroupWidget.playerInventory().left(7).bottom(7)) + .child(SlotGroupWidget.playerInventory(false).left(7).bottom(7)) .child(new ItemSlot() .slot(SyncHandlers.itemSlot(machineHandler, 0) .slotGroup("item_inv")) diff --git a/src/main/java/gregtech/common/metatileentities/multi/multiblockpart/MetaTileEntityMultiFluidHatch.java b/src/main/java/gregtech/common/metatileentities/multi/multiblockpart/MetaTileEntityMultiFluidHatch.java index 5c909ef7a69..dda4c982efc 100644 --- a/src/main/java/gregtech/common/metatileentities/multi/multiblockpart/MetaTileEntityMultiFluidHatch.java +++ b/src/main/java/gregtech/common/metatileentities/multi/multiblockpart/MetaTileEntityMultiFluidHatch.java @@ -33,6 +33,7 @@ import com.cleanroommc.modularui.factory.PosGuiData; import com.cleanroommc.modularui.network.NetworkUtils; import com.cleanroommc.modularui.screen.ModularPanel; +import com.cleanroommc.modularui.screen.UISettings; import com.cleanroommc.modularui.value.sync.PanelSyncManager; import com.cleanroommc.modularui.widgets.layout.Grid; import org.jetbrains.annotations.NotNull; @@ -208,7 +209,7 @@ public boolean usesMui2() { } @Override - public ModularPanel buildUI(PosGuiData guiData, PanelSyncManager guiSyncManager) { + public ModularPanel buildUI(PosGuiData guiData, PanelSyncManager guiSyncManager, UISettings settings) { int rowSize = (int) Math.sqrt(numSlots); List fluidSlots = new ArrayList<>(); diff --git a/src/main/java/gregtech/common/metatileentities/multi/multiblockpart/MetaTileEntityObjectHolder.java b/src/main/java/gregtech/common/metatileentities/multi/multiblockpart/MetaTileEntityObjectHolder.java index 568e897c850..a486765725c 100644 --- a/src/main/java/gregtech/common/metatileentities/multi/multiblockpart/MetaTileEntityObjectHolder.java +++ b/src/main/java/gregtech/common/metatileentities/multi/multiblockpart/MetaTileEntityObjectHolder.java @@ -34,10 +34,11 @@ import com.cleanroommc.modularui.drawable.GuiDraw; import com.cleanroommc.modularui.factory.PosGuiData; import com.cleanroommc.modularui.screen.ModularPanel; +import com.cleanroommc.modularui.screen.UISettings; import com.cleanroommc.modularui.value.sync.PanelSyncManager; import com.cleanroommc.modularui.value.sync.SyncHandlers; -import com.cleanroommc.modularui.widgets.ItemSlot; import com.cleanroommc.modularui.widgets.SlotGroupWidget; +import com.cleanroommc.modularui.widgets.slot.ItemSlot; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -67,13 +68,13 @@ public boolean usesMui2() { } @Override - public ModularPanel buildUI(PosGuiData guiData, PanelSyncManager guiSyncManager) { + public ModularPanel buildUI(PosGuiData guiData, PanelSyncManager guiSyncManager, UISettings settings) { guiSyncManager.registerSlotGroup("item_inv", 2); // TODO: Change the position of the name when it's standardized. return GTGuis.createPanel(this, 176, 166) .child(IKey.lang(getMetaFullName()).asWidget().pos(5, 5)) - .child(SlotGroupWidget.playerInventory().left(7).bottom(7)) + .child(SlotGroupWidget.playerInventory(false).left(7).bottom(7)) .child(GTGuiTextures.PROGRESS_BAR_RESEARCH_STATION_BASE.asWidget() .left(46).top(18) .size(84, 60)) diff --git a/src/main/java/gregtech/common/metatileentities/multi/multiblockpart/MetaTileEntityPassthroughHatchFluid.java b/src/main/java/gregtech/common/metatileentities/multi/multiblockpart/MetaTileEntityPassthroughHatchFluid.java index 14c86351976..a047127d832 100644 --- a/src/main/java/gregtech/common/metatileentities/multi/multiblockpart/MetaTileEntityPassthroughHatchFluid.java +++ b/src/main/java/gregtech/common/metatileentities/multi/multiblockpart/MetaTileEntityPassthroughHatchFluid.java @@ -37,6 +37,7 @@ import com.cleanroommc.modularui.api.widget.IWidget; import com.cleanroommc.modularui.factory.PosGuiData; import com.cleanroommc.modularui.screen.ModularPanel; +import com.cleanroommc.modularui.screen.UISettings; import com.cleanroommc.modularui.value.sync.BooleanSyncValue; import com.cleanroommc.modularui.value.sync.PanelSyncManager; import com.cleanroommc.modularui.widgets.SlotGroupWidget; @@ -138,7 +139,7 @@ public boolean usesMui2() { } @Override - public ModularPanel buildUI(PosGuiData guiData, PanelSyncManager guiSyncManager) { + public ModularPanel buildUI(PosGuiData guiData, PanelSyncManager guiSyncManager, UISettings settings) { int rowSize = (int) Math.sqrt(getTier() + 1); int backgroundWidth = 9 * 18 + 14; @@ -156,7 +157,7 @@ public ModularPanel buildUI(PosGuiData guiData, PanelSyncManager guiSyncManager) BooleanSyncValue workingStateValue = new BooleanSyncValue(() -> workingEnabled, val -> workingEnabled = val); return GTGuis.createPanel(this, backgroundWidth, backgroundHeight) .child(IKey.lang(getMetaFullName()).asWidget().pos(5, 5)) - .child(SlotGroupWidget.playerInventory().left(7).bottom(7)) + .child(SlotGroupWidget.playerInventory(false).left(7).bottom(7)) .child(new Grid() .top(18).height(rowSize * 18) .minElementMargin(0, 0) diff --git a/src/main/java/gregtech/common/metatileentities/multi/multiblockpart/MetaTileEntityPassthroughHatchItem.java b/src/main/java/gregtech/common/metatileentities/multi/multiblockpart/MetaTileEntityPassthroughHatchItem.java index a5be8680efa..4d02dba1e66 100644 --- a/src/main/java/gregtech/common/metatileentities/multi/multiblockpart/MetaTileEntityPassthroughHatchItem.java +++ b/src/main/java/gregtech/common/metatileentities/multi/multiblockpart/MetaTileEntityPassthroughHatchItem.java @@ -36,13 +36,14 @@ import com.cleanroommc.modularui.api.widget.IWidget; import com.cleanroommc.modularui.factory.PosGuiData; import com.cleanroommc.modularui.screen.ModularPanel; +import com.cleanroommc.modularui.screen.UISettings; import com.cleanroommc.modularui.value.sync.BooleanSyncValue; import com.cleanroommc.modularui.value.sync.PanelSyncManager; import com.cleanroommc.modularui.value.sync.SyncHandlers; -import com.cleanroommc.modularui.widgets.ItemSlot; import com.cleanroommc.modularui.widgets.SlotGroupWidget; import com.cleanroommc.modularui.widgets.ToggleButton; import com.cleanroommc.modularui.widgets.layout.Grid; +import com.cleanroommc.modularui.widgets.slot.ItemSlot; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -140,7 +141,7 @@ public boolean usesMui2() { } @Override - public ModularPanel buildUI(PosGuiData guiData, PanelSyncManager guiSyncManager) { + public ModularPanel buildUI(PosGuiData guiData, PanelSyncManager guiSyncManager, UISettings settings) { int rowSize = (int) Math.sqrt(getInventorySize()); guiSyncManager.registerSlotGroup("item_inv", rowSize); @@ -163,7 +164,7 @@ public ModularPanel buildUI(PosGuiData guiData, PanelSyncManager guiSyncManager) BooleanSyncValue workingStateValue = new BooleanSyncValue(() -> workingEnabled, val -> workingEnabled = val); return GTGuis.createPanel(this, backgroundWidth, backgroundHeight) .child(IKey.lang(getMetaFullName()).asWidget().pos(5, 5)) - .child(SlotGroupWidget.playerInventory().left(7).bottom(7)) + .child(SlotGroupWidget.playerInventory(false).left(7).bottom(7)) .child(new Grid() .top(18).height(rowSize * 18) .minElementMargin(0, 0) diff --git a/src/main/java/gregtech/common/metatileentities/multi/multiblockpart/MetaTileEntityReservoirHatch.java b/src/main/java/gregtech/common/metatileentities/multi/multiblockpart/MetaTileEntityReservoirHatch.java index 9f8a133d401..00241591cf8 100644 --- a/src/main/java/gregtech/common/metatileentities/multi/multiblockpart/MetaTileEntityReservoirHatch.java +++ b/src/main/java/gregtech/common/metatileentities/multi/multiblockpart/MetaTileEntityReservoirHatch.java @@ -42,13 +42,14 @@ import com.cleanroommc.modularui.api.drawable.IKey; import com.cleanroommc.modularui.factory.PosGuiData; import com.cleanroommc.modularui.screen.ModularPanel; +import com.cleanroommc.modularui.screen.UISettings; import com.cleanroommc.modularui.utils.Alignment; import com.cleanroommc.modularui.utils.Color; import com.cleanroommc.modularui.value.sync.PanelSyncManager; import com.cleanroommc.modularui.value.sync.SyncHandlers; -import com.cleanroommc.modularui.widgets.ItemSlot; import com.cleanroommc.modularui.widgets.RichTextWidget; import com.cleanroommc.modularui.widgets.SlotGroupWidget; +import com.cleanroommc.modularui.widgets.slot.ItemSlot; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -149,7 +150,7 @@ public boolean usesMui2() { } @Override - public ModularPanel buildUI(PosGuiData guiData, PanelSyncManager guiSyncManager) { + public ModularPanel buildUI(PosGuiData guiData, PanelSyncManager guiSyncManager, UISettings settings) { guiSyncManager.registerSlotGroup("item_inv", 2); GTFluidSyncHandler tankSyncHandler = GTFluidSlot.sync(this.fluidTank) @@ -159,7 +160,7 @@ public ModularPanel buildUI(PosGuiData guiData, PanelSyncManager guiSyncManager) // TODO: Change the position of the name when it's standardized. return GTGuis.createPanel(this, 176, 166) .child(IKey.lang(getMetaFullName()).asWidget().pos(5, 5)) - .child(SlotGroupWidget.playerInventory().left(7).bottom(7)) + .child(SlotGroupWidget.playerInventory(false).left(7).bottom(7)) .child(GTGuiTextures.DISPLAY.asWidget() .left(7).top(16) .size(81, 55)) diff --git a/src/main/java/gregtech/common/metatileentities/multi/multiblockpart/MetaTileEntityRotorHolder.java b/src/main/java/gregtech/common/metatileentities/multi/multiblockpart/MetaTileEntityRotorHolder.java index 9401664249d..d82088dc81a 100644 --- a/src/main/java/gregtech/common/metatileentities/multi/multiblockpart/MetaTileEntityRotorHolder.java +++ b/src/main/java/gregtech/common/metatileentities/multi/multiblockpart/MetaTileEntityRotorHolder.java @@ -41,10 +41,11 @@ import com.cleanroommc.modularui.api.drawable.IKey; import com.cleanroommc.modularui.factory.PosGuiData; import com.cleanroommc.modularui.screen.ModularPanel; +import com.cleanroommc.modularui.screen.UISettings; import com.cleanroommc.modularui.value.sync.PanelSyncManager; import com.cleanroommc.modularui.value.sync.SyncHandlers; -import com.cleanroommc.modularui.widgets.ItemSlot; import com.cleanroommc.modularui.widgets.SlotGroupWidget; +import com.cleanroommc.modularui.widgets.slot.ItemSlot; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -86,12 +87,12 @@ public boolean usesMui2() { } @Override - public ModularPanel buildUI(PosGuiData guiData, PanelSyncManager guiSyncManager) { + public ModularPanel buildUI(PosGuiData guiData, PanelSyncManager guiSyncManager, UISettings settings) { guiSyncManager.registerSlotGroup("item_inv", 1); // TODO: Change the position of the name when it's standardized. return GTGuis.createPanel(this, 176, 166) .child(IKey.lang(getMetaFullName()).asWidget().pos(5, 5)) - .child(SlotGroupWidget.playerInventory().left(7).bottom(7)) + .child(SlotGroupWidget.playerInventory(false).left(7).bottom(7)) .child(new ItemSlot() .slot(SyncHandlers.itemSlot(inventory, 0) .slotGroup("item_inv") diff --git a/src/main/java/gregtech/common/metatileentities/steam/multiblockpart/MetaTileEntitySteamHatch.java b/src/main/java/gregtech/common/metatileentities/steam/multiblockpart/MetaTileEntitySteamHatch.java index 78bc61b5a2d..879cb9c2da0 100644 --- a/src/main/java/gregtech/common/metatileentities/steam/multiblockpart/MetaTileEntitySteamHatch.java +++ b/src/main/java/gregtech/common/metatileentities/steam/multiblockpart/MetaTileEntitySteamHatch.java @@ -39,13 +39,14 @@ import com.cleanroommc.modularui.api.drawable.IKey; import com.cleanroommc.modularui.factory.PosGuiData; import com.cleanroommc.modularui.screen.ModularPanel; +import com.cleanroommc.modularui.screen.UISettings; import com.cleanroommc.modularui.utils.Alignment; import com.cleanroommc.modularui.utils.Color; import com.cleanroommc.modularui.value.sync.PanelSyncManager; import com.cleanroommc.modularui.value.sync.SyncHandlers; -import com.cleanroommc.modularui.widgets.ItemSlot; import com.cleanroommc.modularui.widgets.RichTextWidget; import com.cleanroommc.modularui.widgets.SlotGroupWidget; +import com.cleanroommc.modularui.widgets.slot.ItemSlot; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -140,7 +141,7 @@ public boolean usesMui2() { } @Override - public ModularPanel buildUI(PosGuiData guiData, PanelSyncManager guiSyncManager) { + public ModularPanel buildUI(PosGuiData guiData, PanelSyncManager guiSyncManager, UISettings settings) { guiSyncManager.registerSlotGroup("item_inv", 2); GTFluidSyncHandler tankSyncHandler = GTFluidSlot.sync(this.importFluids.getTankAt(0)) @@ -148,7 +149,7 @@ public ModularPanel buildUI(PosGuiData guiData, PanelSyncManager guiSyncManager) return GTGuis.createPanel(this, 176, 166) .child(IKey.lang(getMetaFullName()).asWidget().pos(5, 5)) - .child(SlotGroupWidget.playerInventory().left(7).bottom(7)) + .child(SlotGroupWidget.playerInventory(false).left(7).bottom(7)) .child((IS_STEEL ? GTGuiTextures.DISPLAY_STEEL : GTGuiTextures.DISPLAY_BRONZE).asWidget() .left(7).top(16) .size(81, 55)) diff --git a/src/main/java/gregtech/common/metatileentities/steam/multiblockpart/MetaTileEntitySteamItemBus.java b/src/main/java/gregtech/common/metatileentities/steam/multiblockpart/MetaTileEntitySteamItemBus.java index c73bcb442a9..6734a00616a 100644 --- a/src/main/java/gregtech/common/metatileentities/steam/multiblockpart/MetaTileEntitySteamItemBus.java +++ b/src/main/java/gregtech/common/metatileentities/steam/multiblockpart/MetaTileEntitySteamItemBus.java @@ -27,10 +27,11 @@ import com.cleanroommc.modularui.api.widget.IWidget; import com.cleanroommc.modularui.factory.PosGuiData; import com.cleanroommc.modularui.screen.ModularPanel; +import com.cleanroommc.modularui.screen.UISettings; import com.cleanroommc.modularui.value.sync.PanelSyncManager; import com.cleanroommc.modularui.value.sync.SyncHandlers; -import com.cleanroommc.modularui.widgets.ItemSlot; import com.cleanroommc.modularui.widgets.layout.Grid; +import com.cleanroommc.modularui.widgets.slot.ItemSlot; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -87,7 +88,7 @@ public void renderMetaTileEntity(CCRenderState renderState, Matrix4 translation, } @Override - public ModularPanel buildUI(PosGuiData guiData, PanelSyncManager panelSyncManager) { + public ModularPanel buildUI(PosGuiData guiData, PanelSyncManager panelSyncManager, UISettings settings) { panelSyncManager.registerSlotGroup("item_inv", 2); List> widgets = new ArrayList<>(); diff --git a/src/main/java/gregtech/common/metatileentities/storage/MetaTileEntityBuffer.java b/src/main/java/gregtech/common/metatileentities/storage/MetaTileEntityBuffer.java index e7a94663d21..353cdf406c3 100644 --- a/src/main/java/gregtech/common/metatileentities/storage/MetaTileEntityBuffer.java +++ b/src/main/java/gregtech/common/metatileentities/storage/MetaTileEntityBuffer.java @@ -30,11 +30,12 @@ import com.cleanroommc.modularui.api.widget.IWidget; import com.cleanroommc.modularui.factory.PosGuiData; import com.cleanroommc.modularui.screen.ModularPanel; +import com.cleanroommc.modularui.screen.UISettings; import com.cleanroommc.modularui.value.sync.PanelSyncManager; import com.cleanroommc.modularui.value.sync.SyncHandlers; -import com.cleanroommc.modularui.widgets.ItemSlot; import com.cleanroommc.modularui.widgets.SlotGroupWidget; import com.cleanroommc.modularui.widgets.layout.Grid; +import com.cleanroommc.modularui.widgets.slot.ItemSlot; import org.apache.commons.lang3.ArrayUtils; import org.apache.commons.lang3.tuple.Pair; import org.jetbrains.annotations.NotNull; @@ -85,7 +86,7 @@ public boolean usesMui2() { } @Override - public ModularPanel buildUI(PosGuiData guiData, PanelSyncManager guiSyncManager) { + public ModularPanel buildUI(PosGuiData guiData, PanelSyncManager guiSyncManager, UISettings settings) { int invTier = tier + 2; guiSyncManager.registerSlotGroup("item_inv", invTier); @@ -108,7 +109,7 @@ public ModularPanel buildUI(PosGuiData guiData, PanelSyncManager guiSyncManager) // TODO: Change the position of the name when it's standardized. return GTGuis.createPanel(this, 176, Math.max(166, 18 + 18 * invTier + 94)) .child(IKey.lang(getMetaFullName()).asWidget().pos(5, 5)) - .child(SlotGroupWidget.playerInventory().left(7).bottom(7)) + .child(SlotGroupWidget.playerInventory(false).left(7).bottom(7)) .child(new Grid() .top(18).height(18 * invTier) .left(7) diff --git a/src/main/java/gregtech/common/metatileentities/storage/MetaTileEntityCrate.java b/src/main/java/gregtech/common/metatileentities/storage/MetaTileEntityCrate.java index 1da4918ffcc..5c6948c5ffc 100644 --- a/src/main/java/gregtech/common/metatileentities/storage/MetaTileEntityCrate.java +++ b/src/main/java/gregtech/common/metatileentities/storage/MetaTileEntityCrate.java @@ -35,10 +35,11 @@ import com.cleanroommc.modularui.api.widget.IWidget; import com.cleanroommc.modularui.factory.PosGuiData; import com.cleanroommc.modularui.screen.ModularPanel; +import com.cleanroommc.modularui.screen.UISettings; import com.cleanroommc.modularui.value.sync.PanelSyncManager; import com.cleanroommc.modularui.value.sync.SyncHandlers; -import com.cleanroommc.modularui.widgets.ItemSlot; import com.cleanroommc.modularui.widgets.layout.Grid; +import com.cleanroommc.modularui.widgets.slot.ItemSlot; import org.apache.commons.lang3.tuple.Pair; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -141,7 +142,7 @@ public boolean usesMui2() { } @Override - public ModularPanel buildUI(PosGuiData guiData, PanelSyncManager panelSyncManager) { + public ModularPanel buildUI(PosGuiData guiData, PanelSyncManager panelSyncManager, UISettings settings) { panelSyncManager.registerSlotGroup("item_inv", rowSize); int rows = inventorySize / rowSize; diff --git a/src/main/java/gregtech/common/metatileentities/storage/MetaTileEntityCreativeChest.java b/src/main/java/gregtech/common/metatileentities/storage/MetaTileEntityCreativeChest.java index c6d7fa6e219..29b350c41e9 100644 --- a/src/main/java/gregtech/common/metatileentities/storage/MetaTileEntityCreativeChest.java +++ b/src/main/java/gregtech/common/metatileentities/storage/MetaTileEntityCreativeChest.java @@ -30,11 +30,12 @@ import com.cleanroommc.modularui.api.drawable.IKey; import com.cleanroommc.modularui.factory.PosGuiData; import com.cleanroommc.modularui.screen.ModularPanel; +import com.cleanroommc.modularui.screen.UISettings; import com.cleanroommc.modularui.value.BoolValue; import com.cleanroommc.modularui.value.sync.IntSyncValue; import com.cleanroommc.modularui.value.sync.PanelSyncManager; -import com.cleanroommc.modularui.value.sync.SyncHandlers; -import com.cleanroommc.modularui.widgets.ItemSlot; +import com.cleanroommc.modularui.widgets.slot.ModularSlot; +import com.cleanroommc.modularui.widgets.slot.PhantomItemSlot; import org.apache.commons.lang3.ArrayUtils; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -58,8 +59,8 @@ public MetaTileEntityCreativeChest(ResourceLocation metaTileEntityId) { @Override protected void initializeInventory() { super.initializeInventory(); - this.itemInventory = this.modifiableHandler = new ModifiableHandler(); - this.creativeHandler = new CreativeItemStackHandler(1); + this.modifiableHandler = new ModifiableHandler(); + this.itemInventory = this.creativeHandler = new CreativeItemStackHandler(1); } @Override @@ -87,7 +88,7 @@ public MetaTileEntity createMetaTileEntity(IGregTechTileEntity tileEntity) { } @Override - public ModularPanel buildUI(PosGuiData guiData, PanelSyncManager guiSyncManager) { + public ModularPanel buildUI(PosGuiData guiData, PanelSyncManager guiSyncManager, UISettings settings) { guiSyncManager.syncValue("handler", this.modifiableHandler); return appendCreativeUI(GTGuis.createPanel(this, 176, 166), false, new BoolValue.Dynamic(() -> active, b -> active = b), @@ -95,8 +96,8 @@ public ModularPanel buildUI(PosGuiData guiData, PanelSyncManager guiSyncManager) new IntSyncValue(() -> ticksPerCycle, v -> ticksPerCycle = v)) .child(IKey.lang("gregtech.creative.chest.item").asWidget() .pos(7, 9)) - .child(new ItemSlot() - .slot(SyncHandlers.phantomItemSlot(modifiableHandler, 0) + .child(new PhantomItemSlot() + .slot(new ModularSlot(modifiableHandler, 0) .changeListener((newItem, onlyAmountChanged, client, init) -> markDirty())) .pos(36, 6)); } diff --git a/src/main/java/gregtech/common/metatileentities/storage/MetaTileEntityCreativeTank.java b/src/main/java/gregtech/common/metatileentities/storage/MetaTileEntityCreativeTank.java index a5658270aac..a6218aa7323 100644 --- a/src/main/java/gregtech/common/metatileentities/storage/MetaTileEntityCreativeTank.java +++ b/src/main/java/gregtech/common/metatileentities/storage/MetaTileEntityCreativeTank.java @@ -31,6 +31,7 @@ import com.cleanroommc.modularui.api.drawable.IKey; import com.cleanroommc.modularui.factory.PosGuiData; import com.cleanroommc.modularui.screen.ModularPanel; +import com.cleanroommc.modularui.screen.UISettings; import com.cleanroommc.modularui.value.BoolValue; import com.cleanroommc.modularui.value.sync.IntSyncValue; import com.cleanroommc.modularui.value.sync.PanelSyncManager; @@ -87,7 +88,7 @@ public MetaTileEntity createMetaTileEntity(IGregTechTileEntity tileEntity) { } @Override - public ModularPanel buildUI(PosGuiData guiData, PanelSyncManager guiSyncManager) { + public ModularPanel buildUI(PosGuiData guiData, PanelSyncManager guiSyncManager, UISettings settings) { return appendCreativeUI(GTGuis.createPanel(this, 176, 166), true, new BoolValue.Dynamic(() -> active, b -> active = b), new IntSyncValue(() -> mBPerCycle, v -> mBPerCycle = v), diff --git a/src/main/java/gregtech/common/metatileentities/storage/MetaTileEntityQuantumChest.java b/src/main/java/gregtech/common/metatileentities/storage/MetaTileEntityQuantumChest.java index 59ee66983e7..4c4cee04ff4 100644 --- a/src/main/java/gregtech/common/metatileentities/storage/MetaTileEntityQuantumChest.java +++ b/src/main/java/gregtech/common/metatileentities/storage/MetaTileEntityQuantumChest.java @@ -14,7 +14,7 @@ import gregtech.api.util.TextFormattingUtil; import gregtech.client.renderer.texture.Textures; import gregtech.client.renderer.texture.custom.QuantumStorageRenderer; -import gregtech.common.mui.widget.GTItemSlot; +import gregtech.common.mui.widget.FakeItemSlot; import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.client.resources.I18n; @@ -46,7 +46,6 @@ import com.cleanroommc.modularui.screen.ModularPanel; import com.cleanroommc.modularui.value.sync.PanelSyncManager; import com.cleanroommc.modularui.value.sync.SyncHandler; -import com.cleanroommc.modularui.widgets.slot.ModularSlot; import org.apache.commons.lang3.ArrayUtils; import org.apache.commons.lang3.tuple.Pair; import org.jetbrains.annotations.NotNull; @@ -324,12 +323,12 @@ protected void createWidgets(ModularPanel mainPanel, PanelSyncManager syncManage () -> virtualItemStack.getDisplayName(), textWidget -> !virtualItemStack.isEmpty(), () -> TextFormattingUtil.formatNumbers(itemsStoredInside))) - .child(new GTItemSlot() + .child(new FakeItemSlot(true) .showTooltip(true) .showAmount(false) .background(IDrawable.NONE) - .slot(new ModularSlot(itemInventory, 0) - .accessibility(false, false)) + .slot(itemInventory, 0) + // TODO: lock from ghost item .receiveItemFromClient(this::setLocked) .pos(148, 41)); } @@ -425,9 +424,11 @@ public void setFrontFacing(EnumFacing frontFacing) { @Override protected void setLocked(boolean locked) { super.setLocked(locked); - if (locked && !this.virtualItemStack.isEmpty() && this.lockedStack.isEmpty()) + if (locked && !this.virtualItemStack.isEmpty() && this.lockedStack.isEmpty()) { this.lockedStack = this.virtualItemStack.copy(); - else if (!locked) this.lockedStack = ItemStack.EMPTY; + } else if (!locked) { + this.lockedStack = ItemStack.EMPTY; + } } protected void setLocked(ItemStack stack) { diff --git a/src/main/java/gregtech/common/metatileentities/storage/MetaTileEntityQuantumStorage.java b/src/main/java/gregtech/common/metatileentities/storage/MetaTileEntityQuantumStorage.java index b42b85779a1..440c4290075 100644 --- a/src/main/java/gregtech/common/metatileentities/storage/MetaTileEntityQuantumStorage.java +++ b/src/main/java/gregtech/common/metatileentities/storage/MetaTileEntityQuantumStorage.java @@ -30,12 +30,15 @@ import codechicken.lib.render.CCRenderState; import codechicken.lib.render.pipeline.IVertexOperation; import codechicken.lib.vec.Matrix4; +import com.cleanroommc.modularui.animation.Animator; import com.cleanroommc.modularui.api.drawable.IKey; import com.cleanroommc.modularui.drawable.DynamicDrawable; import com.cleanroommc.modularui.factory.PosGuiData; import com.cleanroommc.modularui.screen.ModularPanel; +import com.cleanroommc.modularui.screen.UISettings; import com.cleanroommc.modularui.utils.Alignment; import com.cleanroommc.modularui.utils.Color; +import com.cleanroommc.modularui.utils.Interpolation; import com.cleanroommc.modularui.value.BoolValue; import com.cleanroommc.modularui.value.sync.BooleanSyncValue; import com.cleanroommc.modularui.value.sync.IntSyncValue; @@ -43,12 +46,11 @@ import com.cleanroommc.modularui.value.sync.SyncHandlers; import com.cleanroommc.modularui.widget.ParentWidget; import com.cleanroommc.modularui.widgets.ButtonWidget; -import com.cleanroommc.modularui.widgets.ItemSlot; import com.cleanroommc.modularui.widgets.ScrollingTextWidget; import com.cleanroommc.modularui.widgets.SlotGroupWidget; -import com.cleanroommc.modularui.widgets.TextWidget; import com.cleanroommc.modularui.widgets.ToggleButton; import com.cleanroommc.modularui.widgets.layout.Flow; +import com.cleanroommc.modularui.widgets.slot.ItemSlot; import com.cleanroommc.modularui.widgets.textfield.TextFieldWidget; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -172,7 +174,7 @@ public boolean usesMui2() { } @Override - public ModularPanel buildUI(PosGuiData guiData, PanelSyncManager guiSyncManager) { + public ModularPanel buildUI(PosGuiData guiData, PanelSyncManager guiSyncManager, UISettings settings) { var panel = GTGuis.createPanel(this, 176, 166); createWidgets(panel, guiSyncManager); return panel.padding(4) @@ -182,13 +184,15 @@ public ModularPanel buildUI(PosGuiData guiData, PanelSyncManager guiSyncManager) .child(createConnectionButton() .right(9) .top(18 + 45)) - .child(SlotGroupWidget.playerInventory().left(7)); + .child(SlotGroupWidget.playerInventory(false) + .left(7) + .bottom(7)); } protected void createWidgets(ModularPanel mainPanel, PanelSyncManager syncManager) {} public Flow createQuantumDisplay(String lang, - Supplier name, Predicate condition, + Supplier name, Predicate condition, Supplier count) { return Flow.column() .background(GTGuiTextures.DISPLAY) @@ -203,6 +207,8 @@ public Flow createQuantumDisplay(String lang, .left(4) .marginBottom(2)) .child(new ScrollingTextWidget(IKey.dynamic(name)) + // initialize this so it doesn't crash on dispose + .animator(new Animator().curve(Interpolation.SINE_INOUT)) .alignment(Alignment.CenterLeft) .color(Color.WHITE.main) .setEnabledIf(condition) @@ -287,7 +293,6 @@ protected ModularPanel appendCreativeUI(ModularPanel panel, boolean isTank, .left(2) .marginBottom(15) .size(154, 14) - .keepScrollBarInArea(true) .setNumbers(1, Integer.MAX_VALUE) .setMaxLength(11) .value(amountPerCycle)) @@ -296,7 +301,6 @@ protected ModularPanel appendCreativeUI(ModularPanel panel, boolean isTank, .child(new TextFieldWidget() .left(2) .size(154, 14) - .keepScrollBarInArea(true) .setNumbers(1, Integer.MAX_VALUE) .setMaxLength(11) .value(ticksPerCycle))) diff --git a/src/main/java/gregtech/common/metatileentities/storage/MetaTileEntityQuantumTank.java b/src/main/java/gregtech/common/metatileentities/storage/MetaTileEntityQuantumTank.java index ffa614d94ce..36b141fdf86 100644 --- a/src/main/java/gregtech/common/metatileentities/storage/MetaTileEntityQuantumTank.java +++ b/src/main/java/gregtech/common/metatileentities/storage/MetaTileEntityQuantumTank.java @@ -323,6 +323,7 @@ protected void createWidgets(ModularPanel mainPanel, PanelSyncManager syncManage .child(new GTFluidSlot() .background(IDrawable.NONE) .syncHandler(fluidSyncHandler + .accessibility(true, false) .handleLocking(() -> lockedFluid, fluidStack -> { setLocked(fluidStack != null); lockedFluid = fluidStack; @@ -463,10 +464,10 @@ public boolean onScrewdriverClick(EntityPlayer playerIn, EnumHand hand, EnumFaci @Override protected void setLocked(boolean locked) { + if (locked == this.isLocked()) return; super.setLocked(locked); if (locked && fluidTank.getFluid() != null) { - this.lockedFluid = fluidTank.getFluid().copy(); - this.lockedFluid.amount = 1; + this.lockedFluid = GTUtility.copy(1, fluidTank.getFluid()); } else this.lockedFluid = null; } diff --git a/src/main/java/gregtech/common/metatileentities/storage/MetaTileEntityWorkbench.java b/src/main/java/gregtech/common/metatileentities/storage/MetaTileEntityWorkbench.java index cf19d68fe16..3483c603223 100644 --- a/src/main/java/gregtech/common/metatileentities/storage/MetaTileEntityWorkbench.java +++ b/src/main/java/gregtech/common/metatileentities/storage/MetaTileEntityWorkbench.java @@ -47,17 +47,18 @@ import com.cleanroommc.modularui.factory.PosGuiData; import com.cleanroommc.modularui.network.NetworkUtils; import com.cleanroommc.modularui.screen.ModularPanel; +import com.cleanroommc.modularui.screen.UISettings; import com.cleanroommc.modularui.utils.Alignment; import com.cleanroommc.modularui.value.sync.IntSyncValue; import com.cleanroommc.modularui.value.sync.PanelSyncManager; import com.cleanroommc.modularui.widget.scroll.VerticalScrollData; import com.cleanroommc.modularui.widgets.ButtonWidget; -import com.cleanroommc.modularui.widgets.ItemSlot; import com.cleanroommc.modularui.widgets.PageButton; import com.cleanroommc.modularui.widgets.PagedWidget; import com.cleanroommc.modularui.widgets.SlotGroupWidget; import com.cleanroommc.modularui.widgets.layout.Flow; import com.cleanroommc.modularui.widgets.layout.Grid; +import com.cleanroommc.modularui.widgets.slot.ItemSlot; import com.cleanroommc.modularui.widgets.slot.ModularSlot; import com.cleanroommc.modularui.widgets.slot.SlotGroup; import com.google.common.base.Preconditions; @@ -217,7 +218,7 @@ public boolean usesMui2() { } @Override - public ModularPanel buildUI(PosGuiData guiData, PanelSyncManager syncManager) { + public ModularPanel buildUI(PosGuiData guiData, PanelSyncManager syncManager, UISettings settings) { getCraftingRecipeLogic().updateCurrentRecipe(); this.recipeLogic.clearSlotMap(); @@ -322,19 +323,7 @@ public IWidget createCraftingGrid() { } }) .background(GTGuiTextures.SLOT)) - .build() - .child(new ButtonWidget<>() - .margin(2) - .size(8) - .topRel(0f) - .rightRel(0f, 0, 1f) - .background(GTGuiTextures.BUTTON_CLEAR_GRID) - .addTooltipLine(IKey.lang("gregtech.machine.workbench.clear_grid")) - .disableHoverBackground() - .onMousePressed(mouseButton -> { - this.recipeLogic.clearCraftingGrid(); - return true; - })); + .build(); } public IWidget createCraftingOutput(PosGuiData guiData, PanelSyncManager syncManager) { @@ -349,7 +338,18 @@ public IWidget createCraftingOutput(PosGuiData guiData, PanelSyncManager syncMan .marginBottom(4)) .child(IKey.dynamic(() -> TextFormattingUtil.formatLongToCompactString(amountCrafted.getIntValue(), 5)) .alignment(Alignment.Center) - .asWidget().widthRel(1f)); + .asWidget().widthRel(1f)) + .child(new ButtonWidget<>() + .margin(2) + .size(8) + .align(Alignment.TopLeft) + .background(GTGuiTextures.BUTTON_CLEAR_GRID) + .addTooltipLine(IKey.lang("gregtech.machine.workbench.clear_grid")) + .disableHoverBackground() + .onMousePressed(mouseButton -> { + this.recipeLogic.clearCraftingGrid(); + return true; + })); } public IWidget createRecipeMemoryGrid(PanelSyncManager syncManager) { diff --git a/src/main/java/gregtech/common/mui/widget/FakeItemSlot.java b/src/main/java/gregtech/common/mui/widget/FakeItemSlot.java new file mode 100644 index 00000000000..a648f1754cf --- /dev/null +++ b/src/main/java/gregtech/common/mui/widget/FakeItemSlot.java @@ -0,0 +1,249 @@ +package gregtech.common.mui.widget; + +import gregtech.client.utils.RenderUtil; +import gregtech.integration.jei.JustEnoughItemsModule; + +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.network.PacketBuffer; +import net.minecraftforge.items.IItemHandler; + +import com.cleanroommc.modularui.api.ITheme; +import com.cleanroommc.modularui.api.IThemeApi; +import com.cleanroommc.modularui.api.widget.Interactable; +import com.cleanroommc.modularui.integration.recipeviewer.RecipeViewerGhostIngredientSlot; +import com.cleanroommc.modularui.integration.recipeviewer.RecipeViewerIngredientProvider; +import com.cleanroommc.modularui.screen.RichTooltip; +import com.cleanroommc.modularui.screen.viewport.ModularGuiContext; +import com.cleanroommc.modularui.theme.WidgetThemeEntry; +import com.cleanroommc.modularui.value.sync.SyncHandler; +import com.cleanroommc.modularui.widget.Widget; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.io.IOException; +import java.util.function.BooleanSupplier; +import java.util.function.Consumer; +import java.util.function.Supplier; + +public class FakeItemSlot extends Widget + implements Interactable, RecipeViewerGhostIngredientSlot, + RecipeViewerIngredientProvider { + + private final boolean receiveFromRecipeViewer; + + private FakeItemSlotSyncHandler syncHandler; + private BooleanSupplier showTooltip = () -> true; + private BooleanSupplier showAmount = () -> true; + + public FakeItemSlot(boolean receiveFromRecipeViewer) { + this.receiveFromRecipeViewer = receiveFromRecipeViewer; + } + + @Override + public boolean isValidSyncHandler(SyncHandler syncHandler) { + return syncHandler instanceof FakeItemSlotSyncHandler; + } + + public FakeItemSlot item(@NotNull ItemStack itemStack) { + return item(() -> itemStack); + } + + public FakeItemSlot item(@NotNull Supplier<@NotNull ItemStack> itemStackSupplier) { + if (this.syncHandler == null) { + this.syncHandler = new FakeItemSlotSyncHandler(); + setSyncHandler(syncHandler); + } + + this.syncHandler.setItemStackSupplier(itemStackSupplier); + return this; + } + + public FakeItemSlot slot(@NotNull IItemHandler itemHandler, int index) { + return item(() -> itemHandler.getStackInSlot(index)); + } + + public FakeItemSlot receiveItemFromClient(@NotNull Consumer<@NotNull ItemStack> itemStackConsumer) { + if (this.syncHandler == null) { + this.syncHandler = new FakeItemSlotSyncHandler(); + setSyncHandler(syncHandler); + } + + this.syncHandler.setItemStackConsumer(itemStackConsumer); + return this; + } + + @Override + public @NotNull FakeItemSlotSyncHandler getSyncHandler() { + if (this.syncHandler == null) { + throw new IllegalStateException("Widget is not initialised or not synced!"); + } + + return this.syncHandler; + } + + @Override + public void onInit() { + tooltip().setAutoUpdate(true); + tooltip().tooltipBuilder(rt -> { + if (!isSynced()) return; + ItemStack stack = getSyncHandler().getStack(); + if (stack.isEmpty()) return; + rt.addFromItem(stack); + }); + + if (receiveFromRecipeViewer) { + getContext().getRecipeViewerSettings().addGhostIngredientSlot(this); + } + } + + public FakeItemSlot showTooltip(boolean showTooltip) { + return showTooltip(() -> showTooltip); + } + + public FakeItemSlot showTooltip(BooleanSupplier showTooltip) { + this.showTooltip = showTooltip; + return getThis(); + } + + public FakeItemSlot showAmount(boolean showAmount) { + return showAmount(() -> showAmount); + } + + public FakeItemSlot showAmount(BooleanSupplier showAmount) { + this.showAmount = showAmount; + return getThis(); + } + + @Override + public void draw(ModularGuiContext context, WidgetThemeEntry widgetTheme) { + if (this.syncHandler == null) return; + + RenderUtil.drawItemStack(getSyncHandler().getStack(), 1, 1, showAmount.getAsBoolean()); + RenderUtil.handleJEIGhostSlotOverlay(this, widgetTheme); + } + + @Override + public void drawForeground(ModularGuiContext context) { + RichTooltip tooltip = getTooltip(); + if (showTooltip.getAsBoolean() && tooltip != null && isHoveringFor(tooltip.getShowUpTimer())) { + tooltip.draw(getContext(), getSyncHandler().getStack()); + } + } + + @Override + public WidgetThemeEntry getWidgetThemeInternal(ITheme theme) { + return theme.getWidgetTheme(IThemeApi.ITEM_SLOT); + } + + @Override + public @NotNull Result onMousePressed(int mouseButton) { + getSyncHandler().setStackFromCursor(); + return Result.ACCEPT; + } + + @Override + public void setGhostIngredient(@NotNull ItemStack ingredient) { + if (receiveFromRecipeViewer) { + getSyncHandler().setStack(ingredient); + } else { + throw new IllegalStateException( + "setGhostIngredient was called on a FakeItemSlot that had receiveFromRecipeViewer false"); + } + } + + @Override + public @Nullable ItemStack castGhostIngredientIfValid(@NotNull Object ingredient) { + return receiveFromRecipeViewer ? JustEnoughItemsModule.ingredientRegistry + .getIngredientHelper(ingredient) + .getCheatItemStack(ingredient) : null; + } + + @Override + public @Nullable Object getIngredient() { + return getSyncHandler().getStack(); + } + + public static class FakeItemSlotSyncHandler extends SyncHandler { + + private static final int ITEM_CHANGED = 0; + private static final int ITEM_SET_FROM_CLIENT = 1; + private static final int ITEM_SET_TO_CURSOR = 2; + + @Nullable + private Supplier<@NotNull ItemStack> itemStackSupplier; + @Nullable + private Consumer<@NotNull ItemStack> itemStackConsumer; + + @NotNull + private ItemStack cachedStack = ItemStack.EMPTY; + + public void setItemStackSupplier(@Nullable Supplier<@NotNull ItemStack> itemStackSupplier) { + this.itemStackSupplier = itemStackSupplier; + } + + public void setItemStackConsumer(@Nullable Consumer<@NotNull ItemStack> itemStackConsumer) { + this.itemStackConsumer = itemStackConsumer; + } + + public @NotNull ItemStack getStack() { + return cachedStack; + } + + public void setStack(@NotNull ItemStack itemStack) { + syncToServer(ITEM_SET_FROM_CLIENT, buf -> buf.writeItemStack(itemStack)); + } + + public void setStackFromCursor() { + syncToServer(ITEM_SET_TO_CURSOR); + } + + @Override + public void detectAndSendChanges(boolean init) { + if (itemStackSupplier == null) { + return; + } + + ItemStack sourceStack = itemStackSupplier.get(); + boolean itemsEqual = cachedStack.isItemEqual(sourceStack); + if (itemsEqual) { + NBTTagCompound sourceStackNBT = sourceStack.getTagCompound(); + NBTTagCompound cachedStackNBT = cachedStack.getTagCompound(); + if (sourceStackNBT == null) { + itemsEqual = cachedStackNBT == null; + } else { + if (cachedStackNBT != null) { + itemsEqual = cachedStackNBT.equals(sourceStack.getTagCompound()); + } else { + itemsEqual = false; + } + } + } + + if (init || !itemsEqual) { + cachedStack = sourceStack.copy(); + syncToClient(ITEM_CHANGED, buf -> buf.writeItemStack(cachedStack)); + } + } + + @Override + public void readOnClient(int id, PacketBuffer buf) throws IOException { + if (id == ITEM_CHANGED) { + cachedStack = buf.readItemStack(); + } + } + + @Override + public void readOnServer(int id, PacketBuffer buf) throws IOException { + ItemStack itemStack = switch (id) { + case ITEM_SET_FROM_CLIENT -> buf.readItemStack(); + case ITEM_SET_TO_CURSOR -> getSyncManager().getCursorItem(); + default -> ItemStack.EMPTY; + }; + + if (itemStackConsumer != null) { + itemStackConsumer.accept(itemStack); + } + } + } +} diff --git a/src/main/java/gregtech/common/mui/widget/GTFluidSlot.java b/src/main/java/gregtech/common/mui/widget/GTFluidSlot.java index e7fb5115df6..23c14ab82ca 100644 --- a/src/main/java/gregtech/common/mui/widget/GTFluidSlot.java +++ b/src/main/java/gregtech/common/mui/widget/GTFluidSlot.java @@ -9,16 +9,16 @@ import net.minecraftforge.fluids.IFluidTank; import com.cleanroommc.modularui.api.ITheme; +import com.cleanroommc.modularui.api.UpOrDown; +import com.cleanroommc.modularui.api.drawable.IDrawable; import com.cleanroommc.modularui.api.widget.Interactable; import com.cleanroommc.modularui.drawable.GuiDraw; import com.cleanroommc.modularui.drawable.text.TextRenderer; -import com.cleanroommc.modularui.integration.jei.JeiGhostIngredientSlot; -import com.cleanroommc.modularui.integration.jei.JeiIngredientProvider; +import com.cleanroommc.modularui.integration.recipeviewer.RecipeViewerGhostIngredientSlot; +import com.cleanroommc.modularui.integration.recipeviewer.RecipeViewerIngredientProvider; import com.cleanroommc.modularui.network.NetworkUtils; -import com.cleanroommc.modularui.screen.ModularScreen; import com.cleanroommc.modularui.screen.viewport.ModularGuiContext; -import com.cleanroommc.modularui.theme.WidgetSlotTheme; -import com.cleanroommc.modularui.theme.WidgetTheme; +import com.cleanroommc.modularui.theme.WidgetThemeEntry; import com.cleanroommc.modularui.utils.Alignment; import com.cleanroommc.modularui.utils.Color; import com.cleanroommc.modularui.utils.MouseData; @@ -28,15 +28,20 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -public final class GTFluidSlot extends Widget implements Interactable, JeiIngredientProvider, - JeiGhostIngredientSlot { +public final class GTFluidSlot extends Widget implements Interactable, RecipeViewerIngredientProvider, + RecipeViewerGhostIngredientSlot { private final TextRenderer textRenderer = new TextRenderer(); private GTFluidSyncHandler syncHandler; - private boolean disableBackground = false; public GTFluidSlot() { tooltip().titleMargin(); + tooltipAutoUpdate(true); + tooltipBuilder(tooltip -> { + if (isSynced()) { + syncHandler.handleTooltip(tooltip); + } + }); } public static GTFluidSyncHandler sync(IFluidTank tank) { @@ -49,10 +54,8 @@ public void onInit() { this.textRenderer.setScale(0.5f); this.textRenderer.setColor(Color.WHITE.main); if (syncHandler.canLockFluid() || syncHandler.isPhantom()) { - getContext().getJeiSettings().addJeiGhostIngredientSlot(this); + getContext().getRecipeViewerSettings().addGhostIngredientSlot(this); } - tooltipBuilder(syncHandler::handleTooltip); - syncHandler.setChangeConsumer($ -> markTooltipDirty()); } public GTFluidSlot syncHandler(IFluidTank fluidTank) { @@ -61,13 +64,11 @@ public GTFluidSlot syncHandler(IFluidTank fluidTank) { public GTFluidSlot syncHandler(GTFluidSyncHandler syncHandler) { setSyncHandler(syncHandler); - this.syncHandler = syncHandler; return this; } public GTFluidSlot disableBackground() { - this.disableBackground = true; - return this; + return background(IDrawable.NONE); } @Override @@ -76,19 +77,13 @@ public boolean isValidSyncHandler(SyncHandler syncHandler) { } @Override - public void drawBackground(ModularGuiContext context, WidgetTheme widgetTheme) { - if (disableBackground) return; - super.drawBackground(context, widgetTheme); + protected void setSyncHandler(@Nullable SyncHandler syncHandler) { + super.setSyncHandler(syncHandler); + this.syncHandler = (GTFluidSyncHandler) syncHandler; } @Override - public void draw(ModularGuiContext context, WidgetTheme widgetTheme) { - if (widgetTheme instanceof WidgetSlotTheme slotTheme) { - draw(context, slotTheme); - } - } - - public void draw(ModularGuiContext context, WidgetSlotTheme widgetTheme) { + public void draw(ModularGuiContext context, WidgetThemeEntry widgetTheme) { FluidStack content = this.syncHandler.getFluid(); if (content == null) content = this.syncHandler.getLockedFluid(); @@ -100,13 +95,13 @@ public void draw(ModularGuiContext context, WidgetSlotTheme widgetTheme) { float amt = content == null ? 0f : content.amount; float newHeight = height * (amt / this.syncHandler.getCapacity()); y += (int) (height - newHeight); - height = newHeight; + height = (float) Math.ceil(newHeight); } GuiDraw.drawFluidTexture(content, 1, y, getArea().w() - 2, height, 0); if (content != null && this.syncHandler.showAmountOnSlot()) { - String amount = NumberFormat.formatWithMaxDigits(content.amount, 3) + "L"; + String amount = NumberFormat.DEFAULT.format(content.amount) + "L"; this.textRenderer.setAlignment(Alignment.CenterRight, getArea().width - 1f); this.textRenderer.setPos(0, 12); this.textRenderer.draw(amount); @@ -131,7 +126,7 @@ public void draw(ModularGuiContext context, WidgetSlotTheme widgetTheme) { } @Override - public boolean onMouseScroll(ModularScreen.UpOrDown scrollDirection, int amount) { + public boolean onMouseScroll(UpOrDown scrollDirection, int amount) { if (!this.syncHandler.isPhantom()) return false; if ((scrollDirection.isUp() && !this.syncHandler.canFillSlot()) || (scrollDirection.isDown() && !this.syncHandler.canDrainSlot())) { @@ -143,7 +138,7 @@ public boolean onMouseScroll(ModularScreen.UpOrDown scrollDirection, int amount) } @Override - protected WidgetTheme getWidgetThemeInternal(ITheme theme) { + protected WidgetThemeEntry getWidgetThemeInternal(ITheme theme) { return theme.getFluidSlotTheme(); } diff --git a/src/main/java/gregtech/common/mui/widget/GTItemSlot.java b/src/main/java/gregtech/common/mui/widget/GTItemSlot.java deleted file mode 100644 index 3eacfd2f303..00000000000 --- a/src/main/java/gregtech/common/mui/widget/GTItemSlot.java +++ /dev/null @@ -1,198 +0,0 @@ -package gregtech.common.mui.widget; - -import gregtech.client.utils.RenderUtil; - -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.inventory.Slot; -import net.minecraft.item.ItemStack; -import net.minecraftforge.items.IItemHandlerModifiable; - -import com.cleanroommc.modularui.api.ITheme; -import com.cleanroommc.modularui.api.widget.IVanillaSlot; -import com.cleanroommc.modularui.api.widget.Interactable; -import com.cleanroommc.modularui.drawable.GuiDraw; -import com.cleanroommc.modularui.integration.jei.JeiGhostIngredientSlot; -import com.cleanroommc.modularui.integration.jei.JeiIngredientProvider; -import com.cleanroommc.modularui.screen.ClientScreenHandler; -import com.cleanroommc.modularui.screen.ModularScreen; -import com.cleanroommc.modularui.screen.RichTooltip; -import com.cleanroommc.modularui.screen.viewport.ModularGuiContext; -import com.cleanroommc.modularui.theme.WidgetSlotTheme; -import com.cleanroommc.modularui.theme.WidgetTheme; -import com.cleanroommc.modularui.utils.MouseData; -import com.cleanroommc.modularui.value.sync.ItemSlotSH; -import com.cleanroommc.modularui.value.sync.SyncHandler; -import com.cleanroommc.modularui.widget.Widget; -import com.cleanroommc.modularui.widgets.slot.ModularSlot; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -import java.util.function.BooleanSupplier; - -// todo make sure this class is actually needed once we update to rc6 -public class GTItemSlot extends Widget - implements IVanillaSlot, Interactable, JeiGhostIngredientSlot, - JeiIngredientProvider { - - private BooleanSupplier showTooltip = () -> true; - private BooleanSupplier showAmount = () -> true; - private ItemSlotSH syncHandler; - - public GTItemSlot() { - tooltip().setAutoUpdate(true) - .titleMargin(); - tooltipBuilder(tooltip -> { - if (!isSynced()) return; - ItemStack stack = getSlot().getStack(); - if (stack.isEmpty()) return; - tooltip.addFromItem(stack); - }); - } - - @Override - public void onInit() { - if (getScreen().isOverlay()) { - throw new IllegalStateException("Overlays can't have slots!"); - } - size(18); - getContext().getJeiSettings().addJeiGhostIngredientSlot(this); - } - - public GTItemSlot showTooltip(boolean showTooltip) { - return showTooltip(() -> showTooltip); - } - - public GTItemSlot showTooltip(BooleanSupplier showTooltip) { - this.showTooltip = showTooltip; - return getThis(); - } - - public GTItemSlot showAmount(boolean showAmount) { - return showAmount(() -> showAmount); - } - - public GTItemSlot showAmount(BooleanSupplier showAmount) { - this.showAmount = showAmount; - return getThis(); - } - - @SuppressWarnings("UnstableApiUsage") - public GTItemSlot slot(ModularSlot slot) { - this.syncHandler = new ItemSlotSH(slot); - setSyncHandler(this.syncHandler); - return getThis(); - } - - public GTItemSlot slot(IItemHandlerModifiable itemHandler, int index) { - return slot(new ModularSlot(itemHandler, index)); - } - - @Override - public @NotNull Result onMousePressed(int mouseButton) { - if (this.syncHandler.isPhantom()) { - MouseData mouseData = MouseData.create(mouseButton); - this.syncHandler.syncToServer(2, mouseData::writeToPacket); - } else { - ClientScreenHandler.clickSlot(getScreen(), getSlot()); - } - return Result.SUCCESS; - } - - @Override - public boolean onMouseRelease(int mouseButton) { - if (!this.syncHandler.isPhantom()) { - ClientScreenHandler.releaseSlot(); - } - return true; - } - - @Override - public boolean onMouseScroll(ModularScreen.UpOrDown scrollDirection, int amount) { - if (this.syncHandler.isPhantom()) { - MouseData mouseData = MouseData.create(scrollDirection.modifier); - this.syncHandler.syncToServer(3, mouseData::writeToPacket); - return true; - } - return false; - } - - @Override - public void onMouseDrag(int mouseButton, long timeSinceClick) { - ClientScreenHandler.dragSlot(timeSinceClick); - } - - @Override - public boolean isValidSyncHandler(SyncHandler syncHandler) { - this.syncHandler = castIfTypeElseNull(syncHandler, ItemSlotSH.class); - return this.syncHandler != null; - } - - @Override - public void onUpdate() { - super.onUpdate(); - boolean shouldBeEnabled = areAncestorsEnabled(); - if (shouldBeEnabled != getSlot().isEnabled()) { - this.syncHandler.setEnabled(shouldBeEnabled, true); - } - } - - @Override - public void drawForeground(ModularGuiContext context) { - RichTooltip tooltip = getTooltip(); - if (showTooltip.getAsBoolean() && tooltip != null && isHoveringFor(tooltip.getShowUpTimer())) { - tooltip.draw(getContext(), getSlot().getStack()); - } - } - - @Override - public void draw(ModularGuiContext context, WidgetTheme widgetTheme) { - if (this.syncHandler == null) return; - - RenderUtil.drawItemStack(getSlot().getStack(), 1, 1, showAmount.getAsBoolean()); - - if (isHovering()) { - GlStateManager.colorMask(true, true, true, false); - GuiDraw.drawRect(1, 1, 16, 16, getSlotHoverColor()); - GlStateManager.colorMask(true, true, true, true); - } - } - - @Override - public WidgetSlotTheme getWidgetThemeInternal(ITheme theme) { - return theme.getItemSlotTheme(); - } - - public int getSlotHoverColor() { - WidgetTheme theme = getWidgetTheme(getContext().getTheme()); - if (theme instanceof WidgetSlotTheme slotTheme) { - return slotTheme.getSlotHoverColor(); - } - return ITheme.getDefault().getItemSlotTheme().getSlotHoverColor(); - } - - @Override - public Slot getVanillaSlot() { - return getSlot(); - } - - public ModularSlot getSlot() { - return this.syncHandler.getSlot(); - } - - @Override - public void setGhostIngredient(@NotNull ItemStack ingredient) { - if (this.syncHandler.isPhantom()) { - this.syncHandler.updateFromClient(ingredient); - } - } - - @Override - public @Nullable ItemStack castGhostIngredientIfValid(@NotNull Object ingredient) { - return this.syncHandler.isPhantom() && ingredient instanceof ItemStack itemStack ? itemStack : null; - } - - @Override - public @Nullable Object getIngredient() { - return getSlot().getStack(); - } -} diff --git a/src/main/java/gregtech/common/mui/widget/InteractableText.java b/src/main/java/gregtech/common/mui/widget/InteractableText.java index bcafa15208d..0ac02dd22e3 100644 --- a/src/main/java/gregtech/common/mui/widget/InteractableText.java +++ b/src/main/java/gregtech/common/mui/widget/InteractableText.java @@ -15,7 +15,7 @@ import java.util.function.Consumer; -public class InteractableText extends TextWidget implements Interactable { +public class InteractableText extends TextWidget> implements Interactable { private final T entry; private final EntryColorSH syncHandler; diff --git a/src/main/java/gregtech/common/mui/widget/ScrollableTextWidget.java b/src/main/java/gregtech/common/mui/widget/ScrollableTextWidget.java index a20bfc92a41..ee06fa2f5bf 100644 --- a/src/main/java/gregtech/common/mui/widget/ScrollableTextWidget.java +++ b/src/main/java/gregtech/common/mui/widget/ScrollableTextWidget.java @@ -1,11 +1,11 @@ package gregtech.common.mui.widget; -import gregtech.api.mui.IconAcessor; - import net.minecraft.client.gui.FontRenderer; import com.cleanroommc.modularui.api.GuiAxis; +import com.cleanroommc.modularui.api.UpOrDown; import com.cleanroommc.modularui.api.drawable.IHoverable; +import com.cleanroommc.modularui.api.drawable.IIcon; import com.cleanroommc.modularui.api.drawable.IRichTextBuilder; import com.cleanroommc.modularui.api.layout.IViewport; import com.cleanroommc.modularui.api.layout.IViewportStack; @@ -14,10 +14,12 @@ import com.cleanroommc.modularui.drawable.Stencil; import com.cleanroommc.modularui.drawable.text.RichText; import com.cleanroommc.modularui.drawable.text.TextRenderer; -import com.cleanroommc.modularui.integration.jei.JeiIngredientProvider; -import com.cleanroommc.modularui.screen.ModularScreen; +import com.cleanroommc.modularui.integration.recipeviewer.RecipeViewerIngredientProvider; import com.cleanroommc.modularui.screen.RichTooltip; import com.cleanroommc.modularui.screen.viewport.ModularGuiContext; +import com.cleanroommc.modularui.theme.TextFieldTheme; +import com.cleanroommc.modularui.theme.WidgetTheme; +import com.cleanroommc.modularui.theme.WidgetThemeEntry; import com.cleanroommc.modularui.utils.HoveredWidgetList; import com.cleanroommc.modularui.widget.Widget; import com.cleanroommc.modularui.widget.scroll.ScrollArea; @@ -30,7 +32,7 @@ public class ScrollableTextWidget extends Widget implements IRichTextBuilder, Interactable, IViewport, - JeiIngredientProvider { + RecipeViewerIngredientProvider { private final RichText text = new RichText(); private Consumer builder; @@ -50,7 +52,7 @@ public ScrollableTextWidget() { @Override public void onInit() { - this.scroll.setScrollData(ScrollData.of(GuiAxis.Y)); + this.scroll.setScrollData(ScrollData.of(GuiAxis.Y, false, 4)); } @Override @@ -73,8 +75,8 @@ public void drawForeground(ModularGuiContext context) { tooltip.draw(context); } } - if (getHoveredElement() instanceof IconAcessor accessor && - accessor.gregTech$getDrawable() instanceof JeiIngredientProvider provider) { + if (getHoveredElement() instanceof IIcon icon && + icon.getRootDrawable() instanceof RecipeViewerIngredientProvider provider) { lastIngredient = provider.getIngredient(); } else { lastIngredient = null; @@ -94,7 +96,7 @@ public void drawForeground(ModularGuiContext context) { } @Override - public boolean onMouseScroll(ModularScreen.UpOrDown scrollDirection, int amount) { + public boolean onMouseScroll(UpOrDown scrollDirection, int amount) { if (this.scroll.mouseScroll(getContext())) { return true; } @@ -138,7 +140,7 @@ public void transformChildren(IViewportStack stack) { @Override public void getSelfAt(IViewportStack stack, HoveredWidgetList widgets, int x, int y) { if (isInside(stack, x, y)) { - widgets.add(this, stack.peek()); + widgets.add(this, stack, getAdditionalHoverInfo(stack, x, y)); } } @@ -173,13 +175,14 @@ private void drawText(ModularGuiContext context) { } this.dirty = false; } - this.text.setupRenderer(this.renderer, getArea().getPadding().left, getArea().getPadding().top - getScrollY(), - getArea().paddedWidth(), getArea().paddedHeight(), - getWidgetTheme(context.getTheme()).getTextColor(), - getWidgetTheme(context.getTheme()).getTextShadow()); + + TextFieldTheme textFieldTheme = context.getTheme().getTextFieldTheme().getTheme(); + this.text.setupRenderer(this.renderer, getArea().getPadding().getLeft(), + getArea().getPadding().getTop() - getScrollY(), getArea().paddedWidth(), getArea().paddedHeight(), + textFieldTheme.getTextColor(), textFieldTheme.getTextShadow()); this.text.compileAndDraw(this.renderer, context, false); // this isn't perfect, but i hope it's good enough - int diff = (int) Math.ceil((this.renderer.getLastHeight() - getArea().h()) / 2); + int diff = (int) Math.ceil((this.renderer.getLastTrimmedHeight() - getArea().h()) / 2); this.scroll.getScrollY().setScrollSize(getArea().h() + Math.max(0, diff)); } @@ -187,7 +190,8 @@ private void drawText(ModularGuiContext context) { public void postDraw(ModularGuiContext context, boolean transformed) { if (!transformed) { Stencil.remove(); - this.scroll.drawScrollbar(); + WidgetThemeEntry theme = context.getTheme().getScrollbarTheme(); + this.scroll.drawScrollbar(context, theme.getTheme(isHovering()), theme.getTheme().getBackground()); } } diff --git a/src/main/java/gregtech/common/mui/widget/orefilter/ItemOreFilterTestSlot.java b/src/main/java/gregtech/common/mui/widget/orefilter/ItemOreFilterTestSlot.java index 9e16df34dfb..e316b5024cd 100644 --- a/src/main/java/gregtech/common/mui/widget/orefilter/ItemOreFilterTestSlot.java +++ b/src/main/java/gregtech/common/mui/widget/orefilter/ItemOreFilterTestSlot.java @@ -11,7 +11,7 @@ public class ItemOreFilterTestSlot extends ModularSlot { OreFilterTestSlot parent; public ItemOreFilterTestSlot() { - super(new ItemStackHandler(1), 0, true); + super(new ItemStackHandler(1), 0); } void setParent(OreFilterTestSlot parent) { diff --git a/src/main/java/gregtech/common/mui/widget/orefilter/OreFilterTestSlot.java b/src/main/java/gregtech/common/mui/widget/orefilter/OreFilterTestSlot.java index e4d0ea8648c..bbef75a510c 100644 --- a/src/main/java/gregtech/common/mui/widget/orefilter/OreFilterTestSlot.java +++ b/src/main/java/gregtech/common/mui/widget/orefilter/OreFilterTestSlot.java @@ -8,8 +8,8 @@ import com.cleanroommc.modularui.api.drawable.IKey; import com.cleanroommc.modularui.screen.viewport.ModularGuiContext; -import com.cleanroommc.modularui.theme.WidgetTheme; -import com.cleanroommc.modularui.widgets.ItemSlot; +import com.cleanroommc.modularui.theme.WidgetThemeEntry; +import com.cleanroommc.modularui.widgets.slot.PhantomItemSlot; import it.unimi.dsi.fastutil.objects.Object2BooleanAVLTreeMap; import it.unimi.dsi.fastutil.objects.Object2BooleanMap; import org.jetbrains.annotations.Nullable; @@ -22,7 +22,7 @@ /** * @author brachy84 */ -public class OreFilterTestSlot extends ItemSlot { +public class OreFilterTestSlot extends PhantomItemSlot { private final ItemOreFilterTestSlot slot; private Supplier globSupplier = ImpossibleOreGlob::getInstance; @@ -106,14 +106,12 @@ public void updatePreview() { } @Override - public void draw(ModularGuiContext context, WidgetTheme widgetTheme) { + public void draw(ModularGuiContext context, WidgetThemeEntry widgetTheme) { super.draw(context, widgetTheme); if (this.matchSuccess) { - GTGuiTextures.OREDICT_MATCH - .draw(context, 12, -2, 9, 6, widgetTheme); - } else if (testResult.size() > 0) { - GTGuiTextures.OREDICT_NO_MATCH - .draw(context, 12, -3, 7, 7, widgetTheme); + GTGuiTextures.OREDICT_MATCH.draw(context, 12, -2, 9, 6, widgetTheme.getTheme()); + } else if (!testResult.isEmpty()) { + GTGuiTextures.OREDICT_NO_MATCH.draw(context, 12, -3, 7, 7, widgetTheme.getTheme()); } } diff --git a/src/main/java/gregtech/common/mui/widget/workbench/CraftingInputSlot.java b/src/main/java/gregtech/common/mui/widget/workbench/CraftingInputSlot.java index 160fcd5f21d..ef19b86415d 100644 --- a/src/main/java/gregtech/common/mui/widget/workbench/CraftingInputSlot.java +++ b/src/main/java/gregtech/common/mui/widget/workbench/CraftingInputSlot.java @@ -12,12 +12,12 @@ import com.cleanroommc.modularui.api.widget.IGuiAction; import com.cleanroommc.modularui.api.widget.Interactable; -import com.cleanroommc.modularui.integration.jei.JeiGhostIngredientSlot; -import com.cleanroommc.modularui.integration.jei.JeiIngredientProvider; +import com.cleanroommc.modularui.integration.recipeviewer.RecipeViewerGhostIngredientSlot; +import com.cleanroommc.modularui.integration.recipeviewer.RecipeViewerIngredientProvider; import com.cleanroommc.modularui.network.NetworkUtils; import com.cleanroommc.modularui.screen.RichTooltip; import com.cleanroommc.modularui.screen.viewport.ModularGuiContext; -import com.cleanroommc.modularui.theme.WidgetTheme; +import com.cleanroommc.modularui.theme.WidgetThemeEntry; import com.cleanroommc.modularui.value.sync.PanelSyncManager; import com.cleanroommc.modularui.value.sync.SyncHandler; import com.cleanroommc.modularui.widget.Widget; @@ -26,8 +26,8 @@ import org.jetbrains.annotations.Nullable; public class CraftingInputSlot extends Widget implements Interactable, - JeiGhostIngredientSlot, - JeiIngredientProvider { + RecipeViewerGhostIngredientSlot, + RecipeViewerIngredientProvider { private final InputSyncHandler syncHandler; public boolean hasIngredients = true; @@ -75,7 +75,7 @@ public boolean isValidSyncHandler(SyncHandler syncHandler) { @Override public void onInit() { - getContext().getJeiSettings().addJeiGhostIngredientSlot(this); + getContext().getRecipeViewerSettings().addGhostIngredientSlot(this); } public CraftingInputSlot changeListener(IOnSlotChanged listener) { @@ -101,7 +101,7 @@ public void onMouseDrag(int mouseButton, long timeSinceClick) { } @Override - public void draw(ModularGuiContext context, WidgetTheme widgetTheme) { + public void draw(ModularGuiContext context, WidgetThemeEntry widgetTheme) { ItemStack itemstack = this.syncHandler.getStack(); boolean jeiIngredientBeingHovered = JEIUtil.hoveringOverIngredient(this); @@ -135,8 +135,8 @@ public void setGhostIngredient(@NotNull ItemStack ingredient) { @Override public @Nullable ItemStack castGhostIngredientIfValid(@NotNull Object ingredient) { - ingredient = JEIUtil.getBookStackIfEnchantment(ingredient); - return areAncestorsEnabled() && ingredient instanceof ItemStack ? (ItemStack) ingredient : null; + ItemStack stack = JEIUtil.getActualStack(ingredient); + return areAncestorsEnabled() && !stack.isEmpty() ? stack : null; } @Override diff --git a/src/main/java/gregtech/common/mui/widget/workbench/CraftingOutputSlot.java b/src/main/java/gregtech/common/mui/widget/workbench/CraftingOutputSlot.java index b6f80537dbe..8640f4c58d0 100644 --- a/src/main/java/gregtech/common/mui/widget/workbench/CraftingOutputSlot.java +++ b/src/main/java/gregtech/common/mui/widget/workbench/CraftingOutputSlot.java @@ -17,11 +17,11 @@ import net.minecraftforge.items.ItemHandlerHelper; import com.cleanroommc.modularui.api.widget.Interactable; -import com.cleanroommc.modularui.integration.jei.JeiIngredientProvider; +import com.cleanroommc.modularui.integration.recipeviewer.RecipeViewerIngredientProvider; import com.cleanroommc.modularui.network.NetworkUtils; import com.cleanroommc.modularui.screen.RichTooltip; import com.cleanroommc.modularui.screen.viewport.ModularGuiContext; -import com.cleanroommc.modularui.theme.WidgetTheme; +import com.cleanroommc.modularui.theme.WidgetThemeEntry; import com.cleanroommc.modularui.utils.MouseData; import com.cleanroommc.modularui.value.sync.IntSyncValue; import com.cleanroommc.modularui.value.sync.PanelSyncManager; @@ -37,7 +37,8 @@ import java.util.List; import java.util.stream.Collectors; -public class CraftingOutputSlot extends Widget implements Interactable, JeiIngredientProvider { +public class CraftingOutputSlot extends Widget implements Interactable, + RecipeViewerIngredientProvider { private static final int MOUSE_CLICK = 2; private static final int SYNC_STACK = 5; @@ -70,7 +71,7 @@ public boolean isValidSyncHandler(SyncHandler syncHandler) { } @Override - public void draw(ModularGuiContext context, WidgetTheme widgetTheme) { + public void draw(ModularGuiContext context, WidgetThemeEntry widgetTheme) { ItemStack itemstack = this.syncHandler.getOutputStack(); RenderUtil.drawItemStack(itemstack, 1, 1, true); RenderUtil.handleSlotOverlay(this, widgetTheme); @@ -260,7 +261,7 @@ protected static class CraftingOutputMS extends ModularSlot { public CraftingOutputMS(IntSyncValue amountCrafted, MetaTileEntityWorkbench workbench) { super(new InventoryWrapper( workbench.getCraftingRecipeLogic().getCraftingResultInventory(), - workbench.getCraftingRecipeLogic()), 0, true); + workbench.getCraftingRecipeLogic()), 0); this.amountCrafted = amountCrafted; this.recipeLogic = workbench.getCraftingRecipeLogic(); this.recipeMemory = workbench.getRecipeMemory(); diff --git a/src/main/java/gregtech/common/mui/widget/workbench/RecipeMemorySlot.java b/src/main/java/gregtech/common/mui/widget/workbench/RecipeMemorySlot.java index c7c010ce347..af58a753b96 100644 --- a/src/main/java/gregtech/common/mui/widget/workbench/RecipeMemorySlot.java +++ b/src/main/java/gregtech/common/mui/widget/workbench/RecipeMemorySlot.java @@ -10,16 +10,16 @@ import com.cleanroommc.modularui.api.drawable.IKey; import com.cleanroommc.modularui.api.widget.Interactable; -import com.cleanroommc.modularui.integration.jei.JeiIngredientProvider; +import com.cleanroommc.modularui.integration.recipeviewer.RecipeViewerIngredientProvider; import com.cleanroommc.modularui.screen.RichTooltip; import com.cleanroommc.modularui.screen.viewport.ModularGuiContext; -import com.cleanroommc.modularui.theme.WidgetTheme; +import com.cleanroommc.modularui.theme.WidgetThemeEntry; import com.cleanroommc.modularui.utils.MouseData; import com.cleanroommc.modularui.widget.Widget; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -public class RecipeMemorySlot extends Widget implements Interactable, JeiIngredientProvider { +public class RecipeMemorySlot extends Widget implements Interactable, RecipeViewerIngredientProvider { private final CraftingRecipeMemory memory; private final int index; @@ -44,7 +44,7 @@ public RecipeMemorySlot(CraftingRecipeMemory memory, int index) { } @Override - public void draw(ModularGuiContext context, WidgetTheme widgetTheme) { + public void draw(ModularGuiContext context, WidgetThemeEntry widgetTheme) { ItemStack itemStack = this.memory.getRecipeOutputAtIndex(this.index); if (!itemStack.isEmpty()) { @@ -56,7 +56,7 @@ public void draw(ModularGuiContext context, WidgetTheme widgetTheme) { // noinspection DataFlowIssue if (this.memory.getRecipeAtIndex(this.index).isRecipeLocked()) { GlStateManager.disableDepth(); - GTGuiTextures.RECIPE_LOCK.draw(context, 10, 1, 8, 8, widgetTheme); + GTGuiTextures.RECIPE_LOCK.draw(context, 10, 1, 8, 8, widgetTheme.getTheme()); GlStateManager.enableDepth(); } } diff --git a/src/main/java/gregtech/mixins/mui2/AbstractCycleButtonWidgetMixin.java b/src/main/java/gregtech/mixins/mui2/AbstractCycleButtonWidgetMixin.java deleted file mode 100644 index 5f72806e42e..00000000000 --- a/src/main/java/gregtech/mixins/mui2/AbstractCycleButtonWidgetMixin.java +++ /dev/null @@ -1,52 +0,0 @@ -package gregtech.mixins.mui2; - -import com.cleanroommc.modularui.api.ITheme; -import com.cleanroommc.modularui.api.drawable.IDrawable; -import com.cleanroommc.modularui.theme.WidgetTheme; -import com.cleanroommc.modularui.widget.Widget; -import com.cleanroommc.modularui.widgets.AbstractCycleButtonWidget; -import com.llamalad7.mixinextras.injector.ModifyReturnValue; -import com.llamalad7.mixinextras.sugar.Local; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.injection.At; - -import java.util.Arrays; - -@Mixin(value = AbstractCycleButtonWidget.class, remap = false) -public class AbstractCycleButtonWidgetMixin> extends Widget { - - @Shadow - protected IDrawable[] hoverBackground; - - @Shadow - protected IDrawable[] hoverOverlay; - - @ModifyReturnValue(method = "getCurrentOverlay", at = @At(value = "RETURN", ordinal = 0)) - public IDrawable fixOverlay(IDrawable original, - @Local(argsOnly = true) ITheme theme, - @Local(argsOnly = true) WidgetTheme widgetTheme) { - return original != IDrawable.NONE ? original : super.getCurrentOverlay(theme, widgetTheme); - } - - @ModifyReturnValue(method = "getCurrentBackground", at = @At(value = "RETURN", ordinal = 0)) - public IDrawable fixBackground(IDrawable original, - @Local(argsOnly = true) ITheme theme, - @Local(argsOnly = true) WidgetTheme widgetTheme) { - return original != IDrawable.NONE ? original : super.getCurrentBackground(theme, widgetTheme); - } - - @Override - public W disableHoverBackground() { - if (this.hoverBackground != null) - Arrays.fill(this.hoverBackground, IDrawable.NONE); - return getThis(); - } - - @Override - public W disableHoverOverlay() { - if (this.hoverOverlay != null) - Arrays.fill(this.hoverOverlay, IDrawable.NONE); - return getThis(); - } -} diff --git a/src/main/java/gregtech/mixins/mui2/IconMixin.java b/src/main/java/gregtech/mixins/mui2/IconMixin.java deleted file mode 100644 index faaafe69d34..00000000000 --- a/src/main/java/gregtech/mixins/mui2/IconMixin.java +++ /dev/null @@ -1,38 +0,0 @@ -package gregtech.mixins.mui2; - -import gregtech.api.mui.IconAcessor; - -import com.cleanroommc.modularui.api.drawable.IDrawable; -import com.cleanroommc.modularui.api.drawable.IIcon; -import com.cleanroommc.modularui.drawable.DelegateIcon; -import com.cleanroommc.modularui.drawable.Icon; -import org.spongepowered.asm.mixin.Final; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; - -@Mixin(value = Icon.class, remap = false) -public class IconMixin implements IconAcessor { - - @Shadow - @Final - private IDrawable drawable; - - public IDrawable gregTech$getDrawable() { - return this.drawable; - } - - @Mixin(value = DelegateIcon.class, remap = false) - public static abstract class DelegateMixin implements IconAcessor { - - @Shadow - public abstract IIcon getDelegate(); - - @Override - public IDrawable gregTech$getDrawable() { - if (getDelegate() instanceof IconAcessor acessor) { - return acessor.gregTech$getDrawable(); - } - return null; - } - } -} diff --git a/src/main/java/gregtech/mixins/mui2/ItemSlotMixin.java b/src/main/java/gregtech/mixins/mui2/ItemSlotMixin.java deleted file mode 100644 index 1f7bddb0573..00000000000 --- a/src/main/java/gregtech/mixins/mui2/ItemSlotMixin.java +++ /dev/null @@ -1,41 +0,0 @@ -package gregtech.mixins.mui2; - -import gregtech.api.util.JEIUtil; - -import net.minecraft.item.ItemStack; - -import com.cleanroommc.modularui.integration.jei.ModularUIJeiPlugin; -import com.cleanroommc.modularui.widgets.ItemSlot; -import com.llamalad7.mixinextras.injector.wrapmethod.WrapMethod; -import com.llamalad7.mixinextras.injector.wrapoperation.Operation; -import mezz.jei.gui.ghost.GhostIngredientDrag; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Redirect; - -// TODO: remove once MUI PR 146 merges into a release we use -@Mixin(value = ItemSlot.class, remap = false) -public abstract class ItemSlotMixin { - - @Shadow - public abstract @Nullable ItemStack castGhostIngredientIfValid(@NotNull Object ingredient); - - @Redirect(method = "draw", - at = @At(value = "INVOKE", - target = "Lcom/cleanroommc/modularui/integration/jei/ModularUIJeiPlugin;hasDraggingGhostIngredient()Z")) - private boolean onlyHighlightOnValidDrag() { - GhostIngredientDrag ingredientDrag = ModularUIJeiPlugin.getGhostDrag(); - if (ingredientDrag == null) return false; - Object ingredient = ingredientDrag.getIngredient(); - if (ingredient == null) return false; - return castGhostIngredientIfValid(ingredient) != null; - } - - @WrapMethod(method = "castGhostIngredientIfValid(Ljava/lang/Object;)Lnet/minecraft/item/ItemStack;") - public @Nullable ItemStack addSupportForEnchantedBooks(Object ingredient, Operation original) { - return original.call(JEIUtil.getBookStackIfEnchantment(ingredient)); - } -} diff --git a/src/main/java/gregtech/mixins/mui2/LangKeyMixin.java b/src/main/java/gregtech/mixins/mui2/LangKeyMixin.java index e13bf3c8b44..2e5e1a3f8ce 100644 --- a/src/main/java/gregtech/mixins/mui2/LangKeyMixin.java +++ b/src/main/java/gregtech/mixins/mui2/LangKeyMixin.java @@ -3,22 +3,13 @@ import com.cleanroommc.modularui.drawable.text.BaseKey; import com.cleanroommc.modularui.drawable.text.LangKey; import com.llamalad7.mixinextras.injector.ModifyExpressionValue; -import org.jetbrains.annotations.NotNull; import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; - -import java.util.function.Supplier; // all this mixin does is switch newlines to the expected format @Mixin(value = LangKey.class, remap = false) public abstract class LangKeyMixin extends BaseKey { - @Shadow - private long time; - @ModifyExpressionValue(method = "getFormatted", at = @At(value = "INVOKE", target = "Lcom/cleanroommc/modularui/drawable/text/FontRenderHelper;formatArgs([Ljava/lang/Object;Lcom/cleanroommc/modularui/drawable/text/FormattingState;Ljava/lang/String;Z)Ljava/lang/String;")) @@ -34,11 +25,4 @@ public String getTranslateKey(String original) { public String switchNewLines(String original) { return original.replace("/n", "\n"); } - - @Inject(method = "(Ljava/util/function/Supplier;Ljava/util/function/Supplier;)V", - at = @At(value = "RETURN")) - private void setTimeToNegativeOne(@NotNull Supplier keySupplier, @NotNull Supplier argsSupplier, - CallbackInfo ci) { - time = -1; - } } diff --git a/src/main/java/gregtech/mixins/mui2/ModularPanelMixin.java b/src/main/java/gregtech/mixins/mui2/ModularPanelMixin.java deleted file mode 100644 index 78cec0e56bb..00000000000 --- a/src/main/java/gregtech/mixins/mui2/ModularPanelMixin.java +++ /dev/null @@ -1,27 +0,0 @@ -package gregtech.mixins.mui2; - -import com.cleanroommc.modularui.api.layout.IViewport; -import com.cleanroommc.modularui.integration.jei.ModularUIJeiPlugin; -import com.cleanroommc.modularui.screen.ModularPanel; -import com.cleanroommc.modularui.screen.viewport.LocatedWidget; -import com.cleanroommc.modularui.widget.ParentWidget; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Redirect; - -@Mixin(value = ModularPanel.class, remap = false) -public abstract class ModularPanelMixin extends ParentWidget implements IViewport { - - @Redirect(method = "lambda$onMousePressed$3", - at = @At(value = "INVOKE", - target = "Lcom/cleanroommc/modularui/screen/viewport/LocatedWidget;getElement()Ljava/lang/Object;", - ordinal = 1)) - private Object checkDrag(LocatedWidget instance) { - // if we're dragging something, prevent interaction - if (ModularUIJeiPlugin.hasDraggingGhostIngredient()) { - return null; - } - - return instance.getElement(); - } -} diff --git a/src/main/java/gregtech/mixins/mui2/ModularUIJeiPluginMixin.java b/src/main/java/gregtech/mixins/mui2/ModularUIJeiPluginMixin.java deleted file mode 100644 index 2f0853cb4f1..00000000000 --- a/src/main/java/gregtech/mixins/mui2/ModularUIJeiPluginMixin.java +++ /dev/null @@ -1,22 +0,0 @@ -package gregtech.mixins.mui2; - -import com.cleanroommc.modularui.integration.jei.JeiGhostIngredientSlot; -import com.cleanroommc.modularui.integration.jei.ModularUIJeiPlugin; -import mezz.jei.config.Config; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; - -@Mixin(value = ModularUIJeiPlugin.class) -public class ModularUIJeiPluginMixin { - - // TODO: remove this mixin when the fix from Brachy makes it into a release we use - @Inject(method = "hoveringOverIngredient", at = @At(value = "HEAD"), remap = false, cancellable = true) - private static void cancelIfCheatsOn(JeiGhostIngredientSlot ingredientSlot, - CallbackInfoReturnable cir) { - if (Config.isCheatItemsEnabled()) { - cir.setReturnValue(false); - } - } -} diff --git a/src/main/java/gregtech/mixins/mui2/RichTextCompilerMixin.java b/src/main/java/gregtech/mixins/mui2/RichTextCompilerMixin.java deleted file mode 100644 index 79c44c7d20b..00000000000 --- a/src/main/java/gregtech/mixins/mui2/RichTextCompilerMixin.java +++ /dev/null @@ -1,41 +0,0 @@ -package gregtech.mixins.mui2; - -import net.minecraft.client.gui.FontRenderer; - -import com.cleanroommc.modularui.api.drawable.IKey; -import com.cleanroommc.modularui.drawable.text.RichTextCompiler; -import com.llamalad7.mixinextras.sugar.Local; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.ModifyArg; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; - -import java.util.List; - -@Mixin(value = RichTextCompiler.class, remap = false) -public class RichTextCompilerMixin { - - @Shadow - private int x; - - @Shadow - private FontRenderer fr; - - @ModifyArg(method = "trimRight", - at = @At(value = "INVOKE", - target = "Ljava/lang/String;substring(II)Ljava/lang/String;"), - index = 1) - private static int fixTrim(int beginIndex) { - return beginIndex + 1; - } - - @Inject(method = "compile", - at = @At(value = "INVOKE", - target = "Lcom/cleanroommc/modularui/drawable/text/RichTextCompiler;addLineElement(Ljava/lang/Object;)V", - ordinal = 0)) - private void moveXString(List raw, CallbackInfo ci, @Local IKey key) { - x += fr.getStringWidth(key.get()); - } -} diff --git a/src/main/java/gregtech/mixins/mui2/TextWidgetMixin.java b/src/main/java/gregtech/mixins/mui2/TextWidgetMixin.java index cb39b2d6461..f570ad2a1d6 100644 --- a/src/main/java/gregtech/mixins/mui2/TextWidgetMixin.java +++ b/src/main/java/gregtech/mixins/mui2/TextWidgetMixin.java @@ -1,56 +1,39 @@ package gregtech.mixins.mui2; -import com.cleanroommc.modularui.drawable.text.TextRenderer; -import com.cleanroommc.modularui.widget.Widget; +import com.cleanroommc.modularui.api.drawable.IKey; import com.cleanroommc.modularui.widgets.TextWidget; +import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Overwrite; import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.ModifyArgs; -import org.spongepowered.asm.mixin.injection.invoke.arg.Args; -// todo remove both mixins when mui2 is updated past rc4 +import java.util.Objects; + @Mixin(value = TextWidget.class, remap = false) -public class TextWidgetMixin extends Widget { +public abstract class TextWidgetMixin { @Shadow - private Integer color; + @Final + private IKey key; @Shadow - private Boolean shadow; + private String lastText; - /** - * @author Ghzdude - * @reason fix unboxing - */ - @Overwrite - public int getColor() { - return this.color == null ? getWidgetTheme(getContext().getTheme()).getTextColor() : this.color; - } + @Shadow + protected abstract void onTextChanged(String newText); /** * @author Ghzdude - * @reason fix unboxing + * @reason Flawed equals checking. If {@code lastText} is null, then it will never call + * {@link #onTextChanged(String)}, meaning ScrollingTextWidget is never updated to the new String */ @Overwrite - public boolean isShadow() { - return this.shadow == null ? getWidgetTheme(getContext().getTheme()).getTextShadow() : this.shadow; - } - - @Mixin(value = TextRenderer.class, remap = false) - public static class TextRenderMixin { - - /** - * Adjusts the area {@code SHARED} call in {@link TextRenderer#drawScrolling} - * specifically targeting the y and height of the area - */ - @ModifyArgs(method = "drawScrolling", - at = @At(value = "INVOKE", - target = "Lcom/cleanroommc/modularui/widget/sizer/Area;set(IIII)V")) - public void adjustArea(Args args) { - args.set(1, -500); - args.set(3, 1000); + protected String checkString() { + String text = this.key.getFormatted(); + if (!Objects.equals(this.lastText, text)) { + onTextChanged(text); + this.lastText = text; } + return text; } } diff --git a/src/main/resources/mixins.gregtech.mui2.json b/src/main/resources/mixins.gregtech.mui2.json index 01250970807..72a083a3408 100644 --- a/src/main/resources/mixins.gregtech.mui2.json +++ b/src/main/resources/mixins.gregtech.mui2.json @@ -8,18 +8,10 @@ "maxShiftBy": 10 }, "mixins": [ - "AbstractCycleButtonWidgetMixin", - "IconMixin", - "IconMixin$DelegateMixin", - "ModularPanelMixin", - "RichTextCompilerMixin", - "TextWidgetMixin", - "TextWidgetMixin$TextRenderMixin" + "TextWidgetMixin" ], "client": [ - "ItemSlotMixin", - "LangKeyMixin", - "ModularUIJeiPluginMixin" + "LangKeyMixin" ], "server": [] }