From ab28eb1586f1ff4fa41e4cfa20ee802ffc4fc516 Mon Sep 17 00:00:00 2001 From: Tec Date: Wed, 17 Jul 2019 23:15:45 +0200 Subject: Symbol Renderer on containers --- .../tectech/compatibility/gtpp/GtppAtomLoader.java | 2 +- .../entity/projectiles/projectileEM.java | 2 +- .../definitions/dComplexAspectDefinition.java | 26 + .../technus/tectech/font/TecTechFontRender.java | 275 ++++ .../technus/tectech/loader/ElementalLoader.java | 6 +- .../tectech/loader/recipe/RecipeLoader.java | 4 +- .../tectech/mechanics/anomaly/AnomalyHandler.java | 2 +- .../core/cElementalInstanceStackMap.java | 37 + .../elementalMatter/core/cElementalStackMap.java | 19 + .../core/stacks/cElementalInstanceStack.java | 16 + .../core/templates/cElementalPrimitive.java | 14 + .../core/templates/iElementalDefinition.java | 6 +- .../core/transformations/bTransformationInfo.java | 14 +- .../definitions/complex/atom/dAtomDefinition.java | 1657 ------------------- .../definitions/complex/atom/iaeaNuclide.java | 288 ---- .../definitions/complex/dAtomDefinition.java | 1685 ++++++++++++++++++++ .../definitions/complex/dHadronDefinition.java | 481 ++++++ .../complex/hadron/dHadronDefinition.java | 463 ------ .../definitions/complex/iaeaNuclide.java | 288 ++++ .../github/technus/tectech/proxy/ClientProxy.java | 37 +- .../github/technus/tectech/proxy/CommonProxy.java | 7 - .../item/DebugElementalInstanceContainer_EM.java | 35 +- .../item/ElementalDefinitionContainer_EM.java | 27 +- .../item/ElementalDefinitionScanStorage_EM.java | 26 +- .../tectech/thing/item/gui/ScanDisplayScreen.java | 23 +- .../thing/item/renderElemental/IElementalItem.java | 7 + .../item/renderElemental/RenderElementalName.java | 74 + .../hatch/gui/GT_GUIContainer_Param.java | 18 +- .../hatch/gui/GT_GUIContainer_ParamAdv.java | 20 +- .../hatch/gui/GT_GUIContainer_Uncertainty.java | 8 +- .../hatch/gui/GT_GUIContainer_UncertaintyAdv.java | 8 +- .../multi/GT_MetaTileEntity_EM_collider.java | 4 +- .../multi/GT_MetaTileEntity_EM_dequantizer.java | 4 +- .../multi/GT_MetaTileEntity_EM_quantizer.java | 4 +- .../multi/em_machine/Behaviour_Centrifuge.java | 2 +- .../Behaviour_ElectromagneticSeparator.java | 2 +- 36 files changed, 3083 insertions(+), 2508 deletions(-) create mode 100644 src/main/java/com/github/technus/tectech/font/TecTechFontRender.java delete mode 100644 src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/complex/atom/dAtomDefinition.java delete mode 100644 src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/complex/atom/iaeaNuclide.java create mode 100644 src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/complex/dAtomDefinition.java create mode 100644 src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/complex/dHadronDefinition.java delete mode 100644 src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/complex/hadron/dHadronDefinition.java create mode 100644 src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/complex/iaeaNuclide.java create mode 100644 src/main/java/com/github/technus/tectech/thing/item/renderElemental/IElementalItem.java create mode 100644 src/main/java/com/github/technus/tectech/thing/item/renderElemental/RenderElementalName.java (limited to 'src/main/java') diff --git a/src/main/java/com/github/technus/tectech/compatibility/gtpp/GtppAtomLoader.java b/src/main/java/com/github/technus/tectech/compatibility/gtpp/GtppAtomLoader.java index a7cb8bb8a0..ad24f72cb0 100644 --- a/src/main/java/com/github/technus/tectech/compatibility/gtpp/GtppAtomLoader.java +++ b/src/main/java/com/github/technus/tectech/compatibility/gtpp/GtppAtomLoader.java @@ -6,7 +6,7 @@ import net.minecraftforge.fluids.FluidStack; import java.lang.reflect.Method; -import static com.github.technus.tectech.mechanics.elementalMatter.definitions.complex.atom.dAtomDefinition.*; +import static com.github.technus.tectech.mechanics.elementalMatter.definitions.complex.dAtomDefinition.*; public class GtppAtomLoader implements Runnable{ //region reflect a bit diff --git a/src/main/java/com/github/technus/tectech/compatibility/openmodularturrets/entity/projectiles/projectileEM.java b/src/main/java/com/github/technus/tectech/compatibility/openmodularturrets/entity/projectiles/projectileEM.java index c22c6c4b95..e8163833ee 100644 --- a/src/main/java/com/github/technus/tectech/compatibility/openmodularturrets/entity/projectiles/projectileEM.java +++ b/src/main/java/com/github/technus/tectech/compatibility/openmodularturrets/entity/projectiles/projectileEM.java @@ -3,7 +3,7 @@ package com.github.technus.tectech.compatibility.openmodularturrets.entity.proje import com.github.technus.tectech.TecTech; import com.github.technus.tectech.mechanics.elementalMatter.core.cElementalInstanceStackMap; import com.github.technus.tectech.mechanics.elementalMatter.core.stacks.cElementalInstanceStack; -import com.github.technus.tectech.mechanics.elementalMatter.definitions.complex.hadron.dHadronDefinition; +import com.github.technus.tectech.mechanics.elementalMatter.definitions.complex.dHadronDefinition; import com.github.technus.tectech.mechanics.elementalMatter.definitions.primitive.eQuarkDefinition; import gregtech.api.GregTech_API; import gregtech.api.util.GT_Utility; diff --git a/src/main/java/com/github/technus/tectech/compatibility/thaumcraft/elementalMatter/definitions/dComplexAspectDefinition.java b/src/main/java/com/github/technus/tectech/compatibility/thaumcraft/elementalMatter/definitions/dComplexAspectDefinition.java index 77dffad225..059ac44da3 100644 --- a/src/main/java/com/github/technus/tectech/compatibility/thaumcraft/elementalMatter/definitions/dComplexAspectDefinition.java +++ b/src/main/java/com/github/technus/tectech/compatibility/thaumcraft/elementalMatter/definitions/dComplexAspectDefinition.java @@ -108,6 +108,25 @@ public final class dComplexAspectDefinition extends cElementalDefinition impleme return symbol.toString(); } + @Override + public String getShortSymbol() { + StringBuilder symbol = new StringBuilder(8); + for (cElementalDefinitionStack aspect : aspectStacks.values()) { + if (aspect.definition instanceof ePrimalAspectDefinition) { + for (int i = 0; i < aspect.amount; i++) { + symbol.append(aspect.definition.getShortSymbol()); + } + } else { + symbol.append('('); + for (int i = 0; i < aspect.amount; i++) { + symbol.append(aspect.definition.getShortSymbol()); + } + symbol.append(')'); + } + } + return symbol.toString(); + } + @Override public NBTTagCompound toNBT() { return getNbtTagCompound(nbtType, aspectStacks); @@ -266,6 +285,13 @@ public final class dComplexAspectDefinition extends cElementalDefinition impleme return hash; } + @Override + public void addScanShortSymbols(ArrayList lines, int capabilities, long energyLevel) { + if(Util.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(Util.areBitsSet(SCAN_GET_CLASS_TYPE, capabilities)) { diff --git a/src/main/java/com/github/technus/tectech/font/TecTechFontRender.java b/src/main/java/com/github/technus/tectech/font/TecTechFontRender.java new file mode 100644 index 0000000000..f20bc28402 --- /dev/null +++ b/src/main/java/com/github/technus/tectech/font/TecTechFontRender.java @@ -0,0 +1,275 @@ +package com.github.technus.tectech.font; + +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_M = 0.06F; + private static float DISTANCE_M2 = DISTANCE_M *2F; + + private static float DISTANCE_S = 0.06F; + private static float DISTANCE_S2 = DISTANCE_S *2F; + + private static float DISTANCE_A = 0.06F; + private static float DISTANCE_A2 = DISTANCE_A *2F; + + private Method reset; + private Method render; + + private final GameSettings gameSettings; + + private TecTechFontRender() { + super(Minecraft.getMinecraft().gameSettings, new ResourceLocation("textures/font/ascii.png"), Minecraft.getMinecraft().renderEngine, false); + gameSettings = Minecraft.getMinecraft().gameSettings; + + try { + reset =FontRenderer.class.getDeclaredMethod("resetStyles"); + render=FontRenderer.class.getDeclaredMethod("renderString", String.class, int.class, int.class, int.class, boolean.class); + } catch (NoSuchMethodException e) { + try { + reset =FontRenderer.class.getDeclaredMethod("func_78265_b"); + render=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); + } + } + reset.setAccessible(true); + render.setAccessible(true); + } + + private void resetStyles2(){ + try { + reset.invoke(this); + } catch (IllegalAccessException | InvocationTargetException e) { + throw new RuntimeException("Cannot run method resetStyles!",e); + } + } + + 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); + } + } + + + @Override + public int drawString(String str, int x, int y, int color, boolean dropShadow) { + switch (gameSettings.guiScale){ + case 0: + setUnicodeFlag(true); + y--; + GL11.glPushMatrix(); + + if (dropShadow) + { + GL11.glTranslatef(DISTANCE_A, DISTANCE_A, 0F); + drawStringBack(str, x, y, color); + GL11.glTranslatef(-DISTANCE_A2, 0, 0F); + drawStringBack(str, x, y, color); + GL11.glTranslatef(0, -DISTANCE_A2, 0F); + drawStringBack(str, x, y, color); + GL11.glTranslatef(DISTANCE_A2, 0, 0F); + } + + GL11.glTranslatef(DISTANCE_A, DISTANCE_A, 0F); + drawStringFront(str, x, y, color); + GL11.glTranslatef(-DISTANCE_A2, 0, 0F); + drawStringFront(str, x, y, color); + GL11.glTranslatef(0, -DISTANCE_A2, 0F); + drawStringFront(str, x, y, color); + GL11.glTranslatef(DISTANCE_A2, 0, 0F); + + GL11.glPopMatrix(); + break; + case 1: + return Minecraft.getMinecraft().fontRenderer.drawString(str, x, y, color, dropShadow); + case 2: + setUnicodeFlag(true); + y--; + GL11.glPushMatrix(); + + if (dropShadow) + { + GL11.glTranslatef(DISTANCE_M, DISTANCE_M, 0F); + drawStringBack(str, x, y, color); + GL11.glTranslatef(-DISTANCE_M2, 0, 0F); + drawStringBack(str, x, y, color); + GL11.glTranslatef(0, -DISTANCE_M2, 0F); + drawStringBack(str, x, y, color); + GL11.glTranslatef(DISTANCE_M2, 0, 0F); + } + + GL11.glTranslatef(DISTANCE_M, DISTANCE_M, 0F); + drawStringFront(str, x, y, color); + GL11.glTranslatef(-DISTANCE_M2, 0, 0F); + drawStringFront(str, x, y, color); + GL11.glTranslatef(0, -DISTANCE_M2, 0F); + drawStringFront(str, x, y, color); + GL11.glTranslatef(DISTANCE_M2, 0, 0F); + + GL11.glPopMatrix(); + break; + case 3: + setUnicodeFlag(true); + y--; + GL11.glPushMatrix(); + + if (dropShadow) + { + GL11.glTranslatef(DISTANCE_L, DISTANCE_L, 0F); + drawStringBack(str, x, y, color); + GL11.glTranslatef(-DISTANCE_L2, 0, 0F); + drawStringBack(str, x, y, color); + GL11.glTranslatef(0, -DISTANCE_L2, 0F); + drawStringBack(str, x, y, color); + GL11.glTranslatef(DISTANCE_L2, 0, 0F); + } + + GL11.glTranslatef(DISTANCE_L, DISTANCE_L, 0F); + drawStringFront(str, x, y, color); + GL11.glTranslatef(-DISTANCE_L2, 0, 0F); + drawStringFront(str, x, y, color); + GL11.glTranslatef(0, -DISTANCE_L2, 0F); + drawStringFront(str, x, y, color); + GL11.glTranslatef(DISTANCE_L2, 0, 0F); + + GL11.glPopMatrix(); + break; + } + return drawStringFront(str, x, y, color); + } + + @Override + public void drawSplitString(String str, int x, int y, int maxWidth, int color) { + switch (gameSettings.guiScale){ + case 0: + setUnicodeFlag(true); + y--; + GL11.glPushMatrix(); + + GL11.glTranslatef(DISTANCE_A, DISTANCE_A, 0F); + super.drawSplitString(str, x, y, maxWidth, color); + GL11.glTranslatef(-DISTANCE_A2, 0, 0F); + super.drawSplitString(str, x, y, maxWidth, color); + GL11.glTranslatef(0, -DISTANCE_A2, 0F); + super.drawSplitString(str, x, y, maxWidth, color); + GL11.glTranslatef(DISTANCE_A2, 0, 0F); + + GL11.glPopMatrix(); + break; + case 1: + Minecraft.getMinecraft().fontRenderer.drawSplitString(str, x, y, maxWidth, color); + break; + case 2: + setUnicodeFlag(true); + y--; + GL11.glPushMatrix(); + + GL11.glTranslatef(DISTANCE_M, DISTANCE_M, 0F); + super.drawSplitString(str, x, y, maxWidth, color); + GL11.glTranslatef(-DISTANCE_M2, 0, 0F); + super.drawSplitString(str, x, y, maxWidth, color); + GL11.glTranslatef(0, -DISTANCE_M2, 0F); + super.drawSplitString(str, x, y, maxWidth, color); + GL11.glTranslatef(DISTANCE_M2, 0, 0F); + + GL11.glPopMatrix(); + break; + case 3: + setUnicodeFlag(true); + y--; + GL11.glPushMatrix(); + + GL11.glTranslatef(DISTANCE_L, DISTANCE_L, 0F); + super.drawSplitString(str, x, y, maxWidth, color); + GL11.glTranslatef(-DISTANCE_L2, 0, 0F); + super.drawSplitString(str, x, y, maxWidth, color); + GL11.glTranslatef(0, -DISTANCE_L2, 0F); + super.drawSplitString(str, x, y, maxWidth, color); + GL11.glTranslatef(DISTANCE_L2, 0, 0F); + + GL11.glPopMatrix(); + break; + } + } + + private int drawStringFront(String p_85187_1_, int p_85187_2_, int p_85187_3_, int p_85187_4_) { + enableAlpha(); + resetStyles2(); + return renderString2(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_) { + enableAlpha(); + resetStyles2(); + return renderString2(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){ + return Minecraft.getMinecraft().fontRenderer.getStringWidth(p_78256_1_); + } + if (p_78256_1_ == null) + { + return 0; + } + else + { + int i = 0; + boolean flag = false; + + for (int j = 0; j < p_78256_1_.length(); ++j) + { + char c0 = p_78256_1_.charAt(j); + int k = this.getCharWidth(c0); + + 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) + { + flag = false; + } + } + else + { + flag = true; + } + + k = 0; + } + + i += k; + + if (flag && k > 0) + { + ++i; + } + } + + return i; + } + } +} diff --git a/src/main/java/com/github/technus/tectech/loader/ElementalLoader.java b/src/main/java/com/github/technus/tectech/loader/ElementalLoader.java index 130106a76b..79ad5dc98c 100644 --- a/src/main/java/com/github/technus/tectech/loader/ElementalLoader.java +++ b/src/main/java/com/github/technus/tectech/loader/ElementalLoader.java @@ -3,9 +3,9 @@ package com.github.technus.tectech.loader; import com.github.technus.tectech.compatibility.thaumcraft.elementalMatter.definitions.dComplexAspectDefinition; import com.github.technus.tectech.compatibility.thaumcraft.elementalMatter.definitions.ePrimalAspectDefinition; import com.github.technus.tectech.mechanics.elementalMatter.core.templates.cElementalPrimitive; -import com.github.technus.tectech.mechanics.elementalMatter.definitions.complex.atom.dAtomDefinition; -import com.github.technus.tectech.mechanics.elementalMatter.definitions.complex.atom.iaeaNuclide; -import com.github.technus.tectech.mechanics.elementalMatter.definitions.complex.hadron.dHadronDefinition; +import com.github.technus.tectech.mechanics.elementalMatter.definitions.complex.dAtomDefinition; +import com.github.technus.tectech.mechanics.elementalMatter.definitions.complex.iaeaNuclide; +import com.github.technus.tectech.mechanics.elementalMatter.definitions.complex.dHadronDefinition; import com.github.technus.tectech.mechanics.elementalMatter.definitions.primitive.*; /** diff --git a/src/main/java/com/github/technus/tectech/loader/recipe/RecipeLoader.java b/src/main/java/com/github/technus/tectech/loader/recipe/RecipeLoader.java index 56f461eeb5..8a0fb20c59 100644 --- a/src/main/java/com/github/technus/tectech/loader/recipe/RecipeLoader.java +++ b/src/main/java/com/github/technus/tectech/loader/recipe/RecipeLoader.java @@ -2,8 +2,8 @@ package com.github.technus.tectech.loader.recipe; import com.github.technus.tectech.Reference; import com.github.technus.tectech.compatibility.dreamcraft.DreamCraftRecipeLoader; -import com.github.technus.tectech.mechanics.elementalMatter.definitions.complex.atom.dAtomDefinition; -import com.github.technus.tectech.mechanics.elementalMatter.definitions.complex.hadron.dHadronDefinition; +import com.github.technus.tectech.mechanics.elementalMatter.definitions.complex.dAtomDefinition; +import com.github.technus.tectech.mechanics.elementalMatter.definitions.complex.dHadronDefinition; import com.github.technus.tectech.thing.CustomItemList; import com.github.technus.tectech.thing.casing.TT_Container_Casings; import com.github.technus.tectech.thing.item.ConstructableTriggerItem; diff --git a/src/main/java/com/github/technus/tectech/mechanics/anomaly/AnomalyHandler.java b/src/main/java/com/github/technus/tectech/mechanics/anomaly/AnomalyHandler.java index dc7e8faef7..2a770ea332 100644 --- a/src/main/java/com/github/technus/tectech/mechanics/anomaly/AnomalyHandler.java +++ b/src/main/java/com/github/technus/tectech/mechanics/anomaly/AnomalyHandler.java @@ -8,7 +8,7 @@ import com.github.technus.tectech.mechanics.data.ChunkDataHandler; import com.github.technus.tectech.mechanics.data.ChunkDataMessage; import com.github.technus.tectech.mechanics.data.IChunkMetaDataHandler; import com.github.technus.tectech.mechanics.data.PlayerDataMessage; -import com.github.technus.tectech.mechanics.elementalMatter.definitions.complex.atom.dAtomDefinition; +import com.github.technus.tectech.mechanics.elementalMatter.definitions.complex.dAtomDefinition; import cpw.mods.fml.common.gameevent.TickEvent; import gregtech.api.GregTech_API; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; diff --git a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/cElementalInstanceStackMap.java b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/cElementalInstanceStackMap.java index bfbe93bb4f..5893ac1a1f 100644 --- a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/cElementalInstanceStackMap.java +++ b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/cElementalInstanceStackMap.java @@ -316,6 +316,15 @@ public final class cElementalInstanceStackMap implements Comparable getScanShortSymbols(int[] capabilities) { + ArrayList list=new ArrayList<>(16); + for(Map.Entry e:map.entrySet()){ + e.getValue().addScanShortSymbols(list,capabilities); + } + return list; + } + public ArrayList getScanInfo(int[] capabilities) { ArrayList list=new ArrayList<>(16); for(Map.Entry e:map.entrySet()){ @@ -412,6 +429,16 @@ public final class cElementalInstanceStackMap implements Comparable 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); diff --git a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/cElementalStackMap.java b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/cElementalStackMap.java index fb6acec084..dbbfa7bf66 100644 --- a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/cElementalStackMap.java +++ b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/cElementalStackMap.java @@ -34,6 +34,15 @@ abstract class cElementalStackMap implements Comparable { return map.get(def); } + public String[] getShortSymbolsInfo() { + String[] info = new String[map.size()]; + int i = 0; + for (cElementalDefinitionStack instance : map.values()) { + info[i++] = instance.definition.getShortSymbol(); + } + return info; + } + public final String[] getElementalInfo() { String[] info = new String[map.size() * 3]; int i = 0; @@ -86,6 +95,16 @@ abstract class cElementalStackMap implements Comparable { } //NBT + public final 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; + } + public final NBTTagCompound getInfoNBT() { NBTTagCompound nbt = new NBTTagCompound(); String[] info = getElementalInfo(); diff --git a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/stacks/cElementalInstanceStack.java b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/stacks/cElementalInstanceStack.java index 7c04fe2c40..ba3c8f909c 100644 --- a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/stacks/cElementalInstanceStack.java +++ b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/stacks/cElementalInstanceStack.java @@ -420,6 +420,22 @@ public final class cElementalInstanceStack implements iHasElementalDefinition { return this; } + public void addScanShortSymbols(ArrayList lines, int[] detailsOnDepthLevels){ + int capabilities=detailsOnDepthLevels[0]; + definition.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(Util.areBitsSet(SCAN_GET_DEPTH_LEVEL,capabilities)) { diff --git a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/templates/cElementalPrimitive.java b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/templates/cElementalPrimitive.java index 749d5c687b..63642d6dbd 100644 --- a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/templates/cElementalPrimitive.java +++ b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/templates/cElementalPrimitive.java @@ -18,6 +18,7 @@ import java.util.Map; import static com.github.technus.tectech.Util.areBitsSet; import static com.github.technus.tectech.loader.TecTechConfig.DEBUG_MODE; import static com.github.technus.tectech.mechanics.elementalMatter.definitions.primitive.cPrimitiveDefinition.null__; +import static com.github.technus.tectech.thing.item.DebugElementalInstanceContainer_EM.stacksRegistered; import static com.github.technus.tectech.thing.metaTileEntity.multi.GT_MetaTileEntity_EM_scanner.*; /** @@ -67,6 +68,7 @@ public abstract class cElementalPrimitive extends cElementalDefinition { if (bindsBO.put(ID, this) != null) { Minecraft.getMinecraft().crashed(new CrashReport("Primitive definition", new tElementalException("Duplicate ID"))); } + stacksRegistered.add(this); } // @@ -88,6 +90,11 @@ public abstract class cElementalPrimitive extends cElementalDefinition { return symbol; } + @Override + public String getShortSymbol() { + return symbol; + } + @Override public iElementalDefinition getAnti() { return anti;//no need for copy @@ -210,6 +217,13 @@ public abstract class cElementalPrimitive extends cElementalDefinition { return -128; } + @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)) { diff --git a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/templates/iElementalDefinition.java b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/templates/iElementalDefinition.java index 6293e9ccf2..08be835cdf 100644 --- a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/templates/iElementalDefinition.java +++ b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/templates/iElementalDefinition.java @@ -24,6 +24,10 @@ public abstract class iElementalDefinition implements Comparable lines, int capabilities, long energyLevel); + public abstract void addScanResults(ArrayList lines, int capabilities, long energyLevel); public abstract byte getType(); @@ -75,7 +79,7 @@ public abstract class iElementalDefinition implements Comparable oredictQuantization=new HashMap<>(32); public HashMap oredictDequantization; - public static final HashSet stacksRegistered=new HashSet<>(); - public bTransformationInfo(int fluidCap,int itemCap, int oreCap){ if(fluidCap>0) { fluidDequantization = new HashMap<>(fluidCap); @@ -43,18 +42,21 @@ public class bTransformationInfo { fluidQuantization.put(fluidStack.getFluidID(),new aFluidQuantizationInfo(fluidStack,em)); fluidDequantization.put(em.getDefinition(),new aFluidDequantizationInfo(em,fluidStack)); stacksRegistered.add(em.getDefinition()); + stacksRegistered.add(em.getDefinition().getAnti()); } public void addFluid(iHasElementalDefinition em ,int fluidID,int fluidAmount) { fluidQuantization.put(fluidID,new aFluidQuantizationInfo(fluidID,fluidAmount,em)); fluidDequantization.put(em.getDefinition(),new aFluidDequantizationInfo(em,fluidID,fluidAmount)); stacksRegistered.add(em.getDefinition()); + stacksRegistered.add(em.getDefinition().getAnti()); } public void addFluid(iHasElementalDefinition em, Fluid fluid, int fluidAmount){ fluidQuantization.put(fluid.getID(),new aFluidQuantizationInfo(fluid,fluidAmount,em)); fluidDequantization.put(em.getDefinition(),new aFluidDequantizationInfo(em,fluid,fluidAmount)); stacksRegistered.add(em.getDefinition()); + stacksRegistered.add(em.getDefinition().getAnti()); } private void addItemQuantization(aItemQuantizationInfo aIQI){ @@ -65,35 +67,41 @@ public class bTransformationInfo { addItemQuantization(new aItemQuantizationInfo(itemStack,skipNBT,em)); itemDequantization.put(em.getDefinition(),new aItemDequantizationInfo(em,itemStack)); stacksRegistered.add(em.getDefinition()); + stacksRegistered.add(em.getDefinition().getAnti()); } public void addItem(iHasElementalDefinition em, OrePrefixes prefix, Materials material, int amount, boolean skipNBT){ addItemQuantization(new aItemQuantizationInfo(prefix,material,amount,skipNBT,em)); itemDequantization.put(em.getDefinition(),new aItemDequantizationInfo(em,prefix,material,amount)); stacksRegistered.add(em.getDefinition()); + stacksRegistered.add(em.getDefinition().getAnti()); } public void addOredict(iHasElementalDefinition em, int id, int qty){ oredictQuantization.put(id,new aOredictQuantizationInfo(id,qty,em)); oredictDequantization.put(em.getDefinition(),new aOredictDequantizationInfo(em,id,qty)); stacksRegistered.add(em.getDefinition()); + stacksRegistered.add(em.getDefinition().getAnti()); } public void addOredict(iHasElementalDefinition em, String name, int qty){ oredictQuantization.put(OreDictionary.getOreID(name),new aOredictQuantizationInfo(name,qty,em)); oredictDequantization.put(em.getDefinition(),new aOredictDequantizationInfo(em,name,qty)); stacksRegistered.add(em.getDefinition()); + stacksRegistered.add(em.getDefinition().getAnti()); } public void addOredict(iHasElementalDefinition em, OrePrefixes prefix, Materials material, int qty){ oredictQuantization.put(OreDictionary.getOreID(prefix.name() + material.mName),new aOredictQuantizationInfo(prefix,material,qty,em)); oredictDequantization.put(em.getDefinition(),new aOredictDequantizationInfo(em,prefix,material,qty)); stacksRegistered.add(em.getDefinition()); + stacksRegistered.add(em.getDefinition().getAnti()); } public void addOredict(iHasElementalDefinition em, OrePrefixes prefix, String materialName, int qty){ oredictQuantization.put(OreDictionary.getOreID(prefix.name() + materialName),new aOredictQuantizationInfo(prefix,materialName,qty,em)); oredictDequantization.put(em.getDefinition(),new aOredictDequantizationInfo(em,prefix,materialName,qty)); stacksRegistered.add(em.getDefinition()); + stacksRegistered.add(em.getDefinition().getAnti()); } } diff --git a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/complex/atom/dAtomDefinition.java b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/complex/atom/dAtomDefinition.java deleted file mode 100644 index 86d31bfb1b..0000000000 --- a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/complex/atom/dAtomDefinition.java +++ /dev/null @@ -1,1657 +0,0 @@ -package com.github.technus.tectech.mechanics.elementalMatter.definitions.complex.atom; - -import com.github.technus.tectech.Reference; -import com.github.technus.tectech.TecTech; -import com.github.technus.tectech.Util; -import com.github.technus.tectech.XSTR; -import com.github.technus.tectech.compatibility.gtpp.GtppAtomLoader; -import com.github.technus.tectech.mechanics.elementalMatter.core.cElementalDecay; -import com.github.technus.tectech.mechanics.elementalMatter.core.cElementalDefinitionStackMap; -import com.github.technus.tectech.mechanics.elementalMatter.core.cElementalMutableDefinitionStackMap; -import com.github.technus.tectech.mechanics.elementalMatter.core.stacks.cElementalDefinitionStack; -import com.github.technus.tectech.mechanics.elementalMatter.core.tElementalException; -import com.github.technus.tectech.mechanics.elementalMatter.core.templates.cElementalDefinition; -import com.github.technus.tectech.mechanics.elementalMatter.core.templates.iElementalDefinition; -import com.github.technus.tectech.mechanics.elementalMatter.core.transformations.aFluidDequantizationInfo; -import com.github.technus.tectech.mechanics.elementalMatter.core.transformations.aItemDequantizationInfo; -import com.github.technus.tectech.mechanics.elementalMatter.core.transformations.aOredictDequantizationInfo; -import com.github.technus.tectech.mechanics.elementalMatter.core.transformations.bTransformationInfo; -import com.github.technus.tectech.mechanics.elementalMatter.definitions.complex.hadron.dHadronDefinition; -import com.github.technus.tectech.mechanics.elementalMatter.definitions.primitive.eBosonDefinition; -import com.github.technus.tectech.mechanics.elementalMatter.definitions.primitive.eLeptonDefinition; -import com.github.technus.tectech.mechanics.elementalMatter.definitions.primitive.eNeutrinoDefinition; -import cpw.mods.fml.common.Loader; -import gregtech.api.enums.Materials; -import net.minecraft.nbt.NBTTagCompound; - -import java.util.*; - -import static com.github.technus.tectech.XSTR.XSTR_INSTANCE; -import static com.github.technus.tectech.compatibility.thaumcraft.elementalMatter.definitions.dComplexAspectDefinition.getNbtTagCompound; -import static com.github.technus.tectech.loader.TecTechConfig.DEBUG_MODE; -import static com.github.technus.tectech.mechanics.elementalMatter.definitions.primitive.eBosonDefinition.boson_Y__; -import static com.github.technus.tectech.mechanics.elementalMatter.definitions.primitive.eBosonDefinition.deadEnd; -import static com.github.technus.tectech.thing.metaTileEntity.multi.GT_MetaTileEntity_EM_scanner.*; -import static gregtech.api.enums.OrePrefixes.dust; - -/** - * Created by danie_000 on 18.11.2016. - */ -public final class dAtomDefinition extends cElementalDefinition { - public static final long ATOM_COMPLEXITY_LIMIT=65536L; - private static final byte BYTE_OFFSET=32; - - private final int hash; - public static final bTransformationInfo transformation=new bTransformationInfo(16,0,64); - public static float refMass, refUnstableMass; - - private static final byte nbtType = (byte) 'a'; - private static final Random xstr = new XSTR();//NEEDS SEPARATE! - private static Map> stableIsotopes = new HashMap<>(); - private static final Map stableAtoms = new HashMap<>(); - private static Map> mostStableUnstableIsotopes = new HashMap<>(); - private static final Map unstableAtoms = new HashMap<>(); - private static cElementalDefinitionStack alpha,deuterium,tritium,helium_3,beryllium_8,carbon_14,neon_24,silicon_34; - private static final HashMap lifetimeOverrides = new HashMap<>(); - - public final iaeaNuclide iaea; - - private static dAtomDefinition somethingHeavy; - public static dAtomDefinition getSomethingHeavy() { - return somethingHeavy; - } - - private static final ArrayList overrides = new ArrayList<>(); - public static void addOverride(dAtomDefinition atom, float rawLifeTime){ - lifetimeOverrides.put(atom,rawLifeTime); - } - - //float-mass in eV/c^2 - public final float mass; - //public final int charge; - public final int charge; - //int -electric charge in 1/3rds of electron charge for optimization - public final int chargeLeptons; - private float rawLifeTime; - //generation max present inside - minus if contains any anti quark - public final byte type; - - public final byte decayMode;//t neutron to proton+,0,f proton to neutron - //public final boolean stable; - - public final int neutralCount; - public final int element; - - private final boolean iaeaDefinitionExistsAndHasEnergyLevels; - - private final cElementalDefinitionStackMap elementalStacks; - - //stable is rawLifeTime>=10^9 - - @Deprecated - public dAtomDefinition(iElementalDefinition... things) throws tElementalException { - this(true, new cElementalDefinitionStackMap(things)); - } - - @Deprecated - private dAtomDefinition(boolean check, iElementalDefinition... things) throws tElementalException { - this(check, new cElementalDefinitionStackMap(things)); - } - - public dAtomDefinition(cElementalDefinitionStack... things) throws tElementalException { - this(true, new cElementalDefinitionStackMap(things)); - } - - private dAtomDefinition(boolean check, cElementalDefinitionStack... things) throws tElementalException { - this(check, new cElementalDefinitionStackMap(things)); - } - - public dAtomDefinition(cElementalDefinitionStackMap things) throws tElementalException { - this(true, things); - } - - private dAtomDefinition(boolean check, cElementalDefinitionStackMap things) throws tElementalException { - if (check && !canTheyBeTogether(things)) { - throw new tElementalException("Atom Definition error"); - } - elementalStacks = things; - - float mass = 0; - int cLeptons = 0; - int cNucleus = 0; - int neutralCount = 0, element = 0; - int type = 0; - boolean containsAnti = false; - for (cElementalDefinitionStack stack : elementalStacks.values()) { - iElementalDefinition def = stack.definition; - int amount = (int)stack.amount; - mass += stack.getMass(); - if (def.getType() < 0) { - containsAnti = true; - } - type = Math.max(type, Math.abs(def.getType())); - - if (def instanceof eLeptonDefinition) { - cLeptons += stack.getCharge(); - } else { - cNucleus += stack.getCharge(); - if (def.getCharge() == 3) { - element += amount; - } else if (def.getCharge() == -3) { - element -= amount; - } else if (def.getCharge() == 0) { - neutralCount += amount; - } - } - } - this.type = containsAnti ? (byte) -type : (byte) type; - //this.mass = mass; - chargeLeptons = cLeptons; - charge = cNucleus + cLeptons; - this.neutralCount = neutralCount; - this.element = element; - - element = Math.abs(element); - - //stability curve - int StableIsotope = stableIzoCurve(element); - int izoDiff = neutralCount - StableIsotope; - int izoDiffAbs = Math.abs(izoDiff); - - xstr.setSeed((element + 1L) * (neutralCount + 100L)); - iaea =iaeaNuclide.get(element,neutralCount); - if(iaea!=null){ - if(Float.isNaN(iaea.mass)) { - this.mass = mass; - } else { - this.mass = iaea.mass; - } - - if(Float.isNaN(iaea.halfTime)) { - Float overriddenLifeTime= lifetimeOverrides.get(this); - float rawLifeTimeTemp; - if(overriddenLifeTime!=null) { - rawLifeTimeTemp = overriddenLifeTime; - } else { - rawLifeTimeTemp = calculateLifeTime(izoDiff, izoDiffAbs, element, neutralCount, containsAnti); - } - rawLifeTime =rawLifeTimeTemp> iElementalDefinition.STABLE_RAW_LIFE_TIME ? iElementalDefinition.STABLE_RAW_LIFE_TIME :rawLifeTimeTemp; - }else { - rawLifeTime = containsAnti ? iaea.halfTime * 1.5514433E-21f * (1f + xstr.nextFloat() * 9f) : iaea.halfTime; - } - iaeaDefinitionExistsAndHasEnergyLevels =iaea.energeticStatesArray.length>1; - }else{ - this.mass=mass; - - Float overriddenLifeTime= lifetimeOverrides.get(this); - float rawLifeTimeTemp; - if(overriddenLifeTime!=null) { - rawLifeTimeTemp = overriddenLifeTime; - } else { - rawLifeTimeTemp = calculateLifeTime(izoDiff, izoDiffAbs, element, neutralCount, containsAnti); - } - rawLifeTime =rawLifeTimeTemp> iElementalDefinition.STABLE_RAW_LIFE_TIME ? iElementalDefinition.STABLE_RAW_LIFE_TIME :rawLifeTimeTemp; - - iaeaDefinitionExistsAndHasEnergyLevels =false; - } - - if(iaea==null || iaea.energeticStatesArray[0].energy!=0) { - if (izoDiff == 0) { - decayMode = 0; - } else { - decayMode = izoDiff > 0 ? (byte) Math.min(2, 1 + izoDiffAbs / 4) : (byte) -Math.min(2, 1 + izoDiffAbs / 4); - } - }else{ - decayMode = izoDiff > 0 ? (byte) (Math.min(2, 1 + izoDiffAbs / 4)+ BYTE_OFFSET) : (byte) (-Math.min(2, 1 + izoDiffAbs / 4) + BYTE_OFFSET); - } - //this.stable = this.rawLifeTime >= STABLE_RAW_LIFE_TIME; - - hash=super.hashCode(); - } - - private static int stableIzoCurve(int element) { - return (int) Math.round(-1.19561E-06 * Math.pow(element, 4D) + - 1.60885E-04 * Math.pow(element, 3D) + - 3.76604E-04 * Math.pow(element, 2D) + - 1.08418E+00 * (double) element); - } - - private static float calculateLifeTime(int izoDiff, int izoDiffAbs, int element, int isotope, boolean containsAnti) { - float rawLifeTime; - - if (element <= 83 && isotope < 127 && (izoDiffAbs == 0 || element == 1 && isotope == 0 || element == 2 && isotope == 1 || izoDiffAbs == 1 && element > 2 && element % 2 == 1 || izoDiffAbs == 3 && element > 30 && element % 2 == 0 || izoDiffAbs == 5 && element > 30 && element % 2 == 0 || izoDiffAbs == 2 && element > 20 && element % 2 == 1)) { - rawLifeTime = containsAnti ? 2.381e4f * (1f + xstr.nextFloat() * 9f) : (1f + xstr.nextFloat() * 9f) * 1.5347e25F; - } else { - //Y = (X-A)/(B-A) * (D-C) + C - float unstabilityEXP; - if (element == 0) { - return 1e-35f; - } else if (element == 1) { - unstabilityEXP = 1.743f - Math.abs(izoDiff - 1) * 9.743f; - } else if (element == 2) { - switch (isotope) { - case 4: - unstabilityEXP = 1.61f; - break; - case 5: - unstabilityEXP = -7.523F; - break; - case 6: - unstabilityEXP = -1.51f; - break; - default: - unstabilityEXP = -(izoDiffAbs * 6.165F); - break; - } - } else if (element <= 83 || isotope <= 127 && element <= 120) { - float elementPow4 = (float) Math.pow(element, 4f); - - unstabilityEXP = Math.min(element / 2.4f, 6 + ((element + 1) % 2) * 3e6F / elementPow4) + (float) -izoDiff * elementPow4 / 1e8F - Math.abs(izoDiff - 1 + element / 60F) * (3f - element / 12.5f + element * element / 1500f); - } else if (element < 180) { - unstabilityEXP = Math.min((element - 85) * 2, 16 + ((isotope + 1) % 2) * 2.5F - (element - 85) / 3F) - Math.abs(izoDiff) * (3f - element / 13f + element * element / 1600f); - } else { - return -1; - } - if ((isotope == 127 || isotope == 128) && element < 120 && element > 83) { - unstabilityEXP -= 1.8f; - } - if (element > 83 && element < 93 && isotope % 2 == 0 && izoDiff == 3) { - unstabilityEXP += 6; - } - if (element > 93 && element < 103 && isotope % 2 == 0 && izoDiff == 4) { - unstabilityEXP += 6; - } - rawLifeTime = (containsAnti ? 1e-8f : 1f) * (float) Math.pow(10F, unstabilityEXP) * (1f + xstr.nextFloat() * 9f); - } - - if (rawLifeTime < 8e-15) { - return 1e-35f; - } - if (rawLifeTime > 8e28) { - return 8e30f; - } - return rawLifeTime; - } - - private static boolean canTheyBeTogether(cElementalDefinitionStackMap stacks) { - boolean nuclei = false; - long qty=0; - for (cElementalDefinitionStack stack : stacks.values()) { - if (stack.definition instanceof dHadronDefinition) { - if (((dHadronDefinition) stack.definition).amount != 3) { - return false; - } - nuclei = true; - } else if (!(stack.definition instanceof eLeptonDefinition)) { - return false; - } - qty+=stack.amount; - } - return nuclei && qty=iaea.energeticStatesArray.length){ - return iaea.energeticStatesArray[iaea.energeticStatesArray.length-1].Thalf/(currentEnergy-iaea.energeticStatesArray.length+1); - } - return iaea.energeticStatesArray[(int)currentEnergy].Thalf; - } - return rawLifeTime/(currentEnergy+1); - } - - @Override - public boolean isTimeSpanHalfLife() { - return true; - } - - @Override - public byte getColor() { - return -10; - } - - @Override - public String getName() { - int element = Math.abs(this.element); - boolean negative = element < 0; - try { - if (type != 1) { - return (negative ? "~? " : "? ") + nomenclature.Name[element]; - } - return negative ? '~' + nomenclature.Name[-element] : nomenclature.Name[element]; - } catch (Exception e) { - if (DEBUG_MODE) { - e.printStackTrace(); - } - return (negative ? "Element: ~" : "Element: ") + element; - } - } - - @Override - public String getSymbol() { - int element = Math.abs(this.element); - boolean negative = element < 0; - try { - return (negative ? "~" : "") + nomenclature.Symbol[element] + " N:" + neutralCount + " I:" + (neutralCount+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.SymbolIUPAC[10 + s100] + nomenclature.SymbolIUPAC[s10] + nomenclature.SymbolIUPAC[s1] + " N:" + neutralCount + " I:" + (neutralCount+element) + " C:" + getCharge(); - } catch (Exception E) { - if (DEBUG_MODE) { - e.printStackTrace(); - } - return (negative ? "~" : "") + "? N:" + neutralCount + " I:" + (neutralCount+element) + " C:" + getCharge(); - } - } - } - - @Override - public cElementalDefinitionStackMap getSubParticles() { - return elementalStacks.clone(); - } - - @Override - public cElementalDecay[] getDecayArray() { - ArrayList decaysList=new ArrayList<>(4); - return getDecayArray(decaysList,decayMode,true); - } - - private cElementalDecay[] getDecayArray(ArrayList decaysList,int decayMode,boolean tryAnti) { - if (type == 1) { - switch (decayMode) { - case -2: - if(TecTech.RANDOM.nextBoolean() && ElectronCapture(decaysList)) { - return decaysList.toArray(new cElementalDecay[0]); - } else if(PbetaDecay(decaysList)) { - return decaysList.toArray(new cElementalDecay[0]); - } - break; - case -1: - if(Emmision(decaysList, dHadronDefinition.hadron_p1)) { - return decaysList.toArray(new cElementalDecay[0]); - } - break; - case 0: - if(alphaDecay(decaysList)) { - return decaysList.toArray(new cElementalDecay[0]); - } - break; - case 1: - if(Emmision(decaysList, dHadronDefinition.hadron_n1)) { - return decaysList.toArray(new cElementalDecay[0]); - } - break; - case 2: - if(MbetaDecay(decaysList)) { - return decaysList.toArray(new cElementalDecay[0]); - } - break; - default: - if(decayMode>8){ - if(iaeaDecay(decaysList,0)) { - return decaysList.toArray(new cElementalDecay[0]); - } - return getDecayArray(decaysList,decayMode- BYTE_OFFSET,false); - } - } - return cElementalDecay.noDecay; - }else if(type ==-1){ - dAtomDefinition anti=getAnti(); - if(anti!=null) { - return anti.getDecayArray(decaysList, decayMode, false); - } - } - return getNaturalDecayInstant(); - } - - private boolean iaeaDecay(ArrayList decaysList,long energy){ - iaeaNuclide.energeticState state; - if(energy>iaea.energeticStatesArray.length) { - state = iaea.energeticStatesArray[iaea.energeticStatesArray.length - 1]; - } else if(energy<=0) { - state = iaea.energeticStatesArray[0]; - } else { - state = iaea.energeticStatesArray[(int) energy]; - } - for (int i=0;i decaysList, iaeaNuclide.iaeaDecay decay, long energy){ - cElementalMutableDefinitionStackMap withThis=elementalStacks.toMutable(),newStuff=new cElementalMutableDefinitionStackMap(); - switch (decay.decayName){ - case "D": { - if (withThis.removeAllAmounts(false, deuterium.definition.getSubParticles())){ - withThis.putReplace(deuterium); - decaysList.add(new cElementalDecay(decay.chance,withThis.toImmutable_optimized_unsafeLeavesExposedElementalTree())); - return true; - } - } break; - case "3H": { - if (withThis.removeAllAmounts(false, tritium.definition.getSubParticles())){ - withThis.putReplace(tritium); - decaysList.add(new cElementalDecay(decay.chance,withThis.toImmutable_optimized_unsafeLeavesExposedElementalTree())); - return true; - } - } break; - case "3HE": { - if (withThis.removeAllAmounts(false, helium_3.definition.getSubParticles())){ - withThis.putReplace(helium_3); - decaysList.add(new cElementalDecay(decay.chance,withThis.toImmutable_optimized_unsafeLeavesExposedElementalTree())); - return true; - } - } break; - case "8BE": { - if (withThis.removeAllAmounts(false, beryllium_8.definition.getSubParticles())){ - withThis.putReplace(beryllium_8); - decaysList.add(new cElementalDecay(decay.chance,withThis.toImmutable_optimized_unsafeLeavesExposedElementalTree())); - return true; - } - } break; - case "14C": { - if (withThis.removeAllAmounts(false, carbon_14.definition.getSubParticles())){ - newStuff.putReplace(carbon_14); - try{ - newStuff.putReplace(new dAtomDefinition(withThis.toImmutable_optimized_unsafeLeavesExposedElementalTree()).getStackForm(1)); - decaysList.add(new cElementalDecay(decay.chance,newStuff.toImmutable_optimized_unsafeLeavesExposedElementalTree())); - return true; - }catch (Exception e){ - if(DEBUG_MODE) { - e.printStackTrace(); - } - } - } - } break; - case "24NE": { - if (withThis.removeAllAmounts(false, neon_24.definition.getSubParticles())){ - newStuff.putReplace(neon_24); - try{ - newStuff.putReplace(new dAtomDefinition(withThis.toImmutable_optimized_unsafeLeavesExposedElementalTree()).getStackForm(1)); - decaysList.add(new cElementalDecay(decay.chance,newStuff.toImmutable_optimized_unsafeLeavesExposedElementalTree())); - return true; - }catch (Exception e){ - if(DEBUG_MODE) { - e.printStackTrace(); - } - } - } - } break; - case "34SI": { - if (withThis.removeAllAmounts(false, silicon_34.definition.getSubParticles())){ - newStuff.putReplace(silicon_34); - try{ - newStuff.putReplace(new dAtomDefinition(withThis.toImmutable_optimized_unsafeLeavesExposedElementalTree()).getStackForm(1)); - decaysList.add(new cElementalDecay(decay.chance,newStuff.toImmutable_optimized_unsafeLeavesExposedElementalTree())); - return true; - }catch (Exception e){ - if(DEBUG_MODE) { - e.printStackTrace(); - } - } - } - } break; - case "A": case "A?": { - if (withThis.removeAllAmounts(false, dHadronDefinition.hadron_n2,dHadronDefinition.hadron_p2)){ - newStuff.putReplace(alpha); - try{ - newStuff.putReplace(new dAtomDefinition(withThis.toImmutable_optimized_unsafeLeavesExposedElementalTree()).getStackForm(1)); - decaysList.add(new cElementalDecay(decay.chance,newStuff.toImmutable_optimized_unsafeLeavesExposedElementalTree())); - return true; - }catch (Exception e){ - if(DEBUG_MODE) { - e.printStackTrace(); - } - } - } - } break; - case "B+": { - if (withThis.removeAllAmounts(false, dHadronDefinition.hadron_p1)){ - withThis.putUnify(dHadronDefinition.hadron_n1); - newStuff.putReplace(eLeptonDefinition.lepton_e_1); - newStuff.putReplace(eNeutrinoDefinition.lepton_Ve1); - try{ - newStuff.putReplace(new dAtomDefinition(withThis.toImmutable_optimized_unsafeLeavesExposedElementalTree()).getStackForm(1)); - decaysList.add(new cElementalDecay(decay.chance,newStuff.toImmutable_optimized_unsafeLeavesExposedElementalTree())); - return true; - }catch (Exception e){ - if(DEBUG_MODE) { - e.printStackTrace(); - } - } - } - } break; - case "2B+": { - if (withThis.removeAllAmounts(false, dHadronDefinition.hadron_p2)){ - withThis.putUnify(dHadronDefinition.hadron_n2); - newStuff.putReplace(eLeptonDefinition.lepton_e_2); - newStuff.putReplace(eNeutrinoDefinition.lepton_Ve2); - try{ - newStuff.putReplace(new dAtomDefinition(withThis.toImmutable_optimized_unsafeLeavesExposedElementalTree()).getStackForm(1)); - decaysList.add(new cElementalDecay(decay.chance,newStuff.toImmutable_optimized_unsafeLeavesExposedElementalTree())); - return true; - }catch (Exception e){ - if(DEBUG_MODE) { - e.printStackTrace(); - } - } - } - } break; - case "B-": { - if (withThis.removeAllAmounts(false, dHadronDefinition.hadron_n1)){ - withThis.putUnify(dHadronDefinition.hadron_p1); - newStuff.putReplace(eLeptonDefinition.lepton_e1); - newStuff.putReplace(eNeutrinoDefinition.lepton_Ve_1); - try{ - newStuff.putReplace(new dAtomDefinition(withThis.toImmutable_optimized_unsafeLeavesExposedElementalTree()).getStackForm(1)); - decaysList.add(new cElementalDecay(decay.chance,newStuff.toImmutable_optimized_unsafeLeavesExposedElementalTree())); - return true; - }catch (Exception e){ - if(DEBUG_MODE) { - e.printStackTrace(); - } - } - } - } break; - case "2B-": { - if (withThis.removeAllAmounts(false, dHadronDefinition.hadron_n2)){ - withThis.putUnify(dHadronDefinition.hadron_p2); - newStuff.putReplace(eLeptonDefinition.lepton_e2); - newStuff.putReplace(eNeutrinoDefinition.lepton_Ve_2); - try{ - newStuff.putReplace(new dAtomDefinition(withThis.toImmutable_optimized_unsafeLeavesExposedElementalTree()).getStackForm(1)); - decaysList.add(new cElementalDecay(decay.chance,newStuff.toImmutable_optimized_unsafe