diff options
author | Tec <daniel112092@gmail.com> | 2022-01-27 22:09:30 +0100 |
---|---|---|
committer | Martin Robertz <dream-master@gmx.net> | 2022-01-29 21:24:54 +0100 |
commit | a3286688012b742015e97b78420e9768e24a8299 (patch) | |
tree | 4953b71413ab6cdd472af1bf741c5907aeda7694 /src/main/java | |
parent | ad188c2a0680d0af56076bd2097e9aa95ecfe900 (diff) | |
download | GT5-Unofficial-a3286688012b742015e97b78420e9768e24a8299.tar.gz GT5-Unofficial-a3286688012b742015e97b78420e9768e24a8299.tar.bz2 GT5-Unofficial-a3286688012b742015e97b78420e9768e24a8299.zip |
Cleanup Atoms Localization, and FontRenderer
(cherry picked from commit 7adcaf6d9b4a8628711a01ce2467f13582cea7d5)
Diffstat (limited to 'src/main/java')
3 files changed, 219 insertions, 143 deletions
diff --git a/src/main/java/com/github/technus/tectech/font/TecTechFontRender.java b/src/main/java/com/github/technus/tectech/font/TecTechFontRender.java index 4aea8bce92..fbbc12fe36 100644 --- a/src/main/java/com/github/technus/tectech/font/TecTechFontRender.java +++ b/src/main/java/com/github/technus/tectech/font/TecTechFontRender.java @@ -1,85 +1,182 @@ package com.github.technus.tectech.font; +import com.ibm.icu.text.ArabicShaping; +import com.ibm.icu.text.ArabicShapingException; +import com.ibm.icu.text.Bidi; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.FontRenderer; -import net.minecraft.client.settings.GameSettings; import net.minecraft.util.ResourceLocation; import org.lwjgl.opengl.GL11; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; - @SideOnly(Side.CLIENT) public class TecTechFontRender extends FontRenderer { public static final TecTechFontRender INSTANCE = new TecTechFontRender(); - private static float DISTANCE_L = .125F; - private static float DISTANCE_L2 = DISTANCE_L *2F; + private static float DISTANCE_L = .125F; + private static float DISTANCE_L2 = DISTANCE_L * 2F; - private static float DISTANCE_M = 0.06F; - private static float DISTANCE_M2 = DISTANCE_M *2F; + private static float DISTANCE_M = 0.06F; + private static float DISTANCE_M2 = DISTANCE_M * 2F; - private static float DISTANCE_A = 0.06F; - private static float DISTANCE_A2 = DISTANCE_A *2F; + private static float DISTANCE_A = 0.06F; + private static float DISTANCE_A2 = DISTANCE_A * 2F; - private static final Method reset; - private static final Method render; - private final GameSettings gameSettings; + private TecTechFontRender() { + super(Minecraft.getMinecraft().gameSettings, new ResourceLocation("textures/font/ascii.png"), Minecraft.getMinecraft().renderEngine, false); + } - static { - Method resetMethod,renderMethod; - try { - resetMethod =FontRenderer.class.getDeclaredMethod("resetStyles"); - renderMethod=FontRenderer.class.getDeclaredMethod("renderString", String.class, int.class, int.class, int.class, boolean.class); - } catch (NoSuchMethodException e) { - try { - resetMethod =FontRenderer.class.getDeclaredMethod("func_78265_b"); - renderMethod=FontRenderer.class.getDeclaredMethod("func_78258_a", String.class, int.class, int.class, int.class, boolean.class); - } catch (NoSuchMethodException ex) { - throw new RuntimeException("Cannot get methods!",ex); - } - } - resetMethod.setAccessible(true); - renderMethod.setAccessible(true); - reset=resetMethod; - render=renderMethod; + private void resetStyles() { + this.randomStyle = false; + this.boldStyle = false; + this.italicStyle = false; + this.underlineStyle = false; + this.strikethroughStyle = false; } - private TecTechFontRender() { - super(Minecraft.getMinecraft().gameSettings, new ResourceLocation("textures/font/ascii.png"), Minecraft.getMinecraft().renderEngine, false); - gameSettings = Minecraft.getMinecraft().gameSettings; + private int renderString(String p_78258_1_, int p_78258_2_, int p_78258_3_, int p_78258_4_, boolean p_78258_5_) { + if (p_78258_1_ == null) { + return 0; + } else { + if (this.bidiFlag) { + p_78258_1_ = this.bidiReorder(p_78258_1_); + } + + if ((p_78258_4_ & -67108864) == 0) { + p_78258_4_ |= -16777216; + } + + if (p_78258_5_) { + p_78258_4_ = (p_78258_4_ & 16579836) >> 2 | p_78258_4_ & -16777216; + } + + this.red = (float)(p_78258_4_ >> 16 & 255) / 255.0F; + this.blue = (float)(p_78258_4_ >> 8 & 255) / 255.0F; + this.green = (float)(p_78258_4_ & 255) / 255.0F; + this.alpha = (float)(p_78258_4_ >> 24 & 255) / 255.0F; + this.setColor(this.red, this.blue, this.green, this.alpha); + this.posX = (float)p_78258_2_; + this.posY = (float)p_78258_3_; + this.renderStringAtPos(p_78258_1_, p_78258_5_); + return (int)this.posX; + } } - private void resetStyles2(){ + private String bidiReorder(String p_147647_1_) { try { - reset.invoke(this); - } catch (IllegalAccessException | InvocationTargetException e) { - throw new RuntimeException("Cannot run method resetStyles!",e); + Bidi bidi = new Bidi((new ArabicShaping(8)).shape(p_147647_1_), 127); + bidi.setReorderingMode(0); + return bidi.writeReordered(2); + } catch (ArabicShapingException var3) { + return p_147647_1_; } } - private int renderString2(String str, int x, int y, int color, boolean dropShadow){ - try { - return (int)render.invoke(this,str,x,y,color,dropShadow); - } catch (IllegalAccessException | InvocationTargetException e) { - throw new RuntimeException("Cannot run method renderString!",e); + private void renderStringAtPos(String p_78255_1_, boolean p_78255_2_) { + for(int i = 0; i < p_78255_1_.length(); ++i) { + char c0 = p_78255_1_.charAt(i); + int j; + int k; + if (c0 == 167 && i + 1 < p_78255_1_.length()) { + j = "0123456789abcdefklmnor".indexOf(p_78255_1_.toLowerCase().charAt(i + 1)); + if (j < 16) { + this.randomStyle = false; + this.boldStyle = false; + this.strikethroughStyle = false; + this.underlineStyle = false; + this.italicStyle = false; + if (j < 0 || j > 15) { + j = 15; + } + + if (p_78255_2_) { + j += 16; + } + + k = this.colorCode[j]; + this.textColor = k; + this.setColor((float)(k >> 16) / 255.0F, (float)(k >> 8 & 255) / 255.0F, (float)(k & 255) / 255.0F, this.alpha); + } else if (j == 16) { + this.randomStyle = true; + } else if (j == 17) { + this.boldStyle = true; + } else if (j == 18) { + this.strikethroughStyle = true; + } else if (j == 19) { + this.underlineStyle = true; + } else if (j == 20) { + this.italicStyle = true; + } else if (j == 21) { + this.randomStyle = false; + this.boldStyle = false; + this.strikethroughStyle = false; + this.underlineStyle = false; + this.italicStyle = false; + this.setColor(this.red, this.blue, this.green, this.alpha); + } + + ++i; + } else { + j = "ÀÁÂÈÊËÍÓÔÕÚßãõğİıŒœŞşŴŵžȇ\u0000\u0000\u0000\u0000\u0000\u0000\u0000 !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\u0000ÇüéâäàåçêëèïîìÄÅÉæÆôöòûùÿÖÜø£Ø׃áíóúñѪº¿®¬½¼¡«»░▒▓│┤╡╢╖╕╣║╗╝╜╛┐└┴┬├─┼╞╟╚╔╩╦╠═╬╧╨╤╥╙╘╒╓╫╪┘┌█▄▌▐▀αβΓπΣσμτΦΘΩδ∞∅∈∩≡±≥≤⌠⌡÷≈°∙·√ⁿ²■\u0000".indexOf(c0); + if (this.randomStyle && j != -1) { + do { + k = this.fontRandom.nextInt(this.charWidth.length); + } while(this.charWidth[j] != this.charWidth[k]); + + j = k; + } + + float f1 = this.unicodeFlag ? 0.5F : 1.0F; + boolean flag1 = (c0 == 0 || j == -1 || this.unicodeFlag) && p_78255_2_; + if (flag1) { + this.posX -= f1; + this.posY -= f1; + } + + float f = this.renderCharAtPos(j, c0, this.italicStyle); + if (flag1) { + this.posX += f1; + this.posY += f1; + } + + if (this.boldStyle) { + this.posX += f1; + if (flag1) { + this.posX -= f1; + this.posY -= f1; + } + + this.renderCharAtPos(j, c0, this.italicStyle); + this.posX -= f1; + if (flag1) { + this.posX += f1; + this.posY += f1; + } + + ++f; + } + + this.doDraw(f); + } } + } + private float renderCharAtPos(int p_78278_1_, char p_78278_2_, boolean p_78278_3_) { + return p_78278_2_ == ' ' ? 4.0F : ("ÀÁÂÈÊËÍÓÔÕÚßãõğİıŒœŞşŴŵžȇ\u0000\u0000\u0000\u0000\u0000\u0000\u0000 !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\u0000ÇüéâäàåçêëèïîìÄÅÉæÆôöòûùÿÖÜø£Ø׃áíóúñѪº¿®¬½¼¡«»░▒▓│┤╡╢╖╕╣║╗╝╜╛┐└┴┬├─┼╞╟╚╔╩╦╠═╬╧╨╤╥╙╘╒╓╫╪┘┌█▄▌▐▀αβΓπΣσμτΦΘΩδ∞∅∈∩≡±≥≤⌠⌡÷≈°∙·√ⁿ²■\u0000".indexOf(p_78278_2_) != -1 && !this.unicodeFlag ? this.renderDefaultChar(p_78278_1_, p_78278_3_) : this.renderUnicodeChar(p_78278_2_, p_78278_3_)); + } @Override public int drawString(String str, int x, int y, int color, boolean dropShadow) { - switch (gameSettings.guiScale){ + switch (Minecraft.getMinecraft().gameSettings.guiScale) { case 0: setUnicodeFlag(true); y--; GL11.glPushMatrix(); - if (dropShadow) - { + if (dropShadow) { GL11.glTranslatef(DISTANCE_A, DISTANCE_A, 0F); drawStringBack(str, x, y, color); GL11.glTranslatef(-DISTANCE_A2, 0, 0F); @@ -106,8 +203,7 @@ public class TecTechFontRender extends FontRenderer { y--; GL11.glPushMatrix(); - if (dropShadow) - { + if (dropShadow) { GL11.glTranslatef(DISTANCE_M, DISTANCE_M, 0F); drawStringBack(str, x, y, color); GL11.glTranslatef(-DISTANCE_M2, 0, 0F); @@ -132,8 +228,7 @@ public class TecTechFontRender extends FontRenderer { y--; GL11.glPushMatrix(); - if (dropShadow) - { + if (dropShadow) { GL11.glTranslatef(DISTANCE_L, DISTANCE_L, 0F); drawStringBack(str, x, y, color); GL11.glTranslatef(-DISTANCE_L2, 0, 0F); @@ -159,7 +254,7 @@ public class TecTechFontRender extends FontRenderer { @Override public void drawSplitString(String str, int x, int y, int maxWidth, int color) { - switch (gameSettings.guiScale){ + switch (Minecraft.getMinecraft().gameSettings.guiScale) { case 0: setUnicodeFlag(true); y--; @@ -213,50 +308,40 @@ public class TecTechFontRender extends FontRenderer { private int drawStringFront(String p_85187_1_, int p_85187_2_, int p_85187_3_, int p_85187_4_) { GL11.glEnable(3008); - resetStyles2(); - return renderString2(p_85187_1_, p_85187_2_, p_85187_3_, p_85187_4_, false); + resetStyles(); + return renderString(p_85187_1_, p_85187_2_, p_85187_3_, p_85187_4_, false); } private int drawStringBack(String p_85187_1_, int p_85187_2_, int p_85187_3_, int p_85187_4_) { GL11.glEnable(3008); - resetStyles2(); - return renderString2(p_85187_1_, p_85187_2_ + 1, p_85187_3_ + 1, p_85187_4_, true); + resetStyles(); + return renderString(p_85187_1_, p_85187_2_ + 1, p_85187_3_ + 1, p_85187_4_, true); } @Override - public int getStringWidth(String p_78256_1_) - { - if(gameSettings.guiScale==1){ + public int getStringWidth(String p_78256_1_) { + if (Minecraft.getMinecraft().gameSettings.guiScale == 1) { return Minecraft.getMinecraft().fontRenderer.getStringWidth(p_78256_1_); } - if (p_78256_1_ == null) - { + if (p_78256_1_ == null) { return 0; - } - else - { - int i = 0; + } else { + int i = 0; boolean flag = false; - for (int j = 0; j < p_78256_1_.length(); ++j) - { + for (int j = 0; j < p_78256_1_.length(); ++j) { char c0 = p_78256_1_.charAt(j); - int k = this.getCharWidth(c0); + int k = this.getCharWidth(c0); - if (k < 0 && j < p_78256_1_.length() - 1) - { + if (k < 0 && j < p_78256_1_.length() - 1) { ++j; c0 = p_78256_1_.charAt(j); - if (c0 != 108 && c0 != 76) - { - if (c0 == 114 || c0 == 82) - { + if (c0 != 108 && c0 != 76) { + if (c0 == 114 || c0 == 82) { flag = false; } - } - else - { + } else { flag = true; } @@ -265,8 +350,7 @@ public class TecTechFontRender extends FontRenderer { i += k; - if (flag && k > 0) - { + if (flag && k > 0) { ++i; } } @@ -274,4 +358,6 @@ public class TecTechFontRender extends FontRenderer { return i; } } + + } 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 76f4457e94..49fd8b5b54 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 @@ -5,8 +5,8 @@ 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.maps.EMDefinitionStackMap; import com.github.technus.tectech.mechanics.elementalMatter.core.stacks.EMDefinitionStack; @@ -27,12 +27,17 @@ import static com.github.technus.tectech.thing.metaTileEntity.multi.GT_MetaTileE import static com.github.technus.tectech.util.XSTR.XSTR_INSTANCE; import static gregtech.api.enums.Materials.*; import static gregtech.api.enums.OrePrefixes.dust; +import static java.lang.Math.abs; import static net.minecraft.util.StatCollector.translateToLocal; /** * Created by danie_000 on 18.11.2016. */ public class EMAtomDefinition extends EMComplexTemplate { + private static final String[] SYMBOL = new String[]{"Nt", "H", "He", "Li", "Be", "B", "C", "N", "O", "F", "Ne", "Na", "Mg", "Al", "Si", "P", "S", "Cl", "Ar", "K", "Ca", "Sc", "Ti", "V", "Cr", "Mn", "Fe", "Co", "Ni", "Cu", "Zn", "Ga", "Ge", "As", "Se", "Br", "Kr", "Rb", "Sr", "Y", "Zr", "Nb", "Mo", "Tc", "Ru", "Rh", "Pd", "Ag", "Cd", "In", "Sn", "Sb", "Te", "I", "Xe", "Cs", "Ba", "La", "Ce", "Pr", "Nd", "Pm", "Sm", "Eu", "Gd", "Tb", "Dy", "Ho", "Er", "Tm", "Yb", "Lu", "Hf", "Ta", "W", "Re", "Os", "Ir", "Pt", "Au", "Hg", "Tl", "Pb", "Bi", "Po", "At", "Rn", "Fr", "Ra", "Ac", "Th", "Pa", "U", "Np", "Pu", "Am", "Cm", "Bk", "Cf", "Es", "Fm", "Md", "No", "Lr", "Rf", "Db", "Sg", "Bh", "Hs", "Mt", "Ds", "Rg", "Cn", "Nh", "Fl", "Mc", "Lv", "Ts", "Og"}; + private static final String[] NAME = new String[]{"Neutronium", "Hydrogen", "Helium", "Lithium", "Beryllium", "Boron", "Carbon", "Nitrogen", "Oxygen", "Fluorine", "Neon", "Sodium", "Magnesium", "Aluminium", "Silicon", "Phosphorus", "Sulfur", "Chlorine", "Argon", "Potassium", "Calcium", "Scandium", "Titanium", "Vanadium", "Chromium", "Manganese", "Iron", "Cobalt", "Nickel", "Copper", "Zinc", "Gallium", "Germanium", "Arsenic", "Selenium", "Bromine", "Krypton", "Rubidium", "Strontium", "Yttrium", "Zirconium", "Niobium", "Molybdenum", "Technetium", "Ruthenium", "Rhodium", "Palladium", "Silver", "Cadmium", "Indium", "Tin", "Antimony", "Tellurium", "Iodine", "Xenon", "Caesium", "Barium", "Lanthanum", "Cerium", "Praseodymium", "Neodymium", "Promethium", "Samarium", "Europium", "Gadolinium", "Terbium", "Dysprosium", "Holmium", "Erbium", "Thulium", "Ytterbium", "Lutetium", "Hafnium", "Tantalum", "Tungsten", "Rhenium", "Osmium", "Iridium", "Platinum", "Gold", "Mercury", "Thallium", "Lead", "Bismuth", "Polonium", "Astatine", "Radon", "Francium", "Radium", "Actinium", "Thorium", "Protactinium", "Uranium", "Neptunium", "Plutonium", "Americium", "Curium", "Berkelium", "Californium", "Einsteinium", "Fermium", "Mendelevium", "Nobelium", "Lawrencium", "Rutherfordium", "Dubnium", "Seaborgium", "Bohrium", "Hassium", "Meitnerium", "Darmstadtium", "Roentgenium", "Copernicium", "Nihonium", "Flerovium", "Moscovium", "Livermorium", "Tennessine", "Oganesson"}; + private static final String[] SYMBOL_IUPAC = new String[]{"n", "u", "b", "t", "q", "p", "h", "s", "o", "e", "N", "U", "B", "T", "Q", "P", "H", "S", "O", "E"}; + public static final long ATOM_COMPLEXITY_LIMIT = 65536L; private static final byte BYTE_OFFSET = 32; @@ -118,7 +123,7 @@ public class EMAtomDefinition extends EMComplexTemplate { if (def.getGeneration() < 0) { containsAnti = true; } - type = Math.max(type, Math.abs(def.getGeneration())); + type = Math.max(type, abs(def.getGeneration())); if (def instanceof EMLeptonDefinition) { cLeptons += stack.getCharge(); @@ -140,12 +145,12 @@ public class EMAtomDefinition extends EMComplexTemplate { this.neutralCount = neutralCount; this.element = element; - element = Math.abs(element); + element = abs(element); //stability curve int StableIsotope = stableIzoCurve(element); int izoDiff = neutralCount - StableIsotope; - int izoDiffAbs = Math.abs(izoDiff); + int izoDiffAbs = abs(izoDiff); xstr.setSeed((element + 1L) * (neutralCount + 100L)); iaea = EMNuclideIAEA.get(element, neutralCount); @@ -215,7 +220,7 @@ public class EMAtomDefinition extends EMComplexTemplate { if (element == 0) { return 1e-35D; } else if (element == 1) { - unstabilityEXP = 1.743D - Math.abs(izoDiff - 1) * 9.743D; + unstabilityEXP = 1.743D - abs(izoDiff - 1) * 9.743D; } else if (element == 2) { switch (isotope) { case 4: @@ -234,9 +239,9 @@ public class EMAtomDefinition extends EMComplexTemplate { } else if (element <= 83 || isotope <= 127 && element <= 120) { double elementPow4 = Math.pow(element, 4); - unstabilityEXP = Math.min(element / 2.4D, 6 + ((element + 1) % 2) * 3e6D / elementPow4) + -izoDiff * elementPow4 / 1e8D - Math.abs(izoDiff - 1 + element / 60D) * (3D - element / 12.5D + element * element / 1500D); + unstabilityEXP = Math.min(element / 2.4D, 6 + ((element + 1) % 2) * 3e6D / elementPow4) + -izoDiff * elementPow4 / 1e8D - abs(izoDiff - 1 + element / 60D) * (3D - element / 12.5D + element * element / 1500D); } else if (element < 180) { - unstabilityEXP = Math.min((element - 85) * 2, 16 + ((isotope + 1) % 2) * 2.5D - (element - 85) / 3D) - Math.abs(izoDiff) * (3D - element / 13D + element * element / 1600D); + unstabilityEXP = Math.min((element - 85) * 2, 16 + ((isotope + 1) % 2) * 2.5D - (element - 85) / 3D) - abs(izoDiff) * (3D - element / 13D + element * element / 1600D); } else { return -1; } @@ -334,63 +339,51 @@ public class EMAtomDefinition extends EMComplexTemplate { @Override public String getLocalizedName() { - int element = Math.abs(this.getElement()); - boolean negative = this.getElement() < 0; - try { - if (Math.abs(getGeneration()) != 1) { - return (negative ? "~? " : "? ") + Nomenclature.NAME[element]; - } - return negative ? '~' + Nomenclature.NAME[element] : Nomenclature.NAME[element]; - } catch (Exception e) { - if (DEBUG_MODE) { - e.printStackTrace(); + int element = abs(this.getElement()); + boolean anti = this.getElement() < 0; + boolean weird = abs(getGeneration()) != 1; + if(element>=NAME.length){ + StringBuilder s = new StringBuilder(); + if(anti){ + s.append(translateToLocal("tt.IUPAC.Anti")); + do { + s.append(translateToLocal("tt.IUPAC."+SYMBOL_IUPAC[element % 10])); + element = element / 10; + } while (element > 0); + }else { + while (element >= 10) { + s.append(translateToLocal("tt.IUPAC."+SYMBOL_IUPAC[element % 10])); + element = element / 10; + } + s.append(translateToLocal("tt.IUPAC."+SYMBOL_IUPAC[element + 10])); } - return translateToLocal("tt.keyword.Element") + (negative ? ": ~" : ": ") + element; + s.append(weird?translateToLocal("tt.keyword.Weird"):""); + return s.toString(); } + return translateToLocal("tt.element."+(anti?"Anti":"")+NAME[element])+(weird?translateToLocal("tt.keyword.Weird"):""); } @Override public String getSymbol() { - int element = Math.abs(this.getElement()); - boolean negative = this.getElement() < 0; - try { - return (negative ? "~" : "") + Nomenclature.SYMBOL[element] + " N:" + getNeutralCount() + " I:" + (getNeutralCount() + element) + " C:" + getCharge(); - } catch (Exception e) { - if (DEBUG_MODE) { - e.printStackTrace(); - } - try { - int s100 = element / 100, s1 = element / 10 % 10, s10 = element % 10; - return (negative ? "~" : "") + Nomenclature.SYMBOL_IUPAC[10 + s100] + Nomenclature.SYMBOL_IUPAC[s10] + Nomenclature.SYMBOL_IUPAC[s1] + " N:" + getNeutralCount() + " I:" + (getNeutralCount() + element) + " C:" + getCharge(); - } catch (Exception E) { - if (DEBUG_MODE) { - e.printStackTrace(); - } - return (negative ? "~" : "") + "? N:" + getNeutralCount() + " I:" + (getNeutralCount() + element) + " C:" + getCharge(); - } - } + return getShortSymbol() + " N:" + getNeutralCount() + " I:" + (getNeutralCount() + element) + " C:" + getCharge(); } @Override public String getShortSymbol() { - int element = Math.abs(this.getElement()); - boolean negative = this.getElement() < 0; - try { - return (negative ? "~" : "") + Nomenclature.SYMBOL[element]; - } catch (Exception e) { - if (DEBUG_MODE) { - e.printStackTrace(); - } - try { - int s100 = element / 100, s1 = element / 10 % 10, s10 = element % 10; - return (negative ? "~" : "") + Nomenclature.SYMBOL_IUPAC[10 + s100] + Nomenclature.SYMBOL_IUPAC[s10] + Nomenclature.SYMBOL_IUPAC[s1]; - } catch (Exception E) { - if (DEBUG_MODE) { - e.printStackTrace(); - } - return (negative ? "~" : "") + "?"; - } + int element = abs(this.getElement()); + boolean anti = this.getElement() < 0; + boolean weird = abs(getGeneration()) != 1; + if(element>=SYMBOL.length){ + StringBuilder s = new StringBuilder(anti?"~":""); + while (element >= 10) { + s.append(SYMBOL_IUPAC[element % 10]); + element = element / 10; + } + s.append(SYMBOL_IUPAC[element + 10]); + s.append(weird?translateToLocal("tt.keyword.Weird"):""); + return s.toString(); } + return (anti?"~":"")+SYMBOL[element]+(weird?translateToLocal("tt.keyword.Weird"):""); } @Override @@ -1133,7 +1126,7 @@ public class EMAtomDefinition extends EMComplexTemplate { private boolean Fission(ArrayList<EMDecay> decaysList, EMDefinitionStackMap fissile, EMDefinitionStackMap particles, double probability, boolean spontaneousCheck) { EMDefinitionStackMap heavy = new EMDefinitionStackMap(); - double[] liquidDrop = liquidDropFunction(Math.abs(getElement()) <= 97); + double[] liquidDrop = liquidDropFunction(abs(getElement()) <= 97); for (EMDefinitionStack stack : fissile.valuesToArray()) { if (spontaneousCheck && stack.getDefinition() instanceof EMHadronDefinition && @@ -1226,7 +1219,7 @@ public class EMAtomDefinition extends EMComplexTemplate { return decays.toArray(EMDecay.NO_PRODUCT); } } - if (energyLevel < Math.abs(getCharge()) / 3 + getNeutralCount()) { + if (energyLevel < abs(getCharge()) / 3 + getNeutralCount()) { return new EMDecay[]{new EMDecay(1, this, boson_Y__)}; } return getNaturalDecayInstant(); @@ -1363,12 +1356,6 @@ public class EMAtomDefinition extends EMComplexTemplate { return element; } - private static final class Nomenclature { - private static final String[] SYMBOL = new String[]{"Nt", "H", "He", "Li", "Be", "B", "C", "N", "O", "F", "Ne", "Na", "Mg", "Al", "Si", "P", "S", "Cl", "Ar", "K", "Ca", "Sc", "Ti", "V", "Cr", "Mn", "Fe", "Co", "Ni", "Cu", "Zn", "Ga", "Ge", "As", "Se", "Br", "Kr", "Rb", "Sr", "Y", "Zr", "Nb", "Mo", "Tc", "Ru", "Rh", "Pd", "Ag", "Cd", "In", "Sn", "Sb", "Te", "I", "Xe", "Cs", "Ba", "La", "Ce", "Pr", "Nd", "Pm", "Sm", "Eu", "Gd", "Tb", "Dy", "Ho", "Er", "Tm", "Yb", "Lu", "Hf", "Ta", "W", "Re", "Os", "Ir", "Pt", "Au", "Hg", "Tl", "Pb", "Bi", "Po", "At", "Rn", "Fr", "Ra", "Ac", "Th", "Pa", "U", "Np", "Pu", "Am", "Cm", "Bk", "Cf", "Es", "Fm", "Md", "No", "Lr", "Rf", "Db", "Sg", "Bh", "Hs", "Mt", "Ds", "Rg", "Cn", "Nh", "Fl", "Mc", "Lv", "Ts", "Og"}; - private static final String[] NAME = new String[]{"Neutronium", "Hydrogen", "Helium", "Lithium", "Beryllium", "Boron", "Carbon", "Nitrogen", "Oxygen", "Fluorine", "Neon", "Sodium", "Magnesium", "Aluminium", "Silicon", "Phosphorus", "Sulfur", "Chlorine", "Argon", "Potassium", "Calcium", "Scandium", "Titanium", "Vanadium", "Chromium", "Manganese", "Iron", "Cobalt", "Nickel", "Copper", "Zinc", "Gallium", "Germanium", "Arsenic", "Selenium", "Bromine", "Krypton", "Rubidium", "Strontium", "Yttrium", "Zirconium", "Niobium", "Molybdenum", "Technetium", "Ruthenium", "Rhodium", "Palladium", "Silver", "Cadmium", "Indium", "Tin", "Antimony", "Tellurium", "Iodine", "Xenon", "Caesium", "Barium", "Lanthanum", "Cerium", "Praseodymium", "Neodymium", "Promethium", "Samarium", "Europium", "Gadolinium", "Terbium", "Dysprosium", "Holmium", "Erbium", "Thulium", "Ytterbium", "Lutetium", "Hafnium", "Tantalum", "Tungsten", "Rhenium", "Osmium", "Iridium", "Platinum", "Gold", "Mercury", "Thallium", "Lead", "Bismuth", "Polonium", "Astatine", "Radon", "Francium", "Radium", "Actinium", "Thorium", "Protactinium", "Uranium", "Neptunium", "Plutonium", "Americium", "Curium", "Berkelium", "Californium", "Einsteinium", "Fermium", "Mendelevium", "Nobelium", "Lawrencium", "Rutherfordium", "Dubnium", "Seaborgium", "Bohrium", "Hassium", "Meitnerium", "Darmstadtium", "Roentgenium", "Copernicium", "Nihonium", "Flerovium", "Moscovium", "Livermorium", "Tennessine", "Oganesson"}; - private static final String[] SYMBOL_IUPAC = new String[]{"n", "u", "b", "t", "q", "p", "h", "s", "o", "e", "N", "U", "B", "T", "Q", "P", "H", "S", "O", "E"}; - } - @Override protected String getIndirectTagValue() { return nbtType; @@ -1398,7 +1385,7 @@ public class EMAtomDefinition extends EMComplexTemplate { //stability curve int StableIsotope = stableIzoCurve(element); int izoDiff = isotope - StableIsotope; - int izoDiffAbs = Math.abs(izoDiff); + int izoDiffAbs = abs(izoDiff); double rawLifeTime = calculateLifeTime(izoDiff, izoDiffAbs, element, isotope, false); EMNuclideIAEA nuclide = EMNuclideIAEA.get(element, isotope); if (rawLifeTime >= STABLE_RAW_LIFE_TIME || nuclide != null && nuclide.getHalfTime() >= STABLE_RAW_LIFE_TIME) { @@ -1415,7 +1402,7 @@ public class EMAtomDefinition extends EMComplexTemplate { //stability curve int Isotope = stableIzoCurve(element); int izoDiff = isotope - Isotope; - int izoDiffAbs = Math.abs(izoDiff); + int izoDiffAbs = abs(izoDiff); double rawLifeTime = calculateLifeTime(izoDiff, izoDiffAbs, element, isotope, false); TreeMap<Double, Integer> isotopes = mostStableUnstableIsotopes.computeIfAbsent(element, k -> new TreeMap<>()); isotopes.put(rawLifeTime, isotope);//todo dont add stable ones 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 ecebc6afcd..b8ce40b180 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 @@ -141,9 +141,12 @@ public final class DebugElementalInstanceContainer_EM extends Item implements IE 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")),new EMInstanceStackMap(new EMInstanceStack(definition, EM_COUNT_PER_MATERIAL_AMOUNT)))); - list.add(setContent(new ItemStack(this).setStackDisplayName(definition.getLocalizedName()+" "+1+" "+translateToLocal("tt.keyword.itemMols")),new EMInstanceStackMap(new EMInstanceStack(definition, EM_COUNT_PER_ITEM)))); - list.add(setContent(new ItemStack(this).setStackDisplayName(definition.getLocalizedName()+" "+1000+" "+translateToLocal("tt.keyword.mbMols")),new EMInstanceStackMap(new EMInstanceStack(definition, EM_COUNT_PER_1k)))); + list.add(setContent(new ItemStack(this).setStackDisplayName(definition.getLocalizedName()+" "+1+" "+translateToLocal("tt.keyword.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")), + new EMInstanceStackMap(new EMInstanceStack(definition, EM_COUNT_PER_ITEM)))); + list.add(setContent(new ItemStack(this).setStackDisplayName(definition.getLocalizedName()+" "+1000+" "+translateToLocal("tt.keyword.mbMols")), + new EMInstanceStackMap(new EMInstanceStack(definition, EM_COUNT_PER_1k)))); } } |