diff --git a/docs/content/Modpacks/Changes/v8.0.0.md b/docs/content/Modpacks/Changes/v8.0.0.md index af2a7b18ccb..6d4e394dccd 100644 --- a/docs/content/Modpacks/Changes/v8.0.0.md +++ b/docs/content/Modpacks/Changes/v8.0.0.md @@ -15,7 +15,8 @@ Many aspects of the machine classes have been refactored and changed in order to - The `MetaMachineBlockEntity`(MMBE) class has been removed, and `MetaMachine`(MM) is now a BlockEntity. - Most methods and properties of MMBE have been moved onto MM. -- The `IMachineBlockEntity` interface has been removed. Use `MetaMachineBlock` directly instead. +- The `IMachineBlock` interface has been removed. Use `MetaMachineBlock` directly instead. +- The `IMachineBlockEntity` interface has been removed. Use `MetaMachine` directly instead. - Many methods common to all block entities have been moved to the `IGregtechBlockEntity` interface. - Machine instance creation functions have signature `(BlockEntityCreationInfo) -> MetaMachine` instead of `(IMachineBlockEntity) -> MetaMachine` diff --git a/docs/content/Modpacks/Materials-and-Elements/TagPrefixes-and-the-power-of-.setIgnored().md b/docs/content/Modpacks/Materials-and-Elements/TagPrefixes-and-the-power-of-.setIgnored().md index 5438349be25..5ab5c122912 100644 --- a/docs/content/Modpacks/Materials-and-Elements/TagPrefixes-and-the-power-of-.setIgnored().md +++ b/docs/content/Modpacks/Materials-and-Elements/TagPrefixes-and-the-power-of-.setIgnored().md @@ -76,3 +76,25 @@ GTCEuStartupEvents.materialModification(event => { // (1) The `Material` for which you are adjusting the TagPrefix must be registered in GTCEu Modern's material registry; if this material is custom, this is done using `GTCEuStartupEvents.registry()`, as depicted in these docs. + + +## What about fluids? + +Fluids are treated differently to items, their inclusion in a material is a property rather than a TagPrefix or MaterialFlag. +This makes replacing the fluid of a material with a fluid that you or another mod have created require a different approach than setIgnored. +The way to do this is using `GTFluids.handleNonMaterialFluids()` which can be found in the [``GTFluids`` class](https://github.com/GregTechCEu/GregTech-Modern/blob/1.20.1/src/main/java/com/gregtechceu/gtceu/common/data/GTFluids.java) + +`GTFluids.handleNonMaterialFluids()` takes in a `Material` and a `Fluid` or `Supplier` to replace the liquid of the material with the provided fluid. +Assure that the material is registered with a liquid before attempting to replace it with your new fluid. An example is below. + +!!! note "This may differ!" + Depending on the way your fluid is registered you may need to change how you pass the `Fluid` argument, check how it is registered in the mod you are working with. + +```java title="ExampleMaterials.java" +public static void register() { + GLUGG_BRINE = new Material.Builder(MyMod.id("glugg_brine")) + .liquid(new FluidBuilder()).buildAndRegister(); + + GTFluids.handleNonMaterialFluids(GLUGG_BRINE, () -> PVFluidRegistry.BRINE_FLUID_SOURCE.get()); +} +``` diff --git a/gradle/forge.versions.toml b/gradle/forge.versions.toml index 318d42572b5..631f7acc2b1 100644 --- a/gradle/forge.versions.toml +++ b/gradle/forge.versions.toml @@ -3,9 +3,9 @@ registrate = "MC1.21-1.3.0+67" configuration = "3.1.1-neoforge" jei = "19.25.1.328" rei = "16.0.799" -emi = "1.1.22+1.21.1" +emi = "1.1.24+1.21.1" ae2 = "19.2.8" -mui = "3.3.0-SNAPSHOT" +mui = "3.3.1-SNAPSHOT" kubejs = "2101.7.2-build.336" rhino = "2101.2.7-build.81" architectury = "13.0.8" diff --git a/src/main/java/com/gregtechceu/gtceu/api/block/MetaMachineBlock.java b/src/main/java/com/gregtechceu/gtceu/api/block/MetaMachineBlock.java index 876174f8fbb..a6d69976879 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/block/MetaMachineBlock.java +++ b/src/main/java/com/gregtechceu/gtceu/api/block/MetaMachineBlock.java @@ -289,8 +289,9 @@ protected ItemInteractionResult useItemOn(ItemStack stack, BlockState state, Lev InteractionResult machineInteractResult = InteractionResult.PASS; - if (!itemStack.isEmpty()) + if (!itemStack.isEmpty()) { machineInteractResult = machine.onUseWithItem(new ExtendedUseOnContext(player, hand, hit)); + } if (machineInteractResult != InteractionResult.PASS) return getFromInteractionResult(machineInteractResult); machineInteractResult = machine.onUse(new ExtendedUseOnContext(player, hand, hit)); if (machineInteractResult != InteractionResult.PASS) return getFromInteractionResult(machineInteractResult); diff --git a/src/main/java/com/gregtechceu/gtceu/api/cover/filter/FilterHandler.java b/src/main/java/com/gregtechceu/gtceu/api/cover/filter/FilterHandler.java index 9ff9aed219d..2109df03609 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/cover/filter/FilterHandler.java +++ b/src/main/java/com/gregtechceu/gtceu/api/cover/filter/FilterHandler.java @@ -100,6 +100,7 @@ public int getSlotLimit(int slot) { }; this.filterSlot.setFilter(this::canInsertFilterItem); + this.filterSlot.setOnContentsChanged(this::updateFilter); } return this.filterSlot; @@ -107,7 +108,6 @@ public int getSlotLimit(int slot) { public void setFilterItem(ItemStack item) { getFilterSlot().setStackInSlot(0, item); - updateFilter(); } private void updateFilter() { 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 46839877a96..d152c2d08d9 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 @@ -101,9 +101,7 @@ public Flow getFilterUI(GuiData data, PanelSyncManager syncManager, UISettings s .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); - }).ignoreMaxStackSize(true).accessibility(true, false)))); + .ignoreMaxStackSize(true).accessibility(true, false)))); BooleanSyncValue blacklist = new BooleanSyncValue(this::isBlackList, this::setBlackList).allowC2S(); syncManager.syncValue("blacklist", blacklist); 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 6c09f38dbf0..dcbe171c7a6 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 @@ -4,9 +4,12 @@ import com.gregtechceu.gtceu.api.machine.MetaMachine; import com.gregtechceu.gtceu.api.machine.feature.IVoidable; import com.gregtechceu.gtceu.api.machine.feature.multiblock.IDistinctPart; +import com.gregtechceu.gtceu.api.machine.multiblock.WorkableElectricMultiblockMachine; import com.gregtechceu.gtceu.api.machine.multiblock.WorkableMultiblockMachine; import com.gregtechceu.gtceu.api.machine.steam.SimpleSteamMachine; import com.gregtechceu.gtceu.api.machine.trait.feature.IAttachConfiguratorsTrait; +import com.gregtechceu.gtceu.api.recipe.modifier.RecipeModifierList; +import com.gregtechceu.gtceu.common.data.GTRecipeModifiers; import com.gregtechceu.gtceu.common.mui.GTGuiTextures; import com.gregtechceu.gtceu.common.mui.GTMuiWidgets; import com.gregtechceu.gtceu.common.mui.widgets.SteamDialWidget; @@ -27,6 +30,7 @@ import lombok.Setter; import lombok.experimental.Accessors; +import java.util.Arrays; import java.util.function.Consumer; @Accessors(fluent = true) @@ -86,6 +90,11 @@ public MachineUIPanel build(PanelSyncManager syncManager, UISettings settings) { attachRight.childIf(distinctPart.supportsDistinct(), () -> GTMuiWidgets.createDistinctnessButton(distinctPart)); } + if (machine.getDefinition().getRecipeModifier() instanceof RecipeModifierList rml && + Arrays.stream(rml.getModifiers()).anyMatch(m -> m == GTRecipeModifiers.BATCH_MODE) && + machine instanceof WorkableElectricMultiblockMachine workableElectric) { + attachRight.child(GTMuiWidgets.createBatchModeButton(workableElectric)); + } } leftConfigurators.accept(attachLeft); diff --git a/src/main/java/com/gregtechceu/gtceu/api/machine/trait/notifiable/NotifiableFluidTank.java b/src/main/java/com/gregtechceu/gtceu/api/machine/trait/notifiable/NotifiableFluidTank.java index c285ff7a21b..f5ea7b18495 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/machine/trait/notifiable/NotifiableFluidTank.java +++ b/src/main/java/com/gregtechceu/gtceu/api/machine/trait/notifiable/NotifiableFluidTank.java @@ -67,6 +67,7 @@ public NotifiableFluidTank(int slots, int capacity, IO io, IO capabilityIO) { this.storages[i] = new CustomFluidTank(capacity); this.storages[i].setOnContentsChanged(this::onContentsChanged); } + this.lockedFluid.setOnContentsChanged(this::onLockedFluidChanged); } public NotifiableFluidTank(List storages, IO io, IO capabilityIO) { @@ -80,6 +81,7 @@ public NotifiableFluidTank(List storages, IO io, IO capabilityI if (io == IO.IN) { this.allowSameFluids = true; } + this.lockedFluid.setOnContentsChanged(this::onLockedFluidChanged); } public NotifiableFluidTank(int slots, int capacity, IO io) { @@ -96,6 +98,26 @@ public void onContentsChanged() { notifyListeners(); } + protected void onLockedFluidChanged() { + syncDataHolder.markClientSyncFieldDirty("lockedFluid"); + var newFluid = this.lockedFluid.getFluid(); + if (newFluid.isEmpty()) { + this.setFilter(stack -> true); + this.onContentsChanged(); + return; + } + for (int i = 0; i < this.getTanks(); i++) { + if (this.getFluidInTank(i).isEmpty()) continue; + if (!this.getFluidInTank(i).isFluidEqual(newFluid)) { + // Fluid in a tank that doesn't equal the new locked fluid + this.lockedFluid.setFluid(FluidStack.EMPTY); + return; + } + } + this.setFilter(stack -> stack.isFluidEqual(newFluid)); + this.onContentsChanged(); + } + @Override public List handleRecipeInner(IO io, GTRecipe recipe, List left, diff --git a/src/main/java/com/gregtechceu/gtceu/api/placeholder/MultiLineComponent.java b/src/main/java/com/gregtechceu/gtceu/api/placeholder/MultiLineComponent.java index 156e1ea13c6..3f52a0695e1 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/placeholder/MultiLineComponent.java +++ b/src/main/java/com/gregtechceu/gtceu/api/placeholder/MultiLineComponent.java @@ -1,6 +1,8 @@ package com.gregtechceu.gtceu.api.placeholder; import net.minecraft.ChatFormatting; +import net.minecraft.core.HolderLookup; +import net.minecraft.nbt.*; import net.minecraft.network.chat.*; import com.mojang.serialization.Codec; @@ -10,7 +12,6 @@ import lombok.experimental.Accessors; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import org.jetbrains.annotations.UnmodifiableView; import java.util.*; import java.util.ArrayList; @@ -177,6 +178,7 @@ public MultiLineComponent withStyle(UnaryOperator