diff options
author | Technus <daniel112092@gmail.com> | 2017-12-17 09:49:11 +0100 |
---|---|---|
committer | Technus <daniel112092@gmail.com> | 2017-12-17 09:49:11 +0100 |
commit | ddd327e6b10b03cf701f508c52559220b2d64f3e (patch) | |
tree | f486b2411d3137707736dff565fda85360ac3a3b /src/main | |
parent | d248a9c9b8430f1be34d69e3bb3ca2392fbb3e29 (diff) | |
download | GT5-Unofficial-ddd327e6b10b03cf701f508c52559220b2d64f3e.tar.gz GT5-Unofficial-ddd327e6b10b03cf701f508c52559220b2d64f3e.tar.bz2 GT5-Unofficial-ddd327e6b10b03cf701f508c52559220b2d64f3e.zip |
Scanning of elemental matter works.
Diffstat (limited to 'src/main')
7 files changed, 161 insertions, 29 deletions
diff --git a/src/main/java/com/github/technus/tectech/elementalMatter/core/cElementalInstanceStackMap.java b/src/main/java/com/github/technus/tectech/elementalMatter/core/cElementalInstanceStackMap.java index ee8a81dbd1..40bf975a17 100644 --- a/src/main/java/com/github/technus/tectech/elementalMatter/core/cElementalInstanceStackMap.java +++ b/src/main/java/com/github/technus/tectech/elementalMatter/core/cElementalInstanceStackMap.java @@ -453,6 +453,12 @@ public final class cElementalInstanceStackMap implements Comparable<cElementalIn return build.toString(); } + public cElementalInstanceStackMap takeAll(){ + TreeMap<iElementalDefinition, cElementalInstanceStack> map=this.map; + this.map=new TreeMap<>(); + return new cElementalInstanceStackMap(map); + } + public void cleanUp(){ for(Map.Entry<iElementalDefinition, cElementalInstanceStack> entry:map.entrySet()){ if(entry.getValue().amount<=0) map.remove(entry.getKey()); diff --git a/src/main/java/com/github/technus/tectech/elementalMatter/core/stacks/cElementalInstanceStack.java b/src/main/java/com/github/technus/tectech/elementalMatter/core/stacks/cElementalInstanceStack.java index e9de353597..3c5e94121b 100644 --- a/src/main/java/com/github/technus/tectech/elementalMatter/core/stacks/cElementalInstanceStack.java +++ b/src/main/java/com/github/technus/tectech/elementalMatter/core/stacks/cElementalInstanceStack.java @@ -323,7 +323,7 @@ public final class cElementalInstanceStack implements iHasElementalDefinition { lines.add("ENERGY LEVEL = "+energy); if(Util.areBitsSet(SCAN_GET_AMOUNT,capabilities)) lines.add("AMOUNT = "+amount); - lines.add(null);//def separator + lines.add("");//def separator scanContents(lines,definition.getSubParticles(),1,detailsOnDepthLevels); } @@ -336,7 +336,7 @@ public final class cElementalInstanceStack implements iHasElementalDefinition { definition.addScanResults(lines,detailsOnDepthLevels[depth],energy); if(Util.areBitsSet(SCAN_GET_AMOUNT,detailsOnDepthLevels[depth])) lines.add("AMOUNT = "+definitionStack.amount); - lines.add(null);//def separator + lines.add("");//def separator scanContents(lines,definitionStack.definition.getSubParticles(),deeper,detailsOnDepthLevels); } } diff --git a/src/main/java/com/github/technus/tectech/elementalMatter/definitions/complex/atom/dAtomDefinition.java b/src/main/java/com/github/technus/tectech/elementalMatter/definitions/complex/atom/dAtomDefinition.java index 75aabe9af3..bfb024ef50 100644 --- a/src/main/java/com/github/technus/tectech/elementalMatter/definitions/complex/atom/dAtomDefinition.java +++ b/src/main/java/com/github/technus/tectech/elementalMatter/definitions/complex/atom/dAtomDefinition.java @@ -1431,7 +1431,7 @@ public final class dAtomDefinition extends cElementalDefinition { lines.add(getColor()<0?"NOT COLORED":"CARRIES COLOR"); if(Util.areBitsSet(SCAN_GET_MASS,capabilities)) lines.add("MASS = "+getMass()+" eV/c\u00b2"); - if(iaeaDefinitionExistsAndHasEnergyLevels){ + if(iaeaDefinitionExistsAndHasEnergyLevels && Util.areBitsSet(SCAN_GET_ENERGY_STATES,capabilities)){ for(int i=1;i<iaea.energeticStatesArray.length;i++){ lines.add("ENERGY LEVEL "+i+" = "+iaea.energeticStatesArray[i].energy+" eV"); } 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 f9a4f6028a..c474eb4d5c 100644 --- a/src/main/java/com/github/technus/tectech/thing/CustomItemList.java +++ b/src/main/java/com/github/technus/tectech/thing/CustomItemList.java @@ -50,7 +50,9 @@ public enum CustomItemList implements IItemContainer { Machine_Multi_Stabilizer, Machine_Multi_EMCrafter, Machine_Multi_Wormhole, Machine_Multi_Annihilation, Machine_Multi_BHG, - hint_0,hint_1,hint_2,hint_3,hint_4,hint_5,hint_6,hint_7,hint_8,hint_9,hint_10,hint_11, hint_general,hint_air,hint_noAir,hint_error; + hint_0,hint_1,hint_2,hint_3,hint_4,hint_5,hint_6,hint_7,hint_8,hint_9,hint_10,hint_11, hint_general,hint_air,hint_noAir,hint_error, + + scanContainer,parametrizerMemory; private ItemStack mStack = null; diff --git a/src/main/java/com/github/technus/tectech/thing/item/ElementalDefinitionScanStorage_EM.java b/src/main/java/com/github/technus/tectech/thing/item/ElementalDefinitionScanStorage_EM.java index b650e4a564..a64a639c11 100644 --- a/src/main/java/com/github/technus/tectech/thing/item/ElementalDefinitionScanStorage_EM.java +++ b/src/main/java/com/github/technus/tectech/thing/item/ElementalDefinitionScanStorage_EM.java @@ -1,8 +1,10 @@ package com.github.technus.tectech.thing.item; import com.github.technus.tectech.CommonValues; +import com.github.technus.tectech.TecTech; import com.github.technus.tectech.Util; import com.github.technus.tectech.elementalMatter.core.cElementalInstanceStackMap; +import com.github.technus.tectech.thing.CustomItemList; import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; @@ -57,8 +59,10 @@ public class ElementalDefinitionScanStorage_EM extends Item { try { if (aStack.stackTagCompound != null && aStack.stackTagCompound.hasKey("elementalInfo")) { aList.add("Contains scan result"); - if(DEBUG_MODE) + if(DEBUG_MODE) { + aList.add("DEBUG MODE INFO - U CHEATER"); Collections.addAll(aList, Util.infoFromNBT(aStack.stackTagCompound.getCompoundTag("elementalInfo"))); + } } else { aList.add("Storage for matter scan data"); } @@ -70,6 +74,7 @@ public class ElementalDefinitionScanStorage_EM extends Item { public static void run() { INSTANCE = new ElementalDefinitionScanStorage_EM(); GameRegistry.registerItem(INSTANCE, INSTANCE.getUnlocalizedName()); + CustomItemList.scanContainer.set(INSTANCE); } @Override diff --git a/src/main/java/com/github/technus/tectech/thing/item/ParametrizerMemoryCard.java b/src/main/java/com/github/technus/tectech/thing/item/ParametrizerMemoryCard.java index ce6d23ddbd..003720de76 100644 --- a/src/main/java/com/github/technus/tectech/thing/item/ParametrizerMemoryCard.java +++ b/src/main/java/com/github/technus/tectech/thing/item/ParametrizerMemoryCard.java @@ -23,6 +23,7 @@ import net.minecraft.world.World; import java.util.List; import static com.github.technus.tectech.auxiliary.Reference.MODID; +import static com.github.technus.tectech.thing.CustomItemList.parametrizerMemory; /** * Created by Tec on 15.03.2017. @@ -120,6 +121,7 @@ public class ParametrizerMemoryCard extends Item { public static void run() { INSTANCE = new ParametrizerMemoryCard(); GameRegistry.registerItem(INSTANCE, INSTANCE.getUnlocalizedName()); + parametrizerMemory.set(INSTANCE); } @Override diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_scanner.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_scanner.java index e92753a897..ee93b7df98 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_scanner.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_scanner.java @@ -1,12 +1,17 @@ package com.github.technus.tectech.thing.metaTileEntity.multi; import com.github.technus.tectech.CommonValues; +import com.github.technus.tectech.TecTech; +import com.github.technus.tectech.Util; import com.github.technus.tectech.elementalMatter.core.cElementalInstanceStackMap; import com.github.technus.tectech.elementalMatter.core.stacks.cElementalDefinitionStack; import com.github.technus.tectech.elementalMatter.core.stacks.cElementalInstanceStack; +import com.github.technus.tectech.elementalMatter.core.tElementalException; import com.github.technus.tectech.recipe.TT_recipe; +import com.github.technus.tectech.thing.CustomItemList; import com.github.technus.tectech.thing.block.QuantumGlassBlock; import com.github.technus.tectech.thing.block.QuantumStuffBlock; +import com.github.technus.tectech.thing.item.ElementalDefinitionScanStorage_EM; import com.github.technus.tectech.thing.metaTileEntity.IConstructable; import com.github.technus.tectech.thing.metaTileEntity.hatch.GT_MetaTileEntity_Hatch_EnergyMulti; import com.github.technus.tectech.thing.metaTileEntity.multi.base.GT_MetaTileEntity_MultiblockBase_EM; @@ -25,7 +30,9 @@ import net.minecraft.util.EnumChatFormatting; import net.minecraftforge.common.util.ForgeDirection; import static com.github.technus.tectech.Util.StructureBuilder; +import static com.github.technus.tectech.Util.V; import static com.github.technus.tectech.Util.VN; +import static com.github.technus.tectech.auxiliary.TecTechConfig.DEBUG_MODE; import static com.github.technus.tectech.elementalMatter.definitions.primitive.cPrimitiveDefinition.nbtE__; import static com.github.technus.tectech.recipe.TT_recipe.E_RECIPE_ID; import static com.github.technus.tectech.thing.casing.GT_Block_CasingsTT.textureOffset; @@ -38,14 +45,16 @@ import static com.github.technus.tectech.thing.metaTileEntity.multi.GT_MetaTileE */ public class GT_MetaTileEntity_EM_scanner extends GT_MetaTileEntity_MultiblockBase_EM implements IConstructable { public static final int SCAN_DO_NOTHING=0, - SCAN_GET_MASS=1, SCAN_GET_CHARGE=2, SCAN_GET_CLASS_TYPE=4, SCAN_GET_NOMENCLATURE=8, SCAN_GET_TIMESPAN_INFO=16, - SCAN_GET_AMOUNT=256, SCAN_GET_COLOR=512, SCAN_GET_ENERGY_LEVEL=1024, SCAN_GET_AGE=2048, SCAN_GET_TIMESPAN_MULT =4096, - SCAN_GET_DEPTH_LEVEL= 8192, SCAN_GET_ENERGY_STATES=16384; + SCAN_GET_NOMENCLATURE=1,SCAN_GET_DEPTH_LEVEL=2,SCAN_GET_AMOUNT=4,SCAN_GET_CHARGE=8, + SCAN_GET_MASS=16,SCAN_GET_ENERGY_LEVEL=32,SCAN_GET_TIMESPAN_INFO=64,SCAN_GET_ENERGY_STATES=128, + SCAN_GET_COLOR=256,SCAN_GET_AGE=512,SCAN_GET_TIMESPAN_MULT=1024,SCAN_GET_CLASS_TYPE=2048; private TT_recipe.TT_EMRecipe.TT_EMRecipe eRecipe; private cElementalDefinitionStack objectResearched; + private cElementalInstanceStackMap objectsScanned; private String machineType; - private long computationRemaining,computationRequired; + private long totalComputationRemaining, totalComputationRequired; + private int[] scanComplexity; //region structure private static final String[][] shape = new String[][]{ @@ -120,22 +129,33 @@ public class GT_MetaTileEntity_EM_scanner extends GT_MetaTileEntity_MultiblockBa @Override public void saveNBTData(NBTTagCompound aNBT) { super.saveNBTData(aNBT); - aNBT.setLong("eComputationRemaining",computationRemaining); - aNBT.setLong("eComputationRequired",computationRequired); + aNBT.setLong("eComputationRemaining", totalComputationRemaining); + aNBT.setLong("eComputationRequired", totalComputationRequired); if(objectResearched!=null) aNBT.setTag("eObject",objectResearched.toNBT()); else aNBT.removeTag("eObject"); + if(scanComplexity!=null) aNBT.setIntArray("eScanComplexity",scanComplexity); + else aNBT.removeTag("eScanComplexity"); + if(objectsScanned!=null) aNBT.setTag("eScanObjects",objectsScanned.toNBT()); + else aNBT.removeTag("eScanObjects"); } @Override public void loadNBTData(NBTTagCompound aNBT) { super.loadNBTData(aNBT); - computationRemaining=aNBT.getLong("eComputationRemaining"); - computationRequired=aNBT.getLong("eComputationRequired"); + totalComputationRemaining =aNBT.getLong("eComputationRemaining"); + totalComputationRequired =aNBT.getLong("eComputationRequired"); if(aNBT.hasKey("eObject")) { objectResearched = cElementalDefinitionStack.fromNBT(aNBT.getCompoundTag("eObject")); if(objectResearched.definition==nbtE__) objectResearched=null; }else objectResearched=null; + if(aNBT.hasKey("eScanComplexity")) scanComplexity=aNBT.getIntArray("eScanComplexity"); + else scanComplexity=null; + try { + if (aNBT.hasKey("eScanObjects")) objectsScanned = cElementalInstanceStackMap.fromNBT(aNBT.getCompoundTag("eScanObjects")); + }catch (tElementalException e){ + objectsScanned=new cElementalInstanceStackMap(); + } } @Override @@ -151,7 +171,7 @@ public class GT_MetaTileEntity_EM_scanner extends GT_MetaTileEntity_MultiblockBa @Override public void onFirstTick(IGregTechTileEntity aBaseMetaTileEntity) { if(aBaseMetaTileEntity.isServerSide()) { - if (computationRemaining > 0) { + if (totalComputationRemaining > 0) { eRecipe = null; if (objectResearched != null) { if (ItemList.Tool_DataOrb.isStackEqual(mInventory[1], false, true)) { @@ -169,7 +189,8 @@ public class GT_MetaTileEntity_EM_scanner extends GT_MetaTileEntity_MultiblockBa if (eRecipe == null) { quantumStuff(false); objectResearched = null; - computationRequired = computationRemaining = 0; + eRequiredData=0; + totalComputationRequired = totalComputationRemaining = 0; mMaxProgresstime = 0; mEfficiencyIncrease = 0; } else quantumStuff(true); @@ -185,6 +206,7 @@ public class GT_MetaTileEntity_EM_scanner extends GT_MetaTileEntity_MultiblockBa if(ItemList.Tool_DataOrb.isStackEqual(itemStack, false, true)) { GT_Recipe scannerRecipe=null; for(cElementalInstanceStack stackEM:researchEM.values()){ + objectsScanned=null; eRecipe = TT_recipe.TT_Recipe_Map_EM.sMachineRecipesEM.findRecipe(stackEM.definition); if(eRecipe!=null) { scannerRecipe=eRecipe.scannerRecipe; @@ -207,8 +229,8 @@ public class GT_MetaTileEntity_EM_scanner extends GT_MetaTileEntity_MultiblockBa researchEM.remove(stackEM.definition); } if(eRecipe!=null && scannerRecipe!=null){//make sure it werks - computationRequired = computationRemaining = scannerRecipe.mDuration * 20L; - mMaxProgresstime = 20; + totalComputationRequired = totalComputationRemaining = scannerRecipe.mDuration * 20L; + mMaxProgresstime = 20;//const mEfficiencyIncrease = 10000; eRequiredData = (short) (scannerRecipe.mSpecialValue >>> 16); eAmpereFlow = (short) (scannerRecipe.mSpecialValue & 0xFFFF); @@ -216,26 +238,119 @@ public class GT_MetaTileEntity_EM_scanner extends GT_MetaTileEntity_MultiblockBa quantumStuff(true); return true; } - }//else{ - //todo implement molecular in depth info scan - //} + }else if(CustomItemList.scanContainer.isStackEqual(itemStack, false, true)) { + eRecipe=null; + if(researchEM.hasStacks()) { + objectsScanned = researchEM.takeAll(); + cleanMassEM_EM(objectsScanned.getMass()); + + totalComputationRequired =0; + eRequiredData=0; + eAmpereFlow=objectsScanned.size() + TecTech.Rnd.next(objectsScanned.size()); + mEUt=-(int)V[8]; + + //get depth scan complexity array + { + int[] scanComplexityTemp = new int[20]; + for (int i = 0; i < 10; i++) { + scanComplexityTemp[i] = getParameterInInt(i, 0); + scanComplexityTemp[i + 10] = getParameterInInt(i, 1); + } + int maxDepth = 0; + for (int i = 0; i < 20; i++) { + if (scanComplexityTemp[i] == SCAN_DO_NOTHING) continue; + else { + maxDepth = i; + if(!DEBUG_MODE) scanComplexityTemp[i]&=~SCAN_GET_CLASS_TYPE; + addComputationRequirements(i+1,scanComplexityTemp[i]); + } + } + maxDepth+=1;//from index to len + scanComplexity = new int[maxDepth]; + System.arraycopy(scanComplexityTemp,0,scanComplexity,0,maxDepth); + } + + totalComputationRemaining = totalComputationRequired; + mMaxProgresstime = 20;//const + mEfficiencyIncrease = 10000; + quantumStuff(true); + return true; + } + } } quantumStuff(false); objectResearched=null; - computationRequired=computationRemaining=0; + totalComputationRemaining =0; mMaxProgresstime=0; mEfficiencyIncrease = 0; return false; } + private void addComputationRequirements(int depthPlus, int capabilities){ + if(Util.areBitsSet(SCAN_GET_NOMENCLATURE,capabilities)){ + totalComputationRequired +=depthPlus*5; + eRequiredData+=depthPlus; + } + if(Util.areBitsSet(SCAN_GET_DEPTH_LEVEL,capabilities)){ + totalComputationRequired +=depthPlus*10; + eRequiredData+=depthPlus; + + } + if(Util.areBitsSet(SCAN_GET_AMOUNT,capabilities)){ + totalComputationRequired +=depthPlus*64; + eRequiredData+=depthPlus*8; + + } + if(Util.areBitsSet(SCAN_GET_CHARGE,capabilities)){ + totalComputationRequired +=depthPlus*128; + eRequiredData+=depthPlus*4; + + } + if(Util.areBitsSet(SCAN_GET_MASS,capabilities)){ + totalComputationRequired +=depthPlus*256; + eRequiredData+=depthPlus*4; + + } + if(Util.areBitsSet(SCAN_GET_ENERGY_LEVEL,capabilities)){ + totalComputationRequired +=depthPlus*512; + eRequiredData+=depthPlus*16; + + } + if(Util.areBitsSet(SCAN_GET_TIMESPAN_INFO,capabilities)){ + totalComputationRequired +=depthPlus*1024; + eRequiredData+=depthPlus*32; + + } + if(Util.areBitsSet(SCAN_GET_ENERGY_STATES,capabilities)){ + totalComputationRequired +=depthPlus*2048; + eRequiredData+=depthPlus*32; + + } + if(Util.areBitsSet(SCAN_GET_COLOR,capabilities)){ + totalComputationRequired +=depthPlus*1024; + eRequiredData+=depthPlus*48; + + } + if(Util.areBitsSet(SCAN_GET_AGE,capabilities)){ + totalComputationRequired +=depthPlus*2048; + eRequiredData+=depthPlus*64; + + } + if(Util.areBitsSet(SCAN_GET_TIMESPAN_MULT,capabilities)){ + totalComputationRequired +=depthPlus*2048; + eRequiredData+=depthPlus*64; + + } + } + @Override public boolean onRunningTick(ItemStack aStack) { - if(computationRemaining<=0) { - computationRemaining=0; + if(totalComputationRemaining <=0) { + totalComputationRemaining =0; mProgresstime=mMaxProgresstime; return true; }else{ - computationRemaining-=eAvailableData; + totalComputationRemaining -=eAvailableData; mProgresstime=1; return super.onRunningTick(aStack); } @@ -251,10 +366,12 @@ public class GT_MetaTileEntity_EM_scanner extends GT_MetaTileEntity_MultiblockBa tNBT.setString("eMachineType", machineType); tNBT.setTag(E_RECIPE_ID, objectResearched.toNBT()); tNBT.setString("author", EnumChatFormatting.BLUE + "Tec" + EnumChatFormatting.DARK_BLUE + "Tech" + EnumChatFormatting.WHITE + ' ' + machineType+ " EM Recipe Generator"); + }else if(objectsScanned!=null && CustomItemList.scanContainer.isStackEqual(mInventory[1], false, true)){ + ElementalDefinitionScanStorage_EM.setContent(mInventory[1],objectsScanned,scanComplexity); } quantumStuff(false); objectResearched=null; - computationRequired=computationRemaining=0; + totalComputationRemaining =0; } @Override @@ -292,10 +409,10 @@ public class GT_MetaTileEntity_EM_scanner extends GT_MetaTileEntity_MultiblockBa " Efficiency: " + EnumChatFormatting.YELLOW + Float.toString(mEfficiency / 100.0F) + EnumChatFormatting.RESET + " %", "PowerPass: " + EnumChatFormatting.BLUE + ePowerPass + EnumChatFormatting.RESET + " SafeVoid: " + EnumChatFormatting.BLUE + eSafeVoid, - "Computation Available: " + EnumChatFormatting.GREEN + eAvailableData + EnumChatFormatting.RESET, + "Computation Available: " + EnumChatFormatting.GREEN + eAvailableData +EnumChatFormatting.RESET+" / "+EnumChatFormatting.YELLOW + eRequiredData + EnumChatFormatting.RESET, "Computation Remaining:", - EnumChatFormatting.GREEN + Long.toString(computationRemaining / 20L) + EnumChatFormatting.RESET + " / " + - EnumChatFormatting.YELLOW + Long.toString(computationRequired / 20L) + EnumChatFormatting.GREEN + Long.toString(totalComputationRemaining / 20L) + EnumChatFormatting.RESET + " / " + + EnumChatFormatting.YELLOW + Long.toString(totalComputationRequired / 20L) }; } @@ -308,7 +425,7 @@ public class GT_MetaTileEntity_EM_scanner extends GT_MetaTileEntity_MultiblockBa @Override public void stopMachine() { super.stopMachine(); - computationRequired=computationRemaining=0; + totalComputationRequired = totalComputationRemaining =0; objectResearched=null; quantumStuff(false); |