From fe3e8abfbb46a4fd75906e3d41e0dfb4435b8403 Mon Sep 17 00:00:00 2001 From: Tec Date: Sun, 6 Feb 2022 20:47:22 +0100 Subject: More locale work --- .../blocks/turretheads/TurretHeadItemEM.java | 2 +- .../definitions/EMComplexAspectDefinition.java | 39 +------ .../tectech/mechanics/anomaly/CancerCommand.java | 2 + .../core/definitions/EMComplexTemplate.java | 4 +- .../core/definitions/EMPrimitiveTemplate.java | 40 +------ .../core/definitions/IEMDefinition.java | 68 ++++++++--- .../core/maps/EMConstantStackMap.java | 15 +-- .../core/maps/EMDefinitionStackMap.java | 15 +-- .../core/maps/EMInstanceStackMap.java | 124 ++++++++------------ .../elementalMatter/core/maps/EMStackMap.java | 7 +- .../elementalMatter/core/maps/IEMMapRead.java | 61 ++++------ .../elementalMatter/core/maps/IEMMapWrite.java | 14 +-- .../core/maps/IEMMapWriteExact.java | 22 ++-- .../core/stacks/EMInstanceStack.java | 56 ++++----- .../definitions/complex/EMAtomDefinition.java | 40 +------ .../definitions/complex/EMHadronDefinition.java | 35 +----- .../github/technus/tectech/proxy/ClientProxy.java | 1 + .../item/DebugElementalInstanceContainer_EM.java | 69 ++++------- .../item/ElementalDefinitionContainer_EM.java | 52 ++------- .../item/ElementalDefinitionScanStorage_EM.java | 71 ++++-------- .../tectech/thing/item/gui/ScanDisplayScreen.java | 126 +++++++++++---------- .../thing/item/renderElemental/IElementalItem.java | 16 ++- .../item/renderElemental/RenderElementalName.java | 8 +- .../GT_MetaTileEntity_Hatch_OverflowElemental.java | 10 +- .../multi/GT_MetaTileEntity_EM_scanner.java | 60 ++++++---- .../github/technus/tectech/util/CommonValues.java | 49 ++++---- .../github/technus/tectech/util/TT_Utility.java | 41 ++++++- src/main/resources/assets/tectech/lang/en_US.lang | 54 +++++++-- 28 files changed, 457 insertions(+), 644 deletions(-) (limited to 'src') 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 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 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 @@ -182,37 +177,6 @@ public abstract class EMPrimitiveTemplate extends EMComplexTemplate { return Short.MIN_VALUE; } - @Override - public void addScanShortSymbols(ArrayList 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 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()) { 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,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, 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,Cloneable {//IM String getShortLocalizedName(); - default String getLocalizedName(){ - return getLocalizedTypeName()+": "+getShortLocalizedName(); + default String getLocalizedName() { + return getLocalizedTypeName() + ": " + getShortLocalizedName(); } String getShortSymbol(); String getSymbol(); - void addScanShortSymbols(ArrayList lines, int capabilities, long energyLevel); + default void addScanShortSymbols(ArrayList 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 lines, int capabilities, long energyLevel); + default void addScanResults(ArrayList 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,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,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 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 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 implements IEMMapWrite { //Constructors - public EMInstanceStackMap() {} + public EMInstanceStackMap() { + } public EMInstanceStackMap(EMInstanceStack... inSafe) { this(true, inSafe); @@ -35,8 +36,8 @@ public final class EMInstanceStackMap extends EMStackMap implem public EMInstanceStackMap(boolean clone, EMInstanceStack... in) { if (clone) { - EMInstanceStack[] stacks =new EMInstanceStack[in.length]; - for(int i=0;i implem } private EMInstanceStackMap(boolean clone, NavigableMap 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 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 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 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 getScanShortSymbols(int[] capabilities) { - ArrayList list=new ArrayList<>(16); - for(Map.Entry e: getBackingMap().entrySet()){ - e.getValue().addScanShortSymbols(list,capabilities); - } - return list; - } - public ArrayList getScanInfo(int[] capabilities) { - ArrayList list=new ArrayList<>(16); - for(Map.Entry e: getBackingMap().entrySet()){ - e.getValue().addScanResults(list,capabilities); + ArrayList list = new ArrayList<>(16); + for (Map.Entry 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 implem } //NBT - public NBTTagCompound getScanShortSymbolsNBT(int[] capabilities) { - NBTTagCompound nbt = new NBTTagCompound(); - ArrayList 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 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 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 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 implements IEMMapRead { @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 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 extends Comparable>, Cloneable { @@ -87,53 +90,27 @@ public interface IEMMapRead extends Comparable 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 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 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 extends Comparable iterator = values().iterator(); - Iterator iteratorO = o.values().iterator(); + Iterator> iterator = entrySet().iterator(); + Iterator> 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 extends Comparable= 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 extends IEMMapWriteExact { } 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 extends IEMMapWriteExact { * @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 extends IEMMapWriteExact { putReplace(stack); return stack; }else { - removeKey(stack); + removeKey(stack.getDefinition()); return null; } } @@ -105,8 +105,8 @@ public interface IEMMapWrite extends IEMMapWriteExact { } default void putUnifyAll(IEMMapRead inTreeUnsafe) { - for (T in : inTreeUnsafe.values()) { - putUnify(in); + for (Map.Entry 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 extends IEMMapRead { 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 extends IEMMapRead { 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 extends IEMMapRead { boolean hadAll=containsAllKeys(hasElementalDefinition); if(hadAll){ for (IEMStack stack : hasElementalDefinition) { - removeKey(stack); + removeKey(stack.getDefinition()); } } return hadAll; @@ -91,15 +87,15 @@ public interface IEMMapWriteExact extends IEMMapRead { * @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 extends IEMMapRead { } 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 extends IEMMapRead { putReplace(stack); return stack; }else { - removeKey(stack); + removeKey(stack.getDefinition()); return null; } } @@ -159,8 +155,8 @@ public interface IEMMapWriteExact extends IEMMapRead { } default void putUnifyAllExact(IEMMapRead inTreeUnsafe) { - for (T in : inTreeUnsafe.values()) { - putUnifyExact(in); + for (Map.Entry 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 lines, int[] detailsOnDepthLevels) { - int capabilities = detailsOnDepthLevels[0]; - getDefinition().addScanShortSymbols(lines, capabilities, energy); - //scanShortSymbolsContents(lines,definition.getSubParticles(),1,detailsOnDepthLevels); - } - - //private void scanShortSymbolsContents(ArrayList lines, cElementalDefinitionStackMap definitions, int depth, int[] detailsOnDepthLevels){ - // if(definitions!=null && depth 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 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 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 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 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, tNB