Skip to content
This repository has been archived by the owner on May 26, 2024. It is now read-only.

add new solidifier hatches for industrial multi machine #810

Merged
merged 3 commits into from
Feb 27, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions src/main/java/gtPlusPlus/core/recipe/RECIPES_Machines.java
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,7 @@ private static void run() {
thermicFluidHeater();
advHeatExchanger();
chiselBuses();
solidifierHatches();

gt4FarmManager();
gt4Inventory();
Expand Down Expand Up @@ -3040,4 +3041,26 @@ private static void chiselBuses() {
}
}

private static void solidifierHatches() {
ItemStack[] mSuperBusesInput = new ItemStack[] { ItemList.Hatch_Input_IV.get(1),
ItemList.Hatch_Input_LuV.get(1), ItemList.Hatch_Input_ZPM.get(1), ItemList.Hatch_Input_UV.get(1), };

ItemStack[] mSolidifierHatches = new ItemStack[] { GregtechItemList.GT_MetaTileEntity_Solidifier_I.get(1),
GregtechItemList.GT_MetaTileEntity_Solidifier_II.get(1),
GregtechItemList.GT_MetaTileEntity_Solidifier_III.get(1),
GregtechItemList.GT_MetaTileEntity_Solidifier_IV.get(1), };

for (int i = 0; i < 4; i++) {
int componentTier = i + 5;
CORE.RA.addSixSlotAssemblingRecipe(
new ItemStack[] { CI.getNumberedCircuit(17), mSuperBusesInput[i], CI.getSensor(componentTier, 1),
CI.getFluidRegulator(componentTier, 1),
CI.getTieredComponent(OrePrefixes.circuit, componentTier + 1, 4),
ItemUtils.getSimpleStack(Blocks.chest) },
CI.getTieredFluid(componentTier, 144 * 2),
mSolidifierHatches[i],
20 * 30,
(int) GT_Values.VP[componentTier]);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -560,6 +560,12 @@ public enum GregtechItemList implements GregtechItemContainer {
GT_MetaTileEntity_ChiselBus_MV,
GT_MetaTileEntity_ChiselBus_HV,

// Solidifier Hatches for Industrial Multi Machine
GT_MetaTileEntity_Solidifier_I,
GT_MetaTileEntity_Solidifier_II,
GT_MetaTileEntity_Solidifier_III,
GT_MetaTileEntity_Solidifier_IV,

// ----------------------------------------------------------------------------

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
package gtPlusPlus.xmod.gregtech.api.metatileentity.implementations;

import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumChatFormatting;

import com.gtnewhorizons.modularui.api.screen.ModularWindow;
import com.gtnewhorizons.modularui.api.screen.UIBuildContext;
import com.gtnewhorizons.modularui.common.widget.SlotWidget;

import gregtech.api.interfaces.ITexture;
import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
import gregtech.api.metatileentity.MetaTileEntity;
import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Input;
import gregtech.api.util.GT_Utility;

public class GT_MetaTileEntity_Hatch_Solidifier extends GT_MetaTileEntity_Hatch_Input {

static final int moldSlot = 2;

public GT_MetaTileEntity_Hatch_Solidifier(int aID, String aName, String aNameRegional, int aTier) {
super(aID, aName, aNameRegional, aTier);
}

@Override
public String[] getDescription() {
return new String[] {
"Fluid Input with Mold for " + EnumChatFormatting.YELLOW
+ "Large Processing Array"
Dream-Master marked this conversation as resolved.
Show resolved Hide resolved
+ EnumChatFormatting.RESET,
"#22 Circuit is imprinted in Hatch", "Capacity: " + GT_Utility.formatNumbers(getCapacity()) + "L",
"Added by: " + EnumChatFormatting.AQUA
+ "Quetz4l"
+ " - "
+ EnumChatFormatting.RED
+ "[GT++]"
+ EnumChatFormatting.RESET };
}

public GT_MetaTileEntity_Hatch_Solidifier(String aName, int aTier, String[] aDescription,
ITexture[][][] aTextures) {
super(aName, getSlots(aTier), aTier, aDescription, aTextures);
}

@Override
public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) {
return new GT_MetaTileEntity_Hatch_Solidifier(mName, mTier, mDescriptionArray, mTextures);
}

public ItemStack getMold() {
return this.getStackInSlot(moldSlot);
}

@Override
public void addUIWidgets(ModularWindow.Builder builder, UIBuildContext buildContext) {
super.addUIWidgets(builder, buildContext);
builder.widget(new SlotWidget(inventoryHandler, moldSlot).setPos(125, 35).setSize(18, 18));
}

@Override
public void onBlockDestroyed() {
super.onBlockDestroyed();
}

// for a drop-down form when the hatch is destroyed
@Override
public boolean isValidSlot(int aIndex) {
if (aIndex == moldSlot) return true;
else return super.isValidSlot(aIndex);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,13 @@
import static gregtech.api.enums.GT_HatchElement.OutputBus;
import static gregtech.api.enums.GT_HatchElement.OutputHatch;
import static gregtech.api.util.GT_StructureUtility.buildHatchAdder;
import static gregtech.api.util.GT_Utility.filterValidMTEs;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import java.util.Optional;
import java.util.stream.Stream;

import javax.annotation.Nonnull;
Expand All @@ -30,7 +32,9 @@
import net.minecraft.util.StatCollector;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.FluidStack;

import com.google.common.collect.Lists;
import com.gtnewhorizon.structurelib.alignment.constructable.ISurvivalConstructable;
import com.gtnewhorizon.structurelib.structure.IStructureDefinition;
import com.gtnewhorizon.structurelib.structure.ISurvivalBuildEnvironment;
Expand All @@ -41,16 +45,26 @@
import gregtech.api.interfaces.metatileentity.IMetaTileEntity;
import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
import gregtech.api.logic.ProcessingLogic;
import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Input;
import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_InputBus;
import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_MultiInput;
import gregtech.api.recipe.RecipeMap;
import gregtech.api.recipe.RecipeMaps;
import gregtech.api.recipe.check.CheckRecipeResult;
import gregtech.api.recipe.check.CheckRecipeResultRegistry;
import gregtech.api.util.GT_LanguageManager;
import gregtech.api.util.GT_Multiblock_Tooltip_Builder;
import gregtech.api.util.GT_Recipe;
import gregtech.api.util.GT_Utility;
import gregtech.common.tileentities.machines.GT_MetaTileEntity_Hatch_Input_ME;
import gregtech.common.tileentities.machines.IDualInputHatch;
import gregtech.common.tileentities.machines.IDualInputInventory;
import gtPlusPlus.core.block.ModBlocks;
import gtPlusPlus.core.lib.CORE;
import gtPlusPlus.core.recipe.common.CI;
import gtPlusPlus.core.util.minecraft.ItemUtils;
import gtPlusPlus.core.util.minecraft.PlayerUtils;
import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Solidifier;
import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase;
import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock;
import mcp.mobius.waila.api.IWailaConfigHandler;
Expand Down Expand Up @@ -127,6 +141,9 @@ protected GT_Multiblock_Tooltip_Builder createTooltip() {
+ aBuiltStrings[2]
+ EnumChatFormatting.RESET)
.addInfo("Read Multi-Machine Manual for extra information")
.addInfo(
EnumChatFormatting.AQUA + "You can use Solidifier Hatch to solidify multiple liquids."
+ EnumChatFormatting.RESET)
.addPollutionAmount(getPollutionPerSecond(null)).addSeparator().beginStructureBlock(3, 3, 3, true)
.addController("Front Center").addCasingInfoMin("Multi-Use Casings", 6, false)
.addInputBus("Any Casing", 1).addOutputBus("Any Casing", 1).addInputHatch("Any Casing", 1)
Expand Down Expand Up @@ -362,6 +379,130 @@ public void getWailaNBTData(EntityPlayerMP player, TileEntity tile, NBTTagCompou
tag.setInteger("mode", mInternalMode);
}

@Override
protected CheckRecipeResult doCheckRecipe() {

if (mInternalMode != 2 || !isInputSeparationEnabled()) {
return super.doCheckRecipe();
} else {
CheckRecipeResult result = CheckRecipeResultRegistry.NO_RECIPE;

// check crafting input hatches first
if (supportsCraftingMEBuffer()) {
for (IDualInputHatch dualInputHatch : mDualInputHatches) {
for (var it = dualInputHatch.inventories(); it.hasNext();) {
IDualInputInventory slot = it.next();
processingLogic.setInputItems(slot.getItemInputs());
processingLogic.setInputFluids(slot.getFluidInputs());
CheckRecipeResult foundResult = processingLogic.process();
if (foundResult.wasSuccessful()) {
return foundResult;
}
if (foundResult != CheckRecipeResultRegistry.NO_RECIPE) {
// Recipe failed in interesting way, so remember that and continue searching
result = foundResult;
}
}
}
}

// Logic for GT_MetaTileEntity_Hatch_Solidifier
for (GT_MetaTileEntity_Hatch_Input solidifierHatch : mInputHatches) {
if (solidifierHatch instanceof GT_MetaTileEntity_Hatch_Solidifier) {
ItemStack mold = ((GT_MetaTileEntity_Hatch_Solidifier) solidifierHatch).getMold();
FluidStack fluid = solidifierHatch.getFluid();

if (mold != null && fluid != null) {
List<ItemStack> inputItems = new ArrayList<>();
inputItems.add(mold);
inputItems.add(ItemUtils.getGregtechCircuit(22));

processingLogic.setInputItems(inputItems.toArray(new ItemStack[0]));
processingLogic.setInputFluids(fluid);

CheckRecipeResult foundResult = processingLogic.process();
if (foundResult.wasSuccessful()) {
return foundResult;
}
if (foundResult != CheckRecipeResultRegistry.NO_RECIPE) {
// Recipe failed in interesting way, so remember that and continue searching
result = foundResult;
}
}
}
}
processingLogic.clear();
processingLogic.setInputFluids(getStoredFluids());
// Default logic
for (GT_MetaTileEntity_Hatch_InputBus bus : mInputBusses) {
List<ItemStack> inputItems = new ArrayList<>();
for (int i = bus.getSizeInventory() - 1; i >= 0; i--) {
ItemStack stored = bus.getStackInSlot(i);
if (stored != null) {
inputItems.add(stored);
}
}
if (canUseControllerSlotForRecipe() && getControllerSlot() != null) {
inputItems.add(getControllerSlot());
}
processingLogic.setInputItems(inputItems.toArray(new ItemStack[0]));
CheckRecipeResult foundResult = processingLogic.process();
if (foundResult.wasSuccessful()) {
return foundResult;
}
if (foundResult != CheckRecipeResultRegistry.NO_RECIPE) {
// Recipe failed in interesting way, so remember that and continue searching
result = foundResult;
}
}

return result;
}
}

@Override
public ArrayList<FluidStack> getStoredFluids() {
if (supportsCraftingMEBuffer()) {
for (IDualInputHatch tHatch : mDualInputHatches) {
if (tHatch.supportsFluids()) {
Optional<IDualInputInventory> inventory = tHatch.getFirstNonEmptyInventory();
if (inventory.isPresent()) {
return Lists.newArrayList(inventory.get().getFluidInputs());
}
}
}
}

ArrayList<FluidStack> rList = new ArrayList<>();
for (GT_MetaTileEntity_Hatch_Input tHatch : filterValidMTEs(mInputHatches)) {
if (tHatch instanceof GT_MetaTileEntity_Hatch_Solidifier) {
continue;
}

setHatchRecipeMap(tHatch);
if (tHatch instanceof GT_MetaTileEntity_Hatch_MultiInput) {
for (FluidStack tFluid : ((GT_MetaTileEntity_Hatch_MultiInput) tHatch).getStoredFluid()) {
if (tFluid != null) {
rList.add(tFluid);
}
}
} else if (tHatch instanceof GT_MetaTileEntity_Hatch_Input_ME) {
if (isValidMetaTileEntity(tHatch)) {
for (FluidStack fluidStack : ((GT_MetaTileEntity_Hatch_Input_ME) tHatch).getStoredFluids()) {
if (fluidStack == null) continue;
rList.add(fluidStack);
}
}
} else {
if (tHatch.getFillableStack() != null) {
rList.add(tHatch.getFillableStack());
}
}
}

return rList;
}

@Override
public void getWailaBody(ItemStack itemStack, List<String> currentTip, IWailaDataAccessor accessor,
IWailaConfigHandler config) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Muffler_Adv;
import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Naquadah;
import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Reservoir;
import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Solidifier;
import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_TurbineProvider;
import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.GT_MetaTileEntity_SuperBus_Input;
import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.GT_MetaTileEntity_SuperBus_Output;
Expand All @@ -26,6 +27,7 @@ public static void run() {
}
run3();
run4(); // Chisel buses
run6(); // Solidifier hatches
}

private static void run1() {
Expand Down Expand Up @@ -242,7 +244,7 @@ private static GT_MetaTileEntity_ChiselBus makeChiselBus(int id, String unlocali
}

private static void run4() {
int aID = 31778;
int aID = 31778; // 31778 - 31780

GregtechItemList.GT_MetaTileEntity_ChiselBus_LV
.set((makeChiselBus(aID++, "hatch.chisel.tier.01", "Chisel Bus I", 1)).getStackForm(1L));
Expand All @@ -252,4 +254,22 @@ private static void run4() {
.set((makeChiselBus(aID++, "hatch.chisel.tier.03", "Chisel Bus III", 3)).getStackForm(1L));

}

private static void run6() {
int aID = 31781; // 31781-31784

GregtechItemList.GT_MetaTileEntity_Solidifier_I.set(
new GT_MetaTileEntity_Hatch_Solidifier(aID++, "hatch.solidifier.tier.05", "Solidifier Hatch I", 5)
.getStackForm(1L));
GregtechItemList.GT_MetaTileEntity_Solidifier_II.set(
new GT_MetaTileEntity_Hatch_Solidifier(aID++, "hatch.solidifier.tier.06", "Solidifier Hatch II", 6)
.getStackForm(1L));
GregtechItemList.GT_MetaTileEntity_Solidifier_III.set(
new GT_MetaTileEntity_Hatch_Solidifier(aID++, "hatch.solidifier.tier.07", "Solidifier Hatch III", 7)
.getStackForm(1L));
GregtechItemList.GT_MetaTileEntity_Solidifier_IV.set(
new GT_MetaTileEntity_Hatch_Solidifier(aID, "hatch.solidifier.tier.08", "Solidifier Hatch IV", 8)
.getStackForm(1L));
}

}