diff options
| author | Raven Szewczyk <git@eigenraven.me> | 2024-05-25 15:39:05 +0100 |
|---|---|---|
| committer | Raven Szewczyk <git@eigenraven.me> | 2024-05-25 15:39:05 +0100 |
| commit | db88561e8e21fb8b067bf5bf1a1753697d36ed29 (patch) | |
| tree | 7a928f7502c46571b41dfa647151c253064cd5fb /src/main/java/com/elisis/gtnhlanth/common/tileentity | |
| parent | 9069e2aa47be7e6fb6ab1a2a29c5887ec2bfb2d7 (diff) | |
| download | GT5-Unofficial-db88561e8e21fb8b067bf5bf1a1753697d36ed29.tar.gz GT5-Unofficial-db88561e8e21fb8b067bf5bf1a1753697d36ed29.tar.bz2 GT5-Unofficial-db88561e8e21fb8b067bf5bf1a1753697d36ed29.zip | |
Merge Lanthanides sources
Diffstat (limited to 'src/main/java/com/elisis/gtnhlanth/common/tileentity')
| -rw-r--r-- | src/main/java/com/elisis/gtnhlanth/common/tileentity/Digester.java | 244 | ||||
| -rw-r--r-- | src/main/java/com/elisis/gtnhlanth/common/tileentity/DissolutionTank.java | 277 |
2 files changed, 521 insertions, 0 deletions
diff --git a/src/main/java/com/elisis/gtnhlanth/common/tileentity/Digester.java b/src/main/java/com/elisis/gtnhlanth/common/tileentity/Digester.java new file mode 100644 index 0000000000..479569c7f6 --- /dev/null +++ b/src/main/java/com/elisis/gtnhlanth/common/tileentity/Digester.java @@ -0,0 +1,244 @@ +package com.elisis.gtnhlanth.common.tileentity; + +import static com.elisis.gtnhlanth.util.DescTextLocalization.BLUEPRINT_INFO; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; +import static gregtech.api.enums.GT_HatchElement.Energy; +import static gregtech.api.enums.GT_HatchElement.InputBus; +import static gregtech.api.enums.GT_HatchElement.InputHatch; +import static gregtech.api.enums.GT_HatchElement.Maintenance; +import static gregtech.api.enums.GT_HatchElement.Muffler; +import static gregtech.api.enums.GT_HatchElement.OutputBus; +import static gregtech.api.enums.GT_HatchElement.OutputHatch; +import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_OIL_CRACKER; +import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_OIL_CRACKER_ACTIVE; +import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_OIL_CRACKER_ACTIVE_GLOW; +import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_OIL_CRACKER_GLOW; +import static gregtech.api.enums.Textures.BlockIcons.casingTexturePages; +import static gregtech.api.util.GT_StructureUtility.buildHatchAdder; +import static gregtech.api.util.GT_StructureUtility.ofCoil; + +import javax.annotation.Nonnull; + +import net.minecraft.item.ItemStack; +import net.minecraftforge.common.util.ForgeDirection; + +import com.elisis.gtnhlanth.api.recipe.LanthanidesRecipeMaps; +import com.elisis.gtnhlanth.util.DescTextLocalization; +import com.gtnewhorizon.structurelib.alignment.constructable.ISurvivalConstructable; +import com.gtnewhorizon.structurelib.structure.IStructureDefinition; +import com.gtnewhorizon.structurelib.structure.ISurvivalBuildEnvironment; +import com.gtnewhorizon.structurelib.structure.StructureDefinition; + +import gregtech.api.GregTech_API; +import gregtech.api.enums.HeatingCoilLevel; +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.GT_MetaTileEntity_EnhancedMultiBlockBase; +import gregtech.api.recipe.RecipeMap; +import gregtech.api.recipe.check.CheckRecipeResult; +import gregtech.api.recipe.check.CheckRecipeResultRegistry; +import gregtech.api.render.TextureFactory; +import gregtech.api.util.GT_Multiblock_Tooltip_Builder; +import gregtech.api.util.GT_OverclockCalculator; +import gregtech.api.util.GT_Recipe; + +public class Digester extends GT_MetaTileEntity_EnhancedMultiBlockBase<Digester> implements ISurvivalConstructable { + + protected int casingAmount = 0; + protected int height = 0; + + private HeatingCoilLevel heatLevel; + + private final IStructureDefinition<Digester> multiDefinition = StructureDefinition.<Digester>builder() + .addShape( + mName, + transpose( + new String[][] { { " ", " ttttt ", " t---t ", " t---t ", " t---t ", " ttttt ", " " }, + { " ttt ", " t---t ", "t-----t", "t-----t", "t-----t", " t---t ", " ttt " }, + { " tccct ", "tc---ct", "c-----c", "c-----c", "c-----c", "tc---ct", " tccct " }, + { " tt~tt ", "thhhhht", "thsssht", "thsssht", "thsssht", "thhhhht", " ttttt " }, })) + + .addElement( + 't', + buildHatchAdder(Digester.class) + .atLeast(InputHatch, OutputHatch, InputBus, OutputBus, Maintenance, Energy, Muffler) + .casingIndex(47) + .dot(1) + .buildAndChain(GregTech_API.sBlockCasings4, 0)) + .addElement('h', ofBlock(GregTech_API.sBlockCasings1, 11)) + .addElement('s', ofBlock(GregTech_API.sBlockCasings4, 1)) + .addElement('c', ofCoil(Digester::setCoilLevel, Digester::getCoilLevel)) + .build(); + + // private int mHeat; + // private int mNeededHeat; + + public Digester(String name) { + super(name); + } + + public Digester(int id, String name, String nameRegional) { + super(id, name, nameRegional); + } + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + return checkPiece(mName, 3, 3, 0) && !mMufflerHatches.isEmpty() && mMaintenanceHatches.size() == 1; + } + + @Override + public boolean isCorrectMachinePart(ItemStack aStack) { + return true; + } + + public HeatingCoilLevel getCoilLevel() { + return this.heatLevel; + } + + public void setCoilLevel(HeatingCoilLevel level) { + this.heatLevel = level; + } + + @Override + public RecipeMap<?> getRecipeMap() { + return LanthanidesRecipeMaps.digesterRecipes; + } + + @Override + protected ProcessingLogic createProcessingLogic() { + return new ProcessingLogic() { + + @Nonnull + @Override + protected GT_OverclockCalculator createOverclockCalculator(@Nonnull GT_Recipe recipe) { + return super.createOverclockCalculator(recipe).enablePerfectOC(); + } + + @Override + protected @Nonnull CheckRecipeResult validateRecipe(@Nonnull GT_Recipe recipe) { + return recipe.mSpecialValue <= Digester.this.getCoilLevel() + .getHeat() ? CheckRecipeResultRegistry.SUCCESSFUL + : CheckRecipeResultRegistry.insufficientHeat(recipe.mSpecialValue); + } + + }; + } + + @Override + public boolean supportsVoidProtection() { + return true; + } + + @Override + public boolean supportsInputSeparation() { + return true; + } + + @Override + public boolean supportsBatchMode() { + return true; + } + + @Override + public boolean supportsSingleRecipeLocking() { + return true; + } + + @Override + public int getMaxEfficiency(ItemStack itemStack) { + return 10000; + } + + @Override + public int getPollutionPerTick(ItemStack aStack) { + return 20; + } + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity arg0) { + return new Digester(this.mName); + } + + @Override + public void construct(ItemStack itemStack, boolean b) { + buildPiece(mName, itemStack, b, 3, 3, 0); + } + + @Override + public int survivalConstruct(ItemStack stackSize, int elementBudget, ISurvivalBuildEnvironment env) { + if (mMachine) return -1; + return survivialBuildPiece(mName, stackSize, 3, 3, 0, elementBudget, env, false, true); + } + + @Override + public String[] getStructureDescription(ItemStack arg0) { + return DescTextLocalization.addText("Digester.hint", 6); + } + + public ITexture[] getTexture(IGregTechTileEntity te, ForgeDirection side, ForgeDirection facing, int colorIndex, + boolean active, boolean redstone) { + + // Oil Cracker textures cuz I'm lazy + + if (side == facing) { + if (active) return new ITexture[] { casingTexturePages[0][47], TextureFactory.builder() + .addIcon(OVERLAY_FRONT_OIL_CRACKER_ACTIVE) + .extFacing() + .build(), + TextureFactory.builder() + .addIcon(OVERLAY_FRONT_OIL_CRACKER_ACTIVE_GLOW) + .extFacing() + .glow() + .build() }; + return new ITexture[] { casingTexturePages[0][47], TextureFactory.builder() + .addIcon(OVERLAY_FRONT_OIL_CRACKER) + .extFacing() + .build(), + TextureFactory.builder() + .addIcon(OVERLAY_FRONT_OIL_CRACKER_GLOW) + .extFacing() + .glow() + .build() }; + } + return new ITexture[] { casingTexturePages[0][47] }; + } + + @Override + protected GT_Multiblock_Tooltip_Builder createTooltip() { + final GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); + tt.addMachineType("Digester") + .addInfo("Controller block for the Digester") + .addInfo("Input ores and fluid, output water.") + .addInfo(BLUEPRINT_INFO) + .addSeparator() + .addController("Front bottom") + .addInputHatch("Hint block with dot 1") + .addInputBus("Hint block with dot 1") + .addOutputHatch("Hint block with dot 1") + .addOutputBus("Hint block with dot 1") + .addMaintenanceHatch("Hint block with dot 1") + .addMufflerHatch("Hint block with dot 1") + .toolTipFinisher("GTNH: Lanthanides"); + return tt; + } + + @Override + public IStructureDefinition<Digester> getStructureDefinition() { + return multiDefinition; + } + + @Override + public boolean explodesOnComponentBreak(ItemStack arg0) { + // TODO Auto-generated method stub + return false; + } + + @Override + public int getDamageToComponent(ItemStack arg0) { + // TODO Auto-generated method stub + return 0; + } +} diff --git a/src/main/java/com/elisis/gtnhlanth/common/tileentity/DissolutionTank.java b/src/main/java/com/elisis/gtnhlanth/common/tileentity/DissolutionTank.java new file mode 100644 index 0000000000..f515024365 --- /dev/null +++ b/src/main/java/com/elisis/gtnhlanth/common/tileentity/DissolutionTank.java @@ -0,0 +1,277 @@ +package com.elisis.gtnhlanth.common.tileentity; + +import static com.elisis.gtnhlanth.util.DescTextLocalization.BLUEPRINT_INFO; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlockAdder; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; +import static gregtech.api.enums.GT_HatchElement.Energy; +import static gregtech.api.enums.GT_HatchElement.InputBus; +import static gregtech.api.enums.GT_HatchElement.InputHatch; +import static gregtech.api.enums.GT_HatchElement.Maintenance; +import static gregtech.api.enums.GT_HatchElement.OutputBus; +import static gregtech.api.enums.GT_HatchElement.OutputHatch; +import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_OIL_CRACKER; +import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_OIL_CRACKER_ACTIVE; +import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_OIL_CRACKER_ACTIVE_GLOW; +import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_OIL_CRACKER_GLOW; +import static gregtech.api.enums.Textures.BlockIcons.casingTexturePages; +import static gregtech.api.util.GT_StructureUtility.buildHatchAdder; + +import java.util.Arrays; +import java.util.List; + +import javax.annotation.Nonnull; + +import net.minecraft.block.Block; +import net.minecraft.item.ItemStack; +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.FluidStack; + +import org.jetbrains.annotations.NotNull; + +import com.elisis.gtnhlanth.api.recipe.LanthanidesRecipeMaps; +import com.elisis.gtnhlanth.util.DescTextLocalization; +import com.github.bartimaeusnek.bartworks.common.loaders.ItemRegistry; +import com.gtnewhorizon.structurelib.alignment.constructable.ISurvivalConstructable; +import com.gtnewhorizon.structurelib.structure.IStructureDefinition; +import com.gtnewhorizon.structurelib.structure.ISurvivalBuildEnvironment; +import com.gtnewhorizon.structurelib.structure.StructureDefinition; + +import gregtech.api.GregTech_API; +import gregtech.api.interfaces.ISecondaryDescribable; +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.GT_MetaTileEntity_EnhancedMultiBlockBase; +import gregtech.api.recipe.RecipeMap; +import gregtech.api.recipe.check.CheckRecipeResult; +import gregtech.api.recipe.check.CheckRecipeResultRegistry; +import gregtech.api.recipe.check.SimpleCheckRecipeResult; +import gregtech.api.render.TextureFactory; +import gregtech.api.util.GT_Multiblock_Tooltip_Builder; +import gregtech.api.util.GT_Recipe; + +public class DissolutionTank extends GT_MetaTileEntity_EnhancedMultiBlockBase<DissolutionTank> + implements ISurvivalConstructable, ISecondaryDescribable { + + private final IStructureDefinition<DissolutionTank> multiDefinition = StructureDefinition.<DissolutionTank>builder() + .addShape( + mName, + transpose( + new String[][] { { " sss ", "sssss", "sssss", "sssss", " sss " }, + { "sgggs", "g---g", "g---g", "g---g", "sgggs" }, { "sgggs", "g---g", "g---g", "g---g", "sgggs" }, + { "ss~ss", "shhhs", "shhhs", "shhhs", "sssss" }, { "s s", " ", " ", " ", "s s" } })) + .addElement( + 's', + buildHatchAdder(DissolutionTank.class) + .atLeast(InputHatch, OutputHatch, InputBus, OutputBus, Maintenance, Energy) + .casingIndex(49) + .dot(1) + .buildAndChain(GregTech_API.sBlockCasings4, 1)) + .addElement('h', ofBlock(GregTech_API.sBlockCasings1, 11)) + .addElement('g', ofBlockAdder(DissolutionTank::addGlass, ItemRegistry.bw_glasses[0], 1)) + .build(); + + public DissolutionTank(String name) { + super(name); + } + + public DissolutionTank(int id, String name, String nameRegional) { + super(id, name, nameRegional); + } + + @Override + public IStructureDefinition<DissolutionTank> getStructureDefinition() { + return multiDefinition; + } + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + return checkPiece(mName, 2, 3, 0) && mMaintenanceHatches.size() == 1; + } + + @Override + public boolean isCorrectMachinePart(ItemStack aStack) { + return true; + } + + private boolean addGlass(Block block, int meta) { + return block == ItemRegistry.bw_glasses[0]; + } + + @Override + public RecipeMap<?> getRecipeMap() { + return LanthanidesRecipeMaps.dissolutionTankRecipes; + } + + @Override + protected ProcessingLogic createProcessingLogic() { + return new ProcessingLogic() { + + @NotNull + @Override + protected CheckRecipeResult onRecipeStart(@Nonnull GT_Recipe recipe) { + if (!checkRatio(recipe, Arrays.asList(inputFluids))) { + criticalStopMachine(); + return SimpleCheckRecipeResult.ofFailurePersistOnShutdown("dissolution_ratio"); + } + return CheckRecipeResultRegistry.SUCCESSFUL; + } + + }; + } + + @Override + public boolean supportsVoidProtection() { + return true; + } + + @Override + public boolean supportsInputSeparation() { + return true; + } + + @Override + public boolean supportsBatchMode() { + return true; + } + + @Override + public boolean supportsSingleRecipeLocking() { + return true; + } + + private boolean checkRatio(GT_Recipe tRecipe, List<FluidStack> tFluidInputs) { + FluidStack majorGenericFluid = tRecipe.mFluidInputs[0]; + FluidStack minorGenericFluid = tRecipe.mFluidInputs[1]; + + // FluidStack majorInput = null; + // FluidStack minorInput = null; + + int majorAmount; + int minorAmount; + + FluidStack fluidInputOne = tFluidInputs.get(0); + FluidStack fluidInputTwo = tFluidInputs.get(1); + + // majorInput = ((fluidInputOne.getUnlocalizedName().equals(majorGenericFluid.getUnlocalizedName())) + // ? fluidInputOne + // : fluidInputTwo); + // GT_Log.out.print(majorInput.getLocalizedName()); + if (fluidInputOne.getUnlocalizedName() + .equals(majorGenericFluid.getUnlocalizedName())) { + if (fluidInputTwo.getUnlocalizedName() + .equals(minorGenericFluid.getUnlocalizedName())) { + // majorInput = fluidInputOne; + majorAmount = fluidInputOne.amount; + // minorInput = fluidInputTwo; + minorAmount = fluidInputTwo.amount; + // GT_Log.out.print("in first IF"); + } else return false; // No valid other input + + } else if (fluidInputTwo.getUnlocalizedName() + .equals(majorGenericFluid.getUnlocalizedName())) { + if (fluidInputOne.getUnlocalizedName() + .equals(minorGenericFluid.getUnlocalizedName())) { + // majorInput = fluidInputTwo; + majorAmount = fluidInputTwo.amount; + // minorInput = fluidInputOne; + minorAmount = fluidInputOne.amount; + // GT_Log.out.print("in second if"); + } else return false; + + } else return false; + + // GT_Log.out.print("out of switch weirdness"); + + // GT_Log.out.print("major " + majorInput.getLocalizedName()); + // GT_Log.out.print("minor " + minorInput.getLocalizedName()); + + // GT_Log.out.print("mjrinputamt " + majorInput.amount); + return majorAmount / tRecipe.mSpecialValue == minorAmount; + } + + @Override + public int getMaxEfficiency(ItemStack itemStack) { + return 10000; + } + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity arg0) { + return new DissolutionTank(this.mName); + } + + @Override + public void construct(ItemStack itemStack, boolean b) { + buildPiece(mName, itemStack, b, 2, 3, 0); + } + + @Override + public int survivalConstruct(ItemStack stackSize, int elementBudget, ISurvivalBuildEnvironment env) { + if (mMachine) return -1; + return survivialBuildPiece(mName, stackSize, 2, 3, 0, elementBudget, env, false, true); + } + + @Override + public String[] getStructureDescription(ItemStack arg0) { + return DescTextLocalization.addText("DissolutionTank.hint", 4); + } + + @Override + public ITexture[] getTexture(IGregTechTileEntity te, ForgeDirection side, ForgeDirection facing, int colorIndex, + boolean active, boolean redstone) { + + if (side == facing) { + if (active) return new ITexture[] { casingTexturePages[0][49], TextureFactory.builder() + .addIcon(OVERLAY_FRONT_OIL_CRACKER_ACTIVE) + .extFacing() + .build(), + TextureFactory.builder() + .addIcon(OVERLAY_FRONT_OIL_CRACKER_ACTIVE_GLOW) + .extFacing() + .glow() + .build() }; + return new ITexture[] { casingTexturePages[0][49], TextureFactory.builder() + .addIcon(OVERLAY_FRONT_OIL_CRACKER) + .extFacing() + .build(), + TextureFactory.builder() + .addIcon(OVERLAY_FRONT_OIL_CRACKER_GLOW) + .extFacing() + .glow() + .build() }; + } + return new ITexture[] { casingTexturePages[0][49] }; + } + + @Override + protected GT_Multiblock_Tooltip_Builder createTooltip() { + final GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); + tt.addMachineType("Dissolution Tank") + .addInfo("Controller block for the Dissolution Tank") + .addInfo("Input Water and Fluid, output Fluid") + .addInfo("You must input the Fluids at the correct Ratio") + .addInfo(BLUEPRINT_INFO) + .addSeparator() + .addController("Front bottom") + .addInputHatch("Hint block with dot 1") + .addInputBus("Hint block with dot 1") + .addOutputHatch("Hint block with dot 1") + .addOutputBus("Hint block with dot 1") + .addMaintenanceHatch("Hint block with dot 1") + .toolTipFinisher("GTNH: Lanthanides"); + + return tt; + } + + @Override + public boolean explodesOnComponentBreak(ItemStack arg0) { + return false; + } + + @Override + public int getDamageToComponent(ItemStack arg0) { + return 0; + } +} |
