From f80d0e3467231d67d3da303ca2c1385996febb2a Mon Sep 17 00:00:00 2001 From: Technus Date: Thu, 14 Dec 2017 21:21:18 +0100 Subject: first draft of scanning of em data extraction --- src/main/java/com/github/technus/tectech/Util.java | 12 +++ .../definitions/dComplexAspectDefinition.java | 28 +++++ .../core/cElementalInstanceStackMap.java | 21 +++- .../elementalMatter/core/cElementalStackMap.java | 7 -- .../core/containers/cElementalInstanceStack.java | 44 +++++++- .../core/interfaces/iElementalDefinition.java | 4 + .../core/templates/cElementalDefinition.java | 5 + .../core/templates/cElementalPrimitive.java | 25 +++++ .../definitions/complex/dAtomDefinition.java | 45 ++++++-- .../definitions/complex/dHadronDefinition.java | 55 +++++++--- .../github/technus/tectech/loader/MainLoader.java | 6 +- .../technus/tectech/loader/ThingsLoader.java | 12 +-- .../technus/tectech/recipe/TT_recipeAdder.java | 10 +- .../tectech/thing/item/DebugContainer_EM.java | 100 ------------------ .../item/DebugElementalInstanceContainer_EM.java | 101 ++++++++++++++++++ .../tectech/thing/item/DefinitionContainer_EM.java | 114 -------------------- .../item/ElementalDefinitionContainer_EM.java | 115 +++++++++++++++++++++ .../item/ElementalDefinitionScanStorage_EM.java | 96 +++++++++++++++++ .../multi/GT_MetaTileEntity_EM_scanner.java | 7 ++ .../tileentity/turret/TileTurretHeadEM.java | 4 +- src/main/resources/assets/tectech/lang/en_US.lang | 1 + .../textures/items/itemDefinitionScanStorage.png | Bin 0 -> 7526 bytes .../items/itemDefinitionScanStorage.png.mcmeta | 5 + .../items/itemDefinitionScanStorageOff.png | Bin 0 -> 5511 bytes .../items/itemDefinitionScanStorageOff.png.mcmeta | 5 + 25 files changed, 557 insertions(+), 265 deletions(-) delete mode 100644 src/main/java/com/github/technus/tectech/thing/item/DebugContainer_EM.java create mode 100644 src/main/java/com/github/technus/tectech/thing/item/DebugElementalInstanceContainer_EM.java delete mode 100644 src/main/java/com/github/technus/tectech/thing/item/DefinitionContainer_EM.java create mode 100644 src/main/java/com/github/technus/tectech/thing/item/ElementalDefinitionContainer_EM.java create mode 100644 src/main/java/com/github/technus/tectech/thing/item/ElementalDefinitionScanStorage_EM.java create mode 100644 src/main/resources/assets/tectech/textures/items/itemDefinitionScanStorage.png create mode 100644 src/main/resources/assets/tectech/textures/items/itemDefinitionScanStorage.png.mcmeta create mode 100644 src/main/resources/assets/tectech/textures/items/itemDefinitionScanStorageOff.png create mode 100644 src/main/resources/assets/tectech/textures/items/itemDefinitionScanStorageOff.png.mcmeta (limited to 'src') diff --git a/src/main/java/com/github/technus/tectech/Util.java b/src/main/java/com/github/technus/tectech/Util.java index 2f2cc9c298..c0aec1baf8 100644 --- a/src/main/java/com/github/technus/tectech/Util.java +++ b/src/main/java/com/github/technus/tectech/Util.java @@ -11,6 +11,7 @@ import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; import net.minecraftforge.fluids.FluidStack; @@ -815,4 +816,15 @@ public class Util { strings[strings.length-1]=string.substring(lastEnd); return strings; } + + public static String[] infoFromNBT(NBTTagCompound nbt) { + final String[] strings = new String[nbt.getInteger("i")]; + for (int i = 0; i < strings.length; i++) + strings[i] = nbt.getString(Integer.toString(i)); + return strings; + } + + public static boolean areBitsSet(int setBits,int testedValue){ + return (testedValue&setBits)==setBits; + } } diff --git a/src/main/java/com/github/technus/tectech/compatibility/thaumcraft/definitions/dComplexAspectDefinition.java b/src/main/java/com/github/technus/tectech/compatibility/thaumcraft/definitions/dComplexAspectDefinition.java index 034aa55642..29a3a714b8 100644 --- a/src/main/java/com/github/technus/tectech/compatibility/thaumcraft/definitions/dComplexAspectDefinition.java +++ b/src/main/java/com/github/technus/tectech/compatibility/thaumcraft/definitions/dComplexAspectDefinition.java @@ -1,6 +1,7 @@ package com.github.technus.tectech.compatibility.thaumcraft.definitions; import com.github.technus.tectech.TecTech; +import com.github.technus.tectech.Util; import com.github.technus.tectech.elementalMatter.core.cElementalDecay; import com.github.technus.tectech.elementalMatter.core.cElementalDefinitionStackMap; import com.github.technus.tectech.elementalMatter.core.containers.cElementalDefinitionStack; @@ -13,9 +14,12 @@ import com.github.technus.tectech.elementalMatter.core.transformations.aOredictD import com.github.technus.tectech.elementalMatter.definitions.primitive.eBosonDefinition; import net.minecraft.nbt.NBTTagCompound; +import java.util.ArrayList; + import static com.github.technus.tectech.auxiliary.TecTechConfig.DEBUG_MODE; import static com.github.technus.tectech.compatibility.thaumcraft.definitions.AspectDefinitionCompat.aspectDefinitionCompat; import static com.github.technus.tectech.elementalMatter.core.cElementalDecay.noDecay; +import static com.github.technus.tectech.thing.metaTileEntity.multi.GT_MetaTileEntity_EM_scanner.*; /** * Created by Tec on 06.05.2017. @@ -228,4 +232,28 @@ public final class dComplexAspectDefinition extends cElementalDefinition impleme public int hashCode() { return hash; } + + + + @Override + public void addScanResults(ArrayList lines, int capabilities, long energyLevel) { + if(Util.areBitsSet(SCAN_GET_CLASS_TYPE, capabilities)) + lines.add("CLASS = "+nbtType+" "+getClassType()); + if(Util.areBitsSet(SCAN_GET_NOMENCLATURE+SCAN_GET_COLOR+SCAN_GET_CHARGE+SCAN_GET_MASS, capabilities)) { + lines.add("NAME = "+getName()); + //lines.add("SYMBOL = "+getSymbol()); + } + if(Util.areBitsSet(SCAN_GET_CHARGE,capabilities)) + lines.add("CHARGE = "+getCharge()/3f+" eV"); + if(Util.areBitsSet(SCAN_GET_COLOR,capabilities)) + lines.add(getColor()<0?"NOT COLORED":"CARRIES COLOR"); + if(Util.areBitsSet(SCAN_GET_MASS,capabilities)) + lines.add("MASS = "+getMass()+" eV/c\u00b2"); + //TODO decay info - no energy states info here + if(Util.areBitsSet(SCAN_GET_TIMESPAN_INFO, capabilities)){ + lines.add(isTimeSpanHalfLife()?"TIME SPAN IS HALF LIFE":"TIME SPAN IS LIFE TIME"); + lines.add("TIME SPAN = "+getRawTimeSpan(energyLevel)+ " s"); + lines.add(" "+"At current energy level"); + } + } } 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 5891d4e252..347836764b 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 @@ -7,6 +7,7 @@ import com.github.technus.tectech.elementalMatter.core.interfaces.iHasElementalD import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.EnumChatFormatting; +import java.util.ArrayList; import java.util.Iterator; import java.util.Map; import java.util.TreeMap; @@ -307,6 +308,14 @@ public final class cElementalInstanceStackMap implements Comparable getScanInfo(int[] capabilities) { + ArrayList list=new ArrayList<>(16); + for(Map.Entry e:map.entrySet()){ + e.getValue().addScanResults(list,capabilities); + } + return list; + } + public cElementalInstanceStack[] values() { return map.values().toArray(new cElementalInstanceStack[0]); } @@ -370,11 +379,13 @@ public final class cElementalInstanceStackMap implements Comparable info = getScanInfo(capabilities); + nbt.setInteger("i", info.size()); + for (int i = 0; i < info.size(); i++) + nbt.setString(Integer.toString(i), info.get(i)); + return nbt; } public NBTTagCompound toNBT() { diff --git a/src/main/java/com/github/technus/tectech/elementalMatter/core/cElementalStackMap.java b/src/main/java/com/github/technus/tectech/elementalMatter/core/cElementalStackMap.java index 55446e9c93..c95427d906 100644 --- a/src/main/java/com/github/technus/tectech/elementalMatter/core/cElementalStackMap.java +++ b/src/main/java/com/github/technus/tectech/elementalMatter/core/cElementalStackMap.java @@ -80,13 +80,6 @@ abstract class cElementalStackMap implements Comparable { return nbt; } - public static String[] infoFromNBT(NBTTagCompound nbt) { - final String[] strings = new String[nbt.getInteger("i")]; - for (int i = 0; i < strings.length; i++) - strings[i] = nbt.getString(Integer.toString(i)); - return strings; - } - public final NBTTagCompound toNBT() { final NBTTagCompound nbt = new NBTTagCompound(); nbt.setInteger("i", map.size()); diff --git a/src/main/java/com/github/technus/tectech/elementalMatter/core/containers/cElementalInstanceStack.java b/src/main/java/com/github/technus/tectech/elementalMatter/core/containers/cElementalInstanceStack.java index a28fed340e..5a79eeee42 100644 --- a/src/main/java/com/github/technus/tectech/elementalMatter/core/containers/cElementalInstanceStack.java +++ b/src/main/java/com/github/technus/tectech/elementalMatter/core/containers/cElementalInstanceStack.java @@ -1,14 +1,19 @@ package com.github.technus.tectech.elementalMatter.core.containers; import com.github.technus.tectech.TecTech; +import com.github.technus.tectech.Util; import com.github.technus.tectech.elementalMatter.core.cElementalDecay; +import com.github.technus.tectech.elementalMatter.core.cElementalDefinitionStackMap; import com.github.technus.tectech.elementalMatter.core.cElementalInstanceStackMap; import com.github.technus.tectech.elementalMatter.core.interfaces.iElementalDefinition; import com.github.technus.tectech.elementalMatter.core.interfaces.iHasElementalDefinition; import com.github.technus.tectech.elementalMatter.core.templates.cElementalDefinition; import net.minecraft.nbt.NBTTagCompound; +import java.util.ArrayList; + import static com.github.technus.tectech.elementalMatter.definitions.primitive.cPrimitiveDefinition.null__; +import static com.github.technus.tectech.thing.metaTileEntity.multi.GT_MetaTileEntity_EM_scanner.*; /** * Created by danie_000 on 22.10.2016. @@ -147,7 +152,7 @@ public final class cElementalInstanceStack implements iHasElementalDefinition { return decay(1F,apparentAge,postEnergize); } - public cElementalInstanceStackMap decay(Float lifeTimeMult, long apparentAge, long postEnergize) { + public cElementalInstanceStackMap decay(float lifeTimeMult, long apparentAge, long postEnergize) { long newEnergyLevel=postEnergize+this.energy; if(newEnergyLevel>0) newEnergyLevel-=1; else if(newEnergyLevel<0) newEnergyLevel+=1; @@ -300,6 +305,43 @@ public final class cElementalInstanceStack implements iHasElementalDefinition { return this; } + public void addScanResults(ArrayList lines, int[] detailsOnDepthLevels){ + final int capabilities=detailsOnDepthLevels[0]; + if(Util.areBitsSet(SCAN_GET_DEPTH_LEVEL,capabilities)) + lines.add("DEPTH = "+0); + definition.addScanResults(lines,capabilities,energy); + if(Util.areBitsSet(SCAN_GET_TIMESPAN_MULT,capabilities)) { + lines.add("TIME SPAN MULTIPLIER = " + lifeTimeMult); + if(Util.areBitsSet(SCAN_GET_TIMESPAN_INFO,capabilities)) + lines.add("TIME SPAN MULTIPLIED = "+lifeTime+" s"); + } + if(Util.areBitsSet(SCAN_GET_AGE,capabilities)) + lines.add("AGE = " + age+" s"); + if(Util.areBitsSet(SCAN_GET_COLOR,capabilities)) + lines.add("COLOR = "+color+" RGB or CMY"); + if(Util.areBitsSet(SCAN_GET_ENERGY_LEVEL,capabilities)) + lines.add("ENERGY LEVEL = "+energy); + if(Util.areBitsSet(SCAN_GET_AMOUNT,capabilities)) + lines.add("AMOUNT = "+amount); + lines.add(null);//def separator + scanContents(lines,definition.getSubParticles(),1,detailsOnDepthLevels); + } + + private void scanContents(ArrayList lines, cElementalDefinitionStackMap definitions, int depth, int[] detailsOnDepthLevels){ + if(definitions!=null && depth,C String getSymbol(); + void addScanResults(ArrayList lines, int capabilities, long energyLevel); + byte getType(); byte getClassType();//bigger number means bigger things usually, but it is just used to differentiate between classes of iED diff --git a/src/main/java/com/github/technus/tectech/elementalMatter/core/templates/cElementalDefinition.java b/src/main/java/com/github/technus/tectech/elementalMatter/core/templates/cElementalDefinition.java index 021a762f6f..c455506435 100644 --- a/src/main/java/com/github/technus/tectech/elementalMatter/core/templates/cElementalDefinition.java +++ b/src/main/java/com/github/technus/tectech/elementalMatter/core/templates/cElementalDefinition.java @@ -1,17 +1,22 @@ package com.github.technus.tectech.elementalMatter.core.templates; +import com.github.technus.tectech.Util; import com.github.technus.tectech.elementalMatter.core.containers.cElementalDefinitionStack; import com.github.technus.tectech.elementalMatter.core.interfaces.iElementalDefinition; import com.github.technus.tectech.elementalMatter.core.interfaces.iHasElementalDefinition; import net.minecraft.nbt.NBTTagCompound; import java.lang.reflect.Method; +import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; import java.util.Map; 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.thing.metaTileEntity.multi.GT_MetaTileEntity_EM_scanner.*; +import static com.github.technus.tectech.thing.metaTileEntity.multi.GT_MetaTileEntity_EM_scanner.SCAN_GET_MASS; +import static com.github.technus.tectech.thing.metaTileEntity.multi.GT_MetaTileEntity_EM_scanner.SCAN_GET_TIMESPAN_INFO; /** * Created by danie_000 on 23.01.2017. diff --git a/src/main/java/com/github/technus/tectech/elementalMatter/core/templates/cElementalPrimitive.java b/src/main/java/com/github/technus/tectech/elementalMatter/core/templates/cElementalPrimitive.java index 2a2a3459c2..08cf157afb 100644 --- a/src/main/java/com/github/technus/tectech/elementalMatter/core/templates/cElementalPrimitive.java +++ b/src/main/java/com/github/technus/tectech/elementalMatter/core/templates/cElementalPrimitive.java @@ -1,6 +1,7 @@ package com.github.technus.tectech.elementalMatter.core.templates; import com.github.technus.tectech.TecTech; +import com.github.technus.tectech.Util; import com.github.technus.tectech.elementalMatter.core.cElementalDecay; import com.github.technus.tectech.elementalMatter.core.cElementalDefinitionStackMap; import com.github.technus.tectech.elementalMatter.core.interfaces.iElementalDefinition; @@ -12,11 +13,13 @@ import net.minecraft.client.Minecraft; import net.minecraft.crash.CrashReport; import net.minecraft.nbt.NBTTagCompound; +import java.util.ArrayList; import java.util.HashMap; import java.util.Map; import static com.github.technus.tectech.auxiliary.TecTechConfig.DEBUG_MODE; import static com.github.technus.tectech.elementalMatter.definitions.primitive.cPrimitiveDefinition.null__; +import static com.github.technus.tectech.thing.metaTileEntity.multi.GT_MetaTileEntity_EM_scanner.*; /** * Created by danie_000 on 22.10.2016. @@ -176,6 +179,28 @@ public abstract class cElementalPrimitive extends cElementalDefinition { return -128; } + @Override + public void addScanResults(ArrayList lines, int capabilities, long energyLevel) { + if(Util.areBitsSet(SCAN_GET_CLASS_TYPE, capabilities)) + lines.add("CLASS = "+nbtType+" "+getClassType()); + if(Util.areBitsSet(SCAN_GET_NOMENCLATURE+SCAN_GET_COLOR+SCAN_GET_CHARGE+SCAN_GET_MASS, capabilities)) { + lines.add("NAME = "+getName()); + lines.add("SYMBOL = "+getSymbol()); + } + if(Util.areBitsSet(SCAN_GET_CHARGE,capabilities)) + lines.add("CHARGE = "+getCharge()/3f+" eV"); + if(Util.areBitsSet(SCAN_GET_COLOR,capabilities)) + lines.add(getColor()<0?"NOT COLORED":"CARRIES COLOR"); + if(Util.areBitsSet(SCAN_GET_MASS,capabilities)) + lines.add("MASS = "+getMass()+" eV/c\u00b2"); + //TODO decay info - no energy states info here + if(Util.areBitsSet(SCAN_GET_TIMESPAN_INFO, capabilities)){ + lines.add(isTimeSpanHalfLife()?"TIME SPAN IS HALF LIFE":"TIME SPAN IS LIFE TIME"); + lines.add("TIME SPAN = "+getRawTimeSpan(energyLevel)+ " s"); + lines.add(" "+"At current energy level"); + } + } + public static void run() { try { cElementalDefinition.addCreatorFromNBT(nbtType, cElementalPrimitive.class.getMethod("fromNBT", NBTTagCompound.class),(byte)-128); diff --git a/src/main/java/com/github/technus/tectech/elementalMatter/definitions/complex/dAtomDefinition.java b/src/main/java/com/github/technus/tectech/elementalMatter/definitions/complex/dAtomDefinition.java index 92ba693889..d8a04d16b3 100644 --- a/src/main/java/com/github/technus/tectech/elementalMatter/definitions/complex/dAtomDefinition.java +++ b/src/main/java/com/github/technus/tectech/elementalMatter/definitions/complex/dAtomDefinition.java @@ -1,6 +1,7 @@ package com.github.technus.tectech.elementalMatter.definitions.complex; import com.github.technus.tectech.TecTech; +import com.github.technus.tectech.Util; import com.github.technus.tectech.XSTR; import com.github.technus.tectech.compatibility.gtpp.GtppAtomLoader; import com.github.technus.tectech.elementalMatter.core.cElementalDecay; @@ -29,6 +30,7 @@ import static com.github.technus.tectech.XSTR.XSTR_INSTANCE; import static com.github.technus.tectech.auxiliary.TecTechConfig.DEBUG_MODE; import static com.github.technus.tectech.elementalMatter.definitions.primitive.eBosonDefinition.boson_Y__; import static com.github.technus.tectech.elementalMatter.definitions.primitive.eBosonDefinition.deadEnd; +import static com.github.technus.tectech.thing.metaTileEntity.multi.GT_MetaTileEntity_EM_scanner.*; import static gregtech.api.enums.OrePrefixes.dust; /** @@ -397,7 +399,7 @@ public final class dAtomDefinition extends cElementalDefinition { else if(energy<=0) state = iaea.energeticStatesArray[0]; else state=iaea.energeticStatesArray[(int)energy]; for (int i=0;i decaysList,iaeaNuclide.iaeaDecay decay){ + private boolean getDecay(ArrayList decaysList,iaeaNuclide.iaeaDecay decay, long energy){ cElementalMutableDefinitionStackMap withThis=elementalStacks.toMutable(),newStuff=new cElementalMutableDefinitionStackMap(); switch (decay.decayName){ case "D": { @@ -834,9 +836,16 @@ public final class dAtomDefinition extends cElementalDefinition { } } } break; - case "IT": case "IT?": case "G": - decaysList.add(new cElementalDecay(decay.chance, this, eBosonDefinition.boson_Y__)); - return true; + case "IT": case "IT?": case "G": { + if(energy>0){ + decaysList.add(new cElementalDecay(decay.chance, this, eBosonDefinition.boson_Y__)); + return true; + }else{ + if(DEBUG_MODE) TecTech.Logger.info("Tried to emit Gamma from ground state"); + decaysList.add(new cElementalDecay(decay.chance, this)); + return true; + } + } //break; case "IT+EC+B+": { if (withThis.removeAllAmounts(false, dHadronDefinition.hadron_p2,eLeptonDefinition.lepton_e1)){ withThis.putUnify(dHadronDefinition.hadron_n2); @@ -1053,7 +1062,7 @@ public final class dAtomDefinition extends cElementalDefinition { @Override public cElementalDecay[] getNaturalDecayInstant() { //disembody - ArrayList decaysInto = new ArrayList(); + ArrayList decaysInto = new ArrayList<>(); for (cElementalDefinitionStack elementalStack : elementalStacks.values()) { if (elementalStack.definition.getType() == 1 || elementalStack.definition.getType() == -1) { //covers both quarks and antiquarks @@ -1405,4 +1414,28 @@ public final class dAtomDefinition extends cElementalDefinition { public int hashCode() { return hash; } + + + + @Override + public void addScanResults(ArrayList lines, int capabilities, long energyLevel) { + if(Util.areBitsSet(SCAN_GET_CLASS_TYPE, capabilities)) + lines.add("CLASS = "+nbtType+" "+getClassType()); + if(Util.areBitsSet(SCAN_GET_NOMENCLATURE+SCAN_GET_AMOUNT+SCAN_GET_COLOR+SCAN_GET_CHARGE+SCAN_GET_MASS, capabilities)) { + lines.add("NAME = "+getName()); + lines.add("SYMBOL = "+getSymbol()); + } + if(Util.areBitsSet(SCAN_GET_CHARGE,capabilities)) + lines.add("CHARGE = "+getCharge()/3f+" eV"); + if(Util.areBitsSet(SCAN_GET_COLOR,capabilities)) + lines.add(getColor()<0?"NOT COLORED":"CARRIES COLOR"); + if(Util.areBitsSet(SCAN_GET_MASS,capabilities)) + lines.add("MASS = "+getMass()+" eV/c\u00b2"); + //TODO decay info - no energy states info here + if(Util.areBitsSet(SCAN_GET_TIMESPAN_INFO, capabilities)){ + lines.add(isTimeSpanHalfLife()?"TIME SPAN IS HALF LIFE":"TIME SPAN IS LIFE TIME"); + lines.add("TIME SPAN = "+getRawTimeSpan(energyLevel)+ " s"); + lines.add(" "+"At current energy level"); + } + } } diff --git a/src/main/java/com/github/technus/tectech/elementalMatter/definitions/complex/dHadronDefinition.java b/src/main/java/com/github/technus/tectech/elementalMatter/definitions/complex/dHadronDefinition.java index f7bb9c7f5d..bc985aa5b5 100644 --- a/src/main/java/com/github/technus/tectech/elementalMatter/definitions/complex/dHadronDefinition.java +++ b/src/main/java/com/github/technus/tectech/elementalMatter/definitions/complex/dHadronDefinition.java @@ -1,6 +1,7 @@ package com.github.technus.tectech.elementalMatter.definitions.complex; import com.github.technus.tectech.TecTech; +import com.github.technus.tectech.Util; import com.github.technus.tectech.auxiliary.TecTechConfig; import com.github.technus.tectech.elementalMatter.core.cElementalDecay; import com.github.technus.tectech.elementalMatter.core.cElementalDefinitionStackMap; @@ -22,6 +23,9 @@ import java.util.ArrayList; import static com.github.technus.tectech.auxiliary.TecTechConfig.DEBUG_MODE; import static com.github.technus.tectech.elementalMatter.definitions.complex.dAtomDefinition.transformation; import static com.github.technus.tectech.elementalMatter.definitions.primitive.eBosonDefinition.boson_Y__; +import static com.github.technus.tectech.thing.metaTileEntity.multi.GT_MetaTileEntity_EM_scanner.*; +import static com.github.technus.tectech.thing.metaTileEntity.multi.GT_MetaTileEntity_EM_scanner.SCAN_GET_MASS; +import static com.github.technus.tectech.thing.metaTileEntity.multi.GT_MetaTileEntity_EM_scanner.SCAN_GET_TIMESPAN_INFO; import static gregtech.api.enums.OrePrefixes.dust; /** @@ -121,30 +125,29 @@ public final class dHadronDefinition extends cElementalDefinition {//TODO Optimi @Override public String getName() { + StringBuilder name= new StringBuilder(getSimpleName()); + for (cElementalDefinitionStack quark : quarkStacks.values()) { + name.append(" ").append(quark.definition.getSymbol()).append(quark.amount); + } + return name.toString(); + } + + private String getSimpleName() { String name; switch (amount) { case 2: - name = "Meson:"; - break; + return "Meson"; case 3: - name = "Baryon:"; - break; + return "Baryon"; case 4: - name = "Tetraquark:"; - break; + return "Tetraquark"; case 5: - name = "Pentaquark:"; - break; + return "Pentaquark"; case 6: - name = "Hexaquark:"; - break; + return "Hexaquark"; default: - name = "Hadron:"; - } - for (cElementalDefinitionStack quark : quarkStacks.values()) { - name += " " + quark.definition.getSymbol() + quark.amount; + return "Hadron"; } - return name; } @Override @@ -392,4 +395,26 @@ public final class dHadronDefinition extends cElementalDefinition {//TODO Optimi public int hashCode() { return hash; } + + @Override + public void addScanResults(ArrayList lines, int capabilities, long energyLevel) { + if(Util.areBitsSet(SCAN_GET_CLASS_TYPE, capabilities)) + lines.add("CLASS = "+nbtType+" "+getClassType()); + if(Util.areBitsSet(SCAN_GET_NOMENCLATURE+SCAN_GET_AMOUNT, capabilities)) { + lines.add("NAME = "+getSimpleName()); + //lines.add("SYMBOL = "+getSymbol()); + } + if(Util.areBitsSet(SCAN_GET_CHARGE,capabilities)) + lines.add("CHARGE = "+getCharge()/3f+" eV"); + if(Util.areBitsSet(SCAN_GET_COLOR,capabilities)) + lines.add(getColor()<0?"NOT COLORED":"CARRIES COLOR"); + if(Util.areBitsSet(SCAN_GET_MASS,capabilities)) + lines.add("MASS = "+getMass()+" eV/c\u00b2"); + //TODO decay info - no energy states info here + if(Util.areBitsSet(SCAN_GET_TIMESPAN_INFO, capabilities)){ + lines.add(isTimeSpanHalfLife()?"TIME SPAN IS HALF LIFE":"TIME SPAN IS LIFE TIME"); + lines.add("TIME SPAN = "+getRawTimeSpan(energyLevel)+ " s"); + lines.add(" "+"At current energy level"); + } + } } diff --git a/src/main/java/com/github/technus/tectech/loader/MainLoader.java b/src/main/java/com/github/technus/tectech/loader/MainLoader.java index 4259078c69..bcff2ddfaa 100644 --- a/src/main/java/com/github/technus/tectech/loader/MainLoader.java +++ b/src/main/java/com/github/technus/tectech/loader/MainLoader.java @@ -9,7 +9,7 @@ import com.github.technus.tectech.thing.CustomItemList; import com.github.technus.tectech.thing.block.QuantumGlassBlock; import com.github.technus.tectech.thing.casing.TT_Container_Casings; import com.github.technus.tectech.thing.item.ConstructableTriggerItem; -import com.github.technus.tectech.thing.item.DebugContainer_EM; +import com.github.technus.tectech.thing.item.DebugElementalInstanceContainer_EM; import com.github.technus.tectech.thing.item.ParametrizerMemoryCard; import cpw.mods.fml.common.ProgressManager; import cpw.mods.fml.relauncher.Side; @@ -89,7 +89,7 @@ public final class MainLoader { @SideOnly(Side.CLIENT) @Override public Item getTabIconItem() { - return DebugContainer_EM.INSTANCE; + return DebugElementalInstanceContainer_EM.INSTANCE; } @Override @@ -117,7 +117,7 @@ public final class MainLoader { QuantumGlassBlock.INSTANCE.setCreativeTab(mainTab); TT_Container_Casings.sBlockCasingsTT.setCreativeTab(mainTab); TT_Container_Casings.sHintCasingsTT.setCreativeTab(mainTab); - DebugContainer_EM.INSTANCE.setCreativeTab(mainTab); + DebugElementalInstanceContainer_EM.INSTANCE.setCreativeTab(mainTab); ConstructableTriggerItem.INSTANCE.setCreativeTab(mainTab); ParametrizerMemoryCard.INSTANCE.setCreativeTab(mainTab); } diff --git a/src/main/java/com/github/technus/tectech/loader/ThingsLoader.java b/src/main/java/com/github/technus/tectech/loader/ThingsLoader.java index d957152db5..e42e8e8edc 100644 --- a/src/main/java/com/github/technus/tectech/loader/ThingsLoader.java +++ b/src/main/java/com/github/technus/tectech/loader/ThingsLoader.java @@ -7,10 +7,7 @@ import com.github.technus.tectech.thing.block.ReactorSimBlock; import com.github.technus.tectech.thing.casing.GT_Block_CasingsTT; import com.github.technus.tectech.thing.casing.GT_Block_HintTT; import com.github.technus.tectech.thing.casing.TT_Container_Casings; -import com.github.technus.tectech.thing.item.ConstructableTriggerItem; -import com.github.technus.tectech.thing.item.DebugContainer_EM; -import com.github.technus.tectech.thing.item.DefinitionContainer_EM; -import com.github.technus.tectech.thing.item.ParametrizerMemoryCard; +import com.github.technus.tectech.thing.item.*; import cpw.mods.fml.common.Loader; import openmodularturrets.blocks.turretbases.TurretBaseEM; import openmodularturrets.blocks.turretheads.TurretHeadEM; @@ -43,10 +40,11 @@ public class ThingsLoader implements Runnable { ConstructableTriggerItem.run(); ParametrizerMemoryCard.run(); - TecTech.Logger.info("Useful item registered"); + ElementalDefinitionScanStorage_EM.run(); + TecTech.Logger.info("Useful Items registered"); - DefinitionContainer_EM.run(); - DebugContainer_EM.run(); + ElementalDefinitionContainer_EM.run(); + DebugElementalInstanceContainer_EM.run(); TecTech.Logger.info("Debug Items registered"); } } diff --git a/src/main/java/com/github/technus/tectech/recipe/TT_recipeAdder.java b/src/main/java/com/github/technus/tectech/recipe/TT_recipeAdder.java index 880ba1c8d4..9238085a35 100644 --- a/src/main/java/com/github/technus/tectech/recipe/TT_recipeAdder.java +++ b/src/main/java/com/github/technus/tectech/recipe/TT_recipeAdder.java @@ -4,7 +4,7 @@ import com.github.technus.tectech.TecTech; import com.github.technus.tectech.elementalMatter.core.cElementalDefinitionStackMap; import com.github.technus.tectech.elementalMatter.core.containers.cElementalDefinitionStack; import com.github.technus.tectech.elementalMatter.core.interfaces.iElementalDefinition; -import com.github.technus.tectech.thing.item.DefinitionContainer_EM; +import com.github.technus.tectech.thing.item.ElementalDefinitionContainer_EM; import com.github.technus.tectech.thing.metaTileEntity.multi.GT_MetaTileEntity_EM_crafting; import com.github.technus.tectech.thing.metaTileEntity.multi.GT_MetaTileEntity_EM_machine; import gregtech.api.enums.ItemList; @@ -104,8 +104,8 @@ public class TT_recipeAdder extends GT_RecipeAdder { else if(researchAmperage > Short.MAX_VALUE) researchAmperage=Short.MAX_VALUE; if(computationRequiredPerSec<=0) computationRequiredPerSec=1; else if(computationRequiredPerSec > Short.MAX_VALUE) computationRequiredPerSec=Short.MAX_VALUE; - ItemStack placeholder=new ItemStack(DefinitionContainer_EM.INSTANCE); - DefinitionContainer_EM.setContent(placeholder,new cElementalDefinitionStackMap(new cElementalDefinitionStack(aResearchEM,1))); + ItemStack placeholder=new ItemStack(ElementalDefinitionContainer_EM.INSTANCE); + ElementalDefinitionContainer_EM.setContent(placeholder,new cElementalDefinitionStackMap(new cElementalDefinitionStack(aResearchEM,1))); GT_Recipe thisRecipe=TT_recipe.GT_Recipe_MapTT.sScannableFakeRecipes.addFakeRecipe(false, new ItemStack[]{placeholder}, new ItemStack[]{aOutput}, new ItemStack[]{ItemList.Tool_DataOrb.getWithName(1L, "Writes Research result for "+ GT_MetaTileEntity_EM_machine.machine)}, null, null, totalComputationRequired, researchEUt, researchAmperage|(computationRequiredPerSec<<16)); TT_recipe.TT_Recipe_Map_EM.sMachineRecipesEM.add(new TT_recipe.TT_EMRecipe(false,thisRecipe,aResearchEM,aInputs,new ItemStack[]{aOutput},new ItemStack[]{ItemList.Tool_DataOrb.getWithName(1L, "Reads Research result")}, aFluidInputs,machineDuration,machineEUt,machineAmperage,eInputs)); @@ -123,8 +123,8 @@ public class TT_recipeAdder extends GT_RecipeAdder { else if(researchAmperage > Short.MAX_VALUE) researchAmperage=Short.MAX_VALUE; if(computationRequiredPerSec<=0) computationRequiredPerSec=1; else if(computationRequiredPerSec > Short.MAX_VALUE) computationRequiredPerSec=Short.MAX_VALUE; - ItemStack placeholder=new ItemStack(DefinitionContainer_EM.INSTANCE); - DefinitionContainer_EM.setContent(placeholder,new cElementalDefinitionStackMap(new cElementalDefinitionStack(aResearchEM,1))); + ItemStack placeholder=new ItemStack(ElementalDefinitionContainer_EM.INSTANCE); + ElementalDefinitionContainer_EM.setContent(placeholder,new cElementalDefinitionStackMap(new cElementalDefinitionStack(aResearchEM,1))); GT_Recipe thisRecipe=TT_recipe.GT_Recipe_MapTT.sScannableFakeRecipes.addFakeRecipe(false, new ItemStack[]{placeholder}, new ItemStack[]{aOutput}, new ItemStack[]{ItemList.Tool_DataOrb.getWithName(1L, "Writes Research result for "+ GT_MetaTileEntity_EM_crafting.crafter)}, null, null, totalComputationRequired, researchEUt, researchAmperage|(computationRequiredPerSec<<16)); TT_recipe.TT_Recipe_Map_EM.sCrafterRecipesEM.add(new TT_recipe.TT_EMRecipe(false,thisRecipe,aResearchEM,null,new ItemStack[]{aOutput},new ItemStack[]{ItemList.Tool_DataOrb.getWithName(1L, "Reads Research result")}, null,crafterDuration,crafterEUt,crafterAmperage,eInputs,null,catalyst,check)); diff --git a/src/main/java/com/github/technus/tectech/thing/item/DebugContainer_EM.java b/src/main/java/com/github/technus/tectech/thing/item/DebugContainer_EM.java deleted file mode 100644 index 0bc5487432..0000000000 --- a/src/main/java/com/github/technus/tectech/thing/item/DebugContainer_EM.java +++ /dev/null @@ -1,100 +0,0 @@ -package com.github.technus.tectech.thing.item; - -import com.github.technus.tectech.CommonValues; -import com.github.technus.tectech.elementalMatter.core.cElementalInstanceStackMap; -import com.github.technus.tectech.elementalMatter.core.interfaces.iElementalInstanceContainer; -import com.github.technus.tectech.elementalMatter.core.tElementalException; -import cpw.mods.fml.common.registry.GameRegistry; -import gregtech.api.interfaces.metatileentity.IMetaTileEntity; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import net.minecraft.creativetab.CreativeTabs; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.EntityPlayerMP; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.EnumChatFormatting; -import net.minecraft.world.World; - -import java.util.Collections; -import java.util.List; - -import static com.github.technus.tectech.auxiliary.Reference.MODID; -import static com.github.technus.tectech.auxiliary.TecTechConfig.DEBUG_MODE; - -/** - * Created by Tec on 15.03.2017. - */ -public class DebugContainer_EM extends Item { - public static DebugContainer_EM INSTANCE; - - private DebugContainer_EM() { - super(); - setMaxStackSize(1); - setUnlocalizedName("em.debugContainer"); - setTextureName(MODID + ":itemDebugContainer"); - } - - @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 = aStack.getTagCompound(); - TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); - if (aPlayer instanceof EntityPlayerMP) { - aStack.stackSize = 1; - if (tTileEntity != null && tTileEntity instanceof IGregTechTileEntity) { - IMetaTileEntity metaTE = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity(); - if (metaTE != null && metaTE instanceof iElementalInstanceContainer) { - cElementalInstanceStackMap content = ((iElementalInstanceContainer) metaTE).getContainerHandler(); - if (tNBT.hasKey("content")) { - try { - content.putUnifyAll(cElementalInstanceStackMap.fromNBT(tNBT.getCompoundTag("content"))); - } catch (tElementalException e) { - if (DEBUG_MODE) e.printStackTrace(); - return true; - } - ((iElementalInstanceContainer) metaTE).purgeOverflow(); - tNBT.removeTag("content"); - tNBT.removeTag("info"); - } else if (content.hasStacks()) { - ((iElementalInstanceContainer) metaTE).purgeOverflow(); - tNBT.setTag("info", content.getInfoNBT()); - tNBT.setTag("content", content.toNBT()); - content.clear(); - } - return true; - } - } - } - return aPlayer instanceof EntityPlayerMP; - } - - @Override - public void addInformation(ItemStack aStack, EntityPlayer ep, List aList, boolean boo) { - aList.add(CommonValues.TEC_MARK_EM); - try { - NBTTagCompound tNBT = aStack.getTagCompound(); - if (tNBT != null && tNBT.hasKey("info")) { - aList.add("Contains:"); - Collections.addAll(aList, cElementalInstanceStackMap.infoFromNBT(tNBT.getCompoundTag("info"))); - } else { - aList.add("Container for elemental matter"); - aList.add(EnumChatFormatting.BLUE + "Right click on elemental hatches"); - } - } catch (Exception e) { - aList.add("---Unexpected Termination---"); - } - } - - public static void run() { - INSTANCE = new DebugContainer_EM(); - GameRegistry.registerItem(INSTANCE, INSTANCE.getUnlocalizedName()); - } - - @Override - public void getSubItems(Item item, CreativeTabs tab, List list) { - ItemStack that = new ItemStack(this, 1); - that.setTagCompound(new NBTTagCompound()); - list.add(that); - } -} diff --git a/src/main/java/com/github/technus/tectech/thing/item/DebugElementalInstanceContainer_EM.java b/src/main/java/com/github/technus/tectech/thing/item/DebugElementalInstanceContainer_EM.java new file mode 100644 index 0000000000..89362c9469 --- /dev/null +++ b/src/main/java/com/github/technus/tectech/thing/item/DebugElementalInstanceContainer_EM.java @@ -0,0 +1,101 @@ +package com.github.technus.tectech.thing.item; + +import com.github.technus.tectech.CommonValues; +import com.github.technus.tectech.Util; +import com.github.technus.tectech.elementalMatter.core.cElementalInstanceStackMap; +import com.github.technus.tectech.elementalMatter.core.interfaces.iElementalInstanceContainer; +import com.github.technus.tectech.elementalMatter.core.tElementalException; +import cpw.mods.fml.common.registry.GameRegistry; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.world.World; + +import java.util.Collections; +import java.util.List; + +import static com.github.technus.tectech.auxiliary.Reference.MODID; +import static com.github.technus.tectech.auxiliary.TecTechConfig.DEBUG_MODE; + +/** + * Created by Tec on 15.03.2017. + */ +public class DebugElementalInstanceContainer_EM extends Item { + public static DebugElementalInstanceContainer_EM INSTANCE; + + private DebugElementalInstanceContainer_EM() { + super(); + setMaxStackSize(1); + setUnlocalizedName("em.debugContainer"); + setTextureName(MODID + ":itemDebugContainer"); + } + + @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 = aStack.getTagCompound(); + TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); + if (aPlayer instanceof EntityPlayerMP) { + aStack.stackSize = 1; + if (tTileEntity != null && tTileEntity instanceof IGregTechTileEntity) { + IMetaTileEntity metaTE = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity(); + if (metaTE != null && metaTE instanceof iElementalInstanceContainer) { + cElementalInstanceStackMap content = ((iElementalInstanceContainer) metaTE).getContainerHandler(); + if (tNBT.hasKey("content")) { + try { + content.putUnifyAll(cElementalInstanceStackMap.fromNBT(tNBT.getCompoundTag("content"))); + } catch (tElementalException e) { + if (DEBUG_MODE) e.printStackTrace(); + return true; + } + ((iElementalInstanceContainer) metaTE).purgeOverflow(); + tNBT.removeTag("content"); + tNBT.removeTag("info"); + } else if (content.hasStacks()) { + ((iElementalInstanceContainer) metaTE).purgeOverflow(); + tNBT.setTag("info", content.getInfoNBT()); + tNBT.setTag("content", content.toNBT()); + content.clear(); + } + return true; + } + } + } + return aPlayer instanceof EntityPlayerMP; + } + + @Override + public void addInformation(ItemStack aStack, EntityPlayer ep, List aList, boolean boo) { + aList.add(CommonValues.TEC_MARK_EM); + try { + NBTTagCompound tNBT = aStack.getTagCompound(); + if (tNBT != null && tNBT.hasKey("info")) { + aList.add("Contains:"); + Collections.addAll(aList, Util.infoFromNBT(tNBT.getCompoundTag("info"))); + } else { + aList.add("Container for elemental matter"); + aList.add(EnumChatFormatting.BLUE + "Right click on elemental hatches"); + } + } catch (Exception e) { + aList.add("---Unexpected Termination---"); + } + } + + public static void run() { + INSTANCE = new DebugElementalInstanceContainer_EM(); + GameRegistry.registerItem(INSTANCE, INSTANCE.getUnlocalizedName()); + } + + @Override + public void getSubItems(Item item, CreativeTabs tab, List list) { + ItemStack that = new ItemStack(this, 1); + that.setTagCompound(new NBTTagCompound()); + list.add(that); + } +} diff --git a/src/main/java/com/github/technus/tectech/thing/item/DefinitionContainer_EM.java b/src/main/java/com/github/technus/tectech/thing/item/DefinitionContainer_EM.java deleted file mode 100644 index 942e6b97d7..0000000000 --- a/src/main/java/com/github/technus/tectech/thing/item/DefinitionContainer_EM.java +++ /dev/null @@ -1,114 +0,0 @@ -package com.github.technus.tectech.thing.item; - -import com.github.technus.tectech.CommonValues; -import com.github.technus.tectech.elementalMatter.core.cElementalDefinitionStackMap; -import com.github.technus.tectech.elementalMatter.core.tElementalException; -import cpw.mods.fml.common.registry.GameRegistry; -import net.minecraft.creativetab.CreativeTabs; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; - -import java.util.Collections; -import java.util.List; - -import static com.github.technus.tectech.auxiliary.Reference.MODID; -import static com.github.technus.tectech.auxiliary.TecTechConfig.DEBUG_MODE; - -/** - * Created by Tec on 15.03.2017. - */ -public class DefinitionContainer_EM extends Item { - public static DefinitionContainer_EM INSTANCE; - - private DefinitionContainer_EM() { - super(); - setMaxStackSize(1); - setUnlocalizedName("em.definitionContainer"); - setTextureName(MODID + ":itemDefinitionContainer"); - } - - //return previous thing - public static cElementalDefinitionStackMap setContent(ItemStack containerItem, cElementalDefinitionStackMap definitions){ - if(containerItem.getItem() instanceof DefinitionContainer_EM) { - NBTTagCompound tNBT = containerItem.stackTagCompound; - if (tNBT == null) tNBT=containerItem.stackTagCompound=new NBTTagCompound(); - - cElementalDefinitionStackMap oldMap=null; - if (tNBT.hasKey("content")) { - try { - oldMap=cElementalDefinitionStackMap.fromNBT(tNBT.getCompoundTag("content")); - } catch (tElementalException e) { - if (DEBUG_MODE) e.printStackTrace(); - } - } - tNBT.setTag("info", definitions.getInfoNBT()); - tNBT.setTag("content", definitions.toNBT()); - return oldMap; - } - return null; - } - - public static cElementalDefinitionStackMap getContent(ItemStack containerItem){ - if(containerItem.getItem() instanceof DefinitionContainer_EM){ - NBTTagCompound tNBT = containerItem.stackTagCompound; - - if (tNBT == null || !tNBT.hasKey("content")) return null; - try { - return cElementalDefinitionStackMap.fromNBT(tNBT.getCompoundTag("content")); - } catch (tElementalException e) { - if (DEBUG_MODE) e.printStackTrace(); - } - } - return null; - } - - public static cElementalDefinitionStackMap clearContent(ItemStack containerItem){ - if(containerItem.getItem() instanceof DefinitionContainer_EM){ - NBTTagCompound tNBT = containerItem.stackTagCompound; - if (tNBT == null) return null; - - cElementalDefinitionStackMap oldMap=null; - if (tNBT.hasKey("content")) { - try { - oldMap=cElementalDefinitionStackMap.fromNBT(tNBT.getCompoundTag("content")); - } catch (tElementalException e) { - if (DEBUG_MODE) e.printStackTrace(); - } - } - tNBT.removeTag("info"); - tNBT.removeTag("content"); - return oldMap; - } - return null; - } - - @Override - public void addInformation(ItemStack aStack, EntityPlayer ep, List aList, boolean boo) { - aList.add(CommonValues.TEC_MARK_EM); - try { - NBTTagCompound tNBT = aStack.getTagCompound(); - if (tNBT != null && tNBT.hasKey("info")) { - aList.add("Should Contain:"); - Collections.addAll(aList, cElementalDefinitionStackMap.infoFromNBT(tNBT.getCompoundTag("info"))); - } else { - aList.add("Recipe Hint"); - } - } catch (Exception e) { - aList.add("---Unexpected Termination---"); - } - } - - public static void run() { - INSTANCE = new DefinitionContainer_EM(); - GameRegistry.registerItem(INSTANCE, INSTANCE.getUnlocalizedName()); - } - - @Override - public void getSubItems(Item item, CreativeTabs tab, List list) { - ItemStack that = new ItemStack(this, 1); - that.setTagCompound(new NBTTagCompound()); - list.add(that); - } -} diff --git a/src/main/java/com/github/technus/tectech/thing/item/ElementalDefinitionContainer_EM.java b/src/main/java/com/github/technus/tectech/thing/item/ElementalDefinitionContainer_EM.java new file mode 100644 index 0000000000..931a0a94cc --- /dev/null +++ b/src/main/java/com/github/technus/tectech/thing/item/ElementalDefinitionContainer_EM.java @@ -0,0 +1,115 @@ +package com.github.technus.tectech.thing.item; + +import com.github.technus.tectech.CommonValues; +import com.github.technus.tectech.Util; +import com.github.technus.tectech.elementalMatter.core.cElementalDefinitionStackMap; +import com.github.technus.tectech.elementalMatter.core.tElementalException; +import cpw.mods.fml.common.registry.GameRegistry; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; + +import java.util.Collections; +import java.util.List; + +import static com.github.technus.tectech.auxiliary.Reference.MODID; +import static com.github.technus.tectech.auxiliary.TecTechConfig.DEBUG_MODE; + +/** + * Created by Tec on 15.03.2017. + */ +public class ElementalDefinitionContainer_EM extends Item { + public static ElementalDefinitionContainer_EM INSTANCE; + + private ElementalDefinitionContainer_EM() { + super(); + setMaxStackSize(1); + setUnlocalizedName("em.definitionContainer"); + setTextureName(MODID + ":itemDefinitionContainer"); + } + + //return previous thing + public static cElementalDefinitionStackMap setContent(ItemStack containerItem, cElementalDefinitionStackMap definitions){ + if(containerItem.getItem() instanceof ElementalDefinitionContainer_EM) { + NBTTagCompound tNBT = containerItem.stackTagCompound; + if (tNBT == null) tNBT=containerItem.stackTagCompound=new NBTTagCompound(); + + cElementalDefinitionStackMap oldMap=null; + if (tNBT.hasKey("content")) { + try { + oldMap=cElementalDefinitionStackMap.fromNBT(tNBT.getCompoundTag("content")); + } catch (tElementalException e) { + if (DEBUG_MODE) e.printStackTrace(); + } + } + tNBT.setTag("info", definitions.getInfoNBT()); + tNBT.setTag("content", definitions.toNBT()); + return oldMap; + } + return null; + } + + public static cElementalDefinitionStackMap getContent(ItemStack containerItem){ + if(containerItem.getItem() instanceof ElementalDefinitionContainer_EM){ + NBTTagCompound tNBT = containerItem.stackTagCompound; + + if (tNBT == null || !tNBT.hasKey("content")) return null; + try { + return cElementalDefinitionStackMap.fromNBT(tNBT.getCompoundTag("content")); + } catch (tElementalException e) { + if (DEBUG_MODE) e.printStackTrace(); + } + } + return null; + } + + public static cElementalDefinitionStackMap clearContent(ItemStack containerItem){ + if(containerItem.getItem() instanceof ElementalDefinitionContainer_EM){ + NBTTagCompound tNBT = containerItem.stackTagCompound; + if (tNBT == null) return null; + + cElementalDefinitionStackMap oldMap=null; + if (tNBT.hasKey("content")) { + try { + oldMap=cElementalDefinitionStackMap.fromNBT(tNBT.getCompoundTag("content")); + } catch (tElementalException e) { + if (DEBUG_MODE) e.printStackTrace(); + } + } + tNBT.removeTag("info"); + tNBT.removeTag("content"); + return oldMap; + } + return null; + } + + @Override + public void addInformation(ItemStack aStack, EntityPlayer ep, List aList, boolean boo) { + aList.add(CommonValues.TEC_MARK_EM); + try { + NBTTagCompound tNBT = aStack.getTagCompound(); + if (tNBT != null && tNBT.hasKey("info")) { + aList.add("Should Contain:"); + Collections.addAll(aList, Util.infoFromNBT(tNBT.getCompoundTag("info"))); + } else { + aList.add("Recipe Hint"); + } + } catch (Exception e) { + aList.add("---Unexpected Termination---"); + } + } + + public static void run() { + INSTANCE = new ElementalDefinitionContainer_EM(); + GameRegistry.registerItem(INSTANCE, INSTANCE.getUnlocalizedName()); + } + + @Override + public void getSubItems(Item item, CreativeTabs tab, List list) { + ItemStack that = new ItemStack(this, 1); + that.setTagCompound(new NBTTagCompound()); + list.add(that); + } +} 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 new file mode 100644 index 0000000000..2991330564 --- /dev/null +++ b/src/main/java/com/github/technus/tectech/thing/item/ElementalDefinitionScanStorage_EM.java @@ -0,0 +1,96 @@ +package com.github.technus.tectech.thing.item; + +import com.github.technus.tectech.CommonValues; +import com.github.technus.tectech.Util; +import com.github.technus.tectech.elementalMatter.core.cElementalInstanceStackMap; +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.IIcon; + +import java.util.Collections; +import java.util.List; + +import static com.github.technus.tectech.auxiliary.Reference.MODID; +import static com.github.technus.tectech.auxiliary.TecTechConfig.DEBUG_MODE; + +/** + * Created by Tec on 15.03.2017. + */ +public class ElementalDefinitionScanStorage_EM extends Item { + public static ElementalDefinitionScanStorage_EM INSTANCE; + public static IIcon offline, online; + + private ElementalDefinitionScanStorage_EM() { + super(); + setMaxStackSize(1); + setUnlocalizedName("em.definitionScanStorage"); + setTextureName(MODID + ":itemDefinitionScanStorage"); + } + + //return previous thing + public static void setContent(ItemStack containerItem, cElementalInstanceStackMap definitions, int[] detailsOnDepthLevels){ + if(containerItem.getItem() instanceof ElementalDefinitionScanStorage_EM) { + if (containerItem.stackTagCompound == null) containerItem.stackTagCompound=new NBTTagCompound(); + containerItem.stackTagCompound.setTag("elementalInfo", definitions.getScanInfoNBT(detailsOnDepthLevels)); + } + } + + public static void clearContent(ItemStack containerItem){ + if(containerItem.getItem() instanceof ElementalDefinitionScanStorage_EM){ + if (containerItem.stackTagCompound == null) return; + containerItem.stackTagCompound.removeTag("elementalInfo"); + return; + } + return; + } + + @Override + public void addInformation(ItemStack aStack, EntityPlayer ep, List aList, boolean boo) { + aList.add(CommonValues.TEC_MARK_EM); + try { + if (aStack.stackTagCompound != null && aStack.stackTagCompound.hasKey("elementalInfo")) { + aList.add("Scan result:"); + if(DEBUG_MODE) + Collections.addAll(aList, Util.infoFromNBT(aStack.stackTagCompound.getCompoundTag("elementalInfo"))); + } else { + aList.add("Storage for matter scan data"); + } + } catch (Exception e) { + aList.add("---Unexpected Termination---"); + } + } + + public static void run() { + INSTANCE = new ElementalDefinitionScanStorage_EM(); + GameRegistry.registerItem(INSTANCE, INSTANCE.getUnlocalizedName()); + } + + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister iconRegister) { + offline =iconRegister.registerIcon(MODID + ":itemDefinitionScanStorageOff"); + online =this.itemIcon = iconRegister.registerIcon(this.getIconString()); + } + + @Override + public IIcon getIconIndex(ItemStack itemStack) { + NBTTagCompound tagCompound=itemStack.stackTagCompound; + if(tagCompound!=null && tagCompound.hasKey("info")) + return online; + return offline; + } + + @Override + public void getSubItems(Item item, CreativeTabs tab, List list) { + ItemStack that = new ItemStack(this, 1); + that.setTagCompound(new NBTTagCompound()); + list.add(that); + } +} 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 d43765f7f2..19170a91f9 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 @@ -36,6 +36,13 @@ import static com.github.technus.tectech.thing.metaTileEntity.multi.GT_MetaTileE * Created by danie_000 on 17.12.2016. */ 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_DECAY_INFO=32, + SCAN_GET_AMOUNT=256, SCAN_GET_COLOR=512, SCAN_GET_ENERGY_LEVEL=1024, SCAN_GET_AGE=2048, SCAN_GET_TIMESPAN_MULT =4096, + SCAN_GET_ENERGY_STATES=32768, SCAN_GET_ENERGY_STATES_DECAYS=65536, + SCAN_GET_DEPTH_LEVEL=-2147483648; + private TT_recipe.TT_EMRecipe.TT_EMRecipe eRecipe; private cElementalDefinitionStack objectResearched; private String machineType; diff --git a/src/main/java/openmodularturrets/tileentity/turret/TileTurretHeadEM.java b/src/main/java/openmodularturrets/tileentity/turret/TileTurretHeadEM.java index fc2e5db293..343a1e5ebd 100644 --- a/src/main/java/openmodularturrets/tileentity/turret/TileTurretHeadEM.java +++ b/src/main/java/openmodularturrets/tileentity/turret/TileTurretHeadEM.java @@ -1,7 +1,7 @@ package openmodularturrets.tileentity.turret; import com.github.technus.tectech.elementalMatter.core.cElementalInstanceStackMap; -import com.github.technus.tectech.thing.item.DebugContainer_EM; +import com.github.technus.tectech.thing.item.DebugElementalInstanceContainer_EM; import net.minecraft.entity.Entity; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; @@ -54,7 +54,7 @@ public class TileTurretHeadEM extends TurretHead{ } public Item getAmmo() { - return DebugContainer_EM.INSTANCE;//Placeholder item that cannot be achieved, yet still usable for debug + return DebugElementalInstanceContainer_EM.INSTANCE;//Placeholder item that cannot be achieved, yet still usable for debug } public final TurretProjectile createProjectile(World world, Entity target, ItemStack ammo) { diff --git a/src/main/resources/assets/tectech/lang/en_US.lang b/src/main/resources/assets/tectech/lang/en_US.lang index 5d041a12e9..20160069e4 100644 --- a/src/main/resources/assets/tectech/lang/en_US.lang +++ b/src/main/resources/assets/tectech/lang/en_US.lang @@ -3,6 +3,7 @@ tile.quantumGlass.name=Quantum Glass tile.quantumStuff.name=Quantum Stuff item.em.debugContainer.name=Debug EM Container item.em.definitionContainer.name=EM Recipe Hint +item.em.definitionScanStorage.name=EM Scan Storage item.em.debugBuilder.name=Multiblock Machine Blueprint item.em.parametrizerMemoryCard.name=Parametrizer Memory Card diff --git a/src/main/resources/assets/tectech/textures/items/itemDefinitionScanStorage.png b/src/main/resources/assets/tectech/textures/items/itemDefinitionScanStorage.png new file mode 100644 index 0000000000..73c5274ef9 Binary files /dev/null and b/src/main/resources/assets/tectech/textures/items/itemDefinitionScanStorage.png differ diff --git a/src/main/resources/assets/tectech/textures/items/itemDefinitionScanStorage.png.mcmeta b/src/main/resources/assets/tectech/textures/items/itemDefinitionScanStorage.png.mcmeta new file mode 100644 index 0000000000..24f863c95e --- /dev/null +++ b/src/main/resources/assets/tectech/textures/items/itemDefinitionScanStorage.png.mcmeta @@ -0,0 +1,5 @@ +{ + "animation":{ + "frametime":3 + } +} \ No newline at end of file diff --git a/src/main/resources/assets/tectech/textures/items/itemDefinitionScanStorageOff.png b/src/main/resources/assets/tectech/textures/items/itemDefinitionScanStorageOff.png new file mode 100644 index 0000000000..006ae1e62f Binary files /dev/null and b/src/main/resources/assets/tectech/textures/items/itemDefinitionScanStorageOff.png differ diff --git a/src/main/resources/assets/tectech/textures/items/itemDefinitionScanStorageOff.png.mcmeta b/src/main/resources/assets/tectech/textures/items/itemDefinitionScanStorageOff.png.mcmeta new file mode 100644 index 0000000000..24f863c95e --- /dev/null +++ b/src/main/resources/assets/tectech/textures/items/itemDefiniti