From 0acadd13d268476ccbf1e8bcac8df643092e28b0 Mon Sep 17 00:00:00 2001 From: Alkalus <3060479+draknyte1@users.noreply.github.com> Date: Sat, 18 Dec 2021 21:38:20 +0000 Subject: Added MultiBlock Rock Breaker. Added base work for GT Chisels. --- .../xmod/gregtech/api/enums/GregtechItemList.java | 12 + .../basic/GregtechMetaTileEntity_AutoChisel.java | 5 + .../GregtechMetaTileEntity_IndustrialChisel.java | 5 + ...egtechMetaTileEntity_IndustrialRockBreaker.java | 527 +++++++++++++++++++++ .../gregtech/GregtechIndustrialChisel.java | 14 + .../gregtech/GregtechIndustrialRockBreaker.java | 13 + .../gregtech/GregtechIndustrialSifter.java | 1 - 7 files changed, 576 insertions(+), 1 deletion(-) create mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaTileEntity_AutoChisel.java create mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialChisel.java create mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_IndustrialRockBreaker.java create mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIndustrialChisel.java create mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIndustrialRockBreaker.java (limited to 'src/main/java/gtPlusPlus/xmod/gregtech') diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java index 8c814489f2..71d6ae1d68 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java @@ -409,6 +409,12 @@ public enum GregtechItemList implements GregtechItemContainer { // Big Steam Macerator Controller_SteamMaceratorMulti, + + // Industrial Rock Breaker + Controller_IndustrialRockBreaker, + + // Industrial Chisel + Controller_IndustrialAutoChisel, // Custom Machine Casings Casing_Machine_Custom_1, @@ -705,6 +711,12 @@ public enum GregtechItemList implements GregtechItemContainer { //GT RTG RTG, + + // Chisel Machines + GT_Chisel_LV, + GT_Chisel_MV, + GT_Chisel_HV, + //Plasma Tank /*Plasma_Tank,*/ diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaTileEntity_AutoChisel.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaTileEntity_AutoChisel.java new file mode 100644 index 0000000000..39545daec1 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaTileEntity_AutoChisel.java @@ -0,0 +1,5 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.machines.basic; + +public class GregtechMetaTileEntity_AutoChisel { + +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialChisel.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialChisel.java new file mode 100644 index 0000000000..871b863b22 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialChisel.java @@ -0,0 +1,5 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.processing; + +public class GregtechMetaTileEntity_IndustrialChisel { + +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_IndustrialRockBreaker.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_IndustrialRockBreaker.java new file mode 100644 index 0000000000..e681069078 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_IndustrialRockBreaker.java @@ -0,0 +1,527 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production; + +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofChain; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; +import static gregtech.api.util.GT_StructureUtility.ofHatchAdder; +import static gtPlusPlus.core.util.data.ArrayUtils.removeNulls; + +import java.util.ArrayList; +import java.util.List; + +import org.apache.commons.lang3.ArrayUtils; + +import com.gtnewhorizon.structurelib.structure.IStructureDefinition; +import com.gtnewhorizon.structurelib.structure.StructureDefinition; + +import gregtech.api.GregTech_API; +import gregtech.api.enums.Materials; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.enums.TAE; +import gregtech.api.enums.Textures; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Energy; +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_Maintenance; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Muffler; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_OutputBus; +import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.util.GTPP_Recipe; +import gregtech.api.util.GT_Multiblock_Tooltip_Builder; +import gregtech.api.util.GT_OreDictUnificator; +import gregtech.api.util.GT_Recipe; +import gregtech.api.util.GT_Recipe.GT_Recipe_Map; +import gregtech.api.util.GT_Utility; +import gtPlusPlus.core.block.ModBlocks; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.recipe.common.CI; +import gtPlusPlus.core.util.minecraft.ItemUtils; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; +import net.minecraft.init.Blocks; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.FluidRegistry; +import net.minecraftforge.fluids.FluidStack; + +public class GregtechMetaTileEntity_IndustrialRockBreaker extends GregtechMeta_MultiBlockBase { + + private static Item circuit; + private int mCasing; + private IStructureDefinition STRUCTURE_DEFINITION = null; + + + public GregtechMetaTileEntity_IndustrialRockBreaker(final int aID, final String aName, final String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public GregtechMetaTileEntity_IndustrialRockBreaker(final String aName) { + super(aName); + } + + @Override + public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + return new GregtechMetaTileEntity_IndustrialRockBreaker(this.mName); + } + + @Override + public String getMachineType() { + return "Rock Breaker"; + } + + @Override + protected GT_Multiblock_Tooltip_Builder createTooltip() { + GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); + tt.addMachineType(getMachineType()) + .addInfo("Controller Block for the Industrial Rock Breaker") + .addInfo("200% Faster than the single block version") + .addInfo("Only uses 80% of the eu/t normally required") + .addInfo("Processes 8 items per voltage tier") + .addInfo("Circuit goes in the Input Bus or GUI slot") + .addInfo("1 = cobble, 2 = stone, 3 = obsidian") + .addInfo("Supply Water/Lava") + .addPollutionAmount(getPollutionPerSecond(null)) + .addSeparator() + .beginStructureBlock(3, 4, 3, true) + .addController("Bottom Center") + .addCasingInfo("Thermal Processing Casing", 10) + .addCasingInfo("Thermal Containment Casing", 16) + .addInputBus("Any Casing", 1) + .addInputHatch("Any Casing", 1) + .addOutputBus("Any Casing", 1) + .addEnergyHatch("Any Casing", 1) + .addMaintenanceHatch("Any Casing", 1) + .addMufflerHatch("Any Casing", 1) + .toolTipFinisher(CORE.GT_Tooltip_Builder); + return tt; + } + + @Override + public IStructureDefinition getStructureDefinition() { + if (STRUCTURE_DEFINITION == null) { + STRUCTURE_DEFINITION = StructureDefinition.builder() + .addShape(mName, transpose(new String[][]{ + {"CCC", "CCC", "CCC"}, + {"HHH", "H-H", "HHH"}, + {"HHH", "H-H", "HHH"}, + {"C~C", "CCC", "CCC"}, + })) + .addElement( + 'C', + ofChain( + ofHatchAdder( + GregtechMetaTileEntity_IndustrialRockBreaker::addRockBreakerList, TAE.GTPP_INDEX(16), 1 + ), + onElementPass( + x -> ++x.mCasing, + ofBlock( + ModBlocks.blockCasings2Misc, 0 + ) + ) + ) + ) + .addElement( + 'H', + ofBlock( + ModBlocks.blockCasings2Misc, 11 + ) + ) + .build(); + } + return STRUCTURE_DEFINITION; + } + + @Override + public void construct(ItemStack stackSize, boolean hintsOnly) { + buildPiece(mName , stackSize, hintsOnly, 1, 3, 0); + } + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + mCasing = 0; + return checkPiece(mName, 1, 3, 0) && mCasing >= 10 && mEnergyHatches.size() == 1 && checkHatch(); + } + + public final boolean addRockBreakerList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + if (aTileEntity == null) { + return false; + } else { + IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_InputBus){ + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Maintenance){ + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Energy){ + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Muffler) { + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Input) { + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_OutputBus) { + return addToMachineList(aTileEntity, aBaseCasingIndex); + } + } + return false; + } + + + @Override + public String getSound() { + return GregTech_API.sSoundList.get(Integer.valueOf(208)); + } + + @Override + public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final byte aFacing, final byte aColorIndex, final boolean aActive, final boolean aRedstone) { + if (aSide == aFacing) { + return new ITexture[]{Textures.BlockIcons.getCasingTextureForId(TAE.GTPP_INDEX(16)), new GT_RenderedTexture(aActive ? TexturesGtBlock.Overlay_Machine_Controller_Advanced_Active : TexturesGtBlock.Overlay_Machine_Controller_Advanced)}; + } + return new ITexture[]{Textures.BlockIcons.getCasingTextureForId(TAE.GTPP_INDEX(16))}; + } + + @Override + public boolean hasSlotInGUI() { + return true; + } + + @Override + public boolean requiresVanillaGtGUI() { + return true; + } + + @Override + public String getCustomGUIResourceName() { + return "ElectricBlastFurnace"; + } + + @Override + public GT_Recipe.GT_Recipe_Map getRecipeMap() { + return GT_Recipe_Map.sRockBreakerFakeRecipes; + } + + @Override + public boolean isCorrectMachinePart(final ItemStack aStack) { + return true; + } + + private static GT_Recipe sRecipe_Cobblestone; + private static GT_Recipe sRecipe_SmoothStone; + private static GT_Recipe sRecipe_Redstone; + + private static final void generateRecipes() { + if (sRecipe_Cobblestone == null) { + sRecipe_Cobblestone = new GTPP_Recipe( + false, + new ItemStack[] { + CI.getNumberedCircuit(1) + }, + new ItemStack[] { + ItemUtils.getSimpleStack(Blocks.cobblestone) + }, + null, + new int[] {10000}, + null, + null, + 16, + 32, + 0); + } + if (sRecipe_SmoothStone == null) { + sRecipe_SmoothStone = new GTPP_Recipe( + false, + new ItemStack[] { + CI.getNumberedCircuit(2) + }, + new ItemStack[] { + ItemUtils.getSimpleStack(Blocks.stone) + }, + null, + new int[] {10000}, + null, + null, + 16, + 32, + 0); + } + if (sRecipe_Redstone == null) { + sRecipe_Redstone = new GTPP_Recipe( + false, + new ItemStack[] { + CI.getNumberedCircuit(3), + GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Redstone, 1L) + }, + new ItemStack[] { + ItemUtils.getSimpleStack(Blocks.obsidian) + }, + null, + new int[] {10000}, + null, + null, + 128, + 32, + 0); + } + } + + @Override + public boolean checkRecipe(final ItemStack aStack) { + ArrayList aFluids = this.getStoredFluids(); + if (!aFluids.isEmpty()) { + boolean aHasWater = false; + boolean aHasLava = false; + for (FluidStack aFluid : aFluids) { + if (aFluid.getFluid() == FluidRegistry.WATER) { + aHasWater = true; + } + else if (aFluid.getFluid() == FluidRegistry.LAVA) { + aHasLava = true; + } + } + ArrayList aItems = this.getStoredInputs(); + boolean aHasRedstone = false; + if (!aItems.isEmpty()) { + for (ItemStack aItem : aItems) { + if (GT_Utility.areStacksEqual(aItem, GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Redstone, 1L))) { + aHasRedstone = true; + break; + } + } + } + + if (!aHasWater || !aHasLava) { + log("BAD RETURN - 0-1"); + return false; + } + ItemStack aGuiCircuit = this.getGUIItemStack(); + if (aGuiCircuit == null || !ItemUtils.isControlCircuit(aGuiCircuit)) { + log("BAD RETURN - 0-2"); + return false; + } + + generateRecipes(); + + int aCircuit = aGuiCircuit.getItemDamage(); + + GT_Recipe tRecipe = null; + switch (aCircuit) { + case 1: + tRecipe = sRecipe_Cobblestone; + break; + case 2: + tRecipe = sRecipe_SmoothStone; + break; + case 3: + if (aHasRedstone) { + tRecipe = sRecipe_Redstone; + } + break; + } + + if (tRecipe == null) { + log("BAD RETURN - 0-3"); + return false; + } + + // Based on the Processing Array. A bit overkill, but very flexible. + ItemStack[] aItemInputs = aItems.toArray(new ItemStack[aItems.size()]); + FluidStack[] aFluidInputs = aFluids.toArray(new FluidStack[aFluids.size()]); + + // Reset outputs and progress stats + this.mEUt = 0; + this.mMaxProgresstime = 0; + this.mOutputItems = new ItemStack[]{}; + this.mOutputFluids = new FluidStack[]{}; + + long tVoltage = getMaxInputVoltage(); + byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); + long tEnergy = getMaxInputEnergy(); + log("Running checkRecipeGeneric(0)"); + + log("Running checkRecipeGeneric(1)"); + // Remember last recipe - an optimization for findRecipe() + this.mLastRecipe = tRecipe; + + int aMaxParallelRecipes = getMaxParallelRecipes(); + int aEUPercent = getEuDiscountForParallelism(); + int aSpeedBonusPercent = 200; + + aMaxParallelRecipes = this.canBufferOutputs(tRecipe, aMaxParallelRecipes); + if (aMaxParallelRecipes == 0) { + log("BAD RETURN - 2"); + return false; + } + + // EU discount + float tRecipeEUt = (tRecipe.mEUt * aEUPercent) / 100.0f; + float tTotalEUt = 0.0f; + + int parallelRecipes = 0; + + log("parallelRecipes: "+parallelRecipes); + log("aMaxParallelRecipes: "+aMaxParallelRecipes); + log("tTotalEUt: "+tTotalEUt); + log("tVoltage: "+tVoltage); + log("tRecipeEUt: "+tRecipeEUt); + // Count recipes to do in parallel, consuming input items and fluids and considering input voltage limits + for (; parallelRecipes < aMaxParallelRecipes && tTotalEUt < (tEnergy - tRecipeEUt); parallelRecipes++) { + if (!tRecipe.isRecipeInputEqual(true, aFluidInputs, aItemInputs)) { + log("Broke at "+parallelRecipes+"."); + break; + } + log("Bumped EU from "+tTotalEUt+" to "+(tTotalEUt+tRecipeEUt)+"."); + tTotalEUt += tRecipeEUt; + } + + if (parallelRecipes == 0) { + log("BAD RETURN - 3"); + return false; + } + + // -- Try not to fail after this point - inputs have already been consumed! -- + + + + // Convert speed bonus to duration multiplier + // e.g. 100% speed bonus = 200% speed = 100%/200% = 50% recipe duration. + aSpeedBonusPercent = Math.max(-99, aSpeedBonusPercent); + float tTimeFactor = 100.0f / (100.0f + aSpeedBonusPercent); + this.mMaxProgresstime = (int)(tRecipe.mDuration * tTimeFactor); + + this.mEUt = (int)Math.ceil(tTotalEUt); + + this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); + this.mEfficiencyIncrease = 10000; + + // Overclock + if (this.mEUt <= 16) { + this.mEUt = (this.mEUt * (1 << tTier - 1) * (1 << tTier - 1)); + this.mMaxProgresstime = (this.mMaxProgresstime / (1 << tTier - 1)); + } else { + while (this.mEUt <= gregtech.api.enums.GT_Values.V[(tTier - 1)]) { + this.mEUt *= 4; + this.mMaxProgresstime /= 2; + } + } + + if (this.mEUt > 0) { + this.mEUt = (-this.mEUt); + } + + this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime); + + // Collect fluid outputs + FluidStack[] tOutputFluids = new FluidStack[tRecipe.mFluidOutputs.length]; + for (int h = 0; h < tRecipe.mFluidOutputs.length; h++) { + if (tRecipe.getFluidOutput(h) != null) { + tOutputFluids[h] = tRecipe.getFluidOutput(h).copy(); + tOutputFluids[h].amount *= parallelRecipes; + } + } + + // Collect output item types + ItemStack[] tOutputItems = new ItemStack[tRecipe.mOutputs.length]; + for (int h = 0; h < tRecipe.mOutputs.length; h++) { + if (tRecipe.getOutput(h) != null) { + tOutputItems[h] = tRecipe.getOutput(h).copy(); + tOutputItems[h].stackSize = 0; + } + } + + // Set output item stack sizes (taking output chance into account) + for (int f = 0; f < tOutputItems.length; f++) { + if (tRecipe.mOutputs[f] != null && tOutputItems[f] != null) { + for (int g = 0; g < parallelRecipes; g++) { + if (getBaseMetaTileEntity().getRandomNumber(10000) < tRecipe.getOutputChance(f)) + tOutputItems[f].stackSize += tRecipe.mOutputs[f].stackSize; + } + } + } + + tOutputItems = removeNulls(tOutputItems); + + // Sanitize item stack size, splitting any stacks greater than max stack size + List splitStacks = new ArrayList(); + for (ItemStack tItem : tOutputItems) { + while (tItem.getMaxStackSize() < tItem.stackSize) { + ItemStack tmp = tItem.copy(); + tmp.stackSize = tmp.getMaxStackSize(); + tItem.stackSize = tItem.stackSize - tItem.getMaxStackSize(); + splitStacks.add(tmp); + } + } + + if (splitStacks.size() > 0) { + ItemStack[] tmp = new ItemStack[splitStacks.size()]; + tmp = splitStacks.toArray(tmp); + tOutputItems = ArrayUtils.addAll(tOutputItems, tmp); + } + + // Strip empty stacks + List tSList = new ArrayList(); + for (ItemStack tS : tOutputItems) { + if (tS.stackSize > 0) tSList.add(tS); + } + tOutputItems = tSList.toArray(new ItemStack[tSList.size()]); + + // Commit outputs + this.mOutputItems = tOutputItems; + this.mOutputFluids = tOutputFluids; + updateSlots(); + + // Play sounds (GT++ addition - GT multiblocks play no sounds) + startProcess(); + + log("GOOD RETURN - 1"); + return true; + } + + return false; + } + + @Override + public int getMaxParallelRecipes() { + return (8 * GT_Utility.getTier(this.getMaxInputVoltage())); + } + + @Override + public int getEuDiscountForParallelism() { + return 80; + } + + @Override + public int getMaxEfficiency(final ItemStack aStack) { + return 10000; + } + + @Override + public int getPollutionPerSecond(final ItemStack aStack) { + return CORE.ConfigSwitches.pollutionPerSecondMultiABS; + } + + @Override + public int getDamageToComponent(final ItemStack aStack) { + return 0; + } + + @Override + public int getAmountOfOutputs() { + return 2; + } + + @Override + public boolean explodesOnComponentBreak(final ItemStack aStack) { + return false; + } + + @Override + public ArrayList getStoredInputs() { + ArrayList aInputs = super.getStoredInputs(); + if (this.hasSlotInGUI() && this.getGUIItemStack() != null) { + aInputs.add(this.getGUIItemStack()); + } + return aInputs; + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIndustrialChisel.java b/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIndustrialChisel.java new file mode 100644 index 0000000000..aa28faa6f9 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIndustrialChisel.java @@ -0,0 +1,14 @@ +package gtPlusPlus.xmod.gregtech.registration.gregtech; + +import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; +import gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production.GregtechMetaTileEntity_IndustrialRockBreaker; + +public class GregtechIndustrialChisel { + + public static void run() { + // Industrial Maceration Stack Multiblock + /*GregtechItemList.Controller_IndustrialRockBreaker.set(new GregtechMetaTileEntity_IndustrialRockBreaker(32005, + "industrialrockcrusher.controller.tier.single", "Boldarnator").getStackForm(1L));*/ + } + +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIndustrialRockBreaker.java b/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIndustrialRockBreaker.java new file mode 100644 index 0000000000..45b923083e --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIndustrialRockBreaker.java @@ -0,0 +1,13 @@ +package gtPlusPlus.xmod.gregtech.registration.gregtech; + +import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; +import gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production.GregtechMetaTileEntity_IndustrialRockBreaker; + +public class GregtechIndustrialRockBreaker { + + public static void run() { + GregtechItemList.Controller_IndustrialRockBreaker.set(new GregtechMetaTileEntity_IndustrialRockBreaker(32005, + "industrialrockcrusher.controller.tier.single", "Boldarnator").getStackForm(1L)); + } + +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIndustrialSifter.java b/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIndustrialSifter.java index 15bf42c9d4..8fa4cb6cb1 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIndustrialSifter.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIndustrialSifter.java @@ -18,7 +18,6 @@ public class GregtechIndustrialSifter { } private static void run1() { - // Industrial Maceration Stack Multiblock GregtechItemList.Industrial_Sifter.set(new GregtechMetaTileEntity_IndustrialSifter(840, "industrialsifter.controller.tier.single", "Large Sifter Control Block").getStackForm(1L)); -- cgit From 41d303266edf21f9f0daf753c22bc82e3033869d Mon Sep 17 00:00:00 2001 From: Alkalus <3060479+draknyte1@users.noreply.github.com> Date: Sun, 19 Dec 2021 14:10:52 +0000 Subject: Added Logger to check free Meta IDs in dev. Freed up some indexes in TAE. Finished work on Chisel single blocks. Finished work on Chisel multiblock. Finished work on Rock Breaker multiblock. --- src/main/java/gtPlusPlus/GTplusplus.java | 16 + .../xmod/gregtech/api/enums/GregtechItemList.java | 1 + .../common/blocks/GregtechMetaCasingBlocks3.java | 4 + .../common/blocks/GregtechMetaCasingBlocks5.java | 6 +- .../basic/GregtechMetaTileEntity_AutoChisel.java | 128 +++++- .../GregtechMetaTileEntity_IndustrialChisel.java | 437 ++++++++++++++++++++- ...egtechMetaTileEntity_IndustrialRockBreaker.java | 166 ++++---- .../gregtech/GregtechIndustrialChisel.java | 21 +- .../gregtech/GregtechIndustrialRockBreaker.java | 2 +- 9 files changed, 704 insertions(+), 77 deletions(-) (limited to 'src/main/java/gtPlusPlus/xmod/gregtech') diff --git a/src/main/java/gtPlusPlus/GTplusplus.java b/src/main/java/gtPlusPlus/GTplusplus.java index 9787a38504..1513a0999c 100644 --- a/src/main/java/gtPlusPlus/GTplusplus.java +++ b/src/main/java/gtPlusPlus/GTplusplus.java @@ -228,6 +228,22 @@ public class GTplusplus implements ActionListener { Logger.INFO( "Finally, we are finished. Have some cripsy bacon as a reward." ); + + // Log free GT++ Meta IDs + if (CORE.DEVENV) { + // 750 - 999 are reserved for Alkalus. + for (int i=750; i<1000;i++) { + if (gregtech.api.GregTech_API.METATILEENTITIES[i] == null) { + Logger.INFO("MetaID "+i+" is free."); + } + } + // 30000 - 31999 are reserved for Alkalus. + for (int i=30000; i<32000;i++) { + if (gregtech.api.GregTech_API.METATILEENTITIES[i] == null) { + Logger.INFO("MetaID "+i+" is free."); + } + } + } } @EventHandler diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java index 71d6ae1d68..d3caf99af6 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java @@ -415,6 +415,7 @@ public enum GregtechItemList implements GregtechItemContainer { // Industrial Chisel Controller_IndustrialAutoChisel, + Casing_IndustrialAutoChisel, // Custom Machine Casings Casing_Machine_Custom_1, diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaCasingBlocks3.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaCasingBlocks3.java index 8cd6dd0ca8..76bd57b3fa 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaCasingBlocks3.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaCasingBlocks3.java @@ -46,6 +46,10 @@ extends GregtechMetaCasingBlocksAbstract { public GregtechMetaCasingBlocks3() { super(GregtechMetaCasingItemBlocks3.class, "gtplusplus.blockcasings.3", GT_Material_Casings.INSTANCE); for (byte i = 0; i < 16; i = (byte) (i + 1)) { + // Free up Redox casing in TAE + if (i >= 4 && i <= 8) { + continue; + } TAE.registerTexture(2, i, new GT_CopiedBlockTexture(this, 6, i)); } GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".0.name", "Aquatic Casing"); diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaCasingBlocks5.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaCasingBlocks5.java index 61c71ba552..4f84a3daca 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaCasingBlocks5.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaCasingBlocks5.java @@ -31,7 +31,8 @@ extends GregtechMetaCasingBlocksAbstract { TAE.registerTexture(0, 3, new GT_CopiedBlockTexture(this, 6, 3)); GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".4.name", "Sparge Tower Exterior Casing"); // Sparge Tower Casing TAE.registerTexture(0, 4, new GT_CopiedBlockTexture(this, 6, 4)); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".5.name", ""); // Unused + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".5.name", "Sturdy Printer Casing"); // Unused + TAE.registerTexture(1, 10, new GT_CopiedBlockTexture(this, 6, 5)); GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".6.name", ""); // Unused GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".7.name", ""); // Unused GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".8.name", ""); // Unused @@ -48,6 +49,7 @@ extends GregtechMetaCasingBlocksAbstract { GregtechItemList.Casing_IsaMill_Gearbox.set(new ItemStack(this, 1, 2)); GregtechItemList.Casing_ElementalDuplicator.set(new ItemStack(this, 1, 3)); GregtechItemList.Casing_Sparge_Tower_Exterior.set(new ItemStack(this, 1, 4)); + GregtechItemList.Casing_IndustrialAutoChisel.set(new ItemStack(this, 1, 5)); } @Override @@ -69,6 +71,8 @@ extends GregtechMetaCasingBlocksAbstract { return TexturesGtBlock.TEXTURE_TECH_PANEL_D.getIcon(); case 4: return TexturesGtBlock.Casing_Machine_Metal_Sheet_H.getIcon(); + case 5: + return TexturesGtBlock.Casing_Machine_Metal_Sheet_I.getIcon(); } } return Textures.BlockIcons.RENDERING_ERROR.getIcon(); diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaTileEntity_AutoChisel.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaTileEntity_AutoChisel.java index 39545daec1..ea99f8d52a 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaTileEntity_AutoChisel.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaTileEntity_AutoChisel.java @@ -1,5 +1,129 @@ package gtPlusPlus.xmod.gregtech.common.tileentities.machines.basic; -public class GregtechMetaTileEntity_AutoChisel { +import java.util.List; -} +import gregtech.api.enums.Textures.BlockIcons; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_BasicMachine; +import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.util.GT_Recipe; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; +import net.minecraft.item.ItemStack; +import team.chisel.carving.Carving; + +public class GregtechMetaTileEntity_AutoChisel extends GT_MetaTileEntity_BasicMachine { + + public GregtechMetaTileEntity_AutoChisel(int aID, String aName, String aNameRegional, int aTier) { + super(aID, aName, aNameRegional, aTier, 1, "Chisels things, Gregtech style", 1, 1, "Compressor.png", "", + new ITexture[]{ + new GT_RenderedTexture(BlockIcons.OVERLAY_SIDE_MASSFAB_ACTIVE), + new GT_RenderedTexture(BlockIcons.OVERLAY_SIDE_MASSFAB), + new GT_RenderedTexture(BlockIcons.OVERLAY_FRONT_MULTI_SMELTER_ACTIVE), + new GT_RenderedTexture(BlockIcons.OVERLAY_FRONT_MULTI_SMELTER), + new GT_RenderedTexture(TexturesGtBlock.Overlay_MatterFab_Active), + new GT_RenderedTexture(TexturesGtBlock.Overlay_MatterFab), + new GT_RenderedTexture(BlockIcons.OVERLAY_BOTTOM_MASSFAB_ACTIVE), + new GT_RenderedTexture(BlockIcons.OVERLAY_BOTTOM_MASSFAB) + }); + } + + public GregtechMetaTileEntity_AutoChisel(String aName, int aTier, String aDescription, ITexture[][][] aTextures, String aGUIName, String aNEIName) { + super(aName, aTier, 1, aDescription, aTextures, 1, 1, aGUIName, aNEIName); + } + + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GregtechMetaTileEntity_AutoChisel(this.mName, this.mTier, this.mDescription, this.mTextures, this.mGUIName, this.mNEIName); + } + + @Override + public String[] getDescription() { + String[] A = new String[]{ + this.mDescription, + "What you want to chisel goes in slot 1", + "What you want to get goes in the special slot (bottom right)", + "If special slot is empty, first chisel result is used" + }; + return A; + } + + @Override + public GT_Recipe.GT_Recipe_Map getRecipeList() { + return null; + } + + @Override + protected boolean allowPutStackValidated(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + return super.allowPutStackValidated(aBaseMetaTileEntity, aIndex, aSide, aStack) && hasChiselResults(aStack); + } + + // lets make sure the user isn't trying to make something from a block that doesn't have this as a valid target + private static boolean canBeMadeFrom(ItemStack from, ItemStack to) { + List results = getItemsForChiseling(from); + for (ItemStack s : results) { + if (s.getItem() == to.getItem() && s.getItemDamage() == to.getItemDamage()) { + return true; + } + } + return false; + } + + // lets make sure the user isn't trying to make something from a block that doesn't have this as a valid target + private static boolean hasChiselResults(ItemStack from) { + List results = getItemsForChiseling(from); + return results.size() > 0; + } + + private static List getItemsForChiseling(ItemStack aStack){ + return Carving.chisel.getItemsForChiseling(aStack); + } + + @Override + public int checkRecipe() { + ItemStack tOutput = null; + ItemStack aInput = getInputAt(0); + ItemStack aTarget = getSpecialSlot(); + if (aInput != null && hasChiselResults(aInput) && aInput.stackSize > 0) { + Logger.INFO("Has Valid Input."); + if (aTarget != null && canBeMadeFrom(aInput, aTarget)) { + tOutput = aTarget; + Logger.INFO("Has Valid Target."); + } + else { + tOutput = getItemsForChiseling(aInput).get(0); + Logger.INFO("Using target(0)"); + } + if (tOutput != null) { + Logger.INFO("Has Valid Output. "+tOutput.getDisplayName()); + // We can chisel this + if (canOutput(tOutput)) { + Logger.INFO("Can Output"); + getInputAt(0).stackSize -= 1; + Logger.INFO("Consuming 1 input"); + calculateOverclockedNess(16, 20); + Logger.INFO("Did Overclock"); + //In case recipe is too OP for that machine + if (mMaxProgresstime == Integer.MAX_VALUE - 1 && mEUt == Integer.MAX_VALUE - 1) { + Logger.INFO("Brrrrr"); + return FOUND_RECIPE_BUT_DID_NOT_MEET_REQUIREMENTS; + } + Logger.INFO("Setting Output"); + this.mOutputItems[0] = tOutput; + Logger.INFO("Recipe good."); + return FOUND_AND_SUCCESSFULLY_USED_RECIPE; + } + else { + Logger.INFO("Cannot Output"); + mOutputBlocked++; + return FOUND_RECIPE_BUT_DID_NOT_MEET_REQUIREMENTS; + } + } + } + Logger.INFO("Recipe bad."); + return DID_NOT_FIND_RECIPE; + } + +} \ No newline at end of file diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialChisel.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialChisel.java index 871b863b22..51775791f4 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialChisel.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialChisel.java @@ -1,5 +1,438 @@ package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.processing; -public class GregtechMetaTileEntity_IndustrialChisel { +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofChain; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; +import static gregtech.api.util.GT_StructureUtility.ofHatchAdder; +import static gtPlusPlus.core.util.data.ArrayUtils.removeNulls; -} +import java.util.ArrayList; +import java.util.List; + +import org.apache.commons.lang3.ArrayUtils; + +import com.gtnewhorizon.structurelib.structure.IStructureDefinition; +import com.gtnewhorizon.structurelib.structure.StructureDefinition; + +import gregtech.api.enums.Textures; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Energy; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_InputBus; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Maintenance; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Muffler; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_OutputBus; +import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.util.GTPP_Recipe; +import gregtech.api.util.GT_Multiblock_Tooltip_Builder; +import gregtech.api.util.GT_Recipe; +import gregtech.api.util.GT_Utility; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.block.ModBlocks; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.minecraft.ItemUtils; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; +import net.minecraft.init.Blocks; +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.FluidStack; +import team.chisel.carving.Carving; + +public class GregtechMetaTileEntity_IndustrialChisel extends GregtechMeta_MultiBlockBase { + + private int mCasing; + private IStructureDefinition STRUCTURE_DEFINITION = null; + + public GregtechMetaTileEntity_IndustrialChisel(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public GregtechMetaTileEntity_IndustrialChisel(String aName) { + super(aName); + } + + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GregtechMetaTileEntity_IndustrialChisel(this.mName); + } + + @Override + public String getMachineType() { + return "Chisel"; + } + + @Override + protected GT_Multiblock_Tooltip_Builder createTooltip() { + GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); + tt.addMachineType(getMachineType()) + .addInfo("Factory Grade Auto Chisel") + .addInfo("Target block goes in GUI slot") + .addInfo("If no target provided, firdt chisel result is used") + .addInfo("Speed: 200% | Eu Usage: 75% | Parallel: Tier x 16") + .addPollutionAmount(getPollutionPerSecond(null)) + .addSeparator() + .beginStructureBlock(3, 3, 3, true) + .addController("Front center") + .addCasingInfo("Sturdy Printer Casing", 10) + .addInputBus("Any casing", 1) + .addOutputBus("Any casing", 1) + .addEnergyHatch("Any casing", 1) + .addMaintenanceHatch("Any casing", 1) + .addMufflerHatch("Any casing", 1) + .toolTipFinisher(CORE.GT_Tooltip_Builder); + return tt; + } + + @Override + public IStructureDefinition getStructureDefinition() { + if (STRUCTURE_DEFINITION == null) { + STRUCTURE_DEFINITION = StructureDefinition.builder() + .addShape(mName, transpose(new String[][]{ + {"CCC", "CCC", "CCC"}, + {"C~C", "C-C", "CCC"}, + {"CCC", "CCC", "CCC"}, + })) + .addElement( + 'C', + ofChain( + ofHatchAdder( + GregtechMetaTileEntity_IndustrialChisel::addAdvChiselList, 90, 1 + ), + onElementPass( + x -> ++x.mCasing, + ofBlock( + ModBlocks.blockCasings5Misc, 5 + ) + ) + ) + ) + .build(); + } + return STRUCTURE_DEFINITION; + } + + public final boolean addAdvChiselList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + if (aTileEntity == null) { + return false; + } else { + IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_InputBus){ + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_OutputBus) { + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Maintenance){ + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Energy){ + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Muffler) { + return addToMachineList(aTileEntity, aBaseCasingIndex); + } + } + return false; + } + + @Override + public void construct(ItemStack stackSize, boolean hintsOnly) { + buildPiece(mName, stackSize, hintsOnly, 1, 1, 0); + } + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + mCasing = 0; + return checkPiece(mName, 1, 1, 0) && mCasing >= 10 && checkHatch(); + } + + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { + if (aSide == aFacing) { + return new ITexture[]{Textures.BlockIcons.getCasingTextureForId(90), new GT_RenderedTexture(aActive ? TexturesGtBlock.Overlay_Machine_Controller_Advanced_Active : TexturesGtBlock.Overlay_Machine_Controller_Advanced)}; + } + return new ITexture[]{Textures.BlockIcons.getCasingTextureForId(90)}; + } + + @Override + public boolean hasSlotInGUI() { + return true; + } + + @Override + public String getCustomGUIResourceName() { + return "ImplosionCompressor"; + } + + @Override + public boolean requiresVanillaGtGUI() { + return true; + } + + public GT_Recipe.GT_Recipe_Map getRecipeMap() { + return null; + } + + public boolean isCorrectMachinePart(ItemStack aStack) { + return true; + } + + // lets make sure the user isn't trying to make something from a block that doesn't have this as a valid target + private static boolean canBeMadeFrom(ItemStack from, ItemStack to) { + List results = getItemsForChiseling(from); + for (ItemStack s : results) { + if (s.getItem() == to.getItem() && s.getItemDamage() == to.getItemDamage()) { + return true; + } + } + return false; + } + + // lets make sure the user isn't trying to make something from a block that doesn't have this as a valid target + private static boolean hasChiselResults(ItemStack from) { + List results = getItemsForChiseling(from); + return results.size() > 0; + } + + private static List getItemsForChiseling(ItemStack aStack){ + return Carving.chisel.getItemsForChiseling(aStack); + } + + private GTPP_Recipe generateChiselRecipe(ItemStack aInput, ItemStack aTarget) { + if (aInput != null && hasChiselResults(aInput) && aInput.stackSize > 0) { + ItemStack tOutput = null; + if (aTarget != null && canBeMadeFrom(aInput, aTarget)) { + tOutput = aTarget; + } + else { + tOutput = getItemsForChiseling(aInput).get(0); + } + if (tOutput != null) { + // We can chisel this + log("Generated Chisel recipe good."); + GTPP_Recipe aRecipe = new GTPP_Recipe( + false, + new ItemStack[] {ItemUtils.getSimpleStack(aInput, 1)}, + new ItemStack[] {ItemUtils.getSimpleStack(tOutput, 1)}, + null, + new int[] {10000}, + new FluidStack[] {}, + new FluidStack[] {}, + 20, + 16, + 0); + return aRecipe; + } + } + Logger.INFO("Recipe bad."); + return null; + } + + public boolean checkRecipe(final ItemStack aStack) { + ArrayList aItems = this.getStoredInputs(); + if (!aItems.isEmpty()) { + + GT_Recipe tRecipe = generateChiselRecipe(aItems.get(0), this.getGUIItemStack()); + + if (tRecipe == null) { + log("BAD RETURN - 0"); + return false; + } + + // Based on the Processing Array. A bit overkill, but very flexible. + ItemStack[] aItemInputs = aItems.toArray(new ItemStack[aItems.size()]); + FluidStack[] aFluidInputs = new FluidStack[] {}; + + // Reset outputs and progress stats + this.mEUt = 0; + this.mMaxProgresstime = 0; + this.mOutputItems = new ItemStack[]{}; + this.mOutputFluids = new FluidStack[]{}; + + long tVoltage = getMaxInputVoltage(); + byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); + long tEnergy = getMaxInputEnergy(); + log("Running checkRecipeGeneric(0)"); + + log("Running checkRecipeGeneric(1)"); + // Remember last recipe - an optimization for findRecipe() + this.mLastRecipe = tRecipe; + + int aMaxParallelRecipes = getMaxParallelRecipes(); + int aEUPercent = getEuDiscountForParallelism(); + int aSpeedBonusPercent = 200; + + aMaxParallelRecipes = this.canBufferOutputs(tRecipe, aMaxParallelRecipes); + if (aMaxParallelRecipes == 0) { + log("BAD RETURN - 2"); + return false; + } + + // EU discount + float tRecipeEUt = (tRecipe.mEUt * aEUPercent) / 100.0f; + float tTotalEUt = 0.0f; + + int parallelRecipes = 0; + + log("parallelRecipes: "+parallelRecipes); + log("aMaxParallelRecipes: "+aMaxParallelRecipes); + log("tTotalEUt: "+tTotalEUt); + log("tVoltage: "+tVoltage); + log("tRecipeEUt: "+tRecipeEUt); + // Count recipes to do in parallel, consuming input items and fluids and considering input voltage limits + for (; parallelRecipes < aMaxParallelRecipes && tTotalEUt < (tEnergy - tRecipeEUt); parallelRecipes++) { + if (!tRecipe.isRecipeInputEqual(true, aFluidInputs, aItemInputs)) { + log("Broke at "+parallelRecipes+"."); + break; + } + log("Bumped EU from "+tTotalEUt+" to "+(tTotalEUt+tRecipeEUt)+"."); + tTotalEUt += tRecipeEUt; + } + + if (parallelRecipes == 0) { + log("BAD RETURN - 3"); + return false; + } + + // -- Try not to fail after this point - inputs have already been consumed! -- + log("parallelRecipes: "+parallelRecipes); + log("aMaxParallelRecipes: "+aMaxParallelRecipes); + log("tTotalEUt: "+tTotalEUt); + log("tVoltage: "+tVoltage); + log("tRecipeEUt: "+tRecipeEUt); + + + // Convert speed bonus to duration multiplier + // e.g. 100% speed bonus = 200% speed = 100%/200% = 50% recipe duration. + aSpeedBonusPercent = Math.max(-99, aSpeedBonusPercent); + float tTimeFactor = 100.0f / (100.0f + aSpeedBonusPercent); + this.mMaxProgresstime = (int)(tRecipe.mDuration * tTimeFactor); + + this.mEUt = (int)Math.ceil(tTotalEUt); + + this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); + this.mEfficiencyIncrease = 10000; + + // Overclock + if (this.mEUt <= 16) { + this.mEUt = (this.mEUt * (1 << tTier - 1) * (1 << tTier - 1)); + this.mMaxProgresstime = (this.mMaxProgresstime / (1 << tTier - 1)); + } else { + while (this.mEUt <= gregtech.api.enums.GT_Values.V[(tTier - 1)]) { + this.mEUt *= 4; + this.mMaxProgresstime /= 2; + } + } + + if (this.mEUt > 0) { + this.mEUt = (-this.mEUt); + } + + this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime); + + // Collect fluid outputs + FluidStack[] tOutputFluids = new FluidStack[tRecipe.mFluidOutputs.length]; + for (int h = 0; h < tRecipe.mFluidOutputs.length; h++) { + if (tRecipe.getFluidOutput(h) != null) { + tOutputFluids[h] = tRecipe.getFluidOutput(h).copy(); + tOutputFluids[h].amount *= parallelRecipes; + } + } + + // Collect output item types + ItemStack[] tOutputItems = new ItemStack[tRecipe.mOutputs.length]; + for (int h = 0; h < tRecipe.mOutputs.length; h++) { + if (tRecipe.getOutput(h) != null) { + tOutputItems[h] = tRecipe.getOutput(h).copy(); + tOutputItems[h].stackSize = 0; + } + } + + // Set output item stack sizes (taking output chance into account) + for (int f = 0; f < tOutputItems.length; f++) { + if (tRecipe.mOutputs[f] != null && tOutputItems[f] != null) { + for (int g = 0; g < parallelRecipes; g++) { + if (getBaseMetaTileEntity().getRandomNumber(10000) <= tRecipe.getOutputChance(f)) + tOutputItems[f].stackSize += tRecipe.mOutputs[f].stackSize; + } + } + } + + tOutputItems = removeNulls(tOutputItems); + + // Sanitize item stack size, splitting any stacks greater than max stack size + List splitStacks = new ArrayList(); + for (ItemStack tItem : tOutputItems) { + while (tItem.getMaxStackSize() < tItem.stackSize) { + ItemStack tmp = tItem.copy(); + tmp.stackSize = tmp.getMaxStackSize(); + tItem.stackSize = tItem.stackSize - tItem.getMaxStackSize(); + splitStacks.add(tmp); + } + } + + if (splitStacks.size() > 0) { + ItemStack[] tmp = new ItemStack[splitStacks.size()]; + tmp = splitStacks.toArray(tmp); + tOutputItems = ArrayUtils.addAll(tOutputItems, tmp); + } + + // Strip empty stacks + List tSList = new ArrayList(); + for (ItemStack tS : tOutputItems) { + if (tS.stackSize > 0) tSList.add(tS); + } + tOutputItems = tSList.toArray(new ItemStack[tSList.size()]); + + // Commit outputs + this.mOutputItems = tOutputItems; + this.mOutputFluids = tOutputFluids; + updateSlots(); + + // Play sounds (GT++ addition - GT multiblocks play no sounds) + startProcess(); + + log("GOOD RETURN - 1"); + return true; + } + + return false; + } + + @Override + public int getMaxParallelRecipes() { + return (16 * GT_Utility.getTier(this.getMaxInputVoltage())); + } + + @Override + public int getEuDiscountForParallelism() { + return 75; + } + + private static String sChiselSound = null; + + private static final String getChiselSound() { + if (sChiselSound == null) { + sChiselSound = Carving.chisel.getVariationSound(Blocks.stone, 0); + } + return sChiselSound; + } + + @Override + public String getSound() { + return getChiselSound(); + } + + public int getMaxEfficiency(ItemStack aStack) { + return 10000; + } + + public int getPollutionPerSecond(ItemStack aStack) { + return CORE.ConfigSwitches.pollutionPerSecondMultiAdvImplosion; + } + + public int getDamageToComponent(ItemStack aStack) { + return 0; + } + + public boolean explodesOnComponentBreak(ItemStack aStack) { + return false; + } + +} \ No newline at end of file diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_IndustrialRockBreaker.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_IndustrialRockBreaker.java index e681069078..885aa05716 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_IndustrialRockBreaker.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_IndustrialRockBreaker.java @@ -4,10 +4,13 @@ import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofChain; import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; +import static gregtech.api.enums.GT_Values.E; +import static gregtech.api.enums.GT_Values.RES_PATH_GUI; import static gregtech.api.util.GT_StructureUtility.ofHatchAdder; import static gtPlusPlus.core.util.data.ArrayUtils.removeNulls; import java.util.ArrayList; +import java.util.HashSet; import java.util.List; import org.apache.commons.lang3.ArrayUtils; @@ -35,10 +38,12 @@ import gregtech.api.util.GT_Multiblock_Tooltip_Builder; import gregtech.api.util.GT_OreDictUnificator; import gregtech.api.util.GT_Recipe; import gregtech.api.util.GT_Recipe.GT_Recipe_Map; +import gregtech.api.util.GT_Recipe.GT_Recipe_Map_Microwave; import gregtech.api.util.GT_Utility; import gtPlusPlus.core.block.ModBlocks; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.recipe.common.CI; +import gtPlusPlus.core.util.minecraft.FluidUtils; import gtPlusPlus.core.util.minecraft.ItemUtils; import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; @@ -50,7 +55,6 @@ import net.minecraftforge.fluids.FluidStack; public class GregtechMetaTileEntity_IndustrialRockBreaker extends GregtechMeta_MultiBlockBase { - private static Item circuit; private int mCasing; private IStructureDefinition STRUCTURE_DEFINITION = null; @@ -88,7 +92,7 @@ public class GregtechMetaTileEntity_IndustrialRockBreaker extends GregtechMeta_M .addSeparator() .beginStructureBlock(3, 4, 3, true) .addController("Bottom Center") - .addCasingInfo("Thermal Processing Casing", 10) + .addCasingInfo("Thermal Processing Casing", 9) .addCasingInfo("Thermal Containment Casing", 16) .addInputBus("Any Casing", 1) .addInputHatch("Any Casing", 1) @@ -143,7 +147,11 @@ public class GregtechMetaTileEntity_IndustrialRockBreaker extends GregtechMeta_M @Override public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { mCasing = 0; - return checkPiece(mName, 1, 3, 0) && mCasing >= 10 && mEnergyHatches.size() == 1 && checkHatch(); + boolean aCheckPiece = checkPiece(mName, 1, 3, 0); + boolean aCasingCount = mCasing >= 9; + boolean aCheckHatch = checkHatch(); + log(""+aCheckPiece+", "+aCasingCount+", "+aCheckHatch); + return aCheckPiece && aCasingCount && aCheckHatch; } public final boolean addRockBreakerList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { @@ -196,10 +204,31 @@ public class GregtechMetaTileEntity_IndustrialRockBreaker extends GregtechMeta_M public String getCustomGUIResourceName() { return "ElectricBlastFurnace"; } + + private static final GT_Recipe_Map sFakeRecipeMap = new GT_Recipe_Map(new HashSet<>(0), "gt.recipe.fakerockbreaker", "Rock Breaker", "smelting", RES_PATH_GUI + "basicmachines/E_Furnace", 1, 1, 0, 0, 1, E, 1, E, true, false); + private static void generateRecipeMap() { + if (sRecipe_Cobblestone == null || sRecipe_SmoothStone == null || sRecipe_Redstone == null) { + generateRecipes(); + } + FluidStack[] aInputFluids = new FluidStack[] {FluidUtils.getWater(1000), FluidUtils.getLava(1000)}; + GT_Recipe aTemp = sRecipe_Cobblestone.copy(); + aTemp.mFluidInputs = aInputFluids; + sFakeRecipeMap.add(aTemp); + aTemp = sRecipe_SmoothStone.copy(); + aTemp.mFluidInputs = aInputFluids; + sFakeRecipeMap.add(aTemp); + aTemp = sRecipe_Redstone.copy(); + aTemp.mFluidInputs = aInputFluids; + sFakeRecipeMap.add(aTemp); + } + @Override public GT_Recipe.GT_Recipe_Map getRecipeMap() { - return GT_Recipe_Map.sRockBreakerFakeRecipes; + if (sFakeRecipeMap.mRecipeList.isEmpty()) { + generateRecipeMap(); + } + return sFakeRecipeMap; } @Override @@ -212,58 +241,52 @@ public class GregtechMetaTileEntity_IndustrialRockBreaker extends GregtechMeta_M private static GT_Recipe sRecipe_Redstone; private static final void generateRecipes() { - if (sRecipe_Cobblestone == null) { - sRecipe_Cobblestone = new GTPP_Recipe( - false, - new ItemStack[] { - CI.getNumberedCircuit(1) - }, - new ItemStack[] { - ItemUtils.getSimpleStack(Blocks.cobblestone) - }, - null, - new int[] {10000}, - null, - null, - 16, - 32, - 0); - } - if (sRecipe_SmoothStone == null) { - sRecipe_SmoothStone = new GTPP_Recipe( - false, - new ItemStack[] { - CI.getNumberedCircuit(2) - }, - new ItemStack[] { - ItemUtils.getSimpleStack(Blocks.stone) - }, - null, - new int[] {10000}, - null, - null, - 16, - 32, - 0); - } - if (sRecipe_Redstone == null) { - sRecipe_Redstone = new GTPP_Recipe( - false, - new ItemStack[] { - CI.getNumberedCircuit(3), - GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Redstone, 1L) - }, - new ItemStack[] { - ItemUtils.getSimpleStack(Blocks.obsidian) - }, - null, - new int[] {10000}, - null, - null, - 128, - 32, - 0); - } + sRecipe_Cobblestone = new GTPP_Recipe( + false, + new ItemStack[] { + CI.getNumberedCircuit(1) + }, + new ItemStack[] { + ItemUtils.getSimpleStack(Blocks.cobblestone) + }, + null, + new int[] {10000}, + null, + null, + 16, + 32, + 0); + sRecipe_SmoothStone = new GTPP_Recipe( + false, + new ItemStack[] { + CI.getNumberedCircuit(2) + }, + new ItemStack[] { + ItemUtils.getSimpleStack(Blocks.stone) + }, + null, + new int[] {10000}, + null, + null, + 16, + 32, + 0); + sRecipe_Redstone = new GTPP_Recipe( + false, + new ItemStack[] { + CI.getNumberedCircuit(3), + GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Redstone, 1L) + }, + new ItemStack[] { + ItemUtils.getSimpleStack(Blocks.obsidian) + }, + null, + new int[] {10000}, + null, + null, + 128, + 32, + 0); } @Override @@ -301,7 +324,9 @@ public class GregtechMetaTileEntity_IndustrialRockBreaker extends GregtechMeta_M return false; } - generateRecipes(); + if (sRecipe_Cobblestone == null || sRecipe_SmoothStone == null || sRecipe_Redstone == null) { + generateRecipes(); + } int aCircuit = aGuiCircuit.getItemDamage(); @@ -327,7 +352,7 @@ public class GregtechMetaTileEntity_IndustrialRockBreaker extends GregtechMeta_M // Based on the Processing Array. A bit overkill, but very flexible. ItemStack[] aItemInputs = aItems.toArray(new ItemStack[aItems.size()]); - FluidStack[] aFluidInputs = aFluids.toArray(new FluidStack[aFluids.size()]); + FluidStack[] aFluidInputs = new FluidStack[] {}; // Reset outputs and progress stats this.mEUt = 0; @@ -365,16 +390,25 @@ public class GregtechMetaTileEntity_IndustrialRockBreaker extends GregtechMeta_M log("tTotalEUt: "+tTotalEUt); log("tVoltage: "+tVoltage); log("tRecipeEUt: "+tRecipeEUt); - // Count recipes to do in parallel, consuming input items and fluids and considering input voltage limits - for (; parallelRecipes < aMaxParallelRecipes && tTotalEUt < (tEnergy - tRecipeEUt); parallelRecipes++) { - if (!tRecipe.isRecipeInputEqual(true, aFluidInputs, aItemInputs)) { - log("Broke at "+parallelRecipes+"."); - break; + + if (aItems.size() > 0 && aCircuit == 3) { + // Count recipes to do in parallel, consuming input items and fluids and considering input voltage limits + for (; parallelRecipes < aMaxParallelRecipes && tTotalEUt < (tEnergy - tRecipeEUt); parallelRecipes++) { + if (!tRecipe.isRecipeInputEqual(true, aFluidInputs, aItemInputs)) { + break; + } + log("Bumped EU from "+tTotalEUt+" to "+(tTotalEUt+tRecipeEUt)+"."); + tTotalEUt += tRecipeEUt; + } + } + else if (aCircuit >= 1 && aCircuit <= 2) { + for (; parallelRecipes < aMaxParallelRecipes && tTotalEUt < (tEnergy - tRecipeEUt); parallelRecipes++) { + log("Bumped EU from "+tTotalEUt+" to "+(tTotalEUt+tRecipeEUt)+"."); + tTotalEUt += tRecipeEUt; } - log("Bumped EU from "+tTotalEUt+" to "+(tTotalEUt+tRecipeEUt)+"."); - tTotalEUt += tRecipeEUt; } + log("Broke at "+parallelRecipes+"."); if (parallelRecipes == 0) { log("BAD RETURN - 3"); return false; @@ -488,7 +522,7 @@ public class GregtechMetaTileEntity_IndustrialRockBreaker extends GregtechMeta_M @Override public int getEuDiscountForParallelism() { - return 80; + return 75; } @Override diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIndustrialChisel.java b/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIndustrialChisel.java index aa28faa6f9..2027e6b190 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIndustrialChisel.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIndustrialChisel.java @@ -1,14 +1,25 @@ package gtPlusPlus.xmod.gregtech.registration.gregtech; import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; -import gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production.GregtechMetaTileEntity_IndustrialRockBreaker; +import gtPlusPlus.xmod.gregtech.common.tileentities.machines.basic.GregtechMetaTileEntity_AutoChisel; +import gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.processing.GregtechMetaTileEntity_IndustrialChisel; public class GregtechIndustrialChisel { - public static void run() { - // Industrial Maceration Stack Multiblock - /*GregtechItemList.Controller_IndustrialRockBreaker.set(new GregtechMetaTileEntity_IndustrialRockBreaker(32005, - "industrialrockcrusher.controller.tier.single", "Boldarnator").getStackForm(1L));*/ + public static void run() { + GregtechItemList.GT_Chisel_LV.set(new GregtechMetaTileEntity_AutoChisel(31066, + "chisel.tier.01", "Basic Auto-Chisel", 1).getStackForm(1L)); + GregtechItemList.GT_Chisel_MV.set(new GregtechMetaTileEntity_AutoChisel(31067, + "chisel.tier.02", "Advanced Auto-Chisel", 2).getStackForm(1L)); + GregtechItemList.GT_Chisel_HV.set(new GregtechMetaTileEntity_AutoChisel(31068, + "chisel.tier.03", "Precision Auto-Chisel", 3).getStackForm(1L)); + + GregtechItemList.Controller_IndustrialAutoChisel.set( + new GregtechMetaTileEntity_IndustrialChisel(31069, + "multimachine.adv.chisel", + "Industrial 3D Copying Machine").getStackForm(1L)); + + } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIndustrialRockBreaker.java b/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIndustrialRockBreaker.java index 45b923083e..562693ee3e 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIndustrialRockBreaker.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIndustrialRockBreaker.java @@ -6,7 +6,7 @@ import gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production.Gr public class GregtechIndustrialRockBreaker { public static void run() { - GregtechItemList.Controller_IndustrialRockBreaker.set(new GregtechMetaTileEntity_IndustrialRockBreaker(32005, + GregtechItemList.Controller_IndustrialRockBreaker.set(new GregtechMetaTileEntity_IndustrialRockBreaker(31065, "industrialrockcrusher.controller.tier.single", "Boldarnator").getStackForm(1L)); } -- cgit From 998c739e50ef56e3a4cf2c4cdd397a8cdfbeef6d Mon Sep 17 00:00:00 2001 From: Alkalus <3060479+draknyte1@users.noreply.github.com> Date: Sun, 19 Dec 2021 15:00:59 +0000 Subject: Added pollution config values for the new multis. Added recipes for the new blocks. Fix Rock Breaker handling of Redstone/Obsidian. --- .../java/gtPlusPlus/core/config/ConfigHandler.java | 2 + src/main/java/gtPlusPlus/core/lib/CORE.java | 2 + .../gtPlusPlus/core/recipe/RECIPES_Machines.java | 76 +++++++++++++++++++++- .../common/blocks/GregtechMetaCasingBlocks5.java | 3 +- .../GregtechMetaTileEntity_IndustrialChisel.java | 2 +- ...egtechMetaTileEntity_IndustrialRockBreaker.java | 10 ++- 6 files changed, 86 insertions(+), 9 deletions(-) (limited to 'src/main/java/gtPlusPlus/xmod/gregtech') diff --git a/src/main/java/gtPlusPlus/core/config/ConfigHandler.java b/src/main/java/gtPlusPlus/core/config/ConfigHandler.java index 61610a03e9..382b63e2c3 100644 --- a/src/main/java/gtPlusPlus/core/config/ConfigHandler.java +++ b/src/main/java/gtPlusPlus/core/config/ConfigHandler.java @@ -225,6 +225,8 @@ public class ConfigHandler { pollutionPerSecondMultiMassFabricator = config.get("pollution", "pollutionPerSecondMultiMassFabricator", pollutionPerSecondMultiMassFabricator,"pollution rate in gibbl/s for the Matter fabrication CPU").getInt(pollutionPerSecondMultiMassFabricator); pollutionPerSecondMultiRefinery = config.get("pollution", "pollutionPerSecondMultiRefinery", pollutionPerSecondMultiRefinery,"pollution rate in gibbl/s for the Reactor fuel processing plant").getInt(pollutionPerSecondMultiRefinery); //pollutionPerSecondMultiGeneratorArray; + pollutionPerSecondMultiIndustrialRockBreaker = config.get("pollution", "pollutionPerSecondMultiIndustrialRockBreaker", pollutionPerSecondMultiIndustrialRockBreaker,"pollution rate in gibbl/s for the Industrial Rock Breaker").getInt(pollutionPerSecondMultiIndustrialRockBreaker); + pollutionPerSecondMultiIndustrialChisel = config.get("pollution", "pollutionPerSecondMultiIndustrialChisel", pollutionPerSecondMultiIndustrialChisel,"pollution rate in gibbl/s for the Industrial Chisel").getInt(pollutionPerSecondMultiIndustrialChisel); pollutionPerSecondMultiTreeFarm = config.get("pollution", "pollutionPerSecondMultiTreeFarm", pollutionPerSecondMultiTreeFarm,"pollution rate in gibbl/s for the Tree growth simulator").getInt(pollutionPerSecondMultiTreeFarm); pollutionPerSecondMultiFrothFlotationCell = config.get("pollution", "pollutionPerSecondMultiFrothFlotationCell", pollutionPerSecondMultiFrothFlotationCell,"pollution rate in gibbl/s for the Flotation cell regulator").getInt(pollutionPerSecondMultiFrothFlotationCell); pollutionPerSecondMultiAutoCrafter = config.get("pollution", "pollutionPerSecondMultiAutoCrafter", pollutionPerSecondMultiAutoCrafter,"pollution rate in gibbl/s for the Large-Scale auto assembler v1.01").getInt(pollutionPerSecondMultiAutoCrafter); diff --git a/src/main/java/gtPlusPlus/core/lib/CORE.java b/src/main/java/gtPlusPlus/core/lib/CORE.java index 1ef04aa154..7508b9fc8f 100644 --- a/src/main/java/gtPlusPlus/core/lib/CORE.java +++ b/src/main/java/gtPlusPlus/core/lib/CORE.java @@ -300,6 +300,8 @@ public class CORE { public static int pollutionPerSecondMultiAutoCrafter = 500; public static int pollutionPerSecondMultiThermalBoiler = 700; public static int pollutionPerSecondMultiAlgaePond = 0; + public static int pollutionPerSecondMultiIndustrialRockBreaker = 100; + public static int pollutionPerSecondMultiIndustrialChisel = 50; //pollution single blocks public static int basePollutionPerSecondSemiFluidGenerator = 40; public static double[] pollutionReleasedByTierSemiFluidGenerator = new double[]{0,2.0,4.0,8.0}; diff --git a/src/main/java/gtPlusPlus/core/recipe/RECIPES_Machines.java b/src/main/java/gtPlusPlus/core/recipe/RECIPES_Machines.java index 14001d86bd..e190bc67fa 100644 --- a/src/main/java/gtPlusPlus/core/recipe/RECIPES_Machines.java +++ b/src/main/java/gtPlusPlus/core/recipe/RECIPES_Machines.java @@ -253,7 +253,9 @@ public class RECIPES_Machines { chemPlant(); zyngen(); milling(); - sparging(); + sparging(); + chisels(); + rockBreaker(); } @@ -2637,6 +2639,78 @@ public class RECIPES_Machines { 60 * 20 * 2, MaterialUtils.getVoltageForTier(5)); } + + private static void chisels() { + ItemStack[] aChisels = new ItemStack[] { + GregtechItemList.GT_Chisel_LV.get(1), + GregtechItemList.GT_Chisel_MV.get(1), + GregtechItemList.GT_Chisel_HV.get(1), + }; + for (int i=1;i<4;i++) { + CORE.RA.addSixSlotAssemblingRecipe( + new ItemStack[] { + CI.getNumberedBioCircuit(10+i), + CI.getTieredMachineCasing(i), + CI.getPlate(i, 4), + CI.getElectricMotor(i, 2), + CI.getConveyor(i, 2), + CI.getRobotArm(i, 1) + }, + CI.getTieredFluid(i, 144 * 4), + aChisels[i-1], + 20 * 20, + MaterialUtils.getVoltageForTier(i)); + } + + CORE.RA.addSixSlotAssemblingRecipe( + new ItemStack[] { + CI.getNumberedBioCircuit(14), + aChisels[2], + CI.getPlate(4, 8), + CI.getElectricMotor(4, 8), + CI.getConveyor(4, 8), + CI.getRobotArm(4, 4) + }, + CI.getTieredFluid(4, 144 * 8), + GregtechItemList.Controller_IndustrialAutoChisel.get(1), + 20 * 20, + MaterialUtils.getVoltageForTier(4)); + + CORE.RA.addSixSlotAssemblingRecipe( + new ItemStack[] { + CI.getNumberedBioCircuit(14), + ItemList.Casing_SolidSteel.get(2), + CI.getPlate(4, 2), + CI.getTieredComponent(OrePrefixes.plate, 3, 4), + CI.getTieredComponent(OrePrefixes.ring, 3, 8), + CI.getTieredComponent(OrePrefixes.rod, 2, 4), + }, + CI.getTieredFluid(2, 144 * 2), + GregtechItemList.Casing_IndustrialAutoChisel.get(1), + 20 * 20, + MaterialUtils.getVoltageForTier(3)); + + + + } + + private static void rockBreaker() { + + CORE.RA.addSixSlotAssemblingRecipe( + new ItemStack[] { + CI.getNumberedAdvancedCircuit(12), + ItemList.Machine_EV_RockBreaker.get(1), + ALLOY.STAINLESS_STEEL.getPlate(8), + ALLOY.STAINLESS_STEEL.getRing(4), + CI.getTieredComponentOfMaterial(Materials.Aluminium, OrePrefixes.plateDouble, 8), + ALLOY.EGLIN_STEEL.getScrew(8), + }, + ELEMENT.getInstance().ALUMINIUM.getFluidStack(144 * 8), + GregtechItemList.Controller_IndustrialRockBreaker.get(1), + 60 * 20 * 2, + MaterialUtils.getVoltageForTier(4)); + + } private static void fakeMachineCasingCovers() { GregtechItemList[] mMachineCasingCovers = new GregtechItemList[] { diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaCasingBlocks5.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaCasingBlocks5.java index 4f84a3daca..3d15e5cf58 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaCasingBlocks5.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaCasingBlocks5.java @@ -18,7 +18,8 @@ import net.minecraft.world.IBlockAccess; public class GregtechMetaCasingBlocks5 extends GregtechMetaCasingBlocksAbstract { - //Free Indexes within TAE: 90, 91, 92, 94, 114, 116, 117, 118, 119, 120, 121, 124, 125, 126, 127 + // Free Indexes within TAE: 91, 92, 94, 100, 101, 102, 103, 104, 114, 116, 117, 118, 119, 120, 121, 124, 125, 126, 127 + // 19 Free Indexes private static final TexturesGrinderMultiblock mGrinderOverlayHandler = new TexturesGrinderMultiblock(); public GregtechMetaCasingBlocks5() { diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialChisel.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialChisel.java index 51775791f4..77cc19d5d4 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialChisel.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialChisel.java @@ -424,7 +424,7 @@ public class GregtechMetaTileEntity_IndustrialChisel extends GregtechMeta_MultiB } public int getPollutionPerSecond(ItemStack aStack) { - return CORE.ConfigSwitches.pollutionPerSecondMultiAdvImplosion; + return CORE.ConfigSwitches.pollutionPerSecondMultiIndustrialChisel; } public int getDamageToComponent(ItemStack aStack) { diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_IndustrialRockBreaker.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_IndustrialRockBreaker.java index 885aa05716..1b8835f289 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_IndustrialRockBreaker.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_IndustrialRockBreaker.java @@ -82,9 +82,7 @@ public class GregtechMetaTileEntity_IndustrialRockBreaker extends GregtechMeta_M GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); tt.addMachineType(getMachineType()) .addInfo("Controller Block for the Industrial Rock Breaker") - .addInfo("200% Faster than the single block version") - .addInfo("Only uses 80% of the eu/t normally required") - .addInfo("Processes 8 items per voltage tier") + .addInfo("Speed: 200% | Eu Usage: 75% | Parallel: Tier x 8") .addInfo("Circuit goes in the Input Bus or GUI slot") .addInfo("1 = cobble, 2 = stone, 3 = obsidian") .addInfo("Supply Water/Lava") @@ -394,8 +392,8 @@ public class GregtechMetaTileEntity_IndustrialRockBreaker extends GregtechMeta_M if (aItems.size() > 0 && aCircuit == 3) { // Count recipes to do in parallel, consuming input items and fluids and considering input voltage limits for (; parallelRecipes < aMaxParallelRecipes && tTotalEUt < (tEnergy - tRecipeEUt); parallelRecipes++) { - if (!tRecipe.isRecipeInputEqual(true, aFluidInputs, aItemInputs)) { - break; + if (!this.depleteInput(tRecipe.mInputs[1])) { + break; } log("Bumped EU from "+tTotalEUt+" to "+(tTotalEUt+tRecipeEUt)+"."); tTotalEUt += tRecipeEUt; @@ -532,7 +530,7 @@ public class GregtechMetaTileEntity_IndustrialRockBreaker extends GregtechMeta_M @Override public int getPollutionPerSecond(final ItemStack aStack) { - return CORE.ConfigSwitches.pollutionPerSecondMultiABS; + return CORE.ConfigSwitches.pollutionPerSecondMultiIndustrialRockBreaker; } @Override -- cgit From b230d17992013dcb5f3df142788f0cb51a72d1e0 Mon Sep 17 00:00:00 2001 From: Alkalus <3060479+draknyte1@users.noreply.github.com> Date: Sun, 19 Dec 2021 15:48:48 +0000 Subject: Added Advanced Air Intake Hatch. Added Reservoir Hatch. Refactored Air Intake Hatch into a base class. --- .../xmod/gregtech/api/enums/GregtechItemList.java | 4 + .../GT_MetaTileEntity_Hatch_AirIntake.java | 251 +++----------------- .../GT_MetaTileEntity_Hatch_AirIntake_Extreme.java | 110 +++++++++ .../GT_MetaTileEntity_Hatch_FluidGenerator.java | 254 +++++++++++++++++++++ .../GT_MetaTileEntity_Hatch_Reservoir.java | 81 +++++++ .../common/blocks/textures/TexturesGtBlock.java | 2 + .../gregtech/GregtechCustomHatches.java | 5 + .../blocks/TileEntities/adv_machine_water.png | Bin 0 -> 218 bytes 8 files changed, 485 insertions(+), 222 deletions(-) create mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_AirIntake_Extreme.java create mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_FluidGenerator.java create mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Reservoir.java create mode 100644 src/main/resources/assets/miscutils/textures/blocks/TileEntities/adv_machine_water.png (limited to 'src/main/java/gtPlusPlus/xmod/gregtech') diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java index d3caf99af6..a8ee2e24ad 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java @@ -438,6 +438,10 @@ public enum GregtechItemList implements GregtechItemContainer { //Air Intake hatch Hatch_Air_Intake, + Hatch_Air_Intake_Extreme, + + //Reservoir Hatch + Hatch_Reservoir, //XL Turbine Rotor Hatch /*Hatch_Turbine_Rotor,*/ diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_AirIntake.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_AirIntake.java index 5fb3b11d08..4716d8038a 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_AirIntake.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_AirIntake.java @@ -1,165 +1,65 @@ package gtPlusPlus.xmod.gregtech.api.metatileentity.implementations; -import java.lang.reflect.Field; - -import gregtech.api.enums.Textures; -import gregtech.api.interfaces.IIconContainer; 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.objects.GT_RenderedTexture; -import gtPlusPlus.api.objects.random.XSTR; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.util.minecraft.FluidUtils; -import gtPlusPlus.core.util.reflect.ReflectionUtils; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.Fluid; -import net.minecraftforge.fluids.FluidStack; -public class GT_MetaTileEntity_Hatch_AirIntake extends GT_MetaTileEntity_Hatch_Input { - - private static XSTR floatGen; - public int mProgresstime = 0, mMaxProgresstime = 0; +public class GT_MetaTileEntity_Hatch_AirIntake extends GT_MetaTileEntity_Hatch_FluidGenerator { - public GT_MetaTileEntity_Hatch_AirIntake(final int aID, final String aName, final String aNameRegional, - final int aTier) { + public GT_MetaTileEntity_Hatch_AirIntake(final int aID, final String aName, final String aNameRegional, final int aTier) { super(aID, aName, aNameRegional, aTier); } - public GT_MetaTileEntity_Hatch_AirIntake(final String aName, final int aTier, final String aDescription, - final ITexture[][][] aTextures) { + public GT_MetaTileEntity_Hatch_AirIntake(final String aName, final int aTier, final String aDescription, final ITexture[][][] aTextures) { super(aName, aTier, aDescription, aTextures); } - /*public GT_MetaTileEntity_Hatch_AirIntake(final String aName, final int aTier, final String[] aDescription, - final ITexture[][][] aTextures) { - super(aName, aTier, aDescription, aTextures); - }*/ - - private static String[] S; - private static Field F; - - public synchronized String[] getDescription() { - try { - if (F == null || S == null) { - Field t = ReflectionUtils.getField(this.getClass(), "mDescriptionArray"); - if (t != null) { - F = t; - } - else { - F = ReflectionUtils.getField(this.getClass(), "mDescription"); - } - if (S == null && F != null) { - Object o = F.get(this); - if (o instanceof String[]) { - S = (String[]) o; - } - else if (o instanceof String) { - S = new String[] {(String) o}; - } - } - - } - } - catch (Throwable t) { - - } - if (S != null) { - final String[] desc = new String[S.length + 4]; - System.arraycopy(S, 0, desc, 0, S.length); - desc[S.length] = "DO NOT OBSTRUCT THE INPUT!"; - desc[S.length + 1] = "Draws in Air from the surrounding environment"; - desc[S.length + 2] = "Creates 1000L of Air every 4 ticks"; - desc[S.length + 3] = CORE.GT_Tooltip; - return desc; - } - else { - return new String[] {"DO NOT OBSTRUCT THE INPUT!", "Draws in Air from the surrounding environment", "Creates 1000L of Air every 4 ticks", CORE.GT_Tooltip}; - } - - } - - public ITexture[] getTexturesActive(final ITexture aBaseTexture) { - return new ITexture[]{aBaseTexture, - new GT_RenderedTexture((IIconContainer) Textures.BlockIcons.OVERLAY_MUFFLER)}; - } - - public ITexture[] getTexturesInactive(final ITexture aBaseTexture) { - return new ITexture[]{aBaseTexture, - new GT_RenderedTexture((IIconContainer) Textures.BlockIcons.OVERLAY_MUFFLER)}; - } - - public boolean isSimpleMachine() { - return true; - } - - public boolean isFacingValid(final byte aFacing) { - return true; + public MetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + return new GT_MetaTileEntity_Hatch_AirIntake(this.mName, this.mTier, this.mDescription, this.mTextures); } - public boolean isAccessAllowed(final EntityPlayer aPlayer) { - return true; + @Override + public String[] getCustomTooltip() { + String[] aTooltip = new String[3]; + aTooltip[0] = "DO NOT OBSTRUCT THE INPUT!"; + aTooltip[1] = "Draws in Air from the surrounding environment"; + aTooltip[2] = "Creates 1000L of Air every 4 ticks"; + return aTooltip; } - public boolean isValidSlot(final int aIndex) { - return false; + @Override + public Fluid getFluidToGenerate() { + return FluidUtils.getAir(1).getFluid(); } - public MetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { - return new GT_MetaTileEntity_Hatch_AirIntake(this.mName, this.mTier, this.mDescription, this.mTextures); + @Override + public int getAmountOfFluidToGenerate() { + return 1000; } - public boolean allowPullStack(final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, final byte aSide, - final ItemStack aStack) { - return false; + @Override + public int getMaxTickTime() { + return 4; } - public boolean allowPutStack(final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, final byte aSide, - final ItemStack aStack) { - return false; + @Override + public int getCapacity() { + return 128000; } - public void onPostTick(final IGregTechTileEntity aBaseMetaTileEntity, final long aTick) { - super.onPostTick(aBaseMetaTileEntity, aTick); - - if (!aBaseMetaTileEntity.isAllowedToWork()) { - aBaseMetaTileEntity.setActive(false); - mProgresstime = 0; - mMaxProgresstime = 0; - } - else { - aBaseMetaTileEntity.setActive(true); - mMaxProgresstime = 4; - if (++mProgresstime >= mMaxProgresstime) { - addAirToHatch(aTick); - mProgresstime = 0; - } - } + @Override + public boolean doesHatchMeetConditionsToGenerate() { + return this.getBaseMetaTileEntity().getAirAtSide(this.getBaseMetaTileEntity().getFrontFacing()); } - - @Override - public int getProgresstime() { - return mProgresstime; - } - - @Override - public int maxProgresstime() { - return mMaxProgresstime; - } - @Override - public int increaseProgress(int aProgress) { - mProgresstime += aProgress; - return mMaxProgresstime - mProgresstime; - } - - public void pollutionParticles(final World aWorld, final String name) { + @Override + public void generateParticles(World aWorld, String name) { if (this.getBaseMetaTileEntity().isServerSide()) { return; } @@ -207,97 +107,4 @@ public class GT_MetaTileEntity_Hatch_AirIntake extends GT_MetaTileEntity_Hatch_I (double) -ySpd, (double) zSpd); } - static { - GT_MetaTileEntity_Hatch_AirIntake.floatGen = new XSTR(); - } - - public int getTankPressure() { - return 100; - } - - public int getCapacity() { - return 128000; - } - - @Override - public boolean canTankBeEmptied() { - return true; - } - - private static Fluid AIR; - - public boolean isAirInHatch() { - if (this.mFluid != null) { - if (AIR == null) { - AIR = FluidUtils.getAir(1).getFluid(); - } - if (AIR == this.mFluid.getFluid()) { - return true; - } - } - return false; - } - - public boolean addAirToHatch(long aTick) { - if (!this.getBaseMetaTileEntity().getAirAtSide(this.getBaseMetaTileEntity().getFrontFacing())) { - return false; - } - boolean didFill = this.fill(FluidUtils.getAir(1000), true) > 0; - if (didFill) { - this.pollutionParticles(this.getBaseMetaTileEntity().getWorld(), "cloud"); - } - return didFill; - } - - @Override - public boolean canTankBeFilled() { - if (this.mFluid == null || (this.mFluid != null && (this.mFluid.amount <= this.getCapacity()))) { - return true; - } - return false; - } - - @Override - public boolean doesEmptyContainers() { - return false; - } - - @Override - public boolean doesFillContainers() { - return true; - } - - @Override - public int fill(FluidStack aFluid, boolean doFill) { - return super.fill(aFluid, doFill); - } - - @Override - public boolean canFill(ForgeDirection aSide, Fluid aFluid) { - return false; - } - - @Override - public int fill(ForgeDirection arg0, FluidStack arg1, boolean arg2) { - return 0; - } - - @Override - public int fill_default(ForgeDirection aSide, FluidStack aFluid, boolean doFill) { - return 0; - } - - @Override - public void saveNBTData(NBTTagCompound aNBT) { - aNBT.setInteger("mProgresstime", mProgresstime); - aNBT.setInteger("mMaxProgresstime", mMaxProgresstime); - super.saveNBTData(aNBT); - } - - @Override - public void loadNBTData(NBTTagCompound aNBT) { - mProgresstime = aNBT.getInteger("mProgresstime"); - mMaxProgresstime = aNBT.getInteger("mMaxProgresstime"); - super.loadNBTData(aNBT); - } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_AirIntake_Extreme.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_AirIntake_Extreme.java new file mode 100644 index 0000000000..5ebb2da8d4 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_AirIntake_Extreme.java @@ -0,0 +1,110 @@ +package gtPlusPlus.xmod.gregtech.api.metatileentity.implementations; + +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.MetaTileEntity; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.minecraft.FluidUtils; +import net.minecraft.world.World; +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.Fluid; + +public class GT_MetaTileEntity_Hatch_AirIntake_Extreme extends GT_MetaTileEntity_Hatch_FluidGenerator { + + public GT_MetaTileEntity_Hatch_AirIntake_Extreme(final int aID, final String aName, final String aNameRegional, final int aTier) { + super(aID, aName, aNameRegional, aTier); + } + + public GT_MetaTileEntity_Hatch_AirIntake_Extreme(final String aName, final int aTier, final String aDescription, final ITexture[][][] aTextures) { + super(aName, aTier, aDescription, aTextures); + } + + + public MetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + return new GT_MetaTileEntity_Hatch_AirIntake_Extreme(this.mName, this.mTier, this.mDescription, this.mTextures); + } + + @Override + public String[] getCustomTooltip() { + String[] aTooltip = new String[3]; + aTooltip[0] = "DO NOT OBSTRUCT THE INPUT!"; + aTooltip[1] = "Draws in Air from the surrounding environment"; + aTooltip[2] = "Creates 5000L of Air every 4 ticks"; + return aTooltip; + } + + @Override + public Fluid getFluidToGenerate() { + return FluidUtils.getAir(1).getFluid(); + } + + @Override + public int getAmountOfFluidToGenerate() { + return 5000; + } + + @Override + public int getMaxTickTime() { + return 4; + } + + @Override + public int getCapacity() { + return 256000; + } + + @Override + public boolean doesHatchMeetConditionsToGenerate() { + return this.getBaseMetaTileEntity().getAirAtSide(this.getBaseMetaTileEntity().getFrontFacing()); + } + + @Override + public void generateParticles(World aWorld, String name) { + if (this.getBaseMetaTileEntity().isServerSide()) { + return; + } + final float ran1 = GT_MetaTileEntity_Hatch_AirIntake_Extreme.floatGen.nextFloat(); + float ran2 = 0.0f; + float ran3 = 0.0f; + ran2 = GT_MetaTileEntity_Hatch_AirIntake_Extreme.floatGen.nextFloat(); + ran3 = GT_MetaTileEntity_Hatch_AirIntake_Extreme.floatGen.nextFloat(); + + final IGregTechTileEntity aMuffler = this.getBaseMetaTileEntity(); + final ForgeDirection aDir = ForgeDirection.getOrientation((int) aMuffler.getFrontFacing()); + final float xPos = aDir.offsetX * 0.76f + aMuffler.getXCoord() + 0.25f; + float yPos = aDir.offsetY * 0.76f + aMuffler.getYCoord() + 0.65f; + final float zPos = aDir.offsetZ * 0.76f + aMuffler.getZCoord() + 0.25f; + float ySpd = aDir.offsetY * 0.1f + 0.2f + 0.1f * GT_MetaTileEntity_Hatch_AirIntake_Extreme.floatGen.nextFloat(); + float xSpd; + float zSpd; + if (aDir.offsetY == -1) { + //Logger.INFO("Y = -1"); + final float temp = GT_MetaTileEntity_Hatch_AirIntake_Extreme.floatGen.nextFloat() * 2.0f * CORE.PI; + xSpd = (float) Math.sin(temp) * 0.1f; + zSpd = (float) Math.cos(temp) * 0.1f; + ySpd = -ySpd; + yPos = yPos - 0.8f; + } + else { + xSpd = aDir.offsetX * (0.1f + 0.2f * GT_MetaTileEntity_Hatch_AirIntake_Extreme.floatGen.nextFloat()); + zSpd = aDir.offsetZ * (0.1f + 0.2f * GT_MetaTileEntity_Hatch_AirIntake_Extreme.floatGen.nextFloat()); + + xSpd = -xSpd; + zSpd = -zSpd; + } + + aWorld.spawnParticle(name, (double) (xPos + ran1 * 0.5f), + (double) (yPos + GT_MetaTileEntity_Hatch_AirIntake_Extreme.floatGen.nextFloat() * 0.5f), + (double) (zPos + GT_MetaTileEntity_Hatch_AirIntake_Extreme.floatGen.nextFloat() * 0.5f), (double) xSpd, + (double) -ySpd, (double) zSpd); + aWorld.spawnParticle(name, (double) (xPos + ran2 * 0.5f), + (double) (yPos + GT_MetaTileEntity_Hatch_AirIntake_Extreme.floatGen.nextFloat() * 0.5f), + (double) (zPos + GT_MetaTileEntity_Hatch_AirIntake_Extreme.floatGen.nextFloat() * 0.5f), (double) xSpd, + (double) -ySpd, (double) zSpd); + aWorld.spawnParticle(name, (double) (xPos + ran3 * 0.5f), + (double) (yPos + GT_MetaTileEntity_Hatch_AirIntake_Extreme.floatGen.nextFloat() * 0.5f), + (double) (zPos + GT_MetaTileEntity_Hatch_AirIntake_Extreme.floatGen.nextFloat() * 0.5f), (double) xSpd, + (double) -ySpd, (double) zSpd); + } + +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_FluidGenerator.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_FluidGenerator.java new file mode 100644 index 0000000000..7579c8ec5a --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_FluidGenerator.java @@ -0,0 +1,254 @@ +package gtPlusPlus.xmod.gregtech.api.metatileentity.implementations; + +import java.lang.reflect.Field; + +import gregtech.api.enums.Textures; +import gregtech.api.interfaces.IIconContainer; +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.objects.GT_RenderedTexture; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.api.objects.random.XSTR; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.minecraft.FluidUtils; +import gtPlusPlus.core.util.reflect.ReflectionUtils; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.world.World; +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidStack; + +public abstract class GT_MetaTileEntity_Hatch_FluidGenerator extends GT_MetaTileEntity_Hatch_Input { + + protected static XSTR floatGen = new XSTR(); + public int mProgresstime = 0, mMaxProgresstime = 0; + + public GT_MetaTileEntity_Hatch_FluidGenerator(final int aID, final String aName, final String aNameRegional, final int aTier) { + super(aID, aName, aNameRegional, aTier); + } + + public GT_MetaTileEntity_Hatch_FluidGenerator(final String aName, final int aTier, final String aDescription, final ITexture[][][] aTextures) { + super(aName, aTier, aDescription, aTextures); + } + + private static String[] S; + private static Field F; + + public abstract String[] getCustomTooltip(); + + public abstract Fluid getFluidToGenerate(); + + public abstract int getAmountOfFluidToGenerate(); + + public abstract int getMaxTickTime(); + + public synchronized String[] getDescription() { + try { + if (F == null || S == null) { + Field t = ReflectionUtils.getField(this.getClass(), "mDescriptionArray"); + if (t != null) { + F = t; + } + else { + F = ReflectionUtils.getField(this.getClass(), "mDescription"); + } + if (S == null && F != null) { + Object o = F.get(this); + if (o instanceof String[]) { + S = (String[]) o; + } + else if (o instanceof String) { + S = new String[] {(String) o}; + } + } + + } + } + catch (Throwable t) { + Logger.INFO("1"); + t.printStackTrace(); + } + try { + if (S != null) { + String[] aCustomTips = getCustomTooltip(); + final String[] desc = new String[S.length + aCustomTips.length + 1]; + System.arraycopy(S, 0, desc, 0, S.length); + for (int i=0;i= mMaxProgresstime) { + addFluidToHatch(aTick); + mProgresstime = 0; + } + } + } + + @Override + public int getProgresstime() { + return mProgresstime; + } + + @Override + public int maxProgresstime() { + return mMaxProgresstime; + } + + @Override + public int increaseProgress(int aProgress) { + mProgresstime += aProgress; + return mMaxProgresstime - mProgresstime; + } + + public abstract void generateParticles(final World aWorld, final String name); + + public int getTankPressure() { + return 100; + } + + public abstract int getCapacity(); + + @Override + public boolean canTankBeEmptied() { + return true; + } + + public boolean isAirInHatch() { + if (this.mFluid != null) { + if (getFluidToGenerate() == this.mFluid.getFluid()) { + return true; + } + } + return false; + } + + public abstract boolean doesHatchMeetConditionsToGenerate(); + + public boolean addFluidToHatch(long aTick) { + if (!doesHatchMeetConditionsToGenerate()) { + return false; + } + boolean didFill = this.fill(FluidUtils.getFluidStack(getFluidToGenerate(), getAmountOfFluidToGenerate()), true) > 0; + if (didFill) { + this.generateParticles(this.getBaseMetaTileEntity().getWorld(), "cloud"); + } + return didFill; + } + + @Override + public boolean canTankBeFilled() { + if (this.mFluid == null || (this.mFluid != null && (this.mFluid.amount <= this.getCapacity()))) { + return true; + } + return false; + } + + @Override + public boolean doesEmptyContainers() { + return false; + } + + @Override + public boolean doesFillContainers() { + return true; + } + + @Override + public int fill(FluidStack aFluid, boolean doFill) { + return super.fill(aFluid, doFill); + } + + @Override + public boolean canFill(ForgeDirection aSide, Fluid aFluid) { + return false; + } + + @Override + public int fill(ForgeDirection arg0, FluidStack arg1, boolean arg2) { + return 0; + } + + @Override + public int fill_default(ForgeDirection aSide, FluidStack aFluid, boolean doFill) { + return 0; + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + aNBT.setInteger("mProgresstime", mProgresstime); + aNBT.setInteger("mMaxProgresstime", mMaxProgresstime); + super.saveNBTData(aNBT); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + mProgresstime = aNBT.getInteger("mProgresstime"); + mMaxProgresstime = aNBT.getInteger("mMaxProgresstime"); + super.loadNBTData(aNBT); + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Reservoir.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Reservoir.java new file mode 100644 index 0000000000..5cd57e9e92 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Reservoir.java @@ -0,0 +1,81 @@ +package gtPlusPlus.xmod.gregtech.api.metatileentity.implementations; + +import gregtech.api.enums.Textures; +import gregtech.api.interfaces.IIconContainer; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.api.objects.GT_RenderedTexture; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; +import net.minecraft.block.Block; +import net.minecraft.init.Blocks; +import net.minecraft.world.World; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidRegistry; + +public class GT_MetaTileEntity_Hatch_Reservoir extends GT_MetaTileEntity_Hatch_FluidGenerator { + + public GT_MetaTileEntity_Hatch_Reservoir(final int aID, final String aName, final String aNameRegional, final int aTier) { + super(aID, aName, aNameRegional, aTier); + } + + public GT_MetaTileEntity_Hatch_Reservoir(final String aName, final int aTier, final String aDescription, final ITexture[][][] aTextures) { + super(aName, aTier, aDescription, aTextures); + } + + + public MetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + return new GT_MetaTileEntity_Hatch_Reservoir(this.mName, this.mTier, this.mDescription, this.mTextures); + } + + @Override + public String[] getCustomTooltip() { + String[] aTooltip = new String[3]; + aTooltip[0] = "Requires a Block of water facing the intake"; + aTooltip[1] = "Infinite water supply hatch"; + aTooltip[2] = "Creates 2000L of Water every 4 ticks"; + return aTooltip; + } + + @Override + public Fluid getFluidToGenerate() { + return FluidRegistry.WATER; + } + + @Override + public int getAmountOfFluidToGenerate() { + return 2000; + } + + @Override + public int getMaxTickTime() { + return 4; + } + + @Override + public int getCapacity() { + return 128000; + } + + @Override + public boolean doesHatchMeetConditionsToGenerate() { + Block aWater = this.getBaseMetaTileEntity().getBlockAtSide(this.getBaseMetaTileEntity().getFrontFacing()); + return aWater == Blocks.water || aWater == Blocks.flowing_water; + } + + @Override + public void generateParticles(World aWorld, String name) { + + } + + public ITexture[] getTexturesActive(final ITexture aBaseTexture) { + return new ITexture[]{aBaseTexture, + new GT_RenderedTexture(TexturesGtBlock.Overlay_Water)}; + } + + public ITexture[] getTexturesInactive(final ITexture aBaseTexture) { + return new ITexture[]{aBaseTexture, + new GT_RenderedTexture(TexturesGtBlock.Overlay_Water)}; + } + +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/textures/TexturesGtBlock.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/textures/TexturesGtBlock.java index 518ffe0eae..8b372dff0c 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/textures/TexturesGtBlock.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/textures/TexturesGtBlock.java @@ -445,6 +445,8 @@ public class TexturesGtBlock { private static final CustomIcon Internal_Overlay_Oil = new CustomIcon("TileEntities/adv_machine_oil"); public static final CustomIcon Overlay_Oil = Internal_Overlay_Oil; + private static final CustomIcon Internal_Overlay_Water = new CustomIcon("TileEntities/adv_machine_water"); + public static final CustomIcon Overlay_Water = Internal_Overlay_Water; private static final CustomIcon Internal_Overlay_UU_Matter = new CustomIcon("TileEntities/adv_machine_uum"); public static final CustomIcon Overlay_UU_Matter = Internal_Overlay_UU_Matter; diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechCustomHatches.java b/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechCustomHatches.java index 64e77393bd..b93933d088 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechCustomHatches.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechCustomHatches.java @@ -68,7 +68,12 @@ public class GregtechCustomHatches { // Multiblock Air Intake Hatch GregtechItemList.Hatch_Air_Intake.set(new GT_MetaTileEntity_Hatch_AirIntake(861, "hatch.air.intake.tier.00", "Air Intake Hatch", 5).getStackForm(1L)); + GregtechItemList.Hatch_Air_Intake_Extreme.set(new GT_MetaTileEntity_Hatch_AirIntake_Extreme(31070, "hatch.air.intake.tier.01", "Extreme Air Intake Hatch", 6).getStackForm(1L)); + // Multiblock Reservoir Hatch + GregtechItemList.Hatch_Reservoir.set(new GT_MetaTileEntity_Hatch_Reservoir(31071, "hatch.water.intake.tier.00", "Reservoir Hatch", 6).getStackForm(1L)); + + // Steam Hatch GregtechItemList.Hatch_Input_Steam .set(new GT_MetaTileEntity_Hatch_CustomFluidBase(FluidUtils.getSteam(1).getFluid(), // Fluid diff --git a/src/main/resources/assets/miscutils/textures/blocks/TileEntities/adv_machine_water.png b/src/main/resources/assets/miscutils/textures/blocks/TileEntities/adv_machine_water.png new file mode 100644 index 0000000000..3351f5d0a6 Binary files /dev/null and b/src/main/resources/assets/miscutils/textures/blocks/TileEntities/adv_machine_water.png differ -- cgit From 615dd5ae99d6703efef551fd34e2092b1b8a4496 Mon Sep 17 00:00:00 2001 From: Alkalus <3060479+draknyte1@users.noreply.github.com> Date: Sun, 19 Dec 2021 17:50:38 +0000 Subject: Change composition of Ancient Granite & Lepersonnite to make obtaining Ytterbium possible. Fix Recipe for Wood's Glass lens. --- src/main/java/gtPlusPlus/core/item/ModItems.java | 8 ++++- .../core/item/base/cell/BaseItemCell.java | 6 +++- .../java/gtPlusPlus/core/material/ELEMENT.java | 15 +++++----- .../gtPlusPlus/core/material/MISC_MATERIALS.java | 20 +++++++++++++ src/main/java/gtPlusPlus/core/material/ORES.java | 3 +- .../gtPlusPlus/core/recipe/RECIPES_GREGTECH.java | 34 +++++++--------------- .../core/recipe/RECIPES_RareEarthProcessing.java | 20 +++++++++++-- .../interfaces/internal/IGregtech_RecipeAdder.java | 4 +-- .../xmod/gregtech/recipes/GregtechRecipeAdder.java | 32 +++++--------------- .../resources/assets/miscutils/lang/en_US.lang | 1 + 10 files changed, 81 insertions(+), 62 deletions(-) (limited to 'src/main/java/gtPlusPlus/xmod/gregtech') diff --git a/src/main/java/gtPlusPlus/core/item/ModItems.java b/src/main/java/gtPlusPlus/core/item/ModItems.java index 47278c559d..fca4c5d3c6 100644 --- a/src/main/java/gtPlusPlus/core/item/ModItems.java +++ b/src/main/java/gtPlusPlus/core/item/ModItems.java @@ -14,6 +14,7 @@ import gtPlusPlus.core.common.compat.COMPAT_Baubles; import gtPlusPlus.core.creative.AddToCreativeTab; import gtPlusPlus.core.item.base.*; import gtPlusPlus.core.item.base.BaseItemComponent.ComponentTypes; +import gtPlusPlus.core.item.base.cell.BaseItemCell; import gtPlusPlus.core.item.base.dusts.BaseItemDust; import gtPlusPlus.core.item.base.foil.BaseItemFoil; import gtPlusPlus.core.item.base.foods.BaseItemFood; @@ -203,6 +204,8 @@ public final class ModItems { public static Item dustIgnis; public static Item dustTerra; public static Item dustAqua; + + public static Item cellHydrogenChlorideMix; public static BaseEuItem metaItem2; @@ -712,7 +715,10 @@ public final class ModItems { dustAer = ItemUtils.generateSpecialUseDusts(ELEMENT.getInstance().AER, true)[0]; dustIgnis = ItemUtils.generateSpecialUseDusts(ELEMENT.getInstance().IGNIS, true)[0]; dustTerra = ItemUtils.generateSpecialUseDusts(ELEMENT.getInstance().TERRA, true)[0]; - dustAqua = ItemUtils.generateSpecialUseDusts(ELEMENT.getInstance().AQUA, true)[0]; + dustAqua = ItemUtils.generateSpecialUseDusts(ELEMENT.getInstance().AQUA, true)[0]; + + ItemUtils.generateSpecialUseDusts(MISC_MATERIALS.WOODS_GLASS, false); + cellHydrogenChlorideMix = new BaseItemCell("hydrogenchloridemix", "Hydrogen Chloride Mix", MISC_MATERIALS.HYDROGEN_CHLORIDE.getRGB()); //Nuclear Fuel Dusts dustLithiumCarbonate = ItemUtils.generateSpecialUseDusts("LithiumCarbonate", "Lithium Carbonate", "Li2CO3", Utils.rgbtoHexValue(240, 240, 240))[0]; //https://en.wikipedia.org/wiki/Lithium_carbonate diff --git a/src/main/java/gtPlusPlus/core/item/base/cell/BaseItemCell.java b/src/main/java/gtPlusPlus/core/item/base/cell/BaseItemCell.java index 688483b831..ad47adcf64 100644 --- a/src/main/java/gtPlusPlus/core/item/base/cell/BaseItemCell.java +++ b/src/main/java/gtPlusPlus/core/item/base/cell/BaseItemCell.java @@ -12,6 +12,7 @@ import gtPlusPlus.core.util.minecraft.ItemUtils; import ic2.core.Ic2Items; import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidContainerRegistry; +import net.minecraftforge.fluids.FluidStack; public class BaseItemCell extends BaseItemComponent{ @@ -26,7 +27,10 @@ public class BaseItemCell extends BaseItemComponent{ public BaseItemCell(final String unlocalName, final String localName, final short[] RGBa) { super(unlocalName, localName, RGBa); this.fluidColour = RGBa; - FluidContainerRegistry.registerFluidContainer(FluidUtils.getFluidStack(unlocalName.toLowerCase(), 0), ItemUtils.getSimpleStack(this), Ic2Items.cell.copy()); + FluidStack aFluid = FluidUtils.getFluidStack(unlocalName.toLowerCase(), 1000); + if (aFluid != null) { + FluidContainerRegistry.registerFluidContainer(aFluid, ItemUtils.getSimpleStack(this), Ic2Items.cell.copy()); + } } public BaseItemCell(final String unlocalName, final String localName, final short[] RGBa, final Fluid cellFluid) { diff --git a/src/main/java/gtPlusPlus/core/material/ELEMENT.java b/src/main/java/gtPlusPlus/core/material/ELEMENT.java index 54af01ef6e..01d3fd5330 100644 --- a/src/main/java/gtPlusPlus/core/material/ELEMENT.java +++ b/src/main/java/gtPlusPlus/core/material/ELEMENT.java @@ -236,13 +236,14 @@ public final class ELEMENT { 0, false, new MaterialStack[]{ - new MaterialStack(getInstance().OXYGEN, 30), - new MaterialStack(getInstance().IRON, 20), - new MaterialStack(getInstance().SILICONDIOXIDE, 20), - new MaterialStack(getInstance().ALUMINIUMOXIDE, 10), - new MaterialStack(getInstance().POTASSIUM, 10), - new MaterialStack(getInstance().CALCIUM, 5), - new MaterialStack(getInstance().SODIUM, 5) + new MaterialStack(getInstance().OXYGEN, 16), + new MaterialStack(getInstance().IRON, 10), + new MaterialStack(getInstance().SILICONDIOXIDE, 10), + new MaterialStack(getInstance().ALUMINIUMOXIDE, 6), + new MaterialStack(getInstance().POTASSIUM, 6), + new MaterialStack(getInstance().CALCIUM, 4), + new MaterialStack(getInstance().SODIUM, 4), + new MaterialStack(getInstance().YTTERBIUM, 2) });//Not a GT Inherited Material public static final Material RUNITE = new Material("Runite", MaterialState.SOLID, TextureSet.SET_FINE, new short[] {60, 200, 190}, 6750, 11550, 73, 87, true, "ยง", 0);//Not a GT Inherited Material diff --git a/src/main/java/gtPlusPlus/core/material/MISC_MATERIALS.java b/src/main/java/gtPlusPlus/core/material/MISC_MATERIALS.java index 19e8499f02..2740f49d71 100644 --- a/src/main/java/gtPlusPlus/core/material/MISC_MATERIALS.java +++ b/src/main/java/gtPlusPlus/core/material/MISC_MATERIALS.java @@ -114,6 +114,26 @@ public final class MISC_MATERIALS { new MaterialStack(ELEMENT.getInstance().CARBON, 1), new MaterialStack(ELEMENT.getInstance().OXYGEN, 2) }); + + public static final Material WOODS_GLASS = new Material( + "Wood's Glass", //Material Name + MaterialState.SOLID, //State + TextureSets.GEM_A.get(), //Texture Set + new short[] {220, 60, 255}, //Material Colour + -1, + -1, + -1, + -1, + false, + "Si4Ba3Na2Ni", + 0, + false, + new MaterialStack[]{ + new MaterialStack(ELEMENT.getInstance().SILICON, 40), + new MaterialStack(ELEMENT.getInstance().BARIUM, 30), + new MaterialStack(ELEMENT.getInstance().SODIUM, 20), + new MaterialStack(ELEMENT.getInstance().NICKEL, 10), + }); /* diff --git a/src/main/java/gtPlusPlus/core/material/ORES.java b/src/main/java/gtPlusPlus/core/material/ORES.java index 0186c23a07..82757b2ee6 100644 --- a/src/main/java/gtPlusPlus/core/material/ORES.java +++ b/src/main/java/gtPlusPlus/core/material/ORES.java @@ -486,10 +486,11 @@ public final class ORES { -1, //Radiation new MaterialStack[]{ new MaterialStack(ELEMENT.getInstance().CALCIUM, 1), + new MaterialStack(ELEMENT.getInstance().YTTERBIUM, 3), new MaterialStack(ELEMENT.getInstance().GADOLINIUM, 2), new MaterialStack(ELEMENT.getInstance().DYSPROSIUM, 2), new MaterialStack(ELEMENT.getInstance().URANIUM235, 2), - new MaterialStack(ELEMENT.getInstance().OXYGEN,32), + new MaterialStack(ELEMENT.getInstance().OXYGEN,29), new MaterialStack(ELEMENT.getInstance().HYDROGEN, 24) }); diff --git a/src/main/java/gtPlusPlus/core/recipe/RECIPES_GREGTECH.java b/src/main/java/gtPlusPlus/core/recipe/RECIPES_GREGTECH.java index 3d0e6aebfd..f8c923fc7a 100644 --- a/src/main/java/gtPlusPlus/core/recipe/RECIPES_GREGTECH.java +++ b/src/main/java/gtPlusPlus/core/recipe/RECIPES_GREGTECH.java @@ -93,6 +93,7 @@ public class RECIPES_GREGTECH { fluidheaterRecipes(); chemplantRecipes(); packagerRecipes(); + alloySmelterRecipes(); /** @@ -109,7 +110,17 @@ public class RECIPES_GREGTECH { addFuels(); } + private static void alloySmelterRecipes() { + + //Wood's Glass Laser Lens + GT_Values.RA.addAlloySmelterRecipe( + MISC_MATERIALS.WOODS_GLASS.getDust(5), + ItemList.Shape_Mold_Ball.get(0), + GregtechItemList.Laser_Lens_WoodsGlass.get(1), + 20 * 300, + MaterialUtils.getVoltageForTier(3)); + } private static void packagerRecipes() { @@ -1122,29 +1133,6 @@ public class RECIPES_GREGTECH { 20 * 120, 480*4); - - //Wood's Glass Laser Lens - CORE.RA.addBlastSmelterRecipe( - new ItemStack[] { - ItemUtils.getGregtechCircuit(5), - ItemList.Shape_Mold_Ball.get(0), - ELEMENT.getInstance().BARIUM.getDust(1), - ELEMENT.getInstance().SODIUM.getDust(1), - ELEMENT.getInstance().SILICON.getDust(2), - ELEMENT.getInstance().NICKEL.getDust(1), - ItemUtils.getItemStackOfAmountFromOreDict("dustGlass", 5) - }, - FluidUtils.getUUM(1000), - null, - new ItemStack[] { - GregtechItemList.Laser_Lens_WoodsGlass.get(1) - }, - new int[] {10000}, - 20 * 300, - (int) GT_Values.V[3]); - - - } private static void fluidcannerRecipes() { diff --git a/src/main/java/gtPlusPlus/core/recipe/RECIPES_RareEarthProcessing.java b/src/main/java/gtPlusPlus/core/recipe/RECIPES_RareEarthProcessing.java index 864d0bcca8..860a87deae 100644 --- a/src/main/java/gtPlusPlus/core/recipe/RECIPES_RareEarthProcessing.java +++ b/src/main/java/gtPlusPlus/core/recipe/RECIPES_RareEarthProcessing.java @@ -13,6 +13,7 @@ import gregtech.api.enums.GT_Values; import gregtech.api.enums.Materials; import gregtech.api.enums.OrePrefixes; import gregtech.api.util.GT_OreDictUnificator; +import gtPlusPlus.core.item.ModItems; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.material.ELEMENT; import gtPlusPlus.core.material.MISC_MATERIALS; @@ -118,12 +119,25 @@ public class RECIPES_RareEarthProcessing { null, new int[] {10000, 10000, 10000}, 20 * 30, - (int) GT_Values.V[2]); + 120); // Generate Special Laser Recipe + CORE.RA.addMixerRecipe( + CI.getNumberedBioCircuit(2), + ItemUtils.getItemStackOfAmountFromOreDict("cellChlorine", 1), + ItemUtils.getItemStackOfAmountFromOreDict("cellHydrogen", 1), + null, + null, + null, + ItemUtils.getSimpleStack(ModItems.cellHydrogenChlorideMix, 2), + null, + null, + null, + 20 * 10, + 480); + CORE.RA.addUvLaserRecipe( - ELEMENT.getInstance().CHLORINE.getCell(2), - ELEMENT.getInstance().HYDROGEN.getCell(2), + ItemUtils.getSimpleStack(ModItems.cellHydrogenChlorideMix, 4), ItemUtils.getItemStackOfAmountFromOreDict("cellHydrogenChloride", 4), 20 * 30, 480); diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/interfaces/internal/IGregtech_RecipeAdder.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/interfaces/internal/IGregtech_RecipeAdder.java index 6bf048320f..dfc1e58975 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/interfaces/internal/IGregtech_RecipeAdder.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/interfaces/internal/IGregtech_RecipeAdder.java @@ -306,8 +306,8 @@ public interface IGregtech_RecipeAdder { public boolean addVacuumFurnaceRecipe(ItemStack[] aInputs, FluidStack[] aFluidInputs, ItemStack[] aOutputs, FluidStack[] aFluidOutputs, int aDuration, int aEUt, int aLevel); - public boolean addUvLaserRecipe(ItemStack aInput1, ItemStack aInput2, ItemStack aOutput, int time, long eu); - public boolean addIrLaserRecipe(ItemStack aInput1, ItemStack aInput2, ItemStack aOutput, int time, long eu); + public boolean addUvLaserRecipe(ItemStack aInput1, ItemStack aOutput, int time, long eu); + public boolean addIrLaserRecipe(ItemStack aInput1, ItemStack aOutput, int time, long eu); public boolean addChemicalPlantRecipe(ItemStack[] aInputs, FluidStack[] aInputFluids, ItemStack[] aOutputs, FluidStack[] aFluidOutputs, int time, long eu, int aTier); public boolean addChemicalPlantRecipe(ItemStack[] aInputs, FluidStack[] aInputFluids, ItemStack[] aOutputs, FluidStack[] aFluidOutputs, int[] aChances, int time, long eu, int aTier); diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/recipes/GregtechRecipeAdder.java b/src/main/java/gtPlusPlus/xmod/gregtech/recipes/GregtechRecipeAdder.java index be4d6a8f7d..2b324fc172 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/recipes/GregtechRecipeAdder.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/recipes/GregtechRecipeAdder.java @@ -658,14 +658,6 @@ public class GregtechRecipeAdder implements IGregtech_RecipeAdder { if (((aInput1 == null) && (aFluidInput == null)) || ((aOutput1 == null) && (aFluidOutput == null))) { return false; } - if ((aOutput1 != null) - && ((aDuration = GregTech_API.sRecipeFile.get("advancedmixer", aOutput1, aDuration)) <= 0)) { - return false; - } - if ((aFluidOutput != null) && ((aDuration = GregTech_API.sRecipeFile.get("advancedmixer", - aFluidOutput.getFluid().getName(), aDuration)) <= 0)) { - return false; - } GTPP_Recipe aSpecialRecipe = new GTPP_Recipe( true, new ItemStack[] { aInput1, aInput2, aInput3, aInput4 }, @@ -678,17 +670,9 @@ public class GregtechRecipeAdder implements IGregtech_RecipeAdder { Math.max(1, aEUt), 0); - int aSize = GTPP_Recipe.GTPP_Recipe_Map.sAdvancedMixerRecipes.mRecipeList.size(); - int aSize2 = aSize; - GTPP_Recipe.GTPP_Recipe_Map.sAdvancedMixerRecipes.add(aSpecialRecipe); - aSize = GTPP_Recipe.GTPP_Recipe_Map.sAdvancedMixerRecipes.mRecipeList.size(); - - /*GTPP_Recipe.GTPP_Recipe_Map.sAdvancedMixerRecipes.addRecipe(true, - new ItemStack[] { aInput1, aInput2, aInput3, aInput4 }, - new ItemStack[] { aOutput1, aOutput2, aOutput3, aOutput4 }, null, null, - new FluidStack[] { aFluidInput }, new FluidStack[] { aFluidOutput }, aDuration, aEUt, 0);*/ - - return aSize > aSize2; + int aSize = GT_Recipe_Map.sMixerRecipes.mRecipeList.size(); + GT_Recipe_Map.sMixerRecipes.add(aSpecialRecipe); + return GT_Recipe_Map.sMixerRecipes.mRecipeList.size() > aSize; } // Machine Component Assembler @@ -1445,18 +1429,18 @@ public class GregtechRecipeAdder implements IGregtech_RecipeAdder { } @Override - public boolean addUvLaserRecipe(ItemStack aInput1, ItemStack aInput2, ItemStack aOutput, int time, long eu) { + public boolean addUvLaserRecipe(ItemStack aInput1, ItemStack aOutput, int time, long eu) { // Generate Special Laser Recipe GT_Recipe u = new GTPP_Recipe( false, new ItemStack[] { aInput1, - aInput2, + GregtechItemList.Laser_Lens_WoodsGlass.get(1), }, new ItemStack[] { aOutput }, - GregtechItemList.Laser_Lens_WoodsGlass.get(1), + null, new int[] { 10000 }, @@ -1469,8 +1453,8 @@ public class GregtechRecipeAdder implements IGregtech_RecipeAdder { } @Override - public boolean addIrLaserRecipe(ItemStack aInput1, ItemStack aInput2, ItemStack aOutput, int time, long eu) { - return addUvLaserRecipe(aInput1, aInput2, aOutput, time, eu); + public boolean addIrLaserRecipe(ItemStack aInput1, ItemStack aOutput, int time, long eu) { + return addUvLaserRecipe(aInput1, aOutput, time, eu); } diff --git a/src/main/resources/assets/miscutils/lang/en_US.lang b/src/main/resources/assets/miscutils/lang/en_US.lang index 7a021cbc26..4d3555188f 100644 --- a/src/main/resources/assets/miscutils/lang/en_US.lang +++ b/src/main/resources/assets/miscutils/lang/en_US.lang @@ -3365,3 +3365,4 @@ item.itemGearPraseodymium.name=Praseodymium Gear item.itemCellPraseodymium.name=Praseodymium Cell item.milledMonazite.name=Milled Monazite item.FrothMonaziteflotation.name=Monazite Flotation Froth Cell +item.hydrogenchloridemix.name=Hydrogen Chlorine Mix -- cgit From 849ae606a186ff5c1b7e9411bd2ed3589dcb06b5 Mon Sep 17 00:00:00 2001 From: Alkalus <3060479+draknyte1@users.noreply.github.com> Date: Mon, 20 Dec 2021 18:00:48 +0000 Subject: Add RemoteIO and EnderIO support to Reservoir Hatch. Changed Extreme Airtake from 5k/4t to 8k/4t. Clean up some reflection. Cleaned up GT_MetaTileEntity_Hatch_FluidGenerator.java. --- src/main/java/gtPlusPlus/core/lib/LoadedMods.java | 6 +++ .../gtPlusPlus/core/recipe/RECIPES_Machines.java | 10 ++-- .../core/util/minecraft/HazmatUtils.java | 4 +- .../core/util/reflect/ReflectionUtils.java | 6 +-- .../preloader/asm/Preloader_FMLLoadingPlugin.java | 4 +- .../ClassTransformer_TT_ThaumicRestorer.java | 2 +- .../preloader/keyboard/BetterKeyboard.java | 6 +-- .../gtPlusPlus/xmod/bop/HANDLER_BiomesOPlenty.java | 26 +++++----- .../GT_MetaTileEntity_Hatch_AirIntake_Extreme.java | 4 +- .../GT_MetaTileEntity_Hatch_FluidGenerator.java | 26 +++++----- .../GT_MetaTileEntity_Hatch_Reservoir.java | 58 ++++++++++++++++++++-- 11 files changed, 104 insertions(+), 48 deletions(-) (limited to 'src/main/java/gtPlusPlus/xmod/gregtech') diff --git a/src/main/java/gtPlusPlus/core/lib/LoadedMods.java b/src/main/java/gtPlusPlus/core/lib/LoadedMods.java index 1eb8351d65..4f7a10be78 100644 --- a/src/main/java/gtPlusPlus/core/lib/LoadedMods.java +++ b/src/main/java/gtPlusPlus/core/lib/LoadedMods.java @@ -60,6 +60,7 @@ public class LoadedMods { public static boolean CropsPlusPlus = false; //Barts Crop Mod public static boolean Reliquary = false; public static boolean SpiceOfLife = false; + public static boolean RemoteIO = false; @@ -322,6 +323,11 @@ public class LoadedMods { Witchery = true; Logger.INFO("Components enabled for: Witchery"); totalMods++; + } + if (isModLoaded("RIO")){ + RemoteIO = true; + Logger.INFO("Components enabled for: RemoteIO"); + totalMods++; } Logger.INFO("Content found for "+totalMods+" mods"); diff --git a/src/main/java/gtPlusPlus/core/recipe/RECIPES_Machines.java b/src/main/java/gtPlusPlus/core/recipe/RECIPES_Machines.java index 985e783430..f708a99af0 100644 --- a/src/main/java/gtPlusPlus/core/recipe/RECIPES_Machines.java +++ b/src/main/java/gtPlusPlus/core/recipe/RECIPES_Machines.java @@ -2764,11 +2764,11 @@ public class RECIPES_Machines { return; } Class ModBlocksClass = ReflectionUtils.getClass("com.riciJak.Ztones.init.ModBlocks"); - Block agon = (Block) ReflectionUtils.getFieldValue( ReflectionUtils.getField(ModBlocksClass, "agonBlock")); - Block korp = (Block) ReflectionUtils.getFieldValue( ReflectionUtils.getField(ModBlocksClass, "korpBlock")); - Block jelt = (Block) ReflectionUtils.getFieldValue( ReflectionUtils.getField(ModBlocksClass, "jeltBlock")); - Block bitt = (Block) ReflectionUtils.getFieldValue( ReflectionUtils.getField(ModBlocksClass, "bittBlock")); - Block iszm = (Block) ReflectionUtils.getFieldValue( ReflectionUtils.getField(ModBlocksClass, "iszmBlock")); + Block agon = ReflectionUtils.getFieldValue( ReflectionUtils.getField(ModBlocksClass, "agonBlock")); + Block korp = ReflectionUtils.getFieldValue( ReflectionUtils.getField(ModBlocksClass, "korpBlock")); + Block jelt = ReflectionUtils.getFieldValue( ReflectionUtils.getField(ModBlocksClass, "jeltBlock")); + Block bitt = ReflectionUtils.getFieldValue( ReflectionUtils.getField(ModBlocksClass, "bittBlock")); + Block iszm = ReflectionUtils.getFieldValue( ReflectionUtils.getField(ModBlocksClass, "iszmBlock")); // "agon", "iszm", "korp", "jelt", "bitt" diff --git a/src/main/java/gtPlusPlus/core/util/minecraft/HazmatUtils.java b/src/main/java/gtPlusPlus/core/util/minecraft/HazmatUtils.java index b322036ef7..0e2fff3f35 100644 --- a/src/main/java/gtPlusPlus/core/util/minecraft/HazmatUtils.java +++ b/src/main/java/gtPlusPlus/core/util/minecraft/HazmatUtils.java @@ -254,7 +254,7 @@ public class HazmatUtils { aItemFields.add(ReflectionUtils.getField(aItemsGravisuite, "graviChestPlate")); AutoMap aGravisuite = new AutoMap(); for (Field aItemField : aItemFields) { - Item aItemObject = (Item) ReflectionUtils.getFieldValue(aItemField); + Item aItemObject = ReflectionUtils.getFieldValue(aItemField); if (aItemObject != null) { aGravisuite.add(ItemUtils.getSimpleStack(aItemObject)); } @@ -274,7 +274,7 @@ public class HazmatUtils { aItemFields.add(ReflectionUtils.getField(aItemsEMT, "ultimateSolarHelmet")); AutoMap aASP = new AutoMap(); for (Field aItemField : aItemFields) { - Item aItemObject = (Item) ReflectionUtils.getFieldValue(aItemField); + Item aItemObject = ReflectionUtils.getFieldValue(aItemField); if (aItemObject != null) { aASP.add(ItemUtils.getSimpleStack(aItemObject)); } diff --git a/src/main/java/gtPlusPlus/core/util/reflect/ReflectionUtils.java b/src/main/java/gtPlusPlus/core/util/reflect/ReflectionUtils.java index 1ef925f793..92804d72ec 100644 --- a/src/main/java/gtPlusPlus/core/util/reflect/ReflectionUtils.java +++ b/src/main/java/gtPlusPlus/core/util/reflect/ReflectionUtils.java @@ -1060,13 +1060,13 @@ public class ReflectionUtils { return false; } - public static Object getFieldValue(Field field) { + public static T getFieldValue(Field field) { return getFieldValue(field, null); } - public static Object getFieldValue(Field field, Object instance) { + public static T getFieldValue(Field field, Object instance) { try { - return field.get(instance); + return (T) field.get(instance); } catch (IllegalArgumentException | IllegalAccessException e) { } return null; diff --git a/src/main/java/gtPlusPlus/preloader/asm/Preloader_FMLLoadingPlugin.java b/src/main/java/gtPlusPlus/preloader/asm/Preloader_FMLLoadingPlugin.java index 22568e6de7..b52f4eb67e 100644 --- a/src/main/java/gtPlusPlus/preloader/asm/Preloader_FMLLoadingPlugin.java +++ b/src/main/java/gtPlusPlus/preloader/asm/Preloader_FMLLoadingPlugin.java @@ -76,8 +76,8 @@ public class Preloader_FMLLoadingPlugin implements IFMLLoadingPlugin { Preloader_Logger.INFO("Running on "+gtPlusPlus.preloader.CORE_Preloader.JAVA_VERSION+" | Development Environment: "+CORE_Preloader.DEV_ENVIRONMENT); Locale aDefaultLocale = Locale.getDefault(); NumberFormat aFormat = NumberFormat.getInstance(); - Locale aDisplayLocale = (Locale) ReflectionUtils.getFieldValue(ReflectionUtils.getField(Locale.class, "defaultDisplayLocale")); - Locale aFormatLocale = (Locale) ReflectionUtils.getFieldValue(ReflectionUtils.getField(Locale.class, "defaultFormatLocale")); + Locale aDisplayLocale = ReflectionUtils.getFieldValue(ReflectionUtils.getField(Locale.class, "defaultDisplayLocale")); + Locale aFormatLocale = ReflectionUtils.getFieldValue(ReflectionUtils.getField(Locale.class, "defaultFormatLocale")); Preloader_Logger.INFO("Locale: "+aDefaultLocale+" | Test: "+aFormat.format(1000000000)+" | Display: "+aDisplayLocale+" | Format: "+aFormatLocale); } diff --git a/src/main/java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_TT_ThaumicRestorer.java b/src/main/java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_TT_ThaumicRestorer.java index 05b8054ff8..86a22ce4b9 100644 --- a/src/main/java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_TT_ThaumicRestorer.java +++ b/src/main/java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_TT_ThaumicRestorer.java @@ -82,7 +82,7 @@ public class ClassTransformer_TT_ThaumicRestorer { mTookLastTick = ReflectionUtils.getField(mTileRepairerClass, "tookLastTick"); mDamageLastTick = ReflectionUtils.getField(mTileRepairerClass, "dmgLastTick"); mProxyTC = ReflectionUtils.getField(mThaumicTinkerer, "tcProxy"); - repairTConTools = (boolean) ReflectionUtils.getFieldValue(mRepairTiconTools); + repairTConTools = ReflectionUtils.getFieldValue(mRepairTiconTools); mInit = true; } if (mInit) { diff --git a/src/main/java/gtPlusPlus/preloader/keyboard/BetterKeyboard.java b/src/main/java/gtPlusPlus/preloader/keyboard/BetterKeyboard.java index e25c06653c..532d20f1b2 100644 --- a/src/main/java/gtPlusPlus/preloader/keyboard/BetterKeyboard.java +++ b/src/main/java/gtPlusPlus/preloader/keyboard/BetterKeyboard.java @@ -68,7 +68,7 @@ public class BetterKeyboard { Field aKeyNameSize = ReflectionUtils.getField(Keyboard.class, "keyName"); Field aKeyMapSize = ReflectionUtils.getField(Keyboard.class, "keyMap"); Field aKeyDownBuffer = ReflectionUtils.getField(Keyboard.class, "keyDownBuffer"); - String[] aOldKeyNameArray = (String[]) ReflectionUtils.getFieldValue(aKeyNameSize); + String[] aOldKeyNameArray = ReflectionUtils.getFieldValue(aKeyNameSize); if (aOldKeyNameArray != null && aOldKeyNameArray.length < Short.MAX_VALUE) { String[] aNewKeyNameArray = new String[Short.MAX_VALUE]; for (int i=0;i aOldKeyMapArray = (Map) ReflectionUtils.getFieldValue(aKeyMapSize); + Map aOldKeyMapArray = ReflectionUtils.getFieldValue(aKeyMapSize); if (aOldKeyNameArray != null && aOldKeyMapArray.size() < Short.MAX_VALUE) { Map aNewKeyMapArray = new HashMap(Short.MAX_VALUE); aNewKeyMapArray.putAll(aOldKeyMapArray); @@ -94,7 +94,7 @@ public class BetterKeyboard { FMLRelaunchLog.log("[GT++ ASM] LWJGL Keybinding index out of bounds fix", Level.INFO, "Failed Patching Field: "+aKeyDownBuffer.getName()); } } - ByteBuffer aOldByteBuffer = (ByteBuffer) ReflectionUtils.getFieldValue(aKeyDownBuffer); + ByteBuffer aOldByteBuffer = ReflectionUtils.getFieldValue(aKeyDownBuffer); if (aOldByteBuffer != null && aOldByteBuffer.capacity() == Keyboard.KEYBOARD_SIZE) { ByteBuffer aNewByteBuffer = BufferUtils.createByteBuffer(Short.MAX_VALUE); try { diff --git a/src/main/java/gtPlusPlus/xmod/bop/HANDLER_BiomesOPlenty.java b/src/main/java/gtPlusPlus/xmod/bop/HANDLER_BiomesOPlenty.java index 95067300c8..52f498988c 100644 --- a/src/main/java/gtPlusPlus/xmod/bop/HANDLER_BiomesOPlenty.java +++ b/src/main/java/gtPlusPlus/xmod/bop/HANDLER_BiomesOPlenty.java @@ -91,7 +91,7 @@ public class HANDLER_BiomesOPlenty { Field aBopColouredSapling = ReflectionUtils.getField(ReflectionUtils.getClass("biomesoplenty.api.content.BOPCBlocks"), "colorizedSaplings"); if (aBopMiscItem != null) { - Item aMiscItem = (Item) ReflectionUtils.getFieldValue(aBopMiscItem); + Item aMiscItem = ReflectionUtils.getFieldValue(aBopMiscItem); if (aMiscItem != null) { mPineCone = aMiscItem; } @@ -99,25 +99,25 @@ public class HANDLER_BiomesOPlenty { if (aBopBlock1 != null) { - Block aBlock = (Block) ReflectionUtils.getFieldValue(aBopBlock1); + Block aBlock = ReflectionUtils.getFieldValue(aBopBlock1); if (aBlock != null) { logs1 = aBlock; } } if (aBopBlock2 != null) { - Block aBlock = (Block) ReflectionUtils.getFieldValue(aBopBlock2); + Block aBlock = ReflectionUtils.getFieldValue(aBopBlock2); if (aBlock != null) { logs2 = aBlock; } } if (aBopBlock3 != null) { - Block aBlock = (Block) ReflectionUtils.getFieldValue(aBopBlock3); + Block aBlock = ReflectionUtils.getFieldValue(aBopBlock3); if (aBlock != null) { logs3 = aBlock; } } if (aBopBlock4 != null) { - Block aBlock = (Block) ReflectionUtils.getFieldValue(aBopBlock4); + Block aBlock = ReflectionUtils.getFieldValue(aBopBlock4); if (aBlock != null) { logs4 = aBlock; } @@ -125,25 +125,25 @@ public class HANDLER_BiomesOPlenty { if (aBopLeaves1 != null) { - Block aBlock = (Block) ReflectionUtils.getFieldValue(aBopLeaves1); + Block aBlock = ReflectionUtils.getFieldValue(aBopLeaves1); if (aBlock != null) { leaves1 = aBlock; } } if (aBopLeaves2 != null) { - Block aBlock = (Block) ReflectionUtils.getFieldValue(aBopLeaves2); + Block aBlock = ReflectionUtils.getFieldValue(aBopLeaves2); if (aBlock != null) { leaves2 = aBlock; } } if (aBopLeaves3 != null) { - Block aBlock = (Block) ReflectionUtils.getFieldValue(aBopLeaves3); + Block aBlock = ReflectionUtils.getFieldValue(aBopLeaves3); if (aBlock != null) { leaves3 = aBlock; } } if (aBopLeaves4 != null) { - Block aBlock = (Block) ReflectionUtils.getFieldValue(aBopLeaves4); + Block aBlock = ReflectionUtils.getFieldValue(aBopLeaves4); if (aBlock != null) { leaves4 = aBlock; } @@ -151,13 +151,13 @@ public class HANDLER_BiomesOPlenty { if (aBopColouredLeaves1 != null) { - Block aBlock = (Block) ReflectionUtils.getFieldValue(aBopColouredLeaves1); + Block aBlock = ReflectionUtils.getFieldValue(aBopColouredLeaves1); if (aBlock != null) { colorizedLeaves1 = aBlock; } } if (aBopColouredLeaves2 != null) { - Block aBlock = (Block) ReflectionUtils.getFieldValue(aBopColouredLeaves2); + Block aBlock = ReflectionUtils.getFieldValue(aBopColouredLeaves2); if (aBlock != null) { colorizedLeaves2 = aBlock; } @@ -165,13 +165,13 @@ public class HANDLER_BiomesOPlenty { if (aBopSapling != null) { - Block aBlock = (Block) ReflectionUtils.getFieldValue(aBopSapling); + Block aBlock = ReflectionUtils.getFieldValue(aBopSapling); if (aBlock != null) { saplings = aBlock; } } if (aBopColouredSapling != null) { - Block aBlock = (Block) ReflectionUtils.getFieldValue(aBopColouredSapling); + Block aBlock = ReflectionUtils.getFieldValue(aBopColouredSapling); if (aBlock != null) { colorizedSaplings = aBlock; } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_AirIntake_Extreme.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_AirIntake_Extreme.java index 5ebb2da8d4..d70afcb433 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_AirIntake_Extreme.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_AirIntake_Extreme.java @@ -29,7 +29,7 @@ public class GT_MetaTileEntity_Hatch_AirIntake_Extreme extends GT_MetaTileEntity String[] aTooltip = new String[3]; aTooltip[0] = "DO NOT OBSTRUCT THE INPUT!"; aTooltip[1] = "Draws in Air from the surrounding environment"; - aTooltip[2] = "Creates 5000L of Air every 4 ticks"; + aTooltip[2] = "Creates 8000L of Air every 4 ticks"; return aTooltip; } @@ -40,7 +40,7 @@ public class GT_MetaTileEntity_Hatch_AirIntake_Extreme extends GT_MetaTileEntity @Override public int getAmountOfFluidToGenerate() { - return 5000; + return 8000; } @Override diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_FluidGenerator.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_FluidGenerator.java index 7579c8ec5a..d4b8b3a064 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_FluidGenerator.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_FluidGenerator.java @@ -178,31 +178,29 @@ public abstract class GT_MetaTileEntity_Hatch_FluidGenerator extends GT_MetaTile return true; } - public boolean isAirInHatch() { - if (this.mFluid != null) { - if (getFluidToGenerate() == this.mFluid.getFluid()) { - return true; - } - } - return false; - } - public abstract boolean doesHatchMeetConditionsToGenerate(); public boolean addFluidToHatch(long aTick) { if (!doesHatchMeetConditionsToGenerate()) { return false; - } - boolean didFill = this.fill(FluidUtils.getFluidStack(getFluidToGenerate(), getAmountOfFluidToGenerate()), true) > 0; - if (didFill) { - this.generateParticles(this.getBaseMetaTileEntity().getWorld(), "cloud"); + } + boolean didFill = false; + if (canTankBeFilled()) { + didFill = this.fill(FluidUtils.getFluidStack(getFluidToGenerate(), getAmountOfFluidToGenerate()), true) > 0; + if (didFill) { + this.generateParticles(this.getBaseMetaTileEntity().getWorld(), "cloud"); + } } return didFill; } @Override public boolean canTankBeFilled() { - if (this.mFluid == null || (this.mFluid != null && (this.mFluid.amount <= this.getCapacity()))) { + //Logger.INFO("Total Space: "+this.getCapacity()); + //Logger.INFO("Current capacity: "+this.getFluidAmount()); + //Logger.INFO("To add: "+this.getAmountOfFluidToGenerate()); + //Logger.INFO("Space Free: "+(this.getCapacity()-this.getFluidAmount())); + if (this.mFluid == null || (this.mFluid != null && (this.getCapacity() - this.getFluidAmount() >= this.getAmountOfFluidToGenerate()))) { return true; } return false; diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Reservoir.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Reservoir.java index 5cd57e9e92..a2aa4d266c 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Reservoir.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Reservoir.java @@ -1,20 +1,32 @@ package gtPlusPlus.xmod.gregtech.api.metatileentity.implementations; -import gregtech.api.enums.Textures; -import gregtech.api.interfaces.IIconContainer; +import java.lang.reflect.Field; + import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.MetaTileEntity; import gregtech.api.objects.GT_RenderedTexture; +import gtPlusPlus.core.lib.LoadedMods; +import gtPlusPlus.core.util.reflect.ReflectionUtils; import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; import net.minecraft.block.Block; import net.minecraft.init.Blocks; +import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; +import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidRegistry; +import net.minecraftforge.fluids.IFluidHandler; public class GT_MetaTileEntity_Hatch_Reservoir extends GT_MetaTileEntity_Hatch_FluidGenerator { + private static Class sClass_EIO; + private static Class sClass_RIO; + private static Field sField_EIO; + private static Field sField_RIO; + private static Block sBlock_EIO; + private static Block sBlock_RIO; + public GT_MetaTileEntity_Hatch_Reservoir(final int aID, final String aName, final String aNameRegional, final int aTier) { super(aID, aName, aNameRegional, aTier); } @@ -56,11 +68,51 @@ public class GT_MetaTileEntity_Hatch_Reservoir extends GT_MetaTileEntity_Hatch_F public int getCapacity() { return 128000; } + + private static void setCrossModData() { + if (LoadedMods.EnderIO && sClass_EIO == null) { + sClass_EIO = ReflectionUtils.getClass("crazypants.enderio.EnderIO"); + sField_EIO = ReflectionUtils.getField(sClass_EIO, "blockReservoir"); + sBlock_EIO = ReflectionUtils.getFieldValue(sField_EIO, null); + } + if (LoadedMods.RemoteIO && sClass_RIO == null) { + sClass_RIO = ReflectionUtils.getClass("remoteio.common.lib.ModBlocks"); + sField_RIO = ReflectionUtils.getField(sClass_RIO, "machine"); + sBlock_RIO = ReflectionUtils.getFieldValue(sField_RIO, null); + } + } + + public static boolean isTileValid(TileEntity aTile) { + if (aTile != null) { + if (aTile instanceof IFluidHandler) { + IFluidHandler aFluidHandler = (IFluidHandler) aTile; + return aFluidHandler.canDrain(ForgeDirection.UNKNOWN, FluidRegistry.WATER); + } + } + return false; + } @Override public boolean doesHatchMeetConditionsToGenerate() { Block aWater = this.getBaseMetaTileEntity().getBlockAtSide(this.getBaseMetaTileEntity().getFrontFacing()); - return aWater == Blocks.water || aWater == Blocks.flowing_water; + if (aWater != null && aWater != Blocks.air) { + if (!this.canTankBeFilled()) { + return false; + } + setCrossModData(); + if (LoadedMods.EnderIO) { + if (aWater == sBlock_EIO) { + return isTileValid(this.getBaseMetaTileEntity().getTileEntityAtSide(this.getBaseMetaTileEntity().getFrontFacing())); + } + } + if (LoadedMods.RemoteIO) { + if (aWater == sBlock_RIO && this.getBaseMetaTileEntity().getMetaIDAtSide(this.getBaseMetaTileEntity().getFrontFacing()) == 0) { + return isTileValid(this.getBaseMetaTileEntity().getTileEntityAtSide(this.getBaseMetaTileEntity().getFrontFacing())); + } + } + return aWater == Blocks.water || aWater == Blocks.flowing_water; + } + return false; } @Override -- cgit From aadb1b8f7f0f909feb747c05548351fcfe271de5 Mon Sep 17 00:00:00 2001 From: Alkalus <3060479+draknyte1@users.noreply.github.com> Date: Mon, 20 Dec 2021 20:52:41 +0000 Subject: Refactored GT_MetaTileEntity_Hatch_AirIntake_Extreme to extend GT_MetaTileEntity_Hatch_AirIntake. Refactored GT_MetaTileEntity_Hatch_Reservoir. Refactored Chisel singles/multi to utilise a cache. --- .../GT_MetaTileEntity_Hatch_AirIntake.java | 2 +- .../GT_MetaTileEntity_Hatch_AirIntake_Extreme.java | 80 +--------------------- .../GT_MetaTileEntity_Hatch_Reservoir.java | 20 ++---- .../basic/GregtechMetaTileEntity_AutoChisel.java | 62 +++++++++++------ .../GregtechMetaTileEntity_IndustrialChisel.java | 57 +++++++++++---- 5 files changed, 93 insertions(+), 128 deletions(-) (limited to 'src/main/java/gtPlusPlus/xmod/gregtech') diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_AirIntake.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_AirIntake.java index 4716d8038a..02b7a03f3b 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_AirIntake.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_AirIntake.java @@ -29,7 +29,7 @@ public class GT_MetaTileEntity_Hatch_AirIntake extends GT_MetaTileEntity_Hatch_F String[] aTooltip = new String[3]; aTooltip[0] = "DO NOT OBSTRUCT THE INPUT!"; aTooltip[1] = "Draws in Air from the surrounding environment"; - aTooltip[2] = "Creates 1000L of Air every 4 ticks"; + aTooltip[2] = "Creates "+getAmountOfFluidToGenerate()+"L of Air every "+getMaxTickTime()+" ticks"; return aTooltip; } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_AirIntake_Extreme.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_AirIntake_Extreme.java index d70afcb433..45611d9e05 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_AirIntake_Extreme.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_AirIntake_Extreme.java @@ -3,13 +3,8 @@ package gtPlusPlus.xmod.gregtech.api.metatileentity.implementations; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.MetaTileEntity; -import gtPlusPlus.core.lib.CORE; -import gtPlusPlus.core.util.minecraft.FluidUtils; -import net.minecraft.world.World; -import net.minecraftforge.common.util.ForgeDirection; -import net.minecraftforge.fluids.Fluid; -public class GT_MetaTileEntity_Hatch_AirIntake_Extreme extends GT_MetaTileEntity_Hatch_FluidGenerator { +public class GT_MetaTileEntity_Hatch_AirIntake_Extreme extends GT_MetaTileEntity_Hatch_AirIntake { public GT_MetaTileEntity_Hatch_AirIntake_Extreme(final int aID, final String aName, final String aNameRegional, final int aTier) { super(aID, aName, aNameRegional, aTier); @@ -24,87 +19,14 @@ public class GT_MetaTileEntity_Hatch_AirIntake_Extreme extends GT_MetaTileEntity return new GT_MetaTileEntity_Hatch_AirIntake_Extreme(this.mName, this.mTier, this.mDescription, this.mTextures); } - @Override - public String[] getCustomTooltip() { - String[] aTooltip = new String[3]; - aTooltip[0] = "DO NOT OBSTRUCT THE INPUT!"; - aTooltip[1] = "Draws in Air from the surrounding environment"; - aTooltip[2] = "Creates 8000L of Air every 4 ticks"; - return aTooltip; - } - - @Override - public Fluid getFluidToGenerate() { - return FluidUtils.getAir(1).getFluid(); - } - @Override public int getAmountOfFluidToGenerate() { return 8000; } - @Override - public int getMaxTickTime() { - return 4; - } - @Override public int getCapacity() { return 256000; } - @Override - public boolean doesHatchMeetConditionsToGenerate() { - return this.getBaseMetaTileEntity().getAirAtSide(this.getBaseMetaTileEntity().getFrontFacing()); - } - - @Override - public void generateParticles(World aWorld, String name) { - if (this.getBaseMetaTileEntity().isServerSide()) { - return; - } - final float ran1 = GT_MetaTileEntity_Hatch_AirIntake_Extreme.floatGen.nextFloat(); - float ran2 = 0.0f; - float ran3 = 0.0f; - ran2 = GT_MetaTileEntity_Hatch_AirIntake_Extreme.floatGen.nextFloat(); - ran3 = GT_MetaTileEntity_Hatch_AirIntake_Extreme.floatGen.nextFloat(); - - final IGregTechTileEntity aMuffler = this.getBaseMetaTileEntity(); - final ForgeDirection aDir = ForgeDirection.getOrientation((int) aMuffler.getFrontFacing()); - final float xPos = aDir.offsetX * 0.76f + aMuffler.getXCoord() + 0.25f; - float yPos = aDir.offsetY * 0.76f + aMuffler.getYCoord() + 0.65f; - final float zPos = aDir.offsetZ * 0.76f + aMuffler.getZCoord() + 0.25f; - float ySpd = aDir.offsetY * 0.1f + 0.2f + 0.1f * GT_MetaTileEntity_Hatch_AirIntake_Extreme.floatGen.nextFloat(); - float xSpd; - float zSpd; - if (aDir.offsetY == -1) { - //Logger.INFO("Y = -1"); - final float temp = GT_MetaTileEntity_Hatch_AirIntake_Extreme.floatGen.nextFloat() * 2.0f * CORE.PI; - xSpd = (float) Math.sin(temp) * 0.1f; - zSpd = (float) Math.cos(temp) * 0.1f; - ySpd = -ySpd; - yPos = yPos - 0.8f; - } - else { - xSpd = aDir.offsetX * (0.1f + 0.2f * GT_MetaTileEntity_Hatch_AirIntake_Extreme.floatGen.nextFloat()); - zSpd = aDir.offsetZ * (0.1f + 0.2f * GT_MetaTileEntity_Hatch_AirIntake_Extreme.floatGen.nextFloat()); - - xSpd = -xSpd; - zSpd = -zSpd; - } - - aWorld.spawnParticle(name, (double) (xPos + ran1 * 0.5f), - (double) (yPos + GT_MetaTileEntity_Hatch_AirIntake_Extreme.floatGen.nextFloat() * 0.5f), - (double) (zPos + GT_MetaTileEntity_Hatch_AirIntake_Extreme.floatGen.nextFloat() * 0.5f), (double) xSpd, - (double) -ySpd, (double) zSpd); - aWorld.spawnParticle(name, (double) (xPos + ran2 * 0.5f), - (double) (yPos + GT_MetaTileEntity_Hatch_AirIntake_Extreme.floatGen.nextFloat() * 0.5f), - (double) (zPos + GT_MetaTileEntity_Hatch_AirIntake_Extreme.floatGen.nextFloat() * 0.5f), (double) xSpd, - (double) -ySpd, (double) zSpd); - aWorld.spawnParticle(name, (double) (xPos + ran3 * 0.5f), - (double) (yPos + GT_MetaTileEntity_Hatch_AirIntake_Extreme.floatGen.nextFloat() * 0.5f), - (double) (zPos + GT_MetaTileEntity_Hatch_AirIntake_Extreme.floatGen.nextFloat() * 0.5f), (double) xSpd, - (double) -ySpd, (double) zSpd); - } - } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Reservoir.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Reservoir.java index a2aa4d266c..716251ecf0 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Reservoir.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Reservoir.java @@ -1,13 +1,11 @@ package gtPlusPlus.xmod.gregtech.api.metatileentity.implementations; -import java.lang.reflect.Field; - +import cpw.mods.fml.common.registry.GameRegistry; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.MetaTileEntity; import gregtech.api.objects.GT_RenderedTexture; import gtPlusPlus.core.lib.LoadedMods; -import gtPlusPlus.core.util.reflect.ReflectionUtils; import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; import net.minecraft.block.Block; import net.minecraft.init.Blocks; @@ -20,10 +18,6 @@ import net.minecraftforge.fluids.IFluidHandler; public class GT_MetaTileEntity_Hatch_Reservoir extends GT_MetaTileEntity_Hatch_FluidGenerator { - private static Class sClass_EIO; - private static Class sClass_RIO; - private static Field sField_EIO; - private static Field sField_RIO; private static Block sBlock_EIO; private static Block sBlock_RIO; @@ -70,15 +64,11 @@ public class GT_MetaTileEntity_Hatch_Reservoir extends GT_MetaTileEntity_Hatch_F } private static void setCrossModData() { - if (LoadedMods.EnderIO && sClass_EIO == null) { - sClass_EIO = ReflectionUtils.getClass("crazypants.enderio.EnderIO"); - sField_EIO = ReflectionUtils.getField(sClass_EIO, "blockReservoir"); - sBlock_EIO = ReflectionUtils.getFieldValue(sField_EIO, null); + if (LoadedMods.EnderIO && sBlock_EIO == null) { + sBlock_EIO = GameRegistry.findBlock("EnderIO", "blockReservoir"); } - if (LoadedMods.RemoteIO && sClass_RIO == null) { - sClass_RIO = ReflectionUtils.getClass("remoteio.common.lib.ModBlocks"); - sField_RIO = ReflectionUtils.getField(sClass_RIO, "machine"); - sBlock_RIO = ReflectionUtils.getFieldValue(sField_RIO, null); + if (LoadedMods.RemoteIO && sBlock_RIO == null) { + sBlock_RIO = GameRegistry.findBlock("RIO", "machine"); } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaTileEntity_AutoChisel.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaTileEntity_AutoChisel.java index ea99f8d52a..3cdd43c24e 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaTileEntity_AutoChisel.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaTileEntity_AutoChisel.java @@ -9,13 +9,15 @@ import gregtech.api.metatileentity.MetaTileEntity; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_BasicMachine; import gregtech.api.objects.GT_RenderedTexture; import gregtech.api.util.GT_Recipe; -import gtPlusPlus.api.objects.Logger; import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; import net.minecraft.item.ItemStack; import team.chisel.carving.Carving; public class GregtechMetaTileEntity_AutoChisel extends GT_MetaTileEntity_BasicMachine { + private ItemStack mInputCache; + private ItemStack mOutputCache; + public GregtechMetaTileEntity_AutoChisel(int aID, String aName, String aNameRegional, int aTier) { super(aID, aName, aNameRegional, aTier, 1, "Chisels things, Gregtech style", 1, 1, "Compressor.png", "", new ITexture[]{ @@ -54,10 +56,30 @@ public class GregtechMetaTileEntity_AutoChisel extends GT_MetaTileEntity_BasicMa public GT_Recipe.GT_Recipe_Map getRecipeList() { return null; } + + private boolean hasValidCache(ItemStack mItem, boolean mClearOnFailure) { + if (mInputCache != null + && mOutputCache != null + && mInputCache.isItemEqual(mItem) + && ItemStack.areItemStackTagsEqual(mItem, mInputCache)) { + return true; + } + // clear cache if it was invalid + if (mClearOnFailure) { + mInputCache = null; + mOutputCache = null; + } + return false; + } + + private void cacheItem(ItemStack mInputItem, ItemStack mOutputItem) { + mOutputCache = mOutputItem.copy(); + mInputCache = mInputItem.copy(); + } @Override protected boolean allowPutStackValidated(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { - return super.allowPutStackValidated(aBaseMetaTileEntity, aIndex, aSide, aStack) && hasChiselResults(aStack); + return hasValidCache(aStack, false) ? true : super.allowPutStackValidated(aBaseMetaTileEntity, aIndex, aSide, aStack) && hasChiselResults(aStack); } // lets make sure the user isn't trying to make something from a block that doesn't have this as a valid target @@ -81,48 +103,46 @@ public class GregtechMetaTileEntity_AutoChisel extends GT_MetaTileEntity_BasicMa return Carving.chisel.getItemsForChiseling(aStack); } + private static ItemStack getChiselOutput(ItemStack aInput, ItemStack aTarget) { + ItemStack tOutput = null; + if (aTarget != null && canBeMadeFrom(aInput, aTarget)) { + tOutput = aTarget; + } + else { + tOutput = getItemsForChiseling(aInput).get(0); + } + return tOutput; + } + @Override public int checkRecipe() { ItemStack tOutput = null; ItemStack aInput = getInputAt(0); ItemStack aTarget = getSpecialSlot(); + boolean tIsCached = hasValidCache(aInput, true); if (aInput != null && hasChiselResults(aInput) && aInput.stackSize > 0) { - Logger.INFO("Has Valid Input."); - if (aTarget != null && canBeMadeFrom(aInput, aTarget)) { - tOutput = aTarget; - Logger.INFO("Has Valid Target."); - } - else { - tOutput = getItemsForChiseling(aInput).get(0); - Logger.INFO("Using target(0)"); - } + tOutput = tIsCached ? mOutputCache.copy() : getChiselOutput(aInput, aTarget); if (tOutput != null) { - Logger.INFO("Has Valid Output. "+tOutput.getDisplayName()); // We can chisel this if (canOutput(tOutput)) { - Logger.INFO("Can Output"); getInputAt(0).stackSize -= 1; - Logger.INFO("Consuming 1 input"); calculateOverclockedNess(16, 20); - Logger.INFO("Did Overclock"); //In case recipe is too OP for that machine if (mMaxProgresstime == Integer.MAX_VALUE - 1 && mEUt == Integer.MAX_VALUE - 1) { - Logger.INFO("Brrrrr"); return FOUND_RECIPE_BUT_DID_NOT_MEET_REQUIREMENTS; } - Logger.INFO("Setting Output"); - this.mOutputItems[0] = tOutput; - Logger.INFO("Recipe good."); + if (!tIsCached) { + cacheItem(aInput, tOutput); + } + this.mOutputItems[0] = tOutput.copy(); return FOUND_AND_SUCCESSFULLY_USED_RECIPE; } else { - Logger.INFO("Cannot Output"); mOutputBlocked++; return FOUND_RECIPE_BUT_DID_NOT_MEET_REQUIREMENTS; } } } - Logger.INFO("Recipe bad."); return DID_NOT_FIND_RECIPE; } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialChisel.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialChisel.java index 77cc19d5d4..290a36c052 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialChisel.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialChisel.java @@ -29,7 +29,6 @@ import gregtech.api.util.GTPP_Recipe; import gregtech.api.util.GT_Multiblock_Tooltip_Builder; import gregtech.api.util.GT_Recipe; import gregtech.api.util.GT_Utility; -import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.block.ModBlocks; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.util.minecraft.ItemUtils; @@ -44,6 +43,9 @@ public class GregtechMetaTileEntity_IndustrialChisel extends GregtechMeta_MultiB private int mCasing; private IStructureDefinition STRUCTURE_DEFINITION = null; + private ItemStack mInputCache; + private ItemStack mOutputCache; + private GTPP_Recipe mCachedRecipe; public GregtechMetaTileEntity_IndustrialChisel(int aID, String aName, String aNameRegional) { super(aID, aName, aNameRegional); @@ -173,6 +175,27 @@ public class GregtechMetaTileEntity_IndustrialChisel extends GregtechMeta_MultiB return true; } + private boolean hasValidCache(ItemStack aStack, ItemStack aSpecialSlot, boolean aClearOnFailure) { + if (mInputCache != null && mOutputCache != null && mCachedRecipe != null) { + if (GT_Utility.areStacksEqual(aStack, mInputCache) && GT_Utility.areStacksEqual(aSpecialSlot, mOutputCache)) { + return true; + } + } + // clear cache if it was invalid + if (aClearOnFailure) { + mInputCache = null; + mOutputCache = null; + mCachedRecipe = null; + } + return false; + } + + private void cacheItem(ItemStack aInputItem, ItemStack aOutputItem, GTPP_Recipe aRecipe) { + mInputCache = aInputItem.copy(); + mOutputCache = aOutputItem.copy(); + mCachedRecipe = aRecipe; + } + // lets make sure the user isn't trying to make something from a block that doesn't have this as a valid target private static boolean canBeMadeFrom(ItemStack from, ItemStack to) { List results = getItemsForChiseling(from); @@ -194,18 +217,26 @@ public class GregtechMetaTileEntity_IndustrialChisel extends GregtechMeta_MultiB return Carving.chisel.getItemsForChiseling(aStack); } + private static ItemStack getChiselOutput(ItemStack aInput, ItemStack aTarget) { + ItemStack tOutput = null; + if (aTarget != null && canBeMadeFrom(aInput, aTarget)) { + tOutput = aTarget; + } + else { + tOutput = getItemsForChiseling(aInput).get(0); + } + return tOutput; + } + private GTPP_Recipe generateChiselRecipe(ItemStack aInput, ItemStack aTarget) { - if (aInput != null && hasChiselResults(aInput) && aInput.stackSize > 0) { - ItemStack tOutput = null; - if (aTarget != null && canBeMadeFrom(aInput, aTarget)) { - tOutput = aTarget; - } - else { - tOutput = getItemsForChiseling(aInput).get(0); - } - if (tOutput != null) { + boolean tIsCached = hasValidCache(aInput, aTarget, true); + if (tIsCached || aInput != null && hasChiselResults(aInput)) { + ItemStack tOutput = tIsCached ? mOutputCache.copy() : getChiselOutput(aInput, aTarget); + if (tOutput != null) { + if (mCachedRecipe != null && GT_Utility.areStacksEqual(aInput, mInputCache) && GT_Utility.areStacksEqual(tOutput, mOutputCache)) { + return mCachedRecipe; + } // We can chisel this - log("Generated Chisel recipe good."); GTPP_Recipe aRecipe = new GTPP_Recipe( false, new ItemStack[] {ItemUtils.getSimpleStack(aInput, 1)}, @@ -217,10 +248,12 @@ public class GregtechMetaTileEntity_IndustrialChisel extends GregtechMeta_MultiB 20, 16, 0); + + // Cache it + cacheItem(aInput, tOutput, aRecipe); return aRecipe; } } - Logger.INFO("Recipe bad."); return null; } -- cgit From 9f62f89514735c39a48c311593531e7ec6805d09 Mon Sep 17 00:00:00 2001 From: Alkalus <3060479+draknyte1@users.noreply.github.com> Date: Mon, 20 Dec 2021 21:11:54 +0000 Subject: Further cache optimizations. --- .../basic/GregtechMetaTileEntity_AutoChisel.java | 26 +++++++++++++--------- .../GregtechMetaTileEntity_IndustrialChisel.java | 3 +++ 2 files changed, 19 insertions(+), 10 deletions(-) (limited to 'src/main/java/gtPlusPlus/xmod/gregtech') diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaTileEntity_AutoChisel.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaTileEntity_AutoChisel.java index 3cdd43c24e..f2fc0cce7a 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaTileEntity_AutoChisel.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaTileEntity_AutoChisel.java @@ -9,6 +9,8 @@ import gregtech.api.metatileentity.MetaTileEntity; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_BasicMachine; import gregtech.api.objects.GT_RenderedTexture; import gregtech.api.util.GT_Recipe; +import gregtech.api.util.GT_Utility; +import gtPlusPlus.core.util.minecraft.ItemUtils; import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; import net.minecraft.item.ItemStack; import team.chisel.carving.Carving; @@ -57,15 +59,14 @@ public class GregtechMetaTileEntity_AutoChisel extends GT_MetaTileEntity_BasicMa return null; } - private boolean hasValidCache(ItemStack mItem, boolean mClearOnFailure) { - if (mInputCache != null - && mOutputCache != null - && mInputCache.isItemEqual(mItem) - && ItemStack.areItemStackTagsEqual(mItem, mInputCache)) { - return true; + private boolean hasValidCache(ItemStack aStack, ItemStack aSpecialSlot, boolean aClearOnFailure) { + if (mInputCache != null && mOutputCache != null) { + if (GT_Utility.areStacksEqual(aStack, mInputCache) && GT_Utility.areStacksEqual(aSpecialSlot, mOutputCache)) { + return true; + } } // clear cache if it was invalid - if (mClearOnFailure) { + if (aClearOnFailure) { mInputCache = null; mOutputCache = null; } @@ -79,7 +80,7 @@ public class GregtechMetaTileEntity_AutoChisel extends GT_MetaTileEntity_BasicMa @Override protected boolean allowPutStackValidated(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { - return hasValidCache(aStack, false) ? true : super.allowPutStackValidated(aBaseMetaTileEntity, aIndex, aSide, aStack) && hasChiselResults(aStack); + return hasValidCache(aStack, this.getSpecialSlot(), false) ? true : super.allowPutStackValidated(aBaseMetaTileEntity, aIndex, aSide, aStack) && hasChiselResults(aStack); } // lets make sure the user isn't trying to make something from a block that doesn't have this as a valid target @@ -108,6 +109,9 @@ public class GregtechMetaTileEntity_AutoChisel extends GT_MetaTileEntity_BasicMa if (aTarget != null && canBeMadeFrom(aInput, aTarget)) { tOutput = aTarget; } + else if (aTarget != null && !canBeMadeFrom(aInput, aTarget)) { + tOutput = null; + } else { tOutput = getItemsForChiseling(aInput).get(0); } @@ -119,10 +123,12 @@ public class GregtechMetaTileEntity_AutoChisel extends GT_MetaTileEntity_BasicMa ItemStack tOutput = null; ItemStack aInput = getInputAt(0); ItemStack aTarget = getSpecialSlot(); - boolean tIsCached = hasValidCache(aInput, true); + boolean tIsCached = hasValidCache(aInput, aTarget, true); if (aInput != null && hasChiselResults(aInput) && aInput.stackSize > 0) { tOutput = tIsCached ? mOutputCache.copy() : getChiselOutput(aInput, aTarget); if (tOutput != null) { + tOutput = tOutput.copy(); + tOutput.stackSize = 1; // We can chisel this if (canOutput(tOutput)) { getInputAt(0).stackSize -= 1; @@ -132,7 +138,7 @@ public class GregtechMetaTileEntity_AutoChisel extends GT_MetaTileEntity_BasicMa return FOUND_RECIPE_BUT_DID_NOT_MEET_REQUIREMENTS; } if (!tIsCached) { - cacheItem(aInput, tOutput); + cacheItem(ItemUtils.getSimpleStack(aInput, 1), ItemUtils.getSimpleStack(tOutput, 1)); } this.mOutputItems[0] = tOutput.copy(); return FOUND_AND_SUCCESSFULLY_USED_RECIPE; diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialChisel.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialChisel.java index 290a36c052..b59bf61301 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialChisel.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialChisel.java @@ -222,6 +222,9 @@ public class GregtechMetaTileEntity_IndustrialChisel extends GregtechMeta_MultiB if (aTarget != null && canBeMadeFrom(aInput, aTarget)) { tOutput = aTarget; } + else if (aTarget != null && !canBeMadeFrom(aInput, aTarget)) { + tOutput = null; + } else { tOutput = getItemsForChiseling(aInput).get(0); } -- cgit From 06c8eb6bf1e2c634033d21e1d50ff7a8d8474550 Mon Sep 17 00:00:00 2001 From: Alkalus <3060479+draknyte1@users.noreply.github.com> Date: Tue, 21 Dec 2021 17:22:05 +0000 Subject: Changed I/O and recipe for Reservoir Hatch. --- src/main/java/gtPlusPlus/core/recipe/RECIPES_Machines.java | 6 +++--- .../implementations/GT_MetaTileEntity_Hatch_Reservoir.java | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) (limited to 'src/main/java/gtPlusPlus/xmod/gregtech') diff --git a/src/main/java/gtPlusPlus/core/recipe/RECIPES_Machines.java b/src/main/java/gtPlusPlus/core/recipe/RECIPES_Machines.java index f708a99af0..6e042a71b1 100644 --- a/src/main/java/gtPlusPlus/core/recipe/RECIPES_Machines.java +++ b/src/main/java/gtPlusPlus/core/recipe/RECIPES_Machines.java @@ -1414,9 +1414,9 @@ public class RECIPES_Machines { RecipeUtils.addShapedGregtechRecipe( - CI.getPlate(6, 1), ItemList.Casing_Grate.get(1), CI.getPlate(6, 1), - CI.getPlate(6, 1), CI.getFluidRegulator(6, 1), CI.getPlate(6, 1), - CI.getTieredCircuit(6), ItemList.Hatch_Input_LuV.get(1), CI.getTieredCircuit(6), + CI.getPlate(6, 1), ItemList.Casing_Gearbox_Titanium, CI.getPlate(6, 1), + CI.getPlate(6, 1), CI.getFluidRegulator(5, 1), CI.getPlate(6, 1), + CI.getTieredCircuit(6), ItemList.Hatch_Input_IV.get(1), CI.getTieredCircuit(6), GregtechItemList.Hatch_Reservoir.get(1)); RecipeUtils.addShapedGregtechRecipe( diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Reservoir.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Reservoir.java index 716251ecf0..75c5dbb9ee 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Reservoir.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Reservoir.java @@ -39,7 +39,7 @@ public class GT_MetaTileEntity_Hatch_Reservoir extends GT_MetaTileEntity_Hatch_F String[] aTooltip = new String[3]; aTooltip[0] = "Requires a Block of water facing the intake"; aTooltip[1] = "Infinite water supply hatch"; - aTooltip[2] = "Creates 2000L of Water every 4 ticks"; + aTooltip[2] = "Creates 8000L of Water every 4 ticks"; return aTooltip; } @@ -50,7 +50,7 @@ public class GT_MetaTileEntity_Hatch_Reservoir extends GT_MetaTileEntity_Hatch_F @Override public int getAmountOfFluidToGenerate() { - return 2000; + return 8000; } @Override @@ -60,7 +60,7 @@ public class GT_MetaTileEntity_Hatch_Reservoir extends GT_MetaTileEntity_Hatch_F @Override public int getCapacity() { - return 128000; + return 256000; } private static void setCrossModData() { -- cgit