From 77e7b3b339e3478d72ad42a4b9a2c36bd543fde7 Mon Sep 17 00:00:00 2001 From: Quetz4l Date: Tue, 27 Feb 2024 18:24:20 +0200 Subject: [PATCH] add new solidifier hatches for industrial multi machine (#810) * add new solidifier hatches for multi machine * Update GT_MetaTileEntity_Hatch_Solidifier.java --------- Co-authored-by: Martin Robertz --- .../core/recipe/RECIPES_Machines.java | 23 +++ .../gregtech/api/enums/GregtechItemList.java | 6 + .../GT_MetaTileEntity_Hatch_Solidifier.java | 70 +++++++++ ...MetaTileEntity_IndustrialMultiMachine.java | 141 ++++++++++++++++++ .../gregtech/GregtechCustomHatches.java | 22 ++- 5 files changed, 261 insertions(+), 1 deletion(-) create mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Solidifier.java diff --git a/src/main/java/gtPlusPlus/core/recipe/RECIPES_Machines.java b/src/main/java/gtPlusPlus/core/recipe/RECIPES_Machines.java index e09c98f303..4df59ebd81 100644 --- a/src/main/java/gtPlusPlus/core/recipe/RECIPES_Machines.java +++ b/src/main/java/gtPlusPlus/core/recipe/RECIPES_Machines.java @@ -251,6 +251,7 @@ private static void run() { thermicFluidHeater(); advHeatExchanger(); chiselBuses(); + solidifierHatches(); gt4FarmManager(); gt4Inventory(); @@ -3040,4 +3041,26 @@ private static void chiselBuses() { } } + private static void solidifierHatches() { + ItemStack[] mSuperBusesInput = new ItemStack[] { ItemList.Hatch_Input_IV.get(1), + ItemList.Hatch_Input_LuV.get(1), ItemList.Hatch_Input_ZPM.get(1), ItemList.Hatch_Input_UV.get(1), }; + + ItemStack[] mSolidifierHatches = new ItemStack[] { GregtechItemList.GT_MetaTileEntity_Solidifier_I.get(1), + GregtechItemList.GT_MetaTileEntity_Solidifier_II.get(1), + GregtechItemList.GT_MetaTileEntity_Solidifier_III.get(1), + GregtechItemList.GT_MetaTileEntity_Solidifier_IV.get(1), }; + + for (int i = 0; i < 4; i++) { + int componentTier = i + 5; + CORE.RA.addSixSlotAssemblingRecipe( + new ItemStack[] { CI.getNumberedCircuit(17), mSuperBusesInput[i], CI.getSensor(componentTier, 1), + CI.getFluidRegulator(componentTier, 1), + CI.getTieredComponent(OrePrefixes.circuit, componentTier + 1, 4), + ItemUtils.getSimpleStack(Blocks.chest) }, + CI.getTieredFluid(componentTier, 144 * 2), + mSolidifierHatches[i], + 20 * 30, + (int) GT_Values.VP[componentTier]); + } + } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java index 480672f9f9..41ccecbbff 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java @@ -560,6 +560,12 @@ public enum GregtechItemList implements GregtechItemContainer { GT_MetaTileEntity_ChiselBus_MV, GT_MetaTileEntity_ChiselBus_HV, + // Solidifier Hatches for Industrial Multi Machine + GT_MetaTileEntity_Solidifier_I, + GT_MetaTileEntity_Solidifier_II, + GT_MetaTileEntity_Solidifier_III, + GT_MetaTileEntity_Solidifier_IV, + // ---------------------------------------------------------------------------- /** diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Solidifier.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Solidifier.java new file mode 100644 index 0000000000..d8811a72f7 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Solidifier.java @@ -0,0 +1,70 @@ +package gtPlusPlus.xmod.gregtech.api.metatileentity.implementations; + +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumChatFormatting; + +import com.gtnewhorizons.modularui.api.screen.ModularWindow; +import com.gtnewhorizons.modularui.api.screen.UIBuildContext; +import com.gtnewhorizons.modularui.common.widget.SlotWidget; + +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Input; +import gregtech.api.util.GT_Utility; + +public class GT_MetaTileEntity_Hatch_Solidifier extends GT_MetaTileEntity_Hatch_Input { + + static final int moldSlot = 2; + + public GT_MetaTileEntity_Hatch_Solidifier(int aID, String aName, String aNameRegional, int aTier) { + super(aID, aName, aNameRegional, aTier); + } + + @Override + public String[] getDescription() { + return new String[] { + "Fluid Input with Mold for " + EnumChatFormatting.YELLOW + + "Large Processing Factory" + + EnumChatFormatting.RESET, + "#22 Circuit is imprinted in Hatch", "Capacity: " + GT_Utility.formatNumbers(getCapacity()) + "L", + "Added by: " + EnumChatFormatting.AQUA + + "Quetz4l" + + " - " + + EnumChatFormatting.RED + + "[GT++]" + + EnumChatFormatting.RESET }; + } + + public GT_MetaTileEntity_Hatch_Solidifier(String aName, int aTier, String[] aDescription, + ITexture[][][] aTextures) { + super(aName, getSlots(aTier), aTier, aDescription, aTextures); + } + + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GT_MetaTileEntity_Hatch_Solidifier(mName, mTier, mDescriptionArray, mTextures); + } + + public ItemStack getMold() { + return this.getStackInSlot(moldSlot); + } + + @Override + public void addUIWidgets(ModularWindow.Builder builder, UIBuildContext buildContext) { + super.addUIWidgets(builder, buildContext); + builder.widget(new SlotWidget(inventoryHandler, moldSlot).setPos(125, 35).setSize(18, 18)); + } + + @Override + public void onBlockDestroyed() { + super.onBlockDestroyed(); + } + + // for a drop-down form when the hatch is destroyed + @Override + public boolean isValidSlot(int aIndex) { + if (aIndex == moldSlot) return true; + else return super.isValidSlot(aIndex); + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialMultiMachine.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialMultiMachine.java index ebbae1f4b6..efbf5f2fee 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialMultiMachine.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialMultiMachine.java @@ -11,11 +11,13 @@ import static gregtech.api.enums.GT_HatchElement.OutputBus; import static gregtech.api.enums.GT_HatchElement.OutputHatch; import static gregtech.api.util.GT_StructureUtility.buildHatchAdder; +import static gregtech.api.util.GT_Utility.filterValidMTEs; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.List; +import java.util.Optional; import java.util.stream.Stream; import javax.annotation.Nonnull; @@ -30,7 +32,9 @@ import net.minecraft.util.StatCollector; import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.FluidStack; +import com.google.common.collect.Lists; import com.gtnewhorizon.structurelib.alignment.constructable.ISurvivalConstructable; import com.gtnewhorizon.structurelib.structure.IStructureDefinition; import com.gtnewhorizon.structurelib.structure.ISurvivalBuildEnvironment; @@ -41,16 +45,26 @@ import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.logic.ProcessingLogic; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Input; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_InputBus; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_MultiInput; import gregtech.api.recipe.RecipeMap; import gregtech.api.recipe.RecipeMaps; +import gregtech.api.recipe.check.CheckRecipeResult; +import gregtech.api.recipe.check.CheckRecipeResultRegistry; import gregtech.api.util.GT_LanguageManager; import gregtech.api.util.GT_Multiblock_Tooltip_Builder; import gregtech.api.util.GT_Recipe; import gregtech.api.util.GT_Utility; +import gregtech.common.tileentities.machines.GT_MetaTileEntity_Hatch_Input_ME; +import gregtech.common.tileentities.machines.IDualInputHatch; +import gregtech.common.tileentities.machines.IDualInputInventory; import gtPlusPlus.core.block.ModBlocks; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.recipe.common.CI; +import gtPlusPlus.core.util.minecraft.ItemUtils; import gtPlusPlus.core.util.minecraft.PlayerUtils; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Solidifier; import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; import mcp.mobius.waila.api.IWailaConfigHandler; @@ -127,6 +141,9 @@ protected GT_Multiblock_Tooltip_Builder createTooltip() { + aBuiltStrings[2] + EnumChatFormatting.RESET) .addInfo("Read Multi-Machine Manual for extra information") + .addInfo( + EnumChatFormatting.AQUA + "You can use Solidifier Hatch to solidify multiple liquids." + + EnumChatFormatting.RESET) .addPollutionAmount(getPollutionPerSecond(null)).addSeparator().beginStructureBlock(3, 3, 3, true) .addController("Front Center").addCasingInfoMin("Multi-Use Casings", 6, false) .addInputBus("Any Casing", 1).addOutputBus("Any Casing", 1).addInputHatch("Any Casing", 1) @@ -362,6 +379,130 @@ public void getWailaNBTData(EntityPlayerMP player, TileEntity tile, NBTTagCompou tag.setInteger("mode", mInternalMode); } + @Override + protected CheckRecipeResult doCheckRecipe() { + + if (mInternalMode != 2 || !isInputSeparationEnabled()) { + return super.doCheckRecipe(); + } else { + CheckRecipeResult result = CheckRecipeResultRegistry.NO_RECIPE; + + // check crafting input hatches first + if (supportsCraftingMEBuffer()) { + for (IDualInputHatch dualInputHatch : mDualInputHatches) { + for (var it = dualInputHatch.inventories(); it.hasNext();) { + IDualInputInventory slot = it.next(); + processingLogic.setInputItems(slot.getItemInputs()); + processingLogic.setInputFluids(slot.getFluidInputs()); + CheckRecipeResult foundResult = processingLogic.process(); + if (foundResult.wasSuccessful()) { + return foundResult; + } + if (foundResult != CheckRecipeResultRegistry.NO_RECIPE) { + // Recipe failed in interesting way, so remember that and continue searching + result = foundResult; + } + } + } + } + + // Logic for GT_MetaTileEntity_Hatch_Solidifier + for (GT_MetaTileEntity_Hatch_Input solidifierHatch : mInputHatches) { + if (solidifierHatch instanceof GT_MetaTileEntity_Hatch_Solidifier) { + ItemStack mold = ((GT_MetaTileEntity_Hatch_Solidifier) solidifierHatch).getMold(); + FluidStack fluid = solidifierHatch.getFluid(); + + if (mold != null && fluid != null) { + List inputItems = new ArrayList<>(); + inputItems.add(mold); + inputItems.add(ItemUtils.getGregtechCircuit(22)); + + processingLogic.setInputItems(inputItems.toArray(new ItemStack[0])); + processingLogic.setInputFluids(fluid); + + CheckRecipeResult foundResult = processingLogic.process(); + if (foundResult.wasSuccessful()) { + return foundResult; + } + if (foundResult != CheckRecipeResultRegistry.NO_RECIPE) { + // Recipe failed in interesting way, so remember that and continue searching + result = foundResult; + } + } + } + } + processingLogic.clear(); + processingLogic.setInputFluids(getStoredFluids()); + // Default logic + for (GT_MetaTileEntity_Hatch_InputBus bus : mInputBusses) { + List inputItems = new ArrayList<>(); + for (int i = bus.getSizeInventory() - 1; i >= 0; i--) { + ItemStack stored = bus.getStackInSlot(i); + if (stored != null) { + inputItems.add(stored); + } + } + if (canUseControllerSlotForRecipe() && getControllerSlot() != null) { + inputItems.add(getControllerSlot()); + } + processingLogic.setInputItems(inputItems.toArray(new ItemStack[0])); + CheckRecipeResult foundResult = processingLogic.process(); + if (foundResult.wasSuccessful()) { + return foundResult; + } + if (foundResult != CheckRecipeResultRegistry.NO_RECIPE) { + // Recipe failed in interesting way, so remember that and continue searching + result = foundResult; + } + } + + return result; + } + } + + @Override + public ArrayList getStoredFluids() { + if (supportsCraftingMEBuffer()) { + for (IDualInputHatch tHatch : mDualInputHatches) { + if (tHatch.supportsFluids()) { + Optional inventory = tHatch.getFirstNonEmptyInventory(); + if (inventory.isPresent()) { + return Lists.newArrayList(inventory.get().getFluidInputs()); + } + } + } + } + + ArrayList rList = new ArrayList<>(); + for (GT_MetaTileEntity_Hatch_Input tHatch : filterValidMTEs(mInputHatches)) { + if (tHatch instanceof GT_MetaTileEntity_Hatch_Solidifier) { + continue; + } + + setHatchRecipeMap(tHatch); + if (tHatch instanceof GT_MetaTileEntity_Hatch_MultiInput) { + for (FluidStack tFluid : ((GT_MetaTileEntity_Hatch_MultiInput) tHatch).getStoredFluid()) { + if (tFluid != null) { + rList.add(tFluid); + } + } + } else if (tHatch instanceof GT_MetaTileEntity_Hatch_Input_ME) { + if (isValidMetaTileEntity(tHatch)) { + for (FluidStack fluidStack : ((GT_MetaTileEntity_Hatch_Input_ME) tHatch).getStoredFluids()) { + if (fluidStack == null) continue; + rList.add(fluidStack); + } + } + } else { + if (tHatch.getFillableStack() != null) { + rList.add(tHatch.getFillableStack()); + } + } + } + + return rList; + } + @Override public void getWailaBody(ItemStack itemStack, List currentTip, IWailaDataAccessor accessor, IWailaConfigHandler config) { diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechCustomHatches.java b/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechCustomHatches.java index 4d9fb43733..8e498a1d3e 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechCustomHatches.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechCustomHatches.java @@ -11,6 +11,7 @@ import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Muffler_Adv; import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Naquadah; import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Reservoir; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Solidifier; import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_TurbineProvider; import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.GT_MetaTileEntity_SuperBus_Input; import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.GT_MetaTileEntity_SuperBus_Output; @@ -26,6 +27,7 @@ public static void run() { } run3(); run4(); // Chisel buses + run6(); // Solidifier hatches } private static void run1() { @@ -242,7 +244,7 @@ private static GT_MetaTileEntity_ChiselBus makeChiselBus(int id, String unlocali } private static void run4() { - int aID = 31778; + int aID = 31778; // 31778 - 31780 GregtechItemList.GT_MetaTileEntity_ChiselBus_LV .set((makeChiselBus(aID++, "hatch.chisel.tier.01", "Chisel Bus I", 1)).getStackForm(1L)); @@ -252,4 +254,22 @@ private static void run4() { .set((makeChiselBus(aID++, "hatch.chisel.tier.03", "Chisel Bus III", 3)).getStackForm(1L)); } + + private static void run6() { + int aID = 31781; // 31781-31784 + + GregtechItemList.GT_MetaTileEntity_Solidifier_I.set( + new GT_MetaTileEntity_Hatch_Solidifier(aID++, "hatch.solidifier.tier.05", "Solidifier Hatch I", 5) + .getStackForm(1L)); + GregtechItemList.GT_MetaTileEntity_Solidifier_II.set( + new GT_MetaTileEntity_Hatch_Solidifier(aID++, "hatch.solidifier.tier.06", "Solidifier Hatch II", 6) + .getStackForm(1L)); + GregtechItemList.GT_MetaTileEntity_Solidifier_III.set( + new GT_MetaTileEntity_Hatch_Solidifier(aID++, "hatch.solidifier.tier.07", "Solidifier Hatch III", 7) + .getStackForm(1L)); + GregtechItemList.GT_MetaTileEntity_Solidifier_IV.set( + new GT_MetaTileEntity_Hatch_Solidifier(aID, "hatch.solidifier.tier.08", "Solidifier Hatch IV", 8) + .getStackForm(1L)); + } + }