diff options
| author | Tec <daniel112092@gmail.com> | 2022-01-18 21:57:53 +0100 |
|---|---|---|
| committer | Martin Robertz <dream-master@gmx.net> | 2022-01-29 21:23:22 +0100 |
| commit | 3dcc0761ab6247cb20dbe16a83e19abe675a13ed (patch) | |
| tree | 7eb2176d251dc6e7ccba906821261f73fae00d7b | |
| parent | 7edde3bf8c069244dabc7138fb5c5f53ce40336d (diff) | |
| download | GT5-Unofficial-3dcc0761ab6247cb20dbe16a83e19abe675a13ed.tar.gz GT5-Unofficial-3dcc0761ab6247cb20dbe16a83e19abe675a13ed.tar.bz2 GT5-Unofficial-3dcc0761ab6247cb20dbe16a83e19abe675a13ed.zip | |
Cleanup serialization of EM
(cherry picked from commit 44c86af58ecb24de8ba66fa6cf8fa81324a32a28)
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 @@ - |
