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/com') 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_unsafeLeavesExposedElementalTree())); - return true; - }catch (Exception e){ - if(DEBUG_MODE) { - e.printStackTrace(); - } - } - } - } break; - case "EC": { - if (withThis.removeAllAmounts(false, dHadronDefinition.hadron_p1,eLeptonDefinition.lepton_e1)){ - withThis.putUnify(dHadronDefinition.hadron_n1); - 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 "2EC": { - if (withThis.removeAllAmounts(false, dHadronDefinition.hadron_p2,eLeptonDefinition.lepton_e2)){ - withThis.putUnify(dHadronDefinition.hadron_n2); - 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++EC": case "EC+B+": { - if (withThis.removeAllAmounts(false, dHadronDefinition.hadron_p2,eLeptonDefinition.lepton_e1)){ - withThis.putUnify(dHadronDefinition.hadron_n2); - newStuff.putReplace(eLeptonDefinition.lepton_e_1); - 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+A": { - if (withThis.removeAllAmounts(false, dHadronDefinition.hadron_p3, dHadronDefinition.hadron_n1)){ - newStuff.putReplace(eLeptonDefinition.lepton_e_1); - newStuff.putReplace(eNeutrinoDefinition.lepton_Ve1); - 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+P": { - if (withThis.removeAllAmounts(false, dHadronDefinition.hadron_p2)){ - withThis.putUnify(dHadronDefinition.hadron_n1); - newStuff.putReplace(eLeptonDefinition.lepton_e_1); - newStuff.putReplace(eNeutrinoDefinition.lepton_Ve1); - newStuff.putReplace(dHadronDefinition.hadron_p1); - 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+2P": { - if (withThis.removeAllAmounts(false, dHadronDefinition.hadron_p3)){ - withThis.putUnify(dHadronDefinition.hadron_n1); - newStuff.putReplace(eLeptonDefinition.lepton_e_1); - newStuff.putReplace(eNeutrinoDefinition.lepton_Ve1); - newStuff.putReplace(dHadronDefinition.hadron_p2); - 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-A": { - if (withThis.removeAllAmounts(false, dHadronDefinition.hadron_n3, dHadronDefinition.hadron_p1)){ - newStuff.putReplace(eLeptonDefinition.lepton_e1); - newStuff.putReplace(eNeutrinoDefinition.lepton_Ve_1); - 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-N": { - if (withThis.removeAllAmounts(false, dHadronDefinition.hadron_n2)){ - withThis.putUnify(dHadronDefinition.hadron_p1); - newStuff.putReplace(eLeptonDefinition.lepton_e1); - newStuff.putReplace(eNeutrinoDefinition.lepton_Ve_1); - newStuff.putReplace(dHadronDefinition.hadron_n1); - 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-2N": { - if (withThis.removeAllAmounts(false, dHadronDefinition.hadron_n3)){ - withThis.putUnify(dHadronDefinition.hadron_p1); - newStuff.putReplace(eLeptonDefinition.lepton_e1); - newStuff.putReplace(eNeutrinoDefinition.lepton_Ve_1); - newStuff.putReplace(dHadronDefinition.hadron_n2); - 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-P": { - if (withThis.removeAllAmounts(false, dHadronDefinition.hadron_n1)){ - newStuff.putReplace(eLeptonDefinition.lepton_e1); - newStuff.putReplace(eNeutrinoDefinition.lepton_Ve_1); - newStuff.putReplace(dHadronDefinition.hadron_p1); - 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 "ECA": { - if (withThis.removeAllAmounts(false, dHadronDefinition.hadron_n1,eLeptonDefinition.lepton_e1,dHadronDefinition.hadron_p3)){ - newStuff.putReplace(eNeutrinoDefinition.lepton_Ve1); - 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 "ECP": { - if (withThis.removeAllAmounts(false, eLeptonDefinition.lepton_e1,dHadronDefinition.hadron_p2)){ - withThis.putUnify(dHadronDefinition.hadron_n1); - newStuff.putReplace(eNeutrinoDefinition.lepton_Ve1); - newStuff.putReplace(dHadronDefinition.hadron_p1); - 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 "EC2P": { - if (withThis.removeAllAmounts(false, eLeptonDefinition.lepton_e1,dHadronDefinition.hadron_p3)){ - withThis.putUnify(dHadronDefinition.hadron_n1); - newStuff.putReplace(eNeutrinoDefinition.lepton_Ve1); - newStuff.putReplace(dHadronDefinition.hadron_p2); - 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 "ECP+EC2P": {//todo look at branching ratios - if (withThis.removeAllAmounts(false, eLeptonDefinition.lepton_e2,dHadronDefinition.hadron_p5)){ - withThis.putUnify(dHadronDefinition.hadron_n1); - newStuff.putReplace(eNeutrinoDefinition.lepton_Ve2); - newStuff.putReplace(dHadronDefinition.hadron_p3); - 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 "N": { - if (withThis.removeAllAmounts(false, dHadronDefinition.hadron_n1)){ - newStuff.putReplace(dHadronDefinition.hadron_n1); - 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 "2N": { - if (withThis.removeAllAmounts(false, dHadronDefinition.hadron_n2)){ - newStuff.putReplace(dHadronDefinition.hadron_n2); - 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 "P": { - if (withThis.removeAllAmounts(false, dHadronDefinition.hadron_p1)){ - newStuff.putReplace(dHadronDefinition.hadron_p1); - 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 "2P": { - if (withThis.removeAllAmounts(false, dHadronDefinition.hadron_p2)){ - newStuff.putReplace(dHadronDefinition.hadron_p2); - 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 "SF": { - if (Fission(decaysList, withThis, newStuff, decay.chance, false)) { - return true; - } - } break; - case "B-F": { - if (withThis.removeAllAmounts(false, dHadronDefinition.hadron_n1)){ - withThis.putUnify(dHadronDefinition.hadron_p1); - newStuff.putReplace(eLeptonDefinition.lepton_e1); - newStuff.putReplace(eNeutrinoDefinition.lepton_Ve_1); - try{ - if(Fission(decaysList,withThis,newStuff,decay.chance,false)) { - return true; - } - }catch (Exception e){ - if(DEBUG_MODE) { - e.printStackTrace(); - } - } - } - } break; - case "ECF": case "ECSF": case "EC(+SF)": { - if (withThis.removeAllAmounts(false, dHadronDefinition.hadron_p1,eLeptonDefinition.lepton_e1)){ - withThis.putUnify(dHadronDefinition.hadron_n1); - newStuff.putReplace(eNeutrinoDefinition.lepton_Ve1); - try{ - if(Fission(decaysList,withThis,newStuff,decay.chance,false)) { - return true; - } - }catch (Exception e){ - if(DEBUG_MODE) { - e.printStackTrace(); - } - } - } - } break; - case "SF(+EC+B+)": case "SF+EC+B+": { - if (withThis.removeAllAmounts(false, dHadronDefinition.hadron_p2,eLeptonDefinition.lepton_e1)){ - withThis.putUnify(dHadronDefinition.hadron_n2); - newStuff.putReplace(eLeptonDefinition.lepton_e_1); - newStuff.putReplace(eNeutrinoDefinition.lepton_Ve2); - try{ - if(Fission(decaysList,withThis,newStuff,decay.chance,false)) { - return true; - } - }catch (Exception e){ - if(DEBUG_MODE) { - e.printStackTrace(); - } - } - } - } break; - case "SF+EC+B-": { - if (withThis.removeAllAmounts(false, eLeptonDefinition.lepton_e1)){ - newStuff.putReplace(eLeptonDefinition.lepton_e1); - newStuff.putReplace(eNeutrinoDefinition.lepton_Ve1); - newStuff.putReplace(eNeutrinoDefinition.lepton_Ve_1); - try{ - if(Fission(decaysList,withThis,newStuff,decay.chance,false)) { - return true; - } - }catch (Exception e){ - if(DEBUG_MODE) { - e.printStackTrace(); - } - } - } - } break; - case "IT": case "IT?": case "G": { - if(energy>0){ - decaysList.add(new cElementalDecay(decay.chance, this, boson_Y__)); - return true; - }else{ - if(DEBUG_MODE) { - TecTech.LOGGER.info("Tried to emit Gamma from ground state"); - } - decaysList.add(new cElementalDecay(decay.chance, this)); - return true; - } - } //break; - case "IT+EC+B+": { - if (withThis.removeAllAmounts(false, dHadronDefinition.hadron_p2,eLeptonDefinition.lepton_e1)){ - withThis.putUnify(dHadronDefinition.hadron_n2); - newStuff.putReplace(eLeptonDefinition.lepton_e_1); - newStuff.putReplace(eNeutrinoDefinition.lepton_Ve2); - newStuff.putReplace(eBosonDefinition.boson_Y__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 "DEAD_END": - decaysList.add(deadEnd); - return true; - default: throw new Error("Unsupported decay mode: " + decay.decayName + ' ' + neutralCount+ ' ' +element); - } - if(DEBUG_MODE) { - TecTech.LOGGER.info("Failed to decay " + element + ' ' + neutralCount + ' ' + decay.decayName); - } - return false; - } - - private boolean Emmision(ArrayList decaysList, cElementalDefinitionStack emit) { - cElementalMutableDefinitionStackMap tree = elementalStacks.toMutable(); - if (tree.removeAmount(false, emit)) { - try { - decaysList.add(new cElementalDecay((float) 1, new cElementalDefinitionStack(new dAtomDefinition(tree.toImmutable_optimized_unsafeLeavesExposedElementalTree()), 1), emit)); - return true; - } catch (Exception e) { - if (DEBUG_MODE) { - e.printStackTrace(); - } - } - } - return false; - } - - private boolean alphaDecay(ArrayList decaysList) { - cElementalMutableDefinitionStackMap tree = elementalStacks.toMutable(); - if (tree.removeAllAmounts(false, alpha.definition.getSubParticles())) { - try { - decaysList.add(new cElementalDecay((float) 1, new cElementalDefinitionStack(new dAtomDefinition(tree.toImmutable_optimized_unsafeLeavesExposedElementalTree()), 1), alpha)); - return true; - } catch (Exception e) { - if (DEBUG_MODE) { - e.printStackTrace(); - } - } - } - return false; - } - - private boolean MbetaDecay(ArrayList decaysList) { - cElementalMutableDefinitionStackMap tree = elementalStacks.toMutable(); - if (tree.removeAmount(false, dHadronDefinition.hadron_n1)) { - try { - tree.putUnify(dHadronDefinition.hadron_p1); - decaysList.add(new cElementalDecay((float) 1, new cElementalDefinitionStack(new dAtomDefinition(tree.toImmutable_optimized_unsafeLeavesExposedElementalTree()), 1), eLeptonDefinition.lepton_e1, eNeutrinoDefinition.lepton_Ve_1)); - return true; - } catch (Exception e) { - if (DEBUG_MODE) { - e.printStackTrace(); - } - } - } - return false; - } - - private boolean PbetaDecay(ArrayList decaysList) { - cElementalMutableDefinitionStackMap tree = elementalStacks.toMutable(); - if (tree.removeAmount(false, dHadronDefinition.hadron_p1)) { - try { - tree.putUnify(dHadronDefinition.hadron_n1); - decaysList.add(new cElementalDecay((float) 1, new cElementalDefinitionStack(new dAtomDefinition(tree.toImmutable_optimized_unsafeLeavesExposedElementalTree()), 1), eLeptonDefinition.lepton_e_1, eNeutrinoDefinition.lepton_Ve1)); - return true; - } catch (Exception e) { - if (DEBUG_MODE) { - e.printStackTrace(); - } - } - } - return false; - } - - private boolean ElectronCapture(ArrayList decaysList) { - cElementalMutableDefinitionStackMap tree = elementalStacks.toMutable(); - if (tree.removeAllAmounts(false, dHadronDefinition.hadron_p1,eLeptonDefinition.lepton_e1)) { - try { - tree.putUnify(dHadronDefinition.hadron_n1); - decaysList.add(new cElementalDecay((float) 1, new cElementalDefinitionStack(new dAtomDefinition(tree.toImmutable_optimized_unsafeLeavesExposedElementalTree()), 1), eNeutrinoDefinition.lepton_Ve1)); - return true; - } catch (Exception e) { - if (DEBUG_MODE) { - e.printStackTrace(); - } - } - } - return false; - } - - private boolean Fission(ArrayList decaysList, cElementalMutableDefinitionStackMap fissile, cElementalMutableDefinitionStackMap particles,float probability,boolean spontaneousCheck) { - cElementalMutableDefinitionStackMap heavy = new cElementalMutableDefinitionStackMap(); - double[] liquidDrop= liquidDropFunction(Math.abs(element)<=97); - - for(cElementalDefinitionStack stack: fissile.values()){ - if(spontaneousCheck && stack.definition instanceof dHadronDefinition && - (stack.amount<=80 || stack.amount<90 && XSTR_INSTANCE.nextInt(10)XSTR_INSTANCE.nextDouble()?1:0; - particles.putUnify(new cElementalDefinitionStack(stack.definition, neutrals_cnt)); - - int heavy_cnt=(int)Math.ceil(stack.amount*liquidDrop[1]); - while(heavy_cnt+neutrals_cnt>stack.amount) { - heavy_cnt--; - } - fissile.removeAmount(false,new cElementalDefinitionStack(stack.definition,heavy_cnt+neutrals_cnt)); - heavy.putReplace(new cElementalDefinitionStack(stack.definition, heavy_cnt)); - //}else{ - // particles.add(stack); - // light.remove(stack.definition); - //} - }else{ - int heavy_cnt=(int)Math.ceil(stack.amount*liquidDrop[0]); - if(heavy_cnt%2==1 && XSTR_INSTANCE.nextFloat()>0.05f) { - heavy_cnt--; - } - cElementalDefinitionStack new_stack=new cElementalDefinitionStack(stack.definition, heavy_cnt); - fissile.removeAmount(false,new_stack); - heavy.putReplace(new_stack); - } - } - - try { - particles.putReplace(new cElementalDefinitionStack(new dAtomDefinition(fissile.toImmutable_optimized_unsafeLeavesExposedElementalTree()),1)); - particles.putReplace(new cElementalDefinitionStack(new dAtomDefinition(heavy.toImmutable_optimized_unsafeLeavesExposedElementalTree()),1)); - decaysList.add(new cElementalDecay(probability, particles.toImmutable_optimized_unsafeLeavesExposedElementalTree())); - return true; - } catch (Exception e) { - if(DEBUG_MODE) { - e.printStackTrace(); - } - } - return false; - } - - private static double[] liquidDropFunction(boolean asymmetric) { - double[] out = new double[3]; - - out[0] = XSTR_INSTANCE.nextGaussian(); - - if (out[0] < 1 && out[0] >= -1) { - if (XSTR_INSTANCE.nextBoolean()) { - out[0] = XSTR_INSTANCE.nextDouble() * 2d - 1d; - } - } - - if (asymmetric && out[0] > XSTR_INSTANCE.nextDouble() && XSTR_INSTANCE.nextInt(4) == 0) { - out[0] = -out[0]; - } - - //scale to splitting ratio - out[0] = out[0] * 0.05d + .6d; - - if (out[0] < 0 || out[0] > 1) { - return liquidDropFunction(asymmetric); - } - if (out[0] < .5d) { - out[0] = 1d - out[0]; - } - - //extra neutrals - out[2] = 0.012d + XSTR_INSTANCE.nextDouble() * 0.01d; - - if (asymmetric) { - out[1] = out[0]; - } else { - out[1] = out[0] - out[2] * .5d; - } - - return out; - } - - @Override - public cElementalDecay[] getEnergyInducedDecay(long energyLevel) { - if (iaeaDefinitionExistsAndHasEnergyLevels) { - ArrayList decays=new ArrayList<>(4); - if(iaeaDecay(decays,energyLevel)){ - return decays.toArray(new cElementalDecay[0]); - } - } - if(energyLevel< Math.abs(charge)/3+neutralCount) { - return new cElementalDecay[]{new cElementalDecay(1, this, boson_Y__)}; - } - return getNaturalDecayInstant(); - } - - @Override - public float getEnergyDiffBetweenStates(long currentEnergyLevel,long newEnergyLevel) { - if(iaeaDefinitionExistsAndHasEnergyLevels){ - float result=0; - boolean backwards=newEnergyLevel=iaea.energeticStatesArray.length){ - if(currentEnergyLevel>=iaea.energeticStatesArray.length) { - return iElementalDefinition.DEFAULT_ENERGY_REQUIREMENT * (newEnergyLevel - currentEnergyLevel); - } else { - result += iElementalDefinition.DEFAULT_ENERGY_REQUIREMENT * (newEnergyLevel - iaea.energeticStatesArray.length + 1); - } - result+=iaea.energeticStatesArray[iaea.energeticStatesArray.length-1].energy; - }else { - result += iaea.energeticStatesArray[(int) Math.max(0, newEnergyLevel)].energy; - } - - return backwards?-result:result; - } - return iElementalDefinition.DEFAULT_ENERGY_REQUIREMENT *(newEnergyLevel-currentEnergyLevel); - } - - @Override - public boolean usesSpecialEnergeticDecayHandling() { - return iaeaDefinitionExistsAndHasEnergyLevels; - } - - @Override - public boolean usesMultipleDecayCalls(long energyLevel) { - if(!iaeaDefinitionExistsAndHasEnergyLevels) return false; - iaeaNuclide.energeticState state; - if(energyLevel>iaea.energeticStatesArray.length) { - state = iaea.energeticStatesArray[iaea.energeticStatesArray.length - 1]; - } else if(energyLevel<=0) { - state = iaea.energeticStatesArray[0]; - } else { - state = iaea.energeticStatesArray[(int) energyLevel]; - } - for (iaeaNuclide.iaeaDecay decay:state.decaymodes){ - if(decay.decayName.contains("F")) return true;//if is fissile - } - return false; - } - - @Override - public boolean decayMakesEnergy(long energyLevel) { - return iaeaDefinitionExistsAndHasEnergyLevels; - } - - @Override - public boolean fusionMakesEnergy(long energyLevel) { - return iaea!=null || iaeaDefinitionExistsAndHasEnergyLevels; - } - - @Override - public cElementalDecay[] getNaturalDecayInstant() { - //disembody - ArrayList decaysInto = new ArrayList<>(); - for (cElementalDefinitionStack elementalStack : elementalStacks.values()) { - if (elementalStack.definition.getType() == 1 || elementalStack.definition.getType() == -1) { - //covers both quarks and antiquarks - decaysInto.add(elementalStack); - } else { - //covers both quarks and antiquarks - decaysInto.add(new cElementalDefinitionStack(boson_Y__, 2)); - } - } - return new cElementalDecay[]{new cElementalDecay(0.75F, decaysInto.toArray(new cElementalDefinitionStack[0])), deadEnd}; - } - - //@Override - //public iElementalDefinition getAnti() { - // cElementalDefinitionStack[] stacks = this.elementalStacks.values(); - // cElementalDefinitionStack[] antiElements = new cElementalDefinitionStack[stacks.length]; - // for (int i = 0; i < antiElements.length; i++) { - // antiElements[i] = new cElementalDefinitionStack(stacks[i].definition.getAnti(), stacks[i].amount); - // } - // try { - // return new dAtomDefinition(false, antiElements); - // } catch (tElementalException e) { - // if (DEBUG_MODE) e.printStackTrace(); - // return null; - // } - //} - - @Override - public dAtomDefinition getAnti() { - cElementalMutableDefinitionStackMap anti = new cElementalMutableDefinitionStackMap(); - for (cElementalDefinitionStack stack : elementalStacks.values()) { - anti.putReplace(new cElementalDefinitionStack(stack.definition.getAnti(), stack.amount)); - } - try { - return new dAtomDefinition(anti.toImmutable_optimized_unsafeLeavesExposedElementalTree()); - } catch (tElementalException e) { - if (DEBUG_MODE) { - e.printStackTrace(); - } - return null; - } - } - - @Override - public aFluidDequantizationInfo someAmountIntoFluidStack() { - return transformation.fluidDequantization.get(this); - } - - @Override - public aItemDequantizationInfo someAmountIntoItemsStack() { - return null; - } - - @Override - public aOredictDequantizationInfo someAmountIntoOredictStack() { - return transformation.oredictDequantization.get(this); - } - - 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[] SymbolIUPAC = new String[]{"n", "u", "b", "t", "q", "p", "h", "s", "o", "e", "N", "U", "B", "T", "Q", "P", "H", "S", "O", "E"}; - } - - @Override - public NBTTagCompound toNBT() { - return getNbtTagCompound(nbtType, elementalStacks); - } - - public static dAtomDefinition fromNBT(NBTTagCompound nbt) { - cElementalDefinitionStack[] stacks = new cElementalDefinitionStack[nbt.getInteger("i")]; - for (int i = 0; i < stacks.length; i++) { - stacks[i] = cElementalDefinitionStack.fromNBT(nbt.getCompoundTag(Integer.toString(i))); - } - try { - return new dAtomDefinition(stacks); - } catch (tElementalException e) { - if (DEBUG_MODE) { - e.printStackTrace(); - } - return null; - } - } - - public static void run() { - for (Runnable r : overrides) { - r.run(); - } - - for(Map.Entry entry:lifetimeOverrides.entrySet()){ - try { - lifetimeOverrides.put(new dAtomDefinition(entry.getKey().elementalStacks), entry.getValue()); - }catch (tElementalException e){ - e.printStackTrace(); //Impossible - } - } - - //populate stable isotopes - for (int element = 1; element < 83; element++)//Up to Bismuth exclusive - { - for (int isotope = 0; isotope < 130; isotope++) { - xstr.setSeed((long) (element + 1) * (isotope + 100)); - //stability curve - int StableIsotope = stableIzoCurve(element); - int izoDiff = isotope - StableIsotope; - int izoDiffAbs = Math.abs(izoDiff); - float rawLifeTime = calculateLifeTime(izoDiff, izoDiffAbs, element, isotope, false); - iaeaNuclide nuclide = iaeaNuclide.get(element, isotope); - if (rawLifeTime >= STABLE_RAW_LIFE_TIME || nuclide != null && nuclide.halfTime >= STABLE_RAW_LIFE_TIME) { - TreeSet isotopes = stableIsotopes.computeIfAbsent(element, k -> new TreeSet<>()); - isotopes.add(isotope); - } - } - } - - //populate unstable isotopes - for (int element = 83; element < 150; element++) { - for (int isotope = 100; isotope < 180; isotope++) { - xstr.setSeed((long) (element + 1) * (isotope + 100)); - //stability curve - int Isotope = stableIzoCurve(element); - int izoDiff = isotope - Isotope; - int izoDiffAbs = Math.abs(izoDiff); - float rawLifeTime = calculateLifeTime(izoDiff, izoDiffAbs, element, isotope, false); - TreeMap isotopes = mostStableUnstableIsotopes.computeIfAbsent(element, k -> new TreeMap<>()); - isotopes.put(rawLifeTime, isotope); - } - } - - try { - for (Map.Entry> integerTreeSetEntry : stableIsotopes.entrySet()) { - stableAtoms.put(integerTreeSetEntry.getKey(), new dAtomDefinition( - new cElementalDefinitionStack(dHadronDefinition.hadron_p, integerTreeSetEntry.getKey()), - new cElementalDefinitionStack(dHadronDefinition.hadron_n, integerTreeSetEntry.getValue().first()), - new cElementalDefinitionStack(eLeptonDefinition.lepton_e, integerTreeSetEntry.getKey()))); - if (DEBUG_MODE) { - TecTech.LOGGER.info("Added Stable Atom:" + integerTreeSetEntry.getKey() + ' ' + integerTreeSetEntry.getValue().first() + ' ' + stableAtoms.get(integerTreeSetEntry.getKey()).getMass()); - } - } - for (Map.Entry> integerTreeMapEntry : mostStableUnstableIsotopes.entrySet()) { - unstableAtoms.put(integerTreeMapEntry.getKey(), new dAtomDefinition( - new cElementalDefinitionStack(dHadronDefinition.hadron_p, integerTreeMapEntry.getKey()), - new cElementalDefinitionStack(dHadronDefinition.hadron_n, integerTreeMapEntry.getValue().lastEntry().getValue()), - new cElementalDefinitionStack(eLeptonDefinition.lepton_e, integerTreeMapEntry.getKey()))); - if (DEBUG_MODE) { - TecTech.LOGGER.info("Added Unstable Atom:" + integerTreeMapEntry.getKey() + ' ' + integerTreeMapEntry.getValue().lastEntry().getValue() + ' ' + unstableAtoms.get(integerTreeMapEntry.getKey()).getMass()); - } - } - deuterium=new dAtomDefinition( - dHadronDefinition.hadron_p1, - dHadronDefinition.hadron_n1, - eLeptonDefinition.lepton_e1).getStackForm(1); - tritium=new dAtomDefinition( - dHadronDefinition.hadron_p1, - dHadronDefinition.hadron_n2, - eLeptonDefinition.lepton_e1).getStackForm(1); - helium_3=new dAtomDefinition( - dHadronDefinition.hadron_p2, - dHadronDefinition.hadron_n1, - eLeptonDefinition.lepton_e2).getStackForm(1); - alpha = new dAtomDefinition( - dHadronDefinition.hadron_p2, - dHadronDefinition.hadron_n2).getStackForm(1); - beryllium_8=new dAtomDefinition( - new cElementalDefinitionStack(dHadronDefinition.hadron_p, 4), - new cElementalDefinitionStack(dHadronDefinition.hadron_n, 4), - new cElementalDefinitionStack(eLeptonDefinition.lepton_e, 4)).getStackForm(1); - carbon_14=new dAtomDefinition( - new cElementalDefinitionStack(dHadronDefinition.hadron_p, 6), - new cElementalDefinitionStack(dHadronDefinition.hadron_n, 8), - new cElementalDefinitionStack(eLeptonDefinition.lepton_e, 6)).getStackForm(1); - neon_24=new dAtomDefinition( - new cElementalDefinitionStack(dHadronDefinition.hadron_p, 10), - new cElementalDefinitionStack(dHadronDefinition.hadron_n, 14), - new cElementalDefinitionStack(eLeptonDefinition.lepton_e, 10)).getStackForm(1); - silicon_34=new dAtomDefinition( - new cElementalDefinitionStack(dHadronDefinition.hadron_p, 14), - new cElementalDefinitionStack(dHadronDefinition.hadron_n, 20), - new cElementalDefinitionStack(eLeptonDefinition.lepton_e, 14)).getStackForm(1); - } catch (Exception e) { - if (DEBUG_MODE) { - e.printStackTrace(); - } - } - - try { - cElementalDefinition.addCreatorFromNBT(nbtType, dAtomDefinition.class.getMethod("fromNBT", NBTTagCompound.class),(byte)64); - } catch (Exception e) { - if (DEBUG_MODE) { - e.printStackTrace(); - } - } - if(DEBUG_MODE) { - TecTech.LOGGER.info("Registered Elemental Matter Class: Atom " + nbtType + ' ' + 64); - } - } - - public static void setTransformation(){ - /*----STABLE ATOMS----**/ - refMass = getFirstStableIsotope(1).getMass() * 144F; - - transformation.addFluid(new cElementalDefinitionStack(getFirstStableIsotope(1), 144),Materials.Hydrogen.mGas.getID(),144); - transformation.addFluid(new cElementalDefinitionStack(getFirstStableIsotope(2), 144),Materials.Helium.mGas.getID(), 144); - transformation.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(3), 144), dust, Materials.Lithium,1); - transformation.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(4), 144), dust, Materials.Beryllium,1); - transformation.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(5), 144), dust, Materials.Boron,1); - transformation.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(6), 144), dust, Materials.Carbon,1); - transformation.addFluid(new cElementalDefinitionStack(getFirstStableIsotope(7), 144),Materials.Nitrogen.mGas.getID(), 144); - transformation.addFluid(new cElementalDefinitionStack(getFirstStableIsotope(8), 144),Materials.Oxygen.mGas.getID(), 144); - transformation.addFluid(new cElementalDefinitionStack(getFirstStableIsotope(9), 144),Materials.Fluorine.mGas.getID(), 144); - //transformation.addFluid(new cElementalDefinitionStack(getFirstStableIsotope(10), 144),Materials.Neon.mGas.getID(), 144); - transformation.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(11), 144), dust, Materials.Sodium,1); - transformation.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(12), 144), dust, Materials.Magnesium,1); - transformation.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(13), 144), dust, Materials.Aluminium,1); - transformation.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(14), 144), dust, Materials.Silicon,1); - transformation.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(15), 144), dust, Materials.Phosphorus,1); - transformation.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(16), 144), dust, Materials.Sulfur,1); - transformation.addFluid(new cElementalDefinitionStack(getFirstStableIsotope(17), 144),Materials.Chlorine.mGas.getID(), 144); - transformation.addFluid(new cElementalDefinitionStack(getFirstStableIsotope(18), 144),Materials.Argon.mGas.getID(), 144); - transformation.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(19), 144), dust, Materials.Potassium,1); - transformation.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(20), 144), dust, Materials.Calcium,1); - transformation.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(21), 144), dust, Materials.Scandium,1); - transformation.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(22), 144), dust, Materials.Titanium,1); - transformation.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(23), 144), dust, Materials.Vanadium,1); - transformation.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(24), 144), dust, Materials.Chrome,1); - transformation.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(25), 144), dust, Materials.Manganese,1); - transformation.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(26), 144), dust, Materials.Iron,1); - transformation.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(27), 144), dust, Materials.Cobalt,1); - transformation.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(28), 144), dust, Materials.Nickel,1); - transformation.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(29), 144), dust, Materials.Copper,1); - transformation.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(30), 144), dust, Materials.Zinc,1); - transformation.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(31), 144), dust, Materials.Gallium,1); - //transformation.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(32), 144),OrePrefixes.dust, Materials.Germanium,1); - transformation.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(33), 144), dust, Materials.Arsenic,1); - //transformation.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(34), 144),OrePrefixes.dust, Materials.Selenium,1); - //transformation.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(35), 144),OrePrefixes.dust, Materials.Bromine,1); - //transformation.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(36), 144),OrePrefixes.dust, Materials.Krypton,1); - transformation.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(37), 144), dust, Materials.Rubidium,1); - transformation.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(38), 144), dust, Materials.Strontium,1); - transformation.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(39), 144), dust, Materials.Yttrium,1); - //transformation.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(40), 144),OrePrefixes.dust, Materials.Zirconium,1); - transformation.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(41), 144), dust, Materials.Niobium,1); - transformation.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(42), 144), dust, Materials.Molybdenum,1); - //transformation.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(43), 144),OrePrefixes.dust, Materials.Technetium,1); - //transformation.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(44), 144),OrePrefixes.dust, Materials.Ruthenium,1); - //transformation.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(45), 144),OrePrefixes.dust, Materials.Rhodium,1); - transformation.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(46), 144), dust, Materials.Palladium,1); - transformation.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(47), 144), dust, Materials.Silver,1); - transformation.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(48), 144), dust, Materials.Cadmium,1); - transformation.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(49), 144), dust, Materials.Indium,1); - transformation.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(50), 144), dust, Materials.Tin,1); - transformation.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(51), 144), dust, Materials.Antimony,1); - transformation.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(52), 144), dust, Materials.Tellurium,1); - //transformation.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(53), 144),OrePrefixes.dust, Materials.Iodine,1); - //transformation.addFluid(new cElementalDefinitionStack(getFirstStableIsotope(54), 144),Materials.Xenon.mGas.getID(), 144); - transformation.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(55), 144), dust, Materials.Caesium,1); - transformation.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(56), 144), dust, Materials.Barium,1); - transformation.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(57), 144), dust, Materials.Lanthanum,1); - transformation.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(58), 144), dust, Materials.Cerium,1); - transformation.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(59), 144), dust, Materials.Praseodymium,1); - transformation.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(60), 144), dust, Materials.Neodymium,1); - transformation.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(61), 144), dust, Materials.Promethium,1); - transformation.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(62), 144), dust, Materials.Samarium,1); - transformation.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(63), 144), dust, Materials.Europium,1); - transformation.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(64), 144), dust, Materials.Gadolinium,1); - transformation.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(65), 144), dust, Materials.Terbium,1); - transformation.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(66), 144), dust, Materials.Dysprosium,1); - transformation.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(67), 144), dust, Materials.Holmium,1); - transformation.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(68), 144), dust, Materials.Erbium,1); - transformation.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(69), 144), dust, Materials.Thulium,1); - transformation.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(70), 144), dust, Materials.Ytterbium,1); - transformation.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(71), 144), dust, Materials.Lutetium,1); - //transformation.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(72), 144),OrePrefixes.dust, Materials.Hafnum,1); - transformation.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(73), 144), dust, Materials.Tantalum,1); - transformation.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(74), 144), dust, Materials.Tungsten,1); - //transformation.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(75), 144),OrePrefixes.dust, Materials.Rhenium,1); - transformation.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(76), 144), dust, Materials.Osmium,1); - transformation.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(77), 144), dust, Materials.Iridium,1); - transformation.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(78), 144), dust, Materials.Platinum,1); - transformation.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(79), 144), dust, Materials.Gold,1); - transformation.addFluid(new cElementalDefinitionStack(getFirstStableIsotope(80), 144),Materials.Mercury.mFluid.getID(), 144); - //transformation.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(81), 144),OrePrefixes.dust, Materials.Thallium,1); - transformation.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(82), 144), dust, Materials.Lead,1); - - /*----UNSTABLE ATOMS----**/ - refUnstableMass = getFirstStableIsotope(82).getMass() * 144F; - - transformation.addOredict(new cElementalDefinitionStack(getBestUnstableIsotope(83), 144), dust, Materials.Bismuth,1); - //transformation.addOredict(new cElementalDefinitionStack(getBestUnstableIsotope(84),144),OrePrefixes.dust, Materials.Polonium,1); - //transformation.addFluid(new cElementalDefinitionStack(getBestUnstableIsotope(85),144),Materials.Astatine.mPlasma.getID(), 144); - transformation.addFluid(new cElementalDefinitionStack(getBestUnstableIsotope(86),144),Materials.Radon.mGas.getID(), 144); - //transformation.addOredict(new cElementalDefinitionStack(getBestUnstableIsotope(87),144),OrePrefixes.dust, Materials.Francium,1); - //transformation.addOredict(new cElementalDefinitionStack(getBestUnstableIsotope(88),144),OrePrefixes.dust, Materials.Radium,1); - //transformation.addOredict(new cElementalDefinitionStack(getBestUnstableIsotope(89),144),OrePrefixes.dust, Materials.Actinium,1); - transformation.addOredict(new cElementalDefinitionStack(getBestUnstableIsotope(90),144), dust, Materials.Thorium,1); - //transformation.addOredict(new cElementalDefinitionStack(getBestUnstableIsotope(91),144),OrePrefixes.dust, Materials.Protactinium,1); - ////transformation.addOredict(new cElementalDefinitionStack(getBestUnstableIsotope(92),144), dust, Materials.Uranium,1); - //transformation.addOredict(new cElementalDefinitionStack(getBestUnstableIsotope(93),144),OrePrefixes.dust, Materials.Neptunium,1); - ////transformation.addOredict(new cElementalDefinitionStack(getBestUnstableIsotope(94),144), dust, Materials.Plutonium,1); - transformation.addOredict(new cElementalDefinitionStack(getBestUnstableIsotope(95),144), dust, Materials.Americium,1); - - try { - dAtomDefinition temp; - transformation.addFluid(new cElementalDefinitionStack(deuterium.definition, 144),Materials.Deuterium.mGas.getID(), 144); - - transformation.addFluid(new cElementalDefinitionStack(tritium.definition, 144),Materials.Tritium.mGas.getID(), 144); - - transformation.addFluid(new cElementalDefinitionStack(helium_3.definition, 144),Materials.Helium_3.mGas.getID(), 144); - - temp=new dAtomDefinition( - new cElementalDefinitionStack(eLeptonDefinition.lepton_e, 92), - new cElementalDefinitionStack(dHadronDefinition.hadron_p, 92), - new cElementalDefinitionStack(dHadronDefinition.hadron_n, 146) - ); - transformation.addOredict(new cElementalDefinitionStack(temp, 144), dust, Materials.Uranium/*238*/,1); - - float tempMass=temp.getMass(); - - temp=new dAtomDefinition( - new cElementalDefinitionStack(eLeptonDefinition.lepton_e, 92), - new cElementalDefinitionStack(dHadronDefinition.hadron_p, 92), - new cElementalDefinitionStack(dHadronDefinition.hadron_n, 143) - ); - transformation.addOredict(new cElementalDefinitionStack(temp, 144), dust, Materials.Uranium235,1); - - TecTech.LOGGER.info("Diff Mass U : "+(tempMass-temp.getMass())); - - temp=new dAtomDefinition( - new cElementalDefinitionStack(eLeptonDefinition.lepton_e, 94), - new cElementalDefinitionStack(dHadronDefinition.hadron_p, 94), - new cElementalDefinitionStack(dHadronDefinition.hadron_n, 145) - ); - transformation.addOredict(new cElementalDefinitionStack(temp, 144), dust, Materials.Plutonium/*239*/,1); - - somethingHeavy=new dAtomDefinition( - new cElementalDefinitionStack(eLeptonDefinition.lepton_e, 94), - new cElementalDefinitionStack(dHadronDefinition.hadron_p, 94), - new cElementalDefinitionStack(dHadronDefinition.hadron_n, 147) - ); - transformation.addOredict(new cElementalDefinitionStack(somethingHeavy, 144), dust, Materials.Plutonium241,1); - - TecTech.LOGGER.info("Diff Mass Pu: "+(somethingHeavy.getMass()-temp.getMass())); - - TecTech.LOGGER.info("Neutron Mass: "+dHadronDefinition.hadron_n.getMass()); - - } catch (tElementalException e) { - if (DEBUG_MODE) { - e.printStackTrace(); - } - } - - if(Loader.isModLoaded(Reference.GTPLUSPLUS)) { - new GtppAtomLoader().run(); - } - } - - public static dAtomDefinition getFirstStableIsotope(int element) { - return stableAtoms.get(element); - } - - public static dAtomDefinition getBestUnstableIsotope(int element) { - return unstableAtoms.get(element); - } - - @Override - public byte getClassType() { - return 64; - } - - public static byte getClassTypeStatic(){ - return 64; - } - - @Override - public int hashCode() { - return hash; - } - - @Override - public void addScanResults(ArrayList lines, int capabilities, long energyLevel) { - if(Util.areBitsSet(SCAN_GET_CLASS_TYPE, capabilities)) { - lines.add("CLASS = " + nbtType + ' ' + getClassType()); - } - if(Util.areBitsSet(SCAN_GET_NOMENCLATURE|SCAN_GET_CHARGE|SCAN_GET_MASS|SCAN_GET_TIMESPAN_INFO, capabilities)) { - lines.add("NAME = "+getName()); - lines.add("SYMBOL = "+getSymbol()); - } - if(Util.areBitsSet(SCAN_GET_CHARGE,capabilities)) { - lines.add("CHARGE = " + getCharge() / 3f + " e"); - } - if(Util.areBitsSet(SCAN_GET_COLOR,capabilities)) { - lines.add(getColor() < 0 ? "COLORLESS" : "CARRIES COLOR"); - } - if(Util.areBitsSet(SCAN_GET_MASS,capabilities)) { - lines.add("MASS = " + getMass() + " eV/c\u00b2"); - } - if(iaeaDefinitionExistsAndHasEnergyLevels && Util.areBitsSet(SCAN_GET_ENERGY_STATES,capabilities)){ - for(int i=1;i NUCLIDES=new HashMap<>(); - - public static void run(){ - String line=""; - - try { - BufferedReader reader = new BufferedReader(new InputStreamReader(iaeaNuclide.class.getResourceAsStream("nuclides.csv"))); - ArrayList blockOfData=new ArrayList<>(4); - while((line=reader.readLine())!=null) { - String[] split= Util.splitButDifferent(line,","); - if(split.length!=19) { - throw new Error("Invalid count (" + split.length + ") of separators in IAEA nuclides database " + line); - } - if(!split[1].isEmpty() && !blockOfData.isEmpty()) { - new iaeaNuclide(blockOfData.toArray(new String[blockOfData.size()][])); - blockOfData.clear(); - } - blockOfData.add(split); - } - if(!blockOfData.isEmpty()) { - new iaeaNuclide(blockOfData.toArray(new String[blockOfData.size()][])); - blockOfData.clear(); - } - reader.close(); - }catch (Exception e){ - System.out.println(line); - e.printStackTrace(); - } - - try { - BufferedReader reader = new BufferedReader(new InputStreamReader(iaeaNuclide.class.getResourceAsStream("nuclidesTable.csv"))); - while((line=reader.readLine())!=null) { - String[] split= Util.splitButDifferent(line,","); - if(split.length!=47) { - throw new Error("Invalid count (" + split.length + ") of separators in IAEA nuvlidesTable database " + line); - } - get(Integer.parseInt(split[0]),Integer.parseInt(split[1])).getMoreData(split); - } - reader.close(); - }catch (Exception e){ - System.out.println(line); - e.printStackTrace(); - } - - try { - BufferedReader reader = new BufferedReader(new InputStreamReader(iaeaNuclide.class.getResourceAsStream("energyLevels.csv"))); - while((line=reader.readLine())!=null) { - String[] split= Util.splitButDifferent(line,","); - if(split.length!=27) { - throw new Error("Invalid count (" + split.length + ") of separators in IAEA energyLevels database " + line); - } - new energeticState(split); - } - reader.close(); - }catch (Exception e){ - System.out.println(line); - e.printStackTrace(); - } - - for(iaeaNuclide nuclide:NUCLIDES.values()) { - nuclide.makeArrayOfEnergyStates(); - } - } - - public static iaeaNuclide get(int protons, int neutrons){ - return NUCLIDES.get((protons<<16)+neutrons); - } - - public final short N,Z; - public final float halfTime;//sec - public final float mass;//eV/c^2 - public final short discovery;//year - private TreeMap energeticStates; - public energeticState[] energeticStatesArray; - - - private iaeaNuclide(String[][] rows){ - N=Short.parseShort(rows[1][2]); - Z=Short.parseShort(rows[1][0]); - NUCLIDES.put(((int)Z <<16)+N,this); - - String[] parts = Util.splitButDifferent(rows[0][16], "|"); - double Mass=doubleOrNaN(parts[0],"mass"); - if(!Double.isNaN(Mass)) { - //System.out.println("Mass =\t" + Mass+"\t"+(N+Z)+"\t"+N+"\t"+Z+"\t"+(Mass/(N+Z))); - mass = (float)(Mass* MICRO_AMU_TO_EV_DIV_C_C); - } - else { - mass = Float.NaN; - } - - discovery=(short)doubleOrNaN(rows[0][18],"discovery"); - - if(rows[0][3].contains("STABLE")){ - halfTime = STABLE_RAW_LIFE_TIME; - }else{ - parts = Util.splitButDifferent(rows[0][4], "|"); - halfTime = (float)doubleOrNaN(parts[0],"half life"); - } - } - - private void getMoreData(String[] cells){ - //if(DEBUG_MODE) { - // if (add(cells[14])) System.out.println(N + " " + Z); - // if (add(cells[17])) System.out.println(N + " " + Z); - // if (add(cells[20])) System.out.println(N + " " + Z); - //} - new energeticState(this, halfTime, getDecaysFixed(cells[14],doubleOrNaN(cells[15],"chance1"),cells[17],doubleOrNaN(cells[18],"chance1"),cells[20],doubleOrNaN(cells[21],"chance1"))); - } - - private static final energeticState[] empty=new energeticState[0]; - private void makeArrayOfEnergyStates(){ - if(energeticStates==null || energeticStates.isEmpty()) { - energeticStatesArray = empty; - } else { - energeticStatesArray = energeticStates.values().toArray(new energeticState[0]); - } - } - - private double doubleOrNaN(String s, String name){ - s=s.replaceAll("#",""); - if(!s.isEmpty()) { - try { - double value=Double.parseDouble(s); - if(Double.isNaN(value)) { - return Double.NaN; - } - return value != 0 ?value:Double.NaN; - } catch (Exception e) { - System.out.println("Invalid Value " + name + ' ' + N + ' ' + Z + ' ' + s); - e.printStackTrace(); - } - } - return Double.NaN; - } - - public static final class energeticState{ - public final float energy; - public final float Thalf; - public final iaeaDecay[] decaymodes; - - private energeticState(iaeaNuclide nuclide,float Thalf,iaeaDecay[] decaymodes){ - energy=0; - this.Thalf=Thalf; - this.decaymodes=decaymodes; - if(nuclide.energeticStates==null) { - nuclide.energeticStates = new TreeMap<>(); - } - nuclide.energeticStates.put(energy,this); - } - - private energeticState(String[] cells){ - iaeaNuclide nuclide= get((int)doubleOrNaN(cells[0],"protons"),(int)doubleOrNaN(cells[1],"neutrons")); - if(nuclide==null) { - throw new Error("Missing nuclide " + (int) doubleOrNaN(cells[0], "protons") + ' ' + (int) doubleOrNaN(cells[1], "neutrons")); - } - energy =(float) (doubleOrNaN(cells[3],"energy level",nuclide)*1000f);//to eV - if(energy<0) { - throw new Error("Invalid energy " + nuclide.N + ' ' + nuclide.Z + ' ' + cells[3]); - } - Thalf =(float) doubleOrNaN(cells[10],"half life",nuclide); - if(nuclide.energeticStates==null) { - new Exception("Should be initialized before doing this... "+ nuclide.N + ' ' +nuclide.Z).printStackTrace(); - nuclide.energeticStates = new TreeMap<>(); - } - nuclide.energeticStates.put(energy,this); - //if(DEBUG_MODE) { - // if (add(cells[12])) System.out.println(nuclide.N + " " + nuclide.Z); - // if (add(cells[15])) System.out.println(nuclide.N + " " + nuclide.Z); - // if (add(cells[18])) System.out.println(nuclide.N + " " + nuclide.Z); - //} - decaymodes = getDecaysFixed(cells[12],doubleOrNaN(cells[13],"chance 1",nuclide),cells[15],doubleOrNaN(cells[16],"chance 2",nuclide),cells[18],doubleOrNaN(cells[19],"chance 3",nuclide)); - } - - private double doubleOrNaN(String s, String name){ - return doubleOrNaN(s,name,null); - } - - private double doubleOrNaN(String s, String name, iaeaNuclide nuclide){ - s = s.replaceAll("#", ""); - if (!s.isEmpty()) { - try { - return Double.parseDouble(s); - } catch (Exception e) { - if(nuclide==null){ - System.out.println("Invalid Value " + name + ' ' + s); - }else { - System.out.println("Invalid Value " + name + ' ' + nuclide.N + ' ' + nuclide.Z + ' ' + s); - } - e.printStackTrace(); - } - } - return Double.NaN; - } - } - - private static HashSet decays=new HashSet<>(); - private static boolean add(String s){ - if(decays.add(s)){ - System.out.println(s); - return true; - } - return false; - } - - private static iaeaDecay[] getDecaysFixed(String decay1, double chance1,String decay2, double chance2,String decay3, double chance3){ - boolean do1,do2,do3; - do1= !decay1.isEmpty() && !Double.isNaN(chance1); - do2= !decay2.isEmpty() && !Double.isNaN(chance2); - do3= !decay3.isEmpty() && !Double.isNaN(chance3); - TreeMap decays=new TreeMap<>(); - if(do1 && do2 && chance1==100 && chance2==100 && chance3!=100){ - decays.put(1D, new iaeaDecay(1f, decay1)); - if(do3) { - chance3/=100d; - decays.put(chance3, new iaeaDecay((float) chance3, decay2)); - chance2=1d-chance3; - } - chance2/=2d; - decays.put(chance2, new iaeaDecay((float) chance2, decay2)); - }else if(do1 && chance1==100){ - decays.put(1D, new iaeaDecay(1f, decay1)); - if(do2) { - chance2/=100d; - decays.put(chance2, new iaeaDecay((float) chance2, decay2)); - } - if(do3) { - chance3 /= 100d; - if(do2) { - chance3 *= chance2; - } - decays.put(chance3, new iaeaDecay((float) chance3, decay3)); - } - }else{ - double normalization= (do1?chance1:0) + (do2?chance2:0) + (do3?chance3:0); - if(do1) { - chance1/=normalization; - decays.put(chance1, new iaeaDecay((float) chance1, decay1)); - } - if(do2) { - chance2/=normalization; - decays.put(chance2, new iaeaDecay((float) chance2, decay2)); - } - if(do3) { - chance3/=normalization; - decays.put(chance3, new iaeaDecay((float) chance3, decay3)); - } - if(do1||do2||do3) { - decays.put(1D, iaeaDecay.DEAD_END); - } - } - //if(DEBUG_MODE){ - // System.out.println("INVALID SUM?\t"+normalization+"\t"+decay1+"\t"+chance1+"\t"+decay2+"\t"+chance2+"\t"+decay3+"\t"+chance3); - //} - return decays.values().toArray(new iaeaDecay[0]); - } - - public static final class iaeaDecay{ - public final float chance; - public final String decayName; - public static final iaeaDecay DEAD_END=new iaeaDecay(1f,"DEAD_END"); - private iaeaDecay(float chance,String decayName){ - this.chance=chance; - this.decayName=decayName; - } - } -} diff --git a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/complex/dAtomDefinition.java b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/complex/dAtomDefinition.java new file mode 100644 index 0000000000..e6dc5bcd75 --- /dev/null +++ b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/complex/dAtomDefinition.java @@ -0,0 +1,1685 @@ +package com.github.technus.tectech.mechanics.elementalMatter.definitions.complex; + +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.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 = this.element < 0; + try { + if (Math.abs(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 = this.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 String getShortSymbol() { + int element = Math.abs(this.element); + boolean negative = this.element < 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.SymbolIUPAC[10 + s100] + nomenclature.SymbolIUPAC[s10] + nomenclature.SymbolIUPAC[s1]; + } catch (Exception E) { + if (DEBUG_MODE) { + e.printStackTrace(); + } + return (negative ? "~" : "") + "?"; + } + } + } + + @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_unsafeLeavesExposedElementalTree())); + return true; + }catch (Exception e){ + if(DEBUG_MODE) { + e.printStackTrace(); + } + } + } + } break; + case "EC": { + if (withThis.removeAllAmounts(false, dHadronDefinition.hadron_p1,eLeptonDefinition.lepton_e1)){ + withThis.putUnify(dHadronDefinition.hadron_n1); + 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 "2EC": { + if (withThis.removeAllAmounts(false, dHadronDefinition.hadron_p2,eLeptonDefinition.lepton_e2)){ + withThis.putUnify(dHadronDefinition.hadron_n2); + 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++EC": case "EC+B+": { + if (withThis.removeAllAmounts(false, dHadronDefinition.hadron_p2,eLeptonDefinition.lepton_e1)){ + withThis.putUnify(dHadronDefinition.hadron_n2); + newStuff.putReplace(eLeptonDefinition.lepton_e_1); + 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+A": { + if (withThis.removeAllAmounts(false, dHadronDefinition.hadron_p3, dHadronDefinition.hadron_n1)){ + newStuff.putReplace(eLeptonDefinition.lepton_e_1); + newStuff.putReplace(eNeutrinoDefinition.lepton_Ve1); + 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+P": { + if (withThis.removeAllAmounts(false, dHadronDefinition.hadron_p2)){ + withThis.putUnify(dHadronDefinition.hadron_n1); + newStuff.putReplace(eLeptonDefinition.lepton_e_1); + newStuff.putReplace(eNeutrinoDefinition.lepton_Ve1); + newStuff.putReplace(dHadronDefinition.hadron_p1); + 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+2P": { + if (withThis.removeAllAmounts(false, dHadronDefinition.hadron_p3)){ + withThis.putUnify(dHadronDefinition.hadron_n1); + newStuff.putReplace(eLeptonDefinition.lepton_e_1); + newStuff.putReplace(eNeutrinoDefinition.lepton_Ve1); + newStuff.putReplace(dHadronDefinition.hadron_p2); + 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-A": { + if (withThis.removeAllAmounts(false, dHadronDefinition.hadron_n3, dHadronDefinition.hadron_p1)){ + newStuff.putReplace(eLeptonDefinition.lepton_e1); + newStuff.putReplace(eNeutrinoDefinition.lepton_Ve_1); + 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-N": { + if (withThis.removeAllAmounts(false, dHadronDefinition.hadron_n2)){ + withThis.putUnify(dHadronDefinition.hadron_p1); + newStuff.putReplace(eLeptonDefinition.lepton_e1); + newStuff.putReplace(eNeutrinoDefinition.lepton_Ve_1); + newStuff.putReplace(dHadronDefinition.hadron_n1); + 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-2N": { + if (withThis.removeAllAmounts(false, dHadronDefinition.hadron_n3)){ + withThis.putUnify(dHadronDefinition.hadron_p1); + newStuff.putReplace(eLeptonDefinition.lepton_e1); + newStuff.putReplace(eNeutrinoDefinition.lepton_Ve_1); + newStuff.putReplace(dHadronDefinition.hadron_n2); + 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-P": { + if (withThis.removeAllAmounts(false, dHadronDefinition.hadron_n1)){ + newStuff.putReplace(eLeptonDefinition.lepton_e1); + newStuff.putReplace(eNeutrinoDefinition.lepton_Ve_1); + newStuff.putReplace(dHadronDefinition.hadron_p1); + 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 "ECA": { + if (withThis.removeAllAmounts(false, dHadronDefinition.hadron_n1,eLeptonDefinition.lepton_e1,dHadronDefinition.hadron_p3)){ + newStuff.putReplace(eNeutrinoDefinition.lepton_Ve1); + 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 "ECP": { + if (withThis.removeAllAmounts(false, eLeptonDefinition.lepton_e1,dHadronDefinition.hadron_p2)){ + withThis.putUnify(dHadronDefinition.hadron_n1); + newStuff.putReplace(eNeutrinoDefinition.lepton_Ve1); + newStuff.putReplace(dHadronDefinition.hadron_p1); + 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 "EC2P": { + if (withThis.removeAllAmounts(false, eLeptonDefinition.lepton_e1,dHadronDefinition.hadron_p3)){ + withThis.putUnify(dHadronDefinition.hadron_n1); + newStuff.putReplace(eNeutrinoDefinition.lepton_Ve1); + newStuff.putReplace(dHadronDefinition.hadron_p2); + 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 "ECP+EC2P": {//todo look at branching ratios + if (withThis.removeAllAmounts(false, eLeptonDefinition.lepton_e2,dHadronDefinition.hadron_p5)){ + withThis.putUnify(dHadronDefinition.hadron_n1); + newStuff.putReplace(eNeutrinoDefinition.lepton_Ve2); + newStuff.putReplace(dHadronDefinition.hadron_p3); + 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 "N": { + if (withThis.removeAllAmounts(false, dHadronDefinition.hadron_n1)){ + newStuff.putReplace(dHadronDefinition.hadron_n1); + 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 "2N": { + if (withThis.removeAllAmounts(false, dHadronDefinition.hadron_n2)){ + newStuff.putReplace(dHadronDefinition.hadron_n2); + 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 "P": { + if (withThis.removeAllAmounts(false, dHadronDefinition.hadron_p1)){ + newStuff.putReplace(dHadronDefinition.hadron_p1); + 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 "2P": { + if (withThis.removeAllAmounts(false, dHadronDefinition.hadron_p2)){ + newStuff.putReplace(dHadronDefinition.hadron_p2); + 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 "SF": { + if (Fission(decaysList, withThis, newStuff, decay.chance, false)) { + return true; + } + } break; + case "B-F": { + if (withThis.removeAllAmounts(false, dHadronDefinition.hadron_n1)){ + withThis.putUnify(dHadronDefinition.hadron_p1); + newStuff.putReplace(eLeptonDefinition.lepton_e1); + newStuff.putReplace(eNeutrinoDefinition.lepton_Ve_1); + try{ + if(Fission(decaysList,withThis,newStuff,decay.chance,false)) { + return true; + } + }catch (Exception e){ + if(DEBUG_MODE) { + e.printStackTrace(); + } + } + } + } break; + case "ECF": case "ECSF": case "EC(+SF)": { + if (withThis.removeAllAmounts(false, dHadronDefinition.hadron_p1,eLeptonDefinition.lepton_e1)){ + withThis.putUnify(dHadronDefinition.hadron_n1); + newStuff.putReplace(eNeutrinoDefinition.lepton_Ve1); + try{ + if(Fission(decaysList,withThis,newStuff,decay.chance,false)) { + return true; + } + }catch (Exception e){ + if(DEBUG_MODE) { + e.printStackTrace(); + } + } + } + } break; + case "SF(+EC+B+)": case "SF+EC+B+": { + if (withThis.removeAllAmounts(false, dHadronDefinition.hadron_p2,eLeptonDefinition.lepton_e1)){ + withThis.putUnify(dHadronDefinition.hadron_n2); + newStuff.putReplace(eLeptonDefinition.lepton_e_1); + newStuff.putReplace(eNeutrinoDefinition.lepton_Ve2); + try{ + if(Fission(decaysList,withThis,newStuff,decay.chance,false)) { + return true; + } + }catch (Exception e){ + if(DEBUG_MODE) { + e.printStackTrace(); + } + } + } + } break; + case "SF+EC+B-": { + if (withThis.removeAllAmounts(false, eLeptonDefinition.lepton_e1)){ + newStuff.putReplace(eLeptonDefinition.lepton_e1); + newStuff.putReplace(eNeutrinoDefinition.lepton_Ve1); + newStuff.putReplace(eNeutrinoDefinition.lepton_Ve_1); + try{ + if(Fission(decaysList,withThis,newStuff,decay.chance,false)) { + return true; + } + }catch (Exception e){ + if(DEBUG_MODE) { + e.printStackTrace(); + } + } + } + } break; + case "IT": case "IT?": case "G": { + if(energy>0){ + decaysList.add(new cElementalDecay(decay.chance, this, boson_Y__)); + return true; + }else{ + if(DEBUG_MODE) { + TecTech.LOGGER.info("Tried to emit Gamma from ground state"); + } + decaysList.add(new cElementalDecay(decay.chance, this)); + return true; + } + } //break; + case "IT+EC+B+": { + if (withThis.removeAllAmounts(false, dHadronDefinition.hadron_p2,eLeptonDefinition.lepton_e1)){ + withThis.putUnify(dHadronDefinition.hadron_n2); + newStuff.putReplace(eLeptonDefinition.lepton_e_1); + newStuff.putReplace(eNeutrinoDefinition.lepton_Ve2); + newStuff.putReplace(eBosonDefinition.boson_Y__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 "DEAD_END": + decaysList.add(deadEnd); + return true; + default: throw new Error("Unsupported decay mode: " + decay.decayName + ' ' + neutralCount+ ' ' +element); + } + if(DEBUG_MODE) { + TecTech.LOGGER.info("Failed to decay " + element + ' ' + neutralCount + ' ' + decay.decayName); + } + return false; + } + + private boolean Emmision(ArrayList decaysList, cElementalDefinitionStack emit) { + cElementalMutableDefinitionStackMap tree = elementalStacks.toMutable(); + if (tree.removeAmount(false, emit)) { + try { + decaysList.add(new cElementalDecay((float) 1, new cElementalDefinitionStack(new dAtomDefinition(tree.toImmutable_optimized_unsafeLeavesExposedElementalTree()), 1), emit)); + return true; + } catch (Exception e) { + if (DEBUG_MODE) { + e.printStackTrace(); + } + } + } + return false; + } + + private boolean alphaDecay(ArrayList decaysList) { + cElementalMutableDefinitionStackMap tree = elementalStacks.toMutable(); + if (tree.removeAllAmounts(false, alpha.definition.getSubParticles())) { + try { + decaysList.add(new cElementalDecay((float) 1, new cElementalDefinitionStack(new dAtomDefinition(tree.toImmutable_optimized_unsafeLeavesExposedElementalTree()), 1), alpha)); + return true; + } catch (Exception e) { + if (DEBUG_MODE) { + e.printStackTrace(); + } + } + } + return false; + } + + private boolean MbetaDecay(ArrayList decaysList) { + cElementalMutableDefinitionStackMap tree = elementalStacks.toMutable(); + if (tree.removeAmount(false, dHadronDefinition.hadron_n1)) { + try { + tree.putUnify(dHadronDefinition.hadron_p1); + decaysList.add(new cElementalDecay((float) 1, new cElementalDefinitionStack(new dAtomDefinition(tree.toImmutable_optimized_unsafeLeavesExposedElementalTree()), 1), eLeptonDefinition.lepton_e1, eNeutrinoDefinition.lepton_Ve_1)); + return true; + } catch (Exception e) { + if (DEBUG_MODE) { + e.printStackTrace(); + } + } + } + return false; + } + + private boolean PbetaDecay(ArrayList decaysList) { + cElementalMutableDefinitionStackMap tree = elementalStacks.toMutable(); + if (tree.removeAmount(false, dHadronDefinition.hadron_p1)) { + try { + tree.putUnify(dHadronDefinition.hadron_n1); + decaysList.add(new cElementalDecay((float) 1, new cElementalDefinitionStack(new dAtomDefinition(tree.toImmutable_optimized_unsafeLeavesExposedElementalTree()), 1), eLeptonDefinition.lepton_e_1, eNeutrinoDefinition.lepton_Ve1)); + return true; + } catch (Exception e) { + if (DEBUG_MODE) { + e.printStackTrace(); + } + } + } + return false; + } + + private boolean ElectronCapture(ArrayList decaysList) { + cElementalMutableDefinitionStackMap tree = elementalStacks.toMutable(); + if (tree.removeAllAmounts(false, dHadronDefinition.hadron_p1,eLeptonDefinition.lepton_e1)) { + try { + tree.putUnify(dHadronDefinition.hadron_n1); + decaysList.add(new cElementalDecay((float) 1, new cElementalDefinitionStack(new dAtomDefinition(tree.toImmutable_optimized_unsafeLeavesExposedElementalTree()), 1), eNeutrinoDefinition.lepton_Ve1)); + return true; + } catch (Exception e) { + if (DEBUG_MODE) { + e.printStackTrace(); + } + } + } + return false; + } + + private boolean Fission(ArrayList decaysList, cElementalMutableDefinitionStackMap fissile, cElementalMutableDefinitionStackMap particles,float probability,boolean spontaneousCheck) { + cElementalMutableDefinitionStackMap heavy = new cElementalMutableDefinitionStackMap(); + double[] liquidDrop= liquidDropFunction(Math.abs(element)<=97); + + for(cElementalDefinitionStack stack: fissile.values()){ + if(spontaneousCheck && stack.definition instanceof dHadronDefinition && + (stack.amount<=80 || stack.amount<90 && XSTR_INSTANCE.nextInt(10)XSTR_INSTANCE.nextDouble()?1:0; + particles.putUnify(new cElementalDefinitionStack(stack.definition, neutrals_cnt)); + + int heavy_cnt=(int)Math.ceil(stack.amount*liquidDrop[1]); + while(heavy_cnt+neutrals_cnt>stack.amount) { + heavy_cnt--; + } + fissile.removeAmount(false,new cElementalDefinitionStack(stack.definition,heavy_cnt+neutrals_cnt)); + heavy.putReplace(new cElementalDefinitionStack(stack.definition, heavy_cnt)); + //}else{ + // particles.add(stack); + // light.remove(stack.definition); + //} + }else{ + int heavy_cnt=(int)Math.ceil(stack.amount*liquidDrop[0]); + if(heavy_cnt%2==1 && XSTR_INSTANCE.nextFloat()>0.05f) { + heavy_cnt--; + } + cElementalDefinitionStack new_stack=new cElementalDefinitionStack(stack.definition, heavy_cnt); + fissile.removeAmount(false,new_stack); + heavy.putReplace(new_stack); + } + } + + try { + particles.putReplace(new cElementalDefinitionStack(new dAtomDefinition(fissile.toImmutable_optimized_unsafeLeavesExposedElementalTree()),1)); + particles.putReplace(new cElementalDefinitionStack(new dAtomDefinition(heavy.toImmutable_optimized_unsafeLeavesExposedElementalTree()),1)); + decaysList.add(new cElementalDecay(probability, particles.toImmutable_optimized_unsafeLeavesExposedElementalTree())); + return true; + } catch (Exception e) { + if(DEBUG_MODE) { + e.printStackTrace(); + } + } + return false; + } + + private static double[] liquidDropFunction(boolean asymmetric) { + double[] out = new double[3]; + + out[0] = XSTR_INSTANCE.nextGaussian(); + + if (out[0] < 1 && out[0] >= -1) { + if (XSTR_INSTANCE.nextBoolean()) { + out[0] = XSTR_INSTANCE.nextDouble() * 2d - 1d; + } + } + + if (asymmetric && out[0] > XSTR_INSTANCE.nextDouble() && XSTR_INSTANCE.nextInt(4) == 0) { + out[0] = -out[0]; + } + + //scale to splitting ratio + out[0] = out[0] * 0.05d + .6d; + + if (out[0] < 0 || out[0] > 1) { + return liquidDropFunction(asymmetric); + } + if (out[0] < .5d) { + out[0] = 1d - out[0]; + } + + //extra neutrals + out[2] = 0.012d + XSTR_INSTANCE.nextDouble() * 0.01d; + + if (asymmetric) { + out[1] = out[0]; + } else { + out[1] = out[0] - out[2] * .5d; + } + + return out; + } + + @Override + public cElementalDecay[] getEnergyInducedDecay(long energyLevel) { + if (iaeaDefinitionExistsAndHasEnergyLevels) { + ArrayList decays=new ArrayList<>(4); + if(iaeaDecay(decays,energyLevel)){ + return decays.toArray(new cElementalDecay[0]); + } + } + if(energyLevel< Math.abs(charge)/3+neutralCount) { + return new cElementalDecay[]{new cElementalDecay(1, this, boson_Y__)}; + } + return getNaturalDecayInstant(); + } + + @Override + public float getEnergyDiffBetweenStates(long currentEnergyLevel,long newEnergyLevel) { + if(iaeaDefinitionExistsAndHasEnergyLevels){ + float result=0; + boolean backwards=newEnergyLevel=iaea.energeticStatesArray.length){ + if(currentEnergyLevel>=iaea.energeticStatesArray.length) { + return iElementalDefinition.DEFAULT_ENERGY_REQUIREMENT * (newEnergyLevel - currentEnergyLevel); + } else { + result += iElementalDefinition.DEFAULT_ENERGY_REQUIREMENT * (newEnergyLevel - iaea.energeticStatesArray.length + 1); + } + result+=iaea.energeticStatesArray[iaea.energeticStatesArray.length-1].energy; + }else { + result += iaea.energeticStatesArray[(int) Math.max(0, newEnergyLevel)].energy; + } + + return backwards?-result:result; + } + return iElementalDefinition.DEFAULT_ENERGY_REQUIREMENT *(newEnergyLevel-currentEnergyLevel); + } + + @Override + public boolean usesSpecialEnergeticDecayHandling() { + return iaeaDefinitionExistsAndHasEnergyLevels; + } + + @Override + public boolean usesMultipleDecayCalls(long energyLevel) { + if(!iaeaDefinitionExistsAndHasEnergyLevels) return false; + iaeaNuclide.energeticState state; + if(energyLevel>iaea.energeticStatesArray.length) { + state = iaea.energeticStatesArray[iaea.energeticStatesArray.length - 1]; + } else if(energyLevel<=0) { + state = iaea.energeticStatesArray[0]; + } else { + state = iaea.energeticStatesArray[(int) energyLevel]; + } + for (iaeaNuclide.iaeaDecay decay:state.decaymodes){ + if(decay.decayName.contains("F")) return true;//if is fissile + } + return false; + } + + @Override + public boolean decayMakesEnergy(long energyLevel) { + return iaeaDefinitionExistsAndHasEnergyLevels; + } + + @Override + public boolean fusionMakesEnergy(long energyLevel) { + return iaea!=null || iaeaDefinitionExistsAndHasEnergyLevels; + } + + @Override + public cElementalDecay[] getNaturalDecayInstant() { + //disembody + ArrayList decaysInto = new ArrayList<>(); + for (cElementalDefinitionStack elementalStack : elementalStacks.values()) { + if (elementalStack.definition.getType() == 1 || elementalStack.definition.getType() == -1) { + //covers both quarks and antiquarks + decaysInto.add(elementalStack); + } else { + //covers both quarks and antiquarks + decaysInto.add(new cElementalDefinitionStack(boson_Y__, 2)); + } + } + return new cElementalDecay[]{new cElementalDecay(0.75F, decaysInto.toArray(new cElementalDefinitionStack[0])), deadEnd}; + } + + //@Override + //public iElementalDefinition getAnti() { + // cElementalDefinitionStack[] stacks = this.elementalStacks.values(); + // cElementalDefinitionStack[] antiElements = new cElementalDefinitionStack[stacks.length]; + // for (int i = 0; i < antiElements.length; i++) { + // antiElements[i] = new cElementalDefinitionStack(stacks[i].definition.getAnti(), stacks[i].amount); + // } + // try { + // return new dAtomDefinition(false, antiElements); + // } catch (tElementalException e) { + // if (DEBUG_MODE) e.printStackTrace(); + // return null; + // } + //} + + @Override + public dAtomDefinition getAnti() { + cElementalMutableDefinitionStackMap anti = new cElementalMutableDefinitionStackMap(); + for (cElementalDefinitionStack stack : elementalStacks.values()) { + anti.putReplace(new cElementalDefinitionStack(stack.definition.getAnti(), stack.amount)); + } + try { + return new dAtomDefinition(anti.toImmutable_optimized_unsafeLeavesExposedElementalTree()); + } catch (tElementalException e) { + if (DEBUG_MODE) { + e.printStackTrace(); + } + return null; + } + } + + @Override + public aFluidDequantizationInfo someAmountIntoFluidStack() { + return transformation.fluidDequantization.get(this); + } + + @Override + public aItemDequantizationInfo someAmountIntoItemsStack() { + return null; + } + + @Override + public aOredictDequantizationInfo someAmountIntoOredictStack() { + return transformation.oredictDequantization.get(this); + } + + 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[] SymbolIUPAC = new String[]{"n", "u", "b", "t", "q", "p", "h", "s", "o", "e", "N", "U", "B", "T", "Q", "P", "H", "S", "O", "E"}; + } + + @Override + public NBTTagCompound toNBT() { + return getNbtTagCompound(nbtType, elementalStacks); + } + + public static dAtomDefinition fromNBT(NBTTagCompound nbt) { + cElementalDefinitionStack[] stacks = new cElementalDefinitionStack[nbt.getInteger("i")]; + for (int i = 0; i < stacks.length; i++) { + stacks[i] = cElementalDefinitionStack.fromNBT(nbt.getCompoundTag(Integer.toString(i))); + } + try { + return new dAtomDefinition(stacks); + } catch (tElementalException e) { + if (DEBUG_MODE) { + e.printStackTrace(); + } + return null; + } + } + + public static void run() { + for (Runnable r : overrides) { + r.run(); + } + + for(Map.Entry entry:lifetimeOverrides.entrySet()){ + try { + lifetimeOverrides.put(new dAtomDefinition(entry.getKey().elementalStacks), entry.getValue()); + }catch (tElementalException e){ + e.printStackTrace(); //Impossible + } + } + + //populate stable isotopes + for (int element = 1; element < 83; element++)//Up to Bismuth exclusive + { + for (int isotope = 0; isotope < 130; isotope++) { + xstr.setSeed((long) (element + 1) * (isotope + 100)); + //stability curve + int StableIsotope = stableIzoCurve(element); + int izoDiff = isotope - StableIsotope; + int izoDiffAbs = Math.abs(izoDiff); + float rawLifeTime = calculateLifeTime(izoDiff, izoDiffAbs, element, isotope, false); + iaeaNuclide nuclide = iaeaNuclide.get(element, isotope); + if (rawLifeTime >= STABLE_RAW_LIFE_TIME || nuclide != null && nuclide.halfTime >= STABLE_RAW_LIFE_TIME) { + TreeSet isotopes = stableIsotopes.computeIfAbsent(element, k -> new TreeSet<>()); + isotopes.add(isotope); + } + } + } + + //populate unstable isotopes + for (int element = 83; element < 150; element++) { + for (int isotope = 100; isotope < 180; isotope++) { + xstr.setSeed((long) (element + 1) * (isotope + 100)); + //stability curve + int Isotope = stableIzoCurve(element); + int izoDiff = isotope - Isotope; + int izoDiffAbs = Math.abs(izoDiff); + float rawLifeTime = calculateLifeTime(izoDiff, izoDiffAbs, element, isotope, false); + TreeMap isotopes = mostStableUnstableIsotopes.computeIfAbsent(element, k -> new TreeMap<>()); + isotopes.put(rawLifeTime, isotope); + } + } + + try { + for (Map.Entry> integerTreeSetEntry : stableIsotopes.entrySet()) { + stableAtoms.put(integerTreeSetEntry.getKey(), new dAtomDefinition( + new cElementalDefinitionStack(dHadronDefinition.hadron_p, integerTreeSetEntry.getKey()), + new cElementalDefinitionStack(dHadronDefinition.hadron_n, integerTreeSetEntry.getValue().first()), + new cElementalDefinitionStack(eLeptonDefinition.lepton_e, integerTreeSetEntry.getKey()))); + if (DEBUG_MODE) { + TecTech.LOGGER.info("Added Stable Atom:" + integerTreeSetEntry.getKey() + ' ' + integerTreeSetEntry.getValue().first() + ' ' + stableAtoms.get(integerTreeSetEntry.getKey()).getMass()); + } + } + for (Map.Entry> integerTreeMapEntry : mostStableUnstableIsotopes.entrySet()) { + unstableAtoms.put(integerTreeMapEntry.getKey(), new dAtomDefinition( + new cElementalDefinitionStack(dHadronDefinition.hadron_p, integerTreeMapEntry.getKey()), + new cElementalDefinitionStack(dHadronDefinition.hadron_n, integerTreeMapEntry.getValue().lastEntry().getValue()), + new cElementalDefinitionStack(eLeptonDefinition.lepton_e, integerTreeMapEntry.getKey()))); + if (DEBUG_MODE) { + TecTech.LOGGER.info("Added Unstable Atom:" + integerTreeMapEntry.getKey() + ' ' + integerTreeMapEntry.getValue().lastEntry().getValue() + ' ' + unstableAtoms.get(integerTreeMapEntry.getKey()).getMass()); + } + } + deuterium=new dAtomDefinition( + dHadronDefinition.hadron_p1, + dHadronDefinition.hadron_n1, + eLeptonDefinition.lepton_e1).getStackForm(1); + tritium=new dAtomDefinition( + dHadronDefinition.hadron_p1, + dHadronDefinition.hadron_n2, + eLeptonDefinition.lepton_e1).getStackForm(1); + helium_3=new dAtomDefinition( + dHadronDefinition.hadron_p2, + dHadronDefinition.hadron_n1, + eLeptonDefinition.lepton_e2).getStackForm(1); + alpha = new dAtomDefinition( + dHadronDefinition.hadron_p2, + dHadronDefinition.hadron_n2).getStackForm(1); + beryllium_8=new dAtomDefinition( + new cElementalDefinitionStack(dHadronDefinition.hadron_p, 4), + new cElementalDefinitionStack(dHadronDefinition.hadron_n, 4), + new cElementalDefinitionStack(eLeptonDefinition.lepton_e, 4)).getStackForm(1); + carbon_14=new dAtomDefinition( + new cElementalDefinitionStack(dHadronDefinition.hadron_p, 6), + new cElementalDefinitionStack(dHadronDefinition.hadron_n, 8), + new cElementalDefinitionStack(eLeptonDefinition.lepton_e, 6)).getStackForm(1); + neon_24=new dAtomDefinition( + new cElementalDefinitionStack(dHadronDefinition.hadron_p, 10), + new cElementalDefinitionStack(dHadronDefinition.hadron_n, 14), + new cElementalDefinitionStack(eLeptonDefinition.lepton_e, 10)).getStackForm(1); + silicon_34=new dAtomDefinition( + new cElementalDefinitionStack(dHadronDefinition.hadron_p, 14), + new cElementalDefinitionStack(dHadronDefinition.hadron_n, 20), + new cElementalDefinitionStack(eLeptonDefinition.lepton_e, 14)).getStackForm(1); + } catch (Exception e) { + if (DEBUG_MODE) { + e.printStackTrace(); + } + } + + try { + cElementalDefinition.addCreatorFromNBT(nbtType, dAtomDefinition.class.getMethod("fromNBT", NBTTagCompound.class),(byte)64); + } catch (Exception e) { + if (DEBUG_MODE) { + e.printStackTrace(); + } + } + if(DEBUG_MODE) { + TecTech.LOGGER.info("Registered Elemental Matter Class: Atom " + nbtType + ' ' + 64); + } + } + + public static void setTransformation(){ + /*----STABLE ATOMS----**/ + refMass = getFirstStableIsotope(1).getMass() * 144F; + + transformation.addFluid(new cElementalDefinitionStack(getFirstStableIsotope(1), 144),Materials.Hydrogen.mGas.getID(),144); + transformation.addFluid(new cElementalDefinitionStack(getFirstStableIsotope(2), 144),Materials.Helium.mGas.getID(), 144); + transformation.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(3), 144), dust, Materials.Lithium,1); + transformation.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(4), 144), dust, Materials.Beryllium,1); + transformation.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(5), 144), dust, Materials.Boron,1); + transformation.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(6), 144), dust, Materials.Carbon,1); + transformation.addFluid(new cElementalDefinitionStack(getFirstStableIsotope(7), 144),Materials.Nitrogen.mGas.getID(), 144); + transformation.addFluid(new cElementalDefinitionStack(getFirstStableIsotope(8), 144),Materials.Oxygen.mGas.getID(), 144); + transformation.addFluid(new cElementalDefinitionStack(getFirstStableIsotope(9), 144),Materials.Fluorine.mGas.getID(), 144); + //transformation.addFluid(new cElementalDefinitionStack(getFirstStableIsotope(10), 144),Materials.Neon.mGas.getID(), 144); + transformation.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(11), 144), dust, Materials.Sodium,1); + transformation.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(12), 144), dust, Materials.Magnesium,1); + transformation.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(13), 144), dust, Materials.Aluminium,1); + transformation.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(14), 144), dust, Materials.Silicon,1); + transformation.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(15), 144), dust, Materials.Phosphorus,1); + transformation.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(16), 144), dust, Materials.Sulfur,1); + transformation.addFluid(new cElementalDefinitionStack(getFirstStableIsotope(17), 144),Materials.Chlorine.mGas.getID(), 144); + transformation.addFluid(new cElementalDefinitionStack(getFirstStableIsotope(18), 144),Materials.Argon.mGas.getID(), 144); + transformation.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(19), 144), dust, Materials.Potassium,1); + transformation.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(20), 144), dust, Materials.Calcium,1); + transformation.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(21), 144), dust, Materials.Scandium,1); + transformation.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(22), 144), dust, Materials.Titanium,1); + transformation.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(23), 144), dust, Materials.Vanadium,1); + transformation.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(24), 144), dust, Materials.Chrome,1); + transformation.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(25), 144), dust, Materials.Manganese,1); + transformation.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(26), 144), dust, Materials.Iron,1); + transformation.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(27), 144), dust, Materials.Cobalt,1); + transformation.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(28), 144), dust, Materials.Nickel,1); + transformation.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(29), 144), dust, Materials.Copper,1); + transformation.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(30), 144), dust, Materials.Zinc,1); + transformation.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(31), 144), dust, Materials.Gallium,1); + //transformation.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(32), 144),OrePrefixes.dust, Materials.Germanium,1); + transformation.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(33), 144), dust, Materials.Arsenic,1); + //transformation.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(34), 144),OrePrefixes.dust, Materials.Selenium,1); + //transformation.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(35), 144),OrePrefixes.dust, Materials.Bromine,1); + //transformation.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(36), 144),OrePrefixes.dust, Materials.Krypton,1); + transformation.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(37), 144), dust, Materials.Rubidium,1); + transformation.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(38), 144), dust, Materials.Strontium,1); + transformation.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(39), 144), dust, Materials.Yttrium,1); + //transformation.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(40), 144),OrePrefixes.dust, Materials.Zirconium,1); + transformation.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(41), 144), dust, Materials.Niobium,1); + transformation.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(42), 144), dust, Materials.Molybdenum,1); + //transformation.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(43), 144),OrePrefixes.dust, Materials.Technetium,1); + //transformation.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(44), 144),OrePrefixes.dust, Materials.Ruthenium,1); + //transformation.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(45), 144),OrePrefixes.dust, Materials.Rhodium,1); + transformation.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(46), 144), dust, Materials.Palladium,1); + transformation.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(47), 144), dust, Materials.Silver,1); + transformation.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(48), 144), dust, Materials.Cadmium,1); + transformation.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(49), 144), dust, Materials.Indium,1); + transformation.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(50), 144), dust, Materials.Tin,1); + transformation.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(51), 144), dust, Materials.Antimony,1); + transformation.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(52), 144), dust, Materials.Tellurium,1); + //transformation.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(53), 144),OrePrefixes.dust, Materials.Iodine,1); + //transformation.addFluid(new cElementalDefinitionStack(getFirstStableIsotope(54), 144),Materials.Xenon.mGas.getID(), 144); + transformation.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(55), 144), dust, Materials.Caesium,1); + transformation.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(56), 144), dust, Materials.Barium,1); + transformation.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(57), 144), dust, Materials.Lanthanum,1); + transformation.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(58), 144), dust, Materials.Cerium,1); + transformation.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(59), 144), dust, Materials.Praseodymium,1); + transformation.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(60), 144), dust, Materials.Neodymium,1); + transformation.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(61), 144), dust, Materials.Promethium,1); + transformation.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(62), 144), dust, Materials.Samarium,1); + transformation.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(63), 144), dust, Materials.Europium,1); + transformation.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(64), 144), dust, Materials.Gadolinium,1); + transformation.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(65), 144), dust, Materials.Terbium,1); + transformation.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(66), 144), dust, Materials.Dysprosium,1); + transformation.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(67), 144), dust, Materials.Holmium,1); + transformation.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(68), 144), dust, Materials.Erbium,1); + transformation.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(69), 144), dust, Materials.Thulium,1); + transformation.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(70), 144), dust, Materials.Ytterbium,1); + transformation.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(71), 144), dust, Materials.Lutetium,1); + //transformation.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(72), 144),OrePrefixes.dust, Materials.Hafnum,1); + transformation.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(73), 144), dust, Materials.Tantalum,1); + transformation.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(74), 144), dust, Materials.Tungsten,1); + //transformation.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(75), 144),OrePrefixes.dust, Materials.Rhenium,1); + transformation.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(76), 144), dust, Materials.Osmium,1); + transformation.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(77), 144), dust, Materials.Iridium,1); + transformation.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(78), 144), dust, Materials.Platinum,1); + transformation.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(79), 144), dust, Materials.Gold,1); + transformation.addFluid(new cElementalDefinitionStack(getFirstStableIsotope(80), 144),Materials.Mercury.mFluid.getID(), 144); + //transformation.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(81), 144),OrePrefixes.dust, Materials.Thallium,1); + transformation.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(82), 144), dust, Materials.Lead,1); + + /*----UNSTABLE ATOMS----**/ + refUnstableMass = getFirstStableIsotope(82).getMass() * 144F; + + transformation.addOredict(new cElementalDefinitionStack(getBestUnstableIsotope(83), 144), dust, Materials.Bismuth,1); + //transformation.addOredict(new cElementalDefinitionStack(getBestUnstableIsotope(84),144),OrePrefixes.dust, Materials.Polonium,1); + //transformation.addFluid(new cElementalDefinitionStack(getBestUnstableIsotope(85),144),Materials.Astatine.mPlasma.getID(), 144); + transformation.addFluid(new cElementalDefinitionStack(getBestUnstableIsotope(86),144),Materials.Radon.mGas.getID(), 144); + //transformation.addOredict(new cElementalDefinitionStack(getBestUnstableIsotope(87),144),OrePrefixes.dust, Materials.Francium,1); + //transformation.addOredict(new cElementalDefinitionStack(getBestUnstableIsotope(88),144),OrePrefixes.dust, Materials.Radium,1); + //transformation.addOredict(new cElementalDefinitionStack(getBestUnstableIsotope(89),144),OrePrefixes.dust, Materials.Actinium,1); + transformation.addOredict(new cElementalDefinitionStack(getBestUnstableIsotope(90),144), dust, Materials.Thorium,1); + //transformation.addOredict(new cElementalDefinitionStack(getBestUnstableIsotope(91),144),OrePrefixes.dust, Materials.Protactinium,1); + ////transformation.addOredict(new cElementalDefinitionStack(getBestUnstableIsotope(92),144), dust, Materials.Uranium,1); + //transformation.addOredict(new cElementalDefinitionStack(getBestUnstableIsotope(93),144),OrePrefixes.dust, Materials.Neptunium,1); + ////transformation.addOredict(new cElementalDefinitionStack(getBestUnstableIsotope(94),144), dust, Materials.Plutonium,1); + transformation.addOredict(new cElementalDefinitionStack(getBestUnstableIsotope(95),144), dust, Materials.Americium,1); + + try { + dAtomDefinition temp; + transformation.addFluid(new cElementalDefinitionStack(deuterium.definition, 144),Materials.Deuterium.mGas.getID(), 144); + + transformation.addFluid(new cElementalDefinitionStack(tritium.definition, 144),Materials.Tritium.mGas.getID(), 144); + + transformation.addFluid(new cElementalDefinitionStack(helium_3.definition, 144),Materials.Helium_3.mGas.getID(), 144); + + temp=new dAtomDefinition( + new cElementalDefinitionStack(eLeptonDefinition.lepton_e, 92), + new cElementalDefinitionStack(dHadronDefinition.hadron_p, 92), + new cElementalDefinitionStack(dHadronDefinition.hadron_n, 146) + ); + transformation.addOredict(new cElementalDefinitionStack(temp, 144), dust, Materials.Uranium/*238*/,1); + + float tempMass=temp.getMass(); + + temp=new dAtomDefinition( + new cElementalDefinitionStack(eLeptonDefinition.lepton_e, 92), + new cElementalDefinitionStack(dHadronDefinition.hadron_p, 92), + new cElementalDefinitionStack(dHadronDefinition.hadron_n, 143) + ); + transformation.addOredict(new cElementalDefinitionStack(temp, 144), dust, Materials.Uranium235,1); + + TecTech.LOGGER.info("Diff Mass U : "+(tempMass-temp.getMass())); + + temp=new dAtomDefinition( + new cElementalDefinitionStack(eLeptonDefinition.lepton_e, 94), + new cElementalDefinitionStack(dHadronDefinition.hadron_p, 94), + new cElementalDefinitionStack(dHadronDefinition.hadron_n, 145) + ); + transformation.addOredict(new cElementalDefinitionStack(temp, 144), dust, Materials.Plutonium/*239*/,1); + + somethingHeavy=new dAtomDefinition( + new cElementalDefinitionStack(eLeptonDefinition.lepton_e, 94), + new cElementalDefinitionStack(dHadronDefinition.hadron_p, 94), + new cElementalDefinitionStack(dHadronDefinition.hadron_n, 147) + ); + transformation.addOredict(new cElementalDefinitionStack(somethingHeavy, 144), dust, Materials.Plutonium241,1); + + TecTech.LOGGER.info("Diff Mass Pu: "+(somethingHeavy.getMass()-temp.getMass())); + + TecTech.LOGGER.info("Neutron Mass: "+dHadronDefinition.hadron_n.getMass()); + + } catch (tElementalException e) { + if (DEBUG_MODE) { + e.printStackTrace(); + } + } + + if(Loader.isModLoaded(Reference.GTPLUSPLUS)) { + new GtppAtomLoader().run(); + } + } + + public static dAtomDefinition getFirstStableIsotope(int element) { + return stableAtoms.get(element); + } + + public static dAtomDefinition getBestUnstableIsotope(int element) { + return unstableAtoms.get(element); + } + + @Override + public byte getClassType() { + return 64; + } + + public static byte getClassTypeStatic(){ + return 64; + } + + @Override + public int hashCode() { + return hash; + } + + @Override + public void addScanShortSymbols(ArrayList lines, int capabilities, long energyLevel) { + if(Util.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(Util.areBitsSet(SCAN_GET_CLASS_TYPE, capabilities)) { + lines.add("CLASS = " + nbtType + ' ' + getClassType()); + } + if(Util.areBitsSet(SCAN_GET_NOMENCLATURE|SCAN_GET_CHARGE|SCAN_GET_MASS|SCAN_GET_TIMESPAN_INFO, capabilities)) { + lines.add("NAME = "+getName()); + lines.add("SYMBOL = "+getSymbol()); + } + if(Util.areBitsSet(SCAN_GET_CHARGE,capabilities)) { + lines.add("CHARGE = " + getCharge() / 3f + " e"); + } + if(Util.areBitsSet(SCAN_GET_COLOR,capabilities)) { + lines.add(getColor() < 0 ? "COLORLESS" : "CARRIES COLOR"); + } + if(Util.areBitsSet(SCAN_GET_MASS,capabilities)) { + lines.add("MASS = " + getMass() + " eV/c\u00b2"); + } + if(iaeaDefinitionExistsAndHasEnergyLevels && Util.areBitsSet(SCAN_GET_ENERGY_STATES,capabilities)){ + for(int i=1;i= 2 && amount <= 12; + } + + @Override + public String getName() { + StringBuilder name= new StringBuilder(getSimpleName()); + name.append(':'); + for (cElementalDefinitionStack quark : quarkStacks.values()) { + name.append(' ').append(quark.definition.getSymbol()).append(quark.amount); + } + return name.toString(); + } + + private String getSimpleName() { + switch (amount) { + case 2: + return "Meson"; + case 3: + return "Baryon"; + case 4: + return "Tetraquark"; + case 5: + return "Pentaquark"; + case 6: + return "Hexaquark"; + default: + return "Hadron"; + } + } + + @Override + public String getSymbol() { + StringBuilder symbol = new StringBuilder(8); + for (cElementalDefinitionStack quark : quarkStacks.values()) { + for (int i = 0; i < quark.amount; i++) { + symbol.append(quark.definition.getSymbol()); + } + } + return symbol.toString(); + } + + @Override + public String getShortSymbol() { + StringBuilder symbol = new StringBuilder(8); + for (cElementalDefinitionStack quark : quarkStacks.values()) { + for (int i = 0; i < quark.amount; i++) { + symbol.append(quark.definition.getShortSymbol()); + } + } + return symbol.toString(); + } + + @Override + public byte getColor() { + return -7; + } + + @Override + public cElementalDefinitionStackMap getSubParticles() { + return quarkStacks; + } + + @Override + public cElementalDecay[] getNaturalDecayInstant() { + cElementalDefinitionStack[] quarkStacks = this.quarkStacks.values(); + if (amount == 2 && quarkStacks.length == 2 && quarkStacks[0].definition.getMass() == quarkStacks[1].definition.getMass() && quarkStacks[0].definition.getType() == -quarkStacks[1].definition.getType()) { + return cElementalDecay.noProduct; + } + ArrayList decaysInto = new ArrayList<>(); + for (cElementalDefinitionStack quarks : quarkStacks) { + if (quarks.definition.getType() == 1 || quarks.definition.getType() == -1) { + //covers both quarks and antiquarks + decaysInto.add(quarks); + } else { + //covers both quarks and antiquarks + decaysInto.add(new cElementalDefinitionStack(boson_Y__, 2)); + } + } + return new cElementalDecay[]{ + new cElementalDecay(0.75F, decaysInto.toArray(new cElementalDefinitionStack[0])), + eBosonDefinition.deadEnd + }; + } + + @Override + public cElementalDecay[] getEnergyInducedDecay(long energyLevel) { + cElementalDefinitionStack[] quarkStacks = this.quarkStacks.values(); + if (amount == 2 && quarkStacks.length == 2 && quarkStacks[0].definition.getMass() == quarkStacks[1].definition.getMass() && quarkStacks[0].definition.getType() == -quarkStacks[1].definition.getType()) { + return cElementalDecay.noProduct; + } + return new cElementalDecay[]{new cElementalDecay(0.75F, quarkStacks), eBosonDefinition.deadEnd}; //decay into quarks + } + + @Override + public float getEnergyDiffBetweenStates(long currentEnergyLevel, long newEnergyLevel) { + return iElementalDefinition.DEFAULT_ENERGY_REQUIREMENT *(newEnergyLevel-currentEnergyLevel); + } + + @Override + public boolean usesSpecialEnergeticDecayHandling() { + return false; + } + + @Override + public boolean usesMultipleDecayCalls(long energyLevel) { + return false; + } + + @Override + public boolean decayMakesEnergy(long energyLevel) { + return false; + } + + @Override + public boolean fusionMakesEnergy(long energyLevel) { + return false; + } + + @Override + public cElementalDecay[] getDecayArray() { + cElementalDefinitionStack[] quarkStacks = this.quarkStacks.values(); + if (amount == 2 && quarkStacks.length == 2 && quarkStacks[0].definition.getMass() == quarkStacks[1].definition.getMass() && quarkStacks[0].definition.getType() == -quarkStacks[1].definition.getType()) { + return cElementalDecay.noProduct; + } else if (amount != 3) { + return new cElementalDecay[]{new cElementalDecay(0.95F, quarkStacks), eBosonDefinition.deadEnd}; //decay into quarks + } else { + ArrayList newBaryon = new ArrayList<>(); + iElementalDefinition[] Particles = new iElementalDefinition[2]; + for (cElementalDefinitionStack quarks : quarkStacks) { + for (int i = 0; i < quarks.amount; i++) { + newBaryon.add((eQuarkDefinition) quarks.definition); + } + } + //remove last + eQuarkDefinition lastQuark = newBaryon.remove(2); + + if (Math.abs(lastQuark.getType()) > 1) { + cElementalDefinitionStack[] decay = lastQuark.getDecayArray()[1].outputStacks.values(); + newBaryon.add((eQuarkDefinition) decay[0].definition); + Particles[0] = decay[1].definition; + Particles[1] = decay[2].definition; + } else { + cElementalDefinitionStack[] decay = lastQuark.getDecayArray()[0].outputStacks.values(); + newBaryon.add((eQuarkDefinition) decay[0].definition); + Particles[0] = decay[1].definition; + Particles[1] = decay[2].definition; + } + + eQuarkDefinition[] contentOfBaryon = newBaryon.toArray(new eQuarkDefinition[3]); + + try { + return new cElementalDecay[]{ + new cElementalDecay(0.99F, new dHadronDefinition(false, contentOfBaryon), Particles[0], Particles[1]), + new cElementalDecay(0.001F, new dHadronDefinition(false, contentOfBaryon), Particles[0], Particles[1], boson_Y__), + eBosonDefinition.deadEnd}; + } catch (tElementalException e) { + if (DEBUG_MODE) { + e.printStackTrace(); + } + return new cElementalDecay[]{eBosonDefinition.deadEnd}; + } + } + } + + @Override + public float getMass() { + return mass; + } + + @Override + public int getCharge() { + return charge; + } + + @Override + public float getRawTimeSpan(long currentEnergy) { + return rawLifeTime; + } + + @Override + public boolean isTimeSpanHalfLife() { + return true; + } + + @Override + public byte getType() { + return type; + } + + //@Override + //public iElementalDefinition getAnti() { + // cElementalDefinitionStack[] stacks = this.quarkStacks.values(); + // cElementalDefinitionStack[] antiElements = new cElementalDefinitionStack[stacks.length]; + // for (int i = 0; i < antiElements.length; i++) { + // antiElements[i] = new cElementalDefinitionStack(stacks[i].definition.getAnti(), stacks[i].amount); + // } + // try { + // return new dHadronDefinition(false, antiElements); + // } catch (tElementalException e) { + // if (DEBUG_MODE) e.printStackTrace(); + // return null; + // } + //} + + @Override + public iElementalDefinition getAnti() { + cElementalMutableDefinitionStackMap anti = new cElementalMutableDefinitionStackMap(); + for (cElementalDefinitionStack stack : quarkStacks.values()) { + anti.putReplace(new cElementalDefinitionStack(stack.definition.getAnti(), stack.amount)); + } + try { + return new dHadronDefinition(anti.toImmutable_optimized_unsafeLeavesExposedElementalTree()); + } catch (tElementalException e) { + if (DEBUG_MODE) { + e.printStackTrace(); + } + return null; + } + } + + @Override + public aFluidDequantizationInfo someAmountIntoFluidStack() { + return null; + } + + @Override + public aItemDequantizationInfo someAmountIntoItemsStack() { + return null; + } + + @Override + public aOredictDequantizationInfo someAmountIntoOredictStack() { + return null; + } + + @Override + public NBTTagCompound toNBT() { + return getNbtTagCompound(nbtType, quarkStacks); + } + + public static dHadronDefinition fromNBT(NBTTagCompound nbt) { + cElementalDefinitionStack[] stacks = new cElementalDefinitionStack[nbt.getInteger("i")]; + for (int i = 0; i < stacks.length; i++) { + stacks[i] = cElementalDefinitionStack.fromNBT(nbt.getCompoundTag(Integer.toString(i))); + } + try { + return new dHadronDefinition(stacks); + } catch (tElementalException e) { + if (DEBUG_MODE) { + e.printStackTrace(); + } + return null; + } + } + + public static void run() { + try { + hadron_p = new dHadronDefinition(new cElementalDefinitionStackMap(eQuarkDefinition.quark_u.getStackForm(2), eQuarkDefinition.quark_d.getStackForm(1))); + protonMass = hadron_p.mass; + //redefine the proton with proper lifetime (the lifetime is based on mass comparison) + hadron_p = new dHadronDefinition(new cElementalDefinitionStackMap(eQuarkDefinition.quark_u.getStackForm(2), eQuarkDefinition.quark_d.getStackForm(1))); + hadron_p_ = (dHadronDefinition) hadron_p.getAnti(); + hadron_n = new dHadronDefinition(new cElementalDefinitionStackMap(eQuarkDefinition.quark_u.getStackForm(1), eQuarkDefinition.quark_d.getStackForm(2))); + neutronMass = hadron_n.mass; + //redefine the neutron with proper lifetime (the lifetime is based on mass comparison) + hadron_n = new dHadronDefinition(new cElementalDefinitionStackMap(eQuarkDefinition.quark_u.getStackForm(1), eQuarkDefinition.quark_d.getStackForm(2))); + hadron_n_ = (dHadronDefinition) hadron_n.getAnti(); + } catch (tElementalException e) { + if (DEBUG_MODE) { + e.printStackTrace(); + } + protonMass = -1; + neutronMass = -1; + } + hadron_p1 = new cElementalDefinitionStack(hadron_p, 1); + hadron_n1 = new cElementalDefinitionStack(hadron_n, 1); + hadron_p2 = new cElementalDefinitionStack(hadron_p, 2); + hadron_n2 = new cElementalDefinitionStack(hadron_n, 2); + hadron_p3 = new cElementalDefinitionStack(hadron_p, 3); + hadron_n3 = new cElementalDefinitionStack(hadron_n, 3); + hadron_p5 = new cElementalDefinitionStack(hadron_p, 5); + + try { + cElementalDefinition.addCreatorFromNBT(nbtType, dHadronDefinition.class.getMethod("fromNBT", NBTTagCompound.class),(byte)-64); + } catch (Exception e) { + if (DEBUG_MODE) { + e.printStackTrace(); + } + } + if(DEBUG_MODE) { + TecTech.LOGGER.info("Registered Elemental Matter Class: Hadron " + nbtType + ' ' + -64); + } + } + + public static void setTransformations(){ + //Added to atom map, but should be in its own + cElementalDefinitionStack neutrons=new cElementalDefinitionStack(hadron_n, 100000); + transformation.oredictDequantization.put(neutrons.definition,new aOredictDequantizationInfo(neutrons, dust, Materials.Neutronium,1)); + bTransformationInfo.oredictQuantization.put( + OreDictionary.getOreID(OrePrefixes.ingotHot.name()+Materials.Neutronium.mName), + new aOredictQuantizationInfo(OrePrefixes.ingotHot,Materials.Neutronium,1 ,neutrons) + ); + } + + @Override + public byte getClassType() { + return -64; + } + + public static byte getClassTypeStatic(){ + return -64; + } + + @Override + public int hashCode() { + return hash; + } + + @Override + public void addScanShortSymbols(ArrayList lines, int capabilities, long energyLevel) { + if(Util.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(Util.areBitsSet(SCAN_GET_CLASS_TYPE, capabilities)) { + lines.add("CLASS = " + nbtType + ' ' + getClassType()); + } + if(Util.areBitsSet(SCAN_GET_NOMENCLATURE|SCAN_GET_CHARGE|SCAN_GET_MASS|SCAN_GET_TIMESPAN_INFO, capabilities)) { + lines.add("NAME = "+getSimpleName()); + //lines.add("SYMBOL = "+getSymbol()); + } + if(Util.areBitsSet(SCAN_GET_CHARGE,capabilities)) { + lines.add("CHARGE = " + getCharge() / 3f + " e"); + } + if(Util.areBitsSet(SCAN_GET_COLOR,capabilities)) { + lines.add(getColor() < 0 ? "COLORLESS" : "CARRIES COLOR"); + } + if(Util.areBitsSet(SCAN_GET_MASS,capabilities)) { + lines.add("MASS = " + getMass() + " eV/c\u00b2"); + } + if(Util.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/hadron/dHadronDefinition.java b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/complex/hadron/dHadronDefinition.java deleted file mode 100644 index 1d617fcdb9..0000000000 --- a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/complex/hadron/dHadronDefinition.java +++ /dev/null @@ -1,463 +0,0 @@ -package com.github.technus.tectech.mechanics.elementalMatter.definitions.complex.hadron; - -import com.github.technus.tectech.TecTech; -import com.github.technus.tectech.Util; -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.*; -import com.github.technus.tectech.mechanics.elementalMatter.definitions.primitive.eBosonDefinition; -import com.github.technus.tectech.mechanics.elementalMatter.definitions.primitive.eQuarkDefinition; -import gregtech.api.enums.Materials; -import gregtech.api.enums.OrePrefixes; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraftforge.oredict.OreDictionary; - -import java.util.ArrayList; - -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.complex.atom.dAtomDefinition.transformation; -import static com.github.technus.tectech.mechanics.elementalMatter.definitions.primitive.eBosonDefinition.boson_Y__; -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 17.11.2016. - */ -public final class dHadronDefinition extends cElementalDefinition {//TODO Optimize map i/o - private final int hash; - - private static final byte nbtType = (byte) 'h'; - //Helpers - public static dHadronDefinition hadron_p, hadron_n, hadron_p_, hadron_n_; - public static cElementalDefinitionStack hadron_p1, hadron_n1, hadron_p2, hadron_n2, hadron_p3, hadron_n3, hadron_p5; - private static float protonMass = 0F; - private static float neutronMass = 0F; - private static final float actualProtonMass=938272081.3f; - private static final float actualNeutronMass=939565413.3f; - - //float-mass in eV/c^2 - public final float mass; - //int -electric charge in 1/3rds of electron charge for optimization - public final int charge; - public final float rawLifeTime; - public final byte amount; - //generation max present inside - minus if contains any antiquark - public final byte type; - //private final FluidStack fluidThing; - //private final ItemStack itemThing; - - private final cElementalDefinitionStackMap quarkStacks; - - @Deprecated - public dHadronDefinition(eQuarkDefinition... quarks) throws tElementalException { - this(true, new cElementalDefinitionStackMap(quarks)); - } - - @Deprecated - private dHadronDefinition(boolean check, eQuarkDefinition... quarks) throws tElementalException { - this(check, new cElementalDefinitionStackMap(quarks)); - } - - public dHadronDefinition(cElementalDefinitionStack... quarks) throws tElementalException { - this(true, new cElementalDefinitionStackMap(quarks)); - } - - private dHadronDefinition(boolean check, cElementalDefinitionStack... quarks) throws tElementalException { - this(check, new cElementalDefinitionStackMap(quarks)); - } - - public dHadronDefinition(cElementalDefinitionStackMap quarks) throws tElementalException { - this(true, quarks); - } - - private dHadronDefinition(boolean check, cElementalDefinitionStackMap quarks) throws tElementalException { - if (check && !canTheyBeTogether(quarks)) { - throw new tElementalException("Hadron Definition error"); - } - quarkStacks = quarks; - - byte amount = 0; - int charge = 0; - int type = 0; - boolean containsAnti = false; - float mass = 0; - for (cElementalDefinitionStack quarkStack : quarkStacks.values()) { - amount += quarkStack.amount; - mass += quarkStack.getMass(); - charge += quarkStack.getCharge(); - type = Math.max(Math.abs(quarkStack.definition.getType()), type); - if (quarkStack.definition.getType() < 0) { - containsAnti = true; - } - } - this.amount = amount; - this.charge = charge; - this.type = containsAnti ? (byte) -type : (byte) type; - int mult = this.amount * this.amount * (this.amount - 1); - mass = mass * 5.543F * (float) mult;//yes it becomes heavier - - if (mass == protonMass && this.amount == 3) { - rawLifeTime = iElementalDefinition.STABLE_RAW_LIFE_TIME; - mass=actualProtonMass; - } else if (mass == neutronMass && this.amount == 3) { - rawLifeTime = 882F; - mass=actualNeutronMass; - } else { - if (this.amount == 3) { - rawLifeTime = 1.34F / mass * (float) Math.pow(9.81, charge); - } else if (this.amount == 2) { - rawLifeTime = 1.21F / mass / (float) Math.pow(19.80, charge); - } else { - rawLifeTime = 1.21F / mass / (float) Math.pow(9.80, charge); - } - } - this.mass=mass; - hash=super.hashCode(); - } - - //public but u can just try{}catch(){} the constructor it still calls this method - private static boolean canTheyBeTogether(cElementalDefinitionStackMap stacks) { - long amount = 0; - for (cElementalDefinitionStack quarks : stacks.values()) { - if (!(quarks.definition instanceof eQuarkDefinition)) { - return false; - } - amount += quarks.amount; - } - return amount >= 2 && amount <= 12; - } - - @Override - public String getName() { - StringBuilder name= new StringBuilder(getSimpleName()); - name.append(':'); - for (cElementalDefinitionStack quark : quarkStacks.values()) { - name.append(' ').append(quark.definition.getSymbol()).append(quark.amount); - } - return name.toString(); - } - - private String getSimpleName() { - switch (amount) { - case 2: - return "Meson"; - case 3: - return "Baryon"; - case 4: - return "Tetraquark"; - case 5: - return "Pentaquark"; - case 6: - return "Hexaquark"; - default: - return "Hadron"; - } - } - - @Override - public String getSymbol() { - StringBuilder symbol = new StringBuilder(8); - for (cElementalDefinitionStack quark : quarkStacks.values()) { - for (int i = 0; i < quark.amount; i++) { - symbol.append(quark.definition.getSymbol()); - } - } - return symbol.toString(); - } - - @Override - public byte getColor() { - return -7; - } - - @Override - public cElementalDefinitionStackMap getSubParticles() { - return quarkStacks; - } - - @Override - public cElementalDecay[] getNaturalDecayInstant() { - cElementalDefinitionStack[] quarkStacks = this.quarkStacks.values(); - if (amount == 2 && quarkStacks.length == 2 && quarkStacks[0].definition.getMass() == quarkStacks[1].definition.getMass() && quarkStacks[0].definition.getType() == -quarkStacks[1].definition.getType()) { - return cElementalDecay.noProduct; - } - ArrayList decaysInto = new ArrayList<>(); - for (cElementalDefinitionStack quarks : quarkStacks) { - if (quarks.definition.getType() == 1 || quarks.definition.getType() == -1) { - //covers both quarks and antiquarks - decaysInto.add(quarks); - } else { - //covers both quarks and antiquarks - decaysInto.add(new cElementalDefinitionStack(boson_Y__, 2)); - } - } - return new cElementalDecay[]{ - new cElementalDecay(0.75F, decaysInto.toArray(new cElementalDefinitionStack[0])), - eBosonDefinition.deadEnd - }; - } - - @Override - public cElementalDecay[] getEnergyInducedDecay(long energyLevel) { - cElementalDefinitionStack[] quarkStacks = this.quarkStacks.values(); - if (amount == 2 && quarkStacks.length == 2 && quarkStacks[0].definition.getMass() == quarkStacks[1].definition.getMass() && quarkStacks[0].definition.getType() == -quarkStacks[1].definition.getType()) { - return cElementalDecay.noProduct; - } - return new cElementalDecay[]{new cElementalDecay(0.75F, quarkStacks), eBosonDefinition.deadEnd}; //decay into quarks - } - - @Override - public float getEnergyDiffBetweenStates(long currentEnergyLevel, long newEnergyLevel) { - return iElementalDefinition.DEFAULT_ENERGY_REQUIREMENT *(newEnergyLevel-currentEnergyLevel); - } - - @Override - public boolean usesSpecialEnergeticDecayHandling() { - return false; - } - - @Override - public boolean usesMultipleDecayCalls(long energyLevel) { - return false; - } - - @Override - public boolean decayMakesEnergy(long energyLevel) { - return false; - } - - @Override - public boolean fusionMakesEnergy(long energyLevel) { - return false; - } - - @Override - public cElementalDecay[] getDecayArray() { - cElementalDefinitionStack[] quarkStacks = this.quarkStacks.values(); - if (amount == 2 && quarkStacks.length == 2 && quarkStacks[0].definition.getMass() == quarkStacks[1].definition.getMass() && quarkStacks[0].definition.getType() == -quarkStacks[1].definition.getType()) { - return cElementalDecay.noProduct; - } else if (amount != 3) { - return new cElementalDecay[]{new cElementalDecay(0.95F, quarkStacks), eBosonDefinition.deadEnd}; //decay into quarks - } else { - ArrayList newBaryon = new ArrayList<>(); - iElementalDefinition[] Particles = new iElementalDefinition[2]; - for (cElementalDefinitionStack quarks : quarkStacks) { - for (int i = 0; i < quarks.amount; i++) { - newBaryon.add((eQuarkDefinition) quarks.definition); - } - } - //remove last - eQuarkDefinition lastQuark = newBaryon.remove(2); - - if (Math.abs(lastQuark.getType()) > 1) { - cElementalDefinitionStack[] decay = lastQuark.getDecayArray()[1].outputStacks.values(); - newBaryon.add((eQuarkDefinition) decay[0].definition); - Particles[0] = decay[1].definition; - Particles[1] = decay[2].definition; - } else { - cElementalDefinitionStack[] decay = lastQuark.getDecayArray()[0].outputStacks.values(); - newBaryon.add((eQuarkDefinition) decay[0].definition); - Particles[0] = decay[1].definition; - Particles[1] = decay[2].definition; - } - - eQuarkDefinition[] contentOfBaryon = newBaryon.toArray(new eQuarkDefinition[3]); - - try { - return new cElementalDecay[]{ - new cElementalDecay(0.99F, new dHadronDefinition(false, contentOfBaryon), Particles[0], Particles[1]), - new cElementalDecay(0.001F, new dHadronDefinition(false, contentOfBaryon), Particles[0], Particles[1], boson_Y__), - eBosonDefinition.deadEnd}; - } catch (tElementalException e) { - if (DEBUG_MODE) { - e.printStackTrace(); - } - return new cElementalDecay[]{eBosonDefinition.deadEnd}; - } - } - } - - @Override - public float getMass() { - return mass; - } - - @Override - public int getCharge() { - return charge; - } - - @Override - public float getRawTimeSpan(long currentEnergy) { - return rawLifeTime; - } - - @Override - public boolean isTimeSpanHalfLife() { - return true; - } - - @Override - public byte getType() { - return type; - } - - //@Override - //public iElementalDefinition getAnti() { - // cElementalDefinitionStack[] stacks = this.quarkStacks.values(); - // cElementalDefinitionStack[] antiElements = new cElementalDefinitionStack[stacks.length]; - // for (int i = 0; i < antiElements.length; i++) { - // antiElements[i] = new cElementalDefinitionStack(stacks[i].definition.getAnti(), stacks[i].amount); - // } - // try { - // return new dHadronDefinition(false, antiElements); - // } catch (tElementalException e) { - // if (DEBUG_MODE) e.printStackTrace(); - // return null; - // } - //} - - @Override - public iElementalDefinition getAnti() { - cElementalMutableDefinitionStackMap anti = new cElementalMutableDefinitionStackMap(); - for (cElementalDefinitionStack stack : quarkStacks.values()) { - anti.putReplace(new cElementalDefinitionStack(stack.definition.getAnti(), stack.amount)); - } - try { - return new dHadronDefinition(anti.toImmutable_optimized_unsafeLeavesExposedElementalTree()); - } catch (tElementalException e) { - if (DEBUG_MODE) { - e.printStackTrace(); - } - return null; - } - } - - @Override - public aFluidDequantizationInfo someAmountIntoFluidStack() { - return null; - } - - @Override - public aItemDequantizationInfo someAmountIntoItemsStack() { - return null; - } - - @Override - public aOredictDequantizationInfo someAmountIntoOredictStack() { - return null; - } - - @Override - public NBTTagCompound toNBT() { - return getNbtTagCompound(nbtType, quarkStacks); - } - - public static dHadronDefinition fromNBT(NBTTagCompound nbt) { - cElementalDefinitionStack[] stacks = new cElementalDefinitionStack[nbt.getInteger("i")]; - for (int i = 0; i < stacks.length; i++) { - stacks[i] = cElementalDefinitionStack.fromNBT(nbt.getCompoundTag(Integer.toString(i))); - } - try { - return new dHadronDefinition(stacks); - } catch (tElementalException e) { - if (DEBUG_MODE) { - e.printStackTrace(); - } - return null; - } - } - - public static void run() { - try { - hadron_p = new dHadronDefinition(new cElementalDefinitionStackMap(eQuarkDefinition.quark_u.getStackForm(2), eQuarkDefinition.quark_d.getStackForm(1))); - protonMass = hadron_p.mass; - //redefine the proton with proper lifetime (the lifetime is based on mass comparison) - hadron_p = new dHadronDefinition(new cElementalDefinitionStackMap(eQuarkDefinition.quark_u.getStackForm(2), eQuarkDefinition.quark_d.getStackForm(1))); - hadron_p_ = (dHadronDefinition) hadron_p.getAnti(); - hadron_n = new dHadronDefinition(new cElementalDefinitionStackMap(eQuarkDefinition.quark_u.getStackForm(1), eQuarkDefinition.quark_d.getStackForm(2))); - neutronMass = hadron_n.mass; - //redefine the neutron with proper lifetime (the lifetime is based on mass comparison) - hadron_n = new dHadronDefinition(new cElementalDefinitionStackMap(eQuarkDefinition.quark_u.getStackForm(1), eQuarkDefinition.quark_d.getStackForm(2))); - hadron_n_ = (dHadronDefinition) hadron_n.getAnti(); - } catch (tElementalException e) { - if (DEBUG_MODE) { - e.printStackTrace(); - } - protonMass = -1; - neutronMass = -1; - } - hadron_p1 = new cElementalDefinitionStack(hadron_p, 1); - hadron_n1 = new cElementalDefinitionStack(hadron_n, 1); - hadron_p2 = new cElementalDefinitionStack(hadron_p, 2); - hadron_n2 = new cElementalDefinitionStack(hadron_n, 2); - hadron_p3 = new cElementalDefinitionStack(hadron_p, 3); - hadron_n3 = new cElementalDefinitionStack(hadron_n, 3); - hadron_p5 = new cElementalDefinitionStack(hadron_p, 5); - - try { - cElementalDefinition.addCreatorFromNBT(nbtType, dHadronDefinition.class.getMethod("fromNBT", NBTTagCompound.class),(byte)-64); - } catch (Exception e) { - if (DEBUG_MODE) { - e.printStackTrace(); - } - } - if(DEBUG_MODE) { - TecTech.LOGGER.info("Registered Elemental Matter Class: Hadron " + nbtType + ' ' + -64); - } - } - - public static void setTransformations(){ - //Added to atom map, but should be in its own - cElementalDefinitionStack neutrons=new cElementalDefinitionStack(hadron_n, 100000); - transformation.oredictDequantization.put(neutrons.definition,new aOredictDequantizationInfo(neutrons, dust, Materials.Neutronium,1)); - bTransformationInfo.oredictQuantization.put( - OreDictionary.getOreID(OrePrefixes.ingotHot.name()+Materials.Neutronium.mName), - new aOredictQuantizationInfo(OrePrefixes.ingotHot,Materials.Neutronium,1 ,neutrons) - ); - } - - @Override - public byte getClassType() { - return -64; - } - - public static byte getClassTypeStatic(){ - return -64; - } - - @Override - public int hashCode() { - return hash; - } - - @Override - public void addScanResults(ArrayList lines, int capabilities, long energyLevel) { - if(Util.areBitsSet(SCAN_GET_CLASS_TYPE, capabilities)) { - lines.add("CLASS = " + nbtType + ' ' + getClassType()); - } - if(Util.areBitsSet(SCAN_GET_NOMENCLATURE|SCAN_GET_CHARGE|SCAN_GET_MASS|SCAN_GET_TIMESPAN_INFO, capabilities)) { - lines.add("NAME = "+getSimpleName()); - //lines.add("SYMBOL = "+getSymbol()); - } - if(Util.areBitsSet(SCAN_GET_CHARGE,capabilities)) { - lines.add("CHARGE = " + getCharge() / 3f + " e"); - } - if(Util.areBitsSet(SCAN_GET_COLOR,capabilities)) { - lines.add(getColor() < 0 ? "COLORLESS" : "CARRIES COLOR"); - } - if(Util.areBitsSet(SCAN_GET_MASS,capabilities)) { - lines.add("MASS = " + getMass() + " eV/c\u00b2"); - } - if(Util.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/iaeaNuclide.java b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/complex/iaeaNuclide.java new file mode 100644 index 0000000000..8b54bdd306 --- /dev/null +++ b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/complex/iaeaNuclide.java @@ -0,0 +1,288 @@ +package com.github.technus.tectech.mechanics.elementalMatter.definitions.complex; + +import com.github.technus.tectech.Util; + +import java.io.BufferedReader; +import java.io.InputStreamReader; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; +import java.util.TreeMap; + +import static com.github.technus.tectech.mechanics.elementalMatter.core.templates.iElementalDefinition.STABLE_RAW_LIFE_TIME; + +public final class iaeaNuclide { + public static final double AMU_TO_EV_DIV_C_C=9.31494061E08D,MICRO_AMU_TO_EV_DIV_C_C=9.31494061E02D; + + //Nuclide T1/2 T1/2 [s] Decay Modes ? Q Q?- Q? QEC Q?- n Sn Sp Binding/A Atomic Mass Mass Excess Discovery + //Abund. [mole fract.] BR [%] [?N] [barn] [keV] [keV] [keV] [keV] [keV] [keV] [keV] [? AMU] [keV] + + //Z,N,symb,radius, unc, energy, unc, jp, half-life operator, half_life, unc,unit, half_life [s], unc, decay, decay %, unc, decay, decay %, unc, decay, decay %, unc,isospin,magn. dipole, unc, elect. quad , unc,Qb-,unc,Qb- n,unc,Qa, unc, Qec, unc,Sn,unc, Sp,unc,Binding/A,unc,atomic mass, unc, mass excess,unc, + //Z,N,symbol,energy , unc, jp,half-life operator, half_life, unc,unit, half_life [s], unc, decay, decay %, unc, decay, decay %, unc, decay, decay %, unc,isospin,magn. dipole, unc, elect. quadrupole , unc, + private static final HashMap NUCLIDES=new HashMap<>(); + + public static void run(){ + String line=""; + + try { + BufferedReader reader = new BufferedReader(new InputStreamReader(iaeaNuclide.class.getResourceAsStream("nuclides.csv"))); + ArrayList blockOfData=new ArrayList<>(4); + while((line=reader.readLine())!=null) { + String[] split= Util.splitButDifferent(line,","); + if(split.length!=19) { + throw new Error("Invalid count (" + split.length + ") of separators in IAEA nuclides database " + line); + } + if(!split[1].isEmpty() && !blockOfData.isEmpty()) { + new iaeaNuclide(blockOfData.toArray(new String[blockOfData.size()][])); + blockOfData.clear(); + } + blockOfData.add(split); + } + if(!blockOfData.isEmpty()) { + new iaeaNuclide(blockOfData.toArray(new String[blockOfData.size()][])); + blockOfData.clear(); + } + reader.close(); + }catch (Exception e){ + System.out.println(line); + e.printStackTrace(); + } + + try { + BufferedReader reader = new BufferedReader(new InputStreamReader(iaeaNuclide.class.getResourceAsStream("nuclidesTable.csv"))); + while((line=reader.readLine())!=null) { + String[] split= Util.splitButDifferent(line,","); + if(split.length!=47) { + throw new Error("Invalid count (" + split.length + ") of separators in IAEA nuvlidesTable database " + line); + } + get(Integer.parseInt(split[0]),Integer.parseInt(split[1])).getMoreData(split); + } + reader.close(); + }catch (Exception e){ + System.out.println(line); + e.printStackTrace(); + } + + try { + BufferedReader reader = new BufferedReader(new InputStreamReader(iaeaNuclide.class.getResourceAsStream("energyLevels.csv"))); + while((line=reader.readLine())!=null) { + String[] split= Util.splitButDifferent(line,","); + if(split.length!=27) { + throw new Error("Invalid count (" + split.length + ") of separators in IAEA energyLevels database " + line); + } + new energeticState(split); + } + reader.close(); + }catch (Exception e){ + System.out.println(line); + e.printStackTrace(); + } + + for(iaeaNuclide nuclide:NUCLIDES.values()) { + nuclide.makeArrayOfEnergyStates(); + } + } + + public static iaeaNuclide get(int protons, int neutrons){ + return NUCLIDES.get((protons<<16)+neutrons); + } + + public final short N,Z; + public final float halfTime;//sec + public final float mass;//eV/c^2 + public final short discovery;//year + private TreeMap energeticStates; + public energeticState[] energeticStatesArray; + + + private iaeaNuclide(String[][] rows){ + N=Short.parseShort(rows[1][2]); + Z=Short.parseShort(rows[1][0]); + NUCLIDES.put(((int)Z <<16)+N,this); + + String[] parts = Util.splitButDifferent(rows[0][16], "|"); + double Mass=doubleOrNaN(parts[0],"mass"); + if(!Double.isNaN(Mass)) { + //System.out.println("Mass =\t" + Mass+"\t"+(N+Z)+"\t"+N+"\t"+Z+"\t"+(Mass/(N+Z))); + mass = (float)(Mass* MICRO_AMU_TO_EV_DIV_C_C); + } + else { + mass = Float.NaN; + } + + discovery=(short)doubleOrNaN(rows[0][18],"discovery"); + + if(rows[0][3].contains("STABLE")){ + halfTime = STABLE_RAW_LIFE_TIME; + }else{ + parts = Util.splitButDifferent(rows[0][4], "|"); + halfTime = (float)doubleOrNaN(parts[0],"half life"); + } + } + + private void getMoreData(String[] cells){ + //if(DEBUG_MODE) { + // if (add(cells[14])) System.out.println(N + " " + Z); + // if (add(cells[17])) System.out.println(N + " " + Z); + // if (add(cells[20])) System.out.println(N + " " + Z); + //} + new energeticState(this, halfTime, getDecaysFixed(cells[14],doubleOrNaN(cells[15],"chance1"),cells[17],doubleOrNaN(cells[18],"chance1"),cells[20],doubleOrNaN(cells[21],"chance1"))); + } + + private static final energeticState[] empty=new energeticState[0]; + private void makeArrayOfEnergyStates(){ + if(energeticStates==null || energeticStates.isEmpty()) { + energeticStatesArray = empty; + } else { + energeticStatesArray = energeticStates.values().toArray(new energeticState[0]); + } + } + + private double doubleOrNaN(String s, String name){ + s=s.replaceAll("#",""); + if(!s.isEmpty()) { + try { + double value=Double.parseDouble(s); + if(Double.isNaN(value)) { + return Double.NaN; + } + return value != 0 ?value:Double.NaN; + } catch (Exception e) { + System.out.println("Invalid Value " + name + ' ' + N + ' ' + Z + ' ' + s); + e.printStackTrace(); + } + } + return Double.NaN; + } + + public static final class energeticState{ + public final float energy; + public final float Thalf; + public final iaeaDecay[] decaymodes; + + private energeticState(iaeaNuclide nuclide,float Thalf,iaeaDecay[] decaymodes){ + energy=0; + this.Thalf=Thalf; + this.decaymodes=decaymodes; + if(nuclide.energeticStates==null) { + nuclide.energeticStates = new TreeMap<>(); + } + nuclide.energeticStates.put(energy,this); + } + + private energeticState(String[] cells){ + iaeaNuclide nuclide= get((int)doubleOrNaN(cells[0],"protons"),(int)doubleOrNaN(cells[1],"neutrons")); + if(nuclide==null) { + throw new Error("Missing nuclide " + (int) doubleOrNaN(cells[0], "protons") + ' ' + (int) doubleOrNaN(cells[1], "neutrons")); + } + energy =(float) (doubleOrNaN(cells[3],"energy level",nuclide)*1000f);//to eV + if(energy<0) { + throw new Error("Invalid energy " + nuclide.N + ' ' + nuclide.Z + ' ' + cells[3]); + } + Thalf =(float) doubleOrNaN(cells[10],"half life",nuclide); + if(nuclide.energeticStates==null) { + new Exception("Should be initialized before doing this... "+ nuclide.N + ' ' +nuclide.Z).printStackTrace(); + nuclide.energeticStates = new TreeMap<>(); + } + nuclide.energeticStates.put(energy,this); + //if(DEBUG_MODE) { + // if (add(cells[12])) System.out.println(nuclide.N + " " + nuclide.Z); + // if (add(cells[15])) System.out.println(nuclide.N + " " + nuclide.Z); + // if (add(cells[18])) System.out.println(nuclide.N + " " + nuclide.Z); + //} + decaymodes = getDecaysFixed(cells[12],doubleOrNaN(cells[13],"chance 1",nuclide),cells[15],doubleOrNaN(cells[16],"chance 2",nuclide),cells[18],doubleOrNaN(cells[19],"chance 3",nuclide)); + } + + private double doubleOrNaN(String s, String name){ + return doubleOrNaN(s,name,null); + } + + private double doubleOrNaN(String s, String name, iaeaNuclide nuclide){ + s = s.replaceAll("#", ""); + if (!s.isEmpty()) { + try { + return Double.parseDouble(s); + } catch (Exception e) { + if(nuclide==null){ + System.out.println("Invalid Value " + name + ' ' + s); + }else { + System.out.println("Invalid Value " + name + ' ' + nuclide.N + ' ' + nuclide.Z + ' ' + s); + } + e.printStackTrace(); + } + } + return Double.NaN; + } + } + + private static HashSet decays=new HashSet<>(); + private static boolean add(String s){ + if(decays.add(s)){ + System.out.println(s); + return true; + } + return false; + } + + private static iaeaDecay[] getDecaysFixed(String decay1, double chance1,String decay2, double chance2,String decay3, double chance3){ + boolean do1,do2,do3; + do1= !decay1.isEmpty() && !Double.isNaN(chance1); + do2= !decay2.isEmpty() && !Double.isNaN(chance2); + do3= !decay3.isEmpty() && !Double.isNaN(chance3); + TreeMap decays=new TreeMap<>(); + if(do1 && do2 && chance1==100 && chance2==100 && chance3!=100){ + decays.put(1D, new iaeaDecay(1f, decay1)); + if(do3) { + chance3/=100d; + decays.put(chance3, new iaeaDecay((float) chance3, decay2)); + chance2=1d-chance3; + } + chance2/=2d; + decays.put(chance2, new iaeaDecay((float) chance2, decay2)); + }else if(do1 && chance1==100){ + decays.put(1D, new iaeaDecay(1f, decay1)); + if(do2) { + chance2/=100d; + decays.put(chance2, new iaeaDecay((float) chance2, decay2)); + } + if(do3) { + chance3 /= 100d; + if(do2) { + chance3 *= chance2; + } + decays.put(chance3, new iaeaDecay((float) chance3, decay3)); + } + }else{ + double normalization= (do1?chance1:0) + (do2?chance2:0) + (do3?chance3:0); + if(do1) { + chance1/=normalization; + decays.put(chance1, new iaeaDecay((float) chance1, decay1)); + } + if(do2) { + chance2/=normalization; + decays.put(chance2, new iaeaDecay((float) chance2, decay2)); + } + if(do3) { + chance3/=normalization; + decays.put(chance3, new iaeaDecay((float) chance3, decay3)); + } + if(do1||do2||do3) { + decays.put(1D, iaeaDecay.DEAD_END); + } + } + //if(DEBUG_MODE){ + // System.out.println("INVALID SUM?\t"+normalization+"\t"+decay1+"\t"+chance1+"\t"+decay2+"\t"+chance2+"\t"+decay3+"\t"+chance3); + //} + return decays.values().toArray(new iaeaDecay[0]); + } + + public static final class iaeaDecay{ + public final float chance; + public final String decayName; + public static final iaeaDecay DEAD_END=new iaeaDecay(1f,"DEAD_END"); + private iaeaDecay(float chance,String decayName){ + this.chance=chance; + this.decayName=decayName; + } + } +} 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 232beebfb6..720460d56b 100644 --- a/src/main/java/com/github/technus/tectech/proxy/ClientProxy.java +++ b/src/main/java/com/github/technus/tectech/proxy/ClientProxy.java @@ -9,6 +9,9 @@ import com.github.technus.tectech.thing.block.QuantumGlassBlock; import com.github.technus.tectech.thing.block.QuantumGlassRender; import com.github.technus.tectech.thing.block.QuantumStuffBlock; import com.github.technus.tectech.thing.block.QuantumStuffRender; +import com.github.technus.tectech.thing.item.DebugElementalInstanceContainer_EM; +import com.github.technus.tectech.thing.item.ElementalDefinitionContainer_EM; +import com.github.technus.tectech.thing.item.renderElemental.RenderElementalName; import cpw.mods.fml.client.FMLClientHandler; import cpw.mods.fml.client.registry.RenderingRegistry; import cpw.mods.fml.common.Loader; @@ -16,15 +19,14 @@ import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import net.minecraft.block.Block; import net.minecraft.client.Minecraft; import net.minecraft.client.entity.EntityClientPlayerMP; -import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.gui.GuiNewChat; import net.minecraft.client.particle.EntityFX; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.ChatComponentText; import net.minecraft.world.World; +import net.minecraftforge.client.MinecraftForgeClient; import net.minecraftforge.common.util.ForgeDirection; -import org.lwjgl.opengl.GL11; public class ClientProxy extends CommonProxy { @Override @@ -35,6 +37,9 @@ public class ClientProxy extends CommonProxy { QuantumStuffBlock.renderID = RenderingRegistry.getNextAvailableRenderId(); RenderingRegistry.registerBlockHandler(QuantumStuffBlock.renderID, new QuantumStuffRender()); + MinecraftForgeClient.registerItemRenderer(ElementalDefinitionContainer_EM.INSTANCE, RenderElementalName.INSTANCE); + MinecraftForgeClient.registerItemRenderer(DebugElementalInstanceContainer_EM.INSTANCE, RenderElementalName.INSTANCE); + if(Loader.isModLoaded("openmodularturrets")) { new TT_turret_loader().run(); } @@ -119,34 +124,6 @@ public class ClientProxy extends CommonProxy { return FMLClientHandler.instance().getClient().theWorld; } - @Override - public void renderUnicodeString(String str, int x, int y, int maxWidth, int color) { - Minecraft mc = Minecraft.getMinecraft(); - FontRenderer fontRenderer = mc.fontRenderer; - - boolean origFont = fontRenderer.getUnicodeFlag(); - - if (mc.gameSettings.guiScale == 3) { - fontRenderer.setUnicodeFlag(true); - float dist = 0.08F; - y--; - for (int cycle = 0; cycle < 2; cycle++) { - GL11.glTranslatef(-dist, 0F, 0F); - fontRenderer.drawSplitString(str, x, y, maxWidth, color); - GL11.glTranslatef(dist, -dist, 0F); - fontRenderer.drawSplitString(str, x, y, maxWidth, color); - GL11.glTranslatef(dist, 0F, 0F); - fontRenderer.drawSplitString(str, x, y, maxWidth, color); - GL11.glTranslatef(-dist, dist, 0F); - - dist = -dist; - } - fontRenderer.setUnicodeFlag(origFont); - } else { - fontRenderer.drawSplitString(str, x, y, maxWidth, color); - } - } - @Override public void printInchat(String... strings) { GuiNewChat chat = Minecraft.getMinecraft().ingameGUI.getChatGUI(); diff --git a/src/main/java/com/github/technus/tectech/proxy/CommonProxy.java b/src/main/java/com/github/technus/tectech/proxy/CommonProxy.java index 296002b527..955b664bd1 100644 --- a/src/main/java/com/github/technus/tectech/proxy/CommonProxy.java +++ b/src/main/java/com/github/technus/tectech/proxy/CommonProxy.java @@ -34,13 +34,6 @@ public class CommonProxy implements IGuiHandler { return null; } - public void renderUnicodeString(String str, int x, int y, int maxWidth, int color) { - } - - public void setCustomRenderer() {} - - public void setCustomRenderers() {} - public void broadcast(String str) { MinecraftServer.getServer().getConfigurationManager().sendChatMsg(new ChatComponentText(str)); } 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 1f68163238..ab6f06497e 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 @@ -1,16 +1,18 @@ package com.github.technus.tectech.thing.item; import com.github.technus.tectech.CommonValues; +import com.github.technus.tectech.font.TecTechFontRender; import com.github.technus.tectech.Util; import com.github.technus.tectech.mechanics.elementalMatter.core.cElementalInstanceStackMap; import com.github.technus.tectech.mechanics.elementalMatter.core.iElementalInstanceContainer; import com.github.technus.tectech.mechanics.elementalMatter.core.stacks.cElementalInstanceStack; import com.github.technus.tectech.mechanics.elementalMatter.core.tElementalException; import com.github.technus.tectech.mechanics.elementalMatter.core.templates.iElementalDefinition; -import com.github.technus.tectech.mechanics.elementalMatter.core.transformations.bTransformationInfo; +import com.github.technus.tectech.thing.item.renderElemental.IElementalItem; import cpw.mods.fml.common.registry.GameRegistry; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import net.minecraft.client.gui.FontRenderer; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; @@ -23,6 +25,7 @@ import net.minecraft.world.World; import java.util.Collections; import java.util.List; +import java.util.TreeSet; import static com.github.technus.tectech.Reference.MODID; import static com.github.technus.tectech.loader.TecTechConfig.DEBUG_MODE; @@ -30,7 +33,9 @@ import static com.github.technus.tectech.loader.TecTechConfig.DEBUG_MODE; /** * Created by Tec on 15.03.2017. */ -public final class DebugElementalInstanceContainer_EM extends Item { +public final class DebugElementalInstanceContainer_EM extends Item implements IElementalItem { + public static final TreeSet stacksRegistered=new TreeSet<>(); + public static DebugElementalInstanceContainer_EM INSTANCE; private DebugElementalInstanceContainer_EM() { @@ -60,11 +65,13 @@ public final class DebugElementalInstanceContainer_EM extends Item { } ((iElementalInstanceContainer) metaTE).purgeOverflow(); tNBT.removeTag("content"); + tNBT.removeTag("symbols"); tNBT.removeTag("info"); } else if (content.hasStacks()) { ((iElementalInstanceContainer) metaTE).purgeOverflow(); tNBT.setTag("info", content.getInfoNBT()); tNBT.setTag("content", content.toNBT()); + tNBT.setTag("symbols", content.getShortSymbolsNBT()); content.clear(); } return true; @@ -90,9 +97,11 @@ public final class DebugElementalInstanceContainer_EM extends Item { } tNBT.removeTag("content"); tNBT.removeTag("info"); + tNBT.removeTag("symbols"); } else if (content.hasStacks()) { tNBT.setTag("info", content.getInfoNBT()); tNBT.setTag("content", content.toNBT()); + tNBT.setTag("symbols", content.getShortSymbolsNBT()); content.clear(); } return aStack; @@ -125,10 +134,30 @@ public final class DebugElementalInstanceContainer_EM extends Item { ItemStack that = new ItemStack(this, 1); that.setTagCompound(new NBTTagCompound()); list.add(that); - for(iElementalDefinition defintion:bTransformationInfo.stacksRegistered){ + for(iElementalDefinition defintion:stacksRegistered){ list.add(setContent(new ItemStack(this).setStackDisplayName(defintion.getName()+" x"+1),new cElementalInstanceStackMap(new cElementalInstanceStack(defintion,1)))); list.add(setContent(new ItemStack(this).setStackDisplayName(defintion.getName()+" x"+144),new cElementalInstanceStackMap(new cElementalInstanceStack(defintion,144)))); list.add(setContent(new ItemStack(this).setStackDisplayName(defintion.getName()+" x"+1000),new cElementalInstanceStackMap(new cElementalInstanceStack(defintion,1000)))); } } + + @Override + public String getSymbol(ItemStack aStack, int index) { + try { + NBTTagCompound tNBT = aStack.getTagCompound(); + if (tNBT != null && tNBT.hasKey("symbols")) { + String[] strings=Util.infoFromNBT(tNBT.getCompoundTag("symbols")); + return strings[index%strings.length]; + } else { + return null; + } + } catch (Exception e) { + return "#!"; + } + } + + @Override + public FontRenderer getFontRenderer(ItemStack stack) { + return (FontRenderer) (Object) TecTechFontRender.INSTANCE; + } } diff --git a/src/main/java/com/github/technus/tectech/thing/item/ElementalDefinitionContainer_EM.java b/src/main/java/com/github/technus/tectech/thing/item/ElementalDefinitionContainer_EM.java index e774704f46..8de3d1540c 100644 --- a/src/main/java/com/github/technus/tectech/thing/item/ElementalDefinitionContainer_EM.java +++ b/src/main/java/com/github/technus/tectech/thing/item/ElementalDefinitionContainer_EM.java @@ -1,10 +1,13 @@ package com.github.technus.tectech.thing.item; import com.github.technus.tectech.CommonValues; +import com.github.technus.tectech.font.TecTechFontRender; import com.github.technus.tectech.Util; import com.github.technus.tectech.mechanics.elementalMatter.core.cElementalDefinitionStackMap; import com.github.technus.tectech.mechanics.elementalMatter.core.tElementalException; +import com.github.technus.tectech.thing.item.renderElemental.IElementalItem; import cpw.mods.fml.common.registry.GameRegistry; +import net.minecraft.client.gui.FontRenderer; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; @@ -20,7 +23,7 @@ import static com.github.technus.tectech.loader.TecTechConfig.DEBUG_MODE; /** * Created by Tec on 15.03.2017. */ -public final class ElementalDefinitionContainer_EM extends Item { +public final class ElementalDefinitionContainer_EM extends Item implements IElementalItem { public static ElementalDefinitionContainer_EM INSTANCE; private ElementalDefinitionContainer_EM() { @@ -49,6 +52,7 @@ public final class ElementalDefinitionContainer_EM extends Item { } tNBT.setTag("info", definitions.getInfoNBT()); tNBT.setTag("content", definitions.toNBT()); + tNBT.setTag("symbols",definitions.getShortSymbolsNBT()); return oldMap; } return null; @@ -91,6 +95,7 @@ public final class ElementalDefinitionContainer_EM extends Item { } tNBT.removeTag("info"); tNBT.removeTag("content"); + tNBT.removeTag("symbols"); return oldMap; } return null; @@ -123,4 +128,24 @@ public final class ElementalDefinitionContainer_EM extends Item { that.setTagCompound(new NBTTagCompound()); list.add(that); } + + @Override + public String getSymbol(ItemStack aStack, int index) { + try { + NBTTagCompound tNBT = aStack.getTagCompound(); + if (tNBT != null && tNBT.hasKey("symbols")) { + String[] strings=Util.infoFromNBT(tNBT.getCompoundTag("symbols")); + return strings[index%strings.length]; + } else { + return null; + } + } catch (Exception e) { + return "#!"; + } + } + + @Override + public FontRenderer getFontRenderer(ItemStack stack) { + return (FontRenderer) (Object) TecTechFontRender.INSTANCE; + } } diff --git a/src/main/java/com/github/technus/tectech/thing/item/ElementalDefinitionScanStorage_EM.java b/src/main/java/com/github/technus/tectech/thing/item/ElementalDefinitionScanStorage_EM.java index 97371e2449..564209062a 100644 --- a/src/main/java/com/github/technus/tectech/thing/item/ElementalDefinitionScanStorage_EM.java +++ b/src/main/java/com/github/technus/tectech/thing/item/ElementalDefinitionScanStorage_EM.java @@ -2,13 +2,16 @@ package com.github.technus.tectech.thing.item; import com.github.technus.tectech.CommonValues; import com.github.technus.tectech.TecTech; +import com.github.technus.tectech.font.TecTechFontRender; import com.github.technus.tectech.Util; import com.github.technus.tectech.loader.gui.ModGuiHandler; import com.github.technus.tectech.mechanics.elementalMatter.core.cElementalInstanceStackMap; import com.github.technus.tectech.thing.CustomItemList; +import com.github.technus.tectech.thing.item.renderElemental.IElementalItem; import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.player.EntityPlayer; @@ -26,7 +29,7 @@ import static com.github.technus.tectech.Reference.MODID; /** * Created by Tec on 15.03.2017. */ -public final class ElementalDefinitionScanStorage_EM extends Item { +public final class ElementalDefinitionScanStorage_EM extends Item implements IElementalItem { public static ElementalDefinitionScanStorage_EM INSTANCE; public static IIcon offline, online; @@ -43,6 +46,7 @@ public final class ElementalDefinitionScanStorage_EM extends Item { containerItem.stackTagCompound = new NBTTagCompound(); } containerItem.stackTagCompound.setTag("elementalInfo", definitions.getScanInfoNBT(detailsOnDepthLevels)); + containerItem.stackTagCompound.setTag("symbols",definitions.getScanShortSymbolsNBT(detailsOnDepthLevels)); } } @@ -128,4 +132,24 @@ public final class ElementalDefinitionScanStorage_EM extends Item { } return itemStack; } + + @Override + public String getSymbol(ItemStack aStack, int index) { + try { + NBTTagCompound tNBT = aStack.getTagCompound(); + if (tNBT != null && tNBT.hasKey("symbols")) { + String[] strings=Util.infoFromNBT(tNBT.getCompoundTag("symbols")); + return strings[index%strings.length]; + } else { + return null; + } + } catch (Exception e) { + return "#!"; + } + } + + @Override + public FontRenderer getFontRenderer(ItemStack stack) { + return (FontRenderer) (Object) TecTechFontRender.INSTANCE; + } } diff --git a/src/main/java/com/github/technus/tectech/thing/item/gui/ScanDisplayScreen.java b/src/main/java/com/github/technus/tectech/thing/item/gui/ScanDisplayScreen.java index 7f4c9b64fe..20f59b56e2 100644 --- a/src/main/java/com/github/technus/tectech/thing/item/gui/ScanDisplayScreen.java +++ b/src/main/java/com/github/technus/tectech/thing/item/gui/ScanDisplayScreen.java @@ -1,6 +1,7 @@ package com.github.technus.tectech.thing.item.gui; import com.github.technus.tectech.TecTech; +import com.github.technus.tectech.font.TecTechFontRender; import com.github.technus.tectech.thing.item.ElementalDefinitionScanStorage_EM; import net.minecraft.client.Minecraft; import net.minecraft.client.audio.PositionedSoundRecord; @@ -57,33 +58,33 @@ public class ScanDisplayScreen extends GuiScreen { for(int i=firstLine-1, j=8;i>=0 && j!=0;i--,j/=2){ int equalPos=lines[i].indexOf('='); if(equalPos>=0){ - TecTech.proxy.renderUnicodeString(lines[i].substring(0,equalPos), textBaseX, textBaseY - 8 + j, 200, itick); - TecTech.proxy.renderUnicodeString(lines[i].substring(equalPos), textBaseXX, textBaseY - 8 + j, 200, itick); + TecTechFontRender.INSTANCE.drawSplitString(lines[i].substring(0,equalPos), textBaseX, textBaseY - 8 + j, 200, itick); + TecTechFontRender.INSTANCE.drawSplitString(lines[i].substring(equalPos), textBaseXX, textBaseY - 8 + j, 200, itick); }else { - TecTech.proxy.renderUnicodeString(lines[i], textBaseX, textBaseY - 8 + j, 200, itick); + TecTechFontRender.INSTANCE.drawSplitString(lines[i], textBaseX, textBaseY - 8 + j, 200, itick); } } for(int i = firstLine, j = 0; i=0){ - TecTech.proxy.renderUnicodeString(lines[i].substring(0,equalPos), textBaseX, textBaseY, 200, itick); - TecTech.proxy.renderUnicodeString(lines[i].substring(equalPos), textBaseXX, textBaseY, 200, itick); + TecTechFontRender.INSTANCE.drawSplitString(lines[i].substring(0,equalPos), textBaseX, textBaseY, 200, itick); + TecTechFontRender.INSTANCE.drawSplitString(lines[i].substring(equalPos), textBaseXX, textBaseY, 200, itick); }else { - TecTech.proxy.renderUnicodeString(lines[i], textBaseX, textBaseY, 200, itick); + TecTechFontRender.INSTANCE.drawSplitString(lines[i], textBaseX, textBaseY, 200, itick); } } for(int i = firstLine+ renderedLines, j = 8; i=0){ - TecTech.proxy.renderUnicodeString(lines[i].substring(0,equalPos), textBaseX, textBaseY + 17 - j, 200, itick); - TecTech.proxy.renderUnicodeString(lines[i].substring(equalPos), textBaseXX, textBaseY + 17 - j, 200, itick); + TecTechFontRender.INSTANCE.drawSplitString(lines[i].substring(0,equalPos), textBaseX, textBaseY + 17 - j, 200, itick); + TecTechFontRender.INSTANCE.drawSplitString(lines[i].substring(equalPos), textBaseXX, textBaseY + 17 - j, 200, itick); }else { - TecTech.proxy.renderUnicodeString(lines[i], textBaseX, textBaseY + 17 - j, 200, itick); + TecTechFontRender.INSTANCE.drawSplitString(lines[i], textBaseX, textBaseY + 17 - j, 200, itick); } } - TecTech.proxy.renderUnicodeString(Integer.toString(firstLine), textBaseX, baseY+146, 200, itick); - TecTech.proxy.renderUnicodeString(Integer.toString(lines.length), textBaseX, baseY+157, 200, itick); + TecTechFontRender.INSTANCE.drawSplitString(Integer.toString(firstLine), textBaseX, baseY+146, 200, itick); + TecTechFontRender.INSTANCE.drawSplitString(Integer.toString(lines.length), textBaseX, baseY+157, 200, itick); } @Override diff --git a/src/main/java/com/github/technus/tectech/thing/item/renderElemental/IElementalItem.java b/src/main/java/com/github/technus/tectech/thing/item/renderElemental/IElementalItem.java new file mode 100644 index 0000000000..ab68691eaa --- /dev/null +++ b/src/main/java/com/github/technus/tectech/thing/item/renderElemental/IElementalItem.java @@ -0,0 +1,7 @@ +package com.github.technus.tectech.thing.item.renderElemental; + +import net.minecraft.item.ItemStack; + +public interface IElementalItem { + String getSymbol(ItemStack stack,int index); +} diff --git a/src/main/java/com/github/technus/tectech/thing/item/renderElemental/RenderElementalName.java b/src/main/java/com/github/technus/tectech/thing/item/renderElemental/RenderElementalName.java new file mode 100644 index 0000000000..bfb1a188d8 --- /dev/null +++ b/src/main/java/com/github/technus/tectech/thing/item/renderElemental/RenderElementalName.java @@ -0,0 +1,74 @@ +package com.github.technus.tectech.thing.item.renderElemental; + +import com.github.technus.tectech.font.TecTechFontRender; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; +import net.minecraftforge.client.IItemRenderer; +import org.lwjgl.opengl.GL11; + +@SideOnly(Side.CLIENT) +public class RenderElementalName implements IItemRenderer { + public static final RenderElementalName INSTANCE=new RenderElementalName(); + + public boolean handleRenderType(final ItemStack itemStack, final IItemRenderer.ItemRenderType type) { + return type == ItemRenderType.INVENTORY; + } + + public boolean shouldUseRenderHelper(final IItemRenderer.ItemRenderType type, final ItemStack itemStack, final IItemRenderer.ItemRendererHelper helper) { + return false; + } + + public void renderItem(final IItemRenderer.ItemRenderType type, final ItemStack itemStack, final Object... data) { + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glEnable(GL11.GL_ALPHA_TEST); + GL11.glDisable(GL11.GL_BLEND); + GL11.glPushMatrix(); + Item item = itemStack.getItem(); + final Tessellator tessellator = Tessellator.instance; + for (int i = 0; i < item.getRenderPasses(itemStack.getItemDamage()); i++) { + IIcon icon = item.getIcon(itemStack, i); + tessellator.startDrawingQuads(); + tessellator.addVertexWithUV(0.0, 0.0, 0.0, (double)icon.getMinU(), (double)icon.getMinV()); + tessellator.addVertexWithUV(0.0, 16, 0.0, (double)icon.getMinU(), (double)icon.getMaxV()); + tessellator.addVertexWithUV(16, 16, 0.0, (double)icon.getMaxU(), (double)icon.getMaxV()); + tessellator.addVertexWithUV(16, 0.0, 0.0, (double)icon.getMaxU(), (double)icon.getMinV()); + tessellator.draw(); + //ItemRenderer.renderItemIn2D(Tessellator.instance, icon.getMaxU(), icon.getMinV(), icon.getMinU(), icon.getMaxV(), icon.getIconWidth(), icon.getIconHeight(), 0.0625f); + } + String sym=((IElementalItem)item).getSymbol(itemStack,(int)(System.currentTimeMillis()/1000)); + if(sym!=null){ + if(sym.length()>4){ + sym="..."; + } + + GL11.glPushMatrix(); + GL11.glTranslatef(.8F,.8F,0F); + TecTechFontRender.INSTANCE.drawSplitString(sym, 0, 0, 16, 0x222200); + GL11.glTranslatef(-1.6f,0,0); + TecTechFontRender.INSTANCE.drawSplitString(sym, 0, 0, 16, 0x222200); + GL11.glTranslatef(0,-1.6f,0); + TecTechFontRender.INSTANCE.drawSplitString(sym, 0, 0, 16, 0x222200); + GL11.glTranslatef(0,1.6f,0); + TecTechFontRender.INSTANCE.drawSplitString(sym, 0, 0, 16, 0x222200); + GL11.glPopMatrix(); + + GL11.glPushMatrix(); + GL11.glTranslatef(.4F,.4F,0F); + TecTechFontRender.INSTANCE.drawSplitString(sym, 0, 0, 16, 0x222200); + GL11.glTranslatef(-.8f,0,0); + TecTechFontRender.INSTANCE.drawSplitString(sym, 0, 0, 16, 0x222200); + GL11.glTranslatef(0,-.8f,0); + TecTechFontRender.INSTANCE.drawSplitString(sym, 0, 0, 16, 0x222200); + GL11.glTranslatef(0,.8f,0); + TecTechFontRender.INSTANCE.drawSplitString(sym, 0, 0, 16, 0x222200); + GL11.glPopMatrix(); + + TecTechFontRender.INSTANCE.drawSplitString(sym, 0, 0, 16, 0xffff00); + } + GL11.glPopMatrix(); + } +} diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/gui/GT_GUIContainer_Param.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/gui/GT_GUIContainer_Param.java index 015c3742cd..bf63eaa24f 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/gui/GT_GUIContainer_Param.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/gui/GT_GUIContainer_Param.java @@ -1,5 +1,6 @@ package com.github.technus.tectech.thing.metaTileEntity.hatch.gui; +import com.github.technus.tectech.font.TecTechFontRender; import com.github.technus.tectech.Util; import gregtech.api.gui.GT_GUIContainerMetaTile_Machine; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; @@ -8,7 +9,6 @@ import org.lwjgl.opengl.GL11; import java.util.Locale; -import static com.github.technus.tectech.TecTech.proxy; import static gregtech.api.enums.GT_Values.RES_PATH_GUI; public class GT_GUIContainer_Param extends GT_GUIContainerMetaTile_Machine { @@ -19,19 +19,19 @@ public class GT_GUIContainer_Param extends GT_GUIContainerMetaTile_Machine { @Override protected void drawGuiContainerForegroundLayer(int par1, int par2) { if (mContainer != null) { - proxy.renderUnicodeString("Parameters: " + ((GT_Container_Param) mContainer).param, 46, 7, 167, 0xffffff); + TecTechFontRender.INSTANCE.drawSplitString("Parameters: " + ((GT_Container_Param) mContainer).param, 46, 7, 167, 0xffffff); Locale locale= Locale.getDefault(); - proxy.renderUnicodeString("\u24EA\u2b07" + String.format(locale, "%+.5E", ((GT_Container_Param) mContainer).input0f), 46, 16, 167, 0x22ddff); - proxy.renderUnicodeString("\u2460\u2b07" + String.format(locale, "%+.5E", ((GT_Container_Param) mContainer).input1f), 46, 24, 167, 0x00ffff); - proxy.renderUnicodeString("\u24EA\u2b06" + String.format(locale, "%+.5E", ((GT_Container_Param) mContainer).value0f), 46, 33, 167, 0x00bbff); - proxy.renderUnicodeString("\u2460\u2b06" + String.format(locale, "%+.5E", ((GT_Container_Param) mContainer).value1f), 46, 41, 167, 0x0077ff); + TecTechFontRender.INSTANCE.drawSplitString("\u24EA\u2b07" + String.format(locale, "%+.5E", ((GT_Container_Param) mContainer).input0f), 46, 16, 167, 0x22ddff); + TecTechFontRender.INSTANCE.drawSplitString("\u2460\u2b07" + String.format(locale, "%+.5E", ((GT_Container_Param) mContainer).input1f), 46, 24, 167, 0x00ffff); + TecTechFontRender.INSTANCE.drawSplitString("\u24EA\u2b06" + String.format(locale, "%+.5E", ((GT_Container_Param) mContainer).value0f), 46, 33, 167, 0x00bbff); + TecTechFontRender.INSTANCE.drawSplitString("\u2460\u2b06" + String.format(locale, "%+.5E", ((GT_Container_Param) mContainer).value1f), 46, 41, 167, 0x0077ff); GL11.glPushMatrix(); GL11.glScalef(.5f,.5f,.5f); - proxy.renderUnicodeString("\u24EA\u2b06" + Util.longBitsToShortString(Double.doubleToLongBits(((GT_Container_Param) mContainer).value0f)), 92, 100, 334, 0x00bbff); - proxy.renderUnicodeString("\u2460\u2b06" + Util.longBitsToShortString(Double.doubleToLongBits(((GT_Container_Param) mContainer).value1f)), 92, 116, 334, 0x0077ff); + TecTechFontRender.INSTANCE.drawSplitString("\u24EA\u2b06" + Util.longBitsToShortString(Double.doubleToLongBits(((GT_Container_Param) mContainer).value0f)), 92, 100, 334, 0x00bbff); + TecTechFontRender.INSTANCE.drawSplitString("\u2460\u2b06" + Util.longBitsToShortString(Double.doubleToLongBits(((GT_Container_Param) mContainer).value1f)), 92, 116, 334, 0x0077ff); GL11.glPopMatrix(); } else { - proxy.renderUnicodeString("Parameters", 46, 7, 167, 0xffffff); + TecTechFontRender.INSTANCE.drawSplitString("Parameters", 46, 7, 167, 0xffffff); } } diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/gui/GT_GUIContainer_ParamAdv.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/gui/GT_GUIContainer_ParamAdv.java index 5e83290450..a682323f8c 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/gui/GT_GUIContainer_ParamAdv.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/gui/GT_GUIContainer_ParamAdv.java @@ -1,5 +1,6 @@ package com.github.technus.tectech.thing.metaTileEntity.hatch.gui; +import com.github.technus.tectech.font.TecTechFontRender; import com.github.technus.tectech.Util; import gregtech.api.gui.GT_GUIContainerMetaTile_Machine; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; @@ -8,7 +9,6 @@ import org.lwjgl.opengl.GL11; import java.util.Locale; -import static com.github.technus.tectech.TecTech.proxy; import static gregtech.api.enums.GT_Values.RES_PATH_GUI; public class GT_GUIContainer_ParamAdv extends GT_GUIContainerMetaTile_Machine { @@ -19,20 +19,20 @@ public class GT_GUIContainer_ParamAdv extends GT_GUIContainerMetaTile_Machine { @Override protected void drawGuiContainerForegroundLayer(int par1, int par2) { if (mContainer != null) { - proxy.renderUnicodeString("Parameters X: " + ((GT_Container_ParamAdv) mContainer).param, 46, 7, 167, 0xffffff); + TecTechFontRender.INSTANCE.drawSplitString("Parameters X: " + ((GT_Container_ParamAdv) mContainer).param, 46, 7, 167, 0xffffff); Locale locale = Locale.getDefault(); - proxy.renderUnicodeString("\u24EA\u2b07" + String.format(locale, "%+.5E", (((GT_Container_ParamAdv) mContainer).input0f)), 46, 16, 167, 0x22ddff); - proxy.renderUnicodeString("\u2460\u2b07" + String.format(locale, "%+.5E", (((GT_Container_ParamAdv) mContainer).input1f)), 46, 24, 167, 0x00ffff); - proxy.renderUnicodeString("\u24EA\u2b06" + String.format(locale, "%+.5E", (((GT_Container_ParamAdv) mContainer).value0f)), 46, 33, 167, 0x00bbff); - proxy.renderUnicodeString("\u2460\u2b06" + String.format(locale, "%+.5E", (((GT_Container_ParamAdv) mContainer).value1f)), 46, 41, 167, 0x0077ff); + TecTechFontRender.INSTANCE.drawSplitString("\u24EA\u2b07" + String.format(locale, "%+.5E", (((GT_Container_ParamAdv) mContainer).input0f)), 46, 16, 167, 0x22ddff); + TecTechFontRender.INSTANCE.drawSplitString("\u2460\u2b07" + String.format(locale, "%+.5E", (((GT_Container_ParamAdv) mContainer).input1f)), 46, 24, 167, 0x00ffff); + TecTechFontRender.INSTANCE.drawSplitString("\u24EA\u2b06" + String.format(locale, "%+.5E", (((GT_Container_ParamAdv) mContainer).value0f)), 46, 33, 167, 0x00bbff); + TecTechFontRender.INSTANCE.drawSplitString("\u2460\u2b06" + String.format(locale, "%+.5E", (((GT_Container_ParamAdv) mContainer).value1f)), 46, 41, 167, 0x0077ff); GL11.glPushMatrix(); GL11.glScalef(.5f,.5f,.5f); - proxy.renderUnicodeString("\u24EA\u2b06" + Util.longBitsToShortString(Double.doubleToLongBits(((GT_Container_ParamAdv) mContainer).value0f)), 92, 100, 334, 0x00bbff); - proxy.renderUnicodeString("\u2460\u2b06" + Util.longBitsToShortString(Double.doubleToLongBits(((GT_Container_ParamAdv) mContainer).value1f)), 92, 116, 334, 0x0077ff); + TecTechFontRender.INSTANCE.drawSplitString("\u24EA\u2b06" + Util.longBitsToShortString(Double.doubleToLongBits(((GT_Container_ParamAdv) mContainer).value0f)), 92, 100, 334, 0x00bbff); + TecTechFontRender.INSTANCE.drawSplitString("\u2460\u2b06" + Util.longBitsToShortString(Double.doubleToLongBits(((GT_Container_ParamAdv) mContainer).value1f)), 92, 116, 334, 0x0077ff); GL11.glPopMatrix(); - proxy.renderUnicodeString("Pointer " + Integer.toHexString(((GT_Container_ParamAdv) mContainer).pointer | 0x10000).substring(1), 46, 66, 167, 0x0033ff); + TecTechFontRender.INSTANCE.drawSplitString("Pointer " + Integer.toHexString(((GT_Container_ParamAdv) mContainer).pointer | 0x10000).substring(1), 46, 66, 167, 0x0033ff); } else { - proxy.renderUnicodeString("Parameters X", 46, 7, 167, 0xffffff); + TecTechFontRender.INSTANCE.drawSplitString("Parameters X", 46, 7, 167, 0xffffff); } } diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/gui/GT_GUIContainer_Uncertainty.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/gui/GT_GUIContainer_Uncertainty.java index e003774f13..7d7dc1b656 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/gui/GT_GUIContainer_Uncertainty.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/gui/GT_GUIContainer_Uncertainty.java @@ -1,12 +1,12 @@ package com.github.technus.tectech.thing.metaTileEntity.hatch.gui; import com.github.technus.tectech.TecTech; +import com.github.technus.tectech.font.TecTechFontRender; import gregtech.api.gui.GT_GUIContainerMetaTile_Machine; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import net.minecraft.entity.player.InventoryPlayer; import org.lwjgl.opengl.GL11; -import static com.github.technus.tectech.TecTech.proxy; import static gregtech.api.enums.GT_Values.RES_PATH_GUI; public class GT_GUIContainer_Uncertainty extends GT_GUIContainerMetaTile_Machine { @@ -16,11 +16,11 @@ public class GT_GUIContainer_Uncertainty extends GT_GUIContainerMetaTile_Machine @Override protected void drawGuiContainerForegroundLayer(int par1, int par2) { - proxy.renderUnicodeString("Schr\u00F6dinger", 46, 7, 167, 0xffffff); + TecTechFontRender.INSTANCE.drawSplitString("Schr\u00F6dinger", 46, 7, 167, 0xffffff); if (mContainer != null && ((GT_Container_Uncertainty) mContainer).status == 0) { - proxy.renderUnicodeString("Status: OK", 46, 16, 167, 0xffffff); + TecTechFontRender.INSTANCE.drawSplitString("Status: OK", 46, 16, 167, 0xffffff); } else { - proxy.renderUnicodeString("Status: NG", 46, 16, 167, 0xffffff); + TecTechFontRender.INSTANCE.drawSplitString("Status: NG", 46, 16, 167, 0xffffff); } } diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/gui/GT_GUIContainer_UncertaintyAdv.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/gui/GT_GUIContainer_UncertaintyAdv.java index b327424937..51eaf64ce4 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/gui/GT_GUIContainer_UncertaintyAdv.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/gui/GT_GUIContainer_UncertaintyAdv.java @@ -1,10 +1,10 @@ package com.github.technus.tectech.thing.metaTileEntity.hatch.gui; +import com.github.technus.tectech.font.TecTechFontRender; import gregtech.api.gui.GT_GUIContainerMetaTile_Machine; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import net.minecraft.entity.player.InventoryPlayer; -import static com.github.technus.tectech.TecTech.proxy; import static gregtech.api.enums.GT_Values.RES_PATH_GUI; import static org.lwjgl.opengl.GL11.*; @@ -17,11 +17,11 @@ public class GT_GUIContainer_UncertaintyAdv extends GT_GUIContainerMetaTile_Mach @Override protected void drawGuiContainerForegroundLayer(int par1, int par2) { - proxy.renderUnicodeString("Schr\u00F6dinger X", 46, 7, 167, 0xffffff); + TecTechFontRender.INSTANCE.drawSplitString("Schr\u00F6dinger X", 46, 7, 167, 0xffffff); if (mContainer != null && ((GT_Container_Uncertainty) mContainer).status == 0) { - proxy.renderUnicodeString("Status: OK", 46, 16, 167, 0xffffff); + TecTechFontRender.INSTANCE.drawSplitString("Status: OK", 46, 16, 167, 0xffffff); } else { - proxy.renderUnicodeString("Status: NG", 46, 16, 167, 0xffffff); + TecTechFontRender.INSTANCE.drawSplitString("Status: NG", 46, 16, 167, 0xffffff); } } diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_collider.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_collider.java index 166ab90ff1..1dc80606d9 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_collider.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_collider.java @@ -8,8 +8,8 @@ import com.github.technus.tectech.mechanics.elementalMatter.core.cElementalInsta import com.github.technus.tectech.mechanics.elementalMatter.core.cElementalMutableDefinitionStackMap; import com.github.technus.tectech.mechanics.elementalMatter.core.stacks.cElementalInstanceStack; 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.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.mechanics.elementalMatter.definitions.primitive.eQuarkDefinition; import com.github.technus.tectech.thing.block.QuantumGlassBlock; import com.github.technus.tectech.thing.casing.TT_Container_Casings; diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_dequantizer.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_dequantizer.java index d379502540..011105356a 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_dequantizer.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_dequantizer.java @@ -27,8 +27,8 @@ import java.util.ArrayList; import static com.github.technus.tectech.CommonValues.V; import static com.github.technus.tectech.Util.StructureBuilderExtreme; import static com.github.technus.tectech.mechanics.elementalMatter.core.templates.iElementalDefinition.STABLE_RAW_LIFE_TIME; -import static com.github.technus.tectech.mechanics.elementalMatter.definitions.complex.atom.dAtomDefinition.refMass; -import static com.github.technus.tectech.mechanics.elementalMatter.definitions.complex.atom.dAtomDefinition.refUnstableMass; +import static com.github.technus.tectech.mechanics.elementalMatter.definitions.complex.dAtomDefinition.refMass; +import static com.github.technus.tectech.mechanics.elementalMatter.definitions.complex.dAtomDefinition.refUnstableMass; import static com.github.technus.tectech.thing.casing.GT_Block_CasingsTT.textureOffset; import static com.github.technus.tectech.thing.casing.TT_Container_Casings.sBlockCasingsTT; diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_quantizer.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_quantizer.java index 1d3d40666f..c48c9e69de 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_quantizer.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_quantizer.java @@ -34,8 +34,8 @@ import static com.github.technus.tectech.Util.isInputEqual; import static com.github.technus.tectech.loader.TecTechConfig.DEBUG_MODE; import static com.github.technus.tectech.mechanics.elementalMatter.core.templates.iElementalDefinition.DEFAULT_ENERGY_LEVEL; import static com.github.technus.tectech.mechanics.elementalMatter.core.templates.iElementalDefinition.STABLE_RAW_LIFE_TIME; -import static com.github.technus.tectech.mechanics.elementalMatter.definitions.complex.atom.dAtomDefinition.refMass; -import static com.github.technus.tectech.mechanics.elementalMatter.definitions.complex.atom.dAtomDefinition.refUnstableMass; +import static com.github.technus.tectech.mechanics.elementalMatter.definitions.complex.dAtomDefinition.refMass; +import static com.github.technus.tectech.mechanics.elementalMatter.definitions.complex.dAtomDefinition.refUnstableMass; import static com.github.technus.tectech.thing.casing.GT_Block_CasingsTT.textureOffset; import static com.github.technus.tectech.thing.casing.TT_Container_Casings.sBlockCasingsTT; diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/em_machine/Behaviour_Centrifuge.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/em_machine/Behaviour_Centrifuge.java index 56f535f32a..ef8c0e7c3d 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/em_machine/Behaviour_Centrifuge.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/em_machine/Behaviour_Centrifuge.java @@ -3,7 +3,7 @@ package com.github.technus.tectech.thing.metaTileEntity.multi.em_machine; 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.atom.dAtomDefinition; +import com.github.technus.tectech.mechanics.elementalMatter.definitions.complex.dAtomDefinition; import com.github.technus.tectech.thing.metaTileEntity.multi.base.MultiblockControl; import com.github.technus.tectech.thing.metaTileEntity.multi.base.INameFunction; import com.github.technus.tectech.thing.metaTileEntity.multi.base.Parameters; diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/em_machine/Behaviour_ElectromagneticSeparator.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/em_machine/Behaviour_ElectromagneticSeparator.java index 6d95900af0..4b1c5f3cf6 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/em_machine/Behaviour_ElectromagneticSeparator.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/em_machine/Behaviour_ElectromagneticSeparator.java @@ -3,7 +3,7 @@ package com.github.technus.tectech.thing.metaTileEntity.multi.em_machine; 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.atom.dAtomDefinition; +import com.github.technus.tectech.mechanics.elementalMatter.definitions.complex.dAtomDefinition; import com.github.technus.tectech.thing.metaTileEntity.multi.base.MultiblockControl; import com.github.technus.tectech.thing.metaTileEntity.multi.base.INameFunction; import com.github.technus.tectech.thing.metaTileEntity.multi.base.Parameters; -- cgit From ac28fb230016aebbe6c303f28d211a40f94f86c4 Mon Sep 17 00:00:00 2001 From: Tec Date: Thu, 18 Jul 2019 09:47:47 +0200 Subject: Cleanup font render --- .../technus/tectech/font/TecTechFontRender.java | 32 ++++++++++++---------- 1 file changed, 17 insertions(+), 15 deletions(-) (limited to 'src/main/java/com') 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 f20bc28402..a7130bab90 100644 --- a/src/main/java/com/github/technus/tectech/font/TecTechFontRender.java +++ b/src/main/java/com/github/technus/tectech/font/TecTechFontRender.java @@ -21,34 +21,36 @@ public class TecTechFontRender extends FontRenderer { 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 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); - gameSettings = Minecraft.getMinecraft().gameSettings; - + static { + Method resetMethod,renderMethod; try { - reset =FontRenderer.class.getDeclaredMethod("resetStyles"); - render=FontRenderer.class.getDeclaredMethod("renderString", String.class, int.class, int.class, int.class, boolean.class); + resetMethod =FontRenderer.class.getDeclaredMethod("resetStyles"); + renderMethod=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); + 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); } } - reset.setAccessible(true); - render.setAccessible(true); + resetMethod.setAccessible(true); + renderMethod.setAccessible(true); + reset=resetMethod; + render=renderMethod; + } + + private TecTechFontRender() { + super(Minecraft.getMinecraft().gameSettings, new ResourceLocation("textures/font/ascii.png"), Minecraft.getMinecraft().renderEngine, false); + gameSettings = Minecraft.getMinecraft().gameSettings; } private void resetStyles2(){ -- cgit