diff options
author | Connor-Colenso <52056774+Connor-Colenso@users.noreply.github.com> | 2022-08-12 11:53:36 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-12 11:53:36 +0100 |
commit | a6cee61357566c1bd5b9a9610a19f167f3eec291 (patch) | |
tree | 1108e2e293f71746951004e6c4a58e8bc2b900d7 | |
parent | 74fc811ab0ca13c51c915170896be3eead8df142 (diff) | |
parent | 41f917a95588f56813ac381ad0ba28542b159525 (diff) | |
download | GT5-Unofficial-a6cee61357566c1bd5b9a9610a19f167f3eec291.tar.gz GT5-Unofficial-a6cee61357566c1bd5b9a9610a19f167f3eec291.tar.bz2 GT5-Unofficial-a6cee61357566c1bd5b9a9610a19f167f3eec291.zip |
Merge pull request #73 from minecraft7771/EnergyInfuserRework
Improved Energy Infuser
3 files changed, 105 insertions, 49 deletions
diff --git a/src/main/java/com/github/technus/tectech/compatibility/dreamcraft/DreamCraftRecipeLoader.java b/src/main/java/com/github/technus/tectech/compatibility/dreamcraft/DreamCraftRecipeLoader.java index 50ee61544f..40e81c5706 100644 --- a/src/main/java/com/github/technus/tectech/compatibility/dreamcraft/DreamCraftRecipeLoader.java +++ b/src/main/java/com/github/technus/tectech/compatibility/dreamcraft/DreamCraftRecipeLoader.java @@ -153,35 +153,33 @@ public class DreamCraftRecipeLoader { }, Materials.Osmium.getMolten(1296), CustomItemList.eM_Containment.get(1), 800, 500000); //Hollow Casing - TT_recipeAdder.addResearchableAssemblylineRecipe(CustomItemList.eM_Containment.get(1), - 12000, 32, 500000, 6, new ItemStack[]{ + GT_Values.RA.addAssemblylineRecipe(CustomItemList.eM_Containment.get(1), 7500, new ItemStack[]{ CustomItemList.eM_Containment.get(1), - GT_OreDictUnificator.get(OrePrefixes.plateDense, Materials.Neutronium, 2), + GT_OreDictUnificator.get(OrePrefixes.plateDense, Materials.Europium, 2), GT_OreDictUnificator.get(OrePrefixes.plateQuadruple, Materials.Plutonium, 4), GT_OreDictUnificator.get(OrePrefixes.plateDouble, Materials.Lead, 8), - GT_OreDictUnificator.get(OrePrefixes.plate, getOrDefault("BlackPlutonium", Materials.Americium), 16), - GT_OreDictUnificator.get(OrePrefixes.screw, getOrDefault("Quantium", Materials.Neutronium), 16), + GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Uranium, 16), + GT_OreDictUnificator.get(OrePrefixes.screw, getOrDefault("Quantium", Materials.Europium), 16), }, new FluidStack[]{ getOrDefault("Trinium", Materials.Osmium).getMolten(1296), Materials.Osmium.getMolten(1296), new FluidStack(FluidRegistry.getFluid("ic2coolant"), 2000), Materials.Argon.getGas(1000), - }, CustomItemList.eM_Hollow.get(2), 200, 2000000); + }, CustomItemList.eM_Hollow.get(2), 200, 200000); //EM Coil - TT_recipeAdder.addResearchableAssemblylineRecipe(CustomItemList.eM_Hollow.get(1), - 48000, 128, 1000000, 16, new ItemStack[]{ + GT_Values.RA.addAssemblylineRecipe(CustomItemList.eM_Hollow.get(1), 7500, new ItemStack[]{ CustomItemList.eM_Hollow.get(1), - ItemList.Casing_Fusion_Coil.get(4), - ItemList.Casing_Coil_NaquadahAlloy.get(4), - GT_OreDictUnificator.get(OrePrefixes.wireFine, Materials.Neutronium, 64), - GT_OreDictUnificator.get(OrePrefixes.foil, Materials.Neutronium, 64), + ItemList.Casing_Fusion_Coil.get(2), + ItemList.Casing_Coil_NaquadahAlloy.get(2), + GT_OreDictUnificator.get(OrePrefixes.wireFine, Materials.Europium, 64), + GT_OreDictUnificator.get(OrePrefixes.foil, Materials.Europium, 64), }, new FluidStack[]{ Materials.Glass.getMolten(2304), Materials.Silicone.getMolten(1872), new FluidStack(FluidRegistry.getFluid("ic2coolant"), 2000), getOrDefault("Trinium", Materials.Osmium).getMolten(1296), - }, CustomItemList.eM_Coil.get(4), 800, 2000000); + }, CustomItemList.eM_Coil.get(4), 800, 200000); // Infinite Oil Rig TT_recipeAdder.addResearchableAssemblylineRecipe(ItemList.OilDrill3.get(1), @@ -772,17 +770,16 @@ public class DreamCraftRecipeLoader { }, CustomItemList.Machine_Multi_Scanner.get(1), 24000, 500000); //Multi Infuser - TT_recipeAdder.addResearchableAssemblylineRecipe(CustomItemList.Machine_Multi_Transformer.get(1), - 192000, 512, 2000000, 32, new ItemStack[]{ + GT_Values.RA.addAssemblylineRecipe(CustomItemList.Machine_Multi_Transformer.get(1), 7500, new ItemStack[]{ CustomItemList.Machine_Multi_Transformer.get(1), CustomItemList.eM_Coil.get(8), CustomItemList.eM_Power.get(8), GT_OreDictUnificator.get(OrePrefixes.screw, Materials.NeodymiumMagnetic, 16), }, new FluidStack[]{ Materials.Electrum.getMolten(2592), - Materials.Neutronium.getMolten(1872), + Materials.Europium.getMolten(1872), new FluidStack(FluidRegistry.getFluid("ic2coolant"), 2000), - }, CustomItemList.Machine_Multi_Infuser.get(1), 8000, 2000000); + }, CustomItemList.Machine_Multi_Infuser.get(1), 8000, 200000); item_parts_UHV_assline_recipes(); diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_infuser.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_infuser.java index 7d5b16ca8c..51262076cd 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_infuser.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_infuser.java @@ -11,8 +11,10 @@ import com.gtnewhorizon.structurelib.alignment.constructable.IConstructable; import com.gtnewhorizon.structurelib.structure.IStructureDefinition; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; +import gregtech.api.enums.Materials; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_InputBus; import gregtech.api.util.GT_Multiblock_Tooltip_Builder; import ic2.api.item.ElectricItem; import ic2.api.item.IElectricItem; @@ -21,6 +23,7 @@ import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.ResourceLocation; +import net.minecraftforge.fluids.FluidStack; import static com.github.technus.tectech.loader.TecTechConfig.DEBUG_MODE; import static com.github.technus.tectech.thing.casing.GT_Block_CasingsTT.textureOffset; @@ -35,6 +38,11 @@ import static net.minecraft.util.StatCollector.translateToLocal; * Created by danie_000 on 17.12.2016. */ public class GT_MetaTileEntity_EM_infuser extends GT_MetaTileEntity_MultiblockBase_EM implements IConstructable { + + private static final int maxRepairedDamagePerOperation = 1000; + private static final long usedEuPerDurability = 1000; + private static final int usedUumPerDurability = 1; + //region structure private static final String[] description = new String[]{ EnumChatFormatting.AQUA + translateToLocal("tt.keyphrase.Hint_Details") + ":", @@ -68,12 +76,32 @@ public class GT_MetaTileEntity_EM_infuser extends GT_MetaTileEntity_MultiblockBa eDismantleBoom = true; } + private boolean isItemStackFullyCharged(ItemStack stack) { + if (stack == null) { + return true; + } + Item item = stack.getItem(); + if (stack.stackSize == 1) { + if (item instanceof IElectricItem) { + return ElectricItem.manager.getCharge(stack) >= ((IElectricItem)item).getMaxCharge(stack); + } else if (TecTech.hasCOFH && item instanceof IEnergyContainerItem) { + return ((IEnergyContainerItem)item).getEnergyStored(stack) >= ((IEnergyContainerItem)item).getMaxEnergyStored(stack); + } + } + return true; + } + + private boolean isItemStackFullyRepaired(ItemStack stack) { + if (stack == null) { + return true; + } + Item item = stack.getItem(); + return !item.isRepairable() || item.getMaxDamage(stack) <= 0 || item.getDamage(stack) <= 0; + } + private long doChargeItemStack(IElectricItem item, ItemStack stack) { try { double euDiff = item.getMaxCharge(stack) - ElectricItem.manager.getCharge(stack); - if (euDiff > 0) { - setEUVar(getEUVar() - (getEUVar() >> 5)); - } long remove = (long) Math.ceil( ElectricItem.manager.charge(stack, Math.min(euDiff, getEUVar()) @@ -94,7 +122,6 @@ public class GT_MetaTileEntity_EM_infuser extends GT_MetaTileEntity_MultiblockBa private long doChargeItemStackRF(IEnergyContainerItem item, ItemStack stack) { try { long RF = Math.min(item.getMaxEnergyStored(stack) - item.getEnergyStored(stack), getEUVar() * mEUtoRF / 100L); - //if(RF>0)this.setEUVar(this.getEUVar()-this.getEUVar()>>10); RF = item.receiveEnergy(stack, RF > Integer.MAX_VALUE ? Integer.MAX_VALUE : (int) RF, false); RF = RF * 100L / mEUtoRF; setEUVar(getEUVar() - RF); @@ -122,16 +149,24 @@ public class GT_MetaTileEntity_EM_infuser extends GT_MetaTileEntity_MultiblockBa @Override public boolean checkRecipe_EM(ItemStack itemStack) { - if (itemStack != null && itemStack.stackSize == 1) { - Item ofThis = itemStack.getItem(); - if (ofThis instanceof IElectricItem) { - mEfficiencyIncrease = 10000; - mMaxProgresstime = 20; - return true; - } else if (TecTech.hasCOFH && ofThis instanceof IEnergyContainerItem) { - mEfficiencyIncrease = 10000; - mMaxProgresstime = 20; - return true; + for (GT_MetaTileEntity_Hatch_InputBus inputBus : mInputBusses) { + if (inputBus.mInventory != null) { + for (ItemStack itemStackInBus : inputBus.mInventory) { + if (itemStackInBus != null) { + Item item = itemStackInBus.getItem(); + if (itemStackInBus.stackSize == 1 && item != null) { + if (isItemStackFullyCharged(itemStackInBus) && isItemStackFullyRepaired(itemStackInBus)) { + if (addOutput(itemStackInBus)) { + this.depleteInput(itemStackInBus); + } + } else { + mEfficiencyIncrease = 10000; + mMaxProgresstime = 20; + return true; + } + } + } + } } } return false; @@ -139,31 +174,55 @@ public class GT_MetaTileEntity_EM_infuser extends GT_MetaTileEntity_MultiblockBa @Override public void outputAfterRecipe_EM() { - ItemStack itemStack = mInventory[1]; - if (itemStack != null && itemStack.stackSize == 1) { - Item ofThis = itemStack.getItem(); - if (ofThis instanceof IElectricItem) { - if (doChargeItemStack((IElectricItem) ofThis, itemStack) == 0) { - getBaseMetaTileEntity().disableWorking(); - } - return; - } else if (TecTech.hasCOFH && ofThis instanceof IEnergyContainerItem) { - if (doChargeItemStackRF((IEnergyContainerItem) ofThis, itemStack) == 0) { - getBaseMetaTileEntity().disableWorking(); + boolean itemProcessed = false; + for (GT_MetaTileEntity_Hatch_InputBus inputBus : mInputBusses) { + if (inputBus.mInventory != null) { + for (ItemStack itemStackInBus : inputBus.mInventory) { + if (itemStackInBus != null) { + Item item = itemStackInBus.getItem(); + if (itemStackInBus.stackSize == 1 && item != null) { + if (isItemStackFullyCharged(itemStackInBus) && isItemStackFullyRepaired(itemStackInBus)) { + itemProcessed = true; + if (addOutput(itemStackInBus)) { + this.depleteInput(itemStackInBus); + } + } else { + if (item.isRepairable()) { + FluidStack uum = getStoredFluids().stream().filter(fluid -> Materials.UUMatter.getFluid(1).isFluidEqual(fluid)).findAny().orElse(null); + if (uum != null) { + int repairedDamage = Math.min(item.getDamage(itemStackInBus), maxRepairedDamagePerOperation); + long euCost = repairedDamage * usedEuPerDurability; + if (getEUVar() >= euCost && depleteInput(new FluidStack(Materials.UUMatter.mFluid,repairedDamage * usedUumPerDurability))) { + item.setDamage(itemStackInBus, Math.max(item.getDamage(itemStackInBus) - repairedDamage, 0)); + setEUVar(Math.min(getEUVar() - euCost, 0)); + } + } + } + if (item instanceof IElectricItem) { + doChargeItemStack((IElectricItem) item, itemStackInBus); + return; + } else if (TecTech.hasCOFH && item instanceof IEnergyContainerItem) { + doChargeItemStackRF((IEnergyContainerItem) item, itemStackInBus); + return; + } + } + } + } } - return; } } - getBaseMetaTileEntity().disableWorking(); + if (!itemProcessed) { + afterRecipeCheckFailed(); + } } @Override public GT_Multiblock_Tooltip_Builder createTooltip() { final GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); - tt.addMachineType(translateToLocal("gt.blockmachines.multimachine.em.infuser.name")) // Machine Type: Network Switch With QoS + tt.addMachineType(translateToLocal("gt.blockmachines.multimachine.em.infuser.name")) // Machine Type: Energy Infuser .addInfo(translateToLocal("gt.blockmachines.multimachine.em.infuser.desc.0")) // Controller block of the Energy Infuser - .addInfo(translateToLocal("gt.blockmachines.multimachine.em.infuser.desc.1")) // Can be used to charge items in the controller GUI - .addInfo(translateToLocal("gt.blockmachines.multimachine.em.infuser.desc.2")) // Has a loss of 3.125% + .addInfo(translateToLocal("gt.blockmachines.multimachine.em.infuser.desc.1")) // Can be used to charge items (lossless) + .addInfo(translateToLocal("gt.blockmachines.multimachine.em.infuser.desc.2")) // Can be fed with UU-Matter to repair items .addSeparator() .beginStructureBlock(3, 5, 3, false) .addController(translateToLocal("tt.keyword.Structure.FrontCenter3rd")) // Controller: Front 3rd layer center diff --git a/src/main/resources/assets/tectech/lang/en_US.lang b/src/main/resources/assets/tectech/lang/en_US.lang index 15c174691f..6393b2eeed 100644 --- a/src/main/resources/assets/tectech/lang/en_US.lang +++ b/src/main/resources/assets/tectech/lang/en_US.lang @@ -690,8 +690,8 @@ gt.blockmachines.multimachine.em.collider.Structure.AdditionalCollider=Needs ano gt.blockmachines.multimachine.em.infuser.name=Energy Infuser gt.blockmachines.multimachine.em.infuser.hint=1 - Classic Hatches or High Power Casing gt.blockmachines.multimachine.em.infuser.desc.0=Controller block of the Energy Infuser -gt.blockmachines.multimachine.em.infuser.desc.1=Can be used to charge items in the controller GUI -gt.blockmachines.multimachine.em.infuser.desc.2=Has a loss of 3.125% +gt.blockmachines.multimachine.em.infuser.desc.1=Can be used to charge items (lossless) +gt.blockmachines.multimachine.em.infuser.desc.2=Can be fed with UU-Matter to repair items gt.blockmachines.multimachine.em.infuser.Structure.HighPowerCasing=Layer 1 and 5 gt.blockmachines.multimachine.em.infuser.Structure.MolecularCoil=Layer 2 and 4 gt.blockmachines.multimachine.em.infuser.Structure.MolecularCasing=Layer 3 (hollow) |