diff options
author | Tec <daniel112092@gmail.com> | 2022-02-06 20:47:22 +0100 |
---|---|---|
committer | Tec <daniel112092@gmail.com> | 2022-02-06 20:47:22 +0100 |
commit | fe3e8abfbb46a4fd75906e3d41e0dfb4435b8403 (patch) | |
tree | c0c0bb04d96025c85fcef5bec276ea74c6b02294 | |
parent | 5f14081a2b88c07ff95325ddfa9ec88bf4c33e2a (diff) | |
download | GT5-Unofficial-fe3e8abfbb46a4fd75906e3d41e0dfb4435b8403.tar.gz GT5-Unofficial-fe3e8abfbb46a4fd75906e3d41e0dfb4435b8403.tar.bz2 GT5-Unofficial-fe3e8abfbb46a4fd75906e3d41e0dfb4435b8403.zip |
More locale work
28 files changed, 457 insertions, 644 deletions
diff --git a/src/main/java/com/github/technus/tectech/compatibility/openmodularturrets/blocks/turretheads/TurretHeadItemEM.java b/src/main/java/com/github/technus/tectech/compatibility/openmodularturrets/blocks/turretheads/TurretHeadItemEM.java index f4ad25f053..ce11976020 100644 --- a/src/main/java/com/github/technus/tectech/compatibility/openmodularturrets/blocks/turretheads/TurretHeadItemEM.java +++ b/src/main/java/com/github/technus/tectech/compatibility/openmodularturrets/blocks/turretheads/TurretHeadItemEM.java @@ -37,7 +37,7 @@ public class TurretHeadItemEM extends ItemBlock { list.add(EnumChatFormatting.DARK_PURPLE + "--" + translateToLocal("tooltip.damage.label") + "--"); list.add(translateToLocal("tooltip.damage.stat") + ": " + EnumChatFormatting.WHITE + (float)ConfigHandler.getLaserTurretSettings().getDamage() / 2.0F + ' ' + translateToLocal("tooltip.health")); list.add(translateToLocal("tooltip.aoe") + ": " + EnumChatFormatting.WHITE + '0'); - list.add(translateToLocal("tooltip.firerate") + ": " + EnumChatFormatting.WHITE + df.format((double)(20.0F / (float)ConfigHandler.getLaserTurretSettings().getFireRate()))); + list.add(translateToLocal("tooltip.firerate") + ": " + EnumChatFormatting.WHITE + df.format(20.0F / (float)ConfigHandler.getLaserTurretSettings().getFireRate())); list.add(translateToLocal("tooltip.energy.stat") + ": " + EnumChatFormatting.WHITE + ConfigHandler.getLaserTurretSettings().getPowerUsage() + " RF"); list.add(""); list.add(EnumChatFormatting.DARK_GRAY + translateToLocal("flavour.turret.4")); diff --git a/src/main/java/com/github/technus/tectech/compatibility/thaumcraft/elementalMatter/definitions/EMComplexAspectDefinition.java b/src/main/java/com/github/technus/tectech/compatibility/thaumcraft/elementalMatter/definitions/EMComplexAspectDefinition.java index be1ed9bd51..c2d93cf0fd 100644 --- a/src/main/java/com/github/technus/tectech/compatibility/thaumcraft/elementalMatter/definitions/EMComplexAspectDefinition.java +++ b/src/main/java/com/github/technus/tectech/compatibility/thaumcraft/elementalMatter/definitions/EMComplexAspectDefinition.java @@ -6,18 +6,14 @@ import com.github.technus.tectech.mechanics.elementalMatter.core.EMException; import com.github.technus.tectech.mechanics.elementalMatter.core.decay.EMDecay; import com.github.technus.tectech.mechanics.elementalMatter.core.definitions.EMComplexTemplate; import com.github.technus.tectech.mechanics.elementalMatter.core.definitions.IEMDefinition; -import com.github.technus.tectech.mechanics.elementalMatter.core.definitions.registry.EMIndirectType; import com.github.technus.tectech.mechanics.elementalMatter.core.definitions.registry.EMDefinitionsRegistry; +import com.github.technus.tectech.mechanics.elementalMatter.core.definitions.registry.EMIndirectType; import com.github.technus.tectech.mechanics.elementalMatter.core.maps.EMConstantStackMap; import com.github.technus.tectech.mechanics.elementalMatter.core.stacks.EMDefinitionStack; -import com.github.technus.tectech.util.TT_Utility; - -import java.util.ArrayList; import static com.github.technus.tectech.loader.TecTechConfig.DEBUG_MODE; import static com.github.technus.tectech.mechanics.elementalMatter.core.decay.EMDecay.NO_DECAY; import static com.github.technus.tectech.mechanics.elementalMatter.definitions.primitive.EMGaugeBosonDefinition.deadEnd; -import static com.github.technus.tectech.thing.metaTileEntity.multi.GT_MetaTileEntity_EM_scanner.*; import static net.minecraft.util.StatCollector.translateToLocal; /** @@ -125,7 +121,7 @@ public final class EMComplexAspectDefinition extends EMComplexTemplate { } @Override - protected String getIndirectTagValue() { + protected String getTagValue() { return nbtType; } @@ -230,35 +226,4 @@ public final class EMComplexAspectDefinition extends EMComplexTemplate { public int hashCode() { return hash; } - - @Override - public void addScanShortSymbols(ArrayList<String> lines, int capabilities, long energyLevel) { - if (TT_Utility.areBitsSet(SCAN_GET_NOMENCLATURE | SCAN_GET_CHARGE | SCAN_GET_MASS, capabilities)) { - lines.add(getShortSymbol()); - } - } - - @Override - public void addScanResults(ArrayList<String> lines, int capabilities, long energyLevel) { - if (TT_Utility.areBitsSet(SCAN_GET_CLASS_TYPE, capabilities)) { - lines.add(translateToLocal("tt.keyword.CLASS") + " = " + nbtType + ' ' + getMatterMassType()); - } - if (TT_Utility.areBitsSet(SCAN_GET_NOMENCLATURE | SCAN_GET_CHARGE | SCAN_GET_MASS, capabilities)) { - lines.add(translateToLocal("tt.keyword.NAME") + " = " + getLocalizedName()); - //lines.add("SYMBOL = "+getSymbol()); - } - if (TT_Utility.areBitsSet(SCAN_GET_CHARGE, capabilities)) { - lines.add(translateToLocal("tt.keyword.CHARGE") + " = " + getCharge() / 3f + " e"); - } - if (TT_Utility.areBitsSet(SCAN_GET_COLOR, capabilities)) { - lines.add(hasColor() ? translateToLocal("tt.keyword.COLORLESS") : translateToLocal("tt.keyphrase.CARRIES_COLOR")); - } - if (TT_Utility.areBitsSet(SCAN_GET_MASS, capabilities)) { - lines.add(translateToLocal("tt.keyword.MASS") + " = " + getMass() + " eV/c\u00b2"); - } - if (TT_Utility.areBitsSet(SCAN_GET_TIMESPAN_INFO, capabilities)) { - lines.add(translateToLocal("tt.keyphrase.LIFE_TIME") + " = " + getRawTimeSpan(energyLevel) + " s"); - lines.add(" " + translateToLocal("tt.keyphrase.At_current_energy_level")); - } - } } diff --git a/src/main/java/com/github/technus/tectech/mechanics/anomaly/CancerCommand.java b/src/main/java/com/github/technus/tectech/mechanics/anomaly/CancerCommand.java index bb61f50aab..32b0893d8b 100644 --- a/src/main/java/com/github/technus/tectech/mechanics/anomaly/CancerCommand.java +++ b/src/main/java/com/github/technus/tectech/mechanics/anomaly/CancerCommand.java @@ -15,7 +15,9 @@ public class CancerCommand implements ICommand { public CancerCommand(){ aliases.add("cancer_EM"); aliases.add("cancer"); + aliases.add("sanser_EM"); aliases.add("sanser"); + aliases.add("sancer_EM"); aliases.add("sancer"); } diff --git a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/definitions/EMComplexTemplate.java b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/definitions/EMComplexTemplate.java index 13838cf443..be22092163 100644 --- a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/definitions/EMComplexTemplate.java +++ b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/definitions/EMComplexTemplate.java @@ -60,8 +60,8 @@ public abstract class EMComplexTemplate implements IEMDefinition { } public NBTTagCompound toNBT(EMDefinitionsRegistry registry) { - return registry.indirectToNBT(getIndirectTagValue(),getSubParticles()); + return registry.indirectToNBT(getTagValue(),getSubParticles()); } - protected abstract String getIndirectTagValue(); + protected abstract String getTagValue(); } diff --git a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/definitions/EMPrimitiveTemplate.java b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/definitions/EMPrimitiveTemplate.java index edf1827a07..272e7cffc0 100644 --- a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/definitions/EMPrimitiveTemplate.java +++ b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/definitions/EMPrimitiveTemplate.java @@ -1,15 +1,10 @@ package com.github.technus.tectech.mechanics.elementalMatter.core.definitions; -import com.github.technus.tectech.mechanics.elementalMatter.core.EMException; import com.github.technus.tectech.mechanics.elementalMatter.core.decay.EMDecay; import com.github.technus.tectech.mechanics.elementalMatter.core.definitions.registry.EMDefinitionsRegistry; import com.github.technus.tectech.mechanics.elementalMatter.core.maps.EMConstantStackMap; import net.minecraft.nbt.NBTTagCompound; -import java.util.ArrayList; - -import static com.github.technus.tectech.thing.metaTileEntity.multi.GT_MetaTileEntity_EM_scanner.*; -import static com.github.technus.tectech.util.TT_Utility.areBitsSet; import static net.minecraft.util.StatCollector.translateToLocal; /** @@ -169,8 +164,8 @@ public abstract class EMPrimitiveTemplate extends EMComplexTemplate { } @Override - protected final String getIndirectTagValue() { - throw new EMException("This class should only be used directly!"); + protected final String getTagValue() { + return bind; } @Override @@ -183,37 +178,6 @@ public abstract class EMPrimitiveTemplate extends EMComplexTemplate { } @Override - public void addScanShortSymbols(ArrayList<String> lines, int capabilities, long energyLevel) { - if(areBitsSet(SCAN_GET_NOMENCLATURE|SCAN_GET_CHARGE|SCAN_GET_MASS|SCAN_GET_TIMESPAN_INFO, capabilities)) { - lines.add(getShortSymbol()); - } - } - - @Override - public void addScanResults(ArrayList<String> lines, int capabilities, long energyLevel) { - if(areBitsSet(SCAN_GET_CLASS_TYPE, capabilities)) { - lines.add("DIRECT = " + bind + ' ' + getMatterMassType()); - } - if(areBitsSet(SCAN_GET_NOMENCLATURE|SCAN_GET_CHARGE|SCAN_GET_MASS|SCAN_GET_TIMESPAN_INFO, capabilities)) { - lines.add("NAME = "+ getLocalizedName()); - lines.add("SYMBOL = "+getSymbol()); - } - if(areBitsSet(SCAN_GET_CHARGE,capabilities)) { - lines.add("CHARGE = " + getCharge() / 3D + " e"); - } - if(areBitsSet(SCAN_GET_COLOR,capabilities)) { - lines.add(hasColor() ? "COLORLESS" : "CARRIES COLOR"); - } - if(areBitsSet(SCAN_GET_MASS,capabilities)) { - lines.add("MASS = " + getMass() + " eV/c\u00b2"); - } - if(areBitsSet(SCAN_GET_TIMESPAN_INFO, capabilities)){ - lines.add((isTimeSpanHalfLife()?"HALF LIFE = ":"LIFE TIME = ")+getRawTimeSpan(energyLevel)+ " s"); - lines.add(" "+"At current energy level"); - } - } - - @Override public final int compareTo(IEMDefinition o) { if (getMatterMassType() == o.getMatterMassType()) { int oID = ((EMPrimitiveTemplate) o).ID; diff --git a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/definitions/IEMDefinition.java b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/definitions/IEMDefinition.java index aae5a8caca..ee123735f8 100644 --- a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/definitions/IEMDefinition.java +++ b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/definitions/IEMDefinition.java @@ -4,18 +4,23 @@ import com.github.technus.tectech.mechanics.elementalMatter.core.decay.EMDecay; import com.github.technus.tectech.mechanics.elementalMatter.core.definitions.registry.EMDefinitionsRegistry; import com.github.technus.tectech.mechanics.elementalMatter.core.maps.EMConstantStackMap; import com.github.technus.tectech.mechanics.elementalMatter.core.stacks.EMDefinitionStack; +import com.github.technus.tectech.util.TT_Utility; import net.minecraft.nbt.NBTTagCompound; import java.util.ArrayList; +import static com.github.technus.tectech.thing.metaTileEntity.multi.GT_MetaTileEntity_EM_scanner.*; +import static com.github.technus.tectech.util.TT_Utility.areBitsSet; +import static net.minecraft.util.StatCollector.translateToLocal; + /** * Created by danie_000 on 11.11.2016. */ -public interface IEMDefinition extends Comparable<IEMDefinition>,Cloneable {//IMMUTABLE - double STABLE_RAW_LIFE_TIME =1.5e36D; - double NO_DECAY_RAW_LIFE_TIME =-1D; - long DEFAULT_ENERGY_LEVEL =0; - double DEFAULT_ENERGY_REQUIREMENT =25000D;//legit cuz normal atoms should only emit a gamma if they don't have defined energy levels +public interface IEMDefinition extends Comparable<IEMDefinition>, Cloneable {//IMMUTABLE + double STABLE_RAW_LIFE_TIME = 1.5e36D; + double NO_DECAY_RAW_LIFE_TIME = -1D; + long DEFAULT_ENERGY_LEVEL = 0; + double DEFAULT_ENERGY_REQUIREMENT = 25000D;//legit cuz normal atoms should only emit a gamma if they don't have defined energy levels //add text based creators for recipe formula input? //Nomenclature @@ -23,17 +28,52 @@ public interface IEMDefinition extends Comparable<IEMDefinition>,Cloneable {//IM String getShortLocalizedName(); - default String getLocalizedName(){ - return getLocalizedTypeName()+": "+getShortLocalizedName(); + default String getLocalizedName() { + return getLocalizedTypeName() + ": " + getShortLocalizedName(); } String getShortSymbol(); String getSymbol(); - void addScanShortSymbols(ArrayList<String> lines, int capabilities, long energyLevel); + default void addScanShortSymbols(ArrayList<String> lines, int capabilities, long energyLevel, EMDefinitionsRegistry registry) { + if (areBitsSet(SCAN_GET_NOMENCLATURE | SCAN_GET_CLASS_TYPE | SCAN_GET_CHARGE | SCAN_GET_MASS | SCAN_GET_TIMESPAN_INFO, capabilities)) { + lines.add(getShortSymbol()); + } + } - void addScanResults(ArrayList<String> lines, int capabilities, long energyLevel); + default void addScanResults(ArrayList<String> lines, int capabilities, long energyLevel, EMDefinitionsRegistry registry) { + if (TT_Utility.areBitsSet(SCAN_GET_CLASS_TYPE | SCAN_GET_CHARGE | SCAN_GET_MASS | SCAN_GET_TIMESPAN_INFO, capabilities)) { + lines.add(translateToLocal("tt.keyword.scan.class") + + " = " + registry.getTypes().get(getClass()).getLocalizedName()); + if (areBitsSet(SCAN_GET_NOMENCLATURE, capabilities)) { + lines.add(translateToLocal("tt.keyword.scan.name") + + " = " + getLocalizedName()); + lines.add(translateToLocal("tt.keyword.scan.symbol") + + " = " + getSymbol()); + } + } + if (areBitsSet(SCAN_GET_CHARGE, capabilities)) { + lines.add(translateToLocal("tt.keyword.scan.charge") + + " = " + getCharge() / 3D + " " + translateToLocal("tt.keyword.unit.charge")); + } + if (areBitsSet(SCAN_GET_COLORABLE, capabilities)) { + lines.add(hasColor() ? + translateToLocal("tt.keyword.scan.colored") : + translateToLocal("tt.keyword.scan.colorless")); + } + if (areBitsSet(SCAN_GET_MASS, capabilities)) { + lines.add(translateToLocal("tt.keyword.scan.mass") + + " = " + getMass() + " " + translateToLocal("tt.keyword.unit.mass")); + } + if (areBitsSet(SCAN_GET_TIMESPAN_INFO, capabilities)) { + lines.add((isTimeSpanHalfLife() ? + translateToLocal("tt.keyword.scan.half_life") : + translateToLocal("tt.keyword.scan.life_time")) + + " = " + getRawTimeSpan(energyLevel) + " " + translateToLocal("tt.keyword.unit.time")); + lines.add(" " + translateToLocal("tt.keyphrase.scan.at_current_energy_level")); + } + } int getMatterMassType();//bigger number means bigger things usually, but it is just used to differentiate between classes of iED @@ -65,8 +105,8 @@ public interface IEMDefinition extends Comparable<IEMDefinition>,Cloneable {//IM //dynamically changing stuff int getMaxColors(); - default boolean hasColor(){ - return getMaxColors()>0; + default boolean hasColor() { + return getMaxColors() > 0; } double getRawTimeSpan(long currentEnergy);//defined in static fields or generated @@ -77,11 +117,11 @@ public interface IEMDefinition extends Comparable<IEMDefinition>,Cloneable {//IM NBTTagCompound toNBT(EMDefinitionsRegistry registry); - default EMDefinitionStack getStackForm(double amount){ - return new EMDefinitionStack(this,amount); + default EMDefinitionStack getStackForm(double amount) { + return new EMDefinitionStack(this, amount); } - default IEMDefinition clone(){ + default IEMDefinition clone() { return this; } diff --git a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/maps/EMConstantStackMap.java b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/maps/EMConstantStackMap.java index f6bef9910e..ed2ebbab57 100644 --- a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/maps/EMConstantStackMap.java +++ b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/maps/EMConstantStackMap.java @@ -1,16 +1,16 @@ package com.github.technus.tectech.mechanics.elementalMatter.core.maps; -import com.github.technus.tectech.mechanics.elementalMatter.core.definitions.registry.EMDefinitionsRegistry; -import com.github.technus.tectech.mechanics.elementalMatter.core.stacks.EMDefinitionStack; import com.github.technus.tectech.mechanics.elementalMatter.core.EMException; import com.github.technus.tectech.mechanics.elementalMatter.core.definitions.IEMDefinition; +import com.github.technus.tectech.mechanics.elementalMatter.core.definitions.registry.EMDefinitionsRegistry; +import com.github.technus.tectech.mechanics.elementalMatter.core.stacks.EMDefinitionStack; import net.minecraft.nbt.NBTTagCompound; import java.util.Collections; import java.util.NavigableMap; import java.util.TreeMap; -import static com.github.technus.tectech.mechanics.elementalMatter.definitions.primitive.EMPrimitiveDefinition.nbtE__; +import static com.github.technus.tectech.util.TT_Utility.unpackNBT; /** * Created by Tec on 12.05.2017. @@ -47,13 +47,6 @@ public final class EMConstantStackMap/*IMMUTABLE*/ extends EMStackMap<EMDefiniti } public static EMConstantStackMap fromNBT(EMDefinitionsRegistry registry, NBTTagCompound nbt) throws EMException { - EMDefinitionStack[] defStacks = new EMDefinitionStack[nbt.getInteger("i")]; - for (int i = 0; i < defStacks.length; i++) { - defStacks[i] = EMDefinitionStack.fromNBT(registry,nbt.getCompoundTag(Integer.toString(i))); - if (defStacks[i].getDefinition().equals(nbtE__)) { - throw new EMException("Something went Wrong"); - } - } - return new EMConstantStackMap(defStacks); + return new EMConstantStackMap(unpackNBT(EMDefinitionStack.class,inner -> EMDefinitionStack.fromNBT(registry, inner),nbt)); } } diff --git a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/maps/EMDefinitionStackMap.java b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/maps/EMDefinitionStackMap.java index 57b8f7bf1c..6892e2cd59 100644 --- a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/maps/EMDefinitionStackMap.java +++ b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/maps/EMDefinitionStackMap.java @@ -1,15 +1,15 @@ package com.github.technus.tectech.mechanics.elementalMatter.core.maps; -import com.github.technus.tectech.mechanics.elementalMatter.core.definitions.registry.EMDefinitionsRegistry; -import com.github.technus.tectech.mechanics.elementalMatter.core.stacks.EMDefinitionStack; import com.github.technus.tectech.mechanics.elementalMatter.core.EMException; import com.github.technus.tectech.mechanics.elementalMatter.core.definitions.IEMDefinition; +import com.github.technus.tectech.mechanics.elementalMatter.core.definitions.registry.EMDefinitionsRegistry; +import com.github.technus.tectech.mechanics.elementalMatter.core.stacks.EMDefinitionStack; import net.minecraft.nbt.NBTTagCompound; import java.util.NavigableMap; import java.util.TreeMap; -import static com.github.technus.tectech.mechanics.elementalMatter.definitions.primitive.EMPrimitiveDefinition.nbtE__; +import static com.github.technus.tectech.util.TT_Utility.unpackNBT; /** * Created by danie_000 on 22.01.2017. @@ -45,13 +45,6 @@ public final class EMDefinitionStackMap extends EMStackMap<EMDefinitionStack> im } public static EMDefinitionStackMap fromNBT(EMDefinitionsRegistry registry, NBTTagCompound nbt) throws EMException { - EMDefinitionStack[] defStacks = new EMDefinitionStack[nbt.getInteger("i")]; - for (int i = 0; i < defStacks.length; i++) { - defStacks[i] = EMDefinitionStack.fromNBT(registry,nbt.getCompoundTag(Integer.toString(i))); - if (defStacks[i].getDefinition().equals(nbtE__)) { - throw new EMException("Something went Wrong"); - } - } - return new EMDefinitionStackMap(defStacks); + return new EMDefinitionStackMap(unpackNBT(EMDefinitionStack.class,inner -> EMDefinitionStack.fromNBT(registry, inner),nbt)); } } diff --git a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/maps/EMInstanceStackMap.java b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/maps/EMInstanceStackMap.java index bfaad77c33..8a92c819df 100644 --- a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/maps/EMInstanceStackMap.java +++ b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/maps/EMInstanceStackMap.java @@ -18,8 +18,8 @@ import java.util.NavigableMap; import java.util.TreeMap; import static com.github.technus.tectech.mechanics.elementalMatter.core.transformations.EMTransformationRegistry.AVOGADRO_CONSTANT; -import static com.github.technus.tectech.mechanics.elementalMatter.definitions.primitive.EMPrimitiveDefinition.nbtE__; import static com.github.technus.tectech.util.DoubleCount.add; +import static com.github.technus.tectech.util.TT_Utility.unpackNBT; import static net.minecraft.util.StatCollector.translateToLocal; /** @@ -27,7 +27,8 @@ import static net.minecraft.util.StatCollector.translateToLocal; */ public final class EMInstanceStackMap extends EMStackMap<EMInstanceStack> implements IEMMapWrite<EMInstanceStack> { //Constructors - public EMInstanceStackMap() {} + public EMInstanceStackMap() { + } public EMInstanceStackMap(EMInstanceStack... inSafe) { this(true, inSafe); @@ -35,8 +36,8 @@ public final class EMInstanceStackMap extends EMStackMap<EMInstanceStack> implem public EMInstanceStackMap(boolean clone, EMInstanceStack... in) { if (clone) { - EMInstanceStack[] stacks =new EMInstanceStack[in.length]; - for(int i=0;i<stacks.length;i++) { + EMInstanceStack[] stacks = new EMInstanceStack[in.length]; + for (int i = 0; i < stacks.length; i++) { stacks[i] = in[i].clone(); } putUnifyAll(stacks); @@ -50,9 +51,9 @@ public final class EMInstanceStackMap extends EMStackMap<EMInstanceStack> implem } private EMInstanceStackMap(boolean clone, NavigableMap<IEMDefinition, EMInstanceStack> in) { - super(clone?new TreeMap<>():in); + super(clone ? new TreeMap<>() : in); if (clone) { - for(EMInstanceStack stack:in.values()) { + for (EMInstanceStack stack : in.values()) { putUnify(stack.clone()); } } @@ -72,11 +73,11 @@ public final class EMInstanceStackMap extends EMStackMap<EMInstanceStack> implem public double removeOverflow(int stacksCount, double stackCapacity) { double massRemoved = 0; - if (getBackingMap().size() > stacksCount) { + if (size() > stacksCount) { IEMDefinition[] keys = keySetToArray(); for (int i = stacksCount; i < keys.length; i++) { - massRemoved += getBackingMap().get(keys[i]).getDefinitionStack().getMass(); - getBackingMap().remove(keys[i]); + massRemoved += get(keys[i]).getDefinitionStack().getMass(); + removeKey(keys[i]); } } @@ -91,44 +92,38 @@ public final class EMInstanceStackMap extends EMStackMap<EMInstanceStack> implem //Getters public String[] getElementalInfo() { - String[] info = new String[getBackingMap().size()]; - int i = 0; - for (EMInstanceStack instance : getBackingMap().values()) { - info[i++] = EnumChatFormatting.BLUE + instance.getDefinition().getLocalizedName()+ - " "+ EnumChatFormatting.AQUA + instance.getDefinition().getSymbol()+ EnumChatFormatting.RESET+ - " #: " + EnumChatFormatting.GREEN + TT_Utility.formatNumberExp(instance.getAmount() /AVOGADRO_CONSTANT) +" "+translateToLocal("tt.keyword.mol")+ EnumChatFormatting.RESET+ - " E: " + EnumChatFormatting.GREEN + GT_Utility.formatNumbers(instance.getEnergy()) + EnumChatFormatting.RESET+ - " T: " + EnumChatFormatting.GREEN + (instance.getLifeTime()<0?translateToLocal("tt.keyword.stable"):TT_Utility.formatNumberShortExp(instance.getLifeTime())); + String[] info = new String[size()]; + int i = 0; + for (Map.Entry<IEMDefinition, EMInstanceStack> entry : entrySet()) { + EMInstanceStack instance = entry.getValue(); + info[i++] = EnumChatFormatting.BLUE + instance.getDefinition().getLocalizedName() + " " + EnumChatFormatting.AQUA + instance.getDefinition().getSymbol() + EnumChatFormatting.RESET + + " " + translateToLocal("tt.keyword.short.amount") + ": " + EnumChatFormatting.GREEN + TT_Utility.formatNumberExp(instance.getAmount() / AVOGADRO_CONSTANT) + " " + translateToLocal("tt.keyword.unit.mol") + EnumChatFormatting.RESET + + " " + translateToLocal("tt.keyword.short.energy") + ": " + EnumChatFormatting.GREEN + GT_Utility.formatNumbers(instance.getDefinition().getEnergyDiffBetweenStates(0, instance.getEnergy())) + " " + translateToLocal("tt.keyword.unit.energy") + EnumChatFormatting.RESET + + " " + translateToLocal("tt.keyword.short.charge") + ": " + EnumChatFormatting.GREEN + TT_Utility.formatNumberExp(instance.getCharge()) + " " + translateToLocal("tt.keyword.unit.charge") + EnumChatFormatting.RESET + + " " + translateToLocal("tt.keyword.short.time") + ": " + EnumChatFormatting.GREEN + (instance.getLifeTime() < 0 ? + translateToLocal("tt.keyword.stable") : TT_Utility.formatNumberShortExp(instance.getLifeTime()) + " " + translateToLocal("tt.keyword.unit.time")) + EnumChatFormatting.RESET; } return info; } - public ArrayList<String> getScanShortSymbols(int[] capabilities) { - ArrayList<String> list=new ArrayList<>(16); - for(Map.Entry<IEMDefinition, EMInstanceStack> e: getBackingMap().entrySet()){ - e.getValue().addScanShortSymbols(list,capabilities); - } - return list; - } - public ArrayList<String> getScanInfo(int[] capabilities) { - ArrayList<String> list=new ArrayList<>(16); - for(Map.Entry<IEMDefinition, EMInstanceStack> e: getBackingMap().entrySet()){ - e.getValue().addScanResults(list,capabilities); + ArrayList<String> list = new ArrayList<>(16); + for (Map.Entry<IEMDefinition, EMInstanceStack> e : entrySet()) { + e.getValue().addScanResults(list, capabilities); } return list; } - public double tickContent(double lifeTimeMult, int postEnergize, double seconds){ + public double tickContent(double lifeTimeMult, int postEnergize, double seconds) { //cleanUp(); - double diff=0; + double diff = 0; for (EMInstanceStack instance : takeAllToArray()) { instance.setAge(instance.getAge() + seconds); EMDecayResult newInstances = instance.decay(lifeTimeMult, instance.getAge(), postEnergize); if (newInstances == null) { putUnify(instance); } else { - diff=add(diff,newInstances.getMassDiff()); + diff = add(diff, newInstances.getMassDiff()); putUnifyAll(newInstances.getOutput()); } } @@ -136,55 +131,28 @@ public final class EMInstanceStackMap extends EMStackMap<EMInstanceStack> implem } //NBT - public NBTTagCompound getScanShortSymbolsNBT(int[] capabilities) { - NBTTagCompound nbt = new NBTTagCompound(); - ArrayList<String> info = getScanShortSymbols(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 getScanInfoNBT(int[] capabilities) { - NBTTagCompound nbt = new NBTTagCompound(); - ArrayList<String> 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 static EMInstanceStackMap fromNBT(EMDefinitionsRegistry registry, NBTTagCompound nbt) throws EMException { - EMInstanceStack[] instances = new EMInstanceStack[nbt.getInteger("i")]; - for (int i = 0; i < instances.length; i++) { - instances[i] = EMInstanceStack.fromNBT(registry,nbt.getCompoundTag(Integer.toString(i))); - if (instances[i].getDefinition().equals(nbtE__)) { - throw new EMException("Something went Wrong"); - } - } - return new EMInstanceStackMap(false, instances); + return new EMInstanceStackMap(false, unpackNBT(EMInstanceStack.class, inner -> EMInstanceStack.fromNBT(registry, inner), nbt)); } @Override public String toString() { - StringBuilder build=new StringBuilder("Instance Stack Map\n"); - for(EMInstanceStack stack: getBackingMap().values()){ - build.append(stack.toString()).append('\n'); + StringBuilder build = new StringBuilder("Instance Stack Map\n"); + for (Map.Entry<IEMDefinition, EMInstanceStack> stack : entrySet()) { + build.append(stack.getValue().toString()).append('\n'); } return build.toString(); } - public EMInstanceStack[] takeAllToArray(){ + public EMInstanceStack[] takeAllToArray() { EMInstanceStack[] newStack = valuesToArray();//just in case to uncouple The map - this.getBackingMap().clear(); + clear(); return newStack; } - public EMInstanceStackMap takeAll(){ - EMInstanceStackMap newStack =new EMInstanceStackMap(false,new TreeMap<>(this.getBackingMap()));//just in case to uncouple The map - this.getBackingMap().clear(); + public EMInstanceStackMap takeAll() { + EMInstanceStackMap newStack = new EMInstanceStackMap(false, new TreeMap<>(getBackingMap()));//just in case to uncouple The map + clear(); return newStack; } @@ -201,36 +169,36 @@ public final class EMInstanceStackMap extends EMStackMap<EMInstanceStack> implem @Override public EMInstanceStack putUnify(EMInstanceStack stack) { - EMInstanceStack target =get(stack.getDefinition()); - if(target==null) { + EMInstanceStack target = get(stack.getDefinition()); + if (target == null) { putReplace(stack); return stack; } double newAmount = add(target.getAmount(), stack.getAmount()); if (IEMStack.isValidAmount(newAmount)) { - stack=target.unifyIntoThis(stack); + stack = target.unifyIntoThis(stack); putReplace(stack); return stack; - }else { - removeKey(stack); + } else { + removeKey(stack.getDefinition()); return null; } } @Override public EMInstanceStack putUnifyExact(EMInstanceStack stack) { - EMInstanceStack target =get(stack.getDefinition()); - if(target==null) { + EMInstanceStack target = get(stack.getDefinition()); + if (target == null) { putReplace(stack); return stack; } - double newAmount = target.getAmount()+stack.getAmount(); + double newAmount = target.getAmount() + stack.getAmount(); if (IEMStack.isValidAmount(newAmount)) { - stack=target.unifyIntoThis(stack); + stack = target.unifyIntoThis(stack); putReplace(stack); return stack; - }else { - removeKey(stack); + } else { + removeKey(stack.getDefinition()); return null; } } diff --git a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/maps/EMStackMap.java b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/maps/EMStackMap.java index 3765fe6098..10241cb457 100644 --- a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/maps/EMStackMap.java +++ b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/maps/EMStackMap.java @@ -3,6 +3,7 @@ package com.github.technus.tectech.mechanics.elementalMatter.core.maps; import com.github.technus.tectech.mechanics.elementalMatter.core.stacks.IEMStack; import com.github.technus.tectech.mechanics.elementalMatter.core.definitions.IEMDefinition; +import java.util.Map; import java.util.NavigableMap; import java.util.TreeMap; @@ -41,9 +42,9 @@ abstract class EMStackMap<T extends IEMStack> implements IEMMapRead<T> { @Override public int hashCode() {//Hash only definitions to compare contents not amounts or data - int hash = -(getBackingMap().size() << 4); - for (T stack : getBackingMap().values()) { - hash += stack.getDefinition().hashCode(); + int hash = -(size() << 4); + for (Map.Entry<IEMDefinition, T> entry : entrySet()) { + hash += entry.getValue().getDefinition().hashCode(); } return hash; } diff --git a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/maps/IEMMapRead.java b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/maps/IEMMapRead.java index 86ca6de8a8..6bd12a849b 100644 --- a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/maps/IEMMapRead.java +++ b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/maps/IEMMapRead.java @@ -1,17 +1,20 @@ package com.github.technus.tectech.mechanics.elementalMatter.core.maps; import com.github.technus.tectech.TecTech; +import com.github.technus.tectech.mechanics.elementalMatter.core.definitions.IEMDefinition; import com.github.technus.tectech.mechanics.elementalMatter.core.definitions.registry.EMDefinitionsRegistry; import com.github.technus.tectech.mechanics.elementalMatter.core.stacks.IEMStack; -import com.github.technus.tectech.mechanics.elementalMatter.core.definitions.IEMDefinition; +import com.github.technus.tectech.util.TT_Utility; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.EnumChatFormatting; import java.lang.reflect.Array; import java.util.*; -import static com.github.technus.tectech.mechanics.elementalMatter.core.transformations.EMTransformationRegistry.*; +import static com.github.technus.tectech.mechanics.elementalMatter.core.transformations.EMTransformationRegistry.AVOGADRO_CONSTANT; +import static com.github.technus.tectech.mechanics.elementalMatter.core.transformations.EMTransformationRegistry.EM_COUNT_EPSILON; import static com.github.technus.tectech.util.DoubleCount.ulpSigned; +import static com.github.technus.tectech.util.TT_Utility.packNBT; import static net.minecraft.util.StatCollector.translateToLocal; public interface IEMMapRead<T extends IEMStack> extends Comparable<IEMMapRead<? extends IEMStack>>, Cloneable { @@ -87,53 +90,27 @@ public interface IEMMapRead<T extends IEMStack> extends Comparable<IEMMapRead<? default String[] getShortSymbolsInfo() { String[] info = new String[size()]; int i = 0; - for (T instance : values()) { - info[i++] = instance.getDefinition().getShortSymbol(); + for (Map.Entry<IEMDefinition, T> instance : entrySet()) { + info[i++] = instance.getValue().getDefinition().getShortSymbol(); } return info; } default String[] getElementalInfo() { - String[] info = new String[size() * 3]; - int i = 0; - for (T defStack : values()) { - info[i] = EnumChatFormatting.BLUE + defStack.getDefinition().getLocalizedName(); - info[i + 1] = EnumChatFormatting.AQUA + defStack.getDefinition().getSymbol(); - info[i + 2] = "Amount " + EnumChatFormatting.GREEN + defStack.getAmount()/AVOGADRO_CONSTANT+" "+translateToLocal("tt.keyword.mol"); - i += 3; + String[] info = new String[size()]; + int i = 0; + for (Map.Entry<IEMDefinition, T> entry : entrySet()) { + T instance = entry.getValue(); + info[i++] = EnumChatFormatting.BLUE + instance.getDefinition().getLocalizedName() + " " + EnumChatFormatting.AQUA + instance.getDefinition().getSymbol() + EnumChatFormatting.RESET + + " " + translateToLocal("tt.keyword.short.amount") + ": " + EnumChatFormatting.GREEN + TT_Utility.formatNumberExp(instance.getAmount() / AVOGADRO_CONSTANT) + " " + translateToLocal("tt.keyword.unit.mol") + EnumChatFormatting.RESET + + " " + translateToLocal("tt.keyword.short.charge") + ": " + EnumChatFormatting.GREEN + TT_Utility.formatNumberExp(instance.getCharge()) + " " + translateToLocal("tt.keyword.unit.charge") + EnumChatFormatting.RESET; } return info; } //NBT - default NBTTagCompound getShortSymbolsNBT() { - NBTTagCompound nbt = new NBTTagCompound(); - String[] info = getShortSymbolsInfo(); - nbt.setInteger("i", info.length); - for (int i = 0; i < info.length; i++) { - nbt.setString(Integer.toString(i), info[i]); - } - return nbt; - } - - default NBTTagCompound getInfoNBT() { - NBTTagCompound nbt = new NBTTagCompound(); - String[] info = getElementalInfo(); - nbt.setInteger("i", info.length); - for (int i = 0; i < info.length; i++) { - nbt.setString(Integer.toString(i), info[i]); - } - return nbt; - } - default NBTTagCompound toNBT(EMDefinitionsRegistry registry) { - NBTTagCompound nbt = new NBTTagCompound(); - nbt.setInteger("i", size()); - int i = 0; - for (Map.Entry<IEMDefinition, T> entry : entrySet()) { - nbt.setTag(Integer.toString(i++), entry.getValue().toNBT(registry)); - } - return nbt; + return packNBT(t -> t.toNBT(registry),valuesToArray()); } @Override @@ -143,11 +120,11 @@ public interface IEMMapRead<T extends IEMStack> extends Comparable<IEMMapRead<? return sizeDiff; } - Iterator<T> iterator = values().iterator(); - Iterator<? extends IEMStack> iteratorO = o.values().iterator(); + Iterator<Map.Entry<IEMDefinition, T>> iterator = entrySet().iterator(); + Iterator<? extends Map.Entry<IEMDefinition, ? extends IEMStack>> iteratorO = o.entrySet().iterator(); while (iterator.hasNext()) { - int result = iterator.next().compareTo(iteratorO.next()); + int result = iterator.next().getValue().compareTo(iteratorO.next().getValue()); if (result != 0) { return result; } @@ -232,7 +209,7 @@ public interface IEMMapRead<T extends IEMStack> extends Comparable<IEMMapRead<? } default boolean containsAmountExact(IEMDefinition def, double amount) { - T target = getBackingMap().get(def); + T target = get(def); return target != null && target.getAmount() >= amount; } diff --git a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/maps/IEMMapWrite.java b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/maps/IEMMapWrite.java index 15815f2ee0..ac94f9cf6b 100644 --- a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/maps/IEMMapWrite.java +++ b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/maps/IEMMapWrite.java @@ -27,15 +27,15 @@ public interface IEMMapWrite<T extends IEMStack> extends IEMMapWriteExact<T> { } default boolean removeAmount(IEMDefinition def, double amountToConsume, double amountRequired){ - T current=getBackingMap().get(def); + T current=get(def); if(current!=null){ if(current.getAmount()>=amountRequired){ double newAmount=sub(current.getAmount(),amountToConsume); if(IEMStack.isValidAmount(newAmount)){ current=(T)current.mutateAmount(newAmount); - getBackingMap().put(current.getDefinition(),current); + putReplace(current); }else { - getBackingMap().remove(current.getDefinition()); + removeKey(current.getDefinition()); } return true; } @@ -82,7 +82,7 @@ public interface IEMMapWrite<T extends IEMStack> extends IEMMapWriteExact<T> { * @return new mapping or null if merging actually removed stuff */ default T putUnify(T stack) { - T target=getBackingMap().get(stack.getDefinition()); + T target=get(stack.getDefinition()); if(target==null) { putReplace(stack); return stack; @@ -93,7 +93,7 @@ public interface IEMMapWrite<T extends IEMStack> extends IEMMapWriteExact<T> { putReplace(stack); return stack; }else { - removeKey(stack); + removeKey(stack.getDefinition()); return null; } } @@ -105,8 +105,8 @@ public interface IEMMapWrite<T extends IEMStack> extends IEMMapWriteExact<T> { } default void putUnifyAll(IEMMapRead<T> inTreeUnsafe) { - for (T in : inTreeUnsafe.values()) { - putUnify(in); + for (Map.Entry<IEMDefinition, T> in : inTreeUnsafe.entrySet()) { + putUnify(in.getValue()); } } } diff --git a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/maps/IEMMapWriteExact.java b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/maps/IEMMapWriteExact.java index 9da971944c..b30497a47d 100644 --- a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/maps/IEMMapWriteExact.java +++ b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/maps/IEMMapWriteExact.java @@ -21,10 +21,6 @@ public interface IEMMapWriteExact<T extends IEMStack> extends IEMMapRead<T> { return getBackingMap().remove(def); } - default T removeKey(IEMStack has) { - return removeKey(has.getDefinition()); - } - default boolean removeKeys(IEMDefinition... definitions) { boolean hadAll=true; for (IEMDefinition def : definitions) { @@ -36,7 +32,7 @@ public interface IEMMapWriteExact<T extends IEMStack> extends IEMMapRead<T> { default boolean removeKeys(IEMStack... hasElementalDefinition) { boolean hadAll=true; for (IEMStack has : hasElementalDefinition) { - hadAll&=removeKey(has)!=null; + hadAll&=removeKey(has.getDefinition())!=null; } return hadAll; } @@ -55,7 +51,7 @@ public interface IEMMapWriteExact<T extends IEMStack> extends IEMMapRead<T> { boolean hadAll=containsAllKeys(hasElementalDefinition); if(hadAll){ for (IEMStack stack : hasElementalDefinition) { - removeKey(stack); + removeKey(stack.getDefinition()); } } return hadAll; @@ -91,15 +87,15 @@ public interface IEMMapWriteExact<T extends IEMStack> extends IEMMapRead<T> { * @return */ default boolean removeAmountExact(IEMDefinition def, double amountToConsume){ - T current=getBackingMap().get(def); + T current=get(def); if(current!=null){ double newAmount=current.getAmount()-amountToConsume; if(newAmount>=0){ if(current.isValidAmount()){ current=(T)current.mutateAmount(newAmount); - getBackingMap().put(current.getDefinition(),current); + putReplace(current); } else { - getBackingMap().remove(current.getDefinition()); + removeKey(current.getDefinition()); } return true; } @@ -136,7 +132,7 @@ public interface IEMMapWriteExact<T extends IEMStack> extends IEMMapRead<T> { } default T putUnifyExact(T stack) { - T target=getBackingMap().get(stack.getDefinition()); + T target=get(stack.getDefinition()); if(target==null) { putReplace(stack); return stack; @@ -147,7 +143,7 @@ public interface IEMMapWriteExact<T extends IEMStack> extends IEMMapRead<T> { putReplace(stack); return stack; }else { - removeKey(stack); + removeKey(stack.getDefinition()); return null; } } @@ -159,8 +155,8 @@ public interface IEMMapWriteExact<T extends IEMStack> extends IEMMapRead<T> { } default void putUnifyAllExact(IEMMapRead<T> inTreeUnsafe) { - for (T in : inTreeUnsafe.values()) { - putUnifyExact(in); + for (Map.Entry<IEMDefinition, T> in : inTreeUnsafe.entrySet()) { + putUnifyExact(in.getValue()); } } } diff --git a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/stacks/EMInstanceStack.java b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/stacks/EMInstanceStack.java index d37a8bd099..0dbd56609e 100644 --- a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/stacks/EMInstanceStack.java +++ b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/stacks/EMInstanceStack.java @@ -38,7 +38,7 @@ public final class EMInstanceStack implements IEMStack { //energy - if positive then particle should try to decay private long energy; //byte color; 0=Red 1=Green 2=Blue 0=Cyan 1=Magenta 2=Yellow, else ignored (-1 - uncolorable) - private int color; + private int color; private double lifeTime; private double lifeTimeMult; @@ -487,46 +487,32 @@ public final class EMInstanceStack implements IEMStack { return this; } - public void addScanShortSymbols(ArrayList<String> lines, int[] detailsOnDepthLevels) { - int capabilities = detailsOnDepthLevels[0]; - getDefinition().addScanShortSymbols(lines, capabilities, energy); - //scanShortSymbolsContents(lines,definition.getSubParticles(),1,detailsOnDepthLevels); - } - - //private void scanShortSymbolsContents(ArrayList<String> lines, cElementalDefinitionStackMap definitions, int depth, int[] detailsOnDepthLevels){ - // if(definitions!=null && depth<detailsOnDepthLevels.length){ - // int deeper=depth+1; - // for(cElementalDefinitionStack definitionStack:definitions.values()) { - // definition.addScanShortSymbols(lines,detailsOnDepthLevels[depth],energy); - // scanSymbolsContents(lines,definitionStack.definition.getSubParticles(),deeper,detailsOnDepthLevels); - // } - // } - //} - public void addScanResults(ArrayList<String> lines, int[] detailsOnDepthLevels) { int capabilities = detailsOnDepthLevels[0]; if (TT_Utility.areBitsSet(SCAN_GET_DEPTH_LEVEL, capabilities)) { - lines.add("DEPTH = " + 0); + lines.add(translateToLocal("tt.keyword.scan.depth") + " = " + 0); } - getDefinition().addScanResults(lines, capabilities, energy); + getDefinition().addScanResults(lines, capabilities, energy, TecTech.definitionsRegistry); + if (TT_Utility.areBitsSet(SCAN_GET_TIMESPAN_MULT, capabilities)) { - lines.add("TIME MULT = " + lifeTimeMult); - if (TT_Utility.areBitsSet(SCAN_GET_TIMESPAN_INFO, capabilities)) { - lines.add("TIME SPAN = " + lifeTime + " s"); - } + lines.add(translateToLocal("tt.keyword.scan.life_mult") + " = " + lifeTimeMult); } if (TT_Utility.areBitsSet(SCAN_GET_AGE, capabilities)) { - lines.add("AGE = " + getAge() + " s"); + lines.add(translateToLocal("tt.keyword.scan.age") + " = " + getAge() + " " + translateToLocal("tt.keyword.unit.time")); } - if (TT_Utility.areBitsSet(SCAN_GET_COLOR, capabilities)) { - lines.add("COLOR = " + color + " RGB or CMY"); + if (TT_Utility.areBitsSet(SCAN_GET_COLOR_VALUE, capabilities)) { + lines.add(translateToLocal("tt.keyword.scan.color") + " = " + color); + } + if (TT_Utility.areBitsSet(SCAN_GET_ENERGY, capabilities)) { + lines.add(translateToLocal("tt.keyword.scan.energy") + " = " + getDefinition().getEnergyDiffBetweenStates(0, energy) + " " + translateToLocal("tt.keyword.unit.energy")); } if (TT_Utility.areBitsSet(SCAN_GET_ENERGY_LEVEL, capabilities)) { - lines.add("ENERGY = " + energy); + lines.add(translateToLocal("tt.keyword.scan.energyLevel") + " = " + energy); } if (TT_Utility.areBitsSet(SCAN_GET_AMOUNT, capabilities)) { - lines.add("AMOUNT = " + getAmount() /AVOGADRO_CONSTANT + " "+translateToLocal("tt.keyword.mol")); + lines.add(translateToLocal("tt.keyword.scan.amount") + " = " + getAmount() / AVOGADRO_CONSTANT + " " + translateToLocal("tt.keyword.unit.mol")); } + scanContents(lines, getDefinition().getSubParticles(), 1, detailsOnDepthLevels); } @@ -536,11 +522,11 @@ public final class EMInstanceStack implements IEMStack { for (EMDefinitionStack definitionStack : definitions.valuesToArray()) { lines.add("");//def separator if (TT_Utility.areBitsSet(SCAN_GET_DEPTH_LEVEL, detailsOnDepthLevels[depth])) { - lines.add("DEPTH = " + depth); + lines.add(translateToLocal("tt.keyword.scan.depth") +" = " + depth); } - getDefinition().addScanResults(lines, detailsOnDepthLevels[depth], energy); + getDefinition().addScanResults(lines, detailsOnDepthLevels[depth], energy, TecTech.definitionsRegistry); if (TT_Utility.areBitsSet(SCAN_GET_AMOUNT, detailsOnDepthLevels[depth])) { - lines.add("AMOUNT = " + definitionStack.getAmount()); + lines.add(translateToLocal("tt.keyword.scan.count")+" = " + definitionStack.getAmount()); } scanContents(lines, definitionStack.getDefinition().getSubParticles(), deeper, detailsOnDepthLevels); } @@ -551,10 +537,10 @@ public final class EMInstanceStack implements IEMStack { NBTTagCompound nbt = new NBTTagCompound(); nbt.setTag("d", getDefinition().toNBT(registry)); nbt.setDouble("Q", getAmount()); - nbt.setDouble("M", lifeTimeMult); + nbt.setDouble("M", getLifeTimeMultiplier()); nbt.setDouble("A", getAge()); - nbt.setLong("e", energy); - nbt.setInteger("c", color); + nbt.setLong("e", getEnergy()); + nbt.setInteger("c", getColor()); return nbt; } @@ -588,7 +574,7 @@ public final class EMInstanceStack implements IEMStack { @Override public String toString() { - return getDefinition().toString() + ' ' + getAmount() /AVOGADRO_CONSTANT + " "+translateToLocal("tt.keyword.mol")+" " + getMass()+" eV/c^2"; + return getDefinition().toString() + ' ' + getAmount() / AVOGADRO_CONSTANT + " " + translateToLocal("tt.keyword.unit.mol") + " " + getMass() + " "+translateToLocal("tt.keyword.unit.mass"); } public void setAmount(double amount) { diff --git a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/complex/EMAtomDefinition.java b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/complex/EMAtomDefinition.java index 20e58216c1..e14a034b81 100644 --- a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/complex/EMAtomDefinition.java +++ b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/complex/EMAtomDefinition.java @@ -14,7 +14,6 @@ import com.github.technus.tectech.mechanics.elementalMatter.core.transformations import com.github.technus.tectech.mechanics.elementalMatter.definitions.primitive.EMGaugeBosonDefinition; import com.github.technus.tectech.mechanics.elementalMatter.definitions.primitive.EMLeptonDefinition; import com.github.technus.tectech.mechanics.elementalMatter.definitions.primitive.EMNeutrinoDefinition; -import com.github.technus.tectech.util.TT_Utility; import com.github.technus.tectech.util.XSTR; import java.util.*; @@ -23,7 +22,6 @@ import static com.github.technus.tectech.loader.TecTechConfig.DEBUG_MODE; import static com.github.technus.tectech.mechanics.elementalMatter.core.transformations.EMTransformationRegistry.EM_COUNT_PER_MATERIAL_AMOUNT_DIMINISHED; import static com.github.technus.tectech.mechanics.elementalMatter.definitions.primitive.EMGaugeBosonDefinition.boson_Y__; import static com.github.technus.tectech.mechanics.elementalMatter.definitions.primitive.EMGaugeBosonDefinition.deadEnd; -import static com.github.technus.tectech.thing.metaTileEntity.multi.GT_MetaTileEntity_EM_scanner.*; import static com.github.technus.tectech.util.XSTR.XSTR_INSTANCE; import static gregtech.api.enums.Materials.*; import static gregtech.api.enums.OrePrefixes.dust; @@ -1366,7 +1364,7 @@ public class EMAtomDefinition extends EMComplexTemplate { } @Override - protected String getIndirectTagValue() { + protected String getTagValue() { return nbtType; } @@ -1673,40 +1671,4 @@ public class EMAtomDefinition extends EMComplexTemplate { public int hashCode() { return hash; } - - @Override - public void addScanShortSymbols(ArrayList<String> lines, int capabilities, long energyLevel) { - if (TT_Utility.areBitsSet(SCAN_GET_NOMENCLATURE | SCAN_GET_CHARGE | SCAN_GET_MASS | SCAN_GET_TIMESPAN_INFO, capabilities)) { - lines.add(getShortSymbol()); - } - } - - @Override - public void addScanResults(ArrayList<String> lines, int capabilities, long energyLevel) { - if (TT_Utility.areBitsSet(SCAN_GET_CLASS_TYPE, capabilities)) { - lines.add("CLASS = " + getIndirectTagValue() + ' ' + getMatterMassType()); - } - if (TT_Utility.areBitsSet(SCAN_GET_NOMENCLATURE | SCAN_GET_CHARGE | SCAN_GET_MASS | SCAN_GET_TIMESPAN_INFO, capabilities)) { - lines.add("NAME = " + getLocalizedName()); - lines.add("SYMBOL = " + getSymbol()); - } - if (TT_Utility.areBitsSet(SCAN_GET_CHARGE, capabilities)) { - lines.add("CHARGE = " + getCharge() / 3D + " e"); - } - if (TT_Utility.areBitsSet(SCAN_GET_COLOR, capabilities)) { - lines.add(hasColor() ? "COLORLESS" : "CARRIES COLOR"); - } - if (TT_Utility.areBitsSet(SCAN_GET_MASS, capabilities)) { - lines.add("MASS = " + getMass() + " eV/c\u00b2"); - } - if (iaeaDefinitionExistsAndHasEnergyLevels && TT_Utility.areBitsSet(SCAN_GET_ENERGY_STATES, capabilities)) { - for (int i = 1; i < getIaea().getEnergeticStatesArray().length; i++) { - lines.add("E LEVEL " + i + " = " + getIaea().getEnergeticStatesArray()[i].energy + " eV"); - } - } - if (TT_Utility.areBitsSet(SCAN_GET_TIMESPAN_INFO, capabilities)) { - lines.add("HALF LIFE = " + getRawTimeSpan(energyLevel) + " s"); - lines.add(" At current energy level"); - } - } } diff --git a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/complex/EMHadronDefinition.java b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/complex/EMHadronDefinition.java index 85cb07ea33..9fb551e45c 100644 --- a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/complex/EMHadronDefinition.java +++ b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/complex/EMHadronDefinition.java @@ -15,7 +15,6 @@ import com.github.technus.tectech.mechanics.elementalMatter.core.transformations import com.github.technus.tectech.mechanics.elementalMatter.core.transformations.EMTransformationRegistry; import com.github.technus.tectech.mechanics.elementalMatter.core.transformations.OreDictionaryStack; import com.github.technus.tectech.mechanics.elementalMatter.definitions.primitive.EMQuarkDefinition; -import com.github.technus.tectech.util.TT_Utility; import gregtech.api.enums.Materials; import gregtech.api.enums.OrePrefixes; import net.minecraftforge.oredict.OreDictionary; @@ -28,7 +27,6 @@ import static com.github.technus.tectech.loader.TecTechConfig.DEBUG_MODE; import static com.github.technus.tectech.mechanics.elementalMatter.core.transformations.EMTransformationRegistry.EM_COUNT_PER_MATERIAL_AMOUNT_DIMINISHED; import static com.github.technus.tectech.mechanics.elementalMatter.definitions.primitive.EMGaugeBosonDefinition.boson_Y__; import static com.github.technus.tectech.mechanics.elementalMatter.definitions.primitive.EMGaugeBosonDefinition.deadEnd; -import static com.github.technus.tectech.thing.metaTileEntity.multi.GT_MetaTileEntity_EM_scanner.*; import static net.minecraft.util.StatCollector.translateToLocal; /** @@ -371,7 +369,7 @@ public class EMHadronDefinition extends EMComplexTemplate {//TODO Optimize map i } @Override - protected String getIndirectTagValue() { + protected String getTagValue() { return nbtType; } @@ -459,37 +457,6 @@ public class EMHadronDefinition extends EMComplexTemplate {//TODO Optimize map i return hash; } - @Override - public void addScanShortSymbols(ArrayList<String> lines, int capabilities, long energyLevel) { - if (TT_Utility.areBitsSet(SCAN_GET_NOMENCLATURE | SCAN_GET_CHARGE | SCAN_GET_MASS | SCAN_GET_TIMESPAN_INFO, capabilities)) { - lines.add(getShortSymbol()); - } - } - - @Override - public void addScanResults(ArrayList<String> lines, int capabilities, long energyLevel) { - if (TT_Utility.areBitsSet(SCAN_GET_CLASS_TYPE, capabilities)) { - lines.add("CLASS = " + getIndirectTagValue() + ' ' + getMatterMassType()); - } - if (TT_Utility.areBitsSet(SCAN_GET_NOMENCLATURE | SCAN_GET_CHARGE | SCAN_GET_MASS | SCAN_GET_TIMESPAN_INFO, capabilities)) { - lines.add("NAME = " + getLocalizedTypeName()); - //lines.add("SYMBOL = "+getSymbol()); - } - if (TT_Utility.areBitsSet(SCAN_GET_CHARGE, capabilities)) { - lines.add("CHARGE = " + getCharge() / 3D + " e"); - } - if (TT_Utility.areBitsSet(SCAN_GET_COLOR, capabilities)) { - lines.add(hasColor() ? "COLORLESS" : "CARRIES COLOR"); - } - if (TT_Utility.areBitsSet(SCAN_GET_MASS, capabilities)) { - lines.add("MASS = " + getMass() + " eV/c\u00b2"); - } - if (TT_Utility.areBitsSet(SCAN_GET_TIMESPAN_INFO, capabilities)) { - lines.add("HALF LIFE = " + getRawTimeSpan(energyLevel) + " s"); - lines.add(" " + "At current energy level"); - } - } - public double getRawLifeTime() { return rawLifeTime; } diff --git a/src/main/java/com/github/technus/tectech/proxy/ClientProxy.java b/src/main/java/com/github/technus/tectech/proxy/ClientProxy.java index d7baec4ef5..043bd87a21 100644 --- a/src/main/java/com/github/technus/tectech/proxy/ClientProxy.java +++ b/src/main/java/com/github/technus/tectech/proxy/ClientProxy.java @@ -38,6 +38,7 @@ public class ClientProxy extends CommonProxy { MinecraftForgeClient.registerItemRenderer(ElementalDefinitionContainer_EM.INSTANCE, RenderElementalName.INSTANCE); MinecraftForgeClient.registerItemRenderer(DebugElementalInstanceContainer_EM.INSTANCE, RenderElementalName.INSTANCE); + //MinecraftForgeClient.registerItemRenderer(ElementalDefinitionScanStorage_EM.INSTANCE, RenderElementalName.INSTANCE); if(Loader.isModLoaded("openmodularturrets")) { new TT_turret_loader().run(); 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 index 7d7880adca..c19ec6dda1 100644 --- 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 @@ -51,8 +51,8 @@ public final class DebugElementalInstanceContainer_EM extends Item implements IE @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); + NBTTagCompound tNBT = aStack.getTagCompound(); + TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); if (aPlayer instanceof EntityPlayerMP) { aStack.stackSize = 1; if (tTileEntity instanceof IGregTechTileEntity) { @@ -61,7 +61,7 @@ public final class DebugElementalInstanceContainer_EM extends Item implements IE EMInstanceStackMap content = ((IEMContainer) metaTE).getContentHandler(); if (tNBT.hasKey("content")) { try { - content.putUnifyAll(EMInstanceStackMap.fromNBT(TecTech.definitionsRegistry,tNBT.getCompoundTag("content"))); + content.putUnifyAll(EMInstanceStackMap.fromNBT(TecTech.definitionsRegistry, tNBT.getCompoundTag("content"))); } catch (EMException e) { if (DEBUG_MODE) { e.printStackTrace(); @@ -71,12 +71,10 @@ public final class DebugElementalInstanceContainer_EM extends Item implements IE ((IEMContainer) metaTE).purgeOverflow(); tNBT.removeTag("content"); tNBT.removeTag("symbols"); - tNBT.removeTag("info"); } else if (content.hasStacks()) { ((IEMContainer) metaTE).purgeOverflow(); - tNBT.setTag("info", content.getInfoNBT()); tNBT.setTag("content", content.toNBT(TecTech.definitionsRegistry)); - tNBT.setTag("symbols", content.getShortSymbolsNBT()); + tNBT.setTag("symbols", TT_Utility.packStrings(content.getShortSymbolsInfo())); content.clear(); } return true; @@ -86,30 +84,14 @@ public final class DebugElementalInstanceContainer_EM extends Item implements IE return aPlayer instanceof EntityPlayerMP; } - public ItemStack setContent(ItemStack aStack, EMInstanceStackMap content){ + public ItemStack setContent(ItemStack aStack, EMInstanceStackMap content) { NBTTagCompound tNBT = aStack.getTagCompound(); - if(tNBT==null){ - tNBT=new NBTTagCompound(); + if (tNBT == null) { + tNBT = new NBTTagCompound(); aStack.setTagCompound(tNBT); } - if (tNBT.hasKey("content")) { - try { - content.putUnifyAll(EMInstanceStackMap.fromNBT(TecTech.definitionsRegistry,tNBT.getCompoundTag("content"))); - } catch (EMException e) { - if (DEBUG_MODE) { - e.printStackTrace(); - } - return aStack; - } - tNBT.removeTag("content"); - tNBT.removeTag("info"); - tNBT.removeTag("symbols"); - } else if (content.hasStacks()) { - tNBT.setTag("info", content.getInfoNBT()); - tNBT.setTag("content", content.toNBT(TecTech.definitionsRegistry)); - tNBT.setTag("symbols", content.getShortSymbolsNBT()); - content.clear(); - } + tNBT.setTag("content", content.toNBT(TecTech.definitionsRegistry)); + tNBT.setTag("symbols", TT_Utility.packStrings(content.getShortSymbolsInfo())); return aStack; } @@ -118,14 +100,18 @@ public final class DebugElementalInstanceContainer_EM extends Item implements IE aList.add(CommonValues.TEC_MARK_EM); try { NBTTagCompound tNBT = aStack.getTagCompound(); - if (tNBT != null && tNBT.hasKey("info")) { + if (tNBT != null && tNBT.hasKey("content")) { aList.add(translateToLocal("item.em.debugContainer.desc.0") + ": ");//Contains - Collections.addAll(aList, TT_Utility.infoFromNBT(tNBT.getCompoundTag("info"))); + EMInstanceStackMap content = EMInstanceStackMap.fromNBT(TecTech.definitionsRegistry, tNBT.getCompoundTag("content")); + Collections.addAll(aList, content.getElementalInfo()); } else { aList.add(translateToLocal("item.em.debugContainer.desc.1"));//Container for elemental matter - aList.add(EnumChatFormatting.BLUE + translateToLocal("item.em.debugContainer.desc.2"));//Right click on elemental hatches } + aList.add(EnumChatFormatting.BLUE + translateToLocal("item.em.debugContainer.desc.2"));//Right click on elemental hatches } catch (Exception e) { + if (DEBUG_MODE) { + e.printStackTrace(); + } aList.add(translateToLocal("item.em.debugContainer.desc.3"));//---Unexpected Termination--- } } @@ -140,32 +126,17 @@ public final class DebugElementalInstanceContainer_EM extends Item implements IE ItemStack that = new ItemStack(this, 1); that.setTagCompound(new NBTTagCompound()); list.add(that); - for(IEMDefinition definition: TecTech.definitionsRegistry.getStacksRegisteredForDisplay()){ - list.add(setContent(new ItemStack(this).setStackDisplayName(definition.getLocalizedName()+" "+1+" "+translateToLocal("tt.keyword.mbMols")), + for (IEMDefinition definition : TecTech.definitionsRegistry.getStacksRegisteredForDisplay()) { + list.add(setContent(new ItemStack(this).setStackDisplayName(definition.getLocalizedName() + " " + 1 + " " + translateToLocal("tt.keyword.unit.mbMols")), new EMInstanceStackMap(new EMInstanceStack(definition, EM_COUNT_PER_MATERIAL_AMOUNT)))); - list.add(setContent(new ItemStack(this).setStackDisplayName(definition.getLocalizedName()+" "+1+" "+translateToLocal("tt.keyword.itemMols")), + list.add(setContent(new ItemStack(this).setStackDisplayName(definition.getLocalizedName() + " " + 1 + " " + translateToLocal("tt.keyword.unit.itemMols")), new EMInstanceStackMap(new EMInstanceStack(definition, EM_COUNT_PER_ITEM)))); - list.add(setContent(new ItemStack(this).setStackDisplayName(definition.getLocalizedName()+" "+1000+" "+translateToLocal("tt.keyword.mbMols")), + list.add(setContent(new ItemStack(this).setStackDisplayName(definition.getLocalizedName() + " " + 1000 + " " + translateToLocal("tt.keyword.unit.mbMols")), new EMInstanceStackMap(new EMInstanceStack(definition, EM_COUNT_PER_1k)))); } } @Override - public String getSymbol(ItemStack aStack, int index) { - try { - NBTTagCompound tNBT = aStack.getTagCompound(); - if (tNBT != null && tNBT.hasKey("symbols")) { - String[] strings= TT_Utility.infoFromNBT(tNBT.getCompoundTag("symbols")); - return strings[index%strings.length]; - } else { - return null; - } - } catch (Exception e) { - return "#!"; - } - } - - @Override @SideOnly(CLIENT) public FontRenderer getFontRenderer(ItemStack stack) { return TecTechFontRender.INSTANCE; 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 index dede2e36ce..85a853e8aa 100644 --- 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 @@ -4,6 +4,7 @@ import com.github.technus.tectech.TecTech; import com.github.technus.tectech.font.TecTechFontRender; import com.github.technus.tectech.mechanics.elementalMatter.core.EMException; import com.github.technus.tectech.mechanics.elementalMatter.core.maps.EMConstantStackMap; +import com.github.technus.tectech.mechanics.elementalMatter.core.maps.EMDefinitionStackMap; import com.github.technus.tectech.thing.item.renderElemental.IElementalItem; import com.github.technus.tectech.util.CommonValues; import com.github.technus.tectech.util.TT_Utility; @@ -38,30 +39,14 @@ public final class ElementalDefinitionContainer_EM extends Item implements IElem setCreativeTab(creativeTabEM); } - //return previous thing - public static EMConstantStackMap setContent(ItemStack containerItem, EMConstantStackMap definitions){ - if(containerItem.getItem() instanceof ElementalDefinitionContainer_EM) { - NBTTagCompound tNBT = containerItem.stackTagCompound; - if (tNBT == null) { - tNBT = containerItem.stackTagCompound = new NBTTagCompound(); - } - - EMConstantStackMap oldMap =null; - if (tNBT.hasKey("content")) { - try { - oldMap= EMConstantStackMap.fromNBT(TecTech.definitionsRegistry,tNBT.getCompoundTag("content")); - } catch (EMException e) { - if (DEBUG_MODE) { - e.printStackTrace(); - } - } - } - tNBT.setTag("info", definitions.getInfoNBT()); - tNBT.setTag("content", definitions.toNBT(TecTech.definitionsRegistry)); - tNBT.setTag("symbols",definitions.getShortSymbolsNBT()); - return oldMap; + public static void setContent(ItemStack aStack, EMConstantStackMap definitions){ + NBTTagCompound tNBT = aStack.getTagCompound(); + if (tNBT == null) { + tNBT = new NBTTagCompound(); + aStack.setTagCompound(tNBT); } - return null; + tNBT.setTag("content", definitions.toNBT(TecTech.definitionsRegistry)); + tNBT.setTag("symbols", TT_Utility.packStrings(definitions.getShortSymbolsInfo())); } public static EMConstantStackMap getContent(ItemStack containerItem){ @@ -99,7 +84,6 @@ public final class ElementalDefinitionContainer_EM extends Item implements IElem } } } - tNBT.removeTag("info"); tNBT.removeTag("content"); tNBT.removeTag("symbols"); return oldMap; @@ -112,9 +96,10 @@ public final class ElementalDefinitionContainer_EM extends Item implements IElem aList.add(CommonValues.TEC_MARK_EM); try { NBTTagCompound tNBT = aStack.getTagCompound(); - if (tNBT != null && tNBT.hasKey("info")) { + if (tNBT != null && tNBT.hasKey("content")) { aList.add(translateToLocal("item.em.definitionContainer.desc.0") + ": ");//Should Contain - Collections.addAll(aList, TT_Utility.infoFromNBT(tNBT.getCompoundTag("info"))); + EMDefinitionStackMap content = EMDefinitionStackMap.fromNBT(TecTech.definitionsRegistry, tNBT.getCompoundTag("content")); + Collections.addAll(aList, content.getElementalInfo()); } else { aList.add(translateToLocal("item.em.definitionContainer.desc.1"));//Recipe Hint } @@ -136,21 +121,6 @@ public final class ElementalDefinitionContainer_EM extends Item implements IElem } @Override - public String getSymbol(ItemStack aStack, int index) { - try { - NBTTagCompound tNBT = aStack.getTagCompound(); - if (tNBT != null && tNBT.hasKey("symbols")) { - String[] strings= TT_Utility.infoFromNBT(tNBT.getCompoundTag("symbols")); - return strings[index%strings.length]; - } else { - return null; - } - } catch (Exception e) { - return "#!"; - } - } - - @Override @SideOnly(CLIENT) public FontRenderer getFontRenderer(ItemStack stack) { return TecTechFontRender.INSTANCE; 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 22fc6e65a9..976b034455 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 @@ -5,9 +5,7 @@ import com.github.technus.tectech.font.TecTechFontRender; import com.github.technus.tectech.loader.gui.ModGuiHandler; import com.github.technus.tectech.mechanics.elementalMatter.core.maps.EMInstanceStackMap; import com.github.technus.tectech.thing.CustomItemList; -import com.github.technus.tectech.thing.item.renderElemental.IElementalItem; import com.github.technus.tectech.util.CommonValues; -import com.github.technus.tectech.util.TT_Utility; import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; @@ -22,6 +20,7 @@ import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.IIcon; import net.minecraft.world.World; +import java.util.ArrayList; import java.util.List; import static com.github.technus.tectech.Reference.MODID; @@ -32,7 +31,7 @@ import static net.minecraft.util.StatCollector.translateToLocal; /** * Created by Tec on 15.03.2017. */ -public final class ElementalDefinitionScanStorage_EM extends Item implements IElementalItem { +public final class ElementalDefinitionScanStorage_EM extends Item { public static ElementalDefinitionScanStorage_EM INSTANCE; public static IIcon offline, online; @@ -44,14 +43,14 @@ public final class ElementalDefinitionScanStorage_EM extends Item implements IEl } //return previous thing - public static void setContent(ItemStack containerItem, EMInstanceStackMap definitions, int[] detailsOnDepthLevels){ - if(containerItem.getItem() instanceof ElementalDefinitionScanStorage_EM) { - if (containerItem.stackTagCompound == null) { - containerItem.stackTagCompound = new NBTTagCompound(); - } - containerItem.stackTagCompound.setTag("elementalInfo", definitions.getScanInfoNBT(detailsOnDepthLevels)); - containerItem.stackTagCompound.setTag("symbols",definitions.getScanShortSymbolsNBT(detailsOnDepthLevels)); + public static void setContent(ItemStack aStack, EMInstanceStackMap instances, int[] detailsOnDepthLevels){ + NBTTagCompound tNBT = aStack.getTagCompound(); + if (tNBT == null) { + tNBT = new NBTTagCompound(); + aStack.setTagCompound(tNBT); } + tNBT.setTag("content", instances.toNBT(TecTech.definitionsRegistry)); + tNBT.setIntArray("scanConfiguration", detailsOnDepthLevels); } public static void clearContent(ItemStack containerItem){ @@ -63,9 +62,10 @@ public final class ElementalDefinitionScanStorage_EM extends Item implements IEl } } - public static String[] getLines(ItemStack containerItem){ - if(containerItem.stackTagCompound!=null && containerItem.stackTagCompound.hasKey("elementalInfo")) { - return TT_Utility.infoFromNBT(containerItem.stackTagCompound.getCompoundTag("elementalInfo")); + public static ArrayList<String> getLines(ItemStack containerItem){ + if(containerItem.stackTagCompound!=null && containerItem.stackTagCompound.hasKey("content")) { + EMInstanceStackMap contenet = EMInstanceStackMap.fromNBT(TecTech.definitionsRegistry, containerItem.stackTagCompound.getCompoundTag("contenet")); + return contenet.getScanInfo(containerItem.stackTagCompound.getIntArray("scanConfiguration")); } return null; } @@ -73,19 +73,11 @@ public final class ElementalDefinitionScanStorage_EM extends Item implements IEl @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(EnumChatFormatting.BLUE + translateToLocal("item.em.definitionScanStorage.desc.0"));//Contains scan result - aList.add(translateToLocal("item.em.definitionScanStorage.desc.1"));//Use to read - //if(DEBUG_MODE) { - // aList.add("DEBUG MODE INFO - U CHEATER"); - // Collections.addAll(aList, Util.infoFromNBT(aStack.stackTagCompound.getCompoundTag("elementalInfo"))); - //} - } else { - aList.add(translateToLocal("item.em.definitionScanStorage.desc.2"));//Storage for matter scan data - } - } catch (Exception e) { - aList.add(translateToLocal("item.em.definitionScanStorage.desc.3"));//---Unexpected Termination--- + if (aStack.stackTagCompound != null && aStack.stackTagCompound.hasKey("content")) { + aList.add(EnumChatFormatting.BLUE + translateToLocal("item.em.definitionScanStorage.desc.0"));//Contains scan result + aList.add(translateToLocal("item.em.definitionScanStorage.desc.1"));//Use to read + } else { + aList.add(translateToLocal("item.em.definitionScanStorage.desc.2"));//Storage for matter scan data } } @@ -105,19 +97,13 @@ public final class ElementalDefinitionScanStorage_EM extends Item implements IEl @Override public IIcon getIconIndex(ItemStack itemStack) { NBTTagCompound tagCompound=itemStack.stackTagCompound; - if(tagCompound!=null && tagCompound.hasKey("elementalInfo")) { - return online; - } - return offline; + return tagCompound != null && tagCompound.hasKey("content") ? online : offline; } @Override public IIcon getIcon(ItemStack itemStack, int pass) { NBTTagCompound tagCompound=itemStack.stackTagCompound; - if(tagCompound!=null && tagCompound.hasKey("elementalInfo")) { - return online; - } - return offline; + return tagCompound != null && tagCompound.hasKey("content") ? online : offline; } @Override @@ -130,7 +116,7 @@ public final class ElementalDefinitionScanStorage_EM extends Item implements IEl public ItemStack onItemRightClick(ItemStack itemStack, World world, EntityPlayer player) { if(world.isRemote){ NBTTagCompound tagCompound=itemStack.stackTagCompound; - if(tagCompound!=null && tagCompound.hasKey("elementalInfo")) { + if(tagCompound!=null && tagCompound.hasKey("content")) { player.openGui(TecTech.instance, ModGuiHandler.SCAN_DISPLAY_SCREEN_ID, world, 0, 0, 0); } } @@ -138,21 +124,6 @@ public final class ElementalDefinitionScanStorage_EM extends Item implements IEl } @Override - public String getSymbol(ItemStack aStack, int index) { - try { - NBTTagCompound tNBT = aStack.getTagCompound(); - if (tNBT != null && tNBT.hasKey("symbols")) { - String[] strings= TT_Utility.infoFromNBT(tNBT.getCompoundTag("symbols")); - return strings[index%strings.length]; - } else { - return null; - } - } catch (Exception e) { - return "#!"; - } - } - - @Override @SideOnly(CLIENT) public FontRenderer getFontRenderer(ItemStack stack) { return TecTechFontRender.INSTANCE; diff --git a/src/main/java/com/github/technus/tectech/thing/item/gui/ScanDisplayScreen.java b/src/main/java/com/github/technus/tectech/thing/item/gui/ScanDisplayScreen.java index 20f59b56e2..b4300c763c 100644 --- a/src/main/java/com/github/technus/tectech/thing/item/gui/ScanDisplayScreen.java +++ b/src/main/java/com/github/technus/tectech/thing/item/gui/ScanDisplayScreen.java @@ -11,6 +11,8 @@ import net.minecraft.client.gui.GuiScreen; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.util.ResourceLocation; +import java.util.Objects; + import static com.github.technus.tectech.Reference.MODID; import static org.lwjgl.opengl.GL11.*; @@ -18,24 +20,26 @@ import static org.lwjgl.opengl.GL11.*; * Created by danie_000 on 17.12.2017. */ public class ScanDisplayScreen extends GuiScreen { - private static final int sizeX=240,sizeY=220, renderedLines =10; - private int baseX,baseY; - private Button up,down,pgUp,pgDown; + private static final int sizeX = 240, sizeY = 220, renderedLines = 10; + private int baseX, baseY; + private Button up, down, pgUp, pgDown; private final String[] lines; - private int firstLine; + private int firstLine; - private static final ResourceLocation[] BACKGROUNDS =new ResourceLocation[]{new ResourceLocation(MODID+":textures/gui/scanDisplayScreen1.png"), - new ResourceLocation(MODID+":textures/gui/scanDisplayScreen2.png"), - new ResourceLocation(MODID+":textures/gui/scanDisplayScreen3.png"), - new ResourceLocation(MODID+":textures/gui/scanDisplayScreen4.png"), - new ResourceLocation(MODID+":textures/gui/scanDisplayScreen5.png"), - new ResourceLocation(MODID+":textures/gui/scanDisplayScreen6.png"), - new ResourceLocation(MODID+":textures/gui/scanDisplayScreen7.png"), - new ResourceLocation(MODID+":textures/gui/scanDisplayScreen8.png")}; - private static final ResourceLocation ITEM =new ResourceLocation(MODID+":textures/gui/scanDisplayItem.png"); + private static final ResourceLocation[] BACKGROUNDS = new ResourceLocation[]{ + new ResourceLocation(MODID + ":textures/gui/scanDisplayScreen1.png"), + new ResourceLocation(MODID + ":textures/gui/scanDisplayScreen2.png"), + new ResourceLocation(MODID + ":textures/gui/scanDisplayScreen3.png"), + new ResourceLocation(MODID + ":textures/gui/scanDisplayScreen4.png"), + new ResourceLocation(MODID + ":textures/gui/scanDisplayScreen5.png"), + new ResourceLocation(MODID + ":textures/gui/scanDisplayScreen6.png"), + new ResourceLocation(MODID + ":textures/gui/scanDisplayScreen7.png"), + new ResourceLocation(MODID + ":textures/gui/scanDisplayScreen8.png")}; + private static final ResourceLocation ITEM = + new ResourceLocation(MODID + ":textures/gui/scanDisplayItem.png"); - public ScanDisplayScreen(EntityPlayer player){ - lines=ElementalDefinitionScanStorage_EM.getLines(player.getHeldItem()); + public ScanDisplayScreen(EntityPlayer player) { + lines = Objects.requireNonNull(ElementalDefinitionScanStorage_EM.getLines(player.getHeldItem())).toArray(new String[0]); } @Override @@ -43,48 +47,48 @@ public class ScanDisplayScreen extends GuiScreen { glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); mc.getTextureManager().bindTexture(ITEM); - long tick=System.currentTimeMillis()/150; - int itick=(int)(tick%12); - drawTexturedModalRect(baseX+99,baseY+189,32*(itick/6),32*(itick%6), 32, 32); - mc.getTextureManager().bindTexture(BACKGROUNDS[(int)(tick%8)]); - drawTexturedModalRect(baseX,baseY,0,0, sizeX, sizeY); + long tick = System.currentTimeMillis() / 150; + int itick = (int) (tick % 12); + drawTexturedModalRect(baseX + 99, baseY + 189, 32 * (itick / 6), 32 * (itick % 6), 32, 32); + mc.getTextureManager().bindTexture(BACKGROUNDS[(int) (tick % 8)]); + drawTexturedModalRect(baseX, baseY, 0, 0, sizeX, sizeY); glDisable(GL_BLEND); - super.drawScreen(x,y,partialTicks); + super.drawScreen(x, y, partialTicks); - itick=(TecTech.RANDOM.nextInt(0x66)<<16)+0x77EEFF; - int textBaseX=baseX+20; - int textBaseXX=baseX+95; - int textBaseY=baseY+28; - for(int i=firstLine-1, j=8;i>=0 && j!=0;i--,j/=2){ - int equalPos=lines[i].indexOf('='); - if(equalPos>=0){ - TecTechFontRender.INSTANCE.drawSplitString(lines[i].substring(0,equalPos), textBaseX, textBaseY - 8 + j, 200, itick); + itick = (TecTech.RANDOM.nextInt(0x66) << 16) + 0x77EEFF; + int textBaseX = baseX + 20; + int textBaseXX = baseX + 95; + int textBaseY = baseY + 28; + for (int i = firstLine - 1, j = 8; i >= 0 && j != 0; i--, j /= 2) { + int equalPos = lines[i].indexOf('='); + if (equalPos >= 0) { + TecTechFontRender.INSTANCE.drawSplitString(lines[i].substring(0, equalPos), textBaseX, textBaseY - 8 + j, 200, itick); TecTechFontRender.INSTANCE.drawSplitString(lines[i].substring(equalPos), textBaseXX, textBaseY - 8 + j, 200, itick); - }else { + } else { TecTechFontRender.INSTANCE.drawSplitString(lines[i], textBaseX, textBaseY - 8 + j, 200, itick); } } - for(int i = firstLine, j = 0; i<lines.length && j< renderedLines; i++,j++){ + for (int i = firstLine, j = 0; i < lines.length && j < renderedLines; i++, j++) { textBaseY += 9; - int equalPos=lines[i].indexOf('='); - if(equalPos>=0){ - TecTechFontRender.INSTANCE.drawSplitString(lines[i].substring(0,equalPos), textBaseX, textBaseY, 200, itick); + int equalPos = lines[i].indexOf('='); + if (equalPos >= 0) { + TecTechFontRender.INSTANCE.drawSplitString(lines[i].substring(0, equalPos), textBaseX, textBaseY, 200, itick); TecTechFontRender.INSTANCE.drawSplitString(lines[i].substring(equalPos), textBaseXX, textBaseY, 200, itick); - }else { + } else { TecTechFontRender.INSTANCE.drawSplitString(lines[i], textBaseX, textBaseY, 200, itick); } } - for(int i = firstLine+ renderedLines, j = 8; i<lines.length && j!=0; i++,j/=2){ - int equalPos=lines[i].indexOf('='); - if(equalPos>=0){ - TecTechFontRender.INSTANCE.drawSplitString(lines[i].substring(0,equalPos), textBaseX, textBaseY + 17 - j, 200, itick); + for (int i = firstLine + renderedLines, j = 8; i < lines.length && j != 0; i++, j /= 2) { + int equalPos = lines[i].indexOf('='); + if (equalPos >= 0) { + TecTechFontRender.INSTANCE.drawSplitString(lines[i].substring(0, equalPos), textBaseX, textBaseY + 17 - j, 200, itick); TecTechFontRender.INSTANCE.drawSplitString(lines[i].substring(equalPos), textBaseXX, textBaseY + 17 - j, 200, itick); - }else { + } else { TecTechFontRender.INSTANCE.drawSplitString(lines[i], textBaseX, textBaseY + 17 - j, 200, itick); } } - TecTechFontRender.INSTANCE.drawSplitString(Integer.toString(firstLine), textBaseX, baseY+146, 200, itick); - TecTechFontRender.INSTANCE.drawSplitString(Integer.toString(lines.length), textBaseX, baseY+157, 200, itick); + TecTechFontRender.INSTANCE.drawSplitString(Integer.toString(firstLine), textBaseX, baseY + 146, 200, itick); + TecTechFontRender.INSTANCE.drawSplitString(Integer.toString(lines.length), textBaseX, baseY + 157, 200, itick); } @Override @@ -94,13 +98,13 @@ public class ScanDisplayScreen extends GuiScreen { @Override public void initGui() { - baseX=(width- sizeX)/2; - baseY=(height- sizeY)/2-12; - int buttonBaseY=baseY+145; - buttonList.add(pgUp= new Button(0, baseX + 77, buttonBaseY, 0, 220)); - buttonList.add(up= new Button(1, baseX + 99, buttonBaseY, 20, 220)); - buttonList.add(down= new Button(2, baseX + 121, buttonBaseY, 40, 220)); - buttonList.add(pgDown= new Button(3, baseX + 143, buttonBaseY, 60, 220)); + baseX = (width - sizeX) / 2; + baseY = (height - sizeY) / 2 - 12; + int buttonBaseY = baseY + 145; + buttonList.add(pgUp = new Button(0, baseX + 77, buttonBaseY, 0, 220)); + buttonList.add(up = new Button(1, baseX + 99, buttonBaseY, 20, 220)); + buttonList.add(down = new Button(2, baseX + 121, buttonBaseY, 40, 220)); + buttonList.add(pgDown = new Button(3, baseX + 143, buttonBaseY, 60, 220)); } @Override @@ -125,19 +129,18 @@ public class ScanDisplayScreen extends GuiScreen { } } - private static class Button extends GuiButton{ - int u,v; - Button(int id,int x,int y,int u,int v){ - super(id,x,y,20,20,""); - this.u=u; - this.v=v; + private static class Button extends GuiButton { + int u, v; + + Button(int id, int x, int y, int u, int v) { + super(id, x, y, 20, 20, ""); + this.u = u; + this.v = v; } @Override - public void drawButton(Minecraft mc, int xPos, int yPos) - { - if (visible) - { + public void drawButton(Minecraft mc, int xPos, int yPos) { + if (visible) { field_146123_n = xPos >= xPosition && yPos >= yPosition && xPos < xPosition + width && yPos < yPosition + height; glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); @@ -150,9 +153,8 @@ public class ScanDisplayScreen extends GuiScreen { //play cool sound fx @Override - public void func_146113_a(SoundHandler soundHandler) - { - soundHandler.playSound(PositionedSoundRecord.func_147674_a(new ResourceLocation(MODID+":fx_click"), 1.0F)); + public void func_146113_a(SoundHandler soundHandler) { + soundHandler.playSound(PositionedSoundRecord.func_147674_a(new ResourceLocation(MODID + ":fx_click"), 1.0F)); } } } diff --git a/src/main/java/com/github/technus/tectech/thing/item/renderElemental/IElementalItem.java b/src/main/java/com/github/technus/tectech/thing/item/renderElemental/IElementalItem.java index ab68691eaa..37dce47e5f 100644 --- a/src/main/java/com/github/technus/tectech/thing/item/renderElemental/IElementalItem.java +++ b/src/main/java/com/github/technus/tectech/thing/item/renderElemental/IElementalItem.java @@ -1,7 +1,21 @@ package com.github.technus.tectech.thing.item.renderElemental; import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; + +import static com.github.technus.tectech.util.TT_Utility.getSomeString; public interface IElementalItem { - String getSymbol(ItemStack stack,int index); + default String getSymbol(ItemStack stack,int index){ + try { + NBTTagCompound tNBT = stack.getTagCompound(); + if (tNBT != null && tNBT.hasKey("symbols")) { + return getSomeString(tNBT.getCompoundTag("symbols"),index); + } else { + return null; + } + } catch (Exception e) { + return "#!"; + } + } } diff --git a/src/main/java/com/github/technus/tectech/thing/item/renderElemental/RenderElementalName.java b/src/main/java/com/github/technus/tectech/thing/item/renderElemental/RenderElementalName.java index bfb1a188d8..e897f615ad 100644 --- a/src/main/java/com/github/technus/tectech/thing/item/renderElemental/RenderElementalName.java +++ b/src/main/java/com/github/technus/tectech/thing/item/renderElemental/RenderElementalName.java @@ -32,10 +32,10 @@ public class RenderElementalName implements IItemRenderer { for (int i = 0; i < item.getRenderPasses(itemStack.getItemDamage()); i++) { IIcon icon = item.getIcon(itemStack, i); tessellator.startDrawingQuads(); - tessellator.addVertexWithUV(0.0, 0.0, 0.0, (double)icon.getMinU(), (double)icon.getMinV()); - tessellator.addVertexWithUV(0.0, 16, 0.0, (double)icon.getMinU(), (double)icon.getMaxV()); - tessellator.addVertexWithUV(16, 16, 0.0, (double)icon.getMaxU(), (double)icon.getMaxV()); - tessellator.addVertexWithUV(16, 0.0, 0.0, (double)icon.getMaxU(), (double)icon.getMinV()); + tessellator.addVertexWithUV(0.0, 0.0, 0.0, icon.getMinU(), icon.getMinV()); + tessellator.addVertexWithUV(0.0, 16, 0.0, icon.getMinU(), icon.getMaxV()); + tessellator.addVertexWithUV(16, 16, 0.0, icon.getMaxU(), icon.getMaxV()); + tessellator.addVertexWithUV(16, 0.0, 0.0, icon.getMaxU(), icon.getMinV()); tessellator.draw(); //ItemRenderer.renderItemIn2D(Tessellator.instance, icon.getMaxU(), icon.getMinV(), icon.getMinU(), icon.getMaxV(), icon.getIconWidth(), icon.getIconHeight(), 0.0625f); } diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_OverflowElemental.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_OverflowElemental.java index 5223ca5b5b..0d5347a87e 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_OverflowElemental.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_OverflowElemental.java @@ -88,8 +88,8 @@ public class GT_MetaTileEntity_Hatch_OverflowElemental extends GT_MetaTileEntity return new String[]{ CommonValues.TEC_MARK_EM, mDescription, - translateToLocal("gt.blockmachines.hatch.emmuffler.desc.1") + ": " + EnumChatFormatting.AQUA + TT_Utility.formatNumberShortExp(overflowMax) + " eV/c\u00b2", - translateToLocal("gt.blockmachines.hatch.emmuffler.desc.2") + ": " + EnumChatFormatting.AQUA + TT_Utility.formatNumberShortExp(overflowDisperse) + " (eV/c\u00b2)/s", + translateToLocal("gt.blockmachines.hatch.emmuffler.desc.1") + ": " + EnumChatFormatting.AQUA + TT_Utility.formatNumberShortExp(overflowMax) + " "+translateToLocal("tt.keyword.unit.mass"), + translateToLocal("gt.blockmachines.hatch.emmuffler.desc.2") + ": " + EnumChatFormatting.AQUA + TT_Utility.formatNumberShortExp(overflowDisperse) + " "+translateToLocal("tt.keyword.unit.massFlux"), translateToLocal("gt.blockmachines.hatch.emmuffler.desc.3") }; } @@ -217,10 +217,10 @@ public class GT_MetaTileEntity_Hatch_OverflowElemental extends GT_MetaTileEntity public String[] getInfoData() { return new String[]{ translateToLocalFormatted("tt.keyphrase.Contained_mass", clientLocale) + ":", - EnumChatFormatting.RED + TT_Utility.formatNumberExp(overflowMatter) + EnumChatFormatting.RESET + " eV/c\u00b2 /", - EnumChatFormatting.GREEN + TT_Utility.formatNumberShortExp(overflowMax) + EnumChatFormatting.RESET + " eV/c\u00b2", + EnumChatFormatting.RED + TT_Utility.formatNumberExp(overflowMatter) + EnumChatFormatting.RESET + " "+translateToLocal("tt.keyword.unit.mass")+ " / ", + EnumChatFormatting.GREEN + TT_Utility.formatNumberShortExp(overflowMax) + EnumChatFormatting.RESET + " "+translateToLocal("tt.keyword.unit.mass"), translateToLocalFormatted("tt.keyphrase.Mass_Disposal_speed", clientLocale) + ": " + - EnumChatFormatting.BLUE + TT_Utility.formatNumberShortExp(overflowDisperse) + EnumChatFormatting.RESET + " (eV/c\u00b2)/s" + EnumChatFormatting.BLUE + TT_Utility.formatNumberShortExp(overflowDisperse) + EnumChatFormatting.RESET + " "+translateToLocal("tt.keyword.unit.massFlux") }; } 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 474dbdab2c..12220dfe14 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 @@ -35,14 +35,12 @@ import net.minecraft.util.EnumChatFormatting; import net.minecraftforge.common.util.ForgeDirection; import org.apache.commons.lang3.reflect.FieldUtils; -import static com.github.technus.tectech.loader.TecTechConfig.DEBUG_MODE; import static com.github.technus.tectech.recipe.TT_recipe.E_RECIPE_ID; import static com.github.technus.tectech.thing.casing.GT_Block_CasingsTT.textureOffset; import static com.github.technus.tectech.thing.casing.TT_Container_Casings.sBlockCasingsTT; import static com.github.technus.tectech.thing.metaTileEntity.multi.GT_MetaTileEntity_EM_crafting.crafter; import static com.github.technus.tectech.thing.metaTileEntity.multi.em_machine.GT_MetaTileEntity_EM_machine.machine; -import static com.github.technus.tectech.util.CommonValues.V; -import static com.github.technus.tectech.util.CommonValues.VN; +import static com.github.technus.tectech.util.CommonValues.*; import static com.github.technus.tectech.util.TT_Utility.areBitsSet; import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; @@ -56,10 +54,23 @@ import static net.minecraft.util.StatCollector.translateToLocalFormatted; */ public class GT_MetaTileEntity_EM_scanner extends GT_MetaTileEntity_MultiblockBase_EM implements IConstructable { //region variables - public static final int SCAN_DO_NOTHING = 0, - 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; + public static final int + SCAN_DO_NOTHING = 0, + SCAN_GET_NOMENCLATURE = 1<<0, + SCAN_GET_DEPTH_LEVEL = 1<<1, + SCAN_GET_AMOUNT = 1<<2, + SCAN_GET_CHARGE = 1<<3, + SCAN_GET_MASS = 1<<4, + SCAN_GET_ENERGY = 1<<5, + SCAN_GET_ENERGY_LEVEL = 1<<6, + SCAN_GET_TIMESPAN_INFO = 1<<7, + SCAN_GET_ENERGY_STATES = 1<<8, + SCAN_GET_COLORABLE = 1<<9, + SCAN_GET_COLOR_VALUE = 1<<10, + SCAN_GET_AGE = 1<<11, + SCAN_GET_TIMESPAN_MULT = 1<<12, + SCAN_GET_CLASS_TYPE = 1<<13, + SCAN_GET_TOO_BIG = 1<<14;//should be the sum of all flags +1 private TT_recipe.TT_EMRecipe.TT_EMRecipe eRecipe; private EMDefinitionStack objectResearched; @@ -110,7 +121,7 @@ public class GT_MetaTileEntity_EM_scanner extends GT_MetaTileEntity_MultiblockBa } v = (int) v; if (v == 0) return LedStatus.STATUS_NEUTRAL; - if (v >= SCAN_GET_CLASS_TYPE) return LedStatus.STATUS_TOO_HIGH; + if (v >= SCAN_GET_TOO_BIG) return LedStatus.STATUS_TOO_HIGH; if (v < 0) return LedStatus.STATUS_TOO_LOW; return LedStatus.STATUS_OK; }; @@ -148,58 +159,60 @@ public class GT_MetaTileEntity_EM_scanner extends GT_MetaTileEntity_MultiblockBa private void addComputationRequirements(int depthPlus, int capabilities) { if (areBitsSet(SCAN_GET_NOMENCLATURE, capabilities)) { - computationRequired += depthPlus * 5L; + computationRequired += depthPlus * 3L; eRequiredData += depthPlus; } if (areBitsSet(SCAN_GET_DEPTH_LEVEL, capabilities)) { computationRequired += depthPlus * 10L; eRequiredData += depthPlus; - } if (areBitsSet(SCAN_GET_AMOUNT, capabilities)) { computationRequired += depthPlus * 64L; eRequiredData += depthPlus * 8L; - } if (areBitsSet(SCAN_GET_CHARGE, capabilities)) { computationRequired += depthPlus * 128L; eRequiredData += depthPlus * 4L; - } if (areBitsSet(SCAN_GET_MASS, capabilities)) { computationRequired += depthPlus * 256L; eRequiredData += depthPlus * 4L; - + } + if (areBitsSet(SCAN_GET_ENERGY, capabilities)) { + computationRequired += depthPlus * 256L; + eRequiredData += depthPlus * 16L; } if (areBitsSet(SCAN_GET_ENERGY_LEVEL, capabilities)) { - computationRequired += depthPlus * 512L; + computationRequired += depthPlus * 256L; eRequiredData += depthPlus * 16L; - } if (areBitsSet(SCAN_GET_TIMESPAN_INFO, capabilities)) { computationRequired += depthPlus * 1024L; eRequiredData += depthPlus * 32L; - } if (areBitsSet(SCAN_GET_ENERGY_STATES, capabilities)) { computationRequired += depthPlus * 2048L; eRequiredData += depthPlus * 32L; - } - if (areBitsSet(SCAN_GET_COLOR, capabilities)) { + if (areBitsSet(SCAN_GET_COLORABLE, capabilities)) { + computationRequired += depthPlus * 512L; + eRequiredData += depthPlus * 48L; + } + if (areBitsSet(SCAN_GET_COLOR_VALUE, capabilities)) { computationRequired += depthPlus * 1024L; eRequiredData += depthPlus * 48L; - } if (areBitsSet(SCAN_GET_AGE, capabilities)) { computationRequired += depthPlus * 2048L; eRequiredData += depthPlus * 64L; - } if (areBitsSet(SCAN_GET_TIMESPAN_MULT, capabilities)) { computationRequired += depthPlus * 2048L; eRequiredData += depthPlus * 64L; - + } + if (areBitsSet(SCAN_GET_CLASS_TYPE, capabilities)) { + computationRequired += depthPlus * 2L; + eRequiredData += depthPlus; } } @@ -277,9 +290,6 @@ public class GT_MetaTileEntity_EM_scanner extends GT_MetaTileEntity_MultiblockBa for (int i = 0; i < 20; i++) { if (scanComplexityTemp[i] != SCAN_DO_NOTHING) { maxDepth = i; - if (!DEBUG_MODE) { - scanComplexityTemp[i] &= ~SCAN_GET_CLASS_TYPE; - } addComputationRequirements(i + 1, scanComplexityTemp[i]); } } @@ -311,7 +321,7 @@ public class GT_MetaTileEntity_EM_scanner extends GT_MetaTileEntity_MultiblockBa tNBT.setString("eMachineType", machineType); tNBT.setTag(E_RECIPE_ID, objectResearched.toNBT(TecTech.definitionsRegistry)); - tNBT.setString("author", EnumChatFormatting.BLUE + "Tec" + EnumChatFormatting.DARK_BLUE + "Tech" + EnumChatFormatting.WHITE + ' ' + machineType + " EM Recipe Generator"); + tNBT.setString("author", TEC_MARK_SHORT + EnumChatFormatting.WHITE + ' ' + machineType + " EM Recipe Generator"); } else if (objectsScanned != null && CustomItemList.scanContainer.isStackEqual(mInventory[1], false, true)) { ElementalDefinitionScanStorage_EM.setContent(mInventory[1], objectsScanned, scanComplexity); } diff --git a/src/main/java/com/github/technus/tectech/util/CommonValues.java b/src/main/java/com/github/technus/tectech/util/CommonValues.java index f5d5ce6900..603644bcde 100644 --- a/src/main/java/com/github/technus/tectech/util/CommonValues.java +++ b/src/main/java/com/github/technus/tectech/util/CommonValues.java @@ -6,38 +6,33 @@ import net.minecraft.util.EnumChatFormatting; * Created by danie_000 on 11.01.2017. */ public final class CommonValues { - public static final String TEC_MARK_GENERAL = - EnumChatFormatting.BLUE + "Tec" + - EnumChatFormatting.DARK_BLUE + "Tech" + - EnumChatFormatting.BLUE + ": Interdimensional"; - public static final String TEC_MARK_EM = - EnumChatFormatting.BLUE + "Tec" + - EnumChatFormatting.DARK_BLUE + "Tech" + - EnumChatFormatting.BLUE + ": Elemental Matter"; - public static final String BASS_MARK = - EnumChatFormatting.BLUE + "Tec" + - EnumChatFormatting.DARK_BLUE + "Tech" + - EnumChatFormatting.BLUE + ": Theta Movement"; - public static final String COSMIC_MARK = - EnumChatFormatting.BLUE + "Tec" + - EnumChatFormatting.DARK_BLUE + "Tech" + - EnumChatFormatting.BLUE + ": Cosmic";//TODO get a better name than cosmic for *UNDEFINED* thing + public static final String TEC_MARK_SHORT = + EnumChatFormatting.BLUE + "Tec" + EnumChatFormatting.DARK_BLUE + "Tech"; + public static final String TEC_MARK_GENERAL = TEC_MARK_SHORT + + EnumChatFormatting.BLUE + ": Interdimensional"; + public static final String TEC_MARK_EM = TEC_MARK_SHORT + + EnumChatFormatting.BLUE + ": Elemental Matter"; + public static final String BASS_MARK = TEC_MARK_SHORT + + EnumChatFormatting.BLUE + ": Theta Movement"; + public static final String COSMIC_MARK = TEC_MARK_SHORT + + EnumChatFormatting.BLUE + ": Cosmic";//TODO get a better name than cosmic for *UNDEFINED* thing - public static final byte DECAY_AT = 0;// hatches compute decays + public static final byte DECAY_AT = 0;// hatches compute decays public static final byte MULTI_PURGE_1_AT = 2;// multiblocks clean their hatches 1 - public static final byte MOVE_AT = 4;// move stuff around - public static final byte RECIPE_AT = 6;// move stuff around + public static final byte MOVE_AT = 4;// move stuff around + public static final byte RECIPE_AT = 6;// move stuff around public static final byte MULTI_PURGE_2_AT = 8;// multiblocks clean their hatches 2 - public static final byte OVERFLOW_AT = 10;// then hatches clean themselves + public static final byte OVERFLOW_AT = 10;// then hatches clean themselves // - in case some hatches are not in multiblock structure - public static final byte MULTI_CHECK_AT = 12;// multiblock checks it's state - public static final byte DISPERSE_AT = 14;// overflow hatches perform disperse - public static final byte TRANSFER_AT = 16; + public static final byte MULTI_CHECK_AT = 12;// multiblock checks it's state + public static final byte DISPERSE_AT = 14;// overflow hatches perform disperse + public static final byte TRANSFER_AT = 16; - public static final long[] AatV = new long[]{268435455,67108863,16777215,4194303,1048575,262143,65535,16383,4095,1023,255,63,15,3,1,1}; + public static final long[] AatV = new long[]{268435455, 67108863, 16777215, 4194303, 1048575, 262143, 65535, 16383, 4095, 1023, 255, 63, 15, 3, 1, 1}; public static final String[] VOLTAGE_NAMES = new String[]{"Ultra Low Voltage", "Low Voltage", "Medium Voltage", "High Voltage", "Extreme Voltage", "Insane Voltage", "Ludicrous Voltage", "ZPM Voltage", "Ultimate Voltage", "Ultimate High Voltage", "Ultimate Extreme Voltage", "Ultimate Insane Voltage", "Ultimate Mega Voltage", "Ultimate Extended Mega Voltage", "Overpowered Voltage", "Maximum Voltage"}; - public static final String[] VN = new String[]{"ULV", "LV", "MV", "HV", "EV", "IV", "LuV", "ZPM", "UV", "UHV", "UEV", "UIV", "UMV", "UXV", "OpV", "MAX"}; - public static final long[] V = new long[]{8L, 32L, 128L, 512L, 2048L, 8192L, 32768L, 131072L, 524288L, 2097152L, 8388608L, 33554432L, 134217728L, 536870912L, 1073741824L, Integer.MAX_VALUE - 7}; + public static final String[] VN = new String[]{"ULV", "LV", "MV", "HV", "EV", "IV", "LuV", "ZPM", "UV", "UHV", "UEV", "UIV", "UMV", "UXV", "OpV", "MAX"}; + public static final long[] V = new long[]{8L, 32L, 128L, 512L, 2048L, 8192L, 32768L, 131072L, 524288L, 2097152L, 8388608L, 33554432L, 134217728L, 536870912L, 1073741824L, Integer.MAX_VALUE - 7}; - private CommonValues() {} + private CommonValues() { + } } diff --git a/src/main/java/com/github/technus/tectech/util/TT_Utility.java b/src/main/java/com/github/technus/tectech/util/TT_Utility.java index c989fe1e1f..a9732e294a 100644 --- a/src/main/java/com/github/technus/tectech/util/TT_Utility.java +++ b/src/main/java/com/github/technus/tectech/util/TT_Utility.java @@ -29,9 +29,11 @@ import org.apache.commons.lang3.StringUtils; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; +import java.lang.reflect.Array; import java.lang.reflect.Field; import java.nio.charset.StandardCharsets; import java.util.*; +import java.util.function.Function; /** * Created by Tec on 21.03.2017. @@ -39,10 +41,12 @@ import java.util.*; public final class TT_Utility { private TT_Utility() { } - private static final Map<Locale, Formatter> formaters=new HashMap<>(); + private static final StringBuilder STRING_BUILDER =new StringBuilder(); + private static final Map<Locale, Formatter> FORMATTER_MAP =new HashMap<>(); private static Formatter getFormatter(){ - return formaters.computeIfAbsent(Locale.getDefault(Locale.Category.FORMAT), Formatter::new); + STRING_BUILDER.setLength(0); + return FORMATTER_MAP.computeIfAbsent(Locale.getDefault(Locale.Category.FORMAT), locale -> new Formatter(STRING_BUILDER,locale)); } public static String formatNumberShortExp(double value){ @@ -305,7 +309,7 @@ public final class TT_Utility { return strings; } - public static String[] infoFromNBT(NBTTagCompound nbt) { + public static String[] unpackStrings(NBTTagCompound nbt) { String[] strings = new String[nbt.getInteger("i")]; for (int i = 0; i < strings.length; i++) { strings[i] = nbt.getString(Integer.toString(i)); @@ -313,6 +317,37 @@ public final class TT_Utility { return strings; } + public static String getSomeString(NBTTagCompound nbt,int index) { + return nbt.getString(Integer.toString(index%nbt.getInteger("i"))); + } + + public static NBTTagCompound packStrings(String... info) { + NBTTagCompound nbt = new NBTTagCompound(); + nbt.setInteger("i", info.length); + for (int i = 0; i < info.length; i++) { + nbt.setString(Integer.toString(i), info[i]); + } + return nbt; + } + + @SuppressWarnings("unchecked") + public static <T> T[] unpackNBT(Class<T> tClass, Function<NBTTagCompound,T> converter, NBTTagCompound nbt) { + T[] objects = (T[])Array.newInstance(tClass,nbt.getInteger("i")); + for (int i = 0; i < objects.length; i++) { + objects[i] = converter.apply(nbt.getCompoundTag(Integer.toString(i))); + } + return objects; + } + + public static <T> NBTTagCompound packNBT(Function<T,NBTTagCompound> converter, T... info) { + NBTTagCompound nbt = new NBTTagCompound(); + nbt.setInteger("i", info.length); + for (int i = 0; i < info.length; i++) { + nbt.setTag(Integer.toString(i), converter.apply(info[i])); + } + return nbt; + } + public static boolean areBitsSet(int setBits, int testedValue) { return (testedValue & setBits) == setBits; } diff --git a/src/main/resources/assets/tectech/lang/en_US.lang b/src/main/resources/assets/tectech/lang/en_US.lang index f9ab756696..471b0f1062 100644 --- a/src/main/resources/assets/tectech/lang/en_US.lang +++ b/src/main/resources/assets/tectech/lang/en_US.lang @@ -799,16 +799,9 @@ gt.blockmachines.debug.tt.writer.desc.2=ABC axises aligned to machine front tt.keyword.ID=ID #Example: 32EU at 1A tt.keyword.at=at -#EM scan result -tt.keyword.CLASS=CLASS -tt.keyword.NAME=NAME -tt.keyword.CHARGE=CHARGE -tt.keyword.COLORLESS=COLORLESS -tt.keyword.MASS=MASS -tt.keyphrase.LIFE_TIME=LIFE TIME -tt.keyphrase.CARRIES_COLOR=CARRIES COLOR + tt.keyphrase.Hint_Details=Hint Details -tt.keyphrase.At_current_energy_level=At current energy level + #debug boom tt.keyword.BOOM=BOOM! tt.keyword.Destination=Destination @@ -871,11 +864,48 @@ tt.keyphrase.Ass_line_recipe=Assembly Line Recipe tile.turretHeadEM.name=Elemental Matter Turret tile.turretBaseEM.name=Elemental Turret Base -tt.keyword.mol=mol -tt.keyword.itemMols=items -tt.keyword.mbMols=mb +#EM scan result +tt.keyword.scan.depth=Depth +tt.keyword.scan.class=Class +tt.keyword.scan.name=Name +tt.keyword.scan.symbol=Symbol + +tt.keyword.scan.mass=Mass +tt.keyword.scan.count=Count +tt.keyword.scan.amount=Amount +tt.keyword.scan.energy=Energy +tt.keyword.scan.energyLevel=Energy Level +tt.keyword.scan.charge=Charge +tt.keyword.scan.life_mult=Life multiplier +tt.keyword.scan.half_life=Half life +tt.keyword.scan.life_time=Life time +tt.keyword.scan.age=Age +tt.keyphrase.scan.at_current_energy_level=At current energy level +tt.keyword.scan.color=Colorless +tt.keyword.scan.colorless=Colorless +tt.keyword.scan.colored=Colored + +tt.keyword.short.mass=M +tt.keyword.short.count=Qty +tt.keyword.short.amount=Qty +tt.keyword.short.energy=E +tt.keyword.short.energyLevel=EL +tt.keyword.short.charge=C +tt.keyword.short.time=T + +tt.keyword.unit.mass=eV/c² +tt.keyword.unit.massFlux=eV/c²s +tt.keyword.unit.count= +tt.keyword.unit.mol=mol +tt.keyword.unit.itemMols=item(s) +tt.keyword.unit.mbMols=mb +tt.keyword.unit.energy=eV +tt.keyword.unit.charge=e +tt.keyword.unit.time=s +tt.keyword.unit.tick=t #that the thing wont decay tt.keyword.stable=STABLE + #EM types tt.keyword.Primitive=Primitive tt.keyword.Element=Element |