diff --git a/dependencies.gradle b/dependencies.gradle index 394dd851284..7403c43b4e6 100644 --- a/dependencies.gradle +++ b/dependencies.gradle @@ -14,7 +14,7 @@ dependencies { compileOnly(libs.evalEx.get()) // MUI - jarJar(modImplementation(forge.mui.get())) + jarJar(implementation(files("libs/modularui-mc1.20.1-3.2.0-dev.jar"))) // Mixin (& Extras) annotationProcessor(variantOf(libs.mixin) { classifier("processor") }) diff --git a/docs/content/Development/MUI2/Syncing/Sync-Basics.md b/docs/content/Development/MUI2/Syncing/Sync-Basics.md index 12cd19e6337..d85ec57b34a 100644 --- a/docs/content/Development/MUI2/Syncing/Sync-Basics.md +++ b/docs/content/Development/MUI2/Syncing/Sync-Basics.md @@ -27,12 +27,12 @@ The first method is using dynamic widgets, which update every frame regardless o This method is easiest if you just need to sync some data over and display or edit it in a single widget. Some examples are: -- `IKey.dynamic(Supplier)` - Queries the supplier every frame to retrieve the component to display +- `Text.dynamic(Supplier)` - Queries the supplier every frame to retrieve the component to display - `new DynamicDrawable(Supplier)` - Queries the supplier every frame to retrieve the drawable to display !!! Note - To convert IKeys or Drawables to Widgets, you need to chain `.asWidget()` + To convert Texts or Drawables to Widgets, you need to chain `.asWidget()` ```java public class MuiTestMachine extends MetaMachine implements IMuiMachine { @@ -52,7 +52,7 @@ public class MuiTestMachine extends MetaMachine implements IMuiMachine { var column = Flow.column(); - column.child(IKey.dynamic(() -> Component.literal("Ticks: " + this.ticks)) // note that this is a Supplier instead of a Component + column.child(Text.dynamic(() -> Component.literal("Ticks: " + this.ticks)) // note that this is a Supplier instead of a Component .asWidget() .margin(4)); @@ -112,7 +112,7 @@ public class MuiTestMachine extends MetaMachine implements IMuiMachine { int tickValue = intSyncHandler.getValue(); // It is also possible to just reference this.ticks directly int amountOfItems = 1 + (tickValue % 200) / 20; for (int i = 0; i < amountOfItems; i++) { - list.child(IKey.str("Value nr. " + (i + 1)).asWidget()); // No need for IKey.dynamic since we have the value as a variable here, inside the lambda + list.child(Text.str("Value nr. " + (i + 1)).asWidget()); // No need for Text.dynamic since we have the value as a variable here, inside the lambda } return list; }); @@ -159,7 +159,7 @@ public class MuiTestMachine extends MetaMachine implements IMuiMachine { var column = Flow.column().paddingTop(3); column.child( - IKey.dynamic(() -> Component.literal("Pressed: " + this.buttonPressed)) + Text.dynamic(() -> Component.literal("Pressed: " + this.buttonPressed)) .asWidget()); var buttonSyncValue = new BooleanSyncValue(() -> this.buttonPressed, (newValue) -> this.buttonPressed = newValue); @@ -220,7 +220,7 @@ public class MuiTestMachine extends MetaMachine implements IMuiMachine { for (int rowNr = 0; rowNr < this.rows; rowNr++) { Flow row = Flow.row(); for (int columnNr = 0; columnNr < this.columns; columnNr++) { - row.child(IKey.str(rowNr + ", " + columnNr).asWidget().width(20)); + row.child(Text.str(rowNr + ", " + columnNr).asWidget().width(20)); } grid.child(row); } diff --git a/docs/content/Development/MUI2/Syncing/Synced-Actions.md b/docs/content/Development/MUI2/Syncing/Synced-Actions.md index f774ffd201a..751480be487 100644 --- a/docs/content/Development/MUI2/Syncing/Synced-Actions.md +++ b/docs/content/Development/MUI2/Syncing/Synced-Actions.md @@ -21,14 +21,14 @@ public class MuiTestMachine extends MetaMachine implements IMuiMachine { }); Column contents = new Column(); - contents.child(IKey.dynamic(() -> Component.literal("Number: " + number)) + contents.child(Text.dynamic(() -> Component.literal("Number: " + number)) .asWidget() .width(100) .height(16) .margin(4)); contents.child(new ButtonWidget<>() - .onMousePressed((x, y, button) -> { + .onMousePressed((context, button) -> { if (button == 0) { syncManager.callSyncedAction("randomButtonPressed"); } diff --git a/docs/content/Development/MUI2/Test-Machine.md b/docs/content/Development/MUI2/Test-Machine.md index 63d3a9135c5..1fbdd86787a 100644 --- a/docs/content/Development/MUI2/Test-Machine.md +++ b/docs/content/Development/MUI2/Test-Machine.md @@ -13,7 +13,7 @@ public class MuiTestMachine extends MetaMachine implements IMuiMachine { var panel = GTGuis.createPanel(this, 176, 168); // Do stuff with your panel here, add children, etc. // For example: - panel.child(IKey.str("Test machine") + panel.child(Text.str("Test machine") .asWidget() .margin(4)); diff --git a/docs/content/Development/MUI2/Widget-Layout.md b/docs/content/Development/MUI2/Widget-Layout.md index 17bed127395..7f0e6a1cc9b 100644 --- a/docs/content/Development/MUI2/Widget-Layout.md +++ b/docs/content/Development/MUI2/Widget-Layout.md @@ -172,8 +172,8 @@ Flow column = Flow.column() .widthRel(1f) .padding(10) .crossAxisAlignment(Alignment.CrossAxis.START) - .child(new TextWidget<>(IKey.str("Title")).marginBottom(4)) - .child(new TextWidget<>(IKey.str("Body"))); + .child(new TextWidget<>(Text.str("Title")).marginBottom(4)) + .child(new TextWidget<>(Text.str("Body"))); ``` ### Slot grid using absolute positioning diff --git a/gradle/forge.versions.toml b/gradle/forge.versions.toml index 0dbbe67ff0f..6bfa6c0433e 100644 --- a/gradle/forge.versions.toml +++ b/gradle/forge.versions.toml @@ -6,9 +6,9 @@ mixinExtras = "0.5.0-rc.3" jei = "15.20.0.115" rei = "12.1.785" -emi = "1.1.13+1.20.1" +emi = "1.1.22+1.20.1" ae2 = "15.0.18" -mui = "3.1.5" +mui = "3.2.0-SNAPSHOT" kubejs = "2001.6.5-build.16" rhino = "2001.2.3-build.10" architectury = "9.2.14" diff --git a/src/main/java/com/gregtechceu/gtceu/api/capability/recipe/CWURecipeCapability.java b/src/main/java/com/gregtechceu/gtceu/api/capability/recipe/CWURecipeCapability.java index a5409ab7742..565a93a5b63 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/capability/recipe/CWURecipeCapability.java +++ b/src/main/java/com/gregtechceu/gtceu/api/capability/recipe/CWURecipeCapability.java @@ -1,18 +1,7 @@ package com.gregtechceu.gtceu.api.capability.recipe; -import com.gregtechceu.gtceu.api.recipe.GTRecipe; -import com.gregtechceu.gtceu.api.recipe.content.Content; import com.gregtechceu.gtceu.api.recipe.content.ContentModifier; import com.gregtechceu.gtceu.api.recipe.content.SerializerInteger; -import com.gregtechceu.gtceu.utils.FormattingUtil; - -import com.lowdragmc.lowdraglib.gui.widget.LabelWidget; -import com.lowdragmc.lowdraglib.gui.widget.WidgetGroup; -import com.lowdragmc.lowdraglib.utils.LocalizationUtils; - -import org.apache.commons.lang3.mutable.MutableInt; - -import java.util.List; public class CWURecipeCapability extends RecipeCapability { @@ -32,18 +21,4 @@ public Integer copyWithModifier(Integer content, ContentModifier modifier) { return modifier.apply(content); } - @Override - public void addXEIInfo(WidgetGroup group, int xOffset, GTRecipe recipe, List contents, boolean perTick, - boolean isInput, MutableInt yOffset) { - if (perTick) { - int cwu = contents.stream().map(Content::getContent).mapToInt(CWURecipeCapability.CAP::of).sum(); - group.addWidget(new LabelWidget(3 - xOffset, yOffset.addAndGet(10), - LocalizationUtils.format("gtceu.recipe.computation_per_tick", FormattingUtil.formatNumbers(cwu)))); - } - if (recipe.data.getBoolean("duration_is_total_cwu")) { - group.addWidget(new LabelWidget(3 - xOffset, yOffset.addAndGet(10), - LocalizationUtils.format("gtceu.recipe.total_computation", - FormattingUtil.formatNumbers(recipe.duration)))); - } - } } diff --git a/src/main/java/com/gregtechceu/gtceu/api/capability/recipe/EURecipeCapability.java b/src/main/java/com/gregtechceu/gtceu/api/capability/recipe/EURecipeCapability.java index c518228571c..425090f6616 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/capability/recipe/EURecipeCapability.java +++ b/src/main/java/com/gregtechceu/gtceu/api/capability/recipe/EURecipeCapability.java @@ -61,7 +61,7 @@ public int limitMaxParallelByOutput(IRecipeCapabilityHolder holder, GTRecipe rec int maxMultiplier = multiplier; long totalEU = 0L; - for (var content : outputs) totalEU += of(content.content).getTotalEU(); + for (var content : outputs) totalEU += of(content.content()).getTotalEU(); if (totalEU != 0 && multiplier > Long.MAX_VALUE / totalEU) { maxMultiplier = multiplier = GTMath.saturatedCast(Long.MAX_VALUE / totalEU); } @@ -104,8 +104,8 @@ public int getMaxParallelByInput(IRecipeCapabilityHolder holder, GTRecipe recipe long nonConsumable = 0; long consumable = 0; for (Content content : inputs) { - EnergyStack s = of(content.content); - if (content.chance == 0) nonConsumable += s.getTotalEU(); + EnergyStack s = of(content.content()); + if (content.chance() == 0) nonConsumable += s.getTotalEU(); else consumable += s.getTotalEU(); } diff --git a/src/main/java/com/gregtechceu/gtceu/api/capability/recipe/FluidRecipeCapability.java b/src/main/java/com/gregtechceu/gtceu/api/capability/recipe/FluidRecipeCapability.java index 755a9c88955..a09653d2c08 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/capability/recipe/FluidRecipeCapability.java +++ b/src/main/java/com/gregtechceu/gtceu/api/capability/recipe/FluidRecipeCapability.java @@ -1,11 +1,8 @@ package com.gregtechceu.gtceu.api.capability.recipe; -import com.gregtechceu.gtceu.api.gui.widget.TankWidget; -import com.gregtechceu.gtceu.api.machine.trait.RecipeHandlerGroup; -import com.gregtechceu.gtceu.api.machine.trait.RecipeHandlerGroupDistinctness; -import com.gregtechceu.gtceu.api.machine.trait.RecipeHandlerList; +import com.gregtechceu.gtceu.api.machine.MetaMachine; +import com.gregtechceu.gtceu.api.machine.trait.*; import com.gregtechceu.gtceu.api.recipe.GTRecipe; -import com.gregtechceu.gtceu.api.recipe.GTRecipeType; import com.gregtechceu.gtceu.api.recipe.content.Content; import com.gregtechceu.gtceu.api.recipe.content.ContentModifier; import com.gregtechceu.gtceu.api.recipe.content.SerializerFluidIngredient; @@ -14,36 +11,20 @@ import com.gregtechceu.gtceu.api.recipe.lookup.ingredient.AbstractMapIngredient; import com.gregtechceu.gtceu.api.recipe.lookup.ingredient.fluid.*; import com.gregtechceu.gtceu.api.recipe.modifier.ParallelLogic; -import com.gregtechceu.gtceu.api.recipe.ui.GTRecipeTypeUI; -import com.gregtechceu.gtceu.client.TooltipsHandler; import com.gregtechceu.gtceu.common.valueprovider.*; -import com.gregtechceu.gtceu.integration.recipeviewer.entry.fluid.FluidEntryList; -import com.gregtechceu.gtceu.integration.recipeviewer.entry.fluid.FluidStackList; -import com.gregtechceu.gtceu.integration.recipeviewer.entry.fluid.FluidTagList; -import com.gregtechceu.gtceu.integration.recipeviewer.handlers.fluid.CycleFluidEntryHandler; -import com.gregtechceu.gtceu.integration.recipeviewer.widgets.GTRecipeWidget; import com.gregtechceu.gtceu.utils.GTMath; -import com.lowdragmc.lowdraglib.gui.texture.ProgressTexture; -import com.lowdragmc.lowdraglib.gui.widget.Widget; -import com.lowdragmc.lowdraglib.jei.IngredientIO; - -import net.minecraft.ChatFormatting; import net.minecraft.nbt.CompoundTag; -import net.minecraft.network.chat.Component; -import net.minecraft.util.valueproviders.IntProvider; -import net.minecraft.world.item.TooltipFlag; import net.minecraftforge.fluids.FluidStack; -import net.minecraftforge.fluids.capability.IFluidHandler; +import brachy.modularui.integration.recipeviewer.entry.fluid.FluidEntryList; +import brachy.modularui.integration.recipeviewer.entry.fluid.FluidStackList; +import brachy.modularui.integration.recipeviewer.entry.fluid.FluidTagList; import it.unimi.dsi.fastutil.objects.*; -import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import org.jetbrains.annotations.UnknownNullability; import org.jetbrains.annotations.Unmodifiable; import java.util.*; -import java.util.stream.Collectors; import static com.gregtechceu.gtceu.api.recipe.RecipeHelper.addToRecipeHandlerMap; @@ -146,7 +127,7 @@ public int limitMaxParallelByOutput(IRecipeCapabilityHolder holder, GTRecipe rec int maxAmount = 0; List ingredients = new ArrayList<>(outputContents.size()); for (var content : outputContents) { - var ing = this.of(content.content); + var ing = this.of(content.content()); maxAmount = Math.max(maxAmount, ing.getAmount()); ingredients.add(ing); } @@ -191,13 +172,13 @@ public int getMaxParallelByInput(IRecipeCapabilityHolder holder, GTRecipe recipe var nonConsumables = new Object2LongOpenHashMap(); var consumables = new Object2LongOpenHashMap(); for (Content content : inputs) { - FluidIngredient ing = of(content.content); + FluidIngredient ing = of(content.content()); int amount; if (ing instanceof IntProviderFluidIngredient provider) amount = provider.getCountProvider().getMaxValue(); else amount = ing.getAmount(); - if (content.chance == 0) { + if (content.chance() == 0) { nonConsumables.addTo(ing, amount); } else { boolean has = false; @@ -326,89 +307,8 @@ private static List> getInputContents(IRecipeCapabili return invs; } - @Override - public @NotNull List createXEIContainerContents(List contents, GTRecipe recipe, IO io) { - List entryLists = contents.stream() - .map(Content::getContent) - .map(this::of) - .map(FluidRecipeCapability::mapFluid) - .collect(Collectors.toList()); - - while (entryLists.size() < recipe.recipeType.getMaxOutputs(this)) entryLists.add(null); - return entryLists; - } - - public Object createXEIContainer(List contents) { - // cast is safe if you don't pass the wrong thing. - // noinspection unchecked - return new CycleFluidEntryHandler((List) contents); - } - - @NotNull - @Override - public Widget createWidget() { - TankWidget tank = new TankWidget(); - tank.initTemplate(); - tank.setFillDirection(ProgressTexture.FillDirection.ALWAYS_FULL); - return tank; - } - - @NotNull - @Override - public Class getWidgetClass() { - return TankWidget.class; - } - - @Override - public void applyWidgetInfo(@NotNull Widget widget, - int index, - boolean isXEI, - IO io, - GTRecipeTypeUI.@UnknownNullability("null when storage == null") RecipeHolder recipeHolder, - @NotNull GTRecipeType recipeType, - @UnknownNullability("null when content == null") GTRecipe recipe, - @Nullable Content content, - @Nullable Object storage, int recipeTier, int chanceTier) { - if (widget instanceof TankWidget tank) { - if (storage instanceof IFluidHandler fluidHandler) { - tank.setFluidTank(fluidHandler, index); - } - tank.setIngredientIO(io == IO.IN ? IngredientIO.INPUT : IngredientIO.OUTPUT); - tank.setAllowClickFilled(!isXEI); - tank.setAllowClickDrained(!isXEI && io.support(IO.IN)); - if (isXEI) tank.setShowAmount(false); - if (content != null) { - float chance = (float) recipeType.getChanceFunction() - .getBoostedChance(content, recipeTier, chanceTier) / content.maxChance; - tank.setXEIChance(chance); - tank.setOnAddedTooltips((w, tooltips) -> { - FluidIngredient ingredient = FluidRecipeCapability.CAP.of(content.content); - if (!isXEI && ingredient.getStacks().length > 0) { - FluidStack stack = ingredient.getStacks()[0]; - TooltipsHandler.appendFluidTooltips(stack, tooltips::add, TooltipFlag.NORMAL); - } - if (ingredient instanceof IntProviderFluidIngredient provider) { - IntProvider countProvider = provider.getCountProvider(); - tooltips.add(Component.translatable("gtceu.gui.content.fluid_range", - countProvider.getMinValue(), countProvider.getMaxValue()) - .withStyle(ChatFormatting.GOLD)); - } - GTRecipeWidget.setConsumedChance(content, - recipe.getChanceLogicForCapability(this, io, isTickSlot(index, io, recipe)), - tooltips, recipeTier, chanceTier, recipeType.getChanceFunction()); - if (isTickSlot(index, io, recipe)) { - tooltips.add(Component.translatable("gtceu.gui.content.per_tick")); - } - }); - if (io == IO.IN && (content.chance == 0)) { - tank.setIngredientIO(IngredientIO.CATALYST); - } - } - } - } - // Maps fluids to a FluidEntryList for XEI: either a FluidTagList or a FluidStackList - public static FluidEntryList mapFluid(FluidIngredient ingredient) { + public static FluidEntryList mapIngredientToEntryList(FluidIngredient ingredient) { int amount; if (ingredient instanceof IntProviderFluidIngredient) { amount = 1; @@ -456,4 +356,9 @@ public interface ICustomParallel { public boolean shouldBypassDistinct() { return false; } + + public @Nullable NotifiableFluidTank getCapabilityHandler(MetaMachine machine, IO io) { + var handlers = machine.getTraitHolder().getTraits(NotifiableFluidTank.TYPE); + return handlers.stream().filter(v -> v.handlerIO == io).findFirst().orElse(null); + } } diff --git a/src/main/java/com/gregtechceu/gtceu/api/capability/recipe/ItemRecipeCapability.java b/src/main/java/com/gregtechceu/gtceu/api/capability/recipe/ItemRecipeCapability.java index e38611320d5..cd29f2828b8 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/capability/recipe/ItemRecipeCapability.java +++ b/src/main/java/com/gregtechceu/gtceu/api/capability/recipe/ItemRecipeCapability.java @@ -1,12 +1,8 @@ package com.gregtechceu.gtceu.api.capability.recipe; -import com.gregtechceu.gtceu.api.gui.widget.SlotWidget; -import com.gregtechceu.gtceu.api.machine.trait.RecipeHandlerGroup; -import com.gregtechceu.gtceu.api.machine.trait.RecipeHandlerGroupDistinctness; -import com.gregtechceu.gtceu.api.machine.trait.RecipeHandlerList; +import com.gregtechceu.gtceu.api.machine.MetaMachine; +import com.gregtechceu.gtceu.api.machine.trait.*; import com.gregtechceu.gtceu.api.recipe.GTRecipe; -import com.gregtechceu.gtceu.api.recipe.GTRecipeType; -import com.gregtechceu.gtceu.api.recipe.ResearchData; import com.gregtechceu.gtceu.api.recipe.content.Content; import com.gregtechceu.gtceu.api.recipe.content.ContentModifier; import com.gregtechceu.gtceu.api.recipe.content.SerializerIngredient; @@ -16,39 +12,24 @@ import com.gregtechceu.gtceu.api.recipe.lookup.ingredient.AbstractMapIngredient; import com.gregtechceu.gtceu.api.recipe.lookup.ingredient.item.*; import com.gregtechceu.gtceu.api.recipe.modifier.ParallelLogic; -import com.gregtechceu.gtceu.api.recipe.ui.GTRecipeTypeUI; -import com.gregtechceu.gtceu.common.recipe.condition.ResearchCondition; import com.gregtechceu.gtceu.common.valueprovider.*; -import com.gregtechceu.gtceu.config.ConfigHolder; import com.gregtechceu.gtceu.core.mixins.IngredientAccessor; import com.gregtechceu.gtceu.core.mixins.TagValueAccessor; import com.gregtechceu.gtceu.core.mixins.forge.IntersectionIngredientAccessor; -import com.gregtechceu.gtceu.integration.recipeviewer.entry.item.ItemEntryList; -import com.gregtechceu.gtceu.integration.recipeviewer.entry.item.ItemStackList; -import com.gregtechceu.gtceu.integration.recipeviewer.entry.item.ItemTagList; -import com.gregtechceu.gtceu.integration.recipeviewer.handlers.item.CycleItemEntryHandler; -import com.gregtechceu.gtceu.integration.recipeviewer.widgets.GTRecipeWidget; import com.gregtechceu.gtceu.utils.*; -import com.lowdragmc.lowdraglib.gui.widget.Widget; -import com.lowdragmc.lowdraglib.jei.IngredientIO; - -import net.minecraft.ChatFormatting; -import net.minecraft.network.chat.Component; -import net.minecraft.util.valueproviders.IntProvider; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.crafting.Ingredient; import net.minecraftforge.common.crafting.IntersectionIngredient; -import net.minecraftforge.items.IItemHandlerModifiable; +import brachy.modularui.integration.recipeviewer.entry.item.ItemEntryList; +import brachy.modularui.integration.recipeviewer.entry.item.ItemStackList; +import brachy.modularui.integration.recipeviewer.entry.item.ItemTagList; import it.unimi.dsi.fastutil.objects.*; -import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import org.jetbrains.annotations.UnknownNullability; import org.jetbrains.annotations.Unmodifiable; import java.util.*; -import java.util.stream.Collectors; import static com.gregtechceu.gtceu.api.recipe.RecipeHelper.addToRecipeHandlerMap; @@ -163,7 +144,7 @@ public int limitMaxParallelByOutput(IRecipeCapabilityHolder holder, GTRecipe rec int maxCount = 0; List ingredients = new ArrayList<>(outputContents.size()); for (var content : outputContents) { - var ing = of(content.content); + var ing = of(content.content()); int count; if (ing instanceof SizedIngredient sized) count = sized.getAmount(); @@ -214,7 +195,7 @@ public int getMaxParallelByInput(IRecipeCapabilityHolder holder, GTRecipe recipe var nonConsumables = new Object2LongOpenHashMap(); var consumables = new Object2LongOpenHashMap(); for (Content content : inputs) { - Ingredient ing = of(content.content); + Ingredient ing = of(content.content()); if (ing instanceof IntCircuitIngredient) continue; int count; @@ -222,7 +203,7 @@ public int getMaxParallelByInput(IRecipeCapabilityHolder holder, GTRecipe recipe else if (ing instanceof IntProviderIngredient provider) count = provider.getCountProvider().getMaxValue(); else count = 1; - if (content.chance == 0) { + if (content.chance() == 0) { nonConsumables.addTo(ing, count); } else { boolean has = false; @@ -353,151 +334,8 @@ private static List> getInputContents(IRecipeCapabilit return invs; } - @Override - public @NotNull List createXEIContainerContents(List contents, GTRecipe recipe, IO io) { - List entryLists = contents.stream() - .map(Content::getContent) - .map(this::of) - .map(ItemRecipeCapability::mapItem) - .collect(Collectors.toList()); - - if (io == IO.OUT && recipe.recipeType.isScanner()) { - List scannerPossibilities = new ArrayList<>(); - // Scanner Output replacing, used for cycling research outputs - ResearchManager.ResearchItem researchData = null; - for (Content stack : recipe.getOutputContents(this)) { - ItemStack[] stacks = this.of(stack.content).getItems(); - if (stacks.length == 0 || stacks[0].isEmpty()) continue; - - researchData = ResearchManager.readResearchId(stacks[0]); - if (researchData != null) break; - } - if (researchData != null) { - Collection possibleRecipes = researchData.recipeType() - .getDataStickEntry(researchData.researchId()); - Set cache = new ObjectOpenCustomHashSet<>(ItemStackHashStrategy.comparingItem()); - if (possibleRecipes != null) { - for (GTRecipe r : possibleRecipes) { - var outputs = r.getOutputContents(this); - if (outputs.isEmpty()) continue; - - Content outputContent = outputs.get(0); - ItemStack[] stacks = this.of(outputContent.content).getItems(); - if (stacks.length == 0) continue; - - ItemStack researchStack = stacks[0]; - if (!researchStack.isEmpty() && !cache.contains(researchStack)) { - cache.add(researchStack); - scannerPossibilities.add(ItemStackList.of(researchStack.copyWithCount(1))); - } - } - } - scannerPossibilities.add(entryLists.get(0)); - entryLists = scannerPossibilities; - } - } - - while (entryLists.size() < recipe.recipeType.getMaxOutputs(this)) entryLists.add(null); - return entryLists; - } - - public Object createXEIContainer(List contents) { - // cast is safe if you don't pass the wrong thing. - // noinspection unchecked - return new CycleItemEntryHandler((List) contents); - } - - @NotNull - @Override - public Widget createWidget() { - SlotWidget slot = new SlotWidget(); - slot.initTemplate(); - return slot; - } - - @NotNull - @Override - public Class getWidgetClass() { - return SlotWidget.class; - } - - @Override - public void applyWidgetInfo(@NotNull Widget widget, - int index, - boolean isXEI, - IO io, - GTRecipeTypeUI.@UnknownNullability("null when storage == null") RecipeHolder recipeHolder, - @NotNull GTRecipeType recipeType, - @UnknownNullability("null when content == null") GTRecipe recipe, - @Nullable Content content, - @Nullable Object storage, int recipeTier, int chanceTier) { - if (widget instanceof SlotWidget slot) { - if (storage instanceof IItemHandlerModifiable items) { - if (index >= 0 && index < items.getSlots()) { - slot.setHandlerSlot(items, index); - slot.setIngredientIO(io == IO.IN ? IngredientIO.INPUT : IngredientIO.OUTPUT); - slot.setCanTakeItems(!isXEI); - slot.setCanPutItems(!isXEI && io.support(IO.IN)); - } - // 1 over container size. - // If in a recipe viewer and a research slot can be added, add it. - if (isXEI && recipeType.isHasResearchSlot() && index == items.getSlots()) { - if (ConfigHolder.INSTANCE.machines.enableResearch) { - ResearchCondition condition = recipeHolder.conditions().stream() - .filter(ResearchCondition.class::isInstance).findAny() - .map(ResearchCondition.class::cast).orElse(null); - if (condition != null) { - List dataItems = new ArrayList<>(); - for (ResearchData.ResearchEntry entry : condition.data) { - ItemStack dataStick = entry.getDataItem().copy(); - ResearchManager.writeResearchToNBT(dataStick.getOrCreateTag(), entry.getResearchId(), - recipeType); - dataItems.add(dataStick); - } - CycleItemEntryHandler handler = CycleItemEntryHandler.fromStacks(List.of(dataItems)); - slot.setHandlerSlot(handler, 0); - slot.setIngredientIO(IngredientIO.CATALYST); - slot.setCanTakeItems(false); - slot.setCanPutItems(false); - } - } - } - } - if (content != null) { - float chance = (float) recipeType.getChanceFunction() - .getBoostedChance(content, recipeTier, chanceTier) / content.maxChance; - slot.setXEIChance(chance); - slot.setOnAddedTooltips((w, tooltips) -> { - GTRecipeWidget.setConsumedChance(content, - recipe.getChanceLogicForCapability(this, io, isTickSlot(index, io, recipe)), - tooltips, recipeTier, chanceTier, recipeType.getChanceFunction()); - // spotless:off - if (this.of(content.content) instanceof IntProviderIngredient ingredient) { - IntProvider countProvider = ingredient.getCountProvider(); - tooltips.add(Component.translatable("gtceu.gui.content.count_range", - countProvider.getMinValue(), countProvider.getMaxValue()) - .withStyle(ChatFormatting.GOLD)); - } else if (this.of(content.content) instanceof SizedIngredient sizedIngredient && - sizedIngredient.getInner() instanceof IntProviderIngredient ingredient) { - IntProvider countProvider = ingredient.getCountProvider(); - tooltips.add(Component.translatable("gtceu.gui.content.count_range", - countProvider.getMinValue(), countProvider.getMaxValue()) - .withStyle(ChatFormatting.GOLD)); - } - // spotless:on - if (isTickSlot(index, io, recipe)) { - tooltips.add(Component.translatable("gtceu.gui.content.per_tick")); - } - }); - if (io == IO.IN && (content.chance == 0 || this.of(content.content) instanceof IntCircuitIngredient)) { - slot.setIngredientIO(IngredientIO.CATALYST); - } - } - } - } - // Maps ingredients to an ItemEntryList for XEI: either an ItemTagList or an ItemStackList - private static ItemEntryList mapItem(final Ingredient ingredient) { + public static ItemEntryList mapIngredientToEntryList(final Ingredient ingredient) { if (ingredient instanceof SizedIngredient sizedIngredient) { final int amount = sizedIngredient.getAmount(); var mapped = tryMapInner(sizedIngredient.getInner(), amount); @@ -544,7 +382,7 @@ private static ItemEntryList mapIntersection(final IntersectionIngredient inters List children = ((IntersectionIngredientAccessor) intersection).getChildren(); if (children.isEmpty()) return new ItemStackList(); - var childList = mapItem(children.get(0)); + var childList = mapIngredientToEntryList(children.get(0)); ItemStackList stackList = new ItemStackList(); for (var stack : childList.getStacks()) { if (children.stream().skip(1).allMatch(child -> child.test(stack))) { @@ -586,4 +424,9 @@ public interface ICustomParallel { public boolean shouldBypassDistinct() { return false; } + + public @Nullable NotifiableItemStackHandler getCapabilityHandler(MetaMachine machine, IO io) { + var handlers = machine.getTraitHolder().getTraits(NotifiableItemStackHandler.TYPE); + return handlers.stream().filter(v -> v.handlerIO == io).findFirst().orElse(null); + } } diff --git a/src/main/java/com/gregtechceu/gtceu/api/capability/recipe/RecipeCapability.java b/src/main/java/com/gregtechceu/gtceu/api/capability/recipe/RecipeCapability.java index 6d2a54badc1..908e565762d 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/capability/recipe/RecipeCapability.java +++ b/src/main/java/com/gregtechceu/gtceu/api/capability/recipe/RecipeCapability.java @@ -1,18 +1,15 @@ package com.gregtechceu.gtceu.api.capability.recipe; +import com.gregtechceu.gtceu.api.machine.MetaMachine; +import com.gregtechceu.gtceu.api.machine.trait.NotifiableRecipeHandlerTrait; import com.gregtechceu.gtceu.api.recipe.GTRecipe; -import com.gregtechceu.gtceu.api.recipe.GTRecipeType; import com.gregtechceu.gtceu.api.recipe.content.Content; import com.gregtechceu.gtceu.api.recipe.content.ContentModifier; import com.gregtechceu.gtceu.api.recipe.content.IContentSerializer; import com.gregtechceu.gtceu.api.recipe.lookup.ingredient.AbstractMapIngredient; -import com.gregtechceu.gtceu.api.recipe.ui.GTRecipeTypeUI; import com.gregtechceu.gtceu.api.registry.GTRegistries; import com.gregtechceu.gtceu.utils.codec.DispatchedMapCodec; -import com.lowdragmc.lowdraglib.gui.widget.Widget; -import com.lowdragmc.lowdraglib.gui.widget.WidgetGroup; - import net.minecraft.nbt.Tag; import net.minecraft.network.FriendlyByteBuf; import net.minecraft.network.chat.Component; @@ -22,8 +19,6 @@ import io.netty.buffer.Unpooled; import it.unimi.dsi.fastutil.objects.Object2IntMap; import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap; -import org.apache.commons.lang3.mutable.MutableInt; -import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Unmodifiable; @@ -162,46 +157,6 @@ public int getMaxParallelByInput(IRecipeCapabilityHolder holder, GTRecipe recipe return Integer.MAX_VALUE; } - public boolean doAddGuiSlots() { - return isRecipeSearchFilter(); - } - - public void addXEIInfo(WidgetGroup group, int xOffset, GTRecipe recipe, List contents, boolean perTick, - boolean isInput, MutableInt yOffset) {} - - @NotNull - public List createXEIContainerContents(List contents, GTRecipe recipe, IO io) { - return new ArrayList<>(); - } - - @Nullable - public Object createXEIContainer(List contents) { - return null; - } - - @Nullable("null when getWidgetClass() == null") - public Widget createWidget() { - return null; - } - - /** - * Return the class of the supported widget that should be used to display this capability. - */ - @Nullable - public Class getWidgetClass() { - return null; - } - - public void applyWidgetInfo(@NotNull Widget widget, - int index, - boolean isXEI, - IO io, - @Nullable("null when storage == null") GTRecipeTypeUI.RecipeHolder recipeHolder, - @NotNull GTRecipeType recipeType, - @Nullable("null when content == null") GTRecipe recipe, - @Nullable Content content, - @Nullable Object storage, int recipeTier, int chanceTier) {} - /** * Create a cache map for chanced outputs * @@ -223,4 +178,8 @@ public boolean isTickSlot(int index, IO io, GTRecipe recipe) { public boolean shouldBypassDistinct() { return true; } + + public @Nullable NotifiableRecipeHandlerTrait getCapabilityHandler(MetaMachine machine, IO io) { + return null; + } } diff --git a/src/main/java/com/gregtechceu/gtceu/api/cover/filter/SimpleFluidFilter.java b/src/main/java/com/gregtechceu/gtceu/api/cover/filter/SimpleFluidFilter.java index d32f3afba1e..083d95dd2d1 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/cover/filter/SimpleFluidFilter.java +++ b/src/main/java/com/gregtechceu/gtceu/api/cover/filter/SimpleFluidFilter.java @@ -126,7 +126,7 @@ public ModularPanel getPanel(GuiData data, PanelSyncManager syncManager, UISe Grid filterGrid = new Grid() .coverChildren() - .mapTo(3, 9, i -> new FluidSlot().syncHandler("filter_slot_" + i)); + .gridOfSizeWidth(9, 3, (x, y, i) -> new FluidSlot().syncHandler("filter_slot_" + i)); BooleanSyncValue blacklist = new BooleanSyncValue(this::isBlackList, this::setBlackList); syncManager.syncValue("blacklist", blacklist); diff --git a/src/main/java/com/gregtechceu/gtceu/api/cover/filter/SimpleItemFilter.java b/src/main/java/com/gregtechceu/gtceu/api/cover/filter/SimpleItemFilter.java index b187f36ec1b..0c79718beca 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/cover/filter/SimpleItemFilter.java +++ b/src/main/java/com/gregtechceu/gtceu/api/cover/filter/SimpleItemFilter.java @@ -115,7 +115,7 @@ public ModularPanel getPanel(GuiData data, PanelSyncManager syncManager, UISe Grid filterGrid = new Grid() .coverChildren() - .mapTo(3, 9, i -> new PhantomItemSlot() + .gridOfSizeWidth(9, 3, (x, y, i) -> new PhantomItemSlot() .size(16) .syncHandler(new PhantomItemSlotSyncHandler(new ModularSlot(handler, i) .changeListener((stack, amount, client, init) -> { diff --git a/src/main/java/com/gregtechceu/gtceu/api/cover/filter/SmartItemFilter.java b/src/main/java/com/gregtechceu/gtceu/api/cover/filter/SmartItemFilter.java index 4fb3ecb820d..5d95bd47895 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/cover/filter/SmartItemFilter.java +++ b/src/main/java/com/gregtechceu/gtceu/api/cover/filter/SmartItemFilter.java @@ -15,7 +15,7 @@ import net.minecraft.network.chat.Component; import net.minecraft.world.item.ItemStack; -import brachy.modularui.api.drawable.IKey; +import brachy.modularui.api.drawable.Text; import brachy.modularui.drawable.ColorType; import brachy.modularui.drawable.UITexture; import brachy.modularui.factory.GuiData; @@ -96,7 +96,7 @@ public ModularPanel getPanel(GuiData data, PanelSyncManager syncManager, UISe .child(new GTMuiWidgets.EnumRowBuilder<>(SmartFilteringMode.class) .value(mode) .overlay(16, SmartFilteringMode.getTextures()) - .lang(IKey.dynamic(() -> Component.translatable(filterMode.localeName))) + .lang(Text.dynamic(() -> Component.translatable(filterMode.localeName))) .build().margin(7)) .child(SlotGroupWidget.playerInventory(false).left(7).bottom(7)); } @@ -119,7 +119,7 @@ private int lookup(ItemStack itemStack) { return 0; } for (Content content : recipe.getInputContents(ItemRecipeCapability.CAP)) { - var stacks = ItemRecipeCapability.CAP.of(content.getContent()).getItems(); + var stacks = ItemRecipeCapability.CAP.of(content.content()).getItems(); for (var stack : stacks) { if (ItemStack.isSameItem(stack, itemStack)) return stack.getCount(); } diff --git a/src/main/java/com/gregtechceu/gtceu/api/data/chemical/ChemicalHelper.java b/src/main/java/com/gregtechceu/gtceu/api/data/chemical/ChemicalHelper.java index 3cc568351df..faca4586aeb 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/data/chemical/ChemicalHelper.java +++ b/src/main/java/com/gregtechceu/gtceu/api/data/chemical/ChemicalHelper.java @@ -298,7 +298,7 @@ public static TagKey getBlockTag(TagPrefix orePrefix, @NotNull Material m } @Nullable - public static TagKey getTag(TagPrefix orePrefix, @NotNull Material material) { + public static TagKey getTag(TagPrefix orePrefix, Material material) { var tags = orePrefix.getItemTags(material); if (tags.isEmpty()) { return null; diff --git a/src/main/java/com/gregtechceu/gtceu/api/gui/WidgetUtils.java b/src/main/java/com/gregtechceu/gtceu/api/gui/WidgetUtils.java deleted file mode 100644 index ed996599973..00000000000 --- a/src/main/java/com/gregtechceu/gtceu/api/gui/WidgetUtils.java +++ /dev/null @@ -1,52 +0,0 @@ -package com.gregtechceu.gtceu.api.gui; - -import com.lowdragmc.lowdraglib.gui.widget.Widget; -import com.lowdragmc.lowdraglib.gui.widget.WidgetGroup; - -import org.jetbrains.annotations.Nullable; - -import java.util.List; -import java.util.function.Consumer; -import java.util.regex.Pattern; - -public class WidgetUtils { - - public static List getWidgetsById(WidgetGroup group, String regex) { - return group.getWidgetsById(Pattern.compile(regex)); - } - - @Nullable - public static Widget getFirstWidgetById(WidgetGroup group, String regex) { - return group.getFirstWidgetById(Pattern.compile(regex)); - } - - public static void widgetByIdForEach(WidgetGroup group, String regex, Consumer consumer) { - getWidgetsById(group, regex).forEach(consumer); - } - - public static void widgetByIdForEach(WidgetGroup group, String regex, Class clazz, - Consumer consumer) { - for (Widget widget : getWidgetsById(group, regex)) { - if (clazz.isInstance(widget)) { - consumer.accept(clazz.cast(widget)); - } - } - } - - public static int widgetIdIndex(Widget widget) { - var id = widget.getId(); - if (id == null) return -1; - var split = id.split("_"); - if (split.length == 0) return -1; - var end = split[split.length - 1]; - try { - return Integer.parseInt(end); - } catch (Exception e) { - return -1; - } - } - - public static int getInventoryHeight(boolean includeHotbar) { - return 64 + (includeHotbar ? 22 : 0); - } -} diff --git a/src/main/java/com/gregtechceu/gtceu/api/gui/editor/IEditableUI.java b/src/main/java/com/gregtechceu/gtceu/api/gui/editor/IEditableUI.java deleted file mode 100644 index 9af8c25799c..00000000000 --- a/src/main/java/com/gregtechceu/gtceu/api/gui/editor/IEditableUI.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.gregtechceu.gtceu.api.gui.editor; - -import com.lowdragmc.lowdraglib.gui.widget.Widget; -import com.lowdragmc.lowdraglib.gui.widget.WidgetGroup; - -import java.util.function.BiConsumer; -import java.util.function.Supplier; - -public interface IEditableUI { - - W createDefault(); - - void setupUI(WidgetGroup template, T instance); - - record Normal(Supplier supplier, BiConsumer binder) - implements IEditableUI { - - @Override - public A createDefault() { - return supplier.get(); - } - - @Override - public void setupUI(WidgetGroup template, B instance) { - binder.accept(template, instance); - } - } -} diff --git a/src/main/java/com/gregtechceu/gtceu/api/gui/widget/DualProgressWidget.java b/src/main/java/com/gregtechceu/gtceu/api/gui/widget/DualProgressWidget.java deleted file mode 100644 index 668e61c1eb8..00000000000 --- a/src/main/java/com/gregtechceu/gtceu/api/gui/widget/DualProgressWidget.java +++ /dev/null @@ -1,121 +0,0 @@ -package com.gregtechceu.gtceu.api.gui.widget; - -import com.lowdragmc.lowdraglib.gui.editor.annotation.Configurable; -import com.lowdragmc.lowdraglib.gui.editor.annotation.LDLRegister; -import com.lowdragmc.lowdraglib.gui.editor.annotation.NumberRange; -import com.lowdragmc.lowdraglib.gui.editor.configurator.Configurator; -import com.lowdragmc.lowdraglib.gui.editor.configurator.ConfiguratorGroup; -import com.lowdragmc.lowdraglib.gui.editor.configurator.WrapperConfigurator; -import com.lowdragmc.lowdraglib.gui.widget.ProgressWidget; -import com.lowdragmc.lowdraglib.gui.widget.WidgetGroup; - -import lombok.Getter; -import lombok.experimental.Accessors; - -import java.util.function.DoubleSupplier; - -@LDLRegister(name = "dual_progress", group = "widget.group") -@Accessors(chain = true) -public class DualProgressWidget extends WidgetGroup { - - private DoubleSupplier progressSupplier; - @Configurable - @NumberRange(range = { 0.001, 1.0 }, wheel = 0.01) - private double splitPoint; - @Configurable(subConfigurable = true) - @Getter - private ProgressWidget texture1; - @Configurable(subConfigurable = true) - @Getter - private ProgressWidget texture2; - - public DualProgressWidget() { - this(ProgressWidget.JEIProgress, 0.5); - } - - public DualProgressWidget(DoubleSupplier progress, double splitPoint) { - this(new ProgressWidget(ProgressWidget.JEIProgress, 0, 0, 16, 16), - new ProgressWidget(ProgressWidget.JEIProgress, 16, 0, 16, 16), progress, splitPoint); - } - - public DualProgressWidget(ProgressWidget texture1, ProgressWidget texture2, DoubleSupplier progress, - double splitPoint) { - this.progressSupplier = progress; - this.splitPoint = splitPoint; - this.texture1 = texture1.setProgressSupplier( - () -> progress.getAsDouble() >= splitPoint ? 1.0 : (1.0 / splitPoint) * progress.getAsDouble()); - this.texture2 = texture2.setProgressSupplier(() -> progress.getAsDouble() >= splitPoint ? - (1.0 / (1 - splitPoint)) * (progress.getAsDouble() - splitPoint) : 0); - this.addWidget(this.texture1).addWidget(this.texture2); - } - - public DualProgressWidget setTexture1(ProgressWidget widget) { - this.removeWidget(texture1); - this.texture1 = widget.setProgressSupplier(() -> progressSupplier.getAsDouble() >= splitPoint ? 1.0 : - (1.0 / splitPoint) * progressSupplier.getAsDouble()); - this.addWidget(texture1); - return this; - } - - public DualProgressWidget setTexture2(ProgressWidget widget) { - this.removeWidget(texture2); - this.texture2 = widget.setProgressSupplier(() -> progressSupplier.getAsDouble() >= splitPoint ? - (1.0 / (1 - splitPoint)) * (progressSupplier.getAsDouble() - splitPoint) : 0); - this.addWidget(texture2); - return this; - } - - public DualProgressWidget setProgressSupplier(DoubleSupplier progressSupplier) { - this.progressSupplier = progressSupplier; - - this.widgets.clear(); - this.texture1.setProgressSupplier(() -> progressSupplier.getAsDouble() >= splitPoint ? 1.0 : - (1.0 / splitPoint) * progressSupplier.getAsDouble()); - this.addWidget(texture1); - this.texture2.setProgressSupplier(() -> progressSupplier.getAsDouble() >= splitPoint ? - (1.0 / (1 - splitPoint)) * (progressSupplier.getAsDouble() - splitPoint) : 0); - this.addWidget(texture2); - - return this; - } - - public DualProgressWidget setSplitPoint(double splitPoint) { - this.splitPoint = splitPoint; - - this.widgets.clear(); - this.texture1.setProgressSupplier(() -> progressSupplier.getAsDouble() >= splitPoint ? 1.0 : - (1.0 / splitPoint) * progressSupplier.getAsDouble()); - this.addWidget(texture1); - this.texture2.setProgressSupplier(() -> progressSupplier.getAsDouble() >= splitPoint ? - (1.0 / (1 - splitPoint)) * (progressSupplier.getAsDouble() - splitPoint) : 0); - this.addWidget(texture2); - - return this; - } - - @Override - public void buildConfigurator(ConfiguratorGroup father) { - super.buildConfigurator(father); - for (Configurator configurator : father.getConfigurators()) { - if (!setConfiguratorIfProgress(configurator) && configurator instanceof ConfiguratorGroup group) { - for (Configurator subConfigurator : group.getConfigurators()) { - setConfiguratorIfProgress(subConfigurator); - } - } - } - } - - private boolean setConfiguratorIfProgress(Configurator configurator) { - if (configurator instanceof WrapperConfigurator guiConfigurator && - guiConfigurator.inner instanceof ProgressWidget progressWidget) { - if (configurator.getName().equals("texture1")) { - this.setTexture1(progressWidget); - return true; - } else if (configurator.getName().equals("texture2")) { - this.setTexture2(progressWidget); - return true; - } - } - return false; - } -} diff --git a/src/main/java/com/gregtechceu/gtceu/api/gui/widget/PatternPreviewSlotWidget.java b/src/main/java/com/gregtechceu/gtceu/api/gui/widget/PatternPreviewSlotWidget.java index 432e8be1636..9220c9ecf76 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/gui/widget/PatternPreviewSlotWidget.java +++ b/src/main/java/com/gregtechceu/gtceu/api/gui/widget/PatternPreviewSlotWidget.java @@ -2,6 +2,7 @@ import com.lowdragmc.lowdraglib.gui.modular.ModularUIGuiContainer; import com.lowdragmc.lowdraglib.gui.util.DrawerHelper; +import com.lowdragmc.lowdraglib.gui.widget.SlotWidget; import com.lowdragmc.lowdraglib.utils.ColorUtils; import com.lowdragmc.lowdraglib.utils.Position; @@ -22,7 +23,7 @@ public class PatternPreviewSlotWidget extends SlotWidget { public PatternPreviewSlotWidget(IItemHandlerModifiable itemHandler, int slotIndex, int xPosition, int yPosition, boolean canTakeItems, boolean canPutItems) { - super(itemHandler, slotIndex, xPosition, yPosition, canTakeItems, canPutItems); + super(); } /** diff --git a/src/main/java/com/gregtechceu/gtceu/api/gui/widget/PatternPreviewWidget.java b/src/main/java/com/gregtechceu/gtceu/api/gui/widget/PatternPreviewWidget.java index 087670b518f..781b2c91f8d 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/gui/widget/PatternPreviewWidget.java +++ b/src/main/java/com/gregtechceu/gtceu/api/gui/widget/PatternPreviewWidget.java @@ -10,7 +10,6 @@ import com.gregtechceu.gtceu.api.pattern.TraceabilityPredicate; import com.gregtechceu.gtceu.api.pattern.predicates.SimplePredicate; import com.gregtechceu.gtceu.config.ConfigHolder; -import com.gregtechceu.gtceu.integration.recipeviewer.handlers.item.CycleItemEntryHandler; import com.lowdragmc.lowdraglib.client.scene.WorldSceneRenderer; import com.lowdragmc.lowdraglib.client.utils.RenderUtils; @@ -43,6 +42,9 @@ import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; +import brachy.modularui.integration.recipeviewer.entry.item.ItemEntryList; +import brachy.modularui.integration.recipeviewer.entry.item.ItemStackList; +import brachy.modularui.integration.recipeviewer.handlers.item.CycleItemEntryHandler; import com.mojang.blaze3d.systems.RenderSystem; import com.mojang.blaze3d.vertex.PoseStack; import dev.emi.emi.screen.RecipeScreen; @@ -72,8 +74,8 @@ public class PatternPreviewWidget extends WidgetGroup { private final List predicates; private int index; public int layer; - private SlotWidget[] slotWidgets; - private SlotWidget[] candidates; + private com.lowdragmc.lowdraglib.gui.widget.SlotWidget[] slotWidgets; + private com.lowdragmc.lowdraglib.gui.widget.SlotWidget[] candidates; protected PatternPreviewWidget(MultiblockMachineDefinition controllerDefinition) { super(0, 0, 160, 160); @@ -240,12 +242,14 @@ public void setPage(int index) { MBPattern pattern = patterns[index]; setupScene(pattern); if (slotWidgets != null) { - for (SlotWidget slotWidget : slotWidgets) { + for (com.lowdragmc.lowdraglib.gui.widget.SlotWidget slotWidget : slotWidgets) { scrollableWidgetGroup.removeWidget(slotWidget); } } - slotWidgets = new SlotWidget[Math.min(pattern.parts.size(), 18)]; - CycleItemEntryHandler itemHandler = CycleItemEntryHandler.fromStacks(pattern.parts); + slotWidgets = new com.lowdragmc.lowdraglib.gui.widget.SlotWidget[Math.min(pattern.parts.size(), 18)]; + + var itemHandler = new CycleItemEntryHandler( + pattern.parts.stream().map(l -> (ItemEntryList) new ItemStackList(l)).toList()); int xOffset = 0; for (int i = 0; i < slotWidgets.length; i++) { int padding = 1; @@ -286,7 +290,7 @@ private void onPosSelected(BlockPos pos, Direction facing) { predicates.addAll(predicate.limited); predicates.removeIf(p -> p == null || p.candidates == null); // why it happens? if (candidates != null) { - for (SlotWidget candidate : candidates) { + for (com.lowdragmc.lowdraglib.gui.widget.SlotWidget candidate : candidates) { removeWidget(candidate); } } @@ -299,13 +303,13 @@ private void onPosSelected(BlockPos pos, Direction facing) { predicateTips.add(simplePredicate.getToolTips(predicate)); } } - candidates = new SlotWidget[candidateStacks.size()]; - CycleItemEntryHandler itemHandler = CycleItemEntryHandler.fromStacks(candidateStacks); + candidates = new com.lowdragmc.lowdraglib.gui.widget.SlotWidget[candidateStacks.size()]; + var itemHandler = new CycleItemEntryHandler( + candidateStacks.stream().map(l -> (ItemEntryList) new ItemStackList(l)).toList()); int maxCol = (160 - (((slotWidgets.length - 1) / 9 + 1) * 18) - 35) % 18; for (int i = 0; i < candidateStacks.size(); i++) { int finalI = i; - candidates[i] = new SlotWidget(itemHandler, i, 3 + (i / maxCol) * 18, 3 + (i % maxCol) * 18, false, - false) + candidates[i] = new com.lowdragmc.lowdraglib.gui.widget.SlotWidget() .setIngredientIO(IngredientIO.INPUT) .setBackgroundTexture(new ColorRectTexture(0x4fffffff)) .setOnAddedTooltips((slot, list) -> list.addAll(predicateTips.get(finalI))); diff --git a/src/main/java/com/gregtechceu/gtceu/api/gui/widget/PhantomFluidWidget.java b/src/main/java/com/gregtechceu/gtceu/api/gui/widget/PhantomFluidWidget.java deleted file mode 100644 index efed72f4039..00000000000 --- a/src/main/java/com/gregtechceu/gtceu/api/gui/widget/PhantomFluidWidget.java +++ /dev/null @@ -1,268 +0,0 @@ -package com.gregtechceu.gtceu.api.gui.widget; - -import com.gregtechceu.gtceu.GTCEu; - -import com.lowdragmc.lowdraglib.gui.editor.annotation.ConfigSetter; -import com.lowdragmc.lowdraglib.gui.editor.annotation.LDLRegister; -import com.lowdragmc.lowdraglib.gui.editor.configurator.IConfigurableWidget; -import com.lowdragmc.lowdraglib.gui.ingredient.IGhostIngredientTarget; -import com.lowdragmc.lowdraglib.gui.ingredient.Target; -import com.lowdragmc.lowdraglib.gui.util.DrawerHelper; -import com.lowdragmc.lowdraglib.gui.util.TextFormattingUtil; -import com.lowdragmc.lowdraglib.side.fluid.forge.FluidHelperImpl; -import com.lowdragmc.lowdraglib.utils.Position; -import com.lowdragmc.lowdraglib.utils.Size; - -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.Font; -import net.minecraft.client.gui.GuiGraphics; -import net.minecraft.client.renderer.Rect2i; -import net.minecraft.network.FriendlyByteBuf; -import net.minecraft.world.item.Item; -import net.minecraft.world.item.ItemStack; -import net.minecraft.world.item.crafting.Ingredient; -import net.minecraft.world.level.material.Fluid; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.api.distmarker.OnlyIn; -import net.minecraftforge.fluids.FluidStack; -import net.minecraftforge.fluids.FluidType; -import net.minecraftforge.fluids.FluidUtil; -import net.minecraftforge.fluids.capability.IFluidHandler; -import net.minecraftforge.fluids.capability.IFluidHandler.FluidAction; - -import com.google.common.collect.Lists; -import com.mojang.blaze3d.systems.RenderSystem; -import dev.emi.emi.api.stack.EmiStack; -import lombok.Getter; -import lombok.Setter; -import mezz.jei.api.ingredients.ITypedIngredient; -import org.jetbrains.annotations.NotNull; - -import java.util.Collections; -import java.util.List; -import java.util.function.Consumer; -import java.util.function.Supplier; - -import javax.annotation.Nonnull; -import javax.annotation.Nullable; - -@LDLRegister(name = "gtm_phantom_fluid_slot", group = "widget.gtm_container", priority = 50) -public class PhantomFluidWidget extends TankWidget implements IGhostIngredientTarget, IConfigurableWidget { - - @Setter - private Supplier phantomFluidGetter; - @Setter - private Consumer phantomFluidSetter; - - @Nullable - @Getter - protected FluidStack lastPhantomStack; - - public PhantomFluidWidget() { - super(); - } - - public PhantomFluidWidget(@Nullable IFluidHandler fluidTank, int tank, int x, int y, int width, int height, - Supplier phantomFluidGetter, Consumer phantomFluidSetter) { - super(fluidTank, tank, x, y, width, height, false, false); - this.phantomFluidGetter = phantomFluidGetter; - this.phantomFluidSetter = phantomFluidSetter; - } - - @ConfigSetter(field = "allowClickFilled") - public PhantomFluidWidget setAllowClickFilled(boolean v) { - // you cant modify it - return this; - } - - @ConfigSetter(field = "allowClickDrained") - public PhantomFluidWidget setAllowClickDrained(boolean v) { - // you cant modify it - return this; - } - - protected void setLastPhantomStack(FluidStack fluid) { - if (fluid != null) { - this.lastPhantomStack = fluid.copy(); - this.lastPhantomStack.setAmount(1); - } else { - this.lastPhantomStack = null; - } - } - - public static FluidStack drainFrom(Object ingredient) { - if (ingredient instanceof Ingredient ing) { - var items = ing.getItems(); - if (items.length > 0) { - ingredient = items[0]; - } - } - if (ingredient instanceof ItemStack itemStack) { - return FluidUtil.getFluidHandler(itemStack) - .map(h -> h.drain(Integer.MAX_VALUE, FluidAction.SIMULATE)) - .orElse(FluidStack.EMPTY); - } - return FluidStack.EMPTY; - } - - @Override - @OnlyIn(Dist.CLIENT) - public List getPhantomTargets(Object ingredient) { - if (GTCEu.Mods.isREILoaded() && ingredient instanceof dev.architectury.fluid.FluidStack fluidStack) { - ingredient = new FluidStack(fluidStack.getFluid(), (int) fluidStack.getAmount(), fluidStack.getTag()); - } else if (GTCEu.Mods.isEMILoaded() && ingredient instanceof EmiStack emiStack) { - var key = emiStack.getKey(); - if (key instanceof Fluid f) { - int amount = emiStack.getAmount() == 0 ? 1000 : (int) emiStack.getAmount(); - ingredient = new FluidStack(f, amount, emiStack.getNbt()); - } else if (key instanceof Item i) { - ingredient = new ItemStack(i, (int) emiStack.getAmount()); - ((ItemStack) ingredient).setTag(emiStack.getNbt()); - } else { - ingredient = null; - } - } else if (GTCEu.Mods.isJEILoaded() && ingredient instanceof ITypedIngredient jeiStack) { - ingredient = jeiStack.getIngredient(); - } - - if (!(ingredient instanceof FluidStack) && drainFrom(ingredient).isEmpty()) { - return Collections.emptyList(); - } - - Rect2i rectangle = toRectangleBox(); - return Lists.newArrayList(new Target() { - - @Nonnull - @Override - public Rect2i getArea() { - return rectangle; - } - - @Override - public void accept(@Nonnull Object ingredient) { - if (GTCEu.Mods.isREILoaded() && ingredient instanceof dev.architectury.fluid.FluidStack fluidStack) { - ingredient = new FluidStack(fluidStack.getFluid(), - (int) fluidStack.getAmount(), - fluidStack.getTag()); - } else if (GTCEu.Mods.isEMILoaded() && ingredient instanceof EmiStack emiStack) { - var key = emiStack.getKey(); - if (key instanceof Fluid f) { - int amount = emiStack.getAmount() == 0 ? 1000 : (int) emiStack.getAmount(); - ingredient = new FluidStack(f, amount, emiStack.getNbt()); - } else if (key instanceof Item i) { - ingredient = new ItemStack(i, (int) emiStack.getAmount()); - ((ItemStack) ingredient).setTag(emiStack.getNbt()); - } else { - ingredient = null; - } - } - - FluidStack ingredientStack; - if (ingredient instanceof FluidStack fluidStack) ingredientStack = fluidStack; - else ingredientStack = drainFrom(ingredient); - - if (!ingredientStack.isEmpty()) { - writeClientAction(2, ingredientStack::writeToPacket); - } - - if (isClientSideWidget) { - if (phantomFluidSetter != null) { - phantomFluidSetter.accept(ingredientStack); - } - } - } - }); - } - - @Override - public void handleClientAction(int id, FriendlyByteBuf buffer) { - if (id == 1) { - handlePhantomClick(); - } else if (id == 2) { - if (phantomFluidSetter != null) { - phantomFluidSetter.accept(FluidStack.readFromPacket(buffer)); - } - } else if (id == 4) { - phantomFluidSetter.accept(FluidStack.EMPTY); - } else if (id == 5) { - phantomFluidSetter.accept(FluidStack.readFromPacket(buffer)); - } - } - - @Override - public void detectAndSendChanges() { - super.detectAndSendChanges(); - FluidStack stack = phantomFluidGetter.get(); - if (stack == null || stack.isEmpty()) { - if (lastPhantomStack != null) { - setLastPhantomStack(null); - writeUpdateInfo(4, buf -> {}); - } - } else if (lastPhantomStack == null || !stack.isFluidEqual(lastPhantomStack)) { - setLastPhantomStack(stack); - writeUpdateInfo(5, stack::writeToPacket); - } - } - - @Override - @OnlyIn(Dist.CLIENT) - public boolean mouseClicked(double mouseX, double mouseY, int button) { - if (isMouseOverElement(mouseX, mouseY)) { - if (isClientSideWidget) { - handlePhantomClick(); - } else { - writeClientAction(1, buffer -> {}); - } - return true; - } - return false; - } - - private void handlePhantomClick() { - ItemStack itemStack = gui.getModularUIContainer().getCarried(); - FluidStack fluid = FluidUtil.getFluidContained(itemStack) - .map(f -> new FluidStack(f, FluidType.BUCKET_VOLUME)) - .orElse(FluidStack.EMPTY); - if (phantomFluidSetter != null) phantomFluidSetter.accept(fluid); - } - - @Override - public void drawInBackground(@NotNull GuiGraphics graphics, int mouseX, int mouseY, float partialTicks) { - if (this.lastFluidInTank != null) { - super.drawInBackground(graphics, mouseX, mouseY, partialTicks); - return; - } - Position pos = getPosition(); - Size size = getSize(); - FluidStack stack = phantomFluidGetter.get(); - if (stack != null && !stack.isEmpty()) { - RenderSystem.disableBlend(); - - double progress = stack.getAmount() * 1.0 / Math.max(Math.max(stack.getAmount(), lastTankCapacity), 1); - float drawnU = (float) fillDirection.getDrawnU(progress); - float drawnV = (float) fillDirection.getDrawnV(progress); - float drawnWidth = (float) fillDirection.getDrawnWidth(progress); - float drawnHeight = (float) fillDirection.getDrawnHeight(progress); - int width = size.width - 2; - int height = size.height - 2; - int x = pos.x + 1; - int y = pos.y + 1; - DrawerHelper.drawFluidForGui(graphics, FluidHelperImpl.toFluidStack(stack), stack.getAmount(), - (int) (x + drawnU * width), (int) (y + drawnV * height), ((int) (width * drawnWidth)), - ((int) (height * drawnHeight))); - if (showAmount) { - graphics.pose().pushPose(); - graphics.pose().scale(0.5F, 0.5F, 1); - String s = TextFormattingUtil.formatLongToCompactStringBuckets(stack.getAmount(), 3) + "B"; - Font fontRenderer = Minecraft.getInstance().font; - graphics.drawString(fontRenderer, s, - (int) ((pos.x + (size.width / 3f)) * 2 - fontRenderer.width(s) + 21), - (int) ((pos.y + (size.height / 3f) + 6) * 2), 0xFFFFFF, true); - graphics.pose().popPose(); - } - - RenderSystem.enableBlend(); - RenderSystem.setShaderColor(1, 1, 1, 1); - } - } -} diff --git a/src/main/java/com/gregtechceu/gtceu/api/gui/widget/PredicatedButtonWidget.java b/src/main/java/com/gregtechceu/gtceu/api/gui/widget/PredicatedButtonWidget.java deleted file mode 100644 index 11b8e95e682..00000000000 --- a/src/main/java/com/gregtechceu/gtceu/api/gui/widget/PredicatedButtonWidget.java +++ /dev/null @@ -1,70 +0,0 @@ -package com.gregtechceu.gtceu.api.gui.widget; - -import com.lowdragmc.lowdraglib.gui.texture.IGuiTexture; -import com.lowdragmc.lowdraglib.gui.util.ClickData; -import com.lowdragmc.lowdraglib.gui.widget.ButtonWidget; - -import net.minecraft.network.FriendlyByteBuf; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.api.distmarker.OnlyIn; - -import java.util.function.BooleanSupplier; -import java.util.function.Consumer; - -public class PredicatedButtonWidget extends ButtonWidget { - - private final BooleanSupplier predicate; - - public PredicatedButtonWidget(int xPosition, int yPosition, int width, int height, IGuiTexture buttonTexture, - Consumer onPressed, BooleanSupplier predicate, boolean defaultVisibility) { - super(xPosition, yPosition, width, height, buttonTexture, onPressed); - this.predicate = predicate; - setVisible(defaultVisibility); - } - - public PredicatedButtonWidget(int xPosition, int yPosition, int width, int height, IGuiTexture buttonTexture, - Consumer onPressed, BooleanSupplier predicate) { - this(xPosition, yPosition, width, height, buttonTexture, onPressed, predicate, false); - } - - public PredicatedButtonWidget(int xPosition, int yPosition, int width, int height, Consumer onPressed, - BooleanSupplier predicate) { - super(xPosition, yPosition, width, height, onPressed); - this.predicate = predicate; - } - - @Override - public void writeInitialData(FriendlyByteBuf buffer) { - super.writeInitialData(buffer); - var result = predicate == null || predicate.getAsBoolean(); - setVisible(result); - buffer.writeBoolean(result); - } - - @Override - public void readInitialData(FriendlyByteBuf buffer) { - super.readInitialData(buffer); - setVisible(buffer.readBoolean()); - } - - @Override - public void detectAndSendChanges() { - super.detectAndSendChanges(); - if (predicate != null) { - if (isVisible() != predicate.getAsBoolean()) { - setVisible(!isVisible()); - writeUpdateInfo(1, buf -> buf.writeBoolean(isVisible())); - } - } - } - - @Override - @OnlyIn(Dist.CLIENT) - public void readUpdateInfo(int id, FriendlyByteBuf buffer) { - if (id == 1) { - setVisible(buffer.readBoolean()); - } else { - super.readUpdateInfo(id, buffer); - } - } -} diff --git a/src/main/java/com/gregtechceu/gtceu/api/gui/widget/SlotWidget.java b/src/main/java/com/gregtechceu/gtceu/api/gui/widget/SlotWidget.java deleted file mode 100644 index 52b383b7ccc..00000000000 --- a/src/main/java/com/gregtechceu/gtceu/api/gui/widget/SlotWidget.java +++ /dev/null @@ -1,429 +0,0 @@ -package com.gregtechceu.gtceu.api.gui.widget; - -import com.gregtechceu.gtceu.GTCEu; -import com.gregtechceu.gtceu.integration.recipeviewer.entry.item.ItemEntryList; -import com.gregtechceu.gtceu.integration.recipeviewer.entry.item.ItemStackList; -import com.gregtechceu.gtceu.integration.recipeviewer.entry.item.ItemTagList; -import com.gregtechceu.gtceu.integration.recipeviewer.handlers.item.CycleItemEntryHandler; - -import com.lowdragmc.lowdraglib.gui.editor.annotation.LDLRegister; -import com.lowdragmc.lowdraglib.gui.editor.configurator.ConfiguratorGroup; -import com.lowdragmc.lowdraglib.gui.editor.configurator.WrapperConfigurator; -import com.lowdragmc.lowdraglib.gui.editor.runtime.ConfiguratorParser; -import com.lowdragmc.lowdraglib.gui.texture.IGuiTexture; -import com.lowdragmc.lowdraglib.jei.IngredientIO; -import com.lowdragmc.lowdraglib.jei.JEIPlugin; -import com.lowdragmc.lowdraglib.side.item.IItemTransfer; -import com.lowdragmc.lowdraglib.utils.Position; -import com.lowdragmc.lowdraglib.utils.Size; - -import net.minecraft.network.chat.Component; -import net.minecraft.world.Container; -import net.minecraft.world.SimpleContainer; -import net.minecraft.world.entity.player.Player; -import net.minecraft.world.inventory.Slot; -import net.minecraft.world.item.ItemStack; -import net.minecraft.world.level.block.Blocks; -import net.minecraftforge.items.IItemHandlerModifiable; -import net.minecraftforge.items.ItemStackHandler; - -import dev.emi.emi.api.stack.EmiIngredient; -import dev.emi.emi.api.stack.EmiStack; -import lombok.Getter; -import me.shedaniel.rei.api.common.entry.EntryIngredient; -import me.shedaniel.rei.api.common.util.EntryStacks; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.function.BiConsumer; -import java.util.function.Function; -import java.util.function.UnaryOperator; -import java.util.stream.Collectors; -import java.util.stream.Stream; - -@LDLRegister(name = "gtm_item_slot", group = "widget.gtm_container", priority = 50) -public class SlotWidget extends com.lowdragmc.lowdraglib.gui.widget.SlotWidget { - - public SlotWidget() { - super(); - } - - public SlotWidget(Container inventory, int slotIndex, int xPosition, int yPosition, boolean canTakeItems, - boolean canPutItems) { - super(inventory, slotIndex, xPosition, yPosition, canTakeItems, canPutItems); - } - - public SlotWidget(IItemHandlerModifiable itemHandler, int slotIndex, int xPosition, int yPosition, - boolean canTakeItems, boolean canPutItems) { - this.setSelfPosition(xPosition, yPosition); - this.setSize(18, 18); - this.recomputePosition(); - this.setVisible(true); - this.setActive(true); - this.drawHoverOverlay = true; - this.drawHoverTips = true; - this.ingredientIO = IngredientIO.RENDER_ONLY; - this.XEIChance = 1.0f; - this.setBackgroundTexture(ITEM_SLOT_TEXTURE); - this.canTakeItems = canTakeItems; - this.canPutItems = canPutItems; - this.setHandlerSlot(itemHandler, slotIndex); - } - - public SlotWidget(IItemHandlerModifiable itemHandler, int slotIndex, int xPosition, int yPosition) { - this(itemHandler, slotIndex, xPosition, yPosition, true, true); - } - - public SlotWidget(Container container, int slotIndex, int xPosition, int yPosition) { - this(container, slotIndex, xPosition, yPosition, true, true); - } - - protected Slot createSlot(IItemHandlerModifiable itemHandler, int index) { - return new WidgetSlotItemHandler(itemHandler, index, 0, 0); - } - - public SlotWidget setContainerSlot(Container inventory, int slotIndex) { - super.setContainerSlot(inventory, slotIndex); - return this; - } - - @Override - public void updateSlot(Slot slot) { - super.updateSlot(slot); - } - - @Override - public SlotWidget setHandlerSlot(IItemTransfer itemHandler, int slotIndex) { - super.setHandlerSlot(itemHandler, slotIndex); - return this; - } - - public SlotWidget setHandlerSlot(IItemHandlerModifiable itemHandler, int slotIndex) { - updateSlot(createSlot(itemHandler, slotIndex)); - return this; - } - - @Override - public SlotWidget setBackgroundTexture(IGuiTexture backgroundTexture) { - super.setBackgroundTexture(backgroundTexture); - return this; - } - - @Override - public SlotWidget setLocationInfo(boolean isPlayerContainer, boolean isPlayerHotBar) { - super.setLocationInfo(isPlayerContainer, isPlayerHotBar); - return this; - } - - @Override - public SlotWidget setCanTakeItems(boolean canTakeItems) { - super.setCanTakeItems(canTakeItems); - return this; - } - - @Override - public SlotWidget setCanPutItems(boolean canPutItems) { - super.setCanPutItems(canPutItems); - return this; - } - - @Override - public SlotWidget setDrawHoverOverlay(boolean drawHoverOverlay) { - super.setDrawHoverOverlay(drawHoverOverlay); - return this; - } - - @Override - public SlotWidget setDrawHoverTips(boolean drawHoverTips) { - super.setDrawHoverTips(drawHoverTips); - return this; - } - - @Override - public SlotWidget setIngredientIO(IngredientIO ingredientIO) { - super.setIngredientIO(ingredientIO); - return this; - } - - @Override - public SlotWidget setChangeListener(Runnable changeListener) { - super.setChangeListener(changeListener); - return this; - } - - @Override - public SlotWidget setXEIChance(float XEIChance) { - super.setXEIChance(XEIChance); - return this; - } - - @Override - public SlotWidget setItemHook(Function itemHook) { - super.setItemHook(itemHook); - return this; - } - - @Override - public SlotWidget setOnAddedTooltips(BiConsumer> onAddedTooltips) { - super.setOnAddedTooltips(onAddedTooltips); - return this; - } - - @Override - public void buildConfigurator(ConfiguratorGroup father) { - var handler = new ItemStackHandler(); - handler.setStackInSlot(0, Blocks.STONE.asItem().getDefaultInstance()); - father.addConfigurators(new WrapperConfigurator("ldlib.gui.editor.group.preview", new SlotWidget() { - - @Override - public void updateScreen() { - super.updateScreen(); - setHoverTooltips(SlotWidget.this.tooltipTexts); - this.backgroundTexture = SlotWidget.this.backgroundTexture; - this.hoverTexture = SlotWidget.this.hoverTexture; - this.drawHoverOverlay = SlotWidget.this.drawHoverOverlay; - this.drawHoverTips = SlotWidget.this.drawHoverTips; - this.overlay = SlotWidget.this.overlay; - } - }.setCanPutItems(false).setCanTakeItems(false).setHandlerSlot(handler, 0))); - - ConfiguratorParser.createConfigurators(father, new HashMap<>(), getClass(), this); - } - - @Nullable - @Override - public Object getXEIIngredientOverMouse(double mouseX, double mouseY) { - if (self().isMouseOverElement(mouseX, mouseY)) { - var handler = getHandler(); - if (handler == null) return null; - ItemStack realStack = getRealStack(handler.getItem()); - if (handler instanceof WidgetSlotItemHandler slotHandler) { - if (slotHandler.itemHandler instanceof CycleItemEntryHandler entryHandler) { - return getXEIIngredientsClickable(entryHandler, slotHandler.index); - } - } - - if (GTCEu.Mods.isJEILoaded() && !realStack.isEmpty()) { - return JEICallWrapper.getJEIStackClickable(realStack, getPosition(), getSize()); - } else if (GTCEu.Mods.isREILoaded()) { - return EntryStacks.of(realStack); - } else if (GTCEu.Mods.isEMILoaded()) { - return EmiStack.of(realStack).setChance(getXEIChance()); - } - return realStack; - } - return null; - } - - @Override - public List getXEIIngredients() { - if (slotReference == null || slotReference.getItem().isEmpty()) return Collections.emptyList(); - var handler = getHandler(); - if (handler == null) return Collections.emptyList(); - ItemStack realStack = getRealStack(handler.getItem()); - if (handler instanceof WidgetSlotItemHandler slotHandler) { - if (slotHandler.itemHandler instanceof CycleItemEntryHandler entryHandler) { - return getXEIIngredientsClickable(entryHandler, slotHandler.index); - } - } - - if (GTCEu.Mods.isJEILoaded() && !realStack.isEmpty()) { - return List.of(JEICallWrapper.getJEIStackClickable(realStack, getPosition(), getSize())); - } else if (GTCEu.Mods.isREILoaded()) { - return List.of(EntryStacks.of(realStack)); - } else if (GTCEu.Mods.isEMILoaded()) { - return List.of(EmiStack.of(realStack).setChance(getXEIChance())); - } - return List.of(realStack); - } - - private List getXEIIngredients(CycleItemEntryHandler handler, int index) { - ItemEntryList entryList = handler.getEntry(index); - if (GTCEu.Mods.isJEILoaded()) { - return JEICallWrapper.getJEIIngredients(entryList, this::getRealStack); - } else if (GTCEu.Mods.isREILoaded()) { - return REICallWrapper.getREIIngredients(entryList, this::getRealStack); - } else if (GTCEu.Mods.isEMILoaded()) { - return EMICallWrapper.getEMIIngredients(entryList, getXEIChance(), this::getRealStack); - } - return Collections.emptyList(); - } - - private List getXEIIngredientsClickable(CycleItemEntryHandler handler, int index) { - ItemEntryList entryList = handler.getEntry(index); - if (GTCEu.Mods.isJEILoaded()) { - return JEICallWrapper.getJEIIngredientsClickable(entryList, getPosition(), getSize(), this::getRealStack); - } else if (GTCEu.Mods.isREILoaded()) { - return REICallWrapper.getREIIngredients(entryList, this::getRealStack); - } else if (GTCEu.Mods.isEMILoaded()) { - return EMICallWrapper.getEMIIngredients(entryList, getXEIChance(), this::getRealStack); - } - return Collections.emptyList(); - } - - public class WidgetSlotItemHandler extends Slot { - - private static final Container emptyInventory = new SimpleContainer(0); - @Getter - private final IItemHandlerModifiable itemHandler; - private final int index; - - public WidgetSlotItemHandler(IItemHandlerModifiable itemHandler, int index, int xPosition, int yPosition) { - super(emptyInventory, index, xPosition, yPosition); - this.itemHandler = itemHandler; - this.index = index; - } - - @Override - public boolean mayPlace(@NotNull ItemStack stack) { - return SlotWidget.this.canPutStack(stack) && - (!stack.isEmpty() && this.itemHandler.isItemValid(this.index, stack)); - } - - @Override - public boolean mayPickup(@Nullable Player playerIn) { - return SlotWidget.this.canTakeStack(playerIn) && !this.itemHandler.extractItem(index, 1, true).isEmpty(); - } - - @Override - @NotNull - public ItemStack getItem() { - return this.itemHandler.getStackInSlot(index); - } - - @Override - public void setByPlayer(@NotNull ItemStack stack) { - this.itemHandler.setStackInSlot(index, stack); - } - - @Override - public void set(@NotNull ItemStack stack) { - this.itemHandler.setStackInSlot(index, stack); - this.setChanged(); - } - - @Override - public void onQuickCraft(@NotNull ItemStack oldStackIn, @NotNull ItemStack newStackIn) {} - - @Override - public int getMaxStackSize() { - return this.itemHandler.getSlotLimit(this.index); - } - - @Override - public int getMaxStackSize(@NotNull ItemStack stack) { - ItemStack maxAdd = stack.copy(); - int maxInput = stack.getMaxStackSize(); - maxAdd.setCount(maxInput); - ItemStack currentStack = this.itemHandler.getStackInSlot(index); - this.itemHandler.setStackInSlot(index, ItemStack.EMPTY); - ItemStack remainder = this.itemHandler.insertItem(index, maxAdd, true); - this.itemHandler.setStackInSlot(index, currentStack); - return maxInput - remainder.getCount(); - } - - @NotNull - @Override - public ItemStack remove(int amount) { - var result = this.itemHandler.extractItem(index, amount, false); - if (changeListener != null && !getItem().isEmpty()) { - changeListener.run(); - } - return result; - } - - @Override - public void setChanged() { - if (changeListener != null) { - changeListener.run(); - } - SlotWidget.this.onSlotChanged(); - } - - @Override - public boolean isActive() { - return SlotWidget.this.isEnabled() && (HOVER_SLOT == null || HOVER_SLOT == this); - } - } - - public static final class JEICallWrapper { - - public static Object getJEIStackClickable(ItemStack stack, Position pos, Size size) { - return JEIPlugin.getItemIngredient(stack, pos.x, pos.y, size.width, size.height); - } - - public static List getJEIIngredients(ItemEntryList list, UnaryOperator realStack) { - return list.getStacks() - .stream() - .filter(stack -> !stack.isEmpty()) - .map(realStack) - .collect(Collectors.toList()); - } - - public static List getJEIIngredientsClickable(ItemEntryList list, Position pos, Size size, - UnaryOperator realStack) { - return list.getStacks() - .stream() - .filter(stack -> !stack.isEmpty()) - .map(realStack) - .map(stack -> getJEIStackClickable(stack, pos, size)) - .collect(Collectors.toList()); - } - } - - public static final class REICallWrapper { - - private static EntryIngredient toREIIngredient(Stream stream, UnaryOperator realStack) { - return EntryIngredient.of(stream.map(realStack) - .map(EntryStacks::of) - .toList()); - } - - public static List getREIIngredients(ItemStackList list, UnaryOperator realStack) { - return List.of(toREIIngredient(list.stream(), realStack)); - } - - public static List getREIIngredients(ItemTagList list, UnaryOperator realStack) { - return list.getEntries().stream() - .map(ItemTagList.ItemTagEntry::stacks) - .map(stream -> toREIIngredient(stream, realStack)) - .collect(Collectors.toList()); - } - - public static List getREIIngredients(ItemEntryList list, UnaryOperator realStack) { - if (list instanceof ItemTagList tagList) return getREIIngredients(tagList, realStack); - if (list instanceof ItemStackList stackList) return getREIIngredients(stackList, realStack); - return Collections.emptyList(); - } - } - - public static final class EMICallWrapper { - - private static EmiIngredient toEMIIngredient(Stream stream, UnaryOperator realStack) { - return EmiIngredient.of(stream.map(realStack).map(EmiStack::of).toList()); - } - - public static List getEMIIngredients(ItemStackList list, float xeiChance, - UnaryOperator realStack) { - return List.of(toEMIIngredient(list.stream(), realStack).setChance(xeiChance)); - } - - public static List getEMIIngredients(ItemTagList list, float xeiChance, - UnaryOperator realStack) { - return list.getEntries().stream() - .map(ItemTagList.ItemTagEntry::stacks) - .map(stream -> toEMIIngredient(stream, realStack).setChance(xeiChance)) - .collect(Collectors.toList()); - } - - public static List getEMIIngredients(ItemEntryList list, float xeiChance, - UnaryOperator realStack) { - if (list instanceof ItemTagList tagList) return getEMIIngredients(tagList, xeiChance, realStack); - if (list instanceof ItemStackList stackList) return getEMIIngredients(stackList, xeiChance, realStack); - return Collections.emptyList(); - } - } -} diff --git a/src/main/java/com/gregtechceu/gtceu/api/gui/widget/TankWidget.java b/src/main/java/com/gregtechceu/gtceu/api/gui/widget/TankWidget.java deleted file mode 100644 index 2e474162c67..00000000000 --- a/src/main/java/com/gregtechceu/gtceu/api/gui/widget/TankWidget.java +++ /dev/null @@ -1,720 +0,0 @@ -package com.gregtechceu.gtceu.api.gui.widget; - -import com.gregtechceu.gtceu.GTCEu; -import com.gregtechceu.gtceu.api.machine.trait.NotifiableFluidTank; -import com.gregtechceu.gtceu.api.transfer.fluid.IFluidHandlerModifiable; -import com.gregtechceu.gtceu.client.TooltipsHandler; -import com.gregtechceu.gtceu.integration.recipeviewer.entry.fluid.FluidEntryList; -import com.gregtechceu.gtceu.integration.recipeviewer.entry.fluid.FluidStackList; -import com.gregtechceu.gtceu.integration.recipeviewer.entry.fluid.FluidTagList; -import com.gregtechceu.gtceu.integration.recipeviewer.handlers.fluid.CycleFluidEntryHandler; -import com.gregtechceu.gtceu.utils.FormattingUtil; -import com.gregtechceu.gtceu.utils.GTUtil; - -import com.lowdragmc.lowdraglib.gui.editor.annotation.Configurable; -import com.lowdragmc.lowdraglib.gui.editor.annotation.LDLRegister; -import com.lowdragmc.lowdraglib.gui.editor.configurator.ConfiguratorGroup; -import com.lowdragmc.lowdraglib.gui.editor.configurator.IConfigurableWidget; -import com.lowdragmc.lowdraglib.gui.editor.configurator.WrapperConfigurator; -import com.lowdragmc.lowdraglib.gui.ingredient.IRecipeIngredientSlot; -import com.lowdragmc.lowdraglib.gui.texture.IGuiTexture; -import com.lowdragmc.lowdraglib.gui.texture.ProgressTexture; -import com.lowdragmc.lowdraglib.gui.texture.ResourceBorderTexture; -import com.lowdragmc.lowdraglib.gui.util.DrawerHelper; -import com.lowdragmc.lowdraglib.gui.util.TextFormattingUtil; -import com.lowdragmc.lowdraglib.gui.widget.Widget; -import com.lowdragmc.lowdraglib.jei.ClickableIngredient; -import com.lowdragmc.lowdraglib.jei.IngredientIO; -import com.lowdragmc.lowdraglib.jei.JEIPlugin; -import com.lowdragmc.lowdraglib.side.fluid.forge.FluidHelperImpl; -import com.lowdragmc.lowdraglib.utils.Position; -import com.lowdragmc.lowdraglib.utils.Size; - -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.Font; -import net.minecraft.client.gui.GuiGraphics; -import net.minecraft.nbt.CompoundTag; -import net.minecraft.network.FriendlyByteBuf; -import net.minecraft.network.chat.Component; -import net.minecraft.sounds.SoundEvent; -import net.minecraft.sounds.SoundEvents; -import net.minecraft.sounds.SoundSource; -import net.minecraft.world.entity.player.Player; -import net.minecraft.world.item.ItemStack; -import net.minecraft.world.level.material.Fluids; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.api.distmarker.OnlyIn; -import net.minecraftforge.common.SoundActions; -import net.minecraftforge.fluids.FluidActionResult; -import net.minecraftforge.fluids.FluidStack; -import net.minecraftforge.fluids.FluidUtil; -import net.minecraftforge.fluids.capability.IFluidHandler; -import net.minecraftforge.fluids.capability.templates.FluidTank; - -import com.mojang.blaze3d.systems.RenderSystem; -import dev.emi.emi.api.forge.ForgeEmiStack; -import dev.emi.emi.api.stack.EmiIngredient; -import lombok.Getter; -import lombok.Setter; -import lombok.experimental.Accessors; -import me.shedaniel.rei.api.common.entry.EntryIngredient; -import me.shedaniel.rei.api.common.util.EntryStacks; -import mezz.jei.api.helpers.IPlatformFluidHelper; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.function.BiConsumer; -import java.util.stream.Collectors; -import java.util.stream.Stream; - -@SuppressWarnings("unused") -@LDLRegister(name = "gtm_fluid_slot", group = "widget.gtm_container", priority = 50) -@Accessors(chain = true) -public class TankWidget extends Widget implements IRecipeIngredientSlot, IConfigurableWidget { - - public final static ResourceBorderTexture FLUID_SLOT_TEXTURE = new ResourceBorderTexture( - "ldlib:textures/gui/fluid_slot.png", 18, 18, 1, 1); - - @Nullable - @Getter - protected IFluidHandler fluidTank; - @Getter - protected int tank; - @Configurable(name = "ldlib.gui.editor.name.showAmount") - @Setter - protected boolean showAmount; - @Configurable(name = "ldlib.gui.editor.name.allowClickFilled") - @Setter - protected boolean allowClickFilled; - @Configurable(name = "ldlib.gui.editor.name.allowClickDrained") - @Setter - protected boolean allowClickDrained; - @Configurable(name = "ldlib.gui.editor.name.drawHoverOverlay") - @Setter - public boolean drawHoverOverlay = true; - @Configurable(name = "ldlib.gui.editor.name.drawHoverTips") - @Setter - protected boolean drawHoverTips; - @Configurable(name = "ldlib.gui.editor.name.fillDirection") - @Setter - protected ProgressTexture.FillDirection fillDirection = ProgressTexture.FillDirection.ALWAYS_FULL; - @Setter - protected BiConsumer> onAddedTooltips; - @Setter - @Getter - protected IngredientIO ingredientIO = IngredientIO.RENDER_ONLY; - @Setter - @Getter - protected float XEIChance = 1f; - protected FluidStack lastFluidInTank; - protected int lastTankCapacity; - @Setter - protected Runnable changeListener; - @Setter - protected boolean showAmountOverlay = true; - - public TankWidget() { - this(null, 0, 0, 18, 18, true, true); - } - - @Override - public void initTemplate() { - setBackground(FLUID_SLOT_TEXTURE); - setFillDirection(ProgressTexture.FillDirection.DOWN_TO_UP); - } - - public TankWidget(IFluidHandler fluidTank, int x, int y, boolean allowClickContainerFilling, - boolean allowClickContainerEmptying) { - this(fluidTank, x, y, 18, 18, allowClickContainerFilling, allowClickContainerEmptying); - } - - public TankWidget(@Nullable IFluidHandler fluidTank, int x, int y, int width, int height, - boolean allowClickContainerFilling, boolean allowClickContainerEmptying) { - super(new Position(x, y), new Size(width, height)); - setFluidTank(fluidTank, 0); - this.showAmount = true; - this.allowClickFilled = allowClickContainerFilling; - this.allowClickDrained = allowClickContainerEmptying; - this.drawHoverTips = true; - } - - public TankWidget(IFluidHandler fluidHandler, int tank, int x, int y, boolean allowClickContainerFilling, - boolean allowClickContainerEmptying) { - this(fluidHandler, tank, x, y, 18, 18, allowClickContainerFilling, allowClickContainerEmptying); - } - - public TankWidget(@Nullable IFluidHandler fluidHandler, int tank, int x, int y, int width, int height, - boolean allowClickContainerFilling, boolean allowClickContainerEmptying) { - super(new Position(x, y), new Size(width, height)); - setFluidTank(fluidHandler, tank); - this.showAmount = true; - this.allowClickFilled = allowClickContainerFilling; - this.allowClickDrained = allowClickContainerEmptying; - this.drawHoverTips = true; - } - - public TankWidget setFluidTank(IFluidHandler fluidTank) { - return setFluidTank(fluidTank, 0); - } - - public TankWidget setFluidTank(IFluidHandler fluidTank, int tank) { - if (fluidTank instanceof NotifiableFluidTank notifiable) { - this.fluidTank = notifiable.getStorages()[tank]; - this.tank = 0; - } else { - this.fluidTank = fluidTank; - this.tank = tank; - } - if (isClientSideWidget) { - setClientSideWidget(); - } - return this; - } - - // for kjs - public FluidStack getFluid() { - if (isClientSideWidget || isRemote()) { - return lastFluidInTank == null ? FluidStack.EMPTY : lastFluidInTank; - } - return fluidTank != null ? fluidTank.getFluidInTank(tank) : FluidStack.EMPTY; - } - - public TankWidget setFluid(FluidStack fluidStack) { - return setFluid(fluidStack, true); - } - - public TankWidget setFluid(FluidStack fluidStack, boolean notify) { - if (fluidTank instanceof IFluidHandlerModifiable modifiable) { - modifiable.setFluidInTank(tank, fluidStack); - if (notify) { - detectAndSendChanges(); - } - } - return this; - } - - @Override - public TankWidget setClientSideWidget() { - super.setClientSideWidget(); - if (fluidTank != null) { - this.lastFluidInTank = fluidTank.getFluidInTank(tank).copy(); - } else { - this.lastFluidInTank = null; - } - this.lastTankCapacity = fluidTank != null ? fluidTank.getTankCapacity(tank) : 0; - return this; - } - - public TankWidget setBackground(IGuiTexture background) { - super.setBackground(background); - return this; - } - - @Nullable - @Override - public Object getXEIIngredientOverMouse(double mouseX, double mouseY) { - if (self().isMouseOverElement(mouseX, mouseY)) { - if (lastFluidInTank == null || lastFluidInTank.isEmpty()) return null; - - if (fluidTank instanceof CycleFluidEntryHandler entryHandler) { - return getXEIIngredientsClickable(entryHandler, tank).get(0); - } - - if (GTCEu.Mods.isJEILoaded()) { - return JEICallWrapper.getJEIFluidClickable(lastFluidInTank, getPosition(), getSize()); - } else if (GTCEu.Mods.isREILoaded()) { - return EntryStacks.of(REICallWrapper.toREIStack(lastFluidInTank)); - } else if (GTCEu.Mods.isEMILoaded()) { - return ForgeEmiStack.of(lastFluidInTank).setChance(XEIChance); - } - } - return null; - } - - @Override - public List getXEIIngredients() { - if (lastFluidInTank == null || lastFluidInTank.isEmpty()) return Collections.emptyList(); - - if (fluidTank instanceof CycleFluidEntryHandler entryHandler) { - return getXEIIngredientsClickable(entryHandler, tank); - } - - if (GTCEu.Mods.isJEILoaded()) { - return List.of(JEICallWrapper.getJEIFluidClickable(lastFluidInTank, getPosition(), getSize())); - } else if (GTCEu.Mods.isREILoaded()) { - return List.of(EntryStacks.of(REICallWrapper.toREIStack(lastFluidInTank))); - } else if (GTCEu.Mods.isEMILoaded()) { - return List.of(ForgeEmiStack.of(lastFluidInTank).setChance(XEIChance)); - } - return List.of(lastFluidInTank); - } - - private List getXEIIngredients(CycleFluidEntryHandler handler, int index) { - FluidEntryList entryList = handler.getEntry(index); - if (GTCEu.Mods.isJEILoaded()) { - return JEICallWrapper.getJEIIngredients(entryList); - } else if (GTCEu.Mods.isREILoaded()) { - return REICallWrapper.getREIIngredients(entryList); - } else if (GTCEu.Mods.isEMILoaded()) { - return EMICallWrapper.getEMIIngredients(entryList, getXEIChance()); - } - return Collections.emptyList(); - } - - private List getXEIIngredientsClickable(CycleFluidEntryHandler handler, int index) { - FluidEntryList entryList = handler.getEntry(index); - if (GTCEu.Mods.isJEILoaded()) { - return JEICallWrapper.getJEIIngredientsClickable(entryList, getPosition(), getSize()); - } else if (GTCEu.Mods.isREILoaded()) { - return REICallWrapper.getREIIngredients(entryList); - } else if (GTCEu.Mods.isEMILoaded()) { - return EMICallWrapper.getEMIIngredients(entryList, getXEIChance()); - } - return Collections.emptyList(); - } - - @Override - public List getTooltipTexts() { - List tooltips = getAdditionalTooltips(new ArrayList<>()); - tooltips.addAll(tooltipTexts); - return tooltips; - } - - public List getAdditionalTooltips(List list) { - if (this.onAddedTooltips != null) { - this.onAddedTooltips.accept(this, list); - } - return list; - } - - @Override - public List getFullTooltipTexts() { - List tooltips = new ArrayList<>(); - boolean isPhantom = this instanceof PhantomFluidWidget; - var fluidStack = this.lastFluidInTank; - if (fluidStack != null && !fluidStack.isEmpty()) { - tooltips.add(fluidStack.getDisplayName()); - if (!isPhantom && showAmount) { - tooltips.add( - Component.translatable("gtceu.fluid.amount", - FormattingUtil.formatNumbers(fluidStack.getAmount()), - FormattingUtil.formatNumbers(lastTankCapacity))); - } - TooltipsHandler.appendFluidTooltips(fluidStack, tooltips::add, null); - } else { - tooltips.add(Component.translatable("gtceu.fluid.empty")); - if (!isPhantom && showAmount) { - tooltips.add(Component.translatable("gtceu.fluid.amount", 0, - FormattingUtil.formatNumbers(lastTankCapacity))); - } - } - tooltips.addAll(getTooltipTexts()); - return tooltips; - } - - @Override - public Object getXEICurrentIngredient() { - if (lastFluidInTank == null || lastFluidInTank.isEmpty()) return null; - if (GTCEu.Mods.isJEILoaded()) { - return JEICallWrapper.getJEIFluidClickable(lastFluidInTank, getPosition(), getSize()); - } - return null; - } - - @Override - @OnlyIn(Dist.CLIENT) - public void drawInBackground(@NotNull GuiGraphics graphics, int mouseX, int mouseY, float partialTicks) { - super.drawInBackground(graphics, mouseX, mouseY, partialTicks); - if (isClientSideWidget && fluidTank != null) { - FluidStack fluidStack = fluidTank.getFluidInTank(tank); - int capacity = fluidTank.getTankCapacity(tank); - if (capacity != lastTankCapacity) { - this.lastTankCapacity = capacity; - } - if (!fluidStack.isFluidEqual(lastFluidInTank)) { - this.lastFluidInTank = fluidStack.copy(); - } else if (fluidStack.getAmount() != lastFluidInTank.getAmount()) { - this.lastFluidInTank.setAmount(fluidStack.getAmount()); - } - } - Position pos = getPosition(); - Size size = getSize(); - var renderedFluid = lastFluidInTank; - if (renderedFluid != null) { - RenderSystem.disableBlend(); - if (!renderedFluid.isEmpty()) { - double progress = renderedFluid.getAmount() * 1.0 / - Math.max(Math.max(renderedFluid.getAmount(), lastTankCapacity), 1); - float drawnU = (float) fillDirection.getDrawnU(progress); - float drawnV = (float) fillDirection.getDrawnV(progress); - float drawnWidth = (float) fillDirection.getDrawnWidth(progress); - float drawnHeight = (float) fillDirection.getDrawnHeight(progress); - int width = size.width - 2; - int height = size.height - 2; - int x = pos.x + 1; - int y = pos.y + 1; - DrawerHelper.drawFluidForGui(graphics, FluidHelperImpl.toFluidStack(renderedFluid), - renderedFluid.getAmount(), (int) (x + drawnU * width), (int) (y + drawnV * height), - ((int) (width * drawnWidth)), ((int) (height * drawnHeight))); - } - - if (showAmount && showAmountOverlay && !renderedFluid.isEmpty()) { - graphics.pose().pushPose(); - graphics.pose().scale(0.5F, 0.5F, 1); - String s = TextFormattingUtil.formatLongToCompactStringBuckets(renderedFluid.getAmount(), 3) + "B"; - Font fontRenderer = Minecraft.getInstance().font; - graphics.drawString(fontRenderer, s, - (int) ((pos.x + (size.width / 3f)) * 2 - fontRenderer.width(s) + 21), - (int) ((pos.y + (size.height / 3f) + 6) * 2), 0xFFFFFF, true); - graphics.pose().popPose(); - } - - RenderSystem.enableBlend(); - RenderSystem.setShaderColor(1, 1, 1, 1); - } - drawOverlay(graphics, mouseX, mouseY, partialTicks); - if (drawHoverOverlay && isMouseOverElement(mouseX, mouseY) && getHoverElement(mouseX, mouseY) == this) { - RenderSystem.colorMask(true, true, true, false); - DrawerHelper.drawSolidRect(graphics, getPosition().x + 1, getPosition().y + 1, getSize().width - 2, - getSize().height - 2, 0x80FFFFFF); - RenderSystem.colorMask(true, true, true, true); - } - } - - @Override - @OnlyIn(Dist.CLIENT) - public void drawInForeground(@NotNull GuiGraphics graphics, int mouseX, int mouseY, float partialTicks) { - if (drawHoverTips && isMouseOverElement(mouseX, mouseY) && getHoverElement(mouseX, mouseY) == this) { - if (gui != null) { - gui.getModularUIGui().setHoverTooltip(getFullTooltipTexts(), ItemStack.EMPTY, null, null); - } - RenderSystem.setShaderColor(1.0f, 1.0f, 1.0f, 1f); - } else { - super.drawInForeground(graphics, mouseX, mouseY, partialTicks); - } - } - - @Override - public void detectAndSendChanges() { - if (fluidTank != null) { - FluidStack fluidStack = fluidTank.getFluidInTank(tank); - int capacity = fluidTank.getTankCapacity(tank); - if (capacity != lastTankCapacity) { - this.lastTankCapacity = capacity; - writeUpdateInfo(0, buffer -> buffer.writeVarInt(lastTankCapacity)); - } - if (!fluidStack.isFluidEqual(lastFluidInTank)) { - this.lastFluidInTank = fluidStack.copy(); - var tag = fluidStack.writeToNBT(new CompoundTag()); - writeUpdateInfo(2, buffer -> buffer.writeNbt(tag)); - } else if (fluidStack.getAmount() != lastFluidInTank.getAmount()) { - this.lastFluidInTank.setAmount(fluidStack.getAmount()); - writeUpdateInfo(3, buffer -> buffer.writeVarInt(lastFluidInTank.getAmount())); - } else { - super.detectAndSendChanges(); - return; - } - if (changeListener != null) { - changeListener.run(); - } - } - } - - @Override - public void writeInitialData(FriendlyByteBuf buffer) { - buffer.writeBoolean(fluidTank != null); - if (fluidTank != null) { - this.lastTankCapacity = fluidTank.getTankCapacity(tank); - buffer.writeVarInt(lastTankCapacity); - FluidStack fluidStack = fluidTank.getFluidInTank(tank); - this.lastFluidInTank = fluidStack.copy(); - var tag = fluidStack.writeToNBT(new CompoundTag()); - buffer.writeNbt(tag); - } - } - - @Override - public void readInitialData(FriendlyByteBuf buffer) { - if (buffer.readBoolean()) { - this.lastTankCapacity = buffer.readVarInt(); - readUpdateInfo(2, buffer); - } - } - - @Override - @OnlyIn(Dist.CLIENT) - public void readUpdateInfo(int id, FriendlyByteBuf buffer) { - if (id == 0) { - this.lastTankCapacity = buffer.readVarInt(); - } else if (id == 1) { - this.lastFluidInTank = null; - } else if (id == 2) { - this.lastFluidInTank = FluidStack.loadFluidStackFromNBT(buffer.readNbt()); - } else if (id == 3 && lastFluidInTank != null) { - this.lastFluidInTank.setAmount(buffer.readVarInt()); - } else if (id == 4) { - ItemStack currentStack = gui.getModularUIContainer().getCarried(); - int newStackSize = buffer.readVarInt(); - currentStack.setCount(newStackSize); - gui.getModularUIContainer().setCarried(currentStack); - } else { - super.readUpdateInfo(id, buffer); - return; - } - if (changeListener != null) { - changeListener.run(); - } - } - - @Override - public void handleClientAction(int id, FriendlyByteBuf buffer) { - super.handleClientAction(id, buffer); - if (id == 1) { - boolean isShiftKeyDown = buffer.readBoolean(); - int clickResult = tryClickContainer(isShiftKeyDown); - if (clickResult >= 0) { - writeUpdateInfo(4, buf -> buf.writeVarInt(clickResult)); - } - } - } - - private int tryClickContainer(boolean isShiftKeyDown) { - if (fluidTank == null) return -1; - Player player = gui.entityPlayer; - ItemStack currentStack = gui.getModularUIContainer().getCarried(); - var handler = FluidUtil.getFluidHandler(currentStack).resolve().orElse(null); - if (handler == null) return -1; - int maxAttempts = isShiftKeyDown ? currentStack.getCount() : 1; - FluidStack initialFluid = fluidTank.getFluidInTank(tank).copy(); - if (allowClickFilled && initialFluid.getAmount() > 0) { - boolean performedFill = false; - ItemStack filledResult = ItemStack.EMPTY; - for (int i = 0; i < maxAttempts; i++) { - FluidActionResult result = FluidUtil.tryFillContainer(currentStack, fluidTank, Integer.MAX_VALUE, null, - false); - if (!result.isSuccess()) break; - ItemStack remainingStack = FluidUtil - .tryFillContainer(currentStack, fluidTank, Integer.MAX_VALUE, null, true).getResult(); - performedFill = true; - - currentStack.shrink(1); - - if (filledResult.isEmpty()) { - filledResult = remainingStack.copy(); - } else if (GTUtil.isSameItemSameTags(filledResult, remainingStack)) { - if (filledResult.getCount() < filledResult.getMaxStackSize()) - filledResult.grow(1); - else - player.getInventory().placeItemBackInInventory(remainingStack); - } else { - player.getInventory().placeItemBackInInventory(filledResult); - filledResult = remainingStack.copy(); - } - } - if (performedFill) { - SoundEvent soundevent = initialFluid.getFluid().getFluidType().getSound(initialFluid, - SoundActions.BUCKET_FILL); - if (soundevent == null) - soundevent = SoundEvents.BUCKET_FILL; - player.level().playSound(null, player.position().x, player.position().y + 0.5, player.position().z, - soundevent, SoundSource.BLOCKS, 1.0F, 1.0F); - - if (currentStack.isEmpty()) { - gui.getModularUIContainer().setCarried(filledResult); - } else { - gui.getModularUIContainer().setCarried(currentStack); - player.getInventory().placeItemBackInInventory(filledResult); - } - return gui.getModularUIContainer().getCarried().getCount(); - } - } - - if (allowClickDrained) { - boolean performedEmptying = false; - ItemStack drainedResult = ItemStack.EMPTY; - for (int i = 0; i < maxAttempts; i++) { - int remainingCapacity = fluidTank.getTankCapacity(tank) - fluidTank.getFluidInTank(tank).getAmount(); - FluidActionResult result = FluidUtil.tryEmptyContainer(currentStack, fluidTank, remainingCapacity, null, - false); - if (!result.isSuccess()) break; - - ItemStack remainingStack = FluidUtil - .tryEmptyContainer(currentStack, fluidTank, remainingCapacity, null, true) - .getResult(); - performedEmptying = true; - - currentStack.shrink(1); - - if (drainedResult.isEmpty()) { - drainedResult = remainingStack.copy(); - } else if (GTUtil.isSameItemSameTags(drainedResult, remainingStack)) { - if (drainedResult.getCount() < drainedResult.getMaxStackSize()) - drainedResult.grow(1); - else - player.getInventory().placeItemBackInInventory(remainingStack); - } else { - player.getInventory().placeItemBackInInventory(drainedResult); - drainedResult = remainingStack.copy(); - } - } - var filledFluid = fluidTank.getFluidInTank(tank); - if (performedEmptying) { - SoundEvent soundevent = filledFluid.getFluid().getFluidType().getSound(filledFluid, - SoundActions.BUCKET_EMPTY); - if (soundevent == null) - soundevent = SoundEvents.BUCKET_EMPTY; - player.level().playSound(null, player.position().x, player.position().y + 0.5, player.position().z, - soundevent, SoundSource.BLOCKS, 1.0F, 1.0F); - - if (currentStack.isEmpty()) { - gui.getModularUIContainer().setCarried(drainedResult); - } else { - gui.getModularUIContainer().setCarried(currentStack); - player.getInventory().placeItemBackInInventory(drainedResult); - } - return gui.getModularUIContainer().getCarried().getCount(); - } - } - - return -1; - } - - @OnlyIn(Dist.CLIENT) - public boolean mouseClicked(double mouseX, double mouseY, int button) { - if ((allowClickDrained || allowClickFilled) && isMouseOverElement(mouseX, mouseY)) { - if (button == 0) { - if (FluidUtil.getFluidHandler(gui.getModularUIContainer().getCarried()).isPresent()) { - boolean isShiftKeyDown = isShiftDown(); - writeClientAction(1, writer -> writer.writeBoolean(isShiftKeyDown)); - playButtonClickSound(); - return true; - } - } - } - return false; - } - - @Override - public void buildConfigurator(ConfiguratorGroup father) { - var handler = new FluidTank(5000); - handler.fill(new FluidStack(Fluids.WATER, 3000), IFluidHandler.FluidAction.EXECUTE); - father.addConfigurators(new WrapperConfigurator("ldlib.gui.editor.group.preview", new TankWidget() { - - @Override - public void updateScreen() { - super.updateScreen(); - setHoverTooltips(TankWidget.this.tooltipTexts); - this.backgroundTexture = TankWidget.this.backgroundTexture; - this.hoverTexture = TankWidget.this.hoverTexture; - this.showAmount = TankWidget.this.showAmount; - this.drawHoverTips = TankWidget.this.drawHoverTips; - this.fillDirection = TankWidget.this.fillDirection; - this.overlay = TankWidget.this.overlay; - } - }.setAllowClickDrained(false).setAllowClickFilled(false).setFluidTank(handler))); - - IConfigurableWidget.super.buildConfigurator(father); - } - - /** - * Wrapper for methods that use JEI classes so that classloading doesn't brick itself. - */ - public static final class JEICallWrapper { - - public static List getJEIIngredients(FluidEntryList list) { - return list.getStacks() - .stream() - .filter(stack -> !stack.isEmpty()) - .map(JEICallWrapper::getJEIFluid) - .toList(); - } - - public static List getJEIIngredientsClickable(FluidEntryList list, Position pos, Size size) { - return list.getStacks() - .stream() - .filter(stack -> !stack.isEmpty()) - .map(stack -> getJEIFluidClickable(stack, pos, size)) - .toList(); - } - - public static Object getJEIFluid(FluidStack fluidStack) { - return _getJEIFluid(JEIPlugin.jeiHelpers.getPlatformFluidHelper(), fluidStack); - } - - private static Object _getJEIFluid(IPlatformFluidHelper helper, FluidStack fluidStack) { - return helper.create(fluidStack.getFluid(), fluidStack.getAmount(), fluidStack.getTag()); - } - - public static Object getJEIFluidClickable(FluidStack fluidStack, Position pos, Size size) { - return _getJEIFluidClickable(JEIPlugin.jeiHelpers.getPlatformFluidHelper(), fluidStack, pos, - size); - } - - private static Object _getJEIFluidClickable(IPlatformFluidHelper helper, - FluidStack fluidStack, Position pos, Size size) { - T ingredient = helper.create(fluidStack.getFluid(), fluidStack.getAmount(), fluidStack.getTag()); - return JEIPlugin.jeiHelpers.getIngredientManager().createTypedIngredient(ingredient) - .map(typedIngredient -> new ClickableIngredient<>(typedIngredient, pos.x, pos.y, size.width, - size.height)) - .orElse(null); - } - } - - public static final class REICallWrapper { - - public static dev.architectury.fluid.FluidStack toREIStack(FluidStack stack) { - return dev.architectury.fluid.FluidStack.create(stack.getFluid(), stack.getAmount(), stack.getTag()); - } - - private static EntryIngredient toREIIngredient(Stream stream) { - return EntryIngredient.of(stream - .map(REICallWrapper::toREIStack) - .map(EntryStacks::of) - .toList()); - } - - public static List getREIIngredients(FluidStackList list) { - return List.of(toREIIngredient(list.stream())); - } - - public static List getREIIngredients(FluidTagList list) { - return list.getEntries().stream() - .map(FluidTagList.FluidTagEntry::stacks) - .map(REICallWrapper::toREIIngredient) - .collect(Collectors.toList()); - } - - public static List getREIIngredients(FluidEntryList list) { - if (list instanceof FluidTagList tagList) return getREIIngredients(tagList); - if (list instanceof FluidStackList stackList) return getREIIngredients(stackList); - return Collections.emptyList(); - } - } - - public static final class EMICallWrapper { - - private static EmiIngredient toEMIIngredient(Stream stream) { - return EmiIngredient.of(stream.map(ForgeEmiStack::of).toList()); - } - - public static List getEMIIngredients(FluidStackList list, float xeiChance) { - return List.of(toEMIIngredient(list.stream()).setChance(xeiChance)); - } - - public static List getEMIIngredients(FluidTagList list, float xeiChance) { - return list.getEntries().stream() - .map(FluidTagList.FluidTagEntry::stacks) - .map(stream -> toEMIIngredient(stream).setChance(xeiChance)) - .collect(Collectors.toList()); - } - - public static List getEMIIngredients(FluidEntryList list, float xeiChance) { - if (list instanceof FluidTagList tagList) return getEMIIngredients(tagList, xeiChance); - if (list instanceof FluidStackList stackList) return getEMIIngredients(stackList, xeiChance); - return Collections.emptyList(); - } - } -} diff --git a/src/main/java/com/gregtechceu/gtceu/api/item/tool/ToolHelper.java b/src/main/java/com/gregtechceu/gtceu/api/item/tool/ToolHelper.java index ab2cdcdcbc9..494b12351e0 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/item/tool/ToolHelper.java +++ b/src/main/java/com/gregtechceu/gtceu/api/item/tool/ToolHelper.java @@ -436,14 +436,14 @@ public static void applyHammerDropConversion(ServerLevel world, BlockPos pos, It if (prefix.isEmpty()) { for (Content output : hammerRecipe.getOutputContents(ItemRecipeCapability.CAP)) { if (dropChance >= 1.0F || random.nextFloat() <= dropChance) { - drops.add(SizedIngredient.copy(ItemRecipeCapability.CAP.of(output.content)) + drops.add(SizedIngredient.copy(ItemRecipeCapability.CAP.of(output.content())) .getItems()[0]); } } } else if (TagPrefix.ORES.containsKey(prefix)) { for (Content content : hammerRecipe.getOutputContents(ItemRecipeCapability.CAP)) { if (dropChance >= 1.0F || random.nextFloat() <= dropChance) { - ItemStack output = ItemRecipeCapability.CAP.of(content.content).getItems()[0]; + ItemStack output = ItemRecipeCapability.CAP.of(content.content()).getItems()[0]; // Only apply fortune on ore -> crushed forge hammer recipes if (ChemicalHelper.getPrefix(output.getItem()) == TagPrefix.crushed) { output = output.copy(); diff --git a/src/main/java/com/gregtechceu/gtceu/api/machine/feature/IMuiMachine.java b/src/main/java/com/gregtechceu/gtceu/api/machine/feature/IMuiMachine.java index 5da6b7a5d9f..a8a7fa36a3d 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/machine/feature/IMuiMachine.java +++ b/src/main/java/com/gregtechceu/gtceu/api/machine/feature/IMuiMachine.java @@ -28,7 +28,7 @@ default ModularPanel buildUI(PosGuiData data, PanelSyncManager syncManager, U } default MachineUIPanelBuilder getPanelBuilder(PosGuiData data, PanelSyncManager syncManager, UISettings settings) { - return MachineUIPanelBuilder.defaultPanelBuilder(self()); + return MachineUIPanelBuilder.panelBuilder(self()); } default void buildMainUI(ParentWidget mainWidget, PosGuiData guiData, PanelSyncManager syncManager, diff --git a/src/main/java/com/gregtechceu/gtceu/api/machine/mui/MachineUIPanelBuilder.java b/src/main/java/com/gregtechceu/gtceu/api/machine/mui/MachineUIPanelBuilder.java index 281b261be04..c9232c4b1c4 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/machine/mui/MachineUIPanelBuilder.java +++ b/src/main/java/com/gregtechceu/gtceu/api/machine/mui/MachineUIPanelBuilder.java @@ -28,6 +28,9 @@ public class MachineUIPanelBuilder { * Should the GregTech logo be drawn in the bottom right corner of the panel. */ private boolean drawGTLogo = false; + /** + * The texture to use for the GregTech logo. + */ private UITexture gtLogoTexture = GTGuiTextures.GREGTECH_LOGO; /** * Should the player inventory be attached to the bottom of the panel. @@ -98,15 +101,11 @@ public MachineUIPanel build(PanelSyncManager syncManager, UISettings settings) { return panel; } - public static MachineUIPanelBuilder defaultSimpleSingleblockPanelBuilder(MetaMachine machine) { - return new MachineUIPanelBuilder(machine).drawGTLogo(true); - } - - public static MachineUIPanelBuilder defaultPanelBuilder(MetaMachine machine) { + public static MachineUIPanelBuilder panelBuilder(MetaMachine machine) { return new MachineUIPanelBuilder(machine); } - public static MachineUIPanelBuilder defaultSteamMachineBuilder(MetaMachine machine) { + public static MachineUIPanelBuilder defaultSteamMachinePanelBuilder(MetaMachine machine) { return new MachineUIPanelBuilder(machine).drawGTLogo(true).addDefaultConfigurators(false) .addTraitConfigurators(false); } diff --git a/src/main/java/com/gregtechceu/gtceu/api/machine/multiblock/MultiblockDisplayText.java b/src/main/java/com/gregtechceu/gtceu/api/machine/multiblock/MultiblockDisplayText.java index 1b9abeb2afa..623c907ae0b 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/machine/multiblock/MultiblockDisplayText.java +++ b/src/main/java/com/gregtechceu/gtceu/api/machine/multiblock/MultiblockDisplayText.java @@ -439,27 +439,27 @@ public Builder addOutputLines(GTRecipe recipe) { double countD = 1; // number of items output which is actually displayed. Can be either a number, or a range. Component displaycount; - if (item.content instanceof IntProviderIngredient provider) { + if (item.content() instanceof IntProviderIngredient provider) { rounded = true; stack = provider.getMaxSizeStack(); displaycount = Component.translatable("gtceu.gui.content.range", provider.getCountProvider().getMinValue(), provider.getCountProvider().getMaxValue()); - if (item.chance < item.maxChance) { + if (item.chance() < item.maxChance()) { countD = countD * runs * function.getBoostedChance(item, recipeTier, chanceTier) / - item.maxChance; + item.maxChance(); } countD = countD * provider.getMidRoll(); } else { - var stacks = ItemRecipeCapability.CAP.of(item.content).getItems(); + var stacks = ItemRecipeCapability.CAP.of(item.content()).getItems(); if (stacks.length == 0) continue; stack = stacks[0]; count = stack.getCount(); countD *= count; - if (item.chance < item.maxChance) { + if (item.chance() < item.maxChance()) { rounded = true; countD = countD * runs * function.getBoostedChance(item, recipeTier, chanceTier) / - item.maxChance; + item.maxChance(); } count = Math.max(1, (int) Math.round(countD)); displaycount = Component.literal(String.valueOf(count)); @@ -483,27 +483,27 @@ public Builder addOutputLines(GTRecipe recipe) { double amountD = 1; // amount of fluid output which is actually displayed. Can be either a number, or a range. Component displaycount; - if (fluid.content instanceof IntProviderFluidIngredient provider) { + if (fluid.content() instanceof IntProviderFluidIngredient provider) { rounded = true; stack = provider.getMaxSizeStack(); displaycount = Component.translatable("gtceu.gui.content.range", provider.getCountProvider().getMinValue(), provider.getCountProvider().getMaxValue()); - if (fluid.chance < fluid.maxChance) { + if (fluid.chance() < fluid.maxChance()) { amountD = amountD * runs * function.getBoostedChance(fluid, recipeTier, chanceTier) / - fluid.maxChance; + fluid.maxChance(); } amountD = amountD * provider.getMidRoll(); } else { - var stacks = FluidRecipeCapability.CAP.of(fluid.content).getStacks(); + var stacks = FluidRecipeCapability.CAP.of(fluid.content()).getStacks(); if (stacks.length == 0) continue; stack = stacks[0]; amount = stack.getAmount(); amountD *= amount; - if (fluid.chance < fluid.maxChance) { + if (fluid.chance() < fluid.maxChance()) { rounded = true; amountD = amountD * runs * function.getBoostedChance(fluid, recipeTier, chanceTier) / - fluid.maxChance; + fluid.maxChance(); } amount = Math.max(1, (int) Math.round(amountD)); displaycount = Component.literal(String.valueOf(amount)); diff --git a/src/main/java/com/gregtechceu/gtceu/api/machine/multiblock/WorkableElectricMultiblockMachine.java b/src/main/java/com/gregtechceu/gtceu/api/machine/multiblock/WorkableElectricMultiblockMachine.java index 626d931cf2d..e5fbd433338 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/machine/multiblock/WorkableElectricMultiblockMachine.java +++ b/src/main/java/com/gregtechceu/gtceu/api/machine/multiblock/WorkableElectricMultiblockMachine.java @@ -1,5 +1,6 @@ package com.gregtechceu.gtceu.api.machine.multiblock; +import brachy.modularui.api.drawable.Text; import com.gregtechceu.gtceu.api.GTValues; import com.gregtechceu.gtceu.api.blockentity.BlockEntityCreationInfo; import com.gregtechceu.gtceu.api.capability.IEnergyContainer; @@ -106,6 +107,7 @@ public Widget getMainTextPanel(PanelSyncManager syncManager) { .height(MULTI_UI_TEXT_PANEL_HEIGHT - 6) .childSeparator(Icon.EMPTY_2PX) .crossAxisAlignment(Alignment.CrossAxis.START) + .collapseDisabledChildren() .posRel(Alignment.CenterLeft); parentWidget.size(MULTI_UI_TEXT_PANEL_WIDTH, MULTI_UI_TEXT_PANEL_HEIGHT).background(GuiTextures.DISPLAY); @@ -123,6 +125,7 @@ public void buildMainUI(ParentWidget mainWidget, PosGuiData guiData, PanelSyn @Override public List getWidgetsForDisplay(PanelSyncManager syncManager) { List widgets = new ArrayList<>(); + widgets.add(GTMultiblockTextUtil.addUnformedWarning(this, syncManager)); widgets.add(GTMultiblockTextUtil.addEnergyTierLine(this, syncManager)); widgets.add(GTMultiblockTextUtil.addEnergyUsageLine(this, syncManager)); widgets.addAll(super.getWidgetsForDisplay(syncManager)); diff --git a/src/main/java/com/gregtechceu/gtceu/api/machine/steam/SteamBoilerMachine.java b/src/main/java/com/gregtechceu/gtceu/api/machine/steam/SteamBoilerMachine.java index 2a39b698878..6d788931cc2 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/machine/steam/SteamBoilerMachine.java +++ b/src/main/java/com/gregtechceu/gtceu/api/machine/steam/SteamBoilerMachine.java @@ -36,7 +36,7 @@ import net.minecraftforge.fluids.FluidUtil; import net.minecraftforge.fluids.capability.IFluidHandler.FluidAction; -import brachy.modularui.api.drawable.IKey; +import brachy.modularui.api.drawable.Text; import brachy.modularui.drawable.UITexture; import brachy.modularui.factory.PosGuiData; import brachy.modularui.screen.UISettings; @@ -310,7 +310,7 @@ public InteractionResult onUseWithItem(ExtendedUseOnContext context) { @Override public MachineUIPanelBuilder getPanelBuilder(PosGuiData data, PanelSyncManager syncManager, UISettings settings) { - return MachineUIPanelBuilder.defaultSteamMachineBuilder(this); + return MachineUIPanelBuilder.defaultSteamMachinePanelBuilder(this); } @Override @@ -343,8 +343,8 @@ public void buildMainUI(ParentWidget mainWidget, PosGuiData guiData, PanelSyn .value(tempPercentage) .direction(ProgressWidget.Direction.UP) .tooltipAutoUpdate(true) - .tooltipBuilder((r) -> r.addLine(IKey - .lang(Component.translatable("gtceu.fluid.temperature", getCurrentTemperature())))))); + .tooltipBuilder((r) -> r.addLine(Text + .lang("gtceu.fluid.temperature", getCurrentTemperature()))))); } ////////////////////////////////////// @@ -380,7 +380,6 @@ protected void randomDisplayTick(RandomSource random, float x, float y, float z) getLevel().addParticle(ParticleTypes.FLAME, x, y, z, 0, 0, 0); } - @NotNull @Override public List getDataInfo(PortableScannerBehavior.DisplayMode mode) { if (mode == PortableScannerBehavior.DisplayMode.SHOW_ALL || diff --git a/src/main/java/com/gregtechceu/gtceu/api/mui/GTGuiScreen.java b/src/main/java/com/gregtechceu/gtceu/api/mui/GTGuiScreen.java index 8ee59062027..7367550d5ef 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/mui/GTGuiScreen.java +++ b/src/main/java/com/gregtechceu/gtceu/api/mui/GTGuiScreen.java @@ -2,8 +2,6 @@ import com.gregtechceu.gtceu.common.mui.GTGuiTheme; -import net.minecraft.client.gui.navigation.ScreenRectangle; - import brachy.modularui.screen.ModularPanel; import brachy.modularui.screen.ModularScreen; import org.jetbrains.annotations.NotNull; @@ -28,9 +26,4 @@ public GTGuiScreen(String owner, ModularPanel mainPanel, String themeId) { super(owner, mainPanel); useTheme(themeId); } - - @Override - public @NotNull ScreenRectangle getRectangle() { - return super.getRectangle(); - } } diff --git a/src/main/java/com/gregtechceu/gtceu/api/placeholder/PlaceholderHandler.java b/src/main/java/com/gregtechceu/gtceu/api/placeholder/PlaceholderHandler.java index fda0841178e..b02c293ac03 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/placeholder/PlaceholderHandler.java +++ b/src/main/java/com/gregtechceu/gtceu/api/placeholder/PlaceholderHandler.java @@ -21,13 +21,14 @@ import brachy.modularui.api.IPanelHandler; import brachy.modularui.api.drawable.IDrawable; -import brachy.modularui.api.drawable.IKey; +import brachy.modularui.api.drawable.Text; import brachy.modularui.api.value.IBoolValue; import brachy.modularui.api.value.IIntValue; import brachy.modularui.api.value.IStringValue; import brachy.modularui.drawable.GuiTextures; import brachy.modularui.screen.ModularPanel; import brachy.modularui.screen.RichTooltip; +import brachy.modularui.screen.viewport.GuiContext; import brachy.modularui.value.StringValue; import brachy.modularui.value.sync.*; import brachy.modularui.widgets.ButtonWidget; @@ -269,7 +270,7 @@ public static IPanelHandler createPlaceholderEditor(String name, PanelSyncManage i -> new ItemSlot() .slot(ctx.itemStackHandler(), i) .addTooltipLine( - IKey.lang("gtceu.gui.computer_monitor_cover.slot_tooltip", i)))) + Text.lang("gtceu.gui.computer_monitor_cover.slot_tooltip", i)))) .child(Flow.column() .widthRel(.8f) .padding(5) @@ -277,7 +278,7 @@ public static IPanelHandler createPlaceholderEditor(String name, PanelSyncManage .height(20) .childIf(scaleDouble != null, () -> new TextWidget<>( - IKey.lang("gtceu.gui.central_monitor.text_scale"))) + Text.lang("gtceu.gui.central_monitor.text_scale"))) .childIf(scaleDouble != null, () -> new TextFieldWidget() .setNumbersDouble(x -> Math.max(x, 0)) .setDefaultNumber(1.0) @@ -285,7 +286,7 @@ public static IPanelHandler createPlaceholderEditor(String name, PanelSyncManage .marginLeft(4)) .childIf(updateInterval != null, () -> new TextWidget<>( - IKey.lang("gtceu.gui.computer_monitor_cover.update_interval"))) + Text.lang("gtceu.gui.computer_monitor_cover.update_interval"))) .childIf(updateInterval != null, () -> new TextFieldWidget() .setNumbers(1, 1000) .setDefaultNumber(1) @@ -297,19 +298,19 @@ public static IPanelHandler createPlaceholderEditor(String name, PanelSyncManage .value(pause) .background(false, GuiTextures.PAUSE) .background(true, GuiTextures.PLAY) - .addTooltip(false, IKey.lang("gtceu.gui.central_monitor.pause")) - .addTooltip(true, IKey.lang("gtceu.gui.central_monitor.resume")) + .addTooltip(false, Text.lang("gtceu.gui.central_monitor.pause")) + .addTooltip(true, Text.lang("gtceu.gui.central_monitor.resume")) .margin(4)) .childIf(updateText != null, () -> new ButtonWidget<>() .background(GuiTextures.RIGHTLOAD) .hoverBackground(GuiTextures.RIGHTLOAD, new BorderDrawable()) - .addTooltipLine(IKey.lang("gtceu.gui.central_monitor.update_once")) + .addTooltipLine(Text.lang("gtceu.gui.central_monitor.update_once")) .syncHandler("run_code_sync_handler")) .child(new ButtonWidget<>() .background(GuiTextures.HELP) .hoverBackground(GuiTextures.HELP, new BorderDrawable()) .margin(4) - .onMousePressed((mouseX, mouseY, button) -> { + .onMousePressed((GuiContext context, int button) -> { helpPanel.openPanel(); return true; }))) @@ -335,7 +336,7 @@ public static IPanelHandler createPlaceholderEditor(String name, PanelSyncManage .getSingleOrMultiLang( "gtceu.placeholder_info." + w.getWidgetValue()) .stream() - .map(IKey::lang) + .map(Text::of) .map(key -> (IDrawable) key) .toList()))) .toList())))); @@ -346,7 +347,7 @@ public static ModularPanel createHelpPanel() { .size(500, 250) .child(Flow.column() .padding(5) - .child(new TextWidget<>(IKey.lang("gtceu.gui.central_monitor.text_module_help"))) + .child(new TextWidget<>(Text.lang("gtceu.gui.central_monitor.text_module_help"))) .child(new CodeEditorWidget<>(LANG_DEFINITION) .padding(5) .widthRel(.95f) diff --git a/src/main/java/com/gregtechceu/gtceu/api/recipe/GTRecipe.java b/src/main/java/com/gregtechceu/gtceu/api/recipe/GTRecipe.java index 66cdfb58639..762e6e5c463 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/recipe/GTRecipe.java +++ b/src/main/java/com/gregtechceu/gtceu/api/recipe/GTRecipe.java @@ -224,7 +224,7 @@ public ChanceLogic getChanceLogicForCapability(RecipeCapability cap, IO io, b if (outputs == null) return EnergyStack.EMPTY; long v = 0, a = 0; for (var content : outputs) { - EnergyStack stack = EURecipeCapability.CAP.of(content.content); + EnergyStack stack = EURecipeCapability.CAP.of(content.content()); v += stack.voltage(); a += stack.amperage(); } diff --git a/src/main/java/com/gregtechceu/gtceu/api/recipe/GTRecipeType.java b/src/main/java/com/gregtechceu/gtceu/api/recipe/GTRecipeType.java index dd3dbd2353a..3f09775a94c 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/recipe/GTRecipeType.java +++ b/src/main/java/com/gregtechceu/gtceu/api/recipe/GTRecipeType.java @@ -2,23 +2,15 @@ import com.gregtechceu.gtceu.GTCEu; import com.gregtechceu.gtceu.api.capability.recipe.*; -import com.gregtechceu.gtceu.api.gui.SteamTexture; import com.gregtechceu.gtceu.api.recipe.category.GTRecipeCategory; import com.gregtechceu.gtceu.api.recipe.chance.boost.ChanceBoostFunction; import com.gregtechceu.gtceu.api.recipe.gui.GTRecipeTypeUILayout; -import com.gregtechceu.gtceu.api.recipe.gui.GTRecipeTypeUIs; import com.gregtechceu.gtceu.api.recipe.lookup.RecipeAdditionHandler; import com.gregtechceu.gtceu.api.recipe.lookup.RecipeDB; -import com.gregtechceu.gtceu.api.recipe.ui.GTRecipeTypeUI; import com.gregtechceu.gtceu.api.sound.SoundEntry; import com.gregtechceu.gtceu.data.recipe.builder.GTRecipeBuilder; import com.gregtechceu.gtceu.utils.FormattingUtil; -import com.lowdragmc.lowdraglib.gui.texture.IGuiTexture; -import com.lowdragmc.lowdraglib.gui.texture.ProgressTexture; -import com.lowdragmc.lowdraglib.gui.texture.ResourceTexture; -import com.lowdragmc.lowdraglib.gui.widget.WidgetGroup; - import net.minecraft.core.RegistryAccess; import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.data.recipes.FinishedRecipe; @@ -55,9 +47,6 @@ public class GTRecipeType implements RecipeType { @Getter @Setter private ChanceBoostFunction chanceFunction = ChanceBoostFunction.NONE; - @Getter - @Setter - private GTRecipeTypeUI recipeUI = new GTRecipeTypeUI(this); @Setter @Getter private GTRecipeType smallRecipeMap; @@ -100,6 +89,9 @@ public class GTRecipeType implements RecipeType { @Getter private int minRecipeConditions = 0; + @Getter + private GTRecipeTypeUILayout uiLayout; + public GTRecipeType(ResourceLocation registryName, String group, RecipeType... proxyRecipes) { this.registryName = registryName; this.group = group; @@ -141,40 +133,11 @@ public GTRecipeType setMaxSize(IO io, RecipeCapability cap, int max) { } public GTRecipeType UI(UnaryOperator builder) { - var recipeLayout = builder.apply(new GTRecipeTypeUILayout.Builder()).build(); - recipeLayout.setRecipeType(this); - GTRecipeTypeUIs.addRecipeTypeUI(this, recipeLayout); - return this; - } - - public GTRecipeType setSlotOverlay(boolean isOutput, boolean isFluid, IGuiTexture slotOverlay) { - this.recipeUI.setSlotOverlay(isOutput, isFluid, slotOverlay); - return this; - } - - public GTRecipeType setSlotOverlay(boolean isOutput, boolean isFluid, boolean isLast, IGuiTexture slotOverlay) { - this.recipeUI.setSlotOverlay(isOutput, isFluid, isLast, slotOverlay); - return this; - } - - public GTRecipeType setProgressBar(ResourceTexture progressBar, ProgressTexture.FillDirection moveType) { - this.recipeUI.setProgressBar(progressBar, moveType); - return this; - } - - public GTRecipeType setSteamProgressBar(SteamTexture progressBar, ProgressTexture.FillDirection moveType) { - this.recipeUI.setSteamProgressBarTexture(progressBar); - this.recipeUI.setSteamMoveType(moveType); - return this; - } - - public GTRecipeType setUiBuilder(BiConsumer uiBuilder) { - this.recipeUI.setUiBuilder(uiBuilder); + uiLayout = builder.apply(new GTRecipeTypeUILayout.Builder(this)).build(); return this; } public GTRecipeType setMaxTooltips(int maxTooltips) { - this.recipeUI.setMaxTooltips(maxTooltips); return this; } @@ -183,11 +146,6 @@ public GTRecipeType setXEIVisible(boolean XEIVisible) { return this; } - public GTRecipeType addDataInfo(Function dataInfo) { - this.dataInfos.add(dataInfo); - return this; - } - public void setMinRecipeConditions(int n) { minRecipeConditions = Math.max(minRecipeConditions, n); } @@ -241,6 +199,10 @@ public int getMaxOutputs(RecipeCapability cap) { return maxOutputs.getOrDefault(cap, 0); } + public int getMaxSlots(RecipeCapability cap, IO io) { + return io == IO.IN ? getMaxInputs(cap) : getMaxOutputs(cap); + } + ////////////////////////////////////// // ***** Recipe Builder ******// ////////////////////////////////////// diff --git a/src/main/java/com/gregtechceu/gtceu/api/recipe/RecipeCondition.java b/src/main/java/com/gregtechceu/gtceu/api/recipe/RecipeCondition.java index 715e7b6e124..415faf761de 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/recipe/RecipeCondition.java +++ b/src/main/java/com/gregtechceu/gtceu/api/recipe/RecipeCondition.java @@ -3,16 +3,15 @@ import com.gregtechceu.gtceu.GTCEu; import com.gregtechceu.gtceu.api.machine.trait.RecipeLogic; import com.gregtechceu.gtceu.api.recipe.condition.RecipeConditionType; +import com.gregtechceu.gtceu.api.recipe.gui.RecipeUIModifier; import com.gregtechceu.gtceu.api.registry.GTRegistries; -import com.lowdragmc.lowdraglib.gui.texture.IGuiTexture; -import com.lowdragmc.lowdraglib.gui.texture.ResourceTexture; - import net.minecraft.nbt.NbtOps; import net.minecraft.network.FriendlyByteBuf; import net.minecraft.network.chat.Component; import net.minecraft.resources.RegistryOps; +import brachy.modularui.api.drawable.Text; import com.google.gson.JsonObject; import com.mojang.datafixers.Products; import com.mojang.serialization.Codec; @@ -55,25 +54,16 @@ public RecipeCondition(boolean isReverse) { public abstract RecipeConditionType getType(); - public String getTranslationKey() { - return "gtceu.recipe.condition." + getType(); - } - - public IGuiTexture getInValidTexture() { - return new ResourceTexture("gtceu:textures/gui/condition/" + getType() + ".png").getSubTexture(0, 0, 1, 0.5f); - } - - public IGuiTexture getValidTexture() { - return new ResourceTexture("gtceu:textures/gui/condition/" + getType() + ".png").getSubTexture(0, 0.5f, 1, - 0.5f); - } - public boolean isOr() { return false; } public abstract Component getTooltips(); + public RecipeUIModifier modifyUI() { + return RecipeUIModifier.textLine(Text.of(getTooltips())); + } + public boolean check(@NotNull GTRecipe recipe, @NotNull RecipeLogic recipeLogic) { boolean test = testCondition(recipe, recipeLogic); return test != isReverse; diff --git a/src/main/java/com/gregtechceu/gtceu/api/recipe/RecipeHelper.java b/src/main/java/com/gregtechceu/gtceu/api/recipe/RecipeHelper.java index fb84163e48e..37b4b511e86 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/recipe/RecipeHelper.java +++ b/src/main/java/com/gregtechceu/gtceu/api/recipe/RecipeHelper.java @@ -68,25 +68,25 @@ public static int getPreOCRecipeEuTier(GTRecipe recipe) { public static List getInputContents(GTRecipeBuilder builder, RecipeCapability capability) { return builder.input.getOrDefault(capability, Collections.emptyList()).stream() - .map(content -> capability.of(content.getContent())) + .map(content -> capability.of(content.content())) .collect(Collectors.toList()); } public static List getInputContents(GTRecipe recipe, RecipeCapability capability) { return recipe.getInputContents(capability).stream() - .map(content -> capability.of(content.getContent())) + .map(content -> capability.of(content.content())) .collect(Collectors.toList()); } public static List getOutputContents(GTRecipeBuilder builder, RecipeCapability capability) { return builder.output.getOrDefault(capability, Collections.emptyList()).stream() - .map(content -> capability.of(content.getContent())) + .map(content -> capability.of(content.content())) .collect(Collectors.toList()); } public static List getOutputContents(GTRecipe recipe, RecipeCapability capability) { return recipe.getOutputContents(capability).stream() - .map(content -> capability.of(content.getContent())) + .map(content -> capability.of(content.content())) .collect(Collectors.toList()); } @@ -105,7 +105,7 @@ public static List getOutputContents(GTRecipe recipe, RecipeCapability */ public static List getInputItems(GTRecipe recipe) { return recipe.getInputContents(ItemRecipeCapability.CAP).stream() - .map(content -> ItemRecipeCapability.CAP.of(content.getContent())) + .map(content -> ItemRecipeCapability.CAP.of(content.content())) .map(ingredient -> ingredient.getItems()[0]) .collect(Collectors.toList()); } @@ -118,7 +118,7 @@ public static List getInputItems(GTRecipe recipe) { */ public static List getInputFluids(GTRecipe recipe) { return recipe.getInputContents(FluidRecipeCapability.CAP).stream() - .map(content -> FluidRecipeCapability.CAP.of(content.getContent())) + .map(content -> FluidRecipeCapability.CAP.of(content.content())) .map(ingredient -> ingredient.getStacks()[0]) .collect(Collectors.toList()); } @@ -131,7 +131,7 @@ public static List getInputFluids(GTRecipe recipe) { */ public static List getOutputItems(GTRecipe recipe) { return recipe.getOutputContents(ItemRecipeCapability.CAP).stream() - .map(content -> ItemRecipeCapability.CAP.of(content.getContent())) + .map(content -> ItemRecipeCapability.CAP.of(content.content())) .map(ingredient -> ingredient.getItems()[0]) .collect(Collectors.toList()); } @@ -144,7 +144,7 @@ public static List getOutputItems(GTRecipe recipe) { */ public static List getOutputItems(GTRecipeBuilder builder) { return builder.output.getOrDefault(ItemRecipeCapability.CAP, Collections.emptyList()).stream() - .map(content -> ItemRecipeCapability.CAP.of(content.getContent())) + .map(content -> ItemRecipeCapability.CAP.of(content.content())) .map(ingredient -> ingredient.getItems()[0]) .collect(Collectors.toList()); } @@ -157,7 +157,7 @@ public static List getOutputItems(GTRecipeBuilder builder) { */ public static List getOutputFluids(GTRecipe recipe) { return recipe.getOutputContents(FluidRecipeCapability.CAP).stream() - .map(content -> FluidRecipeCapability.CAP.of(content.getContent())) + .map(content -> FluidRecipeCapability.CAP.of(content.content())) .map(ingredient -> ingredient.getStacks()[0]) .collect(Collectors.toList()); } @@ -170,7 +170,7 @@ public static List getOutputFluids(GTRecipe recipe) { */ public static List getOutputFluids(GTRecipeBuilder builder) { return builder.output.getOrDefault(FluidRecipeCapability.CAP, Collections.emptyList()).stream() - .map(content -> FluidRecipeCapability.CAP.of(content.getContent())) + .map(content -> FluidRecipeCapability.CAP.of(content.content())) .map(ingredient -> ingredient.getStacks()[0]) .collect(Collectors.toList()); } @@ -332,7 +332,7 @@ public static Map, List> doTrim(Map, List> entrie var contentList = this.recipeContents.computeIfAbsent(cap, c -> new ArrayList<>()); var searchContentList = this.searchRecipeContents.computeIfAbsent(cap, c -> new ArrayList<>()); for (Content cont : entry.getValue()) { - searchContentList.add(cont.content); + searchContentList.add(cont.content()); // When simulating the recipe handling (used for recipe matching), // searchRecipeContents == recipeContents, so all contents, chanced and unchanced, must match if (simulated) continue; - if (cont.chance >= cont.maxChance) { - contentList.add(cont.content); - } else if (cont.chance > 0 || cont.tierChanceBoost > 0) { + if (cont.chance() >= cont.maxChance()) { + contentList.add(cont.content()); + } else if (cont.chance() > 0 || cont.tierChanceBoost() > 0) { chancedContents.add(cont); } // Do not add Non-Consumed ingredients; they'd just get dropped after the chance roll anyway @@ -110,7 +110,7 @@ private void fillContentMatchList(Map, List> entrie recipe.getTotalRuns()); for (Content cont : chancedContents) { - contentList.add(cont.content); + contentList.add(cont.content()); } } diff --git a/src/main/java/com/gregtechceu/gtceu/api/recipe/chance/boost/ChanceBoostFunction.java b/src/main/java/com/gregtechceu/gtceu/api/recipe/chance/boost/ChanceBoostFunction.java index 5f6b16fba75..39825e62f13 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/recipe/chance/boost/ChanceBoostFunction.java +++ b/src/main/java/com/gregtechceu/gtceu/api/recipe/chance/boost/ChanceBoostFunction.java @@ -18,15 +18,15 @@ public interface ChanceBoostFunction { */ ChanceBoostFunction OVERCLOCK = (entry, recipeTier, chanceTier) -> { int tierDiff = chanceTier - recipeTier; - if (tierDiff <= 0) return entry.chance; // equal or invalid tiers do not boost at all + if (tierDiff <= 0) return entry.chance(); // equal or invalid tiers do not boost at all if (recipeTier == GTValues.ULV) tierDiff--; // LV does not boost over ULV - return Mth.clamp(entry.chance + (entry.tierChanceBoost * tierDiff), 0, entry.maxChance); + return Mth.clamp(entry.chance() + (entry.tierChanceBoost() * tierDiff), 0, entry.maxChance()); }; /** * Chance boosting function which performs no boosting */ - ChanceBoostFunction NONE = (entry, recipeTier, chanceTier) -> entry.chance; + ChanceBoostFunction NONE = (entry, recipeTier, chanceTier) -> entry.chance(); /** * @param entry the amount to boost by diff --git a/src/main/java/com/gregtechceu/gtceu/api/recipe/chance/logic/ChanceLogic.java b/src/main/java/com/gregtechceu/gtceu/api/recipe/chance/logic/ChanceLogic.java index b797868153d..6165c11e2e3 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/recipe/chance/logic/ChanceLogic.java +++ b/src/main/java/com/gregtechceu/gtceu/api/recipe/chance/logic/ChanceLogic.java @@ -45,7 +45,7 @@ public abstract class ChanceLogic { int chanceTier, @Nullable Object2IntMap cache, int times) { ImmutableList.Builder builder = ImmutableList.builder(); for (Content entry : chancedEntries) { - int maxChance = entry.maxChance; + int maxChance = entry.maxChance(); // OR Chanced outputs are deterministic // If a large batch is being done we can calculate how many we expect to get. @@ -63,7 +63,7 @@ public abstract class ChanceLogic { chance -= maxChance; newChance -= maxChance; } - updateCachedChance(entry.content, cache, newChance / 2 + cached); + updateCachedChance(entry.content(), cache, newChance / 2 + cached); } return builder.build(); } @@ -96,9 +96,9 @@ public String toString() { int newChance = getChance(entry, boostFunction, recipeTier, chanceTier); int cached = getCachedChance(entry, cache); int chance = newChance + cached; - if (passesChance(chance, entry.maxChance)) newChance -= entry.maxChance; + if (passesChance(chance, entry.maxChance())) newChance -= entry.maxChance(); else failed = true; - updateCachedChance(entry.content, cache, newChance / 2 + cached); + updateCachedChance(entry.content(), cache, newChance / 2 + cached); if (failed) break; } if (!failed) builder.addAll(chancedEntries); @@ -136,11 +136,11 @@ public String toString() { int newChance = getChance(entry, boostFunction, recipeTier, chanceTier); int cached = getCachedChance(entry, cache); int chance = newChance + cached; - if (passesChance(chance, entry.maxChance)) { + if (passesChance(chance, entry.maxChance())) { selected = entry; - newChance -= entry.maxChance; + newChance -= entry.maxChance(); } - updateCachedChance(entry.content, cache, newChance / 2 + cached); + updateCachedChance(entry.content(), cache, newChance / 2 + cached); if (selected != null) break; } if (selected != null) builder.add(selected); @@ -173,10 +173,10 @@ public String toString() { IntList chancesOutOfTenThousand = new IntArrayList(); for (Content orig : chancedEntries) { - if (orig.maxChance == getMaxChancedValue()) { - chancesOutOfTenThousand.add(orig.chance); + if (orig.maxChance() == getMaxChancedValue()) { + chancesOutOfTenThousand.add(orig.chance()); } else { - chancesOutOfTenThousand.add((int) ((orig.chance / (float) orig.maxChance) * getMaxChancedValue())); + chancesOutOfTenThousand.add((int) ((orig.chance() / (float) orig.maxChance()) * getMaxChancedValue())); } } @@ -204,8 +204,8 @@ public String toString() { // Finally, generate a new Content list with the changes List normalizedEntries = new ArrayList<>(); for (int i = 0; i < chancesOutOfTenThousand.size(); i++) { - normalizedEntries.add(new Content(chancedEntries.get(i).content, chancesOutOfTenThousand.getInt(i), - getMaxChancedValue(), chancedEntries.get(i).tierChanceBoost)); + normalizedEntries.add(new Content(chancedEntries.get(i).content(), chancesOutOfTenThousand.getInt(i), + getMaxChancedValue(), chancedEntries.get(i).tierChanceBoost())); } // Use the new, normalized list for the logic @@ -235,7 +235,7 @@ public String toString() { selected = entry; newChance -= maxChance; } - updateCachedChance(entry.content, cache, newChance / 2 + cached); + updateCachedChance(entry.content(), cache, newChance / 2 + cached); if (selected != null) break; maxChance -= newChance; } @@ -314,13 +314,13 @@ public static int getMaxChancedValue() { * @param entry the current entry * @param cache the cache of previously rolled chances, can be null * @return the cached chance, otherwise a random initial chance - * between 0 and {@link Content#maxChance} (exclusive) + * between 0 and {@link Content#maxChance()} (exclusive) */ static int getCachedChance(Content entry, @Nullable Object2IntMap cache) { - if (cache == null || !cache.containsKey(entry.content)) - return GTValues.RNG.nextInt(entry.maxChance); + if (cache == null || !cache.containsKey(entry.content())) + return GTValues.RNG.nextInt(entry.maxChance()); - return cache.getInt(entry.content); + return cache.getInt(entry.content()); } /** diff --git a/src/main/java/com/gregtechceu/gtceu/api/recipe/content/Content.java b/src/main/java/com/gregtechceu/gtceu/api/recipe/content/Content.java index 59015b68e6e..056abc7dab7 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/recipe/content/Content.java +++ b/src/main/java/com/gregtechceu/gtceu/api/recipe/content/Content.java @@ -1,40 +1,22 @@ package com.gregtechceu.gtceu.api.recipe.content; +import brachy.modularui.screen.RichTooltip; import com.gregtechceu.gtceu.api.capability.recipe.RecipeCapability; import com.gregtechceu.gtceu.api.recipe.chance.boost.ChanceBoostFunction; import com.gregtechceu.gtceu.api.recipe.chance.logic.ChanceLogic; -import com.gregtechceu.gtceu.api.recipe.ingredient.FluidIngredient; -import com.gregtechceu.gtceu.api.recipe.ingredient.IntProviderFluidIngredient; -import com.gregtechceu.gtceu.api.recipe.ingredient.IntProviderIngredient; -import com.gregtechceu.gtceu.utils.FormattingUtil; -import com.gregtechceu.gtceu.utils.GradientUtil; - -import com.lowdragmc.lowdraglib.gui.texture.IGuiTexture; -import com.lowdragmc.lowdraglib.utils.LocalizationUtils; +import com.gregtechceu.gtceu.utils.FormattingUtil; import net.minecraft.ChatFormatting; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.Font; -import net.minecraft.client.gui.GuiGraphics; +import net.minecraft.network.chat.Component; import net.minecraft.util.ExtraCodecs; -import net.minecraft.util.Mth; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.api.distmarker.OnlyIn; -import com.mojang.blaze3d.systems.RenderSystem; import com.mojang.serialization.Codec; import com.mojang.serialization.codecs.RecordCodecBuilder; -import lombok.Getter; import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; -public class Content { +import java.util.List; - @Getter - public final Object content; - public final int chance; - public final int maxChance; - public final int tierChanceBoost; +public record Content(Object content, int chance, int maxChance, int tierChanceBoost) { public Content(Object content, int chance, int maxChance, int tierChanceBoost) { this.content = content; @@ -45,13 +27,13 @@ public Content(Object content, int chance, int maxChance, int tierChanceBoost) { public static Codec codec(RecipeCapability capability) { return RecordCodecBuilder.create(instance -> instance.group( - capability.serializer.codec().fieldOf("content").forGetter(val -> capability.of(val.content)), - ExtraCodecs.NON_NEGATIVE_INT.optionalFieldOf("chance", ChanceLogic.getMaxChancedValue()) - .forGetter(val -> val.chance), - ExtraCodecs.NON_NEGATIVE_INT.optionalFieldOf("maxChance", ChanceLogic.getMaxChancedValue()) - .forGetter(val -> val.maxChance), - Codec.INT.optionalFieldOf("tierChanceBoost", 0) - .forGetter(val -> val.tierChanceBoost)) + capability.serializer.codec().fieldOf("content").forGetter(val -> capability.of(val.content)), + ExtraCodecs.NON_NEGATIVE_INT.optionalFieldOf("chance", ChanceLogic.getMaxChancedValue()) + .forGetter(val -> val.chance), + ExtraCodecs.NON_NEGATIVE_INT.optionalFieldOf("maxChance", ChanceLogic.getMaxChancedValue()) + .forGetter(val -> val.maxChance), + Codec.INT.optionalFieldOf("tierChanceBoost", 0) + .forGetter(val -> val.tierChanceBoost)) .apply(instance, Content::new)); } @@ -104,117 +86,54 @@ private int fixBoost(int chanceBoost) { return chanceBoost < 0 ? -fixed : fixed; } - public IGuiTexture createOverlay(boolean perTick, int recipeTier, int chanceTier, - @Nullable ChanceBoostFunction function) { - return new IGuiTexture() { - - @Override - @OnlyIn(Dist.CLIENT) - public void draw(GuiGraphics graphics, int mouseX, int mouseY, float x, float y, int width, int height) { - drawChance(graphics, x, y, width, height, recipeTier, chanceTier, function); - drawRangeAmount(graphics, x, y, width, height); - drawFluidAmount(graphics, x, y, width, height); - if (perTick) { - drawTick(graphics, x, y, width, height); - } - } - }; - } - - @OnlyIn(Dist.CLIENT) - public void drawRangeAmount(GuiGraphics graphics, float x, float y, int width, int height) { - if (content instanceof IntProviderIngredient ingredient) { - graphics.pose().pushPose(); - graphics.pose().translate(0, 0, 400); - graphics.pose().scale(0.5f, 0.5f, 1); - int min = ingredient.getCountProvider().getMinValue(); - int max = ingredient.getCountProvider().getMaxValue(); - String s = String.format("%s-%s", min, max); - int color = 0xFFFFFF; - Font fontRenderer = Minecraft.getInstance().font; - // 5 == max num of characters that fit in a slot at 0.5x render size - if (s.length() > 5) { - s = "X-Y"; - color = ChatFormatting.GOLD.getColor(); // Orange? - } - graphics.drawString(fontRenderer, s, (int) ((x + (width / 3f)) * 2 - fontRenderer.width(s) + 21), - (int) ((y + (height / 3f) + 6) * 2), color, true); - graphics.pose().popPose(); - } - } - - @OnlyIn(Dist.CLIENT) - public void drawFluidAmount(GuiGraphics graphics, float x, float y, int width, int height) { - if (content instanceof FluidIngredient ingredient) { - graphics.pose().pushPose(); - graphics.pose().translate(0, 0, 400); - graphics.pose().scale(0.5f, 0.5f, 1); - Font fontRenderer = Minecraft.getInstance().font; - int color; - String s; - if (content instanceof IntProviderFluidIngredient) { - // with only 5 characters worth of space, that's not enough for a fluid range - color = ChatFormatting.GOLD.getColor(); - s = "X-Y"; + public static void addChanceTooltips(RichTooltip tooltip, Content content, ChanceLogic logic, int recipeTier, + int chanceTier, ChanceBoostFunction function) { + if (content.chance() < ChanceLogic.getMaxChancedValue()) { + int boostedChance = function.getBoostedChance(content, recipeTier, chanceTier); + if (boostedChance == 0) { + tooltip.addLine(Component.translatable("gtceu.gui.content.chance_nc")); } else { - int amount = ingredient.getAmount(); - color = 0xFFFFFF; - s = FormattingUtil.formatBuckets(amount); - if (fontRenderer.width(s) > 32) - s = FormattingUtil.formatNumberReadable(amount, true, FormattingUtil.DECIMAL_FORMAT_1F, "B"); - if (fontRenderer.width(s) > 32) - s = FormattingUtil.formatNumberReadable(amount, true, FormattingUtil.DECIMAL_FORMAT_0F, "B"); + float baseChanceFloat = 100f * content.chance() / content.maxChance(); + if (content.tierChanceBoost() != 0) { + float boostedChanceFloat = 100f * boostedChance / content.maxChance(); + + if (logic != ChanceLogic.NONE && logic != ChanceLogic.OR) { + tooltip.addLine(Component.translatable("gtceu.gui.content.chance_base_logic", + FormattingUtil.formatNumber2Places(baseChanceFloat), logic.getTranslation()) + .withStyle(ChatFormatting.YELLOW)); + } else { + tooltip.addLine( + FormattingUtil.formatPercentage2Places("gtceu.gui.content.chance_base", + baseChanceFloat)); + } + + String key = "gtceu.gui.content.chance_tier_boost_" + + ((content.tierChanceBoost() > 0) ? "plus" : "minus"); + tooltip.addLine(FormattingUtil.formatPercentage2Places(key, + Math.abs(100f * content.tierChanceBoost() / content.maxChance()))); + + if (logic != ChanceLogic.NONE && logic != ChanceLogic.OR) { + tooltip.addLine(Component.translatable("gtceu.gui.content.chance_boosted_logic", + FormattingUtil.formatNumber2Places(boostedChanceFloat), logic.getTranslation()) + .withStyle(ChatFormatting.YELLOW)); + } else { + tooltip.addLine( + FormattingUtil.formatPercentage2Places("gtceu.gui.content.chance_boosted", + boostedChanceFloat)); + } + } else { + if (logic != ChanceLogic.NONE && logic != ChanceLogic.OR) { + tooltip.addLine(Component.translatable("gtceu.gui.content.chance_no_boost_logic", + FormattingUtil.formatNumber2Places(baseChanceFloat), logic.getTranslation()) + .withStyle(ChatFormatting.YELLOW)); + } else { + tooltip.addLine( + FormattingUtil.formatPercentage2Places("gtceu.gui.content.chance_no_boost", + baseChanceFloat)); + } + } } - graphics.drawString(fontRenderer, s, (int) ((x + (width / 3f)) * 2 - fontRenderer.width(s) + 22), - (int) ((y + (height / 3f) + 6) * 2), color, true); - graphics.pose().popPose(); } } - @OnlyIn(Dist.CLIENT) - public void drawChance(GuiGraphics graphics, float x, float y, int width, int height, int recipeTier, - int chanceTier, @Nullable ChanceBoostFunction function) { - if (chance == ChanceLogic.getMaxChancedValue()) return; - graphics.pose().pushPose(); - graphics.pose().translate(0, 0, 400); - graphics.pose().scale(0.5f, 0.5f, 1); - var func = function == null ? ChanceBoostFunction.NONE : function; - int chance = func.getBoostedChance(this, recipeTier, chanceTier); - float chanceFloat = 1f * chance / this.maxChance; - String percent = FormattingUtil.formatNumber2Places(100 * chanceFloat); - - String s = chance == 0 ? LocalizationUtils.format("gtceu.gui.content.chance_nc_short") : - percent + "%"; - - int color = chance == 0 ? 0xFF0000 : GradientUtil.toRGB(Mth.lerp(chanceFloat, 29f, 167f), 100f, 50f); - Font fontRenderer = Minecraft.getInstance().font; - graphics.drawString(fontRenderer, s, (int) ((x + (width / 3f)) * 2 - fontRenderer.width(s) + 23), - (int) ((y + (height / 3f) + 6) * 2 - height), color, true); - graphics.pose().popPose(); - } - - @OnlyIn(Dist.CLIENT) - public void drawTick(GuiGraphics graphics, float x, float y, int width, int height) { - graphics.pose().pushPose(); - RenderSystem.disableDepthTest(); - graphics.pose().translate(0, 0, 400); - graphics.pose().scale(0.5f, 0.5f, 1); - String s = LocalizationUtils.format("gtceu.gui.content.tips.per_tick_short"); - int color = 0xFFFF00; - Font fontRenderer = Minecraft.getInstance().font; - graphics.drawString(fontRenderer, s, (int) ((x + (width / 3f)) * 2 - fontRenderer.width(s) + 23), - (int) ((y + (height / 3f) + 6) * 2 - height + (chance == ChanceLogic.getMaxChancedValue() ? 0 : 10)), - color); - graphics.pose().popPose(); - } - - @Override - public String toString() { - return "Content{" + - "content=" + content + - ", chance=" + chance + - ", maxChance=" + maxChance + - ", tierChanceBoost=" + tierChanceBoost + - '}'; - } } diff --git a/src/main/java/com/gregtechceu/gtceu/api/recipe/content/IContentSerializer.java b/src/main/java/com/gregtechceu/gtceu/api/recipe/content/IContentSerializer.java index 2186fb6d4ad..8a468fefcf5 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/recipe/content/IContentSerializer.java +++ b/src/main/java/com/gregtechceu/gtceu/api/recipe/content/IContentSerializer.java @@ -36,11 +36,11 @@ default JsonElement toJson(T content) { @SuppressWarnings("unchecked") default void toNetworkContent(FriendlyByteBuf buf, Content content) { - T inner = (T) content.getContent(); + T inner = (T) content.content(); toNetwork(buf, inner); - buf.writeVarInt(content.chance); - buf.writeVarInt(content.maxChance); - buf.writeVarInt(content.tierChanceBoost); + buf.writeVarInt(content.chance()); + buf.writeVarInt(content.maxChance()); + buf.writeVarInt(content.tierChanceBoost()); } default Content fromNetworkContent(FriendlyByteBuf buf) { @@ -58,10 +58,10 @@ default Content fromNetworkContent(FriendlyByteBuf buf) { @SuppressWarnings("unchecked") default JsonElement toJsonContent(Content content) { JsonObject json = new JsonObject(); - json.add("content", toJson((T) content.getContent())); - json.addProperty("chance", content.chance); - json.addProperty("maxChance", content.maxChance); - json.addProperty("tierChanceBoost", content.tierChanceBoost); + json.add("content", toJson((T) content.content())); + json.addProperty("chance", content.chance()); + json.addProperty("maxChance", content.maxChance()); + json.addProperty("tierChanceBoost", content.tierChanceBoost()); return json; } diff --git a/src/main/java/com/gregtechceu/gtceu/api/recipe/gui/CapabilityContentBuilder.java b/src/main/java/com/gregtechceu/gtceu/api/recipe/gui/CapabilityContentBuilder.java new file mode 100644 index 00000000000..72938a3c5d5 --- /dev/null +++ b/src/main/java/com/gregtechceu/gtceu/api/recipe/gui/CapabilityContentBuilder.java @@ -0,0 +1,202 @@ +package com.gregtechceu.gtceu.api.recipe.gui; + +import brachy.modularui.api.drawable.Text; +import brachy.modularui.api.widget.IWidget; +import brachy.modularui.drawable.text.ModularComponent; +import brachy.modularui.integration.recipeviewer.RecipeSlotRole; +import brachy.modularui.integration.recipeviewer.RecipeViewerSlotWidget; +import brachy.modularui.screen.RichTooltip; +import brachy.modularui.widget.WidgetTree; +import brachy.modularui.widgets.TextWidget; +import brachy.modularui.widgets.layout.Flow; +import com.gregtechceu.gtceu.api.GTValues; +import com.gregtechceu.gtceu.api.capability.recipe.CWURecipeCapability; +import com.gregtechceu.gtceu.api.capability.recipe.FluidRecipeCapability; +import com.gregtechceu.gtceu.api.capability.recipe.IO; +import com.gregtechceu.gtceu.api.capability.recipe.ItemRecipeCapability; +import com.gregtechceu.gtceu.api.recipe.GTRecipe; +import com.gregtechceu.gtceu.api.recipe.GTRecipeType; +import com.gregtechceu.gtceu.api.recipe.RecipeHelper; +import com.gregtechceu.gtceu.api.recipe.content.Content; +import com.gregtechceu.gtceu.api.recipe.ingredient.*; +import com.gregtechceu.gtceu.client.TooltipsHandler; +import com.gregtechceu.gtceu.utils.FormattingUtil; +import com.gregtechceu.gtceu.utils.GTUtil; +import net.minecraft.ChatFormatting; +import net.minecraft.network.chat.Component; +import net.minecraft.util.valueproviders.IntProvider; +import net.minecraft.world.item.TooltipFlag; +import net.minecraftforge.fluids.FluidStack; + +import java.util.function.Consumer; + +/** + * Fills recipe viewer UI slots with the capability content for a specific recipe. + */ +@FunctionalInterface +public interface CapabilityContentBuilder { + + /** + * Fills a recipe viewer slot with capability content. + * + * @param widget The widget to attempt to attach content to. + * @param content The content value. + * @param io If this content is a recipe input or output. + * @param perTick If this content is a tick input. + * @param recipeType The type of the recipe this content is for. + * @param recipe The recipe this content is for. + * @param chanceTier The chance tier this recipe should be previewed at + * @param recipeTier The tier this recipe should be previewed at + */ + void buildWidgetContent(IWidget widget, Content content, IO io, boolean perTick, + GTRecipeType recipeType, GTRecipe recipe, int chanceTier, int recipeTier); + + CapabilityContentBuilder ITEM = (widget, content, io, perTick, + recipeType, recipe, chanceTier, recipeTier) -> { + if (!(widget instanceof RecipeViewerSlotWidget recipeViewerSlotWidget)) return; + + float chance = (float) recipeType.getChanceFunction() + .getBoostedChance(content, recipeTier, chanceTier) / content.maxChance(); + var innerContent = ItemRecipeCapability.CAP.of(content.content()); + + recipeViewerSlotWidget.value(ItemRecipeCapability.mapIngredientToEntryList(innerContent)); + recipeViewerSlotWidget.overlay(new ContentOverlay(content, perTick, recipeTier, chanceTier, recipeType.getChanceFunction())); + recipeViewerSlotWidget.chance(chance); + + if (io == IO.IN && (content.chance() == 0 || innerContent instanceof IntCircuitIngredient)) { + recipeViewerSlotWidget.recipeSlotRole(RecipeSlotRole.CATALYST); + } else if (io == IO.IN) { + recipeViewerSlotWidget.recipeSlotRole(RecipeSlotRole.INPUT); + } else { + recipeViewerSlotWidget.recipeSlotRole(RecipeSlotRole.OUTPUT); + } + + recipeViewerSlotWidget.tooltipBuilder((tooltip) -> { + + Content.addChanceTooltips(tooltip, content, + recipe.getChanceLogicForCapability(ItemRecipeCapability.CAP, io, perTick), + recipeTier, chanceTier, recipeType.getChanceFunction()); + + if (innerContent instanceof IntProviderIngredient ingredient) { + IntProvider countProvider = ingredient.getCountProvider(); + tooltip.add(Component.translatable("gtceu.gui.content.count_range", + countProvider.getMinValue(), countProvider.getMaxValue()) + .withStyle(ChatFormatting.GOLD)); + } else if (innerContent instanceof SizedIngredient sizedIngredient && + sizedIngredient.getInner() instanceof IntProviderIngredient ingredient) { + + IntProvider countProvider = ingredient.getCountProvider(); + tooltip.add(Component.translatable("gtceu.gui.content.count_range", + countProvider.getMinValue(), countProvider.getMaxValue()) + .withStyle(ChatFormatting.GOLD)); + } + if (perTick) { + tooltip.add(Component.translatable("gtceu.gui.content.per_tick")); + } + }); + }; + + CapabilityContentBuilder FLUID = (widget, content, io, perTick, + recipeType, recipe, chanceTier, recipeTier) -> { + if (!(widget instanceof RecipeViewerSlotWidget recipeViewerSlotWidget)) return; + + float chance = (float) recipeType.getChanceFunction() + .getBoostedChance(content, recipeTier, chanceTier) / content.maxChance(); + FluidIngredient ingredient = FluidRecipeCapability.CAP.of(content.content()); + + recipeViewerSlotWidget.value(FluidRecipeCapability.mapIngredientToEntryList(ingredient)); + recipeViewerSlotWidget.overlay(new ContentOverlay(content, perTick, recipeTier, chanceTier, recipeType.getChanceFunction())); + recipeViewerSlotWidget.chance(chance); + + + recipeViewerSlotWidget.tooltipBuilder((tooltip) -> { + if (ingredient.getStacks().length > 0) { + FluidStack stack = ingredient.getStacks()[0]; + TooltipsHandler.appendFluidTooltips(stack, tooltip::addLine, TooltipFlag.NORMAL); + } + if (ingredient instanceof IntProviderFluidIngredient provider) { + IntProvider countProvider = provider.getCountProvider(); + tooltip.addLine(Component.translatable("gtceu.gui.content.fluid_range", + countProvider.getMinValue(), countProvider.getMaxValue()) + .withStyle(ChatFormatting.GOLD)); + } + if (perTick) { + tooltip.addLine(Component.translatable("gtceu.gui.content.per_tick")); + } + }); + + if (io == IO.IN && (content.chance() == 0)) { + recipeViewerSlotWidget.recipeSlotRole(RecipeSlotRole.CATALYST); + } else if (io == IO.IN) { + recipeViewerSlotWidget.recipeSlotRole(RecipeSlotRole.INPUT); + } else { + recipeViewerSlotWidget.recipeSlotRole(RecipeSlotRole.OUTPUT); + } + }; + + CapabilityContentBuilder COMPUTATION = (widget, content, io, perTick, + recipeType, recipe, chanceTier, recipeTier) -> { + if (!(widget instanceof Flow flow)) return; + + var existingCompTickWidget = WidgetTree.findFirstWithNameNullable(flow, "comp_tick"); + var existingCompTotal = WidgetTree.findFirstWithNameNullable(flow, "comp_total"); + + if (recipe.tickInputs.get(CWURecipeCapability.CAP) != null) { + if (CWURecipeCapability.CAP.isTickSlot(0, IO.IN, recipe)) { + int cwu = recipe.getTickInputContents(CWURecipeCapability.CAP).stream().map(Content::content).mapToInt(CWURecipeCapability.CAP::of).sum(); + var text = Text.lang("gtceu.recipe.computation_per_tick", FormattingUtil.formatNumbers(cwu)); + + if (existingCompTickWidget != null) ((TextWidget)existingCompTickWidget).value(text); + else flow.child(text.asWidget().name("comp_tick")); + } + if (recipe.data.getBoolean("duration_is_total_cwu")) { + var text = Text.lang("gtceu.recipe.total_computation", FormattingUtil.formatNumbers(recipe.duration)); + + if (existingCompTotal != null) ((TextWidget)existingCompTotal).value(text); + else flow.child(text.asWidget().name("comp_total")); + } + } + }; + + CapabilityContentBuilder EU = (widget, content, io, perTick, recipeType, recipe, chanceTier, recipeTier) -> { + if (!(widget instanceof Flow flow)) return; + + var eu = RecipeHelper.getRealEUt(recipe); + + var minVoltageTier = GTUtil.getTierByVoltage(eu.voltage()); + float minAmperage = (float) eu.getTotalEU() / GTValues.V[minVoltageTier]; + + if (eu.voltage() > 0) { + + var maxEuWidget = WidgetTree.findFirstWithNameNullable(flow, "max_eu"); + var euWidget = WidgetTree.findFirstWithNameNullable(flow, "eu"); + + ModularComponent maxEu; + + // sadly we still need a custom override here, since computation uses duration and EU/t very differently + if (recipe.data.getBoolean("duration_is_total_cwu") && + recipe.tickInputs.containsKey(CWURecipeCapability.CAP)) { + int minimumCWUt = Math.max(recipe.tickInputs.get(CWURecipeCapability.CAP).stream() + .map(Content::content).mapToInt(CWURecipeCapability.CAP::of).sum(), 1); + maxEu = Text.lang("gtceu.recipe.max_eu", + FormattingUtil.formatNumbers(eu.getTotalEU() / minimumCWUt)); + } else { + maxEu = Text.lang("gtceu.recipe.total", FormattingUtil.formatNumbers(eu.getTotalEU()* recipe.duration)); + } + + if (maxEuWidget != null) ((TextWidget)maxEuWidget).value(maxEu); + else flow.child(maxEu.asWidget().name("max_eu")); + + var euText = Text.lang(io == IO.IN ? "gtceu.recipe.eu" : "gtceu.recipe.eu_inverted", FormattingUtil.formatNumber2Places(minAmperage), GTValues.VN[minVoltageTier]) + .withStyle(ChatFormatting.UNDERLINE); + + RichTooltip tooltip = new RichTooltip(); + tooltip.addLine(Text.lang("gtceu.recipe.eu.total", FormattingUtil.formatNumbers(eu.getTotalEU())) + .withStyle(ChatFormatting.UNDERLINE)); + + if (euWidget != null) ((TextWidget)euWidget).value(euText).tooltip(tooltip); + else flow.child(euText.asWidget().tooltip(tooltip).name("eu")); + } + + }; +} diff --git a/src/main/java/com/gregtechceu/gtceu/api/recipe/gui/ContentOverlay.java b/src/main/java/com/gregtechceu/gtceu/api/recipe/gui/ContentOverlay.java new file mode 100644 index 00000000000..4ecb1499c98 --- /dev/null +++ b/src/main/java/com/gregtechceu/gtceu/api/recipe/gui/ContentOverlay.java @@ -0,0 +1,124 @@ +package com.gregtechceu.gtceu.api.recipe.gui; + +import brachy.modularui.api.drawable.IDrawable; +import brachy.modularui.screen.viewport.GuiContext; +import brachy.modularui.theme.WidgetTheme; +import com.gregtechceu.gtceu.api.recipe.chance.boost.ChanceBoostFunction; +import com.gregtechceu.gtceu.api.recipe.chance.logic.ChanceLogic; +import com.gregtechceu.gtceu.api.recipe.content.Content; +import com.gregtechceu.gtceu.api.recipe.ingredient.FluidIngredient; +import com.gregtechceu.gtceu.api.recipe.ingredient.IntProviderFluidIngredient; +import com.gregtechceu.gtceu.api.recipe.ingredient.IntProviderIngredient; +import com.gregtechceu.gtceu.utils.FormattingUtil; +import com.gregtechceu.gtceu.utils.GradientUtil; +import com.mojang.blaze3d.systems.RenderSystem; +import net.minecraft.ChatFormatting; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.Font; +import net.minecraft.client.gui.GuiGraphics; +import net.minecraft.network.chat.Component; +import net.minecraft.util.Mth; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.api.distmarker.OnlyIn; +import org.jetbrains.annotations.Nullable; + +@OnlyIn(Dist.CLIENT) +public record ContentOverlay(Content content, boolean perTick, int recipeTier, int chanceTier, + @Nullable ChanceBoostFunction function) implements IDrawable { + + @Override + public void draw(GuiContext context, int x, int y, int width, int height, WidgetTheme widgetTheme) { + drawChance(context.getGraphics(), x, y, width, height, recipeTier, chanceTier, function); + drawRangeAmount(context.getGraphics(), x, y, width, height); + drawFluidAmount(context.getGraphics(), x, y, width, height); + if (perTick) { + drawTick(context.getGraphics(), x, y, width, height); + } + + } + + public void drawRangeAmount(GuiGraphics graphics, float x, float y, int width, int height) { + if (content.content() instanceof IntProviderIngredient ingredient) { + graphics.pose().pushPose(); + graphics.pose().translate(0, 0, 400); + graphics.pose().scale(0.5f, 0.5f, 1); + int min = ingredient.getCountProvider().getMinValue(); + int max = ingredient.getCountProvider().getMaxValue(); + String s = String.format("%s-%s", min, max); + int color = 0xFFFFFF; + Font fontRenderer = Minecraft.getInstance().font; + // 5 == max num of characters that fit in a slot at 0.5x render size + if (s.length() > 5) { + s = "X-Y"; + color = ChatFormatting.GOLD.getColor(); // Orange? + } + graphics.drawString(fontRenderer, s, (int) ((x + (width / 3f)) * 2 - fontRenderer.width(s) + 21), + (int) ((y + (height / 3f) + 6) * 2), color, true); + graphics.pose().popPose(); + } + } + + public void drawFluidAmount(GuiGraphics graphics, float x, float y, int width, int height) { + if (content.content() instanceof FluidIngredient ingredient) { + graphics.pose().pushPose(); + graphics.pose().translate(0, 0, 400); + graphics.pose().scale(0.5f, 0.5f, 1); + Font fontRenderer = Minecraft.getInstance().font; + int color; + String s; + if (content.content() instanceof IntProviderFluidIngredient) { + // with only 5 characters worth of space, that's not enough for a fluid range + color = ChatFormatting.GOLD.getColor(); + s = "X-Y"; + } else { + int amount = ingredient.getAmount(); + color = 0xFFFFFF; + s = FormattingUtil.formatBuckets(amount); + if (fontRenderer.width(s) > 32) + s = FormattingUtil.formatNumberReadable(amount, true, FormattingUtil.DECIMAL_FORMAT_1F, "B"); + if (fontRenderer.width(s) > 32) + s = FormattingUtil.formatNumberReadable(amount, true, FormattingUtil.DECIMAL_FORMAT_0F, "B"); + } + graphics.drawString(fontRenderer, s, (int) ((x + (width / 3f)) * 2 - fontRenderer.width(s) + 22), + (int) ((y + (height / 3f) + 6) * 2), color, true); + graphics.pose().popPose(); + } + } + + public void drawChance(GuiGraphics graphics, float x, float y, int width, int height, int recipeTier, + int chanceTier, @Nullable ChanceBoostFunction function) { + if (content.chance() == ChanceLogic.getMaxChancedValue()) return; + graphics.pose().pushPose(); + graphics.pose().translate(0, 0, 400); + graphics.pose().scale(0.5f, 0.5f, 1); + var func = function == null ? ChanceBoostFunction.NONE : function; + int chance = func.getBoostedChance(content, recipeTier, chanceTier); + float chanceFloat = 1f * chance / content.maxChance(); + String percent = FormattingUtil.formatNumber2Places(100 * chanceFloat); + + Component s = chance == 0 ? Component.translatable("gtceu.gui.content.chance_nc_short") : + Component.literal(percent + "%"); + + int color = chance == 0 ? 0xFF0000 : GradientUtil.toRGB(Mth.lerp(chanceFloat, 29f, 167f), 100f, 50f); + Font fontRenderer = Minecraft.getInstance().font; + graphics.drawString(fontRenderer, s, (int) ((x + (width / 3f)) * 2 - fontRenderer.width(s) + 23), + (int) ((y + (height / 3f) + 6) * 2 - height), color, true); + graphics.pose().popPose(); + } + + public void drawTick(GuiGraphics graphics, float x, float y, int width, int height) { + graphics.pose().pushPose(); + RenderSystem.disableDepthTest(); + graphics.pose().translate(0, 0, 400); + graphics.pose().scale(0.5f, 0.5f, 1); + + Component s = Component.translatable("gtceu.gui.content.tips.per_tick_short"); + + int color = 0xFFFF00; + Font fontRenderer = Minecraft.getInstance().font; + graphics.drawString(fontRenderer, s, (int) ((x + (width / 3f)) * 2 - fontRenderer.width(s) + 23), + (int) ((y + (height / 3f) + 6) * 2 - height + (content.chance() == ChanceLogic.getMaxChancedValue() ? 0 : 10)), + color); + graphics.pose().popPose(); + } +} diff --git a/src/main/java/com/gregtechceu/gtceu/api/recipe/gui/GTRecipeTypeMachineWidget.java b/src/main/java/com/gregtechceu/gtceu/api/recipe/gui/GTRecipeTypeMachineWidget.java new file mode 100644 index 00000000000..e00ef7c33ed --- /dev/null +++ b/src/main/java/com/gregtechceu/gtceu/api/recipe/gui/GTRecipeTypeMachineWidget.java @@ -0,0 +1,60 @@ +package com.gregtechceu.gtceu.api.recipe.gui; + +import brachy.modularui.api.GuiAxis; +import brachy.modularui.utils.Alignment; +import brachy.modularui.value.sync.DoubleSyncValue; +import brachy.modularui.value.sync.PanelSyncManager; +import brachy.modularui.widgets.layout.Flow; +import com.gregtechceu.gtceu.GTCEu; +import com.gregtechceu.gtceu.api.capability.recipe.IO; +import com.gregtechceu.gtceu.api.machine.MetaMachine; +import com.gregtechceu.gtceu.api.recipe.GTRecipeType; + +import java.util.function.DoubleSupplier; + +/** + * The UI for singleblock recipe machines. + */ +public class GTRecipeTypeMachineWidget extends Flow { + + public final Flow inputColumn = Flow.col().coverChildren().crossAxisAlignment(Alignment.CrossAxis.START); + public final Flow outputColumn = Flow.col().coverChildren().crossAxisAlignment(Alignment.CrossAxis.START); + + public GTRecipeTypeMachineWidget(GTRecipeType recipeType, PanelSyncManager syncManager, + MetaMachine machine, + DoubleSupplier progressSupplier) { + super(GuiAxis.X); + + if (recipeType.getUiLayout() == null) { + GTCEu.LOGGER.error( + "Tried to draw a singleblock recipe type UI for {}, but it does not have a recipe type UI", + machine.getDefinition().getName()); + return; + } + + var layout = recipeType.getUiLayout(); + + DoubleSyncValue progressPercent = syncManager.getOrCreateSyncHandler("progressPercent", + DoubleSyncValue.class, () -> new DoubleSyncValue(progressSupplier)); + + coverChildren(); + center(); + childPadding((layout.getProgressSize() / 2) + 2); + child(inputColumn); + child(layout.getProgressWidgetSupplier().get(layout, progressPercent)); + child(outputColumn); + + for (var entry: recipeType.maxInputs.object2IntEntrySet()) { + var layoutFunc = layout.capabilityInfo(entry.getKey()).machineLayoutBuilder; + if (layoutFunc == null || entry.getIntValue() == 0) continue; + layoutFunc.createCapabilityUILayout(machine, layout, this, IO.IN); + + } + + for (var entry: recipeType.maxOutputs.object2IntEntrySet()) { + var layoutFunc = layout.capabilityInfo(entry.getKey()).machineLayoutBuilder; + if (layoutFunc == null || entry.getIntValue() == 0) continue; + layoutFunc.createCapabilityUILayout(machine, layout, this, IO.OUT); + } + } +} diff --git a/src/main/java/com/gregtechceu/gtceu/api/recipe/gui/GTRecipeTypeUILayout.java b/src/main/java/com/gregtechceu/gtceu/api/recipe/gui/GTRecipeTypeUILayout.java index c914115b2f3..3ce460014ce 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/recipe/gui/GTRecipeTypeUILayout.java +++ b/src/main/java/com/gregtechceu/gtceu/api/recipe/gui/GTRecipeTypeUILayout.java @@ -1,246 +1,197 @@ package com.gregtechceu.gtceu.api.recipe.gui; +import brachy.modularui.api.value.IDoubleValue; +import brachy.modularui.widget.Widget; +import brachy.modularui.widgets.layout.Flow; import com.gregtechceu.gtceu.api.capability.recipe.*; -import com.gregtechceu.gtceu.api.machine.trait.NotifiableFluidTank; -import com.gregtechceu.gtceu.api.machine.trait.NotifiableItemStackHandler; +import com.gregtechceu.gtceu.api.machine.MetaMachine; +import com.gregtechceu.gtceu.api.recipe.GTRecipe; import com.gregtechceu.gtceu.api.recipe.GTRecipeType; import com.gregtechceu.gtceu.common.mui.GTMuiWidgets; import brachy.modularui.api.drawable.IDrawable; import brachy.modularui.drawable.UITexture; -import brachy.modularui.screen.ModularPanel; -import brachy.modularui.theme.ThemeAPI; -import brachy.modularui.value.sync.DoubleSyncValue; -import brachy.modularui.value.sync.PanelSyncManager; -import brachy.modularui.value.sync.SyncHandlers; -import brachy.modularui.widget.ParentWidget; import brachy.modularui.widgets.ProgressWidget; -import brachy.modularui.widgets.SlotGroupWidget; -import brachy.modularui.widgets.layout.Flow; -import brachy.modularui.widgets.slot.FluidSlot; -import brachy.modularui.widgets.slot.ItemSlot; -import brachy.modularui.widgets.slot.ModularSlot; -import brachy.modularui.widgets.slot.SlotGroup; import it.unimi.dsi.fastutil.ints.*; -import it.unimi.dsi.fastutil.objects.Object2ReferenceOpenHashMap; +import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap; +import it.unimi.dsi.fastutil.objects.ObjectArrayList; import lombok.Getter; -import lombok.Setter; -import org.jetbrains.annotations.NotNull; +import org.apache.commons.lang3.NotImplementedException; import org.jetbrains.annotations.Nullable; +import org.jetbrains.annotations.UnknownNullability; import java.util.*; -import java.util.function.DoubleSupplier; +import java.util.function.Function; +/** + * Holds UI information for a recipe type UI. + */ public class GTRecipeTypeUILayout { - @Setter @Getter - private GTRecipeType recipeType; + private final GTRecipeType recipeType; @Getter - private UITexture progressBar; + private UITexture progressBar = UITexture.DEFAULT; @Getter - private int progressSize; + private int progressSize = 10; @Getter - private ProgressWidget.Direction progressDirection; + private ProgressWidget.Direction progressDirection = ProgressWidget.Direction.RIGHT; @Getter - private Set IOs = new HashSet<>(); + private final ProgressWidgetSupplier progressWidgetSupplier; + private final Map, CapabilityUIInfo> capabilityInfo; + @Getter - private Map, Int2ObjectOpenHashMap>> overlays = new EnumMap<>(IO.class); - private Map, Int2IntArrayMap>> gridLength = new EnumMap<>(IO.class); - private Map, Int2IntArrayMap>> gridWidths = new EnumMap<>(IO.class); - - private ParentWidget parentWidget = null; - - public GTRecipeTypeUILayout() {} - - public ParentWidget getBackedSlotsRow(@NotNull PanelSyncManager syncManager, - @NotNull String themeId, - @Nullable NotifiableItemStackHandler inputItems, - @Nullable NotifiableItemStackHandler outputItems, - @Nullable NotifiableFluidTank inputFluids, - @Nullable NotifiableFluidTank outputFluids, - DoubleSupplier progressSupplier, int tier) { - if (recipeType != null) { - var backedSlotsPanel = new ParentWidget<>(); - backedSlotsPanel.coverChildren(); - var backedSlotsRow = Flow.row(); - backedSlotsRow.coverChildrenHeight(); - - int rowWidthPx = 0; - - // List IOs = new ArrayList<>(); - if (inputItems != null || inputFluids != null) { - IOs.add(IO.IN); - } - if (outputFluids != null || outputItems != null) { - IOs.add(IO.OUT); - } + private final List recipeUIModifiers; + @Getter + private final @Nullable Function customUIBuilder; + + public GTRecipeTypeUILayout(GTRecipeType recipeType, Map, CapabilityUIInfo> capabilityInfo, + List recipeUIModifiers, ProgressWidgetSupplier progressWidgetSupplier, + @Nullable Function customUIBuilder) { + this.recipeType = recipeType; + this.capabilityInfo = capabilityInfo; + this.recipeUIModifiers = recipeUIModifiers; + this.progressWidgetSupplier = progressWidgetSupplier; + this.customUIBuilder = customUIBuilder; + } - Map> colWidgetGroups = new Object2ReferenceOpenHashMap<>(); - - int slotLeftShiftPx = 0; - for (var io : IOs) { - boolean in = io == IO.IN; - - var caps = (in ? recipeType.maxInputs : recipeType.maxOutputs); - int slotGroupHeightPx = 0; - - Flow ioColumn = Flow.col(); - // ioColumn.coverChildrenWidth(); - int slotGroupWidthPx = 0; - - var widgetGroups = new ArrayList>(); - - for (var recipeCap : caps.keySet()) { - int maxRecipeTypeSlots = caps.get(recipeCap); - int maxMachineSlots = 0; - if (maxRecipeTypeSlots == 0 || recipeCap == EURecipeCapability.CAP) continue; - if (recipeCap == ItemRecipeCapability.CAP) { - if (in && inputItems == null) continue; - if (!in && outputItems == null) continue; - maxMachineSlots = in ? inputItems.getSlots() : outputItems.getSlots(); - } else if (recipeCap == FluidRecipeCapability.CAP) { - if (in && inputFluids == null) continue; - if (!in && outputFluids == null) continue; - maxMachineSlots = in ? inputFluids.getTanks() : outputFluids.getTanks(); - } - - var grid = createGrid(io, recipeCap, 's', tier, maxMachineSlots); - - slotGroupHeightPx += 18 * grid.length; - - IDrawable defaultSlotBackground = (recipeCap == ItemRecipeCapability.CAP ? - ThemeAPI.INSTANCE.getTheme(themeId).getItemSlotTheme().theme().getBackground() : - ThemeAPI.INSTANCE.getTheme(themeId).getFluidSlotTheme().theme().getBackground()); - - SlotGroupWidget.Builder slotWidgetBuilder = SlotGroupWidget.builder() - .matrix(grid); - - if (recipeCap == ItemRecipeCapability.CAP) { - var handler = in ? inputItems : outputItems; - SlotGroup group = new SlotGroup("item_" + io.name(), grid[0].length()); - if (handler != null) { - slotWidgetBuilder.key('s', i -> { - var overlay = IDrawable.EMPTY; - - if (overlays.containsKey(io) && overlays.get(io).containsKey(recipeCap)) { - overlay = overlays.get(io).get(recipeCap).get(i) != null ? - overlays.get(io).get(recipeCap).get(i) : IDrawable.EMPTY; - } - - return new ItemSlot().slot(new ModularSlot(handler, i) - .slotGroup(group)) - .background(defaultSlotBackground, overlay); - }); - } - } else if (recipeCap == FluidRecipeCapability.CAP) { - var handler = in ? inputFluids : outputFluids; - String syncHandlerName = "fluid_" + io.name(); - for (int i = 0; i < maxMachineSlots; i++) { - syncManager.syncValue(syncHandlerName, i, SyncHandlers.fluidSlot(handler.getStorages()[i])); - } - if (handler != null) { - slotWidgetBuilder.key('s', i -> { - var overlay = IDrawable.EMPTY; - - if (overlays.containsKey(io) && overlays.get(io).containsKey(recipeCap)) { - overlay = overlays.get(io).get(recipeCap).get(i) != null ? - overlays.get(io).get(recipeCap).get(i) : IDrawable.EMPTY; - } - - return new FluidSlot() - .syncHandler(syncHandlerName, i) - .background(defaultSlotBackground, overlay); - }); - } - } - - // calculate full width of each column - slotGroupWidthPx = Math.max(slotGroupWidthPx, Math.min(maxRecipeTypeSlots, grid[0].length()) * 18); - - widgetGroups.add(slotWidgetBuilder.build() - .name(recipeCap.name + "_" + io.name()) - .leftRel(io == IO.IN ? 0f : 1)); - } - - ioColumn.size(slotGroupWidthPx, slotGroupHeightPx); - for (var g : widgetGroups) { - ioColumn.child(g); - } - slotLeftShiftPx += (slotGroupWidthPx / 2) * ((io == io.IN) ? -1 : 1); - - rowWidthPx += slotGroupWidthPx; - colWidgetGroups.put(io, ioColumn); - } - // 2 px padding plus each half of the progress bar (1) - backedSlotsRow.childPadding((progressSize / 2) + 2); - for (var ioColumn : colWidgetGroups.entrySet()) { - var col = ioColumn.getValue(); - var io = ioColumn.getKey(); - backedSlotsRow.child(col.posRel(io == IO.IN ? 0f : 1f, 0.5f)); - } + public CapabilityUIInfo capabilityInfo(RecipeCapability cap) { + var info = capabilityInfo.computeIfAbsent(cap, CapabilityUIInfo::new); + if (info.layout == null) info.layout = this; + return info; + } - // same padding as (1) + half a slot on each side - rowWidthPx += progressSize + 4 + 18; - backedSlotsRow.width(rowWidthPx); + public static class CapabilityUIInfo { + private final Map> overlays = new Object2ObjectOpenHashMap<>(); - backedSlotsPanel.child(backedSlotsRow.left(slotLeftShiftPx)); + private final Map machineLayoutGridBuilders = new EnumMap<>(IO.class); - DoubleSyncValue progressPercent = syncManager.getOrCreateSyncHandler("progressPercent", - DoubleSyncValue.class, () -> new DoubleSyncValue(progressSupplier)); + public @Nullable MachineCapabilityLayoutBuilder machineLayoutBuilder; - backedSlotsPanel.child(new ProgressWidget() - .center() - .value(progressPercent) - .name("progressBar") - .texture(progressBar, progressSize) - .size(progressSize) - .direction(progressDirection)); - return backedSlotsPanel; + public @Nullable CapabilityContentBuilder capabilityWidgetBuilder; + + private final Map recipeViewerLayoutGridBuilders = new EnumMap<>(IO.class); + + public @Nullable RecipeViewerCapabilityLayoutBuilder recipeViewerLayoutBuilder; + + private @UnknownNullability GTRecipeTypeUILayout layout; + private final RecipeCapability cap; + private CapabilityUIInfo(RecipeCapability cap) { + this.cap = cap; } - return ModularPanel.defaultPanel("empty"); - } - public String[] createGrid(IO io, RecipeCapability cap, char key, int tier, int maxMachineSlots) { - int maxWidth = 3; - if (gridWidths.containsKey(io) && gridWidths.get(io).containsKey(cap)) { - int width = gridWidths.get(io).get(cap).get(tier); - if (width != 0) maxWidth = width; + public IDrawable getOverlay(IO io, int index) { + return overlays.computeIfAbsent(io, $ -> new Int2ObjectOpenHashMap<>()).getOrDefault(index, IDrawable.EMPTY); } - int maxSlots = (io == IO.IN ? recipeType.getMaxInputs(cap) : recipeType.getMaxOutputs(cap)); - if (gridLength.containsKey(io) && gridLength.get(io).containsKey(cap)) { - int length = gridLength.get(io).get(cap).get(tier); - if (length != 0) maxSlots = length; + + public String[] getMachineGrid(IO io, MetaMachine machine) { + if (machineLayoutGridBuilders.containsKey(io)) return machineLayoutGridBuilders.get(io).buildGrid(machine, layout); + var slots = layout.recipeType.getMaxSlots(cap, io); + return GTMuiWidgets.createGrid(slots, Math.min(3, slots), io.support(IO.OUT), 's'); + } + + public String[] getRecipeViewerGrid(IO io) { + if (recipeViewerLayoutGridBuilders.containsKey(io)) return recipeViewerLayoutGridBuilders.get(io).buildGrid(layout); + return GTMuiWidgets.createGrid(layout.recipeType.getMaxSlots(cap, io), + Math.min(3, layout.recipeType.getMaxSlots(cap, io)), io.support(IO.OUT), 's'); } - maxSlots = Math.min(maxMachineSlots, maxSlots); - maxWidth = Math.min(maxSlots, maxWidth); - return GTMuiWidgets.createGrid(maxSlots, maxWidth, io.support(IO.OUT), key); + } + + @FunctionalInterface + public interface MachineCapabilityGridBuilder { + String[] buildGrid(MetaMachine machine, GTRecipeTypeUILayout layout); + } + + @FunctionalInterface + public interface RecipeViewerCapabilityGridBuilder { + String[] buildGrid(GTRecipeTypeUILayout layout); + } + + @FunctionalInterface + public interface ProgressWidgetSupplier { + Widget get(GTRecipeTypeUILayout layout, IDoubleValue value); } public static class Builder { - private UITexture progressBar; - private int progressSize; - private ProgressWidget.Direction fillDirection; - private Map, Int2ObjectOpenHashMap>> overlays = new EnumMap<>(IO.class); - private Map, Int2IntArrayMap>> gridLength = new EnumMap<>(IO.class); - private Map, Int2IntArrayMap>> gridWidths = new EnumMap<>(IO.class); + private UITexture progressBar = UITexture.DEFAULT; + private int progressSize = 10; + private ProgressWidget.Direction fillDirection = ProgressWidget.Direction.RIGHT; + + private final Map, CapabilityUIInfo> capabilityInfo = new Object2ObjectOpenHashMap<>(); + private final GTRecipeType recipeType; + private final List recipeUIModifiers = new ObjectArrayList<>(); + private @Nullable ProgressWidgetSupplier progressWidgetSupplier = null; + + private @Nullable Function customUIBuilder; + + public Builder(GTRecipeType recipeType) { + this.recipeType = recipeType; + + // Setup defaults + + getCapInfo(ItemRecipeCapability.CAP).machineLayoutBuilder = MachineCapabilityLayoutBuilder.ITEM; + getCapInfo(FluidRecipeCapability.CAP).machineLayoutBuilder = MachineCapabilityLayoutBuilder.FLUID; + getCapInfo(ItemRecipeCapability.CAP).recipeViewerLayoutBuilder = RecipeViewerCapabilityLayoutBuilder.ITEM; + getCapInfo(FluidRecipeCapability.CAP).recipeViewerLayoutBuilder = RecipeViewerCapabilityLayoutBuilder.FLUID; + getCapInfo(CWURecipeCapability.CAP).recipeViewerLayoutBuilder = RecipeViewerCapabilityLayoutBuilder.COMPUTATION; + getCapInfo(EURecipeCapability.CAP).recipeViewerLayoutBuilder = RecipeViewerCapabilityLayoutBuilder.EU; + + getCapInfo(ItemRecipeCapability.CAP).capabilityWidgetBuilder = CapabilityContentBuilder.ITEM; + getCapInfo(FluidRecipeCapability.CAP).capabilityWidgetBuilder = CapabilityContentBuilder.FLUID; + getCapInfo(CWURecipeCapability.CAP).capabilityWidgetBuilder = CapabilityContentBuilder.COMPUTATION; + getCapInfo(EURecipeCapability.CAP).capabilityWidgetBuilder = CapabilityContentBuilder.EU; + } + + private CapabilityUIInfo getCapInfo(RecipeCapability cap) { + return capabilityInfo.computeIfAbsent(cap, CapabilityUIInfo::new); + } + + /** + * Adds a slot overlay for a specific slot + * + * @param ioMode The IO of the slot + * @param slotIndex The index of the slot. + * @param cap The slot capability + * @param overlay The slot overlay. + */ public Builder setSlotOverlay(IO ioMode, int slotIndex, RecipeCapability cap, IDrawable overlay) { - overlays.computeIfAbsent(ioMode, it -> new Object2ReferenceOpenHashMap<>()) - .computeIfAbsent(cap, it -> new Int2ObjectOpenHashMap<>()) - .put(slotIndex, overlay); + getCapInfo(cap).overlays.computeIfAbsent(ioMode, $ -> new Int2ObjectOpenHashMap<>()) + .put(slotIndex, overlay); return this; } + /** + * Adds a slot overlay for an item slot + * + * @param ioMode The IO of the slot + * @param slotIndex The index of the slot. + * @param overlay The slot overlay. + */ public Builder setItemSlotOverlay(IO ioMode, int slotIndex, IDrawable overlay) { return setSlotOverlay(ioMode, slotIndex, ItemRecipeCapability.CAP, overlay); } + /** + * Adds a slot overlay for a fluid slot + * + * @param ioMode The IO of the slot + * @param slotIndex The index of the slot. + * @param overlay The slot overlay. + */ public Builder setFluidSlotOverlay(IO ioMode, int slotIndex, IDrawable overlay) { return setSlotOverlay(ioMode, slotIndex, FluidRecipeCapability.CAP, overlay); } + /** + * Adds a slot overlay for multiple item slots. + * + * @param ioMode The IO of the slot + * @param slotIndexStart The first item slot to add the overlay to. + * @param slotIndexEnd The last item slot to add the overlay to. + * @param overlay The slot overlay. + */ public Builder setItemSlotsOverlay(IO ioMode, int slotIndexStart, int slotIndexEnd, IDrawable overlay) { for (int i = slotIndexStart; i <= slotIndexEnd; i++) { setSlotOverlay(ioMode, i, ItemRecipeCapability.CAP, overlay); @@ -248,6 +199,14 @@ public Builder setItemSlotsOverlay(IO ioMode, int slotIndexStart, int slotIndexE return this; } + /** + * Adds a slot overlay for multiple fluid slots. + * + * @param ioMode The IO of the slot + * @param slotIndexStart The first fluid slot to add the overlay to. + * @param slotIndexEnd The last fluid slot to add the overlay to. + * @param overlay The slot overlay. + */ public Builder setFluidSlotsOverlay(IO ioMode, int slotIndexStart, int slotIndexEnd, IDrawable overlay) { for (int i = slotIndexStart; i <= slotIndexEnd; i++) { setSlotOverlay(ioMode, i, FluidRecipeCapability.CAP, overlay); @@ -255,10 +214,23 @@ public Builder setFluidSlotsOverlay(IO ioMode, int slotIndexStart, int slotIndex return this; } + /** + * Sets the texture and size of the progress bar + * + * @param progressBar Progress bar texture + * @param progressSize Progress bar size + */ public Builder setProgressBar(UITexture progressBar, int progressSize) { return setProgressBar(progressBar, progressSize, ProgressWidget.Direction.RIGHT); } + /** + * Sets the texture, size and fill direction of the progress bar + * + * @param progressBar Progress bar texture + * @param progressSize Progress bar size + * @param fillDirection Progress bar fill direction + */ public Builder setProgressBar(UITexture progressBar, int progressSize, ProgressWidget.Direction fillDirection) { this.progressBar = progressBar; this.progressSize = progressSize; @@ -266,46 +238,130 @@ public Builder setProgressBar(UITexture progressBar, int progressSize, ProgressW return this; } - public Builder setIOSlotLength(IO ioMode, RecipeCapability cap, int tier, int value) { - gridLength.computeIfAbsent(ioMode, it -> new Object2ReferenceOpenHashMap<>()) - .computeIfAbsent(cap, it -> new Int2IntArrayMap()) - .put(tier, value); + /** + * Sets a supplier which returns a widget to be used as a progress bar + * @param progressBarSupplier Progress widget supplier + */ + public Builder setProgressBarSupplier(ProgressWidgetSupplier progressBarSupplier) { + this.progressWidgetSupplier = progressBarSupplier; return this; } - public Builder setIOSlotLengths(IO ioMode, RecipeCapability cap, int startTier, int endTier, int value) { - for (int i = startTier; i <= endTier; i++) { - gridLength.computeIfAbsent(ioMode, it -> new Object2ReferenceOpenHashMap<>()) - .computeIfAbsent(cap, it -> new Int2IntArrayMap()) - .put(i, value); - } + /** + * For singleblock machines using this recipe type, sets a function that builds the ui for a specific capability + * type. + * + * @param cap The capability type + * @param builder UI builder. + */ + public Builder setMachineCapabilityLayoutBuilder(RecipeCapability cap, + MachineCapabilityLayoutBuilder builder) { + getCapInfo(cap).machineLayoutBuilder = builder; return this; } - public Builder setIOSlotWidth(IO ioMode, RecipeCapability cap, int tier, int value) { - gridWidths.computeIfAbsent(ioMode, it -> new Object2ReferenceOpenHashMap<>()) - .computeIfAbsent(cap, it -> new Int2IntArrayMap()) - .put(tier, value); + /** + * For singleblock machines using this recipe type, sets a function that builds the slot grid layout. + * + * @param cap The capability type + * @param gridBuilder Function that returns a {@code String[]}, where 's' should be used to denote a slot. + */ + public Builder setMachineLayoutGridBuilder(RecipeCapability cap, IO io, + MachineCapabilityGridBuilder gridBuilder) { + getCapInfo(cap).machineLayoutGridBuilders.put(io, gridBuilder); return this; } - public Builder setIOSlotWidths(IO ioMode, RecipeCapability cap, int startTier, int endTier, int value) { - for (int i = startTier; i <= endTier; i++) { - gridWidths.computeIfAbsent(ioMode, it -> new Object2ReferenceOpenHashMap<>()) - .computeIfAbsent(cap, it -> new Int2IntArrayMap()) - .put(i, value); - } + /** + * Loads a recipe type UI from a file.
+ * Loading a recipe type UI from a file will override some other builder options. + * + * @param fileName Filename + */ + public Builder loadRecipeTypeUIFromFile(String fileName) { + throw new NotImplementedException(); + } + + /** + * Sets a custom function which returns a flow to be used as the recipe viewer UI.
+ * Using a custom UI builder will override some other builder options. + * @param customUIBuilder Custom UI builder + */ + public Builder customRecipeTypeUI(Function customUIBuilder) { + this.customUIBuilder = customUIBuilder; + return this; + } + + /** + * For the recipe viewer UI, sets a function that builds the ui for a specific capability type. + * + * @param cap The capability type + * @param builder UI builder. + */ + public Builder setRecipeViewerLayoutCapabilityLayoutBuilder(RecipeCapability cap, + RecipeViewerCapabilityLayoutBuilder builder) { + getCapInfo(cap).recipeViewerLayoutBuilder = builder; + return this; + } + + /** + * For the recipe viewer UI, sets a function that builds the slot grid layout. + * + * @param cap The capability type + * @param gridBuilder Function that returns a {@code String[]}, where 's' should be used to denote a slot. + */ + public Builder setRecipeViewerLayoutGridBuilder(RecipeCapability cap, IO io, + RecipeViewerCapabilityGridBuilder gridBuilder) { + getCapInfo(cap).recipeViewerLayoutGridBuilders.put(io, gridBuilder); + return this; + } + + /** + * Sets a function that builds the slot grid layout for both machine and recipe viewer UI + * @param cap The capability + * @param io IO + * @param gridBuilder Function that returns a {@code String[]}, where 's' should be used to denote a slot. + */ + public Builder setLayoutGridBuilder(RecipeCapability cap, IO io, Function gridBuilder) { + setRecipeViewerLayoutGridBuilder(cap, io, gridBuilder::apply); + setMachineLayoutGridBuilder(cap, io, (m, l) -> gridBuilder.apply(l)); + return this; + } + + /** + * Adds a {@link RecipeUIModifier}, which modifies the recipe viewer UI after creation. Useful for adding extra information to recipe viewer recipes. + * @param recipeUIModifier Recipe UI modifier. + * @see RecipeUIModifier + */ + public Builder addRecipeUIModifier(RecipeUIModifier recipeUIModifier) { + recipeUIModifiers.add(recipeUIModifier); + return this; + } + + /** + * Defines a function used to map recipe contents to their slots.
+ * This should only be used for custom capabilities. + * @param cap Recipe capability + * @param contentBuilder Capability content builder + */ + public Builder setCapabilityContentBuilder(RecipeCapability cap, CapabilityContentBuilder contentBuilder) { + getCapInfo(cap).capabilityWidgetBuilder = contentBuilder; return this; } public GTRecipeTypeUILayout build() { - GTRecipeTypeUILayout layout = new GTRecipeTypeUILayout(); - layout.progressBar = progressBar; + var progressWidgetSupplier = this.progressWidgetSupplier; + if (progressWidgetSupplier == null) progressWidgetSupplier = (l, v) -> new ProgressWidget() + .value(v) + .name("progressBar") + .texture(l.getProgressBar(), l.getProgressSize()) + .size(l.getProgressSize()) + .direction(l.getProgressDirection()); + + var layout = new GTRecipeTypeUILayout(recipeType, capabilityInfo, recipeUIModifiers, progressWidgetSupplier, customUIBuilder); layout.progressSize = progressSize; layout.progressDirection = fillDirection; - layout.overlays = overlays; - layout.gridLength = gridLength; - layout.gridWidths = gridWidths; + layout.progressBar = progressBar; return layout; } } diff --git a/src/main/java/com/gregtechceu/gtceu/api/recipe/gui/GTRecipeTypeUIs.java b/src/main/java/com/gregtechceu/gtceu/api/recipe/gui/GTRecipeTypeUIs.java deleted file mode 100644 index 4ef04d6e89b..00000000000 --- a/src/main/java/com/gregtechceu/gtceu/api/recipe/gui/GTRecipeTypeUIs.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.gregtechceu.gtceu.api.recipe.gui; - -import com.gregtechceu.gtceu.api.recipe.GTRecipeType; - -import java.util.HashMap; -import java.util.Map; - -public class GTRecipeTypeUIs { - - public static Map recipeTypeUIs = new HashMap<>(); - - public static void addRecipeTypeUI(GTRecipeType recipeType, GTRecipeTypeUILayout layout) { - recipeTypeUIs.put(recipeType, layout); - } -} diff --git a/src/main/java/com/gregtechceu/gtceu/api/recipe/gui/GTRecipeViewerUILayout.java b/src/main/java/com/gregtechceu/gtceu/api/recipe/gui/GTRecipeViewerUILayout.java deleted file mode 100644 index 32807be3015..00000000000 --- a/src/main/java/com/gregtechceu/gtceu/api/recipe/gui/GTRecipeViewerUILayout.java +++ /dev/null @@ -1,120 +0,0 @@ -package com.gregtechceu.gtceu.api.recipe.gui; - -import com.gregtechceu.gtceu.api.GTValues; -import com.gregtechceu.gtceu.api.capability.recipe.IO; -import com.gregtechceu.gtceu.api.capability.recipe.ItemRecipeCapability; -import com.gregtechceu.gtceu.common.mui.GTGuiTextures; - -import brachy.modularui.api.drawable.IDrawable; -import brachy.modularui.widget.ParentWidget; -import brachy.modularui.widgets.ProgressWidget; -import brachy.modularui.widgets.SlotGroupWidget; -import brachy.modularui.widgets.layout.Flow; -import it.unimi.dsi.fastutil.objects.Object2ReferenceOpenHashMap; - -import java.util.ArrayList; -import java.util.Map; - -public class GTRecipeViewerUILayout { - - public final GTRecipeTypeUILayout layout; - - private ParentWidget> overrideWidget; - - public GTRecipeViewerUILayout(GTRecipeTypeUILayout layout) { - this.layout = layout; - } - - public GTRecipeViewerUILayout overrideWidget(ParentWidget> overrideWidget) { - this.overrideWidget = overrideWidget; - return this; - } - - public ParentWidget getRecipeWidget() { - if (layout.getRecipeType() != null) { - var parentWidget = new ParentWidget<>(); - parentWidget.coverChildren(); - var slotsRow = Flow.row(); - slotsRow.coverChildrenHeight(); - - int rowWidthPx = 0; - - Map> colWidgetGroups = new Object2ReferenceOpenHashMap<>(); - - int slotLeftShiftPx = 0; - for (var io : layout.getIOs()) { - boolean in = io == IO.IN; - - var caps = (in ? layout.getRecipeType().maxInputs : layout.getRecipeType().maxOutputs); - int slotGroupHeightPx = 0; - - Flow ioColumn = Flow.col(); - // ioColumn.coverChildrenWidth(); - int slotGroupWidthPx = 0; - - var widgetGroups = new ArrayList>(); - - for (var recipeCap : caps.keySet()) { - int maxRecipeTypeSlots = caps.get(recipeCap); - - var grid = layout.createGrid(io, recipeCap, 's', GTValues.MAX, Integer.MAX_VALUE); - - slotGroupHeightPx += 18 * grid.length; - - IDrawable defaultSlotBackground = (recipeCap == ItemRecipeCapability.CAP ? - GTGuiTextures.SLOT : GTGuiTextures.FLUID_SLOT); - - SlotGroupWidget.Builder slotWidgetBuilder = SlotGroupWidget.builder() - .matrix(grid); - var overlays = layout.getOverlays(); - slotWidgetBuilder.key('s', i -> { - var widget = new IDrawable.DrawableWidget(defaultSlotBackground); - if (overlays.containsKey(io) && overlays.get(io).containsKey(recipeCap)) { - widget.overlay(overlays.get(io).get(recipeCap).get(i)); - } - return widget; - }); - - // calculate full width of each column - slotGroupWidthPx = Math.max(slotGroupWidthPx, Math.min(maxRecipeTypeSlots, grid[0].length()) * 18); - - widgetGroups.add(slotWidgetBuilder.build() - .name(recipeCap.name + "_" + io.name()) - .leftRel(io == IO.IN ? 0 : 1)); - } - - ioColumn.size(slotGroupWidthPx, slotGroupHeightPx); - for (var g : widgetGroups) { - ioColumn.child(g); - } - slotLeftShiftPx += (slotGroupWidthPx / 2) * ((io == io.IN) ? -1 : 1); - - rowWidthPx += slotGroupWidthPx; - colWidgetGroups.put(io, ioColumn); - } - // 2 px padding plus each half of the progress bar (1) - slotsRow.childPadding((layout.getProgressSize() / 2) + 2); - for (var ioColumn : colWidgetGroups.entrySet()) { - var col = ioColumn.getValue(); - var io = ioColumn.getKey(); - slotsRow.child(col.posRel(io == IO.IN ? 0f : 1f, 0.5f)); - } - - // same padding as (1) + half a slot on each side - rowWidthPx += layout.getProgressSize() + 4 + 18; - slotsRow.width(rowWidthPx); - - parentWidget.child(slotsRow.left(slotLeftShiftPx)); - - parentWidget.child(new ProgressWidget() - .center() - // .progress(() -> 0.5f) - .name("progressBar") - .texture(layout.getProgressBar(), layout.getProgressSize()) - .size(layout.getProgressSize()) - .direction(layout.getProgressDirection())); - return parentWidget; - } - return new ParentWidget<>(); - } -} diff --git a/src/main/java/com/gregtechceu/gtceu/api/recipe/gui/GTRecipeViewerWidget.java b/src/main/java/com/gregtechceu/gtceu/api/recipe/gui/GTRecipeViewerWidget.java new file mode 100644 index 00000000000..0fe47332c35 --- /dev/null +++ b/src/main/java/com/gregtechceu/gtceu/api/recipe/gui/GTRecipeViewerWidget.java @@ -0,0 +1,240 @@ +package com.gregtechceu.gtceu.api.recipe.gui; + +import brachy.modularui.api.drawable.IDrawable; +import brachy.modularui.api.drawable.IIcon; +import brachy.modularui.api.drawable.Text; +import brachy.modularui.api.widget.IWidget; +import brachy.modularui.drawable.Rectangle; +import brachy.modularui.utils.Alignment; +import brachy.modularui.utils.Color; +import brachy.modularui.utils.MouseData; +import brachy.modularui.value.DoubleValue; +import brachy.modularui.widget.WidgetTree; +import brachy.modularui.widgets.ButtonWidget; +import brachy.modularui.widgets.ListWidget; +import com.gregtechceu.gtceu.GTCEu; +import com.gregtechceu.gtceu.api.GTValues; +import com.gregtechceu.gtceu.api.capability.recipe.IO; +import com.gregtechceu.gtceu.api.capability.recipe.RecipeCapability; +import com.gregtechceu.gtceu.api.recipe.GTRecipe; + +import brachy.modularui.widget.ParentWidget; +import brachy.modularui.widgets.layout.Flow; +import com.gregtechceu.gtceu.api.recipe.GTRecipeType; +import com.gregtechceu.gtceu.api.recipe.OverclockingLogic; +import com.gregtechceu.gtceu.api.recipe.RecipeHelper; +import com.gregtechceu.gtceu.api.recipe.content.Content; +import com.gregtechceu.gtceu.api.recipe.ingredient.EnergyStack; +import com.gregtechceu.gtceu.common.data.GTRecipeTypes; +import com.gregtechceu.gtceu.common.machine.multiblock.electric.FusionReactorMachine; +import com.gregtechceu.gtceu.utils.FormattingUtil; +import net.minecraft.client.Minecraft; +import net.minecraft.network.chat.Component; +import net.minecraftforge.fml.loading.FMLLoader; +import org.lwjgl.glfw.GLFW; + +import java.util.HashSet; +import java.util.List; +import java.util.Objects; + +import static com.gregtechceu.gtceu.api.GTValues.ULV; +import static com.gregtechceu.gtceu.api.GTValues.V; + +public class GTRecipeViewerWidget extends ParentWidget { + + private final GTRecipe baseRecipe; + + private GTRecipe modifiedRecipe; + + private final GTRecipeType recipeType; + private final GTRecipeTypeUILayout uiLayout; + + public final ListWidget textComponents = new ListWidget<>() + .widthRel(1f) + .coverChildrenHeight() + .childSeparator(IIcon.EMPTY_2PX) + .crossAxisAlignment(Alignment.CrossAxis.START) + .collapseDisabledChildren(); + public final Flow inputColumn = Flow.col().coverChildren().crossAxisAlignment(Alignment.CrossAxis.START); + public final Flow outputColumn = Flow.col().coverChildren().crossAxisAlignment(Alignment.CrossAxis.START); + public final Flow recipeContentRow; + public final ParentWidget additionalRecipeContent = new ParentWidget<>() + .coverChildrenHeight().widthRel(1f); + + private final int minTier; + private int tier; + + public GTRecipeViewerWidget(GTRecipe recipe) { + this.baseRecipe = recipe; + this.recipeType = recipe.getType(); + + modifiedRecipe = recipe; + + uiLayout = Objects.requireNonNull(recipe.getType().getUiLayout(), "No recipe type UI declared, add one to your recipe type definition."); + + minTier = RecipeHelper.getRecipeEUtTier(recipe); + tier = minTier; + boolean isEnergyIn = RecipeHelper.getRealEUtWithIO(recipe).isInput(); + Flow mainColumn = Flow.col().widthRel(1f).coverChildrenHeight(); + + child(mainColumn); + padding(3); + coverChildrenWidth(150); + coverChildrenHeight(60); + + // Attach duration here so it is always the first text row + textComponents.child(Text.dynamic(() -> Component.translatable("gtceu.recipe.duration", FormattingUtil.formatNumbers((double)modifiedRecipe.duration/20))) + .asWidget() + .setEnabledIf(v -> !modifiedRecipe.data.getBoolean("hide_duration")) + ); + + recipeContentRow = uiLayout.getCustomUIBuilder() == null ? buildDefaultLayout() : uiLayout.getCustomUIBuilder().apply(recipe); + mainColumn.child(recipeContentRow.marginTop(5).marginBottom(3)); + mainColumn.child(additionalRecipeContent.child(textComponents)); + + loadContentIntoSlots(); + + buildAdditionalRecipeContent(); + + childIf(isEnergyIn, this::buildOverclockButton); + + childIf(!FMLLoader.isProduction(), () -> new ButtonWidget<>() + .overlay(Text.str("ID")) + .decoration() + .top(3).right(3) + .size(15, 15) + .tooltip(r -> r.addLine("Click to copy recipe ID: " + recipe.id)) + .onMousePressed((ctx, b) -> { + Minecraft.getInstance().keyboardHandler.setClipboard(recipe.id.toString()); + return true; + }) + ); + } + + private Flow buildDefaultLayout() { + var row = Flow.row() + .horizontalCenter() + .coverChildren() + .child(inputColumn) + .child(uiLayout.getProgressWidgetSupplier().get(uiLayout, DoubleValue.simulateProgress(2000)).paddingLeft(2 + uiLayout.getProgressSize()/2)) + .child(outputColumn); + for (var entry: recipeType.maxInputs.object2IntEntrySet()) { + var layoutFunc = uiLayout.capabilityInfo(entry.getKey()).recipeViewerLayoutBuilder; + if (layoutFunc == null || entry.getIntValue() == 0) continue; + layoutFunc.createCapabilityUILayout(uiLayout, this, IO.IN); + } + + for (var entry: recipeType.maxOutputs.object2IntEntrySet()) { + var layoutFunc = uiLayout.capabilityInfo(entry.getKey()).recipeViewerLayoutBuilder; + if (layoutFunc == null || entry.getIntValue() == 0) continue; + layoutFunc.createCapabilityUILayout(uiLayout, this, IO.OUT); + } + return row; + } + + public static String capabilityWidgetName(RecipeCapability cap, IO io, int index) { + return "%s_%s_%s".formatted(cap.name, io.toString().toLowerCase(), index); + } + + private void loadContentIntoSlots() { + var allInputCaps = new HashSet<>(modifiedRecipe.inputs.keySet()); + allInputCaps.addAll(modifiedRecipe.tickInputs.keySet()); + var allOutputCaps = new HashSet<>(modifiedRecipe.outputs.keySet()); + allOutputCaps.addAll(modifiedRecipe.tickOutputs.keySet()); + + for (var cap: allInputCaps) { + loadCapContent(cap, IO.IN); + } + + for (var cap: allOutputCaps) { + loadCapContent(cap, IO.OUT); + } + } + + private void loadCapContent(RecipeCapability cap, IO io) { + List contents = io == IO.IN ? modifiedRecipe.getInputContents(cap) : modifiedRecipe.getOutputContents(cap); + List tickContents = io == IO.IN ? modifiedRecipe.getTickInputContents(cap) : modifiedRecipe.getTickOutputContents(cap); + + var widgetBuilder = uiLayout.capabilityInfo(cap).capabilityWidgetBuilder; + if (widgetBuilder == null) return; + + int currentContentIndex = 0; + + for (var content: contents) { + IWidget widget = WidgetTree.findFirstWithNameNullable(this, capabilityWidgetName(cap, io, currentContentIndex)); + if (widget == null) continue; + widgetBuilder.buildWidgetContent(widget, content, io, false, recipeType, modifiedRecipe, tier, tier); + currentContentIndex++; + } + + for (var tickContent: tickContents) { + IWidget widget = WidgetTree.findFirstWithNameNullable(this, capabilityWidgetName(cap, io, currentContentIndex)); + if (widget == null) continue; + widgetBuilder.buildWidgetContent(widget, tickContent, io, true, recipeType, modifiedRecipe, tier, tier); + currentContentIndex++; + } + } + + private void buildAdditionalRecipeContent() { + for (var condition: baseRecipe.conditions) { + condition.modifyUI().buildRecipeUI(baseRecipe, this); + } + + uiLayout.getRecipeUIModifiers().forEach(v -> v.buildRecipeUI(baseRecipe, this)); + } + + private ButtonWidget buildOverclockButton() { + return new ButtonWidget<>().background(IDrawable.NONE) + .hoverBackground(IDrawable.NONE) + .size(22, 15) + .bottomRel(0).rightRel(0) + .decoration() + .overlay(Text.dynamic(() -> Component.literal(GTValues.VNF[tier]))) + .tooltipBuilder(tooltip -> tooltip.addLine(Text.lang("gtceu.oc.tooltip", GTValues.VNF[minTier]))) + .onMousePressed((ctx, b) -> { + GTCEu.LOGGER.info("Row: {} x {}", recipeContentRow.getArea().w(), recipeContentRow.getArea().h()); + GTCEu.LOGGER.info("In: {} x {}", inputColumn.getArea().w(), inputColumn.getArea().h()); + GTCEu.LOGGER.info("Out: {} x {}", outputColumn.getArea().w(), outputColumn.getArea().h()); + GTCEu.LOGGER.info("Total: {} x {}", getArea().w(), getArea().h()); + var mouse = MouseData.create(b); + + OverclockingLogic oc = OverclockingLogic.NON_PERFECT_OVERCLOCK; + + if (b == GLFW.GLFW_MOUSE_BUTTON_LEFT) { + if (tier == GTValues.MAX) return true; + tier++; + } else if (b == GLFW.GLFW_MOUSE_BUTTON_RIGHT) { + if (tier == minTier) return true; + tier--; + } else if (b == GLFW.GLFW_MOUSE_BUTTON_MIDDLE) { + tier = minTier; + } + + if (mouse.shift()) oc = OverclockingLogic.PERFECT_OVERCLOCK; + if (modifiedRecipe.recipeType == GTRecipeTypes.FUSION_RECIPES) { + oc = FusionReactorMachine.FUSION_OC; + } + + applyOverclock(oc); + return true; + }); + } + + private void applyOverclock(OverclockingLogic logic) { + EnergyStack inputEUt = baseRecipe.getInputEUt(); + + if (tier > minTier && !inputEUt.isEmpty()) { + int ocs = tier - minTier; + if (minTier == ULV) ocs--; + var params = new OverclockingLogic.OCParams(inputEUt.voltage(), modifiedRecipe.duration, ocs, 1); + var modifier = logic.runOverclockingLogic(params, V[tier]).toModifier(); + + modifiedRecipe = Objects.requireNonNull(modifier.apply(baseRecipe)); + } else { + modifiedRecipe = baseRecipe; + } + + loadContentIntoSlots(); + } + +} diff --git a/src/main/java/com/gregtechceu/gtceu/api/recipe/gui/MachineCapabilityLayoutBuilder.java b/src/main/java/com/gregtechceu/gtceu/api/recipe/gui/MachineCapabilityLayoutBuilder.java new file mode 100644 index 00000000000..335b4c6acce --- /dev/null +++ b/src/main/java/com/gregtechceu/gtceu/api/recipe/gui/MachineCapabilityLayoutBuilder.java @@ -0,0 +1,101 @@ +package com.gregtechceu.gtceu.api.recipe.gui; + +import com.gregtechceu.gtceu.api.capability.recipe.FluidRecipeCapability; +import com.gregtechceu.gtceu.api.capability.recipe.IO; +import com.gregtechceu.gtceu.api.capability.recipe.ItemRecipeCapability; +import com.gregtechceu.gtceu.api.machine.MetaMachine; +import com.gregtechceu.gtceu.api.machine.SimpleTieredMachine; +import com.gregtechceu.gtceu.api.machine.steam.SimpleSteamMachine; +import com.gregtechceu.gtceu.api.machine.trait.NotifiableFluidTank; +import com.gregtechceu.gtceu.api.machine.trait.NotifiableItemStackHandler; + +import brachy.modularui.widgets.SlotGroupWidget; +import brachy.modularui.widgets.slot.FluidSlot; +import brachy.modularui.widgets.slot.ItemSlot; +import brachy.modularui.widgets.slot.ModularSlot; +import brachy.modularui.widgets.slot.SlotGroup; + +/** + * Builds and attaches the UI for a specific capability in a singleblock recipe machine UI. + */ +@FunctionalInterface +public interface MachineCapabilityLayoutBuilder { + + /** + * Builds and attaches the UI for a specific capability in a singleblock recipe machine UI. + * + * @param machine The singleblock machine, will be either a {@link SimpleTieredMachine} or + * {@link SimpleSteamMachine}. + * @param layout The {@link GTRecipeTypeUILayout} which holds UI layout data. + * @param widget The recipe type widget. Generally, UIs should be attached to either {@link GTRecipeTypeMachineWidget#inputColumn} or {@link GTRecipeTypeMachineWidget#outputColumn}. + * @param io The IO mode widgets are being created for. + */ + void createCapabilityUILayout(MetaMachine machine, GTRecipeTypeUILayout layout, GTRecipeTypeMachineWidget widget, IO io); + + /** + * The default UI layout for item slots. + */ + MachineCapabilityLayoutBuilder ITEM = (machine, layout, widget, io) -> { + + NotifiableItemStackHandler itemHandler = ItemRecipeCapability.CAP.getCapabilityHandler(machine, io); + if (itemHandler == null || layout.getRecipeType().getMaxSlots(ItemRecipeCapability.CAP, io) == 0) return; + + var slotGroup = new SlotGroup(ItemRecipeCapability.CAP.name + "_" + io.name(), 3); + + if (layout.getRecipeType().getMaxSlots(ItemRecipeCapability.CAP, io) == 1) { + var slot = new ItemSlot() + .slot(new ModularSlot(itemHandler, 0) + .slotGroup(slotGroup) + .accessibility(io == IO.IN, true)) + .backgroundOverlay(layout.capabilityInfo(ItemRecipeCapability.CAP).getOverlay(io, 0)); + if (io == IO.IN) widget.inputColumn.child(slot); + else widget.outputColumn.child(slot); + return; + } + + var slotGroupWidget = SlotGroupWidget + .builder() + .matrix(layout.capabilityInfo(ItemRecipeCapability.CAP).getMachineGrid(io, machine)) + .key('s', i -> new ItemSlot() + .slot(new ModularSlot(itemHandler, i) + .slotGroup(slotGroup) + .accessibility(io == IO.IN, true)) + .backgroundOverlay(layout.capabilityInfo(ItemRecipeCapability.CAP).getOverlay(io, i))) + .build() + .size(18, 18) + .coverChildren(18, 18); + + if (io == IO.IN) widget.inputColumn.child(slotGroupWidget); + else widget.outputColumn.child(slotGroupWidget); + }; + + /** + * The default UI layout for fluid slots. + */ + MachineCapabilityLayoutBuilder FLUID = (machine, layout, widget, io) -> { + + NotifiableFluidTank fluidTank = FluidRecipeCapability.CAP.getCapabilityHandler(machine, io); + if (fluidTank == null || layout.getRecipeType().getMaxSlots(FluidRecipeCapability.CAP, io) == 0) return; + + if (layout.getRecipeType().getMaxSlots(FluidRecipeCapability.CAP, io) == 1) { + var slot = new FluidSlot() + .tank(fluidTank.getStorages()[0]) + .backgroundOverlay(layout.capabilityInfo(FluidRecipeCapability.CAP).getOverlay(io, 0)); + if (io == IO.IN) widget.inputColumn.child(slot); + else widget.outputColumn.child(slot); + return; + } + + var slotGroupWidget = SlotGroupWidget.builder() + .matrix(layout.capabilityInfo(FluidRecipeCapability.CAP).getMachineGrid(io, machine)) + .key('s', i -> new FluidSlot() + .tank(fluidTank.getStorages()[i]) + .backgroundOverlay(layout.capabilityInfo(FluidRecipeCapability.CAP).getOverlay(io, i))) + .build() + .size(18, 18) + .coverChildren(); + + if (io == IO.IN) widget.inputColumn.child(slotGroupWidget); + else widget.outputColumn.child(slotGroupWidget); + }; +} diff --git a/src/main/java/com/gregtechceu/gtceu/api/recipe/gui/RecipeUIModifier.java b/src/main/java/com/gregtechceu/gtceu/api/recipe/gui/RecipeUIModifier.java new file mode 100644 index 00000000000..00ab4218837 --- /dev/null +++ b/src/main/java/com/gregtechceu/gtceu/api/recipe/gui/RecipeUIModifier.java @@ -0,0 +1,38 @@ +package com.gregtechceu.gtceu.api.recipe.gui; + +import com.gregtechceu.gtceu.api.recipe.GTRecipe; + +import brachy.modularui.api.drawable.Text; + +@FunctionalInterface +public interface RecipeUIModifier { + + void buildRecipeUI(GTRecipe recipe, GTRecipeViewerWidget widget); + + /** + * A recipe ui modifier that adds a line of the text to the recipe UI + * + * @param text Text to add + * @return Recipe ui modifier + */ + static RecipeUIModifier textLine(Text text) { + return (recipe, widget) -> widget.textComponents.child(text.asWidget()); + } + + default RecipeUIModifier then(RecipeUIModifier... modifiers) { + return (recipe, widget) -> { + buildRecipeUI(recipe, widget); + for (var modifier : modifiers) { + modifier.buildRecipeUI(recipe, widget); + } + }; + } + + static RecipeUIModifier all(RecipeUIModifier... modifiers) { + return (recipe, widget) -> { + for (var modifier : modifiers) { + modifier.buildRecipeUI(recipe, widget); + } + }; + } +} diff --git a/src/main/java/com/gregtechceu/gtceu/api/recipe/gui/RecipeViewerCapabilityLayoutBuilder.java b/src/main/java/com/gregtechceu/gtceu/api/recipe/gui/RecipeViewerCapabilityLayoutBuilder.java new file mode 100644 index 00000000000..c74ef44c181 --- /dev/null +++ b/src/main/java/com/gregtechceu/gtceu/api/recipe/gui/RecipeViewerCapabilityLayoutBuilder.java @@ -0,0 +1,112 @@ +package com.gregtechceu.gtceu.api.recipe.gui; + +import brachy.modularui.drawable.GuiTextures; +import brachy.modularui.integration.recipeviewer.RecipeViewerSlotWidget; +import brachy.modularui.integration.recipeviewer.entry.fluid.FluidStackList; +import brachy.modularui.integration.recipeviewer.entry.item.ItemStackList; +import brachy.modularui.utils.Alignment; +import brachy.modularui.widgets.SlotGroupWidget; +import brachy.modularui.widgets.layout.Flow; +import com.gregtechceu.gtceu.api.capability.recipe.*; +import net.minecraft.world.item.ItemStack; +import net.minecraftforge.fluids.FluidStack; + +/** + * Builds and attaches the UI for a specific capability in a recipe viewer UI. + */ +@FunctionalInterface +public interface RecipeViewerCapabilityLayoutBuilder { + + /** + * Builds and attaches the UI for a specific capability in a recipe viewer UI. + * + * @param layout The {@link GTRecipeTypeUILayout} which holds UI layout data. + * @param widget The {@link GTRecipeViewerWidget} recipe widget. + * @param io The IO mode widgets are being created for. + */ + void createCapabilityUILayout(GTRecipeTypeUILayout layout, GTRecipeViewerWidget widget, IO io); + + /** + * The default recipe viewer UI layout for item slots. + */ + RecipeViewerCapabilityLayoutBuilder ITEM = (layout, widget, io) -> { + + if (layout.getRecipeType().getMaxSlots(ItemRecipeCapability.CAP, io) == 0) return; + + if (layout.getRecipeType().getMaxSlots(ItemRecipeCapability.CAP, io) == 1) { + var slot = RecipeViewerSlotWidget.create().value(ItemStackList.of(ItemStack.EMPTY)) + .background(GuiTextures.SLOT_ITEM, layout.capabilityInfo(ItemRecipeCapability.CAP).getOverlay(io, 0)) + .name(GTRecipeViewerWidget.capabilityWidgetName(ItemRecipeCapability.CAP, io, 0)); + if (io == IO.IN) widget.inputColumn.child(slot); + else widget.outputColumn.child(slot); + return; + } + + var slotGroupWidget = SlotGroupWidget + .builder() + .matrix(layout.capabilityInfo(ItemRecipeCapability.CAP).getRecipeViewerGrid(io)) + .key('s', i -> + RecipeViewerSlotWidget.create().value(ItemStackList.of(ItemStack.EMPTY)) + .background(GuiTextures.SLOT_ITEM, layout.capabilityInfo(ItemRecipeCapability.CAP).getOverlay(io, i)) + .name(GTRecipeViewerWidget.capabilityWidgetName(ItemRecipeCapability.CAP, io, i)) + ) + .build() + .coverChildren(18, 18); + + if (io == IO.IN) widget.inputColumn.child(slotGroupWidget); + else widget.outputColumn.child(slotGroupWidget); + }; + + /** + * The default recipe viewer UI layout for fluid slots. + */ + RecipeViewerCapabilityLayoutBuilder FLUID = (layout, widget, io) -> { + + if (layout.getRecipeType().getMaxSlots(FluidRecipeCapability.CAP, io) == 0) return; + + if (layout.getRecipeType().getMaxSlots(FluidRecipeCapability.CAP, io) == 1) { + var slot = RecipeViewerSlotWidget.create().value(FluidStackList.of(FluidStack.EMPTY)) + .background(GuiTextures.SLOT_FLUID, layout.capabilityInfo(FluidRecipeCapability.CAP).getOverlay(io, 0)) + .name(GTRecipeViewerWidget.capabilityWidgetName(FluidRecipeCapability.CAP, io, 0)); + if (io == IO.IN) widget.inputColumn.child(slot); + else widget.outputColumn.child(slot); + return; + } + + + var slotGroupWidget = SlotGroupWidget.builder() + .matrix(layout.capabilityInfo(FluidRecipeCapability.CAP).getRecipeViewerGrid(io)) + .key('s', i -> + RecipeViewerSlotWidget.create().value(FluidStackList.of(FluidStack.EMPTY)) + .background(GuiTextures.SLOT_FLUID, layout.capabilityInfo(FluidRecipeCapability.CAP).getOverlay(io, i)) + .name(GTRecipeViewerWidget.capabilityWidgetName(FluidRecipeCapability.CAP, io, i)) + ) + .build() + .coverChildren(18, 18); + + if (io == IO.IN) widget.inputColumn.child(slotGroupWidget); + else widget.outputColumn.child(slotGroupWidget); + }; + + RecipeViewerCapabilityLayoutBuilder COMPUTATION = (layout, widget, io) -> { + if (layout.getRecipeType().getMaxSlots(CWURecipeCapability.CAP, io) == 0) return; + + var computationInfo = Flow.col().childPadding(2) + .coverChildrenHeight() + .widthRel(1f) + .crossAxisAlignment(Alignment.CrossAxis.START) + .name(GTRecipeViewerWidget.capabilityWidgetName(CWURecipeCapability.CAP, io, 0)); + + widget.textComponents.child(computationInfo); + }; + + RecipeViewerCapabilityLayoutBuilder EU = (layout, widget, io) -> { + if (layout.getRecipeType().getMaxSlots(EURecipeCapability.CAP, io) == 0) return; + + widget.textComponents.child(Flow.col().childPadding(2) + .coverChildrenHeight() + .widthRel(1f) + .crossAxisAlignment(Alignment.CrossAxis.START) + .name(GTRecipeViewerWidget.capabilityWidgetName(EURecipeCapability.CAP, io, 0))); + }; +} diff --git a/src/main/java/com/gregtechceu/gtceu/api/recipe/gui/package-info.java b/src/main/java/com/gregtechceu/gtceu/api/recipe/gui/package-info.java new file mode 100644 index 00000000000..1b346671819 --- /dev/null +++ b/src/main/java/com/gregtechceu/gtceu/api/recipe/gui/package-info.java @@ -0,0 +1,4 @@ +@NotNullByDefault +package com.gregtechceu.gtceu.api.recipe.gui; + +import org.jetbrains.annotations.NotNullByDefault; \ No newline at end of file diff --git a/src/main/java/com/gregtechceu/gtceu/api/recipe/lookup/RecipeDB.java b/src/main/java/com/gregtechceu/gtceu/api/recipe/lookup/RecipeDB.java index a7862af48d3..27932ac01b9 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/recipe/lookup/RecipeDB.java +++ b/src/main/java/com/gregtechceu/gtceu/api/recipe/lookup/RecipeDB.java @@ -75,7 +75,8 @@ public void clear() { @VisibleForTesting public @Nullable GTRecipe find(@NotNull List> list, @NotNull Predicate predicate) { - return (new RecipeIterator(this, list, predicate)).next(); + var iter = new RecipeIterator(this, list, predicate); + return iter.hasNext() ? iter.next() : null; } /** @@ -174,7 +175,7 @@ boolean add(@NotNull GTRecipe recipe, @NotNull List<@Unmodifiable List { private final Deque stack = new ArrayDeque<>(); + private @Nullable GTRecipe nextCached = null; + private boolean hasCached = false; + @VisibleForTesting public RecipeIterator(@NotNull RecipeDB db, @NotNull List> ingredients, @@ -298,13 +302,7 @@ public RecipeIterator(@NotNull RecipeDB db, } } - @Override - public boolean hasNext() { - return !stack.isEmpty(); - } - - @Override - public GTRecipe next() { + private @Nullable GTRecipe getNext() { while (!stack.isEmpty()) { // We stay on one frame until all ingredients have been checked SearchFrame frame = stack.peek(); @@ -343,6 +341,23 @@ public GTRecipe next() { return null; // no more recipes } + @Override + public boolean hasNext() { + if (!hasCached) { + nextCached = getNext(); + hasCached = true; + } + return nextCached != null; + } + + @Override + public GTRecipe next() { + if (!hasCached) nextCached = getNext(); + hasCached = false; + if (nextCached == null) throw new NoSuchElementException(); + return nextCached; + } + /** * Reset the iterator */ diff --git a/src/main/java/com/gregtechceu/gtceu/api/recipe/lookup/StagingRecipeDB.java b/src/main/java/com/gregtechceu/gtceu/api/recipe/lookup/StagingRecipeDB.java index 131a26e5b55..cc8928f522e 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/recipe/lookup/StagingRecipeDB.java +++ b/src/main/java/com/gregtechceu/gtceu/api/recipe/lookup/StagingRecipeDB.java @@ -88,7 +88,7 @@ public void populateDB(@NotNull RecipeDB db) { private static @NotNull List compressedContent(@NotNull List list, @NotNull RecipeCapability cap) { var contentList = list.stream() - .map(Content::getContent) + .map(Content::content) .toList(); return cap.compressIngredients(contentList); } @@ -106,7 +106,7 @@ public void populateDB(@NotNull RecipeDB db) { List, Object>> list = new ArrayList<>(); map.forEach((k, v) -> { for (var content : v) { - list.add(Pair.of(k, content.getContent())); + list.add(Pair.of(k, content.content())); } }); return list; diff --git a/src/main/java/com/gregtechceu/gtceu/api/recipe/ui/GTRecipeTypeUI.java b/src/main/java/com/gregtechceu/gtceu/api/recipe/ui/GTRecipeTypeUI.java deleted file mode 100644 index 65d9bdcacaa..00000000000 --- a/src/main/java/com/gregtechceu/gtceu/api/recipe/ui/GTRecipeTypeUI.java +++ /dev/null @@ -1,432 +0,0 @@ -package com.gregtechceu.gtceu.api.recipe.ui; - -import com.gregtechceu.gtceu.GTCEu; -import com.gregtechceu.gtceu.api.capability.recipe.FluidRecipeCapability; -import com.gregtechceu.gtceu.api.capability.recipe.IO; -import com.gregtechceu.gtceu.api.capability.recipe.ItemRecipeCapability; -import com.gregtechceu.gtceu.api.capability.recipe.RecipeCapability; -import com.gregtechceu.gtceu.api.gui.GuiTextures; -import com.gregtechceu.gtceu.api.gui.SteamTexture; -import com.gregtechceu.gtceu.api.gui.WidgetUtils; -import com.gregtechceu.gtceu.api.gui.editor.IEditableUI; -import com.gregtechceu.gtceu.api.gui.widget.DualProgressWidget; -import com.gregtechceu.gtceu.api.gui.widget.SlotWidget; -import com.gregtechceu.gtceu.api.gui.widget.TankWidget; -import com.gregtechceu.gtceu.api.recipe.GTRecipe; -import com.gregtechceu.gtceu.api.recipe.GTRecipeType; -import com.gregtechceu.gtceu.api.recipe.RecipeCondition; -import com.gregtechceu.gtceu.api.recipe.category.GTRecipeCategory; -import com.gregtechceu.gtceu.integration.emi.recipe.GTRecipeEMICategory; -import com.gregtechceu.gtceu.integration.jei.recipe.GTRecipeJEICategory; -import com.gregtechceu.gtceu.integration.rei.recipe.GTRecipeREICategory; - -import com.lowdragmc.lowdraglib.gui.editor.configurator.IConfigurableWidget; -import com.lowdragmc.lowdraglib.gui.editor.data.Resources; -import com.lowdragmc.lowdraglib.gui.texture.GuiTextureGroup; -import com.lowdragmc.lowdraglib.gui.texture.IGuiTexture; -import com.lowdragmc.lowdraglib.gui.texture.ProgressTexture; -import com.lowdragmc.lowdraglib.gui.texture.ResourceTexture; -import com.lowdragmc.lowdraglib.gui.widget.ButtonWidget; -import com.lowdragmc.lowdraglib.gui.widget.ProgressWidget; -import com.lowdragmc.lowdraglib.gui.widget.Widget; -import com.lowdragmc.lowdraglib.gui.widget.WidgetGroup; -import com.lowdragmc.lowdraglib.jei.JEIPlugin; -import com.lowdragmc.lowdraglib.utils.Position; -import com.lowdragmc.lowdraglib.utils.Size; - -import net.minecraft.client.Minecraft; -import net.minecraft.nbt.CompoundTag; -import net.minecraft.nbt.NbtAccounter; -import net.minecraft.nbt.NbtIo; -import net.minecraft.resources.ResourceLocation; -import net.minecraft.server.packs.resources.ResourceManager; - -import com.google.common.collect.Table; -import dev.emi.emi.api.EmiApi; -import it.unimi.dsi.fastutil.bytes.Byte2ObjectArrayMap; -import it.unimi.dsi.fastutil.bytes.Byte2ObjectMap; -import it.unimi.dsi.fastutil.objects.Object2IntAVLTreeMap; -import it.unimi.dsi.fastutil.objects.Object2IntSortedMap; -import lombok.Getter; -import lombok.Setter; -import me.shedaniel.rei.api.client.view.ViewSearchBuilder; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -import java.io.DataInputStream; -import java.io.InputStream; -import java.util.ArrayList; -import java.util.List; -import java.util.function.BiConsumer; -import java.util.function.DoubleSupplier; -import java.util.stream.Collectors; - -@SuppressWarnings("UnusedReturnValue") -public class GTRecipeTypeUI { - - @Getter - @Setter - private Byte2ObjectMap slotOverlays = new Byte2ObjectArrayMap<>(); - - private final GTRecipeType recipeType; - - @Getter - @Setter - private ProgressTexture progressBarTexture = new ProgressTexture( - GuiTextures.PROGRESS_BAR_ARROW.getSubTexture(0, 0, 1, 0.5), - GuiTextures.PROGRESS_BAR_ARROW.getSubTexture(0, 0.5, 1, 0.5)); - @Setter - private SteamTexture steamProgressBarTexture = null; - @Setter - private ProgressTexture.FillDirection steamMoveType = ProgressTexture.FillDirection.LEFT_TO_RIGHT; - @Setter - @Nullable - protected BiConsumer uiBuilder; - @Setter - @Getter - protected int maxTooltips = 3; - - private CompoundTag customUICache; - private Size xeiSize; - @Getter - private int originalWidth; - - /** - * @param recipeType the recipemap corresponding to this ui - */ - public GTRecipeTypeUI(@NotNull GTRecipeType recipeType) { - this.recipeType = recipeType; - } - - public CompoundTag getCustomUI() { - if (this.customUICache == null) { - ResourceManager resourceManager = null; - if (GTCEu.isClientSide()) { - resourceManager = Minecraft.getInstance().getResourceManager(); - } else if (GTCEu.getMinecraftServer() != null) { - resourceManager = GTCEu.getMinecraftServer().getResourceManager(); - } - if (resourceManager == null) { - this.customUICache = new CompoundTag(); - } else { - try { - var resource = resourceManager - .getResourceOrThrow(new ResourceLocation(recipeType.registryName.getNamespace(), - "ui/recipe_type/%s.rtui".formatted(recipeType.registryName.getPath()))); - try (InputStream inputStream = resource.open()) { - try (DataInputStream dataInputStream = new DataInputStream(inputStream)) { - this.customUICache = NbtIo.read(dataInputStream, NbtAccounter.UNLIMITED); - } - } - } catch (Exception e) { - this.customUICache = new CompoundTag(); - } - if (this.customUICache == null) { - this.customUICache = new CompoundTag(); - } - } - } - return this.customUICache; - } - - public boolean hasCustomUI() { - return !getCustomUI().isEmpty(); - } - - public void reloadCustomUI() { - this.customUICache = null; - this.xeiSize = null; - } - - public Size getJEISize() { - Size size = this.xeiSize; - if (size == null) { - var originalSize = createEditableUITemplate(false, false).createDefault().getSize(); - this.originalWidth = originalSize.width; - this.xeiSize = size = new Size(Math.max(originalWidth, 150), - getPropertyHeightShift() + 5 + originalSize.height); - } - return size; - } - - public record RecipeHolder(DoubleSupplier progressSupplier, - Table, Object> storages, - CompoundTag data, - List> conditions, - boolean isSteam, - boolean isHighPressure) {} - - /** - * Auto layout UI template for recipes. - * - * @param progressSupplier progress. To create a JEI / REI UI, use the para {@link ProgressWidget#JEIProgress}. - */ - public WidgetGroup createUITemplate(DoubleSupplier progressSupplier, - Table, Object> storages, - CompoundTag data, - List> conditions, - boolean isSteam, - boolean isHighPressure) { - var template = createEditableUITemplate(isSteam, isHighPressure); - var group = template.createDefault(); - template.setupUI(group, - new RecipeHolder(progressSupplier, storages, data, conditions, isSteam, isHighPressure)); - return group; - } - - public WidgetGroup createUITemplate(DoubleSupplier progressSupplier, - Table, Object> storages, - CompoundTag data, - List> conditions) { - return createUITemplate(progressSupplier, storages, data, conditions, false, false); - } - - /** - * Auto layout UI template for recipes. - */ - public IEditableUI createEditableUITemplate(final boolean isSteam, - final boolean isHighPressure) { - return new IEditableUI.Normal<>(() -> { - var isCustomUI = !isSteam && hasCustomUI(); - if (isCustomUI) { - CompoundTag nbt = getCustomUI(); - WidgetGroup group = new WidgetGroup(); - IConfigurableWidget.deserializeNBT(group, nbt.getCompound("root"), - Resources.fromNBT(nbt.getCompound("resources")), false); - group.setSelfPosition(new Position(0, 0)); - return group; - } - - var inputs = addInventorySlotGroup(false, isSteam, isHighPressure); - var outputs = addInventorySlotGroup(true, isSteam, isHighPressure); - var maxWidth = Math.max(inputs.getSize().width, outputs.getSize().width); - var group = new WidgetGroup(0, 0, 2 * maxWidth + 40, - Math.max(inputs.getSize().height, outputs.getSize().height)); - var size = group.getSize(); - - inputs.addSelfPosition((maxWidth - inputs.getSize().width) / 2, - (size.height - inputs.getSize().height) / 2); - outputs.addSelfPosition(maxWidth + 40 + (maxWidth - outputs.getSize().width) / 2, - (size.height - outputs.getSize().height) / 2); - group.addWidget(inputs); - group.addWidget(outputs); - - var progressWidget = new ProgressWidget(ProgressWidget.JEIProgress, maxWidth + 10, size.height / 2 - 10, 20, - 20, progressBarTexture); - progressWidget.setId("progress"); - group.addWidget(progressWidget); - - progressWidget.setProgressTexture((isSteam && steamProgressBarTexture != null) ? new ProgressTexture( - steamProgressBarTexture.get(isHighPressure).getSubTexture(0, 0, 1, 0.5), - steamProgressBarTexture.get(isHighPressure).getSubTexture(0, 0.5, 1, 0.5)) - .setFillDirection(steamMoveType) : progressBarTexture); - - return group; - }, (template, recipeHolder) -> { - var isJEI = recipeHolder.progressSupplier == ProgressWidget.JEIProgress; - - // bind progress - List progress = new ArrayList<>(); - // First set the progress suppliers separately. - WidgetUtils.widgetByIdForEach(template, "^progress$", ProgressWidget.class, progressWidget -> { - progressWidget.setProgressSupplier(recipeHolder.progressSupplier); - progress.add(progressWidget); - }); - // Then set the dual-progress widgets, to override their builtin ones' suppliers, in case someone forgot to - // remove the id from the internal ones. - WidgetUtils.widgetByIdForEach(template, "^progress$", DualProgressWidget.class, dualProgressWidget -> { - dualProgressWidget.setProgressSupplier(recipeHolder.progressSupplier); - progress.add(dualProgressWidget); - }); - // add recipe button - if (!isJEI && (GTCEu.Mods.isREILoaded() || GTCEu.Mods.isJEILoaded() || GTCEu.Mods.isEMILoaded())) { - for (Widget widget : progress) { - template.addWidget(new ButtonWidget(widget.getPosition().x, widget.getPosition().y, - widget.getSize().width, widget.getSize().height, IGuiTexture.EMPTY, cd -> { - if (cd.isRemote) { - if (GTCEu.Mods.isREILoaded()) { - ViewSearchBuilder.builder().addCategories( - recipeType.getCategories().stream() - .filter(GTRecipeCategory::isXEIVisible) - .map(GTRecipeREICategory::machineCategory) - .collect(Collectors.toList())) - .open(); - } else if (GTCEu.Mods.isJEILoaded()) { - JEIPlugin.jeiRuntime.getRecipesGui().showTypes( - recipeType.getCategories().stream() - .filter(GTRecipeCategory::isXEIVisible) - .map(GTRecipeJEICategory::machineType) - .collect(Collectors.toList())); - } else if (GTCEu.Mods.isEMILoaded()) { - EmiApi.displayRecipeCategory( - GTRecipeEMICategory.machineCategory(recipeType.getCategory())); - } - } - }).setHoverTooltips("gtceu.recipe_type.show_recipes")); - } - } - - // Bind I/O - for (var capabilityEntry : recipeHolder.storages.rowMap().entrySet()) { - IO io = capabilityEntry.getKey(); - for (var storagesEntry : capabilityEntry.getValue().entrySet()) { - RecipeCapability cap = storagesEntry.getKey(); - Object storage = storagesEntry.getValue(); - // bind overlays - var widgetClass = cap.getWidgetClass(); - if (widgetClass != null) { - WidgetUtils.widgetByIdForEach(template, "^%s_[0-9]+$".formatted(cap.slotName(io)), widgetClass, - widget -> { - var index = WidgetUtils.widgetIdIndex(widget); - cap.applyWidgetInfo(widget, index, isJEI, io, recipeHolder, recipeType, null, null, - storage, 0, 0); - }); - } - } - } - }); - } - - protected WidgetGroup addInventorySlotGroup(boolean isOutputs, boolean isSteam, boolean isHighPressure) { - int maxCount = 0; - int totalR = 0; - Object2IntSortedMap> map = new Object2IntAVLTreeMap<>(RecipeCapability.COMPARATOR); - if (isOutputs) { - for (var value : recipeType.maxOutputs.object2IntEntrySet()) { - if (value.getKey().doRenderSlot) { - int val = value.getIntValue(); - if (val > maxCount) { - maxCount = Math.min(val, 3); - } - totalR += (val + 2) / 3; - map.put(value.getKey(), val); - } - } - } else { - for (var value : recipeType.maxInputs.object2IntEntrySet()) { - if (value.getKey().doRenderSlot) { - int val = value.getIntValue(); - if (val > maxCount) { - maxCount = Math.min(val, 3); - } - totalR += (val + 2) / 3; - map.put(value.getKey(), val); - } - } - } - WidgetGroup group = new WidgetGroup(0, 0, maxCount * 18 + 8, totalR * 18 + 8); - int index = 0; - for (var entry : map.object2IntEntrySet()) { - RecipeCapability cap = entry.getKey(); - var widgetClass = cap.getWidgetClass(); - if (widgetClass == null) { - continue; - } - int capCount = entry.getIntValue(); - for (int slotIndex = 0; slotIndex < capCount; slotIndex++) { - var slot = cap.createWidget(); - slot.setSelfPosition(new Position((index % 3) * 18 + 4, (index / 3) * 18 + 4)); - slot.setBackground( - getOverlaysForSlot(isOutputs, cap, slotIndex == capCount - 1, isSteam, isHighPressure)); - slot.setId(cap.slotName(isOutputs ? IO.OUT : IO.IN, slotIndex)); - group.addWidget(slot); - index++; - } - // move to new row - index += (3 - (index % 3)) % 3; - } - return group; - } - - /** - * Add a slot to this ui - */ - protected void addSlot(WidgetGroup group, int x, int y, int slotIndex, int count, RecipeCapability capability, - boolean isOutputs, boolean isSteam, boolean isHighPressure) { - if (capability != FluidRecipeCapability.CAP) { - var slot = new SlotWidget(); - slot.initTemplate(); - slot.setSelfPosition(new Position(x, y)); - slot.setBackground( - getOverlaysForSlot(isOutputs, capability, slotIndex == count - 1, isSteam, isHighPressure)); - slot.setId(ItemRecipeCapability.CAP.slotName(isOutputs ? IO.OUT : IO.IN, slotIndex)); - group.addWidget(slot); - } else { - var tank = new TankWidget(); - tank.initTemplate(); - tank.setFillDirection(ProgressTexture.FillDirection.ALWAYS_FULL); - tank.setSelfPosition(new Position(x, y)); - tank.setBackground( - getOverlaysForSlot(isOutputs, capability, slotIndex == count - 1, isSteam, isHighPressure)); - tank.setId(FluidRecipeCapability.CAP.slotName(isOutputs ? IO.OUT : IO.IN, slotIndex)); - group.addWidget(tank); - } - } - - protected static int[] determineSlotsGrid(int itemCount) { - int itemSlotsToLeft; - int itemSlotsToDown; - double sqrt = Math.sqrt(itemCount); - // if the number of input has an integer root - // return it. - if (sqrt % 1 == 0) { - itemSlotsToLeft = itemSlotsToDown = (int) sqrt; - } else if (itemCount == 3) { - itemSlotsToLeft = 3; - itemSlotsToDown = 1; - } else { - // if we couldn't fit all into a perfect square, - // increase the amount of slots to the left - itemSlotsToLeft = (int) Math.ceil(sqrt); - itemSlotsToDown = itemSlotsToLeft - 1; - // if we still can't fit all the slots in a grid, - // increase the amount of slots on the bottom - if (itemCount > itemSlotsToLeft * itemSlotsToDown) { - itemSlotsToDown = itemSlotsToLeft; - } - } - return new int[] { itemSlotsToLeft, itemSlotsToDown }; - } - - protected IGuiTexture getOverlaysForSlot(boolean isOutput, RecipeCapability capability, boolean isLast, - boolean isSteam, boolean isHighPressure) { - IGuiTexture base = capability == FluidRecipeCapability.CAP ? GuiTextures.FLUID_SLOT : - (isSteam ? GuiTextures.SLOT_STEAM.get(isHighPressure) : GuiTextures.SLOT); - byte overlayKey = (byte) ((isOutput ? 2 : 0) + (capability == FluidRecipeCapability.CAP ? 1 : 0) + - (isLast ? 4 : 0)); - if (slotOverlays.containsKey(overlayKey)) { - return new GuiTextureGroup(base, slotOverlays.get(overlayKey)); - } - return base; - } - - /** - * @return the height used to determine size of background texture in JEI - */ - public int getPropertyHeightShift() { - int maxPropertyCount = maxTooltips + recipeType.getDataInfos().size() + recipeType.getMinRecipeConditions(); - return maxPropertyCount * 10; // GTRecipeWidget#LINE_HEIGHT - } - - public void appendJEIUI(GTRecipe recipe, WidgetGroup widgetGroup) { - if (uiBuilder != null) { - uiBuilder.accept(recipe, widgetGroup); - } - } - - public GTRecipeTypeUI setSlotOverlay(boolean isOutput, boolean isFluid, IGuiTexture slotOverlay) { - return this.setSlotOverlay(isOutput, isFluid, false, slotOverlay).setSlotOverlay(isOutput, isFluid, true, - slotOverlay); - } - - public GTRecipeTypeUI setSlotOverlay(boolean isOutput, boolean isFluid, boolean isLast, IGuiTexture slotOverlay) { - this.slotOverlays.put((byte) ((isOutput ? 2 : 0) + (isFluid ? 1 : 0) + (isLast ? 4 : 0)), slotOverlay); - return this; - } - - public GTRecipeTypeUI setProgressBar(ResourceTexture progressBar, ProgressTexture.FillDirection moveType) { - this.progressBarTexture = new ProgressTexture(progressBar.getSubTexture(0, 0, 1, 0.5), - progressBar.getSubTexture(0, 0.5, 1, 0.5)).setFillDirection(moveType); - return this; - } -} diff --git a/src/main/java/com/gregtechceu/gtceu/client/renderer/machine/impl/GrowingPlantRender.java b/src/main/java/com/gregtechceu/gtceu/client/renderer/machine/impl/GrowingPlantRender.java index 2eebe91ad4f..ef13449fab6 100644 --- a/src/main/java/com/gregtechceu/gtceu/client/renderer/machine/impl/GrowingPlantRender.java +++ b/src/main/java/com/gregtechceu/gtceu/client/renderer/machine/impl/GrowingPlantRender.java @@ -206,7 +206,7 @@ protected Optional findGrowing(GTRecipe recipe) { allItemContents.addAll(recipe.getOutputContents(ItemRecipeCapability.CAP)); allItemContents.addAll(recipe.getTickOutputContents(ItemRecipeCapability.CAP)); return allItemContents.stream() - .map(Content::getContent).map(ItemRecipeCapability.CAP::of) + .map(Content::content).map(ItemRecipeCapability.CAP::of) .map(Ingredient::getItems).flatMap(Arrays::stream) .map(ItemStack::getItem) .filter(BlockItem.class::isInstance) diff --git a/src/main/java/com/gregtechceu/gtceu/client/renderer/monitor/MonitorGuiRenderer.java b/src/main/java/com/gregtechceu/gtceu/client/renderer/monitor/MonitorGuiRenderer.java index 66819fe5073..17de5dd7e67 100644 --- a/src/main/java/com/gregtechceu/gtceu/client/renderer/monitor/MonitorGuiRenderer.java +++ b/src/main/java/com/gregtechceu/gtceu/client/renderer/monitor/MonitorGuiRenderer.java @@ -211,7 +211,7 @@ public void render(CentralMonitorMachine machine, MonitorGroup group, float part if (monitor instanceof AdvancedMonitorPartMachine advancedMonitor && mouseX >= 0 && mouseY >= 0 && mouseX <= width && mouseY <= height) { if (advancedMonitor.isClickedThisFrame()) { - this.screen.onMousePressed(mouseX * 256, mouseY * 256, GLFW.GLFW_MOUSE_BUTTON_LEFT); + this.screen.mousePressed(GLFW.GLFW_MOUSE_BUTTON_LEFT); this.vanillaScreen.mouseClicked(mouseX * 256, mouseY * 256, GLFW.GLFW_MOUSE_BUTTON_LEFT); advancedMonitor.setClickedThisFrame(false); } diff --git a/src/main/java/com/gregtechceu/gtceu/client/util/RenderUtil.java b/src/main/java/com/gregtechceu/gtceu/client/util/RenderUtil.java index f1dec39d941..d75830db7da 100644 --- a/src/main/java/com/gregtechceu/gtceu/client/util/RenderUtil.java +++ b/src/main/java/com/gregtechceu/gtceu/client/util/RenderUtil.java @@ -184,12 +184,12 @@ public static Vector3f transformVertex(Vector3fc vertex, Direction direction, } var fluidContent = contents.stream() - .filter(content -> content.content instanceof FluidIngredient ingredient && !ingredient.isEmpty()) + .filter(content -> content.content() instanceof FluidIngredient ingredient && !ingredient.isEmpty()) .findAny(); if (fluidContent.isEmpty()) { return null; } - var ingredient = (FluidIngredient) fluidContent.get().content; + var ingredient = (FluidIngredient) fluidContent.get().content(); var stacks = ingredient.getStacks(); if (stacks.length == 0) { @@ -296,7 +296,7 @@ public static boolean renderResearchItemContent(GuiGraphics graphics, Operation< // check item outputs first List outputs = recipe.getOutputContents(ItemRecipeCapability.CAP); if (!outputs.isEmpty()) { - ItemStack[] items = ItemRecipeCapability.CAP.of(outputs.get(0).content).getItems(); + ItemStack[] items = ItemRecipeCapability.CAP.of(outputs.get(0).content()).getItems(); if (items.length > 0) { ItemStack output = items[0]; if (!output.isEmpty() && !GTUtil.isSameItemSameTags(output, stack)) { @@ -308,7 +308,7 @@ public static boolean renderResearchItemContent(GuiGraphics graphics, Operation< // if there are no item outputs, try to find a fluid output outputs = recipe.getOutputContents(FluidRecipeCapability.CAP); if (!outputs.isEmpty()) { - FluidStack[] fluids = FluidRecipeCapability.CAP.of(outputs.get(0).content).getStacks(); + FluidStack[] fluids = FluidRecipeCapability.CAP.of(outputs.get(0).content()).getStacks(); if (fluids.length != 0) { FluidStack output = fluids[0]; if (!output.isEmpty()) { diff --git a/src/main/java/com/gregtechceu/gtceu/common/cover/ConveyorCover.java b/src/main/java/com/gregtechceu/gtceu/common/cover/ConveyorCover.java index 4ad59a0bd57..c39226bfe03 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/cover/ConveyorCover.java +++ b/src/main/java/com/gregtechceu/gtceu/common/cover/ConveyorCover.java @@ -34,7 +34,7 @@ import net.minecraftforge.items.IItemHandlerModifiable; import net.minecraftforge.items.ItemHandlerHelper; -import brachy.modularui.api.drawable.IKey; +import brachy.modularui.api.drawable.Text; import brachy.modularui.factory.SidedPosGuiData; import brachy.modularui.screen.UISettings; import brachy.modularui.value.sync.*; @@ -444,7 +444,7 @@ public void createCoverUIRows(Flow column, SidedPosGuiData data, PanelSyncManage column.child(new GTMuiWidgets.EnumRowBuilder<>(DistributionMode.class) .value(distMode) .overlay(16, GTGuiTextures.DISTRIBUTION_MODE_OVERLAY) - .lang(IKey.dynamic(() -> Component.translatable(distributionMode.localeName))) + .lang(Text.dynamic(() -> Component.translatable(distributionMode.localeName))) .build()); } @@ -452,7 +452,7 @@ public void createCoverUIRows(Flow column, SidedPosGuiData data, PanelSyncManage column.child(new GTMuiWidgets.EnumRowBuilder<>(ManualIOMode.class) .value(manualMode) .overlay(16, GTGuiTextures.MANUAL_IO_OVERLAY_IN) - .lang(IKey.dynamic(() -> Component.translatable(manualIOMode.localeName))) + .lang(Text.dynamic(() -> Component.translatable(manualIOMode.localeName))) .build()); } diff --git a/src/main/java/com/gregtechceu/gtceu/common/cover/FluidFilterCover.java b/src/main/java/com/gregtechceu/gtceu/common/cover/FluidFilterCover.java index 6b0e87576ae..0f42fda981c 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/cover/FluidFilterCover.java +++ b/src/main/java/com/gregtechceu/gtceu/common/cover/FluidFilterCover.java @@ -22,7 +22,7 @@ import net.minecraft.world.item.ItemStack; import net.minecraftforge.fluids.FluidStack; -import brachy.modularui.api.drawable.IKey; +import brachy.modularui.api.drawable.Text; import brachy.modularui.factory.SidedPosGuiData; import brachy.modularui.screen.UISettings; import brachy.modularui.value.sync.DynamicSyncHandler; @@ -103,7 +103,7 @@ public void createCoverUIRows(Flow column, SidedPosGuiData data, PanelSyncManage DynamicSyncHandler filterButton = new DynamicSyncHandler() .widgetProvider((sm, buf) -> new ButtonWidget<>() - .onMousePressed((x, y, b) -> { + .onMousePressed((context, b) -> { panelHandler.openPanel(); return true; })); @@ -113,13 +113,13 @@ public void createCoverUIRows(Flow column, SidedPosGuiData data, PanelSyncManage column.child(new GTMuiWidgets.EnumRowBuilder<>(FilterMode.class) .value(filterMode) .overlay(16, GTGuiTextures.FILTER_MODE_OVERLAY) - .lang(IKey.dynamic(() -> Component.translatable(getFilterMode().getTooltip()))) + .lang(Text.dynamic(() -> Component.translatable(getFilterMode().getTooltip()))) .build()); column.child(new GTMuiWidgets.EnumRowBuilder<>(ManualIOMode.class) .value(ioMode) .overlay(16, GTGuiTextures.MANUAL_IO_OVERLAY_IN) - .lang(IKey.dynamic(() -> Component.translatable(getAllowFlow().getTooltip()))) + .lang(Text.dynamic(() -> Component.translatable(getAllowFlow().getTooltip()))) .build()); } diff --git a/src/main/java/com/gregtechceu/gtceu/common/cover/FluidRegulatorCover.java b/src/main/java/com/gregtechceu/gtceu/common/cover/FluidRegulatorCover.java index 9c581e1ee58..8b79db6dc75 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/cover/FluidRegulatorCover.java +++ b/src/main/java/com/gregtechceu/gtceu/common/cover/FluidRegulatorCover.java @@ -21,7 +21,7 @@ import net.minecraftforge.fluids.capability.IFluidHandler; import net.minecraftforge.fluids.capability.IFluidHandler.FluidAction; -import brachy.modularui.api.drawable.IKey; +import brachy.modularui.api.drawable.Text; import brachy.modularui.factory.SidedPosGuiData; import brachy.modularui.screen.UISettings; import brachy.modularui.value.sync.EnumSyncValue; @@ -204,7 +204,7 @@ public void createCoverUIRows(Flow column, SidedPosGuiData data, PanelSyncManage column.child(new GTMuiWidgets.EnumRowBuilder<>(TransferMode.class) .value(transferMode) .overlay(16, GTGuiTextures.TRANSFER_MODE_OVERLAY) - .lang(IKey.dynamic(() -> Component.translatable(getTransferMode().tooltip))) + .lang(Text.dynamic(() -> Component.translatable(getTransferMode().tooltip))) .build()); column.child(GTMuiWidgets.createIntInputWithBucketMode(transferSize, transferBucketMode, diff --git a/src/main/java/com/gregtechceu/gtceu/common/cover/ItemFilterCover.java b/src/main/java/com/gregtechceu/gtceu/common/cover/ItemFilterCover.java index 367a6d3e49b..5dfb4298478 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/cover/ItemFilterCover.java +++ b/src/main/java/com/gregtechceu/gtceu/common/cover/ItemFilterCover.java @@ -24,7 +24,7 @@ import net.minecraft.world.item.ItemStack; import net.minecraftforge.items.IItemHandlerModifiable; -import brachy.modularui.api.drawable.IKey; +import brachy.modularui.api.drawable.Text; import brachy.modularui.factory.SidedPosGuiData; import brachy.modularui.screen.UISettings; import brachy.modularui.value.sync.DynamicSyncHandler; @@ -113,7 +113,7 @@ public void createCoverUIRows(Flow column, SidedPosGuiData data, PanelSyncManage DynamicSyncHandler filterButton = new DynamicSyncHandler() .widgetProvider((sm, buf) -> new ButtonWidget<>() - .onMousePressed((x, y, b) -> { + .onMousePressed((context, b) -> { panelHandler.openPanel(); return true; })); @@ -123,13 +123,13 @@ public void createCoverUIRows(Flow column, SidedPosGuiData data, PanelSyncManage column.child(new GTMuiWidgets.EnumRowBuilder<>(FilterMode.class) .value(filterMode) .overlay(16, GTGuiTextures.FILTER_MODE_OVERLAY) - .lang(IKey.dynamic(() -> Component.translatable(getFilterMode().getTooltip()))) + .lang(Text.dynamic(() -> Component.translatable(getFilterMode().getTooltip()))) .build()); column.child(new GTMuiWidgets.EnumRowBuilder<>(ManualIOMode.class) .value(ioMode) .overlay(16, GTGuiTextures.MANUAL_IO_OVERLAY_IN) - .lang(IKey.dynamic(() -> Component.translatable(getAllowFlow().name()))) + .lang(Text.dynamic(() -> Component.translatable(getAllowFlow().name()))) .build()); } diff --git a/src/main/java/com/gregtechceu/gtceu/common/cover/MachineControllerCover.java b/src/main/java/com/gregtechceu/gtceu/common/cover/MachineControllerCover.java index ceef7cc9c4e..97d9344bb8a 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/cover/MachineControllerCover.java +++ b/src/main/java/com/gregtechceu/gtceu/common/cover/MachineControllerCover.java @@ -23,7 +23,7 @@ import net.minecraft.world.level.Level; import net.minecraft.world.level.block.Block; -import brachy.modularui.api.drawable.IKey; +import brachy.modularui.api.drawable.Text; import brachy.modularui.drawable.GuiTextures; import brachy.modularui.drawable.ItemDrawable; import brachy.modularui.drawable.Rectangle; @@ -214,7 +214,7 @@ public ModularPanel buildUI(SidedPosGuiData data, PanelSyncManager syncManage .size(16).left(0) .value(new BooleanSyncValue(this::isInverted, ($) -> this.setInverted(true))) .overlay(GTGuiTextures.OVERLAY_REDSTONE_ON)) - .child(IKey.lang("cover.enable_with_redstone").asWidget() + .child(Text.lang("cover.enable_with_redstone").asWidget() .heightRel(1.0f).left(20))) .child(coverUIRow() .child(new ToggleButton() @@ -222,7 +222,7 @@ public ModularPanel buildUI(SidedPosGuiData data, PanelSyncManager syncManage .value(new BooleanSyncValue(() -> !this.isInverted(), ($) -> this.setInverted(false))) .overlay(GTGuiTextures.OVERLAY_REDSTONE_OFF)) - .child(IKey.lang("cover.disable_with_redstone").asWidget() + .child(Text.lang("cover.disable_with_redstone").asWidget() .heightRel(1.0f).left(20))) .child(coverUIRow() .child(new ToggleButton() @@ -230,10 +230,10 @@ public ModularPanel buildUI(SidedPosGuiData data, PanelSyncManager syncManage .value(new BooleanSyncValue(() -> preventPowerFail, bool -> preventPowerFail = bool)) .overlay(GTGuiTextures.CIRCUIT_OVERLAY)) - .child(IKey.lang("cover.machine_controller.suspend_powerfail").asWidget() + .child(Text.lang("cover.machine_controller.suspend_powerfail").asWidget() .heightRel(1.0f).left(20))) .child(coverUIRow() - .child(IKey + .child(Text .dynamic(() -> Component.translatable("cover.machine_controller.redstone", redstoneSignalOutput)) .asWidget() @@ -252,22 +252,22 @@ public ModularPanel buildUI(SidedPosGuiData data, PanelSyncManager syncManage .child(coverUIRow().child(new Rectangle().color(UI_TEXT_COLOR).asWidget() .height(1).widthRel(0.9f).leftRel(0.5f)).margin(0, 2)) - .child(coverUIRow().child(IKey.lang("cover.machine_controller.control").asWidget() + .child(coverUIRow().child(Text.lang("cover.machine_controller.control").asWidget() .height(16))) // Controlling selector .child(coverUIRow() .child(modeButton(controllerModeValue, ControllerMode.MACHINE).bottom(0)) - .child(modeColumn(controllerModeValue, ControllerMode.COVER_UP, IKey.str("U"))) - .child(modeColumn(controllerModeValue, ControllerMode.COVER_DOWN, IKey.str("D"))) - .child(modeColumn(controllerModeValue, ControllerMode.COVER_NORTH, IKey.str("N"))) - .child(modeColumn(controllerModeValue, ControllerMode.COVER_SOUTH, IKey.str("S"))) - .child(modeColumn(controllerModeValue, ControllerMode.COVER_EAST, IKey.str("E"))) - .child(modeColumn(controllerModeValue, ControllerMode.COVER_WEST, IKey.str("W"))))) + .child(modeColumn(controllerModeValue, ControllerMode.COVER_UP, Text.str("U"))) + .child(modeColumn(controllerModeValue, ControllerMode.COVER_DOWN, Text.str("D"))) + .child(modeColumn(controllerModeValue, ControllerMode.COVER_NORTH, Text.str("N"))) + .child(modeColumn(controllerModeValue, ControllerMode.COVER_SOUTH, Text.str("S"))) + .child(modeColumn(controllerModeValue, ControllerMode.COVER_EAST, Text.str("E"))) + .child(modeColumn(controllerModeValue, ControllerMode.COVER_WEST, Text.str("W"))))) .bindPlayerInventory(); } - private Flow modeColumn(EnumSyncValue syncValue, ControllerMode mode, IKey title) { + private Flow modeColumn(EnumSyncValue syncValue, ControllerMode mode, Text title) { return Flow.column().width(18).height(28) .child(title.asWidget().height(10).leftRel(0.5f)) .child(modeButton(syncValue, mode).bottom(0)); @@ -278,21 +278,21 @@ private Widget modeButton(EnumSyncValue syncValue, Controller if (controllable == null) { // Nothing to control, put a placeholder widget // 3 states possible here: - IKey detail; + Text detail; if (mode.side == attachedSide) { // our own side, we can't control ourselves - detail = IKey.lang("cover.machine_controller.this_cover"); + detail = Text.lang("cover.machine_controller.this_cover"); } else if (mode.side != null) { // some potential cover that either doesn't exist or isn't controllable - detail = IKey.lang("cover.machine_controller.cover_not_controllable"); + detail = Text.lang("cover.machine_controller.cover_not_controllable"); } else { // cover holder is not controllable - detail = IKey.lang("cover.machine_controller.machine_not_controllable"); + detail = Text.lang("cover.machine_controller.machine_not_controllable"); } return GuiTextures.MC_BUTTON.asWidget().size(18) .overlay(GTGuiTextures.BUTTON_CROSS) - .tooltip(t -> t.addLine(IKey.lang(mode.localeName)).addLine(detail)); + .tooltip(t -> t.addLine(Text.lang(mode.localeName)).addLine(detail.getFormatted())); } ItemStack stack; @@ -311,8 +311,8 @@ private Widget modeButton(EnumSyncValue syncValue, Controller return new ToggleButton().size(18) .value(boolValueOf(syncValue, mode)) .overlay(new ItemDrawable(stack).asIcon().size(16)) - .tooltip(t -> t.addLine(IKey.lang(mode.localeName)) - .addLine(IKey.lang(stack.getHoverName()))); + .tooltip(t -> t.addLine(Text.lang(mode.localeName)) + .addLine(stack.getHoverName())); } @Override diff --git a/src/main/java/com/gregtechceu/gtceu/common/cover/PumpCover.java b/src/main/java/com/gregtechceu/gtceu/common/cover/PumpCover.java index cb6edf1f397..2e360a6f946 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/cover/PumpCover.java +++ b/src/main/java/com/gregtechceu/gtceu/common/cover/PumpCover.java @@ -32,7 +32,7 @@ import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.capability.IFluidHandler; -import brachy.modularui.api.drawable.IKey; +import brachy.modularui.api.drawable.Text; import brachy.modularui.factory.SidedPosGuiData; import brachy.modularui.screen.UISettings; import brachy.modularui.value.sync.EnumSyncValue; @@ -288,7 +288,7 @@ public void createCoverUIRows(Flow column, SidedPosGuiData data, PanelSyncManage column.child(new GTMuiWidgets.EnumRowBuilder<>(ManualIOMode.class) .value(manualIOModeSync) .overlay(16, GTGuiTextures.MANUAL_IO_OVERLAY_IN) - .lang(IKey.dynamic(() -> Component.translatable(manualIOMode.localeName))) + .lang(Text.dynamic(() -> Component.translatable(manualIOMode.localeName))) .build()); } diff --git a/src/main/java/com/gregtechceu/gtceu/common/cover/RobotArmCover.java b/src/main/java/com/gregtechceu/gtceu/common/cover/RobotArmCover.java index 12cca37c4d1..c548505e5bc 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/cover/RobotArmCover.java +++ b/src/main/java/com/gregtechceu/gtceu/common/cover/RobotArmCover.java @@ -20,7 +20,7 @@ import net.minecraft.world.item.ItemStack; import net.minecraftforge.items.IItemHandler; -import brachy.modularui.api.drawable.IKey; +import brachy.modularui.api.drawable.Text; import brachy.modularui.factory.SidedPosGuiData; import brachy.modularui.screen.UISettings; import brachy.modularui.value.sync.EnumSyncValue; @@ -175,7 +175,7 @@ public void createCoverUIRows(Flow column, SidedPosGuiData data, PanelSyncManage column.child(new GTMuiWidgets.EnumRowBuilder<>(TransferMode.class) .value(transferMode) .overlay(16, GTGuiTextures.TRANSFER_MODE_OVERLAY) - .lang(IKey.dynamic(() -> Component.translatable(getTransferMode().tooltip))) + .lang(Text.dynamic(() -> Component.translatable(getTransferMode().tooltip))) .build()); column.child(GTMuiWidgets.createIntInputWithButtons(transferSize, () -> 1, () -> getTransferMode().maxStackSize) diff --git a/src/main/java/com/gregtechceu/gtceu/common/cover/detector/AdvancedEnergyDetectorCover.java b/src/main/java/com/gregtechceu/gtceu/common/cover/detector/AdvancedEnergyDetectorCover.java index 2864be3bde2..2ed4cab4737 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/cover/detector/AdvancedEnergyDetectorCover.java +++ b/src/main/java/com/gregtechceu/gtceu/common/cover/detector/AdvancedEnergyDetectorCover.java @@ -15,7 +15,7 @@ import net.minecraft.nbt.CompoundTag; import net.minecraft.server.level.ServerPlayer; -import brachy.modularui.api.drawable.IKey; +import brachy.modularui.api.drawable.Text; import brachy.modularui.factory.SidedPosGuiData; import brachy.modularui.screen.UISettings; import brachy.modularui.theme.ThemeAPI; @@ -135,9 +135,9 @@ public void createCoverUIRows(Flow column, SidedPosGuiData data, PanelSyncManage syncManager.syncValue("minValue", minValueSync); syncManager.syncValue("maxValue", maxValueSync); - column.child(coverUIRow().child(IKey.lang("cover.advanced_energy_detector.min").asWidget().width(20)) + column.child(coverUIRow().child(Text.lang("cover.advanced_energy_detector.min").asWidget().width(20)) .child(GTMuiWidgets.createLongInputWithButtons(minValueSync, () -> 0, this::getMaxValue).width(142))) - .child(coverUIRow().child(IKey.lang("cover.advanced_energy_detector.max").asWidget().width(20)) + .child(coverUIRow().child(Text.lang("cover.advanced_energy_detector.max").asWidget().width(20)) .child(GTMuiWidgets.createLongInputWithButtons(maxValueSync, () -> 0, () -> usePercent ? 100 : getEnergyCapacity()).width(142))) .child(coverUIRow() diff --git a/src/main/java/com/gregtechceu/gtceu/common/cover/detector/AdvancedFluidDetectorCover.java b/src/main/java/com/gregtechceu/gtceu/common/cover/detector/AdvancedFluidDetectorCover.java index cd50bf39090..f47586fd2c5 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/cover/detector/AdvancedFluidDetectorCover.java +++ b/src/main/java/com/gregtechceu/gtceu/common/cover/detector/AdvancedFluidDetectorCover.java @@ -20,7 +20,7 @@ import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.capability.IFluidHandler; -import brachy.modularui.api.drawable.IKey; +import brachy.modularui.api.drawable.Text; import brachy.modularui.factory.SidedPosGuiData; import brachy.modularui.screen.UISettings; import brachy.modularui.value.sync.BooleanSyncValue; @@ -143,9 +143,9 @@ public void createCoverUIRows(Flow column, SidedPosGuiData data, PanelSyncManage GTMuiWidgets.createFilterRow(buttonRow, filterHandler, data, syncManager, settings); - column.child(coverUIRow().child(IKey.lang("cover.advanced_fluid_detector.min").asWidget().width(50)) + column.child(coverUIRow().child(Text.lang("cover.advanced_fluid_detector.min").asWidget().width(50)) .child(GTMuiWidgets.createIntInputWithButtons(minValueSync, () -> 0, this::getMaxValue).width(110))) - .child(coverUIRow().child(IKey.lang("cover.advanced_fluid_detector.max").asWidget().width(50)) + .child(coverUIRow().child(Text.lang("cover.advanced_fluid_detector.max").asWidget().width(50)) .child(GTMuiWidgets.createIntInputWithButtons(maxValueSync, () -> 0, () -> Integer.MAX_VALUE) .width(110))) .child(buttonRow); diff --git a/src/main/java/com/gregtechceu/gtceu/common/cover/detector/AdvancedItemDetectorCover.java b/src/main/java/com/gregtechceu/gtceu/common/cover/detector/AdvancedItemDetectorCover.java index 9d66b094191..95b3ec8e598 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/cover/detector/AdvancedItemDetectorCover.java +++ b/src/main/java/com/gregtechceu/gtceu/common/cover/detector/AdvancedItemDetectorCover.java @@ -20,7 +20,7 @@ import net.minecraft.world.item.ItemStack; import net.minecraftforge.items.IItemHandler; -import brachy.modularui.api.drawable.IKey; +import brachy.modularui.api.drawable.Text; import brachy.modularui.factory.SidedPosGuiData; import brachy.modularui.screen.UISettings; import brachy.modularui.value.sync.BooleanSyncValue; @@ -139,9 +139,9 @@ public void createCoverUIRows(Flow column, SidedPosGuiData data, PanelSyncManage GTMuiWidgets.createFilterRow(buttonRow, filterHandler, data, syncManager, settings); - column.child(coverUIRow().child(IKey.lang("cover.advanced_item_detector.min").asWidget().width(50)) + column.child(coverUIRow().child(Text.lang("cover.advanced_item_detector.min").asWidget().width(50)) .child(GTMuiWidgets.createIntInputWithButtons(minValueSync, () -> 0, this::getMaxValue).width(110))) - .child(coverUIRow().child(IKey.lang("cover.advanced_item_detector.max").asWidget().width(50)) + .child(coverUIRow().child(Text.lang("cover.advanced_item_detector.max").asWidget().width(50)) .child(GTMuiWidgets.createIntInputWithButtons(maxValueSync, () -> 0, () -> Integer.MAX_VALUE) .width(110))) .child(buttonRow); diff --git a/src/main/java/com/gregtechceu/gtceu/common/cover/ender/AbstractEnderLinkCover.java b/src/main/java/com/gregtechceu/gtceu/common/cover/ender/AbstractEnderLinkCover.java index 9df754f5d50..35bcf2a5043 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/cover/ender/AbstractEnderLinkCover.java +++ b/src/main/java/com/gregtechceu/gtceu/common/cover/ender/AbstractEnderLinkCover.java @@ -21,12 +21,11 @@ import net.minecraft.core.Direction; import net.minecraft.nbt.CompoundTag; import net.minecraft.network.FriendlyByteBuf; -import net.minecraft.network.chat.Component; import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer; import brachy.modularui.api.drawable.IDrawable; -import brachy.modularui.api.drawable.IKey; +import brachy.modularui.api.drawable.Text; import brachy.modularui.api.widget.IWidget; import brachy.modularui.drawable.Rectangle; import brachy.modularui.factory.GuiData; @@ -34,6 +33,7 @@ import brachy.modularui.screen.ModularPanel; import brachy.modularui.screen.RichTooltip; import brachy.modularui.screen.UISettings; +import brachy.modularui.screen.viewport.GuiContext; import brachy.modularui.utils.Alignment; import brachy.modularui.utils.Color; import brachy.modularui.utils.MouseData; @@ -273,27 +273,27 @@ public void createCoverUIRows(Flow column, SidedPosGuiData data, PanelSyncManage .stateOverlay(Permissions.PUBLIC, GTGuiTextures.PRIVATE_MODE_BUTTON[0]) .stateOverlay(Permissions.PROTECTED, GTGuiTextures.PRIVATE_MODE_BUTTON[0]) .stateOverlay(Permissions.PRIVATE, GTGuiTextures.PRIVATE_MODE_BUTTON[1]) - .tooltip(0, t -> t.addLine(IKey.lang(Permissions.PUBLIC.tooltip))) - .tooltip(1, t -> t.addLine(IKey.lang(Permissions.PROTECTED.tooltip))) - .tooltip(2, t -> t.addLine(IKey.lang(Permissions.PRIVATE.tooltip))) + .tooltip(0, t -> t.addLine(Text.lang(Permissions.PUBLIC.tooltip))) + .tooltip(1, t -> t.addLine(Text.lang(Permissions.PROTECTED.tooltip))) + .tooltip(2, t -> t.addLine(Text.lang(Permissions.PRIVATE.tooltip))) .value(new EnumSyncValue<>(Permissions.class, this::getPermission, this::setPermission))) .child(new TextFieldWidget() .value(new StringSyncValue(this::getColorStr, this::setColorStr)) .setMaxLength(8) .setValidator(str -> COLOR_INPUT_PATTERN.matcher(str).replaceAll("")) - .addTooltipLine(IKey.lang(Component.translatable("cover.ender_link.tooltip.channel_name")))) + .addTooltipLine(Text.lang("cover.ender_link.tooltip.channel_name"))) .child(new DynamicSyncedWidget<>().syncHandler(dynamicLinkedSyncHandler)) - .child(new ButtonWidget<>().onMousePressed((x, y, b) -> { + .child(new ButtonWidget<>().onMousePressed((GuiContext context, int button) -> { channelManager.openPanel(); return true; }).posRel(Alignment.CenterRight).tooltip(new RichTooltip() - .addLine(IKey.lang(Component.translatable("cover.ender_link.tooltip.list_button")))))); + .addLine(Text.lang("cover.ender_link.tooltip.list_button"))))); column.child(coverUIRow().child(new TextFieldWidget() .setMaxLength(32) .widthRel(1f) - .addTooltipLine(IKey.lang(Component.translatable("cover.ender_link.tooltip.channel_description"))) + .addTooltipLine(Text.lang("cover.ender_link.tooltip.channel_description")) .value(new StringSyncValue(this::getDescription, this::setDescription)))); Flow bottomRow = coverUIRow(); @@ -307,10 +307,10 @@ public void createCoverUIRows(Flow column, SidedPosGuiData data, PanelSyncManage protected ParentWidget getChannelStatusRowShort(PanelSyncManager syncManager, VirtualEntry entry, int idx) { TextWidget str; if (entry.getDescription().isBlank()) { - str = IKey.lang(Component.translatable("cover.ender_link.description_empty")).asWidget().size(98, 12) + str = Text.lang("cover.ender_link.description_empty").asWidget().size(98, 12) .color(Color.GREY.darker(1)); } else { - str = IKey.str(entry.getDescription()).asWidget().size(98, 12); + str = Text.str(entry.getDescription()).asWidget().size(98, 12); } return coverUIRow() .child(createColorBlock(entry::getColor, 18).asWidget() @@ -318,7 +318,7 @@ protected ParentWidget getChannelStatusRowShort(PanelSyncManager syncManager, .size(18, 18)) .child(str) .child(createVirtualEntryWidget(syncManager, entry, 18, 18, idx)) - .child(new ButtonWidget<>().overlay(GTGuiTextures.BUTTON_CROSS).onMousePressed((x, y, button) -> { + .child(new ButtonWidget<>().overlay(GTGuiTextures.BUTTON_CROSS).onMousePressed((context, button) -> { MouseData mouseData = MouseData.create(button); if (mouseData.mouseButton() == 1) { syncManager.callSyncedAction("deleteEntry", diff --git a/src/main/java/com/gregtechceu/gtceu/common/cover/voiding/AdvancedFluidVoidingCover.java b/src/main/java/com/gregtechceu/gtceu/common/cover/voiding/AdvancedFluidVoidingCover.java index 2f68ae7ea1b..f53ca595253 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/cover/voiding/AdvancedFluidVoidingCover.java +++ b/src/main/java/com/gregtechceu/gtceu/common/cover/voiding/AdvancedFluidVoidingCover.java @@ -21,7 +21,7 @@ import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.capability.IFluidHandler; -import brachy.modularui.api.drawable.IKey; +import brachy.modularui.api.drawable.Text; import brachy.modularui.factory.SidedPosGuiData; import brachy.modularui.screen.UISettings; import brachy.modularui.value.sync.EnumSyncValue; @@ -134,7 +134,7 @@ public void createCoverUIRows(Flow column, SidedPosGuiData data, PanelSyncManage column.child(new GTMuiWidgets.EnumRowBuilder<>(VoidingMode.class) .value(voidingMode) .overlay(16, GTGuiTextures.VOIDING_MODES) - .lang(IKey.dynamic(() -> Component.translatable(getVoidingMode().tooltip))) + .lang(Text.dynamic(() -> Component.translatable(getVoidingMode().tooltip))) .build() .marginTop(2)); diff --git a/src/main/java/com/gregtechceu/gtceu/common/cover/voiding/AdvancedItemVoidingCover.java b/src/main/java/com/gregtechceu/gtceu/common/cover/voiding/AdvancedItemVoidingCover.java index 2f5ad86ecbb..97e0b3eddab 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/cover/voiding/AdvancedItemVoidingCover.java +++ b/src/main/java/com/gregtechceu/gtceu/common/cover/voiding/AdvancedItemVoidingCover.java @@ -19,7 +19,7 @@ import net.minecraft.world.item.ItemStack; import net.minecraftforge.items.IItemHandler; -import brachy.modularui.api.drawable.IKey; +import brachy.modularui.api.drawable.Text; import brachy.modularui.factory.SidedPosGuiData; import brachy.modularui.screen.UISettings; import brachy.modularui.value.sync.EnumSyncValue; @@ -130,7 +130,7 @@ public void createCoverUIRows(Flow column, SidedPosGuiData data, PanelSyncManage column.child(new GTMuiWidgets.EnumRowBuilder<>(VoidingMode.class) .value(voidingMode) .overlay(16, GTGuiTextures.VOIDING_MODES) - .lang(IKey.dynamic(() -> Component.translatable(getVoidingMode().tooltip))) + .lang(Text.dynamic(() -> Component.translatable(getVoidingMode().tooltip))) .build() .marginTop(2)); diff --git a/src/main/java/com/gregtechceu/gtceu/common/data/GCYMRecipeTypes.java b/src/main/java/com/gregtechceu/gtceu/common/data/GCYMRecipeTypes.java index 0e4c49b1226..ade476d376f 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/data/GCYMRecipeTypes.java +++ b/src/main/java/com/gregtechceu/gtceu/common/data/GCYMRecipeTypes.java @@ -1,25 +1,26 @@ package com.gregtechceu.gtceu.common.data; +import brachy.modularui.api.drawable.Text; +import brachy.modularui.integration.recipeviewer.RecipeSlotRole; +import brachy.modularui.integration.recipeviewer.RecipeViewerSlotWidget; +import brachy.modularui.widgets.ProgressWidget; +import brachy.modularui.widgets.TextWidget; import com.gregtechceu.gtceu.api.GTCEuAPI; import com.gregtechceu.gtceu.api.block.ICoilType; import com.gregtechceu.gtceu.api.capability.recipe.IO; -import com.gregtechceu.gtceu.api.gui.GuiTextures; -import com.gregtechceu.gtceu.api.gui.widget.SlotWidget; import com.gregtechceu.gtceu.api.recipe.GTRecipeType; -import com.gregtechceu.gtceu.integration.recipeviewer.handlers.item.CycleItemEntryHandler; +import com.gregtechceu.gtceu.common.mui.GTGuiTextures; import com.gregtechceu.gtceu.utils.FormattingUtil; -import com.lowdragmc.lowdraglib.utils.LocalizationUtils; - -import net.minecraft.client.resources.language.I18n; +import net.minecraft.network.chat.Component; import net.minecraft.world.item.ItemStack; -import java.util.ArrayList; +import brachy.modularui.integration.recipeviewer.entry.item.ItemStackList; + import java.util.List; import static com.gregtechceu.gtceu.common.data.GTRecipeTypes.MULTIBLOCK; import static com.gregtechceu.gtceu.common.data.GTRecipeTypes.register; -import static com.lowdragmc.lowdraglib.gui.texture.ProgressTexture.FillDirection.LEFT_TO_RIGHT; public class GCYMRecipeTypes { @@ -29,36 +30,35 @@ public class GCYMRecipeTypes { public final static GTRecipeType ALLOY_BLAST_RECIPES = register("alloy_blast_smelter", MULTIBLOCK) .setMaxIOSize(9, 0, 3, 1) .setEUIO(IO.IN) - .setProgressBar(GuiTextures.PROGRESS_BAR_ARROW, LEFT_TO_RIGHT) - .setSlotOverlay(false, false, false, GuiTextures.FURNACE_OVERLAY_1) - .setSlotOverlay(false, false, true, GuiTextures.FURNACE_OVERLAY_1) - .setSlotOverlay(false, true, false, GuiTextures.FURNACE_OVERLAY_2) - .setSlotOverlay(false, true, true, GuiTextures.FURNACE_OVERLAY_2) - .setSlotOverlay(true, true, false, GuiTextures.FURNACE_OVERLAY_2) - .setSlotOverlay(true, true, true, GuiTextures.FURNACE_OVERLAY_2) - .addDataInfo(data -> { - int temp = data.getInt("ebf_temp"); - return LocalizationUtils.format("gtceu.recipe.temperature", FormattingUtil.formatTemperature(temp)); - }) - .addDataInfo(data -> { - int temp = data.getInt("ebf_temp"); - ICoilType requiredCoil = ICoilType.getMinRequiredType(temp); + .UI(builder -> builder + .setItemSlotsOverlay(IO.IN, 0, 8, GTGuiTextures.FURNACE_OVERLAY_1) + .setFluidSlotsOverlay(IO.IN, 0, 2, GTGuiTextures.FURNACE_OVERLAY_2) + .setFluidSlotOverlay(IO.OUT, 0, GTGuiTextures.FURNACE_OVERLAY_2) + .setProgressBar(GTGuiTextures.PROGRESS_BAR_ARROW, 20, ProgressWidget.Direction.RIGHT) + .addRecipeUIModifier((recipe, widget) -> { + if (recipe.data.contains("ebf_temp")) { + int temp = recipe.data.getInt("ebf_temp"); + + widget.textComponents.child(new TextWidget<>(Text.lang("gtceu.recipe.temperature", FormattingUtil.formatTemperature(temp)))); + + ICoilType requiredCoil = ICoilType.getMinRequiredType(temp); + + if (requiredCoil != null && !requiredCoil.getMaterial().isNull()) { + widget.textComponents.child(new TextWidget<>(Text.lang("gtceu.recipe.coil.tier", Component.translatable(requiredCoil.getMaterial().getUnlocalizedName()).getString()))); + } + + List items = GTCEuAPI.HEATING_COILS.entrySet().stream() + .filter(coil -> coil.getKey().getCoilTemperature() >= temp) + .map(coil -> new ItemStack(coil.getValue().get())).toList(); - if (requiredCoil != null && !requiredCoil.getMaterial().isNull()) { - return LocalizationUtils.format("gtceu.recipe.coil.tier", - I18n.get(requiredCoil.getMaterial().getUnlocalizedName())); - } - return ""; - }) - .setUiBuilder((recipe, widgetGroup) -> { - int temp = recipe.data.getInt("ebf_temp"); - List> items = new ArrayList<>(); - items.add(GTCEuAPI.HEATING_COILS.entrySet().stream() - .filter(coil -> coil.getKey().getCoilTemperature() >= temp) - .map(coil -> new ItemStack(coil.getValue().get())).toList()); - widgetGroup.addWidget(new SlotWidget(CycleItemEntryHandler.fromStacks(items), 0, - widgetGroup.getSize().width - 25, widgetGroup.getSize().height - 40, false, false)); - }) + widget.child(RecipeViewerSlotWidget.create() + .recipeSlotRole(RecipeSlotRole.RENDER_ONLY) + .value(ItemStackList.of(items)) + .posRel(0.80f, 0.80f) + ); + } + }) + ) .setSound(GTSoundEntries.ARC); public static void init() {} diff --git a/src/main/java/com/gregtechceu/gtceu/common/data/GTMachines.java b/src/main/java/com/gregtechceu/gtceu/common/data/GTMachines.java index f0ee613fc6e..ef7027866df 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/data/GTMachines.java +++ b/src/main/java/com/gregtechceu/gtceu/common/data/GTMachines.java @@ -22,8 +22,6 @@ import com.gregtechceu.gtceu.common.data.machines.*; import com.gregtechceu.gtceu.common.data.models.GTModels; import com.gregtechceu.gtceu.common.machine.electric.*; -import com.gregtechceu.gtceu.common.machine.muimachine.TestMuiMachine; -import com.gregtechceu.gtceu.common.machine.muimachine.TestMuiMachine2; import com.gregtechceu.gtceu.common.machine.multiblock.part.*; import com.gregtechceu.gtceu.common.machine.multiblock.part.monitor.AdvancedMonitorPartMachine; import com.gregtechceu.gtceu.common.machine.multiblock.part.monitor.MonitorPartMachine; @@ -126,7 +124,7 @@ public class GTMachines { .recipeModifier(SimpleSteamMachine::recipeModifier) .addOutputLimit(ItemRecipeCapability.CAP, 1) .themeId((i) -> i > 0 ? GTGuiTheme.STEEL.getId() : GTGuiTheme.BRONZE.getId()) - .ui(GTSingleblockMachinePanels.STEAM_MACHINE) + .ui(GTSingleblockMachinePanels.GENERAL_MACHINE) .modelProperty(GTMachineModelProperties.VENT_DIRECTION, RelativeDirection.BACK) .workableSteamHullModel(pressure, GTCEu.id("block/machines/macerator")) .register()); @@ -185,11 +183,9 @@ public class GTMachines { public static final MachineDefinition[] ARC_FURNACE = registerTieredMachines("arc_furnace", (holder, tier) -> new SimpleTieredMachine(holder, tier, defaultTankSizeFunction), (tier, builder) -> builder .langValue("%s Arc Furnace %s".formatted(VLVH[tier], VLVT[tier])) - .ui(GTSingleblockMachinePanels.ARC_FURNACE) - // .editableUI(SimpleTieredMachine.EDITABLE_UI_CREATOR.apply(GTCEu.id("arc_furnace"), - // GTRecipeTypes.ARC_FURNACE_RECIPES)) .rotationState(RotationState.NON_Y_AXIS) .recipeType(GTRecipeTypes.ARC_FURNACE_RECIPES) + .ui(GTSingleblockMachinePanels.GENERAL_MACHINE) .recipeModifier(GTRecipeModifiers.OC_NON_PERFECT) .workableTieredHullModel(GTCEu.id("block/machines/arc_furnace")) .tooltips(workableTiered(tier, GTValues.V[tier], GTValues.V[tier] * 64, @@ -287,7 +283,6 @@ public class GTMachines { public static final MachineDefinition[] MACERATOR = registerTieredMachines("macerator", (holder, tier) -> new SimpleTieredMachine(holder, tier, defaultTankSizeFunction), (tier, builder) -> builder .langValue("%s Macerator %s".formatted(VLVH[tier], VLVT[tier])) - .ui(GTSingleblockMachinePanels.MACERATOR) .rotationState(RotationState.NON_Y_AXIS) .recipeType(GTRecipeTypes.MACERATOR_RECIPES) .addOutputLimit(ItemRecipeCapability.CAP, switch (tier) { @@ -295,6 +290,7 @@ public class GTMachines { case 3 -> 3; default -> 4; }) + .ui(GTSingleblockMachinePanels.GENERAL_MACHINE) .recipeModifier(GTRecipeModifiers.OC_NON_PERFECT) .workableTieredHullModel(GTCEu.id("block/machines/macerator")) .tooltips(workableTiered(tier, GTValues.V[tier], GTValues.V[tier] * 64, @@ -1141,21 +1137,6 @@ public class GTMachines { .allowExtendedFacing(true) .register(); - public static final MachineDefinition MUI_TEST = REGISTRATE - .machine("test_mui", TestMuiMachine::new) - .rotationState(RotationState.ALL) - .model(createOverlayCasingMachineModel(GTCEu.id("block/casings/solid/machine_casing_clean_stainless_steel"), - GTCEu.id("block/machine/part/computer_monitor"))) - .register(); - - public static final MachineDefinition MUI_TEST_2 = REGISTRATE - .machine("test_mui_new", TestMuiMachine2::new) - .rotationState(RotationState.ALL) - .recipeType(GTRecipeTypes.ALLOY_SMELTER_RECIPES) - .model(createOverlayCasingMachineModel(GTCEu.id("block/casings/solid/machine_casing_clean_stainless_steel"), - GTCEu.id("block/machine/part/computer_monitor"))) - .register(); - public static void init() { GTMultiMachines.init(); GCYMMachines.init(); diff --git a/src/main/java/com/gregtechceu/gtceu/common/data/GTRecipeCapabilities.java b/src/main/java/com/gregtechceu/gtceu/common/data/GTRecipeCapabilities.java index 3efd43d9a99..4faf721e0ee 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/data/GTRecipeCapabilities.java +++ b/src/main/java/com/gregtechceu/gtceu/common/data/GTRecipeCapabilities.java @@ -9,14 +9,13 @@ import com.gregtechceu.gtceu.api.registry.GTRegistries; import net.minecraft.world.item.crafting.Ingredient; -import net.minecraft.world.level.block.state.BlockState; import net.minecraftforge.fml.ModLoader; public class GTRecipeCapabilities { public final static RecipeCapability ITEM = ItemRecipeCapability.CAP; public final static RecipeCapability FLUID = FluidRecipeCapability.CAP; - public final static RecipeCapability BLOCK_STATE = BlockStateRecipeCapability.CAP; + // public final static RecipeCapability BLOCK_STATE = BlockStateRecipeCapability.CAP; public final static RecipeCapability EU = EURecipeCapability.CAP; public final static RecipeCapability CWU = CWURecipeCapability.CAP; @@ -25,7 +24,7 @@ public static void init() { GTRegistries.RECIPE_CAPABILITIES.register(ITEM.name, ITEM); GTRegistries.RECIPE_CAPABILITIES.register(FLUID.name, FLUID); - GTRegistries.RECIPE_CAPABILITIES.register(BLOCK_STATE.name, BLOCK_STATE); + // GTRegistries.RECIPE_CAPABILITIES.register(BLOCK_STATE.name, BLOCK_STATE); GTRegistries.RECIPE_CAPABILITIES.register(EU.name, EU); GTRegistries.RECIPE_CAPABILITIES.register(CWU.name, CWU); diff --git a/src/main/java/com/gregtechceu/gtceu/common/data/GTRecipeTypes.java b/src/main/java/com/gregtechceu/gtceu/common/data/GTRecipeTypes.java index f0fd47eb905..86338632462 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/data/GTRecipeTypes.java +++ b/src/main/java/com/gregtechceu/gtceu/common/data/GTRecipeTypes.java @@ -1,5 +1,10 @@ package com.gregtechceu.gtceu.common.data; +import brachy.modularui.api.drawable.Text; +import brachy.modularui.integration.recipeviewer.RecipeSlotRole; +import brachy.modularui.integration.recipeviewer.RecipeViewerSlotWidget; +import brachy.modularui.widgets.TextWidget; +import brachy.modularui.widgets.layout.Flow; import com.gregtechceu.gtceu.GTCEu; import com.gregtechceu.gtceu.api.GTCEuAPI; import com.gregtechceu.gtceu.api.GTValues; @@ -7,34 +12,29 @@ import com.gregtechceu.gtceu.api.capability.recipe.FluidRecipeCapability; import com.gregtechceu.gtceu.api.capability.recipe.IO; import com.gregtechceu.gtceu.api.capability.recipe.ItemRecipeCapability; -import com.gregtechceu.gtceu.api.gui.GuiTextures; -import com.gregtechceu.gtceu.api.gui.widget.SlotWidget; -import com.gregtechceu.gtceu.api.gui.widget.TankWidget; +import com.gregtechceu.gtceu.api.machine.feature.ITieredMachine; import com.gregtechceu.gtceu.api.recipe.*; import com.gregtechceu.gtceu.api.recipe.content.Content; +import com.gregtechceu.gtceu.api.recipe.gui.RecipeUIModifier; import com.gregtechceu.gtceu.api.recipe.ingredient.FluidIngredient; import com.gregtechceu.gtceu.api.registry.GTRegistries; import com.gregtechceu.gtceu.api.sound.ExistingSoundEntry; import com.gregtechceu.gtceu.common.machine.multiblock.electric.FusionReactorMachine; import com.gregtechceu.gtceu.common.machine.trait.customlogic.*; import com.gregtechceu.gtceu.common.mui.GTGuiTextures; +import com.gregtechceu.gtceu.common.mui.GTMuiWidgets; import com.gregtechceu.gtceu.common.recipe.condition.AdjacentFluidCondition; import com.gregtechceu.gtceu.data.recipe.builder.GTRecipeBuilder; import com.gregtechceu.gtceu.integration.kjs.GTRegistryInfo; -import com.gregtechceu.gtceu.integration.recipeviewer.entry.fluid.FluidEntryList; -import com.gregtechceu.gtceu.integration.recipeviewer.entry.fluid.FluidHolderSetList; -import com.gregtechceu.gtceu.integration.recipeviewer.handlers.fluid.CycleFluidEntryHandler; -import com.gregtechceu.gtceu.integration.recipeviewer.handlers.item.CycleItemEntryHandler; import com.gregtechceu.gtceu.utils.FormattingUtil; import com.gregtechceu.gtceu.utils.GTMath; import com.gregtechceu.gtceu.utils.ResearchManager; import com.lowdragmc.lowdraglib.utils.LocalizationUtils; -import net.minecraft.client.resources.language.I18n; import net.minecraft.core.HolderSet; import net.minecraft.core.registries.BuiltInRegistries; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.network.chat.Component; import net.minecraft.sounds.SoundEvents; import net.minecraft.sounds.SoundSource; import net.minecraft.world.item.ItemStack; @@ -42,14 +42,14 @@ import net.minecraft.world.level.material.Fluid; import net.minecraftforge.fml.ModLoader; +import brachy.modularui.integration.recipeviewer.entry.fluid.FluidHolderSetList; +import brachy.modularui.integration.recipeviewer.entry.item.ItemStackList; import brachy.modularui.widgets.ProgressWidget; import java.util.ArrayList; import java.util.Collections; import java.util.List; -import static com.lowdragmc.lowdraglib.gui.texture.ProgressTexture.FillDirection.*; - public class GTRecipeTypes { public static final String STEAM = "steam"; @@ -68,7 +68,7 @@ public class GTRecipeTypes { ////////////////////////////////////// public final static GTRecipeType STEAM_BOILER_RECIPES = register("steam_boiler", STEAM) .setMaxIOSize(1, 0, 1, 1) - .setProgressBar(GuiTextures.PROGRESS_BAR_BOILER_FUEL.get(true), DOWN_TO_UP) + .UI(builder -> builder.setProgressBar(GTGuiTextures.PROGRESS_BAR_BOILER_FUEL_STEEL, 18, ProgressWidget.Direction.UP)) .onRecipeBuild((builder, provider) -> { // all LBB recipes' duration is 1/4 the small boiler recipe's duration int duration = builder.duration / 4; @@ -87,26 +87,19 @@ public class GTRecipeTypes { .prepareBuilder(recipeBuilder -> recipeBuilder.EUt(4)) .UI(builder -> builder.setProgressBar(GTGuiTextures.PROGRESS_BAR_ARROW, 20) .setItemSlotOverlay(IO.IN, 0, GTGuiTextures.FURNACE_OVERLAY_1)) - // .setSlotOverlay(false, false, GuiTextures.FURNACE_OVERLAY_1) - // .setProgressBar(GuiTextures.PROGRESS_BAR_ARROW, LEFT_TO_RIGHT) - .setSteamProgressBar(GuiTextures.PROGRESS_BAR_ARROW_STEAM, LEFT_TO_RIGHT) .setSound(GTSoundEntries.FURNACE); public final static GTRecipeType ALLOY_SMELTER_RECIPES = register("alloy_smelter", ELECTRIC) .setMaxIOSize(2, 1, 0, 0).setEUIO(IO.IN) .UI(builder -> builder.setProgressBar(GTGuiTextures.PROGRESS_BAR_ARROW, 20) .setItemSlotOverlay(IO.IN, 0, GTGuiTextures.FURNACE_OVERLAY_1)) - // .setSlotOverlay(false, false, GuiTextures.FURNACE_OVERLAY_1) - // .setProgressBar(GuiTextures.PROGRESS_BAR_ARROW, LEFT_TO_RIGHT) .setIconSupplier(() -> GTMachines.ALLOY_SMELTER[GTValues.LV].asStack()) - .setSteamProgressBar(GuiTextures.PROGRESS_BAR_ARROW_STEAM, LEFT_TO_RIGHT) .setSound(GTSoundEntries.FURNACE); public final static GTRecipeType ARC_FURNACE_RECIPES = register("arc_furnace", ELECTRIC).setMaxIOSize(1, 4, 1, 1) .setEUIO(IO.IN) .UI(builder -> builder.setProgressBar(GTGuiTextures.PROGRESS_BAR_ARROW, 20) - .setIOSlotWidth(IO.OUT, ItemRecipeCapability.CAP, 0, 2)) - // .setProgressBar(GuiTextures.PROGRESS_BAR_ARC_FURNACE, LEFT_TO_RIGHT) + .setLayoutGridBuilder(ItemRecipeCapability.CAP, IO.OUT, l -> GTMuiWidgets.createGrid(4, 2, true, 's'))) .setSound(GTSoundEntries.ARC) .onRecipeBuild((recipeBuilder, provider) -> { if (recipeBuilder.input.getOrDefault(FluidRecipeCapability.CAP, Collections.emptyList()).isEmpty() && @@ -120,8 +113,6 @@ public class GTRecipeTypes { public final static GTRecipeType ASSEMBLER_RECIPES = register("assembler", ELECTRIC).setMaxIOSize(9, 1, 1, 0) .setEUIO(IO.IN) .UI(builder -> builder.setProgressBar(GTGuiTextures.PROGRESS_BAR_ASSEMBLER, 20)) - // .setSlotOverlay(false, false, GuiTextures.SLOT) - // .setProgressBar(GuiTextures.PROGRESS_BAR_ASSEMBLER, LEFT_TO_RIGHT) .setSound(GTSoundEntries.ASSEMBLER); public final static GTRecipeType AUTOCLAVE_RECIPES = register("autoclave", ELECTRIC).setMaxIOSize(2, 2, 1, 1) @@ -129,9 +120,6 @@ public class GTRecipeTypes { .UI(builder -> builder.setProgressBar(GTGuiTextures.PROGRESS_BAR_CRYSTALLIZATION, 20) .setItemSlotOverlay(IO.IN, 0, GTGuiTextures.DUST_OVERLAY) .setItemSlotOverlay(IO.OUT, 0, GTGuiTextures.CRYSTAL_OVERLAY)) - // .setSlotOverlay(false, false, GuiTextures.DUST_OVERLAY) - // .setSlotOverlay(true, false, GuiTextures.CRYSTAL_OVERLAY) - // .setProgressBar(GuiTextures.PROGRESS_BAR_CRYSTALLIZATION, LEFT_TO_RIGHT) .setSound(GTSoundEntries.FURNACE); public final static GTRecipeType BENDER_RECIPES = register("bender", ELECTRIC).setMaxIOSize(2, 1, 0, 0) @@ -139,9 +127,6 @@ public class GTRecipeTypes { .UI(builder -> builder.setProgressBar(GTGuiTextures.PROGRESS_BAR_BENDING, 20) .setItemSlotOverlay(IO.IN, 0, GTGuiTextures.BENDER_OVERLAY) .setItemSlotOverlay(IO.IN, 1, GTGuiTextures.INT_CIRCUIT_OVERLAY)) - // .setSlotOverlay(false, false, false, GuiTextures.BENDER_OVERLAY) - // .setSlotOverlay(false, false, true, GuiTextures.INT_CIRCUIT_OVERLAY) - // .setProgressBar(GuiTextures.PROGRESS_BAR_BENDING, LEFT_TO_RIGHT) .setSound(GTSoundEntries.MOTOR); public final static GTRecipeType BREWING_RECIPES = register("brewery", ELECTRIC).setMaxIOSize(1, 0, 1, 1) @@ -158,19 +143,23 @@ public class GTRecipeTypes { .setEUIO(IO.IN) .prepareBuilder(recipeBuilder -> recipeBuilder.duration(150).EUt(2)) .UI(builder -> builder.setProgressBar(GTGuiTextures.PROGRESS_BAR_MACERATE, 20) + .setMachineLayoutGridBuilder(ItemRecipeCapability.CAP, IO.OUT, (machine, layout) -> { + var slots = layout.getRecipeType().getMaxOutputs(ItemRecipeCapability.CAP); + + if (machine instanceof ITieredMachine tieredMachine) { + if (tieredMachine.getTier() < GTValues.HV) slots = 1; + else if (tieredMachine.getTier() == GTValues.HV) slots = 3; + else slots = 4; + } + + return GTMuiWidgets.createGrid(slots, Math.min(3, slots), true, 's'); + }) .setItemSlotOverlay(IO.IN, 0, GTGuiTextures.CRUSHED_ORE_OVERLAY) .setItemSlotsOverlay(IO.OUT, 0, 3, GTGuiTextures.DUST_OVERLAY) - .setIOSlotLengths(IO.OUT, ItemRecipeCapability.CAP, 0, 2, 1) - .setIOSlotLength(IO.OUT, ItemRecipeCapability.CAP, 3, 3) - .setIOSlotWidths(IO.OUT, ItemRecipeCapability.CAP, 4, GTValues.MAX, 2)) - // .setSlotOverlay(false, false, GuiTextures.CRUSHED_ORE_OVERLAY) - // .setSlotOverlay(true, false, GuiTextures.DUST_OVERLAY) - // .setProgressBar(GuiTextures.PROGRESS_BAR_MACERATE, LEFT_TO_RIGHT) + .addRecipeUIModifier(RecipeUIModifier.textLine(Text.lang("gtceu.recipe.byproduct_tier", GTValues.VNF[GTValues.HV])))) .setIconSupplier(() -> GTMachines.MACERATOR[GTValues.LV].asStack()) - .setSteamProgressBar(GuiTextures.PROGRESS_BAR_MACERATE_STEAM, LEFT_TO_RIGHT) .addCustomRecipeLogic(MaceratorLogic.INSTANCE) - .setSound(GTSoundEntries.MACERATOR) - .addDataInfo(data -> LocalizationUtils.format("gtceu.recipe.byproduct_tier", GTValues.VNF[GTValues.HV])); + .setSound(GTSoundEntries.MACERATOR); public final static GTRecipeType CANNER_RECIPES = register("canner", ELECTRIC).setMaxIOSize(2, 2, 1, 1) .setEUIO(IO.IN) @@ -180,12 +169,6 @@ public class GTRecipeTypes { .setItemSlotOverlay(IO.OUT, 0, GTGuiTextures.CANISTER_OVERLAY) .setFluidSlotOverlay(IO.IN, 0, GTGuiTextures.DARK_CANISTER_OVERLAY) .setFluidSlotOverlay(IO.OUT, 0, GTGuiTextures.DARK_CANISTER_OVERLAY)) - // .setSlotOverlay(false, false, false, GuiTextures.CANNER_OVERLAY) - // .setSlotOverlay(false, false, true, GuiTextures.CANISTER_OVERLAY) - // .setSlotOverlay(true, false, GuiTextures.CANISTER_OVERLAY) - // .setSlotOverlay(false, true, GuiTextures.DARK_CANISTER_OVERLAY) - // .setSlotOverlay(true, true, GuiTextures.DARK_CANISTER_OVERLAY) - // .setProgressBar(GuiTextures.PROGRESS_BAR_CANNER, LEFT_TO_RIGHT) .addCustomRecipeLogic(CannerLogic.INSTANCE) .setSound(GTSoundEntries.BATH); @@ -242,10 +225,7 @@ public class GTRecipeTypes { .prepareBuilder(recipeBuilder -> recipeBuilder.duration(200).EUt(2)) .UI(builder -> builder.setProgressBar(GTGuiTextures.PROGRESS_BAR_COMPRESS, 20) .setItemSlotOverlay(IO.IN, 0, GTGuiTextures.COMPRESSOR_OVERLAY)) - // .setSlotOverlay(false, false, GuiTextures.COMPRESSOR_OVERLAY) - // .setProgressBar(GuiTextures.PROGRESS_BAR_COMPRESS, LEFT_TO_RIGHT) .setIconSupplier(() -> GTMachines.COMPRESSOR[GTValues.LV].asStack()) - .setSteamProgressBar(GuiTextures.PROGRESS_BAR_COMPRESS_STEAM, LEFT_TO_RIGHT) .setSound(GTSoundEntries.COMPRESSOR); public final static GTRecipeType CUTTER_RECIPES = register("cutter", ELECTRIC).setMaxIOSize(1, 2, 1, 0) @@ -254,22 +234,18 @@ public class GTRecipeTypes { .setItemSlotOverlay(IO.IN, 0, GTGuiTextures.SAWBLADE_OVERLAY) .setItemSlotOverlay(IO.OUT, 0, GTGuiTextures.CUTTER_OVERLAY) .setItemSlotOverlay(IO.OUT, 1, GTGuiTextures.DUST_OVERLAY)) - // .setSlotOverlay(false, false, GuiTextures.SAWBLADE_OVERLAY) - // .setSlotOverlay(true, false, false, GuiTextures.CUTTER_OVERLAY) - // .setSlotOverlay(true, false, true, GuiTextures.DUST_OVERLAY) - // .setProgressBar(GuiTextures.PROGRESS_BAR_SLICE, LEFT_TO_RIGHT) .setSound(GTSoundEntries.CUT) .onRecipeBuild((recipeBuilder, provider) -> { if (recipeBuilder.input.getOrDefault(FluidRecipeCapability.CAP, Collections.emptyList()).isEmpty() && recipeBuilder.tickInput.getOrDefault(FluidRecipeCapability.CAP, Collections.emptyList()) .isEmpty()) { - recipeBuilder.copy(new ResourceLocation(recipeBuilder.id.toString() + "_water")) + recipeBuilder.copy(recipeBuilder.id.withSuffix("_water")) .inputFluids(GTMaterials.Water.getFluid((int) GTMath.clamp( recipeBuilder.duration * recipeBuilder.EUt().getTotalEU() / 320, 4, 1000))) .duration(recipeBuilder.duration * 2) .save(provider); - recipeBuilder.copy(new ResourceLocation(recipeBuilder.id.toString() + "_distilled_water")) + recipeBuilder.copy((recipeBuilder.id.withSuffix("_distilled_water"))) .inputFluids(GTMaterials.DistilledWater.getFluid((int) GTMath.clamp( recipeBuilder.duration * recipeBuilder.EUt().getTotalEU() / 426, 3, 750))) .duration((int) (recipeBuilder.duration * 1.5)) @@ -326,8 +302,7 @@ public class GTRecipeTypes { .setItemSlotOverlay(IO.IN, 0, GTGuiTextures.EXTRACTOR_OVERLAY)) // .setSlotOverlay(false, false, GuiTextures.EXTRACTOR_OVERLAY) // .setProgressBar(GuiTextures.PROGRESS_BAR_EXTRACT, LEFT_TO_RIGHT) - .setIconSupplier(() -> GTMachines.EXTRACTOR[GTValues.LV].asStack()) - .setSteamProgressBar(GuiTextures.PROGRESS_BAR_EXTRACT_STEAM, LEFT_TO_RIGHT); + .setIconSupplier(() -> GTMachines.EXTRACTOR[GTValues.LV].asStack()); public final static GTRecipeType EXTRUDER_RECIPES = register("extruder", ELECTRIC).setMaxIOSize(2, 1, 0, 0) .setEUIO(IO.IN) @@ -371,11 +346,18 @@ public class GTRecipeTypes { public final static GTRecipeType FORGE_HAMMER_RECIPES = register("forge_hammer", ELECTRIC).setMaxIOSize(1, 1, 0, 0) .setEUIO(IO.IN) .UI(builder -> builder.setProgressBar(GTGuiTextures.PROGRESS_BAR_HAMMER, 20, ProgressWidget.Direction.DOWN) - .setItemSlotOverlay(IO.IN, 0, GTGuiTextures.HAMMER_OVERLAY)) - // .setSlotOverlay(false, false, GuiTextures.HAMMER_OVERLAY) - // .setProgressBar(GuiTextures.PROGRESS_BAR_HAMMER, UP_TO_DOWN) + .setItemSlotOverlay(IO.IN, 0, GTGuiTextures.HAMMER_OVERLAY) + .setProgressBarSupplier((layout, value) -> + Flow.col().coverChildren().child(new ProgressWidget() + .value(value) + .name("progressBar") + .texture(layout.getProgressBar(), 20) + .size(layout.getProgressSize()) + .direction(layout.getProgressDirection())) + .child(GTGuiTextures.PROGRESS_BAR_HAMMER_BASE.asWidget().height(5)) + ) + ) .setIconSupplier(() -> GTMachines.FORGE_HAMMER[GTValues.LV].asStack()) - .setSteamProgressBar(GuiTextures.PROGRESS_BAR_HAMMER_STEAM, UP_TO_DOWN) .setSound(GTSoundEntries.FORGE_HAMMER); public final static GTRecipeType FORMING_PRESS_RECIPES = register("forming_press", ELECTRIC) @@ -389,11 +371,17 @@ public class GTRecipeTypes { .UI(builder -> builder.setProgressBar(GTGuiTextures.PROGRESS_BAR_LATHE, 20) .setItemSlotOverlay(IO.IN, 0, GTGuiTextures.PIPE_OVERLAY_1) .setItemSlotOverlay(IO.OUT, 0, GTGuiTextures.PIPE_OVERLAY_2) - .setItemSlotOverlay(IO.OUT, 1, GTGuiTextures.DUST_OVERLAY)) - // .setSlotOverlay(false, false, GuiTextures.PIPE_OVERLAY_1) - // .setSlotOverlay(true, false, false, GuiTextures.PIPE_OVERLAY_2) - // .setSlotOverlay(true, false, true, GuiTextures.DUST_OVERLAY) - // .setProgressBar(GuiTextures.PROGRESS_BAR_LATHE, LEFT_TO_RIGHT) + .setItemSlotOverlay(IO.OUT, 1, GTGuiTextures.DUST_OVERLAY) + .setProgressBarSupplier((layout, value) -> + Flow.row().coverChildren().child(new ProgressWidget() + .value(value) + .name("progressBar") + .texture(layout.getProgressBar(), 20) + .size(layout.getProgressSize()) + .direction(layout.getProgressDirection())) + .child(GTGuiTextures.PROGRESS_BAR_LATHE_BASE.asWidget().width(5)) + ) + ) .setSound(GTSoundEntries.CUT); public final static GTRecipeType MIXER_RECIPES = register("mixer", ELECTRIC).setMaxIOSize(6, 1, 2, 1).setEUIO(IO.IN) @@ -479,7 +467,7 @@ public class GTRecipeTypes { if (recipeBuilder.input.getOrDefault(FluidRecipeCapability.CAP, Collections.emptyList()).isEmpty() && recipeBuilder.tickInput.getOrDefault(FluidRecipeCapability.CAP, Collections.emptyList()) .isEmpty()) { - recipeBuilder.copy(new ResourceLocation(recipeBuilder.id.toString() + "_soldering_alloy")) + recipeBuilder.copy(recipeBuilder.id.withSuffix("_soldering_alloy")) .inputFluids(GTMaterials.SolderingAlloy .getFluid(Math.max(1, (GTValues.L / 2) * recipeBuilder.getSolderMultiplier()))) .save(provider); @@ -497,16 +485,11 @@ public class GTRecipeTypes { .UI(builder -> builder.setProgressBar(GTGuiTextures.PROGRESS_BAR_GAS_COLLECTOR, 20) .setItemSlotOverlay(IO.IN, 0, GTGuiTextures.INT_CIRCUIT_OVERLAY) .setFluidSlotOverlay(IO.OUT, 0, GTGuiTextures.CENTRIFUGE_OVERLAY)) - // .setSlotOverlay(false, false, GuiTextures.INT_CIRCUIT_OVERLAY) - // .setSlotOverlay(true, true, GuiTextures.CENTRIFUGE_OVERLAY) - // .setProgressBar(GuiTextures.PROGRESS_BAR_GAS_COLLECTOR, LEFT_TO_RIGHT) - .setOffsetVoltageText(true) .setSound(GTSoundEntries.COOLING); public final static GTRecipeType AIR_SCRUBBER_RECIPES = register("air_scrubber", ELECTRIC) .setMaxIOSize(1, 3, 1, 3).setEUIO(IO.IN) .UI(builder -> builder.setProgressBar(GTGuiTextures.PROGRESS_BAR_GAS_COLLECTOR, 20)) - // .setProgressBar(GuiTextures.PROGRESS_BAR_GAS_COLLECTOR, LEFT_TO_RIGHT) .setSound(GTSoundEntries.COOLING); public static final GTRecipeType RESEARCH_STATION_RECIPES = register("research_station", ELECTRIC) @@ -514,9 +497,6 @@ public class GTRecipeTypes { .UI(builder -> builder.setProgressBar(GTGuiTextures.PROGRESS_BAR_ARROW, 20) .setItemSlotOverlay(IO.IN, 0, GTGuiTextures.SCANNER_OVERLAY) .setItemSlotOverlay(IO.OUT, 0, GTGuiTextures.RESEARCH_STATION_OVERLAY)) - // .setProgressBar(GuiTextures.PROGRESS_BAR_ARROW, LEFT_TO_RIGHT) - // .setSlotOverlay(false, false, GuiTextures.SCANNER_OVERLAY) - // .setSlotOverlay(true, false, GuiTextures.RESEARCH_STATION_OVERLAY) .setScanner(true) .setMaxTooltips(4) .setSound(GTValues.FOOLS.getAsBoolean() ? GTSoundEntries.SCIENCE : GTSoundEntries.COMPUTATION); @@ -525,42 +505,9 @@ public class GTRecipeTypes { .setEUIO(IO.IN) .UI(builder -> builder.setProgressBar(GTGuiTextures.PROGRESS_BAR_MACERATE, 20) .setItemSlotOverlay(IO.IN, 0, GTGuiTextures.DUST_OVERLAY) - .setItemSlotOverlay(IO.OUT, 0, GTGuiTextures.CRUSHED_ORE_OVERLAY)) - // .setSlotOverlay(false, false, GuiTextures.DUST_OVERLAY) - // .setSlotOverlay(true, false, GuiTextures.CRUSHED_ORE_OVERLAY) - // .setProgressBar(GuiTextures.PROGRESS_BAR_MACERATE, LEFT_TO_RIGHT) + .setItemSlotOverlay(IO.OUT, 0, GTGuiTextures.CRUSHED_ORE_OVERLAY) + ) .setIconSupplier(() -> GTMachines.ROCK_CRUSHER[GTValues.LV].asStack()) - .setSteamProgressBar(GuiTextures.PROGRESS_BAR_MACERATE_STEAM, LEFT_TO_RIGHT) - .setUiBuilder((recipe, widgetGroup) -> { - List> fluids = new ArrayList<>(); - for (RecipeCondition condition : recipe.conditions) { - if (condition instanceof AdjacentFluidCondition adjacentFluid) { - fluids.addAll(adjacentFluid.getOrInitFluids(recipe)); - } - } - if (fluids.isEmpty()) { - return; - } - - int xOffset = 35; - int yOffset = 0; - int i = 0; - for (HolderSet set : fluids) { - if (set.size() == 0) { - continue; - } - List slots = Collections.singletonList(FluidHolderSetList.of(set, 1000, null)); - TankWidget tank = new TankWidget(new CycleFluidEntryHandler(slots), - widgetGroup.getSize().width - 30 - xOffset, widgetGroup.getSize().height - 30 + yOffset, - false, false) - .setBackground(GuiTextures.FLUID_SLOT).setShowAmount(false); - widgetGroup.addWidget(tank); - - i++; - xOffset = 20 * (2 - (i % 3)) - 5; - yOffset = 20 * (i / 3); - } - }) .setSound(GTSoundEntries.FIRE); public static final GTRecipeType SCANNER_RECIPES = register("scanner", ELECTRIC) @@ -568,9 +515,6 @@ public class GTRecipeTypes { .UI(builder -> builder.setProgressBar(GTGuiTextures.PROGRESS_BAR_ARROW, 20) .setItemSlotOverlay(IO.IN, 0, GTGuiTextures.DATA_ORB_OVERLAY) .setItemSlotOverlay(IO.IN, 1, GTGuiTextures.SCANNER_OVERLAY)) - // .setSlotOverlay(false, false, GuiTextures.DATA_ORB_OVERLAY) - // .setSlotOverlay(false, false, true, GuiTextures.SCANNER_OVERLAY) - // .setProgressBar(GuiTextures.PROGRESS_BAR_ARROW, LEFT_TO_RIGHT) .addCustomRecipeLogic(new ResearchManager.DataStickCopyScannerLogic()) .setScanner(true) .setSound(GTSoundEntries.ELECTROLYZER); @@ -580,26 +524,26 @@ public class GTRecipeTypes { ////////////////////////////////////// public final static GTRecipeType COMBUSTION_GENERATOR_FUELS = register("combustion_generator", GENERATOR) .setMaxIOSize(0, 0, 1, 0).setEUIO(IO.OUT) - .setSlotOverlay(false, true, true, GuiTextures.FURNACE_OVERLAY_2) - .setProgressBar(GuiTextures.PROGRESS_BAR_ARROW_MULTIPLE, LEFT_TO_RIGHT) + .UI(builder -> builder.setFluidSlotOverlay(IO.IN, 0, GTGuiTextures.FURNACE_OVERLAY_2) + .setProgressBar(GTGuiTextures.PROGRESS_BAR_ARROW_MULTIPLE, 20, ProgressWidget.Direction.RIGHT)) .setSound(GTSoundEntries.COMBUSTION); public final static GTRecipeType GAS_TURBINE_FUELS = register("gas_turbine", GENERATOR).setMaxIOSize(0, 0, 1, 0) .setEUIO(IO.OUT) - .setSlotOverlay(false, true, true, GuiTextures.DARK_CANISTER_OVERLAY) - .setProgressBar(GuiTextures.PROGRESS_BAR_GAS_COLLECTOR, LEFT_TO_RIGHT) + .UI(builder -> builder.setFluidSlotOverlay(IO.IN, 0, GTGuiTextures.DARK_CANISTER_OVERLAY) + .setProgressBar(GTGuiTextures.PROGRESS_BAR_GAS_COLLECTOR, 20, ProgressWidget.Direction.RIGHT)) .setSound(GTSoundEntries.TURBINE); public final static GTRecipeType STEAM_TURBINE_FUELS = register("steam_turbine", GENERATOR).setMaxIOSize(0, 0, 1, 1) .setEUIO(IO.OUT) - .setSlotOverlay(false, true, true, GuiTextures.CENTRIFUGE_OVERLAY) - .setProgressBar(GuiTextures.PROGRESS_BAR_GAS_COLLECTOR, LEFT_TO_RIGHT) + .UI(builder -> builder.setFluidSlotOverlay(IO.IN, 0, GTGuiTextures.CENTRIFUGE_OVERLAY) + .setProgressBar(GTGuiTextures.PROGRESS_BAR_GAS_COLLECTOR, 20, ProgressWidget.Direction.RIGHT)) .setSound(GTSoundEntries.TURBINE); public final static GTRecipeType PLASMA_GENERATOR_FUELS = register("plasma_generator", GENERATOR) .setMaxIOSize(0, 0, 1, 1).setEUIO(IO.OUT) - .setSlotOverlay(false, true, true, GuiTextures.CENTRIFUGE_OVERLAY) - .setProgressBar(GuiTextures.PROGRESS_BAR_GAS_COLLECTOR, LEFT_TO_RIGHT) + .UI(builder -> builder.setFluidSlotOverlay(IO.IN, 0, GTGuiTextures.CENTRIFUGE_OVERLAY) + .setProgressBar(GTGuiTextures.PROGRESS_BAR_GAS_COLLECTOR, 20, ProgressWidget.Direction.RIGHT)) .setSound(GTSoundEntries.TURBINE); ////////////////////////////////////// @@ -607,60 +551,62 @@ public class GTRecipeTypes { ////////////////////////////////////// public final static GTRecipeType LARGE_BOILER_RECIPES = register("large_boiler", MULTIBLOCK) .setMaxIOSize(1, 0, 1, 1) - .setProgressBar(GuiTextures.PROGRESS_BAR_BOILER_FUEL.get(true), DOWN_TO_UP) + .UI(builder -> builder.setProgressBar(GTGuiTextures.PROGRESS_BAR_BOILER_FUEL_STEEL, 18, ProgressWidget.Direction.UP)) .setMaxTooltips(1) .setSound(GTSoundEntries.FURNACE); public final static GTRecipeType COKE_OVEN_RECIPES = register("coke_oven", MULTIBLOCK).setMaxIOSize(1, 1, 0, 1) - .setProgressBar(GuiTextures.PROGRESS_BAR_ARROW, LEFT_TO_RIGHT) + .UI(builder -> builder.setProgressBar(GTGuiTextures.PROGRESS_BAR_ARROW, 20, ProgressWidget.Direction.RIGHT)) .setMaxTooltips(1) .setSound(GTSoundEntries.FIRE); public final static GTRecipeType PRIMITIVE_BLAST_FURNACE_RECIPES = register("primitive_blast_furnace", MULTIBLOCK) .setMaxIOSize(3, 3, 0, 0) - .setProgressBar(GuiTextures.PROGRESS_BAR_ARROW, LEFT_TO_RIGHT) + .UI(builder -> builder.setProgressBar(GTGuiTextures.PROGRESS_BAR_ARROW, 20, ProgressWidget.Direction.RIGHT)) .setMaxTooltips(1) .setSound(GTSoundEntries.FIRE); public final static GTRecipeType BLAST_RECIPES = register("electric_blast_furnace", MULTIBLOCK) .setMaxIOSize(3, 3, 1, 1).setEUIO(IO.IN) - .addDataInfo(data -> { - int temp = data.getInt("ebf_temp"); - return LocalizationUtils.format("gtceu.recipe.temperature", FormattingUtil.formatTemperature(temp)); - }) - .addDataInfo(data -> { - int temp = data.getInt("ebf_temp"); - ICoilType requiredCoil = ICoilType.getMinRequiredType(temp); + .UI(builder -> builder.setProgressBar(GTGuiTextures.PROGRESS_BAR_ARROW, 20, ProgressWidget.Direction.RIGHT) + .addRecipeUIModifier((recipe, widget) -> { + if (recipe.data.contains("ebf_temp")) { + int temp = recipe.data.getInt("ebf_temp"); - if (requiredCoil != null && !requiredCoil.getMaterial().isNull()) { - return LocalizationUtils.format("gtceu.recipe.coil.tier", - I18n.get(requiredCoil.getMaterial().getUnlocalizedName())); - } - return ""; - }) - .setUiBuilder((recipe, widgetGroup) -> { - int temp = recipe.data.getInt("ebf_temp"); - List> items = new ArrayList<>(); - items.add(GTCEuAPI.HEATING_COILS.entrySet().stream() - .filter(coil -> coil.getKey().getCoilTemperature() >= temp) - .map(coil -> new ItemStack(coil.getValue().get())).toList()); - widgetGroup.addWidget(new SlotWidget(CycleItemEntryHandler.fromStacks(items), 0, - widgetGroup.getSize().width - 25, widgetGroup.getSize().height - 32, false, false)); - }) + widget.textComponents.child(new TextWidget<>(Text.lang("gtceu.recipe.temperature", FormattingUtil.formatTemperature(temp)))); + + ICoilType requiredCoil = ICoilType.getMinRequiredType(temp); + + if (requiredCoil != null && !requiredCoil.getMaterial().isNull()) { + widget.textComponents.child(new TextWidget<>(Text.lang("gtceu.recipe.coil.tier", Component.translatable(requiredCoil.getMaterial().getUnlocalizedName()).getString()))); + } + + List items = GTCEuAPI.HEATING_COILS.entrySet().stream() + .filter(coil -> coil.getKey().getCoilTemperature() >= temp) + .map(coil -> new ItemStack(coil.getValue().get())).toList(); + + widget.child(RecipeViewerSlotWidget.create() + .recipeSlotRole(RecipeSlotRole.RENDER_ONLY) + .value(ItemStackList.of(items)) + .posRel(0.80f, 0.80f) + ); + } + }) + ) .setSound(GTSoundEntries.FURNACE); public final static GTRecipeType DISTILLATION_RECIPES = register("distillation_tower", MULTIBLOCK) .setMaxIOSize(0, 1, 1, 12).setEUIO(IO.IN) .setSound(GTSoundEntries.CHEMICAL) - .setProgressBar(GuiTextures.PROGRESS_BAR_ARROW_MULTIPLE, LEFT_TO_RIGHT) + .UI(builder -> builder.setProgressBar(GTGuiTextures.PROGRESS_BAR_ARROW_MULTIPLE, 20, ProgressWidget.Direction.RIGHT)) .onRecipeBuild((recipeBuilder, provider) -> { if (recipeBuilder.data.getBoolean("disable_distillery")) return; if (recipeBuilder.output.containsKey(FluidRecipeCapability.CAP)) { Content inputContent = recipeBuilder.input.get(FluidRecipeCapability.CAP).get(0); - FluidIngredient input = FluidRecipeCapability.CAP.of(inputContent.getContent()); + FluidIngredient input = FluidRecipeCapability.CAP.of(inputContent.content()); ItemStack[] outputs = recipeBuilder.output.containsKey(ItemRecipeCapability.CAP) ? ItemRecipeCapability.CAP - .of(recipeBuilder.output.get(ItemRecipeCapability.CAP).get(0).getContent()) + .of(recipeBuilder.output.get(ItemRecipeCapability.CAP).get(0).content()) .getItems() : null; ItemStack outputItem = outputs == null || outputs.length == 0 ? ItemStack.EMPTY : outputs[0]; @@ -668,7 +614,7 @@ public class GTRecipeTypes { List contents = recipeBuilder.output.get(FluidRecipeCapability.CAP); for (int i = 0; i < contents.size(); ++i) { Content outputContent = contents.get(i); - FluidIngredient output = FluidRecipeCapability.CAP.of(outputContent.getContent()); + FluidIngredient output = FluidRecipeCapability.CAP.of(outputContent.content()); if (output.isEmpty()) continue; GTRecipeBuilder builder = DISTILLERY_RECIPES .recipeBuilder(recipeBuilder.id.getPath() + "_to_" + @@ -689,11 +635,11 @@ public class GTRecipeTypes { dividedOutputFluid.setAmount(Math.max(1, dividedOutputFluid.getAmount() / ratio)); if (shouldDivide && fluidsDivisible) { - builder.chance(inputContent.chance) - .tierChanceBoost(inputContent.tierChanceBoost) + builder.chance(inputContent.chance()) + .tierChanceBoost(inputContent.tierChanceBoost()) .inputFluids(dividedInputFluid) - .chance(outputContent.chance) - .tierChanceBoost(outputContent.tierChanceBoost) + .chance(outputContent.chance()) + .tierChanceBoost(outputContent.tierChanceBoost()) .outputFluids(dividedOutputFluid) .duration(Math.max(1, recipeDuration / ratio)); } else if (!shouldDivide) { @@ -701,11 +647,11 @@ public class GTRecipeTypes { builder.outputItems(outputItem); } builder.conditions.addAll(recipeBuilder.conditions); - builder.chance(inputContent.chance) - .tierChanceBoost(inputContent.tierChanceBoost) + builder.chance(inputContent.chance()) + .tierChanceBoost(inputContent.tierChanceBoost()) .inputFluids(input) - .chance(outputContent.chance) - .tierChanceBoost(outputContent.tierChanceBoost) + .chance(outputContent.chance()) + .tierChanceBoost(outputContent.tierChanceBoost()) .outputFluids(output) .duration(recipeDuration) .save(provider); @@ -733,18 +679,21 @@ public class GTRecipeTypes { public final static GTRecipeType CRACKING_RECIPES = register("cracker", MULTIBLOCK).setMaxIOSize(1, 0, 2, 2) .setEUIO(IO.IN) - .setSlotOverlay(false, true, GuiTextures.CRACKING_OVERLAY_1) - .setSlotOverlay(true, true, GuiTextures.CRACKING_OVERLAY_2) - .setSlotOverlay(false, false, GuiTextures.CIRCUIT_OVERLAY) - .setProgressBar(GuiTextures.PROGRESS_BAR_CRACKING, LEFT_TO_RIGHT) + .UI(builder -> builder.setProgressBar(GTGuiTextures.PROGRESS_BAR_CRACKING, 20, ProgressWidget.Direction.RIGHT) + .setFluidSlotOverlay(IO.IN, 0, GTGuiTextures.CRACKING_OVERLAY_1) + .setFluidSlotOverlay(IO.OUT, 0, GTGuiTextures.CRACKING_OVERLAY_2) + .setItemSlotOverlay(IO.IN, 0, GTGuiTextures.CIRCUIT_OVERLAY)) .setSound(GTSoundEntries.FIRE); public final static GTRecipeType IMPLOSION_RECIPES = register("implosion_compressor", MULTIBLOCK) .setMaxIOSize(3, 2, 0, 0).setEUIO(IO.IN) .prepareBuilder(recipeBuilder -> recipeBuilder.duration(20).EUt(GTValues.VA[GTValues.LV])) - .setSlotOverlay(false, false, true, GuiTextures.IMPLOSION_OVERLAY_1) - .setSlotOverlay(false, false, false, GuiTextures.IMPLOSION_OVERLAY_2) - .setSlotOverlay(true, false, true, GuiTextures.DUST_OVERLAY) + .UI(builder -> builder + .setProgressBar(GTGuiTextures.PROGRESS_BAR_ARROW, 20, ProgressWidget.Direction.RIGHT) + .setItemSlotOverlay(IO.IN, 2, GTGuiTextures.IMPLOSION_OVERLAY_1) + .setItemSlotOverlay(IO.OUT, 0, GTGuiTextures.IMPLOSION_OVERLAY_2) + .setItemSlotOverlay(IO.OUT, 1, GTGuiTextures.DUST_OVERLAY) + ) .setSound(new ExistingSoundEntry(SoundEvents.GENERIC_EXPLODE, SoundSource.BLOCKS)); public final static GTRecipeType VACUUM_RECIPES = register("vacuum_freezer", MULTIBLOCK).setMaxIOSize(1, 1, 2, 1) @@ -754,7 +703,7 @@ public class GTRecipeTypes { public final static GTRecipeType ASSEMBLY_LINE_RECIPES = register("assembly_line", MULTIBLOCK) .setMaxIOSize(16, 1, 4, 0).setEUIO(IO.IN) - .setProgressBar(GuiTextures.PROGRESS_BAR_ARROW, LEFT_TO_RIGHT) + .UI(builder -> builder.setProgressBar(GTGuiTextures.PROGRESS_BAR_ARROW, 20, ProgressWidget.Direction.RIGHT)) .setSound(GTSoundEntries.ASSEMBLER) .setHasResearchSlot(true) .onRecipeBuild(ResearchManager::createDefaultResearchRecipe); @@ -762,23 +711,24 @@ public class GTRecipeTypes { public static final GTRecipeType LARGE_CHEMICAL_RECIPES = register("large_chemical_reactor", MULTIBLOCK) .setMaxIOSize(3, 3, 5, 4).setEUIO(IO.IN) .prepareBuilder(recipeBuilder -> recipeBuilder.EUt(GTValues.VA[GTValues.LV])) - .setSlotOverlay(false, false, false, GuiTextures.MOLECULAR_OVERLAY_1) - .setSlotOverlay(false, false, true, GuiTextures.MOLECULAR_OVERLAY_2) - .setSlotOverlay(false, true, false, GuiTextures.MOLECULAR_OVERLAY_3) - .setSlotOverlay(false, true, true, GuiTextures.MOLECULAR_OVERLAY_4) - .setSlotOverlay(true, false, GuiTextures.VIAL_OVERLAY_1) - .setSlotOverlay(true, true, GuiTextures.VIAL_OVERLAY_2) + .UI(builder -> builder + .setItemSlotsOverlay(IO.IN, 0, 1, GTGuiTextures.MOLECULAR_OVERLAY_1) + .setItemSlotOverlay(IO.IN, 2, GTGuiTextures.MOLECULAR_OVERLAY_2) + .setFluidSlotsOverlay(IO.IN, 0, 1, GTGuiTextures.MOLECULAR_OVERLAY_3) + .setFluidSlotOverlay(IO.IN, 2, GTGuiTextures.MOLECULAR_OVERLAY_4) + .setItemSlotOverlay(IO.OUT, 0, GTGuiTextures.VIAL_OVERLAY_1) + .setFluidSlotOverlay(IO.OUT, 0, GTGuiTextures.VIAL_OVERLAY_1) + .setProgressBar(GTGuiTextures.PROGRESS_BAR_ARROW_MULTIPLE, 20, ProgressWidget.Direction.RIGHT) + ) .setSound(GTValues.FOOLS.getAsBoolean() ? GTSoundEntries.SCIENCE : GTSoundEntries.CHEMICAL) - .setProgressBar(GuiTextures.PROGRESS_BAR_ARROW_MULTIPLE, LEFT_TO_RIGHT) .setSmallRecipeMap(CHEMICAL_RECIPES); public static final GTRecipeType FUSION_RECIPES = register("fusion_reactor", MULTIBLOCK).setMaxIOSize(0, 0, 2, 1) .setEUIO(IO.IN) - .setProgressBar(GuiTextures.PROGRESS_BAR_FUSION, LEFT_TO_RIGHT) + .UI(builder -> builder.setProgressBar(GTGuiTextures.PROGRESS_BAR_FUSION, 20, ProgressWidget.Direction.RIGHT) + .addRecipeUIModifier(FusionReactorMachine::addEUToStartLabel)) .setSound(GTSoundEntries.ARC) - .setOffsetVoltageText(true) - .setMaxTooltips(4) - .setUiBuilder(FusionReactorMachine::addEUToStartLabel); + .setMaxTooltips(4); public static final GTRecipeType DUMMY_RECIPES = register("dummy", DUMMY) .setXEIVisible(false); diff --git a/src/main/java/com/gregtechceu/gtceu/common/data/machines/GTMachineUtils.java b/src/main/java/com/gregtechceu/gtceu/common/data/machines/GTMachineUtils.java index 32355597ad9..0cfc33d0bef 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/data/machines/GTMachineUtils.java +++ b/src/main/java/com/gregtechceu/gtceu/common/data/machines/GTMachineUtils.java @@ -373,7 +373,7 @@ public static Pair registerSimpleSteamMach .recipeType(recipeType) .recipeModifier(SimpleSteamMachine::recipeModifier) .themeId((i) -> i > 0 ? GTGuiTheme.STEEL.getId() : GTGuiTheme.BRONZE.getId()) - .ui(GTSingleblockMachinePanels.STEAM_MACHINE) + .ui(GTSingleblockMachinePanels.GENERAL_MACHINE) .modelProperty(GTMachineModelProperties.VENT_DIRECTION, RelativeDirection.BACK) .workableSteamHullModel(pressure, GTCEu.id("block/machines/" + name)) .register()); diff --git a/src/main/java/com/gregtechceu/gtceu/common/item/behavior/DataItemBehavior.java b/src/main/java/com/gregtechceu/gtceu/common/item/behavior/DataItemBehavior.java index 58a3e79039d..2dfe385a3e9 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/item/behavior/DataItemBehavior.java +++ b/src/main/java/com/gregtechceu/gtceu/common/item/behavior/DataItemBehavior.java @@ -114,7 +114,7 @@ public void appendHoverText(ItemStack stack, @Nullable Level level, List buildUI(PlayerInventoryGuiData data, PanelSyncManager return new ModularPanel<>("item_magnet") .size(176, 157) .background(GTGuiTextures.BACKGROUND) - .child(IKey.dynamic(() -> Component.translatable(filterSync.getValue().getTooltip())) + .child(Text.dynamic(() -> Component.translatable(filterSync.getValue().getTooltip())) .asWidget() .left(5) .top(5)) @@ -132,7 +132,7 @@ public ModularPanel buildUI(PlayerInventoryGuiData data, PanelSyncManager .stateCount(Filter.values().length) .stateOverlay(Filter.SIMPLE, new ItemDrawable(GTItems.ITEM_FILTER.asItem())) .stateOverlay(Filter.TAG, new ItemDrawable(GTItems.TAG_FILTER.asItem())) - .tooltipBuilder(r -> r.addLine(IKey.dynamic( + .tooltipBuilder(r -> r.addLine(Text.dynamic( () -> Component.translatable(filterSync.getValue().getTooltip()))))) .child(pages) .child(SlotGroupWidget.playerInventory(false).left(7).top(75).disableSortButtons()); @@ -143,7 +143,7 @@ private ParentWidget createSimpleFilterPage(SimpleItemFilter filter) { Grid filterGrid = new Grid() .coverChildren() - .mapTo(3, 9, i -> new PhantomItemSlot() + .gridOfSizeWidth(9, 3, (x, y, i) -> new PhantomItemSlot() .size(16) .syncHandler(new PhantomItemSlotSyncHandler(new ModularSlot(handler, i) .changeListener((stack, amount, client, init) -> handler.setStackInSlot(i, stack)) diff --git a/src/main/java/com/gregtechceu/gtceu/common/item/modules/GuiModuleBehaviour.java b/src/main/java/com/gregtechceu/gtceu/common/item/modules/GuiModuleBehaviour.java index a262c7410c8..81db79c5ca3 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/item/modules/GuiModuleBehaviour.java +++ b/src/main/java/com/gregtechceu/gtceu/common/item/modules/GuiModuleBehaviour.java @@ -11,7 +11,7 @@ import net.minecraft.world.level.Level; import brachy.modularui.api.IPanelHandler; -import brachy.modularui.api.drawable.IKey; +import brachy.modularui.api.drawable.Text; import brachy.modularui.screen.ModularPanel; import brachy.modularui.value.sync.PanelSyncManager; import brachy.modularui.widgets.TextWidget; @@ -37,7 +37,7 @@ public IPanelHandler createModularPanel(ItemStack stack, CentralMonitorMachine m return syncManager.syncedPanel("gui_module_" + group.getName(), true, (psm, handler) -> new ModularPanel<>("gui_module_info") .coverChildren() - .child(new TextWidget<>(IKey.lang("gtceu.gui.central_monitor.gui_module_info")) + .child(new TextWidget<>(Text.lang("gtceu.gui.central_monitor.gui_module_info")) .height(50) .width(200))); } diff --git a/src/main/java/com/gregtechceu/gtceu/common/item/modules/ImageModuleBehaviour.java b/src/main/java/com/gregtechceu/gtceu/common/item/modules/ImageModuleBehaviour.java index 5177be7dc76..b864374217f 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/item/modules/ImageModuleBehaviour.java +++ b/src/main/java/com/gregtechceu/gtceu/common/item/modules/ImageModuleBehaviour.java @@ -14,7 +14,7 @@ import net.minecraft.world.level.Level; import brachy.modularui.api.IPanelHandler; -import brachy.modularui.api.drawable.IKey; +import brachy.modularui.api.drawable.Text; import brachy.modularui.screen.ModularPanel; import brachy.modularui.value.sync.PanelSyncManager; import brachy.modularui.value.sync.SyncHandlers; @@ -42,7 +42,7 @@ public IPanelHandler createModularPanel(ItemStack stack, CentralMonitorMachine m .marginTop(5) .center() .widthRel(1) - .child(new TextWidget<>(IKey.lang("gtceu.gui.central_monitor.url"))) + .child(new TextWidget<>(Text.lang("gtceu.gui.central_monitor.url"))) .child(new TextFieldWidget() .value(SyncHandlers.string(() -> getUrl(stack), s -> setUrl(stack, s))) .center() diff --git a/src/main/java/com/gregtechceu/gtceu/common/item/tool/behavior/AOEConfigUIBehavior.java b/src/main/java/com/gregtechceu/gtceu/common/item/tool/behavior/AOEConfigUIBehavior.java index 1831f22d947..05244f16e8e 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/item/tool/behavior/AOEConfigUIBehavior.java +++ b/src/main/java/com/gregtechceu/gtceu/common/item/tool/behavior/AOEConfigUIBehavior.java @@ -9,7 +9,7 @@ import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.ItemStack; -import brachy.modularui.api.drawable.IKey; +import brachy.modularui.api.drawable.Text; import brachy.modularui.drawable.GuiTextures; import brachy.modularui.factory.PlayerInventoryGuiData; import brachy.modularui.screen.ModularPanel; @@ -107,9 +107,9 @@ public ModularPanel buildUI(PlayerInventoryGuiData data, PanelSyncManager .child(Flow.column() .childPadding(6) .coverChildren() - .child(IKey.lang("item.gtceu.tool.aoe.columns").asWidget()) - .child(IKey.lang("item.gtceu.tool.aoe.rows").asWidget()) - .child(IKey.lang("item.gtceu.tool.aoe.layers").asWidget())) + .child(Text.lang("item.gtceu.tool.aoe.columns").asWidget()) + .child(Text.lang("item.gtceu.tool.aoe.rows").asWidget()) + .child(Text.lang("item.gtceu.tool.aoe.layers").asWidget())) .child(Flow.column() .childPadding(2) .coverChildren() @@ -123,7 +123,7 @@ public ModularPanel buildUI(PlayerInventoryGuiData data, PanelSyncManager .hoverBackground(GuiTextures.MC_BUTTON_HOVERED, GuiTextures.REMOVE.asIcon().size(10)) .syncHandler(minusCols)) - .child(new TextWidget<>(IKey.dynamic(() -> Component.literal(Integer.toString( + .child(new TextWidget<>(Text.dynamic(() -> Component.literal(Integer.toString( 2 * AoESymmetrical.getColumn(tag, defaultDefinition) + 1))))) .child(new ButtonWidget<>() .size(12) @@ -142,7 +142,7 @@ public ModularPanel buildUI(PlayerInventoryGuiData data, PanelSyncManager .hoverBackground(GuiTextures.MC_BUTTON_HOVERED, GuiTextures.REMOVE.asIcon().size(10)) .syncHandler(minusRows)) - .child(new TextWidget<>(IKey.dynamic(() -> Component.literal(Integer.toString( + .child(new TextWidget<>(Text.dynamic(() -> Component.literal(Integer.toString( 2 * AoESymmetrical.getRow(tag, defaultDefinition) + 1))))) .child(new ButtonWidget<>() .size(12) @@ -161,7 +161,7 @@ public ModularPanel buildUI(PlayerInventoryGuiData data, PanelSyncManager .hoverBackground(GuiTextures.MC_BUTTON_HOVERED, GuiTextures.REMOVE.asIcon().size(10)) .syncHandler(minusLayers)) - .child(new TextWidget<>(IKey.dynamic(() -> Component.literal(Integer.toString( + .child(new TextWidget<>(Text.dynamic(() -> Component.literal(Integer.toString( 2 * AoESymmetrical.getLayer(tag, defaultDefinition) + 1))))) .child(new ButtonWidget<>() .size(12) diff --git a/src/main/java/com/gregtechceu/gtceu/common/machine/electric/BatteryBufferMachine.java b/src/main/java/com/gregtechceu/gtceu/common/machine/electric/BatteryBufferMachine.java index 91018404db3..02826682539 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/machine/electric/BatteryBufferMachine.java +++ b/src/main/java/com/gregtechceu/gtceu/common/machine/electric/BatteryBufferMachine.java @@ -25,7 +25,7 @@ import net.minecraftforge.energy.IEnergyStorage; import brachy.modularui.api.drawable.IDrawable; -import brachy.modularui.api.drawable.IKey; +import brachy.modularui.api.drawable.Text; import brachy.modularui.factory.PosGuiData; import brachy.modularui.screen.UISettings; import brachy.modularui.value.sync.DoubleSyncValue; @@ -117,7 +117,7 @@ public void buildMainUI(ParentWidget mainWidget, PosGuiData guiData, PanelSyn .value(energyPercentage) .marginLeft(5) .size(18, 60) - .addTooltipLine(IKey.dynamic(() -> Component.literal( + .addTooltipLine(Text.dynamic(() -> Component.literal( "%s/%s EU".formatted( GTStringUtils.formatInt(energyContainer.getEnergyStored()), GTStringUtils.formatInt(energyContainer.getEnergyCapacity())))))) diff --git a/src/main/java/com/gregtechceu/gtceu/common/machine/electric/ChargerMachine.java b/src/main/java/com/gregtechceu/gtceu/common/machine/electric/ChargerMachine.java index 8ce0b3eb71a..d99bac6b04b 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/machine/electric/ChargerMachine.java +++ b/src/main/java/com/gregtechceu/gtceu/common/machine/electric/ChargerMachine.java @@ -26,7 +26,7 @@ import net.minecraft.world.level.block.state.properties.EnumProperty; import net.minecraftforge.energy.IEnergyStorage; -import brachy.modularui.api.drawable.IKey; +import brachy.modularui.api.drawable.Text; import brachy.modularui.factory.PosGuiData; import brachy.modularui.screen.UISettings; import brachy.modularui.value.sync.DoubleSyncValue; @@ -144,7 +144,7 @@ public void buildMainUI(ParentWidget mainWidget, PosGuiData guiData, PanelSyn .value(energyPercentage) .marginLeft(5) .size(18, 60) - .addTooltipLine(IKey.dynamic(() -> Component.literal( + .addTooltipLine(Text.dynamic(() -> Component.literal( "%s/%s EU".formatted( GTStringUtils.formatInt(energyContainer.getEnergyStored()), GTStringUtils.formatInt(energyContainer.getEnergyCapacity())))))) diff --git a/src/main/java/com/gregtechceu/gtceu/common/machine/electric/FisherMachine.java b/src/main/java/com/gregtechceu/gtceu/common/machine/electric/FisherMachine.java index ee783367fb3..c3187775dba 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/machine/electric/FisherMachine.java +++ b/src/main/java/com/gregtechceu/gtceu/common/machine/electric/FisherMachine.java @@ -288,7 +288,7 @@ protected void chargeBattery() { @Override public MachineUIPanelBuilder getPanelBuilder(PosGuiData data, PanelSyncManager syncManager, UISettings settings) { - return MachineUIPanelBuilder.defaultPanelBuilder(this) + return MachineUIPanelBuilder.panelBuilder(this) .rightConfigurators(configuratorFlow -> configuratorFlow .child(new ToggleButton() .value(new BoolValue.Dynamic(this::isJunkEnabled, this::setJunkEnabled)) diff --git a/src/main/java/com/gregtechceu/gtceu/common/machine/electric/ItemCollectorMachine.java b/src/main/java/com/gregtechceu/gtceu/common/machine/electric/ItemCollectorMachine.java index d641709eaac..63157025bf7 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/machine/electric/ItemCollectorMachine.java +++ b/src/main/java/com/gregtechceu/gtceu/common/machine/electric/ItemCollectorMachine.java @@ -33,7 +33,7 @@ import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; -import brachy.modularui.api.drawable.IKey; +import brachy.modularui.api.drawable.Text; import brachy.modularui.factory.PosGuiData; import brachy.modularui.screen.UISettings; import brachy.modularui.utils.Alignment; @@ -321,7 +321,7 @@ public void buildMainUI(ParentWidget mainWidget, PosGuiData guiData, PanelSyn .childPadding(2) .margin(5) .horizontalCenter() - .child(new TextWidget<>(IKey.lang("gtceu.gui.item_collector.range"))) + .child(new TextWidget<>(Text.lang("gtceu.gui.item_collector.range"))) .child(new TextFieldWidget() .setNumbers(1, maxRange) .value(SyncHandlers.intNumber(this::getRange, this::setRange)))) diff --git a/src/main/java/com/gregtechceu/gtceu/common/machine/electric/MinerMachine.java b/src/main/java/com/gregtechceu/gtceu/common/machine/electric/MinerMachine.java index 439ea906dc3..0e8ae0a783d 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/machine/electric/MinerMachine.java +++ b/src/main/java/com/gregtechceu/gtceu/common/machine/electric/MinerMachine.java @@ -27,7 +27,7 @@ import net.minecraft.network.chat.Style; import net.minecraft.world.InteractionResult; -import brachy.modularui.api.drawable.IKey; +import brachy.modularui.api.drawable.Text; import brachy.modularui.factory.PosGuiData; import brachy.modularui.screen.UISettings; import brachy.modularui.utils.Alignment; @@ -230,7 +230,7 @@ public void buildMainUI(ParentWidget mainWidget, PosGuiData guiData, PanelSyn .padding(5) .background(GTGuiTextures.DISPLAY) .widthRel(.6f) - .child(new TextWidget<>(IKey.dynamic(() -> { + .child(new TextWidget<>(Text.dynamic(() -> { List text = new ArrayList<>(); addDisplayText(text); return text.stream() diff --git a/src/main/java/com/gregtechceu/gtceu/common/machine/electric/PumpMachine.java b/src/main/java/com/gregtechceu/gtceu/common/machine/electric/PumpMachine.java index db003994029..4d8153196d3 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/machine/electric/PumpMachine.java +++ b/src/main/java/com/gregtechceu/gtceu/common/machine/electric/PumpMachine.java @@ -14,6 +14,7 @@ import com.gregtechceu.gtceu.common.mui.GTMuiWidgets; import com.gregtechceu.gtceu.utils.FormattingUtil; +import net.minecraft.ChatFormatting; import net.minecraft.MethodsReturnNonnullByDefault; import net.minecraft.Util; import net.minecraft.core.BlockPos; @@ -32,7 +33,7 @@ import net.minecraftforge.fluids.capability.IFluidHandler.FluidAction; import net.minecraftforge.fluids.capability.wrappers.BucketPickupHandlerWrapper; -import brachy.modularui.api.drawable.IKey; +import brachy.modularui.api.drawable.Text; import brachy.modularui.api.widget.IWidget; import brachy.modularui.factory.PosGuiData; import brachy.modularui.screen.UISettings; @@ -545,14 +546,14 @@ public void buildMainUI(ParentWidget mainWidget, PosGuiData guiData, PanelSyn .background(GTGuiTextures.DISPLAY) .size(90, 63) .center() - .child(IKey.lang("gtceu.gui.fluid_amount").asWidget() + .child(Text.lang("gtceu.gui.fluid_amount").asWidget() .color(0xffffff) .margin(8, 0, 8, 0)) - .child(IKey.dynamic( + .child(Text.dynamic( () -> Component.literal( - FormattingUtil.formatBuckets(bucketSyncer.getIntValue()))) + FormattingUtil.formatBuckets(bucketSyncer.getIntValue())) + .withStyle(ChatFormatting.WHITE)) .asWidget() - .color(0xffffff) .margin(8, 0, 20, 0)) .child(Flow.row() .margin(4, 0, 41, 0) diff --git a/src/main/java/com/gregtechceu/gtceu/common/machine/muimachine/TestMuiMachine.java b/src/main/java/com/gregtechceu/gtceu/common/machine/muimachine/TestMuiMachine.java deleted file mode 100644 index 4c7c6a3c69f..00000000000 --- a/src/main/java/com/gregtechceu/gtceu/common/machine/muimachine/TestMuiMachine.java +++ /dev/null @@ -1,738 +0,0 @@ -package com.gregtechceu.gtceu.common.machine.muimachine; - -import com.gregtechceu.gtceu.api.blockentity.BlockEntityCreationInfo; -import com.gregtechceu.gtceu.api.machine.MetaMachine; -import com.gregtechceu.gtceu.api.machine.TickableSubscription; -import com.gregtechceu.gtceu.api.machine.feature.IMuiMachine; -import com.gregtechceu.gtceu.common.data.GTMaterials; -import com.gregtechceu.gtceu.common.mui.GTGuiTextures; - -import net.minecraft.network.FriendlyByteBuf; -import net.minecraft.network.chat.Component; -import net.minecraft.world.entity.EntityType; -import net.minecraft.world.entity.animal.Fox; -import net.minecraft.world.item.Item; -import net.minecraft.world.item.ItemStack; -import net.minecraft.world.item.Items; -import net.minecraft.world.level.block.Blocks; -import net.minecraftforge.common.capabilities.ForgeCapabilities; -import net.minecraftforge.fluids.capability.templates.FluidTank; -import net.minecraftforge.items.IItemHandlerModifiable; -import net.minecraftforge.items.ItemStackHandler; -import net.minecraftforge.registries.ForgeRegistries; - -import brachy.modularui.api.IPanelHandler; -import brachy.modularui.api.drawable.IKey; -import brachy.modularui.api.widget.IWidget; -import brachy.modularui.client.schemarenderer.BlockHighlight; -import brachy.modularui.drawable.*; -import brachy.modularui.drawable.text.AnimatedText; -import brachy.modularui.factory.GuiData; -import brachy.modularui.factory.PosGuiData; -import brachy.modularui.schema.ArraySchema; -import brachy.modularui.screen.ModularPanel; -import brachy.modularui.screen.RichTooltip; -import brachy.modularui.screen.UISettings; -import brachy.modularui.screen.viewport.ModularGuiContext; -import brachy.modularui.theme.WidgetThemeEntry; -import brachy.modularui.utils.Alignment; -import brachy.modularui.utils.Color; -import brachy.modularui.utils.Interpolation; -import brachy.modularui.value.BoolValue; -import brachy.modularui.value.IntValue; -import brachy.modularui.value.StringValue; -import brachy.modularui.value.sync.*; -import brachy.modularui.value.sync.ItemSlotSyncHandler; -import brachy.modularui.widget.EmptyWidget; -import brachy.modularui.widget.ParentWidget; -import brachy.modularui.widgets.*; -import brachy.modularui.widgets.layout.Flow; -import brachy.modularui.widgets.slot.*; -import brachy.modularui.widgets.textfield.TextFieldWidget; -import it.unimi.dsi.fastutil.objects.Object2IntMap; -import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap; -import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap; -import org.jetbrains.annotations.NotNull; - -import java.util.*; -import java.util.concurrent.atomic.AtomicInteger; -import java.util.concurrent.atomic.AtomicReference; -import java.util.function.DoubleUnaryOperator; - -public class TestMuiMachine extends MetaMachine implements IMuiMachine { - - private static final Object2IntMap handlerSizeMap = new Object2IntOpenHashMap<>() { - - { - put(Items.DIAMOND, 9); - put(Items.EMERALD, 9); - put(Items.GOLD_INGOT, 7); - put(Items.IRON_INGOT, 6); - put(Items.CLAY_BALL, 2); - defaultReturnValue(3); - } - }; - - private final FluidTank fluidTank = new FluidTank(10000); - private final FluidTank fluidTankPhantom = new FluidTank(500000); - private long time = 0; - private int val, val2 = 0; - private String value = ""; - private int intValue = 1234567; - private double doubleValue = 1; - private final int duration = 80; - private int progress = 0; - private int cycleState = 0; - private List serverInts = new ArrayList<>(); - private ItemStack displayItem = new ItemStack(Items.DIAMOND); - private final IItemHandlerModifiable inventory = new ItemStackHandler(2) { - - @Override - public int getSlotLimit(int slot) { - return slot == 0 ? Integer.MAX_VALUE : 64; - } - }; - private final ItemStackHandler bigInventory = new ItemStackHandler(9); - - private final ItemStackHandler mixerItems = new ItemStackHandler(4); - private final ItemStackHandler smallInv = new ItemStackHandler(4); - private final FluidTank mixerFluids1 = new FluidTank(16000); - private final FluidTank mixerFluids2 = new FluidTank(16000); - private final ItemStackHandler craftingInventory = new ItemStackHandler(10); - private final ItemStackHandler storageInventory0 = new ItemStackHandler(1); - private final Map stackHandlerMap = new Object2ObjectOpenHashMap<>(); - - private int num = 2; - - private TickableSubscription sub; - - public TestMuiMachine(BlockEntityCreationInfo info) { - super(info); - sub = subscribeServerTick(this::tick); - } - - @Override - public void buildMainUI(ParentWidget mainWidget, PosGuiData guiData, PanelSyncManager syncManager, - UISettings settings) { - // settings.customContainer(() -> new CraftingModularContainer(3, 3, this.craftingInventory)); - // settings.customGui(() -> TestGuiContainer::new); - - syncManager.registerSlotGroup("item_inv", 3); - syncManager.registerSlotGroup("mixer_items", 2); - - syncManager.syncValue("mixer_fluids", 0, SyncHandlers.fluidSlot(this.mixerFluids1)); - syncManager.syncValue("mixer_fluids", 1, SyncHandlers.fluidSlot(this.mixerFluids2)); - IntSyncValue cycleStateValue = new IntSyncValue(() -> this.cycleState, val -> this.cycleState = val); - syncManager.getHyperVisor().syncValue("cycle_state", cycleStateValue); - syncManager.syncValue("display_item", GenericSyncValue.forItem(() -> this.displayItem, null)); - GenericListSyncHandler numberListSyncHandler = GenericListSyncHandler.builder() - .getter(() -> this.serverInts) - .setter(v -> this.serverInts = v) - .serializer(FriendlyByteBuf::writeInt) - .deserializer(FriendlyByteBuf::readInt) - .immutableCopy() - .build(); - syncManager.syncValue("number_list", numberListSyncHandler); - syncManager.bindPlayerInventory(guiData.getPlayer()); - - DynamicSyncHandler dynamicSyncHandler = new DynamicSyncHandler() - .widgetProvider((syncManager1, packet) -> { - ItemStack itemStack = packet.readItem(); - if (itemStack.isEmpty()) return new EmptyWidget(); - Item item = itemStack.getItem(); - ItemStackHandler handler = stackHandlerMap.computeIfAbsent(item, - k -> new ItemStackHandler(handlerSizeMap.getInt(k))); - String name = item.getName(itemStack).toString(); - Flow flow = Flow.row(); - for (int i = 0; i < handler.getSlots(); i++) { - int finalI = i; - flow.child(new ItemSlot() - .syncHandler(syncManager1.getOrCreateSyncHandler(name, i, ItemSlotSyncHandler.class, - () -> new ItemSlotSyncHandler(new ModularSlot(handler, finalI))))); - } - return flow; - }); - - DynamicLinkedSyncHandler> dynamicLinkedSyncHandler = new DynamicLinkedSyncHandler<>( - numberListSyncHandler) - .widgetProvider((syncManager1, value1) -> { - List vals = value1.getValue(); - return Flow.col() - .widthRel(1f) - .coverChildrenHeight() - .children(vals.size(), i -> IKey.str(String.valueOf(vals.get(i))).asWidget().padding(2)) - .name("synced number col"); - }); - - // disable spotless on the menu layout code so it won't insert random line breaks - // spotless:off - Rectangle colorPickerBackground = new Rectangle().color(Color.RED.main); - ModularPanel panel = new ModularPanel<>("test_tile"); - IPanelHandler panelSyncHandler = syncManager.syncedPanel("other_panel", true, this::openSecondWindow); - IPanelHandler colorPicker = IPanelHandler.simple(panel, - (mainPanel, player) -> new ColorPickerDialog("color_picker", colorPickerBackground.getColor(), true) - .draggable(true) - .relative(mainWidget.getPanel()) - .top(0) - .rightRel(1f), - true); - PagedWidget.Controller tabController = new PagedWidget.Controller(); - mainWidget.resizer() // returns object which is responsible for sizing - .size(176, 220); // set a static size for the main panel - - DoubleSyncValue progressPercent = syncManager.getOrCreateSyncHandler("progressPercent", DoubleSyncValue.class, () -> - new DoubleSyncValue(() -> (this.progress / (double) this.duration))); - - var babyFop = new Fox(EntityType.FOX, guiData.getLevel()); - babyFop.setAge(-1); - panel.child(Flow.row() - .name("Tab row") - .coverChildren() - .topRel(0f, 4, 1f) - .child(new PageButton(0, tabController) - .tab(GTGuiTextures.TAB_TOP, -1) - .overlay(new EntityDrawable<>(babyFop).followMouse())) - .child(new PageButton(1, tabController) - .tab(GTGuiTextures.TAB_TOP, 0) - .overlay(new ItemDrawable(Items.OAK_SAPLING).asIcon())) - .child(new PageButton(2, tabController) - .tab(GTGuiTextures.TAB_TOP, 0) - .overlay(new ItemDrawable(Items.COMPASS).asIcon())) - .child(new PageButton(3, tabController) - .tab(GTGuiTextures.TAB_TOP, 0) - .overlay(new ItemDrawable(Blocks.CHEST).asIcon())) - .child(new PageButton(4, tabController) - .tab(GTGuiTextures.TAB_TOP, 0) - .overlay(new ItemDrawable(Items.ENDER_EYE).asIcon()))) - - .child(new Expandable() - .name("expandable") - .top(0) - .leftRelOffset(1f, 1) - .background(GTGuiTextures.BACKGROUND) - .excludeAreaInRecipeViewer() - .stencilTransform((r, expanded) -> { - r.width = Math.max(20, r.width - 5); - r.height = Math.max(20, r.height - 5); - }) - .animationDuration(500) - .interpolation(Interpolation.BOUNCE_OUT) - .collapsedView(new ItemDrawable(Blocks.CRAFTING_TABLE).asIcon().asWidget().size(20).pos(0, 0)) - .expandedView(new ParentWidget<>() - .name("crafting tab") - .coverChildren() - .child(new ItemDrawable(Blocks.CRAFTING_TABLE).asIcon().asWidget().size(20).pos(0, 0)) - .child(SlotGroupWidget.builder() - .row("III D") - .row("III O") - .row("III ") - .key('I', i -> new ItemSlot().slot(new ModularSlot(this.craftingInventory, i)) - .addTooltipLine("This slot is empty")) - .key('O', new ItemSlot().slot(new ModularCraftingSlot(this.craftingInventory, 9))) - .key('D', new ItemDisplayWidget().syncHandler("display_item")) - .build() - .margin(5, 5, 20, 5).name("crafting")))) - - .child(Flow.column() - .name("main col") - .sizeRel(1f) - .paddingBottom(7) - .child(new ParentWidget<>() - .expanded() - .widthRel(1f) - .child(new PagedWidget<>() - .name("root parent") - .sizeRel(1f) - .controller(tabController) - .addPage(new ParentWidget<>() - .name("page 1 parent") - .sizeRel(1f, 1f) - .padding(7, 0) - .child(Flow.row() - .name("buttons, slots and more tests") - .height(137) - .coverChildrenWidth() - .posRel(Alignment.CenterLeft) - // .padding(7) - .child(Flow.col() - .name("buttons and slots test") - .coverChildren() - .marginRight(8) - // .flex(flex -> flex.height(0.5f)) - // .widthRel(0.5f) - .crossAxisAlignment(Alignment.CrossAxis.CENTER) - .child(new ButtonWidget<>() - .size(60, 18) - .overlay(IKey.dynamic(() -> Component.literal("Button " + this.val)))) - .child(new FluidSlot() - .margin(2) - .syncHandler(SyncHandlers.fluidSlot(this.fluidTank))) - .child(new ButtonWidget<>() - .size(60, 18) - .tooltip(tooltip -> { - tooltip.showUpTimer(10); - tooltip.addLine(IKey.str("Test Line g")); - tooltip.addLine(IKey.str("An image inside of a tooltip:")); - tooltip.addLine(GuiTextures.MUI_LOGO - .asIcon().size(50) - .alignment(Alignment.TopCenter)); - tooltip.addLine(IKey.str("And here a circle:")); - tooltip.addLine(new Circle() - .setColor(Color.RED.darker(2), Color.RED.brighter(2)) - .asIcon() - .size(20)) - .addLine(new ItemDrawable(Items.DIAMOND).asIcon()) - .pos(RichTooltip.Pos.LEFT); - }) - .onMousePressed((mouseX, mouseY, mouseButton) -> { - // panel.getScreen().close(true); - // panel.getScreen().openDialog("dialog", - // this::buildDialog, - // ModularUI.LOGGER::info); - // openSecondWindow(context).openIn(panel.getScreen()); - panelSyncHandler.openPanel(); - return true; - }) - // .flex(flex -> flex.left(3)) // ? - .overlay(IKey.str("Button 2"))) - .child(new TextFieldWidget() - .size(60, 18) - .setTextAlignment(Alignment.CenterRight) - .value(SyncHandlers.string(() -> this.value, - val -> this.value = val)) - .margin(0, 2) - .hintText(Component.literal("hint"))) - .child(new TextFieldWidget() - .size(60, 18) - .paddingTop(1) - .value(SyncHandlers.doubleNumber( - () -> this.doubleValue, - val -> this.doubleValue = val)) - .setNumbersDouble(DoubleUnaryOperator.identity()) - .hintText(Component.literal("number"))) - // .child(IKey.str("Test - // string").asWidget().padding(2).name("test - // string")) - .child(new ScrollingTextWidget( - IKey.str("Very very long test string")) - .widthRel(1f).height(16)) - // .child(IKey.EMPTY.asWidget().name("Empty IKey")) - ) - .child(Flow.col() - .name("button and slots test 2") - .coverChildren() - // .widthRel(0.5f) - .crossAxisAlignment(Alignment.CrossAxis.CENTER) - .child(new ProgressWidget() - .value(progressPercent) - .texture(GTGuiTextures.PROGRESS_BAR_ARROW, 20)) - .child(new ProgressWidget() - .value(progressPercent) - .texture(GTGuiTextures.PROGRESS_BAR_MIXER, 20) - .direction( - ProgressWidget.Direction.CIRCULAR_CW)) - .child(Flow.row().coverChildrenWidth().height(22) - .child(new ToggleButton() - .value(new BoolValue.Dynamic( - () -> cycleStateValue.getIntValue() == 0, - val -> cycleStateValue.setIntValue(0))) - .overlay(GTGuiTextures.CYCLE_BUTTON - .getSubArea(0, 0, 1, 1 / 3f))) - .child(new ToggleButton() - .value(new BoolValue.Dynamic( - () -> cycleStateValue.getIntValue() == 1, - val -> cycleStateValue.setIntValue(1))) - .overlay(GTGuiTextures.CYCLE_BUTTON - .getSubArea(0, 1 / 3f, 1, - 2 / 3f))) - .child(new ToggleButton() - .value(new BoolValue.Dynamic( - () -> cycleStateValue.getIntValue() == 2, - val -> cycleStateValue.setIntValue(2))) - .overlay(GTGuiTextures.CYCLE_BUTTON - .getSubArea(0, 2 / 3f, 1, 1)))) - /* - * .child(new CycleButtonWidget() - * .length(3) - * .texture(GTGuiTextures.CYCLE_BUTTON) - * .addTooltip(0, "State 1") - * .addTooltip(1, "State 2") - * .addTooltip(2, "State 3") - * .background(GTGuiTextures.BUTTON) - * .value(SyncHandlers.intNumber(() -> this.cycleState, - * val -> this.cycleState = val))) - */ - .child(new ItemSlot() - .slot(SyncHandlers.itemSlot(this.inventory, 0) - .ignoreMaxStackSize(true) - .singletonSlotGroup())) - .child(new FluidSlot() - .margin(2) - .width(30) - .alwaysShowFull(false) - .syncHandler(SyncHandlers - .fluidSlot(this.fluidTankPhantom) - .phantom(true))) - .child(Flow.col() - .name("button and slots test 3") - .coverChildren() - .child(new TextFieldWidget() - .size(60, 20) - .value(SyncHandlers.intNumber( - () -> this.intValue, - val -> this.intValue = val)) - .setNumbers(0, 9999999) - .hintText(Component - .literal("integer"))))))) - .addPage(Flow.col() - .name("Slots test page") - .coverChildren() - // .height(120) - .padding(7) - .leftRel(0.5f) - .mainAxisAlignment(Alignment.MainAxis.START) - .childPadding(2) - // .child(SlotGroupWidget.playerInventory().left(0)) - .child(SlotGroupWidget.builder() - .matrix("III", "III", "III") - .key('I', index -> { - // 4 is the middle slot with a negative priority -> shift - // click prioritises middle slot - if (index == 4) { - return new ItemSlot().slot( - SyncHandlers.itemSlot(this.bigInventory, index) - .singletonSlotGroup(-100)); - } - return new ItemSlot().slot( - SyncHandlers.itemSlot(this.bigInventory, index) - .slotGroup("item_inv")); - }) - .build().name("9 slot inv") - .placeSortButtonsTopRightVertical() - // .marginBottom(2) - ) - .child(SlotGroupWidget.builder() - .row("FII") - .row("FII") - .key('F', - index -> new FluidSlot().syncHandler("mixer_fluids", - index)) - .key('I', - index -> ItemSlot.create(index >= 2) - .slot(new ModularSlot(this.mixerItems, index) - .slotGroup("mixer_items") - .filter(stack -> !stack.getCapability( - ForgeCapabilities.ITEM_HANDLER) - .isPresent()))) - .build().name("mixer inv") - .disableSortButtons()) - .child(Flow.row() - .coverChildrenHeight() - .child(new CycleButtonWidget() - .size(20, 20) - .stateCount(3) - .stateOverlay(GTGuiTextures.CYCLE_BUTTON) - .value(new IntSyncValue(() -> this.val2, val -> this.val2 = val)) - .margin(8, 0)) - .child(IKey.str("Hello World").asWidget().height(18))) - .child(new SpecialButton( - IKey.str("A very long string that looks cool when animated") - .withAnimation()) - .height(14) - .widthRel(1f)) - /* - * GuiTextures.LOGO.asIcon() - * .size(80, 80) - * .asWidget() - * .flex(flex -> flex.width(1f).height(1f)) - */) - .addPage(new ParentWidget<>() - .name("page 3 parent") - .sizeRel(1f, 1f) - .padding(7) - // .child(SlotGroupWidget.playerInventory()) - .child(new SliderWidget() - .widthRel(1f).bottom(50).height(16) // test overwriting of units - .top(7) - .stopper(0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100) - .background(GTGuiTextures.FLUID_SLOT)) - .child(new ButtonWidget<>() - .name("color picker button") - .top(25) - .background(colorPickerBackground) - .disableHoverBackground() - .onMousePressed((mouseX, mouseY, mouseButton) -> { - colorPicker.openPanel(); - return true; - })) - .child(new ListWidget<>() - .name("test config list") - .widthRel(1f).top(50).bottom(2) - /* - * .child(new Rectangle().setColor(0xFF606060).asWidget() - * .top(1) - * .left(32) - * .size(1, 40)) - */ - .child(Flow.row() - .name("test config 1") - .widthRel(1f).coverChildrenHeight() - .crossAxisAlignment(Alignment.CrossAxis.CENTER) - .childPadding(2) - .child(new CycleButtonWidget() - .value(new BoolValue(false)) - .stateOverlay(GuiTextures.CHECK_BOX) - .size(14, 14) - .margin(8, 4)) - .child(IKey.str("Boolean config").asWidget().height(14))) - .child(Flow.row() - .name("test config 2") - .widthRel(1f).height(14) - .childPadding(2) - .child(new TextFieldWidget() - .value(new IntValue.Dynamic(() -> this.num, val -> this.num = val)) - .disableHoverBackground() - .setNumbers(1, Short.MAX_VALUE) - .setTextAlignment(Alignment.Center) - .background(new Rectangle().color(0xFFb1b1b1)) - .setTextColor(IKey.TEXT_COLOR) - .size(20, 14)) - .child(IKey.str("Number config").asWidget() - .height(14))) - .child(IKey.str("Config title").asWidget() - .color(0xFF404040) - .alignment(Alignment.CenterLeft) - .left(5).height(14) - .tooltip(tooltip -> tooltip.showUpTimer(10) - .addLine(IKey.str("Config title tooltip")))) - .child(Flow.row() - .name("test config 3") - .widthRel(1f).height(14) - .childPadding(2) - .child(new CycleButtonWidget() - .value(new BoolValue(false)) - .stateOverlay(GuiTextures.CHECK_BOX) - .size(14, 14)) - .child(IKey.str("Boolean config 3").asWidget().height(14))))) - .addPage(new ParentWidget<>() - .name("page 4 storage") - .sizeRel(1f) - .child(Flow.col() - .name("page 4 col, dynamic widgets") - .padding(7) - .child(new ItemSlot() - .slot(new ModularSlot(this.storageInventory0, 0) - .changeListener(((newItem, onlyAmountChanged, client, init) -> { - if (client && !onlyAmountChanged) { - dynamicSyncHandler.notifyUpdate( - packet -> packet.writeItem(newItem)); - } - })))) - .child(new DynamicSyncedWidget<>() - .widthRel(1f) - .syncHandler(dynamicSyncHandler)) - /*.child(new DynamicSyncedWidget<>() - .widthRel(1f) - .coverChildrenHeight() - .syncHandler(dynamicLinkedSyncHandler))*/)) - .addPage(createSchemaPage(guiData)))) - .child(SlotGroupWidget.playerInventory(false))); - /* - * panel.child(new ButtonWidget<>() - * .flex(flex -> flex.size(60, 20) - * .top(7) - * .left(0.5f)) - * .background(GuiTextures.BUTTON, IKey.dynamic(() -> "Button " + this.val))) - * .child(SlotGroup.playerInventory()) - * .child(new FluidSlot().flex(flex -> flex - * .top(30) - * .left(0.5f)) - * .setSynced("fluid_slot")); - */ - // spotless:on - } - - private IWidget createSchemaPage(GuiData data) { - ParentWidget page = new ParentWidget<>(); - page.name("Page 5 schema"); - page.sizeRel(1f); - page.child(IKey.str("Schema").asWidget()); - - if (getLevel().isClientSide()) { - page.child(new SchemaWidget( - new SchemaRenderer(ArraySchema.of(data.getPlayer(), 20)) - .highlightRenderer( - new BlockHighlight(Color.withAlpha(Color.GREEN.brighter(1), 0.9f), 1 / 32f)) - /* .isometric(true) */) - .pos(20, 20) - .size(100, 100)); - } - - return page; - } - - public ModularPanel openSecondWindow(PanelSyncManager syncManager, IPanelHandler syncHandler) { - ModularPanel panel = new Dialog<>("second_window") - .disablePanelsBelow(false) - .closeOnOutOfBoundsClick(false) - .draggable(true) - .size(100, 100) - .resizeableOnDrag(true); - SlotGroup slotGroup = new SlotGroup("small_inv", 2); - IntSyncValue timeSync = new IntSyncValue(() -> (int) java.lang.System.currentTimeMillis()); - syncManager.syncValue(123456, timeSync); - syncManager.registerSlotGroup(slotGroup); - AtomicInteger number = new AtomicInteger(0); - syncManager.syncValue("int_value", new IntSyncValue(number::get, number::set)); - IPanelHandler panelSyncHandler = syncManager.syncedPanel("other_panel_2", true, - (syncManager1, syncHandler1) -> openThirdWindow(syncManager1, syncHandler1, number)); - IntSyncValue num = syncManager.getHyperVisor().findSyncHandler("cycle_state", IntSyncValue.class); - panel.child(ButtonWidget.panelCloseButton()) - .child(new ButtonWidget<>() - .size(10).top(14).right(4) - .overlay((new FluidDrawable().setFluid(GTMaterials.Iron.getFluid(200))), IKey.str("3")) - .size(50, 50) - .onMousePressed((mouseX, mouseY, mouseButton) -> { - panelSyncHandler.openPanel(); - return true; - })) - .child(IKey.str("2nd Panel") - .asWidget() - .pos(5, 5)) - .child(SlotGroupWidget.builder() - .row("II") - .row("II") - .key('I', i -> new ItemSlot().slot(new ModularSlot(smallInv, i).slotGroup(slotGroup))) - .build() - .center()) - .child(new CycleButtonWidget() - .size(16).pos(5, 5 + 11) - .value(num) - .stateOverlay(0, IKey.str("1")) - .stateOverlay(1, IKey.str("2")) - .stateOverlay(2, IKey.str("3")) - .addTooltipLine(IKey.str("Hyper Visor test"))) - .child(new ButtonWidget<>() - .bottom(5) - .right(5) - .tooltip(richTooltip -> richTooltip.textColor(Color.RED.main).add("WARNING! Very Dangerous")) - .onMousePressed((mouseX, mouseY, mouseButton) -> { - if (!panelSyncHandler.isPanelOpen()) { - panelSyncHandler.deleteCachedPanel(); - number.incrementAndGet(); - } - return true; - })); - return panel; - } - - public ModularPanel openThirdWindow(PanelSyncManager syncManager, IPanelHandler syncHandler, - AtomicInteger integer) { - ModularPanel panel = new Dialog<>("third_window") - .disablePanelsBelow(false) - .closeOnOutOfBoundsClick(false) - .draggable(true) - .size(50, 50); - panel.child(ButtonWidget.panelCloseButton()) - .child(IKey.str("3rd Panel: " + integer.get()) - .asWidget() - .pos(5, 17)); - return panel; - } - - public void buildDialog(Dialog dialog) { - AtomicReference value = new AtomicReference<>(""); - dialog.draggable(true); - dialog.child(new TextFieldWidget() - .resizer(flex -> flex.size(100, 20).center()) - .value(new StringValue.Dynamic(value::get, value::set))) - .child(new ButtonWidget<>() - .resizer(flex -> flex.size(8, 8).top(5).right(5)) - .overlay(IKey.str("x")) - .onMousePressed((x, y, mouseButton) -> { - dialog.closeWith(value.get()); - return true; - })); - } - - @Override - public void clientTick() { - if (this.time++ % 20 == 0) { - this.val++; - } - if (++this.progress == this.duration) { - this.progress = 0; - } - } - - public @NotNull ModularPanel buildSearchTest(ModularGuiContext context) { - List items = Arrays.asList("Chicken", "Jockey", "Flint", "Steel", "Steve", "Diamond", "Ingot", "Iron", - "Armor", "Greg"); - StringValue searchValue = new StringValue(""); - return ModularPanel.defaultPanel("search", 100, 150) - .child(Flow.column() - .padding(5) - .child(new TextFieldWidget() - .value(searchValue) - .height(16) - .widthRel(1f)) - .child(new ListWidget<>() - .collapseDisabledChildren() - .expanded() - .widthRel(1f) - .children(items.size(), i -> new TextWidget<>(IKey.str(items.get(i))) - .alignment(Alignment.Center) - .color(Color.WHITE.main) - .widthRel(1f) - .height(16) - .background(GuiTextures.MC_BUTTON) - .setEnabledIf(w -> items.get(i).toLowerCase() - .contains(searchValue.getStringValue()))))); - } - - public void tick() { - if (this.time++ % 20 == 0) { - if (++this.val2 == 3) this.val2 = 0; - Collection vals = ForgeRegistries.ITEMS.getValues(); - Item item = vals.stream().skip(new Random().nextInt(vals.size())).findFirst().orElse(Items.DIAMOND); - this.displayItem = new ItemStack(item, 26735987); - - Random rnd = new Random(); - this.serverInts.clear(); - for (int i = 0; i < 5; i++) { - this.serverInts.add(rnd.nextInt(100)); - } - } - if (++this.progress == this.duration) { - this.progress = 0; - } - } - - private static class SpecialButton extends ButtonWidget { - - private final AnimatedText animatedKey; - - private SpecialButton(AnimatedText animatedKey) { - this.animatedKey = animatedKey.stopAnimation().forward(true); - this.animatedKey.reset(); - } - - @Override - public void draw(ModularGuiContext context, WidgetThemeEntry widgetTheme) { - this.animatedKey.draw(context, 0, 0, getArea().w(), getArea().h(), - getActiveWidgetTheme(widgetTheme, isHovering())); - } - - @Override - public void onMouseStartHover() { - super.onMouseStartHover(); - this.animatedKey.startAnimation().forward(true); - } - - @Override - public void onMouseEndHover() { - super.onMouseEndHover(); - this.animatedKey.forward(false); - } - } -} diff --git a/src/main/java/com/gregtechceu/gtceu/common/machine/muimachine/TestMuiMachine2.java b/src/main/java/com/gregtechceu/gtceu/common/machine/muimachine/TestMuiMachine2.java deleted file mode 100644 index 6f8a7d0152f..00000000000 --- a/src/main/java/com/gregtechceu/gtceu/common/machine/muimachine/TestMuiMachine2.java +++ /dev/null @@ -1,98 +0,0 @@ -package com.gregtechceu.gtceu.common.machine.muimachine; - -import com.gregtechceu.gtceu.api.blockentity.BlockEntityCreationInfo; -import com.gregtechceu.gtceu.api.machine.MetaMachine; -import com.gregtechceu.gtceu.api.machine.TickableSubscription; -import com.gregtechceu.gtceu.api.machine.feature.IMuiMachine; -import com.gregtechceu.gtceu.api.sync_system.annotations.SyncToClient; - -import net.minecraft.network.chat.Component; -import net.minecraft.util.Mth; - -import brachy.modularui.api.drawable.IKey; -import brachy.modularui.drawable.Rectangle; -import brachy.modularui.drawable.graph.GraphDrawable; -import brachy.modularui.factory.PosGuiData; -import brachy.modularui.screen.ModularPanel; -import brachy.modularui.screen.UISettings; -import brachy.modularui.utils.Alignment; -import brachy.modularui.utils.Color; -import brachy.modularui.utils.math.DAM; -import brachy.modularui.value.sync.IntSyncValue; -import brachy.modularui.value.sync.PanelSyncManager; -import brachy.modularui.widget.ParentWidget; -import brachy.modularui.widgets.ButtonWidget; -import brachy.modularui.widgets.layout.Flow; -import org.jetbrains.annotations.NotNull; - -public class TestMuiMachine2 extends MetaMachine implements IMuiMachine { - - private TickableSubscription sub; - - public TestMuiMachine2(BlockEntityCreationInfo info) { - super(info); - sub = subscribeServerTick(this::tick); - } - - @SyncToClient - private int val = 0; - - @Override - public void buildMainUI(ParentWidget mainWidget, PosGuiData guiData, PanelSyncManager syncManager, - UISettings settings) { - IntSyncValue valSync = new IntSyncValue(() -> this.val, (v) -> {}); - syncManager.syncValue("valSync", valSync); - - double[] x = DAM.linspace(-25, 25, 200); - double[] y = DAM.div(DAM.sin(x, null), x, null); - double[] y2 = DAM.cos(x, null); - - // return buildAspectRatioUI(); - - mainWidget - .child(new ButtonWidget<>() - .size(60, 18) - .overlay(IKey.dynamic(() -> Component - .literal("Button " + val)))) - .child(new GraphDrawable() - .yLim(-1.2f, 1.2f) - .xTickFinder(Mth.HALF_PI, 1) - .yTickFinder(0.2f, 1) - .plot(x, y) - .plot(x, y2) - .graphAspectRatio(16 / 9f) - .asWidget().top(50).size(200, 200)); - } - - public static @NotNull ModularPanel buildAspectRatioUI() { - return new ModularPanel<>("aspect_ratio") - .coverChildren() - .padding(10) - .child(Flow.row() - .childPadding(10) - .coverChildren() - .child(new Rectangle().color(Color.BLUE_ACCENT.main) - .asIcon().aspectRatio(4f / 3) - .asWidget().size(80) - .overlay(IKey.str("4:3 Free"))) - .child(new Rectangle().color(Color.RED_ACCENT.main) - .asIcon().aspectRatio(4f / 3).width(70) - .asWidget().size(80) - .overlay(IKey.str("4:3 | width = 70"))) - .child(new Rectangle().color(Color.LIGHT_GREEN.main) - .asIcon().aspectRatio(4f / 3).height(45).alignment(Alignment.BottomRight) - .asWidget().size(80) - .overlay(IKey.str("4:3 | height = 45\nBottom Right")))) - .overlay(); - } - - @Override - public void clientTick() { - super.clientTick(); - } - - public void tick() { - val++; - syncDataHolder.markClientSyncFieldDirty("val"); - } -} diff --git a/src/main/java/com/gregtechceu/gtceu/common/machine/multiblock/electric/ActiveTransformerMachine.java b/src/main/java/com/gregtechceu/gtceu/common/machine/multiblock/electric/ActiveTransformerMachine.java index b8ecb60456f..a3140c46178 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/machine/multiblock/electric/ActiveTransformerMachine.java +++ b/src/main/java/com/gregtechceu/gtceu/common/machine/multiblock/electric/ActiveTransformerMachine.java @@ -24,7 +24,7 @@ import net.minecraft.network.chat.Style; import net.minecraft.world.level.block.Block; -import brachy.modularui.api.drawable.IKey; +import brachy.modularui.api.drawable.Text; import brachy.modularui.api.widget.IWidget; import brachy.modularui.value.sync.BooleanSyncValue; import brachy.modularui.value.sync.LongSyncValue; @@ -200,16 +200,16 @@ public List getWidgetsForDisplay(PanelSyncManager syncManager) { LongSyncValue outputPerSec = new LongSyncValue(this.powerOutput::getOutputPerSec); syncManager.syncValue("outputPerSec", outputPerSec); - widgets.add(IKey.lang(Component.translatable("gtceu.multiblock.work_paused")) + widgets.add(Text.lang("gtceu.multiblock.work_paused") .asWidget() .setEnabledIf((widget) -> isFormed.getBoolValue() && !workingEnabled.getBoolValue())); - widgets.add(IKey.lang(Component.translatable("gtceu.multiblock.running")) + widgets.add(Text.lang("gtceu.multiblock.running") .asWidget() .setEnabledIf( (widget) -> isFormed.getBoolValue() && workingEnabled.getBoolValue() && active.getBoolValue())); - widgets.add(IKey.dynamic(() -> Component + widgets.add(Text.dynamic(() -> Component .translatable("gtceu.multiblock.active_transformer.max_input", FormattingUtil.formatNumbers( Math.abs(inputVoltage.getLongValue() * inputAmperage.getLongValue())))) @@ -217,7 +217,7 @@ public List getWidgetsForDisplay(PanelSyncManager syncManager) { .setEnabledIf( (widget) -> isFormed.getBoolValue() && workingEnabled.getBoolValue() && active.getBoolValue())); - widgets.add(IKey.dynamic(() -> Component + widgets.add(Text.dynamic(() -> Component .translatable("gtceu.multiblock.active_transformer.max_output", FormattingUtil.formatNumbers( Math.abs(outputVoltage.getLongValue() * outputAmperage.getLongValue())))) @@ -225,31 +225,31 @@ public List getWidgetsForDisplay(PanelSyncManager syncManager) { .setEnabledIf( (widget) -> isFormed.getBoolValue() && workingEnabled.getBoolValue() && active.getBoolValue())); - widgets.add(IKey.dynamic(() -> Component + widgets.add(Text.dynamic(() -> Component .translatable("gtceu.multiblock.active_transformer.average_in", FormattingUtil.formatNumbers(Math.abs(inputPerSec.getLongValue() / 20)))) .asWidget() .setEnabledIf( (widget) -> isFormed.getBoolValue() && workingEnabled.getBoolValue() && active.getBoolValue())); - widgets.add(IKey.dynamic(() -> Component + widgets.add(Text.dynamic(() -> Component .translatable("gtceu.multiblock.active_transformer.average_out", FormattingUtil.formatNumbers(Math.abs(outputPerSec.getLongValue() / 20)))) .asWidget() .setEnabledIf( (widget) -> isFormed.getBoolValue() && workingEnabled.getBoolValue() && active.getBoolValue())); - widgets.add(IKey.lang(Component.translatable("gtceu.multiblock.active_transformer.danger_enabled")) + widgets.add(Text.lang("gtceu.multiblock.active_transformer.danger_enabled") .asWidget() .setEnabledIf((widget) -> isFormed.getBoolValue() && workingEnabled.getBoolValue() && active.getBoolValue() && !ConfigHolder.INSTANCE.machines.harmlessActiveTransformers)); - widgets.add(IKey.lang(Component.translatable("gtceu.multiblock.idling")) + widgets.add(Text.lang("gtceu.multiblock.idling") .asWidget() .setEnabledIf((widget) -> isFormed.getBoolValue() && workingEnabled.getBoolValue() && !active.getBoolValue())); - widgets.add(IKey.dynamic(() -> { + widgets.add(Text.dynamic(() -> { Component tooltip = Component.translatable("gtceu.multiblock.invalid_structure.tooltip") .withStyle(ChatFormatting.GRAY); return Component.translatable("gtceu.multiblock.invalid_structure") diff --git a/src/main/java/com/gregtechceu/gtceu/common/machine/multiblock/electric/AssemblyLineMachine.java b/src/main/java/com/gregtechceu/gtceu/common/machine/multiblock/electric/AssemblyLineMachine.java index 8e07f34aa8f..181bd592087 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/machine/multiblock/electric/AssemblyLineMachine.java +++ b/src/main/java/com/gregtechceu/gtceu/common/machine/multiblock/electric/AssemblyLineMachine.java @@ -81,7 +81,7 @@ private boolean checkItemInputs(@NotNull GTRecipe recipe, boolean isTick) { for (int i = 0; i < inputsSize; i++) { var itemStack = itemInventory.get(i); - Ingredient recipeStack = ItemRecipeCapability.CAP.of(itemInputs.get(i).content); + Ingredient recipeStack = ItemRecipeCapability.CAP.of(itemInputs.get(i).content()); if (!recipeStack.test(itemStack)) { return false; } @@ -104,7 +104,7 @@ private ActionResult consumeItemContents(@NotNull GTRecipe recipe, boolean isTic if (itemInventory.size() < inputsSize) return ActionResult.FAIL_NO_REASON; for (int i = 0; i < inputsSize; i++) { - Ingredient recipeStack = ItemRecipeCapability.CAP.of(itemInputs.get(i).content); + Ingredient recipeStack = ItemRecipeCapability.CAP.of(itemInputs.get(i).content()); var currentBus = itemInventory.get(i); if (!(currentBus instanceof NotifiableItemStackHandler itemBus)) throw new RuntimeException( "Handler in Assline.consumeItemContent's ItemRecipeCapability.IN was not of type NotifiableItemStackHandler"); @@ -114,7 +114,7 @@ private ActionResult consumeItemContents(@NotNull GTRecipe recipe, boolean isTic // If we get here, the recipe should be consumable for (int i = 0; i < inputsSize; i++) { - Ingredient recipeStack = ItemRecipeCapability.CAP.of(itemInputs.get(i).content); + Ingredient recipeStack = ItemRecipeCapability.CAP.of(itemInputs.get(i).content()); var currentBus = itemInventory.get(i); if (!(currentBus instanceof NotifiableItemStackHandler itemBus)) throw new RuntimeException( "Handler in Assline.consumeItemContent's ItemRecipeCapability.IN was not of type NotifiableItemStackHandler"); @@ -152,7 +152,7 @@ private boolean checkFluidInputs(@NotNull GTRecipe recipe, boolean isTick) { for (int i = 0; i < inputsSize; i++) { var fluidStack = fluidInventory.get(i); - FluidIngredient recipeStack = FluidRecipeCapability.CAP.of(fluidInputs.get(i).content); + FluidIngredient recipeStack = FluidRecipeCapability.CAP.of(fluidInputs.get(i).content()); if (!recipeStack.test(fluidStack) || recipeStack.getAmount() > fluidStack.getAmount()) { return false; } @@ -174,7 +174,7 @@ private ActionResult consumeFluidContents(@NotNull GTRecipe recipe, boolean isTi if (fluidInventory.size() < fluidsSize) return ActionResult.FAIL_NO_REASON; for (int i = 0; i < fluidsSize; i++) { - FluidIngredient recipeStack = FluidRecipeCapability.CAP.of(fluidInputs.get(i).content); + FluidIngredient recipeStack = FluidRecipeCapability.CAP.of(fluidInputs.get(i).content()); var currentBus = fluidInventory.get(i); if (!(currentBus instanceof NotifiableFluidTank fluidTank)) throw new RuntimeException( "Handler in Assline.consumeItemContent's FluidRecipeCapability.IN was not of type NotifiableFluidTank"); @@ -184,7 +184,7 @@ private ActionResult consumeFluidContents(@NotNull GTRecipe recipe, boolean isTi // If we get here, the recipe should be consumable for (int i = 0; i < fluidsSize; i++) { - FluidIngredient recipeStack = FluidRecipeCapability.CAP.of(fluidInputs.get(i).content); + FluidIngredient recipeStack = FluidRecipeCapability.CAP.of(fluidInputs.get(i).content()); var currentBus = fluidInventory.get(i); if (!(currentBus instanceof NotifiableFluidTank fluidTank)) throw new RuntimeException( "Handler in Assline.consumeItemContent's FluidRecipeCapability.IN was not of type NotifiableFluidTank"); diff --git a/src/main/java/com/gregtechceu/gtceu/common/machine/multiblock/electric/CleanroomMachine.java b/src/main/java/com/gregtechceu/gtceu/common/machine/multiblock/electric/CleanroomMachine.java index 95a9a3b6132..320b5337fa2 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/machine/multiblock/electric/CleanroomMachine.java +++ b/src/main/java/com/gregtechceu/gtceu/common/machine/multiblock/electric/CleanroomMachine.java @@ -56,7 +56,7 @@ import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.properties.DoubleBlockHalf; -import brachy.modularui.api.drawable.IKey; +import brachy.modularui.api.drawable.Text; import brachy.modularui.api.widget.IWidget; import brachy.modularui.value.sync.BooleanSyncValue; import brachy.modularui.value.sync.GenericSyncValue; @@ -500,7 +500,7 @@ public List getWidgetsForDisplay(PanelSyncManager syncManager) { .build(); syncManager.syncValue("distComponent", distComponent); - widgets.add(IKey.dynamic(() -> { + widgets.add(Text.dynamic(() -> { Component tooltip = Component.translatable("gtceu.multiblock.invalid_structure.tooltip") .withStyle(ChatFormatting.GRAY); return Component.translatable("gtceu.multiblock.invalid_structure") @@ -510,7 +510,7 @@ public List getWidgetsForDisplay(PanelSyncManager syncManager) { .asWidget() .setEnabledIf((widget) -> !isFormed.getBoolValue())); - widgets.add(IKey.dynamic(() -> { + widgets.add(Text.dynamic(() -> { String voltageName = GTValues.VNF[GTUtil.getFloorTierByVoltage(maxVoltage.getLongValue())]; return Component.translatable("gtceu.multiblock.max_energy_per_tick", maxVoltage.getLongValue(), voltageName); @@ -518,7 +518,7 @@ public List getWidgetsForDisplay(PanelSyncManager syncManager) { .asWidget() .setEnabledIf((widget) -> isFormed.getBoolValue() && maxVoltage.getLongValue() > 0)); - widgets.add(IKey.dynamic(() -> { + widgets.add(Text.dynamic(() -> { if (cleanroomTypeIsNull.getBoolValue()) { return Component.empty(); } else { @@ -528,39 +528,39 @@ public List getWidgetsForDisplay(PanelSyncManager syncManager) { .asWidget() .setEnabledIf((widget) -> isFormed.getBoolValue() && !cleanroomTypeIsNull.getBoolValue())); - widgets.add(IKey.dynamic(() -> Component.translatable("gtceu.multiblock.work_paused")) + widgets.add(Text.dynamic(() -> Component.translatable("gtceu.multiblock.work_paused")) .asWidget() .setEnabledIf((widget) -> isFormed.getBoolValue() && !workingEnabled.getBoolValue())); widgets.add(GTMultiblockTextUtil.addProgressLine(this, syncManager)); - widgets.add(IKey.lang(Component.translatable("gtceu.multiblock.idling")) + widgets.add(Text.lang("gtceu.multiblock.idling") .asWidget() .setEnabledIf((widget) -> isFormed.getBoolValue() && workingEnabled.getBoolValue() && !active.getBoolValue())); - widgets.add(IKey - .lang(Component.translatable("gtceu.multiblock.waiting") + widgets.add(Text + .of(Component.translatable("gtceu.multiblock.waiting") .setStyle(Style.EMPTY.withColor(ChatFormatting.RED))) .asWidget() .setEnabledIf((widget) -> isFormed.getBoolValue() && waiting.getBoolValue())); - widgets.add(IKey.lang(Component.translatable("gtceu.multiblock.cleanroom.clean_state")) + widgets.add(Text.of(Component.translatable("gtceu.multiblock.cleanroom.clean_state")) .asWidget() .setEnabledIf((widget) -> isFormed.getBoolValue() && cleanroomProviderTraitIsActive.getBoolValue())); - widgets.add(IKey.lang(Component.translatable("gtceu.multiblock.cleanroom.dirty_state")) + widgets.add(Text.of(Component.translatable("gtceu.multiblock.cleanroom.dirty_state")) .asWidget() .setEnabledIf((widget) -> isFormed.getBoolValue() && !cleanroomProviderTraitIsActive.getBoolValue())); - widgets.add(IKey.dynamic( + widgets.add(Text.dynamic( () -> Component.translatable("gtceu.multiblock.cleanroom.clean_amount", cleanAmount.getIntValue())) .asWidget() .setEnabledIf((widget) -> isFormed.getBoolValue())); - widgets.add(IKey.lang(Component.translatable("gtceu.multiblock.dimensions.0")) + widgets.add(Text.of(Component.translatable("gtceu.multiblock.dimensions.0")) .asWidget() .setEnabledIf((widget) -> isFormed.getBoolValue())); - widgets.add(IKey.dynamic(distComponent::getValue) + widgets.add(Text.dynamic(distComponent::getValue) .asWidget() .setEnabledIf((widget) -> isFormed.getBoolValue())); diff --git a/src/main/java/com/gregtechceu/gtceu/common/machine/multiblock/electric/DistillationTowerMachine.java b/src/main/java/com/gregtechceu/gtceu/common/machine/multiblock/electric/DistillationTowerMachine.java index f783a7d5d99..5bbb8cff7c7 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/machine/multiblock/electric/DistillationTowerMachine.java +++ b/src/main/java/com/gregtechceu/gtceu/common/machine/multiblock/electric/DistillationTowerMachine.java @@ -131,7 +131,7 @@ public int limitFluidParallel(GTRecipe recipe, int multiplier, boolean tick) { if (contents == null || contents.isEmpty()) return multiplier; int maxAmount = contents.stream() - .map(Content::getContent) + .map(Content::content) .map(FluidRecipeCapability.CAP::of) .filter(i -> !i.isEmpty()) .mapToInt(FluidIngredient::getAmount) @@ -270,7 +270,7 @@ protected ActionResult handleRecipeIO(GTRecipe recipe, IO io) { private boolean applyFluidOutputs(GTRecipe recipe, FluidAction action, VoidingMode voidMode) { var fluids = recipe.getOutputContents(FluidRecipeCapability.CAP) .stream() - .map(Content::getContent) + .map(Content::content) .map(FluidRecipeCapability.CAP::of) .toList(); diff --git a/src/main/java/com/gregtechceu/gtceu/common/machine/multiblock/electric/FusionReactorMachine.java b/src/main/java/com/gregtechceu/gtceu/common/machine/multiblock/electric/FusionReactorMachine.java index 3a267d1d40f..b776a0cac10 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/machine/multiblock/electric/FusionReactorMachine.java +++ b/src/main/java/com/gregtechceu/gtceu/common/machine/multiblock/electric/FusionReactorMachine.java @@ -1,5 +1,7 @@ package com.gregtechceu.gtceu.common.machine.multiblock.electric; +import brachy.modularui.api.drawable.Text; +import brachy.modularui.widgets.TextWidget; import com.gregtechceu.gtceu.api.GTValues; import com.gregtechceu.gtceu.api.block.IFusionCasingType; import com.gregtechceu.gtceu.api.blockentity.BlockEntityCreationInfo; @@ -17,6 +19,7 @@ import com.gregtechceu.gtceu.api.recipe.GTRecipe; import com.gregtechceu.gtceu.api.recipe.OverclockingLogic; import com.gregtechceu.gtceu.api.recipe.RecipeHelper; +import com.gregtechceu.gtceu.api.recipe.gui.GTRecipeViewerWidget; import com.gregtechceu.gtceu.api.recipe.modifier.ModifierFunction; import com.gregtechceu.gtceu.api.recipe.modifier.RecipeModifier; import com.gregtechceu.gtceu.api.sync_system.annotations.SaveField; @@ -25,10 +28,6 @@ import com.gregtechceu.gtceu.utils.FormattingUtil; import com.gregtechceu.gtceu.utils.GTUtil; -import com.lowdragmc.lowdraglib.gui.widget.LabelWidget; -import com.lowdragmc.lowdraglib.gui.widget.WidgetGroup; -import com.lowdragmc.lowdraglib.utils.LocalizationUtils; - import net.minecraft.MethodsReturnNonnullByDefault; import net.minecraft.network.chat.Component; import net.minecraft.world.level.block.Block; @@ -40,7 +39,6 @@ import it.unimi.dsi.fastutil.longs.Long2ObjectMap; import it.unimi.dsi.fastutil.longs.Long2ObjectMaps; import lombok.Getter; -import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.util.*; @@ -170,7 +168,7 @@ protected void updatePreHeatSubscription() { * @param recipe recipe * @return A {@link ModifierFunction} for the given Fusion Reactor and recipe */ - public static ModifierFunction recipeModifier(@NotNull MetaMachine machine, @NotNull GTRecipe recipe) { + public static ModifierFunction recipeModifier(MetaMachine machine, GTRecipe recipe) { if (!(machine instanceof FusionReactorMachine fusionReactorMachine)) { return RecipeModifier.nullWrongType(FusionReactorMachine.class, machine); } @@ -224,7 +222,7 @@ public boolean onWorking() { if (color == -1) { if (!recipe.getOutputContents(FluidRecipeCapability.CAP).isEmpty()) { var stack = FluidRecipeCapability.CAP - .of(recipe.getOutputContents(FluidRecipeCapability.CAP).get(0).getContent()).getStacks()[0]; + .of(recipe.getOutputContents(FluidRecipeCapability.CAP).get(0).content()).getStacks()[0]; int newColor = 0xFF000000 | GTUtil.getFluidColor(stack); if (!Objects.equals(color, newColor)) { color = newColor; @@ -274,33 +272,21 @@ public long getMaxVoltage() { ////////////////////////////////////// // ******** GUI *********// - ////////////////////////////////////// - // @Override - // public void addDisplayText(List textList) { - // super.addDisplayText(textList); - // if (isFormed()) { - // textList.add(Component.translatable("gtceu.multiblock.fusion_reactor.energy", - // this.energyContainer.getEnergyStored(), this.energyContainer.getEnergyCapacity())); - // textList.add(Component.translatable("gtceu.multiblock.fusion_reactor.heat", heat)); - // } - // } - - public static void addEUToStartLabel(GTRecipe recipe, WidgetGroup group) { + + public static void addEUToStartLabel(GTRecipe recipe, GTRecipeViewerWidget widget) { long euToStart = recipe.data.getLong("eu_to_start"); if (euToStart <= 0) return; int recipeTier = RecipeHelper.getPreOCRecipeEuTier(recipe); int fusionTier = findCeilingTier(euToStart); int tier = Math.max(MINIMUM_TIER, Math.max(recipeTier, fusionTier)); - group.addWidget(new LabelWidget(-8, group.getSizeHeight() - 10, - LocalizationUtils.format("gtceu.recipe.eu_to_start", - FormattingUtil.formatNumberReadable2F(euToStart, false), - FUSION_NAMES.get(tier)))); + widget.textComponents.child(new TextWidget<>(Text.lang("gtceu.recipe.eu_to_start", FormattingUtil.formatNumberReadable2F(euToStart, false), + FUSION_NAMES.get(tier)))); } ////////////////////////////////////// // ******** MISC *********// ////////////////////////////////////// - public static void registerFusionTier(int tier, @NotNull String name) { + public static void registerFusionTier(int tier, String name) { long maxEU = calculateEnergyStorageFactor(tier, 16); FUSION_ENERGY.put(maxEU, tier); FUSION_NAMES.put(tier, name); diff --git a/src/main/java/com/gregtechceu/gtceu/common/machine/multiblock/electric/MultiblockTankMachine.java b/src/main/java/com/gregtechceu/gtceu/common/machine/multiblock/electric/MultiblockTankMachine.java index 2c3c9ec623b..2eb7fde4de4 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/machine/multiblock/electric/MultiblockTankMachine.java +++ b/src/main/java/com/gregtechceu/gtceu/common/machine/multiblock/electric/MultiblockTankMachine.java @@ -12,12 +12,13 @@ import com.gregtechceu.gtceu.utils.ExtendedUseOnContext; import com.gregtechceu.gtceu.utils.FormattingUtil; +import net.minecraft.ChatFormatting; import net.minecraft.MethodsReturnNonnullByDefault; import net.minecraft.core.Direction; import net.minecraft.network.chat.Component; import net.minecraft.world.InteractionResult; -import brachy.modularui.api.drawable.IKey; +import brachy.modularui.api.drawable.Text; import brachy.modularui.api.widget.IWidget; import brachy.modularui.factory.PosGuiData; import brachy.modularui.screen.UISettings; @@ -81,14 +82,14 @@ public void buildMainUI(ParentWidget mainWidget, PosGuiData guiData, PanelSyn mainWidget .background(GTGuiTextures.DISPLAY) - .child(IKey.lang("gtceu.gui.fluid_amount").asWidget() + .child(Text.lang("gtceu.gui.fluid_amount").asWidget() .color(0xffffff) .margin(8, 0, 8, 0)) - .child(IKey.dynamic( + .child(Text.dynamic( () -> Component.literal( - FormattingUtil.formatBuckets(bucketSyncer.getIntValue()))) + FormattingUtil.formatBuckets(bucketSyncer.getIntValue())) + .withStyle(ChatFormatting.WHITE)) .asWidget() - .color(0xffffff) .margin(8, 0, 20, 0)) .child(Flow.column() .margin(68, 0, 23, 0) diff --git a/src/main/java/com/gregtechceu/gtceu/common/machine/multiblock/electric/PowerSubstationMachine.java b/src/main/java/com/gregtechceu/gtceu/common/machine/multiblock/electric/PowerSubstationMachine.java index badd339f0ee..c6e97cadad7 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/machine/multiblock/electric/PowerSubstationMachine.java +++ b/src/main/java/com/gregtechceu/gtceu/common/machine/multiblock/electric/PowerSubstationMachine.java @@ -29,7 +29,7 @@ import net.minecraft.network.chat.Style; import net.minecraftforge.common.util.INBTSerializable; -import brachy.modularui.api.drawable.IKey; +import brachy.modularui.api.drawable.Text; import brachy.modularui.drawable.GuiTextures; import brachy.modularui.drawable.Icon; import brachy.modularui.factory.PosGuiData; @@ -320,17 +320,18 @@ public Widget getMainTextPanel(PanelSyncManager syncManager, int width, int h syncManager.syncValue("outputPerSec", outputPerSec); // Generic machine lines - listWidget.child(IKey.lang(Component.translatable("gtceu.multiblock.work_paused")) + listWidget.child(Text.lang("gtceu.multiblock.work_paused") .asWidget() .setEnabledIf((widget) -> !power.getBoolValue())); - listWidget.child(IKey.lang(Component.translatable("gtceu.multiblock.running")) + listWidget.child(Text.lang("gtceu.multiblock.running") .asWidget() .setEnabledIf((widget) -> active.getBoolValue())); - listWidget.child(IKey.lang(Component.translatable("gtceu.multiblock.idling")) + listWidget.child(Text.lang("gtceu.multiblock.idling") .asWidget() .setEnabledIf((widget) -> !active.getBoolValue() && power.getBoolValue())); - listWidget.child(IKey.lang(Component.translatable("gtceu.multiblock.waiting") - .setStyle(Style.EMPTY.withColor(ChatFormatting.RED))) + listWidget.child(Text + .of(Component.translatable("gtceu.multiblock.waiting") + .setStyle(Style.EMPTY.withColor(ChatFormatting.RED))) .asWidget() .setEnabledIf((widget) -> waiting.getBoolValue())); @@ -341,7 +342,7 @@ public Widget getMainTextPanel(PanelSyncManager syncManager, int width, int h var STYLE_GREEN = Style.EMPTY.withColor(ChatFormatting.GREEN); var STYLE_RED = Style.EMPTY.withColor(ChatFormatting.RED); - listWidget.child(IKey.dynamic(() -> { + listWidget.child(Text.dynamic(() -> { if (!energyBankExists.getBoolValue()) return Component.empty(); var storedComponent = Component.literal(FormattingUtil.formatNumbers(energyStored.getValue())); return Component.translatable("gtceu.multiblock.power_substation.stored", @@ -350,7 +351,7 @@ public Widget getMainTextPanel(PanelSyncManager syncManager, int width, int h .asWidget() .setEnabledIf((widget) -> energyBankExists.getBoolValue())); - listWidget.child(IKey.dynamic(() -> { + listWidget.child(Text.dynamic(() -> { if (!energyBankExists.getBoolValue()) return Component.empty(); var capacityComponent = Component.literal(FormattingUtil.formatNumbers(capacity.getValue())); return Component.translatable("gtceu.multiblock.power_substation.capacity", @@ -359,7 +360,7 @@ public Widget getMainTextPanel(PanelSyncManager syncManager, int width, int h .asWidget() .setEnabledIf((widget) -> energyBankExists.getBoolValue())); - listWidget.child(IKey.dynamic(() -> { + listWidget.child(Text.dynamic(() -> { if (!energyBankExists.getBoolValue()) return Component.empty(); var passiveDrainComponent = Component.literal(FormattingUtil.formatNumbers(passiveDrain.getLongValue())); return Component.translatable("gtceu.multiblock.power_substation.passive_drain", @@ -368,7 +369,7 @@ public Widget getMainTextPanel(PanelSyncManager syncManager, int width, int h .asWidget() .setEnabledIf((widget) -> energyBankExists.getBoolValue())); - listWidget.child(IKey.dynamic(() -> { + listWidget.child(Text.dynamic(() -> { if (!energyBankExists.getBoolValue()) return Component.empty(); var avgInComponent = Component.literal(FormattingUtil.formatNumbers(inputPerSec.getLongValue() / 20)); return Component @@ -379,7 +380,7 @@ public Widget getMainTextPanel(PanelSyncManager syncManager, int width, int h }) .asWidget() .setEnabledIf((widget) -> energyBankExists.getBoolValue())); - listWidget.child(IKey.dynamic(() -> { + listWidget.child(Text.dynamic(() -> { if (!energyBankExists.getBoolValue()) return Component.empty(); var avgOutComponent = Component .literal(FormattingUtil.formatNumbers(Math.abs(outputPerSec.getLongValue() / 20))); @@ -392,7 +393,7 @@ public Widget getMainTextPanel(PanelSyncManager syncManager, int width, int h .asWidget() .setEnabledIf((widget) -> energyBankExists.getBoolValue())); - listWidget.child(IKey.dynamic(() -> { + listWidget.child(Text.dynamic(() -> { if (!energyBankExists.getBoolValue() || inputPerSec.getLongValue() <= outputPerSec.getLongValue()) return Component.empty(); BigInteger timeToFillSeconds = capacity.getValue().subtract(energyStored.getValue()) @@ -404,7 +405,7 @@ public Widget getMainTextPanel(PanelSyncManager syncManager, int width, int h .setEnabledIf((widget) -> energyBankExists.getBoolValue() && inputPerSec.getLongValue() > outputPerSec.getLongValue())); - listWidget.child(IKey.dynamic(() -> { + listWidget.child(Text.dynamic(() -> { if (!energyBankExists.getBoolValue() || inputPerSec.getLongValue() >= outputPerSec.getLongValue()) return Component.empty(); BigInteger timeToDrainSeconds = energyStored.getValue() diff --git a/src/main/java/com/gregtechceu/gtceu/common/machine/multiblock/electric/research/HPCAMachine.java b/src/main/java/com/gregtechceu/gtceu/common/machine/multiblock/electric/research/HPCAMachine.java index 2b10ce3fea9..b37639de7a4 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/machine/multiblock/electric/research/HPCAMachine.java +++ b/src/main/java/com/gregtechceu/gtceu/common/machine/multiblock/electric/research/HPCAMachine.java @@ -46,7 +46,7 @@ import net.minecraftforge.fluids.capability.IFluidHandler; import brachy.modularui.api.drawable.IDrawable; -import brachy.modularui.api.drawable.IKey; +import brachy.modularui.api.drawable.Text; import brachy.modularui.api.widget.IWidget; import brachy.modularui.screen.RichTooltip; import brachy.modularui.value.sync.GenericSyncValue; @@ -269,9 +269,9 @@ public List getWidgetsForDisplay(PanelSyncManager syncManager) { List widgets = new ArrayList<>(); widgets.add(GTMultiblockTextUtil.addWorkingStatusLine(this, syncManager)); widgets.add(GTMultiblockTextUtil.addEnergyUsageExactLine(this, syncManager)); - widgets.add(new TextWidget<>(IKey.dynamic(text::getValue))); + widgets.add(new TextWidget<>(Text.dynamic(text::getValue))); widgets.add(new Grid() - .mapTo(3, 9, i -> hpcaHandler.getComponentTexture(i).asWidget() + .gridOfSizeWidth(9, 3, (x, y, i) -> hpcaHandler.getComponentTexture(i).asWidget() .tooltip(hpcaHandler.getComponentTooltip(i))) .horizontalCenter()); return widgets; diff --git a/src/main/java/com/gregtechceu/gtceu/common/machine/multiblock/electric/research/ResearchStationMachine.java b/src/main/java/com/gregtechceu/gtceu/common/machine/multiblock/electric/research/ResearchStationMachine.java index 404371fc6fd..14054a5e110 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/machine/multiblock/electric/research/ResearchStationMachine.java +++ b/src/main/java/com/gregtechceu/gtceu/common/machine/multiblock/electric/research/ResearchStationMachine.java @@ -198,7 +198,7 @@ protected ActionResult handleRecipeIO(GTRecipe recipe, IO io) { ItemStack outputItem = ItemStack.EMPTY; var contents = lastRecipe.getOutputContents(ItemRecipeCapability.CAP); if (!contents.isEmpty()) { - outputItem = ItemRecipeCapability.CAP.of(contents.get(0).content).getItems()[0]; + outputItem = ItemRecipeCapability.CAP.of(contents.get(0).content()).getItems()[0]; } if (!outputItem.isEmpty()) { holder.setDataItem(outputItem.copy()); diff --git a/src/main/java/com/gregtechceu/gtceu/common/machine/multiblock/part/DataAccessHatchMachine.java b/src/main/java/com/gregtechceu/gtceu/common/machine/multiblock/part/DataAccessHatchMachine.java index c5659df7c2f..f490c7fb7d9 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/machine/multiblock/part/DataAccessHatchMachine.java +++ b/src/main/java/com/gregtechceu/gtceu/common/machine/multiblock/part/DataAccessHatchMachine.java @@ -151,7 +151,7 @@ public List getDataInfo(PortableScannerBehavior.DisplayMode mode) { Collection itemsAdded = new ObjectOpenCustomHashSet<>(ItemStackHashStrategy.comparingAll()); for (GTRecipe recipe : recipes) { ItemStack stack = ItemRecipeCapability.CAP - .of(recipe.getOutputContents(ItemRecipeCapability.CAP).get(0).content).getItems()[0]; + .of(recipe.getOutputContents(ItemRecipeCapability.CAP).get(0).content()).getItems()[0]; if (!itemsAdded.contains(stack)) { itemsAdded.add(stack); list.add(Component.translatable("behavior.data_item.data", stack.getDisplayName())); diff --git a/src/main/java/com/gregtechceu/gtceu/common/machine/multiblock/part/FluidHatchPartMachine.java b/src/main/java/com/gregtechceu/gtceu/common/machine/multiblock/part/FluidHatchPartMachine.java index a00e06a5ad6..ee2e858d6c3 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/machine/multiblock/part/FluidHatchPartMachine.java +++ b/src/main/java/com/gregtechceu/gtceu/common/machine/multiblock/part/FluidHatchPartMachine.java @@ -36,7 +36,7 @@ import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidType; -import brachy.modularui.api.drawable.IKey; +import brachy.modularui.api.drawable.Text; import brachy.modularui.drawable.GuiTextures; import brachy.modularui.factory.PosGuiData; import brachy.modularui.screen.UISettings; @@ -299,9 +299,9 @@ protected Flow createSingleSlotUI(PanelSyncManager syncManager) { .height(60) .mainAxisAlignment(Alignment.MainAxis.CENTER) .childPadding(4) - .child(new TextWidget<>(IKey.dynamic(this::getFluidNameText)) + .child(new TextWidget<>(Text.dynamic(this::getFluidNameText)) .horizontalCenter()) - .child(new TextWidget<>(IKey.dynamic(this::getFluidAmountText)) + .child(new TextWidget<>(Text.dynamic(this::getFluidAmountText)) .horizontalCenter()) .child(Flow.row() .childPadding(2) diff --git a/src/main/java/com/gregtechceu/gtceu/common/machine/multiblock/part/ItemBusPartMachine.java b/src/main/java/com/gregtechceu/gtceu/common/machine/multiblock/part/ItemBusPartMachine.java index 6d89026cc53..d07ea63fb84 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/machine/multiblock/part/ItemBusPartMachine.java +++ b/src/main/java/com/gregtechceu/gtceu/common/machine/multiblock/part/ItemBusPartMachine.java @@ -299,7 +299,7 @@ public void buildMainUI(ParentWidget mainWidget, PosGuiData guiData, PanelSyn .coverChildren() .center() .margin(7, 5) - .mapTo(rowSize, rowSize * rowSize, index -> new ItemSlot() + .gridOfSizeHeight(rowSize * rowSize, rowSize, (x, y, index) -> new ItemSlot() .slot(SyncHandlers.itemSlot(inventory, index) .slotGroup(group) .changeListener((newItem, amount, client, init) -> { diff --git a/src/main/java/com/gregtechceu/gtceu/common/machine/multiblock/part/MaintenanceHatchPartMachine.java b/src/main/java/com/gregtechceu/gtceu/common/machine/multiblock/part/MaintenanceHatchPartMachine.java index c3d293fbb44..8e78d712c96 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/machine/multiblock/part/MaintenanceHatchPartMachine.java +++ b/src/main/java/com/gregtechceu/gtceu/common/machine/multiblock/part/MaintenanceHatchPartMachine.java @@ -20,6 +20,7 @@ import com.gregtechceu.gtceu.utils.GTUtil; import net.minecraft.MethodsReturnNonnullByDefault; +import net.minecraft.network.chat.Component; import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; @@ -29,7 +30,7 @@ import net.minecraftforge.items.wrapper.InvWrapper; import brachy.modularui.api.drawable.IDrawable; -import brachy.modularui.api.drawable.IKey; +import brachy.modularui.api.drawable.Text; import brachy.modularui.api.widget.IWidget; import brachy.modularui.drawable.ItemDrawable; import brachy.modularui.factory.PosGuiData; @@ -400,9 +401,9 @@ public void buildMainUI(ParentWidget mainWidget, PosGuiData guiData, PanelSyn .childPadding(2); Runnable updateWidget = () -> { while (!maintenanceStatusWidget.getChildren().isEmpty()) maintenanceStatusWidget.remove(0); - maintenanceStatusWidget.child(new TextWidget<>(IKey.lang(() -> hasMaintenanceProblems() ? - "gtceu.top.maintenance_broken" : - "gtceu.top.maintenance_fixed"))) + maintenanceStatusWidget.child(new TextWidget<>(Text.dynamic(() -> hasMaintenanceProblems() ? + Component.translatable("gtceu.top.maintenance_broken") : + Component.translatable("gtceu.top.maintenance_fixed")))) .child(Flow.row() .coverChildren() .children(Stream.iterate(Byte.valueOf("0"), i -> i < 6, i -> ++i) @@ -430,18 +431,20 @@ public void buildMainUI(ParentWidget mainWidget, PosGuiData guiData, PanelSyn .childPadding(5) .leftRel(0) .child(new TextWidget<>( - IKey.lang("gtceu.maintenance.configurable_duration.modify"))) + Text.lang("gtceu.maintenance.configurable_duration.modify"))) .child(new TextFieldWidget() .setNumbersDouble(() -> MIN_DURATION_MULTIPLIER, () -> MAX_DURATION_MULTIPLIER) .setDefaultNumber(1) .value(new FloatSyncValue(this::getDurationMultiplier, this::setDurationMultiplier)) - .addTooltipElement(IKey.lang(() -> getDurationMultiplier() == 1.0 ? - "gtceu.maintenance.configurable_duration.unchanged_description" : - "gtceu.maintenance.configurable_duration.changed_description")))) - .child(new TextWidget<>(IKey.lang("gtceu.maintenance.configurable_time", - () -> new Object[] { this.getTimeMultiplier() })) + .addTooltipElement(Text.dynamic(() -> getDurationMultiplier() == 1.0 ? + Component.translatable( + "gtceu.maintenance.configurable_duration.unchanged_description") : + Component.translatable( + "gtceu.maintenance.configurable_duration.changed_description"))))) + .child(new TextWidget<>(Text.lang("gtceu.maintenance.configurable_time", + this.getTimeMultiplier())) .leftRel(0))) .child(Flow.row() .leftRel(0.5f) @@ -455,7 +458,7 @@ public void buildMainUI(ParentWidget mainWidget, PosGuiData guiData, PanelSyn .background(GTGuiTextures.BUTTON_MAINTENANCE) .disableHoverBackground() .addTooltipElement( - IKey.lang("gtceu.machine.maintenance_hatch_tool_slot.tooltip")) + Text.lang("gtceu.machine.maintenance_hatch_tool_slot.tooltip")) .syncHandler(syncHandler))) .child(maintenanceStatusWidget)); } diff --git a/src/main/java/com/gregtechceu/gtceu/common/machine/multiblock/part/ParallelHatchPartMachine.java b/src/main/java/com/gregtechceu/gtceu/common/machine/multiblock/part/ParallelHatchPartMachine.java index b0a8e101438..30e806b7921 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/machine/multiblock/part/ParallelHatchPartMachine.java +++ b/src/main/java/com/gregtechceu/gtceu/common/machine/multiblock/part/ParallelHatchPartMachine.java @@ -11,10 +11,11 @@ import net.minecraft.util.Mth; -import brachy.modularui.api.drawable.IKey; +import brachy.modularui.api.drawable.Text; import brachy.modularui.drawable.DynamicDrawable; import brachy.modularui.factory.PosGuiData; import brachy.modularui.screen.UISettings; +import brachy.modularui.screen.viewport.GuiContext; import brachy.modularui.utils.Alignment; import brachy.modularui.utils.MouseData; import brachy.modularui.value.sync.IntSyncValue; @@ -65,19 +66,19 @@ public void buildMainUI(ParentWidget mainWidget, PosGuiData guiData, PanelSyn .overlay(new DynamicDrawable(() -> { MouseData mouseData = MouseData.create(-1); if (mouseData.ctrl() && mouseData.shift()) { - return IKey.str("/16"); + return Text.str("/16"); } else if (mouseData.ctrl()) { - return IKey.str("/8"); + return Text.str("/8"); } else if (mouseData.shift()) { - return IKey.str("/4"); + return Text.str("/4"); } else { - return IKey.str("/2"); + return Text.str("/2"); } })) .width(32) .height(16) - .onMousePressed((a, b, c) -> { - MouseData mouseData = MouseData.create(c); + .onMousePressed((GuiContext context, int button) -> { + MouseData mouseData = MouseData.create(button); if (mouseData.ctrl() && mouseData.shift()) { parallels.setValue((int) GTMath.clamp(parallels.getValue() / 16, 1, this.maxParallel)); } else if (mouseData.ctrl()) { @@ -104,19 +105,19 @@ public void buildMainUI(ParentWidget mainWidget, PosGuiData guiData, PanelSyn .overlay(new DynamicDrawable(() -> { MouseData mouseData = MouseData.create(-1); if (mouseData.ctrl() && mouseData.shift()) { - return IKey.str("x16"); + return Text.str("x16"); } else if (mouseData.ctrl()) { - return IKey.str("x8"); + return Text.str("x8"); } else if (mouseData.shift()) { - return IKey.str("x4"); + return Text.str("x4"); } else { - return IKey.str("x2"); + return Text.str("x2"); } })) .width(32) .height(16) - .onMousePressed((a, b, c) -> { - MouseData mouseData = MouseData.create(c); + .onMousePressed((GuiContext context, int button) -> { + MouseData mouseData = MouseData.create(button); if (mouseData.ctrl() && mouseData.shift()) { parallels.setValue((int) GTMath.clamp(parallels.getValue() * 16, 1, this.maxParallel)); } else if (mouseData.ctrl()) { @@ -130,7 +131,7 @@ public void buildMainUI(ParentWidget mainWidget, PosGuiData guiData, PanelSyn }) .marginLeft(4) .verticalCenter()) - .child(IKey.lang("gtceu.machine.parallel_hatch.parallel_ui") + .child(Text.lang("gtceu.machine.parallel_hatch.parallel_ui") .asWidget() .marginLeft(4) .marginRight(4) diff --git a/src/main/java/com/gregtechceu/gtceu/common/machine/multiblock/primitive/CokeOvenMachine.java b/src/main/java/com/gregtechceu/gtceu/common/machine/multiblock/primitive/CokeOvenMachine.java index 32e1a8b0429..c7700cb8c84 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/machine/multiblock/primitive/CokeOvenMachine.java +++ b/src/main/java/com/gregtechceu/gtceu/common/machine/multiblock/primitive/CokeOvenMachine.java @@ -45,7 +45,7 @@ public CokeOvenMachine(BlockEntityCreationInfo info) { @Override public MachineUIPanelBuilder getPanelBuilder(PosGuiData data, PanelSyncManager syncManager, UISettings settings) { - return MachineUIPanelBuilder.defaultPanelBuilder(this).addTraitConfigurators(false) + return MachineUIPanelBuilder.panelBuilder(this).addTraitConfigurators(false) .addDefaultConfigurators(false); } diff --git a/src/main/java/com/gregtechceu/gtceu/common/machine/multiblock/primitive/PrimitiveBlastFurnaceMachine.java b/src/main/java/com/gregtechceu/gtceu/common/machine/multiblock/primitive/PrimitiveBlastFurnaceMachine.java index 640e50b0794..ef851691b0f 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/machine/multiblock/primitive/PrimitiveBlastFurnaceMachine.java +++ b/src/main/java/com/gregtechceu/gtceu/common/machine/multiblock/primitive/PrimitiveBlastFurnaceMachine.java @@ -155,7 +155,7 @@ public void clientTick() { @Override public MachineUIPanelBuilder getPanelBuilder(PosGuiData data, PanelSyncManager syncManager, UISettings settings) { - return MachineUIPanelBuilder.defaultPanelBuilder(this).addTraitConfigurators(false) + return MachineUIPanelBuilder.panelBuilder(this).addTraitConfigurators(false) .addDefaultConfigurators(false); } diff --git a/src/main/java/com/gregtechceu/gtceu/common/machine/multiblock/steam/LargeBoilerMachine.java b/src/main/java/com/gregtechceu/gtceu/common/machine/multiblock/steam/LargeBoilerMachine.java index b3516fe8b22..043463e95f8 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/machine/multiblock/steam/LargeBoilerMachine.java +++ b/src/main/java/com/gregtechceu/gtceu/common/machine/multiblock/steam/LargeBoilerMachine.java @@ -30,7 +30,7 @@ import net.minecraft.util.Mth; import net.minecraft.world.level.material.Fluids; -import brachy.modularui.api.drawable.IKey; +import brachy.modularui.api.drawable.Text; import brachy.modularui.drawable.Icon; import brachy.modularui.factory.PosGuiData; import brachy.modularui.screen.UISettings; @@ -262,20 +262,20 @@ public Widget getMainTextPanel(PanelSyncManager syncManager, int width, int h syncManager.syncValue("throttle", throttle); listWidget - .child(IKey.dynamic(() -> { + .child(Text.dynamic(() -> { if (!isFormed.getBoolValue()) return Component.empty(); return Component.translatable("gtceu.multiblock.large_boiler.temperature", currentTemperature.getIntValue() + 274, maxTemperature.getIntValue() + 274) .withStyle(ChatFormatting.WHITE); }) .asWidget()) - .child(IKey.dynamic(() -> { + .child(Text.dynamic(() -> { if (!isFormed.getBoolValue()) return Component.empty(); return Component.translatable("gtceu.multiblock.large_boiler.steam_output", steamGenerated.getIntValue() / TICKS_PER_STEAM_GENERATION).withStyle(ChatFormatting.WHITE); }) .asWidget()) - .child(IKey.lang(Component.translatable("gtceu.multiblock.large_boiler.throttle_modify") + .child(Text.of(Component.translatable("gtceu.multiblock.large_boiler.throttle_modify") .withStyle(ChatFormatting.WHITE)) .asWidget()) .child(createIntInputWithButtons(throttle)) @@ -292,7 +292,7 @@ public static ParentWidget createIntInputWithButtons(IntSyncValue syncValue) var textField = new TextFieldWidget() { @Override - public boolean onMouseScrolled(double mouseX, double mouseY, double delta) { + public boolean onMouseScrolled(double delta) { int inc = (int) delta; int val = Mth.clamp(syncValue.getIntValue() + inc, 25, 100); syncValue.setIntValue(val, true, true); @@ -311,7 +311,7 @@ public boolean onMouseScrolled(double mouseX, double mouseY, double delta) { .widthRel(1.0f) .child(new ButtonWidget<>() .left(0).width(18) - .onMousePressed((x, y, button) -> { + .onMousePressed((context, button) -> { int val = syncValue.getIntValue() - getIncrementValue(MouseData.create(button)); val = Mth.clamp(val, 25, 100); syncValue.setIntValue(val, true, true); @@ -321,7 +321,7 @@ public boolean onMouseScrolled(double mouseX, double mouseY, double delta) { .child(textField) .child(new ButtonWidget<>() .right(0).width(18) - .onMousePressed((x, y, button) -> { + .onMousePressed((context, button) -> { int val = syncValue.getIntValue() + getIncrementValue(MouseData.create(button)); val = Mth.clamp(val, 25, 100); syncValue.setIntValue(val, true, true); @@ -330,7 +330,7 @@ public boolean onMouseScrolled(double mouseX, double mouseY, double delta) { .onUpdateListener(w -> w.overlay(createAdjustOverlay(true)))); } - private static IKey createAdjustOverlay(boolean increment) { + private static Text createAdjustOverlay(boolean increment) { final StringBuilder builder = new StringBuilder(); builder.append(increment ? '+' : '-'); builder.append(getIncrementValue(MouseData.create(-1))); @@ -343,7 +343,7 @@ private static IKey createAdjustOverlay(boolean increment) { } else if (builder.length() > 4) { scale = 0.5f; } - return IKey.str(builder.toString()) + return Text.str(builder.toString()) .color(Color.WHITE.main) .scale(scale); } diff --git a/src/main/java/com/gregtechceu/gtceu/common/machine/steam/SteamLiquidBoilerMachine.java b/src/main/java/com/gregtechceu/gtceu/common/machine/steam/SteamLiquidBoilerMachine.java index f727fa884c5..66d0a666ff9 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/machine/steam/SteamLiquidBoilerMachine.java +++ b/src/main/java/com/gregtechceu/gtceu/common/machine/steam/SteamLiquidBoilerMachine.java @@ -54,7 +54,7 @@ public SteamLiquidBoilerMachine(BlockEntityCreationInfo info, boolean isHighPres return recipeLogic.getRecipeManager().getAllRecipesFor(getRecipeType()).stream().anyMatch(recipe -> { var list = recipe.inputs.getOrDefault(FluidRecipeCapability.CAP, Collections.emptyList()); if (!list.isEmpty()) { - return Arrays.stream(FluidRecipeCapability.CAP.of(list.get(0).content).getStacks()) + return Arrays.stream(FluidRecipeCapability.CAP.of(list.get(0).content()).getStacks()) .anyMatch(stack -> stack.getFluid() == f); } return false; diff --git a/src/main/java/com/gregtechceu/gtceu/common/machine/steam/SteamMinerMachine.java b/src/main/java/com/gregtechceu/gtceu/common/machine/steam/SteamMinerMachine.java index 12302d60185..df73c1d8bb9 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/machine/steam/SteamMinerMachine.java +++ b/src/main/java/com/gregtechceu/gtceu/common/machine/steam/SteamMinerMachine.java @@ -29,7 +29,7 @@ import net.minecraft.world.level.block.Block; import net.minecraftforge.fluids.capability.IFluidHandler; -import brachy.modularui.api.drawable.IKey; +import brachy.modularui.api.drawable.Text; import brachy.modularui.factory.PosGuiData; import brachy.modularui.screen.UISettings; import brachy.modularui.utils.Alignment; @@ -153,7 +153,7 @@ protected void autoOutput() { @Override public MachineUIPanelBuilder getPanelBuilder(PosGuiData data, PanelSyncManager syncManager, UISettings settings) { - return MachineUIPanelBuilder.defaultSteamMachineBuilder(this); + return MachineUIPanelBuilder.defaultSteamMachinePanelBuilder(this); } @Override @@ -171,7 +171,7 @@ public void buildMainUI(ParentWidget mainWidget, PosGuiData guiData, PanelSyn .background(GTGuiTextures.DISPLAY) .widthRel(.6f) .coverChildrenHeight() - .child(new TextWidget<>(IKey.dynamic(() -> { + .child(new TextWidget<>(Text.dynamic(() -> { List text = new ArrayList<>(); addDisplayText(text); return text.stream() diff --git a/src/main/java/com/gregtechceu/gtceu/common/machine/steam/SteamSolidBoilerMachine.java b/src/main/java/com/gregtechceu/gtceu/common/machine/steam/SteamSolidBoilerMachine.java index a564679c4bb..22d78fd43fa 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/machine/steam/SteamSolidBoilerMachine.java +++ b/src/main/java/com/gregtechceu/gtceu/common/machine/steam/SteamSolidBoilerMachine.java @@ -56,7 +56,7 @@ public SteamSolidBoilerMachine(BlockEntityCreationInfo info, boolean isHighPress return recipeLogic.getRecipeManager().getAllRecipesFor(getRecipeType()).stream().anyMatch(recipe -> { var list = recipe.inputs.getOrDefault(ItemRecipeCapability.CAP, Collections.emptyList()); if (!list.isEmpty()) { - return Arrays.stream(ItemRecipeCapability.CAP.of(list.get(0).content).getItems()) + return Arrays.stream(ItemRecipeCapability.CAP.of(list.get(0).content()).getItems()) .map(ItemStack::getItem).anyMatch(i -> i == item); } return false; @@ -91,7 +91,7 @@ public void afterWorking() { var inputs = recipeLogic.getLastRecipe().inputs.getOrDefault(ItemRecipeCapability.CAP, Collections.emptyList()); if (!inputs.isEmpty()) { - var input = ItemRecipeCapability.CAP.of(inputs.get(0).content).getItems(); + var input = ItemRecipeCapability.CAP.of(inputs.get(0).content()).getItems(); if (input.length > 0) { var remaining = getBurningFuelRemainder(input[0]); if (!remaining.isEmpty()) { diff --git a/src/main/java/com/gregtechceu/gtceu/common/machine/storage/CrateMachine.java b/src/main/java/com/gregtechceu/gtceu/common/machine/storage/CrateMachine.java index 7a09d51c2a0..f9170214cfa 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/machine/storage/CrateMachine.java +++ b/src/main/java/com/gregtechceu/gtceu/common/machine/storage/CrateMachine.java @@ -20,7 +20,7 @@ import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.item.ItemStack; -import brachy.modularui.api.drawable.IKey; +import brachy.modularui.api.drawable.Text; import brachy.modularui.factory.PosGuiData; import brachy.modularui.screen.UISettings; import brachy.modularui.value.sync.PanelSyncManager; @@ -63,7 +63,7 @@ public CrateMachine(BlockEntityCreationInfo info, Material material, int invento @Override public MachineUIPanelBuilder getPanelBuilder(PosGuiData data, PanelSyncManager syncManager, UISettings settings) { - return MachineUIPanelBuilder.defaultPanelBuilder(this).addTitleBar(false); + return MachineUIPanelBuilder.panelBuilder(this).addTitleBar(false); } @Override @@ -88,7 +88,7 @@ public void buildMainUI(ParentWidget mainWidget, PosGuiData guiData, PanelSyn .margin(5, 5, 0, 5) .coverChildren(); col.child( - IKey.lang(getBlockState().getBlock().getName()).asWidget().leftRel(0).margin(0, 0, 3, 3)) + Text.of(getBlockState().getBlock().getName()).asWidget().leftRel(0).margin(0, 0, 3, 3)) .child(slots.height(rows * 18)); mainWidget.child(col); } diff --git a/src/main/java/com/gregtechceu/gtceu/common/machine/storage/CreativeChestMachine.java b/src/main/java/com/gregtechceu/gtceu/common/machine/storage/CreativeChestMachine.java index f9917a2a719..acfdc81db18 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/machine/storage/CreativeChestMachine.java +++ b/src/main/java/com/gregtechceu/gtceu/common/machine/storage/CreativeChestMachine.java @@ -16,7 +16,7 @@ import net.minecraft.world.item.ItemStack; import net.minecraftforge.items.ItemHandlerHelper; -import brachy.modularui.api.drawable.IKey; +import brachy.modularui.api.drawable.Text; import brachy.modularui.drawable.Rectangle; import brachy.modularui.factory.PosGuiData; import brachy.modularui.screen.UISettings; @@ -109,7 +109,7 @@ public InteractionResult onUseWithItem(ExtendedUseOnContext context) { @Override public MachineUIPanelBuilder getPanelBuilder(PosGuiData data, PanelSyncManager syncManager, UISettings settings) { - return MachineUIPanelBuilder.defaultPanelBuilder(this).addDefaultConfigurators(false) + return MachineUIPanelBuilder.panelBuilder(this).addDefaultConfigurators(false) .addTraitConfigurators(false).rightConfigurators(f -> f.child(GTMuiWidgets.createPowerButton(this))); } @@ -133,7 +133,7 @@ public void buildMainUI(ParentWidget mainWidget, PosGuiData guiData, PanelSyn .padding(7) .mainAxisAlignment(Alignment.MainAxis.START) .child(Flow.row().coverChildrenHeight() - .child(IKey.lang("gtceu.creative.chest.item").asWidget() + .child(Text.lang("gtceu.creative.chest.item").asWidget() .marginRight(4) .verticalCenter()) .child(new PhantomItemSlot().syncHandler("stored"))) @@ -141,7 +141,7 @@ public void buildMainUI(ParentWidget mainWidget, PosGuiData guiData, PanelSyn .height(1).widthRel(0.95f).marginBottom(4).marginTop(4)) .child(Flow.row() .height(18) - .child(IKey.lang("gtceu.creative.chest.ipc").asWidget() + .child(Text.lang("gtceu.creative.chest.ipc").asWidget() .marginRight(4) .width(80) .verticalCenter()) @@ -153,7 +153,7 @@ public void buildMainUI(ParentWidget mainWidget, PosGuiData guiData, PanelSyn .height(1).widthRel(0.95f).marginBottom(4).marginTop(4)) .child(Flow.row() .height(18) - .child(IKey.lang("gtceu.creative.chest.tpc").asWidget() + .child(Text.lang("gtceu.creative.chest.tpc").asWidget() .marginRight(4) .width(80) .verticalCenter()) diff --git a/src/main/java/com/gregtechceu/gtceu/common/machine/storage/CreativeComputationProviderMachine.java b/src/main/java/com/gregtechceu/gtceu/common/machine/storage/CreativeComputationProviderMachine.java index fb007f5d3d1..5f9f404becb 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/machine/storage/CreativeComputationProviderMachine.java +++ b/src/main/java/com/gregtechceu/gtceu/common/machine/storage/CreativeComputationProviderMachine.java @@ -11,7 +11,7 @@ import net.minecraft.MethodsReturnNonnullByDefault; -import brachy.modularui.api.drawable.IKey; +import brachy.modularui.api.drawable.Text; import brachy.modularui.drawable.Rectangle; import brachy.modularui.factory.PosGuiData; import brachy.modularui.screen.UISettings; @@ -101,7 +101,7 @@ public void setWorkingEnabled(boolean workingEnabled) { @Override public MachineUIPanelBuilder getPanelBuilder(PosGuiData data, PanelSyncManager syncManager, UISettings settings) { - return MachineUIPanelBuilder.defaultPanelBuilder(this).attachInventory(false); + return MachineUIPanelBuilder.panelBuilder(this).attachInventory(false); } @Override @@ -115,7 +115,7 @@ public void buildMainUI(ParentWidget mainWidget, PosGuiData guiData, PanelSyn .leftRel(0) .childPadding(5) .coverChildren() - .child(new TextWidget<>(IKey.lang("gtceu.creative.computation.max_usage"))) + .child(new TextWidget<>(Text.lang("gtceu.creative.computation.max_usage"))) .child(new TextFieldWidget() .setNumbers(0, Integer.MAX_VALUE) .value(new IntSyncValue(() -> maxCWUt, (v) -> maxCWUt = v)))) @@ -125,7 +125,7 @@ public void buildMainUI(ParentWidget mainWidget, PosGuiData guiData, PanelSyn .leftRel(0) .childPadding(5) .coverChildren() - .child(new TextWidget<>(IKey.lang("gtceu.creative.computation.average", - () -> new Object[] { lastRequestedCWUt }))))); + .child(new TextWidget<>(Text.lang("gtceu.creative.computation.average", + lastRequestedCWUt))))); } } diff --git a/src/main/java/com/gregtechceu/gtceu/common/machine/storage/CreativeEnergyContainerMachine.java b/src/main/java/com/gregtechceu/gtceu/common/machine/storage/CreativeEnergyContainerMachine.java index 7da0cd9a184..5b653a321a0 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/machine/storage/CreativeEnergyContainerMachine.java +++ b/src/main/java/com/gregtechceu/gtceu/common/machine/storage/CreativeEnergyContainerMachine.java @@ -20,7 +20,7 @@ import brachy.modularui.api.IPanelHandler; import brachy.modularui.api.drawable.IDrawable; -import brachy.modularui.api.drawable.IKey; +import brachy.modularui.api.drawable.Text; import brachy.modularui.drawable.DynamicDrawable; import brachy.modularui.drawable.GuiTextures; import brachy.modularui.drawable.Rectangle; @@ -28,6 +28,7 @@ import brachy.modularui.screen.ModularPanel; import brachy.modularui.screen.RichTooltip; import brachy.modularui.screen.UISettings; +import brachy.modularui.screen.viewport.GuiContext; import brachy.modularui.utils.Alignment; import brachy.modularui.utils.MouseData; import brachy.modularui.value.sync.BooleanSyncValue; @@ -201,7 +202,7 @@ public void setIOSpeed(long energyIOPerSec) { @Override public MachineUIPanelBuilder getPanelBuilder(PosGuiData data, PanelSyncManager syncManager, UISettings settings) { - return MachineUIPanelBuilder.defaultPanelBuilder(this).attachInventory(false); + return MachineUIPanelBuilder.panelBuilder(this).attachInventory(false); } @Override @@ -234,7 +235,7 @@ private Flow createVoltageRow(IPanelHandler panel, LongSyncValue voltage) { return Flow.row() .height(18) .marginBottom(4) - .child(IKey.str("Voltage").asWidget() + .child(Text.str("Voltage").asWidget() .marginRight(4) .width(50) .verticalCenter()) @@ -245,14 +246,13 @@ private Flow createVoltageRow(IPanelHandler panel, LongSyncValue voltage) { .child(new ButtonWidget<>() .height(18) .width(40) - .overlay(IKey.dynamic( - () -> Component.literal(GTValues.VNF[GTUtil.getTierByVoltage(voltage.getLongValue())])) - .shadow(true)) + .overlay(Text.dynamic( + () -> Component.literal(GTValues.VNF[GTUtil.getTierByVoltage(voltage.getLongValue())]))) // .width(32) .marginLeft(4) .tooltip(new RichTooltip().add("Click to Change Tier")) - .onMousePressed((a, b, c) -> { + .onMousePressed((GuiContext context, int button) -> { if (panel.isPanelOpen()) { panel.closePanel(); } else { @@ -267,7 +267,7 @@ private Flow createVoltageRow(IPanelHandler panel, LongSyncValue voltage) { static Flow createAmpRow(IntSyncValue amps) { return Flow.row() .coverChildrenHeight() - .child(IKey.lang("gtceu.creative.energy.amperage").asWidget() + .child(Text.lang("gtceu.creative.energy.amperage").asWidget() .marginRight(4) .verticalCenter().width(50)) .child( @@ -280,11 +280,11 @@ static Flow createAmpRow(IntSyncValue amps) { .overlay(new DynamicDrawable(() -> { MouseData mouseData = MouseData.create(-1); if (mouseData.shift()) { - return IKey.str("1/2x"); + return Text.str("1/2x"); } else if (mouseData.ctrl()) { - return IKey.str("4x"); + return Text.str("4x"); } else { - return IKey.str("2x"); + return Text.str("2x"); } })) @@ -292,8 +292,8 @@ static Flow createAmpRow(IntSyncValue amps) { .height(18) .tooltip(new RichTooltip().addLine("Click to Double Amperage") .addLine("Shift to half current Amperage")) - .onMousePressed((a, b, c) -> { - MouseData mouseData = MouseData.create(c); + .onMousePressed((GuiContext context, int button) -> { + MouseData mouseData = MouseData.create(button); if (mouseData.shift()) { amps.setValue(amps.getValue() / 2); } else if (mouseData.ctrl()) { @@ -321,7 +321,7 @@ private Flow createSourceSelector(BooleanSyncValue sourceSync) { return IDrawable.EMPTY; })) .value(sourceSync)) - .child(IKey.lang("gtceu.creative.energy.source").asWidget()) + .child(Text.lang("gtceu.creative.energy.source").asWidget()) .paddingBottom(2)) .child(Flow.row() .coverChildrenHeight() @@ -336,7 +336,7 @@ private Flow createSourceSelector(BooleanSyncValue sourceSync) { return IDrawable.EMPTY; })) .value(new BooleanSyncValue(() -> !source, bool -> source = !bool))) - .child(IKey.lang("gtceu.creative.energy.sink").asWidget())); + .child(Text.lang("gtceu.creative.energy.sink").asWidget())); } private ModularPanel createAmpSelector(LongSyncValue voltage, IntSyncValue tier) { @@ -347,7 +347,7 @@ private ModularPanel createAmpSelector(LongSyncValue voltage, IntSyncValue ti .width(72) .height(104) .child(Flow.column() - .child(IKey.lang("gtceu.top.cable_voltage").asWidget().top(4).left(3)) + .child(Text.lang("gtceu.top.cable_voltage").asWidget().top(4).left(3)) .child(new Rectangle().color(0xFF555555).asWidget() .height(1).widthRel(0.80f).horizontalCenter().top(19)) .child(new ListWidget<>() @@ -357,8 +357,8 @@ private ModularPanel createAmpSelector(LongSyncValue voltage, IntSyncValue ti .crossAxisAlignment(Alignment.CrossAxis.CENTER) .children(GTValues.TIER_COUNT, v -> new ButtonWidget<>() .width(36) - .overlay(IKey.lang(Component.literal(GTValues.VNF[v]))) - .onMousePressed((x, y, b) -> { + .overlay(Text.str(GTValues.VNF[v])) + .onMousePressed((context, b) -> { voltage.setValue(GTValues.V[v]); tier.setValue(v); return true; diff --git a/src/main/java/com/gregtechceu/gtceu/common/machine/storage/CreativeTankMachine.java b/src/main/java/com/gregtechceu/gtceu/common/machine/storage/CreativeTankMachine.java index 77bfbc91aeb..2029de1c506 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/machine/storage/CreativeTankMachine.java +++ b/src/main/java/com/gregtechceu/gtceu/common/machine/storage/CreativeTankMachine.java @@ -19,7 +19,7 @@ import net.minecraftforge.fluids.FluidUtil; import net.minecraftforge.items.ItemHandlerHelper; -import brachy.modularui.api.drawable.IKey; +import brachy.modularui.api.drawable.Text; import brachy.modularui.drawable.Rectangle; import brachy.modularui.factory.PosGuiData; import brachy.modularui.screen.UISettings; @@ -142,7 +142,7 @@ public InteractionResult onUse(ExtendedUseOnContext context) { @Override public MachineUIPanelBuilder getPanelBuilder(PosGuiData data, PanelSyncManager syncManager, UISettings settings) { - return MachineUIPanelBuilder.defaultPanelBuilder(this).addDefaultConfigurators(false) + return MachineUIPanelBuilder.panelBuilder(this).addDefaultConfigurators(false) .addTraitConfigurators(false).rightConfigurators(f -> f.child(GTMuiWidgets.createPowerButton(this))); } @@ -165,7 +165,7 @@ public void buildMainUI(ParentWidget mainWidget, PosGuiData guiData, PanelSyn .padding(7) .mainAxisAlignment(Alignment.MainAxis.START) .child(Flow.row().coverChildrenHeight() - .child(IKey.lang("gtceu.creative.tank.fluid").asWidget() + .child(Text.lang("gtceu.creative.tank.fluid").asWidget() .marginRight(4) .verticalCenter()) .child(new FluidSlot().syncHandler("locked_fluid_slot", 0) @@ -174,7 +174,7 @@ public void buildMainUI(ParentWidget mainWidget, PosGuiData guiData, PanelSyn .height(1).widthRel(0.95f).marginBottom(4).marginTop(4)) .child(Flow.row() .height(18) - .child(IKey.lang("gtceu.creative.tank.mbpc").asWidget() + .child(Text.lang("gtceu.creative.tank.mbpc").asWidget() .marginRight(4) .width(80) .verticalCenter()) @@ -186,7 +186,7 @@ public void buildMainUI(ParentWidget mainWidget, PosGuiData guiData, PanelSyn .height(1).widthRel(0.95f).marginBottom(4).marginTop(4)) .child(Flow.row() .height(18) - .child(IKey.lang("gtceu.creative.tank.tpc").asWidget() + .child(Text.lang("gtceu.creative.tank.tpc").asWidget() .marginRight(4) .width(80) .verticalCenter()) diff --git a/src/main/java/com/gregtechceu/gtceu/common/machine/storage/QuantumChestMachine.java b/src/main/java/com/gregtechceu/gtceu/common/machine/storage/QuantumChestMachine.java index 35cfcde83a5..7319c2b3dc2 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/machine/storage/QuantumChestMachine.java +++ b/src/main/java/com/gregtechceu/gtceu/common/machine/storage/QuantumChestMachine.java @@ -19,6 +19,7 @@ import com.gregtechceu.gtceu.common.mui.GTMuiWidgets; import com.gregtechceu.gtceu.utils.*; +import net.minecraft.ChatFormatting; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; import net.minecraft.nbt.CompoundTag; @@ -33,7 +34,7 @@ import net.minecraftforge.items.IItemHandlerModifiable; import net.minecraftforge.items.ItemHandlerHelper; -import brachy.modularui.api.drawable.IKey; +import brachy.modularui.api.drawable.Text; import brachy.modularui.api.widget.IWidget; import brachy.modularui.drawable.UITexture; import brachy.modularui.factory.PosGuiData; @@ -261,14 +262,14 @@ public void buildMainUI(ParentWidget mainWidget, PosGuiData guiData, PanelSyn .background(GTGuiTextures.DISPLAY) .size(90, 63) .center() - .child(IKey.lang("gtceu.machine.quantum_chest.items_stored").asWidget() + .child(Text.lang("gtceu.machine.quantum_chest.items_stored").asWidget() .color(0xffffff) .margin(8, 0, 8, 0)) - .child(IKey.dynamic( + .child(Text.dynamic( () -> Component.literal( - FormattingUtil.formatNumbers(itemSyncer.getLongValue()))) + FormattingUtil.formatNumbers(itemSyncer.getLongValue())) + .withStyle(ChatFormatting.WHITE)) .asWidget() - .color(0xffffff) .margin(8, 0, 18, 0)) .child(Flow.row() .margin(4, 0, 41, 0) diff --git a/src/main/java/com/gregtechceu/gtceu/common/machine/storage/QuantumTankMachine.java b/src/main/java/com/gregtechceu/gtceu/common/machine/storage/QuantumTankMachine.java index ecac6a8f4f5..7c99648896a 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/machine/storage/QuantumTankMachine.java +++ b/src/main/java/com/gregtechceu/gtceu/common/machine/storage/QuantumTankMachine.java @@ -20,6 +20,7 @@ import com.gregtechceu.gtceu.utils.GTMath; import com.gregtechceu.gtceu.utils.GTTransferUtils; +import net.minecraft.ChatFormatting; import net.minecraft.core.Direction; import net.minecraft.nbt.CompoundTag; import net.minecraft.network.chat.Component; @@ -30,7 +31,7 @@ import net.minecraftforge.fluids.capability.IFluidHandler; import net.minecraftforge.items.IItemHandlerModifiable; -import brachy.modularui.api.drawable.IKey; +import brachy.modularui.api.drawable.Text; import brachy.modularui.api.widget.IWidget; import brachy.modularui.factory.PosGuiData; import brachy.modularui.screen.UISettings; @@ -216,14 +217,14 @@ public void buildMainUI(ParentWidget mainWidget, PosGuiData guiData, PanelSyn .background(GTGuiTextures.DISPLAY) .size(90, 63) .center() - .child(IKey.lang("gtceu.gui.fluid_amount").asWidget() + .child(Text.lang("gtceu.gui.fluid_amount").asWidget() .color(0xffffff) .margin(8, 0, 8, 0)) - .child(IKey.dynamic( + .child(Text.dynamic( () -> Component.literal( - FormattingUtil.formatBuckets(bucketSyncer.getLongValue()))) + FormattingUtil.formatBuckets(bucketSyncer.getLongValue())) + .withStyle(ChatFormatting.WHITE)) .asWidget() - .color(0xffffff) .margin(8, 0, 18, 0)) .child(Flow.row() .margin(4, 0, 41, 0) diff --git a/src/main/java/com/gregtechceu/gtceu/common/mui/GTGuiTextures.java b/src/main/java/com/gregtechceu/gtceu/common/mui/GTGuiTextures.java index 006273103ff..67c7724d4af 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/mui/GTGuiTextures.java +++ b/src/main/java/com/gregtechceu/gtceu/common/mui/GTGuiTextures.java @@ -9,51 +9,53 @@ import brachy.modularui.drawable.ColorType; import brachy.modularui.drawable.TabTexture; import brachy.modularui.drawable.UITexture; -import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.Nullable; @SuppressWarnings("unused") -public class GTGuiTextures { +@ApiStatus.NonExtendable +public interface GTGuiTextures { /** Keys used for GT assets registered for use in Themes */ - public static class IDs { + interface IDs { - public static final String STANDARD_BACKGROUND = "gregtech_standard_bg"; - public static final String STANDARD_BACKGROUND_INVERSE = "gregtech_standard_inverse_bg"; - public static final String COVER_BACKGROUND = "gregtech_cover_bg"; - public static final String BRONZE_BACKGROUND = "gregtech_bronze_bg"; - public static final String STEEL_BACKGROUND = "gregtech_steel_bg"; - public static final String PRIMITIVE_BACKGROUND = "gregtech_primitive_bg"; + String STANDARD_BACKGROUND = "gregtech_standard_bg"; + String STANDARD_BACKGROUND_INVERSE = "gregtech_standard_inverse_bg"; + String COVER_BACKGROUND = "gregtech_cover_bg"; + String BRONZE_BACKGROUND = "gregtech_bronze_bg"; + String STEEL_BACKGROUND = "gregtech_steel_bg"; + String PRIMITIVE_BACKGROUND = "gregtech_primitive_bg"; - public static final String STANDARD_SLOT = "gregtech_standard_slot"; - public static final String BRONZE_SLOT = "gregtech_bronze_slot"; - public static final String STEEL_SLOT = "gregtech_steel_slot"; - public static final String PRIMITIVE_SLOT = "gregtech_primitive_slot"; + String STANDARD_SLOT = "gregtech_standard_slot"; + String BRONZE_SLOT = "gregtech_bronze_slot"; + String STEEL_SLOT = "gregtech_steel_slot"; + String PRIMITIVE_SLOT = "gregtech_primitive_slot"; - public static final String STANDARD_FLUID_SLOT = "gregtech_standard_fluid_slot"; + String STANDARD_FLUID_SLOT = "gregtech_standard_fluid_slot"; - public static final String STANDARD_BUTTON = "gregtech_standard_button"; + String STANDARD_BUTTON = "gregtech_standard_button"; } - public static final ResourceLocation MONOCRAFT_FONT = GTCEu.id("monocraft"); + ResourceLocation MONOCRAFT_FONT = GTCEu.id("monocraft"); // ICONS /** @apiNote You may want {@link GTGuiTextures#getLogo} instead. */ - public static final UITexture GREGTECH_LOGO = fullImage("textures/gui/icon/gregtech_logo.png"); + UITexture GREGTECH_LOGO = fullImage("textures/gui/icon/gregtech_logo.png"); /** @apiNote You may want {@link GTGuiTextures#getLogo} instead. */ - 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"); + UITexture GREGTECH_LOGO_XMAS = fullImage("textures/gui/icon/gregtech_logo_xmas.png"); + UITexture GREGTECH_LOGO_DARK = fullImage("textures/gui/icon/gregtech_logo_dark.png"); // todo blinking GT logos - public static final UITexture INDICATOR_NO_ENERGY = fullImage("textures/gui/base/indicator_no_energy.png"); - public static final UITexture INDICATOR_NO_STEAM_BRONZE = fullImage( + UITexture INDICATOR_NO_ENERGY = fullImage("textures/gui/base/indicator_no_energy.png"); + UITexture INDICATOR_NO_STEAM_BRONZE = fullImage( "textures/gui/base/indicator_no_steam_bronze.png"); - public static final UITexture INDICATOR_NO_STEAM_STEEL = fullImage( + UITexture INDICATOR_NO_STEAM_STEEL = fullImage( "textures/gui/base/indicator_no_steam_steel.png"); - public static final UITexture TANK_ICON = fullImage("textures/gui/base/tank_icon.png"); + UITexture TANK_ICON = fullImage("textures/gui/base/tank_icon.png"); // BACKGROUNDS - public static final UITexture BACKGROUND = UITexture.builder() + UITexture BACKGROUND = UITexture.builder() .location(GTCEu.MOD_ID, "textures/gui/base/background.png") .imageSize(16, 16) .adaptable(4) @@ -61,7 +63,7 @@ public static class IDs { .defaultColorType() .build(); - public static final UITexture BACKGROUND_POPUP = UITexture.builder() + UITexture BACKGROUND_POPUP = UITexture.builder() .location(GTCEu.MOD_ID, "textures/gui/base/background_popup.png") .imageSize(195, 136) .adaptable(4) @@ -69,7 +71,7 @@ public static class IDs { .canApplyTheme() .build(); - public static final UITexture BACKGROUND_INVERSE = UITexture.builder() + UITexture BACKGROUND_INVERSE = UITexture.builder() .location(GTCEu.MOD_ID, "textures/gui/base/background_inverse.png") .imageSize(16, 16) .adaptable(3) @@ -77,24 +79,24 @@ public static class IDs { .canApplyTheme() .build(); - public static final UITexture BACKGROUND_BRONZE = UITexture.builder() + UITexture BACKGROUND_BRONZE = UITexture.builder() .location(GTCEu.MOD_ID, "textures/gui/base/background_bronze.png") .imageSize(16, 16) .adaptable(4) .name(IDs.BRONZE_BACKGROUND) .build(); - public static final UITexture BACKGROUND_STEEL = UITexture.builder() + UITexture BACKGROUND_STEEL = UITexture.builder() .location(GTCEu.MOD_ID, "textures/gui/base/background_steel.png") .imageSize(16, 16) .adaptable(4) .name(IDs.STEEL_BACKGROUND) .build(); - public static final UITexture BLANK_TRANSPARENT = fullImage("textures/gui/base/blank_transparent.png"); + UITexture BLANK_TRANSPARENT = fullImage("textures/gui/base/blank_transparent.png"); // todo move to textures/gui/base - public static final UITexture BACKGROUND_PRIMITIVE = UITexture.builder() + UITexture BACKGROUND_PRIMITIVE = UITexture.builder() .location(GTCEu.MOD_ID, "textures/gui/primitive/primitive_background.png") .imageSize(176, 166) .adaptable(3) @@ -104,18 +106,18 @@ public static class IDs { // todo clipboard backgrounds, may deserve some redoing // DISPLAYS - public static final UITexture DISPLAY = new UITexture.Builder() + UITexture DISPLAY = new UITexture.Builder() .location(GTCEu.MOD_ID, "textures/gui/base/display.png") .imageSize(182, 117) .canApplyTheme() .build(); - public static final UITexture DISPLAY_BRONZE = new UITexture.Builder() + UITexture DISPLAY_BRONZE = new UITexture.Builder() .location(GTCEu.MOD_ID, "textures/gui/base/display_bronze.png") .imageSize(162, 121) .build(); - public static final UITexture DISPLAY_STEEL = new UITexture.Builder() + UITexture DISPLAY_STEEL = new UITexture.Builder() .location(GTCEu.MOD_ID, "textures/gui/base/display_steel.png") .imageSize(162, 121) .adaptable(1) @@ -124,7 +126,7 @@ public static class IDs { // todo primitive display? // SLOTS - public static final UITexture SLOT = new UITexture.Builder() + UITexture SLOT = new UITexture.Builder() .location(GTCEu.MOD_ID, "textures/gui/base/slot.png") .imageSize(18, 18) .adaptable(1) @@ -132,14 +134,14 @@ public static class IDs { .canApplyTheme() .build(); - public static final UITexture SLOT_BRONZE = new UITexture.Builder() + UITexture SLOT_BRONZE = new UITexture.Builder() .location(GTCEu.MOD_ID, "textures/gui/base/slot_bronze.png") .imageSize(18, 18) .adaptable(1) .name(IDs.BRONZE_SLOT) .build(); - public static final UITexture SLOT_STEEL = new UITexture.Builder() + UITexture SLOT_STEEL = new UITexture.Builder() .location(GTCEu.MOD_ID, "textures/gui/base/slot_steel.png") .imageSize(18, 18) .adaptable(1) @@ -147,14 +149,14 @@ public static class IDs { .build(); // todo move to textures/gui/base - public static final UITexture SLOT_PRIMITIVE = new UITexture.Builder() + UITexture SLOT_PRIMITIVE = new UITexture.Builder() .location(GTCEu.MOD_ID, "textures/gui/primitive/primitive_slot.png") .imageSize(18, 18) .adaptable(1) .name(IDs.PRIMITIVE_SLOT) .build(); - public static final UITexture FLUID_SLOT = new UITexture.Builder() + UITexture FLUID_SLOT = new UITexture.Builder() .location(GTCEu.MOD_ID, "textures/gui/base/fluid_slot.png") .imageSize(18, 18) .adaptable(1) @@ -162,271 +164,271 @@ public static class IDs { .canApplyTheme() .build(); - public static final UITexture[] BUTTON_POWER = slice("textures/gui/widget/button_power.png", 16, 32, 16, 16, + UITexture[] BUTTON_POWER = slice("textures/gui/widget/button_power.png", 16, 32, 16, 16, ColorType.DEFAULT); - public static final UITexture BUTTON_BLACKLIST = fullImage("textures/gui/widget/button_blacklist.png", + UITexture BUTTON_BLACKLIST = fullImage("textures/gui/widget/button_blacklist.png", ColorType.DEFAULT); - public static final UITexture[] BUTTON_IGNORE_DAMAGE = slice("textures/gui/widget/button_filter_damage.png", + UITexture[] BUTTON_IGNORE_DAMAGE = slice("textures/gui/widget/button_filter_damage.png", 16, 32, 16, 16, ColorType.DEFAULT); - public static final UITexture BUTTON_IGNORE_NBT = fullImage("textures/gui/widget/button_filter_nbt.png", + UITexture BUTTON_IGNORE_NBT = fullImage("textures/gui/widget/button_filter_nbt.png", ColorType.DEFAULT); - public static final UITexture[] BUTTON_CASE_SENSITIVE = slice( + UITexture[] BUTTON_CASE_SENSITIVE = slice( "textures/gui/widget/ore_filter/button_case_sensitive.png", 16, 32, 16, 16, ColorType.DEFAULT); - public static final UITexture[] BUTTON_MATCH_ALL = slice("textures/gui/widget/ore_filter/button_match_all.png", + UITexture[] BUTTON_MATCH_ALL = slice("textures/gui/widget/ore_filter/button_match_all.png", 16, 32, 16, 16, ColorType.DEFAULT); - public static final UITexture BUTTON_LOCK = fullImage("textures/gui/widget/button_lock.png"); + UITexture BUTTON_LOCK = fullImage("textures/gui/widget/button_lock.png"); - public static final UITexture OREDICT_ERROR = fullImage("textures/gui/widget/ore_filter/error.png"); - public static final UITexture OREDICT_INFO = fullImage("textures/gui/widget/ore_filter/info.png"); - public static final UITexture OREDICT_MATCH = fullImage("textures/gui/widget/ore_filter/match.png"); - public static final UITexture OREDICT_NO_MATCH = fullImage("textures/gui/widget/ore_filter/no_match.png"); - public static final UITexture OREDICT_SUCCESS = fullImage("textures/gui/widget/ore_filter/success.png"); - public static final UITexture OREDICT_WAITING = fullImage("textures/gui/widget/ore_filter/waiting.png"); - public static final UITexture OREDICT_WARN = fullImage("textures/gui/widget/ore_filter/warn.png"); + UITexture OREDICT_ERROR = fullImage("textures/gui/widget/ore_filter/error.png"); + UITexture OREDICT_INFO = fullImage("textures/gui/widget/ore_filter/info.png"); + UITexture OREDICT_MATCH = fullImage("textures/gui/widget/ore_filter/match.png"); + UITexture OREDICT_NO_MATCH = fullImage("textures/gui/widget/ore_filter/no_match.png"); + UITexture OREDICT_SUCCESS = fullImage("textures/gui/widget/ore_filter/success.png"); + UITexture OREDICT_WAITING = fullImage("textures/gui/widget/ore_filter/waiting.png"); + UITexture OREDICT_WARN = fullImage("textures/gui/widget/ore_filter/warn.png"); - public static final UITexture INFO = fullImage("textures/gui/widget/information.png"); + UITexture INFO = fullImage("textures/gui/widget/information.png"); - public static final UITexture[] MANUAL_IO_OVERLAY_IN = { fullImage("textures/gui/icon/manual_io_mode/disabled.png"), + UITexture[] MANUAL_IO_OVERLAY_IN = { fullImage("textures/gui/icon/manual_io_mode/disabled.png"), fullImage("textures/gui/icon/manual_io_mode/filtered.png"), fullImage("textures/gui/icon/manual_io_mode/unfiltered.png") }; - public static final UITexture[] MANUAL_IO_OVERLAY_OUT = slice("textures/gui/overlay/manual_io_overlay_out.png", + UITexture[] MANUAL_IO_OVERLAY_OUT = slice("textures/gui/overlay/manual_io_overlay_out.png", 18, 18 * 3, 18, 18, ColorType.DEFAULT); - public static final UITexture[] CONVEYOR_MODE_OVERLAY = slice("textures/gui/overlay/conveyor_mode_overlay.png", + UITexture[] CONVEYOR_MODE_OVERLAY = slice("textures/gui/overlay/conveyor_mode_overlay.png", 18, 18 * 2, 18, 18, ColorType.DEFAULT); - public static final UITexture[] TRANSFER_MODE_OVERLAY = slice("textures/gui/overlay/transfer_mode_overlay.png", + UITexture[] TRANSFER_MODE_OVERLAY = slice("textures/gui/overlay/transfer_mode_overlay.png", 40, 40 * 3, 40, 40, ColorType.DEFAULT); - public static final UITexture[] BUTTON_DISTINCT = slice( + UITexture[] BUTTON_DISTINCT = slice( "textures/gui/widget/button_distinct_buses.png", 16, 32, 16, 16, ColorType.DEFAULT); - public static final UITexture[] FLUID_TRANSFER_MODE_OVERLAY = slice( + UITexture[] FLUID_TRANSFER_MODE_OVERLAY = slice( "textures/gui/overlay/fluid_transfer_mode_overlay.png", 18, 18 * 3, 18, 18, ColorType.DEFAULT); - public static final UITexture[] DISTRIBUTION_MODE_OVERLAY = slice( + UITexture[] DISTRIBUTION_MODE_OVERLAY = slice( "textures/gui/widget/button_distribution_mode.png", 16, 48, 16, 16, ColorType.DEFAULT); - public static final UITexture[] VOIDING_MODES = { fullImage("textures/gui/icon/voiding_mode/void_any.png"), + UITexture[] VOIDING_MODES = { fullImage("textures/gui/icon/voiding_mode/void_any.png"), fullImage("textures/gui/icon/voiding_mode/void_overflow.png") }; - public static final UITexture BUTTON_VOID = fullImage("textures/gui/widget/button_void.png"); + UITexture BUTTON_VOID = fullImage("textures/gui/widget/button_void.png"); - public static final UITexture BUTTON_VOID_PARTIAL = fullImage("textures/gui/widget/button_void_partial.png"); + UITexture BUTTON_VOID_PARTIAL = fullImage("textures/gui/widget/button_void_partial.png"); - public static final UITexture[] BUTTON_VOID_MULTIBLOCK = slice("textures/gui/widget/button_void_multiblock.png", + UITexture[] BUTTON_VOID_MULTIBLOCK = slice("textures/gui/widget/button_void_multiblock.png", 16, 48, 16, 16, ColorType.DEFAULT); - public static final UITexture[] FILTER_MODE_OVERLAY = slice( + UITexture[] FILTER_MODE_OVERLAY = slice( "textures/gui/overlay/filter_mode_overlay.png", 16, 48, 16, 16, ColorType.DEFAULT); - public static final UITexture[] PRIVATE_MODE_BUTTON = slice( + UITexture[] PRIVATE_MODE_BUTTON = slice( "textures/gui/widget/button_public_private.png", 18, 36, 18, 18, ColorType.DEFAULT); - public static final UITexture MENU_OVERLAY = fullImage("textures/gui/overlay/menu_overlay.png"); + UITexture MENU_OVERLAY = fullImage("textures/gui/overlay/menu_overlay.png"); - public static final UITexture RECIPE_LOCK = fullImage("textures/gui/widget/lock.png"); + UITexture RECIPE_LOCK = fullImage("textures/gui/widget/lock.png"); // todo bronze/steel/primitive fluid slots? // SLOT OVERLAYS - public static final UITexture ATOMIC_OVERLAY_1 = fullImage("textures/gui/overlay/atomic_overlay_1.png", + 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", + 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", + 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", + UITexture ARROW_OUTPUT_OVERLAY = fullImage("textures/gui/overlay/arrow_output_overlay.png", ColorType.DEFAULT); - public static final UITexture BATTERY_OVERLAY = fullImage("textures/gui/overlay/battery_overlay.png", + 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", + 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", + 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", + 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", + 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", + 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", + UITexture BOX_OVERLAY = fullImage("textures/gui/overlay/box_overlay.png", ColorType.DEFAULT); + 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", + 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", + 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", + 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", + UITexture CANISTER_OVERLAY = fullImage("textures/gui/overlay/canister_overlay.png", ColorType.DEFAULT); - public static final UITexture CANISTER_OVERLAY_BRONZE = fullImage( + 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", + UITexture CANISTER_OVERLAY_STEEL = fullImage("textures/gui/overlay/canister_overlay_steel.png"); + 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", + 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", + UITexture COAL_OVERLAY_BRONZE = fullImage("textures/gui/overlay/coal_overlay_bronze.png"); + UITexture COAL_OVERLAY_STEEL = fullImage("textures/gui/overlay/coal_overlay_steel.png"); + UITexture COMPRESSOR_OVERLAY = fullImage("textures/gui/overlay/compressor_overlay.png", ColorType.DEFAULT); - public static final UITexture COMPRESSOR_OVERLAY_BRONZE = fullImage( + UITexture COMPRESSOR_OVERLAY_BRONZE = fullImage( "textures/gui/overlay/compressor_overlay_bronze.png"); - public static final UITexture COMPRESSOR_OVERLAY_STEEL = fullImage( + 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", + 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", + 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", + UITexture CRUSHED_ORE_OVERLAY = fullImage("textures/gui/overlay/crushed_ore_overlay.png", ColorType.DEFAULT); - public static final UITexture CRUSHED_ORE_OVERLAY_BRONZE = fullImage( + UITexture CRUSHED_ORE_OVERLAY_BRONZE = fullImage( "textures/gui/overlay/crushed_ore_overlay_bronze.png"); - public static final UITexture CRUSHED_ORE_OVERLAY_STEEL = fullImage( + 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", + 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", + 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", + UITexture DARK_CANISTER_OVERLAY = fullImage("textures/gui/overlay/dark_canister_overlay.png", 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 PRIMITIVE_DUST_OVERLAY = fullImage( + UITexture DUST_OVERLAY = fullImage("textures/gui/overlay/dust_overlay.png", ColorType.DEFAULT); + UITexture DUST_OVERLAY_BRONZE = fullImage("textures/gui/overlay/dust_overlay_bronze.png"); + UITexture DUST_OVERLAY_STEEL = fullImage("textures/gui/overlay/dust_overlay_steel.png"); + UITexture PRIMITIVE_DUST_OVERLAY = fullImage( "textures/gui/primitive/overlay_primitive_dust.png", ColorType.DEFAULT); - public static final UITexture EXTRACTOR_OVERLAY = fullImage("textures/gui/overlay/extractor_overlay.png", + UITexture EXTRACTOR_OVERLAY = fullImage("textures/gui/overlay/extractor_overlay.png", ColorType.DEFAULT); - public static final UITexture EXTRACTOR_OVERLAY_BRONZE = fullImage( + UITexture EXTRACTOR_OVERLAY_BRONZE = fullImage( "textures/gui/overlay/extractor_overlay_bronze.png"); - public static final UITexture EXTRACTOR_OVERLAY_STEEL = fullImage( + 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", + UITexture FILTER_SLOT_OVERLAY = fullImage("textures/gui/overlay/filter_slot_overlay.png", ColorType.DEFAULT); - public static final UITexture FILTER_SETTINGS_OVERLAY = fullImage( + UITexture FILTER_SETTINGS_OVERLAY = fullImage( "textures/gui/overlay/filter_settings_overlay.png", ColorType.DEFAULT); - public static final UITexture FURNACE_OVERLAY_1 = fullImage("textures/gui/overlay/furnace_overlay_1.png", + 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", + 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 PRIMITIVE_FURNACE_OVERLAY = fullImage( + UITexture FURNACE_OVERLAY_BRONZE = fullImage("textures/gui/overlay/furnace_overlay_bronze.png"); + UITexture FURNACE_OVERLAY_STEEL = fullImage("textures/gui/overlay/furnace_overlay_steel.png"); + UITexture PRIMITIVE_FURNACE_OVERLAY = fullImage( "textures/gui/primitive/overlay_primitive_furnace.png", ColorType.DEFAULT); - public static final UITexture PRIMITIVE_LARGE_FLUID_TANK = fullImage( + UITexture PRIMITIVE_LARGE_FLUID_TANK = fullImage( "textures/gui/primitive/primitive_large_fluid_tank.png", ColorType.DEFAULT); - public static final UITexture PRIMITIVE_LARGE_FLUID_TANK_OVERLAY = fullImage( + UITexture PRIMITIVE_LARGE_FLUID_TANK_OVERLAY = fullImage( "textures/gui/primitive/primitive_large_fluid_tank_overlay.png", ColorType.DEFAULT); - public static final UITexture HAMMER_OVERLAY = fullImage("textures/gui/overlay/hammer_overlay.png", + 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", + UITexture HAMMER_OVERLAY_BRONZE = fullImage("textures/gui/overlay/hammer_overlay_bronze.png"); + UITexture HAMMER_OVERLAY_STEEL = fullImage("textures/gui/overlay/hammer_overlay_steel.png"); + 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", + 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", + 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", + 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", + 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", + UITexture IN_SLOT_OVERLAY_BRONZE = fullImage("textures/gui/overlay/in_slot_overlay_bronze.png"); + UITexture IN_SLOT_OVERLAY_STEEL = fullImage("textures/gui/overlay/in_slot_overlay_steel.png"); + UITexture INGOT_OVERLAY = fullImage("textures/gui/overlay/ingot_overlay.png", ColorType.DEFAULT); - public static final UITexture PRIMITIVE_INGOT_OVERLAY = fullImage( + UITexture PRIMITIVE_INGOT_OVERLAY = fullImage( "textures/gui/primitive/overlay_primitive_ingot.png", ColorType.DEFAULT); - public static final UITexture INT_CIRCUIT_OVERLAY = fullImage("textures/gui/overlay/int_circuit_overlay.png", + 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", + UITexture LENS_OVERLAY = fullImage("textures/gui/overlay/lens_overlay.png", ColorType.DEFAULT); + 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", + 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", + UITexture MOLD_OVERLAY = fullImage("textures/gui/overlay/mold_overlay.png", ColorType.DEFAULT); + 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", + 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", + 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", + 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", + UITexture OUT_SLOT_OVERLAY = fullImage("textures/gui/overlay/out_slot_overlay.png", ColorType.DEFAULT); - public static final UITexture OUT_SLOT_OVERLAY_BRONZE = fullImage( + 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", + UITexture OUT_SLOT_OVERLAY_STEEL = fullImage("textures/gui/overlay/out_slot_overlay_steel.png"); + UITexture PAPER_OVERLAY = fullImage("textures/gui/overlay/paper_overlay.png", ColorType.DEFAULT); - public static final UITexture PATTERN_OVERLAY = fullImage("textures/gui/widget/pattern_overlay.png", + UITexture PATTERN_OVERLAY = fullImage("textures/gui/widget/pattern_overlay.png", ColorType.DEFAULT); - public static final UITexture PRINTED_PAPER_OVERLAY = fullImage("textures/gui/overlay/printed_paper_overlay.png", + UITexture PRINTED_PAPER_OVERLAY = fullImage("textures/gui/overlay/printed_paper_overlay.png", ColorType.DEFAULT); - public static final UITexture PIPE_OVERLAY_2 = fullImage("textures/gui/overlay/pipe_overlay_2.png", + 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", + 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", + 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", + 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", + 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", + UITexture PRESS_OVERLAY_4 = fullImage("textures/gui/overlay/press_overlay_4.png", ColorType.DEFAULT); - public static final UITexture REFUND_OVERLAY = fullImage("textures/gui/widget/refund_overlay.png", + UITexture REFUND_OVERLAY = fullImage("textures/gui/widget/refund_overlay.png", ColorType.DEFAULT); - public static final UITexture SAWBLADE_OVERLAY = fullImage("textures/gui/overlay/sawblade_overlay.png", + 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", + 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", + 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", + 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", + 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", + 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", + 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", + UITexture WIREMILL_OVERLAY = fullImage("textures/gui/overlay/wiremill_overlay.png", ColorType.DEFAULT); - public static final UITexture POSITIVE_MATTER_OVERLAY = fullImage( + UITexture POSITIVE_MATTER_OVERLAY = fullImage( "textures/gui/overlay/positive_matter_overlay.png", ColorType.DEFAULT); - public static final UITexture NEUTRAL_MATTER_OVERLAY = fullImage("textures/gui/overlay/neutral_matter_overlay.png", + UITexture NEUTRAL_MATTER_OVERLAY = fullImage("textures/gui/overlay/neutral_matter_overlay.png", ColorType.DEFAULT); - public static final UITexture DATA_ORB_OVERLAY = fullImage("textures/gui/overlay/data_orb_overlay.png", + 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", + 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", + UITexture DUCT_TAPE_OVERLAY = fullImage("textures/gui/overlay/duct_tape_overlay.png", ColorType.DEFAULT); - public static final UITexture RESEARCH_STATION_OVERLAY = fullImage( + UITexture RESEARCH_STATION_OVERLAY = fullImage( "textures/gui/overlay/research_station_overlay.png", ColorType.DEFAULT); - public static final UITexture OVERLAY_REDSTONE_ON = fullImage("textures/gui/overlay/redstone_on.png"); - public static final UITexture OVERLAY_REDSTONE_OFF = fullImage("textures/gui/overlay/redstone_off.png"); + UITexture OVERLAY_REDSTONE_ON = fullImage("textures/gui/overlay/redstone_on.png"); + UITexture OVERLAY_REDSTONE_OFF = fullImage("textures/gui/overlay/redstone_off.png"); // BUTTONS - public static final UITexture BUTTON = new UITexture.Builder() + UITexture BUTTON = new UITexture.Builder() .location(GTCEu.MOD_ID, "textures/gui/widget/button.png") .imageSize(32, 32) .adaptable(2) @@ -436,260 +438,269 @@ public static class IDs { // BUTTON OVERLAYS - public static final UITexture BUTTON_ITEM_OUTPUT = fullImage("textures/gui/widget/button_item_output_overlay.png"); - public static final UITexture BUTTON_FLUID_OUTPUT = fullImage( + UITexture BUTTON_ITEM_OUTPUT = fullImage("textures/gui/widget/button_item_output_overlay.png"); + UITexture BUTTON_FLUID_OUTPUT = fullImage( "textures/gui/widget/button_fluid_output_overlay.png"); - public static final UITexture BUTTON_AUTO_COLLAPSE = fullImage( + 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", ColorType.DEFAULT); - public static final UITexture BUTTON_CLEAR_GRID = fullImage("textures/gui/widget/button_clear_grid.png", null); + UITexture BUTTON_X = fullImage("textures/gui/widget/button_x_overlay.png", ColorType.DEFAULT); + UITexture BUTTON_CLEAR_GRID = fullImage("textures/gui/widget/button_clear_grid.png", null); - public static final UITexture BUTTON_CROSS = fullImage("textures/gui/widget/button_clear_grid.png"); - public static final UITexture BUTTON_DETECTOR_INVERT = fullImage( + UITexture BUTTON_CROSS = fullImage("textures/gui/widget/button_clear_grid.png"); + UITexture BUTTON_DETECTOR_INVERT = fullImage( "textures/gui/widget/button_detector_cover_inverted.png"); - public static final UITexture BUTTON_REDSTONE_ON = fullImage("textures/gui/widget/button_redstone_on.png"); - public static final UITexture BUTTON_REDSTONE_OFF = fullImage("textures/gui/widget/button_redstone_off.png"); - public static final UITexture BUTTON_THROTTLE_PLUS = fullImage("textures/gui/widget/button_throttle_plus.png"); - public static final UITexture BUTTON_THROTTLE_MINUS = fullImage("textures/gui/widget/button_throttle_minus.png"); - public static final UITexture BUTTON_EU = fullImage("textures/gui/overlay/mode_eu.png"); - public static final UITexture BUTTON_PERCENT = fullImage("textures/gui/overlay/mode_percent.png"); - public static final UITexture BUTTON_MAINTENANCE = fullImage("textures/gui/widget/button_maintenance.png"); + UITexture BUTTON_REDSTONE_ON = fullImage("textures/gui/widget/button_redstone_on.png"); + UITexture BUTTON_REDSTONE_OFF = fullImage("textures/gui/widget/button_redstone_off.png"); + UITexture BUTTON_THROTTLE_PLUS = fullImage("textures/gui/widget/button_throttle_plus.png"); + UITexture BUTTON_THROTTLE_MINUS = fullImage("textures/gui/widget/button_throttle_minus.png"); + UITexture BUTTON_EU = fullImage("textures/gui/overlay/mode_eu.png"); + UITexture BUTTON_PERCENT = fullImage("textures/gui/overlay/mode_percent.png"); + UITexture BUTTON_MAINTENANCE = fullImage("textures/gui/widget/button_maintenance.png"); - public static final UITexture BUTTON_AUTO_PULL = fullImage("textures/gui/widget/button_me_auto_pull.png"); + UITexture BUTTON_AUTO_PULL = fullImage("textures/gui/widget/button_me_auto_pull.png"); // PROGRESS BARS - public static final UITexture PROGRESS_BAR_ARC_FURNACE = progressBar( + UITexture PROGRESS_BAR_ARC_FURNACE = progressBar( "textures/gui/progress_bar/progress_bar_arc_furnace.png", ColorType.DEFAULT); - public static final UITexture PRIMITIVE_BLAST_FURNACE_PROGRESS_BAR = progressBar( + UITexture PRIMITIVE_BLAST_FURNACE_PROGRESS_BAR = progressBar( "textures/gui/primitive/progress_bar_primitive_blast_furnace.png", ColorType.DEFAULT); - public static final UITexture PROGRESS_BAR_ARROW = progressBar("textures/gui/progress_bar/progress_bar_arrow.png", + UITexture PROGRESS_BAR_ARROW = progressBar("textures/gui/progress_bar/progress_bar_arrow.png", ColorType.DEFAULT); - public static final UITexture PROGRESS_BAR_ARROW_BRONZE = progressBar( + UITexture PROGRESS_BAR_ARROW_BRONZE = progressBar( "textures/gui/progress_bar/progress_bar_arrow_bronze.png"); - public static final UITexture PROGRESS_BAR_ARROW_STEEL = progressBar( + UITexture PROGRESS_BAR_ARROW_STEEL = progressBar( "textures/gui/progress_bar/progress_bar_arrow_steel.png"); - public static final UITexture PROGRESS_BAR_ARROW_MULTIPLE = progressBar( + UITexture PROGRESS_BAR_ARROW_MULTIPLE = progressBar( "textures/gui/progress_bar/progress_bar_arrow_multiple.png", ColorType.DEFAULT); - public static final UITexture PROGRESS_BAR_ASSEMBLER = progressBar( + UITexture PROGRESS_BAR_ASSEMBLER = progressBar( "textures/gui/progress_bar/progress_bar_assembler.png", ColorType.DEFAULT); - public static final UITexture PROGRESS_BAR_BATH = progressBar("textures/gui/progress_bar/progress_bar_bath.png", + UITexture PROGRESS_BAR_BATH = progressBar("textures/gui/progress_bar/progress_bar_bath.png", ColorType.DEFAULT); - public static final UITexture PROGRESS_BAR_BENDING = progressBar( + UITexture PROGRESS_BAR_BENDING = progressBar( "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", + UITexture PROGRESS_BAR_CANNER = progressBar("textures/gui/progress_bar/progress_bar_canner.png", ColorType.DEFAULT); - public static final UITexture PROGRESS_BAR_CIRCUIT = progressBar( + UITexture PROGRESS_BAR_CIRCUIT = progressBar( "textures/gui/progress_bar/progress_bar_circuit.png", ColorType.DEFAULT); - public static final UITexture PROGRESS_BAR_CIRCUIT_ASSEMBLER = progressBar( + UITexture PROGRESS_BAR_CIRCUIT_ASSEMBLER = progressBar( "textures/gui/progress_bar/progress_bar_circuit_assembler.png", ColorType.DEFAULT); - public static final UITexture PROGRESS_BAR_COMPRESS = progressBar( + UITexture PROGRESS_BAR_COMPRESS = progressBar( "textures/gui/progress_bar/progress_bar_compress.png", ColorType.DEFAULT); - public static final UITexture PROGRESS_BAR_COMPRESS_BRONZE = progressBar( + UITexture PROGRESS_BAR_COMPRESS_BRONZE = progressBar( "textures/gui/progress_bar/progress_bar_compress_bronze.png"); - public static final UITexture PROGRESS_BAR_COMPRESS_STEEL = progressBar( + UITexture PROGRESS_BAR_COMPRESS_STEEL = progressBar( "textures/gui/progress_bar/progress_bar_compress_steel.png"); - public static final UITexture PROGRESS_BAR_CRACKING = progressBar( + UITexture PROGRESS_BAR_CRACKING = progressBar( "textures/gui/progress_bar/progress_bar_cracking.png", ColorType.DEFAULT); - public static final UITexture PROGRESS_BAR_CRACKING_INPUT = progressBar( + UITexture PROGRESS_BAR_CRACKING_INPUT = progressBar( "textures/gui/progress_bar/progress_bar_cracking_2.png", 21, 38, ColorType.DEFAULT); - public static final UITexture PROGRESS_BAR_CRYSTALLIZATION = progressBar( + UITexture PROGRESS_BAR_CRYSTALLIZATION = progressBar( "textures/gui/progress_bar/progress_bar_crystallization.png", ColorType.DEFAULT); - public static final UITexture PROGRESS_BAR_EXTRACT = progressBar( + UITexture PROGRESS_BAR_EXTRACT = progressBar( "textures/gui/progress_bar/progress_bar_extract.png", ColorType.DEFAULT); - public static final UITexture PROGRESS_BAR_EXTRACT_BRONZE = progressBar( + UITexture PROGRESS_BAR_EXTRACT_BRONZE = progressBar( "textures/gui/progress_bar/progress_bar_extract_bronze.png"); - public static final UITexture PROGRESS_BAR_EXTRACT_STEEL = progressBar( + UITexture PROGRESS_BAR_EXTRACT_STEEL = progressBar( "textures/gui/progress_bar/progress_bar_extract_steel.png"); - public static final UITexture PROGRESS_BAR_EXTRUDER = progressBar( + UITexture PROGRESS_BAR_EXTRUDER = progressBar( "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", + UITexture PROGRESS_BAR_FUSION = progressBar("textures/gui/progress_bar/progress_bar_fusion.png", ColorType.DEFAULT); - public static final UITexture PROGRESS_BAR_GAS_COLLECTOR = progressBar( + UITexture PROGRESS_BAR_GAS_COLLECTOR = progressBar( "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", + UITexture PROGRESS_BAR_HAMMER = progressBar("textures/gui/progress_bar/progress_bar_hammer.png", ColorType.DEFAULT); - public static final UITexture PROGRESS_BAR_HAMMER_BRONZE = progressBar( + UITexture PROGRESS_BAR_HAMMER_BRONZE = progressBar( "textures/gui/progress_bar/progress_bar_hammer_bronze.png"); - public static final UITexture PROGRESS_BAR_HAMMER_STEEL = progressBar( + UITexture PROGRESS_BAR_HAMMER_STEEL = progressBar( "textures/gui/progress_bar/progress_bar_hammer_steel.png"); - public static final UITexture PROGRESS_BAR_HAMMER_BASE = fullImage( + UITexture PROGRESS_BAR_HAMMER_BASE = fullImage( "textures/gui/progress_bar/progress_bar_hammer_base.png", ColorType.DEFAULT); - public static final UITexture PROGRESS_BAR_HAMMER_BASE_BRONZE = fullImage( + 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( + 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", + UITexture PROGRESS_BAR_LATHE = progressBar("textures/gui/progress_bar/progress_bar_lathe.png", ColorType.DEFAULT); - public static final UITexture PROGRESS_BAR_LATHE_BASE = fullImage( + UITexture PROGRESS_BAR_LATHE_BASE = fullImage( "textures/gui/progress_bar/progress_bar_lathe_base.png", ColorType.DEFAULT); - public static final UITexture PROGRESS_BAR_MACERATE = progressBar( + UITexture PROGRESS_BAR_MACERATE = progressBar( "textures/gui/progress_bar/progress_bar_macerate.png", ColorType.DEFAULT); - public static final UITexture PROGRESS_BAR_MACERATE_BRONZE = progressBar( + UITexture PROGRESS_BAR_MACERATE_BRONZE = progressBar( "textures/gui/progress_bar/progress_bar_macerate_bronze.png"); - public static final UITexture PROGRESS_BAR_MACERATE_STEEL = progressBar( + 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", + UITexture PROGRESS_BAR_MAGNET = progressBar("textures/gui/progress_bar/progress_bar_magnet.png", ColorType.DEFAULT); - public static final UITexture PROGRESS_BAR_MASS_FAB = progressBar( + UITexture PROGRESS_BAR_MASS_FAB = progressBar( "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", + UITexture PROGRESS_BAR_MIXER = progressBar("textures/gui/progress_bar/progress_bar_mixer.png", ColorType.DEFAULT); - public static final UITexture PROGRESS_BAR_PACKER = progressBar("textures/gui/progress_bar/progress_bar_packer.png", + UITexture PROGRESS_BAR_PACKER = progressBar("textures/gui/progress_bar/progress_bar_packer.png", ColorType.DEFAULT); - public static final UITexture PROGRESS_BAR_RECYCLER = progressBar( + UITexture PROGRESS_BAR_RECYCLER = progressBar( "textures/gui/progress_bar/progress_bar_recycler.png", ColorType.DEFAULT); - public static final UITexture PROGRESS_BAR_REPLICATOR = progressBar( + UITexture PROGRESS_BAR_REPLICATOR = progressBar( "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", + UITexture PROGRESS_BAR_SIFT = progressBar("textures/gui/progress_bar/progress_bar_sift.png", ColorType.DEFAULT); - public static final UITexture PROGRESS_BAR_SLICE = progressBar("textures/gui/progress_bar/progress_bar_slice.png", + UITexture PROGRESS_BAR_SLICE = progressBar("textures/gui/progress_bar/progress_bar_slice.png", ColorType.DEFAULT); - public static final UITexture PROGRESS_BAR_UNPACKER = progressBar( + UITexture PROGRESS_BAR_UNPACKER = progressBar( "textures/gui/progress_bar/progress_bar_unpacker.png", ColorType.DEFAULT); - public static final UITexture PROGRESS_BAR_WIREMILL = progressBar( + UITexture PROGRESS_BAR_WIREMILL = progressBar( "textures/gui/progress_bar/progress_bar_wiremill.png", ColorType.DEFAULT); // more custom progress bars // todo these boiler empty bars can probably be replaced by using a resized steam slot texture - public static final UITexture PROGRESS_BAR_BOILER_EMPTY_BRONZE = new UITexture.Builder() + UITexture PROGRESS_BAR_BOILER_EMPTY_BRONZE = new UITexture.Builder() .location(GTCEu.MOD_ID, "textures/gui/progress_bar/progress_bar_boiler_empty_bronze.png") .imageSize(10, 54) .adaptable(1) .build(); - public static final UITexture PROGRESS_BAR_BOILER_EMPTY_STEEL = new UITexture.Builder() + UITexture PROGRESS_BAR_BOILER_EMPTY_STEEL = new UITexture.Builder() .location(GTCEu.MOD_ID, "textures/gui/progress_bar/progress_bar_boiler_empty_steel.png") .imageSize(10, 54) .adaptable(1) .build(); - public static final UITexture PROGRESS_BAR_BOILER_FUEL_BRONZE = progressBar( + UITexture PROGRESS_BAR_BOILER_FUEL_BRONZE = progressBar( "textures/gui/progress_bar/progress_bar_boiler_fuel_bronze.png", 18, 36); - public static final UITexture PROGRESS_BAR_BOILER_FUEL_STEEL = progressBar( + UITexture PROGRESS_BAR_BOILER_FUEL_STEEL = progressBar( "textures/gui/progress_bar/progress_bar_boiler_fuel_steel.png", 18, 36); - public static final UITexture PROGRESS_BAR_BOILER_HEAT = progressBar( + UITexture PROGRESS_BAR_BOILER_HEAT = progressBar( "textures/gui/progress_bar/progress_bar_boiler_heat.png", ColorType.DEFAULT); - public static final UITexture PROGRESS_BAR_ASSEMBLY_LINE = progressBar( + UITexture PROGRESS_BAR_ASSEMBLY_LINE = progressBar( "textures/gui/progress_bar/progress_bar_assembly_line.png", 54, 144, ColorType.DEFAULT); - public static final UITexture PROGRESS_BAR_ASSEMBLY_LINE_ARROW = progressBar( + UITexture PROGRESS_BAR_ASSEMBLY_LINE_ARROW = progressBar( "textures/gui/progress_bar/progress_bar_assembly_line_arrow.png", 10, 36, ColorType.DEFAULT); - public static final UITexture PROGRESS_BAR_COKE_OVEN = progressBar( + UITexture PROGRESS_BAR_COKE_OVEN = progressBar( "textures/gui/progress_bar/progress_bar_coke_oven.png", 36, 36, ColorType.DEFAULT); - public static final UITexture PROGRESS_BAR_DISTILLATION_TOWER = progressBar( + UITexture PROGRESS_BAR_DISTILLATION_TOWER = progressBar( "textures/gui/progress_bar/progress_bar_distillation_tower.png", 66, 116, ColorType.DEFAULT); - public static final UITexture PROGRESS_BAR_SOLAR_BRONZE = progressBar( + UITexture PROGRESS_BAR_SOLAR_BRONZE = progressBar( "textures/gui/progress_bar/progress_bar_solar_bronze.png", 10, 20); - public static final UITexture PROGRESS_BAR_SOLAR_STEEL = progressBar( + UITexture PROGRESS_BAR_SOLAR_STEEL = progressBar( "textures/gui/progress_bar/progress_bar_solar_steel.png", 10, 20); - public static final UITexture PROGRESS_BAR_RESEARCH_STATION_1 = progressBar( + UITexture PROGRESS_BAR_RESEARCH_STATION_1 = progressBar( "textures/gui/progress_bar/progress_bar_research_station_1.png", 54, 10, ColorType.DEFAULT); - public static final UITexture PROGRESS_BAR_RESEARCH_STATION_2 = progressBar( + UITexture PROGRESS_BAR_RESEARCH_STATION_2 = progressBar( "textures/gui/progress_bar/progress_bar_research_station_2.png", 10, 36, ColorType.DEFAULT); - public static final UITexture PROGRESS_BAR_RESEARCH_STATION_BASE = fullImage( + UITexture PROGRESS_BAR_RESEARCH_STATION_BASE = fullImage( "textures/gui/progress_bar/progress_bar_research_station_base.png", ColorType.DEFAULT); - public static final UITexture PROGRESS_BAR_FUSION_ENERGY = progressBar( + UITexture PROGRESS_BAR_FUSION_ENERGY = progressBar( "textures/gui/progress_bar/progress_bar_fusion_energy.png", 94, 14); - public static final UITexture PROGRESS_BAR_FUSION_HEAT = progressBar( + UITexture PROGRESS_BAR_FUSION_HEAT = progressBar( "textures/gui/progress_bar/progress_bar_fusion_heat.png", 94, 14); - public static final UITexture PROGRESS_BAR_MULTI_ENERGY_YELLOW = progressBar( + UITexture PROGRESS_BAR_MULTI_ENERGY_YELLOW = progressBar( "textures/gui/progress_bar/progress_bar_multi_energy_yellow.png", 190, 14); - public static final UITexture PROGRESS_BAR_HPCA_COMPUTATION = progressBar( + UITexture PROGRESS_BAR_HPCA_COMPUTATION = progressBar( "textures/gui/progress_bar/progress_bar_hpca_computation.png", 94, 14); - public static final UITexture PROGRESS_BAR_LCE_FUEL = progressBar( + UITexture PROGRESS_BAR_LCE_FUEL = progressBar( "textures/gui/progress_bar/progress_bar_lce_fuel.png", 62, 14); - public static final UITexture PROGRESS_BAR_LCE_LUBRICANT = progressBar( + UITexture PROGRESS_BAR_LCE_LUBRICANT = progressBar( "textures/gui/progress_bar/progress_bar_lce_lubricant.png", 62, 14); - public static final UITexture PROGRESS_BAR_LCE_OXYGEN = progressBar( + UITexture PROGRESS_BAR_LCE_OXYGEN = progressBar( "textures/gui/progress_bar/progress_bar_lce_oxygen.png", 62, 14); - public static final UITexture PROGRESS_BAR_TURBINE_ROTOR_SPEED = progressBar( + UITexture PROGRESS_BAR_TURBINE_ROTOR_SPEED = progressBar( "textures/gui/progress_bar/progress_bar_turbine_rotor_speed.png", 62, 14); - public static final UITexture PROGRESS_BAR_TURBINE_ROTOR_DURABILITY = progressBar( + UITexture PROGRESS_BAR_TURBINE_ROTOR_DURABILITY = progressBar( "textures/gui/progress_bar/progress_bar_turbine_rotor_durability.png", 62, 14); - public static final UITexture PROGRESS_BAR_FLUID_RIG_DEPLETION = progressBar( + UITexture PROGRESS_BAR_FLUID_RIG_DEPLETION = progressBar( "textures/gui/progress_bar/progress_bar_fluid_rig_depletion.png", 190, 14); - public static final UITexture CYCLE_BUTTON = UITexture.builder() + UITexture CYCLE_BUTTON = UITexture.builder() .location(GTCEu.MOD_ID, "textures/gui/widget/button_distribution_mode.png") .imageSize(20, 60) .name("cycle") .build(); // 16, 48, 16, 16, true); - public static final TabTexture TAB_TOP = TabTexture.of( + TabTexture TAB_TOP = TabTexture.of( fullImage("textures/gui/tab/tabs_top.png", ColorType.DEFAULT), GuiAxis.Y, false, 28, 32, 4); - public static final UITexture MONITOR = UITexture.fullImage(GTCEu.MOD_ID, "item/computer_monitor_cover"); - public static final UITexture DATA_HATCH = UITexture.fullImage(GTCEu.MOD_ID, "textures/item/data_module.png") + UITexture MONITOR = UITexture.fullImage(GTCEu.MOD_ID, "item/computer_monitor_cover"); + UITexture DATA_HATCH = UITexture.fullImage(GTCEu.MOD_ID, "textures/item/data_module.png") .getSubArea(0, 0, 1, 1 / 13f); - public static final UITexture SEPERATOR_SIMPLE = UITexture.builder() + UITexture SEPERATOR_SIMPLE = UITexture.builder() .location(GTCEu.MOD_ID, "textures/gui/icon/seperator/seperator_simple.png") .imageSize(16, 5) .adaptable(2) .build(); // HPCA - public static final UITexture HPCA_COMPUTATION_COMPONENT = fullImage( + UITexture HPCA_COMPUTATION_COMPONENT = fullImage( "textures/gui/widget/hpca/computation_component.png"); - public static final UITexture HPCA_ADVANCED_COMPUTATION_COMPONENT = fullImage( + UITexture HPCA_ADVANCED_COMPUTATION_COMPONENT = fullImage( "textures/gui/widget/hpca/advanced_computation_component.png"); - public static final UITexture HPCA_DAMAGED_COMPUTATION_COMPONENT = fullImage( + UITexture HPCA_DAMAGED_COMPUTATION_COMPONENT = fullImage( "textures/gui/widget/hpca/damaged_computation_component.png"); - public static final UITexture HPCA_DAMAGED_ADVANCED_COMPUTATION_COMPONENT = fullImage( + UITexture HPCA_DAMAGED_ADVANCED_COMPUTATION_COMPONENT = fullImage( "textures/gui/widget/hpca/damaged_advanced_computation_component.png"); - public static final UITexture HPCA_ACTIVE_COOLER_COMPONENT = fullImage( + UITexture HPCA_ACTIVE_COOLER_COMPONENT = fullImage( "textures/gui/widget/hpca/active_cooler_component.png"); - public static final UITexture HPCA_HEAT_SINK_COMPONENT = fullImage( + UITexture HPCA_HEAT_SINK_COMPONENT = fullImage( "textures/gui/widget/hpca/heat_sink_component.png"); - public static final UITexture HPCA_EMPTY_COMPONENT = fullImage("textures/gui/widget/hpca/empty.png"); - public static final UITexture HPCA_BRIDGE_COMPONENT = fullImage("textures/gui/widget/hpca/bridge_component.png"); - public static final UITexture HPCA_COMPONENT_OUTLINE = fullImage("textures/gui/widget/hpca/component_outline.png"); + UITexture HPCA_EMPTY_COMPONENT = fullImage("textures/gui/widget/hpca/empty.png"); + UITexture HPCA_BRIDGE_COMPONENT = fullImage("textures/gui/widget/hpca/bridge_component.png"); + UITexture HPCA_COMPONENT_OUTLINE = fullImage("textures/gui/widget/hpca/component_outline.png"); // MACHINE GRID OVERLAYS - public static final UITexture TOOL_FRONT_FACING_ROTATION = fullImage( + UITexture TOOL_FRONT_FACING_ROTATION = fullImage( "textures/gui/overlay/tool_front_facing_rotation.png"); - public static final UITexture TOOL_IO_FACING_ROTATION = fullImage( + UITexture TOOL_IO_FACING_ROTATION = fullImage( "textures/gui/overlay/tool_io_facing_rotation.png"); - public static final UITexture TOOL_PAUSE = fullImage("textures/gui/overlay/tool_pause.png"); - public static final UITexture TOOL_START = fullImage("textures/gui/overlay/tool_start.png"); - public static final UITexture TOOL_COVER_SETTINGS = fullImage( + UITexture TOOL_PAUSE = fullImage("textures/gui/overlay/tool_pause.png"); + UITexture TOOL_START = fullImage("textures/gui/overlay/tool_start.png"); + UITexture TOOL_COVER_SETTINGS = fullImage( "textures/gui/overlay/tool_cover_settings.png"); - public static final UITexture TOOL_MUTE = fullImage("textures/gui/overlay/tool_mute.png"); - public static final UITexture TOOL_SOUND = fullImage("textures/gui/overlay/tool_sound.png"); - public static final UITexture TOOL_ALLOW_INPUT = fullImage( + UITexture TOOL_MUTE = fullImage("textures/gui/overlay/tool_mute.png"); + UITexture TOOL_SOUND = fullImage("textures/gui/overlay/tool_sound.png"); + UITexture TOOL_ALLOW_INPUT = fullImage( "textures/gui/overlay/tool_allow_input.png"); - public static final UITexture TOOL_ATTACH_COVER = fullImage( + UITexture TOOL_ATTACH_COVER = fullImage( "textures/gui/overlay/tool_attach_cover.png"); - public static final UITexture TOOL_REMOVE_COVER = fullImage( + UITexture TOOL_REMOVE_COVER = fullImage( "textures/gui/overlay/tool_remove_cover.png"); - public static final UITexture TOOL_PIPE_BLOCK = fullImage( + UITexture TOOL_PIPE_BLOCK = fullImage( "textures/gui/overlay/tool_pipe_block.png"); - public static final UITexture TOOL_PIPE_CONNECT = fullImage( + UITexture TOOL_PIPE_CONNECT = fullImage( "textures/gui/overlay/tool_pipe_connect.png"); - public static final UITexture TOOL_WIRE_BLOCK = fullImage( + UITexture TOOL_WIRE_BLOCK = fullImage( "textures/gui/overlay/tool_wire_block.png"); - public static final UITexture TOOL_WIRE_CONNECT = fullImage( + UITexture TOOL_WIRE_CONNECT = fullImage( "textures/gui/overlay/tool_wire_connect.png"); - public static final UITexture TOOL_AUTO_OUTPUT = fullImage( + UITexture TOOL_AUTO_OUTPUT = fullImage( "textures/gui/overlay/tool_auto_output.png"); - public static final UITexture TOOL_DISABLE_AUTO_OUTPUT = fullImage( + UITexture TOOL_DISABLE_AUTO_OUTPUT = fullImage( "textures/gui/overlay/tool_disable_auto_output.png"); - public static final UITexture TOOL_SWITCH_CONVERTER_NATIVE = fullImage( + UITexture TOOL_SWITCH_CONVERTER_NATIVE = fullImage( "textures/gui/overlay/tool_wire_block.png"); - public static final UITexture TOOL_SWITCH_CONVERTER_EU = fullImage( + UITexture TOOL_SWITCH_CONVERTER_EU = fullImage( "textures/gui/overlay/tool_wire_connect.png"); + // Ore processing + + // ORE PROCESSING + UITexture OREBY_BASE = fullImage("textures/gui/arrows/oreby-base.png"); + UITexture OREBY_CHEM = fullImage("textures/gui/arrows/oreby-chem.png"); + UITexture OREBY_SEP = fullImage("textures/gui/arrows/oreby-sep.png"); + UITexture OREBY_SIFT = fullImage("textures/gui/arrows/oreby-sift.png"); + UITexture OREBY_SMELT = fullImage("textures/gui/arrows/oreby-smelt.png"); + // MISC - public static void init() {/**/} + static void init() {/**/} private static UITexture fullImage(String path) { return fullImage(path, null); } - private static UITexture fullImage(String path, ColorType colorType) { + private static UITexture fullImage(String path, @Nullable ColorType colorType) { return UITexture.fullImage(GTCEu.MOD_ID, path, colorType); } @@ -720,7 +731,7 @@ private static UITexture progressBar(String path) { return progressBar(path, null); } - private static UITexture progressBar(String path, ColorType colorType) { + private static UITexture progressBar(String path, @Nullable ColorType colorType) { return progressBar(path, 20, 40, colorType); } @@ -728,7 +739,7 @@ private static UITexture progressBar(String path, int width, int height) { return progressBar(path, width, height, null); } - private static UITexture progressBar(String path, int width, int height, ColorType colorType) { + private static UITexture progressBar(String path, int width, int height, @Nullable ColorType colorType) { UITexture.Builder builder = new UITexture.Builder() .location(GTCEu.MOD_ID, path) .imageSize(width, height) @@ -737,7 +748,7 @@ private static UITexture progressBar(String path, int width, int height, ColorTy } // todo steam logos? multi indicator blinking logos? - public static @NotNull UITexture getLogo(GTGuiTheme theme) { + static UITexture getLogo(@Nullable GTGuiTheme theme) { if (theme != null) { UITexture logo = theme.getLogo(); if (logo != null) return logo; diff --git a/src/main/java/com/gregtechceu/gtceu/common/mui/GTMuiRecipeTypes.java b/src/main/java/com/gregtechceu/gtceu/common/mui/GTMuiRecipeTypes.java deleted file mode 100644 index 58ec5af2045..00000000000 --- a/src/main/java/com/gregtechceu/gtceu/common/mui/GTMuiRecipeTypes.java +++ /dev/null @@ -1,5 +0,0 @@ -package com.gregtechceu.gtceu.common.mui; - -public class GTMuiRecipeTypes { - -} diff --git a/src/main/java/com/gregtechceu/gtceu/common/mui/GTMuiWidgets.java b/src/main/java/com/gregtechceu/gtceu/common/mui/GTMuiWidgets.java index 80b3188b426..39044c26e92 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/mui/GTMuiWidgets.java +++ b/src/main/java/com/gregtechceu/gtceu/common/mui/GTMuiWidgets.java @@ -1,6 +1,5 @@ package com.gregtechceu.gtceu.common.mui; -import com.gregtechceu.gtceu.api.GTValues; import com.gregtechceu.gtceu.api.capability.IControllable; import com.gregtechceu.gtceu.api.capability.recipe.IO; import com.gregtechceu.gtceu.api.cover.filter.Filter; @@ -26,7 +25,7 @@ import brachy.modularui.api.IPanelHandler; import brachy.modularui.api.drawable.IDrawable; -import brachy.modularui.api.drawable.IKey; +import brachy.modularui.api.drawable.Text; import brachy.modularui.drawable.*; import brachy.modularui.drawable.text.TextRenderer; import brachy.modularui.factory.SidedPosGuiData; @@ -49,6 +48,7 @@ import brachy.modularui.widgets.textfield.TextFieldWidget; import com.mojang.blaze3d.platform.InputConstants; import it.unimi.dsi.fastutil.booleans.BooleanConsumer; +import org.jetbrains.annotations.Nullable; import java.util.function.*; @@ -84,7 +84,7 @@ public static Flow createTitleBar(Icon icon, String text, int panelWidth, UIText int textTitleWidth = TextRenderer.getFont().width(text); int textRows = (int) Math.ceil((double) textTitleWidth / minPanelWidth); - int textHeightPerRow = (int) (IKey.renderer.getFontHeight()); + int textHeightPerRow = (int) (Text.renderer.getFontHeight()); int textHeight = textHeightPerRow * textRows + borderRadius; int rowWidth = Math.min((int) (0.9 * panelWidth), (iconSize + (borderRadius * 4) + textTitleWidth)); @@ -100,7 +100,7 @@ public static Flow createTitleBar(Icon icon, String text, int panelWidth, UIText .child(icon.size(iconSize) .asWidget() .marginLeft(borderRadius)) - .child(IKey.str(text) + .child(Text.str(text) .asWidget() .margin(borderRadius, borderRadius, borderRadius, 1) .size(Math.min(minPanelWidth, textTitleWidth), textHeight)); @@ -114,7 +114,7 @@ public static ToggleButton createToggleButton(BooleanSupplier getter, BooleanCon .overlay(texture) .tooltipAutoUpdate(true) .tooltipBuilder( - (r) -> r.addLine(IKey.lang(langKey + (value.getBoolValue() ? ".enabled" : ".disabled")))); + (r) -> r.addLine(Text.lang(langKey + (value.getBoolValue() ? ".enabled" : ".disabled")))); } public static ToggleButton createToggleButton(BooleanSupplier getter, BooleanConsumer setter, UITexture background, @@ -126,7 +126,7 @@ public static ToggleButton createToggleButton(BooleanSupplier getter, BooleanCon .background(background) .tooltipAutoUpdate(true) .tooltipBuilder( - (r) -> r.addLine(IKey.lang(langKey + (value.getBoolValue() ? ".enabled" : ".disabled")))); + (r) -> r.addLine(Text.lang(langKey + (value.getBoolValue() ? ".enabled" : ".disabled")))); } public static ToggleButton createPowerButton(IRecipeLogicMachine recipeLogicMachine) { @@ -178,7 +178,7 @@ public static CycleButtonWidget createVoidingButton(IVoidable voidable) { .overlay(GTGuiTextures.BUTTON_VOID_MULTIBLOCK) .value(value) .tooltipBuilder( - r -> r.addLine(IKey.dynamic(() -> Component.translatable(value.getValue().getTooltip())))); + r -> r.addLine(Text.dynamic(() -> Component.translatable(value.getValue().getTooltip())))); } public static ToggleButton createDistinctnessButton(IDistinctPart distinct) { @@ -223,7 +223,7 @@ public static ModularPanel createCircuitSlotPanel(IntSyncValue circuitSyncVal syncManager.syncValue("circuit_slot", circuitSyncValue); Grid buttonGrid = new Grid() .coverChildren() - .mapTo(8, 32, i -> new ToggleButton() + .gridOfSizeWidth(32, 8, (x, y, i) -> new ToggleButton() .size(18) .padding(1) .overlay(new ItemDrawable().setItem(IntCircuitBehaviour.stack(i + 1))) @@ -244,7 +244,7 @@ public static ModularPanel createCircuitSlotPanel(IntSyncValue circuitSyncVal .childPadding(7) .top(3) .leftRel(0.5f) - .child(IKey.lang("item.gtceu.circuit.integrated.gui").asWidget()) + .child(Text.lang("item.gtceu.circuit.integrated.gui").asWidget()) .child(buttonGrid)); } @@ -267,7 +267,7 @@ public static ButtonWidget createCircuitSlotPanel(IHasCircuitSlot machine, Mo return new ButtonWidget<>() .size(18) - .onMousePressed((x, y, b) -> { + .onMousePressed((context, b) -> { if (b == InputConstants.MOUSE_BUTTON_LEFT || b == InputConstants.MOUSE_BUTTON_RIGHT) { circuitPanelHandler.openPanel(); } else if (b == InputConstants.MOUSE_BUTTON_MIDDLE) { @@ -275,7 +275,7 @@ public static ButtonWidget createCircuitSlotPanel(IHasCircuitSlot machine, Mo } return true; }) - .onMouseScrolled((x, y, delta) -> { + .onMouseScrolled((context, delta) -> { int newValue = nextCircuitValue(machine.getCircuitInventory().getStackInSlot(0), circuitSyncValue.getIntValue(), delta); circuitSyncValue.setValue(newValue); @@ -290,10 +290,10 @@ public static ButtonWidget createCircuitSlotPanel(IHasCircuitSlot machine, Mo .asIcon().size(16); })) .tooltipAutoUpdate(true) - .tooltipBuilder((r) -> r.addLine(IKey.lang(Component.translatable("metaitem.int_circuit.configuration", + .tooltipBuilder((r) -> r.addLine(Text.lang("metaitem.int_circuit.configuration", (machine.getCircuitInventory().getStackInSlot(0).isEmpty() ? 0 : IntCircuitBehaviour - .getCircuitConfiguration(machine.getCircuitInventory().getStackInSlot(0))))))); + .getCircuitConfiguration(machine.getCircuitInventory().getStackInSlot(0)))))); } private static int nextCircuitValue(ItemStack stack, int current, double delta) { @@ -323,13 +323,6 @@ private static int nextCircuitValue(ItemStack stack, int current, double delta) } } - public static IDrawable.DrawableWidget createGTLogo() { - if (GTValues.XMAS.getAsBoolean()) { - return new IDrawable.DrawableWidget(GTGuiTextures.GREGTECH_LOGO_XMAS); - } - return new IDrawable.DrawableWidget(GTGuiTextures.GREGTECH_LOGO); - } - public static String[] createGrid(int amount, int rowSize, boolean output, char key) { int rows = (int) Math.ceil((float) amount / rowSize); String[] grid = new String[rows]; @@ -373,7 +366,7 @@ public static CycleButtonWidget createIOCycleButton(EnumSyncValue syncValue, .stateOverlay(IO.OUT, IO.OUT.getUiTexture()) .value(syncVal) .tooltipBuilder( - r -> r.addLine(IKey.dynamic(() -> Component.translatable(syncValue.getValue().getTooltip())))); + r -> r.addLine(Text.dynamic(() -> Component.translatable(syncValue.getValue().getTooltip())))); if (allowExtendedIO) { cycleButton.stateOverlay(IO.BOTH, IO.BOTH.getUiTexture()); @@ -401,7 +394,7 @@ public static > ParentWidget createFilterRow(Parent S filter = filterHandler.loadFilter(stack); return new ButtonWidget<>() - .onMousePressed((x, y, b) -> { + .onMousePressed((context, b) -> { panelHandler.openPanel(); return true; }); @@ -437,11 +430,11 @@ private static long getIncrementValue(MouseData data, long step) { return adjust; } - private static IKey createAdjustOverlay(boolean increment) { + private static Text createAdjustOverlay(boolean increment) { return createAdjustOverlay(increment, 1); } - private static IKey createAdjustOverlay(boolean increment, long step) { + private static Text createAdjustOverlay(boolean increment, long step) { final StringBuilder builder = new StringBuilder(); builder.append(increment ? '+' : '-'); builder.append(getIncrementValue(MouseData.create(-1), step)); @@ -454,7 +447,7 @@ private static IKey createAdjustOverlay(boolean increment, long step) { } else if (builder.length() > 4) { scale = 0.5f; } - return IKey.str(builder.toString()) + return Text.str(builder.toString()) .color(Color.WHITE.main) .scale(scale); } @@ -472,7 +465,7 @@ public static ParentWidget createIntInputWithButtons(IntSyncValue syncValue, var textField = new TextFieldWidget() { @Override - public boolean onMouseScrolled(double mouseX, double mouseY, double delta) { + public boolean onMouseScrolled(double delta) { int inc = (int) delta * getIncrementValue(MouseData.create(-1), 1); int val = Mth.clamp(syncValue.getIntValue() + inc, minValue.getAsInt(), maxValue.getAsInt()); @@ -491,7 +484,7 @@ public boolean onMouseScrolled(double mouseX, double mouseY, double delta) { .widthRel(1.0f) .child(new ButtonWidget<>() .width(18) - .onMousePressed((x, y, button) -> { + .onMousePressed((context, button) -> { int val = syncValue.getIntValue() - getIncrementValue(MouseData.create(button), step); val = Mth.clamp(val, minValue.getAsInt(), maxValue.getAsInt()); syncValue.setIntValue(val, true, true); @@ -501,7 +494,7 @@ public boolean onMouseScrolled(double mouseX, double mouseY, double delta) { .child(textField) .child(new ButtonWidget<>() .width(18).right(0) - .onMousePressed((x, y, button) -> { + .onMousePressed((context, button) -> { int val = syncValue.getIntValue() + getIncrementValue(MouseData.create(button), step); val = Mth.clamp(val, minValue.getAsInt(), maxValue.getAsInt()); syncValue.setIntValue(val, true, true); @@ -523,7 +516,7 @@ public static ParentWidget createLongInputWithButtons(LongSyncValue syncValue var textField = new TextFieldWidget() { @Override - public boolean onMouseScrolled(double mouseX, double mouseY, double delta) { + public boolean onMouseScrolled(double delta) { long inc = (long) delta * getIncrementValue(MouseData.create(-1), 1); long min = minValue.getAsLong(); long max = maxValue.getAsLong(); @@ -544,7 +537,7 @@ public boolean onMouseScrolled(double mouseX, double mouseY, double delta) { .widthRel(1.0f) .child(new ButtonWidget<>() .width(18) - .onMousePressed((x, y, button) -> { + .onMousePressed((context, button) -> { long value = syncValue.getLongValue() - getIncrementValue(MouseData.create(button), step); syncValue.setLongValue(GTMath.clamp(value, minValue.getAsLong(), maxValue.getAsLong()), true, true); @@ -554,7 +547,7 @@ public boolean onMouseScrolled(double mouseX, double mouseY, double delta) { .child(textField) .child(new ButtonWidget<>() .width(18).right(0) - .onMousePressed((x, y, button) -> { + .onMousePressed((context, button) -> { long value = syncValue.getLongValue() + getIncrementValue(MouseData.create(button), step); long min = minValue.getAsLong(); long max = maxValue.getAsLong(); @@ -574,7 +567,7 @@ public static ParentWidget createIntInputWithBucketMode(IntSyncValue intSyncV var textField = new TextFieldWidget() { @Override - public boolean onMouseScrolled(double mouseX, double mouseY, double delta) { + public boolean onMouseScrolled(double delta) { int inc = (int) delta * (getIncrementValue(MouseData.create(-1), 1) * bucketModeSyncValue.getValue().multiplier); int val = Mth.clamp(intSyncValue.getIntValue() + inc, 0, maxMB.getAsInt()); @@ -593,7 +586,7 @@ public boolean onMouseScrolled(double mouseX, double mouseY, double delta) { .widthRel(1.0f) .child(new ButtonWidget<>() .width(18) - .onMousePressed((x, y, button) -> { + .onMousePressed((context, button) -> { int val = intSyncValue.getIntValue() - (getIncrementValue(MouseData.create(button), 1) * bucketModeSyncValue.getValue().multiplier); val = Mth.clamp(val, 0, maxMB.getAsInt()); @@ -605,7 +598,7 @@ public boolean onMouseScrolled(double mouseX, double mouseY, double delta) { .child(new ButtonWidget<>() .right(18) .width(18) - .onMousePressed((x, y, button) -> { + .onMousePressed((context, button) -> { int val = intSyncValue.getIntValue() + (getIncrementValue(MouseData.create(button), 1) * bucketModeSyncValue.getValue().multiplier); val = Mth.clamp(val, 0, maxMB.getAsInt()); @@ -622,12 +615,12 @@ public boolean onMouseScrolled(double mouseX, double mouseY, double delta) { public static class EnumRowBuilder> { - private EnumSyncValue syncValue; + private @Nullable EnumSyncValue syncValue; private final Class enumValue; - private IKey lang; - private IDrawable[] background; - private IDrawable selectedBackground; - private IDrawable[] overlay; + private @Nullable Component lang; + private IDrawable @Nullable [] background; + private @Nullable IDrawable selectedBackground; + private IDrawable @Nullable [] overlay; public EnumRowBuilder(Class enumValue) { this.enumValue = enumValue; @@ -638,7 +631,7 @@ public EnumRowBuilder value(EnumSyncValue syncValue) { return this; } - public EnumRowBuilder lang(IKey lang) { + public EnumRowBuilder lang(Component lang) { this.lang = lang; return this; } @@ -672,10 +665,10 @@ private BoolValue.Dynamic boolValueOf(EnumSyncValue syncValue, T value) { public Flow build() { var row = Flow.row().coverChildrenHeight().widthRel(1f); - if (this.enumValue != null && this.syncValue != null) { + if (syncValue != null) { for (var enumVal : enumValue.getEnumConstants()) { var button = new ToggleButton().size(18).marginRight(2) - .value(boolValueOf(this.syncValue, enumVal)); + .value(boolValueOf(syncValue, enumVal)); if (this.background != null && this.background.length > 0) button.background(this.background); @@ -691,14 +684,14 @@ public Flow build() { button.overlay(this.overlay[enumVal.ordinal()]); if (enumVal instanceof StringRepresentable serializable) { - button.addTooltipLine(IKey.lang(serializable.getSerializedName())); + button.addTooltipLine(Text.lang(serializable.getSerializedName())); } row.child(button); } } if (this.lang != null) - row.child(this.lang.asWidget().posRel(Alignment.CenterRight).height(18)); + row.child(Text.of(lang).asWidget().posRel(Alignment.CenterRight).height(18)); return row; } diff --git a/src/main/java/com/gregtechceu/gtceu/common/mui/GTMultiblockTextUtil.java b/src/main/java/com/gregtechceu/gtceu/common/mui/GTMultiblockTextUtil.java index e3778f297e4..6be0d15edd4 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/mui/GTMultiblockTextUtil.java +++ b/src/main/java/com/gregtechceu/gtceu/common/mui/GTMultiblockTextUtil.java @@ -1,5 +1,6 @@ package com.gregtechceu.gtceu.common.mui; +import brachy.modularui.api.drawable.IDrawable; import com.gregtechceu.gtceu.api.GTValues; import com.gregtechceu.gtceu.api.capability.recipe.FluidRecipeCapability; import com.gregtechceu.gtceu.api.capability.recipe.ItemRecipeCapability; @@ -21,12 +22,11 @@ import net.minecraft.world.item.ItemStack; import net.minecraftforge.fluids.FluidStack; -import brachy.modularui.api.drawable.IKey; +import brachy.modularui.api.drawable.Text; import brachy.modularui.drawable.FluidDrawable; import brachy.modularui.drawable.ItemDrawable; import brachy.modularui.screen.RichTooltip; import brachy.modularui.utils.Alignment; -import brachy.modularui.utils.Color; import brachy.modularui.value.sync.*; import brachy.modularui.widget.Widget; import brachy.modularui.widgets.DynamicSyncedWidget; @@ -39,6 +39,16 @@ public class GTMultiblockTextUtil { + public static TextWidget addUnformedWarning(WorkableElectricMultiblockMachine weMachine, PanelSyncManager syncManager) { + BooleanSyncValue isFormed = syncManager.getOrCreateSyncHandler("isFormed", BooleanSyncValue.class, + () -> new BooleanSyncValue(weMachine::isFormed)); + + return Text.lang("gtceu.multiblock.invalid_structure") + .withStyle(ChatFormatting.RED) + .asWidget() + .setEnabledIf(w -> !isFormed.getBoolValue()); + } + public static TextWidget addEnergyUsageLine(WorkableElectricMultiblockMachine weMachine, PanelSyncManager syncManager) { LongSyncValue energyUsage = syncManager.getOrCreateSyncHandler("energyUsage", LongSyncValue.class, @@ -51,7 +61,7 @@ public static TextWidget addEnergyUsageLine(WorkableElectricMultiblockMachine BooleanSyncValue isActive = syncManager.getOrCreateSyncHandler("isActive", BooleanSyncValue.class, () -> new BooleanSyncValue(() -> weMachine.getRecipeLogic().isActive())); - return IKey.dynamic(() -> { + var widget = Text.dynamic(() -> { String energyFormatted = FormattingUtil.formatNumbers(energyUsage.getLongValue()); byte voltageTier = GTUtil.getFloorTierByVoltage(energyUsage.getLongValue()); @@ -63,11 +73,13 @@ public static TextWidget addEnergyUsageLine(WorkableElectricMultiblockMachine Component hoverText = Component.translatable("gtceu.multiblock.max_energy_per_tick_hover") .withStyle(ChatFormatting.GRAY); return bodyText - .withStyle(style -> style.withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, hoverText))); + .withStyle(style -> style.withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, hoverText))) + .withStyle(ChatFormatting.WHITE); }) - .color(Color.WHITE.main) .asWidget() - .setEnabledIf(widget -> isFormed.getBoolValue() && isActive.getBoolValue()); + .setEnabledIf($ -> isFormed.getBoolValue() && isActive.getBoolValue()); + + return widget; } public static TextWidget addEnergyUsageExactLine(WorkableElectricMultiblockMachine weMachine, @@ -85,7 +97,7 @@ public static TextWidget addEnergyUsageExactLine(WorkableElectricMultiblockMa BooleanSyncValue isFormed = syncManager.getOrCreateSyncHandler("isFormed", BooleanSyncValue.class, () -> new BooleanSyncValue(weMachine::isFormed)); - return IKey.dynamic(() -> { + return Text.dynamic(() -> { if (energyUsage.getLongValue() <= 0) return Component.empty(); String energyFormatted = FormattingUtil.formatNumbers(energyUsage.getLongValue()); // wrap in text component to keep it from being formatted @@ -99,9 +111,9 @@ public static TextWidget addEnergyUsageExactLine(WorkableElectricMultiblockMa .setEnabledIf(widget -> isFormed.getBoolValue()); } - public static IKey addEnergyTierLine(boolean formed, int tier) { + public static Component addEnergyTierLine(boolean formed, int tier) { if (!formed || tier < GTValues.ULV || tier > GTValues.MAX) - return IKey.EMPTY; + return Text.EMPTY; Component voltageName = Component.literal(GTValues.VNF[tier]); MutableComponent bodyText = Component.translatable( @@ -109,7 +121,7 @@ public static IKey addEnergyTierLine(boolean formed, int tier) { voltageName).withStyle(ChatFormatting.GRAY); Component hoverText = Component.translatable("gtceu.multiblock.max_recipe_tier_hover") .withStyle(ChatFormatting.GRAY); - return IKey.dynamic(() -> bodyText + return Text.dynamic(() -> bodyText .withStyle(style -> style.withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, hoverText)))); } @@ -126,14 +138,14 @@ public static TextWidget addProgressLine(WorkableMultiblockMachine rlMachine, DoubleSyncValue progressPercent = syncManager.getOrCreateSyncHandler("progressPercent", DoubleSyncValue.class, () -> new DoubleSyncValue(() -> rlMachine.getRecipeLogic().getProgressPercent())); - return IKey.dynamic(() -> { + return Text.dynamic(() -> { int progress = (int) (progressPercent.getDoubleValue() * 100.f); float current = (float) currentProgress.getDoubleValue() / 20.f; float max = (float) maxProgress.getDoubleValue() / 20.f; return Component.translatable("gtceu.multiblock.progress", - String.format("%.2f", current), String.format("%.2f", max), progress); + String.format("%.2f", current), String.format("%.2f", max), progress) + .withStyle(ChatFormatting.WHITE); }) - .color(Color.WHITE.main) .asWidget() .setEnabledIf(widget -> isFormed.getBoolValue() && isActive.getBoolValue()); } @@ -147,11 +159,11 @@ public static TextWidget addProgressLinePercentOnly(WorkableMultiblockMachine DoubleSyncValue progressPercent = syncManager.getOrCreateSyncHandler("progressPercent", DoubleSyncValue.class, () -> new DoubleSyncValue(() -> rlMachine.getRecipeLogic().getProgressPercent())); - return IKey.dynamic(() -> { + return Text.dynamic(() -> { int currentProgress = (int) (progressPercent.getDoubleValue() * 100); - return Component.translatable("gtceu.multiblock.progress_percent", currentProgress); + return Component.translatable("gtceu.multiblock.progress_percent", currentProgress) + .withStyle(ChatFormatting.WHITE); }) - .color(Color.WHITE.main) .asWidget() .setEnabledIf(widget -> isFormed.getBoolValue() && isActive.getBoolValue()); } @@ -164,7 +176,7 @@ public static TextWidget addEnergyTierLine(WorkableElectricMultiblockMachine IntSyncValue tier = syncManager.getOrCreateSyncHandler("energyTier", IntSyncValue.class, () -> new IntSyncValue(rlMachine::getTier)); - return IKey.dynamic(() -> { + return Text.dynamic(() -> { Component voltageName = Component.literal(GTValues.VNF[tier.getIntValue()]); return Component.translatable( "gtceu.multiblock.max_recipe_tier", @@ -183,7 +195,7 @@ public static TextWidget addParallelLine(WorkableMultiblockMachine rlMachine, return rlMachine.getRecipeLogic().getLastRecipe().parallels; })); - return IKey.dynamic(() -> { + return Text.dynamic(() -> { Component runs = Component.literal(FormattingUtil.formatNumbers(parallelAmount.getIntValue())) .withStyle(ChatFormatting.DARK_PURPLE); String key = "gtceu.multiblock.parallel"; @@ -202,7 +214,7 @@ public static TextWidget addBatchModeLine(WorkableMultiblockMachine rlMachine return rlMachine.getRecipeLogic().getLastRecipe().batchParallels; })); - return IKey.dynamic(() -> { + return Text.dynamic(() -> { Component runs = Component.literal(FormattingUtil.formatNumbers(batchAmount.getIntValue())) .withStyle(ChatFormatting.DARK_PURPLE); String key = "gtceu.multiblock.batch_enabled"; @@ -220,7 +232,7 @@ public static TextWidget addSubtickParallelsLine(WorkableMultiblockMachine rl return rlMachine.getRecipeLogic().getLastRecipe().subtickParallels; })); - return IKey.dynamic(() -> { + return Text.dynamic(() -> { Component runs = Component.literal(FormattingUtil.formatNumbers(subtickAmount.getIntValue())) .withStyle(ChatFormatting.DARK_PURPLE); String key = "gtceu.multiblock.subtick_parallels"; @@ -237,7 +249,7 @@ public static TextWidget addTotalRunsLine(WorkableMultiblockMachine rlMachine return rlMachine.getRecipeLogic().getLastRecipe().getTotalRuns(); })); - return IKey.dynamic(() -> { + return Text.dynamic(() -> { Component runs = Component.literal(FormattingUtil.formatNumbers(totalRunAmount.getIntValue())) .withStyle(ChatFormatting.DARK_PURPLE); String key = "gtceu.multiblock.total_runs"; @@ -263,11 +275,10 @@ public static TextWidget addSteamUsageLine(@Nullable SteamEnergyRecipeHandler BooleanSyncValue hasSteamHandler = syncManager.getOrCreateSyncHandler("hasSteam", BooleanSyncValue.class, () -> new BooleanSyncValue(() -> steamRH != null)); - return IKey + return Text .dynamic(() -> Component.translatable("gtceu.multiblock.steam.steam_stored", FormattingUtil.formatNumbers(steamAmount.getIntValue()), - FormattingUtil.formatNumbers(steamCapacity.getIntValue()))) - .color(Color.WHITE.main) + FormattingUtil.formatNumbers(steamCapacity.getIntValue())).withStyle(ChatFormatting.WHITE)) .asWidget() .setEnabledIf((w) -> hasSteamHandler.getBoolValue()); } @@ -301,7 +312,7 @@ public static TextWidget addWorkingStatusLine(WorkableMultiblockMachine rlMac BooleanSyncValue.class, () -> new BooleanSyncValue(() -> rlMachine.getRecipeLogic().isWorkingEnabled())); - return IKey + return Text .dynamic(() -> { if (!isFormed.getBoolValue()) return Component.empty(); if (!isWorkingEnabled.getBoolValue()) { @@ -316,9 +327,10 @@ public static TextWidget addWorkingStatusLine(WorkableMultiblockMachine rlMac .setEnabledIf((w) -> isFormed.getBoolValue()); } + @SuppressWarnings("unchecked") public static DynamicSyncedWidget addOutputLines(WorkableMultiblockMachine rlmachine, PanelSyncManager syncManager) { - GenericSyncValue recipeSyncValue = syncManager.getOrCreateSyncHandler("GTRecipe", + GenericSyncValue recipeSyncValue = (GenericSyncValue)syncManager.getOrCreateSyncHandler("GTRecipe", GenericSyncValue.class, () -> GenericSyncValue.builder(GTRecipe.class) .getter(() -> rlmachine.getRecipeLogic().getLastRecipe()) @@ -374,27 +386,27 @@ public static Optional> createItemLineForOutput(Content itemOutput, GT double countD = 1; // number of items output which is actually displayed. Can be either a number, or a range. Component displaycount; - if (itemOutput.content instanceof IntProviderIngredient provider) { + if (itemOutput.content() instanceof IntProviderIngredient provider) { rounded = true; stack = provider.getMaxSizeStack(); displaycount = Component.translatable("gtceu.gui.content.range", provider.getCountProvider().getMinValue(), provider.getCountProvider().getMaxValue()); - if (itemOutput.chance < itemOutput.maxChance) { + if (itemOutput.chance() < itemOutput.maxChance()) { countD = countD * runs * function.getBoostedChance(itemOutput, recipeTier, chanceTier) / - itemOutput.maxChance; + itemOutput.maxChance(); } countD = countD * provider.getMidRoll(); } else { - var stacks = ItemRecipeCapability.CAP.of(itemOutput.content).getItems(); + var stacks = ItemRecipeCapability.CAP.of(itemOutput.content()).getItems(); if (stacks.length == 0) return Optional.empty(); stack = stacks[0]; count = stack.getCount(); countD *= count; - if (itemOutput.chance < itemOutput.maxChance) { + if (itemOutput.chance() < itemOutput.maxChance()) { rounded = true; countD = countD * runs * function.getBoostedChance(itemOutput, recipeTier, chanceTier) / - itemOutput.maxChance; + itemOutput.maxChance(); } count = Math.max(1, (int) Math.round(countD)); displaycount = Component.literal(String.valueOf(count)); @@ -407,9 +419,9 @@ public static Optional> createItemLineForOutput(Content itemOutput, GT .childPadding(2) .child(new ItemDrawable(stack).asWidget()) .child( - IKey.lang( - Component.translatable(key, stack.getHoverName(), displaycount, - FormattingUtil.formatNumber2Places(maxDurationSec / countD))) + Text.lang( + key, stack.getHoverName(), displaycount, + FormattingUtil.formatNumber2Places(maxDurationSec / countD)) .asWidget())); } else { String key = "gtceu.multiblock.output_line." + (rounded ? "3" : "1"); @@ -419,9 +431,9 @@ public static Optional> createItemLineForOutput(Content itemOutput, GT .childPadding(2) .child(new ItemDrawable(stack).asWidget()) .child( - IKey.lang( - Component.translatable(key, stack.getHoverName(), displaycount, - FormattingUtil.formatNumber2Places(countD / maxDurationSec))) + Text.lang( + key, stack.getHoverName(), displaycount, + FormattingUtil.formatNumber2Places(countD / maxDurationSec)) .asWidget())); } } @@ -442,27 +454,27 @@ public static Optional> createFluidLineForOutput(Content fluidOutput, double amountD = 1; // amount of fluid output which is actually displayed. Can be either a number, or a range. Component displaycount; - if (fluidOutput.content instanceof IntProviderFluidIngredient provider) { + if (fluidOutput.content() instanceof IntProviderFluidIngredient provider) { rounded = true; stack = provider.getMaxSizeStack(); displaycount = Component.translatable("gtceu.gui.content.range", provider.getCountProvider().getMinValue(), provider.getCountProvider().getMaxValue()); - if (fluidOutput.chance < fluidOutput.maxChance) { + if (fluidOutput.chance() < fluidOutput.maxChance()) { amountD = amountD * runs * function.getBoostedChance(fluidOutput, recipeTier, chanceTier) / - fluidOutput.maxChance; + fluidOutput.maxChance(); } amountD = amountD * provider.getMidRoll(); } else { - var stacks = FluidRecipeCapability.CAP.of(fluidOutput.content).getStacks(); + var stacks = FluidRecipeCapability.CAP.of(fluidOutput.content()).getStacks(); if (stacks.length == 0) return Optional.empty(); stack = stacks[0]; amount = stack.getAmount(); amountD *= amount; - if (fluidOutput.chance < fluidOutput.maxChance) { + if (fluidOutput.chance() < fluidOutput.maxChance()) { rounded = true; amountD = amountD * runs * function.getBoostedChance(fluidOutput, recipeTier, chanceTier) / - fluidOutput.maxChance; + fluidOutput.maxChance(); } amount = Math.max(1, (int) Math.round(amountD)); displaycount = Component.literal(String.valueOf(amount)); @@ -475,9 +487,9 @@ public static Optional> createFluidLineForOutput(Content fluidOutput, .childPadding(2) .child(new FluidDrawable(stack).asWidget()) .child( - IKey.lang( - Component.translatable(key, stack.getDisplayName(), displaycount, - FormattingUtil.formatNumber2Places(maxDurationSec / amountD))) + Text.lang( + key, stack.getDisplayName(), displaycount, + FormattingUtil.formatNumber2Places(maxDurationSec / amountD)) .asWidget())); } else { String key = "gtceu.multiblock.output_line." + (rounded ? "3" : "1"); @@ -487,9 +499,8 @@ public static Optional> createFluidLineForOutput(Content fluidOutput, .childPadding(2) .child(new FluidDrawable(stack).asWidget()) .child( - IKey.lang( - Component.translatable(key, stack.getDisplayName(), displaycount, - FormattingUtil.formatNumber2Places(amountD / maxDurationSec))) + Text.lang(key, stack.getDisplayName(), displaycount, + FormattingUtil.formatNumber2Places(amountD / maxDurationSec)) .asWidget())); } } diff --git a/src/main/java/com/gregtechceu/gtceu/common/mui/GTSingleblockMachinePanels.java b/src/main/java/com/gregtechceu/gtceu/common/mui/GTSingleblockMachinePanels.java index ea29de3fd39..011b01735cd 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/mui/GTSingleblockMachinePanels.java +++ b/src/main/java/com/gregtechceu/gtceu/common/mui/GTSingleblockMachinePanels.java @@ -3,146 +3,51 @@ import com.gregtechceu.gtceu.GTCEu; import com.gregtechceu.gtceu.api.machine.MetaMachine; import com.gregtechceu.gtceu.api.machine.SimpleTieredMachine; -import com.gregtechceu.gtceu.api.machine.mui.MachineUIPanel; import com.gregtechceu.gtceu.api.machine.mui.MachineUIPanelBuilder; import com.gregtechceu.gtceu.api.machine.steam.SimpleSteamMachine; +import com.gregtechceu.gtceu.api.machine.trait.RecipeLogic; import com.gregtechceu.gtceu.api.mui.factory.PanelFactory; -import com.gregtechceu.gtceu.api.recipe.gui.GTRecipeTypeUIs; +import com.gregtechceu.gtceu.api.recipe.GTRecipeType; import brachy.modularui.factory.PosGuiData; import brachy.modularui.screen.ModularPanel; import brachy.modularui.screen.UISettings; -import brachy.modularui.utils.Alignment; import brachy.modularui.value.sync.PanelSyncManager; -import brachy.modularui.widgets.layout.Flow; +import com.gregtechceu.gtceu.api.recipe.gui.GTRecipeTypeMachineWidget; public class GTSingleblockMachinePanels { public static PanelFactory GENERAL_MACHINE = (PosGuiData data, PanelSyncManager syncManager, UISettings settings, MetaMachine machine) -> { - if (!(machine instanceof SimpleTieredMachine simpleTieredMachine)) { - GTCEu.LOGGER.error("{} is not a WorkableTieredMachine, can not add slots to its content", - machine.getDefinition().getName()); - return new ModularPanel<>(machine.getDefinition().getName()); - } - - return MachineUIPanelBuilder.defaultSimpleSingleblockPanelBuilder(machine).mainContents((parent) -> { - var inputItemGrid = GTMuiWidgets.createGrid(simpleTieredMachine.importItems.getSize(), 3, false, 'i'); - var inputFluidGrid = GTMuiWidgets.createGrid(simpleTieredMachine.importFluids.getSize(), 3, false, 'f'); - var outputItemGrid = GTMuiWidgets.createGrid(simpleTieredMachine.exportItems.getSize(), 3, true, 'i'); - var outputFluidGrid = GTMuiWidgets.createGrid(simpleTieredMachine.exportFluids.getSize(), 3, true, 'f'); - - int slotHeight = Math.max(inputItemGrid.length + inputFluidGrid.length, - outputItemGrid.length + outputFluidGrid.length); - boolean hasXEI = GTRecipeTypeUIs.recipeTypeUIs.containsKey(simpleTieredMachine.getRecipeType()); - - var theme = machine.getDefinition().getThemeId(); - - parent.child(Flow.row() - .size(MachineUIPanel.DEFAULT_CONTENT_WIDTH, 18 + 9 + 18 * Math.max(2, slotHeight)) - .childIf(hasXEI, () -> GTRecipeTypeUIs.recipeTypeUIs.get(simpleTieredMachine.getRecipeType()) - .getBackedSlotsRow(syncManager, theme, simpleTieredMachine.importItems, - simpleTieredMachine.exportItems, - simpleTieredMachine.importFluids, simpleTieredMachine.exportFluids, - simpleTieredMachine.recipeLogic::getProgressPercent, - -1))); - }).build(syncManager, settings).excludeAreaInRecipeViewer(); - }; - - public static PanelFactory MACERATOR = (PosGuiData data, PanelSyncManager syncManager, UISettings settings, - MetaMachine machine) -> { - if (!(machine instanceof SimpleTieredMachine simpleTieredMachine)) { - GTCEu.LOGGER.error("{} is not a SimpleTieredMachine, can not add slots to its content", - machine.getDefinition().getName()); - return new ModularPanel<>(machine.getDefinition().getName()); - } - - return MachineUIPanelBuilder.defaultSimpleSingleblockPanelBuilder(machine).mainContents((parent) -> { - - var inputItemGrid = GTMuiWidgets.createGrid(simpleTieredMachine.importItems.getSize(), 3, false, 'i'); - var inputFluidGrid = GTMuiWidgets.createGrid(simpleTieredMachine.importFluids.getSize(), 3, false, 'f'); - var outputItemGrid = GTMuiWidgets.createGrid(simpleTieredMachine.exportItems.getSize(), 3, true, 'i'); - var outputFluidGrid = GTMuiWidgets.createGrid(simpleTieredMachine.exportFluids.getSize(), 3, true, 'f'); - int slotHeight = Math.max(inputItemGrid.length + inputFluidGrid.length, - outputItemGrid.length + outputFluidGrid.length); - boolean hasXEI = GTRecipeTypeUIs.recipeTypeUIs.containsKey(simpleTieredMachine.getRecipeType()); - - var theme = machine.getDefinition().getThemeId(); - - parent.child(Flow.row() - .size(MachineUIPanel.DEFAULT_CONTENT_WIDTH, 18 + 9 + 18 * Math.max(2, slotHeight)) - .childIf(hasXEI, () -> GTRecipeTypeUIs.recipeTypeUIs.get(simpleTieredMachine.getRecipeType()) - .getBackedSlotsRow(syncManager, theme, simpleTieredMachine.importItems, - simpleTieredMachine.exportItems, - simpleTieredMachine.importFluids, simpleTieredMachine.exportFluids, - simpleTieredMachine.recipeLogic::getProgressPercent, - simpleTieredMachine.getTier()) - .posRel(Alignment.Center))); - }).build(syncManager, settings).excludeAreaInRecipeViewer(); - }; - - public static PanelFactory ARC_FURNACE = (PosGuiData data, PanelSyncManager syncManager, UISettings settings, - MetaMachine machine) -> { - if (!(machine instanceof SimpleTieredMachine simpleTieredMachine)) { - GTCEu.LOGGER.error("{} is not a WorkableTieredMachine, can not add slots to its content", + GTRecipeType type; + RecipeLogic recipeLogic; + boolean isSteam = false; + + if (machine instanceof SimpleTieredMachine simpleTieredMachine) { + type = simpleTieredMachine.getRecipeType(); + recipeLogic = simpleTieredMachine.getRecipeLogic(); + } else if (machine instanceof SimpleSteamMachine simpleSteamMachine) { + type = simpleSteamMachine.getRecipeType(); + recipeLogic = simpleSteamMachine.recipeLogic; + isSteam = true; + } else { + GTCEu.LOGGER.error("{} is not a SimpleTieredMachine or SimpleSteamMachine, cannot add slots to its content", machine.getDefinition().getName()); return new ModularPanel<>(machine.getDefinition().getName()); } - return MachineUIPanelBuilder.defaultSimpleSingleblockPanelBuilder(machine).mainContents((parent) -> { - var inputItemGrid = GTMuiWidgets.createGrid(simpleTieredMachine.importItems.getSize(), 3, false, 'i'); - var inputFluidGrid = GTMuiWidgets.createGrid(simpleTieredMachine.importFluids.getSize(), 3, false, 'f'); - var outputItemGrid = GTMuiWidgets.createGrid(simpleTieredMachine.exportItems.getSize(), 3, true, 'i'); - var outputFluidGrid = GTMuiWidgets.createGrid(simpleTieredMachine.exportFluids.getSize(), 3, true, 'f'); - - int slotHeight = Math.max(inputItemGrid.length + inputFluidGrid.length, - outputItemGrid.length + outputFluidGrid.length); - - var theme = machine.getDefinition().getThemeId(); - - boolean hasXEI = GTRecipeTypeUIs.recipeTypeUIs.containsKey(simpleTieredMachine.getRecipeType()); - - parent.child(Flow.row() - .size(MachineUIPanel.DEFAULT_CONTENT_WIDTH, 18 + 9 + 18 * Math.max(2, slotHeight)) - .childIf(hasXEI, () -> GTRecipeTypeUIs.recipeTypeUIs.get(simpleTieredMachine.getRecipeType()) - .getBackedSlotsRow(syncManager, theme, simpleTieredMachine.importItems, - simpleTieredMachine.exportItems, - simpleTieredMachine.importFluids, simpleTieredMachine.exportFluids, - simpleTieredMachine.recipeLogic::getProgressPercent, - 0) - .posRel(Alignment.Center))); - }).build(syncManager, settings).excludeAreaInRecipeViewer(); - }; - - public static PanelFactory STEAM_MACHINE = (PosGuiData data, PanelSyncManager syncManager, UISettings settings, - MetaMachine machine) -> { - if (!(machine instanceof SimpleSteamMachine steamMachine)) { - GTCEu.LOGGER.error("{} is not a SimpleSteamMachine, can not add slots to its content", + if (type.getUiLayout() == null) { + GTCEu.LOGGER.error( + "Tried to draw a singleblock recipe type UI for {}, but it does not have a recipe type UI", machine.getDefinition().getName()); return new ModularPanel<>(machine.getDefinition().getName()); } - return MachineUIPanelBuilder.defaultSteamMachineBuilder(machine).mainContents(parent -> { - var inputItemGrid = GTMuiWidgets.createGrid(steamMachine.importItems.getSize(), 3, false, 'i'); - var outputItemGrid = GTMuiWidgets.createGrid(steamMachine.exportItems.getSize(), 3, true, 'i'); - - int slotHeight = Math.max(inputItemGrid.length, - outputItemGrid.length); - - boolean hasXEI = GTRecipeTypeUIs.recipeTypeUIs.containsKey(steamMachine.getRecipeType()); - - var theme = machine.getDefinition().getThemeId(); - - parent.child(Flow.row() - .size(MachineUIPanel.DEFAULT_CONTENT_WIDTH, 18 + 9 + 18 * Math.max(2, slotHeight)) - .childIf(hasXEI, () -> GTRecipeTypeUIs.recipeTypeUIs.get(steamMachine.getRecipeType()) - .getBackedSlotsRow(syncManager, theme, steamMachine.importItems, - steamMachine.exportItems, - null, null, - steamMachine.recipeLogic::getProgressPercent, - steamMachine.getTier()) - .posRel(Alignment.Center))); - }).build(syncManager, settings).excludeAreaInRecipeViewer(); + var builder = isSteam ? MachineUIPanelBuilder.panelBuilder(machine).drawGTLogo(true) : MachineUIPanelBuilder.defaultSteamMachinePanelBuilder(machine); + return builder.mainContents( + (parent) -> parent.child(new GTRecipeTypeMachineWidget(type, syncManager, machine, recipeLogic::getProgressPercent))) + .build(syncManager, settings) + .excludeAreaInRecipeViewer(); }; } diff --git a/src/main/java/com/gregtechceu/gtceu/common/mui/factory/CentralMonitorUIFactory.java b/src/main/java/com/gregtechceu/gtceu/common/mui/factory/CentralMonitorUIFactory.java index 4da57c0019b..ee04d09eccf 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/mui/factory/CentralMonitorUIFactory.java +++ b/src/main/java/com/gregtechceu/gtceu/common/mui/factory/CentralMonitorUIFactory.java @@ -22,7 +22,7 @@ import brachy.modularui.api.GuiAxis; import brachy.modularui.api.IPanelHandler; import brachy.modularui.api.drawable.IDrawable; -import brachy.modularui.api.drawable.IKey; +import brachy.modularui.api.drawable.Text; import brachy.modularui.api.value.IValue; import brachy.modularui.api.widget.IWidget; import brachy.modularui.drawable.DynamicDrawable; @@ -73,20 +73,20 @@ public ModularPanel buildUIFunction(PosGuiData data, PanelSyncManager syncMan groups, helpPanel)); return item.child(Flow.row() .height(20) - .child(new TextWidget<>(IKey.dynamic(() -> Component.literal(item.getWidgetValue().getName()))) + .child(new TextWidget<>(Text.dynamic(() -> Component.literal(item.getWidgetValue().getName()))) .paddingLeft(5) .widthRelOffset(1, -38)) .child(new ButtonWidget<>() .background(GuiTextures.EDIT) .hoverBackground(GuiTextures.EDIT, new BorderDrawable()) - .onMousePressed((mouseX, mouseY, button) -> { + .onMousePressed((context, button) -> { panelHandler.openPanel(); return true; })) .child(new ButtonWidget<>() .background(GuiTextures.CLOSE) .hoverBackground(GuiTextures.CLOSE, new BorderDrawable()) - .onMousePressed((mouseX, mouseY, button) -> { + .onMousePressed((context, button) -> { groups.remove(item.getWidgetValue()); groupSync.setValue(groups); item.removeSelfFromList(); @@ -112,7 +112,7 @@ public ModularPanel buildUIFunction(PosGuiData data, PanelSyncManager syncMan .widthRel(1) .padding(2) .child(new Flow(GuiAxis.X) - .child(new TextWidget<>(IKey.lang("gtceu.central_monitor.gui.monitor_groups")) + .child(new TextWidget<>(Text.lang("gtceu.central_monitor.gui.monitor_groups")) .leftRel(0)) .child(new ButtonWidget<>() .leftRel(1) @@ -164,7 +164,7 @@ private ModularPanel createGroupEditorPanel(PanelSyncManager syncManager, }, new TextFieldWidget().setNumbers(1, component.getDataItems().getSlots()), w -> Integer.parseInt(w.getText()), - IKey.lang("gtceu.central_monitor.gui.data_slot")).draggable(true) + Text.lang("gtceu.central_monitor.gui.data_slot")).draggable(true) .size(160, 80)); IntSupplier colorSupplier = () -> { if (component == null) return 0; @@ -178,7 +178,7 @@ private ModularPanel createGroupEditorPanel(PanelSyncManager syncManager, }; curRow.add(new ButtonWidget<>() .margin(1) - .background(texture, new BorderDrawable(colorSupplier, 1), IKey.dynamic(() -> { + .background(texture, new BorderDrawable(colorSupplier, 1), Text.dynamic(() -> { if (component == null || component.getDataItems() == null) return Component.empty(); BlockPos target = group.getTargetRaw(); boolean isTarget = target != null && target.asLong() == component.getBlockPos().asLong(); @@ -186,7 +186,7 @@ private ModularPanel createGroupEditorPanel(PanelSyncManager syncManager, else return Component.empty(); })) .hoverBackground(texture, new BorderDrawable(() -> colorSupplier.getAsInt() | 0x222222, 1)) - .onMousePressed((mouseX, mouseY, button) -> { + .onMousePressed((context, button) -> { if (component == null) return true; if (button == InputConstants.MOUSE_BUTTON_LEFT) { if (!component.isMonitor()) return true; @@ -218,10 +218,10 @@ private ModularPanel createGroupEditorPanel(PanelSyncManager syncManager, .excludeAreaInRecipeViewer() .child(Flow.column() .padding(10) - .child(new TextWidget<>(IKey.lang("gtceu.central_monitor.gui.group_editor"))) + .child(new TextWidget<>(Text.lang("gtceu.central_monitor.gui.group_editor"))) .child(Flow.row() .height(20) - .child(new TextWidget<>(IKey.lang("gtceu.central_monitor.gui.group_name")) + .child(new TextWidget<>(Text.lang("gtceu.central_monitor.gui.group_name")) .paddingRight(4)) .child(new TextFieldWidget() .value(SyncHandlers.string(group::getName, group::setName))) @@ -245,20 +245,22 @@ private ModularPanel createGroupEditorPanel(PanelSyncManager syncManager, GuiTextures.MC_BUTTON_HOVERED), GuiTextures.EDIT) .setEnabledIf(w -> !group.getItemStackHandler().getStackInSlot(0).isEmpty()) - .addTooltipLine(IKey.lang(() -> moduleChanged.getValue() ? - "gtceu.gui.central_monitor.module_editor_disabled" : - "gtceu.gui.central_monitor.module_editor_button")) - .onMousePressed((mouseX, mouseY, button) -> { + .addTooltipLine(Text.dynamic(() -> moduleChanged.getValue() ? + Component.translatable( + "gtceu.gui.central_monitor.module_editor_disabled") : + Component.translatable( + "gtceu.gui.central_monitor.module_editor_button"))) + .onMousePressed((context, button) -> { if (moduleEditor != null && !moduleChanged.getValue()) moduleEditor.openPanel(); return true; }))) - .child(new Grid().matrix(matrix).leftRel(0.5f).size(matrixWidth, matrixHeight))) + .child(new Grid().grid(matrix).leftRel(0.5f).size(matrixWidth, matrixHeight))) .child(new ButtonWidget<>() .posRel(Alignment.TopRight) .background(GuiTextures.HELP) .hoverBackground(GuiTextures.HELP, new BorderDrawable()) - .onMousePressed((mouseX, mouseY, button) -> { + .onMousePressed((context, button) -> { helpPanel.openPanel(); return true; })); @@ -272,7 +274,7 @@ private ModularPanel createHelpPanel() { .resizeableOnDrag(true) .child(Flow.column() .margin(5) - .child(new TextWidget<>(IKey.lang("gtceu.gui.central_monitor.help"))) + .child(new TextWidget<>(Text.lang("gtceu.gui.central_monitor.help"))) .child(Flow.row() .marginTop(10) .height(40) @@ -284,13 +286,13 @@ private ModularPanel createHelpPanel() { .padding(11) .background(new BorderDrawable(0xFF888888, 1)) .disableHoverBackground()) - .child(new TextWidget<>(IKey.lang("gtceu.gui.central_monitor.in_group")) + .child(new TextWidget<>(Text.lang("gtceu.gui.central_monitor.in_group")) .widthRel(.5f) .heightRel(1) .padding(5) .background(new BorderDrawable(0xFF888888, 1)) .disableHoverBackground()) - .child(new TextWidget<>(IKey.lang("gtceu.gui.central_monitor.left_click")) + .child(new TextWidget<>(Text.lang("gtceu.gui.central_monitor.left_click")) .padding(5) .widthRelOffset(.5f, -40) .heightRel(1) @@ -305,13 +307,13 @@ private ModularPanel createHelpPanel() { .padding(11) .background(new BorderDrawable(0xFF888888, 1)) .disableHoverBackground()) - .child(new TextWidget<>(IKey.lang("gtceu.gui.central_monitor.target")) + .child(new TextWidget<>(Text.lang("gtceu.gui.central_monitor.target")) .widthRel(.5f) .heightRel(1) .padding(5) .background(new BorderDrawable(0xFF888888, 1)) .disableHoverBackground()) - .child(new TextWidget<>(IKey.lang("gtceu.gui.central_monitor.right_click")) + .child(new TextWidget<>(Text.lang("gtceu.gui.central_monitor.right_click")) .padding(5) .widthRelOffset(.5f, -40) .heightRel(1) @@ -327,7 +329,7 @@ private ModularPanel createHelpPanel() { .padding(11) .background(new BorderDrawable(0xFF888888, 1)) .disableHoverBackground()) - .child(new TextWidget<>(IKey.lang("gtceu.gui.central_monitor.in_group_and_target")) + .child(new TextWidget<>(Text.lang("gtceu.gui.central_monitor.in_group_and_target")) .widthRelOffset(1, -40) .heightRel(1) .padding(5) @@ -336,13 +338,13 @@ private ModularPanel createHelpPanel() { .height(40) .widthRel(1) .child(IDrawable.of(new BorderDrawable(0xFF0000FF, 1), - GTGuiTextures.DATA_HATCH, IKey.str("7").color(0xFFFFFFFF)).asWidget() + GTGuiTextures.DATA_HATCH, Text.str("7").color(0xFFFFFFFF)).asWidget() .heightRel(1) .width(40) .padding(11) .background(new BorderDrawable(0xFF888888, 1)) .disableHoverBackground()) - .child(new TextWidget<>(IKey.lang("gtceu.gui.central_monitor.data_hatch_target")) + .child(new TextWidget<>(Text.lang("gtceu.gui.central_monitor.data_hatch_target")) .widthRelOffset(1, -40) .heightRel(1) .padding(5) diff --git a/src/main/java/com/gregtechceu/gtceu/common/mui/widgets/PopupPanel.java b/src/main/java/com/gregtechceu/gtceu/common/mui/widgets/PopupPanel.java index ad96165910c..7c054a1d54b 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/mui/widgets/PopupPanel.java +++ b/src/main/java/com/gregtechceu/gtceu/common/mui/widgets/PopupPanel.java @@ -26,7 +26,7 @@ private PopupPanel(@NotNull String name) { center(); background(GTGuiTextures.BACKGROUND); child(ButtonWidget.panelCloseButton().top(5).right(5) - .onMousePressed((mouseX, mouseY, button) -> { + .onMousePressed((context, button) -> { if (button == 0 || button == 1) { this.closeIfOpen(); return true; diff --git a/src/main/java/com/gregtechceu/gtceu/common/mui/widgets/SimpleDialog.java b/src/main/java/com/gregtechceu/gtceu/common/mui/widgets/SimpleDialog.java index 8b1201a60cd..23ee98be8df 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/mui/widgets/SimpleDialog.java +++ b/src/main/java/com/gregtechceu/gtceu/common/mui/widgets/SimpleDialog.java @@ -1,6 +1,6 @@ package com.gregtechceu.gtceu.common.mui.widgets; -import brachy.modularui.api.drawable.IKey; +import brachy.modularui.api.drawable.Text; import brachy.modularui.drawable.GuiTextures; import brachy.modularui.utils.Alignment; import brachy.modularui.widget.Widget; @@ -13,15 +13,15 @@ public class SimpleDialog> extends Dialog> { - public SimpleDialog(String name, Consumer valueConsumer, W widget, Function valueGetter, IKey title) { + public SimpleDialog(String name, Consumer valueConsumer, W widget, Function valueGetter, Text title) { super(name); - child(new TextWidget<>(title).leftRel(0.5f).marginTop(4)); + child(new TextWidget<>(title.get()).leftRel(0.5f).marginTop(4)); child(widget.center()); child(new ButtonWidget<>() .background(GuiTextures.CLOSE) .hoverBackground(GuiTextures.CLOSE) .posRel(Alignment.TopRight) - .onMousePressed((mouseX, mouseY, button) -> { + .onMousePressed((context, button) -> { closeIfOpen(); return true; })); @@ -29,7 +29,7 @@ public SimpleDialog(String name, Consumer valueConsumer, W widget, Function { + .onMousePressed((context, button) -> { closeWith(valueGetter.apply(widget)); return true; })); diff --git a/src/main/java/com/gregtechceu/gtceu/common/recipe/condition/AdjacentBlockCondition.java b/src/main/java/com/gregtechceu/gtceu/common/recipe/condition/AdjacentBlockCondition.java index af779321ea4..60cff7701e9 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/recipe/condition/AdjacentBlockCondition.java +++ b/src/main/java/com/gregtechceu/gtceu/common/recipe/condition/AdjacentBlockCondition.java @@ -1,9 +1,14 @@ package com.gregtechceu.gtceu.common.recipe.condition; +import brachy.modularui.api.drawable.Text; +import brachy.modularui.integration.recipeviewer.RecipeSlotRole; +import brachy.modularui.integration.recipeviewer.RecipeViewerSlotWidget; +import brachy.modularui.widgets.layout.Flow; import com.gregtechceu.gtceu.api.machine.trait.RecipeLogic; import com.gregtechceu.gtceu.api.recipe.GTRecipe; import com.gregtechceu.gtceu.api.recipe.RecipeCondition; import com.gregtechceu.gtceu.api.recipe.condition.RecipeConditionType; +import com.gregtechceu.gtceu.api.recipe.gui.RecipeUIModifier; import com.gregtechceu.gtceu.common.data.GTRecipeConditions; import com.gregtechceu.gtceu.utils.GTUtil; import com.gregtechceu.gtceu.utils.codec.GTCodecUtils; @@ -16,6 +21,7 @@ import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; import net.minecraft.tags.TagKey; +import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.state.BlockState; @@ -93,6 +99,30 @@ public Component getTooltips() { return Component.translatable("recipe.condition.adjacent_block.tooltip"); } + @Override + public RecipeUIModifier modifyUI() { + return (recipe, widget) -> { + var row = Flow.row().coverChildrenHeight().widthRel(1); + + row.child(Text.lang("recipe.condition.adjacent_block.tooltip").asWidget()); + + List stacksToDisplay = new ArrayList<>(); + for (HolderSet set : resolvedBlocks) { + for (var blockEntry: set) { + stacksToDisplay.add(new ItemStack(blockEntry.value().asItem())); + } + } + + for (var stack: stacksToDisplay) { + row.child(RecipeViewerSlotWidget.create().marginLeft(2).recipeSlotRole(RecipeSlotRole.RENDER_ONLY) + .value(stack)); + } + + widget.textComponents.child(row); + }; + + } + @Override public boolean testCondition(@NotNull GTRecipe recipe, @NotNull RecipeLogic recipeLogic) { Level level = recipeLogic.getMachine().getLevel(); diff --git a/src/main/java/com/gregtechceu/gtceu/common/recipe/condition/AdjacentFluidCondition.java b/src/main/java/com/gregtechceu/gtceu/common/recipe/condition/AdjacentFluidCondition.java index 34268e3ed9b..289d708fa24 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/recipe/condition/AdjacentFluidCondition.java +++ b/src/main/java/com/gregtechceu/gtceu/common/recipe/condition/AdjacentFluidCondition.java @@ -1,9 +1,15 @@ package com.gregtechceu.gtceu.common.recipe.condition; +import brachy.modularui.api.drawable.Text; +import brachy.modularui.integration.recipeviewer.RecipeSlotRole; +import brachy.modularui.integration.recipeviewer.RecipeViewerSlotWidget; +import brachy.modularui.integration.recipeviewer.entry.fluid.FluidHolderSetList; +import brachy.modularui.widgets.layout.Flow; import com.gregtechceu.gtceu.api.machine.trait.RecipeLogic; import com.gregtechceu.gtceu.api.recipe.GTRecipe; import com.gregtechceu.gtceu.api.recipe.RecipeCondition; import com.gregtechceu.gtceu.api.recipe.condition.RecipeConditionType; +import com.gregtechceu.gtceu.api.recipe.gui.RecipeUIModifier; import com.gregtechceu.gtceu.common.data.GTRecipeConditions; import com.gregtechceu.gtceu.utils.GTUtil; import com.gregtechceu.gtceu.utils.codec.GTCodecUtils; @@ -101,6 +107,25 @@ public Component getTooltips() { return tooltips; } + @Override + public RecipeUIModifier modifyUI() { + return (recipe, widget) -> { + var row = Flow.row().coverChildrenHeight().widthRel(1); + + row.child(Text.lang("recipe.condition.adjacent_fluid.tooltip").asWidget()); + + for (HolderSet set : resolvedFluids) { + if (set.size() == 0) { + continue; + } + row.child(RecipeViewerSlotWidget.create().marginLeft(2).recipeSlotRole(RecipeSlotRole.RENDER_ONLY) + .value(FluidHolderSetList.of(set, 1000, null))); + } + + widget.textComponents.child(row); + }; + } + @Override public boolean testCondition(@NotNull GTRecipe recipe, @NotNull RecipeLogic recipeLogic) { Level level = recipeLogic.getMachine().getLevel(); diff --git a/src/main/java/com/gregtechceu/gtceu/common/recipe/condition/DimensionCondition.java b/src/main/java/com/gregtechceu/gtceu/common/recipe/condition/DimensionCondition.java index d046376bdd0..be6ebe9e16e 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/recipe/condition/DimensionCondition.java +++ b/src/main/java/com/gregtechceu/gtceu/common/recipe/condition/DimensionCondition.java @@ -1,19 +1,18 @@ package com.gregtechceu.gtceu.common.recipe.condition; +import brachy.modularui.api.drawable.IDrawable; +import brachy.modularui.integration.recipeviewer.RecipeViewerSlotWidget; +import brachy.modularui.widgets.layout.Flow; import com.gregtechceu.gtceu.api.data.DimensionMarker; -import com.gregtechceu.gtceu.api.gui.widget.SlotWidget; import com.gregtechceu.gtceu.api.machine.trait.RecipeLogic; import com.gregtechceu.gtceu.api.recipe.GTRecipe; import com.gregtechceu.gtceu.api.recipe.RecipeCondition; import com.gregtechceu.gtceu.api.recipe.condition.RecipeConditionType; +import com.gregtechceu.gtceu.api.recipe.gui.RecipeUIModifier; import com.gregtechceu.gtceu.api.registry.GTRegistries; -import com.gregtechceu.gtceu.api.transfer.item.CustomItemStackHandler; import com.gregtechceu.gtceu.common.data.GTRecipeConditions; import com.gregtechceu.gtceu.config.ConfigHolder; -import com.lowdragmc.lowdraglib.gui.texture.TextTexture; -import com.lowdragmc.lowdraglib.jei.IngredientIO; - import net.minecraft.core.registries.Registries; import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceKey; @@ -21,6 +20,8 @@ import net.minecraft.world.level.Level; import net.minecraft.world.level.block.Blocks; +import brachy.modularui.api.drawable.Text; +import brachy.modularui.integration.recipeviewer.RecipeSlotRole; import com.mojang.serialization.Codec; import com.mojang.serialization.codecs.RecordCodecBuilder; import lombok.Getter; @@ -63,20 +64,32 @@ public Component getTooltips() { return Component.translatable("recipe.condition.dimension.tooltip", dimension); } - public SlotWidget setupDimensionMarkers(int xOffset, int yOffset) { - DimensionMarker dimMarker = GTRegistries.DIMENSION_MARKERS.getOrDefault(this.dimension.location(), - new DimensionMarker(DimensionMarker.MAX_TIER, () -> Blocks.BARRIER, this.dimension.toString())); - ItemStack icon = dimMarker.getIcon(); - CustomItemStackHandler handler = new CustomItemStackHandler(1); - SlotWidget dimSlot = new SlotWidget(handler, 0, xOffset, yOffset, false, false) - .setIngredientIO(IngredientIO.INPUT); - handler.setStackInSlot(0, icon); - if (ConfigHolder.INSTANCE.compat.showDimensionTier) { - dimSlot.setOverlay( - new TextTexture("T" + (dimMarker.tier >= DimensionMarker.MAX_TIER ? "?" : dimMarker.tier)) - .scale(0.75f).transform(-3.0f, 5.0f)); - } - return dimSlot; + @Override + public RecipeUIModifier modifyUI() { + return (recipe, widget) -> { + DimensionMarker dimMarker = GTRegistries.DIMENSION_MARKERS.getOrDefault(this.dimension.location(), + new DimensionMarker(DimensionMarker.MAX_TIER, () -> Blocks.BARRIER, + this.dimension.toString())); + ItemStack icon = dimMarker.getIcon(); + String dimTier = "T" + (dimMarker.tier >= DimensionMarker.MAX_TIER ? "?" : dimMarker.tier); + + Flow dimConditionRow = Flow.row().coverChildrenHeight().widthRel(1f); + + dimConditionRow.child(Text.lang("recipe.condition.dimension.tooltip", "").asWidget()); + + RecipeViewerSlotWidget displayWidget = RecipeViewerSlotWidget.create() + .value(icon) + .marginLeft(2) + .recipeSlotRole(RecipeSlotRole.CATALYST) + .background(IDrawable.NONE) + .hoverBackground(IDrawable.NONE); + + if (ConfigHolder.INSTANCE.compat.showDimensionTier) { + displayWidget.overlay(Text.str(dimTier).scale(0.75f)); + } + dimConditionRow.child(displayWidget); + widget.textComponents.child(dimConditionRow); + }; } @Override diff --git a/src/main/java/com/gregtechceu/gtceu/config/ConfigHolder.java b/src/main/java/com/gregtechceu/gtceu/config/ConfigHolder.java index a45bffa4673..c8d67a9608a 100644 --- a/src/main/java/com/gregtechceu/gtceu/config/ConfigHolder.java +++ b/src/main/java/com/gregtechceu/gtceu/config/ConfigHolder.java @@ -900,9 +900,6 @@ public static class DeveloperConfigs { "Default: false" }) public boolean debug = false; @Configurable - @Configurable.Comment({ "Debug UI? (Will draw widget outlines and widget information)", "Default: false" }) - public boolean debugUI = GTCEu.isDev(); - @Configurable @Configurable.Comment({ "Debug ore vein placement? (will print placed veins to server's debug.log)", "Default: false (no placement printout in debug.log)" }) public boolean debugWorldgen = false; @@ -919,59 +916,5 @@ public static class DeveloperConfigs { @Configurable.Comment({ "Executes ./gradlew :processResources when F3+T is pressed", "Only works in a development environment", "Default: false" }) public boolean autoRebuildResources = false; - - @Configurable - public DeveloperConfigs.MuiConfigs mui = new DeveloperConfigs.MuiConfigs(); - - public static class MuiConfigs { - - @Configurable - @Configurable.Comment({ "Color for outlining widgets in debug mode, in ARGB" }) - @Configurable.StringPattern(value = "#[0-9a-fA-F]{1,8}") - @Configurable.Gui.ColorValue - public String textColor = "#dcb42873"; - - @Configurable - @Configurable.Comment({ "Color for outlining widgets in debug mode, in ARGB" }) - @Configurable.StringPattern(value = "#[0-9a-fA-F]{1,8}") - @Configurable.Gui.ColorValue - public String outlineColor = "#dcb42873"; - - @Configurable - @Configurable.Comment({ "Color for cursor in debug mode, in ARGB" }) - @Configurable.StringPattern(value = "#[0-9a-fA-F]{1,8}") - @Configurable.Gui.ColorValue - public String cursorColor = "#ff4cAf50"; - - @Configurable - @Configurable.Comment({ "Scale of debug text", - "Default: 0.8f" }) - @Configurable.DecimalRange(min = 0.1f, max = 10.0f) - public float scale = 0.8f; - - @Configurable - public boolean showHovered = true; - @Configurable - public boolean showPos = true; - @Configurable - public boolean showSize = true; - @Configurable - public boolean showWidgetTheme = true; - @Configurable - public boolean showExtra = true; - @Configurable - public boolean showOutline = true; - - @Configurable - public boolean showParent = true; - @Configurable - public boolean showParentPos = true; - @Configurable - public boolean showParentSize = true; - @Configurable - public boolean showParentWidgetTheme = true; - @Configurable - public boolean showParentOutline = true; - } } } diff --git a/src/main/java/com/gregtechceu/gtceu/core/mixins/client/GuiGraphicsMixin.java b/src/main/java/com/gregtechceu/gtceu/core/mixins/client/GuiGraphicsMixin.java index ac9d4c29c34..41946bd8311 100644 --- a/src/main/java/com/gregtechceu/gtceu/core/mixins/client/GuiGraphicsMixin.java +++ b/src/main/java/com/gregtechceu/gtceu/core/mixins/client/GuiGraphicsMixin.java @@ -105,7 +105,7 @@ public abstract class GuiGraphicsMixin { // Other positions don't really work due to the lack of GuiContext in non-modular uis tooltip.add(textLines.get(0)).newLine(); // vanilla inserts the bundle tooltip here so we need to do it as the 2nd item too - tooltipComponent.ifPresent(tooltip::addLine); + tooltipComponent.ifPresent(component -> tooltip.addLine(component.toString())); if (!this.tooltipStack.isEmpty()) { tooltip.spaceLine(); diff --git a/src/main/java/com/gregtechceu/gtceu/data/recipe/builder/GTRecipeBuilder.java b/src/main/java/com/gregtechceu/gtceu/data/recipe/builder/GTRecipeBuilder.java index 0cc2e4328c3..eb5f7dfa9fe 100644 --- a/src/main/java/com/gregtechceu/gtceu/data/recipe/builder/GTRecipeBuilder.java +++ b/src/main/java/com/gregtechceu/gtceu/data/recipe/builder/GTRecipeBuilder.java @@ -1716,7 +1716,7 @@ private void addOutputMaterialInfo() { var itemOutputs = output.getOrDefault(ItemRecipeCapability.CAP, new ArrayList<>()); var itemInputs = input.getOrDefault(ItemRecipeCapability.CAP, new ArrayList<>()); if (itemOutputs.size() == 1 && (!itemInputs.isEmpty() || !tempFluidStacks.isEmpty())) { - var currOutput = ItemRecipeCapability.CAP.of(itemOutputs.get(0).content); + var currOutput = ItemRecipeCapability.CAP.of(itemOutputs.get(0).content()); Item out = null; int outputCount = 0; @@ -1767,7 +1767,7 @@ private void addOutputMaterialInfo() { private void removeExistingMaterialInfo() { var itemOutputs = output.get(ItemRecipeCapability.CAP); if (itemOutputs.size() == 1) { - var currOutput = ItemRecipeCapability.CAP.of(itemOutputs.get(0).content); + var currOutput = ItemRecipeCapability.CAP.of(itemOutputs.get(0).content()); Item out = null; int outputCount = 0; @@ -1852,7 +1852,7 @@ protected boolean checkChanceAndPrintError(int chance) { public EnergyStack EUt() { if (!tickInput.containsKey(EURecipeCapability.CAP)) return EnergyStack.EMPTY; if (tickInput.get(EURecipeCapability.CAP).isEmpty()) return EnergyStack.EMPTY; - return EURecipeCapability.CAP.of(tickInput.get(EURecipeCapability.CAP).get(0).content); + return EURecipeCapability.CAP.of(tickInput.get(EURecipeCapability.CAP).get(0).content()); } public int getSolderMultiplier() { diff --git a/src/main/java/com/gregtechceu/gtceu/integration/ae2/gui/AEConfigWidget.java b/src/main/java/com/gregtechceu/gtceu/integration/ae2/gui/AEConfigWidget.java index 23c91b9fb1b..dc3dc8f9321 100644 --- a/src/main/java/com/gregtechceu/gtceu/integration/ae2/gui/AEConfigWidget.java +++ b/src/main/java/com/gregtechceu/gtceu/integration/ae2/gui/AEConfigWidget.java @@ -16,7 +16,7 @@ import appeng.api.stacks.AEItemKey; import appeng.api.stacks.GenericStack; -import brachy.modularui.api.drawable.IKey; +import brachy.modularui.api.drawable.Text; import brachy.modularui.api.widget.Interactable; import brachy.modularui.integration.emi.EmiStackConverter; import brachy.modularui.integration.recipeviewer.handlers.GhostIngredientSlot; @@ -106,14 +106,14 @@ private ModularPanel buildAmountEditor(ModularPanel parent, net.minecraft. .posRel(0.5f, 0.35f) .background(GTGuiTextures.BACKGROUND) .child(ButtonWidget.panelCloseButton()) - .child(IKey.str("Amount").asWidget().pos(4, 4)) + .child(Text.str("Amount").asWidget().pos(4, 4)) .child(Flow.row() .left(4).right(4).bottom(4).height(18) .child(amountField) .child(new ButtonWidget<>() .size(18, 18) - .overlay(IKey.str("✓")) - .onMousePressed((mouseX, mouseY, button) -> { + .overlay(Text.str("✓")) + .onMousePressed((context, button) -> { if (button == 0) { confirmAmountEdit(); return true; @@ -232,16 +232,16 @@ public void drawForeground(ModularGuiContext context) { if (tooltipStack != null) { ItemStack wrapped = GenericStack.wrapInItemStack(tooltipStack); graphics.renderTooltip(Minecraft.getInstance().font, wrapped, - (int) context.getAbsMouseX(), (int) context.getAbsMouseY()); + context.getAbsMouseX(), context.getAbsMouseY()); } } } } @Override - public Result onMousePressed(double mouseX, double mouseY, int button) { - double localX = mouseX - getArea().x; - double localY = mouseY - getArea().y; + public Result onMousePressed(int button) { + double localX = getContext().getMouseX() - getArea().x; + double localY = getContext().getMouseY() - getArea().y; int slotIndex = getSlotAtLocal(localX, localY); if (slotIndex < 0) return Result.IGNORE; @@ -275,11 +275,11 @@ public Result onMousePressed(double mouseX, double mouseY, int button) { } @Override - public boolean onMouseScrolled(double mouseX, double mouseY, double delta) { + public boolean onMouseScrolled(double delta) { if (isStocking()) return false; - double localX = mouseX - getArea().x; - double localY = mouseY - getArea().y; + double localX = getContext().getMouseX() - getArea().x; + double localY = getContext().getMouseY() - getArea().y; int slotIndex = getSlotAtLocal(localX, localY); if (slotIndex < 0) return false; diff --git a/src/main/java/com/gregtechceu/gtceu/integration/ae2/machine/MEInputBusPartMachine.java b/src/main/java/com/gregtechceu/gtceu/integration/ae2/machine/MEInputBusPartMachine.java index c5fd32c6e50..d688e216bb3 100644 --- a/src/main/java/com/gregtechceu/gtceu/integration/ae2/machine/MEInputBusPartMachine.java +++ b/src/main/java/com/gregtechceu/gtceu/integration/ae2/machine/MEInputBusPartMachine.java @@ -23,7 +23,7 @@ import appeng.api.stacks.AEItemKey; import appeng.api.stacks.GenericStack; import appeng.api.storage.MEStorage; -import brachy.modularui.api.drawable.IKey; +import brachy.modularui.api.drawable.Text; import brachy.modularui.factory.PosGuiData; import brachy.modularui.screen.UISettings; import brachy.modularui.value.sync.BooleanSyncValue; @@ -131,7 +131,7 @@ public void buildMainUI(ParentWidget mainWidget, PosGuiData guiData, PanelSyn var flow = Flow.col().coverChildren(); - flow.child(IKey.dynamic(() -> isOnlineValue.getBoolValue() ? + flow.child(Text.dynamic(() -> isOnlineValue.getBoolValue() ? Component.translatable("gtceu.gui.me_network.online") : Component.translatable("gtceu.gui.me_network.offline")) .asWidget().marginTop(2).marginBottom(4)); diff --git a/src/main/java/com/gregtechceu/gtceu/integration/ae2/machine/MEInputHatchPartMachine.java b/src/main/java/com/gregtechceu/gtceu/integration/ae2/machine/MEInputHatchPartMachine.java index 820ac0b5f07..02ad4789c0b 100644 --- a/src/main/java/com/gregtechceu/gtceu/integration/ae2/machine/MEInputHatchPartMachine.java +++ b/src/main/java/com/gregtechceu/gtceu/integration/ae2/machine/MEInputHatchPartMachine.java @@ -26,7 +26,7 @@ import appeng.api.config.Actionable; import appeng.api.stacks.GenericStack; import appeng.api.storage.MEStorage; -import brachy.modularui.api.drawable.IKey; +import brachy.modularui.api.drawable.Text; import brachy.modularui.factory.PosGuiData; import brachy.modularui.screen.UISettings; import brachy.modularui.value.sync.BooleanSyncValue; @@ -134,7 +134,7 @@ public void buildMainUI(ParentWidget mainWidget, PosGuiData guiData, PanelSyn var flow = Flow.col().coverChildren(); - flow.child(IKey.dynamic(() -> isOnlineValue.getBoolValue() ? + flow.child(Text.dynamic(() -> isOnlineValue.getBoolValue() ? Component.translatable("gtceu.gui.me_network.online") : Component.translatable("gtceu.gui.me_network.offline")) .asWidget().marginTop(2).marginBottom(4)); diff --git a/src/main/java/com/gregtechceu/gtceu/integration/ae2/machine/MEOutputBusPartMachine.java b/src/main/java/com/gregtechceu/gtceu/integration/ae2/machine/MEOutputBusPartMachine.java index 00772fdbc4d..276606e73cc 100644 --- a/src/main/java/com/gregtechceu/gtceu/integration/ae2/machine/MEOutputBusPartMachine.java +++ b/src/main/java/com/gregtechceu/gtceu/integration/ae2/machine/MEOutputBusPartMachine.java @@ -17,7 +17,7 @@ import appeng.api.config.Actionable; import appeng.api.stacks.AEItemKey; -import brachy.modularui.api.drawable.IKey; +import brachy.modularui.api.drawable.Text; import brachy.modularui.factory.PosGuiData; import brachy.modularui.screen.UISettings; import brachy.modularui.value.sync.BooleanSyncValue; @@ -103,7 +103,7 @@ public void buildMainUI(ParentWidget mainWidget, PosGuiData guiData, PanelSyn var flow = Flow.col().coverChildren(); - flow.child(IKey.dynamic(() -> isOnlineValue.getBoolValue() ? + flow.child(Text.dynamic(() -> isOnlineValue.getBoolValue() ? Component.translatable("gtceu.gui.me_network.online") : Component.translatable("gtceu.gui.me_network.offline")) .asWidget().marginTop(2).marginBottom(4)); @@ -116,12 +116,12 @@ public void buildMainUI(ParentWidget mainWidget, PosGuiData guiData, PanelSyn .widgetProvider((sm, value) -> { var col = Flow.col().leftRel(0.5f).coverChildrenHeight(); var list = value.getValue(); - if (list.isEmpty()) return col.child(new TextWidget<>(IKey.lang("gtceu.gui.waiting_list_empty"))); - col.child(new TextWidget<>(IKey.lang("gtceu.gui.waiting_list")).margin(0, 2)); + if (list.isEmpty()) return col.child(new TextWidget<>(Text.lang("gtceu.gui.waiting_list_empty"))); + col.child(new TextWidget<>(Text.lang("gtceu.gui.waiting_list")).margin(0, 2)); col.child(new ScrollPreservingGrid(savedScroll) .size(167, 80) .scrollable(new VerticalScrollData()) - .mapTo(9, list, (index, stack) -> new AEStackDisplayWidget(list, index))); + .gridOfSizeWidth(9, 1, (x, y, index) -> new AEStackDisplayWidget(list, index))); return col; }); diff --git a/src/main/java/com/gregtechceu/gtceu/integration/ae2/machine/MEOutputHatchPartMachine.java b/src/main/java/com/gregtechceu/gtceu/integration/ae2/machine/MEOutputHatchPartMachine.java index cf167763a73..837d7b7135d 100644 --- a/src/main/java/com/gregtechceu/gtceu/integration/ae2/machine/MEOutputHatchPartMachine.java +++ b/src/main/java/com/gregtechceu/gtceu/integration/ae2/machine/MEOutputHatchPartMachine.java @@ -20,7 +20,7 @@ import appeng.api.config.Actionable; import appeng.api.stacks.AEFluidKey; -import brachy.modularui.api.drawable.IKey; +import brachy.modularui.api.drawable.Text; import brachy.modularui.factory.PosGuiData; import brachy.modularui.screen.UISettings; import brachy.modularui.value.sync.BooleanSyncValue; @@ -105,7 +105,7 @@ public void buildMainUI(ParentWidget mainWidget, PosGuiData guiData, PanelSyn var flow = Flow.col().coverChildren(); - flow.child(IKey.dynamic(() -> isOnlineValue.getBoolValue() ? + flow.child(Text.dynamic(() -> isOnlineValue.getBoolValue() ? Component.translatable("gtceu.gui.me_network.online") : Component.translatable("gtceu.gui.me_network.offline")) .asWidget().marginTop(2).marginBottom(4)); @@ -118,12 +118,12 @@ public void buildMainUI(ParentWidget mainWidget, PosGuiData guiData, PanelSyn .widgetProvider((sm, value) -> { var col = Flow.col().leftRel(0.5f).coverChildrenHeight(); var list = value.getValue(); - if (list.isEmpty()) return col.child(new TextWidget<>(IKey.lang("gtceu.gui.waiting_list_empty"))); - col.child(new TextWidget<>(IKey.lang("gtceu.gui.waiting_list")).margin(0, 2)); + if (list.isEmpty()) return col.child(new TextWidget<>(Text.lang("gtceu.gui.waiting_list_empty"))); + col.child(new TextWidget<>(Text.lang("gtceu.gui.waiting_list")).margin(0, 2)); col.child(new ScrollPreservingGrid(savedScroll) .size(167, 80) .scrollable(new VerticalScrollData()) - .mapTo(9, list, (index, stack) -> new AEStackDisplayWidget(list, index))); + .gridOfSizeWidth(9, 1, (x, y, index) -> new AEStackDisplayWidget(list, index))); return col; }); diff --git a/src/main/java/com/gregtechceu/gtceu/integration/ae2/machine/MEPatternBufferPartMachine.java b/src/main/java/com/gregtechceu/gtceu/integration/ae2/machine/MEPatternBufferPartMachine.java index 1023dc0967b..afaef471de4 100644 --- a/src/main/java/com/gregtechceu/gtceu/integration/ae2/machine/MEPatternBufferPartMachine.java +++ b/src/main/java/com/gregtechceu/gtceu/integration/ae2/machine/MEPatternBufferPartMachine.java @@ -54,7 +54,7 @@ import appeng.crafting.pattern.ProcessingPatternItem; import appeng.helpers.patternprovider.PatternContainer; import brachy.modularui.api.IPanelHandler; -import brachy.modularui.api.drawable.IKey; +import brachy.modularui.api.drawable.Text; import brachy.modularui.drawable.DrawableStack; import brachy.modularui.drawable.DynamicDrawable; import brachy.modularui.drawable.ItemDrawable; @@ -87,7 +87,8 @@ @ParametersAreNonnullByDefault @MethodsReturnNonnullByDefault -public class MEPatternBufferPartMachine extends MEBusPartMachine +public class +MEPatternBufferPartMachine extends MEBusPartMachine implements ICraftingProvider, PatternContainer, IDataStickInteractable { protected static final int MAX_PATTERN_COUNT = 27; @@ -281,7 +282,7 @@ public MachineUIPanelBuilder getPanelBuilder(PosGuiData data, PanelSyncManager s ((syncManager1, syncHandler) -> PopupPanel.createPopupPanel("renaming_panel", 110, 40) .child(Flow.col() .coverChildren() - .child(IKey.lang("gtceu.gui.pattern_buffer.set_custom_name").asWidget()) + .child(Text.lang("gtceu.gui.pattern_buffer.set_custom_name").asWidget()) .child(new TextFieldWidget() .size(90, 20) .value(SyncHandlers.string(() -> this.customName, this::setCustomName))) @@ -292,7 +293,7 @@ public MachineUIPanelBuilder getPanelBuilder(PosGuiData data, PanelSyncManager s SlotGroup sharedItemSlotGroup = new SlotGroup("shared_item_slots", 3, false); return PopupPanel.createPopupPanel("shared_items_panel", 80, 86) - .child(IKey.lang("gui.gtceu.share_inventory.title").asWidget().margin(4)) + .child(Text.lang("gui.gtceu.share_inventory.title").asWidget().margin(4)) .child(new Grid() .name("shared_item_grid") .top(26) @@ -300,7 +301,7 @@ public MachineUIPanelBuilder getPanelBuilder(PosGuiData data, PanelSyncManager s .minElementMargin(0, 0) .minColWidth(18).minRowHeight(18) .leftRel(0.5f) - .mapTo(3, 9, index -> new ItemSlot() + .gridOfSizeWidth(9, 3, (x, y, index) -> new ItemSlot() .slot(SyncHandlers.itemSlot(shareInventory, index) .slotGroup(sharedItemSlotGroup) .accessibility(true, true)))); @@ -308,7 +309,7 @@ public MachineUIPanelBuilder getPanelBuilder(PosGuiData data, PanelSyncManager s IPanelHandler sharedFluidsPanelHandler = syncManager.syncedPanel("shared_fluids", true, (syncManager1, panelHandler) -> PopupPanel.createPopupPanel("shared_fluids_panel", 85, 86) - .child(IKey.lang("gui.gtceu.share_tank.title").asWidget().margin(4)) + .child(Text.lang("gui.gtceu.share_tank.title").asWidget().margin(4)) .child(GTMuiMachineUtil.createSlotGroupFromInventory(syncManager1, shareTank, "shared_fluid_slots", 9, 'F', GTMuiMachineUtil.createSquareMatrix(9, 'F')) @@ -320,10 +321,10 @@ public MachineUIPanelBuilder getPanelBuilder(PosGuiData data, PanelSyncManager s syncManager.registerServerSyncedAction("refundButtonPressed", packet -> refundAll()); - return MachineUIPanelBuilder.defaultPanelBuilder(this).leftConfigurators(f -> { + return MachineUIPanelBuilder.panelBuilder(this).leftConfigurators(f -> { f.child(new ButtonWidget<>() // Shared items subpanel .size(18) - .onMousePressed((x, y, b) -> { + .onMousePressed((context, b) -> { if (b == InputConstants.MOUSE_BUTTON_LEFT) { sharedItemsPanelHandler.openPanel(); return true; @@ -332,11 +333,11 @@ public MachineUIPanelBuilder getPanelBuilder(PosGuiData data, PanelSyncManager s }) .overlay(GTGuiTextures.BUTTON_ITEM_OUTPUT) .tooltip(new RichTooltip() - .addLine(IKey.lang("gui.gtceu.share_inventory.desc.0")) - .addLine(IKey.lang("gui.gtceu.share_inventory.desc.1")))) + .addLine(Text.lang("gui.gtceu.share_inventory.desc.0")) + .addLine(Text.lang("gui.gtceu.share_inventory.desc.1")))) .child(new ButtonWidget<>() // Shared fluids subpanel .size(18) - .onMousePressed((x, y, b) -> { + .onMousePressed((context, b) -> { if (b == InputConstants.MOUSE_BUTTON_LEFT) { sharedFluidsPanelHandler.openPanel(); return true; @@ -345,11 +346,11 @@ public MachineUIPanelBuilder getPanelBuilder(PosGuiData data, PanelSyncManager s }) .overlay(GTGuiTextures.BUTTON_FLUID_OUTPUT) .tooltip(new RichTooltip() - .addLine(IKey.lang("gui.gtceu.share_tank.desc.0")) - .addLine(IKey.lang("gui.gtceu.share_inventory.desc.1")))) + .addLine(Text.lang("gui.gtceu.share_tank.desc.0")) + .addLine(Text.lang("gui.gtceu.share_inventory.desc.1")))) .child(new ButtonWidget<>() // Refund button .size(18) - .onMousePressed((x, y, b) -> { + .onMousePressed((context, b) -> { if (canRefundValue.getBoolValue() && b == InputConstants.MOUSE_BUTTON_LEFT) { syncManager.callSyncedAction("refundButtonPressed"); return true; @@ -367,21 +368,21 @@ public MachineUIPanelBuilder getPanelBuilder(PosGuiData data, PanelSyncManager s } })) .tooltip(new RichTooltip() - .addLine(IKey.lang("gui.gtceu.refund_all.desc")))) + .addLine(Text.lang("gui.gtceu.refund_all.desc")))) .child(new ButtonWidget<>() // Renaming button .size(18) - .onMousePressed((x, y, b) -> { + .onMousePressed((context, b) -> { if (b == InputConstants.MOUSE_BUTTON_LEFT) { renamingPanelHandler.openPanel(); return true; } return false; }) - .overlay(IKey.str("✎") + .overlay(Text.str("✎") .asIcon() .size(16)) .tooltip(new RichTooltip() - .addLine(IKey.lang("gui.gtceu.rename.desc")))); + .addLine(Text.lang("gui.gtceu.rename.desc")))); }); } @@ -395,7 +396,7 @@ public void buildMainUI(ParentWidget mainWidget, PosGuiData guiData, PanelSyn var flow = Flow.col().coverChildren(); - flow.child(IKey.dynamic(() -> isOnlineValue.getBoolValue() ? + flow.child(Text.dynamic(() -> isOnlineValue.getBoolValue() ? Component.translatable("gtceu.gui.me_network.online") : Component.translatable("gtceu.gui.me_network.offline")) .asWidget().marginTop(2).marginBottom(4)); @@ -405,7 +406,7 @@ public void buildMainUI(ParentWidget mainWidget, PosGuiData guiData, PanelSyn .minElementMargin(0, 0) .minColWidth(18).minRowHeight(18) .leftRel(0.5f) - .mapTo(9, MAX_PATTERN_COUNT, index -> new ItemSlot() + .gridOfSizeWidth(MAX_PATTERN_COUNT, 9, (x, y, index) -> new ItemSlot() .slot(SyncHandlers.itemSlot(patternInventory, index) .slotGroup(patternSlotGroup) .accessibility(true, true) diff --git a/src/main/java/com/gregtechceu/gtceu/integration/ae2/machine/feature/multiblock/IMEStockingPart.java b/src/main/java/com/gregtechceu/gtceu/integration/ae2/machine/feature/multiblock/IMEStockingPart.java index e4f72dce81e..57ebcf321ed 100644 --- a/src/main/java/com/gregtechceu/gtceu/integration/ae2/machine/feature/multiblock/IMEStockingPart.java +++ b/src/main/java/com/gregtechceu/gtceu/integration/ae2/machine/feature/multiblock/IMEStockingPart.java @@ -12,7 +12,7 @@ import appeng.api.stacks.GenericStack; import brachy.modularui.api.IPanelHandler; -import brachy.modularui.api.drawable.IKey; +import brachy.modularui.api.drawable.Text; import brachy.modularui.drawable.ItemDrawable; import brachy.modularui.factory.PosGuiData; import brachy.modularui.screen.RichTooltip; @@ -88,35 +88,35 @@ default MachineUIPanelBuilder getPanelBuilder(PosGuiData data, PanelSyncManager (sm, sh) -> PopupPanel.createPopupPanel("stocking_settings_panel", 140, 70) .child(Flow.col() .coverChildren() - .child(IKey.lang("gtceu.gui.me_network.min_stack_size").asWidget()) + .child(Text.lang("gtceu.gui.me_network.min_stack_size").asWidget()) .child(new TextFieldWidget() .size(120, 18) .value(SyncHandlers.intNumber(this::getMinStackSize, this::setMinStackSize)) .setNumbers(1, Integer.MAX_VALUE)) - .child(IKey.lang("gtceu.gui.me_network.ticks_per_cycle").asWidget()) + .child(Text.lang("gtceu.gui.me_network.ticks_per_cycle").asWidget()) .child(new TextFieldWidget() .size(120, 18) .value(SyncHandlers.intNumber(this::getTicksPerCycle, this::setTicksPerCycle)) .setNumbers(1, 200)) .margin(5))); - return MachineUIPanelBuilder.defaultPanelBuilder(this.self()) + return MachineUIPanelBuilder.panelBuilder(this.self()) .rightConfigurators(f -> { f.child(new ToggleButton() .value(new BoolValue.Dynamic(this::isAutoPull, this::setAutoPull)) .stateOverlay(GTGuiTextures.BUTTON_AUTO_PULL) .tooltipAutoUpdate(true) .tooltipBuilder(r -> r - .addLine(IKey.lang("gtceu.gui.me_network.auto_pull_toggle")))) + .addLine(Text.lang("gtceu.gui.me_network.auto_pull_toggle")))) .child(new ButtonWidget<>() .size(18) - .onMousePressed((x, y, b) -> { + .onMousePressed((context, b) -> { settingsPanelHandler.openPanel(); return true; }) .overlay(new ItemDrawable(GTItems.TOOL_DATA_STICK.asItem()).asIcon().size(16)) .tooltip(new RichTooltip() - .addLine(IKey.lang("gtceu.gui.me_network.stocking_settings")))); + .addLine(Text.lang("gtceu.gui.me_network.stocking_settings")))); }); } diff --git a/src/main/java/com/gregtechceu/gtceu/integration/emi/multipage/MultiblockInfoEmiCategory.java b/src/main/java/com/gregtechceu/gtceu/integration/emi/multipage/MultiblockInfoEmiCategory.java deleted file mode 100644 index e42fe5ee698..00000000000 --- a/src/main/java/com/gregtechceu/gtceu/integration/emi/multipage/MultiblockInfoEmiCategory.java +++ /dev/null @@ -1,35 +0,0 @@ -package com.gregtechceu.gtceu.integration.emi.multipage; - -import com.gregtechceu.gtceu.GTCEu; -import com.gregtechceu.gtceu.api.machine.MultiblockMachineDefinition; -import com.gregtechceu.gtceu.api.registry.GTRegistries; -import com.gregtechceu.gtceu.common.data.machines.GTMultiMachines; - -import net.minecraft.network.chat.Component; - -import dev.emi.emi.api.EmiRegistry; -import dev.emi.emi.api.recipe.EmiRecipeCategory; -import dev.emi.emi.api.stack.EmiStack; - -public class MultiblockInfoEmiCategory extends EmiRecipeCategory { - - public static final MultiblockInfoEmiCategory CATEGORY = new MultiblockInfoEmiCategory(); - - private MultiblockInfoEmiCategory() { - super(GTCEu.id("multiblock_info"), EmiStack.of(GTMultiMachines.ELECTRIC_BLAST_FURNACE.getItem())); - } - - public static void registerDisplays(EmiRegistry registry) { - GTRegistries.MACHINES.values().stream() - .filter(MultiblockMachineDefinition.class::isInstance) - .map(MultiblockMachineDefinition.class::cast) - .filter(MultiblockMachineDefinition::isRenderXEIPreview) - .map(MultiblockInfoEmiRecipe::new) - .forEach(registry::addRecipe); - } - - @Override - public Component getName() { - return Component.translatable("gtceu.jei.multiblock_info"); - } -} diff --git a/src/main/java/com/gregtechceu/gtceu/integration/emi/multipage/MultiblockInfoEmiRecipe.java b/src/main/java/com/gregtechceu/gtceu/integration/emi/multipage/MultiblockInfoEmiRecipe.java deleted file mode 100644 index a3957423362..00000000000 --- a/src/main/java/com/gregtechceu/gtceu/integration/emi/multipage/MultiblockInfoEmiRecipe.java +++ /dev/null @@ -1,54 +0,0 @@ -package com.gregtechceu.gtceu.integration.emi.multipage; - -import com.gregtechceu.gtceu.api.gui.widget.PatternPreviewWidget; -import com.gregtechceu.gtceu.api.machine.MultiblockMachineDefinition; - -import com.lowdragmc.lowdraglib.emi.ModularEmiRecipe; -import com.lowdragmc.lowdraglib.gui.widget.WidgetGroup; - -import net.minecraft.resources.ResourceLocation; - -import dev.emi.emi.api.recipe.EmiRecipeCategory; -import dev.emi.emi.api.stack.EmiStack; -import dev.emi.emi.api.widget.SlotWidget; -import dev.emi.emi.api.widget.WidgetHolder; -import org.jetbrains.annotations.Nullable; - -import java.util.List; - -public class MultiblockInfoEmiRecipe extends ModularEmiRecipe { - - private final MultiblockMachineDefinition definition; - private SlotWidget slotWidget; - - public MultiblockInfoEmiRecipe(MultiblockMachineDefinition definition) { - super(() -> PatternPreviewWidget.getPatternWidget(definition)); - this.definition = definition; - } - - @Override - public void addWidgets(WidgetHolder widgets) { - super.addWidgets(widgets); - // numbers gotten from the size of the widget - slotWidget = new SlotWidget(EmiStack.of(definition.getItem().asItem()), 138, 12) - .recipeContext(this) - .drawBack(false); - - widgets.add(slotWidget); - } - - @Override - public EmiRecipeCategory getCategory() { - return MultiblockInfoEmiCategory.CATEGORY; - } - - @Override - public @Nullable ResourceLocation getId() { - return definition.getId(); - } - - @Override - public List getOutputs() { - return List.of(EmiStack.of(definition.getItem())); - } -} diff --git a/src/main/java/com/gregtechceu/gtceu/integration/emi/oreprocessing/GTEmiOreProcessing.java b/src/main/java/com/gregtechceu/gtceu/integration/emi/oreprocessing/GTEmiOreProcessing.java deleted file mode 100644 index fedffb74b58..00000000000 --- a/src/main/java/com/gregtechceu/gtceu/integration/emi/oreprocessing/GTEmiOreProcessing.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.gregtechceu.gtceu.integration.emi.oreprocessing; - -import com.gregtechceu.gtceu.api.data.chemical.material.Material; -import com.gregtechceu.gtceu.integration.recipeviewer.widgets.GTOreByProductWidget; - -import com.lowdragmc.lowdraglib.emi.ModularEmiRecipe; - -import net.minecraft.resources.ResourceLocation; - -import dev.emi.emi.api.recipe.EmiRecipeCategory; -import org.jetbrains.annotations.Nullable; - -public class GTEmiOreProcessing extends ModularEmiRecipe { - - final Material material; - - public GTEmiOreProcessing(Material material) { - super(() -> new GTOreByProductWidget(material)); - this.material = material; - } - - @Override - public EmiRecipeCategory getCategory() { - return GTOreProcessingEmiCategory.CATEGORY; - } - - @Override - public @Nullable ResourceLocation getId() { - return material.getResourceLocation(); - } - - @Override - public boolean supportsRecipeTree() { - return false; - } -} diff --git a/src/main/java/com/gregtechceu/gtceu/integration/emi/orevein/GTBedrockFluid.java b/src/main/java/com/gregtechceu/gtceu/integration/emi/orevein/GTBedrockFluid.java deleted file mode 100644 index 8500635056f..00000000000 --- a/src/main/java/com/gregtechceu/gtceu/integration/emi/orevein/GTBedrockFluid.java +++ /dev/null @@ -1,33 +0,0 @@ -package com.gregtechceu.gtceu.integration.emi.orevein; - -import com.gregtechceu.gtceu.api.data.worldgen.bedrockfluid.BedrockFluidDefinition; -import com.gregtechceu.gtceu.client.ClientProxy; -import com.gregtechceu.gtceu.integration.recipeviewer.widgets.GTOreVeinWidget; - -import com.lowdragmc.lowdraglib.emi.ModularEmiRecipe; -import com.lowdragmc.lowdraglib.gui.widget.WidgetGroup; - -import net.minecraft.resources.ResourceLocation; - -import dev.emi.emi.api.recipe.EmiRecipeCategory; -import org.jetbrains.annotations.Nullable; - -public class GTBedrockFluid extends ModularEmiRecipe { - - private final BedrockFluidDefinition fluid; - - public GTBedrockFluid(BedrockFluidDefinition fluid) { - super(() -> new GTOreVeinWidget(fluid)); - this.fluid = fluid; - } - - @Override - public EmiRecipeCategory getCategory() { - return GTBedrockFluidEmiCategory.CATEGORY; - } - - @Override - public @Nullable ResourceLocation getId() { - return ClientProxy.CLIENT_FLUID_VEINS.inverse().get(fluid).withPrefix("/bedrock_fluid_diagram/"); - } -} diff --git a/src/main/java/com/gregtechceu/gtceu/integration/emi/orevein/GTBedrockOre.java b/src/main/java/com/gregtechceu/gtceu/integration/emi/orevein/GTBedrockOre.java deleted file mode 100644 index 40b5034d035..00000000000 --- a/src/main/java/com/gregtechceu/gtceu/integration/emi/orevein/GTBedrockOre.java +++ /dev/null @@ -1,33 +0,0 @@ -package com.gregtechceu.gtceu.integration.emi.orevein; - -import com.gregtechceu.gtceu.api.data.worldgen.bedrockore.BedrockOreDefinition; -import com.gregtechceu.gtceu.client.ClientProxy; -import com.gregtechceu.gtceu.integration.recipeviewer.widgets.GTOreVeinWidget; - -import com.lowdragmc.lowdraglib.emi.ModularEmiRecipe; -import com.lowdragmc.lowdraglib.gui.widget.WidgetGroup; - -import net.minecraft.resources.ResourceLocation; - -import dev.emi.emi.api.recipe.EmiRecipeCategory; -import org.jetbrains.annotations.Nullable; - -public class GTBedrockOre extends ModularEmiRecipe { - - private final BedrockOreDefinition bedrockOre; - - public GTBedrockOre(BedrockOreDefinition bedrockOre) { - super(() -> new GTOreVeinWidget(bedrockOre)); - this.bedrockOre = bedrockOre; - } - - @Override - public EmiRecipeCategory getCategory() { - return GTBedrockOreEmiCategory.CATEGORY; - } - - @Override - public @Nullable ResourceLocation getId() { - return ClientProxy.CLIENT_BEDROCK_ORE_VEINS.inverse().get(bedrockOre).withPrefix("/bedrock_ore_diagram/"); - } -} diff --git a/src/main/java/com/gregtechceu/gtceu/integration/emi/orevein/GTEmiOreVein.java b/src/main/java/com/gregtechceu/gtceu/integration/emi/orevein/GTEmiOreVein.java deleted file mode 100644 index fa48694355b..00000000000 --- a/src/main/java/com/gregtechceu/gtceu/integration/emi/orevein/GTEmiOreVein.java +++ /dev/null @@ -1,44 +0,0 @@ -package com.gregtechceu.gtceu.integration.emi.orevein; - -import com.gregtechceu.gtceu.api.data.worldgen.GTOreDefinition; -import com.gregtechceu.gtceu.client.ClientProxy; -import com.gregtechceu.gtceu.integration.recipeviewer.widgets.GTOreVeinWidget; - -import com.lowdragmc.lowdraglib.emi.ModularEmiRecipe; -import com.lowdragmc.lowdraglib.gui.widget.WidgetGroup; - -import net.minecraft.resources.ResourceLocation; - -import dev.emi.emi.api.recipe.EmiRecipeCategory; -import dev.emi.emi.api.stack.EmiStack; -import org.jetbrains.annotations.Nullable; - -import java.util.List; - -public class GTEmiOreVein extends ModularEmiRecipe { - - private final GTOreDefinition oreDefinition; - - public GTEmiOreVein(GTOreDefinition oreDefinition) { - super(() -> new GTOreVeinWidget(oreDefinition)); - this.oreDefinition = oreDefinition; - } - - @Override - public EmiRecipeCategory getCategory() { - return GTOreVeinEmiCategory.CATEGORY; - } - - @Override - public @Nullable ResourceLocation getId() { - return ClientProxy.CLIENT_ORE_VEINS.inverse().get(oreDefinition).withPrefix("/ore_vein_diagram/"); - } - - @Override - public List getOutputs() { - return GTOreVeinWidget.getContainedOresAndBlocks(oreDefinition) - .stream() - .map(EmiStack::of) - .toList(); - } -} diff --git a/src/main/java/com/gregtechceu/gtceu/integration/emi/orevein/GTOreVeinEmiCategory.java b/src/main/java/com/gregtechceu/gtceu/integration/emi/orevein/GTOreVeinEmiCategory.java deleted file mode 100644 index e22d41b36b9..00000000000 --- a/src/main/java/com/gregtechceu/gtceu/integration/emi/orevein/GTOreVeinEmiCategory.java +++ /dev/null @@ -1,39 +0,0 @@ -package com.gregtechceu.gtceu.integration.emi.orevein; - -import com.gregtechceu.gtceu.GTCEu; -import com.gregtechceu.gtceu.api.data.worldgen.GTOreDefinition; -import com.gregtechceu.gtceu.client.ClientProxy; -import com.gregtechceu.gtceu.common.data.GTItems; - -import net.minecraft.network.chat.Component; -import net.minecraft.world.item.Items; - -import dev.emi.emi.api.EmiRegistry; -import dev.emi.emi.api.recipe.EmiRecipeCategory; -import dev.emi.emi.api.stack.EmiStack; - -public class GTOreVeinEmiCategory extends EmiRecipeCategory { - - public static final GTOreVeinEmiCategory CATEGORY = new GTOreVeinEmiCategory(); - - public GTOreVeinEmiCategory() { - super(GTCEu.id("ore_vein_diagram"), EmiStack.of(Items.RAW_IRON)); - } - - public static void registerDisplays(EmiRegistry registry) { - for (GTOreDefinition oreDefinition : ClientProxy.CLIENT_ORE_VEINS.values()) { - registry.addRecipe(new GTEmiOreVein(oreDefinition)); - } - } - - public static void registerWorkStations(EmiRegistry registry) { - registry.addWorkstation(CATEGORY, EmiStack.of(GTItems.PROSPECTOR_LV.asStack())); - registry.addWorkstation(CATEGORY, EmiStack.of(GTItems.PROSPECTOR_HV.asStack())); - registry.addWorkstation(CATEGORY, EmiStack.of(GTItems.PROSPECTOR_LuV.asStack())); - } - - @Override - public Component getName() { - return Component.translatable("gtceu.jei.ore_vein_diagram"); - } -} diff --git a/src/main/java/com/gregtechceu/gtceu/integration/emi/recipe/GTEmiRecipe.java b/src/main/java/com/gregtechceu/gtceu/integration/emi/recipe/GTEmiRecipe.java deleted file mode 100644 index b1f8593b29c..00000000000 --- a/src/main/java/com/gregtechceu/gtceu/integration/emi/recipe/GTEmiRecipe.java +++ /dev/null @@ -1,112 +0,0 @@ -package com.gregtechceu.gtceu.integration.emi.recipe; - -import com.gregtechceu.gtceu.api.recipe.GTRecipe; -import com.gregtechceu.gtceu.integration.recipeviewer.widgets.GTRecipeWidget; - -import com.lowdragmc.lowdraglib.emi.ModularEmiRecipe; -import com.lowdragmc.lowdraglib.emi.ModularForegroundRenderWidget; -import com.lowdragmc.lowdraglib.emi.ModularWrapperWidget; -import com.lowdragmc.lowdraglib.gui.ingredient.IRecipeIngredientSlot; -import com.lowdragmc.lowdraglib.gui.widget.DraggableScrollableWidgetGroup; -import com.lowdragmc.lowdraglib.gui.widget.WidgetGroup; -import com.lowdragmc.lowdraglib.jei.IngredientIO; -import com.lowdragmc.lowdraglib.jei.ModularWrapper; - -import net.minecraft.network.chat.Component; -import net.minecraft.resources.ResourceLocation; -import net.minecraftforge.fluids.capability.templates.EmptyFluidHandler; -import net.minecraftforge.items.IItemHandlerModifiable; -import net.minecraftforge.items.wrapper.EmptyHandler; - -import dev.emi.emi.api.recipe.EmiRecipeCategory; -import dev.emi.emi.api.stack.EmiIngredient; -import dev.emi.emi.api.widget.SlotWidget; -import dev.emi.emi.api.widget.TankWidget; -import dev.emi.emi.api.widget.Widget; -import dev.emi.emi.api.widget.WidgetHolder; -import org.jetbrains.annotations.Nullable; - -import java.util.ArrayList; -import java.util.List; - -public class GTEmiRecipe extends ModularEmiRecipe { - - final EmiRecipeCategory category; - final GTRecipe recipe; - - public GTEmiRecipe(GTRecipe recipe, EmiRecipeCategory category) { - super(() -> new GTRecipeWidget(recipe)); - this.category = category; - this.recipe = recipe; - } - - @Override - public EmiRecipeCategory getCategory() { - return category; - } - - @Override - public @Nullable ResourceLocation getId() { - return recipe.getId(); - } - - @Override - public void addWidgets(WidgetHolder widgets) { - var widget = this.widget.get(); - var modular = new ModularWrapper<>(widget); - modular.setRecipeWidget(0, 0); - - synchronized (CACHE_OPENED) { - CACHE_OPENED.add(modular); - } - List slots = new ArrayList<>(); - for (com.lowdragmc.lowdraglib.gui.widget.Widget w : getFlatWidgetCollection(widget)) { - if (w instanceof IRecipeIngredientSlot slot) { - if (w.getParent() instanceof DraggableScrollableWidgetGroup draggable && draggable.isUseScissor()) { - // don't add the EMI widget at all if we have a draggable group, let the draggable widget handle it - // instead. - continue; - } - var io = slot.getIngredientIO(); - if (io != null && io != IngredientIO.RENDER_ONLY) { - // noinspection unchecked - var ingredients = EmiIngredient - .of((List) (List) slot.getXEIIngredients()); - - SlotWidget slotWidget = null; - // Clear the LDLib slots & add EMI slots based on them. - if (slot instanceof com.gregtechceu.gtceu.api.gui.widget.SlotWidget slotW) { - slotW.setHandlerSlot((IItemHandlerModifiable) EmptyHandler.INSTANCE, 0); - slotW.setDrawHoverOverlay(false).setDrawHoverTips(false); - } else if (slot instanceof com.gregtechceu.gtceu.api.gui.widget.TankWidget tankW) { - tankW.setFluidTank(EmptyFluidHandler.INSTANCE); - tankW.setDrawHoverOverlay(false).setDrawHoverTips(false); - long capacity = Math.max(1, ingredients.getAmount()); - slotWidget = new TankWidget(ingredients, w.getPosition().x, w.getPosition().y, - w.getSize().width, w.getSize().height, capacity); - } - if (slotWidget == null) { - slotWidget = new SlotWidget(ingredients, w.getPosition().x, w.getPosition().y); - } - - slotWidget - .customBackground(null, w.getPosition().x, w.getPosition().y, w.getSize().width, - w.getSize().height) - .drawBack(false); - if (io == IngredientIO.CATALYST) { - slotWidget.catalyst(true); - } else if (io == IngredientIO.OUTPUT) { - slotWidget.recipeContext(this); - } - for (Component component : w.getTooltipTexts()) { - slotWidget.appendTooltip(component); - } - slots.add(slotWidget); - } - } - } - widgets.add(new ModularWrapperWidget(modular, slots)); - slots.forEach(widgets::add); - widgets.add(new ModularForegroundRenderWidget(modular)); - } -} diff --git a/src/main/java/com/gregtechceu/gtceu/integration/emi/recipe/GTEmiRecipe2.java b/src/main/java/com/gregtechceu/gtceu/integration/emi/recipe/GTEmiRecipe2.java deleted file mode 100644 index 8d3f526bb61..00000000000 --- a/src/main/java/com/gregtechceu/gtceu/integration/emi/recipe/GTEmiRecipe2.java +++ /dev/null @@ -1,232 +0,0 @@ -package com.gregtechceu.gtceu.integration.emi.recipe; - -import com.gregtechceu.gtceu.utils.memoization.GTMemoizer; -import com.gregtechceu.gtceu.utils.memoization.MemoizedSupplier; - -import net.minecraft.client.gui.GuiGraphics; -import net.minecraft.client.gui.screens.inventory.tooltip.ClientTooltipComponent; -import net.minecraft.locale.Language; -import net.minecraft.network.chat.FormattedText; -import net.minecraft.resources.ResourceLocation; -import net.minecraft.world.item.crafting.Recipe; - -import brachy.modularui.api.widget.ITooltip; -import brachy.modularui.api.widget.IWidget; -import brachy.modularui.drawable.text.RichText; -import brachy.modularui.integration.emi.EmiStackConverter; -import brachy.modularui.integration.recipeviewer.RecipeSlotRole; -import brachy.modularui.integration.recipeviewer.RecipeViewerScreenWrapper; -import brachy.modularui.integration.recipeviewer.handlers.IngredientProvider; -import brachy.modularui.integration.recipeviewer.handlers.fluid.EmptyFluidTank; -import brachy.modularui.integration.recipeviewer.util.RecipeScreenRenderingUtil; -import brachy.modularui.screen.ModularPanel; -import brachy.modularui.screen.ModularScreen; -import brachy.modularui.widget.WidgetTree; -import brachy.modularui.widget.sizer.Area; -import brachy.modularui.widgets.slot.FluidSlot; -import brachy.modularui.widgets.slot.ItemSlot; -import dev.emi.emi.api.recipe.EmiRecipe; -import dev.emi.emi.api.recipe.EmiRecipeCategory; -import dev.emi.emi.api.stack.EmiIngredient; -import dev.emi.emi.api.stack.EmiStack; -import dev.emi.emi.api.widget.*; -import lombok.Getter; -import org.jetbrains.annotations.Nullable; - -import java.time.Duration; -import java.util.ArrayList; -import java.util.List; -import java.util.function.Supplier; - -public abstract class GTEmiRecipe2, W extends IWidget> implements EmiRecipe { - - @Getter - protected final T recipe; - protected final EmiRecipeCategory category; - protected final MemoizedSupplier screen; - - @Getter - public final List inputs; - @Getter - public final List outputs; - @Getter - public final List catalysts; - - @Getter - private final Bounds bounds; - @Getter - private final int displayWidth, displayHeight; - - public boolean allowRecipeTree = true; - - public GTEmiRecipe2(T recipe, EmiRecipeCategory category, Supplier widgetSupplier) { - this.recipe = recipe; - this.category = category; - - this.inputs = new ArrayList<>(); - this.outputs = new ArrayList<>(); - this.catalysts = new ArrayList<>(); - - W recipeWidget = widgetSupplier.get(); - this.displayWidth = recipeWidget.getArea().width; - this.displayHeight = recipeWidget.getArea().height; - this.bounds = new Bounds(0, 0, this.displayWidth, this.displayHeight); - - this.screen = GTMemoizer.memoize(() -> { - W widget = widgetSupplier.get(); - ModularPanel panel = ModularPanel.defaultPanel(recipe.getId().toString(), widget.getArea().w(), - widget.getArea().h()); - panel.child(widget); - return new ModularScreen(recipe.getId().getNamespace(), panel); - }, Duration.ofSeconds(10)); - - WidgetTree.foreachChildBFS(recipeWidget, widget -> { - if (!(widget instanceof IngredientProvider provider)) { - return true; - } - RecipeSlotRole role = provider.recipeRole(); - if (role == RecipeSlotRole.RENDER_ONLY) { - return true; - } - - EmiStackConverter.Converter converter = EmiStackConverter.getForNullable(provider.ingredientClass()); - if (converter == null) { - return true; - } - @SuppressWarnings({ "rawtypes", "unchecked" }) - EmiIngredient ingredient = ((EmiStackConverter.Converter) converter).convertTo(provider); - - switch (role) { - case INPUT -> inputs.add(ingredient); - case OUTPUT -> { - if (ingredient.getEmiStacks().size() > 1) { - allowRecipeTree = false; - } - outputs.addAll(ingredient.getEmiStacks()); - } - case CATALYST -> catalysts.add(ingredient); - } - return true; - }, true); - } - - @Override - public EmiRecipeCategory getCategory() { - return category; - } - - @Override - public void addWidgets(WidgetHolder widgets) { - widgets.add(new UIWrapperWidget()); - - WidgetTree.foreachChildBFS(this.screen.get().getMainPanel(), widget -> { - if (!(widget instanceof IngredientProvider provider)) return true; - - RecipeSlotRole role = provider.recipeRole(); - if (role == RecipeSlotRole.RENDER_ONLY) { - return true; - } - EmiStackConverter.Converter converter = EmiStackConverter.getForNullable(provider.ingredientClass()); - if (converter == null) { - return true; - } - @SuppressWarnings({ "rawtypes", "unchecked" }) - EmiIngredient ingredient = ((EmiStackConverter.Converter) converter).convertTo(provider); - Area widgetArea = widget.getArea(); - - SlotWidget slotWidget = null; - // Clear the MUI slots and add EMI slots based on them. - if (provider instanceof ItemSlot itemSlot) { - itemSlot.slot(RecipeScreenRenderingUtil.EMPTY_ITEM_HANDLER, 0) - .invisible(); - } else if (provider instanceof FluidSlot fluidSlot) { - fluidSlot.syncHandler(EmptyFluidTank.INSTANCE) - .invisible(); - - long capacity = Math.max(1, ingredient.getAmount()); - slotWidget = new TankWidget(ingredient, widgetArea.x, widgetArea.y, widgetArea.width, widgetArea.height, - capacity); - } - if (slotWidget == null) { - slotWidget = new SlotWidget(ingredient, widgetArea.x, widgetArea.y); - } - - slotWidget.customBackground(null, widgetArea.x, widgetArea.y, widgetArea.width, widgetArea.height) - .drawBack(false); - - if (role == RecipeSlotRole.CATALYST) { - slotWidget.catalyst(true); - } else if (role == RecipeSlotRole.OUTPUT) { - slotWidget.recipeContext(this); - } - if (widget instanceof ITooltip tooltip && tooltip.hasTooltip()) { - if (tooltip.tooltip().getRichText() instanceof RichText richText) { - var textList = richText.getAsText(); - for (FormattedText line : textList) { - slotWidget - .appendTooltip(() -> ClientTooltipComponent - .create(Language.getInstance().getVisualOrder(line))); - } - } - } - widgets.add(slotWidget); - return true; - }, true); - widgets.add(new UIForegroundRenderWidget()); - } - - @Override - public @Nullable ResourceLocation getId() { - return this.recipe.getId(); - } - - @Override - public boolean supportsRecipeTree() { - return this.allowRecipeTree && EmiRecipe.super.supportsRecipeTree(); - } - - public class UIWrapperWidget extends Widget { - - public UIWrapperWidget() { - ModularScreen screen = GTEmiRecipe2.this.screen.get(); - screen.construct(new RecipeViewerScreenWrapper(screen)); - } - - @Override - public Bounds getBounds() { - return GTEmiRecipe2.this.bounds; - } - - @Override - public void render(GuiGraphics guiGraphics, int mouseX, int mouseY, float partialTick) { - ModularScreen screen = GTEmiRecipe2.this.screen.get(); - RecipeScreenRenderingUtil.drawScreenBackground(guiGraphics, screen, mouseX, mouseY, partialTick); - } - - @Override - public boolean mouseClicked(int mouseX, int mouseY, int button) { - return screen.get().onMousePressed(mouseX, mouseY, button); - } - - @Override - public boolean keyPressed(int keyCode, int scanCode, int modifiers) { - return screen.get().keyPressed(keyCode, scanCode, modifiers); - } - } - - public class UIForegroundRenderWidget extends Widget { - - public UIForegroundRenderWidget() {} - - @Override - public Bounds getBounds() { - return GTEmiRecipe2.this.bounds; - } - - @Override - public void render(GuiGraphics guiGraphics, int mouseX, int mouseY, float partialTick) { - ModularScreen screen = GTEmiRecipe2.this.screen.get(); - RecipeScreenRenderingUtil.drawScreenForeground(guiGraphics, screen, mouseX, mouseY, partialTick); - } - } -} diff --git a/src/main/java/com/gregtechceu/gtceu/integration/jade/provider/RecipeOutputProvider.java b/src/main/java/com/gregtechceu/gtceu/integration/jade/provider/RecipeOutputProvider.java index 879b288f5a5..422e5b62b0c 100644 --- a/src/main/java/com/gregtechceu/gtceu/integration/jade/provider/RecipeOutputProvider.java +++ b/src/main/java/com/gregtechceu/gtceu/integration/jade/provider/RecipeOutputProvider.java @@ -65,26 +65,26 @@ protected void write(CompoundTag data, BlockAccessor blockAccessor, RecipeLogic ListTag itemTags = new ListTag(); for (var item : itemContents) { CompoundTag itemTag; - if (item.content instanceof IntProviderIngredient provider) { + if (item.content() instanceof IntProviderIngredient provider) { // don't roll for output but do copy for chance and batch IntProviderIngredient chanced = provider; - if (item.chance < item.maxChance) { + if (item.chance() < item.maxChance()) { double countD = (double) runs * - function.getBoostedChance(item, recipeTier, chanceTier) / item.maxChance; + function.getBoostedChance(item, recipeTier, chanceTier) / item.maxChance(); chanced = (IntProviderIngredient) ItemRecipeCapability.CAP.copyWithModifier(provider, ContentModifier.multiplier(countD)); } itemTag = (CompoundTag) JsonOps.INSTANCE.convertTo(NbtOps.INSTANCE, chanced.toJson()); } else { - var stacks = ItemRecipeCapability.CAP.of(item.content).getItems(); + var stacks = ItemRecipeCapability.CAP.of(item.content()).getItems(); if (stacks.length == 0 || stacks[0].isEmpty()) continue; var stack = stacks[0]; itemTag = new CompoundTag(); GTUtil.saveItemStack(stack, itemTag); - if (item.chance < item.maxChance) { + if (item.chance() < item.maxChance()) { int count = stack.getCount(); double countD = (double) count * runs * - function.getBoostedChance(item, recipeTier, chanceTier) / item.maxChance; + function.getBoostedChance(item, recipeTier, chanceTier) / item.maxChance(); count = Math.max(1, (int) Math.round(countD)); itemTag.putInt("Count", count); } @@ -99,28 +99,28 @@ protected void write(CompoundTag data, BlockAccessor blockAccessor, RecipeLogic ListTag fluidTags = new ListTag(); for (var fluid : fluidContents) { CompoundTag fluidTag; - if (fluid.content instanceof IntProviderFluidIngredient provider) { + if (fluid.content() instanceof IntProviderFluidIngredient provider) { // don't bother rolling output for nothing IntProviderFluidIngredient chanced = provider; - if (fluid.chance < fluid.maxChance) { + if (fluid.chance() < fluid.maxChance()) { double countD = (double) runs * - function.getBoostedChance(fluid, recipeTier, chanceTier) / fluid.maxChance; + function.getBoostedChance(fluid, recipeTier, chanceTier) / fluid.maxChance(); chanced = (IntProviderFluidIngredient) FluidRecipeCapability.CAP.copyWithModifier(provider, ContentModifier.multiplier(countD)); } fluidTag = chanced.toNBT(); } else { - FluidStack[] stacks = FluidRecipeCapability.CAP.of(fluid.content).getStacks(); + FluidStack[] stacks = FluidRecipeCapability.CAP.of(fluid.content()).getStacks(); if (stacks.length == 0) continue; if (stacks[0].isEmpty()) continue; var stack = stacks[0]; fluidTag = new CompoundTag(); stack.writeToNBT(fluidTag); - if (fluid.chance < fluid.maxChance) { + if (fluid.chance() < fluid.maxChance()) { int amount = stacks[0].getAmount(); double amountD = (double) amount * runs * - function.getBoostedChance(fluid, recipeTier, chanceTier) / fluid.maxChance; + function.getBoostedChance(fluid, recipeTier, chanceTier) / fluid.maxChance(); amount = Math.max(1, (int) Math.round(amountD)); fluidTag.putInt("Amount", amount); } diff --git a/src/main/java/com/gregtechceu/gtceu/integration/jei/circuit/GTProgrammedCircuitCategory.java b/src/main/java/com/gregtechceu/gtceu/integration/jei/circuit/GTProgrammedCircuitCategory.java deleted file mode 100644 index 1e0af9725af..00000000000 --- a/src/main/java/com/gregtechceu/gtceu/integration/jei/circuit/GTProgrammedCircuitCategory.java +++ /dev/null @@ -1,57 +0,0 @@ -package com.gregtechceu.gtceu.integration.jei.circuit; - -import com.gregtechceu.gtceu.GTCEu; -import com.gregtechceu.gtceu.common.data.GTItems; -import com.gregtechceu.gtceu.integration.recipeviewer.widgets.GTProgrammedCircuitWidget; - -import com.lowdragmc.lowdraglib.jei.ModularUIRecipeCategory; -import com.lowdragmc.lowdraglib.jei.ModularWrapper; - -import net.minecraft.network.chat.Component; - -import mezz.jei.api.gui.drawable.IDrawable; -import mezz.jei.api.helpers.IJeiHelpers; -import mezz.jei.api.recipe.RecipeType; -import org.jetbrains.annotations.Nullable; - -public class GTProgrammedCircuitCategory extends - ModularUIRecipeCategory { - - public final static RecipeType RECIPE_TYPE = new RecipeType<>( - GTCEu.id("programmed_circuit"), GTProgrammedCircuitWrapper.class); - - private final IDrawable background; - private final IDrawable icon; - - public GTProgrammedCircuitCategory(IJeiHelpers helpers) { - background = helpers.getGuiHelper().createBlankDrawable(150, 80); - icon = helpers.getGuiHelper().createDrawableItemStack(GTItems.PROGRAMMED_CIRCUIT.asStack()); - } - - @Override - public RecipeType getRecipeType() { - return RECIPE_TYPE; - } - - @Override - public Component getTitle() { - return Component.translatable("gtceu.jei.programmed_circuit"); - } - - @Override - public @Nullable IDrawable getBackground() { - return background; - } - - @Override - public @Nullable IDrawable getIcon() { - return icon; - } - - public static class GTProgrammedCircuitWrapper extends ModularWrapper { - - public GTProgrammedCircuitWrapper() { - super(new GTProgrammedCircuitWidget()); - } - } -} diff --git a/src/main/java/com/gregtechceu/gtceu/integration/jei/multipage/MultiblockInfoWrapper.java b/src/main/java/com/gregtechceu/gtceu/integration/jei/multipage/MultiblockInfoWrapper.java deleted file mode 100644 index 74dfc3de592..00000000000 --- a/src/main/java/com/gregtechceu/gtceu/integration/jei/multipage/MultiblockInfoWrapper.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.gregtechceu.gtceu.integration.jei.multipage; - -import com.gregtechceu.gtceu.api.gui.widget.PatternPreviewWidget; -import com.gregtechceu.gtceu.api.machine.MultiblockMachineDefinition; - -import com.lowdragmc.lowdraglib.jei.ModularWrapper; - -public class MultiblockInfoWrapper extends ModularWrapper { - - public final MultiblockMachineDefinition definition; - - public MultiblockInfoWrapper(MultiblockMachineDefinition definition) { - super(PatternPreviewWidget.getPatternWidget(definition)); - this.definition = definition; - } -} diff --git a/src/main/java/com/gregtechceu/gtceu/integration/jei/oreprocessing/GTOreProcessingInfoWrapper.java b/src/main/java/com/gregtechceu/gtceu/integration/jei/oreprocessing/GTOreProcessingInfoWrapper.java deleted file mode 100644 index 3ab837f790c..00000000000 --- a/src/main/java/com/gregtechceu/gtceu/integration/jei/oreprocessing/GTOreProcessingInfoWrapper.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.gregtechceu.gtceu.integration.jei.oreprocessing; - -import com.gregtechceu.gtceu.api.data.chemical.material.Material; -import com.gregtechceu.gtceu.integration.recipeviewer.widgets.GTOreByProductWidget; - -import com.lowdragmc.lowdraglib.jei.ModularWrapper; - -public class GTOreProcessingInfoWrapper extends ModularWrapper { - - public final Material material; - - public GTOreProcessingInfoWrapper(Material mat) { - super(new GTOreByProductWidget(mat)); - this.material = mat; - } -} diff --git a/src/main/java/com/gregtechceu/gtceu/integration/jei/orevein/GTBedrockFluidInfoWrapper.java b/src/main/java/com/gregtechceu/gtceu/integration/jei/orevein/GTBedrockFluidInfoWrapper.java deleted file mode 100644 index 8c97cd1c534..00000000000 --- a/src/main/java/com/gregtechceu/gtceu/integration/jei/orevein/GTBedrockFluidInfoWrapper.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.gregtechceu.gtceu.integration.jei.orevein; - -import com.gregtechceu.gtceu.api.data.worldgen.bedrockfluid.BedrockFluidDefinition; -import com.gregtechceu.gtceu.integration.recipeviewer.widgets.GTOreVeinWidget; - -import com.lowdragmc.lowdraglib.jei.ModularWrapper; - -public class GTBedrockFluidInfoWrapper extends ModularWrapper { - - public final BedrockFluidDefinition fluid; - - public GTBedrockFluidInfoWrapper(BedrockFluidDefinition fluid) { - super(new GTOreVeinWidget(fluid)); - this.fluid = fluid; - } -} diff --git a/src/main/java/com/gregtechceu/gtceu/integration/jei/orevein/GTBedrockOreInfoWrapper.java b/src/main/java/com/gregtechceu/gtceu/integration/jei/orevein/GTBedrockOreInfoWrapper.java deleted file mode 100644 index 2a6446090e0..00000000000 --- a/src/main/java/com/gregtechceu/gtceu/integration/jei/orevein/GTBedrockOreInfoWrapper.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.gregtechceu.gtceu.integration.jei.orevein; - -import com.gregtechceu.gtceu.api.data.worldgen.bedrockore.BedrockOreDefinition; -import com.gregtechceu.gtceu.integration.recipeviewer.widgets.GTOreVeinWidget; - -import com.lowdragmc.lowdraglib.jei.ModularWrapper; - -public class GTBedrockOreInfoWrapper extends ModularWrapper { - - public final BedrockOreDefinition bedrockOre; - - public GTBedrockOreInfoWrapper(BedrockOreDefinition bedrockOre) { - super(new GTOreVeinWidget(bedrockOre)); - this.bedrockOre = bedrockOre; - } -} diff --git a/src/main/java/com/gregtechceu/gtceu/integration/jei/orevein/GTOreVeinInfoWrapper.java b/src/main/java/com/gregtechceu/gtceu/integration/jei/orevein/GTOreVeinInfoWrapper.java deleted file mode 100644 index a782c538a12..00000000000 --- a/src/main/java/com/gregtechceu/gtceu/integration/jei/orevein/GTOreVeinInfoWrapper.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.gregtechceu.gtceu.integration.jei.orevein; - -import com.gregtechceu.gtceu.api.data.worldgen.GTOreDefinition; -import com.gregtechceu.gtceu.integration.recipeviewer.widgets.GTOreVeinWidget; - -import com.lowdragmc.lowdraglib.jei.ModularWrapper; - -public class GTOreVeinInfoWrapper extends ModularWrapper { - - public final GTOreDefinition oreDefinition; - - public GTOreVeinInfoWrapper(GTOreDefinition oreDefinition) { - super(new GTOreVeinWidget(oreDefinition)); - this.oreDefinition = oreDefinition; - } -} diff --git a/src/main/java/com/gregtechceu/gtceu/integration/kjs/GregTechKubeJSPlugin.java b/src/main/java/com/gregtechceu/gtceu/integration/kjs/GregTechKubeJSPlugin.java index 7d67308880a..bb81687cbd3 100644 --- a/src/main/java/com/gregtechceu/gtceu/integration/kjs/GregTechKubeJSPlugin.java +++ b/src/main/java/com/gregtechceu/gtceu/integration/kjs/GregTechKubeJSPlugin.java @@ -34,7 +34,6 @@ import com.gregtechceu.gtceu.api.fluids.FluidState; import com.gregtechceu.gtceu.api.fluids.attribute.FluidAttributes; import com.gregtechceu.gtceu.api.fluids.store.FluidStorageKeys; -import com.gregtechceu.gtceu.api.gui.GuiTextures; import com.gregtechceu.gtceu.api.item.tool.GTToolType; import com.gregtechceu.gtceu.api.item.tool.ToolHelper; import com.gregtechceu.gtceu.api.machine.MachineDefinition; @@ -335,8 +334,6 @@ public void registerBindings(BindingsEvent event) { // Sound related event.add("GTSoundEntries", GTSoundEntries.class); event.add("SoundType", SoundType.class); - // GUI related - event.add("GuiTextures", GuiTextures.class); // Client/Server data related event.add("GTModels", GTModels.class); event.add("GTMachineModels", GTMachineModels.class); diff --git a/src/main/java/com/gregtechceu/gtceu/integration/kjs/builders/GTRecipeTypeBuilder.java b/src/main/java/com/gregtechceu/gtceu/integration/kjs/builders/GTRecipeTypeBuilder.java index cc3e4a9b48c..bedb49bbac5 100644 --- a/src/main/java/com/gregtechceu/gtceu/integration/kjs/builders/GTRecipeTypeBuilder.java +++ b/src/main/java/com/gregtechceu/gtceu/integration/kjs/builders/GTRecipeTypeBuilder.java @@ -1,28 +1,18 @@ package com.gregtechceu.gtceu.integration.kjs.builders; import com.gregtechceu.gtceu.api.capability.recipe.*; -import com.gregtechceu.gtceu.api.gui.SteamTexture; -import com.gregtechceu.gtceu.api.recipe.GTRecipe; import com.gregtechceu.gtceu.api.recipe.GTRecipeType; import com.gregtechceu.gtceu.api.registry.registrate.BuilderBase; import com.gregtechceu.gtceu.api.sound.SoundEntry; import com.gregtechceu.gtceu.common.data.GTRecipeTypes; -import com.lowdragmc.lowdraglib.gui.texture.IGuiTexture; -import com.lowdragmc.lowdraglib.gui.texture.ProgressTexture; -import com.lowdragmc.lowdraglib.gui.texture.ResourceTexture; -import com.lowdragmc.lowdraglib.gui.widget.WidgetGroup; - import net.minecraft.resources.ResourceLocation; import net.minecraft.world.item.ItemStack; -import it.unimi.dsi.fastutil.bytes.Byte2ObjectArrayMap; -import it.unimi.dsi.fastutil.bytes.Byte2ObjectMap; import it.unimi.dsi.fastutil.objects.Object2IntMap; import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap; import org.jetbrains.annotations.Nullable; -import java.util.function.BiConsumer; import java.util.function.Supplier; @SuppressWarnings("unused") @@ -31,10 +21,6 @@ public class GTRecipeTypeBuilder extends BuilderBase { public transient String name, category; public transient final Object2IntMap> maxInputs; public transient final Object2IntMap> maxOutputs; - private ProgressTexture progressBarTexture; - private SteamTexture steamProgressBarTexture; - private ProgressTexture.FillDirection steamMoveType; - private transient final Byte2ObjectMap slotOverlays; @Nullable protected SoundEntry sound; protected boolean hasResearchSlot; @@ -42,24 +28,17 @@ public class GTRecipeTypeBuilder extends BuilderBase { private GTRecipeType smallRecipeMap; private Supplier iconSupplier; - @Nullable - protected BiConsumer uiBuilder; public GTRecipeTypeBuilder(ResourceLocation i) { super(i); name = i.getPath(); maxInputs = new Object2IntOpenHashMap<>(); maxOutputs = new Object2IntOpenHashMap<>(); - progressBarTexture = new ProgressTexture(); - steamProgressBarTexture = null; - steamMoveType = ProgressTexture.FillDirection.LEFT_TO_RIGHT; - slotOverlays = new Byte2ObjectArrayMap<>(); this.sound = null; this.hasResearchSlot = false; this.maxTooltips = 4; this.smallRecipeMap = null; this.iconSupplier = null; - this.uiBuilder = null; } public GTRecipeTypeBuilder category(String category) { @@ -94,29 +73,6 @@ public GTRecipeTypeBuilder setMaxSize(IO io, RecipeCapability cap, int max) { return this; } - public GTRecipeTypeBuilder setSlotOverlay(boolean isOutput, boolean isFluid, IGuiTexture slotOverlay) { - return this.setSlotOverlay(isOutput, isFluid, false, slotOverlay).setSlotOverlay(isOutput, isFluid, true, - slotOverlay); - } - - public GTRecipeTypeBuilder setSlotOverlay(boolean isOutput, boolean isFluid, boolean isLast, - IGuiTexture slotOverlay) { - this.slotOverlays.put((byte) ((isOutput ? 2 : 0) + (isFluid ? 1 : 0) + (isLast ? 4 : 0)), slotOverlay); - return this; - } - - public GTRecipeTypeBuilder setProgressBar(ResourceTexture progressBar, ProgressTexture.FillDirection moveType) { - this.progressBarTexture = new ProgressTexture(progressBar.getSubTexture(0, 0, 1, 0.5), - progressBar.getSubTexture(0, 0.5, 1, 0.5)).setFillDirection(moveType); - return this; - } - - public GTRecipeTypeBuilder setSteamProgressBar(SteamTexture progressBar, ProgressTexture.FillDirection moveType) { - this.steamProgressBarTexture = progressBar; - this.steamMoveType = moveType; - return this; - } - public GTRecipeTypeBuilder setSound(SoundEntry sound) { this.sound = sound; return this; @@ -142,26 +98,16 @@ public GTRecipeTypeBuilder setIconSupplier(Supplier iconSupplier) { return this; } - public GTRecipeTypeBuilder setUiBuilder(BiConsumer uiBuilder) { - this.uiBuilder = uiBuilder; - return this; - } - @Override public GTRecipeType register() { var type = GTRecipeTypes.register(name, category); type.maxInputs.putAll(maxInputs); type.maxOutputs.putAll(maxOutputs); - type.getRecipeUI().getSlotOverlays().putAll(slotOverlays); - type.getRecipeUI().setProgressBarTexture(progressBarTexture); - type.getRecipeUI().setSteamProgressBarTexture(steamProgressBarTexture); - type.getRecipeUI().setSteamMoveType(steamMoveType); type.setSound(sound); type.setHasResearchSlot(hasResearchSlot); type.setMaxTooltips(maxTooltips); type.setSmallRecipeMap(smallRecipeMap); type.setIconSupplier(iconSupplier); - type.setUiBuilder(uiBuilder); return value = type; } } diff --git a/src/main/java/com/gregtechceu/gtceu/integration/kjs/recipe/GTRecipeSchema.java b/src/main/java/com/gregtechceu/gtceu/integration/kjs/recipe/GTRecipeSchema.java index 74758b76dfb..3dc78a51447 100644 --- a/src/main/java/com/gregtechceu/gtceu/integration/kjs/recipe/GTRecipeSchema.java +++ b/src/main/java/com/gregtechceu/gtceu/integration/kjs/recipe/GTRecipeSchema.java @@ -1403,7 +1403,7 @@ public JsonElement writeOutputFluid(OutputFluid value) { private static @Nullable String parseItemOutputId(RecipeJS recipe, CapabilityMap map) { var outputs = map.get(ItemRecipeCapability.CAP); if (outputs != null && outputs.length > 0) { - var output = GTRecipeComponents.ITEM_OUT.baseComponent().read(recipe, outputs[0].content); + var output = GTRecipeComponents.ITEM_OUT.baseComponent().read(recipe, outputs[0].content()); var id = output.item.getItemHolder().unwrapKey(); if (id.isPresent()) { return id.get().location().getPath(); @@ -1416,7 +1416,7 @@ public JsonElement writeOutputFluid(OutputFluid value) { private static @Nullable String parseFluidOutputId(RecipeJS recipe, CapabilityMap map) { var outputs = map.get(FluidRecipeCapability.CAP); if (outputs != null && outputs.length > 0) { - var output = GTRecipeComponents.FLUID_OUT.baseComponent().read(recipe, outputs[0].content); + var output = GTRecipeComponents.FLUID_OUT.baseComponent().read(recipe, outputs[0].content()); var fluids = output.ingredient().getStacks(); if (fluids.length == 0) return null; diff --git a/src/main/java/com/gregtechceu/gtceu/integration/kjs/recipe/components/ContentJS.java b/src/main/java/com/gregtechceu/gtceu/integration/kjs/recipe/components/ContentJS.java index 3d9694d7b71..753ca4c0fbf 100644 --- a/src/main/java/com/gregtechceu/gtceu/integration/kjs/recipe/components/ContentJS.java +++ b/src/main/java/com/gregtechceu/gtceu/integration/kjs/recipe/components/ContentJS.java @@ -31,10 +31,10 @@ public Class componentClass() { @Override public JsonElement write(RecipeJS recipe, Content value) { JsonObject object = new JsonObject(); - object.add("content", baseComponent.write(recipe, baseComponent.read(recipe, value.content))); - object.addProperty("chance", value.chance); - object.addProperty("maxChance", value.maxChance); - object.addProperty("tierChanceBoost", value.tierChanceBoost); + object.add("content", baseComponent.write(recipe, baseComponent.read(recipe, value.content()))); + object.addProperty("chance", value.chance()); + object.addProperty("maxChance", value.maxChance()); + object.addProperty("tierChanceBoost", value.tierChanceBoost()); return object; } @@ -53,26 +53,26 @@ else if (from instanceof JsonObject json) { @Override public boolean isInput(RecipeJS recipe, Content value, ReplacementMatch match) { - return !isOutput && baseComponent.isInput(recipe, baseComponent.read(recipe, value.content), match); + return !isOutput && baseComponent.isInput(recipe, baseComponent.read(recipe, value.content()), match); } @Override public boolean isOutput(RecipeJS recipe, Content value, ReplacementMatch match) { - return isOutput && baseComponent.isOutput(recipe, baseComponent.read(recipe, value.content), match); + return isOutput && baseComponent.isOutput(recipe, baseComponent.read(recipe, value.content()), match); } @Override public Content replaceInput(RecipeJS recipe, Content original, ReplacementMatch match, InputReplacement with) { return isInput(recipe, original, match) ? new Content( - baseComponent.replaceInput(recipe, baseComponent.read(recipe, original.content), match, with), - original.chance, original.maxChance, original.tierChanceBoost) : + baseComponent.replaceInput(recipe, baseComponent.read(recipe, original.content()), match, with), + original.chance(), original.maxChance(), original.tierChanceBoost()) : original; } @Override public Content replaceOutput(RecipeJS recipe, Content original, ReplacementMatch match, OutputReplacement with) { return isOutput(recipe, original, match) ? new Content(with.replaceOutput(recipe, match, with), - original.chance, original.maxChance, original.tierChanceBoost) : + original.chance(), original.maxChance(), original.tierChanceBoost()) : original; } } diff --git a/src/main/java/com/gregtechceu/gtceu/integration/map/layer/builtin/OreRenderLayer.java b/src/main/java/com/gregtechceu/gtceu/integration/map/layer/builtin/OreRenderLayer.java index dea2be0b90e..127b2192f21 100644 --- a/src/main/java/com/gregtechceu/gtceu/integration/map/layer/builtin/OreRenderLayer.java +++ b/src/main/java/com/gregtechceu/gtceu/integration/map/layer/builtin/OreRenderLayer.java @@ -9,7 +9,7 @@ import com.gregtechceu.gtceu.config.ConfigHolder; import com.gregtechceu.gtceu.integration.map.GenericMapRenderer; import com.gregtechceu.gtceu.integration.map.layer.MapRenderLayer; -import com.gregtechceu.gtceu.integration.recipeviewer.widgets.GTOreVeinWidget; +import com.gregtechceu.gtceu.integration.recipeviewer.widgets.OreVeinRecipeWidget; import net.minecraft.core.BlockPos; import net.minecraft.network.chat.Component; @@ -38,7 +38,7 @@ public static MutableComponent getName(GeneratedVeinMetadata vein) { ClientProxy.CLIENT_ORE_VEINS.inverse().get(vein.definition()) == null) { return Component.translatable("gtceu.minimap.ore_vein.depleted"); } - return Component.translatable("gtceu.jei.ore_vein." + GTOreVeinWidget.getOreName(vein.definition())); + return Component.translatable("gtceu.jei.ore_vein." + OreVeinRecipeWidget.getOreName(vein.definition())); } public static @NotNull Material getMaterial(@NotNull GeneratedVeinMetadata vein) { diff --git a/src/main/java/com/gregtechceu/gtceu/integration/emi/GTEMIPlugin.java b/src/main/java/com/gregtechceu/gtceu/integration/recipeviewer/emi/GTEMIPlugin.java similarity index 82% rename from src/main/java/com/gregtechceu/gtceu/integration/emi/GTEMIPlugin.java rename to src/main/java/com/gregtechceu/gtceu/integration/recipeviewer/emi/GTEMIPlugin.java index ad042816170..54a209cd9be 100644 --- a/src/main/java/com/gregtechceu/gtceu/integration/emi/GTEMIPlugin.java +++ b/src/main/java/com/gregtechceu/gtceu/integration/recipeviewer/emi/GTEMIPlugin.java @@ -1,4 +1,4 @@ -package com.gregtechceu.gtceu.integration.emi; +package com.gregtechceu.gtceu.integration.recipeviewer.emi; import com.gregtechceu.gtceu.GTCEu; import com.gregtechceu.gtceu.api.GTValues; @@ -12,15 +12,12 @@ import com.gregtechceu.gtceu.common.fluid.potion.PotionFluidHelper; import com.gregtechceu.gtceu.common.item.behavior.IntCircuitBehaviour; import com.gregtechceu.gtceu.config.ConfigHolder; -import com.gregtechceu.gtceu.integration.emi.circuit.GTProgrammedCircuitCategory; -import com.gregtechceu.gtceu.integration.emi.multipage.MultiblockInfoEmiCategory; -import com.gregtechceu.gtceu.integration.emi.oreprocessing.GTOreProcessingEmiCategory; -import com.gregtechceu.gtceu.integration.emi.orevein.GTBedrockFluidEmiCategory; -import com.gregtechceu.gtceu.integration.emi.orevein.GTBedrockOreEmiCategory; -import com.gregtechceu.gtceu.integration.emi.orevein.GTOreVeinEmiCategory; -import com.gregtechceu.gtceu.integration.emi.recipe.Ae2PatternTerminalHandler; -import com.gregtechceu.gtceu.integration.emi.recipe.GTEmiRecipeHandler; -import com.gregtechceu.gtceu.integration.emi.recipe.GTRecipeEMICategory; +import com.gregtechceu.gtceu.integration.recipeviewer.emi.orevein.GTBedrockFluidEmiCategory; +import com.gregtechceu.gtceu.integration.recipeviewer.emi.orevein.GTBedrockOreEmiCategory; +import com.gregtechceu.gtceu.integration.recipeviewer.emi.orevein.GTOreVeinEmiCategory; +import com.gregtechceu.gtceu.integration.recipeviewer.emi.recipe.Ae2PatternTerminalHandler; +import com.gregtechceu.gtceu.integration.recipeviewer.emi.recipe.GTEmiRecipeHandler; +import com.gregtechceu.gtceu.integration.recipeviewer.emi.recipe.GTRecipeEMICategory; import com.lowdragmc.lowdraglib.gui.modular.ModularUIContainer; @@ -62,7 +59,7 @@ public void register(EmiRegistry registry) { if (GTCEu.isModLoaded(GTValues.MODID_AE2WTLIB)) { registry.addRecipeHandler(WETMenu.TYPE, new Ae2PatternTerminalHandler<>()); } - registry.addCategory(GTProgrammedCircuitCategory.CATEGORY); + registry.addCategory(ProgrammedCircuitEmiCategory.CATEGORY); // Recipes MultiblockInfoEmiCategory.registerDisplays(registry); @@ -73,7 +70,7 @@ public void register(EmiRegistry registry) { GTBedrockFluidEmiCategory.registerDisplays(registry); if (ConfigHolder.INSTANCE.machines.doBedrockOres) GTBedrockOreEmiCategory.registerDisplays(registry); - GTProgrammedCircuitCategory.registerDisplays(registry); + ProgrammedCircuitEmiCategory.registerDisplays(registry); // workstations GTRecipeEMICategory.registerWorkStations(registry); @@ -92,7 +89,7 @@ public void register(EmiRegistry registry) { registry.setDefaultComparison(GTItems.PROGRAMMED_CIRCUIT.asItem(), Comparison.compareNbt()); registry.removeEmiStacks(EmiStack.of(GTItems.PROGRAMMED_CIRCUIT.asStack())); registry.addEmiStack(EmiStack.of(IntCircuitBehaviour.stack(0))); - registry.addWorkstation(GTProgrammedCircuitCategory.CATEGORY, EmiStack.of(IntCircuitBehaviour.stack(0))); + registry.addWorkstation(ProgrammedCircuitEmiCategory.CATEGORY, EmiStack.of(IntCircuitBehaviour.stack(0))); Comparison potionComparison = Comparison.compareData(stack -> PotionUtils.getPotion(stack.getNbt())); PotionFluid potionFluid = GTFluids.POTION.get(); diff --git a/src/main/java/com/gregtechceu/gtceu/integration/emi/oreprocessing/GTOreProcessingEmiCategory.java b/src/main/java/com/gregtechceu/gtceu/integration/recipeviewer/emi/GTOreProcessingEmiCategory.java similarity index 55% rename from src/main/java/com/gregtechceu/gtceu/integration/emi/oreprocessing/GTOreProcessingEmiCategory.java rename to src/main/java/com/gregtechceu/gtceu/integration/recipeviewer/emi/GTOreProcessingEmiCategory.java index 26c4a4e8306..ae68be6d3f1 100644 --- a/src/main/java/com/gregtechceu/gtceu/integration/emi/oreprocessing/GTOreProcessingEmiCategory.java +++ b/src/main/java/com/gregtechceu/gtceu/integration/recipeviewer/emi/GTOreProcessingEmiCategory.java @@ -1,5 +1,6 @@ -package com.gregtechceu.gtceu.integration.emi.oreprocessing; +package com.gregtechceu.gtceu.integration.recipeviewer.emi; +import brachy.modularui.integration.emi.EmiRecipeViewerSlot; import com.gregtechceu.gtceu.GTCEu; import com.gregtechceu.gtceu.api.GTCEuAPI; import com.gregtechceu.gtceu.api.data.chemical.material.Material; @@ -7,20 +8,26 @@ import com.gregtechceu.gtceu.api.machine.MachineDefinition; import com.gregtechceu.gtceu.api.recipe.GTRecipeType; import com.gregtechceu.gtceu.api.registry.GTRegistries; +import com.gregtechceu.gtceu.integration.recipeviewer.widgets.GTOreByProduct; +import com.gregtechceu.gtceu.integration.recipeviewer.widgets.OreProcessingRecipeWidget; +import dev.emi.emi.api.stack.EmiIngredient; import net.minecraft.network.chat.Component; +import net.minecraft.resources.ResourceLocation; import net.minecraft.world.item.Items; +import brachy.modularui.integration.emi.recipe.ModularUIEmiRecipe; import dev.emi.emi.api.EmiRegistry; import dev.emi.emi.api.recipe.EmiRecipeCategory; import dev.emi.emi.api.stack.EmiStack; +import org.jetbrains.annotations.Nullable; import java.util.ArrayList; import java.util.List; import static com.gregtechceu.gtceu.api.data.chemical.material.properties.PropertyKey.ORE; import static com.gregtechceu.gtceu.common.data.GTRecipeTypes.*; -import static com.gregtechceu.gtceu.integration.emi.recipe.GTRecipeEMICategory.sortDefinition; +import static com.gregtechceu.gtceu.integration.recipeviewer.emi.recipe.GTRecipeEMICategory.sortDefinition; public class GTOreProcessingEmiCategory extends EmiRecipeCategory { @@ -33,7 +40,7 @@ public GTOreProcessingEmiCategory() { public static void registerDisplays(EmiRegistry registry) { for (Material mat : GTCEuAPI.materialManager.getRegisteredMaterials()) { if (mat.hasProperty(ORE) && !mat.hasFlag(MaterialFlags.NO_ORE_PROCESSING_TAB)) { - registry.addRecipe(new GTEmiOreProcessing(mat)); + registry.addRecipe(new GTEmiOreProcessingWrapper(mat)); } } } @@ -63,4 +70,40 @@ public static void registerWorkStations(EmiRegistry registry) { public Component getName() { return Component.translatable("gtceu.jei.ore_processing_diagram"); } + + public static class GTEmiOreProcessingWrapper extends ModularUIEmiRecipe { + + final Material material; + final GTOreByProduct byProduct; + public GTEmiOreProcessingWrapper(Material material) { + super(material.getResourceLocation().withPrefix("/ore_proc/"), () -> new OreProcessingRecipeWidget(material)); + this.material = material; + byProduct = new GTOreByProduct(material); + } + + @Override + public EmiRecipeCategory getCategory() { + return CATEGORY; + } + + @Override + public List getInputs() { + var items = byProduct.getItemInputs(); + var fluids = byProduct.getFluidInputs(); + List ingredients = new ArrayList<>(); + ingredients.addAll(items.stream().map(v -> EmiRecipeViewerSlot.EmiIngredientHandler.toEmiIngredient(v, 1, $ -> $)).toList()); + ingredients.addAll(fluids.stream().map(v -> EmiRecipeViewerSlot.EmiIngredientHandler.toEmiIngredient(v, 1)).toList()); + return ingredients; + } + + @Override + public List getOutputs() { + return byProduct.getItemOutputs().stream().map(EmiStack::of).toList(); + } + + @Override + public boolean supportsRecipeTree() { + return false; + } + } } diff --git a/src/main/java/com/gregtechceu/gtceu/integration/recipeviewer/emi/MultiblockInfoEmiCategory.java b/src/main/java/com/gregtechceu/gtceu/integration/recipeviewer/emi/MultiblockInfoEmiCategory.java new file mode 100644 index 00000000000..b327c936724 --- /dev/null +++ b/src/main/java/com/gregtechceu/gtceu/integration/recipeviewer/emi/MultiblockInfoEmiCategory.java @@ -0,0 +1,82 @@ +package com.gregtechceu.gtceu.integration.recipeviewer.emi; + +import com.gregtechceu.gtceu.GTCEu; +import com.gregtechceu.gtceu.api.gui.widget.PatternPreviewWidget; +import com.gregtechceu.gtceu.api.machine.MultiblockMachineDefinition; +import com.gregtechceu.gtceu.api.registry.GTRegistries; +import com.gregtechceu.gtceu.common.data.machines.GTMultiMachines; + +import com.lowdragmc.lowdraglib.emi.ModularEmiRecipe; +import com.lowdragmc.lowdraglib.gui.widget.WidgetGroup; + +import net.minecraft.network.chat.Component; +import net.minecraft.resources.ResourceLocation; + +import dev.emi.emi.api.EmiRegistry; +import dev.emi.emi.api.recipe.EmiRecipeCategory; +import dev.emi.emi.api.stack.EmiStack; +import dev.emi.emi.api.widget.SlotWidget; +import dev.emi.emi.api.widget.WidgetHolder; +import org.jetbrains.annotations.Nullable; + +import java.util.List; + +public class MultiblockInfoEmiCategory extends EmiRecipeCategory { + + public static final MultiblockInfoEmiCategory CATEGORY = new MultiblockInfoEmiCategory(); + + private MultiblockInfoEmiCategory() { + super(GTCEu.id("multiblock_info"), EmiStack.of(GTMultiMachines.ELECTRIC_BLAST_FURNACE.getItem())); + } + + public static void registerDisplays(EmiRegistry registry) { + GTRegistries.MACHINES.values().stream() + .filter(MultiblockMachineDefinition.class::isInstance) + .map(MultiblockMachineDefinition.class::cast) + .filter(MultiblockMachineDefinition::isRenderXEIPreview) + .map(MultiblockInfoEmiWrapper::new) + .forEach(registry::addRecipe); + } + + @Override + public Component getName() { + return Component.translatable("gtceu.jei.multiblock_info"); + } + + public static class MultiblockInfoEmiWrapper extends ModularEmiRecipe { + + private final MultiblockMachineDefinition definition; + private SlotWidget slotWidget; + + public MultiblockInfoEmiWrapper(MultiblockMachineDefinition definition) { + super(() -> PatternPreviewWidget.getPatternWidget(definition)); + this.definition = definition; + } + + @Override + public void addWidgets(WidgetHolder widgets) { + super.addWidgets(widgets); + // numbers gotten from the size of the widget + slotWidget = new SlotWidget(EmiStack.of(definition.getItem().asItem()), 138, 12) + .recipeContext(this) + .drawBack(false); + + widgets.add(slotWidget); + } + + @Override + public EmiRecipeCategory getCategory() { + return CATEGORY; + } + + @Override + public @Nullable ResourceLocation getId() { + return definition.getId().withPrefix("/multi_info/"); + } + + @Override + public List getOutputs() { + return List.of(EmiStack.of(definition.getItem())); + } + } +} diff --git a/src/main/java/com/gregtechceu/gtceu/integration/emi/circuit/GTProgrammedCircuitCategory.java b/src/main/java/com/gregtechceu/gtceu/integration/recipeviewer/emi/ProgrammedCircuitEmiCategory.java similarity index 58% rename from src/main/java/com/gregtechceu/gtceu/integration/emi/circuit/GTProgrammedCircuitCategory.java rename to src/main/java/com/gregtechceu/gtceu/integration/recipeviewer/emi/ProgrammedCircuitEmiCategory.java index b15f374402c..27736b717e6 100644 --- a/src/main/java/com/gregtechceu/gtceu/integration/emi/circuit/GTProgrammedCircuitCategory.java +++ b/src/main/java/com/gregtechceu/gtceu/integration/recipeviewer/emi/ProgrammedCircuitEmiCategory.java @@ -1,33 +1,33 @@ -package com.gregtechceu.gtceu.integration.emi.circuit; +package com.gregtechceu.gtceu.integration.recipeviewer.emi; import com.gregtechceu.gtceu.GTCEu; import com.gregtechceu.gtceu.common.data.GTItems; import com.gregtechceu.gtceu.common.item.behavior.IntCircuitBehaviour; -import com.gregtechceu.gtceu.integration.recipeviewer.widgets.GTProgrammedCircuitWidget; - -import com.lowdragmc.lowdraglib.emi.ModularEmiRecipe; +import com.gregtechceu.gtceu.integration.recipeviewer.widgets.ProgrammedCircuitRecipeWidget; +import dev.emi.emi.api.stack.EmiIngredient; import net.minecraft.network.chat.Component; -import net.minecraft.resources.ResourceLocation; +import brachy.modularui.integration.emi.recipe.ModularUIEmiRecipe; import dev.emi.emi.api.EmiRegistry; import dev.emi.emi.api.recipe.EmiRecipeCategory; import dev.emi.emi.api.stack.EmiStack; -import org.jetbrains.annotations.Nullable; +import org.jetbrains.annotations.NotNull; +import java.util.ArrayList; import java.util.List; import java.util.stream.IntStream; -public class GTProgrammedCircuitCategory extends EmiRecipeCategory { +public class ProgrammedCircuitEmiCategory extends EmiRecipeCategory { - public static final GTProgrammedCircuitCategory CATEGORY = new GTProgrammedCircuitCategory(); + public static final ProgrammedCircuitEmiCategory CATEGORY = new ProgrammedCircuitEmiCategory(); - public GTProgrammedCircuitCategory() { + public ProgrammedCircuitEmiCategory() { super(GTCEu.id("programmed_circuit"), EmiStack.of(GTItems.PROGRAMMED_CIRCUIT.asItem())); } public static void registerDisplays(EmiRegistry registry) { - registry.addRecipe(new GTProgrammedCircuitCategory.GTProgrammedCircuitWrapper()); + registry.addRecipe(new ProgrammedCircuitEmiCategory.GTProgrammedCircuitWrapper()); } @Override @@ -35,10 +35,10 @@ public Component getName() { return Component.translatable("gtceu.jei.programmed_circuit"); } - public static class GTProgrammedCircuitWrapper extends ModularEmiRecipe { + public static class GTProgrammedCircuitWrapper extends ModularUIEmiRecipe { public GTProgrammedCircuitWrapper() { - super(GTProgrammedCircuitWidget::new); + super(GTCEu.id("/programmed_circuit"), ProgrammedCircuitRecipeWidget::new); } @Override @@ -47,17 +47,12 @@ public EmiRecipeCategory getCategory() { } @Override - public int getDisplayWidth() { - return super.getDisplayWidth(); - } - - @Override - public @Nullable ResourceLocation getId() { - return GTCEu.id("programmed_circuit"); + public List getInputs() { + return List.of(); } @Override - public List getOutputs() { + public @NotNull List getOutputs() { return IntStream.range(0, 33) .mapToObj(IntCircuitBehaviour::stack) .map(EmiStack::of) diff --git a/src/main/java/com/gregtechceu/gtceu/integration/emi/orevein/GTBedrockFluidEmiCategory.java b/src/main/java/com/gregtechceu/gtceu/integration/recipeviewer/emi/orevein/GTBedrockFluidEmiCategory.java similarity index 51% rename from src/main/java/com/gregtechceu/gtceu/integration/emi/orevein/GTBedrockFluidEmiCategory.java rename to src/main/java/com/gregtechceu/gtceu/integration/recipeviewer/emi/orevein/GTBedrockFluidEmiCategory.java index d4d6b6b36d0..ca710cf6b7c 100644 --- a/src/main/java/com/gregtechceu/gtceu/integration/emi/orevein/GTBedrockFluidEmiCategory.java +++ b/src/main/java/com/gregtechceu/gtceu/integration/recipeviewer/emi/orevein/GTBedrockFluidEmiCategory.java @@ -1,16 +1,24 @@ -package com.gregtechceu.gtceu.integration.emi.orevein; +package com.gregtechceu.gtceu.integration.recipeviewer.emi.orevein; import com.gregtechceu.gtceu.GTCEu; import com.gregtechceu.gtceu.api.data.worldgen.bedrockfluid.BedrockFluidDefinition; import com.gregtechceu.gtceu.client.ClientProxy; import com.gregtechceu.gtceu.common.data.GTItems; import com.gregtechceu.gtceu.common.data.GTMaterials; +import com.gregtechceu.gtceu.integration.recipeviewer.widgets.OreVeinRecipeWidget; +import dev.emi.emi.api.stack.EmiIngredient; import net.minecraft.network.chat.Component; +import brachy.modularui.integration.emi.recipe.ModularUIEmiRecipe; import dev.emi.emi.api.EmiRegistry; import dev.emi.emi.api.recipe.EmiRecipeCategory; import dev.emi.emi.api.stack.EmiStack; +import dev.emi.emi.api.stack.FluidEmiStack; +import org.jetbrains.annotations.NotNull; + +import java.util.Arrays; +import java.util.List; public class GTBedrockFluidEmiCategory extends EmiRecipeCategory { @@ -35,4 +43,30 @@ public static void registerWorkStations(EmiRegistry registry) { public Component getName() { return Component.translatable("gtceu.jei.bedrock_fluid_diagram"); } + + public static class GTBedrockFluid extends ModularUIEmiRecipe { + + private final BedrockFluidDefinition fluid; + + public GTBedrockFluid(BedrockFluidDefinition fluid) { + super(ClientProxy.CLIENT_FLUID_VEINS.inverse().get(fluid).withPrefix("/bedrock_fluid_diagram/"), + () -> new OreVeinRecipeWidget(fluid)); + this.fluid = fluid; + } + + @Override + public EmiRecipeCategory getCategory() { + return GTBedrockFluidEmiCategory.CATEGORY; + } + + @Override + public List getInputs() { + return Arrays.stream(OreVeinRecipeWidget.getDimensionMarkers(fluid.dimensionFilter)).map(v -> (EmiIngredient)EmiStack.of(v.getIcon())).toList(); + } + + @Override + public @NotNull List getOutputs() { + return List.of(EmiStack.of(fluid.getStoredFluid().get())); + } + } } diff --git a/src/main/java/com/gregtechceu/gtceu/integration/emi/orevein/GTBedrockOreEmiCategory.java b/src/main/java/com/gregtechceu/gtceu/integration/recipeviewer/emi/orevein/GTBedrockOreEmiCategory.java similarity index 53% rename from src/main/java/com/gregtechceu/gtceu/integration/emi/orevein/GTBedrockOreEmiCategory.java rename to src/main/java/com/gregtechceu/gtceu/integration/recipeviewer/emi/orevein/GTBedrockOreEmiCategory.java index d6c27769df1..5a9775a8971 100644 --- a/src/main/java/com/gregtechceu/gtceu/integration/emi/orevein/GTBedrockOreEmiCategory.java +++ b/src/main/java/com/gregtechceu/gtceu/integration/recipeviewer/emi/orevein/GTBedrockOreEmiCategory.java @@ -1,4 +1,4 @@ -package com.gregtechceu.gtceu.integration.emi.orevein; +package com.gregtechceu.gtceu.integration.recipeviewer.emi.orevein; import com.gregtechceu.gtceu.GTCEu; import com.gregtechceu.gtceu.api.data.chemical.ChemicalHelper; @@ -7,13 +7,19 @@ import com.gregtechceu.gtceu.client.ClientProxy; import com.gregtechceu.gtceu.common.data.GTItems; import com.gregtechceu.gtceu.common.data.GTMaterials; +import com.gregtechceu.gtceu.integration.recipeviewer.widgets.OreVeinRecipeWidget; +import dev.emi.emi.api.stack.EmiIngredient; import net.minecraft.network.chat.Component; +import brachy.modularui.integration.emi.recipe.ModularUIEmiRecipe; import dev.emi.emi.api.EmiRegistry; import dev.emi.emi.api.recipe.EmiRecipeCategory; import dev.emi.emi.api.stack.EmiStack; +import java.util.Arrays; +import java.util.List; + public class GTBedrockOreEmiCategory extends EmiRecipeCategory { public static final GTBedrockOreEmiCategory CATEGORY = new GTBedrockOreEmiCategory(); @@ -38,4 +44,30 @@ public static void registerWorkStations(EmiRegistry registry) { public Component getName() { return Component.translatable("gtceu.jei.bedrock_ore_diagram"); } + + public static class GTBedrockOre extends ModularUIEmiRecipe { + + private final BedrockOreDefinition bedrockOre; + + public GTBedrockOre(BedrockOreDefinition bedrockOre) { + super(ClientProxy.CLIENT_BEDROCK_ORE_VEINS.inverse().get(bedrockOre).withPrefix("/bedrock_ore_diagram/"), + () -> new OreVeinRecipeWidget(bedrockOre)); + this.bedrockOre = bedrockOre; + } + + @Override + public EmiRecipeCategory getCategory() { + return GTBedrockOreEmiCategory.CATEGORY; + } + + @Override + public List getInputs() { + return Arrays.stream(OreVeinRecipeWidget.getDimensionMarkers(bedrockOre.dimensionFilter())).map(v -> (EmiIngredient)EmiStack.of(v.getIcon())).toList(); + } + + @Override + public List getOutputs() { + return OreVeinRecipeWidget.getRawMaterialList(bedrockOre).stream().map(EmiStack::of).toList(); + } + } } diff --git a/src/main/java/com/gregtechceu/gtceu/integration/recipeviewer/emi/orevein/GTOreVeinEmiCategory.java b/src/main/java/com/gregtechceu/gtceu/integration/recipeviewer/emi/orevein/GTOreVeinEmiCategory.java new file mode 100644 index 00000000000..b30962a177e --- /dev/null +++ b/src/main/java/com/gregtechceu/gtceu/integration/recipeviewer/emi/orevein/GTOreVeinEmiCategory.java @@ -0,0 +1,75 @@ +package com.gregtechceu.gtceu.integration.recipeviewer.emi.orevein; + +import com.gregtechceu.gtceu.GTCEu; +import com.gregtechceu.gtceu.api.data.worldgen.GTOreDefinition; +import com.gregtechceu.gtceu.client.ClientProxy; +import com.gregtechceu.gtceu.common.data.GTItems; +import com.gregtechceu.gtceu.integration.recipeviewer.widgets.OreVeinRecipeWidget; + +import dev.emi.emi.api.stack.EmiIngredient; +import net.minecraft.network.chat.Component; +import net.minecraft.world.item.Items; + +import brachy.modularui.integration.emi.recipe.ModularUIEmiRecipe; +import dev.emi.emi.api.EmiRegistry; +import dev.emi.emi.api.recipe.EmiRecipeCategory; +import dev.emi.emi.api.stack.EmiStack; +import org.jetbrains.annotations.NotNull; + +import java.util.Arrays; +import java.util.List; + +public class GTOreVeinEmiCategory extends EmiRecipeCategory { + + public static final GTOreVeinEmiCategory CATEGORY = new GTOreVeinEmiCategory(); + + public GTOreVeinEmiCategory() { + super(GTCEu.id("ore_vein_diagram"), EmiStack.of(Items.RAW_IRON)); + } + + public static void registerDisplays(EmiRegistry registry) { + for (GTOreDefinition oreDefinition : ClientProxy.CLIENT_ORE_VEINS.values()) { + registry.addRecipe(new GTEmiOreVein(oreDefinition)); + } + } + + public static void registerWorkStations(EmiRegistry registry) { + registry.addWorkstation(CATEGORY, EmiStack.of(GTItems.PROSPECTOR_LV.asStack())); + registry.addWorkstation(CATEGORY, EmiStack.of(GTItems.PROSPECTOR_HV.asStack())); + registry.addWorkstation(CATEGORY, EmiStack.of(GTItems.PROSPECTOR_LuV.asStack())); + } + + @Override + public Component getName() { + return Component.translatable("gtceu.jei.ore_vein_diagram"); + } + + public static class GTEmiOreVein extends ModularUIEmiRecipe { + + private final GTOreDefinition oreDefinition; + + public GTEmiOreVein(GTOreDefinition oreDefinition) { + super(ClientProxy.CLIENT_ORE_VEINS.inverse().get(oreDefinition).withPrefix("/ore_vein_diagram/"), + () -> new OreVeinRecipeWidget(oreDefinition)); + this.oreDefinition = oreDefinition; + } + + @Override + public EmiRecipeCategory getCategory() { + return GTOreVeinEmiCategory.CATEGORY; + } + + @Override + public List getInputs() { + return Arrays.stream(OreVeinRecipeWidget.getDimensionMarkers(oreDefinition.dimensionFilter())).map(v -> (EmiIngredient)EmiStack.of(v.getIcon())).toList(); + } + + @Override + public @NotNull List getOutputs() { + return OreVeinRecipeWidget.getContainedOresAndBlocks(oreDefinition) + .stream() + .map(EmiStack::of) + .toList(); + } + } +} diff --git a/src/main/java/com/gregtechceu/gtceu/integration/emi/recipe/Ae2PatternTerminalHandler.java b/src/main/java/com/gregtechceu/gtceu/integration/recipeviewer/emi/recipe/Ae2PatternTerminalHandler.java similarity index 93% rename from src/main/java/com/gregtechceu/gtceu/integration/emi/recipe/Ae2PatternTerminalHandler.java rename to src/main/java/com/gregtechceu/gtceu/integration/recipeviewer/emi/recipe/Ae2PatternTerminalHandler.java index e1a6c87e270..a2ce8ba1415 100644 --- a/src/main/java/com/gregtechceu/gtceu/integration/emi/recipe/Ae2PatternTerminalHandler.java +++ b/src/main/java/com/gregtechceu/gtceu/integration/recipeviewer/emi/recipe/Ae2PatternTerminalHandler.java @@ -1,6 +1,6 @@ -package com.gregtechceu.gtceu.integration.emi.recipe; +package com.gregtechceu.gtceu.integration.recipeviewer.emi.recipe; -import com.gregtechceu.gtceu.integration.emi.multipage.MultiblockInfoEmiRecipe; +import com.gregtechceu.gtceu.integration.recipeviewer.emi.MultiblockInfoEmiCategory; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen; @@ -39,7 +39,7 @@ public EmiPlayerInventory getInventory(AbstractContainerScreen screen) { @Override public boolean supportsRecipe(EmiRecipe recipe) { - return recipe instanceof GTEmiRecipe || recipe instanceof MultiblockInfoEmiRecipe; + return recipe instanceof GTEmiRecipe || recipe instanceof MultiblockInfoEmiCategory.MultiblockInfoEmiWrapper; } @Override diff --git a/src/main/java/com/gregtechceu/gtceu/integration/recipeviewer/emi/recipe/GTEmiRecipe.java b/src/main/java/com/gregtechceu/gtceu/integration/recipeviewer/emi/recipe/GTEmiRecipe.java new file mode 100644 index 00000000000..fc513cf11c0 --- /dev/null +++ b/src/main/java/com/gregtechceu/gtceu/integration/recipeviewer/emi/recipe/GTEmiRecipe.java @@ -0,0 +1,92 @@ +package com.gregtechceu.gtceu.integration.recipeviewer.emi.recipe; + +import brachy.modularui.integration.emi.EmiRecipeViewerSlot; +import brachy.modularui.integration.emi.recipe.ModularUIEmiRecipe; +import com.gregtechceu.gtceu.api.capability.recipe.FluidRecipeCapability; +import com.gregtechceu.gtceu.api.capability.recipe.ItemRecipeCapability; +import com.gregtechceu.gtceu.api.recipe.GTRecipe; +import com.gregtechceu.gtceu.api.recipe.RecipeHelper; +import com.gregtechceu.gtceu.api.recipe.gui.GTRecipeViewerWidget; + +import dev.emi.emi.api.stack.EmiStack; + +import dev.emi.emi.api.recipe.EmiRecipeCategory; +import dev.emi.emi.api.stack.EmiIngredient; +import it.unimi.dsi.fastutil.objects.ObjectArrayList; + +import java.util.List; + +public class GTEmiRecipe extends ModularUIEmiRecipe { + + final EmiRecipeCategory category; + final GTRecipe recipe; + + public GTEmiRecipe(GTRecipe recipe, EmiRecipeCategory category) { + super(recipe.getId(), () -> new GTRecipeViewerWidget(recipe)); + this.category = category; + this.recipe = recipe; + + } + + @Override + public EmiRecipeCategory getCategory() { + return category; + } + + @Override + public List getInputs() { + + List ingredients = new ObjectArrayList<>(); + + var items = recipe.getInputContents(ItemRecipeCapability.CAP); + var fluids = recipe.getInputContents(FluidRecipeCapability.CAP); + + for (var itemContent: items) { + float chance = (float) recipe.recipeType.getChanceFunction() + .getBoostedChance(itemContent, RecipeHelper.getRecipeEUtTier(recipe), RecipeHelper.getRecipeEUtTier(recipe)) / itemContent.maxChance(); + + var mapped = ItemRecipeCapability.mapIngredientToEntryList(ItemRecipeCapability.CAP.of(itemContent.content())); + + ingredients.add(EmiRecipeViewerSlot.EmiIngredientHandler.toEmiIngredient(mapped, chance, $ -> $)); + } + + for (var fluidContent: fluids) { + float chance = (float) recipe.recipeType.getChanceFunction() + .getBoostedChance(fluidContent, RecipeHelper.getRecipeEUtTier(recipe), RecipeHelper.getRecipeEUtTier(recipe)) / fluidContent.maxChance(); + + var mapped = FluidRecipeCapability.mapIngredientToEntryList(FluidRecipeCapability.CAP.of(fluidContent.content())); + + ingredients.add(EmiRecipeViewerSlot.EmiIngredientHandler.toEmiIngredient(mapped, chance)); + } + + return ingredients; + } + + @Override + public List getOutputs() { + List outputs = new ObjectArrayList<>(); + + var items = recipe.getOutputContents(ItemRecipeCapability.CAP); + var fluids = recipe.getOutputContents(FluidRecipeCapability.CAP); + + for (var itemContent: items) { + float chance = (float) recipe.recipeType.getChanceFunction() + .getBoostedChance(itemContent, RecipeHelper.getRecipeEUtTier(recipe), RecipeHelper.getRecipeEUtTier(recipe)) / itemContent.maxChance(); + + var mapped = ItemRecipeCapability.mapIngredientToEntryList(ItemRecipeCapability.CAP.of(itemContent.content())); + + outputs.add(EmiStack.of(mapped.getStacks().get(0)).setChance(chance)); + } + + for (var fluidContent: fluids) { + float chance = (float) recipe.recipeType.getChanceFunction() + .getBoostedChance(fluidContent, RecipeHelper.getRecipeEUtTier(recipe), RecipeHelper.getRecipeEUtTier(recipe)) / fluidContent.maxChance(); + + var mapped = FluidRecipeCapability.mapIngredientToEntryList(FluidRecipeCapability.CAP.of(fluidContent.content())); + var fluid = mapped.getStacks().get(0); + outputs.add(EmiStack.of(fluid.getFluid(), fluid.getAmount()).setChance(chance)); + } + + return outputs; + } +} diff --git a/src/main/java/com/gregtechceu/gtceu/integration/emi/recipe/GTEmiRecipeHandler.java b/src/main/java/com/gregtechceu/gtceu/integration/recipeviewer/emi/recipe/GTEmiRecipeHandler.java similarity index 94% rename from src/main/java/com/gregtechceu/gtceu/integration/emi/recipe/GTEmiRecipeHandler.java rename to src/main/java/com/gregtechceu/gtceu/integration/recipeviewer/emi/recipe/GTEmiRecipeHandler.java index 909f27f555b..97ecf734048 100644 --- a/src/main/java/com/gregtechceu/gtceu/integration/emi/recipe/GTEmiRecipeHandler.java +++ b/src/main/java/com/gregtechceu/gtceu/integration/recipeviewer/emi/recipe/GTEmiRecipeHandler.java @@ -1,4 +1,4 @@ -package com.gregtechceu.gtceu.integration.emi.recipe; +package com.gregtechceu.gtceu.integration.recipeviewer.emi.recipe; import com.lowdragmc.lowdraglib.gui.modular.ModularUIContainer; import com.lowdragmc.lowdraglib.gui.widget.SlotWidget; diff --git a/src/main/java/com/gregtechceu/gtceu/integration/emi/recipe/GTRecipeEMICategory.java b/src/main/java/com/gregtechceu/gtceu/integration/recipeviewer/emi/recipe/GTRecipeEMICategory.java similarity index 98% rename from src/main/java/com/gregtechceu/gtceu/integration/emi/recipe/GTRecipeEMICategory.java rename to src/main/java/com/gregtechceu/gtceu/integration/recipeviewer/emi/recipe/GTRecipeEMICategory.java index f2b9ab4a9ec..47e25475baa 100644 --- a/src/main/java/com/gregtechceu/gtceu/integration/emi/recipe/GTRecipeEMICategory.java +++ b/src/main/java/com/gregtechceu/gtceu/integration/recipeviewer/emi/recipe/GTRecipeEMICategory.java @@ -1,4 +1,4 @@ -package com.gregtechceu.gtceu.integration.emi.recipe; +package com.gregtechceu.gtceu.integration.recipeviewer.emi.recipe; import com.gregtechceu.gtceu.GTCEu; import com.gregtechceu.gtceu.api.machine.MachineDefinition; diff --git a/src/main/java/com/gregtechceu/gtceu/integration/recipeviewer/entry/EntryList.java b/src/main/java/com/gregtechceu/gtceu/integration/recipeviewer/entry/EntryList.java deleted file mode 100644 index 449b161a476..00000000000 --- a/src/main/java/com/gregtechceu/gtceu/integration/recipeviewer/entry/EntryList.java +++ /dev/null @@ -1,10 +0,0 @@ -package com.gregtechceu.gtceu.integration.recipeviewer.entry; - -import java.util.List; - -public interface EntryList { - - List getStacks(); - - boolean isEmpty(); -} diff --git a/src/main/java/com/gregtechceu/gtceu/integration/recipeviewer/entry/fluid/FluidEntryList.java b/src/main/java/com/gregtechceu/gtceu/integration/recipeviewer/entry/fluid/FluidEntryList.java deleted file mode 100644 index c12930cba2d..00000000000 --- a/src/main/java/com/gregtechceu/gtceu/integration/recipeviewer/entry/fluid/FluidEntryList.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.gregtechceu.gtceu.integration.recipeviewer.entry.fluid; - -import com.gregtechceu.gtceu.integration.recipeviewer.entry.EntryList; - -import net.minecraftforge.fluids.FluidStack; - -import java.util.List; - -public sealed interface FluidEntryList extends EntryList - permits FluidStackList, FluidTagList, FluidHolderSetList { - - List getStacks(); - - boolean isEmpty(); -} diff --git a/src/main/java/com/gregtechceu/gtceu/integration/recipeviewer/entry/fluid/FluidHolderSetList.java b/src/main/java/com/gregtechceu/gtceu/integration/recipeviewer/entry/fluid/FluidHolderSetList.java deleted file mode 100644 index 4cf0200be90..00000000000 --- a/src/main/java/com/gregtechceu/gtceu/integration/recipeviewer/entry/fluid/FluidHolderSetList.java +++ /dev/null @@ -1,53 +0,0 @@ -package com.gregtechceu.gtceu.integration.recipeviewer.entry.fluid; - -import net.minecraft.core.HolderSet; -import net.minecraft.nbt.CompoundTag; -import net.minecraft.world.level.material.Fluid; -import net.minecraftforge.fluids.FluidStack; - -import lombok.Getter; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -import java.util.ArrayList; -import java.util.List; -import java.util.stream.Stream; - -public final class FluidHolderSetList implements FluidEntryList { - - @Getter - private final List entries = new ArrayList<>(); - - public static FluidHolderSetList of(@NotNull HolderSet set, int amount, @Nullable CompoundTag nbt) { - var list = new FluidHolderSetList(); - list.add(set, amount, nbt); - return list; - } - - public void add(FluidHolderSetEntry entry) { - entries.add(entry); - } - - public void add(@NotNull HolderSet set, int amount, @Nullable CompoundTag nbt) { - add(new FluidHolderSetEntry(set, amount, nbt)); - } - - @Override - public boolean isEmpty() { - return entries.isEmpty(); - } - - @Override - public List getStacks() { - return entries.stream() - .flatMap(FluidHolderSetEntry::stacks) - .toList(); - } - - public record FluidHolderSetEntry(@NotNull HolderSet set, int amount, @Nullable CompoundTag nbt) { - - public Stream stacks() { - return set.stream().map(holder -> new FluidStack(holder.get(), amount, nbt)); - } - } -} diff --git a/src/main/java/com/gregtechceu/gtceu/integration/recipeviewer/entry/fluid/FluidStackList.java b/src/main/java/com/gregtechceu/gtceu/integration/recipeviewer/entry/fluid/FluidStackList.java deleted file mode 100644 index 196f26261b1..00000000000 --- a/src/main/java/com/gregtechceu/gtceu/integration/recipeviewer/entry/fluid/FluidStackList.java +++ /dev/null @@ -1,51 +0,0 @@ -package com.gregtechceu.gtceu.integration.recipeviewer.entry.fluid; - -import net.minecraftforge.fluids.FluidStack; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; -import java.util.stream.Stream; - -public final class FluidStackList implements FluidEntryList { - - private final List stacks; - - public FluidStackList() { - this.stacks = new ArrayList<>(); - } - - public static FluidStackList of(FluidStack stack) { - var list = new FluidStackList(); - list.add(stack); - return list; - } - - public static FluidStackList of(Collection coll) { - var list = new FluidStackList(); - list.addAll(coll); - return list; - } - - public void add(FluidStack stack) { - stacks.add(stack); - } - - public void addAll(Collection list) { - stacks.addAll(list); - } - - @Override - public boolean isEmpty() { - return stacks.isEmpty(); - } - - @Override - public List getStacks() { - return stacks; - } - - public Stream stream() { - return stacks.stream(); - } -} diff --git a/src/main/java/com/gregtechceu/gtceu/integration/recipeviewer/entry/fluid/FluidTagList.java b/src/main/java/com/gregtechceu/gtceu/integration/recipeviewer/entry/fluid/FluidTagList.java deleted file mode 100644 index 615d6c19510..00000000000 --- a/src/main/java/com/gregtechceu/gtceu/integration/recipeviewer/entry/fluid/FluidTagList.java +++ /dev/null @@ -1,56 +0,0 @@ -package com.gregtechceu.gtceu.integration.recipeviewer.entry.fluid; - -import net.minecraft.core.HolderSet; -import net.minecraft.core.registries.BuiltInRegistries; -import net.minecraft.nbt.CompoundTag; -import net.minecraft.tags.TagKey; -import net.minecraft.world.level.material.Fluid; -import net.minecraftforge.fluids.FluidStack; - -import lombok.Getter; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -import java.util.ArrayList; -import java.util.List; -import java.util.stream.Stream; - -public final class FluidTagList implements FluidEntryList { - - @Getter - private final List entries = new ArrayList<>(); - - public static FluidTagList of(@NotNull TagKey tag, int amount, @Nullable CompoundTag nbt) { - var list = new FluidTagList(); - list.add(tag, amount, nbt); - return list; - } - - public void add(FluidTagEntry entry) { - entries.add(entry); - } - - public void add(@NotNull TagKey tag, int amount, @Nullable CompoundTag nbt) { - add(new FluidTagEntry(tag, amount, nbt)); - } - - @Override - public boolean isEmpty() { - return entries.isEmpty(); - } - - @Override - public List getStacks() { - return entries.stream() - .flatMap(FluidTagEntry::stacks) - .toList(); - } - - public record FluidTagEntry(@NotNull TagKey tag, int amount, @Nullable CompoundTag nbt) { - - public Stream stacks() { - return BuiltInRegistries.FLUID.getTag(tag).map(HolderSet.ListBacked::stream).orElseGet(Stream::empty) - .map(holder -> new FluidStack(holder.get(), amount, nbt)); - } - } -} diff --git a/src/main/java/com/gregtechceu/gtceu/integration/recipeviewer/entry/item/ItemEntryList.java b/src/main/java/com/gregtechceu/gtceu/integration/recipeviewer/entry/item/ItemEntryList.java deleted file mode 100644 index 8fba73c48b8..00000000000 --- a/src/main/java/com/gregtechceu/gtceu/integration/recipeviewer/entry/item/ItemEntryList.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.gregtechceu.gtceu.integration.recipeviewer.entry.item; - -import com.gregtechceu.gtceu.integration.recipeviewer.entry.EntryList; - -import net.minecraft.world.item.ItemStack; - -import java.util.List; - -public sealed interface ItemEntryList extends EntryList - permits ItemStackList, ItemTagList, ItemHolderSetList { - - List getStacks(); - - boolean isEmpty(); -} diff --git a/src/main/java/com/gregtechceu/gtceu/integration/recipeviewer/entry/item/ItemHolderSetList.java b/src/main/java/com/gregtechceu/gtceu/integration/recipeviewer/entry/item/ItemHolderSetList.java deleted file mode 100644 index c0bf2a3a672..00000000000 --- a/src/main/java/com/gregtechceu/gtceu/integration/recipeviewer/entry/item/ItemHolderSetList.java +++ /dev/null @@ -1,53 +0,0 @@ -package com.gregtechceu.gtceu.integration.recipeviewer.entry.item; - -import net.minecraft.core.HolderSet; -import net.minecraft.nbt.CompoundTag; -import net.minecraft.world.item.Item; -import net.minecraft.world.item.ItemStack; - -import lombok.Getter; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -import java.util.ArrayList; -import java.util.List; -import java.util.stream.Stream; - -public final class ItemHolderSetList implements ItemEntryList { - - @Getter - private final List entries = new ArrayList<>(); - - public static ItemHolderSetList of(@NotNull HolderSet set, int amount, @Nullable CompoundTag nbt) { - var list = new ItemHolderSetList(); - list.add(set, amount, nbt); - return list; - } - - public void add(ItemHolderSetEntry entry) { - entries.add(entry); - } - - public void add(@NotNull HolderSet set, int amount, @Nullable CompoundTag nbt) { - add(new ItemHolderSetEntry(set, amount, nbt)); - } - - @Override - public boolean isEmpty() { - return entries.isEmpty(); - } - - @Override - public List getStacks() { - return entries.stream() - .flatMap(ItemHolderSetEntry::stacks) - .toList(); - } - - public record ItemHolderSetEntry(@NotNull HolderSet set, int amount, @Nullable CompoundTag nbt) { - - public Stream stacks() { - return set.stream().map(holder -> ItemTagList.stackWithTag(holder, amount, nbt)); - } - } -} diff --git a/src/main/java/com/gregtechceu/gtceu/integration/recipeviewer/entry/item/ItemStackList.java b/src/main/java/com/gregtechceu/gtceu/integration/recipeviewer/entry/item/ItemStackList.java deleted file mode 100644 index 19946e51e35..00000000000 --- a/src/main/java/com/gregtechceu/gtceu/integration/recipeviewer/entry/item/ItemStackList.java +++ /dev/null @@ -1,55 +0,0 @@ -package com.gregtechceu.gtceu.integration.recipeviewer.entry.item; - -import net.minecraft.world.item.ItemStack; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; -import java.util.stream.Stream; - -public final class ItemStackList implements ItemEntryList { - - private final List stacks; - - public ItemStackList() { - this.stacks = new ArrayList<>(); - } - - public ItemStackList(List list) { - this.stacks = new ArrayList<>(list); - } - - public static ItemStackList of(ItemStack stack) { - var list = new ItemStackList(); - list.add(stack); - return list; - } - - public static ItemStackList of(Collection coll) { - var list = new ItemStackList(); - list.addAll(coll); - return list; - } - - public void add(ItemStack stack) { - stacks.add(stack); - } - - public void addAll(Collection list) { - stacks.addAll(list); - } - - @Override - public boolean isEmpty() { - return stacks.isEmpty(); - } - - @Override - public List getStacks() { - return stacks; - } - - public Stream stream() { - return stacks.stream(); - } -} diff --git a/src/main/java/com/gregtechceu/gtceu/integration/recipeviewer/entry/item/ItemTagList.java b/src/main/java/com/gregtechceu/gtceu/integration/recipeviewer/entry/item/ItemTagList.java deleted file mode 100644 index f269f42d817..00000000000 --- a/src/main/java/com/gregtechceu/gtceu/integration/recipeviewer/entry/item/ItemTagList.java +++ /dev/null @@ -1,63 +0,0 @@ -package com.gregtechceu.gtceu.integration.recipeviewer.entry.item; - -import net.minecraft.core.Holder; -import net.minecraft.core.HolderSet; -import net.minecraft.core.registries.BuiltInRegistries; -import net.minecraft.nbt.CompoundTag; -import net.minecraft.tags.TagKey; -import net.minecraft.world.item.Item; -import net.minecraft.world.item.ItemStack; - -import lombok.Getter; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -import java.util.ArrayList; -import java.util.List; -import java.util.stream.Stream; - -public final class ItemTagList implements ItemEntryList { - - @Getter - private final List entries = new ArrayList<>(); - - public static ItemTagList of(@NotNull TagKey tag, int amount, @Nullable CompoundTag nbt) { - var list = new ItemTagList(); - list.add(tag, amount, nbt); - return list; - } - - public void add(ItemTagEntry entry) { - entries.add(entry); - } - - public void add(@NotNull TagKey tag, int amount, @Nullable CompoundTag nbt) { - add(new ItemTagEntry(tag, amount, nbt)); - } - - @Override - public boolean isEmpty() { - return entries.isEmpty(); - } - - @Override - public List getStacks() { - return entries.stream() - .flatMap(ItemTagEntry::stacks) - .toList(); - } - - public record ItemTagEntry(@NotNull TagKey tag, int amount, @Nullable CompoundTag nbt) { - - public Stream stacks() { - return BuiltInRegistries.ITEM.getTag(tag).map(HolderSet.ListBacked::stream).orElseGet(Stream::empty) - .map(holder -> stackWithTag(holder, amount, nbt)); - } - } - - static ItemStack stackWithTag(Holder holder, int amount, @Nullable CompoundTag nbt) { - ItemStack stack = new ItemStack(holder.value(), amount); - stack.setTag(nbt); - return stack; - } -} diff --git a/src/main/java/com/gregtechceu/gtceu/integration/recipeviewer/handlers/fluid/CycleFluidEntryHandler.java b/src/main/java/com/gregtechceu/gtceu/integration/recipeviewer/handlers/fluid/CycleFluidEntryHandler.java deleted file mode 100644 index 96444cd34d1..00000000000 --- a/src/main/java/com/gregtechceu/gtceu/integration/recipeviewer/handlers/fluid/CycleFluidEntryHandler.java +++ /dev/null @@ -1,103 +0,0 @@ -package com.gregtechceu.gtceu.integration.recipeviewer.handlers.fluid; - -import com.gregtechceu.gtceu.integration.recipeviewer.entry.fluid.FluidEntryList; - -import net.minecraftforge.fluids.FluidStack; -import net.minecraftforge.fluids.capability.IFluidHandler; - -import lombok.Getter; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -import java.util.ArrayList; -import java.util.List; -import java.util.stream.Collectors; - -public class CycleFluidEntryHandler implements IFluidHandler { - - @Getter - private final List entries; - - private List> unwrapped = null; - - public CycleFluidEntryHandler(List entries) { - this.entries = new ArrayList<>(entries); - } - - public List> getUnwrapped() { - if (unwrapped == null) { - unwrapped = entries.stream() - .map(CycleFluidEntryHandler::getStacksNullable) - .collect(Collectors.toCollection(ArrayList::new)); - } - return unwrapped; - } - - private static @Nullable List getStacksNullable(FluidEntryList list) { - if (list == null) return null; - return list.getStacks(); - } - - public FluidEntryList getEntry(int index) { - return entries.get(index); - } - - @Override - public int getTanks() { - return entries.size(); - } - - @NotNull - @Override - public FluidStack getFluidInTank(int tank) { - List stackList = getUnwrapped().get(tank); - return stackList == null || stackList.isEmpty() ? FluidStack.EMPTY : - stackList.get(Math.abs((int) (System.currentTimeMillis() / 1000) % stackList.size())); - } - - /* - * @Override - * public void setFluidInTank(int tank, @NotNull FluidStack fluidStack) { - * if (tank >= 0 && tank < entries.size()) { - * entries.set(tank, FluidStackList.of(fluidStack)); - * unwrapped = null; - * } - * } - */ - - @Override - public int getTankCapacity(int tank) { - return getFluidInTank(tank).getAmount(); - } - - @Override - public boolean isFluidValid(int tank, @NotNull FluidStack stack) { - return false; - } - - @Override - public int fill(FluidStack resource, FluidAction action) { - return 0; - } - - // @Override - // public boolean supportsFill(int tank) { - // return false; - // } - - @NotNull - @Override - public FluidStack drain(FluidStack resource, FluidAction action) { - return FluidStack.EMPTY; - } - - @Override - public @NotNull FluidStack drain(int maxDrain, FluidAction action) { - return FluidStack.EMPTY; - } - - // @Override - // public boolean supportsDrain(int tank) { - // return false; - // } -} diff --git a/src/main/java/com/gregtechceu/gtceu/integration/recipeviewer/handlers/fluid/EmptyFluidTank.java b/src/main/java/com/gregtechceu/gtceu/integration/recipeviewer/handlers/fluid/EmptyFluidTank.java deleted file mode 100644 index d57216d41ea..00000000000 --- a/src/main/java/com/gregtechceu/gtceu/integration/recipeviewer/handlers/fluid/EmptyFluidTank.java +++ /dev/null @@ -1,49 +0,0 @@ -package com.gregtechceu.gtceu.integration.recipeviewer.handlers.fluid; - -import net.minecraftforge.fluids.FluidStack; -import net.minecraftforge.fluids.IFluidTank; -import net.minecraftforge.fluids.capability.IFluidHandler; - -import org.jetbrains.annotations.NotNull; - -public class EmptyFluidTank implements IFluidTank { - - public static final EmptyFluidTank INSTANCE = new EmptyFluidTank(); - - protected EmptyFluidTank() {} - - @Override - public @NotNull FluidStack getFluid() { - return FluidStack.EMPTY; - } - - @Override - public int getFluidAmount() { - return 0; - } - - @Override - public int getCapacity() { - return 0; - } - - @Override - public boolean isFluidValid(@NotNull FluidStack stack) { - return false; - } - - @Override - public int fill(@NotNull FluidStack resource, @NotNull IFluidHandler.FluidAction action) { - return 0; - } - - @Override - public @NotNull FluidStack drain(int maxDrain, IFluidHandler.FluidAction action) { - return FluidStack.EMPTY; - } - - @Override - public @NotNull FluidStack drain(FluidStack resource, IFluidHandler.FluidAction action) { - return FluidStack.EMPTY; - } -} diff --git a/src/main/java/com/gregtechceu/gtceu/integration/recipeviewer/handlers/item/CycleItemEntryHandler.java b/src/main/java/com/gregtechceu/gtceu/integration/recipeviewer/handlers/item/CycleItemEntryHandler.java deleted file mode 100644 index 469c560a2a6..00000000000 --- a/src/main/java/com/gregtechceu/gtceu/integration/recipeviewer/handlers/item/CycleItemEntryHandler.java +++ /dev/null @@ -1,97 +0,0 @@ -package com.gregtechceu.gtceu.integration.recipeviewer.handlers.item; - -import com.gregtechceu.gtceu.integration.recipeviewer.entry.item.ItemEntryList; -import com.gregtechceu.gtceu.integration.recipeviewer.entry.item.ItemStackList; - -import net.minecraft.world.item.ItemStack; -import net.minecraftforge.items.IItemHandlerModifiable; - -import lombok.Getter; -import org.jetbrains.annotations.NotNull; - -import java.util.ArrayList; -import java.util.List; -import java.util.stream.Collectors; - -public class CycleItemEntryHandler implements IItemHandlerModifiable { - - @Getter - private final List entries; - private List> unwrapped = null; - - public CycleItemEntryHandler(List entries) { - this.entries = new ArrayList<>(entries); - } - - public static CycleItemEntryHandler fromStacks(List> stacks) { - List entries = new ArrayList<>(); - for (var list : stacks) { - entries.add(ItemStackList.of(list)); - } - CycleItemEntryHandler handler = new CycleItemEntryHandler(entries); - handler.unwrapped = new ArrayList<>(stacks); - - return handler; - } - - public List> getUnwrapped() { - if (unwrapped == null) { - unwrapped = entries.stream() - .map(CycleItemEntryHandler::getStacksNullable) - .collect(Collectors.toCollection(ArrayList::new)); - } - return unwrapped; - } - - private static List getStacksNullable(ItemEntryList list) { - if (list == null) return null; - return list.getStacks(); - } - - public ItemEntryList getEntry(int index) { - return entries.get(index); - } - - @Override - public int getSlots() { - return entries.size(); - } - - @NotNull - @Override - public ItemStack getStackInSlot(int slot) { - List stackList = getUnwrapped().get(slot); - return stackList == null || stackList.isEmpty() ? ItemStack.EMPTY : - stackList.get(Math.abs((int) (System.currentTimeMillis() / 1000) % stackList.size())); - } - - @Override - public void setStackInSlot(int index, ItemStack stack) { - if (index >= 0 && index < entries.size()) { - entries.set(index, ItemStackList.of(stack)); - unwrapped = null; - } - } - - @NotNull - @Override - public ItemStack insertItem(int slot, @NotNull ItemStack stack, boolean simulate) { - return stack; - } - - @NotNull - @Override - public ItemStack extractItem(int slot, int amount, boolean simulate) { - return ItemStack.EMPTY; - } - - @Override - public int getSlotLimit(int slot) { - return Integer.MAX_VALUE; - } - - @Override - public boolean isItemValid(int slot, @NotNull ItemStack stack) { - return true; - } -} diff --git a/src/main/java/com/gregtechceu/gtceu/integration/jei/GTJEIPlugin.java b/src/main/java/com/gregtechceu/gtceu/integration/recipeviewer/jei/GTJEIPlugin.java similarity index 80% rename from src/main/java/com/gregtechceu/gtceu/integration/jei/GTJEIPlugin.java rename to src/main/java/com/gregtechceu/gtceu/integration/recipeviewer/jei/GTJEIPlugin.java index 13219a4cff0..591e72dfbed 100644 --- a/src/main/java/com/gregtechceu/gtceu/integration/jei/GTJEIPlugin.java +++ b/src/main/java/com/gregtechceu/gtceu/integration/recipeviewer/jei/GTJEIPlugin.java @@ -1,4 +1,4 @@ -package com.gregtechceu.gtceu.integration.jei; +package com.gregtechceu.gtceu.integration.recipeviewer.jei; import com.gregtechceu.gtceu.GTCEu; import com.gregtechceu.gtceu.api.recipe.category.GTRecipeCategory; @@ -10,14 +10,11 @@ import com.gregtechceu.gtceu.common.fluid.potion.PotionFluid; import com.gregtechceu.gtceu.common.item.behavior.IntCircuitBehaviour; import com.gregtechceu.gtceu.config.ConfigHolder; -import com.gregtechceu.gtceu.integration.jei.circuit.GTProgrammedCircuitCategory; -import com.gregtechceu.gtceu.integration.jei.multipage.MultiblockInfoCategory; -import com.gregtechceu.gtceu.integration.jei.oreprocessing.GTOreProcessingInfoCategory; -import com.gregtechceu.gtceu.integration.jei.orevein.GTBedrockFluidInfoCategory; -import com.gregtechceu.gtceu.integration.jei.orevein.GTBedrockOreInfoCategory; -import com.gregtechceu.gtceu.integration.jei.orevein.GTOreVeinInfoCategory; -import com.gregtechceu.gtceu.integration.jei.recipe.GTRecipeJEICategory; -import com.gregtechceu.gtceu.integration.jei.subtype.PotionFluidSubtypeInterpreter; +import com.gregtechceu.gtceu.integration.recipeviewer.jei.orevein.GTBedrockFluidInfoCategory; +import com.gregtechceu.gtceu.integration.recipeviewer.jei.orevein.GTBedrockOreInfoCategory; +import com.gregtechceu.gtceu.integration.recipeviewer.jei.orevein.GTOreVeinInfoCategory; +import com.gregtechceu.gtceu.integration.recipeviewer.jei.recipe.GTRecipeJEICategory; +import com.gregtechceu.gtceu.integration.recipeviewer.jei.subtype.PotionFluidSubtypeInterpreter; import net.minecraft.MethodsReturnNonnullByDefault; import net.minecraft.core.registries.BuiltInRegistries; @@ -64,9 +61,9 @@ public void registerCategories(@NotNull IRecipeCategoryRegistration registry) { if (GTCEu.Mods.isREILoaded() || GTCEu.Mods.isEMILoaded()) return; GTCEu.LOGGER.info("JEI register categories"); IJeiHelpers jeiHelpers = registry.getJeiHelpers(); - registry.addRecipeCategories(new MultiblockInfoCategory(jeiHelpers)); + registry.addRecipeCategories(new MultiblockInfoJeiCategory(jeiHelpers)); if (!ConfigHolder.INSTANCE.compat.hideOreProcessingDiagrams) - registry.addRecipeCategories(new GTOreProcessingInfoCategory(jeiHelpers)); + registry.addRecipeCategories(new GTOreProcessingJeiCategory(jeiHelpers)); registry.addRecipeCategories(new GTOreVeinInfoCategory(jeiHelpers)); registry.addRecipeCategories(new GTBedrockFluidInfoCategory(jeiHelpers)); if (ConfigHolder.INSTANCE.machines.doBedrockOres) @@ -76,7 +73,7 @@ public void registerCategories(@NotNull IRecipeCategoryRegistration registry) { // registry.addRecipeCategories(new GTRecipeJEICategory(jeiHelpers, category)); } } - registry.addRecipeCategories(new GTProgrammedCircuitCategory(jeiHelpers)); + registry.addRecipeCategories(new ProgrammedCircuitJeiCategory(jeiHelpers)); } @Override @@ -84,30 +81,30 @@ public void registerRecipeCatalysts(@NotNull IRecipeCatalystRegistration registr if (GTCEu.Mods.isREILoaded() || GTCEu.Mods.isEMILoaded()) return; GTRecipeJEICategory.registerRecipeCatalysts(registration); if (!ConfigHolder.INSTANCE.compat.hideOreProcessingDiagrams) - GTOreProcessingInfoCategory.registerRecipeCatalysts(registration); + GTOreProcessingJeiCategory.registerRecipeCatalysts(registration); GTOreVeinInfoCategory.registerRecipeCatalysts(registration); GTBedrockFluidInfoCategory.registerRecipeCatalysts(registration); if (ConfigHolder.INSTANCE.machines.doBedrockOres) GTBedrockOreInfoCategory.registerRecipeCatalysts(registration); registration.addRecipeCatalyst(GTMultiMachines.LARGE_CHEMICAL_REACTOR.asStack(), GTRecipeJEICategory.TYPES.apply(GTRecipeTypes.CHEMICAL_RECIPES.getCategory())); - registration.addRecipeCatalyst(IntCircuitBehaviour.stack(0), GTProgrammedCircuitCategory.RECIPE_TYPE); + registration.addRecipeCatalyst(IntCircuitBehaviour.stack(0), ProgrammedCircuitJeiCategory.RECIPE_TYPE); } @Override public void registerRecipes(@NotNull IRecipeRegistration registration) { if (GTCEu.Mods.isREILoaded() || GTCEu.Mods.isEMILoaded()) return; GTCEu.LOGGER.info("JEI register"); - MultiblockInfoCategory.registerRecipes(registration); + MultiblockInfoJeiCategory.registerRecipes(registration); GTRecipeJEICategory.registerRecipes(registration); if (!ConfigHolder.INSTANCE.compat.hideOreProcessingDiagrams) - GTOreProcessingInfoCategory.registerRecipes(registration); + GTOreProcessingJeiCategory.registerRecipes(registration); GTOreVeinInfoCategory.registerRecipes(registration); GTBedrockFluidInfoCategory.registerRecipes(registration); if (ConfigHolder.INSTANCE.machines.doBedrockOres) GTBedrockOreInfoCategory.registerRecipes(registration); - registration.addRecipes(GTProgrammedCircuitCategory.RECIPE_TYPE, - List.of(new GTProgrammedCircuitCategory.GTProgrammedCircuitWrapper())); + registration.addRecipes(ProgrammedCircuitJeiCategory.RECIPE_TYPE, + List.of(new ProgrammedCircuitJeiCategory.GTProgrammedCircuitWrapper())); } @Override diff --git a/src/main/java/com/gregtechceu/gtceu/integration/jei/oreprocessing/GTOreProcessingInfoCategory.java b/src/main/java/com/gregtechceu/gtceu/integration/recipeviewer/jei/GTOreProcessingJeiCategory.java similarity index 79% rename from src/main/java/com/gregtechceu/gtceu/integration/jei/oreprocessing/GTOreProcessingInfoCategory.java rename to src/main/java/com/gregtechceu/gtceu/integration/recipeviewer/jei/GTOreProcessingJeiCategory.java index cf18967945c..e35d3d91cc8 100644 --- a/src/main/java/com/gregtechceu/gtceu/integration/jei/oreprocessing/GTOreProcessingInfoCategory.java +++ b/src/main/java/com/gregtechceu/gtceu/integration/recipeviewer/jei/GTOreProcessingJeiCategory.java @@ -1,18 +1,18 @@ -package com.gregtechceu.gtceu.integration.jei.oreprocessing; +package com.gregtechceu.gtceu.integration.recipeviewer.jei; import com.gregtechceu.gtceu.GTCEu; import com.gregtechceu.gtceu.api.GTCEuAPI; import com.gregtechceu.gtceu.api.GTValues; import com.gregtechceu.gtceu.api.data.chemical.ChemicalHelper; +import com.gregtechceu.gtceu.api.data.chemical.material.Material; import com.gregtechceu.gtceu.api.data.chemical.material.info.MaterialFlags; import com.gregtechceu.gtceu.api.data.chemical.material.properties.PropertyKey; - -import com.lowdragmc.lowdraglib.jei.ModularUIRecipeCategory; +import com.gregtechceu.gtceu.integration.recipeviewer.widgets.OreProcessingRecipeWidget; import net.minecraft.network.chat.Component; +import brachy.modularui.integration.jei.recipe.ModularUIRecipeCategory; import mezz.jei.api.gui.drawable.IDrawable; -import mezz.jei.api.helpers.IGuiHelper; import mezz.jei.api.helpers.IJeiHelpers; import mezz.jei.api.recipe.RecipeType; import mezz.jei.api.registration.IRecipeCatalystRegistration; @@ -23,16 +23,15 @@ import static com.gregtechceu.gtceu.common.data.GTMachines.*; import static com.gregtechceu.gtceu.common.data.GTMaterials.Iron; -public class GTOreProcessingInfoCategory extends ModularUIRecipeCategory { +public class GTOreProcessingJeiCategory extends + ModularUIRecipeCategory { public final static RecipeType RECIPE_TYPE = new RecipeType<>( GTCEu.id("ore_processing_diagram"), GTOreProcessingInfoWrapper.class); - private final IDrawable background; private final IDrawable icon; - public GTOreProcessingInfoCategory(IJeiHelpers helpers) { - IGuiHelper guiHelper = helpers.getGuiHelper(); - this.background = guiHelper.createBlankDrawable(186, 174); + public GTOreProcessingJeiCategory(IJeiHelpers helpers) { + super(v -> new OreProcessingRecipeWidget(v.material), v -> v.material.getResourceLocation()); this.icon = helpers.getGuiHelper().createDrawableItemStack(ChemicalHelper.get(rawOre, Iron)); } @@ -66,15 +65,11 @@ public Component getTitle() { return Component.translatable("gtceu.jei.ore_processing_diagram"); } - @NotNull - @Override - public IDrawable getBackground() { - return background; - } - @NotNull @Override public IDrawable getIcon() { return icon; } + + public record GTOreProcessingInfoWrapper(Material material) {} } diff --git a/src/main/java/com/gregtechceu/gtceu/integration/jei/multipage/MultiblockInfoCategory.java b/src/main/java/com/gregtechceu/gtceu/integration/recipeviewer/jei/MultiblockInfoJeiCategory.java similarity index 86% rename from src/main/java/com/gregtechceu/gtceu/integration/jei/multipage/MultiblockInfoCategory.java rename to src/main/java/com/gregtechceu/gtceu/integration/recipeviewer/jei/MultiblockInfoJeiCategory.java index 8984a418d3c..3353fdc4103 100644 --- a/src/main/java/com/gregtechceu/gtceu/integration/jei/multipage/MultiblockInfoCategory.java +++ b/src/main/java/com/gregtechceu/gtceu/integration/recipeviewer/jei/MultiblockInfoJeiCategory.java @@ -1,12 +1,14 @@ -package com.gregtechceu.gtceu.integration.jei.multipage; +package com.gregtechceu.gtceu.integration.recipeviewer.jei; import com.gregtechceu.gtceu.GTCEu; +import com.gregtechceu.gtceu.api.gui.widget.PatternPreviewWidget; import com.gregtechceu.gtceu.api.machine.MultiblockMachineDefinition; import com.gregtechceu.gtceu.api.registry.GTRegistries; import com.gregtechceu.gtceu.common.data.machines.GTMultiMachines; import com.lowdragmc.lowdraglib.gui.widget.Widget; import com.lowdragmc.lowdraglib.jei.ModularUIRecipeCategory; +import com.lowdragmc.lowdraglib.jei.ModularWrapper; import net.minecraft.MethodsReturnNonnullByDefault; import net.minecraft.client.gui.navigation.ScreenPosition; @@ -34,14 +36,15 @@ @MethodsReturnNonnullByDefault @ParametersAreNonnullByDefault -public class MultiblockInfoCategory extends ModularUIRecipeCategory { +public class MultiblockInfoJeiCategory extends + ModularUIRecipeCategory { public final static RecipeType RECIPE_TYPE = new RecipeType<>(GTCEu.id("multiblock_info"), MultiblockInfoWrapper.class); private final IDrawable background; private final IDrawable icon; - public MultiblockInfoCategory(IJeiHelpers helpers) { + public MultiblockInfoJeiCategory(IJeiHelpers helpers) { IGuiHelper guiHelper = helpers.getGuiHelper(); this.background = guiHelper.createBlankDrawable(160, 160); this.icon = helpers.getGuiHelper().createDrawableItemStack(GTMultiMachines.ELECTRIC_BLAST_FURNACE.asStack()); @@ -124,4 +127,14 @@ public IDrawable getBackground() { public IDrawable getIcon() { return icon; } + + public static class MultiblockInfoWrapper extends ModularWrapper { + + public final MultiblockMachineDefinition definition; + + public MultiblockInfoWrapper(MultiblockMachineDefinition definition) { + super(PatternPreviewWidget.getPatternWidget(definition)); + this.definition = definition; + } + } } diff --git a/src/main/java/com/gregtechceu/gtceu/integration/recipeviewer/jei/ProgrammedCircuitJeiCategory.java b/src/main/java/com/gregtechceu/gtceu/integration/recipeviewer/jei/ProgrammedCircuitJeiCategory.java new file mode 100644 index 00000000000..81ee74c7c3c --- /dev/null +++ b/src/main/java/com/gregtechceu/gtceu/integration/recipeviewer/jei/ProgrammedCircuitJeiCategory.java @@ -0,0 +1,45 @@ +package com.gregtechceu.gtceu.integration.recipeviewer.jei; + +import com.gregtechceu.gtceu.GTCEu; +import com.gregtechceu.gtceu.common.data.GTItems; +import com.gregtechceu.gtceu.integration.recipeviewer.widgets.ProgrammedCircuitRecipeWidget; + +import net.minecraft.network.chat.Component; + +import brachy.modularui.integration.jei.recipe.ModularUIRecipeCategory; +import mezz.jei.api.gui.drawable.IDrawable; +import mezz.jei.api.helpers.IJeiHelpers; +import mezz.jei.api.recipe.RecipeType; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +public class ProgrammedCircuitJeiCategory extends + ModularUIRecipeCategory { + + public final static RecipeType RECIPE_TYPE = new RecipeType<>( + GTCEu.id("programmed_circuit"), GTProgrammedCircuitWrapper.class); + + private final IDrawable icon; + + public ProgrammedCircuitJeiCategory(IJeiHelpers helpers) { + super($ -> new ProgrammedCircuitRecipeWidget(), $ -> GTCEu.id("programmed_circuit")); + icon = helpers.getGuiHelper().createDrawableItemStack(GTItems.PROGRAMMED_CIRCUIT.asStack()); + } + + @Override + public @NotNull RecipeType getRecipeType() { + return RECIPE_TYPE; + } + + @Override + public @NotNull Component getTitle() { + return Component.translatable("gtceu.jei.programmed_circuit"); + } + + @Override + public @Nullable IDrawable getIcon() { + return icon; + } + + public static class GTProgrammedCircuitWrapper {} +} diff --git a/src/main/java/com/gregtechceu/gtceu/integration/jei/orevein/GTBedrockFluidInfoCategory.java b/src/main/java/com/gregtechceu/gtceu/integration/recipeviewer/jei/orevein/GTBedrockFluidInfoCategory.java similarity index 61% rename from src/main/java/com/gregtechceu/gtceu/integration/jei/orevein/GTBedrockFluidInfoCategory.java rename to src/main/java/com/gregtechceu/gtceu/integration/recipeviewer/jei/orevein/GTBedrockFluidInfoCategory.java index ea01410570f..e4fb4dafbf8 100644 --- a/src/main/java/com/gregtechceu/gtceu/integration/jei/orevein/GTBedrockFluidInfoCategory.java +++ b/src/main/java/com/gregtechceu/gtceu/integration/recipeviewer/jei/orevein/GTBedrockFluidInfoCategory.java @@ -1,40 +1,38 @@ -package com.gregtechceu.gtceu.integration.jei.orevein; +package com.gregtechceu.gtceu.integration.recipeviewer.jei.orevein; import com.gregtechceu.gtceu.GTCEu; +import com.gregtechceu.gtceu.api.data.worldgen.bedrockfluid.BedrockFluidDefinition; import com.gregtechceu.gtceu.client.ClientProxy; import com.gregtechceu.gtceu.common.data.GTItems; import com.gregtechceu.gtceu.common.data.GTMaterials; -import com.gregtechceu.gtceu.integration.recipeviewer.widgets.GTOreVeinWidget; - -import com.lowdragmc.lowdraglib.jei.ModularUIRecipeCategory; +import com.gregtechceu.gtceu.integration.recipeviewer.widgets.OreVeinRecipeWidget; import net.minecraft.network.chat.Component; +import brachy.modularui.integration.jei.recipe.ModularUIRecipeCategory; import mezz.jei.api.gui.drawable.IDrawable; -import mezz.jei.api.helpers.IGuiHelper; import mezz.jei.api.helpers.IJeiHelpers; import mezz.jei.api.recipe.RecipeType; import mezz.jei.api.registration.IRecipeCatalystRegistration; import mezz.jei.api.registration.IRecipeRegistration; import org.jetbrains.annotations.NotNull; -public class GTBedrockFluidInfoCategory extends ModularUIRecipeCategory { +public class GTBedrockFluidInfoCategory extends + ModularUIRecipeCategory { - public final static RecipeType RECIPE_TYPE = new RecipeType<>( - GTCEu.id("bedrock_fluid_diagram"), GTBedrockFluidInfoWrapper.class); - private final IDrawable background; + public final static RecipeType RECIPE_TYPE = new RecipeType<>( + GTCEu.id("bedrock_fluid_diagram"), BedrockFluidInfoWrapper.class); private final IDrawable icon; public GTBedrockFluidInfoCategory(IJeiHelpers helpers) { - IGuiHelper guiHelper = helpers.getGuiHelper(); - this.background = guiHelper.createBlankDrawable(GTOreVeinWidget.width, 120); + super(v -> new OreVeinRecipeWidget(v.fluid), v -> ClientProxy.CLIENT_FLUID_VEINS.inverse().get(v.fluid)); this.icon = helpers.getGuiHelper() .createDrawableItemStack(GTMaterials.Oil.getFluid().getBucket().asItem().getDefaultInstance()); } public static void registerRecipes(IRecipeRegistration registry) { registry.addRecipes(RECIPE_TYPE, ClientProxy.CLIENT_FLUID_VEINS.values().stream() - .map(GTBedrockFluidInfoWrapper::new) + .map(BedrockFluidInfoWrapper::new) .toList()); } @@ -45,7 +43,7 @@ public static void registerRecipeCatalysts(IRecipeCatalystRegistration registrat @NotNull @Override - public RecipeType getRecipeType() { + public RecipeType getRecipeType() { return RECIPE_TYPE; } @@ -55,15 +53,11 @@ public Component getTitle() { return Component.translatable("gtceu.jei.bedrock_fluid_diagram"); } - @NotNull - @Override - public IDrawable getBackground() { - return background; - } - @NotNull @Override public IDrawable getIcon() { return icon; } + + public record BedrockFluidInfoWrapper(BedrockFluidDefinition fluid) {} } diff --git a/src/main/java/com/gregtechceu/gtceu/integration/jei/orevein/GTBedrockOreInfoCategory.java b/src/main/java/com/gregtechceu/gtceu/integration/recipeviewer/jei/orevein/GTBedrockOreInfoCategory.java similarity index 71% rename from src/main/java/com/gregtechceu/gtceu/integration/jei/orevein/GTBedrockOreInfoCategory.java rename to src/main/java/com/gregtechceu/gtceu/integration/recipeviewer/jei/orevein/GTBedrockOreInfoCategory.java index b0589480b87..15108185589 100644 --- a/src/main/java/com/gregtechceu/gtceu/integration/jei/orevein/GTBedrockOreInfoCategory.java +++ b/src/main/java/com/gregtechceu/gtceu/integration/recipeviewer/jei/orevein/GTBedrockOreInfoCategory.java @@ -1,36 +1,34 @@ -package com.gregtechceu.gtceu.integration.jei.orevein; +package com.gregtechceu.gtceu.integration.recipeviewer.jei.orevein; import com.gregtechceu.gtceu.GTCEu; +import com.gregtechceu.gtceu.api.data.worldgen.bedrockore.BedrockOreDefinition; import com.gregtechceu.gtceu.client.ClientProxy; import com.gregtechceu.gtceu.common.data.GTItems; -import com.gregtechceu.gtceu.integration.recipeviewer.widgets.GTOreVeinWidget; - -import com.lowdragmc.lowdraglib.jei.ModularUIRecipeCategory; +import com.gregtechceu.gtceu.integration.recipeviewer.widgets.OreVeinRecipeWidget; import net.minecraft.network.chat.Component; import net.minecraft.world.item.Items; +import brachy.modularui.integration.jei.recipe.ModularUIRecipeCategory; import lombok.Getter; import mezz.jei.api.gui.drawable.IDrawable; -import mezz.jei.api.helpers.IGuiHelper; import mezz.jei.api.helpers.IJeiHelpers; import mezz.jei.api.recipe.RecipeType; import mezz.jei.api.registration.IRecipeCatalystRegistration; import mezz.jei.api.registration.IRecipeRegistration; import org.jetbrains.annotations.NotNull; -public class GTBedrockOreInfoCategory extends ModularUIRecipeCategory { +public class GTBedrockOreInfoCategory extends + ModularUIRecipeCategory { public final static RecipeType RECIPE_TYPE = new RecipeType<>( GTCEu.id("bedrock_ore_diagram"), GTBedrockOreInfoWrapper.class); @Getter - private final IDrawable background; - @Getter private final IDrawable icon; public GTBedrockOreInfoCategory(IJeiHelpers helpers) { - IGuiHelper guiHelper = helpers.getGuiHelper(); - this.background = guiHelper.createBlankDrawable(GTOreVeinWidget.width, 120); + super(v -> new OreVeinRecipeWidget(v.bedrockOre), + v -> ClientProxy.CLIENT_BEDROCK_ORE_VEINS.inverse().get(v.bedrockOre)); this.icon = helpers.getGuiHelper() .createDrawableItemStack(Items.RAW_IRON.getDefaultInstance()); } @@ -57,4 +55,6 @@ public RecipeType getRecipeType() { public Component getTitle() { return Component.translatable("gtceu.jei.bedrock_ore_diagram"); } + + public record GTBedrockOreInfoWrapper(BedrockOreDefinition bedrockOre) {} } diff --git a/src/main/java/com/gregtechceu/gtceu/integration/jei/orevein/GTOreVeinInfoCategory.java b/src/main/java/com/gregtechceu/gtceu/integration/recipeviewer/jei/orevein/GTOreVeinInfoCategory.java similarity index 76% rename from src/main/java/com/gregtechceu/gtceu/integration/jei/orevein/GTOreVeinInfoCategory.java rename to src/main/java/com/gregtechceu/gtceu/integration/recipeviewer/jei/orevein/GTOreVeinInfoCategory.java index 0abe2f636c1..e36e2020ad3 100644 --- a/src/main/java/com/gregtechceu/gtceu/integration/jei/orevein/GTOreVeinInfoCategory.java +++ b/src/main/java/com/gregtechceu/gtceu/integration/recipeviewer/jei/orevein/GTOreVeinInfoCategory.java @@ -1,20 +1,19 @@ -package com.gregtechceu.gtceu.integration.jei.orevein; +package com.gregtechceu.gtceu.integration.recipeviewer.jei.orevein; import com.gregtechceu.gtceu.GTCEu; import com.gregtechceu.gtceu.api.data.chemical.ChemicalHelper; import com.gregtechceu.gtceu.api.data.tag.TagPrefix; +import com.gregtechceu.gtceu.api.data.worldgen.GTOreDefinition; import com.gregtechceu.gtceu.client.ClientProxy; import com.gregtechceu.gtceu.common.data.GTItems; import com.gregtechceu.gtceu.common.data.GTMaterials; -import com.gregtechceu.gtceu.integration.recipeviewer.widgets.GTOreVeinWidget; - -import com.lowdragmc.lowdraglib.jei.ModularUIRecipeCategory; +import com.gregtechceu.gtceu.integration.recipeviewer.widgets.OreVeinRecipeWidget; import net.minecraft.network.chat.Component; +import brachy.modularui.integration.jei.recipe.ModularUIRecipeCategory; import mezz.jei.api.gui.builder.IRecipeLayoutBuilder; import mezz.jei.api.gui.drawable.IDrawable; -import mezz.jei.api.helpers.IGuiHelper; import mezz.jei.api.helpers.IJeiHelpers; import mezz.jei.api.recipe.IFocusGroup; import mezz.jei.api.recipe.RecipeIngredientRole; @@ -23,16 +22,19 @@ import mezz.jei.api.registration.IRecipeRegistration; import org.jetbrains.annotations.NotNull; -public class GTOreVeinInfoCategory extends ModularUIRecipeCategory { +import javax.annotation.ParametersAreNonnullByDefault; + +@ParametersAreNonnullByDefault +public class GTOreVeinInfoCategory extends ModularUIRecipeCategory { public final static RecipeType RECIPE_TYPE = new RecipeType<>(GTCEu.id("ore_vein_diagram"), GTOreVeinInfoWrapper.class); - private final IDrawable background; private final IDrawable icon; public GTOreVeinInfoCategory(IJeiHelpers helpers) { - IGuiHelper guiHelper = helpers.getGuiHelper(); - this.background = guiHelper.createBlankDrawable(GTOreVeinWidget.width, 120); + super(v -> new OreVeinRecipeWidget(v.oreDefinition), + v -> ClientProxy.CLIENT_ORE_VEINS.inverse().get(v.oreDefinition)); + this.icon = helpers.getGuiHelper() .createDrawableItemStack(ChemicalHelper.get(TagPrefix.rawOre, GTMaterials.Iron)); } @@ -47,7 +49,7 @@ public static void registerRecipes(IRecipeRegistration registry) { public void setRecipe(IRecipeLayoutBuilder builder, GTOreVeinInfoWrapper wrapper, IFocusGroup focuses) { super.setRecipe(builder, wrapper, focuses); builder.addInvisibleIngredients(RecipeIngredientRole.OUTPUT) - .addItemStacks(GTOreVeinWidget.getContainedOresAndBlocks(wrapper.oreDefinition)); + .addItemStacks(OreVeinRecipeWidget.getContainedOresAndBlocks(wrapper.oreDefinition)); } public static void registerRecipeCatalysts(IRecipeCatalystRegistration registration) { @@ -68,15 +70,11 @@ public Component getTitle() { return Component.translatable("gtceu.jei.ore_vein_diagram"); } - @NotNull - @Override - public IDrawable getBackground() { - return background; - } - @NotNull @Override public IDrawable getIcon() { return icon; } + + public record GTOreVeinInfoWrapper(GTOreDefinition oreDefinition) {} } diff --git a/src/main/java/com/gregtechceu/gtceu/integration/jei/recipe/GTRecipeJEICategory.java b/src/main/java/com/gregtechceu/gtceu/integration/recipeviewer/jei/recipe/GTRecipeJEICategory.java similarity index 77% rename from src/main/java/com/gregtechceu/gtceu/integration/jei/recipe/GTRecipeJEICategory.java rename to src/main/java/com/gregtechceu/gtceu/integration/recipeviewer/jei/recipe/GTRecipeJEICategory.java index d07b5a88b6d..3f2f1aac7d9 100644 --- a/src/main/java/com/gregtechceu/gtceu/integration/jei/recipe/GTRecipeJEICategory.java +++ b/src/main/java/com/gregtechceu/gtceu/integration/recipeviewer/jei/recipe/GTRecipeJEICategory.java @@ -1,4 +1,4 @@ -package com.gregtechceu.gtceu.integration.jei.recipe; +package com.gregtechceu.gtceu.integration.recipeviewer.jei.recipe; import com.gregtechceu.gtceu.GTCEu; import com.gregtechceu.gtceu.api.machine.MachineDefinition; @@ -24,39 +24,15 @@ import java.util.function.Function; public abstract class GTRecipeJEICategory, W extends IWidget> - extends ModularUIRecipeCategory { + extends ModularUIRecipeCategory { public static final Function> TYPES = Util .memoize(c -> new RecipeType<>(c.registryKey, GTRecipe.class)); - /* - * private final GTRecipeCategory category; - * - * @Getter - * private final IDrawable background; - * - * @Getter - * private final IDrawable icon; - */ - - protected GTRecipeJEICategory(Function wrapperFunction, Function recipeIdGetter) { + protected GTRecipeJEICategory(Function wrapperFunction, Function recipeIdGetter) { super(wrapperFunction, recipeIdGetter); } - /* - * public GTRecipeJEICategory(IJeiHelpers helpers, - * - * @NotNull GTRecipeCategory category) { - * super(GTRecipeWrapper::new); - * this.category = category; - * var recipeType = category.getRecipeType(); - * IGuiHelper guiHelper = helpers.getGuiHelper(); - * var size = recipeType.getRecipeUI().getJEISize(); - * this.background = guiHelper.createBlankDrawable(size.width, size.height); - * this.icon = IGui2IDrawable.toDrawable(category.getIcon(), 16, 16); - * } - */ - public static void registerRecipes(IRecipeRegistration registration) { List subCategories = new ArrayList<>(); // run main categories first diff --git a/src/main/java/com/gregtechceu/gtceu/integration/jei/recipe/GTRecipeWrapper.java b/src/main/java/com/gregtechceu/gtceu/integration/recipeviewer/jei/recipe/GTRecipeWrapper.java similarity index 65% rename from src/main/java/com/gregtechceu/gtceu/integration/jei/recipe/GTRecipeWrapper.java rename to src/main/java/com/gregtechceu/gtceu/integration/recipeviewer/jei/recipe/GTRecipeWrapper.java index cce39320743..42ecefc105e 100644 --- a/src/main/java/com/gregtechceu/gtceu/integration/jei/recipe/GTRecipeWrapper.java +++ b/src/main/java/com/gregtechceu/gtceu/integration/recipeviewer/jei/recipe/GTRecipeWrapper.java @@ -1,9 +1,9 @@ -package com.gregtechceu.gtceu.integration.jei.recipe; +package com.gregtechceu.gtceu.integration.recipeviewer.jei.recipe; import com.gregtechceu.gtceu.api.recipe.GTRecipe; -import com.gregtechceu.gtceu.integration.recipeviewer.widgets.GTRecipeWidget; import com.lowdragmc.lowdraglib.gui.widget.Widget; +import com.lowdragmc.lowdraglib.gui.widget.WidgetGroup; import com.lowdragmc.lowdraglib.jei.ModularWrapper; public class GTRecipeWrapper extends ModularWrapper { @@ -11,7 +11,7 @@ public class GTRecipeWrapper extends ModularWrapper { public final GTRecipe recipe; public GTRecipeWrapper(GTRecipe recipe) { - super(new GTRecipeWidget(recipe)); + super(new WidgetGroup()); this.recipe = recipe; } } diff --git a/src/main/java/com/gregtechceu/gtceu/integration/jei/subtype/PotionFluidSubtypeInterpreter.java b/src/main/java/com/gregtechceu/gtceu/integration/recipeviewer/jei/subtype/PotionFluidSubtypeInterpreter.java similarity index 95% rename from src/main/java/com/gregtechceu/gtceu/integration/jei/subtype/PotionFluidSubtypeInterpreter.java rename to src/main/java/com/gregtechceu/gtceu/integration/recipeviewer/jei/subtype/PotionFluidSubtypeInterpreter.java index 0313ac87aab..4bba459f172 100644 --- a/src/main/java/com/gregtechceu/gtceu/integration/jei/subtype/PotionFluidSubtypeInterpreter.java +++ b/src/main/java/com/gregtechceu/gtceu/integration/recipeviewer/jei/subtype/PotionFluidSubtypeInterpreter.java @@ -1,4 +1,4 @@ -package com.gregtechceu.gtceu.integration.jei.subtype; +package com.gregtechceu.gtceu.integration.recipeviewer.jei.subtype; import net.minecraft.nbt.CompoundTag; import net.minecraft.world.effect.MobEffectInstance; diff --git a/src/main/java/com/gregtechceu/gtceu/integration/rei/oreprocessing/GTOreProcessingDisplayCategory.java b/src/main/java/com/gregtechceu/gtceu/integration/recipeviewer/rei/GTOreProcessingReiCategory.java similarity index 63% rename from src/main/java/com/gregtechceu/gtceu/integration/rei/oreprocessing/GTOreProcessingDisplayCategory.java rename to src/main/java/com/gregtechceu/gtceu/integration/recipeviewer/rei/GTOreProcessingReiCategory.java index 0d86bae41c9..7f24340956d 100644 --- a/src/main/java/com/gregtechceu/gtceu/integration/rei/oreprocessing/GTOreProcessingDisplayCategory.java +++ b/src/main/java/com/gregtechceu/gtceu/integration/recipeviewer/rei/GTOreProcessingReiCategory.java @@ -1,19 +1,17 @@ -package com.gregtechceu.gtceu.integration.rei.oreprocessing; +package com.gregtechceu.gtceu.integration.recipeviewer.rei; import com.gregtechceu.gtceu.GTCEu; import com.gregtechceu.gtceu.api.GTCEuAPI; import com.gregtechceu.gtceu.api.GTValues; import com.gregtechceu.gtceu.api.data.chemical.material.Material; import com.gregtechceu.gtceu.api.data.chemical.material.info.MaterialFlags; - -import com.lowdragmc.lowdraglib.gui.texture.ItemStackTexture; -import com.lowdragmc.lowdraglib.rei.IGui2Renderer; -import com.lowdragmc.lowdraglib.rei.ModularUIDisplayCategory; -import com.lowdragmc.lowdraglib.utils.Size; +import com.gregtechceu.gtceu.integration.recipeviewer.widgets.OreProcessingRecipeWidget; import net.minecraft.network.chat.Component; import net.minecraft.world.item.Items; +import brachy.modularui.integration.rei.recipe.ModularUIREIDisplay; +import brachy.modularui.integration.rei.recipe.ModularUIREIDisplayCategory; import lombok.Getter; import me.shedaniel.rei.api.client.gui.Renderer; import me.shedaniel.rei.api.client.registry.category.CategoryRegistry; @@ -25,19 +23,16 @@ import static com.gregtechceu.gtceu.api.data.chemical.material.properties.PropertyKey.ORE; import static com.gregtechceu.gtceu.common.data.GTMachines.*; -public class GTOreProcessingDisplayCategory extends ModularUIDisplayCategory { +public class GTOreProcessingReiCategory extends + ModularUIREIDisplayCategory { public static final CategoryIdentifier CATEGORY = CategoryIdentifier .of(GTCEu.id("ore_processing_diagram")); @Getter private final Renderer icon; - @Getter - private final Size size; - - public GTOreProcessingDisplayCategory() { - this.icon = IGui2Renderer.toDrawable(new ItemStackTexture(Items.RAW_IRON)); - this.size = new Size(176, 166); + public GTOreProcessingReiCategory() { + this.icon = EntryStacks.of(Items.RAW_IRON); } @Override @@ -45,16 +40,6 @@ public CategoryIdentifier getCategoryIdentifie return CATEGORY; } - @Override - public int getDisplayHeight() { - return getSize().height; - } - - @Override - public int getDisplayWidth(GTOreProcessingDisplay display) { - return getSize().width; - } - @NotNull @Override public Component getTitle() { @@ -70,19 +55,26 @@ public static void registerDisplays(DisplayRegistry registry) { } public static void registerWorkstations(CategoryRegistry registry) { - registry.addWorkstations(GTOreProcessingDisplayCategory.CATEGORY, + registry.addWorkstations(GTOreProcessingReiCategory.CATEGORY, EntryStacks.of(MACERATOR[GTValues.LV].asStack())); - registry.addWorkstations(GTOreProcessingDisplayCategory.CATEGORY, + registry.addWorkstations(GTOreProcessingReiCategory.CATEGORY, EntryStacks.of(ORE_WASHER[GTValues.LV].asStack())); - registry.addWorkstations(GTOreProcessingDisplayCategory.CATEGORY, + registry.addWorkstations(GTOreProcessingReiCategory.CATEGORY, EntryStacks.of(THERMAL_CENTRIFUGE[GTValues.LV].asStack())); - registry.addWorkstations(GTOreProcessingDisplayCategory.CATEGORY, + registry.addWorkstations(GTOreProcessingReiCategory.CATEGORY, EntryStacks.of(CENTRIFUGE[GTValues.LV].asStack())); - registry.addWorkstations(GTOreProcessingDisplayCategory.CATEGORY, + registry.addWorkstations(GTOreProcessingReiCategory.CATEGORY, EntryStacks.of(CHEMICAL_BATH[GTValues.LV].asStack())); - registry.addWorkstations(GTOreProcessingDisplayCategory.CATEGORY, + registry.addWorkstations(GTOreProcessingReiCategory.CATEGORY, EntryStacks.of(ELECTROMAGNETIC_SEPARATOR[GTValues.LV].asStack())); - registry.addWorkstations(GTOreProcessingDisplayCategory.CATEGORY, + registry.addWorkstations(GTOreProcessingReiCategory.CATEGORY, EntryStacks.of(SIFTER[GTValues.LV].asStack())); } + + public static class GTOreProcessingDisplay extends ModularUIREIDisplay { + + public GTOreProcessingDisplay(Material material) { + super(material.getResourceLocation(), () -> new OreProcessingRecipeWidget(material), CATEGORY); + } + } } diff --git a/src/main/java/com/gregtechceu/gtceu/integration/rei/GTREIPlugin.java b/src/main/java/com/gregtechceu/gtceu/integration/recipeviewer/rei/GTREIPlugin.java similarity index 86% rename from src/main/java/com/gregtechceu/gtceu/integration/rei/GTREIPlugin.java rename to src/main/java/com/gregtechceu/gtceu/integration/recipeviewer/rei/GTREIPlugin.java index 6d3db3661eb..3e9ea55f1f3 100644 --- a/src/main/java/com/gregtechceu/gtceu/integration/rei/GTREIPlugin.java +++ b/src/main/java/com/gregtechceu/gtceu/integration/recipeviewer/rei/GTREIPlugin.java @@ -1,4 +1,4 @@ -package com.gregtechceu.gtceu.integration.rei; +package com.gregtechceu.gtceu.integration.recipeviewer.rei; import com.gregtechceu.gtceu.GTCEu; import com.gregtechceu.gtceu.api.data.tag.TagPrefix; @@ -10,13 +10,10 @@ import com.gregtechceu.gtceu.common.fluid.potion.PotionFluid; import com.gregtechceu.gtceu.common.fluid.potion.PotionFluidHelper; import com.gregtechceu.gtceu.config.ConfigHolder; -import com.gregtechceu.gtceu.integration.rei.circuit.GTProgrammedCircuitCategory; -import com.gregtechceu.gtceu.integration.rei.multipage.MultiblockInfoDisplayCategory; -import com.gregtechceu.gtceu.integration.rei.oreprocessing.GTOreProcessingDisplayCategory; -import com.gregtechceu.gtceu.integration.rei.orevein.GTBedrockFluidDisplayCategory; -import com.gregtechceu.gtceu.integration.rei.orevein.GTBedrockOreDisplayCategory; -import com.gregtechceu.gtceu.integration.rei.orevein.GTOreVeinDisplayCategory; -import com.gregtechceu.gtceu.integration.rei.recipe.GTRecipeREICategory; +import com.gregtechceu.gtceu.integration.recipeviewer.rei.orevein.GTBedrockFluidDisplayCategory; +import com.gregtechceu.gtceu.integration.recipeviewer.rei.orevein.GTBedrockOreDisplayCategory; +import com.gregtechceu.gtceu.integration.recipeviewer.rei.orevein.GTOreVeinDisplayCategory; +import com.gregtechceu.gtceu.integration.recipeviewer.rei.recipe.GTRecipeREICategory; import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.network.chat.Component; @@ -46,9 +43,9 @@ public class GTREIPlugin implements REIClientPlugin { @Override public void registerCategories(CategoryRegistry registry) { // Categories - registry.add(new MultiblockInfoDisplayCategory()); + registry.add(new MultiblockInfoReiCategory()); if (!ConfigHolder.INSTANCE.compat.hideOreProcessingDiagrams) - registry.add(new GTOreProcessingDisplayCategory()); + registry.add(new GTOreProcessingReiCategory()); registry.add(new GTOreVeinDisplayCategory()); registry.add(new GTBedrockFluidDisplayCategory()); if (ConfigHolder.INSTANCE.machines.doBedrockOres) @@ -58,12 +55,12 @@ public void registerCategories(CategoryRegistry registry) { registry.add(new GTRecipeREICategory(category)); } } - registry.add(new GTProgrammedCircuitCategory()); + registry.add(new ProgrammedCircuitReiCategory()); // Workstations GTRecipeREICategory.registerWorkStations(registry); if (!ConfigHolder.INSTANCE.compat.hideOreProcessingDiagrams) - GTOreProcessingDisplayCategory.registerWorkstations(registry); + GTOreProcessingReiCategory.registerWorkstations(registry); GTOreVeinDisplayCategory.registerWorkstations(registry); GTBedrockFluidDisplayCategory.registerWorkstations(registry); if (ConfigHolder.INSTANCE.machines.doBedrockOres) @@ -75,14 +72,14 @@ public void registerCategories(CategoryRegistry registry) { @Override public void registerDisplays(DisplayRegistry registry) { GTRecipeREICategory.registerDisplays(registry); - MultiblockInfoDisplayCategory.registerDisplays(registry); + MultiblockInfoReiCategory.registerDisplays(registry); if (!ConfigHolder.INSTANCE.compat.hideOreProcessingDiagrams) - GTOreProcessingDisplayCategory.registerDisplays(registry); + GTOreProcessingReiCategory.registerDisplays(registry); GTOreVeinDisplayCategory.registerDisplays(registry); GTBedrockFluidDisplayCategory.registerDisplays(registry); if (ConfigHolder.INSTANCE.machines.doBedrockOres) GTBedrockOreDisplayCategory.registerDisplays(registry); - registry.add(new GTProgrammedCircuitCategory.GTProgrammedCircuitDisplay()); + registry.add(new ProgrammedCircuitReiCategory.GTProgrammedCircuitDisplay()); } @Override diff --git a/src/main/java/com/gregtechceu/gtceu/integration/rei/multipage/MultiblockInfoDisplayCategory.java b/src/main/java/com/gregtechceu/gtceu/integration/recipeviewer/rei/MultiblockInfoReiCategory.java similarity index 64% rename from src/main/java/com/gregtechceu/gtceu/integration/rei/multipage/MultiblockInfoDisplayCategory.java rename to src/main/java/com/gregtechceu/gtceu/integration/recipeviewer/rei/MultiblockInfoReiCategory.java index e064dc47c7d..ce9bcccaf70 100644 --- a/src/main/java/com/gregtechceu/gtceu/integration/rei/multipage/MultiblockInfoDisplayCategory.java +++ b/src/main/java/com/gregtechceu/gtceu/integration/recipeviewer/rei/MultiblockInfoReiCategory.java @@ -1,27 +1,34 @@ -package com.gregtechceu.gtceu.integration.rei.multipage; +package com.gregtechceu.gtceu.integration.recipeviewer.rei; import com.gregtechceu.gtceu.GTCEu; +import com.gregtechceu.gtceu.api.gui.widget.PatternPreviewWidget; import com.gregtechceu.gtceu.api.machine.MultiblockMachineDefinition; import com.gregtechceu.gtceu.api.registry.GTRegistries; import com.gregtechceu.gtceu.common.data.machines.GTMultiMachines; import com.lowdragmc.lowdraglib.gui.texture.ItemStackTexture; +import com.lowdragmc.lowdraglib.gui.widget.WidgetGroup; import com.lowdragmc.lowdraglib.rei.IGui2Renderer; +import com.lowdragmc.lowdraglib.rei.ModularDisplay; import com.lowdragmc.lowdraglib.rei.ModularUIDisplayCategory; import net.minecraft.network.chat.Component; +import net.minecraft.resources.ResourceLocation; import me.shedaniel.rei.api.client.gui.Renderer; import me.shedaniel.rei.api.client.registry.display.DisplayRegistry; import me.shedaniel.rei.api.common.category.CategoryIdentifier; -public class MultiblockInfoDisplayCategory extends ModularUIDisplayCategory { +import java.util.Optional; + +public class MultiblockInfoReiCategory extends + ModularUIDisplayCategory { public static final CategoryIdentifier CATEGORY = CategoryIdentifier .of(GTCEu.id("multiblock_info")); private final Renderer icon; - public MultiblockInfoDisplayCategory() { + public MultiblockInfoReiCategory() { this.icon = IGui2Renderer.toDrawable(new ItemStackTexture(GTMultiMachines.ELECTRIC_BLAST_FURNACE.getItem())); } @@ -58,4 +65,19 @@ public Component getTitle() { public Renderer getIcon() { return icon; } + + public static class MultiblockInfoDisplay extends ModularDisplay { + + public final MultiblockMachineDefinition definition; + + public MultiblockInfoDisplay(MultiblockMachineDefinition definition) { + super(() -> PatternPreviewWidget.getPatternWidget(definition), CATEGORY); + this.definition = definition; + } + + @Override + public Optional getDisplayLocation() { + return Optional.of(definition.getId()); + } + } } diff --git a/src/main/java/com/gregtechceu/gtceu/integration/recipeviewer/rei/ProgrammedCircuitReiCategory.java b/src/main/java/com/gregtechceu/gtceu/integration/recipeviewer/rei/ProgrammedCircuitReiCategory.java new file mode 100644 index 00000000000..9cbedd610d0 --- /dev/null +++ b/src/main/java/com/gregtechceu/gtceu/integration/recipeviewer/rei/ProgrammedCircuitReiCategory.java @@ -0,0 +1,46 @@ +package com.gregtechceu.gtceu.integration.recipeviewer.rei; + +import com.gregtechceu.gtceu.GTCEu; +import com.gregtechceu.gtceu.common.data.GTItems; +import com.gregtechceu.gtceu.integration.recipeviewer.widgets.ProgrammedCircuitRecipeWidget; + +import net.minecraft.network.chat.Component; + +import brachy.modularui.integration.rei.recipe.ModularUIREIDisplay; +import brachy.modularui.integration.rei.recipe.ModularUIREIDisplayCategory; +import lombok.Getter; +import me.shedaniel.rei.api.client.gui.Renderer; +import me.shedaniel.rei.api.common.category.CategoryIdentifier; +import me.shedaniel.rei.api.common.util.EntryStacks; + +public class ProgrammedCircuitReiCategory extends + ModularUIREIDisplayCategory { + + public static CategoryIdentifier CATEGORY = CategoryIdentifier + .of(GTCEu.id("programmed_circuit")); + + @Getter + private final Renderer icon; + + public ProgrammedCircuitReiCategory() { + this.icon = EntryStacks.of(GTItems.PROGRAMMED_CIRCUIT.asItem()); + } + + @Override + public CategoryIdentifier getCategoryIdentifier() { + return CATEGORY; + } + + @Override + public Component getTitle() { + return Component.translatable("gtceu.jei.programmed_circuit"); + } + + public static class GTProgrammedCircuitDisplay extends ModularUIREIDisplay { + + public GTProgrammedCircuitDisplay() { + super(GTCEu.id("programmed_circuit"), ProgrammedCircuitRecipeWidget::new, + ProgrammedCircuitReiCategory.CATEGORY); + } + } +} diff --git a/src/main/java/com/gregtechceu/gtceu/integration/rei/orevein/GTBedrockFluidDisplayCategory.java b/src/main/java/com/gregtechceu/gtceu/integration/recipeviewer/rei/orevein/GTBedrockFluidDisplayCategory.java similarity index 51% rename from src/main/java/com/gregtechceu/gtceu/integration/rei/orevein/GTBedrockFluidDisplayCategory.java rename to src/main/java/com/gregtechceu/gtceu/integration/recipeviewer/rei/orevein/GTBedrockFluidDisplayCategory.java index 1d32a4b855a..caccb996ee5 100644 --- a/src/main/java/com/gregtechceu/gtceu/integration/rei/orevein/GTBedrockFluidDisplayCategory.java +++ b/src/main/java/com/gregtechceu/gtceu/integration/recipeviewer/rei/orevein/GTBedrockFluidDisplayCategory.java @@ -1,40 +1,41 @@ -package com.gregtechceu.gtceu.integration.rei.orevein; +package com.gregtechceu.gtceu.integration.recipeviewer.rei.orevein; import com.gregtechceu.gtceu.GTCEu; import com.gregtechceu.gtceu.api.data.worldgen.bedrockfluid.BedrockFluidDefinition; import com.gregtechceu.gtceu.client.ClientProxy; import com.gregtechceu.gtceu.common.data.GTItems; import com.gregtechceu.gtceu.common.data.GTMaterials; -import com.gregtechceu.gtceu.integration.recipeviewer.widgets.GTOreVeinWidget; - -import com.lowdragmc.lowdraglib.gui.texture.ItemStackTexture; -import com.lowdragmc.lowdraglib.rei.IGui2Renderer; -import com.lowdragmc.lowdraglib.rei.ModularUIDisplayCategory; -import com.lowdragmc.lowdraglib.utils.Size; +import com.gregtechceu.gtceu.integration.recipeviewer.widgets.OreVeinRecipeWidget; import net.minecraft.network.chat.Component; +import net.minecraft.resources.ResourceLocation; +import brachy.modularui.integration.rei.recipe.ModularUIREIDisplay; +import brachy.modularui.integration.rei.recipe.ModularUIREIDisplayCategory; import lombok.Getter; import me.shedaniel.rei.api.client.gui.Renderer; import me.shedaniel.rei.api.client.registry.category.CategoryRegistry; import me.shedaniel.rei.api.client.registry.display.DisplayRegistry; import me.shedaniel.rei.api.common.category.CategoryIdentifier; +import me.shedaniel.rei.api.common.entry.EntryIngredient; +import me.shedaniel.rei.api.common.util.EntryIngredients; import me.shedaniel.rei.api.common.util.EntryStacks; import org.jetbrains.annotations.NotNull; +import java.util.ArrayList; +import java.util.List; + @Getter -public class GTBedrockFluidDisplayCategory extends ModularUIDisplayCategory { +public class GTBedrockFluidDisplayCategory extends + ModularUIREIDisplayCategory { public static final CategoryIdentifier CATEGORY = CategoryIdentifier .of(GTCEu.id("bedrock_fluid_diagram")); private final Renderer icon; - private final Size size; - public GTBedrockFluidDisplayCategory() { - this.icon = IGui2Renderer.toDrawable(new ItemStackTexture(GTMaterials.Oil.getFluid().getBucket().asItem())); - this.size = new Size(10 + GTOreVeinWidget.width, 140); + this.icon = EntryStacks.of(GTMaterials.Oil.getFluid().getBucket().asItem()); } @Override @@ -42,16 +43,6 @@ public CategoryIdentifier getCategoryIdentifier return CATEGORY; } - @Override - public int getDisplayHeight() { - return getSize().height; - } - - @Override - public int getDisplayWidth(GTBedrockFluidDisplay display) { - return getSize().width; - } - @NotNull @Override public Component getTitle() { @@ -59,8 +50,8 @@ public Component getTitle() { } public static void registerDisplays(DisplayRegistry registry) { - for (BedrockFluidDefinition fluid : ClientProxy.CLIENT_FLUID_VEINS.values()) { - registry.add(new GTBedrockFluidDisplay(fluid)); + for (var fluid : ClientProxy.CLIENT_FLUID_VEINS.entrySet()) { + registry.add(new GTBedrockFluidDisplay(fluid.getKey(), fluid.getValue())); } } @@ -70,4 +61,21 @@ public static void registerWorkstations(CategoryRegistry registry) { registry.addWorkstations(GTBedrockFluidDisplayCategory.CATEGORY, EntryStacks.of(GTItems.PROSPECTOR_LuV.asStack())); } + + public static class GTBedrockFluidDisplay extends ModularUIREIDisplay { + + private final BedrockFluidDefinition fluid; + + public GTBedrockFluidDisplay(ResourceLocation id, BedrockFluidDefinition fluid) { + super(id, () -> new OreVeinRecipeWidget(fluid), GTBedrockFluidDisplayCategory.CATEGORY); + this.fluid = fluid; + } + + @Override + public @NotNull List getOutputEntries() { + List outputs = new ArrayList<>(); + outputs.add(EntryIngredients.of(fluid.getStoredFluid().get())); + return outputs; + } + } } diff --git a/src/main/java/com/gregtechceu/gtceu/integration/recipeviewer/rei/orevein/GTBedrockOreDisplayCategory.java b/src/main/java/com/gregtechceu/gtceu/integration/recipeviewer/rei/orevein/GTBedrockOreDisplayCategory.java new file mode 100644 index 00000000000..a82c7cf1da7 --- /dev/null +++ b/src/main/java/com/gregtechceu/gtceu/integration/recipeviewer/rei/orevein/GTBedrockOreDisplayCategory.java @@ -0,0 +1,86 @@ +package com.gregtechceu.gtceu.integration.recipeviewer.rei.orevein; + +import com.gregtechceu.gtceu.GTCEu; +import com.gregtechceu.gtceu.api.data.chemical.ChemicalHelper; +import com.gregtechceu.gtceu.api.data.chemical.material.Material; +import com.gregtechceu.gtceu.api.data.tag.TagPrefix; +import com.gregtechceu.gtceu.api.data.worldgen.bedrockore.BedrockOreDefinition; +import com.gregtechceu.gtceu.client.ClientProxy; +import com.gregtechceu.gtceu.common.data.GTItems; +import com.gregtechceu.gtceu.common.data.GTMaterials; +import com.gregtechceu.gtceu.integration.recipeviewer.widgets.OreVeinRecipeWidget; + +import net.minecraft.network.chat.Component; +import net.minecraft.resources.ResourceLocation; + +import brachy.modularui.integration.rei.recipe.ModularUIREIDisplay; +import brachy.modularui.integration.rei.recipe.ModularUIREIDisplayCategory; +import lombok.Getter; +import me.shedaniel.rei.api.client.gui.Renderer; +import me.shedaniel.rei.api.client.registry.category.CategoryRegistry; +import me.shedaniel.rei.api.client.registry.display.DisplayRegistry; +import me.shedaniel.rei.api.common.category.CategoryIdentifier; +import me.shedaniel.rei.api.common.entry.EntryIngredient; +import me.shedaniel.rei.api.common.util.EntryIngredients; +import me.shedaniel.rei.api.common.util.EntryStacks; +import org.jetbrains.annotations.NotNull; + +import java.util.ArrayList; +import java.util.List; + +@Getter +public class GTBedrockOreDisplayCategory extends + ModularUIREIDisplayCategory { + + public static final CategoryIdentifier CATEGORY = CategoryIdentifier + .of(GTCEu.id("bedrock_ore_diagram")); + + private final Renderer icon; + + public GTBedrockOreDisplayCategory() { + this.icon = EntryStacks.of(GTMaterials.Oil.getFluid().getBucket().asItem()); + } + + @Override + public CategoryIdentifier getCategoryIdentifier() { + return CATEGORY; + } + + @NotNull + @Override + public Component getTitle() { + return Component.translatable("gtceu.jei.bedrock_ore_diagram"); + } + + public static void registerDisplays(DisplayRegistry registry) { + for (var fluid : ClientProxy.CLIENT_BEDROCK_ORE_VEINS.entrySet()) { + registry.add(new GTBedrockOreDisplay(fluid.getKey(), fluid.getValue())); + } + } + + public static void registerWorkstations(CategoryRegistry registry) { + registry.addWorkstations(GTBedrockOreDisplayCategory.CATEGORY, + EntryStacks.of(GTItems.PROSPECTOR_HV.asStack())); + registry.addWorkstations(GTBedrockOreDisplayCategory.CATEGORY, + EntryStacks.of(GTItems.PROSPECTOR_LuV.asStack())); + } + + public static class GTBedrockOreDisplay extends ModularUIREIDisplay { + + private final BedrockOreDefinition bedrockOre; + + public GTBedrockOreDisplay(ResourceLocation id, BedrockOreDefinition bedrockOre) { + super(id, () -> new OreVeinRecipeWidget(bedrockOre), CATEGORY); + this.bedrockOre = bedrockOre; + } + + @Override + public @NotNull List getOutputEntries() { + List outputs = new ArrayList<>(); + for (Material material : bedrockOre.getAllMaterials()) { + outputs.add(EntryIngredients.of(ChemicalHelper.get(TagPrefix.rawOre, material))); + } + return outputs; + } + } +} diff --git a/src/main/java/com/gregtechceu/gtceu/integration/rei/orevein/GTOreVeinDisplayCategory.java b/src/main/java/com/gregtechceu/gtceu/integration/recipeviewer/rei/orevein/GTOreVeinDisplayCategory.java similarity index 50% rename from src/main/java/com/gregtechceu/gtceu/integration/rei/orevein/GTOreVeinDisplayCategory.java rename to src/main/java/com/gregtechceu/gtceu/integration/recipeviewer/rei/orevein/GTOreVeinDisplayCategory.java index 0935a15e5d6..062159a6599 100644 --- a/src/main/java/com/gregtechceu/gtceu/integration/rei/orevein/GTOreVeinDisplayCategory.java +++ b/src/main/java/com/gregtechceu/gtceu/integration/recipeviewer/rei/orevein/GTOreVeinDisplayCategory.java @@ -1,40 +1,41 @@ -package com.gregtechceu.gtceu.integration.rei.orevein; +package com.gregtechceu.gtceu.integration.recipeviewer.rei.orevein; import com.gregtechceu.gtceu.GTCEu; import com.gregtechceu.gtceu.api.data.worldgen.GTOreDefinition; import com.gregtechceu.gtceu.client.ClientProxy; import com.gregtechceu.gtceu.common.data.GTItems; -import com.gregtechceu.gtceu.integration.recipeviewer.widgets.GTOreVeinWidget; - -import com.lowdragmc.lowdraglib.gui.texture.ItemStackTexture; -import com.lowdragmc.lowdraglib.rei.IGui2Renderer; -import com.lowdragmc.lowdraglib.rei.ModularUIDisplayCategory; -import com.lowdragmc.lowdraglib.utils.Size; +import com.gregtechceu.gtceu.integration.recipeviewer.widgets.OreVeinRecipeWidget; import net.minecraft.network.chat.Component; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; +import brachy.modularui.integration.rei.recipe.ModularUIREIDisplay; +import brachy.modularui.integration.rei.recipe.ModularUIREIDisplayCategory; import lombok.Getter; import me.shedaniel.rei.api.client.gui.Renderer; import me.shedaniel.rei.api.client.registry.category.CategoryRegistry; import me.shedaniel.rei.api.client.registry.display.DisplayRegistry; import me.shedaniel.rei.api.common.category.CategoryIdentifier; +import me.shedaniel.rei.api.common.entry.EntryIngredient; +import me.shedaniel.rei.api.common.util.EntryIngredients; import me.shedaniel.rei.api.common.util.EntryStacks; import org.jetbrains.annotations.NotNull; +import java.util.ArrayList; +import java.util.List; + @Getter -public class GTOreVeinDisplayCategory extends ModularUIDisplayCategory { +public class GTOreVeinDisplayCategory extends ModularUIREIDisplayCategory { public static final CategoryIdentifier CATEGORY = CategoryIdentifier .of(GTCEu.id("ore_vein_diagram")); private final Renderer icon; - private final Size size; - public GTOreVeinDisplayCategory() { - this.icon = IGui2Renderer.toDrawable(new ItemStackTexture(Items.IRON_INGOT.asItem())); - this.size = new Size(10 + GTOreVeinWidget.width, 140); + this.icon = EntryStacks.of(Items.IRON_INGOT); } @Override @@ -42,16 +43,6 @@ public CategoryIdentifier getCategoryIdentifier() { return CATEGORY; } - @Override - public int getDisplayHeight() { - return getSize().height; - } - - @Override - public int getDisplayWidth(GTOreVeinDisplay display) { - return getSize().width; - } - @NotNull @Override public Component getTitle() { @@ -59,8 +50,8 @@ public Component getTitle() { } public static void registerDisplays(DisplayRegistry registry) { - for (GTOreDefinition oreDefinition : ClientProxy.CLIENT_ORE_VEINS.values()) { - registry.add(new GTOreVeinDisplay(oreDefinition)); + for (var oreDefinition : ClientProxy.CLIENT_ORE_VEINS.entrySet()) { + registry.add(new GTOreVeinDisplay(oreDefinition.getKey(), oreDefinition.getValue())); } } @@ -69,4 +60,23 @@ public static void registerWorkstations(CategoryRegistry registry) { registry.addWorkstations(GTOreVeinDisplayCategory.CATEGORY, EntryStacks.of(GTItems.PROSPECTOR_HV.asStack())); registry.addWorkstations(GTOreVeinDisplayCategory.CATEGORY, EntryStacks.of(GTItems.PROSPECTOR_LuV.asStack())); } + + public static class GTOreVeinDisplay extends ModularUIREIDisplay { + + private final GTOreDefinition oreDefinition; + + public GTOreVeinDisplay(ResourceLocation id, GTOreDefinition oreDefinition) { + super(id, () -> new OreVeinRecipeWidget(oreDefinition), CATEGORY); + this.oreDefinition = oreDefinition; + } + + @Override + public @NotNull List getOutputEntries() { + List ingredients = new ArrayList<>(); + for (ItemStack output : OreVeinRecipeWidget.getContainedOresAndBlocks(oreDefinition)) { + ingredients.add(EntryIngredients.of(output)); + } + return ingredients; + } + } } diff --git a/src/main/java/com/gregtechceu/gtceu/integration/rei/recipe/GTRecipeDisplay.java b/src/main/java/com/gregtechceu/gtceu/integration/recipeviewer/rei/recipe/GTRecipeDisplay.java similarity index 85% rename from src/main/java/com/gregtechceu/gtceu/integration/rei/recipe/GTRecipeDisplay.java rename to src/main/java/com/gregtechceu/gtceu/integration/recipeviewer/rei/recipe/GTRecipeDisplay.java index 9e84d189fea..986dff5017c 100644 --- a/src/main/java/com/gregtechceu/gtceu/integration/rei/recipe/GTRecipeDisplay.java +++ b/src/main/java/com/gregtechceu/gtceu/integration/recipeviewer/rei/recipe/GTRecipeDisplay.java @@ -1,7 +1,6 @@ -package com.gregtechceu.gtceu.integration.rei.recipe; +package com.gregtechceu.gtceu.integration.recipeviewer.rei.recipe; import com.gregtechceu.gtceu.api.recipe.GTRecipe; -import com.gregtechceu.gtceu.integration.recipeviewer.widgets.GTRecipeWidget; import com.lowdragmc.lowdraglib.gui.widget.WidgetGroup; import com.lowdragmc.lowdraglib.rei.ModularDisplay; @@ -21,7 +20,7 @@ public class GTRecipeDisplay extends ModularDisplay { protected List allInputs; public GTRecipeDisplay(GTRecipe recipe, CategoryIdentifier category) { - super(() -> new GTRecipeWidget(recipe), category); + super(WidgetGroup::new, category); this.recipe = recipe; allInputs = new ArrayList<>(inputs); allInputs.addAll(catalysts); diff --git a/src/main/java/com/gregtechceu/gtceu/integration/rei/recipe/GTRecipeREICategory.java b/src/main/java/com/gregtechceu/gtceu/integration/recipeviewer/rei/recipe/GTRecipeREICategory.java similarity index 95% rename from src/main/java/com/gregtechceu/gtceu/integration/rei/recipe/GTRecipeREICategory.java rename to src/main/java/com/gregtechceu/gtceu/integration/recipeviewer/rei/recipe/GTRecipeREICategory.java index b79a00e7bc0..c31f254ded9 100644 --- a/src/main/java/com/gregtechceu/gtceu/integration/rei/recipe/GTRecipeREICategory.java +++ b/src/main/java/com/gregtechceu/gtceu/integration/recipeviewer/rei/recipe/GTRecipeREICategory.java @@ -1,4 +1,4 @@ -package com.gregtechceu.gtceu.integration.rei.recipe; +package com.gregtechceu.gtceu.integration.recipeviewer.rei.recipe; import com.gregtechceu.gtceu.GTCEu; import com.gregtechceu.gtceu.api.machine.MachineDefinition; @@ -41,8 +41,7 @@ public class GTRecipeREICategory extends ModularUIDisplayCategory { - - private final GTRecipe recipe; - - public GTMuiRecipeWidget(GTRecipe recipe) { - this.recipe = recipe; - } - - private void initializeWidgets() {} -} diff --git a/src/main/java/com/gregtechceu/gtceu/integration/recipeviewer/widgets/GTOreByProduct.java b/src/main/java/com/gregtechceu/gtceu/integration/recipeviewer/widgets/GTOreByProduct.java index 386f21d108b..1725b2353d4 100644 --- a/src/main/java/com/gregtechceu/gtceu/integration/recipeviewer/widgets/GTOreByProduct.java +++ b/src/main/java/com/gregtechceu/gtceu/integration/recipeviewer/widgets/GTOreByProduct.java @@ -11,20 +11,21 @@ import com.gregtechceu.gtceu.api.recipe.content.Content; import com.gregtechceu.gtceu.common.data.GTMachines; import com.gregtechceu.gtceu.common.data.GTMaterials; -import com.gregtechceu.gtceu.integration.recipeviewer.entry.fluid.FluidEntryList; -import com.gregtechceu.gtceu.integration.recipeviewer.entry.fluid.FluidStackList; -import com.gregtechceu.gtceu.integration.recipeviewer.entry.fluid.FluidTagList; -import com.gregtechceu.gtceu.integration.recipeviewer.entry.item.ItemEntryList; -import com.gregtechceu.gtceu.integration.recipeviewer.entry.item.ItemStackList; -import com.gregtechceu.gtceu.integration.recipeviewer.entry.item.ItemTagList; import com.gregtechceu.gtceu.utils.FormattingUtil; +import lombok.Getter; import net.minecraft.core.NonNullList; -import net.minecraft.network.chat.Component; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; import net.minecraft.world.level.block.Blocks; +import brachy.modularui.integration.recipeviewer.entry.fluid.FluidEntryList; +import brachy.modularui.integration.recipeviewer.entry.fluid.FluidStackList; +import brachy.modularui.integration.recipeviewer.entry.fluid.FluidTagList; +import brachy.modularui.integration.recipeviewer.entry.item.ItemEntryList; +import brachy.modularui.integration.recipeviewer.entry.item.ItemStackList; +import brachy.modularui.integration.recipeviewer.entry.item.ItemTagList; +import brachy.modularui.screen.RichTooltip; import com.google.common.collect.ImmutableList; import it.unimi.dsi.fastutil.ints.Int2ObjectMap; import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap; @@ -32,6 +33,8 @@ import java.util.ArrayList; import java.util.List; +import java.util.Objects; +import java.util.function.Consumer; public class GTOreByProduct { @@ -48,8 +51,11 @@ public static void addOreByProductPrefix(TagPrefix orePrefix) { private static ImmutableList ALWAYS_MACHINES; private final Int2ObjectMap chances = new Int2ObjectOpenHashMap<>(); + @Getter protected final List itemInputs = new ArrayList<>(); + @Getter protected final NonNullList itemOutputs = NonNullList.create(); + @Getter protected final List fluidInputs = new ArrayList<>(); private boolean hasDirectSmelt = false; private boolean hasChemBath = false; @@ -96,9 +102,9 @@ public GTOreByProduct(Material material) { ItemTagList oreStacks = new ItemTagList(); for (TagPrefix prefix : ORES) { // get all ores with the relevant oredicts instead of just the first unified ore - oreStacks.add(ChemicalHelper.getTag(prefix, material), 1, null); + oreStacks.add(Objects.requireNonNull(ChemicalHelper.getTag(prefix, material)), 1, null); } - oreStacks.add(ChemicalHelper.getTag(TagPrefix.rawOre, material), 1, null); + oreStacks.add(Objects.requireNonNull(ChemicalHelper.getTag(TagPrefix.rawOre, material)), 1, null); itemInputs.add(oreStacks); // set up machines as inputs @@ -142,7 +148,7 @@ public GTOreByProduct(Material material) { // add prefixes that should count as inputs to input lists (they will not be displayed in actual page) for (TagPrefix prefix : IN_PROCESSING_STEPS) { - itemInputs.add(ItemTagList.of(ChemicalHelper.getTag(prefix, material), 1, null)); + itemInputs.add(ItemTagList.of(Objects.requireNonNull(ChemicalHelper.getTag(prefix, material)), 1, null)); } // total number of inputs added @@ -288,18 +294,22 @@ public GTOreByProduct(Material material) { } } - public void getTooltip(int slotIndex, List tooltips) { - if (chances.containsKey(slotIndex)) { - Content entry = chances.get(slotIndex); - float chance = 100 * (float) entry.chance / entry.maxChance; - if (entry.tierChanceBoost != 0) { - float boost = entry.tierChanceBoost / 100.0f; - tooltips.add(FormattingUtil.formatPercentage2Places("gtceu.gui.content.chance_base", chance)); - tooltips.add(FormattingUtil.formatPercentage2Places("gtceu.gui.content.chance_tier_boost_plus", boost)); - } else { - tooltips.add(FormattingUtil.formatPercentage2Places("gtceu.gui.content.chance_no_boost", chance)); + public Consumer getTooltip(int slotIndex) { + return tooltip -> { + if (chances.containsKey(slotIndex)) { + Content entry = chances.get(slotIndex); + float chance = 100 * (float) entry.chance() / entry.maxChance(); + if (entry.tierChanceBoost() != 0) { + float boost = entry.tierChanceBoost() / 100.0f; + tooltip.addLine(FormattingUtil.formatPercentage2Places("gtceu.gui.content.chance_base", chance)); + tooltip.addLine( + FormattingUtil.formatPercentage2Places("gtceu.gui.content.chance_tier_boost_plus", boost)); + } else { + tooltip.addLine( + FormattingUtil.formatPercentage2Places("gtceu.gui.content.chance_no_boost", chance)); + } } - } + }; } public Content getChance(int slot) { diff --git a/src/main/java/com/gregtechceu/gtceu/integration/recipeviewer/widgets/GTOreVeinWidget.java b/src/main/java/com/gregtechceu/gtceu/integration/recipeviewer/widgets/GTOreVeinWidget.java deleted file mode 100644 index ae7fcf3d6d7..00000000000 --- a/src/main/java/com/gregtechceu/gtceu/integration/recipeviewer/widgets/GTOreVeinWidget.java +++ /dev/null @@ -1,258 +0,0 @@ -package com.gregtechceu.gtceu.integration.recipeviewer.widgets; - -import com.gregtechceu.gtceu.api.data.DimensionMarker; -import com.gregtechceu.gtceu.api.data.chemical.ChemicalHelper; -import com.gregtechceu.gtceu.api.data.tag.TagPrefix; -import com.gregtechceu.gtceu.api.data.worldgen.GTOreDefinition; -import com.gregtechceu.gtceu.api.data.worldgen.bedrockfluid.BedrockFluidDefinition; -import com.gregtechceu.gtceu.api.data.worldgen.bedrockore.BedrockOreDefinition; -import com.gregtechceu.gtceu.api.gui.widget.SlotWidget; -import com.gregtechceu.gtceu.api.gui.widget.TankWidget; -import com.gregtechceu.gtceu.api.registry.GTRegistries; -import com.gregtechceu.gtceu.api.transfer.fluid.CustomFluidTank; -import com.gregtechceu.gtceu.api.transfer.item.CustomItemStackHandler; -import com.gregtechceu.gtceu.client.ClientProxy; -import com.gregtechceu.gtceu.config.ConfigHolder; - -import com.lowdragmc.lowdraglib.gui.texture.IGuiTexture; -import com.lowdragmc.lowdraglib.gui.texture.TextTexture; -import com.lowdragmc.lowdraglib.gui.widget.ImageWidget; -import com.lowdragmc.lowdraglib.gui.widget.LabelWidget; -import com.lowdragmc.lowdraglib.gui.widget.WidgetGroup; -import com.lowdragmc.lowdraglib.jei.IngredientIO; -import com.lowdragmc.lowdraglib.utils.LocalizationUtils; - -import net.minecraft.core.NonNullList; -import net.minecraft.network.chat.Component; -import net.minecraft.resources.ResourceKey; -import net.minecraft.resources.ResourceLocation; -import net.minecraft.world.item.ItemStack; -import net.minecraft.world.level.Level; -import net.minecraft.world.level.block.Blocks; -import net.minecraft.world.level.levelgen.heightproviders.HeightProvider; -import net.minecraft.world.level.levelgen.heightproviders.UniformHeight; -import net.minecraft.world.level.material.Fluid; -import net.minecraftforge.fluids.FluidStack; - -import it.unimi.dsi.fastutil.ints.IntList; -import lombok.Getter; - -import java.util.Comparator; -import java.util.HashSet; -import java.util.List; -import java.util.Set; -import java.util.stream.Stream; - -@Getter -public class GTOreVeinWidget extends WidgetGroup { - - private final String name; - private final int weight; - private final String range; - private final Set> dimensionFilter; - public final static int width = 120; - - public GTOreVeinWidget(GTOreDefinition oreDefinition) { - super(0, 0, width, 160); - this.name = getOreName(oreDefinition); - this.weight = oreDefinition.weight(); - this.dimensionFilter = oreDefinition.dimensionFilter(); - this.range = range(oreDefinition); - setClientSideWidget(); - setupBaseGui(oreDefinition); - setupText(oreDefinition); - } - - public GTOreVeinWidget(BedrockFluidDefinition fluid) { - super(0, 0, width, 140); - this.name = getFluidName(fluid); - this.weight = fluid.getWeight(); - this.dimensionFilter = fluid.getDimensionFilter(); - this.range = "NULL"; - setClientSideWidget(); - setupBaseGui(fluid); - setupText(fluid); - } - - public GTOreVeinWidget(BedrockOreDefinition bedrockOre) { - super(0, 0, width, 140); - this.name = getBedrockOreName(bedrockOre); - this.weight = bedrockOre.weight(); - this.dimensionFilter = bedrockOre.dimensionFilter(); - this.range = "NULL"; - setClientSideWidget(); - setupBaseGui(bedrockOre); - setupText(bedrockOre); - } - - @SuppressWarnings("all") - private String range(GTOreDefinition oreDefinition) { - HeightProvider height = oreDefinition.range().height; - int minHeight = 0, maxHeight = 0; - if (height instanceof UniformHeight uniform) { - minHeight = uniform.minInclusive.resolveY(null); - maxHeight = uniform.maxInclusive.resolveY(null); - } - return String.format("%d - %d", minHeight, maxHeight); - } - - private void setupBaseGui(GTOreDefinition oreDefinition) { - NonNullList containedOresAsItemStacks = NonNullList.create(); - List chances = oreDefinition.veinGenerator().getAllChances(); - containedOresAsItemStacks.addAll(getRawMaterialList(oreDefinition)); - int n = containedOresAsItemStacks.size(); - int x = (width - 18 * n) / 2; - for (int i = 0; i < n; i++) { - SlotWidget oreSlot = new SlotWidget(new CustomItemStackHandler(containedOresAsItemStacks), i, x, 18, false, - false); - int finalIndex = i; - oreSlot.setOnAddedTooltips((stack, tooltips) -> tooltips.add(Component - .nullToEmpty( - LocalizationUtils.format("gtceu.jei.ore_vein_diagram.chance", chances.get(finalIndex))))); - oreSlot.setIngredientIO(IngredientIO.OUTPUT); - addWidget(oreSlot); - x += 18; - } - } - - private void setupBaseGui(BedrockFluidDefinition fluid) { - Fluid storedFluid = fluid.getStoredFluid().get(); - TankWidget fluidSlot = new TankWidget( - new CustomFluidTank(new FluidStack(storedFluid, 1000)), 51, 18, false, false); - fluidSlot.setIngredientIO(IngredientIO.OUTPUT); - addWidget(fluidSlot); - } - - private void setupBaseGui(BedrockOreDefinition bedrockOreDefinition) { - NonNullList containedOresAsItemStacks = NonNullList.create(); - IntList chances = bedrockOreDefinition.getAllChances(); - containedOresAsItemStacks.addAll(getRawMaterialList(bedrockOreDefinition)); - int n = containedOresAsItemStacks.size(); - int x = (width - 18 * n) / 2; - for (int i = 0; i < n; i++) { - SlotWidget oreSlot = new SlotWidget(new CustomItemStackHandler(containedOresAsItemStacks), i, x, 18, false, - false); - int finalIndex = i; - oreSlot.setOnAddedTooltips((stack, tooltips) -> tooltips.add(Component - .nullToEmpty( - LocalizationUtils.format("gtceu.jei.ore_vein_diagram.chance", - chances.getInt(finalIndex))))); - oreSlot.setIngredientIO(IngredientIO.OUTPUT); - addWidget(oreSlot); - x += 18; - } - } - - private void setupText(GTOreDefinition ignored) { - addWidget(new ImageWidget(5, 0, width - 10, 16, - new TextTexture("gtceu.jei.ore_vein." + name).setType(TextTexture.TextType.LEFT_ROLL) - .setWidth(width - 10))); - addWidget(new LabelWidget(5, 40, - LocalizationUtils.format("gtceu.jei.ore_vein_diagram.spawn_range"))); - addWidget(new LabelWidget(5, 50, range)); - - addWidget(new LabelWidget(5, 60, - LocalizationUtils.format("gtceu.jei.ore_vein_diagram.weight", weight))); - addWidget(new LabelWidget(5, 70, - LocalizationUtils.format("gtceu.jei.ore_vein_diagram.dimensions"))); - setupDimensionMarker(80); - } - - private void setupText(BedrockFluidDefinition ignored) { - addWidget(new ImageWidget(5, 0, width - 10, 16, - new TextTexture("gtceu.jei.bedrock_fluid." + name).setType(TextTexture.TextType.LEFT_ROLL) - .setWidth(width - 10))); - addWidget(new LabelWidget(5, 40, - LocalizationUtils.format("gtceu.jei.ore_vein_diagram.weight", weight))); - addWidget(new LabelWidget(5, 50, - LocalizationUtils.format("gtceu.jei.ore_vein_diagram.dimensions"))); - setupDimensionMarker(60); - } - - private void setupText(BedrockOreDefinition ignored) { - addWidget(new ImageWidget(5, 0, width - 10, 16, - new TextTexture("gtceu.jei.bedrock_ore." + name).setType(TextTexture.TextType.LEFT_ROLL) - .setWidth(width - 10))); - addWidget(new LabelWidget(5, 40, - LocalizationUtils.format("gtceu.jei.ore_vein_diagram.weight", weight))); - addWidget(new LabelWidget(5, 50, - LocalizationUtils.format("gtceu.jei.ore_vein_diagram.dimensions"))); - setupDimensionMarker(60); - } - - private void setupDimensionMarker(int yPosition) { - if (this.dimensionFilter != null) { - int interval = 2; - int rowSlots = (width - 10 + interval) / (16 + interval); - - DimensionMarker[] dimMarkers = dimensionFilter.stream() - .map(ResourceKey::location) - .map(loc -> GTRegistries.DIMENSION_MARKERS.getOrDefault(loc, - new DimensionMarker(DimensionMarker.MAX_TIER, () -> Blocks.BARRIER, loc.toString()))) - .sorted(Comparator.comparingInt(DimensionMarker::getTier)) - .toArray(DimensionMarker[]::new); - var handler = new CustomItemStackHandler(dimMarkers.length); - for (int i = 0; i < dimMarkers.length; i++) { - var dimMarker = dimMarkers[i]; - var icon = dimMarker.getIcon(); - int row = Math.floorDiv(i, rowSlots); - SlotWidget dimSlot = new SlotWidget(handler, i, - 5 + (16 + interval) * (i - row * rowSlots), - yPosition + 18 * row, - false, false).setIngredientIO(IngredientIO.CATALYST); - handler.setStackInSlot(i, icon); - if (ConfigHolder.INSTANCE.compat.showDimensionTier) { - dimSlot.setOverlay( - new TextTexture("T" + (dimMarker.tier >= DimensionMarker.MAX_TIER ? "?" : dimMarker.tier)) - .scale(0.75F) - .transform(-3F, 5F)); - } - addWidget(dimSlot.setBackgroundTexture(IGuiTexture.EMPTY)); - } - } else { - addWidget(new LabelWidget(5, yPosition, "Any")); - } - } - - public static List getContainedOresAndBlocks(GTOreDefinition oreDefinition) { - return oreDefinition.veinGenerator().getAllEntries().stream() - .flatMap(entry -> entry.map(state -> Stream.of(state.getBlock().asItem().getDefaultInstance()), - material -> { - Set ores = new HashSet<>(); - ores.add(ChemicalHelper.get(TagPrefix.rawOre, material)); - for (TagPrefix prefix : TagPrefix.ORES.keySet()) { - ores.add(ChemicalHelper.get(prefix, material)); - } - return ores.stream(); - })) - .toList(); - } - - public static List getRawMaterialList(GTOreDefinition oreDefinition) { - return oreDefinition.veinGenerator().getAllEntries().stream() - .map(entry -> entry.map(state -> state.getBlock().asItem().getDefaultInstance(), - material -> ChemicalHelper.get(TagPrefix.rawOre, material))) - .toList(); - } - - public static List getRawMaterialList(BedrockOreDefinition bedrockOreDefinition) { - return bedrockOreDefinition.materials().stream() - .map(entry -> ChemicalHelper.get(TagPrefix.rawOre, entry.material())) - .toList(); - } - - public static String getOreName(GTOreDefinition oreDefinition) { - ResourceLocation id = ClientProxy.CLIENT_ORE_VEINS.inverse().get(oreDefinition); - return id.getPath(); - } - - public static String getFluidName(BedrockFluidDefinition fluid) { - ResourceLocation id = ClientProxy.CLIENT_FLUID_VEINS.inverse().get(fluid); - return id.getPath(); - } - - public static String getBedrockOreName(BedrockOreDefinition oreDefinition) { - ResourceLocation id = ClientProxy.CLIENT_BEDROCK_ORE_VEINS.inverse().get(oreDefinition); - return id.getPath(); - } -} diff --git a/src/main/java/com/gregtechceu/gtceu/integration/recipeviewer/widgets/GTProgrammedCircuitWidget.java b/src/main/java/com/gregtechceu/gtceu/integration/recipeviewer/widgets/GTProgrammedCircuitWidget.java deleted file mode 100644 index c3fef8d35b3..00000000000 --- a/src/main/java/com/gregtechceu/gtceu/integration/recipeviewer/widgets/GTProgrammedCircuitWidget.java +++ /dev/null @@ -1,34 +0,0 @@ -package com.gregtechceu.gtceu.integration.recipeviewer.widgets; - -import com.gregtechceu.gtceu.api.gui.GuiTextures; -import com.gregtechceu.gtceu.api.gui.widget.SlotWidget; -import com.gregtechceu.gtceu.api.transfer.item.CustomItemStackHandler; -import com.gregtechceu.gtceu.common.item.behavior.IntCircuitBehaviour; - -import com.lowdragmc.lowdraglib.gui.widget.ImageWidget; -import com.lowdragmc.lowdraglib.gui.widget.WidgetGroup; -import com.lowdragmc.lowdraglib.jei.IngredientIO; - -import net.minecraftforge.items.ItemStackHandler; - -public class GTProgrammedCircuitWidget extends WidgetGroup { - - public GTProgrammedCircuitWidget() { - super(0, 0, 150, 80); - setClientSideWidget(); - setRecipe(); - } - - public void setRecipe() { - addWidget(new ImageWidget(39, 0, 36, 36, GuiTextures.SLOT)); - - ItemStackHandler handler = new CustomItemStackHandler(32); - for (int j = 0; j < 4; j++) { - for (int i = 0; i < 8; i++) { - handler.setStackInSlot((i + j * 8), IntCircuitBehaviour.stack(1 + (i + j * 8))); - addWidget(new SlotWidget(handler, (i + j * 8), 3 + 18 * i, 18 * j, false, false) - .setIngredientIO((i + j * 8 == 31 ? IngredientIO.OUTPUT : IngredientIO.BOTH))); - } - } - } -} diff --git a/src/main/java/com/gregtechceu/gtceu/integration/recipeviewer/widgets/GTRecipeWidget.java b/src/main/java/com/gregtechceu/gtceu/integration/recipeviewer/widgets/GTRecipeWidget.java deleted file mode 100644 index 36b8f1c5a0d..00000000000 --- a/src/main/java/com/gregtechceu/gtceu/integration/recipeviewer/widgets/GTRecipeWidget.java +++ /dev/null @@ -1,454 +0,0 @@ -package com.gregtechceu.gtceu.integration.recipeviewer.widgets; - -import com.gregtechceu.gtceu.GTCEu; -import com.gregtechceu.gtceu.api.GTValues; -import com.gregtechceu.gtceu.api.capability.recipe.CWURecipeCapability; -import com.gregtechceu.gtceu.api.capability.recipe.IO; -import com.gregtechceu.gtceu.api.capability.recipe.RecipeCapability; -import com.gregtechceu.gtceu.api.gui.GuiTextures; -import com.gregtechceu.gtceu.api.gui.WidgetUtils; -import com.gregtechceu.gtceu.api.gui.widget.PredicatedButtonWidget; -import com.gregtechceu.gtceu.api.recipe.GTRecipe; -import com.gregtechceu.gtceu.api.recipe.OverclockingLogic; -import com.gregtechceu.gtceu.api.recipe.RecipeCondition; -import com.gregtechceu.gtceu.api.recipe.RecipeHelper; -import com.gregtechceu.gtceu.api.recipe.chance.boost.ChanceBoostFunction; -import com.gregtechceu.gtceu.api.recipe.chance.logic.ChanceLogic; -import com.gregtechceu.gtceu.api.recipe.content.Content; -import com.gregtechceu.gtceu.api.recipe.ingredient.EnergyStack; -import com.gregtechceu.gtceu.common.data.GTRecipeTypes; -import com.gregtechceu.gtceu.common.machine.multiblock.electric.FusionReactorMachine; -import com.gregtechceu.gtceu.common.recipe.condition.DimensionCondition; -import com.gregtechceu.gtceu.data.lang.LangHandler; -import com.gregtechceu.gtceu.utils.FormattingUtil; -import com.gregtechceu.gtceu.utils.GTUtil; - -import com.lowdragmc.lowdraglib.gui.texture.GuiTextureGroup; -import com.lowdragmc.lowdraglib.gui.texture.IGuiTexture; -import com.lowdragmc.lowdraglib.gui.texture.TextTexture; -import com.lowdragmc.lowdraglib.gui.widget.*; - -import net.minecraft.ChatFormatting; -import net.minecraft.client.Minecraft; -import net.minecraft.nbt.CompoundTag; -import net.minecraft.network.chat.Component; -import net.minecraft.util.Mth; -import net.minecraftforge.fml.loading.FMLLoader; - -import com.google.common.collect.Table; -import com.google.common.collect.Tables; -import it.unimi.dsi.fastutil.objects.Object2ObjectLinkedOpenHashMap; -import org.apache.commons.lang3.mutable.MutableInt; -import org.jetbrains.annotations.NotNull; -import org.lwjgl.glfw.GLFW; - -import java.util.*; -import java.util.function.Function; -import java.util.regex.Pattern; - -import static com.gregtechceu.gtceu.api.GTValues.*; - -public class GTRecipeWidget extends WidgetGroup { - - public static final String RECIPE_CONTENT_GROUP_ID = "recipeContentGroup"; - public static final Pattern RECIPE_CONTENT_GROUP_ID_REGEX = Pattern.compile("^recipeContentGroup$"); - - public static final int LINE_HEIGHT = 10; - - private final int xOffset; - private final GTRecipe recipe; - private final List recipeParaTexts = new ArrayList<>(); - private LabelWidget recipeVoltageText = null; - private final int minTier; - private int tier; - private int yOffset; - private LabelWidget voltageTextWidget; - - public GTRecipeWidget(GTRecipe recipe) { - super(getXOffset(recipe), 0, recipe.recipeType.getRecipeUI().getJEISize().width, - recipe.recipeType.getRecipeUI().getJEISize().height); - this.recipe = recipe; - this.xOffset = getXOffset(recipe); - this.minTier = RecipeHelper.getRecipeEUtTier(recipe); - setRecipeWidget(); - setTierToMin(); - initializeRecipeTextWidget(); - addButtons(); - } - - private static int getXOffset(GTRecipe recipe) { - if (recipe.recipeType.getRecipeUI().getOriginalWidth() != recipe.recipeType.getRecipeUI().getJEISize().width) { - return (recipe.recipeType.getRecipeUI().getJEISize().width - - recipe.recipeType.getRecipeUI().getOriginalWidth()) / 2; - } - return 0; - } - - @SuppressWarnings("UnstableApiUsage") - private void setRecipeWidget() { - setClientSideWidget(); - - var storages = Tables.newCustomTable(new EnumMap<>(IO.class), LinkedHashMap, Object>::new); - var contents = Tables.newCustomTable(new EnumMap<>(IO.class), - LinkedHashMap, List>::new); - collectStorage(storages, contents, recipe); - - WidgetGroup group = recipe.recipeType.getRecipeUI().createUITemplate(ProgressWidget.JEIProgress, storages, - recipe.data.copy(), recipe.conditions); - addSlots(contents, group, recipe); - - var size = group.getSize(); - - // Ensure any previous instances of the widget are removed first. This applies when changing the recipe - // preview's voltage tier, as this recipe widget stays the same while its contents are updated. - group.setId(RECIPE_CONTENT_GROUP_ID); - getWidgetsById(RECIPE_CONTENT_GROUP_ID_REGEX).forEach(this::removeWidget); - - addWidget(group); - - EnergyStack EUt = RecipeHelper.getRealEUt(recipe); - int yOffset = 5 + size.height; - this.yOffset = yOffset; - yOffset += !EUt.isEmpty() ? 21 : 0; - if (recipe.data.getBoolean("duration_is_total_cwu")) { - yOffset -= 10; - } - - /// add text based on i/o's - MutableInt yOff = new MutableInt(yOffset); - for (var capability : recipe.inputs.entrySet()) { - capability.getKey().addXEIInfo(this, xOffset, recipe, capability.getValue(), false, true, yOff); - } - for (var capability : recipe.tickInputs.entrySet()) { - capability.getKey().addXEIInfo(this, xOffset, recipe, capability.getValue(), true, true, yOff); - } - for (var capability : recipe.outputs.entrySet()) { - capability.getKey().addXEIInfo(this, xOffset, recipe, capability.getValue(), false, false, yOff); - } - for (var capability : recipe.tickOutputs.entrySet()) { - capability.getKey().addXEIInfo(this, xOffset, recipe, capability.getValue(), true, false, yOff); - } - - for (RecipeCondition condition : recipe.conditions) { - if (condition.getTooltips() == null) continue; - if (condition instanceof DimensionCondition dimCondition) { - addWidget(dimCondition - .setupDimensionMarkers(recipe.recipeType.getRecipeUI().getJEISize().width - xOffset - 44, - recipe.recipeType.getRecipeUI().getJEISize().height - 32) - .setBackgroundTexture(IGuiTexture.EMPTY)); - } else addWidget(new LabelWidget(3 - xOffset, yOffset += LINE_HEIGHT, condition.getTooltips().getString())); - } - for (Function dataInfo : recipe.recipeType.getDataInfos()) { - addWidget(new LabelWidget(3 - xOffset, yOffset += LINE_HEIGHT, dataInfo.apply(recipe.data))); - } - recipe.recipeType.getRecipeUI().appendJEIUI(recipe, this); - } - - private void initializeRecipeTextWidget() { - String tierText = GTValues.VNF[tier]; - int textsY = yOffset - 10; - int duration = recipe.duration; - var EUt = RecipeHelper.getRealEUtWithIO(recipe); - var minVoltageTier = GTUtil.getTierByVoltage(EUt.voltage()); - float minAmperage = (float) EUt.getTotalEU() / GTValues.V[minVoltageTier]; - - List texts = getRecipeParaText(recipe, duration, EUt); - for (Component text : texts) { - textsY += 10; - LabelWidget labelWidget = new LabelWidget(3 - xOffset, textsY, text).setTextColor(-1).setDropShadow(true); - addWidget(labelWidget); - recipeParaTexts.add(labelWidget); - } - - if (EUt.voltage() > 0) { - textsY += 10; - Component text = Component.translatable(EUt.isInput() ? "gtceu.recipe.eu" : "gtceu.recipe.eu_inverted", - FormattingUtil.formatNumber2Places(minAmperage), GTValues.VN[minVoltageTier]) - .withStyle(ChatFormatting.UNDERLINE); - recipeVoltageText = new LabelWidget(3 - xOffset, textsY, text).setTextColor(-1) - .setDropShadow(true); - recipeVoltageText.setHoverTooltips( - Component.translatable("gtceu.recipe.eu.total", FormattingUtil.formatNumbers(EUt.getTotalEU())) - .withStyle(ChatFormatting.UNDERLINE)); - if (recipeVoltageText != null) { - addWidget(recipeVoltageText); - } - } - - if (EUt.isInput()) { - LabelWidget voltageTextWidget = new LabelWidget(getVoltageXOffset() - xOffset, getSize().height - 10, - tierText).setTextColor(-1).setDropShadow(false); - if (recipe.recipeType.isOffsetVoltageText()) { - voltageTextWidget.setSelfPositionY(getSize().height - recipe.recipeType.getVoltageTextOffset()); - } - // make it clickable - // voltageTextWidget.setBackground(new GuiTextureGroup(GuiTextures.BUTTON)); - addWidget(new ButtonWidget(voltageTextWidget.getPositionX(), voltageTextWidget.getPositionY(), - voltageTextWidget.getSizeWidth(), voltageTextWidget.getSizeHeight(), - cd -> setRecipeOC(cd.button, cd.isShiftClick)) - .setHoverTooltips(LangHandler.getMultiLang("gtceu.oc.tooltip", GTValues.VNF[minTier]) - .toArray(Component[]::new))); - addWidget(this.voltageTextWidget = voltageTextWidget); - } - } - - @NotNull - private static List getRecipeParaText(GTRecipe recipe, int duration, - EnergyStack.WithIO eu) { - List texts = new ArrayList<>(); - if (!recipe.data.getBoolean("hide_duration")) { - texts.add(Component.translatable("gtceu.recipe.duration", FormattingUtil.formatNumbers(duration / 20f))); - } - if (eu.voltage() > 0) { - long euTotal = eu.getTotalEU() * duration; - // sadly we still need a custom override here, since computation uses duration and EU/t very differently - if (recipe.data.getBoolean("duration_is_total_cwu") && - recipe.tickInputs.containsKey(CWURecipeCapability.CAP)) { - int minimumCWUt = Math.max(recipe.tickInputs.get(CWURecipeCapability.CAP).stream() - .map(Content::getContent).mapToInt(CWURecipeCapability.CAP::of).sum(), 1); - texts.add(Component.translatable("gtceu.recipe.max_eu", - FormattingUtil.formatNumbers(euTotal / minimumCWUt))); - } else { - texts.add(Component.translatable("gtceu.recipe.total", FormattingUtil.formatNumbers(euTotal))); - } - } - - return texts; - } - - private void addButtons() { - // add a recipe id getter, btw all the things can only click within the WidgetGroup while using EMI - int x = getSize().width - xOffset - 18; - int y = getSize().height - 30; - addWidget( - new PredicatedButtonWidget(x, y, 15, 15, new GuiTextureGroup(GuiTextures.BUTTON, new TextTexture("ID")), - cd -> Minecraft.getInstance().keyboardHandler.setClipboard(recipe.id.toString()), - () -> !FMLLoader.isProduction(), !FMLLoader.isProduction()) - .setHoverTooltips("click to copy: " + recipe.id)); - } - - private int getVoltageXOffset() { - int x = getSize().width - switch (tier) { - case ULV, LuV, ZPM, UHV, UEV, UXV -> 20; - case OpV, MAX -> 22; - case UIV -> 18; - case IV -> 12; - default -> 14; - }; - if (!GTCEu.Mods.isEMILoaded()) { - x -= 3; - } - return x; - } - - public void setRecipeOC(int button, boolean isShiftClick) { - OverclockingLogic oc = OverclockingLogic.NON_PERFECT_OVERCLOCK; - if (button == GLFW.GLFW_MOUSE_BUTTON_LEFT) { - setTier(tier + 1); - } else if (button == GLFW.GLFW_MOUSE_BUTTON_RIGHT) { - setTier(tier - 1); - } else if (button == GLFW.GLFW_MOUSE_BUTTON_MIDDLE) { - setTierToMin(); - } - if (isShiftClick) { - oc = OverclockingLogic.PERFECT_OVERCLOCK; - } - if (recipe.recipeType == GTRecipeTypes.FUSION_RECIPES) { - oc = FusionReactorMachine.FUSION_OC; - } - setRecipeOverclockWidget(oc); - setRecipeWidget(); - } - - private void setRecipeOverclockWidget(OverclockingLogic logic) { - EnergyStack inputEUt = recipe.getInputEUt(); - int duration = recipe.duration; - String tierText = GTValues.VNF[tier]; - - if (tier > minTier && !inputEUt.isEmpty()) { - int ocs = tier - minTier; - if (minTier == ULV) ocs--; - var params = new OverclockingLogic.OCParams(inputEUt.voltage(), recipe.duration, ocs, 1); - var result = logic.runOverclockingLogic(params, V[tier]); - duration = (int) (duration * result.durationMultiplier()); - inputEUt = inputEUt.multiplyVoltage(result.eutMultiplier()); - tierText = tierText.formatted(ChatFormatting.ITALIC); - } - var minVoltageTier = GTUtil.getTierByVoltage(inputEUt.voltage()); - float minAmperage = (float) inputEUt.getTotalEU() / GTValues.V[minVoltageTier]; - List texts = getRecipeParaText(recipe, duration, new EnergyStack.WithIO(inputEUt, IO.IN)); - for (int i = 0; i < texts.size(); i++) { - recipeParaTexts.get(i).setComponent(texts.get(i)); - } - voltageTextWidget.setText(tierText); - voltageTextWidget.setSelfPositionX(getVoltageXOffset() - xOffset); - if (recipeVoltageText != null) { - recipeVoltageText.setComponent(Component.translatable("gtceu.recipe.eu", - FormattingUtil.formatNumber2Places(minAmperage), GTValues.VN[minVoltageTier]) - .withStyle(ChatFormatting.UNDERLINE)); - recipeVoltageText.setHoverTooltips( - Component.translatable("gtceu.recipe.eu.total", FormattingUtil.formatNumbers(inputEUt.getTotalEU())) - .withStyle(ChatFormatting.UNDERLINE)); - } - detectAndSendChanges(); - updateScreen(); - } - - public static void setConsumedChance(Content content, ChanceLogic logic, List tooltips, int recipeTier, - int chanceTier, ChanceBoostFunction function) { - if (content.chance < ChanceLogic.getMaxChancedValue()) { - int boostedChance = function.getBoostedChance(content, recipeTier, chanceTier); - if (boostedChance == 0) { - tooltips.add(Component.translatable("gtceu.gui.content.chance_nc")); - } else { - float baseChanceFloat = 100f * content.chance / content.maxChance; - if (content.tierChanceBoost != 0) { - float boostedChanceFloat = 100f * boostedChance / content.maxChance; - - if (logic != ChanceLogic.NONE && logic != ChanceLogic.OR) { - tooltips.add(Component.translatable("gtceu.gui.content.chance_base_logic", - FormattingUtil.formatNumber2Places(baseChanceFloat), logic.getTranslation()) - .withStyle(ChatFormatting.YELLOW)); - } else { - tooltips.add( - FormattingUtil.formatPercentage2Places("gtceu.gui.content.chance_base", - baseChanceFloat)); - } - - String key = "gtceu.gui.content.chance_tier_boost_" + - ((content.tierChanceBoost > 0) ? "plus" : "minus"); - tooltips.add(FormattingUtil.formatPercentage2Places(key, - Math.abs(100f * content.tierChanceBoost / content.maxChance))); - - if (logic != ChanceLogic.NONE && logic != ChanceLogic.OR) { - tooltips.add(Component.translatable("gtceu.gui.content.chance_boosted_logic", - FormattingUtil.formatNumber2Places(boostedChanceFloat), logic.getTranslation()) - .withStyle(ChatFormatting.YELLOW)); - } else { - tooltips.add( - FormattingUtil.formatPercentage2Places("gtceu.gui.content.chance_boosted", - boostedChanceFloat)); - } - } else { - if (logic != ChanceLogic.NONE && logic != ChanceLogic.OR) { - tooltips.add(Component.translatable("gtceu.gui.content.chance_no_boost_logic", - FormattingUtil.formatNumber2Places(baseChanceFloat), logic.getTranslation()) - .withStyle(ChatFormatting.YELLOW)); - } else { - tooltips.add( - FormattingUtil.formatPercentage2Places("gtceu.gui.content.chance_no_boost", - baseChanceFloat)); - } - } - } - } - } - - private void setTier(int tier) { - this.tier = Mth.clamp(tier, minTier, GTValues.MAX); - } - - private void setTierToMin() { - setTier(minTier); - } - - public void collectStorage(Table, Object> extraTable, - Table, List> extraContents, GTRecipe recipe) { - for (var entry : recipe.inputs.entrySet()) { - RecipeCapability cap = entry.getKey(); - List contents = entry.getValue(); - - extraContents.put(IO.IN, cap, contents); - } - for (var entry : recipe.tickInputs.entrySet()) { - RecipeCapability cap = entry.getKey(); - List contents = entry.getValue(); - - if (extraContents.get(IO.IN, cap) == null) { - extraContents.put(IO.IN, cap, contents); - } else { - ArrayList fullContents = new ArrayList<>(extraContents.get(IO.IN, cap)); - fullContents.addAll(contents); - extraContents.put(IO.IN, cap, fullContents); - } - } - if (extraContents.containsRow(IO.IN)) { - Map, List> inputCapabilities = new Object2ObjectLinkedOpenHashMap<>(); - for (var entry : extraContents.row(IO.IN).entrySet()) { - RecipeCapability cap = entry.getKey(); - inputCapabilities.put(cap, cap.createXEIContainerContents(entry.getValue(), recipe, IO.IN)); - } - - for (var entry : inputCapabilities.entrySet()) { - while (entry.getValue().size() < recipe.recipeType.getMaxInputs(entry.getKey())) - entry.getValue().add(null); - var container = entry.getKey().createXEIContainer(entry.getValue()); - if (container != null) { - extraTable.put(IO.IN, entry.getKey(), container); - } - } - } - - for (var entry : recipe.outputs.entrySet()) { - RecipeCapability cap = entry.getKey(); - List contents = entry.getValue(); - - extraContents.put(IO.OUT, cap, contents); - } - for (var entry : recipe.tickOutputs.entrySet()) { - RecipeCapability cap = entry.getKey(); - List contents = entry.getValue(); - - if (extraContents.get(IO.OUT, cap) == null) { - extraContents.put(IO.OUT, cap, contents); - } else { - ArrayList fullContents = new ArrayList<>(extraContents.get(IO.IN, cap)); - fullContents.addAll(contents); - extraContents.put(IO.OUT, cap, fullContents); - } - } - if (extraContents.containsRow(IO.OUT)) { - Map, List> outputCapabilities = new Object2ObjectLinkedOpenHashMap<>(); - for (var entry : extraContents.row(IO.OUT).entrySet()) { - RecipeCapability cap = entry.getKey(); - outputCapabilities.put(cap, cap.createXEIContainerContents(entry.getValue(), recipe, IO.OUT)); - } - for (var entry : outputCapabilities.entrySet()) { - while (entry.getValue().size() < recipe.recipeType.getMaxOutputs(entry.getKey())) - entry.getValue().add(null); - var container = entry.getKey().createXEIContainer(entry.getValue()); - if (container != null) { - extraTable.put(IO.OUT, entry.getKey(), container); - } - } - } - } - - public void addSlots(Table, List> contentTable, WidgetGroup group, - GTRecipe recipe) { - for (var capabilityEntry : contentTable.rowMap().entrySet()) { - IO io = capabilityEntry.getKey(); - for (var contentsEntry : capabilityEntry.getValue().entrySet()) { - RecipeCapability cap = contentsEntry.getKey(); - int nonTickCount = (io == IO.IN ? recipe.getInputContents(cap) : recipe.getOutputContents(cap)).size(); - List contents = contentsEntry.getValue(); - // bind fluid out overlay - var widgetClass = cap.getWidgetClass(); - if (widgetClass != null) { - WidgetUtils.widgetByIdForEach(group, "^%s_[0-9]+$".formatted(cap.slotName(io)), widgetClass, - widget -> { - var index = WidgetUtils.widgetIdIndex(widget); - if (index >= 0 && index < contents.size()) { - var content = contents.get(index); - cap.applyWidgetInfo(widget, index, true, io, null, recipe.getType(), recipe, - content, - null, minTier, tier); - widget.setOverlay(content.createOverlay(index >= nonTickCount, minTier, tier, - recipe.getType().getChanceFunction())); - } - }); - } - } - } - } -} diff --git a/src/main/java/com/gregtechceu/gtceu/integration/recipeviewer/widgets/GTOreByProductWidget.java b/src/main/java/com/gregtechceu/gtceu/integration/recipeviewer/widgets/OreProcessingRecipeWidget.java similarity index 50% rename from src/main/java/com/gregtechceu/gtceu/integration/recipeviewer/widgets/GTOreByProductWidget.java rename to src/main/java/com/gregtechceu/gtceu/integration/recipeviewer/widgets/OreProcessingRecipeWidget.java index fd4da1417a5..f8bec8ba737 100644 --- a/src/main/java/com/gregtechceu/gtceu/integration/recipeviewer/widgets/GTOreByProductWidget.java +++ b/src/main/java/com/gregtechceu/gtceu/integration/recipeviewer/widgets/OreProcessingRecipeWidget.java @@ -1,33 +1,26 @@ package com.gregtechceu.gtceu.integration.recipeviewer.widgets; +import brachy.modularui.drawable.GuiTextures; +import brachy.modularui.integration.recipeviewer.RecipeViewerSlotWidget; import com.gregtechceu.gtceu.api.data.chemical.material.Material; -import com.gregtechceu.gtceu.api.gui.GuiTextures; -import com.gregtechceu.gtceu.api.gui.widget.SlotWidget; -import com.gregtechceu.gtceu.api.gui.widget.TankWidget; import com.gregtechceu.gtceu.api.recipe.content.Content; -import com.gregtechceu.gtceu.api.transfer.fluid.CustomFluidTank; -import com.gregtechceu.gtceu.api.transfer.item.CustomItemStackHandler; -import com.gregtechceu.gtceu.integration.recipeviewer.entry.fluid.FluidEntryList; -import com.gregtechceu.gtceu.integration.recipeviewer.entry.item.ItemEntryList; -import com.gregtechceu.gtceu.integration.recipeviewer.handlers.fluid.CycleFluidEntryHandler; -import com.gregtechceu.gtceu.integration.recipeviewer.handlers.item.CycleItemEntryHandler; - -import com.lowdragmc.lowdraglib.gui.texture.IGuiTexture; -import com.lowdragmc.lowdraglib.gui.widget.ImageWidget; -import com.lowdragmc.lowdraglib.gui.widget.WidgetGroup; -import com.lowdragmc.lowdraglib.jei.IngredientIO; +import com.gregtechceu.gtceu.api.recipe.gui.ContentOverlay; +import com.gregtechceu.gtceu.common.mui.GTGuiTextures; import net.minecraft.core.NonNullList; import net.minecraft.world.item.ItemStack; -import it.unimi.dsi.fastutil.booleans.BooleanArrayList; -import it.unimi.dsi.fastutil.booleans.BooleanList; +import brachy.modularui.api.drawable.IDrawable; +import brachy.modularui.integration.recipeviewer.RecipeSlotRole; +import brachy.modularui.integration.recipeviewer.entry.fluid.FluidEntryList; +import brachy.modularui.integration.recipeviewer.entry.item.ItemEntryList; +import brachy.modularui.widget.ParentWidget; import it.unimi.dsi.fastutil.ints.IntImmutableList; import it.unimi.dsi.fastutil.ints.IntSet; import java.util.List; -public class GTOreByProductWidget extends WidgetGroup { +public class OreProcessingRecipeWidget extends ParentWidget { // XY positions of every item and fluid, in three enormous lists protected final static IntImmutableList ITEM_INPUT_LOCATIONS = IntImmutableList.of( @@ -95,100 +88,74 @@ public class GTOreByProductWidget extends WidgetGroup { protected final static IntSet FINAL_OUTPUT_INDICES = IntSet.of( 0, 4, 8, 10, 12, 16, 20, 22, 24, 28, 30, 32, 40, 44, 48, 50, 52, 54, 56, 58, 60, 62, 64, 66); - public GTOreByProductWidget(Material material) { - super(0, 0, 176, 166); - setClientSideWidget(); + public OreProcessingRecipeWidget(Material material) { + size(176, 166); setRecipe(new GTOreByProduct(material)); } public void setRecipe(GTOreByProduct recipeWrapper) { - BooleanList itemOutputExists = new BooleanArrayList(); - // only draw slot on inputs if it is the ore - addWidget(new ImageWidget(ITEM_INPUT_LOCATIONS.getInt(0), ITEM_INPUT_LOCATIONS.getInt(1), 18, 18, - GuiTextures.SLOT)); boolean hasSifter = recipeWrapper.hasSifter(); - addWidget(new ImageWidget(0, 0, 176, 166, GuiTextures.OREBY_BASE)); + child(GTGuiTextures.OREBY_BASE.asWidget().size(176, 166)); if (recipeWrapper.hasDirectSmelt()) { - addWidget(new ImageWidget(0, 0, 176, 166, GuiTextures.OREBY_SMELT)); + child(GTGuiTextures.OREBY_SMELT.asWidget().size(176, 166)); } if (recipeWrapper.hasChemBath()) { - addWidget(new ImageWidget(0, 0, 176, 166, GuiTextures.OREBY_CHEM)); + child(GTGuiTextures.OREBY_CHEM.asWidget().size(176, 166)); } if (recipeWrapper.hasSeparator()) { - addWidget(new ImageWidget(0, 0, 176, 166, GuiTextures.OREBY_SEP)); + child(GTGuiTextures.OREBY_SEP.asWidget().size(176, 166)); } if (hasSifter) { - addWidget(new ImageWidget(0, 0, 176, 166, GuiTextures.OREBY_SIFT)); + child(GTGuiTextures.OREBY_SIFT.asWidget().size(176, 166)); } List itemInputs = recipeWrapper.itemInputs; - CycleItemEntryHandler itemInputsHandler = new CycleItemEntryHandler(itemInputs); - WidgetGroup itemStackGroup = new WidgetGroup(); + ParentWidget itemStackGroup = new ParentWidget<>().sizeRel(1f); for (int i = 0; i < ITEM_INPUT_LOCATIONS.size(); i += 2) { - final int finalI = i; - itemStackGroup.addWidget(new SlotWidget(itemInputsHandler, i / 2, ITEM_INPUT_LOCATIONS.getInt(i), - ITEM_INPUT_LOCATIONS.getInt(i + 1)) - .setCanTakeItems(false) - .setCanPutItems(false) - .setIngredientIO(IngredientIO.INPUT) - .setOnAddedTooltips((slot, tooltips) -> recipeWrapper.getTooltip(finalI / 2, tooltips)) - .setBackground((IGuiTexture) null)); + itemStackGroup.child(RecipeViewerSlotWidget.create() + .recipeSlotRole(RecipeSlotRole.INPUT) + .pos(ITEM_INPUT_LOCATIONS.getInt(i), ITEM_INPUT_LOCATIONS.getInt(i + 1)) + .tooltipBuilder(recipeWrapper.getTooltip(i / 2)) + .value(itemInputs.get(i/2)) + .background(i == 0 ? GuiTextures.SLOT_ITEM : IDrawable.NONE)); } NonNullList itemOutputs = recipeWrapper.itemOutputs; - CustomItemStackHandler itemOutputsHandler = new CustomItemStackHandler(itemOutputs); for (int i = 0; i < ITEM_OUTPUT_LOCATIONS.size(); i += 2) { int slotIndex = i / 2; - float xeiChance = 1.0f; Content chance = recipeWrapper.getChance(i / 2 + itemInputs.size()); - IGuiTexture overlay = null; + IDrawable overlay = null; if (chance != null) { - xeiChance = (float) chance.chance / chance.maxChance; - overlay = chance.createOverlay(false, 0, 0, null); + overlay = new ContentOverlay(chance, false, 0, 0, null); } if (itemOutputs.get(slotIndex).isEmpty()) { - itemOutputExists.add(false); continue; } - itemStackGroup.addWidget(new SlotWidget(itemOutputsHandler, slotIndex, ITEM_OUTPUT_LOCATIONS.getInt(i), - ITEM_OUTPUT_LOCATIONS.getInt(i + 1)) - .setCanTakeItems(false) - .setCanPutItems(false) - .setIngredientIO(FINAL_OUTPUT_INDICES.contains(i) ? IngredientIO.OUTPUT : IngredientIO.BOTH) - .setXEIChance(xeiChance) - .setOnAddedTooltips( - (slot, tooltips) -> recipeWrapper.getTooltip(slotIndex + itemInputs.size(), tooltips)) - .setBackground((IGuiTexture) null).setOverlay(overlay)); - itemOutputExists.add(true); + itemStackGroup.child(RecipeViewerSlotWidget.create() + .pos(ITEM_OUTPUT_LOCATIONS.getInt(i), ITEM_OUTPUT_LOCATIONS.getInt(i + 1)) + .recipeSlotRole(RecipeSlotRole.OUTPUT) + .tooltip(recipeWrapper.getTooltip(slotIndex + itemInputs.size())) + .overlay(overlay) + .value(itemOutputs.get(i/2))); } List fluidInputs = recipeWrapper.fluidInputs; - CycleFluidEntryHandler fluidInputsHandler = new CycleFluidEntryHandler(fluidInputs); - WidgetGroup fluidStackGroup = new WidgetGroup(); + ParentWidget fluidStackGroup = new ParentWidget<>().sizeRel(1f); for (int i = 0; i < FLUID_LOCATIONS.size(); i += 2) { int slotIndex = i / 2; if (!fluidInputs.get(slotIndex).isEmpty()) { - var tank = new TankWidget(new CustomFluidTank(fluidInputsHandler.getFluidInTank(slotIndex)), - FLUID_LOCATIONS.getInt(i), FLUID_LOCATIONS.getInt(i + 1), false, false) - .setIngredientIO(IngredientIO.INPUT) - .setBackground(GuiTextures.FLUID_SLOT) - .setShowAmount(false); - fluidStackGroup.addWidget(tank); + fluidStackGroup.child(RecipeViewerSlotWidget.create() + .recipeSlotRole(RecipeSlotRole.INPUT) + .pos(FLUID_LOCATIONS.getInt(i), FLUID_LOCATIONS.getInt(i + 1)) + .value(fluidInputs.get(slotIndex)) + ); } } - this.addWidget(itemStackGroup); - this.addWidget(fluidStackGroup); - - for (int i = 0; i < ITEM_OUTPUT_LOCATIONS.size(); i += 2) { - // stupid hack to show all sifter slots if the first one exists - if (itemOutputExists.getBoolean(i / 2) || (i > 28 * 2 && itemOutputExists.getBoolean(28) && hasSifter)) { - addWidget(this.widgets.size() - 3, new ImageWidget(ITEM_OUTPUT_LOCATIONS.getInt(i), - ITEM_OUTPUT_LOCATIONS.getInt(i + 1), 18, 18, GuiTextures.SLOT)); - } - } + child(itemStackGroup); + child(fluidStackGroup); } } diff --git a/src/main/java/com/gregtechceu/gtceu/integration/recipeviewer/widgets/OreVeinRecipeWidget.java b/src/main/java/com/gregtechceu/gtceu/integration/recipeviewer/widgets/OreVeinRecipeWidget.java new file mode 100644 index 00000000000..816cf4cd331 --- /dev/null +++ b/src/main/java/com/gregtechceu/gtceu/integration/recipeviewer/widgets/OreVeinRecipeWidget.java @@ -0,0 +1,185 @@ +package com.gregtechceu.gtceu.integration.recipeviewer.widgets; + +import brachy.modularui.api.drawable.IDrawable; +import brachy.modularui.integration.recipeviewer.RecipeViewerSlotWidget; +import com.gregtechceu.gtceu.api.data.DimensionMarker; +import com.gregtechceu.gtceu.api.data.chemical.ChemicalHelper; +import com.gregtechceu.gtceu.api.data.tag.TagPrefix; +import com.gregtechceu.gtceu.api.data.worldgen.GTOreDefinition; +import com.gregtechceu.gtceu.api.data.worldgen.bedrockfluid.BedrockFluidDefinition; +import com.gregtechceu.gtceu.api.data.worldgen.bedrockore.BedrockOreDefinition; +import com.gregtechceu.gtceu.api.registry.GTRegistries; +import com.gregtechceu.gtceu.client.ClientProxy; +import com.gregtechceu.gtceu.config.ConfigHolder; + +import net.minecraft.core.NonNullList; +import net.minecraft.resources.ResourceKey; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.levelgen.heightproviders.HeightProvider; +import net.minecraft.world.level.levelgen.heightproviders.UniformHeight; +import net.minecraftforge.fluids.FluidStack; + +import brachy.modularui.api.drawable.Text; +import brachy.modularui.integration.recipeviewer.RecipeSlotRole; +import brachy.modularui.widget.ParentWidget; +import brachy.modularui.widgets.layout.Flow; +import it.unimi.dsi.fastutil.ints.IntList; +import org.jetbrains.annotations.Nullable; + +import java.util.*; +import java.util.stream.Stream; + +public class OreVeinRecipeWidget extends ParentWidget { + + private final String nameLang; + private final int weight; + private final @Nullable String range; + private final @Nullable Set> dimensionFilter; + public final static int WIDTH = 120; + + private OreVeinRecipeWidget(int width, int height, String nameLang, int weight, @Nullable String range, + @Nullable Set> dimensionFilter) { + size(width, height); + this.nameLang = nameLang; + this.weight = weight; + this.range = range; + this.dimensionFilter = dimensionFilter; + } + + public OreVeinRecipeWidget(BedrockFluidDefinition fluid) { + this(WIDTH, 140, getFluidName(fluid), fluid.getWeight(), null, fluid.dimensionFilter); + drawUI(Flow.row().coverChildren().child(RecipeViewerSlotWidget.create().value(new FluidStack(fluid.getStoredFluid().get(), 1000)).recipeSlotRole(RecipeSlotRole.OUTPUT))); + + } + + public OreVeinRecipeWidget(GTOreDefinition oreDefinition) { + this(WIDTH, 160, getOreName(oreDefinition), oreDefinition.weight(), range(oreDefinition), + oreDefinition.dimensionFilter()); + + NonNullList containedOresAsItemStacks = NonNullList.create(); + List chances = oreDefinition.veinGenerator().getAllChances(); + containedOresAsItemStacks.addAll(getRawMaterialList(oreDefinition)); + + var slots = Flow.row().coverChildren(); + for (int i = 0; i < containedOresAsItemStacks.size(); i++) { + RecipeViewerSlotWidget oreSlot = RecipeViewerSlotWidget.create().value(containedOresAsItemStacks.get(i)) + .recipeSlotRole(RecipeSlotRole.OUTPUT); + int finalI = i; + oreSlot.tooltipBuilder(r -> r.add(Text.lang("gtceu.jei.ore_vein_diagram.chance", chances.get(finalI)))); + slots.child(oreSlot); + } + drawUI(slots); + } + + public OreVeinRecipeWidget(BedrockOreDefinition bedrockOre) { + this(WIDTH, 140, getBedrockOreName(bedrockOre), bedrockOre.weight(), null, bedrockOre.dimensionFilter()); + + NonNullList containedOresAsItemStacks = NonNullList.create(); + IntList chances = bedrockOre.getAllChances(); + containedOresAsItemStacks.addAll(getRawMaterialList(bedrockOre)); + + var slots = Flow.row().coverChildren(); + for (int i = 0; i < containedOresAsItemStacks.size(); i++) { + RecipeViewerSlotWidget oreSlot = RecipeViewerSlotWidget.create().value(containedOresAsItemStacks.get(i)) + .recipeSlotRole(RecipeSlotRole.OUTPUT); + int finalI = i; + oreSlot.tooltipBuilder(r -> r.add(Text.lang("gtceu.jei.ore_vein_diagram.chance", chances.getInt(finalI)))); + slots.child(oreSlot); + } + drawUI(slots); + } + + private void drawUI(Flow contentsRow) { + var col = Flow.col().sizeRel(1f) + .child(Text.lang(nameLang).asWidget().marginBottom(3)) + .child(contentsRow.marginBottom(3)) + .childIf(range != null, () -> Text.lang("gtceu.jei.ore_vein_diagram.spawn_range").asWidget().marginBottom(1)) + .childIf(range != null, () -> Text.str(Objects.requireNonNull(range)).asWidget().marginBottom(3)) + .child(Text.lang("gtceu.jei.ore_vein_diagram.weight", weight).asWidget().marginBottom(3)) + .child(Text.lang("gtceu.jei.ore_vein_diagram.dimensions").asWidget()); + + if (this.dimensionFilter != null) { + + Flow row = Flow.row().coverChildren().padding(2); + + for (DimensionMarker dimMarker : getDimensionMarkers(dimensionFilter)) { + RecipeViewerSlotWidget dimSlot = RecipeViewerSlotWidget.create().value(dimMarker.getIcon()).recipeSlotRole(RecipeSlotRole.CATALYST).background(IDrawable.NONE); + if (ConfigHolder.INSTANCE.compat.showDimensionTier) { + dimSlot.overlay( + Text.str("T" + (dimMarker.tier >= DimensionMarker.MAX_TIER ? "?" : dimMarker.tier))); + } + row.child(dimSlot); + } + col.child(row); + } else { + col.child(Text.str("Any").asWidget()); + } + child(col); + } + + @SuppressWarnings("all") + private static String range(GTOreDefinition oreDefinition) { + HeightProvider height = oreDefinition.range().height; + int minHeight = 0, maxHeight = 0; + if (height instanceof UniformHeight uniform) { + minHeight = uniform.minInclusive.resolveY(null); + maxHeight = uniform.maxInclusive.resolveY(null); + } + return String.format("%d - %d", minHeight, maxHeight); + } + + public static List getContainedOresAndBlocks(GTOreDefinition oreDefinition) { + return oreDefinition.veinGenerator().getAllEntries().stream() + .flatMap(entry -> entry.map(state -> Stream.of(state.getBlock().asItem().getDefaultInstance()), + material -> { + Set ores = new HashSet<>(); + ores.add(ChemicalHelper.get(TagPrefix.rawOre, material)); + for (TagPrefix prefix : TagPrefix.ORES.keySet()) { + ores.add(ChemicalHelper.get(prefix, material)); + } + return ores.stream(); + })) + .toList(); + } + + public static List getRawMaterialList(GTOreDefinition oreDefinition) { + return oreDefinition.veinGenerator().getAllEntries().stream() + .map(entry -> entry.map(state -> state.getBlock().asItem().getDefaultInstance(), + material -> ChemicalHelper.get(TagPrefix.rawOre, material))) + .toList(); + } + + public static List getRawMaterialList(BedrockOreDefinition bedrockOreDefinition) { + return bedrockOreDefinition.materials().stream() + .map(entry -> ChemicalHelper.get(TagPrefix.rawOre, entry.material())) + .toList(); + } + + public static DimensionMarker[] getDimensionMarkers(Set> dimensionFilter) { + return dimensionFilter.stream() + .map(ResourceKey::location) + .map(loc -> GTRegistries.DIMENSION_MARKERS.getOrDefault(loc, + new DimensionMarker(DimensionMarker.MAX_TIER, () -> Blocks.BARRIER, loc.toString()))) + .sorted(Comparator.comparingInt(DimensionMarker::getTier)) + .toArray(DimensionMarker[]::new); + + } + + public static String getOreName(GTOreDefinition oreDefinition) { + ResourceLocation id = ClientProxy.CLIENT_ORE_VEINS.inverse().get(oreDefinition); + return "gtceu.jei.ore_vein." + id.getPath(); + } + + public static String getFluidName(BedrockFluidDefinition fluid) { + ResourceLocation id = ClientProxy.CLIENT_FLUID_VEINS.inverse().get(fluid); + return "gtceu.jei.bedrock_fluid." + id.getPath(); + } + + public static String getBedrockOreName(BedrockOreDefinition oreDefinition) { + ResourceLocation id = ClientProxy.CLIENT_BEDROCK_ORE_VEINS.inverse().get(oreDefinition); + return "gtceu.jei.bedrock_ore." + id.getPath(); + } +} diff --git a/src/main/java/com/gregtechceu/gtceu/integration/recipeviewer/widgets/ProgrammedCircuitRecipeWidget.java b/src/main/java/com/gregtechceu/gtceu/integration/recipeviewer/widgets/ProgrammedCircuitRecipeWidget.java new file mode 100644 index 00000000000..3122152ae4d --- /dev/null +++ b/src/main/java/com/gregtechceu/gtceu/integration/recipeviewer/widgets/ProgrammedCircuitRecipeWidget.java @@ -0,0 +1,27 @@ +package com.gregtechceu.gtceu.integration.recipeviewer.widgets; + +import brachy.modularui.integration.recipeviewer.RecipeViewerSlotWidget; +import com.gregtechceu.gtceu.api.transfer.item.CustomItemStackHandler; +import com.gregtechceu.gtceu.common.item.behavior.IntCircuitBehaviour; + +import brachy.modularui.integration.recipeviewer.RecipeSlotRole; +import brachy.modularui.widget.ParentWidget; +import brachy.modularui.widgets.layout.Grid; +import brachy.modularui.widgets.slot.ItemSlot; +import brachy.modularui.widgets.slot.ModularSlot; + +public class ProgrammedCircuitRecipeWidget extends ParentWidget { + + public ProgrammedCircuitRecipeWidget() { + super(); + size(150, 80); + + Grid circuits = new Grid() + .coverChildren() + .gridOfSizeWidth(32, 8, (x, y, i) -> RecipeViewerSlotWidget.create() + .recipeSlotRole(RecipeSlotRole.RENDER_ONLY) + .value(IntCircuitBehaviour.stack(i + 1))); + + child(circuits.center()); + } +} diff --git a/src/main/java/com/gregtechceu/gtceu/integration/rei/circuit/GTProgrammedCircuitCategory.java b/src/main/java/com/gregtechceu/gtceu/integration/rei/circuit/GTProgrammedCircuitCategory.java deleted file mode 100644 index b28c65433a8..00000000000 --- a/src/main/java/com/gregtechceu/gtceu/integration/rei/circuit/GTProgrammedCircuitCategory.java +++ /dev/null @@ -1,70 +0,0 @@ -package com.gregtechceu.gtceu.integration.rei.circuit; - -import com.gregtechceu.gtceu.GTCEu; -import com.gregtechceu.gtceu.common.data.GTItems; -import com.gregtechceu.gtceu.integration.recipeviewer.widgets.GTProgrammedCircuitWidget; - -import com.lowdragmc.lowdraglib.gui.texture.ItemStackTexture; -import com.lowdragmc.lowdraglib.gui.widget.WidgetGroup; -import com.lowdragmc.lowdraglib.rei.IGui2Renderer; -import com.lowdragmc.lowdraglib.rei.ModularDisplay; -import com.lowdragmc.lowdraglib.rei.ModularUIDisplayCategory; -import com.lowdragmc.lowdraglib.utils.Size; - -import net.minecraft.network.chat.Component; -import net.minecraft.resources.ResourceLocation; - -import lombok.Getter; -import me.shedaniel.rei.api.client.gui.Renderer; -import me.shedaniel.rei.api.common.category.CategoryIdentifier; - -import java.util.Optional; - -public class GTProgrammedCircuitCategory extends - ModularUIDisplayCategory { - - public static CategoryIdentifier CATEGORY = CategoryIdentifier - .of(GTCEu.id("programmed_circuit")); - - @Getter - private final Renderer icon; - @Getter - private final Size size; - - public GTProgrammedCircuitCategory() { - this.icon = IGui2Renderer.toDrawable(new ItemStackTexture(GTItems.PROGRAMMED_CIRCUIT.asItem())); - this.size = new Size(158, 80); - } - - @Override - public CategoryIdentifier getCategoryIdentifier() { - return CATEGORY; - } - - @Override - public Component getTitle() { - return Component.translatable("gtceu.jei.programmed_circuit"); - } - - @Override - public int getDisplayHeight() { - return getSize().height; - } - - @Override - public int getDisplayWidth(GTProgrammedCircuitDisplay display) { - return getSize().width; - } - - public static class GTProgrammedCircuitDisplay extends ModularDisplay { - - public GTProgrammedCircuitDisplay() { - super(GTProgrammedCircuitWidget::new, GTProgrammedCircuitCategory.CATEGORY); - } - - @Override - public Optional getDisplayLocation() { - return Optional.of(GTCEu.id("programmed_circuit")); - } - } -} diff --git a/src/main/java/com/gregtechceu/gtceu/integration/rei/multipage/MultiblockInfoDisplay.java b/src/main/java/com/gregtechceu/gtceu/integration/rei/multipage/MultiblockInfoDisplay.java deleted file mode 100644 index 89d21bee0c0..00000000000 --- a/src/main/java/com/gregtechceu/gtceu/integration/rei/multipage/MultiblockInfoDisplay.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.gregtechceu.gtceu.integration.rei.multipage; - -import com.gregtechceu.gtceu.api.gui.widget.PatternPreviewWidget; -import com.gregtechceu.gtceu.api.machine.MultiblockMachineDefinition; - -import com.lowdragmc.lowdraglib.gui.widget.WidgetGroup; -import com.lowdragmc.lowdraglib.rei.ModularDisplay; - -import net.minecraft.resources.ResourceLocation; - -import java.util.Optional; - -public class MultiblockInfoDisplay extends ModularDisplay { - - public final MultiblockMachineDefinition definition; - - public MultiblockInfoDisplay(MultiblockMachineDefinition definition) { - super(() -> PatternPreviewWidget.getPatternWidget(definition), MultiblockInfoDisplayCategory.CATEGORY); - this.definition = definition; - } - - @Override - public Optional getDisplayLocation() { - return Optional.of(definition.getId()); - } -} diff --git a/src/main/java/com/gregtechceu/gtceu/integration/rei/oreprocessing/GTOreProcessingDisplay.java b/src/main/java/com/gregtechceu/gtceu/integration/rei/oreprocessing/GTOreProcessingDisplay.java deleted file mode 100644 index a0b17b42ab2..00000000000 --- a/src/main/java/com/gregtechceu/gtceu/integration/rei/oreprocessing/GTOreProcessingDisplay.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.gregtechceu.gtceu.integration.rei.oreprocessing; - -import com.gregtechceu.gtceu.api.data.chemical.material.Material; -import com.gregtechceu.gtceu.integration.recipeviewer.widgets.GTOreByProductWidget; - -import com.lowdragmc.lowdraglib.gui.widget.WidgetGroup; -import com.lowdragmc.lowdraglib.rei.ModularDisplay; - -import net.minecraft.resources.ResourceLocation; - -import java.util.Optional; - -public class GTOreProcessingDisplay extends ModularDisplay { - - private final Material material; - - public GTOreProcessingDisplay(Material material) { - super(() -> new GTOreByProductWidget(material), GTOreProcessingDisplayCategory.CATEGORY); - this.material = material; - } - - @Override - public Optional getDisplayLocation() { - return Optional.of(material.getResourceLocation()); - } -} diff --git a/src/main/java/com/gregtechceu/gtceu/integration/rei/orevein/GTBedrockFluidDisplay.java b/src/main/java/com/gregtechceu/gtceu/integration/rei/orevein/GTBedrockFluidDisplay.java deleted file mode 100644 index c7ca98bdeb7..00000000000 --- a/src/main/java/com/gregtechceu/gtceu/integration/rei/orevein/GTBedrockFluidDisplay.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.gregtechceu.gtceu.integration.rei.orevein; - -import com.gregtechceu.gtceu.api.data.worldgen.bedrockfluid.BedrockFluidDefinition; -import com.gregtechceu.gtceu.integration.recipeviewer.widgets.GTOreVeinWidget; - -import com.lowdragmc.lowdraglib.gui.widget.WidgetGroup; -import com.lowdragmc.lowdraglib.rei.ModularDisplay; - -import me.shedaniel.rei.api.common.entry.EntryIngredient; -import me.shedaniel.rei.api.common.util.EntryIngredients; - -import java.util.ArrayList; -import java.util.List; - -public class GTBedrockFluidDisplay extends ModularDisplay { - - private final BedrockFluidDefinition fluid; - - public GTBedrockFluidDisplay(BedrockFluidDefinition fluid) { - super(() -> new GTOreVeinWidget(fluid), GTBedrockFluidDisplayCategory.CATEGORY); - this.fluid = fluid; - } - - @Override - public List getOutputEntries() { - List outputs = new ArrayList<>(); - outputs.add(EntryIngredients.of(fluid.getStoredFluid().get())); - return outputs; - } -} diff --git a/src/main/java/com/gregtechceu/gtceu/integration/rei/orevein/GTBedrockOreDisplay.java b/src/main/java/com/gregtechceu/gtceu/integration/rei/orevein/GTBedrockOreDisplay.java deleted file mode 100644 index 43d10393d5f..00000000000 --- a/src/main/java/com/gregtechceu/gtceu/integration/rei/orevein/GTBedrockOreDisplay.java +++ /dev/null @@ -1,35 +0,0 @@ -package com.gregtechceu.gtceu.integration.rei.orevein; - -import com.gregtechceu.gtceu.api.data.chemical.ChemicalHelper; -import com.gregtechceu.gtceu.api.data.chemical.material.Material; -import com.gregtechceu.gtceu.api.data.tag.TagPrefix; -import com.gregtechceu.gtceu.api.data.worldgen.bedrockore.BedrockOreDefinition; -import com.gregtechceu.gtceu.integration.recipeviewer.widgets.GTOreVeinWidget; - -import com.lowdragmc.lowdraglib.gui.widget.WidgetGroup; -import com.lowdragmc.lowdraglib.rei.ModularDisplay; - -import me.shedaniel.rei.api.common.entry.EntryIngredient; -import me.shedaniel.rei.api.common.util.EntryIngredients; - -import java.util.ArrayList; -import java.util.List; - -public class GTBedrockOreDisplay extends ModularDisplay { - - private final BedrockOreDefinition bedrockOre; - - public GTBedrockOreDisplay(BedrockOreDefinition bedrockOre) { - super(() -> new GTOreVeinWidget(bedrockOre), GTBedrockOreDisplayCategory.CATEGORY); - this.bedrockOre = bedrockOre; - } - - @Override - public List getOutputEntries() { - List outputs = new ArrayList<>(); - for (Material material : bedrockOre.getAllMaterials()) { - outputs.add(EntryIngredients.of(ChemicalHelper.get(TagPrefix.rawOre, material))); - } - return outputs; - } -} diff --git a/src/main/java/com/gregtechceu/gtceu/integration/rei/orevein/GTBedrockOreDisplayCategory.java b/src/main/java/com/gregtechceu/gtceu/integration/rei/orevein/GTBedrockOreDisplayCategory.java deleted file mode 100644 index 07db738a459..00000000000 --- a/src/main/java/com/gregtechceu/gtceu/integration/rei/orevein/GTBedrockOreDisplayCategory.java +++ /dev/null @@ -1,73 +0,0 @@ -package com.gregtechceu.gtceu.integration.rei.orevein; - -import com.gregtechceu.gtceu.GTCEu; -import com.gregtechceu.gtceu.api.data.worldgen.bedrockore.BedrockOreDefinition; -import com.gregtechceu.gtceu.client.ClientProxy; -import com.gregtechceu.gtceu.common.data.GTItems; -import com.gregtechceu.gtceu.common.data.GTMaterials; -import com.gregtechceu.gtceu.integration.recipeviewer.widgets.GTOreVeinWidget; - -import com.lowdragmc.lowdraglib.gui.texture.ItemStackTexture; -import com.lowdragmc.lowdraglib.rei.IGui2Renderer; -import com.lowdragmc.lowdraglib.rei.ModularUIDisplayCategory; -import com.lowdragmc.lowdraglib.utils.Size; - -import net.minecraft.network.chat.Component; - -import lombok.Getter; -import me.shedaniel.rei.api.client.gui.Renderer; -import me.shedaniel.rei.api.client.registry.category.CategoryRegistry; -import me.shedaniel.rei.api.client.registry.display.DisplayRegistry; -import me.shedaniel.rei.api.common.category.CategoryIdentifier; -import me.shedaniel.rei.api.common.util.EntryStacks; -import org.jetbrains.annotations.NotNull; - -@Getter -public class GTBedrockOreDisplayCategory extends ModularUIDisplayCategory { - - public static final CategoryIdentifier CATEGORY = CategoryIdentifier - .of(GTCEu.id("bedrock_ore_diagram")); - - private final Renderer icon; - - private final Size size; - - public GTBedrockOreDisplayCategory() { - this.icon = IGui2Renderer.toDrawable(new ItemStackTexture(GTMaterials.Oil.getFluid().getBucket().asItem())); - this.size = new Size(10 + GTOreVeinWidget.width, 140); - } - - @Override - public CategoryIdentifier getCategoryIdentifier() { - return CATEGORY; - } - - @Override - public int getDisplayHeight() { - return getSize().height; - } - - @Override - public int getDisplayWidth(GTBedrockOreDisplay display) { - return getSize().width; - } - - @NotNull - @Override - public Component getTitle() { - return Component.translatable("gtceu.jei.bedrock_ore_diagram"); - } - - public static void registerDisplays(DisplayRegistry registry) { - for (BedrockOreDefinition fluid : ClientProxy.CLIENT_BEDROCK_ORE_VEINS.values()) { - registry.add(new GTBedrockOreDisplay(fluid)); - } - } - - public static void registerWorkstations(CategoryRegistry registry) { - registry.addWorkstations(GTBedrockOreDisplayCategory.CATEGORY, - EntryStacks.of(GTItems.PROSPECTOR_HV.asStack())); - registry.addWorkstations(GTBedrockOreDisplayCategory.CATEGORY, - EntryStacks.of(GTItems.PROSPECTOR_LuV.asStack())); - } -} diff --git a/src/main/java/com/gregtechceu/gtceu/integration/rei/orevein/GTOreVeinDisplay.java b/src/main/java/com/gregtechceu/gtceu/integration/rei/orevein/GTOreVeinDisplay.java deleted file mode 100644 index ffd68cfb57e..00000000000 --- a/src/main/java/com/gregtechceu/gtceu/integration/rei/orevein/GTOreVeinDisplay.java +++ /dev/null @@ -1,34 +0,0 @@ -package com.gregtechceu.gtceu.integration.rei.orevein; - -import com.gregtechceu.gtceu.api.data.worldgen.GTOreDefinition; -import com.gregtechceu.gtceu.integration.recipeviewer.widgets.GTOreVeinWidget; - -import com.lowdragmc.lowdraglib.gui.widget.WidgetGroup; -import com.lowdragmc.lowdraglib.rei.ModularDisplay; - -import net.minecraft.world.item.ItemStack; - -import me.shedaniel.rei.api.common.entry.EntryIngredient; -import me.shedaniel.rei.api.common.util.EntryIngredients; - -import java.util.ArrayList; -import java.util.List; - -public class GTOreVeinDisplay extends ModularDisplay { - - private final GTOreDefinition oreDefinition; - - public GTOreVeinDisplay(GTOreDefinition oreDefinition) { - super(() -> new GTOreVeinWidget(oreDefinition), GTOreVeinDisplayCategory.CATEGORY); - this.oreDefinition = oreDefinition; - } - - @Override - public List getOutputEntries() { - List ingredients = new ArrayList<>(); - for (ItemStack output : GTOreVeinWidget.getContainedOresAndBlocks(oreDefinition)) { - ingredients.add(EntryIngredients.of(output)); - } - return ingredients; - } -} diff --git a/src/main/java/com/gregtechceu/gtceu/utils/input/SyncedKeyMapping.java b/src/main/java/com/gregtechceu/gtceu/utils/input/SyncedKeyMapping.java index 7e630c44192..639f551f822 100644 --- a/src/main/java/com/gregtechceu/gtceu/utils/input/SyncedKeyMapping.java +++ b/src/main/java/com/gregtechceu/gtceu/utils/input/SyncedKeyMapping.java @@ -46,8 +46,8 @@ public final class SyncedKeyMapping { private static final Int2BooleanMap updatingKeyDown = new Int2BooleanOpenHashMap(); private final WeakHashMap serverMapping = new WeakHashMap<>(); - private final WeakHashMap> playerListeners = new WeakHashMap<>(); - private final Set globalListeners = Collections.newSetFromMap(new WeakHashMap<>()); + private final WeakHashMap> playerListeners = new WeakHashMap<>(); + private final Set globalListeners = Collections.newSetFromMap(new WeakHashMap<>()); private SyncedKeyMapping(Supplier> mcKeyMapping) { if (GTCEu.isClientSide()) { @@ -172,15 +172,15 @@ private boolean isKeyDownClient() { } /** - * Registers an {@link IKeyPressedListener} to this key, which will have its {@link IKeyPressedListener#onKeyPressed + * Registers an {@link TextPressedListener} to this key, which will have its {@link TextPressedListener#onKeyPressed * onKeyPressed} method called when the provided player presses this key. * * @param player The player who owns this listener. * @param listener The handler for the key clicked event. */ public @NotNull SyncedKeyMapping registerPlayerListener(@NotNull ServerPlayer player, - @NotNull IKeyPressedListener listener) { - Set listenerSet = playerListeners + @NotNull TextPressedListener listener) { + Set listenerSet = playerListeners .computeIfAbsent(player, $ -> Collections.newSetFromMap(new WeakHashMap<>())); listenerSet.add(listener); return this; @@ -205,20 +205,20 @@ public static void onRegisterKeyBinds(@NotNull RegisterKeyMappingsEvent event) { * @param player The player who owns this listener. * @param listener The handler for the key clicked event. */ - public void removePlayerListener(@NotNull ServerPlayer player, @NotNull IKeyPressedListener listener) { - Set listenerSet = playerListeners.get(player); + public void removePlayerListener(@NotNull ServerPlayer player, @NotNull TextPressedListener listener) { + Set listenerSet = playerListeners.get(player); if (listenerSet != null) { listenerSet.remove(listener); } } /** - * Registers an {@link IKeyPressedListener} to this key, which will have its {@link IKeyPressedListener#onKeyPressed + * Registers an {@link TextPressedListener} to this key, which will have its {@link TextPressedListener#onKeyPressed * onKeyPressed} method called when any player presses this key. * * @param listener The handler for the key clicked event. */ - public @NotNull SyncedKeyMapping registerGlobalListener(@NotNull IKeyPressedListener listener) { + public @NotNull SyncedKeyMapping registerGlobalListener(@NotNull TextPressedListener listener) { globalListeners.add(listener); return this; } @@ -228,7 +228,7 @@ public void removePlayerListener(@NotNull ServerPlayer player, @NotNull IKeyPres * * @param listener The handler for the key clicked event. */ - public void removeGlobalListener(@NotNull IKeyPressedListener listener) { + public void removeGlobalListener(@NotNull TextPressedListener listener) { globalListeners.remove(listener); } @@ -264,14 +264,14 @@ public void serverActivate(boolean keyDown, ServerPlayer player) { this.serverMapping.put(player, keyDown); // Player listeners - Set listenerSet = playerListeners.get(player); + Set listenerSet = playerListeners.get(player); if (listenerSet != null && !listenerSet.isEmpty()) { - for (IKeyPressedListener listener : listenerSet) { + for (TextPressedListener listener : listenerSet) { listener.onKeyPressed(player, this, keyDown); } } // Global listeners - for (IKeyPressedListener listener : globalListeners) { + for (TextPressedListener listener : globalListeners) { listener.onKeyPressed(player, this, keyDown); } } diff --git a/src/main/java/com/gregtechceu/gtceu/utils/input/IKeyPressedListener.java b/src/main/java/com/gregtechceu/gtceu/utils/input/TextPressedListener.java similarity index 91% rename from src/main/java/com/gregtechceu/gtceu/utils/input/IKeyPressedListener.java rename to src/main/java/com/gregtechceu/gtceu/utils/input/TextPressedListener.java index c7857530e9b..2607d06f1df 100644 --- a/src/main/java/com/gregtechceu/gtceu/utils/input/IKeyPressedListener.java +++ b/src/main/java/com/gregtechceu/gtceu/utils/input/TextPressedListener.java @@ -3,7 +3,7 @@ import net.minecraft.server.level.ServerPlayer; @FunctionalInterface -public interface IKeyPressedListener { +public interface TextPressedListener { /** * Called server-side only when a player presses a specified keybinding. diff --git a/src/main/resources/assets/gtceu/ui/recipe_type/forge_hammer.rtui b/src/main/resources/assets/gtceu/ui/recipe_type/forge_hammer.rtui deleted file mode 100644 index dfcad283b78..00000000000 Binary files a/src/main/resources/assets/gtceu/ui/recipe_type/forge_hammer.rtui and /dev/null differ diff --git a/src/main/resources/assets/gtceu/ui/recipe_type/lathe.rtui b/src/main/resources/assets/gtceu/ui/recipe_type/lathe.rtui deleted file mode 100644 index c4d0acc5f9a..00000000000 Binary files a/src/main/resources/assets/gtceu/ui/recipe_type/lathe.rtui and /dev/null differ diff --git a/src/test/java/com/gregtechceu/gtceu/api/recipe/ingredient/IntProviderFluidIngredientTest.java b/src/test/java/com/gregtechceu/gtceu/api/recipe/ingredient/IntProviderFluidIngredientTest.java index c5969ab5b0d..a7a558b462c 100644 --- a/src/test/java/com/gregtechceu/gtceu/api/recipe/ingredient/IntProviderFluidIngredientTest.java +++ b/src/test/java/com/gregtechceu/gtceu/api/recipe/ingredient/IntProviderFluidIngredientTest.java @@ -284,7 +284,7 @@ public static void singleblockRangedFluidOutputSabotaged(GameTestHelper helper) helper.runAfterDelay(2, () -> { if (machine.getRecipeLogic().getLastRecipe().getOutputContents(FluidRecipeCapability.CAP).get(0) - .getContent() instanceof IntProviderFluidIngredient ingredient) { + .content() instanceof IntProviderFluidIngredient ingredient) { ingredient.setSampledCount(0); if (ingredient.getSampledCount() != 0) { diff --git a/src/test/java/com/gregtechceu/gtceu/api/recipe/ingredient/IntProviderIngredientTest.java b/src/test/java/com/gregtechceu/gtceu/api/recipe/ingredient/IntProviderIngredientTest.java index f3b7bee123a..ff30bfd0aca 100644 --- a/src/test/java/com/gregtechceu/gtceu/api/recipe/ingredient/IntProviderIngredientTest.java +++ b/src/test/java/com/gregtechceu/gtceu/api/recipe/ingredient/IntProviderIngredientTest.java @@ -278,7 +278,7 @@ public static void singleblockRangedItemOutputSabotaged(GameTestHelper helper) { helper.runAfterDelay(2, () -> { if (machine.getRecipeLogic().getLastRecipe().getOutputContents(ItemRecipeCapability.CAP).get(0) - .getContent() instanceof IntProviderIngredient ingredient) { + .content() instanceof IntProviderIngredient ingredient) { ingredient.setSampledCount(0); if (ingredient.getSampledCount() != 0) { diff --git a/src/test/java/com/gregtechceu/gtceu/api/recipe/lookup/GTRecipeLookupTest.java b/src/test/java/com/gregtechceu/gtceu/api/recipe/lookup/GTRecipeLookupTest.java index dcd992640e5..affb882c9be 100644 --- a/src/test/java/com/gregtechceu/gtceu/api/recipe/lookup/GTRecipeLookupTest.java +++ b/src/test/java/com/gregtechceu/gtceu/api/recipe/lookup/GTRecipeLookupTest.java @@ -172,7 +172,7 @@ public static void recipeLookupCustomCountCanHandleTest(GameTestHelper helper) { recipe -> recipe.inputs .getOrDefault(ItemRecipeCapability.CAP, List.of()) .stream() - .allMatch(content -> ((SizedIngredient) content.getContent()).getAmount() > 4)); + .allMatch(content -> ((SizedIngredient) content.content()).getAmount() > 4)); helper.assertTrue(SMELT_CHERRY_WOOD.equals(resultRecipe), "GT Recipe should be smelt_cherry_wood, instead was " + resultRecipe); @@ -181,7 +181,7 @@ public static void recipeLookupCustomCountCanHandleTest(GameTestHelper helper) { resultRecipe = DB.find(ingredients, recipe -> recipe.inputs .getOrDefault(ItemRecipeCapability.CAP, List.of()) .stream() - .allMatch(content -> ((SizedIngredient) content.getContent()).getAmount() > 32)); + .allMatch(content -> ((SizedIngredient) content.content()).getAmount() > 32)); helper.assertTrue(resultRecipe == null, "GT Recipe should be empty (null), instead was " + resultRecipe); helper.succeed();