diff options
author | Tec <daniel112092@gmail.com> | 2020-07-18 13:01:44 +0200 |
---|---|---|
committer | Tec <daniel112092@gmail.com> | 2020-07-18 13:01:44 +0200 |
commit | d44e0b0c61384ca1a63f0dc322715d8a4e57678a (patch) | |
tree | 4566856c99d9368056c82255b928062d52a9e937 | |
parent | 7e55f6a68a7b7b307034c994f2fac95a83f3753b (diff) | |
download | GT5-Unofficial-d44e0b0c61384ca1a63f0dc322715d8a4e57678a.tar.gz GT5-Unofficial-d44e0b0c61384ca1a63f0dc322715d8a4e57678a.tar.bz2 GT5-Unofficial-d44e0b0c61384ca1a63f0dc322715d8a4e57678a.zip |
Rework API
24 files changed, 611 insertions, 420 deletions
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..3472f15cec 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 @@ -3,6 +3,7 @@ package com.github.technus.tectech.mechanics.elementalMatter.core; 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.templates.iElementalDefinition; +import com.github.technus.tectech.util.DoubleCount; /** * Created by danie_000 on 22.10.2016. @@ -15,50 +16,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(2D, 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(2D, 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(2D, 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= DoubleCount.add(qtty,stack.amount); } - if (qtty <= 0) { + if (qtty <= 0D) { return decayResult; } //energyTotalForProducts /= qtty; @@ -66,7 +67,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/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..9544d8d7e5 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 @@ -4,6 +4,7 @@ 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.stacks.iHasElementalDefinition; import com.github.technus.tectech.mechanics.elementalMatter.core.templates.iElementalDefinition; +import com.github.technus.tectech.util.DoubleCount; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.EnumChatFormatting; @@ -131,7 +132,7 @@ public final class cElementalInstanceStackMap implements Comparable<cElementalIn if (testOnly) { return target.amount >= instance.amount; } else { - long diff = target.amount - instance.amount; + double diff = DoubleCount.sub(target.amount,instance.amount); if (diff > 0) { target.amount = diff; return true; @@ -151,7 +152,7 @@ public final class cElementalInstanceStackMap implements Comparable<cElementalIn if (testOnly) { return target.amount >= stack.getAmount(); } else { - long diff = target.amount - stack.getAmount(); + double diff = DoubleCount.sub(target.amount,stack.getAmount()); if (diff > 0) { target.amount = diff; return true; @@ -165,7 +166,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 +235,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(); @@ -364,24 +365,25 @@ 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; + @Deprecated + public double getCountOfAllAmounts(){ + double sum=0; for(cElementalInstanceStack stack:map.values()){ sum+=stack.amount; } @@ -410,11 +412,11 @@ public final class cElementalInstanceStackMap implements Comparable<cElementalIn } //Tick Content - public void tickContentByOneSecond(float lifeTimeMult, int postEnergize) { - tickContent(lifeTimeMult,postEnergize,1); + public void tickContentByOneSecond(double lifeTimeMult, int postEnergize) { + tickContent(lifeTimeMult,postEnergize,1D); } - public void tickContent(float lifeTimeMult, int postEnergize, int seconds){ + public void tickContent(double lifeTimeMult, int postEnergize, double seconds){ for (cElementalInstanceStack instance : values()) { cElementalInstanceStackMap newInstances = instance.decay(lifeTimeMult, instance.age += seconds, postEnergize); if (newInstances == null) { 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..5b925aeea6 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 @@ -4,6 +4,7 @@ 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.stacks.iHasElementalDefinition; import com.github.technus.tectech.mechanics.elementalMatter.core.templates.iElementalDefinition; +import com.github.technus.tectech.util.DoubleCount; import net.minecraft.nbt.NBTTagCompound; import java.util.Map; @@ -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 = DoubleCount.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 = DoubleCount.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..3e5a7f7b33 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 @@ -65,6 +65,7 @@ abstract class cElementalStackMap implements Comparable<cElementalStackMap> { return var.toArray(new iElementalDefinition[0]); } + @Deprecated public long getCountOfAllAmounts(){ long sum=0; for(cElementalDefinitionStack stack:map.values()){ 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..2371b1b986 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 @@ -2,6 +2,7 @@ package com.github.technus.tectech.mechanics.elementalMatter.core.stacks; 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.DoubleCount; import net.minecraft.nbt.NBTTagCompound; import static com.github.technus.tectech.mechanics.elementalMatter.definitions.primitive.cPrimitiveDefinition.null__; @@ -11,9 +12,9 @@ import static com.github.technus.tectech.mechanics.elementalMatter.definitions.p */ 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, DoubleCount.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=DoubleCount.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..fb4f0fed33 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,12 +1,13 @@ 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.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.DoubleCount; +import com.github.technus.tectech.util.Util; import net.minecraft.nbt.NBTTagCompound; import java.util.ArrayList; @@ -14,36 +15,37 @@ import java.util.ArrayList; 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 java.lang.Math.ulp; /** * 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=16,MAX_MULTIPLE_DECAY_CALLS=64,DECAY_CALL_PER=144;//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 +77,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 +100,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 +135,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,15 +152,15 @@ 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 cElementalInstanceStackMap tickStackByOneSecond(double lifeTimeMult, int postEnergize){ + return tickStack(lifeTimeMult,postEnergize,1D); } - public cElementalInstanceStackMap tickStack(float lifeTimeMult, int postEnergize, int seconds){ + public cElementalInstanceStackMap tickStack(double lifeTimeMult, int postEnergize, double seconds){ cElementalInstanceStackMap newInstances = decay(lifeTimeMult, age += seconds, postEnergize); if (newInstances == null) { nextColor(); @@ -171,14 +173,14 @@ public final class cElementalInstanceStack implements iHasElementalDefinition { } public cElementalInstanceStackMap decay() { - return decay(1F, age, 0);//try to decay without changes + return decay(1D, age, 0);//try to decay without changes } - public cElementalInstanceStackMap decay(long apparentAge, long postEnergize) { - return decay(1F,apparentAge,postEnergize); + public cElementalInstanceStackMap decay(double apparentAge, long postEnergize) { + return decay(1D,apparentAge,postEnergize); } - public cElementalInstanceStackMap decay(float lifeTimeMult, long apparentAge, long postEnergize) { + public cElementalInstanceStackMap decay(double lifeTimeMult, double apparentAge, long postEnergize) { long newEnergyLevel = postEnergize + energy; if (newEnergyLevel > 0) { newEnergyLevel -= 1; @@ -186,10 +188,10 @@ public final class cElementalInstanceStack implements iHasElementalDefinition { newEnergyLevel += 1; } 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); + double amountTemp=amount; + long decayCnt=(long) Math.min(Math.max(amount/DECAY_CALL_PER,MIN_MULTIPLE_DECAY_CALLS),MAX_MULTIPLE_DECAY_CALLS); + double amountPer= DoubleCount.div(amount,decayCnt); + amount=DoubleCount.sub(amount,amountPer*(--decayCnt)); cElementalInstanceStackMap output=decayMechanics(lifeTimeMult,apparentAge,newEnergyLevel); if(output==null){ amount=amountTemp; @@ -211,29 +213,28 @@ public final class cElementalInstanceStack implements iHasElementalDefinition { } } - private cElementalInstanceStackMap decayMechanics(float lifeTimeMult, long apparentAge, long newEnergyLevel) { + private cElementalInstanceStackMap 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 cElementalInstanceStackMap exponentialDecayCompute(cElementalDecay[] decays, double lifeTimeMult, double newProductsAge, long newEnergyLevel) { + double decayInverseRatio=Math.pow(2D,1D/* 1 second *//lifeTime); + double newAmount=DoubleCount.div(amount,decayInverseRatio+ulp(decayInverseRatio)); //if(definition.getSymbol().startsWith("U ")) { // System.out.println("newAmount = " + newAmount); // System.out.println("amountRemaining = " + amountRemaining); @@ -244,23 +245,24 @@ public final class cElementalInstanceStack implements iHasElementalDefinition { // } // } //} - if(amountRemaining==amount) { - return null;//nothing decayed - } else if(amountRemaining<=0) { - return decayCompute(decays, lifeTimeMult, newProductsAge, newEnergyLevel); - } + //if(newAmount==amount) {//no longer needed + // return null;//nothing decayed + //} else if(newAmount<=0) {//no longer needed + // return decayCompute(decays, lifeTimeMult, newProductsAge, newEnergyLevel); + //}//no longer needed + //split to non decaying and decaying part - long amount=this.amount; - this.amount-=amountRemaining; + double amount=this.amount; + this.amount=DoubleCount.sub(this.amount,newAmount); cElementalInstanceStackMap products=decayCompute(decays,lifeTimeMult,newProductsAge,newEnergyLevel); - this.amount=amountRemaining; + this.amount=newAmount; products.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 cElementalInstanceStackMap decayCompute(cElementalDecay[] decays, double lifeTimeMult, double newProductsAge, long newEnergyLevel) { if (decays == null) { return null;//Can not decay so it wont } @@ -299,51 +301,55 @@ public final class cElementalInstanceStack implements iHasElementalDefinition { } else { cElementalInstanceStackMap output = new cElementalInstanceStackMap(); 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; - } - } - - 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[] probabilities=new double[differentDecays]; + for (int i = 0; i < probabilities.length; i++) { + probabilities[i]=decays[i].probability; } + double[] qttyOfDecay = DoubleCount.distribute(this.amount, probabilities); + //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(this.energy)){ for (int i = 0; i < differentDecays; i++) { @@ -394,14 +400,14 @@ 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=DoubleCount.add(amount,instance.amount); + energyTotal += instance.energy * instance.amount; if(instance.energy>maxEnergy){ maxEnergy=instance.energy; } @@ -411,12 +417,16 @@ public final class cElementalInstanceStack implements iHasElementalDefinition { } 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=Math.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(Math.min(maxEnergy,energy)); return this; } @@ -483,11 +493,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 +505,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; 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..0061550ace 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,7 +122,8 @@ 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; } 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..65446548e6 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 @@ -37,7 +37,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 +49,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 +57,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,7 +72,7 @@ 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; @@ -111,7 +111,7 @@ public abstract class cElementalPrimitive extends cElementalDefinition { } @Override - public float getMass() { + public double getMass() { return mass; } @@ -136,7 +136,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 +166,7 @@ public abstract class cElementalPrimitive extends cElementalDefinition { } @Override - public float getRawTimeSpan(long currentEnergy) { + public double getRawTimeSpan(long currentEnergy) { return rawLifeTime; } @@ -234,7 +234,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/definitions/complex/dAtomDefinition.java b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/complex/dAtomDefinition.java index 205851c61b..e2a3e9e542 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 @@ -42,16 +42,16 @@ public final class dAtomDefinition extends cElementalDefinition { private final int hash; public static final bTransformationInfo transformation=new bTransformationInfo(16,0,64); - public static float refMass, refUnstableMass; + 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 +61,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 +115,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 +124,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 +163,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, iElementalDefinition.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, iElementalDefinition.STABLE_RAW_LIFE_TIME); iaeaDefinitionExistsAndHasEnergyLevels =false; } @@ -209,50 +212,50 @@ public final class dAtomDefinition extends cElementalDefinition { } 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 @@ -1327,10 +1332,10 @@ public final class dAtomDefinition extends cElementalDefinition { return transformation.oredictDequantization.get(this); } - private static final class nomenclature { - private static final String[] Symbol = new String[]{"Nt", "H", "He", "Li", "Be", "B", "C", "N", "O", "F", "Ne", "Na", "Mg", "Al", "Si", "P", "S", "Cl", "Ar", "K", "Ca", "Sc", "Ti", "V", "Cr", "Mn", "Fe", "Co", "Ni", "Cu", "Zn", "Ga", "Ge", "As", "Se", "Br", "Kr", "Rb", "Sr", "Y", "Zr", "Nb", "Mo", "Tc", "Ru", "Rh", "Pd", "Ag", "Cd", "In", "Sn", "Sb", "Te", "I", "Xe", "Cs", "Ba", "La", "Ce", "Pr", "Nd", "Pm", "Sm", "Eu", "Gd", "Tb", "Dy", "Ho", "Er", "Tm", "Yb", "Lu", "Hf", "Ta", "W", "Re", "Os", "Ir", "Pt", "Au", "Hg", "Tl", "Pb", "Bi", "Po", "At", "Rn", "Fr", "Ra", "Ac", "Th", "Pa", "U", "Np", "Pu", "Am", "Cm", "Bk", "Cf", "Es", "Fm", "Md", "No", "Lr", "Rf", "Db", "Sg", "Bh", "Hs", "Mt", "Ds", "Rg", "Cn", "Nh", "Fl", "Mc", "Lv", "Ts", "Og"}; - private static final String[] Name = new String[]{"Neutronium", "Hydrogen", "Helium", "Lithium", "Beryllium", "Boron", "Carbon", "Nitrogen", "Oxygen", "Fluorine", "Neon", "Sodium", "Magnesium", "Aluminium", "Silicon", "Phosphorus", "Sulfur", "Chlorine", "Argon", "Potassium", "Calcium", "Scandium", "Titanium", "Vanadium", "Chromium", "Manganese", "Iron", "Cobalt", "Nickel", "Copper", "Zinc", "Gallium", "Germanium", "Arsenic", "Selenium", "Bromine", "Krypton", "Rubidium", "Strontium", "Yttrium", "Zirconium", "Niobium", "Molybdenum", "Technetium", "Ruthenium", "Rhodium", "Palladium", "Silver", "Cadmium", "Indium", "Tin", "Antimony", "Tellurium", "Iodine", "Xenon", "Caesium", "Barium", "Lanthanum", "Cerium", "Praseodymium", "Neodymium", "Promethium", "Samarium", "Europium", "Gadolinium", "Terbium", "Dysprosium", "Holmium", "Erbium", "Thulium", "Ytterbium", "Lutetium", "Hafnium", "Tantalum", "Tungsten", "Rhenium", "Osmium", "Iridium", "Platinum", "Gold", "Mercury", "Thallium", "Lead", "Bismuth", "Polonium", "Astatine", "Radon", "Francium", "Radium", "Actinium", "Thorium", "Protactinium", "Uranium", "Neptunium", "Plutonium", "Americium", "Curium", "Berkelium", "Californium", "Einsteinium", "Fermium", "Mendelevium", "Nobelium", "Lawrencium", "Rutherfordium", "Dubnium", "Seaborgium", "Bohrium", "Hassium", "Meitnerium", "Darmstadtium", "Roentgenium", "Copernicium", "Nihonium", "Flerovium", "Moscovium", "Livermorium", "Tennessine", "Oganesson"}; - private static final String[] SymbolIUPAC = new String[]{"n", "u", "b", "t", "q", "p", "h", "s", "o", "e", "N", "U", "B", "T", "Q", "P", "H", "S", "O", "E"}; + 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,7 +1473,7 @@ public final class dAtomDefinition extends cElementalDefinition { public static void setTransformation(){ /*----STABLE ATOMS----**/ - refMass = getFirstStableIsotope(1).getMass() * 144F; + refMass = getFirstStableIsotope(1).getMass() * 144D; transformation.addFluid(new cElementalDefinitionStack(getFirstStableIsotope(1), 144),Materials.Hydrogen.mGas.getID(),144); transformation.addFluid(new cElementalDefinitionStack(getFirstStableIsotope(2), 144),Materials.Helium.mGas.getID(), 144); @@ -1554,7 +1559,7 @@ public final class dAtomDefinition extends cElementalDefinition { transformation.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(82), 144), dust, Materials.Lead,1); /*----UNSTABLE ATOMS----**/ - refUnstableMass = getFirstStableIsotope(82).getMass() * 144F; + refUnstableMass = getFirstStableIsotope(82).getMass() * 144D; transformation.addOredict(new cElementalDefinitionStack(getBestUnstableIsotope(83), 144), dust, Materials.Bismuth,1); //transformation.addOredict(new cElementalDefinitionStack(getBestUnstableIsotope(84),144),OrePrefixes.dust, Materials.Polonium,1); @@ -1585,7 +1590,7 @@ public final class dAtomDefinition extends cElementalDefinition { ); transformation.addOredict(new cElementalDefinitionStack(temp, 144), dust, Materials.Uranium/*238*/,1); - float tempMass=temp.getMass(); + double tempMass=temp.getMass(); temp=new dAtomDefinition( new cElementalDefinitionStack(eLeptonDefinition.lepton_e, 92), @@ -1664,7 +1669,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..ce5e4a50aa 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 @@ -41,17 +41,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 +87,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 +107,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 +136,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; @@ -229,7 +235,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 +246,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); } @@ -274,7 +280,7 @@ 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; } 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]; @@ -302,8 +308,8 @@ public final class dHadronDefinition extends cElementalDefinition {//TODO Optimi 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.99D, new dHadronDefinition(false, contentOfBaryon), Particles[0], Particles[1]), + new cElementalDecay(0.001D, new dHadronDefinition(false, contentOfBaryon), Particles[0], Particles[1], boson_Y__), eBosonDefinition.deadEnd}; } catch (tElementalException e) { if (DEBUG_MODE) { @@ -315,7 +321,7 @@ public final class dHadronDefinition extends cElementalDefinition {//TODO Optimi } @Override - public float getMass() { + public double getMass() { return mass; } @@ -325,7 +331,7 @@ public final class dHadronDefinition extends cElementalDefinition {//TODO Optimi } @Override - public float getRawTimeSpan(long currentEnergy) { + public double getRawTimeSpan(long currentEnergy) { return rawLifeTime; } @@ -436,13 +442,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); @@ -497,7 +503,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..410e53810e 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,7 +50,7 @@ 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); } @@ -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]; @@ -156,11 +161,11 @@ public final class iaeaNuclide { } public static final class energeticState{ - public final float energy; - public final float Thalf; + public final double energy; + public final 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 +180,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 +195,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 +242,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 +288,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..f1f740f665 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 @@ -9,23 +9,23 @@ import com.github.technus.tectech.mechanics.elementalMatter.core.templates.cElem */ 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_H__.init(null, 1.56e-22D, 0, 0, + new cElementalDecay(0.96D, new cElementalDefinitionStack(boson_Y__, 4)), + new cElementalDecay(0.02D, eLeptonDefinition.lepton_t, eLeptonDefinition.lepton_t_), + new cElementalDecay(0.01D, eQuarkDefinition.quark_b, eQuarkDefinition.quark_b_), 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..dd57d6875e 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 @@ -9,19 +9,19 @@ import com.github.technus.tectech.mechanics.elementalMatter.core.templates.cElem */ 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; @@ -31,12 +31,12 @@ public final class eLeptonDefinition extends cElementalPrimitive { 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), + lepton_m.init(lepton_m_, 2.197019e-6D, 0, 1, + new cElementalDecay(0.9D, 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), + lepton_t.init(lepton_t_, 2.906e-13D, 1, 3, + new cElementalDecay(0.8D, lepton_m, eNeutrinoDefinition.lepton_Vm_, eNeutrinoDefinition.lepton_Vt, eBosonDefinition.boson_Y__), + new cElementalDecay(0.1D, 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 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..ba084af9a2 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 @@ -9,38 +9,38 @@ import com.github.technus.tectech.mechanics.elementalMatter.core.templates.cElem */ 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), + lepton_Vm.init(lepton_Vm_, 1D, 1, 0, + new cElementalDecay(0.825D, nothing), eBosonDefinition.deadEndHalf); - lepton_Vt.init(lepton_Vt_, 1F, 1, 0, + lepton_Vt.init(lepton_Vt_, 1, 1, 0, new cElementalDecay(0.75F, nothing), eBosonDefinition.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, + lepton_Vt_.init(lepton_Vt, 1, 1, 0, new cElementalDecay(0.75F, nothing), eBosonDefinition.deadEnd); } 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..027b604dc5 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 @@ -8,62 +8,62 @@ import com.github.technus.tectech.mechanics.elementalMatter.core.templates.cElem */ 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(0.9D, quark_d, eLeptonDefinition.lepton_e_, eNeutrinoDefinition.lepton_Ve), + new cElementalDecay(0.050778116D, quark_s/*,lepton_m_,lepton_Vm*/), + new cElementalDecay(1.23201e-5D, quark_b/*,lepton_t_,lepton_Vt*/), 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.9D, quark_s, eLeptonDefinition.lepton_e_, eNeutrinoDefinition.lepton_Ve), + new cElementalDecay(0.05071504D, quark_d, eLeptonDefinition.lepton_m_, eNeutrinoDefinition.lepton_Vm), + new cElementalDecay(0.00169744D, quark_b/*,lepton_t_,lepton_Vt*/), 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, 2, -1, + new cElementalDecay(0.9D, quark_b, eLeptonDefinition.lepton_e_, eNeutrinoDefinition.lepton_Ve), + new cElementalDecay(0.00163216D, quark_s, eLeptonDefinition.lepton_m_, eNeutrinoDefinition.lepton_Vm), + new cElementalDecay(7.51689e-5D, quark_d, eLeptonDefinition.lepton_t_, eNeutrinoDefinition.lepton_Vt), 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.9D, quark_u, eLeptonDefinition.lepton_e, eNeutrinoDefinition.lepton_Ve_), + new cElementalDecay(0.05071504D, quark_c/*,lepton_m,lepton_Vm_*/), + new cElementalDecay(7.51689e-5D, quark_t/*,lepton_t,lepton_Vt_*/), 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.9D, quark_c, eLeptonDefinition.lepton_e, eNeutrinoDefinition.lepton_Ve_), + new cElementalDecay(0.050778116D, quark_u, eLeptonDefinition.lepton_m, eNeutrinoDefinition.lepton_Vm_), + new cElementalDecay(0.00163216D, quark_t/*,lepton_t,lepton_Vt_*/), 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, 2, -1, + new cElementalDecay(0.9D, quark_t, eLeptonDefinition.lepton_e, eNeutrinoDefinition.lepton_Ve_), + new cElementalDecay(0.00169744D, quark_c, eLeptonDefinition.lepton_m, eNeutrinoDefinition.lepton_Vm_), + new cElementalDecay(1.23201e-5D, quark_u, eLeptonDefinition.lepton_t, eNeutrinoDefinition.lepton_Vt_), 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(0.9D, quark_d_, eLeptonDefinition.lepton_e, eNeutrinoDefinition.lepton_Ve_), + new cElementalDecay(0.050778116D, quark_s_/*,lepton_m,lepton_Vm_*/), + new cElementalDecay(1.23201e-5D, quark_b_/*,lepton_t,lepton_Vt_*/), eBosonDefinition.deadEnd);//makes photons and don't care - quark_c_.init(quark_c, 0.5e-13F, 1, -1, + quark_c_.init(quark_c, 0.5e-13D, 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_*/), 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..e364e634bc 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 @@ -36,6 +36,7 @@ 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.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; @@ -280,7 +281,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 +299,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 +324,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") + ":", @@ -405,6 +406,39 @@ public class GT_MetaTileEntity_EM_collider extends GT_MetaTileEntity_MultiblockB return 0; } + protected double collide(GT_MetaTileEntity_EM_collider partner) { + 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(); + //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; + } + for (cElementalInstanceStack newStack : map.values()) { + check &= newStack.definition.fusionMakesEnergy(newStack.getEnergy()); + } + //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 check ? preMass - map.getMass() : + Math.min(preMass - map.getMass(), 0); + } + return 0; + } + private boolean handleRecipe(cElementalInstanceStack stack2, cElementalInstanceStackMap map, IColliderHandler colliderHandler) { if (colliderHandler != null && eTier >= colliderHandler.getRequiredTier()) { colliderHandler.collide(stack2, stack, map); @@ -438,7 +472,9 @@ 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() { @@ -476,7 +512,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; @@ -541,7 +577,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 +711,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/util/DoubleCount.java b/src/main/java/com/github/technus/tectech/util/DoubleCount.java new file mode 100644 index 0000000000..e7ef18be08 --- /dev/null +++ b/src/main/java/com/github/technus/tectech/util/DoubleCount.java @@ -0,0 +1,113 @@ +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){ + 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; + sum+=output[i]=out-ulp(out); + if(previous<probability){ + throw new ArithmeticException("Malformed probability order: "+ Arrays.toString(probabilities)); + } + previous=probability; + } + 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; + } +} |