diff options
author | basdxz <tudurap.com@gmail.com> | 2020-09-10 13:26:10 +0100 |
---|---|---|
committer | basdxz <tudurap.com@gmail.com> | 2020-09-10 13:26:10 +0100 |
commit | cac180287c2bc07f307e8ebdd37d2df3f782e3cd (patch) | |
tree | a209d6dfa6b857c6c8d598d3c38c2e26e04d8177 | |
parent | 23e8843b01ec3ff95123e6472656c61632c1c598 (diff) | |
parent | 4eb402956e5bc05c4954ae9812f2d60024677129 (diff) | |
download | GT5-Unofficial-cac180287c2bc07f307e8ebdd37d2df3f782e3cd.tar.gz GT5-Unofficial-cac180287c2bc07f307e8ebdd37d2df3f782e3cd.tar.bz2 GT5-Unofficial-cac180287c2bc07f307e8ebdd37d2df3f782e3cd.zip |
Merge remote-tracking branch 'origin/master' into BassAddons
50 files changed, 1270 insertions, 921 deletions
diff --git a/build.properties b/build.properties index ec613edcdf..be76171615 100644 --- a/build.properties +++ b/build.properties @@ -1,13 +1,13 @@ minecraft.version=1.7.10 forge.version=10.13.4.1614 -tectech.version=3.10.0 +tectech.version=4.8.3 ic2.version=2.2.790-experimental codechickenlib.version=1.1.3.140 codechickencore.version=1.0.7.47 nei.version=1.0.5.120 -gregtech.jenkinsbuild=620 -gregtech.version=5.09.33.50 +gregtech.jenkinsbuild=648 +gregtech.version=5.09.33.52 cofhcore.version=[1.7.10]3.1.4-329-dev yamcore.version=0.5.79 baubles.version=1.0.1.10 diff --git a/src/main/java/com/github/technus/tectech/compatibility/dreamcraft/DreamCraftRecipeLoader.java b/src/main/java/com/github/technus/tectech/compatibility/dreamcraft/DreamCraftRecipeLoader.java index 748888c5c9..df5c11e67b 100644 --- a/src/main/java/com/github/technus/tectech/compatibility/dreamcraft/DreamCraftRecipeLoader.java +++ b/src/main/java/com/github/technus/tectech/compatibility/dreamcraft/DreamCraftRecipeLoader.java @@ -1186,6 +1186,26 @@ public class DreamCraftRecipeLoader implements Runnable { Materials.Concrete.getMolten(73728L) }, getItemContainer("StargateFramePart").get(1L), 72000, 2000000); + //Deep Dark Portal + TT_recipeAdder.addResearchableAssemblylineRecipe(GT_ModHandler.getModItem("dreamcraft", "item.HeavyDutyPlateTier8", 1, 0), + 16777216, 2048, 2000000, 64, new Object[]{ + GT_ModHandler.getModItem("ExtraUtilities", "cobblestone_compressed", 1, 7), + GT_ModHandler.getModItem("IC2", "blockMachine2", 1, 0), + GT_OreDictUnificator.get(OrePrefixes.block, Materials.Infinity, 4L), + new Object[]{OrePrefixes.circuit.get(Materials.Nano), 1}, + new Object[]{OrePrefixes.circuit.get(Materials.Nano), 1}, + new Object[]{OrePrefixes.circuit.get(Materials.Nano), 1}, + new Object[]{OrePrefixes.circuit.get(Materials.Nano), 1}, + GT_ModHandler.getModItem("dreamcraft", "item.PicoWafer", 32, 0), + ItemList.Robot_Arm_UEV.get(4), + ItemList.Emitter_UEV.get(4), + ItemList.Sensor_UEV.get(4), + }, new FluidStack[]{ + new FluidStack(FluidRegistry.getFluid("oganesson"), 50000), + Materials.Infinity.getMolten(9216L), + Materials.Cheese.getMolten(232000L), + }, ItemList.Block_BedrockiumCompressed.get(1), 10000, 5000000); + //Batteries TT_recipeAdder.addResearchableAssemblylineRecipe(ItemList.Energy_Cluster.get(1L), 12000, 16, 100000, 3, new Object[]{ @@ -1218,7 +1238,7 @@ public class DreamCraftRecipeLoader implements Runnable { ItemList.Circuit_Wafer_UHPIC.get(64), ItemList.Circuit_Wafer_SoC2.get(32), ItemList.Circuit_Parts_DiodeASMD.get(64), - GT_OreDictUnificator.get(OrePrefixes.wireGt02, Materials.Neutronium, 64), + GT_OreDictUnificator.get(OrePrefixes.wireGt02, Materials.SuperconductorUHV, 64), }, new FluidStack[]{ Materials.SolderingAlloy.getMolten(3760), Materials.Naquadria.getMolten(9216), 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 ad24f72cb0..32db2caed9 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,6 +6,7 @@ import net.minecraftforge.fluids.FluidStack; import java.lang.reflect.Method; +import static com.github.technus.tectech.mechanics.elementalMatter.core.transformations.bTransformationInfo.AVOGADRO_CONSTANT_144; import static com.github.technus.tectech.mechanics.elementalMatter.definitions.complex.dAtomDefinition.*; public class GtppAtomLoader implements Runnable{ @@ -57,34 +58,34 @@ public class GtppAtomLoader implements Runnable{ } //endregion - transformation.addFluid(new cElementalDefinitionStack(getFirstStableIsotope(10), 144), getFluid("NEON",144)); + TRANSFORMATION_INFO.addFluid(new cElementalDefinitionStack(getFirstStableIsotope(10), AVOGADRO_CONSTANT_144), getFluid("NEON",144)); generate("GERMANIUM",true,true); - transformation.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(32), 144), OrePrefixes.dust, getUnlocalizedName("GERMANIUM"),1); - transformation.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(34), 144), OrePrefixes.dust, getUnlocalizedName("SELENIUM"),1); - transformation.addFluid(new cElementalDefinitionStack(getFirstStableIsotope(35), 144), getFluid("BROMINE",144)); - transformation.addFluid(new cElementalDefinitionStack(getFirstStableIsotope(36), 144), getFluid("KRYPTON",144)); - transformation.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(40), 144),OrePrefixes.dust, getUnlocalizedName("ZIRCONIUM"),1); - transformation.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(43), 144),OrePrefixes.dust, getUnlocalizedName("TECHNETIUM"),1); - transformation.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(44), 144),OrePrefixes.dust, getUnlocalizedName("RUTHENIUM"),1); - transformation.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(45), 144),OrePrefixes.dust, getUnlocalizedName("RHODIUM"),1); - transformation.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(53), 144),OrePrefixes.dust, getUnlocalizedName("IODINE"),1); - transformation.addFluid(new cElementalDefinitionStack(getFirstStableIsotope(54), 144),getFluid("XENON",144)); - transformation.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(72), 144),OrePrefixes.dust, getUnlocalizedName("HAFNIUM"),1); - transformation.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(75), 144),OrePrefixes.dust, getUnlocalizedName("RHENIUM"),1); - transformation.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(81), 144),OrePrefixes.dust, getUnlocalizedName("THALLIUM"),1); + TRANSFORMATION_INFO.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(32), AVOGADRO_CONSTANT_144), OrePrefixes.dust, getUnlocalizedName("GERMANIUM"),1); + TRANSFORMATION_INFO.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(34), AVOGADRO_CONSTANT_144), OrePrefixes.dust, getUnlocalizedName("SELENIUM"),1); + TRANSFORMATION_INFO.addFluid(new cElementalDefinitionStack(getFirstStableIsotope(35), AVOGADRO_CONSTANT_144), getFluid("BROMINE",144)); + TRANSFORMATION_INFO.addFluid(new cElementalDefinitionStack(getFirstStableIsotope(36), AVOGADRO_CONSTANT_144), getFluid("KRYPTON",144)); + TRANSFORMATION_INFO.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(40), AVOGADRO_CONSTANT_144),OrePrefixes.dust, getUnlocalizedName("ZIRCONIUM"),1); + TRANSFORMATION_INFO.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(43), AVOGADRO_CONSTANT_144),OrePrefixes.dust, getUnlocalizedName("TECHNETIUM"),1); + TRANSFORMATION_INFO.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(44), AVOGADRO_CONSTANT_144),OrePrefixes.dust, getUnlocalizedName("RUTHENIUM"),1); + TRANSFORMATION_INFO.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(45), AVOGADRO_CONSTANT_144),OrePrefixes.dust, getUnlocalizedName("RHODIUM"),1); + TRANSFORMATION_INFO.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(53), AVOGADRO_CONSTANT_144),OrePrefixes.dust, getUnlocalizedName("IODINE"),1); + TRANSFORMATION_INFO.addFluid(new cElementalDefinitionStack(getFirstStableIsotope(54), AVOGADRO_CONSTANT_144),getFluid("XENON",144)); + TRANSFORMATION_INFO.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(72), AVOGADRO_CONSTANT_144),OrePrefixes.dust, getUnlocalizedName("HAFNIUM"),1); + TRANSFORMATION_INFO.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(75), AVOGADRO_CONSTANT_144),OrePrefixes.dust, getUnlocalizedName("RHENIUM"),1); + TRANSFORMATION_INFO.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(81), AVOGADRO_CONSTANT_144),OrePrefixes.dust, getUnlocalizedName("THALLIUM"),1); - transformation.addOredict(new cElementalDefinitionStack(getBestUnstableIsotope(84),144),OrePrefixes.dust, getUnlocalizedName("POLONIUM"),1); - transformation.addOredict(new cElementalDefinitionStack(getBestUnstableIsotope(85),144),OrePrefixes.dust, getUnlocalizedName("ASTATINE"),1); - transformation.addOredict(new cElementalDefinitionStack(getBestUnstableIsotope(87),144),OrePrefixes.dust, getUnlocalizedName("FRANCIUM"),1); - transformation.addOredict(new cElementalDefinitionStack(getBestUnstableIsotope(88),144),OrePrefixes.dust, getUnlocalizedName("RADIUM"),1); - transformation.addOredict(new cElementalDefinitionStack(getBestUnstableIsotope(89),144),OrePrefixes.dust, getUnlocalizedName("ACTINIUM"),1); - transformation.addOredict(new cElementalDefinitionStack(getBestUnstableIsotope(91),144),OrePrefixes.dust, getUnlocalizedName("PROTACTINIUM"),1); - transformation.addOredict(new cElementalDefinitionStack(getBestUnstableIsotope(93),144),OrePrefixes.dust, getUnlocalizedName("NEPTUNIUM"),1); + TRANSFORMATION_INFO.addOredict(new cElementalDefinitionStack(getBestUnstableIsotope(84), AVOGADRO_CONSTANT_144),OrePrefixes.dust, getUnlocalizedName("POLONIUM"),1); + TRANSFORMATION_INFO.addOredict(new cElementalDefinitionStack(getBestUnstableIsotope(85), AVOGADRO_CONSTANT_144),OrePrefixes.dust, getUnlocalizedName("ASTATINE"),1); + TRANSFORMATION_INFO.addOredict(new cElementalDefinitionStack(getBestUnstableIsotope(87), AVOGADRO_CONSTANT_144),OrePrefixes.dust, getUnlocalizedName("FRANCIUM"),1); + TRANSFORMATION_INFO.addOredict(new cElementalDefinitionStack(getBestUnstableIsotope(88), AVOGADRO_CONSTANT_144),OrePrefixes.dust, getUnlocalizedName("RADIUM"),1); + TRANSFORMATION_INFO.addOredict(new cElementalDefinitionStack(getBestUnstableIsotope(89), AVOGADRO_CONSTANT_144),OrePrefixes.dust, getUnlocalizedName("ACTINIUM"),1); + TRANSFORMATION_INFO.addOredict(new cElementalDefinitionStack(getBestUnstableIsotope(91), AVOGADRO_CONSTANT_144),OrePrefixes.dust, getUnlocalizedName("PROTACTINIUM"),1); + TRANSFORMATION_INFO.addOredict(new cElementalDefinitionStack(getBestUnstableIsotope(93), AVOGADRO_CONSTANT_144),OrePrefixes.dust, getUnlocalizedName("NEPTUNIUM"),1); - transformation.addOredict(new cElementalDefinitionStack(getBestUnstableIsotope(96),144),OrePrefixes.dust, getUnlocalizedName("CURIUM"),1); - transformation.addOredict(new cElementalDefinitionStack(getBestUnstableIsotope(97),144),OrePrefixes.dust, getUnlocalizedName("BERKELIUM"),1); - transformation.addOredict(new cElementalDefinitionStack(getBestUnstableIsotope(98),144),OrePrefixes.dust, getUnlocalizedName("CALIFORNIUM"),1); - transformation.addOredict(new cElementalDefinitionStack(getBestUnstableIsotope(99),144),OrePrefixes.dust, getUnlocalizedName("EINSTEINIUM"),1); - transformation.addOredict(new cElementalDefinitionStack(getBestUnstableIsotope(100),144),OrePrefixes.dust, getUnlocalizedName("FERMIUM"),1); + TRANSFORMATION_INFO.addOredict(new cElementalDefinitionStack(getBestUnstableIsotope(96), AVOGADRO_CONSTANT_144),OrePrefixes.dust, getUnlocalizedName("CURIUM"),1); + TRANSFORMATION_INFO.addOredict(new cElementalDefinitionStack(getBestUnstableIsotope(97), AVOGADRO_CONSTANT_144),OrePrefixes.dust, getUnlocalizedName("BERKELIUM"),1); + TRANSFORMATION_INFO.addOredict(new cElementalDefinitionStack(getBestUnstableIsotope(98), AVOGADRO_CONSTANT_144),OrePrefixes.dust, getUnlocalizedName("CALIFORNIUM"),1); + TRANSFORMATION_INFO.addOredict(new cElementalDefinitionStack(getBestUnstableIsotope(99), AVOGADRO_CONSTANT_144),OrePrefixes.dust, getUnlocalizedName("EINSTEINIUM"),1); + TRANSFORMATION_INFO.addOredict(new cElementalDefinitionStack(getBestUnstableIsotope(100), AVOGADRO_CONSTANT_144),OrePrefixes.dust, getUnlocalizedName("FERMIUM"),1); } } 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 e8163833ee..702ed77315 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 @@ -59,7 +59,7 @@ public class projectileEM extends LaserProjectile { avalableEM.clear(); } else { cElementalInstanceStack consumeFromThis=avalableEM.get(TecTech.RANDOM.nextInt(avalableEM.size())); - massFactor =consumeFromThis.definition.getMass()/ dHadronDefinition.hadron_n_.getMass(); + massFactor =(float) (consumeFromThis.definition.getMass()/ dHadronDefinition.hadron_n_.getMass()); if(consumeFromThis.definition.getType()>1 || consumeFromThis.definition.getType()<-1) { exotic = true; 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 070a05d7e9..ddef29b214 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 @@ -26,7 +26,7 @@ import static net.minecraft.util.StatCollector.translateToLocal; */ public final class dComplexAspectDefinition extends cElementalDefinition implements iElementalAspect { private final int hash; - public final float mass; + public final double mass; private static final byte nbtType = (byte) 'c'; @@ -74,6 +74,9 @@ public final class dComplexAspectDefinition extends cElementalDefinition impleme if (!(aspects.definition instanceof dComplexAspectDefinition) && !(aspects.definition instanceof ePrimalAspectDefinition)) { return false; } + if((int)aspects.amount!=aspects.amount){ + throw new ArithmeticException("Amount cannot be safely converted to int!"); + } amount += aspects.amount; } return amount == 2; @@ -160,7 +163,7 @@ public final class dComplexAspectDefinition extends cElementalDefinition impleme } @Override - public float getRawTimeSpan(long currentEnergy) { + public double getRawTimeSpan(long currentEnergy) { return -1; } @@ -195,7 +198,7 @@ public final class dComplexAspectDefinition extends cElementalDefinition impleme } @Override - public float getEnergyDiffBetweenStates(long currentEnergyLevel, long newEnergyLevel) { + public double getEnergyDiffBetweenStates(long currentEnergyLevel, long newEnergyLevel) { return iElementalDefinition.DEFAULT_ENERGY_REQUIREMENT * (newEnergyLevel - currentEnergyLevel); } @@ -230,7 +233,7 @@ public final class dComplexAspectDefinition extends cElementalDefinition impleme } @Override - public float getMass() { + public double getMass() { return mass; } diff --git a/src/main/java/com/github/technus/tectech/compatibility/thaumcraft/elementalMatter/definitions/ePrimalAspectDefinition.java b/src/main/java/com/github/technus/tectech/compatibility/thaumcraft/elementalMatter/definitions/ePrimalAspectDefinition.java index bcb6e3f6fc..02e7d2fe21 100644 --- a/src/main/java/com/github/technus/tectech/compatibility/thaumcraft/elementalMatter/definitions/ePrimalAspectDefinition.java +++ b/src/main/java/com/github/technus/tectech/compatibility/thaumcraft/elementalMatter/definitions/ePrimalAspectDefinition.java @@ -10,14 +10,14 @@ import static net.minecraft.util.StatCollector.translateToLocal; */ public final class ePrimalAspectDefinition extends cElementalPrimitive implements iElementalAspect { public static final ePrimalAspectDefinition - magic_air = new ePrimalAspectDefinition(translateToLocal("tt.keyword.Air"), "a`", 1e1F, 35), - magic_earth = new ePrimalAspectDefinition(translateToLocal("tt.keyword.Earth"), "e`", 1e9F, 34), - magic_fire = new ePrimalAspectDefinition(translateToLocal("tt.keyword.Fire"), "f`", 1e3F, 33), - magic_water = new ePrimalAspectDefinition(translateToLocal("tt.keyword.Water"), "w`", 1e7F, 32), - magic_order = new ePrimalAspectDefinition(translateToLocal("tt.keyword.Order"), "o`", 1e5F, 30), - magic_entropy = new ePrimalAspectDefinition(translateToLocal("tt.keyword.Entropy"), "e`", 1e5F, 31); - - private ePrimalAspectDefinition(String name, String symbol, float mass, int ID) { + magic_air = new ePrimalAspectDefinition(translateToLocal("tt.keyword.Air"), "a`", 1e1D, 35), + magic_earth = new ePrimalAspectDefinition(translateToLocal("tt.keyword.Earth"), "e`", 1e9D, 34), + magic_fire = new ePrimalAspectDefinition(translateToLocal("tt.keyword.Fire"), "f`", 1e3D, 33), + magic_water = new ePrimalAspectDefinition(translateToLocal("tt.keyword.Water"), "w`", 1e7D, 32), + magic_order = new ePrimalAspectDefinition(translateToLocal("tt.keyword.Order"), "o`", 1e5D, 30), + magic_entropy = new ePrimalAspectDefinition(translateToLocal("tt.keyword.Entropy"), "e`", 1e5D, 31); + + private ePrimalAspectDefinition(String name, String symbol, double mass, int ID) { super(name, symbol, 0, mass, 0, -1, ID); } diff --git a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/cElementalDecay.java b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/cElementalDecay.java index 7d5e079876..e67f773a86 100644 --- a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/cElementalDecay.java +++ b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/cElementalDecay.java @@ -4,6 +4,8 @@ import com.github.technus.tectech.mechanics.elementalMatter.core.stacks.cElement import com.github.technus.tectech.mechanics.elementalMatter.core.stacks.cElementalInstanceStack; import com.github.technus.tectech.mechanics.elementalMatter.core.templates.iElementalDefinition; +import static com.github.technus.tectech.util.DoubleCount.add; + /** * Created by danie_000 on 22.10.2016. */ @@ -15,50 +17,50 @@ public final class cElementalDecay { public static final cElementalDecay[] noProduct = new cElementalDecay[0]; //this in turn can be used to tell that the thing should just vanish public final cElementalDefinitionStackMap outputStacks; - public final float probability; + public final double probability; public cElementalDecay(iElementalDefinition... outSafe) { - this(2F, outSafe); + this(1D, outSafe); } - public cElementalDecay(float probability, iElementalDefinition... outSafe) { + public cElementalDecay(double probability, iElementalDefinition... outSafe) { cElementalDefinitionStack[] outArr = new cElementalDefinitionStack[outSafe.length]; for (int i = 0; i < outArr.length; i++) { - outArr[i] = new cElementalDefinitionStack(outSafe[i], 1); + outArr[i] = new cElementalDefinitionStack(outSafe[i], 1D); } outputStacks = new cElementalDefinitionStackMap(outArr); this.probability = probability; } public cElementalDecay(cElementalDefinitionStack... outSafe) { - this(2F, outSafe); + this(1D, outSafe); } - public cElementalDecay(float probability, cElementalDefinitionStack... out) { + public cElementalDecay(double probability, cElementalDefinitionStack... out) { outputStacks = new cElementalDefinitionStackMap(out); this.probability = probability; } public cElementalDecay(cElementalDefinitionStackMap tree) { - this(2F, tree); + this(1D, tree); } - public cElementalDecay(float probability, cElementalDefinitionStackMap tree) { + public cElementalDecay(double probability, cElementalDefinitionStackMap tree) { outputStacks = tree; this.probability = probability; } - public cElementalInstanceStackMap getResults(float lifeMult, long age, long energyTotalForProducts, long amountDecaying) { + public cElementalInstanceStackMap getResults(double lifeMult, double age, long energyTotalForProducts, double amountDecaying) { cElementalInstanceStackMap decayResult = new cElementalInstanceStackMap(); if (outputStacks == null) { return decayResult;//This is to prevent null pointer exceptions. } //Deny decay code is in instance! - long qtty = 0; + double qtty = 0D; for (cElementalDefinitionStack stack : outputStacks.values()) { - qtty += stack.amount; + qtty= add(qtty,stack.amount); } - if (qtty <= 0) { + if (qtty <= 0D) { return decayResult; } //energyTotalForProducts /= qtty; @@ -66,7 +68,7 @@ public final class cElementalDecay { for (cElementalDefinitionStack stack : outputStacks.values()) { decayResult.putUnify(new cElementalInstanceStack(stack.definition, amountDecaying * stack.amount, - lifeMult, age/*new products*/, energyTotalForProducts / Math.max(1, Math.abs(stack.amount))));//get instances from stack + lifeMult, age/*new products*/, (long)(energyTotalForProducts / Math.max(1D, Math.abs(stack.amount)))));//get instances from stack } return decayResult; } diff --git a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/cElementalDecayResult.java b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/cElementalDecayResult.java new file mode 100644 index 0000000000..4ca63d14fe --- /dev/null +++ b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/cElementalDecayResult.java @@ -0,0 +1,41 @@ +package com.github.technus.tectech.mechanics.elementalMatter.core; + +public class cElementalDecayResult { + private final cElementalInstanceStackMap output; + private double massAffected; + private double massDiff; + + public cElementalDecayResult(cElementalInstanceStackMap output, double massAffected, double massDiff) { + this.output = output; + this.massAffected = massAffected; + this.massDiff = massDiff; + } + + public cElementalInstanceStackMap getOutput() { + return output; + } + + /** + * How much was lost in the process (decayed or removed) + * @return + */ + public double getMassAffected() { + return massAffected; + } + + /** + * Difference of mass of actually decayed elements + * @return + */ + public double getMassDiff() { + return massDiff; + } + + public void setMassAffected(double massAffected) { + this.massAffected = massAffected; + } + + public void setMassDiff(double massDiff) { + this.massDiff = massDiff; + } +} diff --git a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/cElementalDefinitionStackMap.java b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/cElementalDefinitionStackMap.java index 294acfc479..ce0840bc8b 100644 --- a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/cElementalDefinitionStackMap.java +++ b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/cElementalDefinitionStackMap.java @@ -13,7 +13,7 @@ import static com.github.technus.tectech.mechanics.elementalMatter.definitions.p */ public final class cElementalDefinitionStackMap/*IMMUTABLE*/ extends cElementalStackMap {//Target class for construction of definitions/recipes //Constructors + Clone, all make a whole new OBJ. - public static final cElementalDefinitionStackMap empty = new cElementalDefinitionStackMap(); + public static final cElementalDefinitionStackMap EMPTY = new cElementalDefinitionStackMap(); private cElementalDefinitionStackMap() { map = new TreeMap<>(); 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 5893ac1a1f..e1fdc6a553 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 @@ -9,7 +9,11 @@ import net.minecraft.util.EnumChatFormatting; import java.util.*; +import static com.github.technus.tectech.mechanics.elementalMatter.core.transformations.bTransformationInfo.AVOGADRO_CONSTANT; +import static com.github.technus.tectech.mechanics.elementalMatter.core.transformations.bTransformationInfo.AVOGADRO_CONSTANT_UNCERTAINTY; import static com.github.technus.tectech.mechanics.elementalMatter.definitions.primitive.cPrimitiveDefinition.nbtE__; +import static com.github.technus.tectech.util.DoubleCount.add; +import static com.github.technus.tectech.util.DoubleCount.sub; /** * Created by danie_000 on 22.01.2017. @@ -95,6 +99,11 @@ public final class cElementalInstanceStackMap implements Comparable<cElementalIn return map; } + public Set<Map.Entry<iElementalDefinition, cElementalInstanceStack>> getEntrySet() { + return map.entrySet(); + } + + //Removers public void clear() { map.clear(); @@ -131,7 +140,7 @@ public final class cElementalInstanceStackMap implements Comparable<cElementalIn if (testOnly) { return target.amount >= instance.amount; } else { - long diff = target.amount - instance.amount; + double diff = sub(target.amount,instance.amount); if (diff > 0) { target.amount = diff; return true; @@ -151,7 +160,7 @@ public final class cElementalInstanceStackMap implements Comparable<cElementalIn if (testOnly) { return target.amount >= stack.getAmount(); } else { - long diff = target.amount - stack.getAmount(); + double diff = sub(target.amount,stack.getAmount()); if (diff > 0) { target.amount = diff; return true; @@ -165,7 +174,7 @@ public final class cElementalInstanceStackMap implements Comparable<cElementalIn @Deprecated public boolean removeAmount(boolean testOnly, iElementalDefinition def) { - return removeAmount(testOnly, new cElementalDefinitionStack(def, 1)); + return removeAmount(testOnly, new cElementalDefinitionStack(def, 1D)); } public boolean removeAllAmounts(boolean testOnly, cElementalInstanceStack... instances) { @@ -234,8 +243,8 @@ public final class cElementalInstanceStackMap implements Comparable<cElementalIn } //Remove overflow - public float removeOverflow(int stacksCount, long stackCapacity) { - float massRemoved = 0; + public double removeOverflow(int stacksCount, double stackCapacity) { + double massRemoved = 0; if (map.size() > stacksCount) { iElementalDefinition[] keys = keys(); @@ -326,14 +335,14 @@ public final class cElementalInstanceStackMap implements Comparable<cElementalIn } public String[] getElementalInfo() { - String[] info = new String[map.size() * 4]; + String[] info = new String[map.size()]; int i = 0; for (cElementalInstanceStack instance : map.values()) { - info[i] = EnumChatFormatting.BLUE + instance.definition.getName(); - info[i + 1] = EnumChatFormatting.AQUA + instance.definition.getSymbol(); - info[i + 2] = "Amount " + EnumChatFormatting.GREEN + instance.amount; - info[i + 3] = "LifeTime " + EnumChatFormatting.GREEN + instance.getLifeTime(); - i += 4; + info[i++] = EnumChatFormatting.BLUE + instance.definition.getName()+ + " "+ EnumChatFormatting.AQUA + instance.definition.getSymbol()+ EnumChatFormatting.RESET+ + " #: " + EnumChatFormatting.GREEN + String.format("%.3E",instance.amount/ AVOGADRO_CONSTANT) +" mol"+ EnumChatFormatting.RESET+ + " E: " + EnumChatFormatting.GREEN + instance.getEnergy() + EnumChatFormatting.RESET+ + " T: " + EnumChatFormatting.GREEN + (instance.getLifeTime()<0?"STABLE":String.format("%.3E",instance.getLifeTime())); } return info; } @@ -364,26 +373,26 @@ public final class cElementalInstanceStackMap implements Comparable<cElementalIn return var.toArray(new iElementalDefinition[0]); } - public float getMass() { - float mass = 0; + public double getMass() { + double mass = 0; for (cElementalInstanceStack stack : map.values()) { mass += stack.getMass(); } return mass; } - public long getCharge() { - long charge = 0; + public double getCharge() { + double charge = 0; for (cElementalInstanceStack stack : map.values()) { charge += stack.getCharge(); } return charge; } - public long getCountOfAllAmounts(){ - long sum=0; + public double getCountOfAllAmounts(){ + double sum=0; for(cElementalInstanceStack stack:map.values()){ - sum+=stack.amount; + sum= add(sum,stack.amount); } return sum; } @@ -410,22 +419,24 @@ public final class cElementalInstanceStackMap implements Comparable<cElementalIn } //Tick Content - public void tickContentByOneSecond(float lifeTimeMult, int postEnergize) { - tickContent(lifeTimeMult,postEnergize,1); + public double tickContentByOneSecond(double lifeTimeMult, int postEnergize) { + return tickContent(lifeTimeMult,postEnergize,1D); } - public void tickContent(float lifeTimeMult, int postEnergize, int seconds){ + public double tickContent(double lifeTimeMult, int postEnergize, double seconds){ + cleanUp(); + double diff=0; for (cElementalInstanceStack instance : values()) { - cElementalInstanceStackMap newInstances = instance.decay(lifeTimeMult, instance.age += seconds, postEnergize); + cElementalDecayResult newInstances = instance.decay(lifeTimeMult, instance.age += seconds, postEnergize); if (newInstances == null) { instance.nextColor(); } else { + diff=add(diff,newInstances.getMassDiff()); removeAmount(false,instance); - for (cElementalInstanceStack newInstance : newInstances.values()) { - putUnify(newInstance); - } + putUnifyAll(newInstances.getOutput()); } } + return diff; } //NBT @@ -549,10 +560,6 @@ public final class cElementalInstanceStackMap implements Comparable<cElementalIn } public void cleanUp(){ - for(Map.Entry<iElementalDefinition, cElementalInstanceStack> entry:map.entrySet()){ - if(entry.getValue().amount<=0) { - map.remove(entry.getKey()); - } - } + map.entrySet().removeIf(entry -> entry.getValue().amount < AVOGADRO_CONSTANT_UNCERTAINTY); } } diff --git a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/cElementalMutableDefinitionStackMap.java b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/cElementalMutableDefinitionStackMap.java index 829af20ca6..020f5a5f8c 100644 --- a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/cElementalMutableDefinitionStackMap.java +++ b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/cElementalMutableDefinitionStackMap.java @@ -10,6 +10,7 @@ import java.util.Map; import java.util.TreeMap; import static com.github.technus.tectech.mechanics.elementalMatter.definitions.primitive.cPrimitiveDefinition.nbtE__; +import static com.github.technus.tectech.util.DoubleCount.sub; /** * Created by danie_000 on 22.01.2017. @@ -100,7 +101,7 @@ public final class cElementalMutableDefinitionStackMap extends cElementalStackMa if (testOnly) { return target.amount >= instance.amount; } else { - long diff = target.amount - instance.amount; + double diff = sub(target.amount,instance.amount); if (diff > 0) { map.put(target.definition, new cElementalDefinitionStack(target.definition, diff)); return true; @@ -120,7 +121,7 @@ public final class cElementalMutableDefinitionStackMap extends cElementalStackMa if (testOnly) { return target.amount >= stack.getAmount(); } else { - long diff = target.amount - stack.getAmount(); + double diff = sub(target.amount,stack.getAmount()); if (diff > 0) { map.put(target.definition, new cElementalDefinitionStack(target.definition, diff)); return true; 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 dbbfa7bf66..f8e7aa39e4 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 @@ -9,6 +9,8 @@ import java.util.Collection; import java.util.Set; import java.util.TreeMap; +import static com.github.technus.tectech.util.DoubleCount.add; + /** * Created by Tec on 12.05.2017. */ @@ -65,10 +67,10 @@ abstract class cElementalStackMap implements Comparable<cElementalStackMap> { return var.toArray(new iElementalDefinition[0]); } - public long getCountOfAllAmounts(){ - long sum=0; + public double getCountOfAllAmounts(){ + double sum=0; for(cElementalDefinitionStack stack:map.values()){ - sum+=stack.amount; + sum= add(sum,stack.amount); } return sum; } diff --git a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/commands/GiveEM.java b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/commands/GiveEM.java index de1934fed7..912d44ff43 100644 --- a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/commands/GiveEM.java +++ b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/commands/GiveEM.java @@ -50,7 +50,7 @@ public class GiveEM implements ICommand { cElementalDefinitionStack def= getDefinitionStack(list); if(def!=null) { - cElementalInstanceStack instanceStack = new cElementalInstanceStack(def, 1, 0, Long.parseLong(energy)); + cElementalInstanceStack instanceStack = new cElementalInstanceStack(def, 1D, 0D, Long.parseLong(energy)); sender.addChatMessage(new ChatComponentText(instanceStack.definition.getSymbol() + " - " + instanceStack.definition.getName())); @@ -73,7 +73,7 @@ public class GiveEM implements ICommand { args.remove(0); return null; } - long amount=Long.parseLong(args.remove(0)); + double amount=Double.parseDouble(args.remove(0)); try{ int id=Integer.parseInt(args.get(0)); args.remove(0); diff --git a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/stacks/cElementalDefinitionStack.java b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/stacks/cElementalDefinitionStack.java index 6b6fe35b41..a2d22c30ed 100644 --- a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/stacks/cElementalDefinitionStack.java +++ b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/stacks/cElementalDefinitionStack.java @@ -5,15 +5,16 @@ import com.github.technus.tectech.mechanics.elementalMatter.core.templates.iElem import net.minecraft.nbt.NBTTagCompound; import static com.github.technus.tectech.mechanics.elementalMatter.definitions.primitive.cPrimitiveDefinition.null__; +import static com.github.technus.tectech.util.DoubleCount.add; /** * Created by danie_000 on 20.11.2016. */ public final class cElementalDefinitionStack implements iHasElementalDefinition { public final iElementalDefinition definition; - public final long amount; + public final double amount; - public cElementalDefinitionStack(iElementalDefinition def, long amount) { + public cElementalDefinitionStack(iElementalDefinition def, double amount) { definition = def == null ? null__ : def; this.amount = amount; } @@ -29,47 +30,47 @@ public final class cElementalDefinitionStack implements iHasElementalDefinition } @Override - public long getAmount() { + public double getAmount() { return amount; } @Override - public long getCharge() { + public double getCharge() { return definition.getCharge() * amount; } @Override - public float getMass() { + public double getMass() { return definition.getMass() * amount; } public NBTTagCompound toNBT() { NBTTagCompound nbt = new NBTTagCompound(); nbt.setTag("d", definition.toNBT()); - nbt.setLong("q", amount); + nbt.setDouble("Q", amount); return nbt; } public static cElementalDefinitionStack fromNBT(NBTTagCompound nbt) { return new cElementalDefinitionStack( cElementalDefinition.fromNBT(nbt.getCompoundTag("d")), - nbt.getLong("q")); + nbt.getLong("q")+nbt.getDouble("Q")); } - public cElementalDefinitionStack addAmountIntoNewInstance(long amount) { + public cElementalDefinitionStack addAmountIntoNewInstance(double amount) { if(amount==0) { return this; } - return new cElementalDefinitionStack(definition, amount + this.amount); + return new cElementalDefinitionStack(definition, add(amount,this.amount)); } public cElementalDefinitionStack addAmountIntoNewInstance(cElementalDefinitionStack... other) { if (other == null || other.length == 0) { return this; } - long l = 0; + double l = 0; for (cElementalDefinitionStack stack : other) { - l += stack.amount; + l= add(l,stack.amount); } return addAmountIntoNewInstance(l); } 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 c108d8c8ae..559d7ab8d9 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 @@ -1,49 +1,56 @@ package com.github.technus.tectech.mechanics.elementalMatter.core.stacks; import com.github.technus.tectech.TecTech; -import com.github.technus.tectech.util.Util; import com.github.technus.tectech.mechanics.elementalMatter.core.cElementalDecay; +import com.github.technus.tectech.mechanics.elementalMatter.core.cElementalDecayResult; import com.github.technus.tectech.mechanics.elementalMatter.core.cElementalDefinitionStackMap; import com.github.technus.tectech.mechanics.elementalMatter.core.cElementalInstanceStackMap; 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.util.Util; +import net.minecraft.client.Minecraft; +import net.minecraft.crash.CrashReport; import net.minecraft.nbt.NBTTagCompound; import java.util.ArrayList; +import static com.github.technus.tectech.mechanics.elementalMatter.core.transformations.bTransformationInfo.AVOGADRO_CONSTANT; import static com.github.technus.tectech.mechanics.elementalMatter.definitions.primitive.cPrimitiveDefinition.null__; 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 com.github.technus.tectech.util.DoubleCount.*; +import static java.lang.Math.*; /** * Created by danie_000 on 22.10.2016. */ public final class cElementalInstanceStack implements iHasElementalDefinition { - public static int MIN_MULTIPLE_DECAY_CALLS=4,MAX_MULTIPLE_DECAY_CALLS=16,DECAY_CALL_PER=144; + public static int MIN_MULTIPLE_DECAY_CALLS=4,MAX_MULTIPLE_DECAY_CALLS=16; + public static double DECAY_CALL_PER=AVOGADRO_CONSTANT;//todo public final iElementalDefinition definition; //energy - if positive then particle should try to decay private long energy; //byte color; 0=Red 1=Green 2=Blue 0=Cyan 1=Magenta 2=Yellow, else ignored (-1 - uncolorable) private byte color; - public long age; - public long amount; - private float lifeTime; - private float lifeTimeMult; + public double age; + public double amount; + private double lifeTime; + private double lifeTimeMult; public cElementalInstanceStack(cElementalDefinitionStack stackSafe) { - this(stackSafe.definition, stackSafe.amount, 1F, 0, 0); + this(stackSafe.definition, stackSafe.amount, 1D, 0D, 0); } - public cElementalInstanceStack(cElementalDefinitionStack stackSafe, float lifeTimeMult, long age, long energy) { + public cElementalInstanceStack(cElementalDefinitionStack stackSafe, double lifeTimeMult, double age, long energy) { this(stackSafe.definition, stackSafe.amount, lifeTimeMult, age, energy); } - public cElementalInstanceStack(iElementalDefinition defSafe, long amount) { - this(defSafe, amount, 1F, 0, 0); + public cElementalInstanceStack(iElementalDefinition defSafe, double amount) { + this(defSafe, amount, 1D, 0D, 0); } - public cElementalInstanceStack(iElementalDefinition defSafe, long amount, float lifeTimeMult, long age, long energy) { + public cElementalInstanceStack(iElementalDefinition defSafe, double amount, double lifeTimeMult, double age, long energy) { definition = defSafe == null ? null__ : defSafe; byte bColor = definition.getColor(); if (bColor < 0 || bColor > 2) {//transforms colorable??? into proper color @@ -75,17 +82,17 @@ public final class cElementalInstanceStack implements iHasElementalDefinition { } @Override - public long getAmount() { + public double getAmount() { return amount; } @Override - public long getCharge() { + public double getCharge() { return definition.getCharge() * amount; } @Override - public float getMass() { + public double getMass() { return definition.getMass() * amount; } @@ -98,11 +105,11 @@ public final class cElementalInstanceStack implements iHasElementalDefinition { setLifeTimeMultiplier(getLifeTimeMultiplier()); } - public float getEnergySettingCost(long currentEnergyLevel, long newEnergyLevel){ + public double getEnergySettingCost(long currentEnergyLevel, long newEnergyLevel){ return definition.getEnergyDiffBetweenStates(currentEnergyLevel,newEnergyLevel)*amount; } - public float getEnergySettingCost(long newEnergyLevel){ + public double getEnergySettingCost(long newEnergyLevel){ return definition.getEnergyDiffBetweenStates(energy,newEnergyLevel)*amount; } @@ -133,11 +140,11 @@ public final class cElementalInstanceStack implements iHasElementalDefinition { return color = (byte) TecTech.RANDOM.nextInt(3); } - public float getLifeTime() { + public double getLifeTime() { return lifeTime; } - public float setLifeTimeMultiplier(float mult) { + public double setLifeTimeMultiplier(double mult) { if(mult<=0) //since infinity*0=nan { throw new IllegalArgumentException("multiplier must be >0"); @@ -150,90 +157,94 @@ public final class cElementalInstanceStack implements iHasElementalDefinition { return lifeTime; } - public float getLifeTimeMultiplier() { + public double getLifeTimeMultiplier() { return lifeTimeMult; } - public cElementalInstanceStackMap tickStackByOneSecond(float lifeTimeMult, int postEnergize){ - return tickStack(lifeTimeMult,postEnergize,1); + public cElementalDecayResult tickStackByOneSecond(double lifeTimeMult, int postEnergize){ + return tickStack(lifeTimeMult,postEnergize,1D); } - public cElementalInstanceStackMap tickStack(float lifeTimeMult, int postEnergize, int seconds){ - cElementalInstanceStackMap newInstances = decay(lifeTimeMult, age += seconds, postEnergize); + public cElementalDecayResult tickStack(double lifeTimeMult, int postEnergize, double seconds){ + cElementalDecayResult newInstances = decay(lifeTimeMult, age += seconds, postEnergize); if (newInstances == null) { nextColor(); } else { - for (cElementalInstanceStack newInstance : newInstances.values()) { + for (cElementalInstanceStack newInstance : newInstances.getOutput().values()) { newInstance.nextColor(); } } return newInstances; } - public cElementalInstanceStackMap decay() { - return decay(1F, age, 0);//try to decay without changes + public cElementalDecayResult decay() { + return decay(1D, age, 0);//try to decay without changes } - public cElementalInstanceStackMap decay(long apparentAge, long postEnergize) { - return decay(1F,apparentAge,postEnergize); + public cElementalDecayResult decay(double apparentAge, long postEnergize) { + return decay(1D,apparentAge,postEnergize); } - public cElementalInstanceStackMap decay(float lifeTimeMult, long apparentAge, long postEnergize) { + public cElementalDecayResult decay(double lifeTimeMult, double apparentAge, long postEnergize) { long newEnergyLevel = postEnergize + energy; if (newEnergyLevel > 0) { newEnergyLevel -= 1; } else if (newEnergyLevel < 0) { newEnergyLevel += 1; } + cElementalDecayResult output; if(definition.usesMultipleDecayCalls(energy)){ - long amountTemp=amount; - long decayCnt=Math.min(Math.max(amount/DECAY_CALL_PER,MIN_MULTIPLE_DECAY_CALLS),MAX_MULTIPLE_DECAY_CALLS); - long amountPer=amount/decayCnt; - amount-=amountPer*(--decayCnt); - cElementalInstanceStackMap output=decayMechanics(lifeTimeMult,apparentAge,newEnergyLevel); + double amountTemp=amount; + int decayCnt=(int) min(MAX_MULTIPLE_DECAY_CALLS,max(amount/DECAY_CALL_PER,MIN_MULTIPLE_DECAY_CALLS)); + amount= div(amount,decayCnt); + decayCnt--; + + output=decayMechanics(lifeTimeMult,apparentAge,newEnergyLevel); if(output==null){ amount=amountTemp; return null; } - if(amountPer>0){ - amount=amountPer; - for(int i=0;i<decayCnt;i++){ - cElementalInstanceStackMap map=decayMechanics(lifeTimeMult,apparentAge,newEnergyLevel); - if(map!=null){ - output.putUnifyAll(map); - } + + for(int i=0;i<decayCnt;i++){ + cElementalDecayResult map=decayMechanics(lifeTimeMult,apparentAge,newEnergyLevel); + if(map!=null){ + output.getOutput().putUnifyAll(map.getOutput()); + output.setMassDiff(add(output.getMassDiff(),map.getMassDiff())); + output.setMassAffected(output.getMassDiff()+map.getMassDiff()); } } amount=amountTemp; - return output; }else{ - return decayMechanics(lifeTimeMult,apparentAge,newEnergyLevel); + output=decayMechanics(lifeTimeMult,apparentAge,newEnergyLevel); + } + if(output!=null){ + output.getOutput().cleanUp(); } + return output; } - private cElementalInstanceStackMap decayMechanics(float lifeTimeMult, long apparentAge, long newEnergyLevel) { + private cElementalDecayResult decayMechanics(double lifeTimeMult, double apparentAge, long newEnergyLevel) { if (energy > 0 && !definition.usesSpecialEnergeticDecayHandling()) { setLifeTimeMultiplier(getLifeTimeMultiplier()); - return decayCompute(definition.getEnergyInducedDecay(energy), lifeTimeMult, -1, newEnergyLevel); + return decayCompute(definition.getEnergyInducedDecay(energy), lifeTimeMult, -1D, newEnergyLevel); } else if (definition.getRawTimeSpan(energy) < 0) { return null;//return null, decay cannot be achieved } else if (definition.isTimeSpanHalfLife()) { - return exponentialDecayCompute(energy > 0 ? definition.getEnergyInducedDecay(energy) : definition.getDecayArray(), lifeTimeMult, -1, newEnergyLevel); + return exponentialDecayCompute(energy > 0 ? definition.getEnergyInducedDecay(energy) : definition.getDecayArray(), lifeTimeMult, -1D, newEnergyLevel); } else { - if (1F > lifeTime) { - return decayCompute(energy > 0 ? definition.getEnergyInducedDecay(energy) : definition.getNaturalDecayInstant(), lifeTimeMult, 0, newEnergyLevel); - } else if ((float) apparentAge > lifeTime) { - return decayCompute(energy > 0 ? definition.getEnergyInducedDecay(energy) : definition.getDecayArray(), lifeTimeMult, 0, newEnergyLevel); + if (1 > lifeTime) { + return decayCompute(energy > 0 ? definition.getEnergyInducedDecay(energy) : definition.getNaturalDecayInstant(), lifeTimeMult, 0D, newEnergyLevel); + } else if (apparentAge > lifeTime) { + return decayCompute(energy > 0 ? definition.getEnergyInducedDecay(energy) : definition.getDecayArray(), lifeTimeMult, 0D, newEnergyLevel); } } return null;//return null since decay cannot be achieved } //Use to get direct decay output providing correct decay array - private cElementalInstanceStackMap exponentialDecayCompute(cElementalDecay[] decays, float lifeTimeMult, long newProductsAge, long newEnergyLevel) { - double decayInverseRatio=Math.pow(2d,1d/* 1 second *//(double)lifeTime); - double newAmount=(double)amount/decayInverseRatio; - long amountRemaining= (long)Math.floor(newAmount) +(TecTech.RANDOM.nextDouble()<=newAmount-Math.floor(newAmount)?1:0); + private cElementalDecayResult exponentialDecayCompute(cElementalDecay[] decays, double lifeTimeMult, double newProductsAge, long newEnergyLevel) { + double newAmount= div(amount,Math.pow(2D,1D/* 1 second *//lifeTime)); + //if(definition.getSymbol().startsWith("U ")) { // System.out.println("newAmount = " + newAmount); // System.out.println("amountRemaining = " + amountRemaining); @@ -244,124 +255,137 @@ public final class cElementalInstanceStack implements iHasElementalDefinition { // } // } //} - if(amountRemaining==amount) { - return null;//nothing decayed - } else if(amountRemaining<=0) { + if(newAmount==amount) { + newAmount-=ulp(newAmount); + } else if(newAmount<1) { return decayCompute(decays, lifeTimeMult, newProductsAge, newEnergyLevel); } + //split to non decaying and decaying part - long amount=this.amount; - this.amount-=amountRemaining; - cElementalInstanceStackMap products=decayCompute(decays,lifeTimeMult,newProductsAge,newEnergyLevel); - this.amount=amountRemaining; - products.putUnify(clone()); + double amount=this.amount; + this.amount-=newAmount; + cElementalDecayResult products=decayCompute(decays,lifeTimeMult,newProductsAge,newEnergyLevel); + this.amount=newAmount; + if(products!=null){ + products.getOutput().putUnify(clone()); + } this.amount=amount; return products; } //Use to get direct decay output providing correct decay array - private cElementalInstanceStackMap decayCompute(cElementalDecay[] decays, float lifeTimeMult, long newProductsAge, long newEnergyLevel) { + private cElementalDecayResult decayCompute(cElementalDecay[] decays, double lifeTimeMult, double newProductsAge, long newEnergyLevel) { if (decays == null) { return null;//Can not decay so it wont } + boolean makesEnergy=definition.decayMakesEnergy(energy); + double mass=getMass(); if (decays.length == 0) { - if(definition.decayMakesEnergy(this.energy)) { - return null; - } - return new cElementalInstanceStackMap();//provide non null 0 length array for annihilation + return makesEnergy ? null : new cElementalDecayResult(new cElementalInstanceStackMap(), mass, 0); + //provide non null 0 length array for annihilation } else if (decays.length == 1) {//only one type of decay :D, doesn't need dead end - if(decays[0]==deadEnd && definition.decayMakesEnergy(this.energy)) { - return null;//no extra photons + if(decays[0]==deadEnd) { + return makesEnergy ? null : new cElementalDecayResult(decays[0].getResults(lifeTimeMult, newProductsAge, newEnergyLevel, amount), mass, 0); } - cElementalInstanceStackMap products=decays[0].getResults(lifeTimeMult, newProductsAge, newEnergyLevel, amount); + cElementalInstanceStackMap output = decays[0].getResults(lifeTimeMult, newProductsAge, newEnergyLevel, amount); if(newProductsAge<0){ - if(products.size()==1) { - if(products.size()==1 && products.get(0).definition.equals(definition)) { - products.get(0).setEnergy(energy); - products.get(0).age=age; + if(output.size()==1) { + if(output.size()==1 && output.get(0).definition.equals(definition)) { + output.get(0).setEnergy(energy); + output.get(0).age=age; } }else { - for (cElementalInstanceStack stack : products.values()) { + for (cElementalInstanceStack stack : output.values()) { if (stack.definition.equals(definition)) { stack.age = age; } } } }else{ - if(products.size()==1 && products.get(0).definition.equals(definition)) { - products.get(0).setEnergy(energy); + if(output.size()==1 && output.get(0).definition.equals(definition)) { + output.get(0).setEnergy(energy); } } - if(this.energy <= 0 && products.getMass() > getMass()){ + if(energy <= 0 && output.getMass() > mass){ return null;//no energy usage to decay } - return products; + return new cElementalDecayResult(new cElementalInstanceStackMap(), mass, makesEnergy ? output.getMass()-mass:0); } else { - cElementalInstanceStackMap output = new cElementalInstanceStackMap(); + cElementalDecayResult totalOutput = new cElementalDecayResult(new cElementalInstanceStackMap(),getMass(),0); + cElementalInstanceStackMap output=totalOutput.getOutput(),results; int differentDecays = decays.length; - long[] qttyOfDecay = new long[differentDecays]; - long amountRemaining = this.amount, amount = this.amount; - float remainingProbability = 1F; - - for (int i = 0; i < differentDecays; i++) { - if (decays[i].probability >= 1F) { - long thisDecayAmount = (long) Math.floor(remainingProbability * (double) amount); - if (thisDecayAmount > 0) { - if (thisDecayAmount <= amountRemaining) { - amountRemaining -= thisDecayAmount; - qttyOfDecay[i] += thisDecayAmount; - }else {//in case too much was made - qttyOfDecay[i] += amountRemaining; - amountRemaining = 0; - //remainingProbability=0; - } - } - break; - } - long thisDecayAmount = (long) Math.floor(decays[i].probability * (double) amount); - if (thisDecayAmount <= amountRemaining && thisDecayAmount > 0) {//some was made - amountRemaining -= thisDecayAmount; - qttyOfDecay[i] += thisDecayAmount; - } else if (thisDecayAmount > amountRemaining) {//too much was made - qttyOfDecay[i] += amountRemaining; - amountRemaining = 0; - //remainingProbability=0; - break; - } - remainingProbability -= decays[i].probability; - if(remainingProbability<=0) { - break; - } + double[] probabilities=new double[differentDecays]; + for (int i = 0; i < probabilities.length; i++) { + probabilities[i]=decays[i].probability; } - - for (int i = 0; i < amountRemaining; i++) { - double rand = TecTech.RANDOM.nextDouble(); - for (int j = 0; j < differentDecays; j++) {//looking for the thing it decayed into - rand -= decays[j].probability; - if (rand <= 0D) { - qttyOfDecay[j]++; - break; - } - } + double[] qttyOfDecay; + try{ + qttyOfDecay = distribute(amount, probabilities); + }catch (ArithmeticException e){ + Minecraft.getMinecraft().crashed(new CrashReport("Decay failed for: "+this.toString(),e)); + return null; } - - if(definition.decayMakesEnergy(this.energy)){ - for (int i = 0; i < differentDecays; i++) { - if (qttyOfDecay[i] > 0) { - if(decays[i]==deadEnd){ - cElementalInstanceStack clone=this.clone(); - clone.amount=qttyOfDecay[i]; - output.putUnify(clone); - }else { - output.putUnifyAll(decays[i].getResults(lifeTimeMult, newProductsAge, newEnergyLevel, qttyOfDecay[i])); - } + //long amountRemaining = this.amount, amount = this.amount; + //float remainingProbability = 1D; +// + //for (int i = 0; i < differentDecays; i++) { + // if (decays[i].probability >= 1D) { + // long thisDecayAmount = (long) Math.floor(remainingProbability * (double) amount); + // if (thisDecayAmount > 0) { + // if (thisDecayAmount <= amountRemaining) { + // amountRemaining -= thisDecayAmount; + // qttyOfDecay[i] += thisDecayAmount; + // }else {//in case too much was made + // qttyOfDecay[i] += amountRemaining; + // amountRemaining = 0; + // //remainingProbability=0; + // } + // } + // break; + // } + // long thisDecayAmount = (long) Math.floor(decays[i].probability * (double) amount); + // if (thisDecayAmount <= amountRemaining && thisDecayAmount > 0) {//some was made + // amountRemaining -= thisDecayAmount; + // qttyOfDecay[i] += thisDecayAmount; + // } else if (thisDecayAmount > amountRemaining) {//too much was made + // qttyOfDecay[i] += amountRemaining; + // amountRemaining = 0; + // //remainingProbability=0; + // break; + // } + // remainingProbability -= decays[i].probability; + // if(remainingProbability<=0) { + // break; + // } + //} + + //for (int i = 0; i < amountRemaining; i++) { + // double rand = TecTech.RANDOM.nextDouble(); + // for (int j = 0; j < differentDecays; j++) {//looking for the thing it decayed into + // rand -= decays[j].probability; + // if (rand <= 0D) { + // qttyOfDecay[j]++; + // break; + // } + // } + //} + + if(definition.decayMakesEnergy(energy)){ + for (int i = differentDecays - 1; i >= 0; i--) { + if(decays[i]==deadEnd){ + cElementalInstanceStack clone=clone(); + clone.amount=qttyOfDecay[i]; + output.putUnify(clone); + }else { + results=decays[i].getResults(lifeTimeMult, newProductsAge, newEnergyLevel, qttyOfDecay[i]); + output.putUnifyAll(results); + totalOutput.setMassDiff(add(totalOutput.getMassDiff(),results.getMass()-mass)); } } }else{ - for (int i = 0; i < differentDecays; i++) { - if (qttyOfDecay[i] > 0) { - output.putUnifyAll(decays[i].getResults(lifeTimeMult, newProductsAge, newEnergyLevel, qttyOfDecay[i])); - } + for (int i = differentDecays - 1; i >= 0; i--) { + results=decays[i].getResults(lifeTimeMult, newProductsAge, newEnergyLevel, qttyOfDecay[i]); + output.putUnifyAll(results); } } @@ -382,10 +406,10 @@ public final class cElementalInstanceStack implements iHasElementalDefinition { output.get(0).age=age; } } - if(this.energy <= 0 && output.getMass() > getMass()){ + if(energy <= 0 && output.getMass() > getMass()){ return null;//no energy usage to decay } - return output; + return totalOutput; } } @@ -394,29 +418,33 @@ public final class cElementalInstanceStack implements iHasElementalDefinition { return this; } //returns with the definition from the first object passed - double energy = this.energy * amount; + double energyTotal = this.energy * amount; long maxEnergy=this.energy; - float lifeTimeMul = lifeTimeMult; + double lifeTimeMul = lifeTimeMult; for (cElementalInstanceStack instance : instances) { if (instance != null && compareTo(instance) == 0) { - amount += instance.amount; - energy += instance.energy * instance.amount; + amount= add(amount,instance.amount); + energyTotal += instance.energy * instance.amount; if(instance.energy>maxEnergy){ maxEnergy=instance.energy; } - lifeTimeMul = Math.min(lifeTimeMul, instance.lifeTimeMult); - age = Math.max(age, instance.age); + lifeTimeMul = min(lifeTimeMul, instance.lifeTimeMult); + age = max(age, instance.age); } } if (amount != 0) { - energy /= Math.abs(amount); + energyTotal /= Math.abs(amount); } - double wholeParts=Math.floor(energy); - energy=Math.min(energy-wholeParts,1)+(wholeParts>=0?-0.11709966304863834:0.11709966304863834); - setEnergy(Math.min(maxEnergy,(long)wholeParts+(energy>TecTech.RANDOM.nextDouble()?1:0))); + double wholeParts=Math.floor(energyTotal); + energyTotal= min(energyTotal-wholeParts,1D)+(wholeParts>=0?-0.11709966304863834D:0.11709966304863834D); + long energy=(long) wholeParts + ((energyTotal > TecTech.RANDOM.nextDouble()) ? 1 : 0); + if(energy*energyTotal<0){ + energy=0; + } + setEnergy(min(maxEnergy,energy)); return this; } @@ -458,7 +486,7 @@ public final class cElementalInstanceStack implements iHasElementalDefinition { lines.add("ENERGY = " + energy); } if(Util.areBitsSet(SCAN_GET_AMOUNT,capabilities)) { - lines.add("AMOUNT = " + amount); + lines.add("AMOUNT = " + amount/ AVOGADRO_CONSTANT +" mol"); } scanContents(lines,definition.getSubParticles(),1,detailsOnDepthLevels); } @@ -483,11 +511,11 @@ public final class cElementalInstanceStack implements iHasElementalDefinition { public NBTTagCompound toNBT() { NBTTagCompound nbt = new NBTTagCompound(); nbt.setTag("d", definition.toNBT()); - nbt.setLong("q", amount); + nbt.setDouble("Q", amount); nbt.setLong("e", energy); nbt.setByte("c", color); - nbt.setLong("a", age); - nbt.setFloat("m", lifeTimeMult); + nbt.setDouble("A", age); + nbt.setDouble("M", lifeTimeMult); return nbt; } @@ -495,9 +523,9 @@ public final class cElementalInstanceStack implements iHasElementalDefinition { NBTTagCompound definition = nbt.getCompoundTag("d"); cElementalInstanceStack instance = new cElementalInstanceStack( cElementalDefinition.fromNBT(definition), - nbt.getLong("q"), - nbt.getFloat("m"), - nbt.getLong("a"), + nbt.getLong("q")+nbt.getDouble("Q"), + nbt.getFloat("m")+nbt.getDouble("M"), + nbt.getLong("a")+nbt.getDouble("A"), nbt.getLong("e")); instance.setColor(nbt.getByte("c")); return instance; @@ -527,6 +555,6 @@ public final class cElementalInstanceStack implements iHasElementalDefinition { @Override public String toString() { - return definition.getName()+ '\n' + definition.getSymbol() + '\n' + amount + '\n' + getMass(); + return definition.toString() + '\n' + amount/ AVOGADRO_CONSTANT + " mol\n" + getMass(); } } diff --git a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/stacks/iHasElementalDefinition.java b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/stacks/iHasElementalDefinition.java index 480707d570..1d8af7bab7 100644 --- a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/stacks/iHasElementalDefinition.java +++ b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/stacks/iHasElementalDefinition.java @@ -8,11 +8,11 @@ import com.github.technus.tectech.mechanics.elementalMatter.core.templates.iElem public interface iHasElementalDefinition extends Comparable<iHasElementalDefinition>,Cloneable { iElementalDefinition getDefinition(); - long getAmount(); + double getAmount(); - long getCharge(); + double getCharge(); - float getMass(); + double getMass(); iHasElementalDefinition clone(); } diff --git a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/templates/cElementalDefinition.java b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/templates/cElementalDefinition.java index de8ccb7b2b..51025148a7 100644 --- a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/templates/cElementalDefinition.java +++ b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/templates/cElementalDefinition.java @@ -100,8 +100,8 @@ public abstract class cElementalDefinition extends iElementalDefinition { } @Override - public final cElementalDefinitionStack getStackForm(long i) { - return new cElementalDefinitionStack(this,i); + public final cElementalDefinitionStack getStackForm(double amount) { + return new cElementalDefinitionStack(this, amount); } @Override @@ -122,8 +122,14 @@ public abstract class cElementalDefinition extends iElementalDefinition { public int hashCode() {//Internal amounts should be also hashed int hash = -(getSubParticles().size() << 4); for (cElementalDefinitionStack stack : getSubParticles().values()) { - hash += ((stack.amount & 0x1) == 0 ? -stack.amount : stack.amount) + stack.definition.hashCode(); + int amount=(int)stack.amount; + hash += ((amount & 0x1) == 0 ? -amount : amount) + stack.definition.hashCode(); } return hash; } + + @Override + public String toString() { + return getName()+ '\n' + getSymbol(); + } } 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 701682cdaa..6ee8591c58 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 @@ -11,9 +11,7 @@ import net.minecraft.client.Minecraft; import net.minecraft.crash.CrashReport; import net.minecraft.nbt.NBTTagCompound; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Map; +import java.util.*; import static com.github.technus.tectech.util.Util.areBitsSet; import static com.github.technus.tectech.loader.TecTechConfig.DEBUG_MODE; @@ -37,7 +35,7 @@ public abstract class cElementalPrimitive extends cElementalDefinition { public final String name; public final String symbol; //float-mass in eV/c^2 - public final float mass; + public final double mass; //int -electric charge in 1/3rds of electron charge for optimization public final byte charge; //byte color; 0=Red 1=Green 2=Blue 0=Cyan 1=Magenta 2=Yellow, else ignored (-1 - uncolorable) @@ -49,7 +47,7 @@ public abstract class cElementalPrimitive extends cElementalDefinition { private cElementalDecay[] elementalDecays; private byte naturalDecayInstant; private byte energeticDecayInstant; - private float rawLifeTime; + private double rawLifeTime; public final int ID; @@ -57,7 +55,7 @@ public abstract class cElementalPrimitive extends cElementalDefinition { // _ at end - anti particle // __ at end - self is antiparticle - protected cElementalPrimitive(String name, String symbol, int type, float mass, int charge, int color, int ID) { + protected cElementalPrimitive(String name, String symbol, int type, double mass, int charge, int color, int ID) { this.name = name; this.symbol = symbol; this.type = (byte) type; @@ -72,12 +70,12 @@ public abstract class cElementalPrimitive extends cElementalDefinition { } // - protected void init(cElementalPrimitive antiParticle, float rawLifeTime, int naturalInstant, int energeticInstant, cElementalDecay... elementalDecaysArray) { + protected void init(cElementalPrimitive antiParticle, double rawLifeTime, int naturalInstant, int energeticInstant, cElementalDecay... elementalDecaysArray) { anti = antiParticle; this.rawLifeTime = rawLifeTime; naturalDecayInstant = (byte) naturalInstant; energeticDecayInstant = (byte) energeticInstant; - elementalDecays = elementalDecaysArray; + elementalDecays =elementalDecaysArray; } @Override @@ -111,7 +109,7 @@ public abstract class cElementalPrimitive extends cElementalDefinition { } @Override - public float getMass() { + public double getMass() { return mass; } @@ -136,7 +134,7 @@ public abstract class cElementalPrimitive extends cElementalDefinition { } @Override - public float getEnergyDiffBetweenStates(long currentEnergyLevel, long newEnergyLevel) { + public double getEnergyDiffBetweenStates(long currentEnergyLevel, long newEnergyLevel) { return iElementalDefinition.DEFAULT_ENERGY_REQUIREMENT *(newEnergyLevel-currentEnergyLevel); } @@ -166,7 +164,7 @@ public abstract class cElementalPrimitive extends cElementalDefinition { } @Override - public float getRawTimeSpan(long currentEnergy) { + public double getRawTimeSpan(long currentEnergy) { return rawLifeTime; } @@ -234,7 +232,7 @@ public abstract class cElementalPrimitive extends cElementalDefinition { lines.add("SYMBOL = "+getSymbol()); } if(areBitsSet(SCAN_GET_CHARGE,capabilities)) { - lines.add("CHARGE = " + getCharge() / 3f + " e"); + lines.add("CHARGE = " + getCharge() / 3D + " e"); } if(areBitsSet(SCAN_GET_COLOR,capabilities)) { lines.add(getColor() < 0 ? "COLORLESS" : "CARRIES COLOR"); 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 08be835cdf..90ac2eb339 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 @@ -14,10 +14,10 @@ import java.util.ArrayList; * Created by danie_000 on 11.11.2016. */ public abstract class iElementalDefinition implements Comparable<iElementalDefinition>,Cloneable {//IMMUTABLE - public static final float STABLE_RAW_LIFE_TIME =1.5e36f; - public static final float NO_DECAY_RAW_LIFE_TIME=-1; + public static final double STABLE_RAW_LIFE_TIME =1.5e36D; + public static final double NO_DECAY_RAW_LIFE_TIME=-1D; public static final long DEFAULT_ENERGY_LEVEL=0; - public static final float DEFAULT_ENERGY_REQUIREMENT=25000;//legit cuz normal atoms should only emit a gamma if they don't have defined energy levels + public static final double DEFAULT_ENERGY_REQUIREMENT=25000D;//legit cuz normal atoms should only emit a gamma if they don't have defined energy levels //Nomenclature public abstract String getName(); @@ -43,24 +43,24 @@ public abstract class iElementalDefinition implements Comparable<iElementalDefin public abstract cElementalDecay[] getEnergyInducedDecay(long energyLevel);//energetic decay - public abstract boolean usesSpecialEnergeticDecayHandling(); + public abstract boolean usesSpecialEnergeticDecayHandling(); public abstract boolean usesMultipleDecayCalls(long energyLevel); public abstract boolean decayMakesEnergy(long energyLevel); - public abstract boolean fusionMakesEnergy(long energyLevel); + public abstract boolean fusionMakesEnergy(long energyLevel); - public abstract float getEnergyDiffBetweenStates(long currentEnergy, long newEnergyLevel);//positive or negative + public abstract double getEnergyDiffBetweenStates(long currentEnergy, long newEnergyLevel);//positive or negative - public abstract float getMass();//mass... MeV/c^2 + public abstract double getMass();//mass... MeV/c^2 public abstract int getCharge();//charge 1/3 electron charge //dynamically changing stuff public abstract byte getColor();//-1 nope cannot 0 it can but undefined - public abstract float getRawTimeSpan(long currentEnergy);//defined in static fields or generated + public abstract double getRawTimeSpan(long currentEnergy);//defined in static fields or generated public abstract boolean isTimeSpanHalfLife(); @@ -74,7 +74,7 @@ public abstract class iElementalDefinition implements Comparable<iElementalDefin public abstract NBTTagCompound toNBT(); - public abstract cElementalDefinitionStack getStackForm(long i); + public abstract cElementalDefinitionStack getStackForm(double amount); @Override public abstract iElementalDefinition clone(); diff --git a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/transformations/aFluidDequantizationInfo.java b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/transformations/aFluidDequantizationInfo.java index 057d9cdb36..3d8b7a881f 100644 --- a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/transformations/aFluidDequantizationInfo.java +++ b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/transformations/aFluidDequantizationInfo.java @@ -7,7 +7,7 @@ import net.minecraftforge.fluids.FluidStack; /** * Created by Tec on 23.05.2017. */ -public class aFluidDequantizationInfo implements iExchangeInfo { +public class aFluidDequantizationInfo implements iExchangeInfo<iHasElementalDefinition,FluidStack> { private final iHasElementalDefinition in; private final FluidStack out; @@ -16,12 +16,6 @@ public class aFluidDequantizationInfo implements iExchangeInfo { out=fluidStackOut; } - @Deprecated - public aFluidDequantizationInfo(iHasElementalDefinition emIn ,int fluidID,int fluidAmount) { - in = emIn; - out = new FluidStack(fluidID, fluidAmount); - } - public aFluidDequantizationInfo(iHasElementalDefinition emIn, Fluid fluid, int fluidAmount){ in=emIn; out=new FluidStack(fluid,fluidAmount); diff --git a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/transformations/aFluidQuantizationInfo.java b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/transformations/aFluidQuantizationInfo.java index 57ce67bf6d..563b87f8ee 100644 --- a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/transformations/aFluidQuantizationInfo.java +++ b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/transformations/aFluidQuantizationInfo.java @@ -7,7 +7,7 @@ import net.minecraftforge.fluids.FluidStack; /** * Created by Tec on 23.05.2017. */ -public class aFluidQuantizationInfo implements iExchangeInfo { +public class aFluidQuantizationInfo implements iExchangeInfo<FluidStack,iHasElementalDefinition> { private final FluidStack in; private final iHasElementalDefinition out; @@ -16,12 +16,6 @@ public class aFluidQuantizationInfo implements iExchangeInfo { out=emOut; } - @Deprecated - public aFluidQuantizationInfo(int fluidID,int fluidAmount, iHasElementalDefinition emOut){ - in=new FluidStack(fluidID,fluidAmount); - out=emOut; - } - public aFluidQuantizationInfo(Fluid fluid, int fluidAmount, iHasElementalDefinition emOut){ in=new FluidStack(fluid,fluidAmount); out=emOut; diff --git a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/transformations/aItemDequantizationInfo.java b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/transformations/aItemDequantizationInfo.java index b764f59863..8b42c61d6c 100644 --- a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/transformations/aItemDequantizationInfo.java +++ b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/transformations/aItemDequantizationInfo.java @@ -9,7 +9,7 @@ import net.minecraft.item.ItemStack; /** * Created by Tec on 23.05.2017. */ -public class aItemDequantizationInfo implements iExchangeInfo { +public class aItemDequantizationInfo implements iExchangeInfo<iHasElementalDefinition,ItemStack> { private final iHasElementalDefinition in; private final ItemStack out; diff --git a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/transformations/aItemQuantizationInfo.java b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/transformations/aItemQuantizationInfo.java index 80179e1eb8..8f33f5096d 100644 --- a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/transformations/aItemQuantizationInfo.java +++ b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/transformations/aItemQuantizationInfo.java @@ -11,7 +11,7 @@ import net.minecraftforge.oredict.OreDictionary; /** * Created by Tec on 23.05.2017. */ -public class aItemQuantizationInfo implements iExchangeInfo { +public class aItemQuantizationInfo implements iExchangeInfo<ItemStack,iHasElementalDefinition> { private final ItemStack in; private final boolean skipNBT; private final iHasElementalDefinition out; diff --git a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/transformations/aOredictDequantizationInfo.java b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/transformations/aOredictDequantizationInfo.java index 51b1a6806d..bbf94682b4 100644 --- a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/transformations/aOredictDequantizationInfo.java +++ b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/transformations/aOredictDequantizationInfo.java @@ -3,37 +3,30 @@ package com.github.technus.tectech.mechanics.elementalMatter.core.transformation import com.github.technus.tectech.mechanics.elementalMatter.core.stacks.iHasElementalDefinition; import gregtech.api.enums.Materials; import gregtech.api.enums.OrePrefixes; -import net.minecraftforge.oredict.OreDictionary; /** * Created by Tec on 23.05.2017. */ -public class aOredictDequantizationInfo implements iExchangeInfo { +public class aOredictDequantizationInfo implements iExchangeInfo<iHasElementalDefinition,String> { private final iHasElementalDefinition in; - public final int out; + public final String out; public final int amount; - public aOredictDequantizationInfo(iHasElementalDefinition emIn, int id, int qty) { - in = emIn; - out = id; - amount = qty; - } - public aOredictDequantizationInfo(iHasElementalDefinition emIn, String name, int qty) { in = emIn; - out = OreDictionary.getOreID(name); + out =name; amount = qty; } public aOredictDequantizationInfo(iHasElementalDefinition emIn, OrePrefixes prefix, Materials material, int qty) { in = emIn; - out = OreDictionary.getOreID(prefix.name() + material.mName); + out = prefix.name() + material.mName; amount = qty; } public aOredictDequantizationInfo(iHasElementalDefinition emIn, OrePrefixes prefix, String materialName, int qty) { in = emIn; - out = OreDictionary.getOreID(prefix.name() + materialName); + out = prefix.name() + materialName; amount = qty; } @@ -43,7 +36,7 @@ public class aOredictDequantizationInfo implements iExchangeInfo { } @Override - public Integer output() { + public String output() { return out; } diff --git a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/transformations/aOredictQuantizationInfo.java b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/transformations/aOredictQuantizationInfo.java index 99e8589060..964d317b80 100644 --- a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/transformations/aOredictQuantizationInfo.java +++ b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/transformations/aOredictQuantizationInfo.java @@ -3,42 +3,35 @@ package com.github.technus.tectech.mechanics.elementalMatter.core.transformation import com.github.technus.tectech.mechanics.elementalMatter.core.stacks.iHasElementalDefinition; import gregtech.api.enums.Materials; import gregtech.api.enums.OrePrefixes; -import net.minecraftforge.oredict.OreDictionary; /** * Created by Tec on 23.05.2017. */ -public class aOredictQuantizationInfo implements iExchangeInfo { - public final int in; +public class aOredictQuantizationInfo implements iExchangeInfo<String,iHasElementalDefinition> { + public final String in; public final int amount; private final iHasElementalDefinition out; - public aOredictQuantizationInfo(int id, int qty, iHasElementalDefinition emOut){ - in=id; - amount=qty; - out=emOut; - } - public aOredictQuantizationInfo(String name, int qty, iHasElementalDefinition emOut){ - in=OreDictionary.getOreID(name); + in=name; amount=qty; out=emOut; } - public aOredictQuantizationInfo( OrePrefixes prefix, Materials material, int qty, iHasElementalDefinition emOut){ - in=OreDictionary.getOreID(prefix.name() + material.mName); + public aOredictQuantizationInfo(OrePrefixes prefix, Materials material, int qty, iHasElementalDefinition emOut){ + in=prefix.name() + material.mName; amount=qty; out=emOut; } - public aOredictQuantizationInfo( OrePrefixes prefix, String materialName, int qty, iHasElementalDefinition emOut){ - in=OreDictionary.getOreID(prefix.name() + materialName); + public aOredictQuantizationInfo(OrePrefixes prefix, String materialName, int qty, iHasElementalDefinition emOut){ + in=prefix.name() + materialName; amount=qty; out=emOut; } @Override - public Integer input() { + public String input() { return in; } @@ -49,7 +42,7 @@ public class aOredictQuantizationInfo implements iExchangeInfo { @Override public int hashCode() { - return in; + return in.hashCode(); } @Override diff --git a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/transformations/bTransformationInfo.java b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/transformations/bTransformationInfo.java index c23894d6b1..c9ac204554 100644 --- a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/transformations/bTransformationInfo.java +++ b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/transformations/bTransformationInfo.java @@ -17,13 +17,18 @@ import static com.github.technus.tectech.thing.item.DebugElementalInstanceContai * Created by Tec on 26.05.2017. */ public class bTransformationInfo { + public static final double AVOGADRO_CONSTANT =6.02214076e23D; + public static final double AVOGADRO_CONSTANT_UNCERTAINTY =(144*1000)/6.02214076e23D; + public static final double AVOGADRO_CONSTANT_144 = AVOGADRO_CONSTANT *144D; + public static final HashMap<Integer,aFluidQuantizationInfo> fluidQuantization=new HashMap<>(32); + public static final HashMap<aItemQuantizationInfo,aItemQuantizationInfo> itemQuantization=new HashMap<>(32); + public static final HashMap<Integer,aOredictQuantizationInfo> oredictQuantization=new HashMap<>(32); + public HashMap<iElementalDefinition,aFluidDequantizationInfo> fluidDequantization; - public static final HashMap<aItemQuantizationInfo,aItemQuantizationInfo> itemQuantization=new HashMap<>(32); public HashMap<iElementalDefinition,aItemDequantizationInfo> itemDequantization; - public static final HashMap<Integer,aOredictQuantizationInfo> oredictQuantization=new HashMap<>(32); public HashMap<iElementalDefinition,aOredictDequantizationInfo> oredictDequantization; public bTransformationInfo(int fluidCap,int itemCap, int oreCap){ @@ -45,13 +50,6 @@ public class bTransformationInfo { STACKS_REGISTERED.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)); - STACKS_REGISTERED.add(em.getDefinition()); - STACKS_REGISTERED.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)); @@ -77,13 +75,6 @@ public class bTransformationInfo { STACKS_REGISTERED.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)); - STACKS_REGISTERED.add(em.getDefinition()); - STACKS_REGISTERED.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)); diff --git a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/transformations/iExchangeInfo.java b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/transformations/iExchangeInfo.java index f4e77bfe2b..2e8ef92073 100644 --- a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/transformations/iExchangeInfo.java +++ b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/transformations/iExchangeInfo.java @@ -3,9 +3,9 @@ package com.github.technus.tectech.mechanics.elementalMatter.core.transformation /** * Created by Tec on 23.05.2017. */ -public interface iExchangeInfo { - Object output();//what should be given - ItemStack,FluidStack,AspectStack, (EM definitionStack->)EM instance stack - etc. +public interface iExchangeInfo<IN,OUT> { + OUT output();//what should be given - ItemStack,FluidStack,AspectStack, (EM definitionStack->)EM instance stack - etc. //This must return new Object! - if obj is immutable don't care that much (applies to defStacks) - Object input();//same as above but for input + IN input();//same as above but for input } 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 index 205851c61b..965c46cef6 100644 --- 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 @@ -2,8 +2,6 @@ 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.Util; -import com.github.technus.tectech.util.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; @@ -19,18 +17,21 @@ 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.eLeptonDefinition; import com.github.technus.tectech.mechanics.elementalMatter.definitions.primitive.eNeutrinoDefinition; +import com.github.technus.tectech.util.Util; +import com.github.technus.tectech.util.XSTR; 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.util.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.core.transformations.bTransformationInfo.AVOGADRO_CONSTANT_144; 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 com.github.technus.tectech.util.XSTR.XSTR_INSTANCE; import static gregtech.api.enums.OrePrefixes.dust; /** @@ -41,17 +42,17 @@ public final class dAtomDefinition extends cElementalDefinition { 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; + public static final bTransformationInfo TRANSFORMATION_INFO = new bTransformationInfo(16,0,64); + public static double refMass, refUnstableMass; private static final byte nbtType = (byte) 'a'; private static final Random xstr = new XSTR();//NEEDS SEPARATE! private static Map<Integer, TreeSet<Integer>> stableIsotopes = new HashMap<>(); private static final Map<Integer, dAtomDefinition> stableAtoms = new HashMap<>(); - private static Map<Integer, TreeMap<Float, Integer>> mostStableUnstableIsotopes = new HashMap<>(); + private static Map<Integer, TreeMap<Double, Integer>> mostStableUnstableIsotopes = new HashMap<>(); private static final Map<Integer, dAtomDefinition> unstableAtoms = new HashMap<>(); private static cElementalDefinitionStack alpha,deuterium,tritium,helium_3,beryllium_8,carbon_14,neon_24,silicon_34; - private static final HashMap<dAtomDefinition,Float> lifetimeOverrides = new HashMap<>(); + private static final HashMap<dAtomDefinition,Double> lifetimeOverrides = new HashMap<>(); public final iaeaNuclide iaea; @@ -61,17 +62,17 @@ public final class dAtomDefinition extends cElementalDefinition { } private static final ArrayList<Runnable> overrides = new ArrayList<>(); - public static void addOverride(dAtomDefinition atom, float rawLifeTime){ + public static void addOverride(dAtomDefinition atom, double rawLifeTime){ lifetimeOverrides.put(atom,rawLifeTime); } //float-mass in eV/c^2 - public final float mass; + public final double 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; + private double rawLifeTime; //generation max present inside - minus if contains any anti quark public final byte type; @@ -115,7 +116,7 @@ public final class dAtomDefinition extends cElementalDefinition { } elementalStacks = things; - float mass = 0; + double mass = 0; int cLeptons = 0; int cNucleus = 0; int neutralCount = 0, element = 0; @@ -124,6 +125,9 @@ public final class dAtomDefinition extends cElementalDefinition { for (cElementalDefinitionStack stack : elementalStacks.values()) { iElementalDefinition def = stack.definition; int amount = (int)stack.amount; + if((int)stack.amount!=stack.amount){ + throw new ArithmeticException("Amount cannot be safely converted to int!"); + } mass += stack.getMass(); if (def.getType() < 0) { containsAnti = true; @@ -160,36 +164,36 @@ public final class dAtomDefinition extends cElementalDefinition { xstr.setSeed((element + 1L) * (neutralCount + 100L)); iaea =iaeaNuclide.get(element,neutralCount); if(iaea!=null){ - if(Float.isNaN(iaea.mass)) { + if(Double.isNaN(iaea.mass)) { this.mass = mass; } else { this.mass = iaea.mass; } - if(Float.isNaN(iaea.halfTime)) { - Float overriddenLifeTime= lifetimeOverrides.get(this); - float rawLifeTimeTemp; + if(Double.isNaN(iaea.halfTime)) { + Double overriddenLifeTime= lifetimeOverrides.get(this); + double 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; + rawLifeTime = Math.min(rawLifeTimeTemp, STABLE_RAW_LIFE_TIME); }else { - rawLifeTime = containsAnti ? iaea.halfTime * 1.5514433E-21f * (1f + xstr.nextFloat() * 9f) : iaea.halfTime; + rawLifeTime = containsAnti ? iaea.halfTime * 1.5514433E-21d * (1d + xstr.nextDouble() * 9d) : iaea.halfTime; } iaeaDefinitionExistsAndHasEnergyLevels =iaea.energeticStatesArray.length>1; }else{ this.mass=mass; - Float overriddenLifeTime= lifetimeOverrides.get(this); - float rawLifeTimeTemp; + Double overriddenLifeTime= lifetimeOverrides.get(this); + double 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; + rawLifeTime = Math.min(rawLifeTimeTemp, STABLE_RAW_LIFE_TIME); iaeaDefinitionExistsAndHasEnergyLevels =false; } @@ -204,55 +208,54 @@ public final class dAtomDefinition extends cElementalDefinition { 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); + return (int) Math.round(-1.19561E-06D * Math.pow(element, 4D) + + 1.60885E-04D * Math.pow(element, 3D) + + 3.76604E-04D * Math.pow(element, 2D) + + 1.08418E+00D * (double) element); } - private static float calculateLifeTime(int izoDiff, int izoDiffAbs, int element, int isotope, boolean containsAnti) { - float rawLifeTime; + private static double calculateLifeTime(int izoDiff, int izoDiffAbs, int element, int isotope, boolean containsAnti) { + double 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; + rawLifeTime = (1D + xstr.nextDouble() * 9D) * (containsAnti ? 2.381e4D : 1.5347e25D); } else { //Y = (X-A)/(B-A) * (D-C) + C - float unstabilityEXP; + double unstabilityEXP; if (element == 0) { - return 1e-35f; + return 1e-35D; } else if (element == 1) { - unstabilityEXP = 1.743f - Math.abs(izoDiff - 1) * 9.743f; + unstabilityEXP = 1.743D - Math.abs(izoDiff - 1) * 9.743D; } else if (element == 2) { switch (isotope) { case 4: - unstabilityEXP = 1.61f; + unstabilityEXP = 1.61D; break; case 5: - unstabilityEXP = -7.523F; + unstabilityEXP = -7.523D; break; case 6: - unstabilityEXP = -1.51f; + unstabilityEXP = -1.51D; break; default: - unstabilityEXP = -(izoDiffAbs * 6.165F); + unstabilityEXP = -(izoDiffAbs * 6.165D); break; } } else if (element <= 83 || isotope <= 127 && element <= 120) { - float elementPow4 = (float) Math.pow(element, 4f); + double elementPow4 = Math.pow(element, 4); - 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); + unstabilityEXP = Math.min(element / 2.4D, 6 + ((element + 1) % 2) * 3e6D / elementPow4) + -izoDiff * elementPow4 / 1e8D - Math.abs(izoDiff - 1 + element / 60D) * (3D - element / 12.5D + element * element / 1500D); } 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); + unstabilityEXP = Math.min((element - 85) * 2, 16 + ((isotope + 1) % 2) * 2.5D - (element - 85) / 3D) - Math.abs(izoDiff) * (3D - element / 13D + element * element / 1600D); } else { return -1; } if ((isotope == 127 || isotope == 128) && element < 120 && element > 83) { - unstabilityEXP -= 1.8f; + unstabilityEXP -= 1.8D; } if (element > 83 && element < 93 && isotope % 2 == 0 && izoDiff == 3) { unstabilityEXP += 6; @@ -260,14 +263,14 @@ public final class dAtomDefinition extends cElementalDefinition { 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); + rawLifeTime = (containsAnti ? 1e-8D : 1) * Math.pow(10D, unstabilityEXP) * (1D + xstr.nextDouble() * 9D); } - if (rawLifeTime < 8e-15) { - return 1e-35f; + if (rawLifeTime < 8e-15D) { + return 1e-35D; } - if (rawLifeTime > 8e28) { - return 8e30f; + if (rawLifeTime > 8e28D) { + return 8e30D; } return rawLifeTime; } @@ -284,6 +287,9 @@ public final class dAtomDefinition extends cElementalDefinition { } else if (!(stack.definition instanceof eLeptonDefinition)) { return false; } + if((int)stack.amount!=stack.amount){ + throw new ArithmeticException("Amount cannot be safely converted to int!"); + } qty+=stack.amount; } return nuclei && qty<ATOM_COMPLEXITY_LIMIT; @@ -307,7 +313,7 @@ public final class dAtomDefinition extends cElementalDefinition { } @Override - public float getMass() { + public double getMass() { return mass; } @@ -317,7 +323,7 @@ public final class dAtomDefinition extends cElementalDefinition { } @Override - public float getRawTimeSpan(long currentEnergy) { + public double getRawTimeSpan(long currentEnergy) { if(currentEnergy<=0) { return rawLifeTime; } @@ -346,9 +352,9 @@ public final class dAtomDefinition extends cElementalDefinition { boolean negative = this.element < 0; try { if (Math.abs(type) != 1) { - return (negative ? "~? " : "? ") + nomenclature.Name[element]; + return (negative ? "~? " : "? ") + Nomenclature.NAME[element]; } - return negative ? '~' + nomenclature.Name[element] : nomenclature.Name[element]; + return negative ? '~' + Nomenclature.NAME[element] : Nomenclature.NAME[element]; } catch (Exception e) { if (DEBUG_MODE) { e.printStackTrace(); @@ -362,14 +368,14 @@ public final class dAtomDefinition extends cElementalDefinition { int element = Math.abs(this.element); boolean negative = this.element < 0; try { - return (negative ? "~" : "") + nomenclature.Symbol[element] + " N:" + neutralCount + " I:" + (neutralCount+element) + " C:" + getCharge(); + 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(); + return (negative ? "~" : "") + Nomenclature.SYMBOL_IUPAC[10 + s100] + Nomenclature.SYMBOL_IUPAC[s10] + Nomenclature.SYMBOL_IUPAC[s1] + " N:" + neutralCount + " I:" + (neutralCount+element) + " C:" + getCharge(); } catch (Exception E) { if (DEBUG_MODE) { e.printStackTrace(); @@ -384,14 +390,14 @@ public final class dAtomDefinition extends cElementalDefinition { int element = Math.abs(this.element); boolean negative = this.element < 0; try { - return (negative ? "~" : "") + nomenclature.Symbol[element]; + 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]; + return (negative ? "~" : "") + Nomenclature.SYMBOL_IUPAC[10 + s100] + Nomenclature.SYMBOL_IUPAC[s10] + Nomenclature.SYMBOL_IUPAC[s1]; } catch (Exception E) { if (DEBUG_MODE) { e.printStackTrace(); @@ -412,7 +418,7 @@ public final class dAtomDefinition extends cElementalDefinition { return getDecayArray(decaysList,decayMode,true); } - private cElementalDecay[] getDecayArray(ArrayList<cElementalDecay> decaysList,int decayMode,boolean tryAnti) { + private cElementalDecay[] getDecayArray(ArrayList<cElementalDecay> decaysList,int decayMode,boolean tryAnti) {//todo? if (type == 1) { switch (decayMode) { case -2: @@ -981,14 +987,13 @@ public final class dAtomDefinition extends cElementalDefinition { 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; } + return true; } //break; case "IT+EC+B+": { if (withThis.removeAllAmounts(false, dHadronDefinition.hadron_p2,eLeptonDefinition.lepton_e1)){ @@ -1022,7 +1027,7 @@ public final class dAtomDefinition extends cElementalDefinition { 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)); + decaysList.add(new cElementalDecay(1, new cElementalDefinitionStack(new dAtomDefinition(tree.toImmutable_optimized_unsafeLeavesExposedElementalTree()), 1), emit)); return true; } catch (Exception e) { if (DEBUG_MODE) { @@ -1037,7 +1042,7 @@ public final class dAtomDefinition extends cElementalDefinition { 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)); + decaysList.add(new cElementalDecay(1, new cElementalDefinitionStack(new dAtomDefinition(tree.toImmutable_optimized_unsafeLeavesExposedElementalTree()), 1), alpha)); return true; } catch (Exception e) { if (DEBUG_MODE) { @@ -1053,7 +1058,7 @@ public final class dAtomDefinition extends cElementalDefinition { 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)); + decaysList.add(new cElementalDecay(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) { @@ -1069,7 +1074,7 @@ public final class dAtomDefinition extends cElementalDefinition { 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)); + decaysList.add(new cElementalDecay(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) { @@ -1085,7 +1090,7 @@ public final class dAtomDefinition extends cElementalDefinition { 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)); + decaysList.add(new cElementalDecay(1, new cElementalDefinitionStack(new dAtomDefinition(tree.toImmutable_optimized_unsafeLeavesExposedElementalTree()), 1), eNeutrinoDefinition.lepton_Ve1)); return true; } catch (Exception e) { if (DEBUG_MODE) { @@ -1096,7 +1101,7 @@ public final class dAtomDefinition extends cElementalDefinition { return false; } - private boolean Fission(ArrayList<cElementalDecay> decaysList, cElementalMutableDefinitionStackMap fissile, cElementalMutableDefinitionStackMap particles,float probability,boolean spontaneousCheck) { + private boolean Fission(ArrayList<cElementalDecay> decaysList, cElementalMutableDefinitionStackMap fissile, cElementalMutableDefinitionStackMap particles,double probability,boolean spontaneousCheck) { cElementalMutableDefinitionStackMap heavy = new cElementalMutableDefinitionStackMap(); double[] liquidDrop= liquidDropFunction(Math.abs(element)<=97); @@ -1124,7 +1129,7 @@ public final class dAtomDefinition extends cElementalDefinition { //} }else{ int heavy_cnt=(int)Math.ceil(stack.amount*liquidDrop[0]); - if(heavy_cnt%2==1 && XSTR_INSTANCE.nextFloat()>0.05f) { + if(heavy_cnt%2==1 && XSTR_INSTANCE.nextDouble()>0.05D) { heavy_cnt--; } cElementalDefinitionStack new_stack=new cElementalDefinitionStack(stack.definition, heavy_cnt); @@ -1198,9 +1203,9 @@ public final class dAtomDefinition extends cElementalDefinition { } @Override - public float getEnergyDiffBetweenStates(long currentEnergyLevel,long newEnergyLevel) { + public double getEnergyDiffBetweenStates(long currentEnergyLevel,long newEnergyLevel) { if(iaeaDefinitionExistsAndHasEnergyLevels){ - float result=0; + double result=0; boolean backwards=newEnergyLevel<currentEnergyLevel; if(backwards){ long temp=currentEnergyLevel; @@ -1278,7 +1283,7 @@ public final class dAtomDefinition extends cElementalDefinition { decaysInto.add(new cElementalDefinitionStack(boson_Y__, 2)); } } - return new cElementalDecay[]{new cElementalDecay(0.75F, decaysInto.toArray(new cElementalDefinitionStack[0])), deadEnd}; + return new cElementalDecay[]{new cElementalDecay(0.75D, decaysInto.toArray(new cElementalDefinitionStack[0])), deadEnd}; } //@Override @@ -1314,23 +1319,23 @@ public final class dAtomDefinition extends cElementalDefinition { @Override public aFluidDequantizationInfo someAmountIntoFluidStack() { - return transformation.fluidDequantization.get(this); + return TRANSFORMATION_INFO.fluidDequantization.get(this); } @Override public aItemDequantizationInfo someAmountIntoItemsStack() { - return null; + return TRANSFORMATION_INFO.itemDequantization.get(this); } @Override public aOredictDequantizationInfo someAmountIntoOredictStack() { - return transformation.oredictDequantization.get(this); + return TRANSFORMATION_INFO.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"}; + private static final class Nomenclature { + private static final String[] SYMBOL = new String[]{"Nt", "H", "He", "Li", "Be", "B", "C", "N", "O", "F", "Ne", "Na", "Mg", "Al", "Si", "P", "S", "Cl", "Ar", "K", "Ca", "Sc", "Ti", "V", "Cr", "Mn", "Fe", "Co", "Ni", "Cu", "Zn", "Ga", "Ge", "As", "Se", "Br", "Kr", "Rb", "Sr", "Y", "Zr", "Nb", "Mo", "Tc", "Ru", "Rh", "Pd", "Ag", "Cd", "In", "Sn", "Sb", "Te", "I", "Xe", "Cs", "Ba", "La", "Ce", "Pr", "Nd", "Pm", "Sm", "Eu", "Gd", "Tb", "Dy", "Ho", "Er", "Tm", "Yb", "Lu", "Hf", "Ta", "W", "Re", "Os", "Ir", "Pt", "Au", "Hg", "Tl", "Pb", "Bi", "Po", "At", "Rn", "Fr", "Ra", "Ac", "Th", "Pa", "U", "Np", "Pu", "Am", "Cm", "Bk", "Cf", "Es", "Fm", "Md", "No", "Lr", "Rf", "Db", "Sg", "Bh", "Hs", "Mt", "Ds", "Rg", "Cn", "Nh", "Fl", "Mc", "Lv", "Ts", "Og"}; + private static final String[] NAME = new String[]{"Neutronium", "Hydrogen", "Helium", "Lithium", "Beryllium", "Boron", "Carbon", "Nitrogen", "Oxygen", "Fluorine", "Neon", "Sodium", "Magnesium", "Aluminium", "Silicon", "Phosphorus", "Sulfur", "Chlorine", "Argon", "Potassium", "Calcium", "Scandium", "Titanium", "Vanadium", "Chromium", "Manganese", "Iron", "Cobalt", "Nickel", "Copper", "Zinc", "Gallium", "Germanium", "Arsenic", "Selenium", "Bromine", "Krypton", "Rubidium", "Strontium", "Yttrium", "Zirconium", "Niobium", "Molybdenum", "Technetium", "Ruthenium", "Rhodium", "Palladium", "Silver", "Cadmium", "Indium", "Tin", "Antimony", "Tellurium", "Iodine", "Xenon", "Caesium", "Barium", "Lanthanum", "Cerium", "Praseodymium", "Neodymium", "Promethium", "Samarium", "Europium", "Gadolinium", "Terbium", "Dysprosium", "Holmium", "Erbium", "Thulium", "Ytterbium", "Lutetium", "Hafnium", "Tantalum", "Tungsten", "Rhenium", "Osmium", "Iridium", "Platinum", "Gold", "Mercury", "Thallium", "Lead", "Bismuth", "Polonium", "Astatine", "Radon", "Francium", "Radium", "Actinium", "Thorium", "Protactinium", "Uranium", "Neptunium", "Plutonium", "Americium", "Curium", "Berkelium", "Californium", "Einsteinium", "Fermium", "Mendelevium", "Nobelium", "Lawrencium", "Rutherfordium", "Dubnium", "Seaborgium", "Bohrium", "Hassium", "Meitnerium", "Darmstadtium", "Roentgenium", "Copernicium", "Nihonium", "Flerovium", "Moscovium", "Livermorium", "Tennessine", "Oganesson"}; + private static final String[] SYMBOL_IUPAC = new String[]{"n", "u", "b", "t", "q", "p", "h", "s", "o", "e", "N", "U", "B", "T", "Q", "P", "H", "S", "O", "E"}; } @Override @@ -1358,7 +1363,7 @@ public final class dAtomDefinition extends cElementalDefinition { r.run(); } - for(Map.Entry<dAtomDefinition,Float> entry:lifetimeOverrides.entrySet()){ + for(Map.Entry<dAtomDefinition,Double> entry:lifetimeOverrides.entrySet()){ try { lifetimeOverrides.put(new dAtomDefinition(entry.getKey().elementalStacks), entry.getValue()); }catch (tElementalException e){ @@ -1375,7 +1380,7 @@ public final class dAtomDefinition extends cElementalDefinition { int StableIsotope = stableIzoCurve(element); int izoDiff = isotope - StableIsotope; int izoDiffAbs = Math.abs(izoDiff); - float rawLifeTime = calculateLifeTime(izoDiff, izoDiffAbs, element, isotope, false); + double 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<Integer> isotopes = stableIsotopes.computeIfAbsent(element, k -> new TreeSet<>()); @@ -1392,8 +1397,8 @@ public final class dAtomDefinition extends cElementalDefinition { int Isotope = stableIzoCurve(element); int izoDiff = isotope - Isotope; int izoDiffAbs = Math.abs(izoDiff); - float rawLifeTime = calculateLifeTime(izoDiff, izoDiffAbs, element, isotope, false); - TreeMap<Float, Integer> isotopes = mostStableUnstableIsotopes.computeIfAbsent(element, k -> new TreeMap<>()); + double rawLifeTime = calculateLifeTime(izoDiff, izoDiffAbs, element, isotope, false); + TreeMap<Double, Integer> isotopes = mostStableUnstableIsotopes.computeIfAbsent(element, k -> new TreeMap<>()); isotopes.put(rawLifeTime, isotope); } } @@ -1408,7 +1413,7 @@ public final class dAtomDefinition extends cElementalDefinition { TecTech.LOGGER.info("Added Stable Atom:" + integerTreeSetEntry.getKey() + ' ' + integerTreeSetEntry.getValue().first() + ' ' + stableAtoms.get(integerTreeSetEntry.getKey()).getMass()); } } - for (Map.Entry<Integer, TreeMap<Float, Integer>> integerTreeMapEntry : mostStableUnstableIsotopes.entrySet()) { + for (Map.Entry<Integer, TreeMap<Double, Integer>> 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()), @@ -1468,131 +1473,130 @@ public final class dAtomDefinition extends cElementalDefinition { 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); + refMass = getFirstStableIsotope(1).getMass() * AVOGADRO_CONSTANT_144; + + TRANSFORMATION_INFO.addFluid(new cElementalDefinitionStack(getFirstStableIsotope(1), AVOGADRO_CONSTANT_144),Materials.Hydrogen.mGas,144); + TRANSFORMATION_INFO.addFluid(new cElementalDefinitionStack(getFirstStableIsotope(2), AVOGADRO_CONSTANT_144),Materials.Helium.mGas, 144); + TRANSFORMATION_INFO.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(3), AVOGADRO_CONSTANT_144), dust, Materials.Lithium,1); + TRANSFORMATION_INFO.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(4), AVOGADRO_CONSTANT_144), dust, Materials.Beryllium,1); + TRANSFORMATION_INFO.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(5), AVOGADRO_CONSTANT_144), dust, Materials.Boron,1); + TRANSFORMATION_INFO.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(6), AVOGADRO_CONSTANT_144), dust, Materials.Carbon,1); + TRANSFORMATION_INFO.addFluid(new cElementalDefinitionStack(getFirstStableIsotope(7), AVOGADRO_CONSTANT_144),Materials.Nitrogen.mGas, 144); + TRANSFORMATION_INFO.addFluid(new cElementalDefinitionStack(getFirstStableIsotope(8), AVOGADRO_CONSTANT_144),Materials.Oxygen.mGas, 144); + TRANSFORMATION_INFO.addFluid(new cElementalDefinitionStack(getFirstStableIsotope(9), AVOGADRO_CONSTANT_144),Materials.Fluorine.mGas, 144); + //transformation.addFluid(new cElementalDefinitionStack(getFirstStableIsotope(10), AVOGADRO_CONSTANT_144),Materials.Neon.mGas.getID(), 144); + TRANSFORMATION_INFO.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(11), AVOGADRO_CONSTANT_144), dust, Materials.Sodium,1); + TRANSFORMATION_INFO.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(12), AVOGADRO_CONSTANT_144), dust, Materials.Magnesium,1); + TRANSFORMATION_INFO.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(13), AVOGADRO_CONSTANT_144), dust, Materials.Aluminium,1); + TRANSFORMATION_INFO.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(14), AVOGADRO_CONSTANT_144), dust, Materials.Silicon,1); + TRANSFORMATION_INFO.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(15), AVOGADRO_CONSTANT_144), dust, Materials.Phosphorus,1); + TRANSFORMATION_INFO.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(16), AVOGADRO_CONSTANT_144), dust, Materials.Sulfur,1); + TRANSFORMATION_INFO.addFluid(new cElementalDefinitionStack(getFirstStableIsotope(17), AVOGADRO_CONSTANT_144),Materials.Argon.mGas, 144); + TRANSFORMATION_INFO.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(19), AVOGADRO_CONSTANT_144), dust, Materials.Potassium,1); + TRANSFORMATION_INFO.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(20), AVOGADRO_CONSTANT_144), dust, Materials.Calcium,1); + TRANSFORMATION_INFO.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(21), AVOGADRO_CONSTANT_144), dust, Materials.Scandium,1); + TRANSFORMATION_INFO.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(22), AVOGADRO_CONSTANT_144), dust, Materials.Titanium,1); + TRANSFORMATION_INFO.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(23), AVOGADRO_CONSTANT_144), dust, Materials.Vanadium,1); + TRANSFORMATION_INFO.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(24), AVOGADRO_CONSTANT_144), dust, Materials.Chrome,1); + TRANSFORMATION_INFO.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(25), AVOGADRO_CONSTANT_144), dust, Materials.Manganese,1); + TRANSFORMATION_INFO.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(26), AVOGADRO_CONSTANT_144), dust, Materials.Iron,1); + TRANSFORMATION_INFO.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(27), AVOGADRO_CONSTANT_144), dust, Materials.Cobalt,1); + TRANSFORMATION_INFO.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(28), AVOGADRO_CONSTANT_144), dust, Materials.Nickel,1); + TRANSFORMATION_INFO.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(29), AVOGADRO_CONSTANT_144), dust, Materials.Copper,1); + TRANSFORMATION_INFO.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(30), AVOGADRO_CONSTANT_144), dust, Materials.Zinc,1); + TRANSFORMATION_INFO.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(31), AVOGADRO_CONSTANT_144), dust, Materials.Gallium,1); + //transformation.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(32), AVOGADRO_CONSTANT_144),OrePrefixes.dust, Materials.Germanium,1); + TRANSFORMATION_INFO.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(33), AVOGADRO_CONSTANT_144), dust, Materials.Arsenic,1); + //transformation.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(34), AVOGADRO_CONSTANT_144),OrePrefixes.dust, Materials.Selenium,1); + //transformation.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(35), AVOGADRO_CONSTANT_144),OrePrefixes.dust, Materials.Bromine,1); + //transformation.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(36), AVOGADRO_CONSTANT_144),OrePrefixes.dust, Materials.Krypton,1); + TRANSFORMATION_INFO.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(37), AVOGADRO_CONSTANT_144), dust, Materials.Rubidium,1); + TRANSFORMATION_INFO.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(38), AVOGADRO_CONSTANT_144), dust, Materials.Strontium,1); + TRANSFORMATION_INFO.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(39), AVOGADRO_CONSTANT_144), dust, Materials.Yttrium,1); + //transformation.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(40), AVOGADRO_CONSTANT_144),OrePrefixes.dust, Materials.Zirconium,1); + TRANSFORMATION_INFO.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(41), AVOGADRO_CONSTANT_144), dust, Materials.Niobium,1); + TRANSFORMATION_INFO.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(42), AVOGADRO_CONSTANT_144), dust, Materials.Molybdenum,1); + //transformation.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(43), AVOGADRO_CONSTANT_144),OrePrefixes.dust, Materials.Technetium,1); + //transformation.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(44), AVOGADRO_CONSTANT_144),OrePrefixes.dust, Materials.Ruthenium,1); + //transformation.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(45), AVOGADRO_CONSTANT_144),OrePrefixes.dust, Materials.Rhodium,1); + TRANSFORMATION_INFO.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(46), AVOGADRO_CONSTANT_144), dust, Materials.Palladium,1); + TRANSFORMATION_INFO.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(47), AVOGADRO_CONSTANT_144), dust, Materials.Silver,1); + TRANSFORMATION_INFO.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(48), AVOGADRO_CONSTANT_144), dust, Materials.Cadmium,1); + TRANSFORMATION_INFO.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(49), AVOGADRO_CONSTANT_144), dust, Materials.Indium,1); + TRANSFORMATION_INFO.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(50), AVOGADRO_CONSTANT_144), dust, Materials.Tin,1); + TRANSFORMATION_INFO.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(51), AVOGADRO_CONSTANT_144), dust, Materials.Antimony,1); + TRANSFORMATION_INFO.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(52), AVOGADRO_CONSTANT_144), dust, Materials.Tellurium,1); + //transformation.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(53), AVOGADRO_CONSTANT_144),OrePrefixes.dust, Materials.Iodine,1); + //transformation.addFluid(new cElementalDefinitionStack(getFirstStableIsotope(54), AVOGADRO_CONSTANT_144),Materials.Xenon.mGas.getID(), 144); + TRANSFORMATION_INFO.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(55), AVOGADRO_CONSTANT_144), dust, Materials.Caesium,1); + TRANSFORMATION_INFO.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(56), AVOGADRO_CONSTANT_144), dust, Materials.Barium,1); + TRANSFORMATION_INFO.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(57), AVOGADRO_CONSTANT_144), dust, Materials.Lanthanum,1); + TRANSFORMATION_INFO.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(58), AVOGADRO_CONSTANT_144), dust, Materials.Cerium,1); + TRANSFORMATION_INFO.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(59), AVOGADRO_CONSTANT_144), dust, Materials.Praseodymium,1); + TRANSFORMATION_INFO.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(60), AVOGADRO_CONSTANT_144), dust, Materials.Neodymium,1); + TRANSFORMATION_INFO.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(61), AVOGADRO_CONSTANT_144), dust, Materials.Promethium,1); + TRANSFORMATION_INFO.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(62), AVOGADRO_CONSTANT_144), dust, Materials.Samarium,1); + TRANSFORMATION_INFO.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(63), AVOGADRO_CONSTANT_144), dust, Materials.Europium,1); + TRANSFORMATION_INFO.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(64), AVOGADRO_CONSTANT_144), dust, Materials.Gadolinium,1); + TRANSFORMATION_INFO.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(65), AVOGADRO_CONSTANT_144), dust, Materials.Terbium,1); + TRANSFORMATION_INFO.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(66), AVOGADRO_CONSTANT_144), dust, Materials.Dysprosium,1); + TRANSFORMATION_INFO.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(67), AVOGADRO_CONSTANT_144), dust, Materials.Holmium,1); + TRANSFORMATION_INFO.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(68), AVOGADRO_CONSTANT_144), dust, Materials.Erbium,1); + TRANSFORMATION_INFO.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(69), AVOGADRO_CONSTANT_144), dust, Materials.Thulium,1); + TRANSFORMATION_INFO.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(70), AVOGADRO_CONSTANT_144), dust, Materials.Ytterbium,1); + TRANSFORMATION_INFO.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(71), AVOGADRO_CONSTANT_144), dust, Materials.Lutetium,1); + //transformation.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(72), AVOGADRO_CONSTANT_144),OrePrefixes.dust, Materials.Hafnum,1); + TRANSFORMATION_INFO.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(73), AVOGADRO_CONSTANT_144), dust, Materials.Tantalum,1); + TRANSFORMATION_INFO.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(74), AVOGADRO_CONSTANT_144), dust, Materials.Tungsten,1); + //transformation.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(75), AVOGADRO_CONSTANT_144),OrePrefixes.dust, Materials.Rhenium,1); + TRANSFORMATION_INFO.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(76), AVOGADRO_CONSTANT_144), dust, Materials.Osmium,1); + TRANSFORMATION_INFO.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(77), AVOGADRO_CONSTANT_144), dust, Materials.Iridium,1); + TRANSFORMATION_INFO.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(78), AVOGADRO_CONSTANT_144), dust, Materials.Platinum,1); + TRANSFORMATION_INFO.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(79), AVOGADRO_CONSTANT_144), dust, Materials.Gold,1); + TRANSFORMATION_INFO.addFluid(new cElementalDefinitionStack(getFirstStableIsotope(80), AVOGADRO_CONSTANT_144),Materials.Mercury.mFluid, 144); + //transformation.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(81), AVOGADRO_CONSTANT_144),OrePrefixes.dust, Materials.Thallium,1); + TRANSFORMATION_INFO.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(82), AVOGADRO_CONSTANT_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); + refUnstableMass = getFirstStableIsotope(82).getMass() * AVOGADRO_CONSTANT_144; + + TRANSFORMATION_INFO.addOredict(new cElementalDefinitionStack(getBestUnstableIsotope(83), AVOGADRO_CONSTANT_144), dust, Materials.Bismuth,1); + //transformation.addOredict(new cElementalDefinitionStack(getBestUnstableIsotope(84),AVOGADRO_CONSTANT_144),OrePrefixes.dust, Materials.Polonium,1); + //transformation.addFluid(new cElementalDefinitionStack(getBestUnstableIsotope(85),AVOGADRO_CONSTANT_144),Materials.Astatine.mPlasma.getID(), 144); + TRANSFORMATION_INFO.addFluid(new cElementalDefinitionStack(getBestUnstableIsotope(86), AVOGADRO_CONSTANT_144),Materials.Radon.mGas, 144); + //transformation.addOredict(new cElementalDefinitionStack(getBestUnstableIsotope(87),AVOGADRO_CONSTANT_144),OrePrefixes.dust, Materials.Francium,1); + //transformation.addOredict(new cElementalDefinitionStack(getBestUnstableIsotope(88),AVOGADRO_CONSTANT_144),OrePrefixes.dust, Materials.Radium,1); + //transformation.addOredict(new cElementalDefinitionStack(getBestUnstableIsotope(89),AVOGADRO_CONSTANT_144),OrePrefixes.dust, Materials.Actinium,1); + TRANSFORMATION_INFO.addOredict(new cElementalDefinitionStack(getBestUnstableIsotope(90), AVOGADRO_CONSTANT_144), dust, Materials.Thorium,1); + //transformation.addOredict(new cElementalDefinitionStack(getBestUnstableIsotope(91),AVOGADRO_CONSTANT_144),OrePrefixes.dust, Materials.Protactinium,1); + ////transformation.addOredict(new cElementalDefinitionStack(getBestUnstableIsotope(92),AVOGADRO_CONSTANT_144), dust, Materials.Uranium,1); + //transformation.addOredict(new cElementalDefinitionStack(getBestUnstableIsotope(93),AVOGADRO_CONSTANT_144),OrePrefixes.dust, Materials.Neptunium,1); + ////transformation.addOredict(new cElementalDefinitionStack(getBestUnstableIsotope(94),AVOGADRO_CONSTANT_144), dust, Materials.Plutonium,1); + TRANSFORMATION_INFO.addOredict(new cElementalDefinitionStack(getBestUnstableIsotope(95), AVOGADRO_CONSTANT_144), dust, Materials.Americium,1); try { dAtomDefinition temp; - transformation.addFluid(new cElementalDefinitionStack(deuterium.definition, 144),Materials.Deuterium.mGas.getID(), 144); + TRANSFORMATION_INFO.addFluid(new cElementalDefinitionStack(deuterium.definition, AVOGADRO_CONSTANT_144),Materials.Deuterium.mGas, 144); - transformation.addFluid(new cElementalDefinitionStack(tritium.definition, 144),Materials.Tritium.mGas.getID(), 144); + TRANSFORMATION_INFO.addFluid(new cElementalDefinitionStack(tritium.definition, AVOGADRO_CONSTANT_144),Materials.Tritium.mGas, 144); - transformation.addFluid(new cElementalDefinitionStack(helium_3.definition, 144),Materials.Helium_3.mGas.getID(), 144); + TRANSFORMATION_INFO.addFluid(new cElementalDefinitionStack(helium_3.definition, AVOGADRO_CONSTANT_144),Materials.Helium_3.mGas, 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); + TRANSFORMATION_INFO.addOredict(new cElementalDefinitionStack(temp, AVOGADRO_CONSTANT_144), dust, Materials.Uranium/*238*/,1); - float tempMass=temp.getMass(); + double 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); + TRANSFORMATION_INFO.addOredict(new cElementalDefinitionStack(temp, AVOGADRO_CONSTANT_144), dust, Materials.Uranium235,1); TecTech.LOGGER.info("Diff Mass U : "+(tempMass-temp.getMass())); @@ -1601,14 +1605,14 @@ public final class dAtomDefinition extends cElementalDefinition { new cElementalDefinitionStack(dHadronDefinition.hadron_p, 94), new cElementalDefinitionStack(dHadronDefinition.hadron_n, 145) ); - transformation.addOredict(new cElementalDefinitionStack(temp, 144), dust, Materials.Plutonium/*239*/,1); + TRANSFORMATION_INFO.addOredict(new cElementalDefinitionStack(temp, AVOGADRO_CONSTANT_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); + TRANSFORMATION_INFO.addOredict(new cElementalDefinitionStack(somethingHeavy, AVOGADRO_CONSTANT_144), dust, Materials.Plutonium241,1); TecTech.LOGGER.info("Diff Mass Pu: "+(somethingHeavy.getMass()-temp.getMass())); @@ -1664,7 +1668,7 @@ public final class dAtomDefinition extends cElementalDefinition { lines.add("SYMBOL = "+getSymbol()); } if(Util.areBitsSet(SCAN_GET_CHARGE,capabilities)) { - lines.add("CHARGE = " + getCharge() / 3f + " e"); + lines.add("CHARGE = " + getCharge() / 3D + " e"); } if(Util.areBitsSet(SCAN_GET_COLOR,capabilities)) { lines.add(getColor() < 0 ? "COLORLESS" : "CARRIES COLOR"); diff --git a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/complex/dHadronDefinition.java b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/complex/dHadronDefinition.java index 96ee5cc3db..c5efaf1403 100644 --- a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/complex/dHadronDefinition.java +++ b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/complex/dHadronDefinition.java @@ -1,7 +1,6 @@ package com.github.technus.tectech.mechanics.elementalMatter.definitions.complex; import com.github.technus.tectech.TecTech; -import com.github.technus.tectech.util.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; @@ -13,6 +12,7 @@ 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 com.github.technus.tectech.thing.item.DebugElementalInstanceContainer_EM; +import com.github.technus.tectech.util.Util; import gregtech.api.enums.Materials; import gregtech.api.enums.OrePrefixes; import net.minecraft.nbt.NBTTagCompound; @@ -24,7 +24,8 @@ import java.util.Map; 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.dAtomDefinition.transformation; +import static com.github.technus.tectech.mechanics.elementalMatter.core.transformations.bTransformationInfo.AVOGADRO_CONSTANT_144; +import static com.github.technus.tectech.mechanics.elementalMatter.definitions.complex.dAtomDefinition.TRANSFORMATION_INFO; 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; @@ -41,17 +42,17 @@ public final class dHadronDefinition extends cElementalDefinition {//TODO Optimi public static final Map<dHadronDefinition,String> NAME_MAP =new HashMap<>(); 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; + private static double protonMass = 0D; + private static double neutronMass = 0D; + private static final double actualProtonMass=938272081.3D; + private static final double actualNeutronMass=939565413.3D; //float-mass in eV/c^2 - public final float mass; + public final double mass; //int -electric charge in 1/3rds of electron charge for optimization public final int charge; - public final float rawLifeTime; - public final byte amount; + public final double rawLifeTime; + public final int amount; //generation max present inside - minus if contains any antiquark public final byte type; //private final FluidStack fluidThing; @@ -87,13 +88,16 @@ public final class dHadronDefinition extends cElementalDefinition {//TODO Optimi } quarkStacks = quarks; - byte amount = 0; + int amount = 0; int charge = 0; int type = 0; boolean containsAnti = false; - float mass = 0; + double mass = 0; for (cElementalDefinitionStack quarkStack : quarkStacks.values()) { amount += quarkStack.amount; + if((int)quarkStack.amount!=quarkStack.amount){ + throw new ArithmeticException("Amount cannot be safely converted to int!"); + } mass += quarkStack.getMass(); charge += quarkStack.getCharge(); type = Math.max(Math.abs(quarkStack.definition.getType()), type); @@ -104,22 +108,22 @@ public final class dHadronDefinition extends cElementalDefinition {//TODO Optimi 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 + long mult = this.amount * this.amount * (this.amount - 1); + mass = mass * 5.543D * 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; + rawLifeTime = 882D; mass=actualNeutronMass; } else { if (this.amount == 3) { - rawLifeTime = 1.34F / mass * (float) Math.pow(9.81, charge); + rawLifeTime = 1.34D / mass * Math.pow(9.81, charge); } else if (this.amount == 2) { - rawLifeTime = 1.21F / mass / (float) Math.pow(19.80, charge); + rawLifeTime = 1.21D / mass / Math.pow(19.80, charge); } else { - rawLifeTime = 1.21F / mass / (float) Math.pow(9.80, charge); + rawLifeTime = 1.21D / mass / Math.pow(9.80, charge); } } this.mass=mass; @@ -133,6 +137,9 @@ public final class dHadronDefinition extends cElementalDefinition {//TODO Optimi if (!(quarks.definition instanceof eQuarkDefinition)) { return false; } + if((int)quarks.amount!=quarks.amount){ + throw new ArithmeticException("Amount cannot be safely converted to int!"); + } amount += quarks.amount; } return amount >= 2 && amount <= 12; @@ -147,7 +154,7 @@ public final class dHadronDefinition extends cElementalDefinition {//TODO Optimi name.append(' ').append(sym); }else { for (cElementalDefinitionStack quark : quarkStacks.values()) { - name.append(' ').append(quark.definition.getSymbol()).append(quark.amount); + name.append(' ').append(quark.definition.getSymbol()).append((int)quark.amount); } } return name.toString(); @@ -229,7 +236,7 @@ public final class dHadronDefinition extends cElementalDefinition {//TODO Optimi } } return new cElementalDecay[]{ - new cElementalDecay(0.75F, decaysInto.toArray(new cElementalDefinitionStack[0])), + new cElementalDecay(0.75D, decaysInto.toArray(new cElementalDefinitionStack[0])), eBosonDefinition.deadEnd }; } @@ -240,11 +247,11 @@ public final class dHadronDefinition extends cElementalDefinition {//TODO Optimi 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 + return new cElementalDecay[]{new cElementalDecay(0.75D, quarkStacks), eBosonDefinition.deadEnd}; //decay into quarks } @Override - public float getEnergyDiffBetweenStates(long currentEnergyLevel, long newEnergyLevel) { + public double getEnergyDiffBetweenStates(long currentEnergyLevel, long newEnergyLevel) { return iElementalDefinition.DEFAULT_ENERGY_REQUIREMENT *(newEnergyLevel-currentEnergyLevel); } @@ -271,10 +278,12 @@ public final class dHadronDefinition extends cElementalDefinition {//TODO Optimi @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()) { + 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 + return new cElementalDecay[]{new cElementalDecay(0.95D, quarkStacks), eBosonDefinition.deadEnd}; //decay into quarks } else { ArrayList<eQuarkDefinition> newBaryon = new ArrayList<>(); iElementalDefinition[] Particles = new iElementalDefinition[2]; @@ -286,24 +295,22 @@ public final class dHadronDefinition extends cElementalDefinition {//TODO Optimi //remove last eQuarkDefinition lastQuark = newBaryon.remove(2); + cElementalDefinitionStack[] decay; 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; + decay = lastQuark.getDecayArray()[1].outputStacks.values(); } else { - cElementalDefinitionStack[] decay = lastQuark.getDecayArray()[0].outputStacks.values(); - newBaryon.add((eQuarkDefinition) decay[0].definition); - Particles[0] = decay[1].definition; - Particles[1] = decay[2].definition; + decay = lastQuark.getDecayArray()[2].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__), + new cElementalDecay(0.001D, new dHadronDefinition(false, contentOfBaryon), Particles[0], Particles[1], boson_Y__), + new cElementalDecay(0.99D, new dHadronDefinition(false, contentOfBaryon), Particles[0], Particles[1]), eBosonDefinition.deadEnd}; } catch (tElementalException e) { if (DEBUG_MODE) { @@ -315,7 +322,7 @@ public final class dHadronDefinition extends cElementalDefinition {//TODO Optimi } @Override - public float getMass() { + public double getMass() { return mass; } @@ -325,7 +332,7 @@ public final class dHadronDefinition extends cElementalDefinition {//TODO Optimi } @Override - public float getRawTimeSpan(long currentEnergy) { + public double getRawTimeSpan(long currentEnergy) { return rawLifeTime; } @@ -436,13 +443,13 @@ public final class dHadronDefinition extends cElementalDefinition {//TODO Optimi 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); + hadron_p1 = new cElementalDefinitionStack(hadron_p, 1D); + hadron_n1 = new cElementalDefinitionStack(hadron_n, 1D); + hadron_p2 = new cElementalDefinitionStack(hadron_p, 2D); + hadron_n2 = new cElementalDefinitionStack(hadron_n, 2D); + hadron_p3 = new cElementalDefinitionStack(hadron_p, 3D); + hadron_n3 = new cElementalDefinitionStack(hadron_n, 3D); + hadron_p5 = new cElementalDefinitionStack(hadron_p, 5D); try { cElementalDefinition.addCreatorFromNBT(nbtType, dHadronDefinition.class.getMethod("fromNBT", NBTTagCompound.class),(byte)-64); @@ -458,8 +465,8 @@ public final class dHadronDefinition extends cElementalDefinition {//TODO Optimi 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)); + cElementalDefinitionStack neutrons=new cElementalDefinitionStack(hadron_n, 1000* AVOGADRO_CONSTANT_144); + TRANSFORMATION_INFO.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) @@ -497,7 +504,7 @@ public final class dHadronDefinition extends cElementalDefinition {//TODO Optimi //lines.add("SYMBOL = "+getSymbol()); } if(Util.areBitsSet(SCAN_GET_CHARGE,capabilities)) { - lines.add("CHARGE = " + getCharge() / 3f + " e"); + lines.add("CHARGE = " + getCharge() / 3D + " e"); } if(Util.areBitsSet(SCAN_GET_COLOR,capabilities)) { lines.add(getColor() < 0 ? "COLORLESS" : "CARRIES COLOR"); 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 index 87a71b684f..8b09bfd2e0 100644 --- 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 @@ -1,7 +1,5 @@ package com.github.technus.tectech.mechanics.elementalMatter.definitions.complex; -import com.github.technus.tectech.util.Util; - import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.ArrayList; @@ -10,6 +8,7 @@ import java.util.HashSet; import java.util.TreeMap; import static com.github.technus.tectech.mechanics.elementalMatter.core.templates.iElementalDefinition.STABLE_RAW_LIFE_TIME; +import static com.github.technus.tectech.util.Util.splitButDifferent; 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; @@ -28,7 +27,7 @@ public final class iaeaNuclide { BufferedReader reader = new BufferedReader(new InputStreamReader(iaeaNuclide.class.getResourceAsStream("nuclides.csv"))); ArrayList<String[]> blockOfData=new ArrayList<>(4); while((line=reader.readLine())!=null) { - String[] split= Util.splitButDifferent(line,","); + String[] split= splitButDifferent(line,","); if(split.length!=19) { throw new Error("Invalid count (" + split.length + ") of separators in IAEA nuclides database " + line); } @@ -51,9 +50,9 @@ public final class iaeaNuclide { try { BufferedReader reader = new BufferedReader(new InputStreamReader(iaeaNuclide.class.getResourceAsStream("nuclidesTable.csv"))); while((line=reader.readLine())!=null) { - String[] split= Util.splitButDifferent(line,","); + String[] split= splitButDifferent(line,","); if(split.length!=47) { - throw new Error("Invalid count (" + split.length + ") of separators in IAEA nuvlidesTable database " + line); + throw new Error("Invalid count (" + split.length + ") of separators in IAEA nuclidesTable database " + line); } get(Integer.parseInt(split[0]),Integer.parseInt(split[1])).getMoreData(split); } @@ -66,7 +65,7 @@ public final class iaeaNuclide { try { BufferedReader reader = new BufferedReader(new InputStreamReader(iaeaNuclide.class.getResourceAsStream("energyLevels.csv"))); while((line=reader.readLine())!=null) { - String[] split= Util.splitButDifferent(line,","); + String[] split= splitButDifferent(line,","); if(split.length!=27) { throw new Error("Invalid count (" + split.length + ") of separators in IAEA energyLevels database " + line); } @@ -88,10 +87,10 @@ public final class iaeaNuclide { } public final short N,Z; - public final float halfTime;//sec - public final float mass;//eV/c^2 + public final double halfTime;//sec + public final double mass;//eV/c^2 public final short discovery;//year - private TreeMap<Float,energeticState> energeticStates; + private TreeMap<Double,energeticState> energeticStates; public energeticState[] energeticStatesArray; @@ -100,14 +99,14 @@ public final class iaeaNuclide { Z=Short.parseShort(rows[1][0]); NUCLIDES.put(((int)Z <<16)+N,this); - String[] parts = Util.splitButDifferent(rows[0][16], "|"); + String[] parts = 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); + mass = Mass* MICRO_AMU_TO_EV_DIV_C_C; } else { - mass = Float.NaN; + mass = Double.NaN; } discovery=(short)doubleOrNaN(rows[0][18],"discovery"); @@ -115,8 +114,8 @@ public final class iaeaNuclide { 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"); + parts = splitButDifferent(rows[0][4], "|"); + halfTime = doubleOrNaN(parts[0],"half life"); } } @@ -126,7 +125,13 @@ public final class iaeaNuclide { // 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"))); + 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]; @@ -135,6 +140,14 @@ public final class iaeaNuclide { energeticStatesArray = empty; } else { energeticStatesArray = energeticStates.values().toArray(new energeticState[0]); + double life=halfTime; + for (energeticState energeticState : energeticStatesArray) { + if(Double.isNaN(energeticState.Thalf)){ + energeticState.Thalf=life; + }else { + life=energeticState.Thalf; + } + } } } @@ -156,11 +169,11 @@ public final class iaeaNuclide { } public static final class energeticState{ - public final float energy; - public final float Thalf; + public final double energy; + public double Thalf; public final iaeaDecay[] decaymodes; - private energeticState(iaeaNuclide nuclide,float Thalf,iaeaDecay[] decaymodes){ + private energeticState(iaeaNuclide nuclide,double Thalf,iaeaDecay[] decaymodes){ energy=0; this.Thalf=Thalf; this.decaymodes=decaymodes; @@ -175,11 +188,11 @@ public final class iaeaNuclide { 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 + energy =doubleOrNaN(cells[3],"energy level",nuclide)*1000D;//to eV if(energy<0) { throw new Error("Invalid energy " + nuclide.N + ' ' + nuclide.Z + ' ' + cells[3]); } - Thalf =(float) doubleOrNaN(cells[10],"half life",nuclide); + Thalf =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<>(); @@ -190,7 +203,13 @@ public final class iaeaNuclide { // 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)); + 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){ @@ -231,40 +250,40 @@ public final class iaeaNuclide { do3= !decay3.isEmpty() && !Double.isNaN(chance3); TreeMap<Double,iaeaDecay> decays=new TreeMap<>(); if(do1 && do2 && chance1==100 && chance2==100 && chance3!=100){ - decays.put(1D, new iaeaDecay(1f, decay1)); + decays.put(1D, new iaeaDecay(1D, decay1)); if(do3) { chance3/=100d; - decays.put(chance3, new iaeaDecay((float) chance3, decay2)); + decays.put(chance3, new iaeaDecay(chance3, decay2)); chance2=1d-chance3; } chance2/=2d; - decays.put(chance2, new iaeaDecay((float) chance2, decay2)); + decays.put(chance2, new iaeaDecay(chance2, decay2)); }else if(do1 && chance1==100){ - decays.put(1D, new iaeaDecay(1f, decay1)); + decays.put(1D, new iaeaDecay(1D, decay1)); if(do2) { chance2/=100d; - decays.put(chance2, new iaeaDecay((float) chance2, decay2)); + decays.put(chance2, new iaeaDecay(chance2, decay2)); } if(do3) { chance3 /= 100d; if(do2) { chance3 *= chance2; } - decays.put(chance3, new iaeaDecay((float) chance3, decay3)); + decays.put(chance3, new iaeaDecay(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)); + decays.put(chance1, new iaeaDecay(chance1, decay1)); } if(do2) { chance2/=normalization; - decays.put(chance2, new iaeaDecay((float) chance2, decay2)); + decays.put(chance2, new iaeaDecay(chance2, decay2)); } if(do3) { chance3/=normalization; - decays.put(chance3, new iaeaDecay((float) chance3, decay3)); + decays.put(chance3, new iaeaDecay(chance3, decay3)); } if(do1||do2||do3) { decays.put(1D, iaeaDecay.DEAD_END); @@ -277,10 +296,10 @@ public final class iaeaNuclide { } public static final class iaeaDecay{ - public final float chance; + public final double chance; public final String decayName; - public static final iaeaDecay DEAD_END=new iaeaDecay(1f,"DEAD_END"); - private iaeaDecay(float chance,String decayName){ + public static final iaeaDecay DEAD_END=new iaeaDecay(1D,"DEAD_END"); + private iaeaDecay(double chance,String decayName){ this.chance=chance; this.decayName=decayName; } diff --git a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/primitive/cPrimitiveDefinition.java b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/primitive/cPrimitiveDefinition.java index a09fc60835..a3efe12b7e 100644 --- a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/primitive/cPrimitiveDefinition.java +++ b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/primitive/cPrimitiveDefinition.java @@ -9,13 +9,13 @@ import static com.github.technus.tectech.mechanics.elementalMatter.core.cElement */ public final class cPrimitiveDefinition extends cElementalPrimitive { public static final cPrimitiveDefinition - nbtE__ = new cPrimitiveDefinition("NBT ERROR", "!", 0, 0f, Integer.MIN_VALUE, Integer.MIN_VALUE+10_000), - null__ = new cPrimitiveDefinition("NULL POINTER", ".", 0, 0F, -3, Integer.MAX_VALUE-10_000), - space__ = new cPrimitiveDefinition("Space", "_", 0, 0F, -4, 0), - magic = new cPrimitiveDefinition("Magic", "Ma", 4, 1e5F, 0, 1), - magic_ = new cPrimitiveDefinition("Antimagic", "~Ma", -4, 1e5F, 0, 2); + nbtE__ = new cPrimitiveDefinition("NBT ERROR", "!", 0, 0D, Integer.MIN_VALUE, Integer.MIN_VALUE+10_000), + null__ = new cPrimitiveDefinition("NULL POINTER", ".", 0, 0D, -3, Integer.MAX_VALUE-10_000), + space__ = new cPrimitiveDefinition("Space", "_", 0, 0D, -4, 0), + magic = new cPrimitiveDefinition("Magic", "Ma", 4, 1e5D, 0, 1), + magic_ = new cPrimitiveDefinition("Antimagic", "~Ma", -4, 1e5D, 0, 2); - private cPrimitiveDefinition(String name, String symbol, int type, float mass, int color, int ID) { + private cPrimitiveDefinition(String name, String symbol, int type, double mass, int color, int ID) { super(name, symbol, type, mass, 0, color, ID); } diff --git a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/primitive/eBosonDefinition.java b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/primitive/eBosonDefinition.java index 3f314151f3..9a82cdd6c0 100644 --- a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/primitive/eBosonDefinition.java +++ b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/primitive/eBosonDefinition.java @@ -4,28 +4,32 @@ import com.github.technus.tectech.mechanics.elementalMatter.core.cElementalDecay import com.github.technus.tectech.mechanics.elementalMatter.core.stacks.cElementalDefinitionStack; import com.github.technus.tectech.mechanics.elementalMatter.core.templates.cElementalPrimitive; +import static com.github.technus.tectech.mechanics.elementalMatter.core.cElementalDecay.*; +import static com.github.technus.tectech.mechanics.elementalMatter.definitions.primitive.eLeptonDefinition.*; +import static com.github.technus.tectech.mechanics.elementalMatter.definitions.primitive.eQuarkDefinition.*; + /** * Created by danie_000 on 22.10.2016. */ public final class eBosonDefinition extends cElementalPrimitive { public static final eBosonDefinition - boson_Y__ = new eBosonDefinition("Photon", "\u03b3", 1e-18F, -1, 27), - boson_H__ = new eBosonDefinition("Higgs", "\u0397", 126.09e9F, -2, 28); + boson_Y__ = new eBosonDefinition("Photon", "\u03b3", 1e-18D, -1, 27), + boson_H__ = new eBosonDefinition("Higgs", "\u0397", 126.09e9D, -2, 28); //deadEnd public static final cElementalDecay deadEnd = new cElementalDecay(boson_Y__, boson_Y__); public static final cElementalDecay deadEndHalf = new cElementalDecay(boson_Y__); public static final cElementalDefinitionStack boson_Y__1=new cElementalDefinitionStack(boson_Y__,1); - private eBosonDefinition(String name, String symbol, float mass, int color, int ID) { + private eBosonDefinition(String name, String symbol, double mass, int color, int ID) { super(name, symbol, 0, mass, 0, color, ID); } public static void run() { - boson_Y__.init(null, NO_DECAY_RAW_LIFE_TIME, -1, -1, cElementalDecay.noDecay); - boson_H__.init(null, 1.56e-22F, 0, 0, - new cElementalDecay(0.96F, new cElementalDefinitionStack(boson_Y__, 4)), - new cElementalDecay(0.02F, eLeptonDefinition.lepton_t, eLeptonDefinition.lepton_t_), - new cElementalDecay(0.01F, eQuarkDefinition.quark_b, eQuarkDefinition.quark_b_), + boson_Y__.init(null, NO_DECAY_RAW_LIFE_TIME, -1, -1, noDecay); + boson_H__.init(null, 1.56e-22D, 2, 2, + new cElementalDecay(0.01D, quark_b, quark_b_), + new cElementalDecay(0.02D, lepton_t, lepton_t_), + new cElementalDecay(0.96D, new cElementalDefinitionStack(boson_Y__, 4)), deadEnd); } diff --git a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/primitive/eLeptonDefinition.java b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/primitive/eLeptonDefinition.java index 20132e2095..1e3b7189a8 100644 --- a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/primitive/eLeptonDefinition.java +++ b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/primitive/eLeptonDefinition.java @@ -4,24 +4,28 @@ import com.github.technus.tectech.mechanics.elementalMatter.core.cElementalDecay import com.github.technus.tectech.mechanics.elementalMatter.core.stacks.cElementalDefinitionStack; import com.github.technus.tectech.mechanics.elementalMatter.core.templates.cElementalPrimitive; +import static com.github.technus.tectech.mechanics.elementalMatter.definitions.primitive.eBosonDefinition.*; +import static com.github.technus.tectech.mechanics.elementalMatter.definitions.primitive.eBosonDefinition.boson_Y__; +import static com.github.technus.tectech.mechanics.elementalMatter.definitions.primitive.eNeutrinoDefinition.*; + /** * Created by danie_000 on 22.10.2016. */ public final class eLeptonDefinition extends cElementalPrimitive { public static final eLeptonDefinition - lepton_e = new eLeptonDefinition("Electron", "\u03b2-", 1, 0.511e6F, -3, 15), - lepton_m = new eLeptonDefinition("Muon", "\u03bc-", 2, 105.658e6F, -3, 17), - lepton_t = new eLeptonDefinition("Tauon", "\u03c4-", 3, 1776.83e6F, -3, 19), - lepton_e_ = new eLeptonDefinition("Positron", "\u03b2+", -1, 0.511e6F, 3, 16), - lepton_m_ = new eLeptonDefinition("Antimuon", "\u03bc+", -2, 105.658e6F, 3, 18), - lepton_t_ = new eLeptonDefinition("Antitauon", "\u03c4+", -3, 1776.83e6F, 3, 20); + lepton_e = new eLeptonDefinition("Electron", "\u03b2-", 1, 0.511e6D, -3, 15), + lepton_m = new eLeptonDefinition("Muon", "\u03bc-", 2, 105.658e6D, -3, 17), + lepton_t = new eLeptonDefinition("Tauon", "\u03c4-", 3, 1776.83e6D, -3, 19), + lepton_e_ = new eLeptonDefinition("Positron", "\u03b2+", -1, 0.511e6D, 3, 16), + lepton_m_ = new eLeptonDefinition("Antimuon", "\u03bc+", -2, 105.658e6D, 3, 18), + lepton_t_ = new eLeptonDefinition("Antitauon", "\u03c4+", -3, 1776.83e6D, 3, 20); public static final cElementalDefinitionStack lepton_e1 = new cElementalDefinitionStack(lepton_e, 1); public static final cElementalDefinitionStack lepton_e2 = new cElementalDefinitionStack(lepton_e, 2); public static final cElementalDefinitionStack lepton_e_1 = new cElementalDefinitionStack(lepton_e_, 1); public static final cElementalDefinitionStack lepton_e_2 = new cElementalDefinitionStack(lepton_e_, 2); - private eLeptonDefinition(String name, String symbol, int type, float mass, int charge, int ID) { + private eLeptonDefinition(String name, String symbol, int type, double mass, int charge, int ID) { super(name, symbol, type, mass, charge, -1, ID); //this.itemThing=null; //this.fluidThing=null; @@ -29,28 +33,28 @@ public final class eLeptonDefinition extends cElementalPrimitive { public static void run() { lepton_e.init(lepton_e_, STABLE_RAW_LIFE_TIME, 0, 1, - eBosonDefinition.deadEnd,//makes photons and don't care - new cElementalDecay(lepton_e, eBosonDefinition.boson_Y__)); - lepton_m.init(lepton_m_, 2.197019e-6F, 0, 1, - new cElementalDecay(0.9F, lepton_e, eNeutrinoDefinition.lepton_Ve_, eNeutrinoDefinition.lepton_Vm), - eBosonDefinition.deadEnd);//makes photons and don't care - lepton_t.init(lepton_t_, 2.906e-13F, 1, 3, - new cElementalDecay(0.8F, lepton_m, eNeutrinoDefinition.lepton_Vm_, eNeutrinoDefinition.lepton_Vt, eBosonDefinition.boson_Y__), - new cElementalDecay(0.1F, lepton_e, eNeutrinoDefinition.lepton_Ve_, eNeutrinoDefinition.lepton_Vm), - new cElementalDecay(0.05F, lepton_m, eNeutrinoDefinition.lepton_Vm_, eNeutrinoDefinition.lepton_Vt, eBosonDefinition.boson_H__), - eBosonDefinition.deadEnd);//makes photons and don't care + deadEnd, + new cElementalDecay(lepton_e,boson_Y__)); + lepton_m.init(lepton_m_, 2.197019e-6D, 0, 1, + new cElementalDecay(0.9D, lepton_e, lepton_Ve_, lepton_Vm), + deadEnd);//makes photons and don't care + lepton_t.init(lepton_t_, 2.906e-13D, 1, 3, + new cElementalDecay(0.05F, lepton_m, lepton_Vm_, lepton_Vt, boson_H__), + new cElementalDecay(0.1D, lepton_e, lepton_Ve_, lepton_Vm), + new cElementalDecay(0.8D, lepton_m, lepton_Vm_, lepton_Vt, boson_Y__), + deadEnd);//makes photons and don't care lepton_e_.init(lepton_e, STABLE_RAW_LIFE_TIME, 0, 1, - eBosonDefinition.deadEnd,//makes photons and don't care - new cElementalDecay(lepton_e_, eBosonDefinition.boson_Y__)); + deadEnd, + new cElementalDecay(lepton_e,boson_Y__)); lepton_m_.init(lepton_m, 2.197019e-6F, 0, 1, - new cElementalDecay(0.9F, lepton_e_, eNeutrinoDefinition.lepton_Ve, eNeutrinoDefinition.lepton_Vm_), - eBosonDefinition.deadEnd);//makes photons and don't care + new cElementalDecay(0.9F, lepton_e_, lepton_Ve, lepton_Vm_), + deadEnd);//makes photons and don't care lepton_t_.init(lepton_t, 2.906e-13F, 1, 3, - new cElementalDecay(0.8F, lepton_m_, eNeutrinoDefinition.lepton_Vm, eNeutrinoDefinition.lepton_Vt_, eBosonDefinition.boson_Y__), - new cElementalDecay(0.1F, lepton_e_, eNeutrinoDefinition.lepton_Ve, eNeutrinoDefinition.lepton_Vm_), - new cElementalDecay(0.05F, lepton_m_, eNeutrinoDefinition.lepton_Vm, eNeutrinoDefinition.lepton_Vt_, eBosonDefinition.boson_H__), - eBosonDefinition.deadEnd);//makes photons and don't care + new cElementalDecay(0.05F, lepton_m_, lepton_Vm, lepton_Vt_, boson_H__), + new cElementalDecay(0.1F, lepton_e_, lepton_Ve, lepton_Vm_), + new cElementalDecay(0.8F, lepton_m_, lepton_Vm, lepton_Vt_, boson_Y__), + deadEnd);//makes photons and don't care } @Override diff --git a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/primitive/eNeutrinoDefinition.java b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/primitive/eNeutrinoDefinition.java index 5f6a4a7b5e..c55e7f6364 100644 --- a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/primitive/eNeutrinoDefinition.java +++ b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/primitive/eNeutrinoDefinition.java @@ -4,45 +4,47 @@ import com.github.technus.tectech.mechanics.elementalMatter.core.cElementalDecay import com.github.technus.tectech.mechanics.elementalMatter.core.stacks.cElementalDefinitionStack; import com.github.technus.tectech.mechanics.elementalMatter.core.templates.cElementalPrimitive; +import static com.github.technus.tectech.mechanics.elementalMatter.definitions.primitive.eBosonDefinition.*; + /** * Created by danie_000 on 22.10.2016. */ public final class eNeutrinoDefinition extends cElementalPrimitive { public static final eNeutrinoDefinition - lepton_Ve = new eNeutrinoDefinition("Electron neutrino", "\u03bd\u03b2", 1, 2e0F, 21), - lepton_Vm = new eNeutrinoDefinition("Muon neutrino", "\u03bd\u03bc", 2, 0.15e6F, 23), - lepton_Vt = new eNeutrinoDefinition("Tauon neutrino", "\u03bd\u03c4", 3, 15e6F, 25), - lepton_Ve_ = new eNeutrinoDefinition("Positron neutrino", "~\u03bd\u03b2", -1, 2e0F, 22), - lepton_Vm_ = new eNeutrinoDefinition("Antimuon neutrino", "~\u03bd\u03bc", -2, 0.15e6F, 24), - lepton_Vt_ = new eNeutrinoDefinition("Antitauon neutrino", "~\u03bd\u03c4", -3, 15e6F, 26); + lepton_Ve = new eNeutrinoDefinition("Electron neutrino", "\u03bd\u03b2", 1, 2e0D, 21), + lepton_Vm = new eNeutrinoDefinition("Muon neutrino", "\u03bd\u03bc", 2, 0.15e6D, 23), + lepton_Vt = new eNeutrinoDefinition("Tauon neutrino", "\u03bd\u03c4", 3, 15e6D, 25), + lepton_Ve_ = new eNeutrinoDefinition("Positron neutrino", "~\u03bd\u03b2", -1, 2e0D, 22), + lepton_Vm_ = new eNeutrinoDefinition("Antimuon neutrino", "~\u03bd\u03bc", -2, 0.15e6D, 24), + lepton_Vt_ = new eNeutrinoDefinition("Antitauon neutrino", "~\u03bd\u03c4", -3, 15e6D, 26); public static final cElementalDefinitionStack lepton_Ve1 = new cElementalDefinitionStack(lepton_Ve, 1); public static final cElementalDefinitionStack lepton_Ve2 = new cElementalDefinitionStack(lepton_Ve, 2); public static final cElementalDefinitionStack lepton_Ve_1 = new cElementalDefinitionStack(lepton_Ve_, 1); public static final cElementalDefinitionStack lepton_Ve_2 = new cElementalDefinitionStack(lepton_Ve_, 2); - private eNeutrinoDefinition(String name, String symbol, int type, float mass, int ID) { + private eNeutrinoDefinition(String name, String symbol, int type, double mass, int ID) { super(name, symbol, type, mass, 0, -1, ID); } public static void run() { - lepton_Ve.init(lepton_Ve_, 1F, -1, -1, + lepton_Ve.init(lepton_Ve_, 1D, -1, -1, cElementalDecay.noProduct); - lepton_Vm.init(lepton_Vm_, 1F, 1, 0, - new cElementalDecay(0.825F, nothing), - eBosonDefinition.deadEndHalf); - lepton_Vt.init(lepton_Vt_, 1F, 1, 0, + lepton_Vm.init(lepton_Vm_, 1D, 1, 0, + new cElementalDecay(0.825D, nothing), + deadEndHalf); + lepton_Vt.init(lepton_Vt_, 1, 1, 0, new cElementalDecay(0.75F, nothing), - eBosonDefinition.deadEnd); + deadEnd); - lepton_Ve_.init(lepton_Ve, 1F, -1, -1, + lepton_Ve_.init(lepton_Ve, 1, -1, -1, cElementalDecay.noProduct); - lepton_Vm_.init(lepton_Vm, 1F, 1, 0, + lepton_Vm_.init(lepton_Vm, 1, 1, 0, new cElementalDecay(0.825F, nothing), - eBosonDefinition.deadEndHalf); - lepton_Vt_.init(lepton_Vt, 1F, 1, 0, + deadEndHalf); + lepton_Vt_.init(lepton_Vt, 1, 1, 0, new cElementalDecay(0.75F, nothing), - eBosonDefinition.deadEnd); + deadEnd); } @Override diff --git a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/primitive/eQuarkDefinition.java b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/primitive/eQuarkDefinition.java index be6879d435..9e5b2e66bb 100644 --- a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/primitive/eQuarkDefinition.java +++ b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/primitive/eQuarkDefinition.java @@ -3,91 +3,94 @@ package com.github.technus.tectech.mechanics.elementalMatter.definitions.primiti import com.github.technus.tectech.mechanics.elementalMatter.core.cElementalDecay; import com.github.technus.tectech.mechanics.elementalMatter.core.templates.cElementalPrimitive; +import static com.github.technus.tectech.mechanics.elementalMatter.definitions.primitive.eLeptonDefinition.*; +import static com.github.technus.tectech.mechanics.elementalMatter.definitions.primitive.eNeutrinoDefinition.*; + /** * Created by danie_000 on 22.10.2016. */ public final class eQuarkDefinition extends cElementalPrimitive { public static final eQuarkDefinition - quark_u = new eQuarkDefinition("Up", "u", 1, 2.3e6F, 2, 3), - quark_c = new eQuarkDefinition("Charm", "c", 2, 1.29e9F, 2, 9), - quark_t = new eQuarkDefinition("Top", "t", 3, 172.44e9F, 2, 13), - quark_d = new eQuarkDefinition("Down", "d", 1, 4.8e6F, -1, 5), - quark_s = new eQuarkDefinition("Strange", "s", 2, 95e6F, -1, 7), - quark_b = new eQuarkDefinition("Bottom", "b", 3, 4.65e9F, -1, 11), - quark_u_ = new eQuarkDefinition("AntiUp", "~u", -1, 2.3e6F, -2, 4), - quark_c_ = new eQuarkDefinition("AntiCharm", "~c", -2, 1.29e9F, -2, 10), - quark_t_ = new eQuarkDefinition("AntiTop", "~t", -3, 172.44e9F, -2, 14), - quark_d_ = new eQuarkDefinition("AntiDown", "~d", -1, 4.8e6F, 1, 6), - quark_s_ = new eQuarkDefinition("AntiStrange", "~s", -2, 95e6F, 1, 8), - quark_b_ = new eQuarkDefinition("AntiBottom", "~b", -3, 4.65e9F, 1, 12); + quark_u = new eQuarkDefinition("Up", "u", 1, 2.3e6D, 2, 3), + quark_c = new eQuarkDefinition("Charm", "c", 2, 1.29e9D, 2, 9), + quark_t = new eQuarkDefinition("Top", "t", 3, 172.44e9D, 2, 13), + quark_d = new eQuarkDefinition("Down", "d", 1, 4.8e6D, -1, 5), + quark_s = new eQuarkDefinition("Strange", "s", 2, 95e6D, -1, 7), + quark_b = new eQuarkDefinition("Bottom", "b", 3, 4.65e9D, -1, 11), + quark_u_ = new eQuarkDefinition("AntiUp", "~u", -1, 2.3e6D, -2, 4), + quark_c_ = new eQuarkDefinition("AntiCharm", "~c", -2, 1.29e9D, -2, 10), + quark_t_ = new eQuarkDefinition("AntiTop", "~t", -3, 172.44e9D, -2, 14), + quark_d_ = new eQuarkDefinition("AntiDown", "~d", -1, 4.8e6D, 1, 6), + quark_s_ = new eQuarkDefinition("AntiStrange", "~s", -2, 95e6D, 1, 8), + quark_b_ = new eQuarkDefinition("AntiBottom", "~b", -3, 4.65e9D, 1, 12); - private eQuarkDefinition(String name, String symbol, int type, float mass, int charge, int ID) { + private eQuarkDefinition(String name, String symbol, int type, double mass, int charge, int ID) { super(name, symbol, type, mass, charge, 0, ID); } public static void run() { quark_u.init(quark_u_, STABLE_RAW_LIFE_TIME, 3, -1, - new cElementalDecay(0.9F, quark_d, eLeptonDefinition.lepton_e_, eNeutrinoDefinition.lepton_Ve), - new cElementalDecay(0.050778116F, quark_s/*,lepton_m_,lepton_Vm*/), - new cElementalDecay(1.23201e-5F, quark_b/*,lepton_t_,lepton_Vt*/), + new cElementalDecay(1.23201e-5D, quark_b/*,lepton_t_,lepton_Vt*/), + new cElementalDecay(0.050778116D, quark_s/*,lepton_m_,lepton_Vm*/), + new cElementalDecay(0.9D, quark_d, lepton_e_, lepton_Ve), eBosonDefinition.deadEnd);//makes photons and don't care - quark_c.init(quark_c_, 0.5e-13F, 1, -1, - new cElementalDecay(0.9F, quark_s, eLeptonDefinition.lepton_e_, eNeutrinoDefinition.lepton_Ve), - new cElementalDecay(0.05071504F, quark_d, eLeptonDefinition.lepton_m_, eNeutrinoDefinition.lepton_Vm), - new cElementalDecay(0.00169744F, quark_b/*,lepton_t_,lepton_Vt*/), + quark_c.init(quark_c_, 0.5e-13D, 1, -1, + new cElementalDecay(0.00169744D, quark_b/*,lepton_t_,lepton_Vt*/), + new cElementalDecay(0.05071504D, quark_d, lepton_m_, lepton_Vm), + new cElementalDecay(0.9D, quark_s, lepton_e_, lepton_Ve), eBosonDefinition.deadEnd);//makes photons and don't care - quark_t.init(quark_t_, 2.5e-26F, 2, -1, - new cElementalDecay(0.9F, quark_b, eLeptonDefinition.lepton_e_, eNeutrinoDefinition.lepton_Ve), - new cElementalDecay(0.00163216F, quark_s, eLeptonDefinition.lepton_m_, eNeutrinoDefinition.lepton_Vm), - new cElementalDecay(7.51689e-5F, quark_d, eLeptonDefinition.lepton_t_, eNeutrinoDefinition.lepton_Vt), + quark_t.init(quark_t_, 2.5e-26D, 0, -1, + new cElementalDecay(7.51689e-5D, quark_d, lepton_t_, lepton_Vt), + new cElementalDecay(0.00163216D, quark_s, lepton_m_, lepton_Vm), + new cElementalDecay(0.9D, quark_b, lepton_e_, lepton_Ve), eBosonDefinition.deadEnd);//makes photons and don't care quark_d.init(quark_d_, STABLE_RAW_LIFE_TIME, 3, -1, - new cElementalDecay(0.9F, quark_u, eLeptonDefinition.lepton_e, eNeutrinoDefinition.lepton_Ve_), - new cElementalDecay(0.05071504F, quark_c/*,lepton_m,lepton_Vm_*/), - new cElementalDecay(7.51689e-5F, quark_t/*,lepton_t,lepton_Vt_*/), + new cElementalDecay(7.51689e-5D, quark_t/*,lepton_t,lepton_Vt_*/), + new cElementalDecay(0.05071504D, quark_c/*,lepton_m,lepton_Vm_*/), + new cElementalDecay(0.9D, quark_u, lepton_e, lepton_Ve_), eBosonDefinition.deadEnd);//makes photons and don't care - quark_s.init(quark_s_, 0.6e-9F, 1, -1, - new cElementalDecay(0.9F, quark_c, eLeptonDefinition.lepton_e, eNeutrinoDefinition.lepton_Ve_), - new cElementalDecay(0.050778116F, quark_u, eLeptonDefinition.lepton_m, eNeutrinoDefinition.lepton_Vm_), - new cElementalDecay(0.00163216F, quark_t/*,lepton_t,lepton_Vt_*/), + quark_s.init(quark_s_, 0.6e-9D, 1, -1, + new cElementalDecay(0.00163216D, quark_t/*,lepton_t,lepton_Vt_*/), + new cElementalDecay(0.050778116D, quark_u, lepton_m, lepton_Vm_), + new cElementalDecay(0.9D, quark_c, lepton_e, lepton_Ve_), eBosonDefinition.deadEnd);//makes photons and don't care - quark_b.init(quark_b_, 0.7e-13F, 2, -1, - new cElementalDecay(0.9F, quark_t, eLeptonDefinition.lepton_e, eNeutrinoDefinition.lepton_Ve_), - new cElementalDecay(0.00169744F, quark_c, eLeptonDefinition.lepton_m, eNeutrinoDefinition.lepton_Vm_), - new cElementalDecay(1.23201e-5F, quark_u, eLeptonDefinition.lepton_t, eNeutrinoDefinition.lepton_Vt_), + quark_b.init(quark_b_, 0.7e-13D, 0, -1, + new cElementalDecay(1.23201e-5D, quark_u, lepton_t, lepton_Vt_), + new cElementalDecay(0.00169744D, quark_c, lepton_m, lepton_Vm_), + new cElementalDecay(0.9D, quark_t, lepton_e, lepton_Ve_), eBosonDefinition.deadEnd);//makes photons and don't care quark_u_.init(quark_u, STABLE_RAW_LIFE_TIME, 3, -1, - new cElementalDecay(0.9F, quark_d_, eLeptonDefinition.lepton_e, eNeutrinoDefinition.lepton_Ve_), - new cElementalDecay(0.050778116F, quark_s_/*,lepton_m,lepton_Vm_*/), - new cElementalDecay(1.23201e-5F, quark_b_/*,lepton_t,lepton_Vt_*/), + new cElementalDecay(1.23201e-5D, quark_b_/*,lepton_t,lepton_Vt_*/), + new cElementalDecay(0.050778116D, quark_s_/*,lepton_m,lepton_Vm_*/), + new cElementalDecay(0.9D, quark_d_, lepton_e, lepton_Ve_), eBosonDefinition.deadEnd);//makes photons and don't care - quark_c_.init(quark_c, 0.5e-13F, 1, -1, - new cElementalDecay(0.9F, quark_s_, eLeptonDefinition.lepton_e, eNeutrinoDefinition.lepton_Ve_), - new cElementalDecay(0.05071504F, quark_d_, eLeptonDefinition.lepton_m, eNeutrinoDefinition.lepton_Vm_), + quark_c_.init(quark_c, 0.5e-13D, 1, -1, new cElementalDecay(0.00169744F, quark_b_/*,lepton_t,lepton_Vt_*/), + new cElementalDecay(0.05071504F, quark_d_, lepton_m, lepton_Vm_), + new cElementalDecay(0.9F, quark_s_, lepton_e, lepton_Ve_), eBosonDefinition.deadEnd);//makes photons and don't care - quark_t_.init(quark_t, 2.5e-26F, 2, -1, - new cElementalDecay(0.9F, quark_b_, eLeptonDefinition.lepton_e, eNeutrinoDefinition.lepton_Ve_), - new cElementalDecay(0.00163216F, quark_s_, eLeptonDefinition.lepton_m, eNeutrinoDefinition.lepton_Vm_), - new cElementalDecay(7.51689e-5F, quark_d_, eLeptonDefinition.lepton_t, eNeutrinoDefinition.lepton_Vt_), + quark_t_.init(quark_t, 2.5e-26F, 0, -1, + new cElementalDecay(7.51689e-5F, quark_d_, lepton_t, lepton_Vt_), + new cElementalDecay(0.00163216F, quark_s_, lepton_m, lepton_Vm_), + new cElementalDecay(0.9F, quark_b_, lepton_e, lepton_Ve_), eBosonDefinition.deadEnd);//makes photons and don't care quark_d_.init(quark_d, STABLE_RAW_LIFE_TIME, 3, -1, - new cElementalDecay(0.9F, quark_u_, eLeptonDefinition.lepton_e_, eNeutrinoDefinition.lepton_Ve), - new cElementalDecay(0.05071504F, quark_c_/*,lepton_m_,lepton_Vm*/), new cElementalDecay(7.51689e-5F, quark_t_/*,lepton_t_,lepton_Vt*/), + new cElementalDecay(0.05071504F, quark_c_/*,lepton_m_,lepton_Vm*/), + new cElementalDecay(0.9F, quark_u_, lepton_e_, lepton_Ve), eBosonDefinition.deadEnd);//makes photons and don't care quark_s_.init(quark_s, 0.6e-9F, 1, -1, - new cElementalDecay(0.9F, quark_c_, eLeptonDefinition.lepton_e_, eNeutrinoDefinition.lepton_Ve), - new cElementalDecay(0.050778116F, quark_u_, eLeptonDefinition.lepton_m_, eNeutrinoDefinition.lepton_Vm), new cElementalDecay(0.00163216F, quark_t_/*,lepton_t_,lepton_Vt*/), + new cElementalDecay(0.050778116F, quark_u_, lepton_m_, lepton_Vm), + new cElementalDecay(0.9F, quark_c_, lepton_e_, lepton_Ve), eBosonDefinition.deadEnd);//makes photons and don't care - quark_b_.init(quark_b, 0.7e-13F, 2, -1, - new cElementalDecay(0.9F, quark_t_, eLeptonDefinition.lepton_e_, eNeutrinoDefinition.lepton_Ve), - new cElementalDecay(0.00169744F, quark_c_, eLeptonDefinition.lepton_m_, eNeutrinoDefinition.lepton_Vm), - new cElementalDecay(1.23201e-5F, quark_u_, eLeptonDefinition.lepton_t_, eNeutrinoDefinition.lepton_Vt), + quark_b_.init(quark_b, 0.7e-13F, 0, -1, + new cElementalDecay(1.23201e-5F, quark_u_, lepton_t_, lepton_Vt), + new cElementalDecay(0.00169744F, quark_c_, lepton_m_, lepton_Vm), + new cElementalDecay(0.9F, quark_t_, lepton_e_, lepton_Ve), eBosonDefinition.deadEnd);//makes photons and don't care } diff --git a/src/main/java/com/github/technus/tectech/mechanics/structure/StructureUtility.java b/src/main/java/com/github/technus/tectech/mechanics/structure/StructureUtility.java index a9b88af2f3..2f6998f028 100644 --- a/src/main/java/com/github/technus/tectech/mechanics/structure/StructureUtility.java +++ b/src/main/java/com/github/technus/tectech/mechanics/structure/StructureUtility.java @@ -23,7 +23,13 @@ import java.util.function.Function; import java.util.function.Supplier; import static com.github.technus.tectech.thing.casing.TT_Container_Casings.sHintCasingsTT; +import static java.lang.Integer.MIN_VALUE; +/** + * Fluent API for structure checking! + * + * (Just import static this class to have a nice fluent syntax while defining structure definitions) + */ public class StructureUtility { private static final String NICE_CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz=|!@#$%&()[]{};:<>/?_,.*^'`"; @SuppressWarnings("rawtypes") @@ -197,7 +203,7 @@ public class StructureUtility { @Override public boolean check(T t, World world, int x, int y, int z) { Block worldBlock = world.getBlock(x, y, z); - return blocsMap.getOrDefault(worldBlock, -1) == worldBlock.getDamageValue(world, x, y, z); + return blocsMap.getOrDefault(worldBlock, MIN_VALUE) == worldBlock.getDamageValue(world, x, y, z); } @Override @@ -289,7 +295,7 @@ public class StructureUtility { @Override public boolean check(T t, World world, int x, int y, int z) { Block worldBlock = world.getBlock(x, y, z); - return blocsMap.getOrDefault(worldBlock, -1) == worldBlock.getDamageValue(world, x, y, z); + return blocsMap.getOrDefault(worldBlock, MIN_VALUE) == worldBlock.getDamageValue(world, x, y, z); } @Override @@ -309,7 +315,7 @@ public class StructureUtility { @Override public boolean check(T t, World world, int x, int y, int z) { Block worldBlock = world.getBlock(x, y, z); - return blocsMap.getOrDefault(worldBlock, -1) == worldBlock.getDamageValue(world, x, y, z); + return blocsMap.getOrDefault(worldBlock, MIN_VALUE) == worldBlock.getDamageValue(world, x, y, z); } @Override @@ -429,10 +435,72 @@ public class StructureUtility { } } + /** + * Same as above but ignores target meta id + */ + public static <T> IStructureElement<T> ofBlockAnyMeta(Block block, Block defaultBlock, int defaultMeta) { + if (block == null || defaultBlock == null) { + throw new IllegalArgumentException(); + } + if(block instanceof ICustomBlockSetting){ + return new IStructureElement<T>() { + @Override + public boolean check(T t, World world, int x, int y, int z) { + return block == world.getBlock(x, y, z); + } + + @Override + public boolean placeBlock(T t, World world, int x, int y, int z, ItemStack trigger) { + ((ICustomBlockSetting) defaultBlock).setBlock(world, x, y, z, defaultMeta); + return true; + } + + @Override + public boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger) { + TecTech.proxy.hint_particle(world, x, y, z, defaultBlock, defaultMeta); + return true; + } + }; + } else { + return new IStructureElement<T>() { + @Override + public boolean check(T t, World world, int x, int y, int z) { + return block == world.getBlock(x, y, z); + } + + @Override + public boolean placeBlock(T t, World world, int x, int y, int z, ItemStack trigger) { + world.setBlock(x, y, z, defaultBlock, defaultMeta, 2); + return true; + } + + @Override + public boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger) { + TecTech.proxy.hint_particle(world, x, y, z, defaultBlock, defaultMeta); + return true; + } + }; + } + } + public static <T> IStructureElement<T> ofBlock(Block block, int meta) { return ofBlock(block, meta, block, meta); } + /** + * Same as above but ignores target meta id + */ + public static <T> IStructureElement<T> ofBlockAnyMeta(Block block) { + return ofBlockAnyMeta(block, block, 0); + } + + /** + * Same as above but allows to set hint particle render + */ + public static <T> IStructureElement<T> ofBlockAnyMeta(Block block,int defaultMeta) { + return ofBlockAnyMeta(block, block, defaultMeta); + } + //endregion //region adders 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 b23a580bbf..6850b24e0f 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 @@ -31,6 +31,8 @@ import java.util.TreeSet; import static com.github.technus.tectech.Reference.MODID; import static com.github.technus.tectech.loader.TecTechConfig.DEBUG_MODE; import static com.github.technus.tectech.loader.gui.CreativeTabTecTech.creativeTabTecTech; +import static com.github.technus.tectech.mechanics.elementalMatter.core.transformations.bTransformationInfo.AVOGADRO_CONSTANT; +import static com.github.technus.tectech.mechanics.elementalMatter.core.transformations.bTransformationInfo.AVOGADRO_CONSTANT_144; import static cpw.mods.fml.relauncher.Side.CLIENT; import static net.minecraft.util.StatCollector.translateToLocal; @@ -140,10 +142,10 @@ public final class DebugElementalInstanceContainer_EM extends Item implements IE ItemStack that = new ItemStack(this, 1); that.setTagCompound(new NBTTagCompound()); list.add(that); - for(iElementalDefinition defintion: STACKS_REGISTERED){ - 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)))); + for(iElementalDefinition definition: STACKS_REGISTERED){ + list.add(setContent(new ItemStack(this).setStackDisplayName(definition.getName()+" 1 mol"),new cElementalInstanceStackMap(new cElementalInstanceStack(definition, AVOGADRO_CONSTANT)))); + list.add(setContent(new ItemStack(this).setStackDisplayName(definition.getName()+" 144 mol"),new cElementalInstanceStackMap(new cElementalInstanceStack(definition, AVOGADRO_CONSTANT_144)))); + list.add(setContent(new ItemStack(this).setStackDisplayName(definition.getName()+" 1000 mol"),new cElementalInstanceStackMap(new cElementalInstanceStack(definition, AVOGADRO_CONSTANT *1000)))); } } diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_ElementalContainer.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_ElementalContainer.java index d0b9411773..c8606f68f0 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_ElementalContainer.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_ElementalContainer.java @@ -1,11 +1,11 @@ package com.github.technus.tectech.thing.metaTileEntity.hatch; import com.github.technus.tectech.TecTech; -import com.github.technus.tectech.util.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.tElementalException; import com.github.technus.tectech.mechanics.pipe.IConnectsToElementalPipe; +import com.github.technus.tectech.util.Util; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import gregtech.api.enums.Dyes; @@ -23,8 +23,9 @@ import net.minecraft.util.EnumChatFormatting; import net.minecraftforge.fluids.FluidStack; import org.apache.commons.lang3.reflect.FieldUtils; -import static com.github.technus.tectech.util.CommonValues.*; import static com.github.technus.tectech.loader.TecTechConfig.DEBUG_MODE; +import static com.github.technus.tectech.mechanics.elementalMatter.core.transformations.bTransformationInfo.AVOGADRO_CONSTANT_144; +import static com.github.technus.tectech.util.CommonValues.*; import static gregtech.api.enums.Dyes.MACHINE_METAL; import static gregtech.api.metatileentity.implementations.GT_MetaTileEntity_MultiBlockBase.isValidMetaTileEntity; import static net.minecraft.util.StatCollector.translateToLocal; @@ -43,7 +44,7 @@ public abstract class GT_MetaTileEntity_Hatch_ElementalContainer extends GT_Meta protected cElementalInstanceStackMap content = new cElementalInstanceStackMap(); //float lifeTimeMult=1f; public int postEnergize = 0; - public float overflowMatter = 0f; + public double overflowMatter = 0f; public short id = -1; private byte deathDelay = 2; @@ -80,7 +81,8 @@ public abstract class GT_MetaTileEntity_Hatch_ElementalContainer extends GT_Meta super.saveNBTData(aNBT); aNBT.setInteger("postEnergize", postEnergize); //aNBT.setFloat("lifeTimeMult",lifeTimeMult); - aNBT.setFloat("overflowMatter", overflowMatter); + aNBT.setDouble("OverflowMatter", overflowMatter); + content.cleanUp(); aNBT.setTag("eM_Stacks", content.toNBT()); aNBT.setShort("eID", id); } @@ -90,7 +92,7 @@ public abstract class GT_MetaTileEntity_Hatch_ElementalContainer extends GT_Meta super.loadNBTData(aNBT); postEnergize = aNBT.getInteger("postEnergize"); //lifeTimeMult=aNBT.getFloat("lifeTimeMult"); - overflowMatter = aNBT.getFloat("overflowMatter"); + overflowMatter = aNBT.getFloat("overflowMatter")+aNBT.getDouble("OverflowMatter"); id = aNBT.getShort("eID"); try { content = cElementalInstanceStackMap.fromNBT(aNBT.getCompoundTag("eM_Stacks")); @@ -151,6 +153,7 @@ public abstract class GT_MetaTileEntity_Hatch_ElementalContainer extends GT_Meta } } else if (MOVE_AT == Tick) { if (content.hasStacks()) { + content.cleanUp(); moveAround(aBaseMetaTileEntity); } getBaseMetaTileEntity().setActive(content.hasStacks()); @@ -203,11 +206,11 @@ public abstract class GT_MetaTileEntity_Hatch_ElementalContainer extends GT_Meta } public int getMaxStacksCount() { - return mTier * 2; + return mTier * 128; } - public int getMaxStackSize() { - return mTier * (mTier - 7) * 1000; + public double getMaxStackSize() { + return mTier * (mTier - 7) * 64D * AVOGADRO_CONSTANT_144; } @Override @@ -239,7 +242,7 @@ public abstract class GT_MetaTileEntity_Hatch_ElementalContainer extends GT_Meta @Override public String[] getInfoData() { - if (TecTech.configTecTech.EASY_SCAN) { + if (TecTech.configTecTech.EASY_SCAN || DEBUG_MODE) { if (id > 0) { if (content == null || content.size() == 0) { return new String[]{translateToLocalFormatted("tt.keyword.ID", clientLocale) + ": " + EnumChatFormatting.AQUA + id, translateToLocalFormatted("tt.keyphrase.No_Stacks", clientLocale)}; diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_OverflowElemental.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_OverflowElemental.java index ad7f1fe159..a5e6dc4d5d 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_OverflowElemental.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_OverflowElemental.java @@ -44,13 +44,13 @@ public class GT_MetaTileEntity_Hatch_OverflowElemental extends GT_MetaTileEntity private static Textures.BlockIcons.CustomIcon EM_T_ACTIVE; public static Textures.BlockIcons.CustomIcon MufflerEM; public static Textures.BlockIcons.CustomIcon MufflerEMidle; - private float overflowMatter; - public final float overflowMax; - private final float overflowDisperse; + private double overflowMatter; + public final double overflowMax; + private final double overflowDisperse; private String clientLocale = "en_US"; - public GT_MetaTileEntity_Hatch_OverflowElemental(int aID, String aName, String aNameRegional, int aTier, float max) { + public GT_MetaTileEntity_Hatch_OverflowElemental(int aID, String aName, String aNameRegional, int aTier, double max) { super(aID, aName, aNameRegional, aTier, 0, translateToLocal("gt.blockmachines.hatch.emmuffler.desc.0"));//Disposes excess elemental Matter overflowMatter = max / 2; overflowMax = max; @@ -58,7 +58,7 @@ public class GT_MetaTileEntity_Hatch_OverflowElemental extends GT_MetaTileEntity Util.setTier(aTier, this); } - public GT_MetaTileEntity_Hatch_OverflowElemental(String aName, int aTier, float max, String aDescription, ITexture[][][] aTextures) { + public GT_MetaTileEntity_Hatch_OverflowElemental(String aName, int aTier, double max, String aDescription, ITexture[][][] aTextures) { super(aName, aTier, 0, aDescription, aTextures); overflowMatter = max / 2; overflowMax = max; @@ -124,13 +124,13 @@ public class GT_MetaTileEntity_Hatch_OverflowElemental extends GT_MetaTileEntity @Override public void saveNBTData(NBTTagCompound aNBT) { super.saveNBTData(aNBT); - aNBT.setFloat("overflowMatter", overflowMatter); + aNBT.setDouble("OverflowMatter", overflowMatter); } @Override public void loadNBTData(NBTTagCompound aNBT) { super.loadNBTData(aNBT); - overflowMatter = aNBT.getFloat("overflowMatter"); + overflowMatter = aNBT.getFloat("overflowMatter")+aNBT.getDouble("OverflowMatter"); } @Override @@ -235,17 +235,17 @@ public class GT_MetaTileEntity_Hatch_OverflowElemental extends GT_MetaTileEntity } //Return - Should Explode - public boolean addOverflowMatter(float matter) { + public boolean addOverflowMatter(double matter) { overflowMatter += matter; return overflowMatter > overflowMax; } - public float getOverflowMatter() { + public double getOverflowMatter() { return overflowMatter; } //Return - Should Explode - public boolean setOverflowMatter(float overflowMatter) { + public boolean setOverflowMatter(double overflowMatter) { this.overflowMatter = overflowMatter; return overflowMatter > overflowMax; } diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_bhg.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_bhg.java index 24fbb9e423..06476fb62e 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_bhg.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_bhg.java @@ -35,6 +35,7 @@ public class GT_MetaTileEntity_EM_bhg extends GT_MetaTileEntity_MultiblockBase_E private static Textures.BlockIcons.CustomIcon ScreenOFF; private static Textures.BlockIcons.CustomIcon ScreenON; + //todo CHECK VALUES private static final double NEUTRONIUM_BLOCK_MASS = 4.1E17; private static final double NEUTRONIUM_BLOCK_ATOM_COUNT = 2.4478671E44; private static final double NEUTRONIUM_BLOCK_TO_EU_INSTANT = URANIUM_MASS_TO_EU_INSTANT * NEUTRONIUM_BLOCK_MASS / (URANIUM_INGOT_MASS_DIFF * 1.78266191e-36);//~ 5.314e40 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 8f4e7969ee..329b3cbc14 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 @@ -4,6 +4,7 @@ import com.github.technus.tectech.TecTech; 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.constructable.IConstructable; +import com.github.technus.tectech.mechanics.elementalMatter.core.cElementalDecayResult; import com.github.technus.tectech.mechanics.elementalMatter.core.cElementalInstanceStackMap; import com.github.technus.tectech.mechanics.elementalMatter.core.cElementalMutableDefinitionStackMap; import com.github.technus.tectech.mechanics.elementalMatter.core.stacks.cElementalInstanceStack; @@ -36,11 +37,14 @@ import net.minecraftforge.common.util.ForgeDirection; import java.util.HashMap; +import static com.github.technus.tectech.loader.TecTechConfig.DEBUG_MODE; +import static com.github.technus.tectech.mechanics.elementalMatter.core.transformations.bTransformationInfo.AVOGADRO_CONSTANT; import static com.github.technus.tectech.mechanics.structure.StructureUtility.*; import static com.github.technus.tectech.thing.casing.GT_Block_CasingsTT.textureOffset; import static com.github.technus.tectech.thing.casing.GT_Block_CasingsTT.texturePage; import static com.github.technus.tectech.thing.casing.TT_Container_Casings.sBlockCasingsTT; import static com.github.technus.tectech.thing.metaTileEntity.multi.base.LedStatus.*; +import static com.github.technus.tectech.util.DoubleCount.add; import static net.minecraft.util.StatCollector.translateToLocal; /** @@ -280,7 +284,7 @@ public class GT_MetaTileEntity_EM_collider extends GT_MetaTileEntity_MultiblockB } return STATUS_WRONG; } - return STATUS_UNUSED; + return STATUS_OK; }; private static final INameFunction<GT_MetaTileEntity_EM_collider> MODE_NAME = (base_EM, p) -> { if (base_EM.isMaster()) { @@ -298,9 +302,9 @@ public class GT_MetaTileEntity_EM_collider extends GT_MetaTileEntity_MultiblockB //region structure //use multi A energy inputs, use less power the longer it runs - private static final IStructureDefinition<GT_MetaTileEntity_EM_collider> STRUCTURE_DEFINITION= StructureDefinition + private static final IStructureDefinition<GT_MetaTileEntity_EM_collider> STRUCTURE_DEFINITION = StructureDefinition .<GT_MetaTileEntity_EM_collider>builder() - .addShapeOldApi("main",new String[][]{ + .addShapeOldApi("main", new String[][]{ {"I0A0A0", "I00000", "I0A0A0",}, {"H0000000", "G001111100", "H0000000",}, {"F22223332222", "F41155555114", "F22223332222",}, @@ -323,23 +327,23 @@ public class GT_MetaTileEntity_EM_collider extends GT_MetaTileEntity_MultiblockB {"E20!!22222!!02", "E4155111115514", "E20!!22222!!02",}, {"F2222#$#2222", "F41155555114", "F2222#$#2222",}, }) - .addElement('0', ofBlock(sBlockCasingsTT,4)) - .addElement('1', ofBlock(sBlockCasingsTT,7)) - .addElement('2', defer(t->(int)t.eTier,(t,item)->2-(item.stackSize&1), - error(),ofBlock(sBlockCasingsTT,4),ofBlock(sBlockCasingsTT,5))) - .addElement('3', ofBlock(QuantumGlassBlock.INSTANCE,0)) - .addElement('4', defer(t->(int)t.eTier,(t,item)->2-(item.stackSize&1), - error(),ofBlock(sBlockCasingsTT,4),ofBlock(sBlockCasingsTT,6))) - .addElement('5', defer(t->(int)t.eTier,(t,item)->2-(item.stackSize&1), - error(),ofBlock(sBlockCasingsTT,8),ofBlock(sBlockCasingsTT,9))) + .addElement('0', ofBlock(sBlockCasingsTT, 4)) + .addElement('1', ofBlock(sBlockCasingsTT, 7)) + .addElement('2', defer(t -> (int) t.eTier, (t, item) -> 2 - (item.stackSize & 1), + error(), ofBlock(sBlockCasingsTT, 4), ofBlock(sBlockCasingsTT, 5))) + .addElement('3', ofBlock(QuantumGlassBlock.INSTANCE, 0)) + .addElement('4', defer(t -> (int) t.eTier, (t, item) -> 2 - (item.stackSize & 1), + error(), ofBlock(sBlockCasingsTT, 4), ofBlock(sBlockCasingsTT, 6))) + .addElement('5', defer(t -> (int) t.eTier, (t, item) -> 2 - (item.stackSize & 1), + error(), ofBlock(sBlockCasingsTT, 8), ofBlock(sBlockCasingsTT, 9))) .addElement('&', ofHatchAdderOptional(GT_MetaTileEntity_EM_collider::addClassicToMachineList, - textureOffset,1,sBlockCasingsTT,0)) + textureOffset, 1, sBlockCasingsTT, 0)) .addElement('!', ofHatchAdderOptional(GT_MetaTileEntity_EM_collider::addElementalInputToMachineList, - textureOffset + 4,2,sBlockCasingsTT,4)) + textureOffset + 4, 2, sBlockCasingsTT, 4)) .addElement('$', ofHatchAdderOptional(GT_MetaTileEntity_EM_collider::addElementalOutputToMachineList, - textureOffset + 4,3,sBlockCasingsTT,4)) + textureOffset + 4, 3, sBlockCasingsTT, 4)) .addElement('#', ofHatchAdderOptional(GT_MetaTileEntity_EM_collider::addElementalMufflerToMachineList, - textureOffset + 4,4,sBlockCasingsTT,4)) + textureOffset + 4, 4, sBlockCasingsTT, 4)) .build(); private static final String[] description = new String[]{ EnumChatFormatting.AQUA + translateToLocal("tt.keyphrase.Hint_Details") + ":", @@ -366,19 +370,19 @@ public class GT_MetaTileEntity_EM_collider extends GT_MetaTileEntity_MultiblockB } public static void setValues(int heliumPlasmaValue) { - double MASS_TO_EU_PARTIAL = heliumPlasmaValue / 1.75893000478707E07;//mass diff + double MASS_TO_EU_PARTIAL = heliumPlasmaValue / (1.75893000478707E07* AVOGADRO_CONSTANT);//mass diff MASS_TO_EU_INSTANT = MASS_TO_EU_PARTIAL * 20; STARTUP_COST = -heliumPlasmaValue * 10000; KEEPUP_COST = -heliumPlasmaValue; } - protected double fuse(GT_MetaTileEntity_EM_collider partner) { + protected double fuse(GT_MetaTileEntity_EM_collider partner) {///CAN MAKE EU if (partner.stack != null && stack != null) {//todo add single event mode as an option boolean check = stack.definition.fusionMakesEnergy(stack.getEnergy()) && partner.stack.definition.fusionMakesEnergy(partner.stack.getEnergy()); cElementalInstanceStack stack2 = partner.stack; - double preMass = stack2.getMass() + stack.getMass(); + double preMass = add(stack2.getMass(),stack.getMass()); //System.out.println("preMass = " + preMass); cElementalInstanceStackMap map = new cElementalInstanceStackMap(); @@ -399,8 +403,33 @@ public class GT_MetaTileEntity_EM_collider extends GT_MetaTileEntity_MultiblockB partner.stack = stack = null; //System.out.println("check = " + check); //System.out.println("preMass-map.getMass() = " + (preMass - map.getMass())); - return check ? preMass - map.getMass() : - Math.min(preMass - map.getMass(), 0); + return check ? preMass - map.getMass() : Math.min(preMass - map.getMass(), 0); + } + return 0; + } + + protected double collide(GT_MetaTileEntity_EM_collider partner) {//DOES NOT MAKE EU! + if (partner.stack != null && stack != null) {//todo add single event mode as an option + cElementalInstanceStack stack2 = partner.stack; + double preMass = stack2.getMass() + stack.getMass(); + //System.out.println("preMass = " + preMass); + + cElementalInstanceStackMap map = new cElementalInstanceStackMap(); + IColliderHandler colliderHandler; + if (stack2.definition.getClassType() > stack.definition.getClassType()) {//always bigger first + colliderHandler = FUSE_HANDLERS.get((stack2.definition.getClassType() << 16) | stack.definition.getClassType()); + if (handleRecipe(stack2, map, colliderHandler)) return 0; + } else { + colliderHandler = FUSE_HANDLERS.get((stack.definition.getClassType() << 16) | stack2.definition.getClassType()); + if (handleRecipe(stack2, map, colliderHandler)) return 0; + } + //System.out.println("outputEM[0].getMass() = " + outputEM[0].getMass()); + outputEM = new cElementalInstanceStackMap[]{map}; + + partner.stack = stack = null; + //System.out.println("check = " + check); + //System.out.println("preMass-map.getMass() = " + (preMass - map.getMass())); + return Math.min(preMass - map.getMass(), 0); } return 0; } @@ -438,20 +467,23 @@ public class GT_MetaTileEntity_EM_collider extends GT_MetaTileEntity_MultiblockB private void makeEU(double massDiff) { plasmaEnergy += massDiff * MASS_TO_EU_INSTANT; - System.out.println("plasmaEnergy = " + plasmaEnergy); + if (DEBUG_MODE) { + System.out.println("plasmaEnergy = " + plasmaEnergy); + } } private cElementalInstanceStackMap tickStack() { if (stack == null) { return null; } - cElementalInstanceStackMap newInstances = stack.decay(1, stack.age += 1, 0); + cElementalDecayResult newInstances = stack.decay(1, stack.age += 1, 0); if (newInstances == null) { stack.nextColor(); + return null; } else { - stack = newInstances.remove(newInstances.getLast().definition); + stack = newInstances.getOutput().remove(newInstances.getOutput().getLast().definition); + return newInstances.getOutput(); } - return newInstances; } @Override @@ -476,7 +508,7 @@ public class GT_MetaTileEntity_EM_collider extends GT_MetaTileEntity_MultiblockB eTier = 0; return false; } - if (structureCheck_EM("main",11, 1, 18)) { + if (structureCheck_EM("main", 11, 1, 18)) { return true; } eTier = 0; @@ -515,14 +547,13 @@ public class GT_MetaTileEntity_EM_collider extends GT_MetaTileEntity_MultiblockB mMaxProgresstime = 20; mEUt = KEEPUP_COST; eAmpereFlow = 2; - return true; } else { started = true; mMaxProgresstime = 20; mEUt = STARTUP_COST; eAmpereFlow = 10; - return true; } + return true; } @Override @@ -541,7 +572,7 @@ public class GT_MetaTileEntity_EM_collider extends GT_MetaTileEntity_MultiblockB makeEU(fuse(partner)); break; case COLLIDE_MODE: - //collide(partner);//todo + collide(partner);//todo break; default: { outputEM = new cElementalInstanceStackMap[2]; @@ -675,7 +706,7 @@ public class GT_MetaTileEntity_EM_collider extends GT_MetaTileEntity_MultiblockB iGregTechTileEntity.getZCoord() + zDir, TT_Container_Casings.sHintCasingsTT, 12); } - structureBuild_EM("main",11, 1, 18,hintsOnly, stackSize); + structureBuild_EM("main", 11, 1, 18, hintsOnly, stackSize); } @Override diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_decay.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_decay.java index d8ddc2c5b5..d534b41fec 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_decay.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_decay.java @@ -31,6 +31,7 @@ import net.minecraft.item.ItemStack; import net.minecraft.util.EnumChatFormatting; import org.apache.commons.lang3.reflect.FieldUtils; +import static com.github.technus.tectech.mechanics.elementalMatter.core.transformations.bTransformationInfo.AVOGADRO_CONSTANT; import static com.github.technus.tectech.mechanics.structure.Structure.adders; import static com.github.technus.tectech.thing.casing.GT_Block_CasingsTT.textureOffset; import static com.github.technus.tectech.thing.casing.GT_Block_CasingsTT.texturePage; @@ -49,7 +50,7 @@ public class GT_MetaTileEntity_EM_decay extends GT_MetaTileEntity_MultiblockBase private static Textures.BlockIcons.CustomIcon ScreenOFF; private static Textures.BlockIcons.CustomIcon ScreenON; - public static final double URANIUM_INGOT_MASS_DIFF = 1.6114516E10; + public static final double URANIUM_INGOT_MASS_DIFF = 1.6114516E10* AVOGADRO_CONSTANT; private static final double URANIUM_MASS_TO_EU_PARTIAL = ConfigUtil.getFloat(MainConfig.get(), "balance/energy/generator/nuclear") * 3_000_000.0 / URANIUM_INGOT_MASS_DIFF; public static final double URANIUM_MASS_TO_EU_INSTANT = URANIUM_MASS_TO_EU_PARTIAL * 20; @@ -131,28 +132,24 @@ public class GT_MetaTileEntity_EM_decay extends GT_MetaTileEntity_MultiblockBase outputEM[0] = input; outputEM[1] = new cElementalInstanceStackMap(); - for (cElementalInstanceStack stack : outputEM[0].values()) { - if (stack.getEnergy() == 0 && stack.definition.decayMakesEnergy(1) - && getBaseMetaTileEntity().decreaseStoredEnergyUnits( - (long) (stack.getEnergySettingCost(1) * URANIUM_MASS_TO_EU_INSTANT), false)) { + if (stack.getEnergy() == 0 && stack.definition.decayMakesEnergy(1) && + getBaseMetaTileEntity().decreaseStoredEnergyUnits( + (long) (stack.getEnergySettingCost(1) * URANIUM_MASS_TO_EU_INSTANT), false)) { stack.setEnergy(1); } else if (!stack.definition.decayMakesEnergy(stack.getEnergy())) { outputEM[0].remove(stack.definition); outputEM[1].putReplace(stack); } - //System.out.println(stack.definition.getSymbol()+" "+stack.amount); } - float preMass = outputEM[0].getMass(); - outputEM[0].tickContent(1, 0, 1); - double energyDose = ((preMass - outputEM[0].getMass()) * URANIUM_MASS_TO_EU_PARTIAL); eAmpereFlow = (long) ampereFlow.get(); if (eAmpereFlow <= 0) { mEUt = 0; return false; } - mEUt = (int) (energyDose / eAmpereFlow); + double energyDose = -outputEM[0].tickContent(1, 0, 1) * URANIUM_MASS_TO_EU_PARTIAL; + mEUt = (int) ( energyDose / eAmpereFlow); return outputEM[0].hasStacks(); } 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 1ba1389c80..9814092710 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 @@ -4,10 +4,11 @@ import com.github.technus.tectech.mechanics.constructable.IConstructable; 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.core.stacks.iHasElementalDefinition; +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.iExchangeInfo; -import com.github.technus.tectech.mechanics.structure.adders.IHatchAdder; import com.github.technus.tectech.mechanics.structure.Structure; +import com.github.technus.tectech.mechanics.structure.adders.IHatchAdder; import com.github.technus.tectech.thing.block.QuantumGlassBlock; import com.github.technus.tectech.thing.metaTileEntity.hatch.GT_MetaTileEntity_Hatch_InputElemental; import com.github.technus.tectech.thing.metaTileEntity.multi.base.GT_MetaTileEntity_MultiblockBase_EM; @@ -74,8 +75,8 @@ public class GT_MetaTileEntity_EM_dequantizer extends GT_MetaTileEntity_Multiblo private void startRecipe(iHasElementalDefinition from, long energy) { mMaxProgresstime = 20; mEfficiencyIncrease = 10000; - float mass = from.getMass(); - float euMult = Math.abs(mass / refMass); + double mass = from.getMass(); + double euMult = Math.abs(mass / refMass); eAmpereFlow = (int) Math.ceil(Math.sqrt(Math.sqrt(euMult))); if (mass > refUnstableMass || from.getDefinition().getRawTimeSpan(energy) < STABLE_RAW_LIFE_TIME) { mEUt = (int) -V[8]; @@ -99,32 +100,36 @@ public class GT_MetaTileEntity_EM_dequantizer extends GT_MetaTileEntity_Multiblo for (GT_MetaTileEntity_Hatch_InputElemental in : eInputHatches) { cElementalInstanceStackMap map = in.getContainerHandler(); for (cElementalInstanceStack stack : map.values()) { - iExchangeInfo info = stack.getDefinition().someAmountIntoFluidStack(); - if (info != null) { - if (map.removeAllAmounts(false, (iHasElementalDefinition) info.input())) { - mOutputFluids = new FluidStack[]{(FluidStack) info.output()}; - startRecipe((iHasElementalDefinition) info.input(), stack.getEnergy()); - return true; + { + aFluidDequantizationInfo info = stack.getDefinition().someAmountIntoFluidStack(); + if (info != null) { + if (map.removeAllAmounts(false, info.input())) { + mOutputFluids = new FluidStack[]{info.output()}; + startRecipe(info.input(), stack.getEnergy()); + return true; + } } } - - info = stack.getDefinition().someAmountIntoItemsStack(); - if (info != null) { - if (map.removeAllAmounts(false, (iHasElementalDefinition) info.input())) { - mOutputItems = new ItemStack[]{(ItemStack) info.output()}; - startRecipe((iHasElementalDefinition) info.input(), stack.getEnergy()); - return true; + { + aItemDequantizationInfo info = stack.getDefinition().someAmountIntoItemsStack(); + if (info != null) { + if (map.removeAllAmounts(false, info.input())) { + mOutputItems = new ItemStack[]{info.output()}; + startRecipe(info.input(), stack.getEnergy()); + return true; + } } } - - info = stack.getDefinition().someAmountIntoOredictStack(); - if (info != null) { - if (map.removeAllAmounts(false, (iHasElementalDefinition) info.input())) { - ArrayList<ItemStack> items = OreDictionary.getOres(((aOredictDequantizationInfo) info).out); - if (items != null && !items.isEmpty()) { - mOutputItems = new ItemStack[]{items.get(0)}; - startRecipe((iHasElementalDefinition) info.input(), stack.getEnergy()); - return true; + { + aOredictDequantizationInfo info = stack.getDefinition().someAmountIntoOredictStack(); + if (info != null) { + if (map.removeAllAmounts(false, info.input())) { + ArrayList<ItemStack> items = OreDictionary.getOres(info.out); + if (items != null && !items.isEmpty()) { + mOutputItems = new ItemStack[]{items.get(0)}; + startRecipe(info.input(), stack.getEnergy()); + return true; + } } } } 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 a04a960bf1..d6ab35cd4b 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 @@ -155,8 +155,8 @@ public class GT_MetaTileEntity_EM_quantizer extends GT_MetaTileEntity_Multiblock private void startRecipe(iHasElementalDefinition into) { mMaxProgresstime = 20; mEfficiencyIncrease = 10000; - float mass = into.getMass(); - float euMult = Math.abs(mass / refMass); + double mass = into.getMass(); + double euMult = Math.abs(mass / refMass); eAmpereFlow = (int) Math.ceil(Math.sqrt(Math.sqrt(euMult))); if (mass > refUnstableMass || into.getDefinition().getRawTimeSpan(DEFAULT_ENERGY_LEVEL) < STABLE_RAW_LIFE_TIME) { mEUt = (int) -V[8]; diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/base/GT_MetaTileEntity_MultiblockBase_EM.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/base/GT_MetaTileEntity_MultiblockBase_EM.java index 28c90b58d0..9e508f9e7e 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/base/GT_MetaTileEntity_MultiblockBase_EM.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/base/GT_MetaTileEntity_MultiblockBase_EM.java @@ -14,9 +14,9 @@ import com.github.technus.tectech.mechanics.elementalMatter.core.cElementalInsta import com.github.technus.tectech.mechanics.elementalMatter.core.stacks.cElementalDefinitionStack; 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.structure.adders.IHatchAdder; import com.github.technus.tectech.mechanics.structure.IStructureDefinition; import com.github.technus.tectech.mechanics.structure.Structure; +import com.github.technus.tectech.mechanics.structure.adders.IHatchAdder; import com.github.technus.tectech.thing.metaTileEntity.hatch.*; import com.github.technus.tectech.thing.metaTileEntity.multi.base.render.TT_RenderedExtendedFacingTexture; import com.github.technus.tectech.util.Util; @@ -49,7 +49,9 @@ import java.util.ArrayList; import static com.github.technus.tectech.loader.TecTechConfig.DEBUG_MODE; import static com.github.technus.tectech.thing.casing.GT_Block_CasingsTT.texturePage; import static com.github.technus.tectech.util.CommonValues.*; +import static com.github.technus.tectech.util.DoubleCount.div; import static com.github.technus.tectech.util.Util.getTier; +import static java.lang.Math.min; /** * Created by danie_000 on 27.10.2016. @@ -1374,12 +1376,12 @@ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEnt if (voider.overflowMax < voider.getOverflowMatter()) { continue; } - float remaining = voider.overflowMax - voider.getOverflowMatter(); + double remaining = voider.overflowMax - voider.getOverflowMatter(); for (GT_MetaTileEntity_Hatch_InputElemental in : eInputHatches) { for (cElementalInstanceStack instance : in.getContainerHandler().values()) { - long qty = (long) Math.floor(remaining / instance.definition.getMass()); + double qty = div(remaining,instance.definition.getMass()); if (qty > 0) { - qty = Math.min(qty, instance.amount); + qty = min(qty, instance.amount); if (voider.addOverflowMatter(instance.definition.getMass() * qty)) { voider.setOverflowMatter(voider.overflowMax); } @@ -1389,9 +1391,9 @@ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEnt } for (GT_MetaTileEntity_Hatch_OutputElemental out : eOutputHatches) { for (cElementalInstanceStack instance : out.getContainerHandler().values()) { - long qty = (long) Math.floor(remaining / instance.definition.getMass()); + double qty = div(remaining,instance.definition.getMass()); if (qty > 0) { - qty = Math.min(qty, instance.amount); + qty = min(qty, instance.amount); if (voider.addOverflowMatter(instance.definition.getMass() * qty)) { voider.setOverflowMatter(voider.overflowMax); } @@ -1496,7 +1498,7 @@ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEnt mEfficiencyIncrease = 0; if (aBaseMetaTileEntity.isAllowedToWork()) { if (checkRecipe(mInventory[1])) { - mEfficiency = Math.max(0, Math.min(mEfficiency + mEfficiencyIncrease, getMaxEfficiency(mInventory[1]) - (getIdealStatus() - getRepairStatus()) * 1000)); + mEfficiency = Math.max(0, min(mEfficiency + mEfficiencyIncrease, getMaxEfficiency(mInventory[1]) - (getIdealStatus() - getRepairStatus()) * 1000)); } else { afterRecipeCheckFailed(); } @@ -1511,7 +1513,7 @@ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEnt } else if (RECIPE_AT == Tick || aBaseMetaTileEntity.hasWorkJustBeenEnabled()) { if (aBaseMetaTileEntity.isAllowedToWork()) { if (checkRecipe(mInventory[1])) { - mEfficiency = Math.max(0, Math.min(mEfficiency + mEfficiencyIncrease, getMaxEfficiency(mInventory[1]) - (getIdealStatus() - getRepairStatus()) * 1000)); + mEfficiency = Math.max(0, min(mEfficiency + mEfficiencyIncrease, getMaxEfficiency(mInventory[1]) - (getIdealStatus() - getRepairStatus()) * 1000)); } else { afterRecipeCheckFailed(); } @@ -1684,7 +1686,7 @@ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEnt } } } - setEUVar(Math.min(getEUVar() + euVar, maxEUStore())); + setEUVar(min(getEUVar() + euVar, maxEUStore())); return false; } @@ -1863,7 +1865,7 @@ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEnt cleanMassEM_EM(target.getMass()); } - public void cleanMassEM_EM(float mass) { + public void cleanMassEM_EM(double mass) { if (mass > 0) { if (eMufflerHatches.size() < 1) { TecTech.anomalyHandler.addAnomaly(getBaseMetaTileEntity(), mass); diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/base/MultiblockControl.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/base/MultiblockControl.java index 41bc0e5a37..8429bf4e67 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/base/MultiblockControl.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/base/MultiblockControl.java @@ -5,68 +5,70 @@ package com.github.technus.tectech.thing.metaTileEntity.multi.base; */ public class MultiblockControl<T>{ - private final int[] controls=new int[7]; private final boolean shouldExplode; - private final T values; + private final T value; + private final int eUt; + private final int amperes; + private final int requiredData; + private final int effIncrease; + private final int maxProgressTime; + private final int pollutionToAdd; + private final double excessMass; - public MultiblockControl(T values, int EUt, int amperes, int requiredData, int effIncrease, int maxProgressTime){ - this.values = values; - controls[0]=EUt; - controls[1]=amperes; - controls[2]=requiredData; - controls[3]=effIncrease; - controls[4]=maxProgressTime; - shouldExplode=false; + public MultiblockControl(T value, int eUt, int amperes, int requiredData, int effIncrease, int maxProgressTime, int pollutionToAdd, double excessMass,boolean shouldExplode){ + this.value = value; + this.eUt = eUt; + this.amperes = amperes; + this.requiredData = requiredData; + this.effIncrease = effIncrease; + this.maxProgressTime = maxProgressTime; + this.pollutionToAdd = pollutionToAdd; + this.excessMass = excessMass; + this.shouldExplode=shouldExplode; } - public MultiblockControl(T values, int EUt, int amperes, int requiredData, int effIncrease, int maxProgressTime, int pollutionToAdd, float excessMass){ - this.values = values; - controls[0]=EUt; - controls[1]=amperes; - controls[2]=requiredData; - controls[3]=effIncrease; - controls[4]=maxProgressTime; - controls[5]=pollutionToAdd; - controls[6]=Float.floatToIntBits(excessMass); - shouldExplode=false; + public MultiblockControl(T value, int eUt, int amperes, int requiredData, int effIncrease, int maxProgressTime, int pollutionToAdd, double excessMass){ + this(value, eUt, amperes, requiredData, effIncrease, maxProgressTime,pollutionToAdd,excessMass,false); } - public MultiblockControl(float excessMass){ - this.values = null; - controls[6]=Float.floatToIntBits(excessMass); - shouldExplode=true; + public MultiblockControl(T value, int eUt, int amperes, int requiredData, int effIncrease, int maxProgressTime){ + this(value,eUt,amperes,requiredData,effIncrease,maxProgressTime,0,0); + } + + public MultiblockControl(double excessMass){ + this(null,0,0,0,0,0,0,excessMass,true); } public T getValue() { - return values; + return value; } public int getEUT(){ - return controls[0]; + return eUt; } public int getAmperage(){ - return controls[1]; + return amperes; } public int getRequiredData(){ - return controls[2]; + return requiredData; } public int getEffIncrease(){ - return controls[3]; + return effIncrease; } public int getMaxProgressTime(){ - return controls[4]; + return maxProgressTime; } public int getPollutionToAdd(){ - return controls[5]; + return pollutionToAdd; } - public float getExcessMass(){ - return Float.intBitsToFloat(controls[6]); + public double getExcessMass(){ + return excessMass; } public boolean shouldExplode() { 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 9612426598..1ed1278bce 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 @@ -11,16 +11,22 @@ import com.github.technus.tectech.thing.metaTileEntity.multi.base.Parameters; import java.util.Arrays; -import static com.github.technus.tectech.util.CommonValues.V; import static com.github.technus.tectech.loader.TecTechConfig.DEBUG_MODE; +import static com.github.technus.tectech.mechanics.elementalMatter.core.transformations.bTransformationInfo.AVOGADRO_CONSTANT_144; import static com.github.technus.tectech.thing.metaTileEntity.multi.base.LedStatus.*; +import static com.github.technus.tectech.util.CommonValues.V; +import static com.github.technus.tectech.util.DoubleCount.*; /** * Created by danie_000 on 24.12.2017. */ public class Behaviour_Centrifuge implements GT_MetaTileEntity_EM_machine.IBehaviour { private final byte tier; - private float radius, maxRPM, maxRCF, maxForce, maxCapacity; + private double maxRPM; + private final double radius; + private final double maxRCF; + private final double maxForce; + private final double maxCapacity; private Parameters.Group.ParameterIn settingRPM, settingFraction; private final static INameFunction<GT_MetaTileEntity_EM_machine> rpmName= (gt_metaTileEntity_em_machine, iParameter) -> "RPM Setting"; private final IStatusFunction<GT_MetaTileEntity_EM_machine> rpmStatus= (gt_metaTileEntity_em_machine, iParameter) -> { @@ -65,12 +71,12 @@ public class Behaviour_Centrifuge implements GT_MetaTileEntity_EM_machine.IBehav //6 to 12 recommended public Behaviour_Centrifuge(int desiredTier) { tier = (byte) desiredTier; - radius = 0.5f - (12 - tier) / 64f; - maxRCF = (float) (Math.pow(Math.E, tier) * 12); - maxRPM = (float) Math.sqrt(maxRCF / (0.001118 * radius)); - float maxSafeMass = dAtomDefinition.getSomethingHeavy().getMass() * (1 << tier); + radius = 0.5D - (12D - tier) / 64D; + maxRCF = Math.pow(Math.E, tier) * 12D; + maxRPM = Math.sqrt(maxRCF / (0.001118D * radius)); + double maxSafeMass = dAtomDefinition.getSomethingHeavy().getMass() * (1 << tier); maxForce = maxSafeMass * maxRCF;// (eV/c^2 * m/s) / g - maxCapacity = maxSafeMass * 4f * radius;// eV/c^2 + maxCapacity = maxSafeMass * AVOGADRO_CONSTANT_144 * radius;// eV/c^2 } private double getRCF(double RPM) { @@ -78,19 +84,19 @@ public class Behaviour_Centrifuge implements GT_MetaTileEntity_EM_machine.IBehav } private void addRandomly(cElementalInstanceStack me, cElementalInstanceStackMap[] toThis, int fractionCount) { - long amountPerFraction = me.amount / fractionCount; + double amountPerFraction = div(me.amount,fractionCount); cElementalInstanceStack[] stacks = new cElementalInstanceStack[fractionCount]; for (int i = 0; i < fractionCount; i++) { stacks[i] = me.clone(); stacks[i].amount = amountPerFraction; toThis[i].putReplace(stacks[i]); } - int remainingAmount = (int) (me.amount % fractionCount); - while (remainingAmount > 0) { - int amountToAdd = TecTech.RANDOM.nextInt(remainingAmount) + 1; - stacks[TecTech.RANDOM.nextInt(fractionCount)].amount += amountToAdd; - remainingAmount -= amountToAdd; - } + //int remainingAmount = (int) (me.amount % fractionCount); + //while (remainingAmount > 0) { + // int amountToAdd = TecTech.RANDOM.nextInt(remainingAmount) + 1; + // stacks[TecTech.RANDOM.nextInt(fractionCount)].amount += amountToAdd; + // remainingAmount -= amountToAdd; + //} } @Override @@ -116,15 +122,16 @@ public class Behaviour_Centrifuge implements GT_MetaTileEntity_EM_machine.IBehav for (cElementalInstanceStack stack : stacks) { inputMass += Math.abs(stack.getMass()); } - float excessMass = 0; + double excessMass = 0; while (inputMass > maxCapacity) { cElementalInstanceStack randomStack = stacks[TecTech.RANDOM.nextInt(stacks.length)]; - int amountToRemove = TecTech.RANDOM.nextInt((int) randomStack.getAmount()) + 1; - randomStack.amount -= amountToRemove;//mutates the parent InstanceStackMap + double amountToRemove = TecTech.RANDOM.nextDouble()/10D * randomStack.getAmount(); + randomStack.amount= sub(randomStack.amount,amountToRemove);//mutates the parent InstanceStackMap if (randomStack.amount <= 0) { input.remove(randomStack.definition); + stacks = input.values(); } - float mass = Math.abs(randomStack.getDefinition().getMass()) * amountToRemove; + double mass = Math.abs(randomStack.getDefinition().getMass()) * amountToRemove; excessMass += mass; inputMass -= mass; } @@ -147,7 +154,7 @@ public class Behaviour_Centrifuge implements GT_MetaTileEntity_EM_machine.IBehav TecTech.LOGGER.info("mixingFactor "+mixingFactor); } - int mEut = (int) (Math.pow(settingRPM.get() / maxRPM, 3f) * V[tier]); + int mEut = (int) (Math.pow(settingRPM.get() / maxRPM, 3D) * V[tier]); mEut = Math.max(mEut, 512); mEut = -mEut; int mTicks = (int) (20 * (inputMass / maxCapacity) * (fractionCount - 1)); @@ -158,8 +165,8 @@ public class Behaviour_Centrifuge implements GT_MetaTileEntity_EM_machine.IBehav stacks = input.takeAllToNewMap().values();//cleanup stacks if (stacks.length > 1) { Arrays.sort(stacks, (o1, o2) -> { - float m1 = o1.definition.getMass(); - float m2 = o2.definition.getMass(); + double m1 = o1.definition.getMass(); + double m2 = o2.definition.getMass(); if (m1 < m2) return -1; if (m1 > m2) return 1; return o1.compareTo(o2); @@ -169,17 +176,17 @@ public class Behaviour_Centrifuge implements GT_MetaTileEntity_EM_machine.IBehav for (cElementalInstanceStack stack : stacks) { double tempMass=Math.abs(stack.getMass()); if(tempMass!=0) { - long amount = stack.amount; - stack.amount *= mixingFactor; + double amount = stack.amount; + stack.amount = mul(stack.amount,mixingFactor); addRandomly(stack, outputs, fractionCount); - stack.amount = amount - stack.amount; + stack.amount = sub(amount,stack.amount); absMassPerOutput += tempMass; } } //if(DEBUG_MODE){ // TecTech.LOGGER.info("absMass "+absMassPerOutput); //} - absMassPerOutput /= fractionCount; + absMassPerOutput = div(absMassPerOutput,fractionCount); if(DEBUG_MODE){ TecTech.LOGGER.info("absMassPerOutput "+absMassPerOutput); } @@ -190,7 +197,7 @@ public class Behaviour_Centrifuge implements GT_MetaTileEntity_EM_machine.IBehav for (int stackNo = 0; stackNo < stacks.length; stackNo++) { if (stacks[stackNo] != null) { double stackMass = Math.abs(stacks[stackNo].getMass()); - long amount = (long) (remaining/Math.abs(stacks[stackNo].definition.getMass())); + double amount = div(remaining,Math.abs(stacks[stackNo].definition.getMass())); //if(DEBUG_MODE){ // TecTech.LOGGER.info("stackMass "+stackMass); // TecTech.LOGGER.info("defMass "+stacks[stackNo].definition.getMass()); @@ -201,15 +208,15 @@ public class Behaviour_Centrifuge implements GT_MetaTileEntity_EM_machine.IBehav addRandomly(stacks[stackNo], outputs, fractionCount); stacks[stackNo] = null; } else if (amount >= stacks[stackNo].amount) { - remaining -= stackMass; + remaining= sub(remaining,stackMass); outputs[fraction].putUnify(stacks[stackNo]); stacks[stackNo] = null; } else if (amount > 0) { - remaining -= amount * stacks[stackNo].definition.getMass(); + remaining= sub(remaining, mul(amount,stacks[stackNo].definition.getMass())); cElementalInstanceStack clone = stacks[stackNo].clone(); clone.amount = amount; outputs[fraction].putUnify(clone); - stacks[stackNo].amount-=amount; + stacks[stackNo].amount= sub(stacks[stackNo].amount,amount); //if(DEBUG_MODE){ // TecTech.LOGGER.info("remainingAfter "+remaining); // TecTech.LOGGER.info("amountCloneAfter "+clone.amount+"/"+stacks[stackNo].amount); 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 c79087d051..40e2942bab 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 @@ -9,8 +9,11 @@ import com.github.technus.tectech.thing.metaTileEntity.multi.base.IStatusFunctio import com.github.technus.tectech.thing.metaTileEntity.multi.base.MultiblockControl; import com.github.technus.tectech.thing.metaTileEntity.multi.base.Parameters; +import static com.github.technus.tectech.mechanics.elementalMatter.core.transformations.bTransformationInfo.AVOGADRO_CONSTANT_144; import static com.github.technus.tectech.util.CommonValues.V; import static com.github.technus.tectech.thing.metaTileEntity.multi.base.LedStatus.*; +import static com.github.technus.tectech.util.DoubleCount.mul; +import static com.github.technus.tectech.util.DoubleCount.sub; /** * Created by danie_000 on 24.12.2017. @@ -19,8 +22,8 @@ public class Behaviour_ElectromagneticSeparator implements GT_MetaTileEntity_EM_ private final byte tier; private int ticks; private byte precisionFull,precisionMinimal; - private float maxCapacity; - private long maxCharge; + private double maxCapacity; + private double maxCharge; private int offsetMax; private Parameters.Group.ParameterIn fullSetting,minimalSetting,offsetSetting; private final static INameFunction<GT_MetaTileEntity_EM_machine> fullName= (gt_metaTileEntity_em_machine, iParameter) -> "Full Precision Input [e/3]"; @@ -85,8 +88,8 @@ public class Behaviour_ElectromagneticSeparator implements GT_MetaTileEntity_EM_ public Behaviour_ElectromagneticSeparator(int desiredTier){ tier=(byte) desiredTier; ticks =Math.max(20,(1<<(12-desiredTier))*20); - maxCapacity= dAtomDefinition.getSomethingHeavy().getMass()*(2<<tier); - maxCharge=144*(1<<(tier-5)); + maxCapacity= dAtomDefinition.getSomethingHeavy().getMass()*(2<<tier)* AVOGADRO_CONSTANT_144; + maxCharge=144D*(1<<(tier-5)); switch (tier){ case 12: precisionFull=1; @@ -153,20 +156,20 @@ public class Behaviour_ElectromagneticSeparator implements GT_MetaTileEntity_EM_ float excessMass = 0; while (inputMass > maxCapacity) { cElementalInstanceStack randomStack = stacks[TecTech.RANDOM.nextInt(stacks.length)]; - int amountToRemove = TecTech.RANDOM.nextInt((int) randomStack.getAmount()) + 1; - randomStack.amount -= amountToRemove;//mutates the parent InstanceStackMap + double amountToRemove = TecTech.RANDOM.nextDouble()/10D * randomStack.getAmount(); + randomStack.amount= sub(randomStack.amount,amountToRemove);//mutates the parent InstanceStackMap if (randomStack.amount <= 0) { input.remove(randomStack.definition); } - float mass = Math.abs(randomStack.getDefinition().getMass()) * amountToRemove; + double mass = Math.abs(randomStack.getDefinition().getMass()) * amountToRemove; excessMass += mass; inputMass -= mass; } - long totalCharge=Math.abs(input.getCharge()); + double totalCharge=Math.abs(input.getCharge()); if (totalCharge>maxCharge) return new MultiblockControl<>(excessMass);//AND THEN IT EXPLODES - int mEut=(int)(((double)totalCharge/(double) maxCharge)*V[tier]); + int mEut=(int)((totalCharge/ maxCharge)*V[tier]); mEut = Math.max(mEut, 512); int mTicks=(int)(ticks*(inputMass/maxCapacity)); mTicks=Math.max(mTicks,20); @@ -192,24 +195,18 @@ public class Behaviour_ElectromagneticSeparator implements GT_MetaTileEntity_EM_ }else if(charge<=-precisionFullIn){ outputs[0].putReplace(stack); }else{ - long amount=(long)(stack.amount*((Math.abs(charge)-precisionMinimalIn+1)/levelsCountPlus1));//todo check - if(amount>=stack.amount){ - if(charge>0){ - outputs[2].putReplace(stack); - }else { - outputs[0].putReplace(stack); - } - }else { - cElementalInstanceStack clone=stack.clone(); - clone.amount-=amount; + double amount=mul(stack.amount,(Math.abs(charge)-precisionMinimalIn+1D)/levelsCountPlus1);//todo check + if (amount < stack.amount) { + cElementalInstanceStack clone = stack.clone(); + clone.amount = sub(clone.amount, amount); outputs[1].putReplace(clone); - stack.amount=amount; - if(charge>0){ - outputs[2].putReplace(stack); - }else { - outputs[0].putReplace(stack); - } + stack.amount = amount; + } + if(charge>0){ + outputs[2].putReplace(stack); + }else { + outputs[0].putReplace(stack); } } } diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/em_machine/Behaviour_Recycler.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/em_machine/Behaviour_Recycler.java index b81dd885a5..c86c06b2a0 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/em_machine/Behaviour_Recycler.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/em_machine/Behaviour_Recycler.java @@ -11,10 +11,10 @@ import static com.github.technus.tectech.util.CommonValues.V; */ public class Behaviour_Recycler implements GT_MetaTileEntity_EM_machine.IBehaviour { private final int tier; - private final float coeff; + private final double coeff; public Behaviour_Recycler(int tier){ this.tier=tier; - coeff=(float)(1/Math.pow(2,tier-4)); + coeff=(1D/Math.pow(2D,tier-4)); } @Override @@ -27,7 +27,7 @@ public class Behaviour_Recycler implements GT_MetaTileEntity_EM_machine.IBehavio @Override public MultiblockControl<cElementalInstanceStackMap[]> process(cElementalInstanceStackMap[] inputs, GT_MetaTileEntity_EM_machine te, Parameters parameters) { - float mass=0; + double mass=0; for (cElementalInstanceStackMap input : inputs) { if (input != null) { mass += input.getMass(); diff --git a/src/main/java/com/github/technus/tectech/util/DoubleCount.java b/src/main/java/com/github/technus/tectech/util/DoubleCount.java new file mode 100644 index 0000000000..0c5865d56e --- /dev/null +++ b/src/main/java/com/github/technus/tectech/util/DoubleCount.java @@ -0,0 +1,116 @@ +package com.github.technus.tectech.util; + +import java.util.Arrays; + +import static java.lang.Math.max; +import static java.lang.Math.ulp; + +public class DoubleCount { + public static double[] distribute(double count,double... probabilities) throws ArithmeticException{ + if(probabilities==null){ + return null; + }else if(count==0){ + return new double[probabilities.length]; + }else { + switch (probabilities.length){ + default: { + int size=probabilities.length; + double[] output=new double[size]; + size--; + double remaining=count,previous=probabilities[size],probability,out,sum=0; + for (int i = size - 1; i >= 0; i--) { + probability=probabilities[i]; + remaining-=out=count*(probability-ulp(probability)); + sum+=output[i]=out; + if(previous<probability){ + throw new ArithmeticException("Malformed probability order: "+ Arrays.toString(probabilities)); + } + previous=probability; + if(probability>=1){ + break; + } + } + if(remaining*count<0){ + throw new ArithmeticException("Malformed probability sum: "+ Arrays.toString(probabilities)); + } + sum+=output[size]=remaining-ulp(remaining)*size; + if(sum>count){ + throw new ArithmeticException("Too much outputted: "+ Arrays.toString(output)+" "+sum+" / "+count); + } + return output; + } + case 1: return new double[]{count}; + case 0: return probabilities;//empty array at hand... + } + } + } + + public static double div(double count,double divisor){ + if (divisor == 0) { + throw new ArithmeticException("Divide by 0"); + }else if(count==0 || divisor==1){ + return count; + }else if(divisor==-1){ + return -count; + } else { + double result = count / divisor; + if(result*count<0){ + return 0; + } + return result-ulp(result); + } + } + + public static double mul(double count,double multiplier){ + if(count==0 || multiplier==1){ + return count; + }else if(multiplier==-1){ + return -count; + } else { + double result = count * multiplier; + if(result*count<0){ + return 0; + } + return result-ulp(result); + } + } + + public static double sub(double count,double value){ + if(value==0){ + return count; + } + if(count==0){ + return -value; + } + if(value==count){ + return 0; + } + return value < 0 ? addInternal(count, -value) : subInternal(count, value); + } + + public static double add(double count,double value){ + if(value==0){ + return count; + } + if(count==0){ + return value; + } + return value < 0 ? subInternal(count, -value) : addInternal(count, value); + } + + private static double subInternal(double count,double value){ + double result = count - max(value,ulp(count)); + if (result+value>count || value>count-result){ + result-=ulp(result); + } + return result; + } + + private static double addInternal(double count,double value){ + double result = count + value; + if (result-value>count || result-count>value){ + result-=ulp(result); + } + return result; + } +} |