diff options
author | Technus <daniel112092@gmail.com> | 2017-12-10 18:14:29 +0100 |
---|---|---|
committer | Technus <daniel112092@gmail.com> | 2017-12-10 18:14:29 +0100 |
commit | 5c47e8b47c73bc579846e17ce0f908632d37f9b2 (patch) | |
tree | 4c6a6e75b59835c95fb44cad28082e15c54f8879 /src | |
parent | b428671426df430efa38fad0f46f6f1547ca7ee8 (diff) | |
download | GT5-Unofficial-5c47e8b47c73bc579846e17ce0f908632d37f9b2.tar.gz GT5-Unofficial-5c47e8b47c73bc579846e17ce0f908632d37f9b2.tar.bz2 GT5-Unofficial-5c47e8b47c73bc579846e17ce0f908632d37f9b2.zip |
More decay work/ more IAEA work
Diffstat (limited to 'src')
17 files changed, 211 insertions, 112 deletions
diff --git a/src/main/java/com/github/technus/tectech/compatibility/thaumcraft/definitions/dComplexAspectDefinition.java b/src/main/java/com/github/technus/tectech/compatibility/thaumcraft/definitions/dComplexAspectDefinition.java index 0643153fbf..034aa55642 100644 --- a/src/main/java/com/github/technus/tectech/compatibility/thaumcraft/definitions/dComplexAspectDefinition.java +++ b/src/main/java/com/github/technus/tectech/compatibility/thaumcraft/definitions/dComplexAspectDefinition.java @@ -126,7 +126,7 @@ public final class dComplexAspectDefinition extends cElementalDefinition impleme } @Override - public float getRawTimeSpan() { + public float getRawTimeSpan(long currentEnergy) { return -1; } @@ -156,11 +156,16 @@ public final class dComplexAspectDefinition extends cElementalDefinition impleme } @Override - public cElementalDecay[] getEnergyInducedDecay(long energy) { + public cElementalDecay[] getEnergyInducedDecay(long energyLevel) { return new cElementalDecay[]{new cElementalDecay(0.75F, aspectStacks), eBosonDefinition.deadEnd}; } @Override + public float getEnergyDiffBetweenStates(long currentEnergyLevel, long newEnergyLevel) { + return DEFAULT_ENERGY_REQUIREMENT*(newEnergyLevel-currentEnergyLevel); + } + + @Override public boolean usesSpecialEnergeticDecayHandling() { return false; } diff --git a/src/main/java/com/github/technus/tectech/elementalMatter/core/containers/cElementalInstanceStack.java b/src/main/java/com/github/technus/tectech/elementalMatter/core/containers/cElementalInstanceStack.java index afc0bb2678..920e2fae61 100644 --- a/src/main/java/com/github/technus/tectech/elementalMatter/core/containers/cElementalInstanceStack.java +++ b/src/main/java/com/github/technus/tectech/elementalMatter/core/containers/cElementalInstanceStack.java @@ -16,7 +16,7 @@ import static com.github.technus.tectech.elementalMatter.definitions.primitive.c public final class cElementalInstanceStack implements iHasElementalDefinition { public final iElementalDefinition definition; //energy - if positive then particle should try to decay - public long energy; + 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; @@ -45,9 +45,9 @@ public final class cElementalInstanceStack implements iHasElementalDefinition { this.color = (byte) (TecTech.Rnd.nextInt(3)); } this.lifeTimeMult = lifeTimeMult; - this.lifeTime = definition.getRawTimeSpan() * this.lifeTimeMult; - this.age = age; this.energy = energy; + this.lifeTime = definition.getRawTimeSpan(energy) * this.lifeTimeMult; + this.age = age; this.amount = amount; } @@ -80,6 +80,25 @@ public final class cElementalInstanceStack implements iHasElementalDefinition { return definition.getMass() * amount; } + public long getEnergy() { + return energy; + } + + public void setEnergy(long newEnergyLevel){ + energy=newEnergyLevel; + setLifeTimeMultipleOfBaseValue(getLifeTimeMult()); + } + + @Deprecated //can be done from definition + public float getEnergySettingCost(long currentEnergyLevel, long newEnergyLevel){ + return definition.getEnergyDiffBetweenStates(currentEnergyLevel,newEnergyLevel); + } + + @Deprecated //can be done from definition + public float getEnergySettingCost(long newEnergyLevel){ + return definition.getEnergyDiffBetweenStates(energy,newEnergyLevel); + } + public cElementalDefinitionStack getDefinitionStack() { return new cElementalDefinitionStack(definition, amount); } @@ -107,12 +126,12 @@ public final class cElementalInstanceStack implements iHasElementalDefinition { return lifeTime; } - public float setLifeTimeMult(float mult) { + public float setLifeTimeMultipleOfBaseValue(float mult) { if(mult<=0) //since infinity*0=nan throw new IllegalArgumentException("mult must be >0"); this.lifeTimeMult = mult; - if (definition.getRawTimeSpan() <= 0) return this.lifeTime; - this.lifeTime = definition.getRawTimeSpan() * this.lifeTimeMult; + if (definition.getRawTimeSpan(energy) <= 0) return this.lifeTime; + this.lifeTime = definition.getRawTimeSpan(energy) * this.lifeTimeMult; return this.lifeTime; } @@ -131,8 +150,9 @@ public final class cElementalInstanceStack implements iHasElementalDefinition { public cElementalInstanceStackMap decay(Float lifeTimeMult, long apparentAge, long postEnergize) { if (this.energy > 0 && !definition.usesSpecialEnergeticDecayHandling()) { this.energy--; + setLifeTimeMultipleOfBaseValue(getLifeTimeMult()); return decayCompute(definition.getEnergyInducedDecay(this.energy), lifeTimeMult, -1, postEnergize + this.energy); - }else if (definition.getRawTimeSpan() < 0) { + }else if (definition.getRawTimeSpan(energy) < 0) { return null;//return null, decay cannot be achieved } else if(definition.isTimeSpanHalfLife()){ return exponentialDecayCompute(energy>0?definition.getEnergyInducedDecay(this.energy):definition.getDecayArray(), lifeTimeMult, -1, postEnergize + this.energy); @@ -147,17 +167,19 @@ public final class cElementalInstanceStack implements iHasElementalDefinition { } //Use to get direct decay output providing correct decay array - public cElementalInstanceStackMap exponentialDecayCompute(cElementalDecay[] decays, float lifeTimeMult, long newProductsAge, long energy) { + private cElementalInstanceStackMap exponentialDecayCompute(cElementalDecay[] decays, float lifeTimeMult, long newProductsAge, long energy) { double decayInverseRatio=Math.pow(2d,1d/* 1 second *//(double)lifeTime); double newAmount=(double)amount/decayInverseRatio; long amountRemaining=((long)Math.floor(newAmount))+(TecTech.Rnd.nextDouble()<=newAmount-Math.floor(newAmount)?1:0); if(amountRemaining==amount) return null;//nothing decayed else if(amountRemaining<=0) return decayCompute(decays,lifeTimeMult,newProductsAge,energy); //split to non decaying and decaying part - amount-=amountRemaining; + long amount=this.amount; + this.amount-=amountRemaining; cElementalInstanceStackMap products=decayCompute(decays,lifeTimeMult,newProductsAge,energy); - amount=amountRemaining; - products.putUnify(this); + this.amount=amountRemaining; + products.putUnify(this.clone()); + this.amount=amount; return products; } @@ -258,7 +280,7 @@ public final class cElementalInstanceStack implements iHasElementalDefinition { if (amount != 0) energy /= Math.abs(amount); this.energy = energy; - this.setLifeTimeMult(lifeTimeMul); + this.setLifeTimeMultipleOfBaseValue(lifeTimeMul); return this; } diff --git a/src/main/java/com/github/technus/tectech/elementalMatter/core/interfaces/iElementalDefinition.java b/src/main/java/com/github/technus/tectech/elementalMatter/core/interfaces/iElementalDefinition.java index 98523ffce1..33432bad5d 100644 --- a/src/main/java/com/github/technus/tectech/elementalMatter/core/interfaces/iElementalDefinition.java +++ b/src/main/java/com/github/technus/tectech/elementalMatter/core/interfaces/iElementalDefinition.java @@ -14,6 +14,8 @@ import net.minecraft.nbt.NBTTagCompound; public interface iElementalDefinition extends Comparable<iElementalDefinition>,Cloneable {//IMMUTABLE float STABLE_RAW_LIFE_TIME =1.5e36f; float NO_DECAY_RAW_LIFE_TIME=-1; + long DEFAULT_ENERGY_LEVEL=0; + float DEFAULT_ENERGY_REQUIREMENT=25000f; //Nomenclature String getName(); @@ -31,10 +33,12 @@ public interface iElementalDefinition extends Comparable<iElementalDefinition>,C cElementalDecay[] getNaturalDecayInstant();//natural decay if lifespan <1tick - cElementalDecay[] getEnergyInducedDecay(long energy);//energetic decay + cElementalDecay[] getEnergyInducedDecay(long energyLevel);//energetic decay boolean usesSpecialEnergeticDecayHandling(); + float getEnergyDiffBetweenStates(long currentEnergy, long newEnergyLevel);//positive or negative + float getMass();//mass... MeV/c^2 int getCharge();//charge 1/3 electron charge @@ -42,7 +46,7 @@ public interface iElementalDefinition extends Comparable<iElementalDefinition>,C //dynamically changing stuff byte getColor();//-1 nope cannot 0 it can but undefined - float getRawTimeSpan();//defined in static fields or generated + float getRawTimeSpan(long currentEnergy);//defined in static fields or generated boolean isTimeSpanHalfLife(); diff --git a/src/main/java/com/github/technus/tectech/elementalMatter/core/templates/cElementalPrimitive.java b/src/main/java/com/github/technus/tectech/elementalMatter/core/templates/cElementalPrimitive.java index d98cd93e04..2a2a3459c2 100644 --- a/src/main/java/com/github/technus/tectech/elementalMatter/core/templates/cElementalPrimitive.java +++ b/src/main/java/com/github/technus/tectech/elementalMatter/core/templates/cElementalPrimitive.java @@ -108,12 +108,17 @@ public abstract class cElementalPrimitive extends cElementalDefinition { } @Override - public cElementalDecay[] getEnergyInducedDecay(long energy) { + public cElementalDecay[] getEnergyInducedDecay(long energyLevel) { if (energeticDecayInstant < 0) return elementalDecays; return new cElementalDecay[]{elementalDecays[energeticDecayInstant]}; } @Override + public float getEnergyDiffBetweenStates(long currentEnergyLevel, long newEnergyLevel) { + return DEFAULT_ENERGY_REQUIREMENT*(newEnergyLevel-currentEnergyLevel); + } + + @Override public boolean usesSpecialEnergeticDecayHandling() { return false; } @@ -124,7 +129,7 @@ public abstract class cElementalPrimitive extends cElementalDefinition { } @Override - public float getRawTimeSpan() { + public float getRawTimeSpan(long currentEnergy) { return rawLifeTime; } diff --git a/src/main/java/com/github/technus/tectech/elementalMatter/definitions/complex/dAtomDefinition.java b/src/main/java/com/github/technus/tectech/elementalMatter/definitions/complex/dAtomDefinition.java index 76e8f51033..12380e0ffd 100644 --- a/src/main/java/com/github/technus/tectech/elementalMatter/definitions/complex/dAtomDefinition.java +++ b/src/main/java/com/github/technus/tectech/elementalMatter/definitions/complex/dAtomDefinition.java @@ -62,17 +62,17 @@ public final class dAtomDefinition extends cElementalDefinition { public final int charge; //int -electric charge in 1/3rds of electron charge for optimization public final int chargeLeptons; - public final float rawLifeTime; + private float rawLifeTime; //generation max present inside - minus if contains any anti quark public final byte type; public final byte decayMode;//t neutron to proton+,0,f proton to neutron - public final boolean stable; + //public final boolean stable; public final int neutralCount; public final int element; - public final boolean specialEnergeticDecayHandling; + private final boolean iaeaDefinitionExistsAndHasEnergyLevels; private final cElementalDefinitionStackMap elementalStacks; @@ -127,7 +127,7 @@ public final class dAtomDefinition extends cElementalDefinition { } } this.type = containsAnti ? (byte) -type : (byte) type; - this.mass = mass; + //this.mass = mass; this.chargeLeptons = cLeptons; this.charge = cNucleus + cLeptons; this.neutralCount = neutralCount; @@ -140,15 +140,28 @@ public final class dAtomDefinition extends cElementalDefinition { int izoDiff = neutralCount - StableIsotope; int izoDiffAbs = Math.abs(izoDiff); - hash=super.hashCode(); - xstr.setSeed((element + 1L) * (neutralCount + 100L)); this.iaea=iaeaNuclide.get(element,neutralCount); if(iaea!=null){ - this.rawLifeTime=containsAnti ? iaea.Thalf * 1.5514433E-21f * (1f + xstr.nextFloat() * 9f):iaea.Thalf; - this.specialEnergeticDecayHandling=iaea.energeticStates!=null && iaea.energeticStates.size()>1;//todo fix since it also has base level - //todo add energetic decays? + if(Float.isNaN(iaea.mass)) this.mass=mass; + else this.mass=iaea.mass; + + if(Float.isNaN(iaea.halfTime)) { + Float overriddenLifeTime=lifetimeOverrides.get(this); + float rawLifeTimeTemp; + if(overriddenLifeTime!=null) + rawLifeTimeTemp = overriddenLifeTime; + else { + rawLifeTimeTemp = calculateLifeTime(izoDiff, izoDiffAbs, element, neutralCount, containsAnti); + } + this.rawLifeTime=rawLifeTimeTemp> STABLE_RAW_LIFE_TIME ? STABLE_RAW_LIFE_TIME :rawLifeTimeTemp; + }else { + this.rawLifeTime = containsAnti ? iaea.halfTime * 1.5514433E-21f * (1f + xstr.nextFloat() * 9f) : iaea.halfTime; + } + this.iaeaDefinitionExistsAndHasEnergyLevels =iaea.energeticStatesArray.length>1; }else{ + this.mass=mass; + Float overriddenLifeTime=lifetimeOverrides.get(this); float rawLifeTimeTemp; if(overriddenLifeTime!=null) @@ -157,11 +170,11 @@ public final class dAtomDefinition extends cElementalDefinition { rawLifeTimeTemp = calculateLifeTime(izoDiff, izoDiffAbs, element, neutralCount, containsAnti); } this.rawLifeTime=rawLifeTimeTemp> STABLE_RAW_LIFE_TIME ? STABLE_RAW_LIFE_TIME :rawLifeTimeTemp; - this.specialEnergeticDecayHandling=false; - } + this.iaeaDefinitionExistsAndHasEnergyLevels =false; + } - if(iaea==null || iaea.energeticStates==null || iaea.energeticStates.get(0f)==null) { + if(iaea==null || iaea.energeticStatesArray[0].energy!=0) { if (izoDiff == 0) this.decayMode = 0; else @@ -169,7 +182,9 @@ public final class dAtomDefinition extends cElementalDefinition { }else{ this.decayMode=Byte.MAX_VALUE; } - this.stable = this.rawLifeTime >= STABLE_RAW_LIFE_TIME; + //this.stable = this.rawLifeTime >= STABLE_RAW_LIFE_TIME; + + hash=super.hashCode(); } private static int stableIzoCurve(int element) { @@ -271,8 +286,15 @@ public final class dAtomDefinition extends cElementalDefinition { } @Override - public float getRawTimeSpan() { - return rawLifeTime; + public float getRawTimeSpan(long currentEnergy) { + if(currentEnergy<=0) return rawLifeTime; + if(iaeaDefinitionExistsAndHasEnergyLevels){ + if(currentEnergy>=iaea.energeticStatesArray.length){ + return iaea.energeticStatesArray[iaea.energeticStatesArray.length-1].Thalf/(currentEnergy-iaea.energeticStatesArray.length+1); + } + return iaea.energeticStatesArray[(int)currentEnergy].Thalf; + } + return rawLifeTime/(currentEnergy+1); } @Override @@ -291,7 +313,7 @@ public final class dAtomDefinition extends cElementalDefinition { final boolean negative = element < 0; try { if (type != 1) 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(); return (negative ? "Element: ~" : "Element: ") + element; @@ -344,11 +366,6 @@ public final class dAtomDefinition extends cElementalDefinition { private cElementalDecay[] iaeaDecay(long energy){ //todo - if(energy==0){ - - }else{ - - } return null; } @@ -517,10 +534,9 @@ public final class dAtomDefinition extends cElementalDefinition { } @Override - public cElementalDecay[] getEnergyInducedDecay(long energy) { - if (specialEnergeticDecayHandling) { - //todo map energetic states - return iaeaDecay(energy); + public cElementalDecay[] getEnergyInducedDecay(long energyLevel) { + if (iaeaDefinitionExistsAndHasEnergyLevels) { + return iaeaDecay(energyLevel); } //strip leptons boolean doIt = true; @@ -549,8 +565,34 @@ public final class dAtomDefinition extends cElementalDefinition { } @Override + public float getEnergyDiffBetweenStates(long currentEnergyLevel,long newEnergyLevel) { + if(iaeaDefinitionExistsAndHasEnergyLevels){ + float result=0; + boolean backwards=newEnergyLevel<currentEnergyLevel; + if(backwards){ + long temp=currentEnergyLevel; + currentEnergyLevel=newEnergyLevel; + newEnergyLevel=temp; + } + + if(currentEnergyLevel<=0){ + if(newEnergyLevel<=0) return DEFAULT_ENERGY_REQUIREMENT*(newEnergyLevel-currentEnergyLevel); + else result+=DEFAULT_ENERGY_REQUIREMENT*(-currentEnergyLevel); + }else result-=iaea.energeticStatesArray[(int)Math.min(iaea.energeticStatesArray.length-1,currentEnergyLevel)].energy; + if(newEnergyLevel>=iaea.energeticStatesArray.length){ + if(currentEnergyLevel>=iaea.energeticStatesArray.length) return DEFAULT_ENERGY_REQUIREMENT*(newEnergyLevel-currentEnergyLevel); + else result+=DEFAULT_ENERGY_REQUIREMENT*(newEnergyLevel-iaea.energeticStatesArray.length+1); + result+=iaea.energeticStatesArray[iaea.energeticStatesArray.length-1].energy; + }else result+=iaea.energeticStatesArray[(int)Math.max(0,newEnergyLevel)].energy; + + return backwards?-result:result; + } + return DEFAULT_ENERGY_REQUIREMENT*(newEnergyLevel-currentEnergyLevel); + } + + @Override public boolean usesSpecialEnergeticDecayHandling() { - return specialEnergeticDecayHandling; + return iaeaDefinitionExistsAndHasEnergyLevels; } @Override @@ -663,7 +705,7 @@ public final class dAtomDefinition extends cElementalDefinition { final int izoDiffAbs = Math.abs(izoDiff); final float rawLifeTime = calculateLifeTime(izoDiff, izoDiffAbs, element, isotope, false); iaeaNuclide nuclide=iaeaNuclide.get(element,isotope); - if (rawLifeTime>= STABLE_RAW_LIFE_TIME || (nuclide!=null && nuclide.Thalf>=STABLE_RAW_LIFE_TIME)) { + if (rawLifeTime>= STABLE_RAW_LIFE_TIME || (nuclide!=null && nuclide.halfTime >=STABLE_RAW_LIFE_TIME)) { TreeSet<Integer> isotopes = stableIsotopes.get(element); if (isotopes == null) stableIsotopes.put(element, isotopes = new TreeSet<>()); isotopes.add(isotope); diff --git a/src/main/java/com/github/technus/tectech/elementalMatter/definitions/complex/dHadronDefinition.java b/src/main/java/com/github/technus/tectech/elementalMatter/definitions/complex/dHadronDefinition.java index 404020ba07..59f67851f1 100644 --- a/src/main/java/com/github/technus/tectech/elementalMatter/definitions/complex/dHadronDefinition.java +++ b/src/main/java/com/github/technus/tectech/elementalMatter/definitions/complex/dHadronDefinition.java @@ -183,7 +183,7 @@ public final class dHadronDefinition extends cElementalDefinition {//TODO Optimi } @Override - public cElementalDecay[] getEnergyInducedDecay(long energy) { + public cElementalDecay[] getEnergyInducedDecay(long energyLevel) { cElementalDefinitionStack[] quarkStacks = this.quarkStacks.values(); if (amount == 2 && quarkStacks.length == 2 && quarkStacks[0].definition.getMass() == quarkStacks[1].definition.getMass() && quarkStacks[0].definition.getType() == -quarkStacks[1].definition.getType()) return cElementalDecay.noProduct; @@ -191,6 +191,11 @@ public final class dHadronDefinition extends cElementalDefinition {//TODO Optimi } @Override + public float getEnergyDiffBetweenStates(long currentEnergyLevel, long newEnergyLevel) { + return DEFAULT_ENERGY_REQUIREMENT*(newEnergyLevel-currentEnergyLevel); + } + + @Override public boolean usesSpecialEnergeticDecayHandling() { return false; } @@ -249,7 +254,7 @@ public final class dHadronDefinition extends cElementalDefinition {//TODO Optimi } @Override - public float getRawTimeSpan() { + public float getRawTimeSpan(long currentEnergy) { return rawLifeTime; } diff --git a/src/main/java/com/github/technus/tectech/elementalMatter/definitions/complex/iaea/iaeaNuclide.java b/src/main/java/com/github/technus/tectech/elementalMatter/definitions/complex/iaea/iaeaNuclide.java index 1e3d23c9ef..31fda970a6 100644 --- a/src/main/java/com/github/technus/tectech/elementalMatter/definitions/complex/iaea/iaeaNuclide.java +++ b/src/main/java/com/github/technus/tectech/elementalMatter/definitions/complex/iaea/iaeaNuclide.java @@ -9,7 +9,6 @@ import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.HashMap; -import java.util.HashSet; import java.util.TreeMap; import static com.github.technus.tectech.elementalMatter.core.interfaces.iElementalDefinition.STABLE_RAW_LIFE_TIME; @@ -75,13 +74,8 @@ public final class iaeaNuclide { e.printStackTrace(); } - for(String s:decays){ - System.out.println(s); - } - - for(iaeaNuclide nuclide:NUCLIDES.values()){ - //todo fix decays - } + for(iaeaNuclide nuclide:NUCLIDES.values()) + nuclide.makeArrayOfEnergyStates(); } public static iaeaNuclide get(int protons, int neutrons){ @@ -89,10 +83,11 @@ public final class iaeaNuclide { } public final short N,Z; - public final float Thalf;//sec + public final float halfTime;//sec public final float mass;//eV/c^2 public final short discovery;//year - public TreeMap<Float,energeticState> energeticStates; + private TreeMap<Float,energeticState> energeticStates; + public energeticState[] energeticStatesArray; private iaeaNuclide(String[][] rows){ @@ -108,27 +103,32 @@ public final class iaeaNuclide { discovery=(short)doubleOrNaN(rows[0][18],"discovery"); if(rows[0][3].contains("STABLE")){ - Thalf= STABLE_RAW_LIFE_TIME; + halfTime = STABLE_RAW_LIFE_TIME; }else{ parts = Util.splitButDifferent(rows[0][4], "|"); - Thalf = (float)doubleOrNaN(parts[0],"half life"); + halfTime = (float)doubleOrNaN(parts[0],"half life"); } } private void getMoreData(String[] cells){ - if(add(cells[14])); //System.out.println(Z+" "+N); - if(add(cells[17])); //System.out.println(Z+" "+N); - if(add(cells[20])); //System.out.println(Z+" "+N); - TreeMap<Float,String> decaymodes=new TreeMap<>(); + //if(add(cells[14]))System.out.println(N+" "+Z); + //if(add(cells[17]))System.out.println(N+" "+Z); + //if(add(cells[20]))System.out.println(N+" "+Z); + new energeticState(this, halfTime,getDecaysFixed(cells[14],doubleOrNaN(cells[15],"chance1"),cells[17],doubleOrNaN(cells[18],"chance1"),cells[20],doubleOrNaN(cells[21],"chance1"))); + } - new energeticState(this,Thalf,decaymodes); + private static final energeticState[] empty=new energeticState[0]; + private void makeArrayOfEnergyStates(){ + if(energeticStates==null || energeticStates.size()==0)energeticStatesArray=empty; + else energeticStatesArray=energeticStates.values().toArray(new energeticState[energeticStates.size()]); } private double doubleOrNaN(String s, String name){ s=s.replaceAll("#",""); if(s.length()>0) { try { - return Double.parseDouble(s); + double value=Double.parseDouble(s); + return value != 0 ?value:Float.NaN; } catch (Exception e) { System.out.println("Invalid Value " + name + " " + N + " " + Z + " " + s); e.printStackTrace(); @@ -140,9 +140,9 @@ public final class iaeaNuclide { public static class energeticState{ public final float energy; public final float Thalf; - public TreeMap<Float,String> decaymodes; + public final iaeaDecay[] decaymodes; - private energeticState(iaeaNuclide nuclide,float Thalf,TreeMap<Float,String> decaymodes){ + private energeticState(iaeaNuclide nuclide,float Thalf,iaeaDecay[] decaymodes){ energy=0; this.Thalf=Thalf; this.decaymodes=decaymodes; @@ -155,7 +155,8 @@ public final class iaeaNuclide { iaeaNuclide nuclide=get((int)doubleOrNaN(cells[0],"protons"),(int)doubleOrNaN(cells[1],"neutrons")); if(nuclide==null) throw new Error("Missing nuclide "+(int)doubleOrNaN(cells[0],"protons")+" "+(int)doubleOrNaN(cells[1],"neutrons")); - this.energy=(float) (doubleOrNaN(cells[3],"energy level",nuclide)*1000);//to eV + this.energy=(float) (doubleOrNaN(cells[3],"energy level",nuclide)*1000f);//to eV + if(energy<0) throw new Error("Invalid energy "+ nuclide.N +" "+nuclide.Z+ " "+cells[3]); this.Thalf=(float) doubleOrNaN(cells[10],"half life",nuclide); if(nuclide.energeticStates==null) { new Exception("Should be initialized before doing this... "+ nuclide.N +" "+nuclide.Z).printStackTrace(); @@ -163,9 +164,10 @@ public final class iaeaNuclide { } nuclide.energeticStates.put(energy,this); - if(add(cells[12])); //System.out.println(nuclide.Z+" "+nuclide.N); - if(add(cells[15])); //System.out.println(nuclide.Z+" "+nuclide.N); - if(add(cells[18])); //System.out.println(nuclide.Z+" "+nuclide.N); + //if(add(cells[12]))System.out.println(nuclide.N+" "+nuclide.Z); + //if(add(cells[15]))System.out.println(nuclide.N+" "+nuclide.Z); + //if(add(cells[18]))System.out.println(nuclide.N+" "+nuclide.Z); + this.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){ @@ -190,21 +192,35 @@ public final class iaeaNuclide { } } - private static HashSet<String> decays=new HashSet<>(); - private static boolean add(String s){ - int len=decays.size(); - decays.add(s); - if(decays.size()>len){ - System.out.println(s); - return true; - } - return false; + //private static HashSet<String> decays=new HashSet<>(); + //private static boolean add(String s){ + // int len=decays.size(); + // if(decays.add(s)){ + // System.out.println(s); + // return true; + // } + // return false; + //} + + private static iaeaDecay[] getDecaysFixed(String decay1, double chance1,String decay2, double chance2,String decay3, double chance3){ + TreeMap<Double,iaeaDecay> decays=new TreeMap<>(); + if(decay1.length()>0) + decays.put(chance1/100D,new iaeaDecay((float)(chance1/100D),decay1)); + if(decay2.length()>0) + decays.put(chance2/100D,new iaeaDecay((float)(chance2/100D),decay3)); + if(decay3.length()>0) + decays.put(chance3/100D,new iaeaDecay((float)(chance3/100D),decay3)); + decays.put(1D,iaeaDecay.DEAD_END); + return decays.values().toArray(new iaeaDecay[decays.size()]); } - public enum decayType{ - ; - public final String name; - decayType(String name){ - this.name=name; + + public static class iaeaDecay{ + public final float chance; + public final String decayName; + public static final iaeaDecay DEAD_END=new iaeaDecay(1f,"DEAD_END"); + private iaeaDecay(float chance,String decayName){ + this.chance=chance; + this.decayName=decayName; } } } diff --git a/src/main/java/com/github/technus/tectech/elementalMatter/definitions/primitive/cPrimitiveDefinition.java b/src/main/java/com/github/technus/tectech/elementalMatter/definitions/primitive/cPrimitiveDefinition.java index ee58c69b5a..1a4582386b 100644 --- a/src/main/java/com/github/technus/tectech/elementalMatter/definitions/primitive/cPrimitiveDefinition.java +++ b/src/main/java/com/github/technus/tectech/elementalMatter/definitions/primitive/cPrimitiveDefinition.java @@ -3,7 +3,6 @@ package com.github.technus.tectech.elementalMatter.definitions.primitive; import com.github.technus.tectech.elementalMatter.core.templates.cElementalPrimitive; import static com.github.technus.tectech.elementalMatter.core.cElementalDecay.noDecay; -import static com.github.technus.tectech.elementalMatter.core.cElementalDecay.noProduct; /** * Created by danie_000 on 22.10.2016. @@ -21,11 +20,11 @@ public final class cPrimitiveDefinition extends cElementalPrimitive { } public static void run() { - nbtE__.init(null__, -1F, -1, -1, noDecay); - null__.init(null__, -1F, -1, -1, noProduct); - space__.init(space__, -1F, -1, -1, noProduct); - magic.init(magic_, -1F, -1, -1, noDecay); - magic_.init(magic, -1F, -1, -1, noDecay); + nbtE__.init(null__, NO_DECAY_RAW_LIFE_TIME, -1, -1, noDecay); + null__.init(null__, NO_DECAY_RAW_LIFE_TIME, -1, -1, noDecay); + space__.init(space__, NO_DECAY_RAW_LIFE_TIME, -1, -1, noDecay); + magic.init(magic_, NO_DECAY_RAW_LIFE_TIME, -1, -1, noDecay); + magic_.init(magic, NO_DECAY_RAW_LIFE_TIME, -1, -1, noDecay); } @Override diff --git a/src/main/java/com/github/technus/tectech/elementalMatter/definitions/primitive/eBosonDefinition.java b/src/main/java/com/github/technus/tectech/elementalMatter/definitions/primitive/eBosonDefinition.java index 62c1d2b9ab..25696992a6 100644 --- a/src/main/java/com/github/technus/tectech/elementalMatter/definitions/primitive/eBosonDefinition.java +++ b/src/main/java/com/github/technus/tectech/elementalMatter/definitions/primitive/eBosonDefinition.java @@ -20,8 +20,7 @@ public final class eBosonDefinition extends cElementalPrimitive { } public static void run() { - boson_Y__.init(null, -1F, 0, 0, - deadEndHalf); + 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_), diff --git a/src/main/java/com/github/technus/tectech/elementalMatter/definitions/primitive/eLeptonDefinition.java b/src/main/java/com/github/technus/tectech/elementalMatter/definitions/primitive/eLeptonDefinition.java index 8edb7ab503..3ef4e4b258 100644 --- a/src/main/java/com/github/technus/tectech/elementalMatter/definitions/primitive/eLeptonDefinition.java +++ b/src/main/java/com/github/technus/tectech/elementalMatter/definitions/primitive/eLeptonDefinition.java @@ -41,10 +41,10 @@ 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.197e-6F, 0, 1, + lepton_m_.init(lepton_m, 2.197019e-6F, 0, 1, new cElementalDecay(0.9F, lepton_e_, eNeutrinoDefinition.lepton_Ve, eNeutrinoDefinition.lepton_Vm_), eBosonDefinition.deadEnd);//makes photons and don't care - lepton_t_.init(lepton_t, 2.9e-13F, 1, 3, + lepton_t_.init(lepton_t, 2.906e-13F, 1, 3, new cElementalDecay(0.8F, lepton_m_, eNeutrinoDefinition.lepton_Vm, eNeutrinoDefinition.lepton_Vt_, eBosonDefinition.boson_Y__), new cElementalDecay(0.1F, lepton_e_, eNeutrinoDefinition.lepton_Ve, eNeutrinoDefinition.lepton_Vm_), new cElementalDecay(0.05F, lepton_m_, eNeutrinoDefinition.lepton_Vm, eNeutrinoDefinition.lepton_Vt_, eBosonDefinition.boson_H__), diff --git a/src/main/java/com/github/technus/tectech/elementalMatter/definitions/primitive/eNeutrinoDefinition.java b/src/main/java/com/github/technus/tectech/elementalMatter/definitions/primitive/eNeutrinoDefinition.java index 9abe584e8d..07e7452144 100644 --- a/src/main/java/com/github/technus/tectech/elementalMatter/definitions/primitive/eNeutrinoDefinition.java +++ b/src/main/java/com/github/technus/tectech/elementalMatter/definitions/primitive/eNeutrinoDefinition.java @@ -27,19 +27,19 @@ public final class eNeutrinoDefinition extends cElementalPrimitive { lepton_Ve.init(lepton_Ve_, 1F, 0, 0, cElementalDecay.noProduct); lepton_Vm.init(lepton_Vm_, 1F, 1, 0, - new cElementalDecay(0.95F, nothing), + new cElementalDecay(0.825F, nothing), eBosonDefinition.deadEndHalf); lepton_Vt.init(lepton_Vt_, 1F, 1, 0, - new cElementalDecay(0.9F, nothing), + new cElementalDecay(0.75F, nothing), eBosonDefinition.deadEnd); lepton_Ve_.init(lepton_Ve, 1F, 0, 0, cElementalDecay.noProduct); lepton_Vm_.init(lepton_Vm, 1F, 1, 0, - new cElementalDecay(0.95F, nothing), + new cElementalDecay(0.825F, nothing), eBosonDefinition.deadEndHalf); lepton_Vt_.init(lepton_Vt, 1F, 1, 0, - new cElementalDecay(0.9F, nothing), + new cElementalDecay(0.75F, nothing), eBosonDefinition.deadEnd); } diff --git a/src/main/java/com/github/technus/tectech/elementalMatter/definitions/primitive/eQuarkDefinition.java b/src/main/java/com/github/technus/tectech/elementalMatter/definitions/primitive/eQuarkDefinition.java index 3ddb650f12..3abf04464f 100644 --- a/src/main/java/com/github/technus/tectech/elementalMatter/definitions/primitive/eQuarkDefinition.java +++ b/src/main/java/com/github/technus/tectech/elementalMatter/definitions/primitive/eQuarkDefinition.java @@ -26,7 +26,7 @@ public final class eQuarkDefinition extends cElementalPrimitive { } public static void run() { - quark_u.init(quark_u_, 1e35F, 3, -1, + 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*/), @@ -42,7 +42,7 @@ public final class eQuarkDefinition extends cElementalPrimitive { new cElementalDecay(7.51689e-5F, quark_d, eLeptonDefinition.lepton_t_, eNeutrinoDefinition.lepton_Vt), eBosonDefinition.deadEnd);//makes photons and don't care - quark_d.init(quark_d_, 1e35F, 3, -1, + 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_*/), @@ -58,7 +58,7 @@ public final class eQuarkDefinition extends cElementalPrimitive { new cElementalDecay(1.23201e-5F, quark_u, eLeptonDefinition.lepton_t, eNeutrinoDefinition.lepton_Vt_), eBosonDefinition.deadEnd);//makes photons and don't care - quark_u_.init(quark_u, 88, 3, -1, + 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_*/), @@ -74,7 +74,7 @@ public final class eQuarkDefinition extends cElementalPrimitive { new cElementalDecay(7.51689e-5F, quark_d_, eLeptonDefinition.lepton_t, eNeutrinoDefinition.lepton_Vt_), eBosonDefinition.deadEnd);//makes photons and don't care - quark_d_.init(quark_d, 44F, 3, -1, + 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*/), diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_decay.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_decay.java index 9395d5de37..f00f182de1 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_decay.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_decay.java @@ -128,7 +128,7 @@ public class GT_MetaTileEntity_EM_decay extends GT_MetaTileEntity_MultiblockBase mMaxProgresstime = 1;//(int)m3; mEfficiencyIncrease = 10000; m1 = input.getMass()/input.amount; - cElementalInstanceStackMap decayed=input.decayCompute(input.getDefinition().getDecayArray(),1,0,0); + cElementalInstanceStackMap decayed=input.decay(); m2 = decayed.getMass()/input.amount; //TecTech.Logger.info("I " + input.toString()); //TecTech.Logger.info("O " + decayed.toString()); diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_dequantizer.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_dequantizer.java index 57900f37e4..92ff23b6bb 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_dequantizer.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_dequantizer.java @@ -21,6 +21,7 @@ import java.util.ArrayList; import static com.github.technus.tectech.Util.StructureBuilder; import static com.github.technus.tectech.Util.V; +import static com.github.technus.tectech.elementalMatter.core.interfaces.iElementalDefinition.STABLE_RAW_LIFE_TIME; import static com.github.technus.tectech.elementalMatter.definitions.complex.dAtomDefinition.refMass; import static com.github.technus.tectech.elementalMatter.definitions.complex.dAtomDefinition.refUnstableMass; import static com.github.technus.tectech.thing.casing.GT_Block_CasingsTT.textureOffset; @@ -89,7 +90,7 @@ public class GT_MetaTileEntity_EM_dequantizer extends GT_MetaTileEntity_Multiblo if (info != null) { if (map.removeAllAmounts(false, (iHasElementalDefinition) info.input())) { mOutputFluids = new FluidStack[]{(FluidStack) info.output()}; - startRecipe((iHasElementalDefinition) info.input()); + startRecipe((iHasElementalDefinition) info.input(),stack.getEnergy()); return true; } } @@ -98,7 +99,7 @@ public class GT_MetaTileEntity_EM_dequantizer extends GT_MetaTileEntity_Multiblo if (info != null) { if (map.removeAllAmounts(false, (iHasElementalDefinition) info.input())) { mOutputItems = new ItemStack[]{(ItemStack) info.output()}; - startRecipe((iHasElementalDefinition) info.input()); + startRecipe((iHasElementalDefinition) info.input(),stack.getEnergy()); return true; } } @@ -109,7 +110,7 @@ public class GT_MetaTileEntity_EM_dequantizer extends GT_MetaTileEntity_Multiblo ArrayList<ItemStack> items = OreDictionary.getOres(((aOredictDequantizationInfo) info).out); if (items != null && items.size() > 0) { mOutputItems = new ItemStack[]{items.get(0)}; - startRecipe((iHasElementalDefinition) info.input()); + startRecipe((iHasElementalDefinition) info.input(),stack.getEnergy()); return true; } } @@ -121,13 +122,13 @@ public class GT_MetaTileEntity_EM_dequantizer extends GT_MetaTileEntity_Multiblo return false; } - private void startRecipe(iHasElementalDefinition from) { + private void startRecipe(iHasElementalDefinition from, long energy) { mMaxProgresstime = 20; mEfficiencyIncrease = 10000; float mass = from.getMass(); float euMult = mass / refMass; eAmpereFlow = (int) Math.ceil(euMult); - if (mass > refUnstableMass || from.getDefinition().getRawTimeSpan() < 1.5e25f) { + if (mass > refUnstableMass || from.getDefinition().getRawTimeSpan(energy) < STABLE_RAW_LIFE_TIME) { mEUt = (int) -V[10]; } else { mEUt = (int) -V[8]; diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_quantizer.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_quantizer.java index 96d8e97361..4ebbc9438b 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_quantizer.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_quantizer.java @@ -22,6 +22,7 @@ import net.minecraftforge.oredict.OreDictionary; import static com.github.technus.tectech.Util.*; import static com.github.technus.tectech.auxiliary.TecTechConfig.DEBUG_MODE; +import static com.github.technus.tectech.elementalMatter.core.interfaces.iElementalDefinition.DEFAULT_ENERGY_LEVEL; import static com.github.technus.tectech.elementalMatter.definitions.complex.dAtomDefinition.refMass; import static com.github.technus.tectech.elementalMatter.definitions.complex.dAtomDefinition.refUnstableMass; import static com.github.technus.tectech.thing.casing.GT_Block_CasingsTT.textureOffset; @@ -153,7 +154,7 @@ public class GT_MetaTileEntity_EM_quantizer extends GT_MetaTileEntity_Multiblock float mass = into.getMass(); float euMult = mass / refMass; eAmpereFlow = (int) Math.ceil(euMult); - if (mass > refUnstableMass || into.getDefinition().getRawTimeSpan() < 1.5e25f) { + if (mass > refUnstableMass || into.getDefinition().getRawTimeSpan(DEFAULT_ENERGY_LEVEL) < 1.5e25f) { mEUt = (int) -V[10]; } else { mEUt = (int) -V[8]; diff --git a/src/main/resources/assets/tectech/energyLevels.csv b/src/main/resources/assets/tectech/energyLevels.csv index ec98b17ab2..484768d8b7 100644 --- a/src/main/resources/assets/tectech/energyLevels.csv +++ b/src/main/resources/assets/tectech/energyLevels.csv @@ -2917,4 +2917,4 @@ 105,152,Db,370,-1,(1/2-),,0.67,6,S,0.67,0.06,A,87,0,SF,13,0,,,,,,,,, 106,159,Sg,152,0,,,8.5,+26-16,S,8.5,2.1,SF,51,0,A,49,0,,,,,,,,, 108,157,Hs,300,-1,,,0.75,+17-12,MS,0.00075,0.00015,A,100,0,SF,1,0,,,,,,,,, -110,160,Ds,1130,0,,,6.0,+82-22,MS,0.006,0.0052,A,70,0,IT,,0,,,,,,,,, +110,160,Ds,1130,0,,,6.0,+82-22,MS,0.006,0.0052,A,70,0,IT,,0,,,,,,,,,
\ No newline at end of file diff --git a/src/main/resources/assets/tectech/nuclidesTable.csv b/src/main/resources/assets/tectech/nuclidesTable.csv index 940dbf0cb1..783276227a 100644 --- a/src/main/resources/assets/tectech/nuclidesTable.csv +++ b/src/main/resources/assets/tectech/nuclidesTable.csv @@ -3252,4 +3252,4 @@ 116,177,LV,,,0,0,,,53,+62-19,MS,0.053,0.041,A,100,0,,,,,,,,,,,,-3716,1000,-10978,889,10679.42,50,,,5644,996,,,7111,2,293204691,629,190669,586, 117,176,Ts,,,,0,,,14,+11-4,MS,0.014,0.008,A,100,0,SF,,0,,,,,,,,,,,,,,,,,,,,,,,,,,, 117,177,Ts,,,,0,,,,,,,,A,100,0,SF,,0,,,,,,,,,,,,,,,,,,,,,,,,,,, -118,176,Og,,,0,0,0+,,1.8,+84-8,MS,0.0018,0.0046,A,100,0,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +118,176,Og,,,0,0,0+,,1.8,+84-8,MS,0.0018,0.0046,A,100,0,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
\ No newline at end of file |