From cbc6526d403d9eb0f64de603099c7b41f7e8fc72 Mon Sep 17 00:00:00 2001 From: Technus Date: Mon, 20 Mar 2017 14:28:41 +0100 Subject: Minor refactor, adding stabilizer, working energy infuser --- .../java/com/github/technus/tectech/TecTech.java | 1 + .../elementalMatter/classes/rElementalRecipe.java | 18 +- .../classes/rElementalRecipeTree.java | 45 ++- .../technus/tectech/loader/GT_Loader_Machines.java | 15 +- .../technus/tectech/loader/GT_Loader_Recipes.java | 4 +- .../technus/tectech/thing/CustomItemList.java | 2 +- .../tectech/thing/item/debug_container_EM.java | 9 +- .../multi/GT_MetaTileEntity_EM_dequantifier.java | 66 ---- .../multi/GT_MetaTileEntity_EM_dequantizer.java | 66 ++++ .../multi/GT_MetaTileEntity_EM_infuser.java | 79 ++++- .../multi/GT_MetaTileEntity_EM_quantifier.java | 389 --------------------- .../multi/GT_MetaTileEntity_EM_quantizer.java | 389 +++++++++++++++++++++ .../multi/GT_MetaTileEntity_EM_stabilizer.java | 51 +++ 13 files changed, 624 insertions(+), 510 deletions(-) delete mode 100644 src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_dequantifier.java create mode 100644 src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_dequantizer.java delete mode 100644 src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_quantifier.java create mode 100644 src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_quantizer.java create mode 100644 src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_stabilizer.java (limited to 'src/main/java') diff --git a/src/main/java/com/github/technus/tectech/TecTech.java b/src/main/java/com/github/technus/tectech/TecTech.java index b9ce2ed5f9..1a74b762bb 100644 --- a/src/main/java/com/github/technus/tectech/TecTech.java +++ b/src/main/java/com/github/technus/tectech/TecTech.java @@ -98,6 +98,7 @@ public class TecTech { super.displayAllReleventItems(stuffToShow); } }; + RegisterThingsInTabs(); if (Loader.isModLoaded("dreamcraft")) ;//TODO init recipes for GTNH coremod } diff --git a/src/main/java/com/github/technus/tectech/elementalMatter/classes/rElementalRecipe.java b/src/main/java/com/github/technus/tectech/elementalMatter/classes/rElementalRecipe.java index b7abbd86fd..98f11cb4d4 100644 --- a/src/main/java/com/github/technus/tectech/elementalMatter/classes/rElementalRecipe.java +++ b/src/main/java/com/github/technus/tectech/elementalMatter/classes/rElementalRecipe.java @@ -7,29 +7,35 @@ import net.minecraftforge.fluids.FluidStack; * Created by Tec on 02.03.2017. */ public class rElementalRecipe implements Comparable { - public final cElementalDefinitionStackTree inEM; - public final cElementalDefinitionStackTree outEM; - public final ItemStack[] outItems; - public final FluidStack[] outFluids; + public cElementalDefinitionStackTree inEM; + public cElementalDefinitionStackTree outEM; + public ItemStack[] outItems; + public FluidStack[] outFluids; public Object[] extension = null; + private short comparableID=0; public rElementalRecipe( cElementalDefinitionStackTree inEMnotNull, + short comparableID, cElementalDefinitionStackTree outEM, ItemStack[] outItems, FluidStack[] outFluids) { this.inEM = inEMnotNull; + this.comparableID=comparableID;//allows multiple recipes with the same input EM this.outEM = outEM; this.outItems = outItems; this.outFluids = outFluids; } - public void extend(Object... data) { + public rElementalRecipe extend(Object... data) { extension = data; + return this; } @Override public int compareTo(rElementalRecipe o) { - return inEM.compareTo(o.inEM); + final int compare=inEM.compareTo(o.inEM); + if(compare!=0)return compare; + return (int)comparableID-o.comparableID; } } diff --git a/src/main/java/com/github/technus/tectech/elementalMatter/classes/rElementalRecipeTree.java b/src/main/java/com/github/technus/tectech/elementalMatter/classes/rElementalRecipeTree.java index 92d9c5e05f..e2d9431432 100644 --- a/src/main/java/com/github/technus/tectech/elementalMatter/classes/rElementalRecipeTree.java +++ b/src/main/java/com/github/technus/tectech/elementalMatter/classes/rElementalRecipeTree.java @@ -6,57 +6,54 @@ import java.util.TreeMap; * Created by Tec on 02.03.2017. */ public class rElementalRecipeTree { - private TreeMap recipes = new TreeMap<>(); + //Multimap for multiple recipes from the same thing - you know parameters might differ the output + private TreeMap > recipes = new TreeMap<>(); - public rElementalRecipeTree(rElementalRecipe... contents) { - for (rElementalRecipe recipe : contents) - recipes.put(recipe.inEM, recipe); - } + public rElementalRecipeTree() {} public rElementalRecipe put(rElementalRecipe in) { - return recipes.put(in.inEM, in); + TreeMap r=recipes.get(in.inEM); + if(r==null){ + r=new TreeMap<>(); + recipes.put(in.inEM,r); + } + return r.put(in.comparableID, in); } public void putAll(rElementalRecipe... contents) { for (rElementalRecipe recipe : contents) - recipes.put(recipe.inEM, recipe); + put(recipe); } - public rElementalRecipe findExact(cElementalDefinitionStackTree in) { + public TreeMap findExact(cElementalDefinitionStackTree in) { return recipes.get(in); } - public rElementalRecipe findTopMatch(cElementalDefinitionStackTree in) { - for (cElementalDefinitionStackTree requirement : recipes.descendingKeySet()) { + public TreeMap findTopMatch(cElementalDefinitionStackTree in) { + for (cElementalDefinitionStackTree requirement : recipes.descendingKeySet()) if (in.removeAllAmounts(true, requirement)) return recipes.get(requirement); - } return null; } - public rElementalRecipe findTopMatch(cElementalInstanceStackTree in, boolean testOnly) { - for (cElementalDefinitionStackTree requirement : recipes.descendingKeySet()) { + public TreeMap findTopMatch(cElementalInstanceStackTree in, boolean testOnly) { + for (cElementalDefinitionStackTree requirement : recipes.descendingKeySet()) if (in.removeAllAmounts(testOnly, requirement)) return recipes.get(requirement); - } return null; } - public rElementalRecipe findBottomMatch(cElementalDefinitionStackTree in) { - for (cElementalDefinitionStackTree requirement : recipes.keySet()) { - if (in.removeAllAmounts(true, requirement)) { + public TreeMap findBottomMatch(cElementalDefinitionStackTree in) { + for (cElementalDefinitionStackTree requirement : recipes.keySet()) + if (in.removeAllAmounts(true, requirement)) return recipes.get(requirement); - } - } return null; } - public rElementalRecipe findBottomMatch(cElementalInstanceStackTree in, boolean testOnly) { - for (cElementalDefinitionStackTree requirement : recipes.keySet()) { - if (in.removeAllAmounts(testOnly, requirement)) { + public TreeMap findBottomMatch(cElementalInstanceStackTree in, boolean testOnly) { + for (cElementalDefinitionStackTree requirement : recipes.keySet()) + if (in.removeAllAmounts(testOnly, requirement)) return recipes.get(requirement); - } - } return null; } } diff --git a/src/main/java/com/github/technus/tectech/loader/GT_Loader_Machines.java b/src/main/java/com/github/technus/tectech/loader/GT_Loader_Machines.java index 0fe2512f0e..21824b4579 100644 --- a/src/main/java/com/github/technus/tectech/loader/GT_Loader_Machines.java +++ b/src/main/java/com/github/technus/tectech/loader/GT_Loader_Machines.java @@ -176,27 +176,28 @@ public class GT_Loader_Machines implements Runnable { Machine_Multi_Transformer.set(new GT_MetaTileEntity_EM_transformer(12160, "multimachine.em.transformer", "Active Transformer").getStackForm(1L)); Machine_Multi_Infuser.set(new GT_MetaTileEntity_EM_infuser(12161,"multimachine.em.infuser","Energy infuser").getStackForm(1)); - Machine_Multi_MatterToEM.set(new GT_MetaTileEntity_EM_quantifier(12162, "multimachine.em.mattertoem", "Matter Quantifier").getStackForm(1L)); - Machine_Multi_EMToMatter.set(new GT_MetaTileEntity_EM_dequantifier(12163, "multimachine.em.emtomatter", "Matter De-quantifier").getStackForm(1L)); + Machine_Multi_MatterToEM.set(new GT_MetaTileEntity_EM_quantizer(12162, "multimachine.em.mattertoem", "Matter Quantizer").getStackForm(1L)); + Machine_Multi_EMToMatter.set(new GT_MetaTileEntity_EM_dequantizer(12163, "multimachine.em.emtomatter", "Matter Dequantizer").getStackForm(1L)); Machine_Multi_EMjunction.set(new GT_MetaTileEntity_EM_junction(12164, "multimachine.em.junction", "Matter junction").getStackForm(1L)); Machine_Multi_EMmachine.set(new GT_MetaTileEntity_EM_machine(12165, "multimachine.em.processing", "Quantum Processing Machine").getStackForm(1L)); Machine_Multi_EMCrafter.set(new GT_MetaTileEntity_EM_crafter(12166, "multimachine.em.crafter", "Matter Assembler").getStackForm(1L)); Machine_Multi_Collider.set(new GT_MetaTileEntity_EM_collider(12167, "multimachine.em.collider", "Matter Collider").getStackForm(1L)); Machine_Multi_BHG.set(new GT_MetaTileEntity_EM_bhg(12168, "multimachine.em.blackholegenerator", "Black Hole Generator").getStackForm(1L)); Machine_Multi_Wormhole.set(new GT_MetaTileEntity_EM_wormhole(12169, "multimachine.em.wormhole", "Wormhole").getStackForm(1L)); - Machine_Multi_Scanner.set(new GT_MetaTileEntity_EM_scanner(12170, "multimachine.em.scanner", "Elemental Scanner").getStackForm(1L)); - Machine_Multi_Computer.set(new GT_MetaTileEntity_EM_computer(12171, "multimachine.em.computer", "Quantum computer").getStackForm(1L)); + Machine_Multi_Stabilizer.set(new GT_MetaTileEntity_EM_stabilizer(12170, "multimachine.em.stabilizer", "Elemental Stabilizer").getStackForm(1L)); + Machine_Multi_Scanner.set(new GT_MetaTileEntity_EM_scanner(12171, "multimachine.em.scanner", "Elemental Scanner").getStackForm(1L)); + Machine_Multi_Computer.set(new GT_MetaTileEntity_EM_computer(12172, "multimachine.em.computer", "Quantum computer").getStackForm(1L)); // =================================================================================================== // Hatches EM // =================================================================================================== Parametrizer_Hatch.set(new GT_MetaTileEntity_Hatch_Param(12180, "hatch.param.tier.06", "Parametrizer for machines", 6).getStackForm(1L)); - Uncertainty_Hatch.set(new GT_MetaTileEntity_Hatch_Uncertainty(12181, "hatch.emcertain.tier.06", "Uncertainty resolver", 6).getStackForm(1L)); - UncertaintyX_Hatch.set(new GT_MetaTileEntity_Hatch_Uncertainty(12182, "hatch.emcertain.tier.10", "Uncertainty resolver X", 10).getStackForm(1L)); + Uncertainty_Hatch.set(new GT_MetaTileEntity_Hatch_Uncertainty(12181, "hatch.certain.tier.06", "Uncertainty resolver", 6).getStackForm(1L)); + UncertaintyX_Hatch.set(new GT_MetaTileEntity_Hatch_Uncertainty(12182, "hatch.certain.tier.10", "Uncertainty resolver X", 10).getStackForm(1L)); // =================================================================================================== // EM pipe // =================================================================================================== - EMpipe.set(new GT_MetaTileEntity_Pipe_EM(12179, "pipe.elementalmatter", "Quantum tunnel").getStackForm(1L)); + EMpipe.set(new GT_MetaTileEntity_Pipe_EM(12199, "pipe.elementalmatter", "Quantum tunnel").getStackForm(1L)); } } diff --git a/src/main/java/com/github/technus/tectech/loader/GT_Loader_Recipes.java b/src/main/java/com/github/technus/tectech/loader/GT_Loader_Recipes.java index a4885f5401..d4c76198d2 100644 --- a/src/main/java/com/github/technus/tectech/loader/GT_Loader_Recipes.java +++ b/src/main/java/com/github/technus/tectech/loader/GT_Loader_Recipes.java @@ -2,7 +2,7 @@ package com.github.technus.tectech.loader; import com.github.technus.tectech.elementalMatter.classes.cElementalPrimitive; import com.github.technus.tectech.elementalMatter.definitions.*; -import com.github.technus.tectech.thing.metaTileEntity.multi.GT_MetaTileEntity_EM_quantifier; +import com.github.technus.tectech.thing.metaTileEntity.multi.GT_MetaTileEntity_EM_quantizer; /** * Created by danie_000 on 16.11.2016. @@ -30,6 +30,6 @@ public class GT_Loader_Recipes implements Runnable { // Recipe init // =================================================================================================== - GT_MetaTileEntity_EM_quantifier.run(); + GT_MetaTileEntity_EM_quantizer.run(); } } diff --git a/src/main/java/com/github/technus/tectech/thing/CustomItemList.java b/src/main/java/com/github/technus/tectech/thing/CustomItemList.java index fa47c10b87..e40b478325 100644 --- a/src/main/java/com/github/technus/tectech/thing/CustomItemList.java +++ b/src/main/java/com/github/technus/tectech/thing/CustomItemList.java @@ -32,7 +32,7 @@ public enum CustomItemList implements IItemContainer { debugBlock, Machine_Multi_MatterToEM, Machine_Multi_EMToMatter, Machine_Multi_EMjunction, Machine_Multi_Transformer, Machine_Multi_Computer, Machine_Multi_Infuser, - Machine_Multi_BHG, Machine_Multi_EMmachine, Machine_Multi_Collider, Machine_Multi_Wormhole, Machine_Multi_EMCrafter, Machine_Multi_Scanner; + Machine_Multi_BHG, Machine_Multi_EMmachine, Machine_Multi_Stabilizer, Machine_Multi_Collider, Machine_Multi_Wormhole, Machine_Multi_EMCrafter, Machine_Multi_Scanner; private ItemStack mStack = null; diff --git a/src/main/java/com/github/technus/tectech/thing/item/debug_container_EM.java b/src/main/java/com/github/technus/tectech/thing/item/debug_container_EM.java index d828a672aa..01e55898b5 100644 --- a/src/main/java/com/github/technus/tectech/thing/item/debug_container_EM.java +++ b/src/main/java/com/github/technus/tectech/thing/item/debug_container_EM.java @@ -37,11 +37,7 @@ public class debug_container_EM extends Item { @Override public boolean onItemUseFirst(ItemStack aStack, EntityPlayer aPlayer, World aWorld, int aX, int aY, int aZ, int aSide, float hitX, float hitY, float hitZ) { - NBTTagCompound tNBT; - //if(aStack.getTagCompound()==null){ - // aStack.setTagCompound(new NBTTagCompound()); - //} - tNBT = aStack.getTagCompound(); + NBTTagCompound tNBT = aStack.getTagCompound(); TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); if (aPlayer instanceof EntityPlayerMP) { aStack.stackSize = 1; @@ -75,13 +71,12 @@ public class debug_container_EM extends Item { @Override public void addInformation(ItemStack aStack, EntityPlayer ep, List aList, boolean boo) { aList.add(commonValues.tecMark); - aList.add("Container for elemental matter"); try { NBTTagCompound tNBT = aStack.getTagCompound(); if (tNBT!=null && tNBT.hasKey("info")) { aList.add("Contains:"); Collections.addAll(aList, cElementalInstanceStackTree.infoFromNBT(tNBT.getCompoundTag("info"))); - } + }else aList.add("Container for elemental matter"); } catch (Exception e) { aList.add("---Unexpected Termination---"); } diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_dequantifier.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_dequantifier.java deleted file mode 100644 index 9df5fbe8e3..0000000000 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_dequantifier.java +++ /dev/null @@ -1,66 +0,0 @@ -package com.github.technus.tectech.thing.metaTileEntity.multi; - -import com.github.technus.tectech.elementalMatter.commonValues; -import com.github.technus.tectech.thing.block.QuantumGlass; -import com.github.technus.tectech.thing.casing.GT_Container_CasingsTT; -import com.github.technus.tectech.thing.metaTileEntity.GT_MetaTileEntity_MultiblockBase_EM; -import gregtech.api.interfaces.metatileentity.IMetaTileEntity; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import net.minecraft.item.ItemStack; -import net.minecraft.util.EnumChatFormatting; -import net.minecraftforge.common.util.ForgeDirection; - -/** - * Created by danie_000 on 17.12.2016. - */ -public class GT_MetaTileEntity_EM_dequantifier extends GT_MetaTileEntity_MultiblockBase_EM { - - public GT_MetaTileEntity_EM_dequantifier(int aID, String aName, String aNameRegional) { - super(aID, aName, aNameRegional); - } - - public GT_MetaTileEntity_EM_dequantifier(String aName) { - super(aName); - } - - public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GT_MetaTileEntity_EM_dequantifier(this.mName); - } - - @Override - public boolean checkMachine(IGregTechTileEntity iGregTechTileEntity, ItemStack itemStack) { - int xDir = ForgeDirection.getOrientation(iGregTechTileEntity.getBackFacing()).offsetX; - int yDir = ForgeDirection.getOrientation(iGregTechTileEntity.getBackFacing()).offsetY; - int zDir = ForgeDirection.getOrientation(iGregTechTileEntity.getBackFacing()).offsetZ; - if (iGregTechTileEntity.getBlockOffset(xDir, yDir, zDir) != QuantumGlass.INSTANCE) return false; - for (int i = -1; i < 2; i++) { - for (int j = -1; j < 2; j++) { - for (int h = -1; h < 2; h++) { - if ((i != 0 || j != 0 || h != 0)/*exclude center*/ && (xDir + i != 0 || yDir + h != 0 || zDir + j != 0)/*exclude this*/) { - IGregTechTileEntity tTileEntity = iGregTechTileEntity.getIGregTechTileEntityOffset(xDir + i, yDir + h, zDir + j); - if ((!addMaintenanceToMachineList(tTileEntity, 99)) && - (!addElementalInputToMachineList(tTileEntity, 99)) && - (!addClassicOutputToMachineList(tTileEntity, 99)) && - (!addMufflerToMachineList(tTileEntity, 99)) && - (!addEnergyIOToMachineList(tTileEntity, 99))) { - if (iGregTechTileEntity.getBlockOffset(xDir + i, yDir + h, zDir + j) != GT_Container_CasingsTT.sBlockCasingsTT || - iGregTechTileEntity.getMetaIDOffset(xDir + i, yDir + h, zDir + j) != 3) { - return false; - } - } - } - } - } - } - return true; - } - - @Override - public String[] getDescription() { - return new String[]{ - commonValues.tecMark, - "Transform quantum form back to regular one...", - EnumChatFormatting.AQUA.toString() + EnumChatFormatting.BOLD + "but why?" - }; - } -} diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_dequantizer.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_dequantizer.java new file mode 100644 index 0000000000..5b4405ce4f --- /dev/null +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_dequantizer.java @@ -0,0 +1,66 @@ +package com.github.technus.tectech.thing.metaTileEntity.multi; + +import com.github.technus.tectech.elementalMatter.commonValues; +import com.github.technus.tectech.thing.block.QuantumGlass; +import com.github.technus.tectech.thing.casing.GT_Container_CasingsTT; +import com.github.technus.tectech.thing.metaTileEntity.GT_MetaTileEntity_MultiblockBase_EM; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumChatFormatting; +import net.minecraftforge.common.util.ForgeDirection; + +/** + * Created by danie_000 on 17.12.2016. + */ +public class GT_MetaTileEntity_EM_dequantizer extends GT_MetaTileEntity_MultiblockBase_EM { + + public GT_MetaTileEntity_EM_dequantizer(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public GT_MetaTileEntity_EM_dequantizer(String aName) { + super(aName); + } + + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GT_MetaTileEntity_EM_dequantizer(this.mName); + } + + @Override + public boolean checkMachine(IGregTechTileEntity iGregTechTileEntity, ItemStack itemStack) { + int xDir = ForgeDirection.getOrientation(iGregTechTileEntity.getBackFacing()).offsetX; + int yDir = ForgeDirection.getOrientation(iGregTechTileEntity.getBackFacing()).offsetY; + int zDir = ForgeDirection.getOrientation(iGregTechTileEntity.getBackFacing()).offsetZ; + if (iGregTechTileEntity.getBlockOffset(xDir, yDir, zDir) != QuantumGlass.INSTANCE) return false; + for (int i = -1; i < 2; i++) { + for (int j = -1; j < 2; j++) { + for (int h = -1; h < 2; h++) { + if ((i != 0 || j != 0 || h != 0)/*exclude center*/ && (xDir + i != 0 || yDir + h != 0 || zDir + j != 0)/*exclude this*/) { + IGregTechTileEntity tTileEntity = iGregTechTileEntity.getIGregTechTileEntityOffset(xDir + i, yDir + h, zDir + j); + if ((!addMaintenanceToMachineList(tTileEntity, 99)) && + (!addElementalInputToMachineList(tTileEntity, 99)) && + (!addClassicOutputToMachineList(tTileEntity, 99)) && + (!addMufflerToMachineList(tTileEntity, 99)) && + (!addEnergyIOToMachineList(tTileEntity, 99))) { + if (iGregTechTileEntity.getBlockOffset(xDir + i, yDir + h, zDir + j) != GT_Container_CasingsTT.sBlockCasingsTT || + iGregTechTileEntity.getMetaIDOffset(xDir + i, yDir + h, zDir + j) != 3) { + return false; + } + } + } + } + } + } + return true; + } + + @Override + public String[] getDescription() { + return new String[]{ + commonValues.tecMark, + "Transform quantum form back to regular one...", + EnumChatFormatting.AQUA.toString() + EnumChatFormatting.BOLD + "but why?" + }; + } +} 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 3dfb088b27..90e1bd655c 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 @@ -1,18 +1,25 @@ package com.github.technus.tectech.thing.metaTileEntity.multi; +import cofh.api.energy.IEnergyContainerItem; +import com.github.technus.tectech.TecTech; import com.github.technus.tectech.elementalMatter.commonValues; import com.github.technus.tectech.thing.metaTileEntity.GT_MetaTileEntity_MultiblockBase_EM; import com.github.technus.tectech.thing.metaTileEntity.multi.gui.GT_GUIContainer_MultiMachineEM; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import ic2.api.item.ElectricItem; +import ic2.api.item.IElectricItem; +import ic2.api.item.IElectricItemManager; +import ic2.api.item.ISpecialElectricItem; import net.minecraft.block.Block; import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.EnumChatFormatting; import net.minecraftforge.common.util.ForgeDirection; -import static com.github.technus.tectech.elementalMatter.commonValues.multiCheckAt; import static com.github.technus.tectech.thing.casing.GT_Container_CasingsTT.sBlockCasingsTT; +import static gregtech.api.GregTech_API.mEUtoRF; /** * Created by danie_000 on 17.12.2016. @@ -59,7 +66,8 @@ public class GT_MetaTileEntity_EM_infuser extends GT_MetaTileEntity_MultiblockBa for (int h = -1; h < 2; h++) { if ((i != 0 || j != 0 || h != 0)/*exclude center*/ && (xDir + i != 0 || yDir + h != 0 || zDir + j != 0)/*exclude this*/) { IGregTechTileEntity tTileEntity = iGregTechTileEntity.getIGregTechTileEntityOffset(xDir + i, yDir + h, zDir + j); - if (!addEnergyIOToMachineList(tTileEntity, 99)) { + if ((!addMaintenanceToMachineList(tTileEntity, 99)) && + (!addEnergyIOToMachineList(tTileEntity, 99))) { if (iGregTechTileEntity.getBlockOffset(xDir + i, yDir + h, zDir + j) != sBlockCasingsTT || iGregTechTileEntity.getMetaIDOffset(xDir + i, yDir + h, zDir + j) != 3) { return false; @@ -74,9 +82,15 @@ public class GT_MetaTileEntity_EM_infuser extends GT_MetaTileEntity_MultiblockBa @Override public boolean EM_checkRecipe(ItemStack itemStack) { - if (getBaseMetaTileEntity().isAllowedToWork()) { - - + if (getBaseMetaTileEntity().isAllowedToWork() && getRepairStatus()==getIdealStatus() && itemStack!=null && itemStack.stackSize==1) { + Item ofThis=itemStack.getItem(); + if(itemStack.getItem() instanceof ISpecialElectricItem){ + doChargeItemStackSpecial((ISpecialElectricItem) ofThis,itemStack); + }else if(itemStack.getItem() instanceof IElectricItem){ + doChargeItemStack((IElectricItem) ofThis,itemStack); + }else if(itemStack.getItem() instanceof IEnergyContainerItem){ + doChargeItemStackRF((IEnergyContainerItem) ofThis,itemStack); + } mEfficiencyIncrease = 10000; mMaxProgresstime = 20; eDismatleBoom=true; @@ -94,9 +108,58 @@ public class GT_MetaTileEntity_EM_infuser extends GT_MetaTileEntity_MultiblockBa public String[] getDescription() { return new String[]{ commonValues.tecMark, - "Power substation", - EnumChatFormatting.AQUA.toString() + EnumChatFormatting.BOLD + "All the transformation!", - EnumChatFormatting.BLUE + "Insanely fast lossy charging, HAYO!", + "Power Transfer Extreme!", + EnumChatFormatting.AQUA.toString() + EnumChatFormatting.BOLD + "Insanely fast charging!", + EnumChatFormatting.BLUE + "Doesn't work while broken!", + EnumChatFormatting.BLUE + "Power loss is a thing." }; } + + private void doChargeItemStack(IElectricItem item, ItemStack stack ) + { + try { + double euDiff=item.getMaxCharge(stack) - ElectricItem.manager.getCharge(stack); + if(euDiff>0)this.setEUVar(this.getEUVar()-this.getEUVar()>>5); + this.setEUVar( + this.getEUVar()-(long)Math.ceil( + ElectricItem.manager.charge(stack, + Math.min(euDiff,this.getEUVar()) + ,item.getTier(stack),true,false) + )); + } catch( Exception e ) { + if(TecTech.ModConfig.DEBUG_MODE) + e.printStackTrace(); + } + } + + private void doChargeItemStackSpecial(ISpecialElectricItem item, ItemStack stack ) + { + try { + final IElectricItemManager manager=item.getManager(stack); + double euDiff=item.getMaxCharge(stack) - manager.getCharge(stack); + if(euDiff>0)this.setEUVar(this.getEUVar()-this.getEUVar()>>5); + this.setEUVar( + this.getEUVar()-(long)Math.ceil( + manager.charge(stack, + Math.min(euDiff,this.getEUVar()) + ,item.getTier(stack),true,false) + )); + } catch( Exception e ) { + if(TecTech.ModConfig.DEBUG_MODE) + e.printStackTrace(); + } + } + + private void doChargeItemStackRF(IEnergyContainerItem item, ItemStack stack ) + { + try { + long RF=Math.min(item.getMaxEnergyStored(stack)-item.getEnergyStored(stack),this.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); + this.setEUVar(this.getEUVar()-(RF*100L/mEUtoRF)); + } catch( Exception e ) { + if (TecTech.ModConfig.DEBUG_MODE) + e.printStackTrace(); + } + } } diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_quantifier.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_quantifier.java deleted file mode 100644 index b39cc9c5e0..0000000000 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_quantifier.java +++ /dev/null @@ -1,389 +0,0 @@ -package com.github.technus.tectech.thing.metaTileEntity.multi; - -import com.github.technus.tectech.TecTech; -import com.github.technus.tectech.elementalMatter.classes.cElementalDefinitionStack; -import com.github.technus.tectech.elementalMatter.classes.cElementalInstanceStack; -import com.github.technus.tectech.elementalMatter.classes.cElementalInstanceStackTree; -import com.github.technus.tectech.elementalMatter.classes.tElementalException; -import com.github.technus.tectech.elementalMatter.commonValues; -import com.github.technus.tectech.elementalMatter.definitions.dAtomDefinition; -import com.github.technus.tectech.elementalMatter.definitions.dHadronDefinition; -import com.github.technus.tectech.elementalMatter.definitions.eLeptonDefinition; -import com.github.technus.tectech.thing.block.QuantumGlass; -import com.github.technus.tectech.thing.casing.GT_Container_CasingsTT; -import com.github.technus.tectech.thing.metaTileEntity.GT_MetaTileEntity_MultiblockBase_EM; -import gregtech.api.GregTech_API; -import gregtech.api.enums.Materials; -import gregtech.api.enums.OrePrefixes; -import gregtech.api.interfaces.metatileentity.IMetaTileEntity; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import net.minecraft.item.ItemStack; -import net.minecraft.util.EnumChatFormatting; -import net.minecraftforge.common.util.ForgeDirection; -import net.minecraftforge.fluids.FluidStack; -import net.minecraftforge.oredict.OreDictionary; - -import java.util.HashMap; - -import static com.github.technus.tectech.elementalMatter.definitions.dAtomDefinition.getBestUnstableIsotope; -import static com.github.technus.tectech.elementalMatter.definitions.dAtomDefinition.getFirstStableIsotope; -import static gregtech.api.enums.GT_Values.V; - -/** - * Created by danie_000 on 17.12.2016. - */ -public class GT_MetaTileEntity_EM_quantifier extends GT_MetaTileEntity_MultiblockBase_EM { - public static HashMap itemBinds = new HashMap<>(32); - public static HashMap fluidBind = new HashMap<>(8); - private static float refMass, refUnstableMass; - - public GT_MetaTileEntity_EM_quantifier(int aID, String aName, String aNameRegional) { - super(aID, aName, aNameRegional); - } - - public GT_MetaTileEntity_EM_quantifier(String aName) { - super(aName); - } - - public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GT_MetaTileEntity_EM_quantifier(this.mName); - } - - @Override - public boolean checkMachine(IGregTechTileEntity iGregTechTileEntity, ItemStack itemStack) { - int xDir = ForgeDirection.getOrientation(iGregTechTileEntity.getBackFacing()).offsetX; - int yDir = ForgeDirection.getOrientation(iGregTechTileEntity.getBackFacing()).offsetY; - int zDir = ForgeDirection.getOrientation(iGregTechTileEntity.getBackFacing()).offsetZ; - if (iGregTechTileEntity.getBlockOffset(xDir, yDir, zDir) != QuantumGlass.INSTANCE) return false; - for (int i = -1; i < 2; i++) { - for (int j = -1; j < 2; j++) { - for (int h = -1; h < 2; h++) { - if ((i != 0 || j != 0 || h != 0)/*exclude center*/ && (xDir + i != 0 || yDir + h != 0 || zDir + j != 0)/*exclude this*/) { - IGregTechTileEntity tTileEntity = iGregTechTileEntity.getIGregTechTileEntityOffset(xDir + i, yDir + h, zDir + j); - if ((!addMaintenanceToMachineList(tTileEntity, 99)) && - (!addClassicInputToMachineList(tTileEntity, 99)) && - (!addElementalOutputToMachineList(tTileEntity, 99)) && - (!addMufflerToMachineList(tTileEntity, 99)) && - (!addEnergyIOToMachineList(tTileEntity, 99))) { - if (iGregTechTileEntity.getBlockOffset(xDir + i, yDir + h, zDir + j) != GT_Container_CasingsTT.sBlockCasingsTT || - iGregTechTileEntity.getMetaIDOffset(xDir + i, yDir + h, zDir + j) != 3) { - return false; - } - } - } - } - } - } - return true; - } - - @Override - public String[] getDescription() { - return new String[]{ - commonValues.tecMark, - "Conveniently convert regular stuff into quantum form.", - EnumChatFormatting.AQUA.toString() + EnumChatFormatting.BOLD + "To make it more inconvenient." - }; - } - - @Override - public boolean EM_checkRecipe(ItemStack itemStack) { - if (GregTech_API.sPostloadFinished) { - ItemStack[] inI = getStoredInputs().toArray(new ItemStack[0]); - if (inI.length > 0) { - for (ItemStack is : inI) { - int[] oreIDs = OreDictionary.getOreIDs(is); - if (TecTech.ModConfig.DEBUG_MODE) - TecTech.Logger.info("Quantifier-recipe " + is.getItem().getUnlocalizedName() + "." + is.getItemDamage() + " " + is.getDisplayName()); - for (int ID : oreIDs) { - if (TecTech.ModConfig.DEBUG_MODE) - TecTech.Logger.info("Quantifier-recipe " + is.getItem().getUnlocalizedName() + "." + is.getItemDamage() + " " + OreDictionary.getOreName(ID)); - cElementalDefinitionStack into = itemBinds.get(ID); - if (into != null && isInputEqual(true, false, - nothingF, new ItemStack[]{new ItemStack(is.getItem(), 1, is.getItemDamage())}, null, inI)) { - mMaxProgresstime = 20; - mEfficiencyIncrease = 10000; - float mass = into.getMass(); - float euMult = mass / refMass; - eAmpereFlow = (int) Math.ceil(euMult); - if (mass > refUnstableMass) { - mEUt = (int) -V[9]; - } else { - mEUt = (int) -V[8]; - } - outputEM = new cElementalInstanceStackTree[1]; - outputEM[0] = new cElementalInstanceStackTree(new cElementalInstanceStack(into)); - return true; - } - } - } - } - FluidStack[] inF = getStoredFluids().toArray(new FluidStack[0]); - if (inF.length > 0) { - for (FluidStack fs : inF) { - cElementalDefinitionStack into = fluidBind.get(fs.getFluid().getID()); - if (into != null && fs.amount >= 144 && isInputEqual(true, false, - new FluidStack[]{new FluidStack(fs.getFluid(), 144)}, nothingI, inF, (ItemStack[]) null)) { - mMaxProgresstime = 20; - mEfficiencyIncrease = 10000; - float mass = into.getMass(); - float euMult = mass / refMass; - eAmpereFlow = (int) Math.ceil(euMult); - if (mass > refUnstableMass) { - mEUt = (int) -V[9]; - } else { - mEUt = (int) -V[8]; - } - outputEM = new cElementalInstanceStackTree[1]; - outputEM[0] = new cElementalInstanceStackTree(new cElementalInstanceStack(into)); - return true; - } - } - } - } - mEfficiencyIncrease = 0; - mMaxProgresstime = 0; - return false; - } - - @Override - public void EM_outputFunction() { - if (eOutputHatches.size() < 1) { - stopMachine(); - return; - } - eOutputHatches.get(0).getContainerHandler().putUnifyAll(outputEM[0]); - } - - private static int getID(OrePrefixes prefix, Materials material) { - return OreDictionary.getOreID(prefix.name() + material.name()); - } - - public static void run() { - refMass = getFirstStableIsotope(1).getMass() * 144F; - fluidBind.put(Materials.Hydrogen.mGas.getID(), new cElementalDefinitionStack(getFirstStableIsotope(1), 144)); - fluidBind.put(Materials.Helium.mGas.getID(), new cElementalDefinitionStack(getFirstStableIsotope(2), 144)); - itemBinds.put(getID(OrePrefixes.dust, Materials.Lithium), - new cElementalDefinitionStack(getFirstStableIsotope(3), 144)); - itemBinds.put(getID(OrePrefixes.dust, Materials.Beryllium), - new cElementalDefinitionStack(getFirstStableIsotope(4), 144)); - itemBinds.put(getID(OrePrefixes.dust, Materials.Boron), - new cElementalDefinitionStack(getFirstStableIsotope(5), 144)); - itemBinds.put(getID(OrePrefixes.dust, Materials.Carbon), - new cElementalDefinitionStack(getFirstStableIsotope(6), 144)); - fluidBind.put(Materials.Nitrogen.mGas.getID(), new cElementalDefinitionStack(getFirstStableIsotope(7), 144)); - fluidBind.put(Materials.Oxygen.mGas.getID(), new cElementalDefinitionStack(getFirstStableIsotope(8), 144)); - fluidBind.put(Materials.Fluorine.mGas.getID(), new cElementalDefinitionStack(getFirstStableIsotope(9), 144)); - //fluidBind.put(Materials.Neon.mGas.getID(),new cElementalDefinitionStack(getFirstStableIsotope(10),144)); - itemBinds.put(getID(OrePrefixes.dust, Materials.Sodium), - new cElementalDefinitionStack(getFirstStableIsotope(11), 144)); - itemBinds.put(getID(OrePrefixes.dust, Materials.Magnesium), - new cElementalDefinitionStack(getFirstStableIsotope(12), 144)); - itemBinds.put(getID(OrePrefixes.dust, Materials.Aluminium), - new cElementalDefinitionStack(getFirstStableIsotope(13), 144)); - itemBinds.put(getID(OrePrefixes.dust, Materials.Silicon), - new cElementalDefinitionStack(getFirstStableIsotope(14), 144)); - itemBinds.put(getID(OrePrefixes.dust, Materials.Phosphorus), - new cElementalDefinitionStack(getFirstStableIsotope(15), 144)); - itemBinds.put(getID(OrePrefixes.dust, Materials.Sulfur), - new cElementalDefinitionStack(getFirstStableIsotope(16), 144)); - fluidBind.put(Materials.Chlorine.mFluid.getID(), new cElementalDefinitionStack(getFirstStableIsotope(17), 144)); - fluidBind.put(Materials.Argon.mGas.getID(), new cElementalDefinitionStack(getFirstStableIsotope(18), 144)); - itemBinds.put(getID(OrePrefixes.dust, Materials.Potassium), - new cElementalDefinitionStack(getFirstStableIsotope(19), 144)); - itemBinds.put(getID(OrePrefixes.dust, Materials.Calcium), - new cElementalDefinitionStack(getFirstStableIsotope(20), 144)); - itemBinds.put(getID(OrePrefixes.dust, Materials.Scandium), - new cElementalDefinitionStack(getFirstStableIsotope(21), 144)); - itemBinds.put(getID(OrePrefixes.dust, Materials.Titanium), - new cElementalDefinitionStack(getFirstStableIsotope(22), 144)); - itemBinds.put(getID(OrePrefixes.dust, Materials.Vanadium), - new cElementalDefinitionStack(getFirstStableIsotope(23), 144)); - itemBinds.put(getID(OrePrefixes.dust, Materials.Chrome), - new cElementalDefinitionStack(getFirstStableIsotope(24), 144)); - itemBinds.put(getID(OrePrefixes.dust, Materials.Manganese), - new cElementalDefinitionStack(getFirstStableIsotope(25), 144)); - itemBinds.put(getID(OrePrefixes.dust, Materials.Iron), - new cElementalDefinitionStack(getFirstStableIsotope(26), 144)); - itemBinds.put(getID(OrePrefixes.dust, Materials.IronMagnetic), - new cElementalDefinitionStack(getFirstStableIsotope(26), 144)); - itemBinds.put(getID(OrePrefixes.dust, Materials.Cobalt), - new cElementalDefinitionStack(getFirstStableIsotope(27), 144)); - itemBinds.put(getID(OrePrefixes.dust, Materials.Nickel), - new cElementalDefinitionStack(getFirstStableIsotope(28), 144)); - itemBinds.put(getID(OrePrefixes.dust, Materials.Copper), - new cElementalDefinitionStack(getFirstStableIsotope(29), 144)); - itemBinds.put(getID(OrePrefixes.dust, Materials.Zinc), - new cElementalDefinitionStack(getFirstStableIsotope(30), 144)); - itemBinds.put(getID(OrePrefixes.dust, Materials.Gallium), - new cElementalDefinitionStack(getFirstStableIsotope(31), 144)); - //itemBinds.put(getID(OrePrefixes.dust, Materials.Germanium), - // new cElementalDefinitionStack(getFirstStableIsotope(32),144)); - itemBinds.put(getID(OrePrefixes.dust, Materials.Arsenic), - new cElementalDefinitionStack(getFirstStableIsotope(33), 144)); - //itemBinds.put(getID(OrePrefixes.dust, Materials.Selenium), - // new cElementalDefinitionStack(getFirstStableIsotope(34),144)); - //itemBinds.put(getID(OrePrefixes.dust, Materials.Bromine), - // new cElementalDefinitionStack(getFirstStableIsotope(35),144)); - //itemBinds.put(getID(OrePrefixes.dust, Materials.Krypton), - // new cElementalDefinitionStack(getFirstStableIsotope(36),144)); - itemBinds.put(getID(OrePrefixes.dust, Materials.Rubidium), - new cElementalDefinitionStack(getFirstStableIsotope(37), 144)); - itemBinds.put(getID(OrePrefixes.dust, Materials.Strontium), - new cElementalDefinitionStack(getFirstStableIsotope(38), 144)); - itemBinds.put(getID(OrePrefixes.dust, Materials.Yttrium), - new cElementalDefinitionStack(getFirstStableIsotope(39), 144)); - //itemBinds.put(getID(OrePrefixes.dust, Materials.Zirconium), - // new cElementalDefinitionStack(getFirstStableIsotope(40),144)); - itemBinds.put(getID(OrePrefixes.dust, Materials.Niobium), - new cElementalDefinitionStack(getFirstStableIsotope(41), 144)); - itemBinds.put(getID(OrePrefixes.dust, Materials.Molybdenum), - new cElementalDefinitionStack(getFirstStableIsotope(42), 144)); - //itemBinds.put(getID(OrePrefixes.dust, Materials.Technetium), - // new cElementalDefinitionStack(getFirstStableIsotope(43),144)); - //itemBinds.put(getID(OrePrefixes.dust, Materials.Ruthenium), - // new cElementalDefinitionStack(getFirstStableIsotope(44),144)); - //itemBinds.put(getID(OrePrefixes.dust, Materials.Rhodium), - // new cElementalDefinitionStack(getFirstStableIsotope(45),144)); - itemBinds.put(getID(OrePrefixes.dust, Materials.Palladium), - new cElementalDefinitionStack(getFirstStableIsotope(46), 144)); - itemBinds.put(getID(OrePrefixes.dust, Materials.Silver), - new cElementalDefinitionStack(getFirstStableIsotope(47), 144)); - itemBinds.put(getID(OrePrefixes.dust, Materials.Cadmium), - new cElementalDefinitionStack(getFirstStableIsotope(48), 144)); - itemBinds.put(getID(OrePrefixes.dust, Materials.Indium), - new cElementalDefinitionStack(getFirstStableIsotope(49), 144)); - itemBinds.put(getID(OrePrefixes.dust, Materials.Tin), - new cElementalDefinitionStack(getFirstStableIsotope(50), 144)); - itemBinds.put(getID(OrePrefixes.dust, Materials.Antimony), - new cElementalDefinitionStack(getFirstStableIsotope(51), 144)); - itemBinds.put(getID(OrePrefixes.dust, Materials.Tellurium), - new cElementalDefinitionStack(getFirstStableIsotope(52), 144)); - //itemBinds.put(getID(OrePrefixes.dust, Materials.Iodine), - // new cElementalDefinitionStack(getFirstStableIsotope(53),144)); - //fluidBind.put(Materials.Xenon.mGas.getID(),new cElementalDefinitionStack(getFirstStableIsotope(54),144)); - itemBinds.put(getID(OrePrefixes.dust, Materials.Caesium), - new cElementalDefinitionStack(getFirstStableIsotope(55), 144)); - itemBinds.put(getID(OrePrefixes.dust, Materials.Barium), - new cElementalDefinitionStack(getFirstStableIsotope(56), 144)); - itemBinds.put(getID(OrePrefixes.dust, Materials.Lanthanum), - new cElementalDefinitionStack(getFirstStableIsotope(57), 144)); - itemBinds.put(getID(OrePrefixes.dust, Materials.Cerium), - new cElementalDefinitionStack(getFirstStableIsotope(58), 144)); - itemBinds.put(getID(OrePrefixes.dust, Materials.Praseodymium), - new cElementalDefinitionStack(getFirstStableIsotope(59), 144)); - itemBinds.put(getID(OrePrefixes.dust, Materials.Neodymium), - new cElementalDefinitionStack(getFirstStableIsotope(60), 144)); - itemBinds.put(getID(OrePrefixes.dust, Materials.NeodymiumMagnetic), - new cElementalDefinitionStack(getFirstStableIsotope(60), 144)); - itemBinds.put(getID(OrePrefixes.dust, Materials.Promethium), - new cElementalDefinitionStack(getFirstStableIsotope(61), 144)); - itemBinds.put(getID(OrePrefixes.dust, Materials.Samarium), - new cElementalDefinitionStack(getFirstStableIsotope(62), 144)); - //itemBinds.put(getID(OrePrefixes.dust, Materials.SamariumMagnetic), - // new cElementalDefinitionStack(getFirstStableIsotope(62),144)); - itemBinds.put(getID(OrePrefixes.dust, Materials.Europium), - new cElementalDefinitionStack(getFirstStableIsotope(63), 144)); - itemBinds.put(getID(OrePrefixes.dust, Materials.Gadolinium), - new cElementalDefinitionStack(getFirstStableIsotope(64), 144)); - itemBinds.put(getID(OrePrefixes.dust, Materials.Terbium), - new cElementalDefinitionStack(getFirstStableIsotope(65), 144)); - itemBinds.put(getID(OrePrefixes.dust, Materials.Dysprosium), - new cElementalDefinitionStack(getFirstStableIsotope(66), 144)); - itemBinds.put(getID(OrePrefixes.dust, Materials.Holmium), - new cElementalDefinitionStack(getFirstStableIsotope(67), 144)); - itemBinds.put(getID(OrePrefixes.dust, Materials.Erbium), - new cElementalDefinitionStack(getFirstStableIsotope(68), 144)); - itemBinds.put(getID(OrePrefixes.dust, Materials.Thulium), - new cElementalDefinitionStack(getFirstStableIsotope(69), 144)); - itemBinds.put(getID(OrePrefixes.dust, Materials.Ytterbium), - new cElementalDefinitionStack(getFirstStableIsotope(70), 144)); - itemBinds.put(getID(OrePrefixes.dust, Materials.Lutetium), - new cElementalDefinitionStack(getFirstStableIsotope(71), 144)); - //itemBinds.put(getID(OrePrefixes.dust, Materials.Hafnum), - // new cElementalDefinitionStack(getFirstStableIsotope(72),144)); - itemBinds.put(getID(OrePrefixes.dust, Materials.Tantalum), - new cElementalDefinitionStack(getFirstStableIsotope(73), 144)); - itemBinds.put(getID(OrePrefixes.dust, Materials.Tungsten), - new cElementalDefinitionStack(getFirstStableIsotope(74), 144)); - //itemBinds.put(getID(OrePrefixes.dust, Materials.Rhenium), - // new cElementalDefinitionStack(getFirstStableIsotope(75),144)); - itemBinds.put(getID(OrePrefixes.dust, Materials.Osmium), - new cElementalDefinitionStack(getFirstStableIsotope(76), 144)); - itemBinds.put(getID(OrePrefixes.dust, Materials.Iridium), - new cElementalDefinitionStack(getFirstStableIsotope(77), 144)); - itemBinds.put(getID(OrePrefixes.dust, Materials.Platinum), - new cElementalDefinitionStack(getFirstStableIsotope(78), 144)); - itemBinds.put(getID(OrePrefixes.dust, Materials.Gold), - new cElementalDefinitionStack(getFirstStableIsotope(79), 144)); - fluidBind.put(Materials.Mercury.mFluid.getID(), new cElementalDefinitionStack(getFirstStableIsotope(80), 144)); - //itemBinds.put(getID(OrePrefixes.dust, Materials.Thalium), - // new cElementalDefinitionStack(getFirstStableIsotope(81),144)); - itemBinds.put(getID(OrePrefixes.dust, Materials.Lead), - new cElementalDefinitionStack(getFirstStableIsotope(82), 144)); - itemBinds.put(getID(OrePrefixes.dust, Materials.Bismuth), - new cElementalDefinitionStack(getFirstStableIsotope(83), 144)); - //UNSTABLE ATOMS - refUnstableMass = getFirstStableIsotope(83).getMass() * 144F; - //itemBinds.put(getID(OrePrefixes.dust, Materials.Polonium), - // new cElementalDefinitionStack(getBestUnstableIsotope(84),144)); - //fluidBind.put(Materials.Astatine.mPlasma.getID(),new cElementalDefinitionStack(getBestUnstableIsotope(85),144)); - fluidBind.put(Materials.Radon.mGas.getID(), new cElementalDefinitionStack(getBestUnstableIsotope(86), 144)); - //itemBinds.put(getID(OrePrefixes.dust, Materials.Francium), - // new cElementalDefinitionStack(getBestUnstableIsotope(87),144)); - //itemBinds.put(getID(OrePrefixes.dust, Materials.Radium), - // new cElementalDefinitionStack(getBestUnstableIsotope(88),144)); - //itemBinds.put(getID(OrePrefixes.dust, Materials.Actinium), - // new cElementalDefinitionStack(getBestUnstableIsotope(89),144)); - itemBinds.put(getID(OrePrefixes.dust, Materials.Thorium), - new cElementalDefinitionStack(getBestUnstableIsotope(90), 144)); - //itemBinds.put(getID(OrePrefixes.dust, Materials.Protactinium), - // new cElementalDefinitionStack(getBestUnstableIsotope(91),144)); - itemBinds.put(getID(OrePrefixes.dust, Materials.Uranium), - new cElementalDefinitionStack(getBestUnstableIsotope(92), 144)); - //itemBinds.put(getID(OrePrefixes.dust, Materials.Neptunium), - // new cElementalDefinitionStack(getBestUnstableIsotope(93),144)); - itemBinds.put(getID(OrePrefixes.dust, Materials.Plutonium), - new cElementalDefinitionStack(getBestUnstableIsotope(94), 144)); - itemBinds.put(getID(OrePrefixes.dust, Materials.Americium), - new cElementalDefinitionStack(getBestUnstableIsotope(95), 144)); - /* ... */ - itemBinds.put(getID(OrePrefixes.ingotHot, Materials.Neutronium), - new cElementalDefinitionStack(dHadronDefinition.hadron_n, 100000)); - - try { - fluidBind.put(Materials.Deuterium.mGas.getID(), new cElementalDefinitionStack( - new dAtomDefinition( - eLeptonDefinition.lepton_e1, - dHadronDefinition.hadron_p1, - dHadronDefinition.hadron_n1 - ), 144)); - fluidBind.put(Materials.Tritium.mGas.getID(), new cElementalDefinitionStack( - new dAtomDefinition( - eLeptonDefinition.lepton_e1, - dHadronDefinition.hadron_p1, - dHadronDefinition.hadron_n2 - ), 144)); - fluidBind.put(Materials.Helium_3.mGas.getID(), new cElementalDefinitionStack( - new dAtomDefinition( - new cElementalDefinitionStack(eLeptonDefinition.lepton_e, 2), - dHadronDefinition.hadron_p2, - new cElementalDefinitionStack(dHadronDefinition.hadron_n, 3) - ), 144)); - itemBinds.put(getID(OrePrefixes.dust, Materials.Uranium235), - new cElementalDefinitionStack(new dAtomDefinition( - new cElementalDefinitionStack(eLeptonDefinition.lepton_e, 92), - new cElementalDefinitionStack(dHadronDefinition.hadron_p, 92), - new cElementalDefinitionStack(dHadronDefinition.hadron_n, 143) - ), 144)); - itemBinds.put(getID(OrePrefixes.dust, Materials.Plutonium241), - new cElementalDefinitionStack(new dAtomDefinition( - new cElementalDefinitionStack(eLeptonDefinition.lepton_e, 94), - new cElementalDefinitionStack(dHadronDefinition.hadron_p, 94), - new cElementalDefinitionStack(dHadronDefinition.hadron_n, 149) - ), 144)); - } catch (tElementalException e) { - if (TecTech.ModConfig.DEBUG_MODE) e.printStackTrace(); - } - } -} diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_quantizer.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_quantizer.java new file mode 100644 index 0000000000..15535e8a20 --- /dev/null +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_quantizer.java @@ -0,0 +1,389 @@ +package com.github.technus.tectech.thing.metaTileEntity.multi; + +import com.github.technus.tectech.TecTech; +import com.github.technus.tectech.elementalMatter.classes.cElementalDefinitionStack; +import com.github.technus.tectech.elementalMatter.classes.cElementalInstanceStack; +import com.github.technus.tectech.elementalMatter.classes.cElementalInstanceStackTree; +import com.github.technus.tectech.elementalMatter.classes.tElementalException; +import com.github.technus.tectech.elementalMatter.commonValues; +import com.github.technus.tectech.elementalMatter.definitions.dAtomDefinition; +import com.github.technus.tectech.elementalMatter.definitions.dHadronDefinition; +import com.github.technus.tectech.elementalMatter.definitions.eLeptonDefinition; +import com.github.technus.tectech.thing.block.QuantumGlass; +import com.github.technus.tectech.thing.casing.GT_Container_CasingsTT; +import com.github.technus.tectech.thing.metaTileEntity.GT_MetaTileEntity_MultiblockBase_EM; +import gregtech.api.GregTech_API; +import gregtech.api.enums.Materials; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumChatFormatting; +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.oredict.OreDictionary; + +import java.util.HashMap; + +import static com.github.technus.tectech.elementalMatter.definitions.dAtomDefinition.getBestUnstableIsotope; +import static com.github.technus.tectech.elementalMatter.definitions.dAtomDefinition.getFirstStableIsotope; +import static gregtech.api.enums.GT_Values.V; + +/** + * Created by danie_000 on 17.12.2016. + */ +public class GT_MetaTileEntity_EM_quantizer extends GT_MetaTileEntity_MultiblockBase_EM { + public static HashMap itemBinds = new HashMap<>(32); + public static HashMap fluidBind = new HashMap<>(8); + private static float refMass, refUnstableMass; + + public GT_MetaTileEntity_EM_quantizer(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public GT_MetaTileEntity_EM_quantizer(String aName) { + super(aName); + } + + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GT_MetaTileEntity_EM_quantizer(this.mName); + } + + @Override + public boolean checkMachine(IGregTechTileEntity iGregTechTileEntity, ItemStack itemStack) { + int xDir = ForgeDirection.getOrientation(iGregTechTileEntity.getBackFacing()).offsetX; + int yDir = ForgeDirection.getOrientation(iGregTechTileEntity.getBackFacing()).offsetY; + int zDir = ForgeDirection.getOrientation(iGregTechTileEntity.getBackFacing()).offsetZ; + if (iGregTechTileEntity.getBlockOffset(xDir, yDir, zDir) != QuantumGlass.INSTANCE) return false; + for (int i = -1; i < 2; i++) { + for (int j = -1; j < 2; j++) { + for (int h = -1; h < 2; h++) { + if ((i != 0 || j != 0 || h != 0)/*exclude center*/ && (xDir + i != 0 || yDir + h != 0 || zDir + j != 0)/*exclude this*/) { + IGregTechTileEntity tTileEntity = iGregTechTileEntity.getIGregTechTileEntityOffset(xDir + i, yDir + h, zDir + j); + if ((!addMaintenanceToMachineList(tTileEntity, 99)) && + (!addClassicInputToMachineList(tTileEntity, 99)) && + (!addElementalOutputToMachineList(tTileEntity, 99)) && + (!addMufflerToMachineList(tTileEntity, 99)) && + (!addEnergyIOToMachineList(tTileEntity, 99))) { + if (iGregTechTileEntity.getBlockOffset(xDir + i, yDir + h, zDir + j) != GT_Container_CasingsTT.sBlockCasingsTT || + iGregTechTileEntity.getMetaIDOffset(xDir + i, yDir + h, zDir + j) != 3) { + return false; + } + } + } + } + } + } + return true; + } + + @Override + public String[] getDescription() { + return new String[]{ + commonValues.tecMark, + "Conveniently convert regular stuff into quantum form.", + EnumChatFormatting.AQUA.toString() + EnumChatFormatting.BOLD + "To make it more inconvenient." + }; + } + + @Override + public boolean EM_checkRecipe(ItemStack itemStack) { + if (GregTech_API.sPostloadFinished) { + ItemStack[] inI = getStoredInputs().toArray(new ItemStack[0]); + if (inI.length > 0) { + for (ItemStack is : inI) { + int[] oreIDs = OreDictionary.getOreIDs(is); + if (TecTech.ModConfig.DEBUG_MODE) + TecTech.Logger.info("Quantifier-recipe " + is.getItem().getUnlocalizedName() + "." + is.getItemDamage() + " " + is.getDisplayName()); + for (int ID : oreIDs) { + if (TecTech.ModConfig.DEBUG_MODE) + TecTech.Logger.info("Quantifier-recipe " + is.getItem().getUnlocalizedName() + "." + is.getItemDamage() + " " + OreDictionary.getOreName(ID)); + cElementalDefinitionStack into = itemBinds.get(ID); + if (into != null && isInputEqual(true, false, + nothingF, new ItemStack[]{new ItemStack(is.getItem(), 1, is.getItemDamage())}, null, inI)) { + mMaxProgresstime = 20; + mEfficiencyIncrease = 10000; + float mass = into.getMass(); + float euMult = mass / refMass; + eAmpereFlow = (int) Math.ceil(euMult); + if (mass > refUnstableMass) { + mEUt = (int) -V[9]; + } else { + mEUt = (int) -V[8]; + } + outputEM = new cElementalInstanceStackTree[1]; + outputEM[0] = new cElementalInstanceStackTree(new cElementalInstanceStack(into)); + return true; + } + } + } + } + FluidStack[] inF = getStoredFluids().toArray(new FluidStack[0]); + if (inF.length > 0) { + for (FluidStack fs : inF) { + cElementalDefinitionStack into = fluidBind.get(fs.getFluid().getID()); + if (into != null && fs.amount >= 144 && isInputEqual(true, false, + new FluidStack[]{new FluidStack(fs.getFluid(), 144)}, nothingI, inF, (ItemStack[]) null)) { + mMaxProgresstime = 20; + mEfficiencyIncrease = 10000; + float mass = into.getMass(); + float euMult = mass / refMass; + eAmpereFlow = (int) Math.ceil(euMult); + if (mass > refUnstableMass) { + mEUt = (int) -V[9]; + } else { + mEUt = (int) -V[8]; + } + outputEM = new cElementalInstanceStackTree[1]; + outputEM[0] = new cElementalInstanceStackTree(new cElementalInstanceStack(into)); + return true; + } + } + } + } + mEfficiencyIncrease = 0; + mMaxProgresstime = 0; + return false; + } + + @Override + public void EM_outputFunction() { + if (eOutputHatches.size() < 1) { + stopMachine(); + return; + } + eOutputHatches.get(0).getContainerHandler().putUnifyAll(outputEM[0]); + } + + private static int getID(OrePrefixes prefix, Materials material) { + return OreDictionary.getOreID(prefix.name() + material.name()); + } + + public static void run() { + refMass = getFirstStableIsotope(1).getMass() * 144F; + fluidBind.put(Materials.Hydrogen.mGas.getID(), new cElementalDefinitionStack(getFirstStableIsotope(1), 144)); + fluidBind.put(Materials.Helium.mGas.getID(), new cElementalDefinitionStack(getFirstStableIsotope(2), 144)); + itemBinds.put(getID(OrePrefixes.dust, Materials.Lithium), + new cElementalDefinitionStack(getFirstStableIsotope(3), 144)); + itemBinds.put(getID(OrePrefixes.dust, Materials.Beryllium), + new cElementalDefinitionStack(getFirstStableIsotope(4), 144)); + itemBinds.put(getID(OrePrefixes.dust, Materials.Boron), +