aboutsummaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
authorTec <daniel112092@gmail.com>2022-01-18 21:57:53 +0100
committerMartin Robertz <dream-master@gmx.net>2022-01-29 21:23:22 +0100
commit3dcc0761ab6247cb20dbe16a83e19abe675a13ed (patch)
tree7eb2176d251dc6e7ccba906821261f73fae00d7b /src/main
parent7edde3bf8c069244dabc7138fb5c5f53ce40336d (diff)
downloadGT5-Unofficial-3dcc0761ab6247cb20dbe16a83e19abe675a13ed.tar.gz
GT5-Unofficial-3dcc0761ab6247cb20dbe16a83e19abe675a13ed.tar.bz2
GT5-Unofficial-3dcc0761ab6247cb20dbe16a83e19abe675a13ed.zip
Cleanup serialization of EM
(cherry picked from commit 44c86af58ecb24de8ba66fa6cf8fa81324a32a28)
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/com/github/technus/tectech/compatibility/openmodularturrets/entity/projectiles/projectileEM.java4
-rw-r--r--src/main/java/com/github/technus/tectech/compatibility/thaumcraft/elementalMatter/definitions/EMComplexAspectDefinition.java30
-rw-r--r--src/main/java/com/github/technus/tectech/compatibility/thaumcraft/elementalMatter/definitions/EMPrimalAspectDefinition.java4
-rw-r--r--src/main/java/com/github/technus/tectech/compatibility/thaumcraft/elementalMatter/transformations/AspectDefinitionCompat.java2
-rw-r--r--src/main/java/com/github/technus/tectech/compatibility/thaumcraft/elementalMatter/transformations/AspectDefinitionCompatEnabled.java4
-rw-r--r--src/main/java/com/github/technus/tectech/compatibility/thaumcraft/thing/metaTileEntity/multi/EssentiaCompat.java2
-rw-r--r--src/main/java/com/github/technus/tectech/compatibility/thaumcraft/thing/metaTileEntity/multi/EssentiaCompatEnabled.java2
-rw-r--r--src/main/java/com/github/technus/tectech/compatibility/thaumcraft/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_essentiaQuantizer.java2
-rw-r--r--src/main/java/com/github/technus/tectech/loader/ElementalLoader.java3
-rw-r--r--src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/EMException.java17
-rw-r--r--src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/commands/EMGive.java15
-rw-r--r--src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/commands/EMList.java14
-rw-r--r--src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/decay/EMDecay.java2
-rw-r--r--src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/definitions/EMComplexTemplate.java73
-rw-r--r--src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/definitions/EMDefinitionsRegistry.java110
-rw-r--r--src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/definitions/EMPrimitiveTemplate.java (renamed from src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/templates/EMPrimitive.java)76
-rw-r--r--src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/definitions/IEMDefinition.java (renamed from src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/templates/IEMDefinition.java)13
-rw-r--r--src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/maps/EMConstantStackMap.java2
-rw-r--r--src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/maps/EMDefinitionStackMap.java2
-rw-r--r--src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/maps/EMInstanceStackMap.java2
-rw-r--r--src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/maps/EMStackMap.java2
-rw-r--r--src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/maps/IEMMapRead.java39
-rw-r--r--src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/maps/IEMMapWrite.java2
-rw-r--r--src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/maps/IEMMapWriteExact.java2
-rw-r--r--src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/stacks/EMDefinitionStack.java6
-rw-r--r--src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/stacks/EMInstanceStack.java7
-rw-r--r--src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/stacks/IEMStack.java2
-rw-r--r--src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/templates/EMComplex.java135
-rw-r--r--src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/transformations/EMTransformationInfo.java25
-rw-r--r--src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/complex/EMAtomDefinition.java34
-rw-r--r--src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/complex/EMHadronDefinition.java50
-rw-r--r--src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/complex/EMNuclideIAEA.java2
-rw-r--r--src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/primitive/EMBosonDefinition.java4
-rw-r--r--src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/primitive/EMLeptonDefinition.java4
-rw-r--r--src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/primitive/EMNeutrinoDefinition.java4
-rw-r--r--src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/primitive/EMPrimitiveDefinition.java10
-rw-r--r--src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/primitive/EMQuarkDefinition.java4
-rw-r--r--src/main/java/com/github/technus/tectech/recipe/TT_recipe.java6
-rw-r--r--src/main/java/com/github/technus/tectech/recipe/TT_recipeAdder.java2
-rw-r--r--src/main/java/com/github/technus/tectech/thing/item/DebugElementalInstanceContainer_EM.java7
-rw-r--r--src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_collider.java10
-rw-r--r--src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_dequantizer.java2
-rw-r--r--src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_quantizer.java4
43 files changed, 389 insertions, 353 deletions
diff --git a/src/main/java/com/github/technus/tectech/compatibility/openmodularturrets/entity/projectiles/projectileEM.java b/src/main/java/com/github/technus/tectech/compatibility/openmodularturrets/entity/projectiles/projectileEM.java
index d594a826bc..785b59f093 100644
--- a/src/main/java/com/github/technus/tectech/compatibility/openmodularturrets/entity/projectiles/projectileEM.java
+++ b/src/main/java/com/github/technus/tectech/compatibility/openmodularturrets/entity/projectiles/projectileEM.java
@@ -52,10 +52,10 @@ public class projectileEM extends LaserProjectile {
charge=projectileContent.getCharge();
massFactor =(float) (projectileContent.getDefinition().getMass()/ EMHadronDefinition.hadron_n_.getMass());
- if(projectileContent.getDefinition().getType()>1 || projectileContent.getDefinition().getType()<-1) {
+ if(projectileContent.getDefinition().getMatterType()>1 || projectileContent.getDefinition().getMatterType()<-1) {
strange = true;
}
- if(projectileContent.getDefinition().getType()<0) {
+ if(projectileContent.getDefinition().getMatterType()<0) {
antiMatter = true;
}
diff --git a/src/main/java/com/github/technus/tectech/compatibility/thaumcraft/elementalMatter/definitions/EMComplexAspectDefinition.java b/src/main/java/com/github/technus/tectech/compatibility/thaumcraft/elementalMatter/definitions/EMComplexAspectDefinition.java
index 432d151b80..e56e31f166 100644
--- a/src/main/java/com/github/technus/tectech/compatibility/thaumcraft/elementalMatter/definitions/EMComplexAspectDefinition.java
+++ b/src/main/java/com/github/technus/tectech/compatibility/thaumcraft/elementalMatter/definitions/EMComplexAspectDefinition.java
@@ -2,13 +2,14 @@ package com.github.technus.tectech.compatibility.thaumcraft.elementalMatter.defi
import com.github.technus.tectech.TecTech;
import com.github.technus.tectech.compatibility.thaumcraft.elementalMatter.transformations.AspectDefinitionCompat;
+import com.github.technus.tectech.mechanics.elementalMatter.core.definitions.EMDefinitionsRegistry;
import com.github.technus.tectech.util.Util;
import com.github.technus.tectech.mechanics.elementalMatter.core.decay.EMDecay;
import com.github.technus.tectech.mechanics.elementalMatter.core.maps.EMConstantStackMap;
import com.github.technus.tectech.mechanics.elementalMatter.core.stacks.EMDefinitionStack;
import com.github.technus.tectech.mechanics.elementalMatter.core.EMException;
-import com.github.technus.tectech.mechanics.elementalMatter.core.templates.EMComplex;
-import com.github.technus.tectech.mechanics.elementalMatter.core.templates.IEMDefinition;
+import com.github.technus.tectech.mechanics.elementalMatter.core.definitions.EMComplexTemplate;
+import com.github.technus.tectech.mechanics.elementalMatter.core.definitions.IEMDefinition;
import com.github.technus.tectech.mechanics.elementalMatter.core.transformations.EMFluidDequantizationInfo;
import com.github.technus.tectech.mechanics.elementalMatter.core.transformations.EMItemDequantizationInfo;
import com.github.technus.tectech.mechanics.elementalMatter.core.transformations.EMOredictDequantizationInfo;
@@ -25,7 +26,7 @@ import static net.minecraft.util.StatCollector.translateToLocal;
/**
* Created by Tec on 06.05.2017.
*/
-public final class EMComplexAspectDefinition extends EMComplex {
+public final class EMComplexAspectDefinition extends EMComplexTemplate {
private final int hash;
private final double mass;
@@ -123,19 +124,8 @@ public final class EMComplexAspectDefinition extends EMComplex {
}
@Override
- public NBTTagCompound toNBT() {
- return getNbtTagCompound(nbtType, aspectStacks);
- }
-
- public static NBTTagCompound getNbtTagCompound(byte nbtType, EMConstantStackMap aspectStacks) {
- NBTTagCompound nbt = new NBTTagCompound();
- nbt.setByte("t", nbtType);
- EMDefinitionStack[] quarkStacksValues = aspectStacks.valuesToArray();
- nbt.setInteger("i", quarkStacksValues.length);
- for (int i = 0; i < quarkStacksValues.length; i++) {
- nbt.setTag(Integer.toString(i), quarkStacksValues[i].toNBT());
- }
- return nbt;
+ protected int getIndirectTagValue() {
+ return nbtType;
}
public static EMComplexAspectDefinition fromNBT(NBTTagCompound nbt) {
@@ -169,7 +159,7 @@ public final class EMComplexAspectDefinition extends EMComplex {
}
@Override
- public byte getType() {
+ public byte getMatterType() {
return 0;
}
@@ -250,20 +240,20 @@ public final class EMComplexAspectDefinition extends EMComplex {
public static void run() {
try {
- EMComplex.addCreatorFromNBT(nbtType, EMComplexAspectDefinition.class.getMethod("fromNBT", NBTTagCompound.class), (byte) -96);
+ EMDefinitionsRegistry.registerDefinitionClass(nbtType, EMComplexAspectDefinition::fromNBT,EMComplexAspectDefinition.class, getClassTypeStatic());
} catch (Exception e) {
if (DEBUG_MODE) {
e.printStackTrace();
}
}
if (DEBUG_MODE) {
- TecTech.LOGGER.info("Registered Elemental Matter Class: ComplexAspect " + nbtType + ' ' + -96);
+ TecTech.LOGGER.info("Registered Elemental Matter Class: ComplexAspect " + nbtType + ' ' + getClassTypeStatic());
}
}
@Override
public byte getClassType() {
- return -96;
+ return getClassTypeStatic();
}
public static byte getClassTypeStatic() {
diff --git a/src/main/java/com/github/technus/tectech/compatibility/thaumcraft/elementalMatter/definitions/EMPrimalAspectDefinition.java b/src/main/java/com/github/technus/tectech/compatibility/thaumcraft/elementalMatter/definitions/EMPrimalAspectDefinition.java
index bf9703d6d7..e62c2e5278 100644
--- a/src/main/java/com/github/technus/tectech/compatibility/thaumcraft/elementalMatter/definitions/EMPrimalAspectDefinition.java
+++ b/src/main/java/com/github/technus/tectech/compatibility/thaumcraft/elementalMatter/definitions/EMPrimalAspectDefinition.java
@@ -1,6 +1,6 @@
package com.github.technus.tectech.compatibility.thaumcraft.elementalMatter.definitions;
-import com.github.technus.tectech.mechanics.elementalMatter.core.templates.EMPrimitive;
+import com.github.technus.tectech.mechanics.elementalMatter.core.definitions.EMPrimitiveTemplate;
import static com.github.technus.tectech.mechanics.elementalMatter.core.decay.EMDecay.NO_DECAY;
import static net.minecraft.util.StatCollector.translateToLocal;
@@ -8,7 +8,7 @@ import static net.minecraft.util.StatCollector.translateToLocal;
/**
* Created by Tec on 06.05.2017.
*/
-public final class EMPrimalAspectDefinition extends EMPrimitive {
+public final class EMPrimalAspectDefinition extends EMPrimitiveTemplate {
public static final EMPrimalAspectDefinition
magic_air = new EMPrimalAspectDefinition(translateToLocal("tt.keyword.Air"), "a`", 1e1D, 35),
magic_earth = new EMPrimalAspectDefinition(translateToLocal("tt.keyword.Earth"), "e`", 1e9D, 34),
diff --git a/src/main/java/com/github/technus/tectech/compatibility/thaumcraft/elementalMatter/transformations/AspectDefinitionCompat.java b/src/main/java/com/github/technus/tectech/compatibility/thaumcraft/elementalMatter/transformations/AspectDefinitionCompat.java
index c7f38eb21d..a4328d2e03 100644
--- a/src/main/java/com/github/technus/tectech/compatibility/thaumcraft/elementalMatter/transformations/AspectDefinitionCompat.java
+++ b/src/main/java/com/github/technus/tectech/compatibility/thaumcraft/elementalMatter/transformations/AspectDefinitionCompat.java
@@ -1,7 +1,7 @@
package com.github.technus.tectech.compatibility.thaumcraft.elementalMatter.transformations;
-import com.github.technus.tectech.mechanics.elementalMatter.core.templates.IEMDefinition;
+import com.github.technus.tectech.mechanics.elementalMatter.core.definitions.IEMDefinition;
import java.util.HashMap;
diff --git a/src/main/java/com/github/technus/tectech/compatibility/thaumcraft/elementalMatter/transformations/AspectDefinitionCompatEnabled.java b/src/main/java/com/github/technus/tectech/compatibility/thaumcraft/elementalMatter/transformations/AspectDefinitionCompatEnabled.java
index c9ca5d7b9f..ead8a5fdef 100644
--- a/src/main/java/com/github/technus/tectech/compatibility/thaumcraft/elementalMatter/transformations/AspectDefinitionCompatEnabled.java
+++ b/src/main/java/com/github/technus/tectech/compatibility/thaumcraft/elementalMatter/transformations/AspectDefinitionCompatEnabled.java
@@ -2,13 +2,13 @@ package com.github.technus.tectech.compatibility.thaumcraft.elementalMatter.tran
import com.github.technus.tectech.compatibility.thaumcraft.elementalMatter.definitions.EMComplexAspectDefinition;
import com.github.technus.tectech.mechanics.elementalMatter.core.EMException;
-import com.github.technus.tectech.mechanics.elementalMatter.core.templates.IEMDefinition;
+import com.github.technus.tectech.mechanics.elementalMatter.core.definitions.IEMDefinition;
import thaumcraft.api.aspects.Aspect;
import java.util.ArrayList;
import static com.github.technus.tectech.compatibility.thaumcraft.elementalMatter.definitions.EMPrimalAspectDefinition.*;
-import static com.github.technus.tectech.thing.item.DebugElementalInstanceContainer_EM.STACKS_REGISTERED;
+import static com.github.technus.tectech.mechanics.elementalMatter.core.definitions.EMDefinitionsRegistry.STACKS_REGISTERED;
/**
* Created by Tec on 21.05.2017.
diff --git a/src/main/java/com/github/technus/tectech/compatibility/thaumcraft/thing/metaTileEntity/multi/EssentiaCompat.java b/src/main/java/com/github/technus/tectech/compatibility/thaumcraft/thing/metaTileEntity/multi/EssentiaCompat.java
index d51bc8dc2d..35d3a1b91f 100644
--- a/src/main/java/com/github/technus/tectech/compatibility/thaumcraft/thing/metaTileEntity/multi/EssentiaCompat.java
+++ b/src/main/java/com/github/technus/tectech/compatibility/thaumcraft/thing/metaTileEntity/multi/EssentiaCompat.java
@@ -1,6 +1,6 @@
package com.github.technus.tectech.compatibility.thaumcraft.thing.metaTileEntity.multi;
-import com.github.technus.tectech.mechanics.elementalMatter.core.templates.IEMDefinition;
+import com.github.technus.tectech.mechanics.elementalMatter.core.definitions.IEMDefinition;
import com.github.technus.tectech.thing.metaTileEntity.multi.base.GT_MetaTileEntity_MultiblockBase_EM;
import net.minecraft.tileentity.TileEntity;
diff --git a/src/main/java/com/github/technus/tectech/compatibility/thaumcraft/thing/metaTileEntity/multi/EssentiaCompatEnabled.java b/src/main/java/com/github/technus/tectech/compatibility/thaumcraft/thing/metaTileEntity/multi/EssentiaCompatEnabled.java
index ab682ba1a5..37df2c48cc 100644
--- a/src/main/java/com/github/technus/tectech/compatibility/thaumcraft/thing/metaTileEntity/multi/EssentiaCompatEnabled.java
+++ b/src/main/java/com/github/technus/tectech/compatibility/thaumcraft/thing/metaTileEntity/multi/EssentiaCompatEnabled.java
@@ -1,6 +1,6 @@
package com.github.technus.tectech.compatibility.thaumcraft.thing.metaTileEntity.multi;
-import com.github.technus.tectech.mechanics.elementalMatter.core.templates.IEMDefinition;
+import com.github.technus.tectech.mechanics.elementalMatter.core.definitions.IEMDefinition;
import com.github.technus.tectech.thing.metaTileEntity.multi.base.GT_MetaTileEntity_MultiblockBase_EM;
import net.minecraft.tileentity.TileEntity;
import thaumcraft.api.aspects.Aspect;
diff --git a/src/main/java/com/github/technus/tectech/compatibility/thaumcraft/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_essentiaQuantizer.java b/src/main/java/com/github/technus/tectech/compatibility/thaumcraft/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_essentiaQuantizer.java
index 5606442c37..5fe8c973fe 100644
--- a/src/main/java/com/github/technus/tectech/compatibility/thaumcraft/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_essentiaQuantizer.java
+++ b/src/main/java/com/github/technus/tectech/compatibility/thaumcraft/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_essentiaQuantizer.java
@@ -5,7 +5,7 @@ import com.github.technus.tectech.compatibility.thaumcraft.elementalMatter.defin
import com.github.technus.tectech.mechanics.constructable.IConstructable;
import com.github.technus.tectech.mechanics.elementalMatter.core.maps.EMInstanceStackMap;
import com.github.technus.tectech.mechanics.elementalMatter.core.stacks.EMInstanceStack;
-import com.github.technus.tectech.mechanics.elementalMatter.core.templates.IEMDefinition;
+import com.github.technus.tectech.mechanics.elementalMatter.core.definitions.IEMDefinition;
import com.github.technus.tectech.mechanics.structure.Structure;
import com.github.technus.tectech.mechanics.structure.adders.IHatchAdder;
import com.github.technus.tectech.thing.block.QuantumGlassBlock;
diff --git a/src/main/java/com/github/technus/tectech/loader/ElementalLoader.java b/src/main/java/com/github/technus/tectech/loader/ElementalLoader.java
index 7ce371e57e..61989e7b13 100644
--- a/src/main/java/com/github/technus/tectech/loader/ElementalLoader.java
+++ b/src/main/java/com/github/technus/tectech/loader/ElementalLoader.java
@@ -2,7 +2,6 @@ package com.github.technus.tectech.loader;
import com.github.technus.tectech.compatibility.thaumcraft.elementalMatter.definitions.EMComplexAspectDefinition;
import com.github.technus.tectech.compatibility.thaumcraft.elementalMatter.definitions.EMPrimalAspectDefinition;
-import com.github.technus.tectech.mechanics.elementalMatter.core.templates.EMPrimitive;
import com.github.technus.tectech.mechanics.elementalMatter.definitions.complex.EMAtomDefinition;
import com.github.technus.tectech.mechanics.elementalMatter.definitions.complex.EMHadronDefinition;
import com.github.technus.tectech.mechanics.elementalMatter.definitions.complex.EMNuclideIAEA;
@@ -18,8 +17,6 @@ public class ElementalLoader implements Runnable {
// Definition init
// ===================================================================================================
- EMPrimitive.run();
-
EMPrimitiveDefinition.run();
EMQuarkDefinition.run();
diff --git a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/EMException.java b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/EMException.java
index 23ca5d77d9..e00e72446d 100644
--- a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/EMException.java
+++ b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/EMException.java
@@ -3,8 +3,23 @@ package com.github.technus.tectech.mechanics.elementalMatter.core;
/**
* Created by danie_000 on 19.11.2016.
*/
-public final class EMException extends Exception {
+public final class EMException extends RuntimeException {
public EMException(String message) {
super(message);
}
+
+ public EMException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public EMException(Throwable cause) {
+ super(cause);
+ }
+
+ public EMException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
+ super(message, cause, enableSuppression, writableStackTrace);
+ }
+
+ public EMException() {
+ }
}
diff --git a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/commands/EMGive.java b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/commands/EMGive.java
index 64e9bcea1e..af4caf854b 100644
--- a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/commands/EMGive.java
+++ b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/commands/EMGive.java
@@ -5,9 +5,8 @@ import com.github.technus.tectech.mechanics.elementalMatter.core.maps.EMInstance
import com.github.technus.tectech.mechanics.elementalMatter.core.maps.EMDefinitionStackMap;
import com.github.technus.tectech.mechanics.elementalMatter.core.stacks.EMDefinitionStack;
import com.github.technus.tectech.mechanics.elementalMatter.core.stacks.EMInstanceStack;
-import com.github.technus.tectech.mechanics.elementalMatter.core.templates.EMComplex;
-import com.github.technus.tectech.mechanics.elementalMatter.core.templates.EMPrimitive;
-import com.github.technus.tectech.mechanics.elementalMatter.core.templates.IEMDefinition;
+import com.github.technus.tectech.mechanics.elementalMatter.core.definitions.EMPrimitiveTemplate;
+import com.github.technus.tectech.mechanics.elementalMatter.core.definitions.IEMDefinition;
import com.github.technus.tectech.thing.item.DebugElementalInstanceContainer_EM;
import net.minecraft.command.ICommand;
import net.minecraft.command.ICommandSender;
@@ -77,11 +76,11 @@ public class EMGive implements ICommand {
try{
int id=Integer.parseInt(args.get(0));
args.remove(0);
- IEMDefinition primitive = EMPrimitive.getBindsPrimitive().get(id);
+ IEMDefinition primitive = IEMDefinition.getBindsPrimitive().get(id);
return new EMDefinitionStack(primitive,amount);
}catch (NumberFormatException e){
byte clazz = (byte) args.remove(0).charAt(0);
- Method constructor = EMComplex.getBindsComplex().get(clazz);
+ Method constructor = IEMDefinition.getBindsComplex().get(clazz);
EMDefinitionStackMap stacks =new EMDefinitionStackMap();
while(args.size()>0){
@@ -129,12 +128,12 @@ public class EMGive implements ICommand {
private List<String> completionsForClassOrID(){
ArrayList<String> strings=new ArrayList<>(8);
- Map<Byte,Method> binds= EMComplex.getBindsComplex();
+ Map<Byte,Method> binds= IEMDefinition.getBindsComplex();
for (Map.Entry<Byte,Method> e:binds.entrySet()) {
strings.add(String.valueOf((char)e.getKey().byteValue()));
}
- Map<Integer, EMPrimitive> bindsBO = EMPrimitive.getBindsPrimitive();
- for (Map.Entry<Integer, EMPrimitive> e:bindsBO.entrySet()) {
+ Map<Integer, EMPrimitiveTemplate> bindsBO = IEMDefinition.getBindsPrimitive();
+ for (Map.Entry<Integer, EMPrimitiveTemplate> e:bindsBO.entrySet()) {
strings.add(String.valueOf(e.getKey().byteValue()));
}
return strings;
diff --git a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/commands/EMList.java b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/commands/EMList.java
index 395592036f..13531dbf85 100644
--- a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/commands/EMList.java
+++ b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/commands/EMList.java
@@ -1,7 +1,7 @@
package com.github.technus.tectech.mechanics.elementalMatter.core.commands;
-import com.github.technus.tectech.mechanics.elementalMatter.core.templates.EMComplex;
-import com.github.technus.tectech.mechanics.elementalMatter.core.templates.EMPrimitive;
+import com.github.technus.tectech.mechanics.elementalMatter.core.definitions.EMPrimitiveTemplate;
+import com.github.technus.tectech.mechanics.elementalMatter.core.definitions.IEMDefinition;
import net.minecraft.command.ICommand;
import net.minecraft.command.ICommandSender;
import net.minecraft.util.ChatComponentText;
@@ -27,15 +27,15 @@ public class EMList implements ICommand {
if (!sender.getEntityWorld().isRemote) {
if(args.length == 0) {
sender.addChatMessage(new ChatComponentText(" Available Classes: tag - name"));
- Map<Byte,Method> binds= EMComplex.getBindsComplex();
+ Map<Byte,Method> binds= IEMDefinition.getBindsComplex();
for (Map.Entry<Byte,Method> e:binds.entrySet()) {
sender.addChatMessage(new ChatComponentText((char) e.getKey().byteValue() +" - "+e.getValue().getReturnType().getSimpleName()));
}
}else if(args.length==1){
sender.addChatMessage(new ChatComponentText(" Available Primitives: symbol - name"));
- if(args[0].equals(String.valueOf((char) EMPrimitive.nbtType))){
- Map<Integer, EMPrimitive> bindsBO = EMPrimitive.getBindsPrimitive();
- for (Map.Entry<Integer, EMPrimitive> e:bindsBO.entrySet()) {
+ if(args[0].equals(String.valueOf((char) EMPrimitiveTemplate.nbtType))){
+ Map<Integer, EMPrimitiveTemplate> bindsBO = IEMDefinition.getBindsPrimitive();
+ for (Map.Entry<Integer, EMPrimitiveTemplate> e:bindsBO.entrySet()) {
sender.addChatMessage(new ChatComponentText(e.getKey() + " - "+e.getValue().getLocalizedName()));
}
}else{
@@ -65,7 +65,7 @@ public class EMList implements ICommand {
@Override
public List<String> addTabCompletionOptions(ICommandSender sender, String[] args) {
if(args.length==0){
- Map<Byte,Method> binds= EMComplex.getBindsComplex();
+ Map<Byte,Method> binds= IEMDefinition.getBindsComplex();
ArrayList<String> strings=new ArrayList<>(binds.size());
for (Map.Entry<Byte,Method> e:binds.entrySet()) {
strings.add(String.valueOf((char)e.getKey().byteValue())+' '+e.getValue().getReturnType().getSimpleName());
diff --git a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/decay/EMDecay.java b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/decay/EMDecay.java
index bed49a5040..a6bd623414 100644
--- a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/decay/EMDecay.java
+++ b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/decay/EMDecay.java
@@ -4,7 +4,7 @@ import com.github.technus.tectech.mechanics.elementalMatter.core.maps.EMConstant
import com.github.technus.tectech.mechanics.elementalMatter.core.maps.EMInstanceStackMap;
import com.github.technus.tectech.mechanics.elementalMatter.core.stacks.EMDefinitionStack;
import com.github.technus.tectech.mechanics.elementalMatter.core.stacks.EMInstanceStack;
-import com.github.technus.tectech.mechanics.elementalMatter.core.templates.IEMDefinition;
+import com.github.technus.tectech.mechanics.elementalMatter.core.definitions.IEMDefinition;
import static com.github.technus.tectech.util.DoubleCount.mul;
diff --git a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/definitions/EMComplexTemplate.java b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/definitions/EMComplexTemplate.java
new file mode 100644
index 0000000000..94a50ce322
--- /dev/null
+++ b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/definitions/EMComplexTemplate.java
@@ -0,0 +1,73 @@
+package com.github.technus.tectech.mechanics.elementalMatter.core.definitions;
+
+import com.github.technus.tectech.mechanics.elementalMatter.core.stacks.EMDefinitionStack;
+import com.github.technus.tectech.mechanics.elementalMatter.core.stacks.IEMStack;
+import net.minecraft.nbt.NBTTagCompound;
+
+/**
+ * Created by danie_000 on 23.01.2017.
+ */
+public abstract class EMComplexTemplate implements IEMDefinition {
+ /**
+ * Just empty array?
+ */
+ public static final IEMDefinition[] nothing = new EMPrimitiveTemplate[0];
+
+ @Override
+ public final EMComplexTemplate clone() {
+ return this;//IMMUTABLE
+ }
+
+ @Override
+ public int compareTo(IEMDefinition o) {
+ int classCompare = compareClassID(o);
+ if (classCompare != 0) {
+ return classCompare;
+ }
+ //that allows neat check if the same thing and
+ //top hierarchy amount can be used to store amount info
+ return getSubParticles().compareWithAmountsInternal(o.getSubParticles());
+ }
+
+ @Override
+ public final EMDefinitionStack getStackForm(double amount) {
+ return new EMDefinitionStack(this, amount);
+ }
+
+ @Override
+ public final boolean equals(Object obj) {
+ if(this==obj) {
+ return true;
+ }
+ if (obj instanceof IEMDefinition) {
+ return compareTo((IEMDefinition) obj) == 0;
+ }
+ if (obj instanceof IEMStack) {
+ return compareTo(((IEMStack) obj).getDefinition()) == 0;
+ }
+ return false;
+ }
+
+ @Override
+ public int hashCode() {//Internal amounts should be also hashed
+ int hash = -(getSubParticles().size() << 4);
+ for (EMDefinitionStack stack : getSubParticles().valuesToArray()) {
+ int amount=(int) stack.getAmount();
+ hash += ((amount & 0x1) == 0 ? -amount : amount) + stack.getDefinition().hashCode();
+ }
+ return hash;
+ }
+
+ @Override
+ public String toString() {
+ return getLocalizedName()+ '\n' + getSymbol();
+ }
+
+ public NBTTagCompound toNBT() {
+ NBTTagCompound nbtTagCompound = getSubParticles().toNBT();
+ nbtTagCompound.setInteger(EMDefinitionsRegistry.getIndirectTagName(), getIndirectTagValue());
+ return nbtTagCompound;
+ }
+
+ protected abstract int getIndirectTagValue();
+}
diff --git a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/definitions/EMDefinitionsRegistry.java b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/definitions/EMDefinitionsRegistry.java
new file mode 100644
index 0000000000..c0f9df32f2
--- /dev/null
+++ b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/definitions/EMDefinitionsRegistry.java
@@ -0,0 +1,110 @@
+package com.github.technus.tectech.mechanics.elementalMatter.core.definitions;
+
+import com.github.technus.tectech.mechanics.elementalMatter.core.EMException;
+import net.minecraft.nbt.NBTTagCompound;
+
+import java.util.*;
+import java.util.function.Function;
+
+import static com.github.technus.tectech.loader.TecTechConfig.DEBUG_MODE;
+import static com.github.technus.tectech.mechanics.elementalMatter.definitions.primitive.EMPrimitiveDefinition.nbtE__;
+import static com.github.technus.tectech.mechanics.elementalMatter.definitions.primitive.EMPrimitiveDefinition.null__;
+
+public class EMDefinitionsRegistry {
+ private static final NavigableSet<IEMDefinition> STACKS_REGISTERED = new TreeSet<>();
+ private static final Map<Integer, IEMDefinition> DIRECT_BINDS = new HashMap<>();
+ private static final Map<Integer, Function<NBTTagCompound, ? extends IEMDefinition>> CLASS_BINDS = new HashMap<>();//creator methods in subclasses
+ private static final Map<Integer, Class<? extends IEMDefinition>> CLASSES = new HashMap<>();
+ private static final Map<Class<? extends IEMDefinition>, Integer> CLASS_TYPES = new HashMap<>();
+ private static final String INDIRECT_TAG = "t";
+ private static final String DIRECT_TAG = "c";
+
+ private EMDefinitionsRegistry() {
+ }
+
+ static {
+ CLASS_BINDS.put(0, EMDefinitionsRegistry::getDefinitionDirect);
+ CLASS_BINDS.put((int) 'p', EMDefinitionsRegistry::getDefinitionDirect);
+ }
+
+ private static IEMDefinition getDefinitionDirect(NBTTagCompound nbt) {
+ return DIRECT_BINDS.get(nbt.getInteger(getDirectTagName()));
+ }
+
+ public static IEMDefinition fromNBT(NBTTagCompound nbt) {
+ IEMDefinition apply;
+ try {
+ apply = CLASS_BINDS.get(nbt.getInteger(getIndirectTagName())).apply(nbt);
+ } catch (Exception e) {
+ EMException emException = new EMException("Failed to create from: " + nbt.toString(), e);
+ if (DEBUG_MODE) {
+ emException.printStackTrace();
+ return nbtE__;
+ } else {
+ throw emException;
+ }
+ }
+ if (!DEBUG_MODE) {
+ if (apply == nbtE__) {
+ throw new EMException("Deserialized to NBT ERROR!");
+ } else if (apply == null__ || apply == null) {
+ throw new EMException("Deserialized to NULL POINTER!");
+ }
+ }
+ if (apply == null) {
+ return null__;
+ }
+ return apply;
+ }
+
+ public static <T extends IEMDefinition> void registerDefinitionClass(int shortcutNBT, Function<NBTTagCompound, T> creator, Class<T> clazz, int classID) {
+ if (CLASS_BINDS.put(shortcutNBT, creator) != null) {
+ EMException e = new EMException("Duplicate NBT shortcut! " + shortcutNBT + " used for NBT based creation");
+ if (DEBUG_MODE) {
+ e.printStackTrace();
+ } else {
+ throw e;
+ }
+ }
+ if (CLASSES.put(classID, clazz) != null) {
+ EMException e = new EMException("Duplicate Class ID! " + classID + " used for class comparison");
+ if (DEBUG_MODE) {
+ e.printStackTrace();
+ } else {
+ throw e;
+ }
+ }
+ CLASS_TYPES.put(clazz, classID);
+ }
+
+ public static void registerDirectDefinition(IEMDefinition definition, int id) {
+ IEMDefinition old = DIRECT_BINDS.put(id, definition);
+ if (old != null) {
+ EMException e = new EMException("Duplicate primitive EM ID: " + id +
+ " for " + definition.getLocalizedName() +
+ " and " + old.getLocalizedName());
+ if (DEBUG_MODE) {
+ e.printStackTrace();
+ } else {
+ throw e;
+ }
+ }
+ }
+
+ public static NavigableSet<IEMDefinition> getStacksRegisteredForDisplay() {
+ return STACKS_REGISTERED;
+ }
+
+ public static void registerForDisplay(IEMDefinition definition){
+ STACKS_REGISTERED.add(definition);
+ STACKS_REGISTERED.add(definition.getAnti());
+ }
+
+ public static String getIndirectTagName() {
+ return INDIRECT_TAG;
+ }
+
+ public static String getDirectTagName() {
+ return DIRECT_TAG;
+ }
+}
diff --git a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/templates/EMPrimitive.java b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/definitions/EMPrimitiveTemplate.java
index 587affd0f1..f3ce34dd1d 100644
--- a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/templates/EMPrimitive.java
+++ b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/definitions/EMPrimitiveTemplate.java
@@ -1,37 +1,22 @@
-package com.github.technus.tectech.mechanics.elementalMatter.core.templates;
+package com.github.technus.tectech.mechanics.elementalMatter.core.definitions;
-import com.github.technus.tectech.TecTech;
import com.github.technus.tectech.mechanics.elementalMatter.core.decay.EMDecay;
import com.github.technus.tectech.mechanics.elementalMatter.core.maps.EMConstantStackMap;
-import com.github.technus.tectech.mechanics.elementalMatter.core.EMException;
import com.github.technus.tectech.mechanics.elementalMatter.core.transformations.EMFluidDequantizationInfo;
import com.github.technus.tectech.mechanics.elementalMatter.core.transformations.EMItemDequantizationInfo;
import com.github.technus.tectech.mechanics.elementalMatter.core.transformations.EMOredictDequantizationInfo;
-import net.minecraft.client.Minecraft;
-import net.minecraft.crash.CrashReport;
import net.minecraft.nbt.NBTTagCompound;
-import java.util.*;
+import java.util.ArrayList;
-import static com.github.technus.tectech.util.Util.areBitsSet;
-import static com.github.technus.tectech.loader.TecTechConfig.DEBUG_MODE;
-import static com.github.technus.tectech.mechanics.elementalMatter.definitions.primitive.EMPrimitiveDefinition.null__;
-import static com.github.technus.tectech.thing.item.DebugElementalInstanceContainer_EM.STACKS_REGISTERED;
import static com.github.technus.tectech.thing.metaTileEntity.multi.GT_MetaTileEntity_EM_scanner.*;
+import static com.github.technus.tectech.util.Util.areBitsSet;
/**
* Created by danie_000 on 22.10.2016.
- * EXTEND THIS TO ADD NEW PRIMITIVES, WATCH OUT FOR ID'S!!! (-1 to 32 can be assumed as used)
+ * EXTEND THIS TO ADD NEW PRIMITIVES, WATCH OUT FOR ID'S!!!
*/
-public abstract class EMPrimitive extends EMComplex {
- public static final byte nbtType = (byte) 'p';
-
- private static final Map<Integer, EMPrimitive> bindsBO = new HashMap<>();
-
- public static Map<Integer, EMPrimitive> getBindsPrimitive() {
- return bindsBO;
- }
-
+public abstract class EMPrimitiveTemplate extends EMComplexTemplate {
private final String name;
private final String symbol;
//float-mass in eV/c^2
@@ -43,8 +28,8 @@ public abstract class EMPrimitive extends EMComplex {
//-1/-2/-3 anti matter generations, +1/+2/+3 matter generations, 0 self anti
private final byte type;
- private EMPrimitive anti;//IMMUTABLE
- private EMDecay[] elementalDecays;
+ private EMPrimitiveTemplate anti;//IMMUTABLE
+ private EMDecay[] elementalDecays;
private byte naturalDecayInstant;
private byte energeticDecayInstant;
private double rawLifeTime;
@@ -55,7 +40,7 @@ public abstract class EMPrimitive extends EMComplex {
// _ at end - anti particle
// __ at end - self is antiparticle
- protected EMPrimitive(String name, String symbol, int type, double mass, int charge, int color, int ID) {
+ protected EMPrimitiveTemplate(String name, String symbol, int type, double mass, int charge, int color, int ID) {
this.name = name;
this.symbol = symbol;
this.type = (byte) type;
@@ -63,19 +48,17 @@ public abstract class EMPrimitive extends EMComplex {
this.charge = charge;
this.color = (byte) color;
this.ID = ID;
- if (bindsBO.put(ID, this) != null) {
- Minecraft.getMinecraft().crashed(new CrashReport("Primitive definition", new EMException("Duplicate ID")));
- }
- STACKS_REGISTERED.add(this);
+ EMDefinitionsRegistry.registerDirectDefinition(this,ID);
}
//
- protected void init(EMPrimitive antiParticle, double rawLifeTime, int naturalInstant, int energeticInstant, EMDecay... elementalDecaysArray) {
+ protected void init(EMPrimitiveTemplate antiParticle, double rawLifeTime, int naturalInstant, int energeticInstant, EMDecay... elementalDecaysArray) {
anti = antiParticle;
this.rawLifeTime = rawLifeTime;
naturalDecayInstant = (byte) naturalInstant;
energeticDecayInstant = (byte) energeticInstant;
elementalDecays =elementalDecaysArray;
+ EMDefinitionsRegistry.registerForDisplay(this);
}
@Override
@@ -189,26 +172,20 @@ public abstract class EMPrimitive extends EMComplex {
}
@Override
- public byte getType() {
+ public byte getMatterType() {
return type;
}
@Override
public final NBTTagCompound toNBT() {
NBTTagCompound nbt = new NBTTagCompound();
- nbt.setByte("t", nbtType);
- nbt.setInteger("c", getID());
+ nbt.setInteger(EMDefinitionsRegistry.getDirectTagName(), ID);
return nbt;
}
- public static EMPrimitive fromNBT(NBTTagCompound content) {
- EMPrimitive primitive = bindsBO.get(content.getInteger("c"));
- return primitive == null ? null__ : primitive;
- }
-
@Override
public final byte getClassType() {
- return -128;
+ return getClassTypeStatic();
}
public static byte getClassTypeStatic(){
@@ -225,7 +202,7 @@ public abstract class EMPrimitive extends EMComplex {
@Override
public void addScanResults(ArrayList<String> lines, int capabilities, long energyLevel) {
if(areBitsSet(SCAN_GET_CLASS_TYPE, capabilities)) {
- lines.add("CLASS = " + nbtType + ' ' + getClassType());
+ lines.add("CLASS = " + EMDefinitionsRegistry.getDirectTagName() + ' ' + getClassType());
}
if(areBitsSet(SCAN_GET_NOMENCLATURE|SCAN_GET_CHARGE|SCAN_GET_MASS|SCAN_GET_TIMESPAN_INFO, capabilities)) {
lines.add("NAME = "+ getLocalizedName());
@@ -246,38 +223,21 @@ public abstract class EMPrimitive extends EMComplex {
}
}
- public static void run() {
- try {
- EMComplex.addCreatorFromNBT(nbtType, EMPrimitive.class.getMethod("fromNBT", NBTTagCompound.class),(byte)-128);
- } catch (Exception e) {
- if (DEBUG_MODE) {
- e.printStackTrace();
- }
- }
- if(DEBUG_MODE) {
- TecTech.LOGGER.info("Registered Elemental Matter Class: Primitive " + nbtType + ' ' + -128);
- }
- }
-
@Override
public final int compareTo(IEMDefinition o) {
if (getClassType() == o.getClassType()) {
- int oID = ((EMPrimitive) o).getID();
- return Integer.compare(getID(), oID);
+ int oID = ((EMPrimitiveTemplate) o).ID;
+ return Integer.compare(ID, oID);
}
return compareClassID(o);
}
@Override
public final int hashCode() {
- return getID();
+ return ID;
}
public String getName() {
return name;
}
-
- public int getID() {
- return ID;
- }
} \ No newline at end of file
diff --git a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/templates/IEMDefinition.java b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/definitions/IEMDefinition.java
index 7ae6d0395c..06bfc61737 100644
--- a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/templates/IEMDefinition.java
+++ b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/definitions/IEMDefinition.java
@@ -1,4 +1,4 @@
-package com.github.technus.tectech.mechanics.elementalMatter.core.templates;
+package com.github.technus.tectech.mechanics.elementalMatter.core.definitions;
import com.github.technus.tectech.mechanics.elementalMatter.core.decay.EMDecay;
import com.github.technus.tectech.mechanics.elementalMatter.core.maps.EMConstantStackMap;
@@ -14,10 +14,11 @@ import java.util.ArrayList;
* Created by danie_000 on 11.11.2016.
*/
public interface IEMDefinition extends Comparable<IEMDefinition>,Cloneable {//IMMUTABLE
- double STABLE_RAW_LIFE_TIME =1.5e36D;
- double NO_DECAY_RAW_LIFE_TIME=-1D;
- long DEFAULT_ENERGY_LEVEL=0;
- double DEFAULT_ENERGY_REQUIREMENT=25000D;//legit cuz normal atoms should only emit a gamma if they don't have defined energy levels
+ double STABLE_RAW_LIFE_TIME =1.5e36D;
+ double NO_DECAY_RAW_LIFE_TIME =-1D;
+ long DEFAULT_ENERGY_LEVEL =0;
+ double DEFAULT_ENERGY_REQUIREMENT =25000D;//legit cuz normal atoms should only emit a gamma if they don't have defined energy levels
+ //add text based creators for recipe formula input?
//Nomenclature
String getLocalizedName();
@@ -30,7 +31,7 @@ public interface IEMDefinition extends Comparable<IEMDefinition>,Cloneable {//IM
void addScanResults(ArrayList<String> lines, int capabilities, long energyLevel);
- byte getType();
+ byte getMatterType();
byte getClassType();//bigger number means bigger things usually, but it is just used to differentiate between classes of iED
diff --git a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/maps/EMConstantStackMap.java b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/maps/EMConstantStackMap.java
index d9297436a0..e6cfa7d03e 100644
--- a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/maps/EMConstantStackMap.java
+++ b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/maps/EMConstantStackMap.java
@@ -2,7 +2,7 @@ package com.github.technus.tectech.mechanics.elementalMatter.core.maps;
import com.github.technus.tectech.mechanics.elementalMatter.core.stacks.EMDefinitionStack;
import com.github.technus.tectech.mechanics.elementalMatter.core.EMException;
-import com.github.technus.tectech.mechanics.elementalMatter.core.templates.IEMDefinition;
+import com.github.technus.tectech.mechanics.elementalMatter.core.definitions.IEMDefinition;
import net.minecraft.nbt.NBTTagCompound;
import java.util.Collections;
diff --git a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/maps/EMDefinitionStackMap.java b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/maps/EMDefinitionStackMap.java
index 45ce50d5c7..78bb8d740a 100644
--- a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/maps/EMDefinitionStackMap.java
+++ b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/maps/EMDefinitionStackMap.java
@@ -2,7 +2,7 @@ package com.github.technus.tectech.mechanics.elementalMatter.core.maps;
import com.github.technus.tectech.mechanics.elementalMatter.core.stacks.EMDefinitionStack;
import com.github.technus.tectech.mechanics.elementalMatter.core.EMException;
-import com.github.technus.tectech.mechanics.elementalMatter.core.templates.IEMDefinition;
+import com.github.technus.tectech.mechanics.elementalMatter.core.definitions.IEMDefinition;
import net.minecraft.nbt.NBTTagCompound;
import java.util.NavigableMap;
diff --git a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/maps/EMInstanceStackMap.java b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/maps/EMInstanceStackMap.java
index c15142787f..69dc53f83d 100644
--- a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/maps/EMInstanceStackMap.java
+++ b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/maps/EMInstanceStackMap.java
@@ -4,7 +4,7 @@ import com.github.technus.tectech.mechanics.elementalMatter.core.decay.EMDecayRe
import com.github.technus.tectech.mechanics.elementalMatter.core.stacks.EMDefinitionStack;
import com.github.technus.tectech.mechanics.elementalMatter.core.stacks.EMInstanceStack;
import com.github.technus.tectech.mechanics.elementalMatter.core.EMException;
-import com.github.technus.tectech.mechanics.elementalMatter.core.templates.IEMDefinition;
+import com.github.technus.tectech.mechanics.elementalMatter.core.definitions.IEMDefinition;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.EnumChatFormatting;
diff --git a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/maps/EMStackMap.java b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/maps/EMStackMap.java
index 4c798499b5..795ac3d3bf 100644
--- a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/maps/EMStackMap.java
+++ b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/maps/EMStackMap.java
@@ -1,7 +1,7 @@
package com.github.technus.tectech.mechanics.elementalMatter.core.maps;
import com.github.technus.tectech.mechanics.elementalMatter.core.stacks.IEMStack;
-import com.github.technus.tectech.mechanics.elementalMatter.core.templates.IEMDefinition;
+import com.github.technus.tectech.mechanics.elementalMatter.core.definitions.IEMDefinition;
import java.util.NavigableMap;
import java.util.TreeMap;
diff --git a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/maps/IEMMapRead.java b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/maps/IEMMapRead.java
index 392d06f5cf..1322566914 100644
--- a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/maps/IEMMapRead.java
+++ b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/maps/IEMMapRead.java
@@ -2,7 +2,7 @@ package com.github.technus.tectech.mechanics.elementalMatter.core.maps;
import com.github.technus.tectech.TecTech;
import com.github.technus.tectech.mechanics.elementalMatter.core.stacks.IEMStack;
-import com.github.technus.tectech.mechanics.elementalMatter.core.templates.IEMDefinition;
+import com.github.technus.tectech.mechanics.elementalMatter.core.definitions.IEMDefinition;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.EnumChatFormatting;
@@ -136,8 +136,8 @@ public interface IEMMapRead<T extends IEMStack> extends Comparable<IEMMapRead<?>
NBTTagCompound nbt = new NBTTagCompound();
nbt.setInteger("i", size());
int i = 0;
- for (T stack : values()) {
- nbt.setTag(Integer.toString(i++), stack.toNBT());
+ for (Map.Entry<IEMDefinition, T> entry : entrySet()) {
+ nbt.setTag(Integer.toString(i++), entry.getValue().toNBT());
}
return nbt;
}
@@ -161,6 +161,39 @@ public interface IEMMapRead<T extends IEMStack> extends Comparable<IEMMapRead<?>
return 0;
}
+ /**
+ * use only for nested operations!
+ * @param o
+ * @return
+ */
+ default int compareWithAmountsInternal(IEMMapRead<? extends IEMStack> o) {
+ if (o == null) {
+ return 1;
+ }
+
+ int lenDiff = size() - o.size();
+ if (lenDiff != 0) {
+ return lenDiff;
+ }
+
+ Iterator<Map.Entry<IEMDefinition, T>> iterator = entrySet().iterator();
+ Iterator<? extends Map.Entry<IEMDefinition, ? extends IEMStack>> iteratorO = o.entrySet().iterator();
+
+ while (iterator.hasNext()) {
+ T first = iterator.next().getValue();
+ IEMStack second = iteratorO.next().getValue();
+ int result = first.compareTo(second);
+ if (result != 0) {
+ return result;
+ }
+ result=Double.compare(first.getAmount(),second.getAmount());
+ if (result != 0) {
+ return result;
+ }
+ }
+ return 0;
+ }
+
default double getMass(){
double mass=0;
for (Map.Entry<IEMDefinition, T> entry : entrySet()) {
diff --git a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/maps/IEMMapWrite.java b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/maps/IEMMapWrite.java
index cc22267474..f13e82fb26 100644
--- a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/maps/IEMMapWrite.java
+++ b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/maps/IEMMapWrite.java
@@ -1,7 +1,7 @@
package com.github.technus.tectech.mechanics.elementalMatter.core.maps;
import com.github.technus.tectech.mechanics.elementalMatter.core.stacks.IEMStack;
-import com.github.technus.tectech.mechanics.elementalMatter.core.templates.IEMDefinition;
+import com.github.technus.tectech.mechanics.elementalMatter.core.definitions.IEMDefinition;
import com.github.technus.tectech.mechanics.elementalMatter.core.transformations.EMTransformationInfo;
import java.util.Map;
diff --git a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/maps/IEMMapWriteExact.java b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/maps/IEMMapWriteExact.java
index 7b8853a2f4..167ec8451d 100644
--- a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/maps/IEMMapWriteExact.java
+++ b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/maps/IEMMapWriteExact.java
@@ -1,7 +1,7 @@
package com.github.technus.tectech.mechanics.elementalMatter.core.maps;
import com.github.technus.tectech.mechanics.elementalMatter.core.stacks.IEMStack;
-import com.github.technus.tectech.mechanics.elementalMatter.core.templates.IEMDefinition;
+import com.github.technus.tectech.mechanics.elementalMatter.core.definitions.IEMDefinition;
import java.util.Map;
diff --git a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/stacks/EMDefinitionStack.java b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/stacks/EMDefinitionStack.java
index fe0c73e795..f868dbe0ad 100644
--- a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/stacks/EMDefinitionStack.java
+++ b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/stacks/EMDefinitionStack.java
@@ -1,7 +1,7 @@
package com.github.technus.tectech.mechanics.elementalMatter.core.stacks;
-import com.github.technus.tectech.mechanics.elementalMatter.core.templates.EMComplex;
-import com.github.technus.tectech.mechanics.elementalMatter.core.templates.IEMDefinition;
+import com.github.technus.tectech.mechanics.elementalMatter.core.definitions.EMDefinitionsRegistry;
+import com.github.technus.tectech.mechanics.elementalMatter.core.definitions.IEMDefinition;
import net.minecraft.nbt.NBTTagCompound;
import static com.github.technus.tectech.mechanics.elementalMatter.definitions.primitive.EMPrimitiveDefinition.null__;
@@ -50,7 +50,7 @@ public final class EMDefinitionStack implements IEMStack {
public static EMDefinitionStack fromNBT(NBTTagCompound nbt) {
return new EMDefinitionStack(
- EMComplex.fromNBT(nbt.getCompoundTag("d")),
+ EMDefinitionsRegistry.fromNBT(nbt.getCompoundTag("d")),
nbt.getLong("q")+nbt.getDouble("Q"));
}
diff --git a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/stacks/EMInstanceStack.java b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/stacks/EMInstanceStack.java
index b73bd21f02..6347cd2144 100644
--- a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/stacks/EMInstanceStack.java
+++ b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/stacks/EMInstanceStack.java
@@ -1,12 +1,12 @@
package com.github.technus.tectech.mechanics.elementalMatter.core.stacks;
import com.github.technus.tectech.TecTech;
+import com.github.technus.tectech.mechanics.elementalMatter.core.definitions.EMDefinitionsRegistry;
import com.github.technus.tectech.mechanics.elementalMatter.core.decay.EMDecay;
import com.github.technus.tectech.mechanics.elementalMatter.core.decay.EMDecayResult;
import com.github.technus.tectech.mechanics.elementalMatter.core.maps.EMConstantStackMap;
import com.github.technus.tectech.mechanics.elementalMatter.core.maps.EMInstanceStackMap;
-import com.github.technus.tectech.mechanics.elementalMatter.core.templates.EMComplex;
-import com.github.technus.tectech.mechanics.elementalMatter.core.templates.IEMDefinition;
+import com.github.technus.tectech.mechanics.elementalMatter.core.definitions.IEMDefinition;
import com.github.technus.tectech.util.Util;
import net.minecraft.client.Minecraft;
import net.minecraft.crash.CrashReport;
@@ -558,9 +558,8 @@ public final class EMInstanceStack implements IEMStack {
}
public static EMInstanceStack fromNBT(NBTTagCompound nbt) {
- NBTTagCompound definition = nbt.getCompoundTag("d");
EMInstanceStack instance = new EMInstanceStack(
- EMComplex.fromNBT(definition),
+ EMDefinitionsRegistry.fromNBT(nbt.getCompoundTag("d")),
nbt.getLong("q") + nbt.getDouble("Q"),
nbt.getFloat("m") + nbt.getDouble("M"),
nbt.getLong("a") + nbt.getDouble("A"),
diff --git a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/stacks/IEMStack.java b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/stacks/IEMStack.java
index 94c76634d9..5672b31c04 100644
--- a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/stacks/IEMStack.java
+++ b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/stacks/IEMStack.java
@@ -1,6 +1,6 @@
package com.github.technus.tectech.mechanics.elementalMatter.core.stacks;
-import com.github.technus.tectech.mechanics.elementalMatter.core.templates.IEMDefinition;
+import com.github.technus.tectech.mechanics.elementalMatter.core.definitions.IEMDefinition;
import net.minecraft.nbt.NBTTagCompound;
/**
diff --git a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/templates/EMComplex.java b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/templates/EMComplex.java
deleted file mode 100644
index 7fc074bded..0000000000
--- a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/templates/EMComplex.java
+++ /dev/null
@@ -1,135 +0,0 @@
-package com.github.technus.tectech.mechanics.elementalMatter.core.templates;
-
-import com.github.technus.tectech.mechanics.elementalMatter.core.stacks.EMDefinitionStack;
-import com.github.technus.tectech.mechanics.elementalMatter.core.stacks.IEMStack;
-import net.minecraft.nbt.NBTTagCompound;
-
-import java.lang.reflect.Method;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-
-import static com.github.technus.tectech.loader.TecTechConfig.DEBUG_MODE;
-import static com.github.technus.tectech.mechanics.elementalMatter.definitions.primitive.EMPrimitiveDefinition.nbtE__;
-
-/**
- * Created by danie_000 on 23.01.2017.
- */
-public abstract class EMComplex implements IEMDefinition {
- //Nothing array
- public static final IEMDefinition[] nothing = new EMPrimitive[0];
-
- //add text based creators for recipe formula input?
- private static final Map<Byte, Method> nbtCreationBind = new HashMap<>();//creator methods in subclasses
- private static final HashSet<Byte> classSet = new HashSet<>();
-
- protected static void addCreatorFromNBT(byte shortcutNBT, Method constructorFromNBT,byte classID) {
- if(nbtCreationBind.put(shortcutNBT, constructorFromNBT)!=null) {
- throw new Error("Duplicate NBT shortcut! " + shortcutNBT + " used for NBT based creation");
- }
- if(!classSet.add(classID)) {
- throw new Error("Duplicate Class ID! " + classID + " used for class comparison");
- }
- }
-
- public static Map<Byte, Method> getBindsComplex(){
- return nbtCreationBind;
- }
-
- @Override
- public final EMComplex clone() {
- return this;//IMMUTABLE
- }
-
- public static IEMDefinition fromNBT(NBTTagCompound nbt) {
- try {
- return (IEMDefinition) nbtCreationBind.get(nbt.getByte("t")).invoke(null, nbt);
- } catch (Exception e) {
- if (DEBUG_MODE) {
- e.printStackTrace();
- }
- return nbtE__;
- }
- }
-
- @Override
- public int compareTo(IEMDefinition o) {
- int classCompare = compareClassID(o);
- if (classCompare != 0) {
- return classCompare;
- }
-
- //only of the internal def stacks!!!
- //that allows neat check if the same thing and
- //top hierarchy amount can be used to store amount info
- return compareInnerContentsWithAmounts(getSubParticles().valuesToArray(), o.getSubParticles().valuesToArray());
- }
-
- //use only for nested operations!
- private static int compareInnerContentsWithAmounts(EMDefinitionStack[] tc, EMDefinitionStack[] sc) {
- if (tc == null) {
- if (sc == null) {
- return 0;
- } else {
- return -1;
- }
- }
- if (sc == null) {
- return 1;
- }
-
- int lenDiff = tc.length - sc.length;
- if (lenDiff != 0) {
- return lenDiff;
- }
-
- for (int i = 0; i < tc.length; i++) {
- int cn = tc[i].getDefinition().compareTo(sc[i].getDefinition());
- if (cn != 0) {
- return cn;
- }
-
- if (tc[i].getAmount() > sc[i].getAmount()) {
- return 1;
- }
- if (tc[i].getAmount() < sc[i].getAmount()) {
- return -1;
- }
- }
- return 0;
- }
-
- @Override
- public final EMDefinitionStack getStackForm(double amount) {
- return new EMDefinitionStack(this, amount);
- }
-
- @Override
- public final boolean equals(Object obj) {
- if(this==obj) {
- return true;
- }
- if (obj instanceof IEMDefinition) {
- return compareTo((IEMDefinition) obj) == 0;
- }
- if (obj instanceof IEMStack) {
- return compareTo(((IEMStack) obj).getDefinition()) == 0;
- }
- return false;
- }
-
- @Override
- public int hashCode() {//Internal amounts should be also hashed
- int hash = -(getSubParticles().size() << 4);
- for (EMDefinitionStack stack : getSubParticles().valuesToArray()) {
- int amount=(int) stack.getAmount();
- hash += ((amount & 0x1) == 0 ? -amount : amount) + stack.getDefinition().hashCode();
- }
- return hash;
- }
-
- @Override
- public String toString() {
- return getLocalizedName()+ '\n' + getSymbol();
- }
-}
diff --git a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/transformations/EMTransformationInfo.java b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/transformations/EMTransformationInfo.java
index fca79b0b6f..d6f6731aec 100644
--- a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/transformations/EMTransformationInfo.java
+++ b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/transformations/EMTransformationInfo.java
@@ -1,7 +1,8 @@
package com.github.technus.tectech.mechanics.elementalMatter.core.transformations;
+import com.github.technus.tectech.mechanics.elementalMatter.core.definitions.EMDefinitionsRegistry;
+import com.github.technus.tectech.mechanics.elementalMatter.core.definitions.IEMDefinition;
import com.github.technus.tectech.mechanics.elementalMatter.core.stacks.IEMStack;
-import com.github.technus.tectech.mechanics.elementalMatter.core.templates.IEMDefinition;
import gregtech.api.enums.Materials;
import gregtech.api.enums.OrePrefixes;
import net.minecraft.item.ItemStack;
@@ -12,7 +13,6 @@ import net.minecraftforge.oredict.OreDictionary;
import java.util.HashMap;
import java.util.Map;
-import static com.github.technus.tectech.thing.item.DebugElementalInstanceContainer_EM.STACKS_REGISTERED;
import static java.lang.Math.pow;
/**
@@ -72,15 +72,13 @@ public class EMTransformationInfo {
public void addFluid(IEMStack em, FluidStack fluidStack){
getFluidQuantization().put(fluidStack.getFluidID(),new EMFluidQuantizationInfo(fluidStack,em));
getFluidDequantization().put(em.getDefinition(),new EMFluidDequantizationInfo(em,fluidStack));
- STACKS_REGISTERED.add(em.getDefinition());
- STACKS_REGISTERED.add(em.getDefinition().getAnti());
+ EMDefinitionsRegistry.registerForDisplay(em.getDefinition());
}
public void addFluid(IEMStack em, Fluid fluid, int fluidAmount){
getFluidQuantization().put(fluid.getID(),new EMFluidQuantizationInfo(fluid,fluidAmount,em));
getFluidDequantization().put(em.getDefinition(),new EMFluidDequantizationInfo(em,fluid,fluidAmount));
- STACKS_REGISTERED.add(em.getDefinition());
- STACKS_REGISTERED.add(em.getDefinition().getAnti());
+ EMDefinitionsRegistry.registerForDisplay(em.getDefinition());
}
private void addItemQuantization(EMItemQuantizationInfo aIQI){
@@ -90,36 +88,31 @@ public class EMTransformationInfo {
public void addItem(IEMStack em, ItemStack itemStack, boolean skipNBT){
addItemQuantization(new EMItemQuantizationInfo(itemStack,skipNBT,em));
getItemDequantization().put(em.getDefinition(),new EMItemDequantizationInfo(em,itemStack));
- STACKS_REGISTERED.add(em.getDefinition());
- STACKS_REGISTERED.add(em.getDefinition().getAnti());
+ EMDefinitionsRegistry.registerForDisplay(em.getDefinition());
}
public void addItem(IEMStack em, OrePrefixes prefix, Materials material, int amount, boolean skipNBT){
addItemQuantization(new EMItemQuantizationInfo(prefix,material,amount,skipNBT,em));
getItemDequantization().put(em.getDefinition(),new EMItemDequantizationInfo(em,prefix,material,amount));
- STACKS_REGISTERED.add(em.getDefinition());
- STACKS_REGISTERED.add(em.getDefinition().getAnti());
+ EMDefinitionsRegistry.registerForDisplay(em.getDefinition());
}
public void addOredict(IEMStack em, String name, int qty){
getOredictQuantization().put(OreDictionary.getOreID(name),new EMOredictQuantizationInfo(name,qty,em));
getOredictDequantization().put(em.getDefinition(),new EMOredictDequantizationInfo(em,name,qty));
- STACKS_REGISTERED.add(em.getDefinition());
- STACKS_REGISTERED.add(em.getDefinition().getAnti());
+ EMDefinitionsRegistry.registerForDisplay(em.getDefinition());
}
public void addOredict(IEMStack em, OrePrefixes prefix, Materials material, int qty){
getOredictQuantization().put(OreDictionary.getOreID(prefix.name() + material.mName),new EMOredictQuantizationInfo(prefix,material,qty,em));
getOredictDequantization().put(em.getDefinition(),new EMOredictDequantizationInfo(em,prefix,material,qty));
- STACKS_REGISTERED.add(em.getDefinition());
- STACKS_REGISTERED.add(em.getDefinition().getAnti());
+ EMDefinitionsRegistry.registerForDisplay(em.getDefinition());
}
public void addOredict(IEMStack em, OrePrefixes prefix, String materialName, int qty){
getOredictQuantization().put(OreDictionary.getOreID(prefix.name() + materialName),new EMOredictQuantizationInfo(prefix,materialName,qty,em));
getOredictDequantization().put(em.getDefinition(),new EMOredictDequantizationInfo(em,prefix,materialName,qty));
- STACKS_REGISTERED.add(em.getDefinition());
- STACKS_REGISTERED.add(em.getDefinition().getAnti());
+ EMDefinitionsRegistry.registerForDisplay(em.getDefinition());
}
public Map<Integer, EMFluidQuantizationInfo> getFluidQuantization() {
diff --git a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/complex/EMAtomDefinition.java b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/complex/EMAtomDefinition.java
index 77ac6c46c4..666249f408 100644
--- a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/complex/EMAtomDefinition.java
+++ b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/complex/EMAtomDefinition.java
@@ -3,13 +3,14 @@ package com.github.technus.tectech.mechanics.elementalMatter.definitions.complex
import com.github.technus.tectech.Reference;
import com.github.technus.tectech.TecTech;
import com.github.technus.tectech.compatibility.gtpp.GtppAtomLoader;
+import com.github.technus.tectech.mechanics.elementalMatter.core.EMException;
import com.github.technus.tectech.mechanics.elementalMatter.core.decay.EMDecay;
+import com.github.technus.tectech.mechanics.elementalMatter.core.definitions.EMComplexTemplate;
+import com.github.technus.tectech.mechanics.elementalMatter.core.definitions.EMDefinitionsRegistry;
+import com.github.technus.tectech.mechanics.elementalMatter.core.definitions.IEMDefinition;
import com.github.technus.tectech.mechanics.elementalMatter.core.maps.EMConstantStackMap;
import com.github.technus.tectech.mechanics.elementalMatter.core.maps.EMDefinitionStackMap;
import com.github.technus.tectech.mechanics.elementalMatter.core.stacks.EMDefinitionStack;
-import com.github.technus.tectech.mechanics.elementalMatter.core.EMException;
-import com.github.technus.tectech.mechanics.elementalMatter.core.templates.EMComplex;
-import com.github.technus.tectech.mechanics.elementalMatter.core.templates.IEMDefinition;
import com.github.technus.tectech.mechanics.elementalMatter.core.transformations.EMFluidDequantizationInfo;
import com.github.technus.tectech.mechanics.elementalMatter.core.transformations.EMItemDequantizationInfo;
import com.github.technus.tectech.mechanics.elementalMatter.core.transformations.EMOredictDequantizationInfo;
@@ -25,7 +26,6 @@ import net.minecraft.nbt.NBTTagCompound;
import java.util.*;
-import static com.github.technus.tectech.compatibility.thaumcraft.elementalMatter.definitions.EMComplexAspectDefinition.getNbtTagCompound;
import static com.github.technus.tectech.loader.TecTechConfig.DEBUG_MODE;
import static com.github.technus.tectech.mechanics.elementalMatter.core.transformations.EMTransformationInfo.AVOGADRO_CONSTANT_144;
import static com.github.technus.tectech.mechanics.elementalMatter.definitions.primitive.EMBosonDefinition.boson_Y__;
@@ -37,7 +37,7 @@ import static gregtech.api.enums.OrePrefixes.dust;
/**
* Created by danie_000 on 18.11.2016.
*/
-public final class EMAtomDefinition extends EMComplex {
+public final class EMAtomDefinition extends EMComplexTemplate {
public static final long ATOM_COMPLEXITY_LIMIT=65536L;
private static final byte BYTE_OFFSET=32;
@@ -118,10 +118,10 @@ public final class EMAtomDefinition extends EMComplex {
throw new ArithmeticException("Amount cannot be safely converted to int!");
}
mass += stack.getMass();
- if (def.getType() < 0) {
+ if (def.getMatterType() < 0) {
containsAnti = true;
}
- type = Math.max(type, Math.abs(def.getType()));
+ type = Math.max(type, Math.abs(def.getMatterType()));
if (def instanceof EMLeptonDefinition) {
cLeptons += stack.getCharge();
@@ -307,7 +307,7 @@ public final class EMAtomDefinition extends EMComplex {
}
@Override
- public byte getType() {
+ public byte getMatterType() {
return type;
}
@@ -340,7 +340,7 @@ public final class EMAtomDefinition extends EMComplex {
int element = Math.abs(this.getElement());
boolean negative = this.getElement() < 0;
try {
- if (Math.abs(getType()) != 1) {
+ if (Math.abs(getMatterType()) != 1) {
return (negative ? "~? " : "? ") + Nomenclature.NAME[element];
}
return negative ? '~' + Nomenclature.NAME[element] : Nomenclature.NAME[element];
@@ -408,7 +408,7 @@ public final class EMAtomDefinition extends EMComplex {
}
private EMDecay[] getDecayArray(ArrayList<EMDecay> decaysList, int decayMode, boolean tryAnti) {//todo?
- if (getType() == 1) {
+ if (getMatterType() == 1) {
switch (decayMode) {
case -2:
if(TecTech.RANDOM.nextBoolean() && ElectronCapture(decaysList)) {
@@ -446,7 +446,7 @@ public final class EMAtomDefinition extends EMComplex {
}
}
return EMDecay.NO_DECAY;
- }else if(getType() ==-1){
+ }else if(getMatterType() ==-1){
EMAtomDefinition anti =getAnti();
if(anti!=null) {
return anti.getDecayArray(decaysList, decayMode, false);
@@ -1264,7 +1264,7 @@ public final class EMAtomDefinition extends EMComplex {
//disembody
ArrayList<EMDefinitionStack> decaysInto = new ArrayList<>();
for (EMDefinitionStack elementalStack : elementalStacks.valuesToArray()) {
- if (elementalStack.getDefinition().getType() == 1 || elementalStack.getDefinition().getType() == -1) {
+ if (elementalStack.getDefinition().getMatterType() == 1 || elementalStack.getDefinition().getMatterType() == -1) {
//covers both quarks and antiquarks
decaysInto.add(elementalStack);
} else {
@@ -1344,8 +1344,8 @@ public final class EMAtomDefinition extends EMComplex {
}
@Override
- public NBTTagCompound toNBT() {
- return getNbtTagCompound(nbtType, elementalStacks);
+ protected int getIndirectTagValue() {
+ return nbtType;
}
public static EMAtomDefinition fromNBT(NBTTagCompound nbt) {
@@ -1465,14 +1465,14 @@ public final class EMAtomDefinition extends EMComplex {
}
try {
- EMComplex.addCreatorFromNBT(nbtType, EMAtomDefinition.class.getMethod("fromNBT", NBTTagCompound.class),(byte)64);
+ EMDefinitionsRegistry.registerDefinitionClass(nbtType, EMAtomDefinition::fromNBT,EMAtomDefinition.class,getClassTypeStatic());
} catch (Exception e) {
if (DEBUG_MODE) {
e.printStackTrace();
}
}
if(DEBUG_MODE) {
- TecTech.LOGGER.info("Registered Elemental Matter Class: Atom " + nbtType + ' ' + 64);
+ TecTech.LOGGER.info("Registered Elemental Matter Class: Atom " + nbtType + ' ' + getClassTypeStatic());
}
}
@@ -1644,7 +1644,7 @@ public final class EMAtomDefinition extends EMComplex {
@Override
public byte getClassType() {
- return 64;
+ return getClassTypeStatic();
}
public static byte getClassTypeStatic(){
diff --git a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/complex/EMHadronDefinition.java b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/complex/EMHadronDefinition.java
index 384087770f..a901f5c8fc 100644
--- a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/complex/EMHadronDefinition.java
+++ b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/complex/EMHadronDefinition.java
@@ -1,17 +1,20 @@
package com.github.technus.tectech.mechanics.elementalMatter.definitions.complex;
import com.github.technus.tectech.TecTech;
+import com.github.technus.tectech.mechanics.elementalMatter.core.EMException;
import com.github.technus.tectech.mechanics.elementalMatter.core.decay.EMDecay;
+import com.github.technus.tectech.mechanics.elementalMatter.core.definitions.EMComplexTemplate;
+import com.github.technus.tectech.mechanics.elementalMatter.core.definitions.EMDefinitionsRegistry;
+import com.github.technus.tectech.mechanics.elementalMatter.core.definitions.IEMDefinition;
import com.github.technus.tectech.mechanics.elementalMatter.core.maps.EMConstantStackMap;
import com.github.technus.tectech.mechanics.elementalMatter.core.maps.EMDefinitionStackMap;
import com.github.technus.tectech.mechanics.elementalMatter.core.stacks.EMDefinitionStack;
-import com.github.technus.tectech.mechanics.elementalMatter.core.EMException;
-import com.github.technus.tectech.mechanics.elementalMatter.core.templates.EMComplex;
-import com.github.technus.tectech.mechanics.elementalMatter.core.templates.IEMDefinition;
-import com.github.technus.tectech.mechanics.elementalMatter.core.transformations.*;
+import com.github.technus.tectech.mechanics.elementalMatter.core.transformations.EMFluidDequantizationInfo;
+import com.github.technus.tectech.mechanics.elementalMatter.core.transformations.EMItemDequantizationInfo;
+import com.github.technus.tectech.mechanics.elementalMatter.core.transformations.EMOredictDequantizationInfo;
+import com.github.technus.tectech.mechanics.elementalMatter.core.transformations.EMOredictQuantizationInfo;
import com.github.technus.tectech.mechanics.elementalMatter.definitions.primitive.EMBosonDefinition;
import com.github.technus.tectech.mechanics.elementalMatter.definitions.primitive.EMQuarkDefinition;
-import com.github.technus.tectech.thing.item.DebugElementalInstanceContainer_EM;
import com.github.technus.tectech.util.Util;
import gregtech.api.enums.Materials;
import gregtech.api.enums.OrePrefixes;
@@ -22,7 +25,6 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
-import static com.github.technus.tectech.compatibility.thaumcraft.elementalMatter.definitions.EMComplexAspectDefinition.getNbtTagCompound;
import static com.github.technus.tectech.loader.TecTechConfig.DEBUG_MODE;
import static com.github.technus.tectech.mechanics.elementalMatter.core.transformations.EMTransformationInfo.AVOGADRO_CONSTANT_144;
import static com.github.technus.tectech.mechanics.elementalMatter.core.transformations.EMTransformationInfo.TRANSFORMATION_INFO;
@@ -33,7 +35,7 @@ import static gregtech.api.enums.OrePrefixes.dust;
/**
* Created by danie_000 on 17.11.2016.
*/
-public final class EMHadronDefinition extends EMComplex {//TODO Optimize map i/o
+public final class EMHadronDefinition extends EMComplexTemplate {//TODO Optimize map i/o
private final int hash;
private static final byte nbtType = (byte) 'h';
@@ -90,8 +92,8 @@ public final class EMHadronDefinition extends EMComplex {//TODO Optimize map i/o
}
mass += quarkStack.getMass();
charge += quarkStack.getCharge();
- type = Math.max(Math.abs(quarkStack.getDefinition().getType()), type);
- if (quarkStack.getDefinition().getType() < 0) {
+ type = Math.max(Math.abs(quarkStack.getDefinition().getMatterType()), type);
+ if (quarkStack.getDefinition().getMatterType() < 0) {
containsAnti = true;
}
}
@@ -212,12 +214,12 @@ public final class EMHadronDefinition extends EMComplex {//TODO Optimize map i/o
@Override
public EMDecay[] getNaturalDecayInstant() {
EMDefinitionStack[] quarkStacks = this.quarkStacks.valuesToArray();
- if (getAmount() == 2 && quarkStacks.length == 2 && quarkStacks[0].getDefinition().getMass() == quarkStacks[1].getDefinition().getMass() && quarkStacks[0].getDefinition().getType() == -quarkStacks[1].getDefinition().getType()) {
+ if (getAmount() == 2 && quarkStacks.length == 2 && quarkStacks[0].getDefinition().getMass() == quarkStacks[1].getDefinition().getMass() && quarkStacks[0].getDefinition().getMatterType() == -quarkStacks[1].getDefinition().getMatterType()) {
return EMDecay.NO_PRODUCT;
}
ArrayList<EMDefinitionStack> decaysInto = new ArrayList<>();
for (EMDefinitionStack quarks : quarkStacks) {
- if (quarks.getDefinition().getType() == 1 || quarks.getDefinition().getType() == -1) {
+ if (quarks.getDefinition().getMatterType() == 1 || quarks.getDefinition().getMatterType() == -1) {
//covers both quarks and antiquarks
decaysInto.add(quarks);
} else {
@@ -234,7 +236,7 @@ public final class EMHadronDefinition extends EMComplex {//TODO Optimize map i/o
@Override
public EMDecay[] getEnergyInducedDecay(long energyLevel) {
EMDefinitionStack[] quarkStacks = this.quarkStacks.valuesToArray();
- if (getAmount() == 2 && quarkStacks.length == 2 && quarkStacks[0].getDefinition().getMass() == quarkStacks[1].getDefinition().getMass() && quarkStacks[0].getDefinition().getType() == -quarkStacks[1].getDefinition().getType()) {
+ if (getAmount() == 2 && quarkStacks.length == 2 && quarkStacks[0].getDefinition().getMass() == quarkStacks[1].getDefinition().getMass() && quarkStacks[0].getDefinition().getMatterType() == -quarkStacks[1].getDefinition().getMatterType()) {
return EMDecay.NO_PRODUCT;
}
return new EMDecay[]{new EMDecay(0.75D, quarkStacks), EMBosonDefinition.deadEnd}; //decay into quarks
@@ -270,7 +272,7 @@ public final class EMHadronDefinition extends EMComplex {//TODO Optimize map i/o
EMDefinitionStack[] quarkStacks = this.quarkStacks.valuesToArray();
if (getAmount() == 2 && quarkStacks.length == 2 &&
quarkStacks[0].getDefinition().getMass() == quarkStacks[1].getDefinition().getMass() &&
- quarkStacks[0].getDefinition().getType() == -quarkStacks[1].getDefinition().getType()) {
+ quarkStacks[0].getDefinition().getMatterType() == -quarkStacks[1].getDefinition().getMatterType()) {
return EMDecay.NO_PRODUCT;
} else if (getAmount() != 3) {
return new EMDecay[]{new EMDecay(0.95D, quarkStacks), EMBosonDefinition.deadEnd}; //decay into quarks
@@ -286,7 +288,7 @@ public final class EMHadronDefinition extends EMComplex {//TODO Optimize map i/o
EMQuarkDefinition lastQuark = newBaryon.remove(2);
EMDefinitionStack[] decay;
- if (Math.abs(lastQuark.getType()) > 1) {
+ if (Math.abs(lastQuark.getMatterType()) > 1) {
decay = lastQuark.getDecayArray()[1].getOutputStacks().valuesToArray();
} else {
decay = lastQuark.getDecayArray()[2].getOutputStacks().valuesToArray();
@@ -334,7 +336,7 @@ public final class EMHadronDefinition extends EMComplex {//TODO Optimize map i/o
}
@Override
- public byte getType() {
+ public byte getMatterType() {
return type;
}
@@ -385,8 +387,8 @@ public final class EMHadronDefinition extends EMComplex {//TODO Optimize map i/o
}
@Override
- public NBTTagCompound toNBT() {
- return getNbtTagCompound(nbtType, quarkStacks);
+ protected int getIndirectTagValue() {
+ return nbtType;
}
public static EMHadronDefinition fromNBT(NBTTagCompound nbt) {
@@ -412,22 +414,22 @@ public final class EMHadronDefinition extends EMComplex {//TODO Optimize map i/o
hadron_p = new EMHadronDefinition(new EMConstantStackMap(EMQuarkDefinition.quark_u.getStackForm(2), EMQuarkDefinition.quark_d.getStackForm(1)));
SYMBOL_MAP.put(hadron_p,"p");
NAME_MAP.put(hadron_p,"Proton");
- DebugElementalInstanceContainer_EM.STACKS_REGISTERED.add(hadron_p);
+ EMDefinitionsRegistry.getStacksRegisteredForDisplay().add(hadron_p);
hadron_p_ = (EMHadronDefinition) hadron_p.getAnti();
SYMBOL_MAP.put(hadron_p_,"~p");
NAME_MAP.put(hadron_p_,"Anti Proton");
- DebugElementalInstanceContainer_EM.STACKS_REGISTERED.add(hadron_p_);
+ EMDefinitionsRegistry.getStacksRegisteredForDisplay().add(hadron_p_);
hadron_n = new EMHadronDefinition(new EMConstantStackMap(EMQuarkDefinition.quark_u.getStackForm(1), EMQuarkDefinition.quark_d.getStackForm(2)));
neutronMass = hadron_n.getMass();
//redefine the neutron with proper lifetime (the lifetime is based on mass comparison)
hadron_n = new EMHadronDefinition(new EMConstantStackMap(EMQuarkDefinition.quark_u.getStackForm(1), EMQuarkDefinition.quark_d.getStackForm(2)));
SYMBOL_MAP.put(hadron_n, "n");
NAME_MAP.put(hadron_n, "Neutron");
- DebugElementalInstanceContainer_EM.STACKS_REGISTERED.add(hadron_n);
+ EMDefinitionsRegistry.getStacksRegisteredForDisplay().add(hadron_n);
hadron_n_ = (EMHadronDefinition) hadron_n.getAnti();
SYMBOL_MAP.put(hadron_n_,"~n");
NAME_MAP.put(hadron_n_,"Anti Neutron");
- DebugElementalInstanceContainer_EM.STACKS_REGISTERED.add(hadron_n_);
+ EMDefinitionsRegistry.getStacksRegisteredForDisplay().add(hadron_n_);
} catch (EMException e) {
if (DEBUG_MODE) {
e.printStackTrace();
@@ -444,14 +446,14 @@ public final class EMHadronDefinition extends EMComplex {//TODO Optimize map i/o
hadron_p5 = new EMDefinitionStack(hadron_p, 5D);
try {
- EMComplex.addCreatorFromNBT(nbtType, EMHadronDefinition.class.getMethod("fromNBT", NBTTagCompound.class),(byte)-64);
+ EMDefinitionsRegistry.registerDefinitionClass(nbtType, EMHadronDefinition::fromNBT,EMHadronDefinition.class,getClassTypeStatic());
} catch (Exception e) {
if (DEBUG_MODE) {
e.printStackTrace();
}
}
if(DEBUG_MODE) {
- TecTech.LOGGER.info("Registered Elemental Matter Class: Hadron " + nbtType + ' ' + -64);
+ TecTech.LOGGER.info("Registered Elemental Matter Class: Hadron " + nbtType + ' ' + getClassTypeStatic());
}
}
@@ -467,7 +469,7 @@ public final class EMHadronDefinition extends EMComplex {//TODO Optimize map i/o
@Override
public byte getClassType() {
- return -64;
+ return getClassTypeStatic();
}
public static byte getClassTypeStatic(){
diff --git a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/complex/EMNuclideIAEA.java b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/complex/EMNuclideIAEA.java
index 9a22f54941..bd34733cb6 100644
--- a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/complex/EMNuclideIAEA.java
+++ b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/complex/EMNuclideIAEA.java
@@ -7,7 +7,7 @@ import java.util.HashMap;
import java.util.HashSet;
import java.util.TreeMap;
-import static com.github.technus.tectech.mechanics.elementalMatter.core.templates.IEMDefinition.STABLE_RAW_LIFE_TIME;
+import static com.github.technus.tectech.mechanics.elementalMatter.core.definitions.IEMDefinition.STABLE_RAW_LIFE_TIME;
import static com.github.technus.tectech.util.Util.splitButDifferent;
public final class EMNuclideIAEA {
diff --git a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/primitive/EMBosonDefinition.java b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/primitive/EMBosonDefinition.java
index e3efa3b7e6..5f14eefcdb 100644
--- a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/primitive/EMBosonDefinition.java
+++ b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/primitive/EMBosonDefinition.java
@@ -2,7 +2,7 @@ package com.github.technus.tectech.mechanics.elementalMatter.definitions.primiti
import com.github.technus.tectech.mechanics.elementalMatter.core.decay.EMDecay;
import com.github.technus.tectech.mechanics.elementalMatter.core.stacks.EMDefinitionStack;
-import com.github.technus.tectech.mechanics.elementalMatter.core.templates.EMPrimitive;
+import com.github.technus.tectech.mechanics.elementalMatter.core.definitions.EMPrimitiveTemplate;
import static com.github.technus.tectech.mechanics.elementalMatter.core.decay.EMDecay.*;
import static com.github.technus.tectech.mechanics.elementalMatter.definitions.primitive.EMLeptonDefinition.*;
@@ -11,7 +11,7 @@ import static com.github.technus.tectech.mechanics.elementalMatter.definitions.p
/**
* Created by danie_000 on 22.10.2016.
*/
-public final class EMBosonDefinition extends EMPrimitive {
+public final class EMBosonDefinition extends EMPrimitiveTemplate {
public static final EMBosonDefinition
boson_Y__ = new EMBosonDefinition("Photon", "\u03b3", 1e-18D, -1, 27),
boson_H__ = new EMBosonDefinition("Higgs", "\u0397", 126.09e9D, -2, 28);
diff --git a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/primitive/EMLeptonDefinition.java b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/primitive/EMLeptonDefinition.java
index 98bdf7ca5c..0f9898775f 100644
--- a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/primitive/EMLeptonDefinition.java
+++ b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/primitive/EMLeptonDefinition.java
@@ -2,7 +2,7 @@ package com.github.technus.tectech.mechanics.elementalMatter.definitions.primiti
import com.github.technus.tectech.mechanics.elementalMatter.core.decay.EMDecay;
import com.github.technus.tectech.mechanics.elementalMatter.core.stacks.EMDefinitionStack;
-import com.github.technus.tectech.mechanics.elementalMatter.core.templates.EMPrimitive;
+import com.github.technus.tectech.mechanics.elementalMatter.core.definitions.EMPrimitiveTemplate;
import static com.github.technus.tectech.mechanics.elementalMatter.definitions.primitive.EMBosonDefinition.*;
import static com.github.technus.tectech.mechanics.elementalMatter.definitions.primitive.EMBosonDefinition.boson_Y__;
@@ -11,7 +11,7 @@ import static com.github.technus.tectech.mechanics.elementalMatter.definitions.p
/**
* Created by danie_000 on 22.10.2016.
*/
-public final class EMLeptonDefinition extends EMPrimitive {
+public final class EMLeptonDefinition extends EMPrimitiveTemplate {
public static final EMLeptonDefinition
lepton_e = new EMLeptonDefinition("Electron", "\u03b2-", 1, 0.511e6D, -3, 15),
lepton_m = new EMLeptonDefinition("Muon", "\u03bc-", 2, 105.658e6D, -3, 17),
diff --git a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/primitive/EMNeutrinoDefinition.java b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/primitive/EMNeutrinoDefinition.java
index e77c74ed89..ac06a80728 100644
--- a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/primitive/EMNeutrinoDefinition.java
+++ b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/primitive/EMNeutrinoDefinition.java
@@ -2,14 +2,14 @@ package com.github.technus.tectech.mechanics.elementalMatter.definitions.primiti
import com.github.technus.tectech.mechanics.elementalMatter.core.decay.EMDecay;
import com.github.technus.tectech.mechanics.elementalMatter.core.stacks.EMDefinitionStack;
-import com.github.technus.tectech.mechanics.elementalMatter.core.templates.EMPrimitive;
+import com.github.technus.tectech.mechanics.elementalMatter.core.definitions.EMPrimitiveTemplate;
import static com.github.technus.tectech.mechanics.elementalMatter.definitions.primitive.EMBosonDefinition.*;
/**
* Created by danie_000 on 22.10.2016.
*/
-public final class EMNeutrinoDefinition extends EMPrimitive {
+public final class EMNeutrinoDefinition extends EMPrimitiveTemplate {
public static final EMNeutrinoDefinition
lepton_Ve = new EMNeutrinoDefinition("Electron neutrino", "\u03bd\u03b2", 1, 2e0D, 21),
lepton_Vm = new EMNeutrinoDefinition("Muon neutrino", "\u03bd\u03bc", 2, 0.15e6D, 23),
diff --git a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/primitive/EMPrimitiveDefinition.java b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/primitive/EMPrimitiveDefinition.java
index 68591cc4e6..e4a92fbae1 100644
--- a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/primitive/EMPrimitiveDefinition.java
+++ b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/primitive/EMPrimitiveDefinition.java
@@ -1,17 +1,17 @@
package com.github.technus.tectech.mechanics.elementalMatter.definitions.primitive;
-import com.github.technus.tectech.mechanics.elementalMatter.core.templates.EMPrimitive;
+import com.github.technus.tectech.mechanics.elementalMatter.core.definitions.EMPrimitiveTemplate;
import static com.github.technus.tectech.mechanics.elementalMatter.core.decay.EMDecay.NO_DECAY;
/**
* Created by danie_000 on 22.10.2016.
*/
-public final class EMPrimitiveDefinition extends EMPrimitive {
+public final class EMPrimitiveDefinition extends EMPrimitiveTemplate {
public static final EMPrimitiveDefinition
- nbtE__ = new EMPrimitiveDefinition("NBT ERROR", "!", 0, 0D, Integer.MIN_VALUE, Integer.MIN_VALUE+10_000),
- null__ = new EMPrimitiveDefinition("NULL POINTER", ".", 0, 0D, -3, Integer.MAX_VALUE-10_000),
- space__ = new EMPrimitiveDefinition("Space", "_", 0, 0D, -4, 0),
+ nbtE__ = new EMPrimitiveDefinition("NBT ERROR", "!", 0, 0D, Integer.MIN_VALUE, 0),
+ null__ = new EMPrimitiveDefinition("NULL POINTER", ".", 0, 0D, -3, Integer.MIN_VALUE),
+ space__ = new EMPrimitiveDefinition("Space", "_", 0, 0D, -4, Integer.MIN_VALUE+1),
magic = new EMPrimitiveDefinition("Magic", "Ma", 4, 1e5D, 0, 1),
magic_ = new EMPrimitiveDefinition("Antimagic", "~Ma", -4, 1e5D, 0, 2);
diff --git a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/primitive/EMQuarkDefinition.java b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/primitive/EMQuarkDefinition.java
index b0a5c419e1..9afa04d243 100644
--- a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/primitive/EMQuarkDefinition.java
+++ b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/primitive/EMQuarkDefinition.java
@@ -1,7 +1,7 @@
package com.github.technus.tectech.mechanics.elementalMatter.definitions.primitive;
import com.github.technus.tectech.mechanics.elementalMatter.core.decay.EMDecay;
-import com.github.technus.tectech.mechanics.elementalMatter.core.templates.EMPrimitive;
+import com.github.technus.tectech.mechanics.elementalMatter.core.definitions.EMPrimitiveTemplate;
import static com.github.technus.tectech.mechanics.elementalMatter.definitions.primitive.EMLeptonDefinition.*;
import static com.github.technus.tectech.mechanics.elementalMatter.definitions.primitive.EMNeutrinoDefinition.*;
@@ -9,7 +9,7 @@ import static com.github.technus.tectech.mechanics.elementalMatter.definitions.p
/**
* Created by danie_000 on 22.10.2016.
*/
-public final class EMQuarkDefinition extends EMPrimitive {
+public final class EMQuarkDefinition extends EMPrimitiveTemplate {
public static final EMQuarkDefinition
quark_u = new EMQuarkDefinition("Up", "u", 1, 2.3e6D, 2, 3),
quark_c = new EMQuarkDefinition("Charm", "c", 2, 1.29e9D, 2, 9),
diff --git a/src/main/java/com/github/technus/tectech/recipe/TT_recipe.java b/src/main/java/com/github/technus/tectech/recipe/TT_recipe.java
index f5cfad22f3..b7310485a2 100644
--- a/src/main/java/com/github/technus/tectech/recipe/TT_recipe.java
+++ b/src/main/java/com/github/technus/tectech/recipe/TT_recipe.java
@@ -1,11 +1,11 @@
package com.github.technus.tectech.recipe;
+import com.github.technus.tectech.mechanics.elementalMatter.core.definitions.EMDefinitionsRegistry;
import com.github.technus.tectech.mechanics.elementalMatter.core.maps.EMConstantStackMap;
import com.github.technus.tectech.mechanics.elementalMatter.core.maps.EMInstanceStackMap;
import com.github.technus.tectech.mechanics.elementalMatter.core.maps.IEMMapRead;
import com.github.technus.tectech.mechanics.elementalMatter.core.stacks.IEMStack;
-import com.github.technus.tectech.mechanics.elementalMatter.core.templates.EMComplex;
-import com.github.technus.tectech.mechanics.elementalMatter.core.templates.IEMDefinition;
+import com.github.technus.tectech.mechanics.elementalMatter.core.definitions.IEMDefinition;
import cpw.mods.fml.common.registry.GameRegistry;
import gregtech.api.util.GT_Recipe;
import net.minecraft.item.ItemStack;
@@ -262,7 +262,7 @@ public class TT_recipe extends GT_Recipe {
return null;
}
try {
- return mRecipeMap.get(EMComplex.fromNBT(dataHandler.stackTagCompound.getCompoundTag(E_RECIPE_ID)));
+ return mRecipeMap.get(EMDefinitionsRegistry.fromNBT(dataHandler.stackTagCompound.getCompoundTag(E_RECIPE_ID)));
}catch (Exception e){
if (DEBUG_MODE) {
e.printStackTrace();
diff --git a/src/main/java/com/github/technus/tectech/recipe/TT_recipeAdder.java b/src/main/java/com/github/technus/tectech/recipe/TT_recipeAdder.java
index c72bf0ab9e..97cd4a6ea6 100644
--- a/src/main/java/com/github/technus/tectech/recipe/TT_recipeAdder.java
+++ b/src/main/java/com/github/technus/tectech/recipe/TT_recipeAdder.java
@@ -3,7 +3,7 @@ package com.github.technus.tectech.recipe;
import com.github.technus.tectech.TecTech;
import com.github.technus.tectech.mechanics.elementalMatter.core.maps.EMConstantStackMap;
import com.github.technus.tectech.mechanics.elementalMatter.core.stacks.EMDefinitionStack;
-import com.github.technus.tectech.mechanics.elementalMatter.core.templates.IEMDefinition;
+import com.github.technus.tectech.mechanics.elementalMatter.core.definitions.IEMDefinition;
import com.github.technus.tectech.thing.CustomItemList;
import com.github.technus.tectech.thing.item.ElementalDefinitionContainer_EM;
import com.github.technus.tectech.thing.metaTileEntity.multi.GT_MetaTileEntity_EM_crafting;
diff --git a/src/main/java/com/github/technus/tectech/thing/item/DebugElementalInstanceContainer_EM.java b/src/main/java/com/github/technus/tectech/thing/item/DebugElementalInstanceContainer_EM.java
index 107cb97103..2062173cfd 100644
--- a/src/main/java/com/github/technus/tectech/thing/item/DebugElementalInstanceContainer_EM.java
+++ b/src/main/java/com/github/technus/tectech/thing/item/DebugElementalInstanceContainer_EM.java
@@ -1,5 +1,6 @@
package com.github.technus.tectech.thing.item;
+import com.github.technus.tectech.mechanics.elementalMatter.core.definitions.EMDefinitionsRegistry;
import com.github.technus.tectech.util.CommonValues;
import com.github.technus.tectech.util.Util;
import com.github.technus.tectech.font.TecTechFontRender;
@@ -7,7 +8,7 @@ import com.github.technus.tectech.mechanics.elementalMatter.core.maps.EMInstance
import com.github.technus.tectech.mechanics.elementalMatter.core.IEMContainer;
import com.github.technus.tectech.mechanics.elementalMatter.core.stacks.EMInstanceStack;
import com.github.technus.tectech.mechanics.elementalMatter.core.EMException;
-import com.github.technus.tectech.mechanics.elementalMatter.core.templates.IEMDefinition;
+import com.github.technus.tectech.mechanics.elementalMatter.core.definitions.IEMDefinition;
import com.github.technus.tectech.thing.item.renderElemental.IElementalItem;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.relauncher.SideOnly;
@@ -26,7 +27,6 @@ import net.minecraft.world.World;
import java.util.Collections;
import java.util.List;
-import java.util.TreeSet;
import static com.github.technus.tectech.Reference.MODID;
import static com.github.technus.tectech.loader.TecTechConfig.DEBUG_MODE;
@@ -39,7 +39,6 @@ import static net.minecraft.util.StatCollector.translateToLocal;
* Created by Tec on 15.03.2017.
*/
public final class DebugElementalInstanceContainer_EM extends Item implements IElementalItem {
- public static final TreeSet<IEMDefinition> STACKS_REGISTERED =new TreeSet<>();
public static DebugElementalInstanceContainer_EM INSTANCE;
@@ -141,7 +140,7 @@ public final class DebugElementalInstanceContainer_EM extends Item implements IE
ItemStack that = new ItemStack(this, 1);
that.setTagCompound(new NBTTagCompound());
list.add(that);
- for(IEMDefinition definition: STACKS_REGISTERED){
+ for(IEMDefinition definition: EMDefinitionsRegistry.getStacksRegisteredForDisplay()){
list.add(setContent(new ItemStack(this).setStackDisplayName(definition.getLocalizedName()+" 1 mol"),new EMInstanceStackMap(new EMInstanceStack(definition, AVOGADRO_CONSTANT))));
list.add(setContent(new ItemStack(this).setStackDisplayName(definition.getLocalizedName()+" 144 mol"),new EMInstanceStackMap(new EMInstanceStack(definition, AVOGADRO_CONSTANT_144))));
list.add(setContent(new ItemStack(this).setStackDisplayName(definition.getLocalizedName()+" 1000 mol"),new EMInstanceStackMap(new EMInstanceStack(definition, AVOGADRO_CONSTANT_1000))));
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 4a0bb55784..3015d024c7 100644
--- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_collider.java
+++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_collider.java
@@ -8,7 +8,7 @@ import com.github.technus.tectech.mechanics.elementalMatter.core.decay.EMDecayRe
import com.github.technus.tectech.mechanics.elementalMatter.core.maps.EMInstanceStackMap;
import com.github.technus.tectech.mechanics.elementalMatter.core.maps.EMDefinitionStackMap;
import com.github.technus.tectech.mechanics.elementalMatter.core.stacks.EMInstanceStack;
-import com.github.technus.tectech.mechanics.elementalMatter.core.templates.EMPrimitive;
+import com.github.technus.tectech.mechanics.elementalMatter.core.definitions.EMPrimitiveTemplate;
import com.github.technus.tectech.mechanics.elementalMatter.definitions.complex.EMAtomDefinition;
import com.github.technus.tectech.mechanics.elementalMatter.definitions.complex.EMHadronDefinition;
import com.github.technus.tectech.mechanics.elementalMatter.definitions.primitive.EMQuarkDefinition;
@@ -108,7 +108,7 @@ public class GT_MetaTileEntity_EM_collider extends GT_MetaTileEntity_MultiblockB
});
registerSimpleAtomFuse(EMHadronDefinition.getClassTypeStatic());
registerSimpleAtomFuse(EMComplexAspectDefinition.getClassTypeStatic());
- registerSimpleAtomFuse(EMPrimitive.getClassTypeStatic());
+ registerSimpleAtomFuse(EMPrimitiveTemplate.getClassTypeStatic());
FUSE_HANDLERS.put((EMHadronDefinition.getClassTypeStatic() << 16) | EMHadronDefinition.getClassTypeStatic(), new IColliderHandler() {
@Override
@@ -135,7 +135,7 @@ public class GT_MetaTileEntity_EM_collider extends GT_MetaTileEntity_MultiblockB
return 2;
}
});
- FUSE_HANDLERS.put((EMHadronDefinition.getClassTypeStatic() << 16) | EMPrimitive.getClassTypeStatic(), new IColliderHandler() {
+ FUSE_HANDLERS.put((EMHadronDefinition.getClassTypeStatic() << 16) | EMPrimitiveTemplate.getClassTypeStatic(), new IColliderHandler() {
@Override
public void collide(EMInstanceStack in1, EMInstanceStack in2, EMInstanceStackMap out) {
try {
@@ -162,9 +162,9 @@ public class GT_MetaTileEntity_EM_collider extends GT_MetaTileEntity_MultiblockB
});
registerSimpleAspectFuse(EMComplexAspectDefinition.getClassTypeStatic());
- registerSimpleAspectFuse(EMPrimitive.getClassTypeStatic());
+ registerSimpleAspectFuse(EMPrimitiveTemplate.getClassTypeStatic());
- FUSE_HANDLERS.put((EMPrimitive.getClassTypeStatic() << 16) | EMPrimitive.getClassTypeStatic(), new IColliderHandler() {
+ FUSE_HANDLERS.put((EMPrimitiveTemplate.getClassTypeStatic() << 16) | EMPrimitiveTemplate.getClassTypeStatic(), new IColliderHandler() {
@Override
public void collide(EMInstanceStack in1, EMInstanceStack in2, EMInstanceStackMap out) {
IPrimitiveColliderHandler collisionHandler = PRIMITIVE_FUSE_HANDLERS.get(in1.getDefinition().getClass().getName() + '\0' + in2.getDefinition().getClass().getName());
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 466f82071b..e769d3e480 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
@@ -26,7 +26,7 @@ import net.minecraftforge.oredict.OreDictionary;
import java.util.ArrayList;
-import static com.github.technus.tectech.mechanics.elementalMatter.core.templates.IEMDefinition.STABLE_RAW_LIFE_TIME;
+import static com.github.technus.tectech.mechanics.elementalMatter.core.definitions.IEMDefinition.STABLE_RAW_LIFE_TIME;
import static com.github.technus.tectech.mechanics.elementalMatter.definitions.complex.EMAtomDefinition.refMass;
import static com.github.technus.tectech.mechanics.elementalMatter.definitions.complex.EMAtomDefinition.refUnstableMass;
import static com.github.technus.tectech.mechanics.structure.Structure.adders;
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 630569a25d..64949fe402 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
@@ -29,8 +29,8 @@ import net.minecraftforge.oredict.OreDictionary;
import java.util.ArrayList;
import static com.github.technus.tectech.loader.TecTechConfig.DEBUG_MODE;
-import static com.github.technus.tectech.mechanics.elementalMatter.core.templates.IEMDefinition.DEFAULT_ENERGY_LEVEL;
-import static com.github.technus.tectech.mechanics.elementalMatter.core.templates.IEMDefinition.STABLE_RAW_LIFE_TIME;
+import static com.github.technus.tectech.mechanics.elementalMatter.core.definitions.IEMDefinition.DEFAULT_ENERGY_LEVEL;
+import static com.github.technus.tectech.mechanics.elementalMatter.core.definitions.IEMDefinition.STABLE_RAW_LIFE_TIME;
import static com.github.technus.tectech.mechanics.elementalMatter.core.transformations.EMTransformationInfo.TRANSFORMATION_INFO;
import static com.github.technus.tectech.mechanics.elementalMatter.definitions.complex.EMAtomDefinition.refMass;
import static com.github.technus.tectech.mechanics.elementalMatter.definitions.complex.EMAtomDefinition.refUnstableMass;