From ce2954eb8dfafb480e5be731a80c5990f9d3294d Mon Sep 17 00:00:00 2001 From: GDCloud Date: Fri, 27 Dec 2024 20:48:14 +0100 Subject: [PATCH 01/27] pcb nanite absorption --- .../machines/multi/MTEPCBFactory.java | 53 +++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/MTEPCBFactory.java b/src/main/java/gregtech/common/tileentities/machines/multi/MTEPCBFactory.java index 189bdd4640f..2de4628f836 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/MTEPCBFactory.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/MTEPCBFactory.java @@ -19,7 +19,10 @@ import static gregtech.api.util.GTStructureUtility.ofFrame; import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; import java.util.List; +import java.util.Map; import javax.annotation.Nonnull; @@ -73,6 +76,7 @@ import gregtech.api.metatileentity.implementations.MTEExtendedPowerMultiBlockBase; import gregtech.api.metatileentity.implementations.MTEHatch; import gregtech.api.metatileentity.implementations.MTEHatchInput; +import gregtech.api.metatileentity.implementations.MTEHatchInputBus; import gregtech.api.objects.ItemData; import gregtech.api.recipe.RecipeMap; import gregtech.api.recipe.RecipeMaps; @@ -92,6 +96,7 @@ import gregtech.api.util.ParallelHelper; import gregtech.api.util.shutdown.ShutDownReasonRegistry; import gregtech.common.blocks.BlockCasings8; +import gregtech.common.tileentities.machines.MTEHatchInputBusME; @SuppressWarnings("SpellCheckingInspection") public class MTEPCBFactory extends MTEExtendedPowerMultiBlockBase implements ISurvivalConstructable { @@ -108,6 +113,13 @@ public class MTEPCBFactory extends MTEExtendedPowerMultiBlockBase private int mUpgradesInstalled = 0; private final int mCurrentParallel = 0; private int mMaxParallel = 0; + private Map storedNanites = new HashMap<>() { + + { + put(Materials.Silver, 0); + put(Materials.Gold, 0); + } + }; private boolean mBioUpgrade = false, mBioRotate = false, mOCTier1 = false, mOCTier2 = false; private final int[] mBioOffsets = new int[] { -5, -1 }; private final int[] mOCTier1Offsets = new int[] { 2, -11 }; @@ -121,6 +133,8 @@ public class MTEPCBFactory extends MTEExtendedPowerMultiBlockBase private static final int mTier2BitMap = 0b10; private static final int mTier1BitMap = 0b1; private static final int COOLANT_CONSUMED_PER_SEC = 10; + private static final int MAX_NANITE_COUNT = 2048; + private static final List VALID_NANITE_MATERIALS = Arrays.asList(Materials.Silver, Materials.Gold); private static final IStructureDefinition STRUCTURE_DEFINITION = StructureDefinition .builder() .addShape( @@ -630,6 +644,45 @@ public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { // TODO: Look for proper fix // Updates every 10 sec if (mUpdate <= -150) mUpdate = 50; + + if (aTick % 100 == 0) { + for (MTEHatchInputBus inputBus : mInputBusses) { + ItemStack[] busInventory = inputBus.getRealInventory(); + for (int j = 0; j < busInventory.length; j++) { + ItemStack itemStack = busInventory[j]; + if (itemStack == null) { + continue; + } + ItemData data = GTOreDictUnificator.getAssociation(itemStack); + if (data == null) { + continue; + } + OrePrefixes prefix = data.mPrefix; + Materials mat = data.mMaterial.mMaterial; + if (storedNanites.get(mat) == 2048) { + continue; + } + if (prefix == OrePrefixes.nanite && VALID_NANITE_MATERIALS.contains(mat)) { + int stacksize = itemStack.stackSize; + startRecipeProcessing(); + if (inputBus instanceof MTEHatchInputBusME meBus) { + ItemStack realItem = meBus.getRealInventory()[j + 16]; + if (realItem == null) { + break; + } + stacksize = realItem.stackSize; + } + int storedNaniteAmount = storedNanites.get(mat); + int absorbedNanites = Math.min(stacksize, MAX_NANITE_COUNT - storedNaniteAmount); + inputBus.decrStackSize(j, absorbedNanites); + int updatedAmount = storedNaniteAmount + absorbedNanites; + storedNanites.put(mat, updatedAmount); + endRecipeProcessing(); + } + } + inputBus.updateSlots(); + } + } } } From 66796aa7a23d11d97723097447fae57b46d46e6b Mon Sep 17 00:00:00 2001 From: GDCloud Date: Fri, 27 Dec 2024 21:31:01 +0100 Subject: [PATCH 02/27] nbt handling --- .../machines/multi/MTEPCBFactory.java | 98 ++++++++++++------- 1 file changed, 63 insertions(+), 35 deletions(-) diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/MTEPCBFactory.java b/src/main/java/gregtech/common/tileentities/machines/multi/MTEPCBFactory.java index 2de4628f836..70822e9fc6e 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/MTEPCBFactory.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/MTEPCBFactory.java @@ -113,7 +113,7 @@ public class MTEPCBFactory extends MTEExtendedPowerMultiBlockBase private int mUpgradesInstalled = 0; private final int mCurrentParallel = 0; private int mMaxParallel = 0; - private Map storedNanites = new HashMap<>() { + private final Map storedNanites = new HashMap<>() { { put(Materials.Silver, 0); @@ -659,10 +659,10 @@ public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { } OrePrefixes prefix = data.mPrefix; Materials mat = data.mMaterial.mMaterial; - if (storedNanites.get(mat) == 2048) { - continue; - } if (prefix == OrePrefixes.nanite && VALID_NANITE_MATERIALS.contains(mat)) { + if (storedNanites.get(mat) == 2048) { + continue; + } int stacksize = itemStack.stackSize; startRecipeProcessing(); if (inputBus instanceof MTEHatchInputBusME meBus) { @@ -1005,41 +1005,69 @@ protected MultiblockTooltipBuilder createTooltip() { } @Override - public void saveNBTData(NBTTagCompound aNBT) { - super.saveNBTData(aNBT); - aNBT.setBoolean("mBioUpgrade", mBioUpgrade); - aNBT.setBoolean("mBioRotate", mBioRotate); - aNBT.setInteger("mBioOffsetX", mBioOffsets[0]); - aNBT.setInteger("mBioOffsetZ", mBioOffsets[1]); - aNBT.setBoolean("mOCTier1Upgrade", mOCTier1); - aNBT.setInteger("mOCTier1OffsetX", mOCTier1Offsets[0]); - aNBT.setInteger("mOCTier1OffsetZ", mOCTier1Offsets[1]); - aNBT.setBoolean("mOCTier2Upgrade", mOCTier2); - aNBT.setInteger("mOCTier2OffsetX", mOCTier2Offsets[0]); - aNBT.setInteger("mOCTier2OffsetZ", mOCTier2Offsets[1]); - aNBT.setFloat("mRoughnessMultiplier", mRoughnessMultiplier); - aNBT.setInteger("mSetTier", mSetTier); + public void setItemNBT(NBTTagCompound NBT) { + NBTTagCompound naniteTag = new NBTTagCompound(); + boolean empty = true; + for (Materials naniteMat : storedNanites.keySet()) { + int naniteAmount = storedNanites.get(naniteMat); + if (naniteAmount != 0) { + empty = false; + } + naniteTag.setInteger(naniteMat.toString(), naniteAmount); + } + if (!empty) { + NBT.setTag("storedNanites", naniteTag); + } + } + + @Override + public void saveNBTData(NBTTagCompound NBT) { + super.saveNBTData(NBT); + NBT.setBoolean("mBioUpgrade", mBioUpgrade); + NBT.setBoolean("mBioRotate", mBioRotate); + NBT.setInteger("mBioOffsetX", mBioOffsets[0]); + NBT.setInteger("mBioOffsetZ", mBioOffsets[1]); + NBT.setBoolean("mOCTier1Upgrade", mOCTier1); + NBT.setInteger("mOCTier1OffsetX", mOCTier1Offsets[0]); + NBT.setInteger("mOCTier1OffsetZ", mOCTier1Offsets[1]); + NBT.setBoolean("mOCTier2Upgrade", mOCTier2); + NBT.setInteger("mOCTier2OffsetX", mOCTier2Offsets[0]); + NBT.setInteger("mOCTier2OffsetZ", mOCTier2Offsets[1]); + NBT.setFloat("mRoughnessMultiplier", mRoughnessMultiplier); + NBT.setInteger("mSetTier", mSetTier); + + NBTTagCompound naniteTag = new NBTTagCompound(); + for (Materials naniteMat : storedNanites.keySet()) { + naniteTag.setInteger(naniteMat.toString(), storedNanites.get(naniteMat)); + } + NBT.setTag("storedNanites", naniteTag); } @Override - public void loadNBTData(final NBTTagCompound aNBT) { - super.loadNBTData(aNBT); - if (aNBT.hasKey("mSeparate")) { + public void loadNBTData(final NBTTagCompound NBT) { + super.loadNBTData(NBT); + if (NBT.hasKey("mSeparate")) { // backward compatibility - inputSeparation = aNBT.getBoolean("mSeparate"); + inputSeparation = NBT.getBoolean("mSeparate"); + } + mBioUpgrade = NBT.getBoolean("mBioUpgrade"); + mBioRotate = NBT.getBoolean("mBioRotate"); + mBioOffsets[0] = NBT.getInteger("mBioOffsetX"); + mBioOffsets[1] = NBT.getInteger("mBioOffsetZ"); + mOCTier1 = NBT.getBoolean("mOCTier1Upgrade"); + mOCTier1Offsets[0] = NBT.getInteger("mOCTier1OffsetX"); + mOCTier1Offsets[1] = NBT.getInteger("mOCTier1OffsetZ"); + mOCTier2 = NBT.getBoolean("mOCTier2Upgrade"); + mOCTier2Offsets[0] = NBT.getInteger("mOCTier2OffsetX"); + mOCTier2Offsets[1] = NBT.getInteger("mOCTier2OffsetZ"); + mRoughnessMultiplier = NBT.getFloat("mRoughnessMultiplier"); + mSetTier = NBT.getInteger("mSetTier"); + + NBTTagCompound naniteTag = NBT.getCompoundTag("storedNanites"); + for (Materials material : storedNanites.keySet()) { + int storedAmount = naniteTag.getInteger(material.toString()); + storedNanites.put(material, storedAmount); } - mBioUpgrade = aNBT.getBoolean("mBioUpgrade"); - mBioRotate = aNBT.getBoolean("mBioRotate"); - mBioOffsets[0] = aNBT.getInteger("mBioOffsetX"); - mBioOffsets[1] = aNBT.getInteger("mBioOffsetZ"); - mOCTier1 = aNBT.getBoolean("mOCTier1Upgrade"); - mOCTier1Offsets[0] = aNBT.getInteger("mOCTier1OffsetX"); - mOCTier1Offsets[1] = aNBT.getInteger("mOCTier1OffsetZ"); - mOCTier2 = aNBT.getBoolean("mOCTier2Upgrade"); - mOCTier2Offsets[0] = aNBT.getInteger("mOCTier2OffsetX"); - mOCTier2Offsets[1] = aNBT.getInteger("mOCTier2OffsetZ"); - mRoughnessMultiplier = aNBT.getFloat("mRoughnessMultiplier"); - mSetTier = aNBT.getInteger("mSetTier"); } @Override @@ -1059,7 +1087,7 @@ public byte getUpdateData() { data += mTier1BitMap; } else if (mSetTier == 2) { data += mTier2BitMap; - } else { + } else if (mSetTier == 3) { data += mTier3BitMap; } From f6183252d1f8a8174594f592bda7970208deb106 Mon Sep 17 00:00:00 2001 From: GDCloud Date: Fri, 27 Dec 2024 22:25:12 +0100 Subject: [PATCH 03/27] integrate into processinglogic and fix some nbt issues --- .../machines/multi/MTEPCBFactory.java | 35 ++++++++++--------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/MTEPCBFactory.java b/src/main/java/gregtech/common/tileentities/machines/multi/MTEPCBFactory.java index 70822e9fc6e..d7b824f4c4c 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/MTEPCBFactory.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/MTEPCBFactory.java @@ -134,6 +134,10 @@ public class MTEPCBFactory extends MTEExtendedPowerMultiBlockBase private static final int mTier1BitMap = 0b1; private static final int COOLANT_CONSUMED_PER_SEC = 10; private static final int MAX_NANITE_COUNT = 2048; + private static final int BIO_OFFSET_X = -5; + private static final int BIO_OFFSET_Y = -1; + private static final int COOLING_OFFSET_X = 2; + private static final int COOLING_OFFSET_Y = -11; private static final List VALID_NANITE_MATERIALS = Arrays.asList(Materials.Silver, Materials.Gold); private static final IStructureDefinition STRUCTURE_DEFINITION = StructureDefinition .builder() @@ -563,14 +567,13 @@ protected ProcessingLogic createProcessingLogic() { protected CheckRecipeResult validateRecipe(@Nonnull GTRecipe recipe) { // Here we check the dynamic parallels, which depend on the recipe int numberOfNanites = 0; - ItemStack aNanite = recipe.getRepresentativeInput(1); - ItemData naniteData = GTOreDictUnificator.getAssociation(aNanite); - if (naniteData != null && naniteData.mPrefix != null && naniteData.mPrefix.equals(OrePrefixes.nanite)) { - for (ItemStack aItem : inputItems) { - if (aItem != null && aItem.isItemEqual(aNanite)) { - numberOfNanites += aItem.stackSize; - } - } + ItemStack nanite = recipe.getRepresentativeInput(1); + ItemData naniteData = GTOreDictUnificator.getAssociation(nanite); + if (naniteData != null && naniteData.mMaterial != null + && naniteData.mPrefix != null + && naniteData.mPrefix.equals(OrePrefixes.nanite)) { + Materials mat = naniteData.mMaterial.mMaterial; + numberOfNanites = storedNanites.get(mat); } maxParallel = (int) Math.min(Math.max(Math.ceil(Math.pow(numberOfNanites, 0.75)), 1), 256); mMaxParallel = maxParallel; @@ -1052,16 +1055,16 @@ public void loadNBTData(final NBTTagCompound NBT) { } mBioUpgrade = NBT.getBoolean("mBioUpgrade"); mBioRotate = NBT.getBoolean("mBioRotate"); - mBioOffsets[0] = NBT.getInteger("mBioOffsetX"); - mBioOffsets[1] = NBT.getInteger("mBioOffsetZ"); + mBioOffsets[0] = NBT.hasKey("mRoughnessMultiplier") ? NBT.getInteger("mBioOffsetX") : BIO_OFFSET_X; + mBioOffsets[1] = NBT.hasKey("mRoughnessMultiplier") ? NBT.getInteger("mBioOffsetZ") : BIO_OFFSET_Y; mOCTier1 = NBT.getBoolean("mOCTier1Upgrade"); - mOCTier1Offsets[0] = NBT.getInteger("mOCTier1OffsetX"); - mOCTier1Offsets[1] = NBT.getInteger("mOCTier1OffsetZ"); + mOCTier1Offsets[0] = NBT.hasKey("mRoughnessMultiplier") ? NBT.getInteger("mOCTier1OffsetX") : COOLING_OFFSET_X; + mOCTier1Offsets[1] = NBT.hasKey("mRoughnessMultiplier") ? NBT.getInteger("mOCTier1OffsetZ") : COOLING_OFFSET_Y; mOCTier2 = NBT.getBoolean("mOCTier2Upgrade"); - mOCTier2Offsets[0] = NBT.getInteger("mOCTier2OffsetX"); - mOCTier2Offsets[1] = NBT.getInteger("mOCTier2OffsetZ"); - mRoughnessMultiplier = NBT.getFloat("mRoughnessMultiplier"); - mSetTier = NBT.getInteger("mSetTier"); + mOCTier2Offsets[0] = NBT.hasKey("mRoughnessMultiplier") ? NBT.getInteger("mOCTier2OffsetX") : COOLING_OFFSET_X; + mOCTier2Offsets[1] = NBT.hasKey("mRoughnessMultiplier") ? NBT.getInteger("mOCTier2OffsetZ") : COOLING_OFFSET_Y; + mRoughnessMultiplier = NBT.hasKey("mRoughnessMultiplier") ? NBT.getFloat("mRoughnessMultiplier") : 1; + mSetTier = NBT.hasKey("mRoughnessMultiplier") ? NBT.getInteger("mSetTier") : 1; NBTTagCompound naniteTag = NBT.getCompoundTag("storedNanites"); for (Materials material : storedNanites.keySet()) { From d17646f4c2dab29f4e4042f4e8f8bd9244408b31 Mon Sep 17 00:00:00 2001 From: GDCloud Date: Sat, 28 Dec 2024 00:53:43 +0100 Subject: [PATCH 04/27] make recipes work via stored nanites --- .../java/gregtech/api/recipe/RecipeMaps.java | 7 +++ .../gregtech/api/util/GTRecipeConstants.java | 6 ++ .../machines/multi/MTEPCBFactory.java | 16 +++--- .../loaders/postload/MachineRecipeLoader.java | 2 + .../chains/PCBFactoryRecipesNoNanites.java | 55 +++++++++++++++++++ src/main/java/gregtech/nei/NEIGTConfig.java | 1 + .../resources/assets/gregtech/lang/en_US.lang | 1 + 7 files changed, 80 insertions(+), 8 deletions(-) create mode 100644 src/main/java/gregtech/loaders/postload/chains/PCBFactoryRecipesNoNanites.java diff --git a/src/main/java/gregtech/api/recipe/RecipeMaps.java b/src/main/java/gregtech/api/recipe/RecipeMaps.java index 31c4ce8b249..5fcf924db9b 100644 --- a/src/main/java/gregtech/api/recipe/RecipeMaps.java +++ b/src/main/java/gregtech/api/recipe/RecipeMaps.java @@ -1102,11 +1102,18 @@ && isArrayEmptyOrNull(b.getFluidOutputs()) .minInputs(3, 1) .progressBar(GTUITextures.PROGRESSBAR_ASSEMBLE) .disableOptimize() + .neiHandlerInfo(builder -> builder.setDisplayStack(ItemList.PCBFactory.get(1))) .neiRecipeComparator( Comparator .comparing(recipe -> recipe.getMetadataOrDefault(PCBFactoryTierKey.INSTANCE, 1)) .thenComparing(GTRecipe::compareTo)) .build(); + public static final RecipeMap pcbFactoryRecipesNoNanites = RecipeMapBuilder + .of("gt.recipe.pcbfactorynonanites") + .maxIO(6, 9, 3, 0) + .minInputs(3, 1) + .disableOptimize() + .build(); public static final RecipeMap purificationClarifierRecipes = RecipeMapBuilder .of("gt.recipe.purificationplantclarifier") .maxIO(1, 4, 1, 1) diff --git a/src/main/java/gregtech/api/util/GTRecipeConstants.java b/src/main/java/gregtech/api/util/GTRecipeConstants.java index 9b7916d5126..f9172df39e1 100644 --- a/src/main/java/gregtech/api/util/GTRecipeConstants.java +++ b/src/main/java/gregtech/api/util/GTRecipeConstants.java @@ -113,6 +113,12 @@ public class GTRecipeConstants { public static final RecipeMetadataKey NANO_FORGE_TIER = SimpleRecipeMetadataKey .create(Integer.class, "nano_forge_tier"); + /** + * PCB Factory nanite material + */ + public static final RecipeMetadataKey PCB_NANITE_MATERIAL = SimpleRecipeMetadataKey + .create(Materials.class, "pcb_nanite_material"); + /** * FOG Exotic recipe tier. */ diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/MTEPCBFactory.java b/src/main/java/gregtech/common/tileentities/machines/multi/MTEPCBFactory.java index d7b824f4c4c..9e3f2499430 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/MTEPCBFactory.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/MTEPCBFactory.java @@ -90,6 +90,7 @@ import gregtech.api.util.GTModHandler; import gregtech.api.util.GTOreDictUnificator; import gregtech.api.util.GTRecipe; +import gregtech.api.util.GTRecipeConstants; import gregtech.api.util.GTUtility; import gregtech.api.util.MultiblockTooltipBuilder; import gregtech.api.util.OverclockCalculator; @@ -555,7 +556,7 @@ public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack a @Override public RecipeMap getRecipeMap() { - return RecipeMaps.pcbFactoryRecipes; + return RecipeMaps.pcbFactoryRecipesNoNanites; } @Override @@ -567,13 +568,12 @@ protected ProcessingLogic createProcessingLogic() { protected CheckRecipeResult validateRecipe(@Nonnull GTRecipe recipe) { // Here we check the dynamic parallels, which depend on the recipe int numberOfNanites = 0; - ItemStack nanite = recipe.getRepresentativeInput(1); - ItemData naniteData = GTOreDictUnificator.getAssociation(nanite); - if (naniteData != null && naniteData.mMaterial != null - && naniteData.mPrefix != null - && naniteData.mPrefix.equals(OrePrefixes.nanite)) { - Materials mat = naniteData.mMaterial.mMaterial; - numberOfNanites = storedNanites.get(mat); + Materials naniteMaterial = recipe.getMetadata(GTRecipeConstants.PCB_NANITE_MATERIAL); + if (naniteMaterial != null) { + numberOfNanites = storedNanites.get(naniteMaterial); + if (numberOfNanites == 0) { + return SimpleCheckRecipeResult.ofFailure("nanites_missing"); + } } maxParallel = (int) Math.min(Math.max(Math.ceil(Math.pow(numberOfNanites, 0.75)), 1), 256); mMaxParallel = maxParallel; diff --git a/src/main/java/gregtech/loaders/postload/MachineRecipeLoader.java b/src/main/java/gregtech/loaders/postload/MachineRecipeLoader.java index c64ea6cf7b5..be8c5ffb6b3 100644 --- a/src/main/java/gregtech/loaders/postload/MachineRecipeLoader.java +++ b/src/main/java/gregtech/loaders/postload/MachineRecipeLoader.java @@ -4,6 +4,7 @@ import gregtech.loaders.postload.chains.BauxiteRefineChain; import gregtech.loaders.postload.chains.NaniteChain; import gregtech.loaders.postload.chains.PCBFactoryRecipes; +import gregtech.loaders.postload.chains.PCBFactoryRecipesNoNanites; import gregtech.loaders.postload.chains.PurifiedWaterRecipes; import gregtech.loaders.postload.recipes.AlloySmelterRecipes; import gregtech.loaders.postload.recipes.ArcFurnaceRecipes; @@ -121,6 +122,7 @@ public void run() { BauxiteRefineChain.run(); NaniteChain.run(); PCBFactoryRecipes.load(); + PCBFactoryRecipesNoNanites.load(); PurifiedWaterRecipes.run(); } } diff --git a/src/main/java/gregtech/loaders/postload/chains/PCBFactoryRecipesNoNanites.java b/src/main/java/gregtech/loaders/postload/chains/PCBFactoryRecipesNoNanites.java new file mode 100644 index 00000000000..44fdd275924 --- /dev/null +++ b/src/main/java/gregtech/loaders/postload/chains/PCBFactoryRecipesNoNanites.java @@ -0,0 +1,55 @@ +package gregtech.loaders.postload.chains; + +import java.util.ArrayList; +import java.util.List; + +import net.minecraft.item.ItemStack; + +import gregtech.api.enums.GTValues; +import gregtech.api.enums.Materials; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.objects.ItemData; +import gregtech.api.recipe.RecipeMaps; +import gregtech.api.recipe.metadata.PCBFactoryTierKey; +import gregtech.api.util.GTOreDictUnificator; +import gregtech.api.util.GTRecipe; +import gregtech.api.util.GTRecipeBuilder; +import gregtech.api.util.GTRecipeConstants; + +public class PCBFactoryRecipesNoNanites { + + private static final PCBFactoryTierKey TIER = PCBFactoryTierKey.INSTANCE; + + public static void load() { + for (GTRecipe recipe : RecipeMaps.pcbFactoryRecipes.getAllRecipes()) { + List itemInputs = new ArrayList<>(); + + Materials naniteMaterial = null; + for (int i = 0; i < recipe.mInputs.length; i++) { + ItemStack stack = recipe.getRepresentativeInput(i); + if (stack == null) continue; + ItemData data = GTOreDictUnificator.getAssociation(stack); + if (data != null && data.mPrefix != null && data.mPrefix.equals(OrePrefixes.nanite)) { + naniteMaterial = data.mMaterial.mMaterial; + continue; + } + itemInputs.add(stack); + } + + GTRecipeBuilder builder = GTValues.RA.stdBuilder() + .noOptimize() + .itemInputs(itemInputs.toArray(new ItemStack[0])) + .itemOutputs(recipe.mOutputs) + .fluidInputs(recipe.mFluidInputs) + .duration(recipe.mDuration) + .eut(recipe.mEUt) + .hidden() + .metadata(TIER, recipe.getMetadata(TIER)); + + if (naniteMaterial != null) { + builder.metadata(GTRecipeConstants.PCB_NANITE_MATERIAL, naniteMaterial); + } + builder.addTo(RecipeMaps.pcbFactoryRecipesNoNanites); + } + } +} diff --git a/src/main/java/gregtech/nei/NEIGTConfig.java b/src/main/java/gregtech/nei/NEIGTConfig.java index ab81530e1fe..ec0bd165d17 100644 --- a/src/main/java/gregtech/nei/NEIGTConfig.java +++ b/src/main/java/gregtech/nei/NEIGTConfig.java @@ -103,6 +103,7 @@ private void registerCatalysts() { API.addRecipeCatalyst( GTModHandler.getIC2Item("nuclearReactor", 1, null), RecipeMaps.ic2NuclearFakeRecipes.unlocalizedName); + API.addRecipeCatalyst(ItemList.PCBFactory.get(1), RecipeMaps.pcbFactoryRecipes.unlocalizedName); } private void registerItemEntries() { diff --git a/src/main/resources/assets/gregtech/lang/en_US.lang b/src/main/resources/assets/gregtech/lang/en_US.lang index 78ea8d1d537..f3ff62d6823 100644 --- a/src/main/resources/assets/gregtech/lang/en_US.lang +++ b/src/main/resources/assets/gregtech/lang/en_US.lang @@ -524,6 +524,7 @@ GT5U.gui.text.cycle_idle=§6Waiting for cycle to start GT5U.gui.text.fuel_quality_too_high=§7Fuel quality too high to run without boost GT5U.gui.text.no_data_sticks=§7No Data Sticks found GT5U.gui.text.bio_upgrade_missing=§7Recipe needs Bio Upgrade to start +GT5U.gui.text.nanites_missing=§7Missing nanites GT5U.gui.text.electromagnet_missing=§7Needs an Electromagnet to run GT5U.gui.text.electromagnet_insufficient=§7Electromagnet too weak to handle multi-amp energy hatches GT5U.gui.text.laser_insufficient=§7Laser source is too weak to run this recipe From 59440354e4957b323f244267906e9eba90442107 Mon Sep 17 00:00:00 2001 From: GDCloud Date: Sun, 29 Dec 2024 18:19:05 +0100 Subject: [PATCH 05/27] add NC hatch base and nanite hatch --- .../java/gregtech/api/enums/ItemList.java | 1 + .../gregtech/api/enums/MetaTileEntityIDs.java | 1 + .../implementations/MTEHatchNanite.java | 60 ++++++ .../MTEHatchNonConsumableBase.java | 188 ++++++++++++++++++ .../preload/LoaderMetaTileEntities.java | 3 + 5 files changed, 253 insertions(+) create mode 100644 src/main/java/gregtech/api/metatileentity/implementations/MTEHatchNanite.java create mode 100644 src/main/java/gregtech/api/metatileentity/implementations/MTEHatchNonConsumableBase.java diff --git a/src/main/java/gregtech/api/enums/ItemList.java b/src/main/java/gregtech/api/enums/ItemList.java index f3ed791eb21..2a3b2aec80d 100644 --- a/src/main/java/gregtech/api/enums/ItemList.java +++ b/src/main/java/gregtech/api/enums/ItemList.java @@ -2593,6 +2593,7 @@ public enum ItemList implements IItemContainer { ResearchCompleter, SpaceElevatorController, // Populated in GTNH-Intergalactic Spray_Color_Infinite, + Hatch_Nanite, // semicolon after the comment to reduce merge conflicts ; diff --git a/src/main/java/gregtech/api/enums/MetaTileEntityIDs.java b/src/main/java/gregtech/api/enums/MetaTileEntityIDs.java index 4e7c28a2bda..c2fc8060f63 100644 --- a/src/main/java/gregtech/api/enums/MetaTileEntityIDs.java +++ b/src/main/java/gregtech/api/enums/MetaTileEntityIDs.java @@ -856,6 +856,7 @@ public enum MetaTileEntityIDs { PURIFICATION_UNIT_DEGASIFIER(9412), HATCH_DEGASIFIER_CONTROL(9413), PURIFICATION_UNIT_PARTICLE_EXTRACTOR(9414), + HATCH_NANITE(9415), PLASMA_GENERATOR_ZPM(10752), PLASMA_GENERATOR_UV(10753), ALLOY_SMELTER_LuV(10760), diff --git a/src/main/java/gregtech/api/metatileentity/implementations/MTEHatchNanite.java b/src/main/java/gregtech/api/metatileentity/implementations/MTEHatchNanite.java new file mode 100644 index 00000000000..04630b0a227 --- /dev/null +++ b/src/main/java/gregtech/api/metatileentity/implementations/MTEHatchNanite.java @@ -0,0 +1,60 @@ +package gregtech.api.metatileentity.implementations; + +import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_EMS_HOUSING; +import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_EMS_HOUSING_GLOW; + +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.render.TextureFactory; + +public class MTEHatchNanite extends MTEHatchNonConsumableBase { + + private int naniteCapacity = 0; + + public MTEHatchNanite(int ID, String name, String nameRegional, int tier, int itemCapacity) { + super(ID, name, nameRegional, tier, "Holds nanites for use in multiblocks"); + naniteCapacity = itemCapacity; + } + + public MTEHatchNanite(String name, String[] description, ITexture[][][] textures, int tier, int itemCapacity) { + super(name, tier, description, textures); + naniteCapacity = itemCapacity; + } + + @Override + protected int getItemCapacity() { + return naniteCapacity; + } + + @Override + public ITexture[] getTexturesActive(ITexture aBaseTexture) { + return new ITexture[] { aBaseTexture, TextureFactory.builder() + .addIcon(OVERLAY_EMS_HOUSING) + .extFacing() + .build(), + TextureFactory.builder() + .addIcon(OVERLAY_EMS_HOUSING_GLOW) + .extFacing() + .glow() + .build() }; + } + + @Override + public ITexture[] getTexturesInactive(ITexture aBaseTexture) { + return new ITexture[] { aBaseTexture, TextureFactory.builder() + .addIcon(OVERLAY_EMS_HOUSING) + .extFacing() + .build(), + TextureFactory.builder() + .addIcon(OVERLAY_EMS_HOUSING_GLOW) + .extFacing() + .glow() + .build() }; + } + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new MTEHatchNanite(mName, mDescriptionArray, mTextures, mTier, naniteCapacity); + } +} diff --git a/src/main/java/gregtech/api/metatileentity/implementations/MTEHatchNonConsumableBase.java b/src/main/java/gregtech/api/metatileentity/implementations/MTEHatchNonConsumableBase.java new file mode 100644 index 00000000000..bf4796f35a7 --- /dev/null +++ b/src/main/java/gregtech/api/metatileentity/implementations/MTEHatchNonConsumableBase.java @@ -0,0 +1,188 @@ +package gregtech.api.metatileentity.implementations; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraftforge.common.util.ForgeDirection; + +import com.gtnewhorizons.modularui.api.screen.ModularWindow; +import com.gtnewhorizons.modularui.api.screen.UIBuildContext; +import com.gtnewhorizons.modularui.common.widget.DrawableWidget; +import com.gtnewhorizons.modularui.common.widget.FakeSyncWidget; +import com.gtnewhorizons.modularui.common.widget.SlotWidget; +import com.gtnewhorizons.modularui.common.widget.TextWidget; + +import gregtech.api.gui.modularui.GTUIInfos; +import gregtech.api.gui.modularui.GTUITextures; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.util.GTUtility; + +public abstract class MTEHatchNonConsumableBase extends MTEHatch { + + private ItemStack itemStack = null; + private int itemCount = 0; + + public MTEHatchNonConsumableBase(int ID, String name, String nameRegional, int tier, String description) { + super(ID, name, nameRegional, tier, 3, description); + } + + public MTEHatchNonConsumableBase(String name, int tier, String[] description, ITexture[][][] textures) { + super(name, tier, 3, description, textures); + } + + @Override + public boolean isSimpleMachine() { + return true; + } + + @Override + public boolean isFacingValid(ForgeDirection facing) { + return true; + } + + protected int clientItemCount; + + @Override + public void addUIWidgets(ModularWindow.Builder builder, UIBuildContext buildContext) { + builder.widget( + new DrawableWidget().setDrawable(GTUITextures.PICTURE_SCREEN_BLACK) + .setPos(7, 16) + .setSize(71, 45)) + .widget( + new SlotWidget(inventoryHandler, 0) + .setBackground(getGUITextureSet().getItemSlot(), GTUITextures.OVERLAY_SLOT_IN) + .setPos(79, 16)) + .widget( + new SlotWidget(inventoryHandler, 1).setAccess(true, false) + .setBackground(getGUITextureSet().getItemSlot(), GTUITextures.OVERLAY_SLOT_OUT) + .setPos(79, 52)) + .widget( + SlotWidget.phantom(inventoryHandler, 2) + .disableInteraction() + .setBackground(GTUITextures.TRANSPARENT) + .setPos(59, 42)) + .widget( + new TextWidget("Item Amount").setDefaultColor(COLOR_TEXT_WHITE.get()) + .setPos(10, 20)) + .widget( + new TextWidget().setStringSupplier(() -> numberFormat.format(clientItemCount)) + .setDefaultColor(COLOR_TEXT_WHITE.get()) + .setPos(10, 30)) + .widget(new FakeSyncWidget.IntegerSyncer(() -> itemCount, value -> clientItemCount = value)); + + } + + protected ItemStack getItemStack() { + return itemStack; + } + + protected void setItemStack(ItemStack stack) { + itemStack = stack; + } + + protected int getItemCount() { + return itemCount; + } + + @Override + public void setItemCount(int amount) { + itemCount = amount; + } + + protected abstract int getItemCapacity(); + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTimer) { + + if (getBaseMetaTileEntity().isServerSide() && getBaseMetaTileEntity().isAllowedToWork()) { + if ((getItemCount() <= 0)) { + setItemStack(null); + setItemCount(0); + } + if (getItemStack() == null && mInventory[0] != null) { + setItemStack(mInventory[0].copy()); + } + int count = getItemCount(); + ItemStack stack = getItemStack(); + int savedCount = count; + + if ((mInventory[0] != null) && ((count < getItemCapacity())) + && GTUtility.areStacksEqual(mInventory[0], stack)) { + count += mInventory[0].stackSize; + if (count <= getItemCapacity()) { + mInventory[0] = null; + } else { + mInventory[0].stackSize = (count - getItemCapacity()); + count = getItemCapacity(); + } + } + if (mInventory[1] == null && stack != null) { + mInventory[1] = stack.copy(); + mInventory[1].stackSize = Math.min(stack.getMaxStackSize(), count); + count -= mInventory[1].stackSize; + } else if ((count > 0) && GTUtility.areStacksEqual(mInventory[1], stack) + && mInventory[1].getMaxStackSize() > mInventory[1].stackSize) { + int tmp = Math.min(count, mInventory[1].getMaxStackSize() - mInventory[1].stackSize); + mInventory[1].stackSize += tmp; + count -= tmp; + } + setItemCount(count); + if (stack != null) { + mInventory[2] = stack.copy(); + mInventory[2].stackSize = Math.min(stack.getMaxStackSize(), count); + } else { + mInventory[2] = null; + } + + // notifyListeners(count - savedCount, stack); + if (count != savedCount) getBaseMetaTileEntity().markDirty(); + } + } + + @Override + public boolean isAccessAllowed(EntityPlayer aPlayer) { + return true; + } + + @Override + public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { + GTUIInfos.openGTTileEntityUI(aBaseMetaTileEntity, aPlayer); + return true; + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + aNBT.setInteger("itemCount", getItemCount()); + if (getItemStack() != null) aNBT.setTag("itemStack", getItemStack().writeToNBT(new NBTTagCompound())); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + if (aNBT.hasKey("itemCount")) setItemCount(aNBT.getInteger("itemCount")); + if (aNBT.hasKey("itemStack")) + setItemStack(ItemStack.loadItemStackFromNBT((NBTTagCompound) aNBT.getTag("itemStack"))); + } + + @Override + public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side, + ItemStack aStack) { + // if (GTValues.disableDigitalChestsExternalAccess && hasActiveMEConnection()) return false; + return aIndex == 1; + } + + @Override + public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side, + ItemStack aStack) { + // if (GTValues.disableDigitalChestsExternalAccess && hasActiveMEConnection()) return false; + if (aIndex != 0) return false; + if ((mInventory[0] != null && !GTUtility.areStacksEqual(mInventory[0], aStack))) return false; + if (getItemStack() == null) return mInventory[1] == null || GTUtility.areStacksEqual(mInventory[1], aStack); + return GTUtility.areStacksEqual(getItemStack(), aStack); + } + + @Override + public ItemStack[] getStoredItemData() { + return mInventory; + } +} diff --git a/src/main/java/gregtech/loaders/preload/LoaderMetaTileEntities.java b/src/main/java/gregtech/loaders/preload/LoaderMetaTileEntities.java index c02c1d94dfc..bca83b75727 100644 --- a/src/main/java/gregtech/loaders/preload/LoaderMetaTileEntities.java +++ b/src/main/java/gregtech/loaders/preload/LoaderMetaTileEntities.java @@ -956,6 +956,7 @@ import gregtech.api.metatileentity.implementations.MTEHatchMaintenance; import gregtech.api.metatileentity.implementations.MTEHatchMuffler; import gregtech.api.metatileentity.implementations.MTEHatchMultiInput; +import gregtech.api.metatileentity.implementations.MTEHatchNanite; import gregtech.api.metatileentity.implementations.MTEHatchOutput; import gregtech.api.metatileentity.implementations.MTEHatchOutputBus; import gregtech.api.metatileentity.implementations.MTEHatchQuadrupleHumongous; @@ -12974,6 +12975,8 @@ public void run() { ItemList.Hatch_LensIndicator.set( new MTEHatchLensIndicator(HATCH_LENS_INDICATOR.ID, "hatch.lensindicator", "Lens Indicator Hatch", 8) .getStackForm(1L)); + ItemList.Hatch_Nanite.set( + new MTEHatchNanite(HATCH_NANITE.ID, "hatch.nanite", "Nanite Containment Hatch", 8, 2048).getStackForm(1)); generateWiresAndPipes(); } From 9829f2b654b3fec2c92f87973f9b0a6ed0817ba2 Mon Sep 17 00:00:00 2001 From: GDCloud Date: Sun, 29 Dec 2024 18:48:10 +0100 Subject: [PATCH 06/27] add filtering --- .../implementations/MTEHatchNanite.java | 15 +++++++++++++++ .../MTEHatchNonConsumableBase.java | 4 +++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/main/java/gregtech/api/metatileentity/implementations/MTEHatchNanite.java b/src/main/java/gregtech/api/metatileentity/implementations/MTEHatchNanite.java index 04630b0a227..4d85a92121f 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/MTEHatchNanite.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/MTEHatchNanite.java @@ -3,10 +3,15 @@ import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_EMS_HOUSING; import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_EMS_HOUSING_GLOW; +import net.minecraft.item.ItemStack; + +import gregtech.api.enums.OrePrefixes; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.objects.ItemData; import gregtech.api.render.TextureFactory; +import gregtech.api.util.GTOreDictUnificator; public class MTEHatchNanite extends MTEHatchNonConsumableBase { @@ -27,6 +32,16 @@ protected int getItemCapacity() { return naniteCapacity; } + @Override + protected boolean isValidItem(ItemStack item) { + ItemData data = GTOreDictUnificator.getAssociation(item); + if (data == null) { + return false; + } + OrePrefixes prefix = data.mPrefix; + return prefix == OrePrefixes.nanite; + } + @Override public ITexture[] getTexturesActive(ITexture aBaseTexture) { return new ITexture[] { aBaseTexture, TextureFactory.builder() diff --git a/src/main/java/gregtech/api/metatileentity/implementations/MTEHatchNonConsumableBase.java b/src/main/java/gregtech/api/metatileentity/implementations/MTEHatchNonConsumableBase.java index bf4796f35a7..219df316a87 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/MTEHatchNonConsumableBase.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/MTEHatchNonConsumableBase.java @@ -92,6 +92,8 @@ public void setItemCount(int amount) { protected abstract int getItemCapacity(); + protected abstract boolean isValidItem(ItemStack item); + @Override public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTimer) { @@ -100,7 +102,7 @@ public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTimer) { setItemStack(null); setItemCount(0); } - if (getItemStack() == null && mInventory[0] != null) { + if (getItemStack() == null && mInventory[0] != null && isValidItem(mInventory[0])) { setItemStack(mInventory[0].copy()); } int count = getItemCount(); From 579420ee230b66e63e3600ad93e161c645897222 Mon Sep 17 00:00:00 2001 From: GDCloud Date: Sun, 29 Dec 2024 19:53:16 +0100 Subject: [PATCH 07/27] nanite hatch textures --- src/main/java/gregtech/api/enums/Textures.java | 4 +++- .../implementations/MTEHatchNanite.java | 12 +++++------- .../blocks/iconsets/OVERLAY_NANITE_HATCH.png | Bin 0 -> 492 bytes .../blocks/iconsets/OVERLAY_NANITE_HATCH_GLOW.png | Bin 0 -> 465 bytes 4 files changed, 8 insertions(+), 8 deletions(-) create mode 100644 src/main/resources/assets/gregtech/textures/blocks/iconsets/OVERLAY_NANITE_HATCH.png create mode 100644 src/main/resources/assets/gregtech/textures/blocks/iconsets/OVERLAY_NANITE_HATCH_GLOW.png diff --git a/src/main/java/gregtech/api/enums/Textures.java b/src/main/java/gregtech/api/enums/Textures.java index 39979445e51..2e7a0534aac 100644 --- a/src/main/java/gregtech/api/enums/Textures.java +++ b/src/main/java/gregtech/api/enums/Textures.java @@ -1460,7 +1460,9 @@ public enum BlockIcons implements IIconContainer, Runnable { NEUTRONIUM_STABLE_CASING, EXTREME_DENSITY_CASING, RADIATION_ABSORBENT_CASING, - HAWKING_GLASS; + HAWKING_GLASS, + OVERLAY_NANITE_HATCH, + OVERLAY_NANITE_HATCH_GLOW,; /** * Icon for Fresh CFoam diff --git a/src/main/java/gregtech/api/metatileentity/implementations/MTEHatchNanite.java b/src/main/java/gregtech/api/metatileentity/implementations/MTEHatchNanite.java index 4d85a92121f..e2aad52d3fc 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/MTEHatchNanite.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/MTEHatchNanite.java @@ -1,11 +1,9 @@ package gregtech.api.metatileentity.implementations; -import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_EMS_HOUSING; -import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_EMS_HOUSING_GLOW; - import net.minecraft.item.ItemStack; import gregtech.api.enums.OrePrefixes; +import gregtech.api.enums.Textures; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; @@ -45,11 +43,11 @@ protected boolean isValidItem(ItemStack item) { @Override public ITexture[] getTexturesActive(ITexture aBaseTexture) { return new ITexture[] { aBaseTexture, TextureFactory.builder() - .addIcon(OVERLAY_EMS_HOUSING) + .addIcon(Textures.BlockIcons.OVERLAY_NANITE_HATCH) .extFacing() .build(), TextureFactory.builder() - .addIcon(OVERLAY_EMS_HOUSING_GLOW) + .addIcon(Textures.BlockIcons.OVERLAY_NANITE_HATCH_GLOW) .extFacing() .glow() .build() }; @@ -58,11 +56,11 @@ public ITexture[] getTexturesActive(ITexture aBaseTexture) { @Override public ITexture[] getTexturesInactive(ITexture aBaseTexture) { return new ITexture[] { aBaseTexture, TextureFactory.builder() - .addIcon(OVERLAY_EMS_HOUSING) + .addIcon(Textures.BlockIcons.OVERLAY_NANITE_HATCH) .extFacing() .build(), TextureFactory.builder() - .addIcon(OVERLAY_EMS_HOUSING_GLOW) + .addIcon(Textures.BlockIcons.OVERLAY_NANITE_HATCH_GLOW) .extFacing() .glow() .build() }; diff --git a/src/main/resources/assets/gregtech/textures/blocks/iconsets/OVERLAY_NANITE_HATCH.png b/src/main/resources/assets/gregtech/textures/blocks/iconsets/OVERLAY_NANITE_HATCH.png new file mode 100644 index 0000000000000000000000000000000000000000..38a9b800f611209ed640f5036780da92f9eebf88 GIT binary patch literal 492 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!63?wyl`GbKJV{wqX6T`Z5GB1G~mUKs7M+SzC z{oH>NS%G|&0G|+7Nl8g{T?YYS88InUp~?G&dbSF-tl}@5`I>>@G6TalpfU!A$WXgx zAjMM>=PdAuEM{Qf76xHPhFNnYfPxYwt`Q}{`DrEPiAAXl0g0J; zC3=3YAqu8?hI)ocTZ4FjYPO|Dc&2%JYB6vCIjjs)jI0cdK$aH}OGDWpUuiHhgTmdKI;Vst0CW#@7ytkO literal 0 HcmV?d00001 diff --git a/src/main/resources/assets/gregtech/textures/blocks/iconsets/OVERLAY_NANITE_HATCH_GLOW.png b/src/main/resources/assets/gregtech/textures/blocks/iconsets/OVERLAY_NANITE_HATCH_GLOW.png new file mode 100644 index 0000000000000000000000000000000000000000..ed48ca6cecaeae4ddf410e19105e4debd48c93d0 GIT binary patch literal 465 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|SkfJR9T^xl z_H+M9WCij$3p^r=85sBugD~Uq{1qucL5ULAh?3y^w370~qEv=}#LT=BJwMkF1yemk zJ;S7}K|DY;+fpMu(>y)37&w3&Rt70XRt82O%L|C5p=^+AG#Ht|;!HrcAtMvmbx}Ze zW;+X5JPXJMfdn81>4(v1mNGCiFic=)U;(NyFfuk^TmUf@q=R(<#H1-eHV7~Q&0zwo z46?KUvY@&Q4GciC(j}LtT;XWr1~MBwT^vI!{F5cp9Ad9Ow72T@<#7q-HE_x_V3=9= z`4gkt!jr!hxBdCUw(Q^kA6(1sUvDuybftl{fN=+-N5lRcwZ!F%f4?`q@aePz&(kKx zT~cZqy`p;<9vv4@%WM$Qf57LGz;K9(pXFa|)%gz_wdd||P?0{s#4+=j8r!0F-h>1O YhEF#=rybUqT?ulRr>mdKI;Vst0F Date: Sun, 29 Dec 2024 21:27:05 +0100 Subject: [PATCH 08/27] add output slot locking --- .../MTEHatchNonConsumableBase.java | 25 +++++++++++++++++-- .../resources/assets/gregtech/lang/en_US.lang | 1 + 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/src/main/java/gregtech/api/metatileentity/implementations/MTEHatchNonConsumableBase.java b/src/main/java/gregtech/api/metatileentity/implementations/MTEHatchNonConsumableBase.java index 219df316a87..c640916d0c2 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/MTEHatchNonConsumableBase.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/MTEHatchNonConsumableBase.java @@ -1,12 +1,17 @@ package gregtech.api.metatileentity.implementations; +import static gregtech.api.metatileentity.BaseTileEntity.TOOLTIP_DELAY; +import static net.minecraft.util.StatCollector.translateToLocal; + import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraftforge.common.util.ForgeDirection; +import com.gtnewhorizons.modularui.api.drawable.UITexture; import com.gtnewhorizons.modularui.api.screen.ModularWindow; import com.gtnewhorizons.modularui.api.screen.UIBuildContext; +import com.gtnewhorizons.modularui.common.widget.ButtonWidget; import com.gtnewhorizons.modularui.common.widget.DrawableWidget; import com.gtnewhorizons.modularui.common.widget.FakeSyncWidget; import com.gtnewhorizons.modularui.common.widget.SlotWidget; @@ -22,6 +27,7 @@ public abstract class MTEHatchNonConsumableBase extends MTEHatch { private ItemStack itemStack = null; private int itemCount = 0; + private boolean isOutputSlotLocked = true; public MTEHatchNonConsumableBase(int ID, String name, String nameRegional, int tier, String description) { super(ID, name, nameRegional, tier, 3, description); @@ -69,6 +75,20 @@ public void addUIWidgets(ModularWindow.Builder builder, UIBuildContext buildCont new TextWidget().setStringSupplier(() -> numberFormat.format(clientItemCount)) .setDefaultColor(COLOR_TEXT_WHITE.get()) .setPos(10, 30)) + .widget( + new ButtonWidget().setOnClick((clickData, widget) -> { isOutputSlotLocked = !isOutputSlotLocked; }) + .setBackground( + () -> new UITexture[] { + isOutputSlotLocked ? GTUITextures.BUTTON_STANDARD_PRESSED : GTUITextures.BUTTON_STANDARD, + isOutputSlotLocked ? GTUITextures.OVERLAY_BUTTON_RECIPE_LOCKED + : GTUITextures.OVERLAY_BUTTON_RECIPE_UNLOCKED }) + .addTooltip(translateToLocal("GT5U.gui.button.toggle_output_slot_lock")) + .setTooltipShowUpDelay(TOOLTIP_DELAY) + .attachSyncer( + new FakeSyncWidget.BooleanSyncer(() -> isOutputSlotLocked, val -> isOutputSlotLocked = val), + builder) + .setPos(100, 52) + .setSize(18, 18)) .widget(new FakeSyncWidget.IntegerSyncer(() -> itemCount, value -> clientItemCount = value)); } @@ -119,12 +139,13 @@ public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTimer) { count = getItemCapacity(); } } - if (mInventory[1] == null && stack != null) { + if (mInventory[1] == null && stack != null && !isOutputSlotLocked) { mInventory[1] = stack.copy(); mInventory[1].stackSize = Math.min(stack.getMaxStackSize(), count); count -= mInventory[1].stackSize; } else if ((count > 0) && GTUtility.areStacksEqual(mInventory[1], stack) - && mInventory[1].getMaxStackSize() > mInventory[1].stackSize) { + && mInventory[1].getMaxStackSize() > mInventory[1].stackSize + && !isOutputSlotLocked) { int tmp = Math.min(count, mInventory[1].getMaxStackSize() - mInventory[1].stackSize); mInventory[1].stackSize += tmp; count -= tmp; diff --git a/src/main/resources/assets/gregtech/lang/en_US.lang b/src/main/resources/assets/gregtech/lang/en_US.lang index f3ff62d6823..3d7945975e8 100644 --- a/src/main/resources/assets/gregtech/lang/en_US.lang +++ b/src/main/resources/assets/gregtech/lang/en_US.lang @@ -510,6 +510,7 @@ GT5U.gui.button.drone_name=Sort by §3name GT5U.gui.button.drone_distance=Sort by §3distance GT5U.gui.button.drone_error=Sort by §3shutdown status GT5U.gui.button.drone_showLocalName=Show localized name +GT5U.gui.button.toggle_output_slot_lock=Toggle output slot GT5U.gui.text.success=§aProcessing recipe GT5U.gui.text.generating=§aGenerating power GT5U.gui.text.no_recipe=§7No valid recipe found From 43969d06a5cf047ed76238153dc1fb0b0c920e02 Mon Sep 17 00:00:00 2001 From: GDCloud Date: Sun, 29 Dec 2024 21:39:43 +0100 Subject: [PATCH 09/27] save to item nbt --- .../MTEHatchNonConsumableBase.java | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/main/java/gregtech/api/metatileentity/implementations/MTEHatchNonConsumableBase.java b/src/main/java/gregtech/api/metatileentity/implementations/MTEHatchNonConsumableBase.java index c640916d0c2..59a6da34f38 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/MTEHatchNonConsumableBase.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/MTEHatchNonConsumableBase.java @@ -4,8 +4,10 @@ import static net.minecraft.util.StatCollector.translateToLocal; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; import net.minecraftforge.common.util.ForgeDirection; import com.gtnewhorizons.modularui.api.drawable.UITexture; @@ -174,6 +176,31 @@ public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlaye return true; } + @Override + public void setItemNBT(NBTTagCompound aNBT) { + NBTTagList invData = new NBTTagList(); + boolean hasInvData = false; + for (int i = 0; i < 3; i++) { + if (mInventory[i] != null) { + NBTTagCompound tNBT = new NBTTagCompound(); + tNBT.setByte("count", (byte) mInventory[i].stackSize); + tNBT.setShort("damage", (short) mInventory[i].getItemDamage()); + tNBT.setShort("id", (short) Item.getIdFromItem(mInventory[i].getItem())); + tNBT.setInteger("intSlot", i); + if (mInventory[i].hasTagCompound()) { + tNBT.setTag("tag", mInventory[i].getTagCompound()); + } + invData.appendTag(tNBT); + hasInvData = true; + } + } + if (getItemStack() != null) aNBT.setTag("itemStack", getItemStack().writeToNBT(new NBTTagCompound())); + if (hasInvData) aNBT.setTag("inventory", invData); + if (getItemCount() > 0) aNBT.setInteger("itemCount", getItemCount()); + + super.setItemNBT(aNBT); + } + @Override public void saveNBTData(NBTTagCompound aNBT) { aNBT.setInteger("itemCount", getItemCount()); From 08d045dd5c352eef71c7aa3012a14afd63f8d2d1 Mon Sep 17 00:00:00 2001 From: GDCloud Date: Sun, 29 Dec 2024 23:26:32 +0100 Subject: [PATCH 10/27] add stored amount to tooltip --- .../MTEHatchNonConsumableBase.java | 27 ++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/src/main/java/gregtech/api/metatileentity/implementations/MTEHatchNonConsumableBase.java b/src/main/java/gregtech/api/metatileentity/implementations/MTEHatchNonConsumableBase.java index 59a6da34f38..b44fe45888f 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/MTEHatchNonConsumableBase.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/MTEHatchNonConsumableBase.java @@ -3,11 +3,14 @@ import static gregtech.api.metatileentity.BaseTileEntity.TOOLTIP_DELAY; import static net.minecraft.util.StatCollector.translateToLocal; +import java.util.List; + import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; +import net.minecraft.util.EnumChatFormatting; import net.minecraftforge.common.util.ForgeDirection; import com.gtnewhorizons.modularui.api.drawable.UITexture; @@ -23,6 +26,7 @@ import gregtech.api.gui.modularui.GTUITextures; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.util.GTLanguageManager; import gregtech.api.util.GTUtility; public abstract class MTEHatchNonConsumableBase extends MTEHatch { @@ -32,7 +36,7 @@ public abstract class MTEHatchNonConsumableBase extends MTEHatch { private boolean isOutputSlotLocked = true; public MTEHatchNonConsumableBase(int ID, String name, String nameRegional, int tier, String description) { - super(ID, name, nameRegional, tier, 3, description); + super(ID, name, nameRegional, tier, 3, new String[] { description, "Will keep its contents when broken" }); } public MTEHatchNonConsumableBase(String name, int tier, String[] description, ITexture[][][] textures) { @@ -95,6 +99,27 @@ public void addUIWidgets(ModularWindow.Builder builder, UIBuildContext buildCont } + @Override + public void addAdditionalTooltipInformation(ItemStack stack, List tooltip) { + if (stack.hasTagCompound() && stack.stackTagCompound.hasKey("itemStack")) { + final ItemStack tContents = ItemStack + .loadItemStackFromNBT(stack.stackTagCompound.getCompoundTag("itemStack")); + final int tSize = stack.stackTagCompound.getInteger("itemCount"); + if (tContents != null && tSize > 0) { + tooltip.add( + GTLanguageManager.addStringLocalization("TileEntity_CHEST_INFO", "Contains Item: ") + + EnumChatFormatting.YELLOW + + tContents.getDisplayName() + + EnumChatFormatting.GRAY); + tooltip.add( + GTLanguageManager.addStringLocalization("TileEntity_CHEST_AMOUNT", "Item Amount: ") + + EnumChatFormatting.GREEN + + GTUtility.formatNumbers(tSize) + + EnumChatFormatting.GRAY); + } + } + } + protected ItemStack getItemStack() { return itemStack; } From 707df407f16e53a201ef5a369b12722695562421 Mon Sep 17 00:00:00 2001 From: GDCloud Date: Sun, 29 Dec 2024 23:58:40 +0100 Subject: [PATCH 11/27] add ae2 integration --- src/main/java/gregtech/GTMod.java | 2 + .../MTEHatchNonConsumableBase.java | 215 ++++++++++++++++-- .../objects/AE2NonconsumableHatchHandler.java | 26 +++ 3 files changed, 229 insertions(+), 14 deletions(-) create mode 100644 src/main/java/gregtech/api/objects/AE2NonconsumableHatchHandler.java diff --git a/src/main/java/gregtech/GTMod.java b/src/main/java/gregtech/GTMod.java index f3f02f1adb6..e21fbeca28a 100644 --- a/src/main/java/gregtech/GTMod.java +++ b/src/main/java/gregtech/GTMod.java @@ -62,6 +62,7 @@ import gregtech.api.gui.modularui.GTUIInfos; import gregtech.api.interfaces.internal.IGTMod; import gregtech.api.metatileentity.BaseMetaPipeEntity; +import gregtech.api.metatileentity.implementations.MTEHatchNonConsumableBase; import gregtech.api.objects.ItemData; import gregtech.api.objects.XSTR; import gregtech.api.registries.LHECoolantRegistry; @@ -512,6 +513,7 @@ public void onPostLoad(FMLPostInitializationEvent aEvent) { GTForestryCompat.transferSqueezerRecipes(); } MTEDigitalChestBase.registerAEIntegration(); + MTEHatchNonConsumableBase.registerAEIntegration(); ItemStack facade = AEApi.instance() .definitions() .items() diff --git a/src/main/java/gregtech/api/metatileentity/implementations/MTEHatchNonConsumableBase.java b/src/main/java/gregtech/api/metatileentity/implementations/MTEHatchNonConsumableBase.java index b44fe45888f..4cd6883dc25 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/MTEHatchNonConsumableBase.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/MTEHatchNonConsumableBase.java @@ -3,7 +3,9 @@ import static gregtech.api.metatileentity.BaseTileEntity.TOOLTIP_DELAY; import static net.minecraft.util.StatCollector.translateToLocal; +import java.util.HashMap; import java.util.List; +import java.util.Map; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; @@ -22,18 +24,29 @@ import com.gtnewhorizons.modularui.common.widget.SlotWidget; import com.gtnewhorizons.modularui.common.widget.TextWidget; +import appeng.api.storage.IMEMonitor; +import appeng.api.storage.IMEMonitorHandlerReceiver; +import appeng.api.storage.StorageChannel; +import appeng.api.storage.data.IAEItemStack; +import appeng.api.storage.data.IItemList; +import appeng.util.item.AEItemStack; +import appeng.util.item.ItemList; +import gregtech.api.enums.GTValues; import gregtech.api.gui.modularui.GTUIInfos; import gregtech.api.gui.modularui.GTUITextures; import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.modularui.IAddUIWidgets; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.objects.AE2NonconsumableHatchHandler; import gregtech.api.util.GTLanguageManager; import gregtech.api.util.GTUtility; -public abstract class MTEHatchNonConsumableBase extends MTEHatch { +public abstract class MTEHatchNonConsumableBase extends MTEHatch implements IMEMonitor, IAddUIWidgets { private ItemStack itemStack = null; private int itemCount = 0; private boolean isOutputSlotLocked = true; + private Map, Object> listeners = null; public MTEHatchNonConsumableBase(int ID, String name, String nameRegional, int tier, String description) { super(ID, name, nameRegional, tier, 3, new String[] { description, "Will keep its contents when broken" }); @@ -53,6 +66,27 @@ public boolean isFacingValid(ForgeDirection facing) { return true; } + protected ItemStack getItemStack() { + return itemStack; + } + + protected void setItemStack(ItemStack stack) { + itemStack = stack; + } + + protected int getItemCount() { + return itemCount; + } + + @Override + public void setItemCount(int amount) { + itemCount = amount; + } + + protected abstract int getItemCapacity(); + + protected abstract boolean isValidItem(ItemStack item); + protected int clientItemCount; @Override @@ -120,26 +154,179 @@ public void addAdditionalTooltipInformation(ItemStack stack, List toolti } } - protected ItemStack getItemStack() { - return itemStack; + public static void registerAEIntegration() { + appeng.api.AEApi.instance() + .registries() + .externalStorage() + .addExternalStorageInterface(new AE2NonconsumableHatchHandler()); } - protected void setItemStack(ItemStack stack) { - itemStack = stack; + @Override + public void addListener(IMEMonitorHandlerReceiver meMonitorHandlerReceiver, Object o) { + if (listeners == null) listeners = new HashMap<>(); + listeners.put(meMonitorHandlerReceiver, o); } - protected int getItemCount() { - return itemCount; + @Override + public void removeListener(IMEMonitorHandlerReceiver meMonitorHandlerReceiver) { + if (listeners == null) listeners = new HashMap<>(); + listeners.remove(meMonitorHandlerReceiver); } @Override - public void setItemCount(int amount) { - itemCount = amount; + public appeng.api.config.AccessRestriction getAccess() { + return appeng.api.config.AccessRestriction.READ_WRITE; } - protected abstract int getItemCapacity(); + @Override + public boolean isPrioritized(IAEItemStack aeItemStack) { + ItemStack s = getItemStack(); + if (s == null || aeItemStack == null) return false; + return aeItemStack.isSameType(s); + } - protected abstract boolean isValidItem(ItemStack item); + @Override + public boolean canAccept(IAEItemStack aeItemStack) { + ItemStack s = getItemStack(); + if (s == null || aeItemStack == null) return true; + return aeItemStack.isSameType(s); + } + + @Override + public int getPriority() { + return 0; + } + + @Override + public int getSlot() { + return 0; + } + + @Override + public boolean validForPass(int i) { + return true; + } + + @SuppressWarnings("unchecked") + @Override + public IItemList getAvailableItems(final IItemList out, int iteration) { + ItemStack storedStack = getItemStack(); + if (storedStack != null) { + AEItemStack s = AEItemStack.create(storedStack); + s.setStackSize(getItemCount()); + out.add(s); + } + return out; + } + + @Override + public IItemList getStorageList() { + IItemList res = new ItemList(); + ItemStack storedStack = getItemStack(); + if (storedStack != null) { + AEItemStack s = AEItemStack.create(storedStack); + s.setStackSize(getItemCount()); + res.add(s); + } + return res; + } + + @Override + public IAEItemStack injectItems(final IAEItemStack input, final appeng.api.config.Actionable mode, + final appeng.api.networking.security.BaseActionSource src) { + if (getBaseMetaTileEntity() == null) return input; + + final ItemStack inputStack = input.getItemStack(); + final int maxCapacity = getItemCapacity(); + final int itemCount = getItemCount(); + final long toAdd = input.getStackSize(); + final ItemStack storedStack = getItemStack(); + + if (storedStack != null && !GTUtility.areStacksEqual(storedStack, inputStack)) { + // Can't stack with existing item, just return the input. + return input; + } + + if (storedStack == null && !isValidItem(inputStack)) { + // Invalid item, return input. + return input; + } + + // Number of items not added because there's too much to add. + final long notAdded = itemCount + toAdd - maxCapacity; + + if (mode == appeng.api.config.Actionable.MODULATE) { + final int newCount = (int) Math.min(maxCapacity, itemCount + toAdd); + + if (storedStack == null) { + setItemStack(inputStack.copy()); + } + setItemCount(newCount); + getBaseMetaTileEntity().markDirty(); + } + + if (notAdded <= 0) { + return null; + } else { + return input.copy() + .setStackSize(notAdded); + } + + } + + @Override + public IAEItemStack extractItems(final IAEItemStack request, final appeng.api.config.Actionable mode, + final appeng.api.networking.security.BaseActionSource src) { + if (request.isSameType(getItemStack())) { + if (getBaseMetaTileEntity() == null) return null; + if (mode != appeng.api.config.Actionable.SIMULATE) getBaseMetaTileEntity().markDirty(); + if (request.getStackSize() >= getItemCount()) { + AEItemStack result = AEItemStack.create(getItemStack()); + result.setStackSize(getItemCount()); + if (mode != appeng.api.config.Actionable.SIMULATE) setItemCount(0); + return result; + } else { + if (mode != appeng.api.config.Actionable.SIMULATE) + setItemCount(getItemCount() - (int) request.getStackSize()); + return request.copy(); + } + } + return null; + } + + private void notifyListeners(int count, ItemStack stack) { + if (listeners == null) { + listeners = new HashMap<>(); + return; + } + if (count == 0 || stack == null) return; + ItemList change = new ItemList(); + AEItemStack s = AEItemStack.create(stack); + s.setStackSize(count); + change.add(s); + listeners.forEach((l, o) -> { + if (l.isValid(o)) l.postChange(this, change, null); + else removeListener(l); + }); + } + + private boolean hasActiveMEConnection() { + if (listeners == null || listeners.isEmpty()) return false; + for (Map.Entry, Object> e : listeners.entrySet()) { + if ((e.getKey() instanceof appeng.api.parts.IPart)) { + appeng.api.networking.IGridNode n = ((appeng.api.parts.IPart) e.getKey()).getGridNode(); + if (n != null && n.isActive()) return true; + } + } + // if there are no active storage buses - clear the listeners + listeners.clear(); + return false; + } + + @Override + public StorageChannel getChannel() { + return StorageChannel.ITEMS; + } @Override public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTimer) { @@ -185,7 +372,7 @@ public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTimer) { mInventory[2] = null; } - // notifyListeners(count - savedCount, stack); + notifyListeners(count - savedCount, stack); if (count != savedCount) getBaseMetaTileEntity().markDirty(); } } @@ -242,14 +429,14 @@ public void loadNBTData(NBTTagCompound aNBT) { @Override public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side, ItemStack aStack) { - // if (GTValues.disableDigitalChestsExternalAccess && hasActiveMEConnection()) return false; + if (GTValues.disableDigitalChestsExternalAccess && hasActiveMEConnection()) return false; return aIndex == 1; } @Override public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side, ItemStack aStack) { - // if (GTValues.disableDigitalChestsExternalAccess && hasActiveMEConnection()) return false; + if (GTValues.disableDigitalChestsExternalAccess && hasActiveMEConnection()) return false; if (aIndex != 0) return false; if ((mInventory[0] != null && !GTUtility.areStacksEqual(mInventory[0], aStack))) return false; if (getItemStack() == null) return mInventory[1] == null || GTUtility.areStacksEqual(mInventory[1], aStack); diff --git a/src/main/java/gregtech/api/objects/AE2NonconsumableHatchHandler.java b/src/main/java/gregtech/api/objects/AE2NonconsumableHatchHandler.java new file mode 100644 index 00000000000..62307c8ce91 --- /dev/null +++ b/src/main/java/gregtech/api/objects/AE2NonconsumableHatchHandler.java @@ -0,0 +1,26 @@ +package gregtech.api.objects; + +import net.minecraft.tileentity.TileEntity; +import net.minecraftforge.common.util.ForgeDirection; + +import gregtech.api.metatileentity.BaseMetaTileEntity; +import gregtech.api.metatileentity.implementations.MTEHatchNonConsumableBase; + +public class AE2NonconsumableHatchHandler implements appeng.api.storage.IExternalStorageHandler { + + @Override + public boolean canHandle(final TileEntity te, final ForgeDirection d, final appeng.api.storage.StorageChannel chan, + final appeng.api.networking.security.BaseActionSource mySrc) { + return chan == appeng.api.storage.StorageChannel.ITEMS && te instanceof BaseMetaTileEntity + && ((BaseMetaTileEntity) te).getMetaTileEntity() instanceof MTEHatchNonConsumableBase; + } + + @Override + public appeng.api.storage.IMEInventory getInventory(final TileEntity te, final ForgeDirection d, + final appeng.api.storage.StorageChannel chan, final appeng.api.networking.security.BaseActionSource src) { + if (chan == appeng.api.storage.StorageChannel.ITEMS) { + return ((MTEHatchNonConsumableBase) (((BaseMetaTileEntity) te).getMetaTileEntity())); + } + return null; + } +} From f0b92ee70d8754f0a323c26c80cd7dea2c40875c Mon Sep 17 00:00:00 2001 From: GDCloud Date: Mon, 30 Dec 2024 01:44:38 +0100 Subject: [PATCH 12/27] integrate hatch into pcb factory and revert some now obsoleted changes --- .../implementations/MTEHatchNanite.java | 8 + .../MTEHatchNonConsumableBase.java | 4 +- .../machines/multi/MTEPCBFactory.java | 225 ++++++++---------- 3 files changed, 114 insertions(+), 123 deletions(-) diff --git a/src/main/java/gregtech/api/metatileentity/implementations/MTEHatchNanite.java b/src/main/java/gregtech/api/metatileentity/implementations/MTEHatchNanite.java index e2aad52d3fc..fa3cd6643c6 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/MTEHatchNanite.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/MTEHatchNanite.java @@ -2,6 +2,7 @@ import net.minecraft.item.ItemStack; +import gregtech.api.enums.Materials; import gregtech.api.enums.OrePrefixes; import gregtech.api.enums.Textures; import gregtech.api.interfaces.ITexture; @@ -30,6 +31,13 @@ protected int getItemCapacity() { return naniteCapacity; } + public Materials getStoredNaniteMaterial() { + if (getItemStack() == null) return null; + ItemData data = GTOreDictUnificator.getAssociation(getItemStack()); + if (data == null) return null; + return data.mMaterial.mMaterial; + } + @Override protected boolean isValidItem(ItemStack item) { ItemData data = GTOreDictUnificator.getAssociation(item); diff --git a/src/main/java/gregtech/api/metatileentity/implementations/MTEHatchNonConsumableBase.java b/src/main/java/gregtech/api/metatileentity/implementations/MTEHatchNonConsumableBase.java index 4cd6883dc25..52826a8778e 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/MTEHatchNonConsumableBase.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/MTEHatchNonConsumableBase.java @@ -66,7 +66,7 @@ public boolean isFacingValid(ForgeDirection facing) { return true; } - protected ItemStack getItemStack() { + public ItemStack getItemStack() { return itemStack; } @@ -74,7 +74,7 @@ protected void setItemStack(ItemStack stack) { itemStack = stack; } - protected int getItemCount() { + public int getItemCount() { return itemCount; } diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/MTEPCBFactory.java b/src/main/java/gregtech/common/tileentities/machines/multi/MTEPCBFactory.java index 9e3f2499430..8a8255a3011 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/MTEPCBFactory.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/MTEPCBFactory.java @@ -20,9 +20,8 @@ import java.util.ArrayList; import java.util.Arrays; -import java.util.HashMap; +import java.util.Collections; import java.util.List; -import java.util.Map; import javax.annotation.Nonnull; @@ -64,10 +63,10 @@ import gregtech.api.GregTechAPI; import gregtech.api.enums.Materials; import gregtech.api.enums.Mods; -import gregtech.api.enums.OrePrefixes; import gregtech.api.enums.SoundResource; import gregtech.api.enums.Textures.BlockIcons; import gregtech.api.gui.modularui.GTUITextures; +import gregtech.api.interfaces.IHatchElement; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; @@ -76,8 +75,7 @@ import gregtech.api.metatileentity.implementations.MTEExtendedPowerMultiBlockBase; import gregtech.api.metatileentity.implementations.MTEHatch; import gregtech.api.metatileentity.implementations.MTEHatchInput; -import gregtech.api.metatileentity.implementations.MTEHatchInputBus; -import gregtech.api.objects.ItemData; +import gregtech.api.metatileentity.implementations.MTEHatchNanite; import gregtech.api.recipe.RecipeMap; import gregtech.api.recipe.RecipeMaps; import gregtech.api.recipe.check.CheckRecipeResult; @@ -88,16 +86,15 @@ import gregtech.api.recipe.metadata.PCBFactoryUpgradeKey; import gregtech.api.render.TextureFactory; import gregtech.api.util.GTModHandler; -import gregtech.api.util.GTOreDictUnificator; import gregtech.api.util.GTRecipe; import gregtech.api.util.GTRecipeConstants; import gregtech.api.util.GTUtility; +import gregtech.api.util.IGTHatchAdder; import gregtech.api.util.MultiblockTooltipBuilder; import gregtech.api.util.OverclockCalculator; import gregtech.api.util.ParallelHelper; import gregtech.api.util.shutdown.ShutDownReasonRegistry; import gregtech.common.blocks.BlockCasings8; -import gregtech.common.tileentities.machines.MTEHatchInputBusME; @SuppressWarnings("SpellCheckingInspection") public class MTEPCBFactory extends MTEExtendedPowerMultiBlockBase implements ISurvivalConstructable { @@ -114,18 +111,12 @@ public class MTEPCBFactory extends MTEExtendedPowerMultiBlockBase private int mUpgradesInstalled = 0; private final int mCurrentParallel = 0; private int mMaxParallel = 0; - private final Map storedNanites = new HashMap<>() { - - { - put(Materials.Silver, 0); - put(Materials.Gold, 0); - } - }; private boolean mBioUpgrade = false, mBioRotate = false, mOCTier1 = false, mOCTier2 = false; private final int[] mBioOffsets = new int[] { -5, -1 }; private final int[] mOCTier1Offsets = new int[] { 2, -11 }; private final int[] mOCTier2Offsets = new int[] { 2, -11 }; private MTEHatchInput mCoolantInputHatch; + private final ArrayList naniteBuses = new ArrayList<>(); private static final int mBioRotateBitMap = 0b1000000; private static final int mOCTier2BitMap = 0b100000; private static final int mOCTier1BitMap = 0b10000; @@ -134,12 +125,6 @@ public class MTEPCBFactory extends MTEExtendedPowerMultiBlockBase private static final int mTier2BitMap = 0b10; private static final int mTier1BitMap = 0b1; private static final int COOLANT_CONSUMED_PER_SEC = 10; - private static final int MAX_NANITE_COUNT = 2048; - private static final int BIO_OFFSET_X = -5; - private static final int BIO_OFFSET_Y = -1; - private static final int COOLING_OFFSET_X = 2; - private static final int COOLING_OFFSET_Y = -11; - private static final List VALID_NANITE_MATERIALS = Arrays.asList(Materials.Silver, Materials.Gold); private static final IStructureDefinition STRUCTURE_DEFINITION = StructureDefinition .builder() .addShape( @@ -255,7 +240,13 @@ public class MTEPCBFactory extends MTEExtendedPowerMultiBlockBase .addElement( 'P', buildHatchAdder(MTEPCBFactory.class) - .atLeast(InputHatch, OutputBus, InputBus, Maintenance, Energy.or(ExoticEnergy)) + .atLeast( + InputHatch, + OutputBus, + InputBus, + Maintenance, + Energy.or(ExoticEnergy), + SpecialHatchElement.NaniteBus) .dot(1) .casingIndex(((BlockCasings8) GregTechAPI.sBlockCasings8).getTextureIndex(11)) .buildAndChain(GregTechAPI.sBlockCasings8, 11)) @@ -266,7 +257,13 @@ public class MTEPCBFactory extends MTEExtendedPowerMultiBlockBase .addElement( 'J', buildHatchAdder(MTEPCBFactory.class) - .atLeast(InputHatch, OutputBus, InputBus, Maintenance, Energy.or(ExoticEnergy)) + .atLeast( + InputHatch, + OutputBus, + InputBus, + Maintenance, + Energy.or(ExoticEnergy), + SpecialHatchElement.NaniteBus) .dot(1) .casingIndex(((BlockCasings8) GregTechAPI.sBlockCasings8).getTextureIndex(13)) .buildAndChain(GregTechAPI.sBlockCasings8, 13)) @@ -570,8 +567,21 @@ protected CheckRecipeResult validateRecipe(@Nonnull GTRecipe recipe) { int numberOfNanites = 0; Materials naniteMaterial = recipe.getMetadata(GTRecipeConstants.PCB_NANITE_MATERIAL); if (naniteMaterial != null) { - numberOfNanites = storedNanites.get(naniteMaterial); - if (numberOfNanites == 0) { + if (naniteBuses.isEmpty()) { + return SimpleCheckRecipeResult.ofFailure("nanites_missing"); + } + boolean nanitesFound = false; + for (MTEHatchNanite naniteBus : naniteBuses) { + ItemStack storedNanites = naniteBus.getItemStack(); + Materials storedNaniteMaterial = naniteBus.getStoredNaniteMaterial(); + if (storedNanites == null || storedNaniteMaterial != naniteMaterial) { + continue; + } + numberOfNanites = naniteBus.getItemCount(); + nanitesFound = true; + break; + } + if (!nanitesFound) { return SimpleCheckRecipeResult.ofFailure("nanites_missing"); } } @@ -647,45 +657,6 @@ public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { // TODO: Look for proper fix // Updates every 10 sec if (mUpdate <= -150) mUpdate = 50; - - if (aTick % 100 == 0) { - for (MTEHatchInputBus inputBus : mInputBusses) { - ItemStack[] busInventory = inputBus.getRealInventory(); - for (int j = 0; j < busInventory.length; j++) { - ItemStack itemStack = busInventory[j]; - if (itemStack == null) { - continue; - } - ItemData data = GTOreDictUnificator.getAssociation(itemStack); - if (data == null) { - continue; - } - OrePrefixes prefix = data.mPrefix; - Materials mat = data.mMaterial.mMaterial; - if (prefix == OrePrefixes.nanite && VALID_NANITE_MATERIALS.contains(mat)) { - if (storedNanites.get(mat) == 2048) { - continue; - } - int stacksize = itemStack.stackSize; - startRecipeProcessing(); - if (inputBus instanceof MTEHatchInputBusME meBus) { - ItemStack realItem = meBus.getRealInventory()[j + 16]; - if (realItem == null) { - break; - } - stacksize = realItem.stackSize; - } - int storedNaniteAmount = storedNanites.get(mat); - int absorbedNanites = Math.min(stacksize, MAX_NANITE_COUNT - storedNaniteAmount); - inputBus.decrStackSize(j, absorbedNanites); - int updatedAmount = storedNaniteAmount + absorbedNanites; - storedNanites.put(mat, updatedAmount); - endRecipeProcessing(); - } - } - inputBus.updateSlots(); - } - } } } @@ -1008,69 +979,41 @@ protected MultiblockTooltipBuilder createTooltip() { } @Override - public void setItemNBT(NBTTagCompound NBT) { - NBTTagCompound naniteTag = new NBTTagCompound(); - boolean empty = true; - for (Materials naniteMat : storedNanites.keySet()) { - int naniteAmount = storedNanites.get(naniteMat); - if (naniteAmount != 0) { - empty = false; - } - naniteTag.setInteger(naniteMat.toString(), naniteAmount); - } - if (!empty) { - NBT.setTag("storedNanites", naniteTag); - } + public void saveNBTData(NBTTagCompound aNBT) { + super.saveNBTData(aNBT); + aNBT.setBoolean("mBioUpgrade", mBioUpgrade); + aNBT.setBoolean("mBioRotate", mBioRotate); + aNBT.setInteger("mBioOffsetX", mBioOffsets[0]); + aNBT.setInteger("mBioOffsetZ", mBioOffsets[1]); + aNBT.setBoolean("mOCTier1Upgrade", mOCTier1); + aNBT.setInteger("mOCTier1OffsetX", mOCTier1Offsets[0]); + aNBT.setInteger("mOCTier1OffsetZ", mOCTier1Offsets[1]); + aNBT.setBoolean("mOCTier2Upgrade", mOCTier2); + aNBT.setInteger("mOCTier2OffsetX", mOCTier2Offsets[0]); + aNBT.setInteger("mOCTier2OffsetZ", mOCTier2Offsets[1]); + aNBT.setFloat("mRoughnessMultiplier", mRoughnessMultiplier); + aNBT.setInteger("mSetTier", mSetTier); } @Override - public void saveNBTData(NBTTagCompound NBT) { - super.saveNBTData(NBT); - NBT.setBoolean("mBioUpgrade", mBioUpgrade); - NBT.setBoolean("mBioRotate", mBioRotate); - NBT.setInteger("mBioOffsetX", mBioOffsets[0]); - NBT.setInteger("mBioOffsetZ", mBioOffsets[1]); - NBT.setBoolean("mOCTier1Upgrade", mOCTier1); - NBT.setInteger("mOCTier1OffsetX", mOCTier1Offsets[0]); - NBT.setInteger("mOCTier1OffsetZ", mOCTier1Offsets[1]); - NBT.setBoolean("mOCTier2Upgrade", mOCTier2); - NBT.setInteger("mOCTier2OffsetX", mOCTier2Offsets[0]); - NBT.setInteger("mOCTier2OffsetZ", mOCTier2Offsets[1]); - NBT.setFloat("mRoughnessMultiplier", mRoughnessMultiplier); - NBT.setInteger("mSetTier", mSetTier); - - NBTTagCompound naniteTag = new NBTTagCompound(); - for (Materials naniteMat : storedNanites.keySet()) { - naniteTag.setInteger(naniteMat.toString(), storedNanites.get(naniteMat)); - } - NBT.setTag("storedNanites", naniteTag); - } - - @Override - public void loadNBTData(final NBTTagCompound NBT) { - super.loadNBTData(NBT); - if (NBT.hasKey("mSeparate")) { + public void loadNBTData(final NBTTagCompound aNBT) { + super.loadNBTData(aNBT); + if (aNBT.hasKey("mSeparate")) { // backward compatibility - inputSeparation = NBT.getBoolean("mSeparate"); - } - mBioUpgrade = NBT.getBoolean("mBioUpgrade"); - mBioRotate = NBT.getBoolean("mBioRotate"); - mBioOffsets[0] = NBT.hasKey("mRoughnessMultiplier") ? NBT.getInteger("mBioOffsetX") : BIO_OFFSET_X; - mBioOffsets[1] = NBT.hasKey("mRoughnessMultiplier") ? NBT.getInteger("mBioOffsetZ") : BIO_OFFSET_Y; - mOCTier1 = NBT.getBoolean("mOCTier1Upgrade"); - mOCTier1Offsets[0] = NBT.hasKey("mRoughnessMultiplier") ? NBT.getInteger("mOCTier1OffsetX") : COOLING_OFFSET_X; - mOCTier1Offsets[1] = NBT.hasKey("mRoughnessMultiplier") ? NBT.getInteger("mOCTier1OffsetZ") : COOLING_OFFSET_Y; - mOCTier2 = NBT.getBoolean("mOCTier2Upgrade"); - mOCTier2Offsets[0] = NBT.hasKey("mRoughnessMultiplier") ? NBT.getInteger("mOCTier2OffsetX") : COOLING_OFFSET_X; - mOCTier2Offsets[1] = NBT.hasKey("mRoughnessMultiplier") ? NBT.getInteger("mOCTier2OffsetZ") : COOLING_OFFSET_Y; - mRoughnessMultiplier = NBT.hasKey("mRoughnessMultiplier") ? NBT.getFloat("mRoughnessMultiplier") : 1; - mSetTier = NBT.hasKey("mRoughnessMultiplier") ? NBT.getInteger("mSetTier") : 1; - - NBTTagCompound naniteTag = NBT.getCompoundTag("storedNanites"); - for (Materials material : storedNanites.keySet()) { - int storedAmount = naniteTag.getInteger(material.toString()); - storedNanites.put(material, storedAmount); + inputSeparation = aNBT.getBoolean("mSeparate"); } + mBioUpgrade = aNBT.getBoolean("mBioUpgrade"); + mBioRotate = aNBT.getBoolean("mBioRotate"); + mBioOffsets[0] = aNBT.getInteger("mBioOffsetX"); + mBioOffsets[1] = aNBT.getInteger("mBioOffsetZ"); + mOCTier1 = aNBT.getBoolean("mOCTier1Upgrade"); + mOCTier1Offsets[0] = aNBT.getInteger("mOCTier1OffsetX"); + mOCTier1Offsets[1] = aNBT.getInteger("mOCTier1OffsetZ"); + mOCTier2 = aNBT.getBoolean("mOCTier2Upgrade"); + mOCTier2Offsets[0] = aNBT.getInteger("mOCTier2OffsetX"); + mOCTier2Offsets[1] = aNBT.getInteger("mOCTier2OffsetZ"); + mRoughnessMultiplier = aNBT.getFloat("mRoughnessMultiplier"); + mSetTier = aNBT.getInteger("mSetTier"); } @Override @@ -1346,6 +1289,46 @@ protected ModularWindow createConfigurationWindow(final EntityPlayer player) { return builder.build(); } + public boolean addNaniteBusToMachineList(IGregTechTileEntity tileEntity, int baseCasingIndex) { + if (tileEntity == null) return false; + IMetaTileEntity metaTileEntity = tileEntity.getMetaTileEntity(); + if (metaTileEntity instanceof MTEHatchNanite naniteBus) { + naniteBus.updateTexture(baseCasingIndex); + this.naniteBuses.add(naniteBus); + return true; + } + return false; + } + + private enum SpecialHatchElement implements IHatchElement { + + NaniteBus(MTEPCBFactory::addNaniteBusToMachineList, MTEHatchNanite.class) { + + @Override + public long count(MTEPCBFactory gtMetaTileEntityPCBFactory) { + return gtMetaTileEntityPCBFactory.naniteBuses.size(); + } + }; + + private final List> mteClasses; + private final IGTHatchAdder adder; + + @SafeVarargs + SpecialHatchElement(IGTHatchAdder adder, Class... mteClasses) { + this.mteClasses = Collections.unmodifiableList(Arrays.asList(mteClasses)); + this.adder = adder; + } + + @Override + public List> mteClasses() { + return mteClasses; + } + + public IGTHatchAdder adder() { + return adder; + } + } + @Override public boolean supportsVoidProtection() { return true; From ac90bb0cc841c33968fe3abb571b13d4d9aa6787 Mon Sep 17 00:00:00 2001 From: GDCloud Date: Mon, 30 Dec 2024 01:51:29 +0100 Subject: [PATCH 13/27] clear nanite bus list on structurecheck --- .../common/tileentities/machines/multi/MTEPCBFactory.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/MTEPCBFactory.java b/src/main/java/gregtech/common/tileentities/machines/multi/MTEPCBFactory.java index 8a8255a3011..3bd2c37a4db 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/MTEPCBFactory.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/MTEPCBFactory.java @@ -474,6 +474,7 @@ public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack a mTier = 0; mUpgradesInstalled = 0; mCoolantInputHatch = null; + naniteBuses.clear(); if (mSetTier < 3) { if (!checkPiece(tier1, 3, 5, 0)) { return false; From baf4b0cd87885d4c0b019ea9e1e57f1b38efbdc7 Mon Sep 17 00:00:00 2001 From: GDCloud Date: Mon, 30 Dec 2024 01:52:01 +0100 Subject: [PATCH 14/27] rename hatch to bus --- .../java/gregtech/loaders/preload/LoaderMetaTileEntities.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/gregtech/loaders/preload/LoaderMetaTileEntities.java b/src/main/java/gregtech/loaders/preload/LoaderMetaTileEntities.java index bca83b75727..39dc3a6b80b 100644 --- a/src/main/java/gregtech/loaders/preload/LoaderMetaTileEntities.java +++ b/src/main/java/gregtech/loaders/preload/LoaderMetaTileEntities.java @@ -12976,7 +12976,7 @@ public void run() { new MTEHatchLensIndicator(HATCH_LENS_INDICATOR.ID, "hatch.lensindicator", "Lens Indicator Hatch", 8) .getStackForm(1L)); ItemList.Hatch_Nanite.set( - new MTEHatchNanite(HATCH_NANITE.ID, "hatch.nanite", "Nanite Containment Hatch", 8, 2048).getStackForm(1)); + new MTEHatchNanite(HATCH_NANITE.ID, "hatch.nanite", "Nanite Containment Bus", 8, 2048).getStackForm(1)); generateWiresAndPipes(); } From 0f5b98f1b5d8f70da3e4744187fe29934d1228c0 Mon Sep 17 00:00:00 2001 From: GDCloud Date: Mon, 30 Dec 2024 02:39:08 +0100 Subject: [PATCH 15/27] add bulk catalyst housing --- .../java/gregtech/api/enums/ItemList.java | 1 + .../gregtech/api/enums/MetaTileEntityIDs.java | 1 + .../MTEHatchBulkCatalystHousing.java | 72 +++++++++++++++++++ .../preload/LoaderMetaTileEntities.java | 8 +++ 4 files changed, 82 insertions(+) create mode 100644 src/main/java/gregtech/api/metatileentity/implementations/MTEHatchBulkCatalystHousing.java diff --git a/src/main/java/gregtech/api/enums/ItemList.java b/src/main/java/gregtech/api/enums/ItemList.java index 2a3b2aec80d..a296216b7d1 100644 --- a/src/main/java/gregtech/api/enums/ItemList.java +++ b/src/main/java/gregtech/api/enums/ItemList.java @@ -2594,6 +2594,7 @@ public enum ItemList implements IItemContainer { SpaceElevatorController, // Populated in GTNH-Intergalactic Spray_Color_Infinite, Hatch_Nanite, + Hatch_Catalyst_Bulk, // semicolon after the comment to reduce merge conflicts ; diff --git a/src/main/java/gregtech/api/enums/MetaTileEntityIDs.java b/src/main/java/gregtech/api/enums/MetaTileEntityIDs.java index c2fc8060f63..7a2d464e5a6 100644 --- a/src/main/java/gregtech/api/enums/MetaTileEntityIDs.java +++ b/src/main/java/gregtech/api/enums/MetaTileEntityIDs.java @@ -857,6 +857,7 @@ public enum MetaTileEntityIDs { HATCH_DEGASIFIER_CONTROL(9413), PURIFICATION_UNIT_PARTICLE_EXTRACTOR(9414), HATCH_NANITE(9415), + HATCH_CATALYST_BULK(9416), PLASMA_GENERATOR_ZPM(10752), PLASMA_GENERATOR_UV(10753), ALLOY_SMELTER_LuV(10760), diff --git a/src/main/java/gregtech/api/metatileentity/implementations/MTEHatchBulkCatalystHousing.java b/src/main/java/gregtech/api/metatileentity/implementations/MTEHatchBulkCatalystHousing.java new file mode 100644 index 00000000000..b721f721cc5 --- /dev/null +++ b/src/main/java/gregtech/api/metatileentity/implementations/MTEHatchBulkCatalystHousing.java @@ -0,0 +1,72 @@ +package gregtech.api.metatileentity.implementations; + +import net.minecraft.item.ItemStack; + +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.render.TextureFactory; +import gtPlusPlus.core.util.minecraft.ItemUtils; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; + +public class MTEHatchBulkCatalystHousing extends MTEHatchNonConsumableBase { + + private int catalystCapacity = 0; + + public MTEHatchBulkCatalystHousing(int ID, String name, String nameRegional, int tier, int itemCapacity) { + super(ID, name, nameRegional, tier, "Dedicated Catalyst Storage"); + catalystCapacity = itemCapacity; + } + + public MTEHatchBulkCatalystHousing(String name, String[] description, ITexture[][][] textures, int tier, + int itemCapacity) { + super(name, tier, description, textures); + catalystCapacity = itemCapacity; + } + + @Override + protected int getItemCapacity() { + return catalystCapacity; + } + + public int getStoredCatalystMeta() { + if (getItemStack() == null) return -1; + return getItemStack().getItemDamage(); + } + + @Override + protected boolean isValidItem(ItemStack item) { + return ItemUtils.isCatalyst(item); + } + + @Override + public ITexture[] getTexturesActive(ITexture aBaseTexture) { + return new ITexture[] { aBaseTexture, TextureFactory.builder() + .addIcon(TexturesGtBlock.Overlay_Bus_Catalyst) + .extFacing() + .build(), + TextureFactory.builder() + .addIcon(TexturesGtBlock.Overlay_Bus_Catalyst) + .extFacing() + .glow() + .build() }; + } + + @Override + public ITexture[] getTexturesInactive(ITexture aBaseTexture) { + return new ITexture[] { aBaseTexture, TextureFactory.builder() + .addIcon(TexturesGtBlock.Overlay_Bus_Catalyst) + .extFacing() + .build(), + TextureFactory.builder() + .addIcon(TexturesGtBlock.Overlay_Bus_Catalyst) + .extFacing() + .glow() + .build() }; + } + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new MTEHatchBulkCatalystHousing(mName, mDescriptionArray, mTextures, mTier, catalystCapacity); + } +} diff --git a/src/main/java/gregtech/loaders/preload/LoaderMetaTileEntities.java b/src/main/java/gregtech/loaders/preload/LoaderMetaTileEntities.java index 39dc3a6b80b..9defc8e2164 100644 --- a/src/main/java/gregtech/loaders/preload/LoaderMetaTileEntities.java +++ b/src/main/java/gregtech/loaders/preload/LoaderMetaTileEntities.java @@ -947,6 +947,7 @@ import gregtech.api.metatileentity.implementations.MTECable; import gregtech.api.metatileentity.implementations.MTEFluid; import gregtech.api.metatileentity.implementations.MTEFrame; +import gregtech.api.metatileentity.implementations.MTEHatchBulkCatalystHousing; import gregtech.api.metatileentity.implementations.MTEHatchDataAccess; import gregtech.api.metatileentity.implementations.MTEHatchDynamo; import gregtech.api.metatileentity.implementations.MTEHatchEnergy; @@ -12977,6 +12978,13 @@ public void run() { .getStackForm(1L)); ItemList.Hatch_Nanite.set( new MTEHatchNanite(HATCH_NANITE.ID, "hatch.nanite", "Nanite Containment Bus", 8, 2048).getStackForm(1)); + ItemList.Hatch_Catalyst_Bulk.set( + new MTEHatchBulkCatalystHousing( + HATCH_CATALYST_BULK.ID, + "hatch.catalystbulk", + "Bulk Catalyst Housing", + 10, + Integer.MAX_VALUE).getStackForm(1)); generateWiresAndPipes(); } From 91556231e7c5abd45bc1700b615add7602f8ee7a Mon Sep 17 00:00:00 2001 From: GDCloud Date: Mon, 30 Dec 2024 03:13:45 +0100 Subject: [PATCH 16/27] add qft functionality --- src/main/java/bartworks/MainMod.java | 2 + .../gregtech/api/util/GTRecipeConstants.java | 6 ++ .../gtPlusPlus/api/recipe/GTPPRecipeMaps.java | 6 ++ .../java/gtPlusPlus/nei/NEIGTPPConfig.java | 4 + .../MTEQuantumForceTransformer.java | 94 +++++++++++++++---- .../recipe/RecipeLoaderQFTNoCatalysts.java | 52 ++++++++++ 6 files changed, 146 insertions(+), 18 deletions(-) create mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/loaders/recipe/RecipeLoaderQFTNoCatalysts.java diff --git a/src/main/java/bartworks/MainMod.java b/src/main/java/bartworks/MainMod.java index a321718b17f..de9921865cc 100644 --- a/src/main/java/bartworks/MainMod.java +++ b/src/main/java/bartworks/MainMod.java @@ -71,6 +71,7 @@ import gregtech.api.enums.Mods; import gregtech.api.recipe.RecipeMap; import gregtech.api.recipe.check.CheckRecipeResultRegistry; +import gtPlusPlus.xmod.gregtech.loaders.recipe.RecipeLoaderQFTNoCatalysts; import tectech.loader.recipe.Godforge; @Mod( @@ -210,6 +211,7 @@ public static void runOnPlayerJoined(boolean classicMode, boolean disableExtraGa // because the above code runs so late that I couldn't find anywhere else to call this if (!recipesAdded) Godforge.initMoltenModuleRecipes(); + if (!recipesAdded) RecipeLoaderQFTNoCatalysts.generate(); recipesAdded = true; } diff --git a/src/main/java/gregtech/api/util/GTRecipeConstants.java b/src/main/java/gregtech/api/util/GTRecipeConstants.java index f9172df39e1..fe1f623fcd7 100644 --- a/src/main/java/gregtech/api/util/GTRecipeConstants.java +++ b/src/main/java/gregtech/api/util/GTRecipeConstants.java @@ -161,6 +161,12 @@ public class GTRecipeConstants { public static final RecipeMetadataKey QFT_FOCUS_TIER = SimpleRecipeMetadataKey .create(Integer.class, "qft_focus_tier"); + /** + * QFT catalyst meta. + */ + public static final RecipeMetadataKey QFT_CATALYST_META = SimpleRecipeMetadataKey + .create(Integer.class, "qft_catalyst_meta"); + /** * Tier of advanced compression (HIP/black hole) */ diff --git a/src/main/java/gtPlusPlus/api/recipe/GTPPRecipeMaps.java b/src/main/java/gtPlusPlus/api/recipe/GTPPRecipeMaps.java index 064d59af879..615ef0df702 100644 --- a/src/main/java/gtPlusPlus/api/recipe/GTPPRecipeMaps.java +++ b/src/main/java/gtPlusPlus/api/recipe/GTPPRecipeMaps.java @@ -54,6 +54,12 @@ public class GTPPRecipeMaps { .frontend(QuantumForceTransformerFrontend::new) .disableOptimize() .build(); + public static final RecipeMap quantumForceTransformerRecipesNoCatalysts = RecipeMapBuilder + .of("gtpp.recipe.quantumforcesmelternocatalysts") + .maxIO(6, 6, 6, 6) + .minInputs(1, 0) + .disableOptimize() + .build(); public static final RecipeMap chemicalDehydratorRecipes = RecipeMapBuilder .of("gtpp.recipe.chemicaldehydrator") .maxIO(2, 9, 1, 1) diff --git a/src/main/java/gtPlusPlus/nei/NEIGTPPConfig.java b/src/main/java/gtPlusPlus/nei/NEIGTPPConfig.java index 05d0991e4c5..9c0d933cf70 100644 --- a/src/main/java/gtPlusPlus/nei/NEIGTPPConfig.java +++ b/src/main/java/gtPlusPlus/nei/NEIGTPPConfig.java @@ -68,6 +68,10 @@ public synchronized void loadConfig() { API.addItemListEntry(GregtechItemList.VOLUMETRIC_FLASK_32k.get(1)); API.addItemListEntry(GregtechItemList.KLEIN_BOTTLE.get(1)); } + // QFT + API.addRecipeCatalyst( + GregtechItemList.QuantumForceTransformer.get(1), + GTPPRecipeMaps.quantumForceTransformerRecipes.unlocalizedName); sIsAdded = true; } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/MTEQuantumForceTransformer.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/MTEQuantumForceTransformer.java index d86395368f8..616e6d0b272 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/MTEQuantumForceTransformer.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/MTEQuantumForceTransformer.java @@ -21,6 +21,7 @@ import java.util.ArrayList; import java.util.Arrays; +import java.util.Collections; import java.util.List; import javax.annotation.Nonnull; @@ -56,12 +57,14 @@ import gregtech.api.enums.SoundResource; import gregtech.api.enums.TAE; import gregtech.api.enums.Textures; +import gregtech.api.interfaces.IHatchElement; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.logic.ProcessingLogic; import gregtech.api.metatileentity.implementations.MTEExtendedPowerMultiBlockBase; import gregtech.api.metatileentity.implementations.MTEHatch; +import gregtech.api.metatileentity.implementations.MTEHatchBulkCatalystHousing; import gregtech.api.metatileentity.implementations.MTEHatchInput; import gregtech.api.objects.ItemData; import gregtech.api.recipe.RecipeMap; @@ -70,14 +73,15 @@ import gregtech.api.recipe.check.SimpleCheckRecipeResult; import gregtech.api.render.TextureFactory; import gregtech.api.util.GTRecipe; +import gregtech.api.util.GTRecipeConstants; import gregtech.api.util.GTUtility; +import gregtech.api.util.IGTHatchAdder; import gregtech.api.util.MultiblockTooltipBuilder; import gregtech.api.util.ParallelHelper; import gregtech.api.util.shutdown.ShutDownReasonRegistry; import gtPlusPlus.api.recipe.GTPPRecipeMaps; import gtPlusPlus.core.block.ModBlocks; import gtPlusPlus.core.material.MaterialsElements; -import gtPlusPlus.core.util.minecraft.ItemUtils; import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; @SuppressWarnings("SpellCheckingInspection") @@ -94,6 +98,7 @@ public class MTEQuantumForceTransformer extends MTEExtendedPowerMultiBlockBase catalystHounsings = new ArrayList<>(); private static final IStructureDefinition STRUCTURE_DEFINITION = StructureDefinition .builder() .addShape( @@ -200,7 +205,12 @@ public class MTEQuantumForceTransformer extends MTEExtendedPowerMultiBlockBase ++x.mCasing, ofBlock(ModBlocks.blockCasings2Misc, 12)))) @@ -298,6 +308,7 @@ public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack a this.mCasing = 0; this.mCraftingTier = 0; this.mFocusingTier = 0; + catalystHounsings.clear(); if (!checkPiece(MAIN_PIECE, 7, 20, 4)) { return false; } @@ -420,7 +431,7 @@ protected int getCasingTextureId() { @Override public RecipeMap getRecipeMap() { - return GTPPRecipeMaps.quantumForceTransformerRecipes; + return GTPPRecipeMaps.quantumForceTransformerRecipesNoCatalysts; } @Override @@ -441,26 +452,31 @@ protected CheckRecipeResult validateRecipe(@NotNull GTRecipe recipe) { if (recipe.mSpecialValue > getCraftingTier()) { return CheckRecipeResultRegistry.insufficientMachineTier(recipe.mSpecialValue); } - ItemStack catalyst = null; - for (ItemStack item : recipe.mInputs) { - if (ItemUtils.isCatalyst(item)) { - catalyst = item; + + int numberOfCatalyst = 0; + int catalystMeta = recipe.getMetadataOrDefault(GTRecipeConstants.QFT_CATALYST_META, -1); + if (catalystMeta != -1) { + if (catalystHounsings.isEmpty()) { + return SimpleCheckRecipeResult.ofFailure("no_catalyst"); + } + boolean catalystsFound = false; + for (MTEHatchBulkCatalystHousing catalystHousing : catalystHounsings) { + ItemStack storedCatalysts = catalystHousing.getItemStack(); + int storedCatalystMeta = catalystHousing.getStoredCatalystMeta(); + if (storedCatalysts == null || storedCatalystMeta != catalystMeta) { + continue; + } + numberOfCatalyst = catalystHousing.getItemCount(); + catalystsFound = true; break; } - } - - if (catalyst == null) { - return SimpleCheckRecipeResult.ofFailure("no_catalyst"); - } - - maxParallel = 0; - for (ItemStack item : inputItems) { - if (ItemUtils.isCatalyst(item) && item.isItemEqual(catalyst)) { - maxParallel += item.stackSize; + if (!catalystsFound) { + return SimpleCheckRecipeResult.ofFailure("no_catalyst"); } } - mMaxParallel = maxParallel; + mMaxParallel = numberOfCatalyst; + maxParallel = mMaxParallel; doFermium = false; doNeptunium = false; @@ -729,6 +745,48 @@ public boolean addFermiumHatch(IGregTechTileEntity aTileEntity, short aBaseCasin return false; } + public boolean addCatalystHousingToMachineList(IGregTechTileEntity tileEntity, int baseCasingIndex) { + if (tileEntity == null) return false; + IMetaTileEntity metaTileEntity = tileEntity.getMetaTileEntity(); + if (metaTileEntity instanceof MTEHatchBulkCatalystHousing catalystHousing) { + catalystHousing.updateTexture(baseCasingIndex); + this.catalystHounsings.add(catalystHousing); + return true; + } + return false; + } + + private enum SpecialHatchElement implements IHatchElement { + + CatalystHousing(MTEQuantumForceTransformer::addCatalystHousingToMachineList, + MTEHatchBulkCatalystHousing.class) { + + @Override + public long count(MTEQuantumForceTransformer gtMetaTileEntityQFT) { + return gtMetaTileEntityQFT.catalystHounsings.size(); + } + }; + + private final List> mteClasses; + private final IGTHatchAdder adder; + + @SafeVarargs + SpecialHatchElement(IGTHatchAdder adder, + Class... mteClasses) { + this.mteClasses = Collections.unmodifiableList(Arrays.asList(mteClasses)); + this.adder = adder; + } + + @Override + public List> mteClasses() { + return mteClasses; + } + + public IGTHatchAdder adder() { + return adder; + } + } + public Block getCasingBlock1() { return ModBlocks.blockCasings5Misc; } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/loaders/recipe/RecipeLoaderQFTNoCatalysts.java b/src/main/java/gtPlusPlus/xmod/gregtech/loaders/recipe/RecipeLoaderQFTNoCatalysts.java new file mode 100644 index 00000000000..2e68fcc6c44 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/loaders/recipe/RecipeLoaderQFTNoCatalysts.java @@ -0,0 +1,52 @@ +package gtPlusPlus.xmod.gregtech.loaders.recipe; + +import static gregtech.api.util.GTRecipeConstants.QFT_CATALYST_META; +import static gregtech.api.util.GTRecipeConstants.QFT_FOCUS_TIER; +import static gtPlusPlus.api.recipe.GTPPRecipeMaps.quantumForceTransformerRecipes; +import static gtPlusPlus.api.recipe.GTPPRecipeMaps.quantumForceTransformerRecipesNoCatalysts; + +import java.util.ArrayList; +import java.util.List; + +import net.minecraft.item.ItemStack; + +import gregtech.api.enums.GTValues; +import gregtech.api.util.GTRecipe; +import gregtech.api.util.GTRecipeBuilder; +import gtPlusPlus.core.util.minecraft.ItemUtils; + +public class RecipeLoaderQFTNoCatalysts { + + public static void generate() { + for (GTRecipe recipe : quantumForceTransformerRecipes.getAllRecipes()) { + List itemInputs = new ArrayList<>(); + + int meta = -1; + for (int i = 0; i < recipe.mInputs.length; i++) { + ItemStack stack = recipe.getRepresentativeInput(i); + if (stack == null) continue; + if (ItemUtils.isCatalyst(stack)) { + meta = stack.getItemDamage(); + continue; + } + itemInputs.add(stack); + } + + GTRecipeBuilder builder = GTValues.RA.stdBuilder() + .noOptimize() + .itemInputs(itemInputs.toArray(new ItemStack[0])) + .itemOutputs(recipe.mOutputs) + .fluidInputs(recipe.mFluidInputs) + .fluidOutputs(recipe.mFluidOutputs) + .duration(recipe.mDuration) + .eut(recipe.mEUt) + .hidden() + .metadata(QFT_FOCUS_TIER, recipe.getMetadata(QFT_FOCUS_TIER)); + + if (meta != -1) { + builder.metadata(QFT_CATALYST_META, meta); + } + builder.addTo(quantumForceTransformerRecipesNoCatalysts); + } + } +} From ee58e1ad5c3cd85c1800b8385b123cb3e423f043 Mon Sep 17 00:00:00 2001 From: GDCloud Date: Mon, 30 Dec 2024 03:17:53 +0100 Subject: [PATCH 17/27] add glow to regular catalyst housing --- .../nbthandlers/MTEHatchCatalysts.java | 22 ++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/nbthandlers/MTEHatchCatalysts.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/nbthandlers/MTEHatchCatalysts.java index ca8624a7d28..fcaec57ba25 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/nbthandlers/MTEHatchCatalysts.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/nbthandlers/MTEHatchCatalysts.java @@ -10,7 +10,7 @@ import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.MetaTileEntity; -import gregtech.api.objects.GTRenderedTexture; +import gregtech.api.render.TextureFactory; import gtPlusPlus.core.lib.GTPPCore; import gtPlusPlus.core.util.minecraft.ItemUtils; import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; @@ -27,12 +27,28 @@ public MTEHatchCatalysts(String aName, String[] aDescription, ITexture[][][] aTe @Override public ITexture[] getTexturesActive(ITexture aBaseTexture) { - return new ITexture[] { aBaseTexture, new GTRenderedTexture(TexturesGtBlock.Overlay_Bus_Catalyst) }; + return new ITexture[] { aBaseTexture, TextureFactory.builder() + .addIcon(TexturesGtBlock.Overlay_Bus_Catalyst) + .extFacing() + .build(), + TextureFactory.builder() + .addIcon(TexturesGtBlock.Overlay_Bus_Catalyst) + .extFacing() + .glow() + .build() }; } @Override public ITexture[] getTexturesInactive(ITexture aBaseTexture) { - return new ITexture[] { aBaseTexture, new GTRenderedTexture(TexturesGtBlock.Overlay_Bus_Catalyst) }; + return new ITexture[] { aBaseTexture, TextureFactory.builder() + .addIcon(TexturesGtBlock.Overlay_Bus_Catalyst) + .extFacing() + .build(), + TextureFactory.builder() + .addIcon(TexturesGtBlock.Overlay_Bus_Catalyst) + .extFacing() + .glow() + .build() }; } @Override From 45354d7c2327c2e7a65d6fa231520ae0d2bfdfda Mon Sep 17 00:00:00 2001 From: GDCloud Date: Mon, 30 Dec 2024 03:25:54 +0100 Subject: [PATCH 18/27] update tooltips --- .../tileentities/machines/multi/MTEPCBFactory.java | 9 ++++++++- .../multi/production/MTEQuantumForceTransformer.java | 6 ++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/MTEPCBFactory.java b/src/main/java/gregtech/common/tileentities/machines/multi/MTEPCBFactory.java index 3bd2c37a4db..b76fe28736c 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/MTEPCBFactory.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/MTEPCBFactory.java @@ -900,7 +900,14 @@ protected MultiblockTooltipBuilder createTooltip() { .addOutputBus(EnumChatFormatting.GOLD + "0" + EnumChatFormatting.GRAY + "+", 1) .addInputHatch(EnumChatFormatting.GOLD + "0" + EnumChatFormatting.GRAY + "+", 1) .addStructureInfo( - "Coolant Hatch (Input Hatch): " + EnumChatFormatting.GOLD + EnumChatFormatting.WHITE + "Nanite Containment Bus: " + + EnumChatFormatting.GOLD + + "0" + + EnumChatFormatting.GRAY + + "+") + .addStructureInfo( + EnumChatFormatting.WHITE + "Coolant Hatch (Input Hatch): " + + EnumChatFormatting.GOLD + "1" + EnumChatFormatting.GRAY + " Center of the Liquid Cooling/Thermosink") diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/MTEQuantumForceTransformer.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/MTEQuantumForceTransformer.java index 616e6d0b272..f7c43f6f498 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/MTEQuantumForceTransformer.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/MTEQuantumForceTransformer.java @@ -282,6 +282,12 @@ protected MultiblockTooltipBuilder createTooltip() { .addOutputHatch(EnumChatFormatting.AQUA + "Top" + EnumChatFormatting.GRAY + " Layer", 5) .addOutputBus(EnumChatFormatting.AQUA + "Top" + EnumChatFormatting.GRAY + " Layer", 5) .addEnergyHatch(EnumChatFormatting.BLUE + "Bottom" + EnumChatFormatting.GRAY + " Layer", 4) + .addStructureInfo( + EnumChatFormatting.WHITE + "Bulk Catalyst Housing: " + + EnumChatFormatting.BLUE + + "Bottom" + + EnumChatFormatting.GRAY + + " Layer") .addStructureInfo( EnumChatFormatting.WHITE + "Neptunium Plasma Hatch: " + EnumChatFormatting.GREEN From 554dccf60ed8c1ad86b666a3886981f74e288a64 Mon Sep 17 00:00:00 2001 From: GDCloud Date: Mon, 30 Dec 2024 17:33:10 +0100 Subject: [PATCH 19/27] add capacity to tooltip --- .../implementations/MTEHatchNonConsumableBase.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/gregtech/api/metatileentity/implementations/MTEHatchNonConsumableBase.java b/src/main/java/gregtech/api/metatileentity/implementations/MTEHatchNonConsumableBase.java index 52826a8778e..3126126f0d6 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/MTEHatchNonConsumableBase.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/MTEHatchNonConsumableBase.java @@ -135,6 +135,7 @@ public void addUIWidgets(ModularWindow.Builder builder, UIBuildContext buildCont @Override public void addAdditionalTooltipInformation(ItemStack stack, List tooltip) { + tooltip.add("Capacity: " + EnumChatFormatting.GOLD + getItemCapacity() + EnumChatFormatting.GRAY + " Items"); if (stack.hasTagCompound() && stack.stackTagCompound.hasKey("itemStack")) { final ItemStack tContents = ItemStack .loadItemStackFromNBT(stack.stackTagCompound.getCompoundTag("itemStack")); From 4d1e590be1946f721877f348250932a070918bdf Mon Sep 17 00:00:00 2001 From: GDCloud Date: Mon, 30 Dec 2024 18:41:50 +0100 Subject: [PATCH 20/27] bump nanite bus tier --- .../java/gregtech/loaders/preload/LoaderMetaTileEntities.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/gregtech/loaders/preload/LoaderMetaTileEntities.java b/src/main/java/gregtech/loaders/preload/LoaderMetaTileEntities.java index 9defc8e2164..f6f2cb92e43 100644 --- a/src/main/java/gregtech/loaders/preload/LoaderMetaTileEntities.java +++ b/src/main/java/gregtech/loaders/preload/LoaderMetaTileEntities.java @@ -12977,7 +12977,7 @@ public void run() { new MTEHatchLensIndicator(HATCH_LENS_INDICATOR.ID, "hatch.lensindicator", "Lens Indicator Hatch", 8) .getStackForm(1L)); ItemList.Hatch_Nanite.set( - new MTEHatchNanite(HATCH_NANITE.ID, "hatch.nanite", "Nanite Containment Bus", 8, 2048).getStackForm(1)); + new MTEHatchNanite(HATCH_NANITE.ID, "hatch.nanite", "Nanite Containment Bus", 9, 2048).getStackForm(1)); ItemList.Hatch_Catalyst_Bulk.set( new MTEHatchBulkCatalystHousing( HATCH_CATALYST_BULK.ID, From ad3ab293b45404849af5967d862a763758db1f60 Mon Sep 17 00:00:00 2001 From: GDCloud Date: Mon, 30 Dec 2024 23:31:31 +0100 Subject: [PATCH 21/27] fix controller texture --- .../production/MTEQuantumForceTransformer.java | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/MTEQuantumForceTransformer.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/MTEQuantumForceTransformer.java index f7c43f6f498..00f53a2b3d9 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/MTEQuantumForceTransformer.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/MTEQuantumForceTransformer.java @@ -830,22 +830,20 @@ public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, ForgeDirec int aColorIndex, boolean aActive, boolean aRedstone) { if (side == facing) { if (aActive) { - return new ITexture[] { Textures.BlockIcons.getCasingTextureForId(TAE.GTPP_INDEX(15)), - TextureFactory.builder() - .addIcon(TexturesGtBlock.oMCAQFTActive) - .extFacing() - .build(), + return new ITexture[] { getCasingTexture(), TextureFactory.builder() + .addIcon(TexturesGtBlock.oMCAQFTActive) + .extFacing() + .build(), TextureFactory.builder() .addIcon(TexturesGtBlock.oMCAQFTActiveGlow) .extFacing() .glow() .build() }; } - return new ITexture[] { Textures.BlockIcons.getCasingTextureForId(TAE.GTPP_INDEX(15)), - TextureFactory.builder() - .addIcon(TexturesGtBlock.oMCAQFT) - .extFacing() - .build(), + return new ITexture[] { getCasingTexture(), TextureFactory.builder() + .addIcon(TexturesGtBlock.oMCAQFT) + .extFacing() + .build(), TextureFactory.builder() .addIcon(TexturesGtBlock.oMCAQFTGlow) .extFacing() From be3b52dd40b32558469d4b8ad1030b94a2abedb4 Mon Sep 17 00:00:00 2001 From: GDCloud Date: Mon, 30 Dec 2024 23:31:40 +0100 Subject: [PATCH 22/27] add qft icon to recipemap --- src/main/java/gtPlusPlus/api/recipe/GTPPRecipeMaps.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/gtPlusPlus/api/recipe/GTPPRecipeMaps.java b/src/main/java/gtPlusPlus/api/recipe/GTPPRecipeMaps.java index 615ef0df702..cc6b17ee313 100644 --- a/src/main/java/gtPlusPlus/api/recipe/GTPPRecipeMaps.java +++ b/src/main/java/gtPlusPlus/api/recipe/GTPPRecipeMaps.java @@ -22,6 +22,7 @@ import gregtech.nei.formatter.SimpleSpecialValueFormatter; import gtPlusPlus.core.util.math.MathUtils; import gtPlusPlus.core.util.minecraft.ItemUtils; +import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; import gtPlusPlus.xmod.gregtech.api.gui.GTPPUITextures; import gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production.MTETreeFarm; @@ -50,6 +51,7 @@ public class GTPPRecipeMaps { .maxIO(6, 6, 6, 6) .minInputs(1, 0) .progressBar(GTUITextures.PROGRESSBAR_ARROW_MULTIPLE) + .neiHandlerInfo(builder -> builder.setDisplayStack(GregtechItemList.QuantumForceTransformer.get(1))) .neiSpecialInfoFormatter(new SimpleSpecialValueFormatter("GT5U.nei.tier")) .frontend(QuantumForceTransformerFrontend::new) .disableOptimize() From f01612d8a71676a70fc693dd18e13eb42c2f90fd Mon Sep 17 00:00:00 2001 From: GDCloud Date: Tue, 7 Jan 2025 00:49:15 +0100 Subject: [PATCH 23/27] add mention of new hatches to tooltips --- .../common/tileentities/machines/multi/MTEPCBFactory.java | 1 + .../multi/production/MTEQuantumForceTransformer.java | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/MTEPCBFactory.java b/src/main/java/gregtech/common/tileentities/machines/multi/MTEPCBFactory.java index b76fe28736c..11ecfbddb60 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/MTEPCBFactory.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/MTEPCBFactory.java @@ -874,6 +874,7 @@ protected MultiblockTooltipBuilder createTooltip() { .addInfo("Each tier and upgrade requires additional structures.") .addInfo("Power consumption is multiplied by Sqrt(structures).") .addInfo("Tier 2 and 3 allow parallel by using extra nanites.") + .addInfo("Nanites have to be placed in a Nanite Containment Bus.") .addInfo("The formula for parallels is the amount of nanites^0.75, rounded up.") .addInfo("Maximum parallel is 256.") .addInfo("Recipes require a cooling upgrade to be overclocked.") diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/MTEQuantumForceTransformer.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/MTEQuantumForceTransformer.java index 00f53a2b3d9..cf6940f3baf 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/MTEQuantumForceTransformer.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/MTEQuantumForceTransformer.java @@ -255,15 +255,16 @@ protected MultiblockTooltipBuilder createTooltip() { tt.addMachineType("Quantum Force Transformer, QFT") .addInfo("Allows Complex chemical lines to be performed instantly in one step") .addInfo("Every recipe requires a catalyst, each catalyst adds 1 parallel and lasts forever") + .addInfo("Catalysts have to be placed in a Bulk Catalyst Housing") .addInfo("All inputs go on the bottom, all outputs go on the top") .addInfo("Put a circuit in the controller to specify the focused output") - .addInfo("Check NEI to see the order of outputs, and which circuit number you need.") + .addInfo("Check NEI to see the order of outputs, and which circuit number you need") .addInfo("If separate input busses are enabled put the circuit in the circuit slot of the bus") .addInfo("Uses FocusTier*4*sqrt(parallels) Neptunium Plasma if focusing") .addInfo("Can use FocusTier*4*sqrt(parallels) Fermium Plasma for additional chance output") .addInfo("Use a screwdriver to enable Fluid mode") .addInfo( - "Fluid mode turns all possible outputs into their fluid variant, those which can't are left as they were.") + "Fluid mode turns all possible outputs into their fluid variant, those which can't are left as they were") .addInfo("This multi gets improved when all casings of some types are upgraded") .addInfo("Casing functions:") .addInfo("Pulse Manipulators: Recipe Tier Allowed (check NEI for the tier of each recipe)") From 79d1f7e27c6c1a78ab2699b4f84aab9d6484821a Mon Sep 17 00:00:00 2001 From: Martin Robertz Date: Thu, 9 Jan 2025 19:29:39 +0100 Subject: [PATCH 24/27] Update ItemList.java --- src/main/java/gregtech/api/enums/ItemList.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/gregtech/api/enums/ItemList.java b/src/main/java/gregtech/api/enums/ItemList.java index ccb4f3292e4..2e3046e0904 100644 --- a/src/main/java/gregtech/api/enums/ItemList.java +++ b/src/main/java/gregtech/api/enums/ItemList.java @@ -2599,6 +2599,7 @@ public enum ItemList implements IItemContainer { Casing_AirFilter_Turbine_T3, Casing_AirFilter_Vent_T3, Casing_Pyrolyse, + NameRemover, Hatch_Nanite, Hatch_Catalyst_Bulk, Machine_Multi_AirFilterT1, From c82587afdcf544acf22e8e8693aed15012f4b859 Mon Sep 17 00:00:00 2001 From: Martin Robertz Date: Thu, 9 Jan 2025 19:30:45 +0100 Subject: [PATCH 25/27] Update Textures.java --- src/main/java/gregtech/api/enums/Textures.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/java/gregtech/api/enums/Textures.java b/src/main/java/gregtech/api/enums/Textures.java index 2e7a0534aac..9c3a8414edd 100644 --- a/src/main/java/gregtech/api/enums/Textures.java +++ b/src/main/java/gregtech/api/enums/Textures.java @@ -1462,7 +1462,10 @@ public enum BlockIcons implements IIconContainer, Runnable { RADIATION_ABSORBENT_CASING, HAWKING_GLASS, OVERLAY_NANITE_HATCH, - OVERLAY_NANITE_HATCH_GLOW,; + OVERLAY_NANITE_HATCH_GLOW + + // semicolon after the comment to reduce merge conflicts + ; /** * Icon for Fresh CFoam From 06023c69088d5515a82d8969e18f5e2ec2a7b181 Mon Sep 17 00:00:00 2001 From: Martin Robertz Date: Thu, 9 Jan 2025 19:31:41 +0100 Subject: [PATCH 26/27] sa --- src/main/java/gregtech/api/enums/ItemList.java | 2 +- src/main/java/gregtech/api/enums/Textures.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/gregtech/api/enums/ItemList.java b/src/main/java/gregtech/api/enums/ItemList.java index 2e3046e0904..8c507ee0b77 100644 --- a/src/main/java/gregtech/api/enums/ItemList.java +++ b/src/main/java/gregtech/api/enums/ItemList.java @@ -2606,7 +2606,7 @@ public enum ItemList implements IItemContainer { Machine_Multi_AirFilterT2, Machine_Multi_AirFilterT3, - // semicolon after the comment to reduce merge conflicts + // semicolon after the comment to reduce merge conflicts ; public static final ItemList[] DYE_ONLY_ITEMS = { Color_00, Color_01, Color_02, Color_03, Color_04, Color_05, diff --git a/src/main/java/gregtech/api/enums/Textures.java b/src/main/java/gregtech/api/enums/Textures.java index 9c3a8414edd..77923258cf8 100644 --- a/src/main/java/gregtech/api/enums/Textures.java +++ b/src/main/java/gregtech/api/enums/Textures.java @@ -1463,7 +1463,7 @@ public enum BlockIcons implements IIconContainer, Runnable { HAWKING_GLASS, OVERLAY_NANITE_HATCH, OVERLAY_NANITE_HATCH_GLOW - + // semicolon after the comment to reduce merge conflicts ; From 4f971465889fb779a7515e3039a28a695f8cf782 Mon Sep 17 00:00:00 2001 From: GDCloud Date: Sat, 11 Jan 2025 00:22:48 +0100 Subject: [PATCH 27/27] refactor recipe addition to use downstream --- src/main/java/bartworks/MainMod.java | 2 - .../java/gregtech/api/recipe/RecipeMaps.java | 24 ++++++++ .../loaders/postload/MachineRecipeLoader.java | 2 - .../chains/PCBFactoryRecipesNoNanites.java | 55 ------------------- .../gtPlusPlus/api/recipe/GTPPRecipeMaps.java | 32 ++++++++++- .../recipe/RecipeLoaderQFTNoCatalysts.java | 52 ------------------ 6 files changed, 55 insertions(+), 112 deletions(-) delete mode 100644 src/main/java/gregtech/loaders/postload/chains/PCBFactoryRecipesNoNanites.java delete mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/loaders/recipe/RecipeLoaderQFTNoCatalysts.java diff --git a/src/main/java/bartworks/MainMod.java b/src/main/java/bartworks/MainMod.java index de9921865cc..a321718b17f 100644 --- a/src/main/java/bartworks/MainMod.java +++ b/src/main/java/bartworks/MainMod.java @@ -71,7 +71,6 @@ import gregtech.api.enums.Mods; import gregtech.api.recipe.RecipeMap; import gregtech.api.recipe.check.CheckRecipeResultRegistry; -import gtPlusPlus.xmod.gregtech.loaders.recipe.RecipeLoaderQFTNoCatalysts; import tectech.loader.recipe.Godforge; @Mod( @@ -211,7 +210,6 @@ public static void runOnPlayerJoined(boolean classicMode, boolean disableExtraGa // because the above code runs so late that I couldn't find anywhere else to call this if (!recipesAdded) Godforge.initMoltenModuleRecipes(); - if (!recipesAdded) RecipeLoaderQFTNoCatalysts.generate(); recipesAdded = true; } diff --git a/src/main/java/gregtech/api/recipe/RecipeMaps.java b/src/main/java/gregtech/api/recipe/RecipeMaps.java index 5fcf924db9b..701ba5697a4 100644 --- a/src/main/java/gregtech/api/recipe/RecipeMaps.java +++ b/src/main/java/gregtech/api/recipe/RecipeMaps.java @@ -24,6 +24,7 @@ import java.util.Collection; import java.util.Collections; import java.util.Comparator; +import java.util.List; import java.util.Optional; import net.minecraft.init.Blocks; @@ -1236,5 +1237,28 @@ && isArrayEmptyOrNull(b.getFluidOutputs()) b.copy() .duration(1 * TICK) .eut(TierEU.RECIPE_UEV)))); + RecipeMaps.pcbFactoryRecipes.addDownstream(IRecipeMap.newRecipeMap(b -> { + b = b.copy(); + List itemInputs = new ArrayList<>(); + + Materials naniteMaterial = null; + for (int i = 0; i < b.getItemInputsBasic().length; i++) { + ItemStack stack = b.getItemInputBasic(i); + if (stack == null) continue; + ItemData data = GTOreDictUnificator.getAssociation(stack); + if (data != null && data.mPrefix != null && data.mPrefix.equals(OrePrefixes.nanite)) { + naniteMaterial = data.mMaterial.mMaterial; + continue; + } + itemInputs.add(stack); + } + + if (naniteMaterial != null) { + b.metadata(GTRecipeConstants.PCB_NANITE_MATERIAL, naniteMaterial); + } + return RecipeMaps.pcbFactoryRecipesNoNanites.doAdd( + b.itemInputs(itemInputs.toArray(new ItemStack[0])) + .hidden()); + })); } } diff --git a/src/main/java/gregtech/loaders/postload/MachineRecipeLoader.java b/src/main/java/gregtech/loaders/postload/MachineRecipeLoader.java index be8c5ffb6b3..c64ea6cf7b5 100644 --- a/src/main/java/gregtech/loaders/postload/MachineRecipeLoader.java +++ b/src/main/java/gregtech/loaders/postload/MachineRecipeLoader.java @@ -4,7 +4,6 @@ import gregtech.loaders.postload.chains.BauxiteRefineChain; import gregtech.loaders.postload.chains.NaniteChain; import gregtech.loaders.postload.chains.PCBFactoryRecipes; -import gregtech.loaders.postload.chains.PCBFactoryRecipesNoNanites; import gregtech.loaders.postload.chains.PurifiedWaterRecipes; import gregtech.loaders.postload.recipes.AlloySmelterRecipes; import gregtech.loaders.postload.recipes.ArcFurnaceRecipes; @@ -122,7 +121,6 @@ public void run() { BauxiteRefineChain.run(); NaniteChain.run(); PCBFactoryRecipes.load(); - PCBFactoryRecipesNoNanites.load(); PurifiedWaterRecipes.run(); } } diff --git a/src/main/java/gregtech/loaders/postload/chains/PCBFactoryRecipesNoNanites.java b/src/main/java/gregtech/loaders/postload/chains/PCBFactoryRecipesNoNanites.java deleted file mode 100644 index 44fdd275924..00000000000 --- a/src/main/java/gregtech/loaders/postload/chains/PCBFactoryRecipesNoNanites.java +++ /dev/null @@ -1,55 +0,0 @@ -package gregtech.loaders.postload.chains; - -import java.util.ArrayList; -import java.util.List; - -import net.minecraft.item.ItemStack; - -import gregtech.api.enums.GTValues; -import gregtech.api.enums.Materials; -import gregtech.api.enums.OrePrefixes; -import gregtech.api.objects.ItemData; -import gregtech.api.recipe.RecipeMaps; -import gregtech.api.recipe.metadata.PCBFactoryTierKey; -import gregtech.api.util.GTOreDictUnificator; -import gregtech.api.util.GTRecipe; -import gregtech.api.util.GTRecipeBuilder; -import gregtech.api.util.GTRecipeConstants; - -public class PCBFactoryRecipesNoNanites { - - private static final PCBFactoryTierKey TIER = PCBFactoryTierKey.INSTANCE; - - public static void load() { - for (GTRecipe recipe : RecipeMaps.pcbFactoryRecipes.getAllRecipes()) { - List itemInputs = new ArrayList<>(); - - Materials naniteMaterial = null; - for (int i = 0; i < recipe.mInputs.length; i++) { - ItemStack stack = recipe.getRepresentativeInput(i); - if (stack == null) continue; - ItemData data = GTOreDictUnificator.getAssociation(stack); - if (data != null && data.mPrefix != null && data.mPrefix.equals(OrePrefixes.nanite)) { - naniteMaterial = data.mMaterial.mMaterial; - continue; - } - itemInputs.add(stack); - } - - GTRecipeBuilder builder = GTValues.RA.stdBuilder() - .noOptimize() - .itemInputs(itemInputs.toArray(new ItemStack[0])) - .itemOutputs(recipe.mOutputs) - .fluidInputs(recipe.mFluidInputs) - .duration(recipe.mDuration) - .eut(recipe.mEUt) - .hidden() - .metadata(TIER, recipe.getMetadata(TIER)); - - if (naniteMaterial != null) { - builder.metadata(GTRecipeConstants.PCB_NANITE_MATERIAL, naniteMaterial); - } - builder.addTo(RecipeMaps.pcbFactoryRecipesNoNanites); - } - } -} diff --git a/src/main/java/gtPlusPlus/api/recipe/GTPPRecipeMaps.java b/src/main/java/gtPlusPlus/api/recipe/GTPPRecipeMaps.java index c2953307987..2ee6ff219a6 100644 --- a/src/main/java/gtPlusPlus/api/recipe/GTPPRecipeMaps.java +++ b/src/main/java/gtPlusPlus/api/recipe/GTPPRecipeMaps.java @@ -1,15 +1,20 @@ package gtPlusPlus.api.recipe; import static gregtech.api.util.GTRecipeConstants.LFTR_OUTPUT_POWER; +import static gregtech.api.util.GTRecipeConstants.QFT_CATALYST_META; +import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; +import java.util.List; +import net.minecraft.item.ItemStack; import net.minecraft.util.StatCollector; import com.gtnewhorizons.modularui.common.widget.ProgressBar; import gregtech.api.gui.modularui.GTUITextures; +import gregtech.api.interfaces.IRecipeMap; import gregtech.api.recipe.RecipeMap; import gregtech.api.recipe.RecipeMapBackend; import gregtech.api.recipe.RecipeMapBuilder; @@ -59,7 +64,7 @@ public class GTPPRecipeMaps { public static final RecipeMap quantumForceTransformerRecipesNoCatalysts = RecipeMapBuilder .of("gtpp.recipe.quantumforcesmelternocatalysts") .maxIO(6, 6, 6, 6) - .minInputs(1, 0) + .minInputs(0, 0) .disableOptimize() .build(); public static final RecipeMap chemicalDehydratorRecipes = RecipeMapBuilder @@ -249,4 +254,29 @@ public class GTPPRecipeMaps { .maxIO(2, 1, 0, 0) .disableRegisterNEI() .build(); + + static { + GTPPRecipeMaps.quantumForceTransformerRecipes.addDownstream(IRecipeMap.newRecipeMap(b -> { + b = b.copy(); + List itemInputs = new ArrayList<>(); + + int meta = -1; + for (int i = 0; i < b.getItemInputsBasic().length; i++) { + ItemStack stack = b.getItemInputBasic(i); + if (stack == null) continue; + if (ItemUtils.isCatalyst(stack)) { + meta = stack.getItemDamage(); + continue; + } + itemInputs.add(stack); + } + + if (meta != -1) { + b.metadata(QFT_CATALYST_META, meta); + } + return GTPPRecipeMaps.quantumForceTransformerRecipesNoCatalysts.doAdd( + b.itemInputs(itemInputs.toArray(new ItemStack[0])) + .hidden()); + })); + } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/loaders/recipe/RecipeLoaderQFTNoCatalysts.java b/src/main/java/gtPlusPlus/xmod/gregtech/loaders/recipe/RecipeLoaderQFTNoCatalysts.java deleted file mode 100644 index 2e68fcc6c44..00000000000 --- a/src/main/java/gtPlusPlus/xmod/gregtech/loaders/recipe/RecipeLoaderQFTNoCatalysts.java +++ /dev/null @@ -1,52 +0,0 @@ -package gtPlusPlus.xmod.gregtech.loaders.recipe; - -import static gregtech.api.util.GTRecipeConstants.QFT_CATALYST_META; -import static gregtech.api.util.GTRecipeConstants.QFT_FOCUS_TIER; -import static gtPlusPlus.api.recipe.GTPPRecipeMaps.quantumForceTransformerRecipes; -import static gtPlusPlus.api.recipe.GTPPRecipeMaps.quantumForceTransformerRecipesNoCatalysts; - -import java.util.ArrayList; -import java.util.List; - -import net.minecraft.item.ItemStack; - -import gregtech.api.enums.GTValues; -import gregtech.api.util.GTRecipe; -import gregtech.api.util.GTRecipeBuilder; -import gtPlusPlus.core.util.minecraft.ItemUtils; - -public class RecipeLoaderQFTNoCatalysts { - - public static void generate() { - for (GTRecipe recipe : quantumForceTransformerRecipes.getAllRecipes()) { - List itemInputs = new ArrayList<>(); - - int meta = -1; - for (int i = 0; i < recipe.mInputs.length; i++) { - ItemStack stack = recipe.getRepresentativeInput(i); - if (stack == null) continue; - if (ItemUtils.isCatalyst(stack)) { - meta = stack.getItemDamage(); - continue; - } - itemInputs.add(stack); - } - - GTRecipeBuilder builder = GTValues.RA.stdBuilder() - .noOptimize() - .itemInputs(itemInputs.toArray(new ItemStack[0])) - .itemOutputs(recipe.mOutputs) - .fluidInputs(recipe.mFluidInputs) - .fluidOutputs(recipe.mFluidOutputs) - .duration(recipe.mDuration) - .eut(recipe.mEUt) - .hidden() - .metadata(QFT_FOCUS_TIER, recipe.getMetadata(QFT_FOCUS_TIER)); - - if (meta != -1) { - builder.metadata(QFT_CATALYST_META, meta); - } - builder.addTo(quantumForceTransformerRecipesNoCatalysts); - } - } -}