diff options
Diffstat (limited to 'src/main')
20 files changed, 623 insertions, 164 deletions
diff --git a/src/main/java/com/github/technus/tectech/TecTech.java b/src/main/java/com/github/technus/tectech/TecTech.java index 989968c170..6f1c4fc7a0 100644 --- a/src/main/java/com/github/technus/tectech/TecTech.java +++ b/src/main/java/com/github/technus/tectech/TecTech.java @@ -76,7 +76,7 @@ public class TecTech { hasCOFH = Loader.isModLoaded(Reference.COFHCORE); MainLoader.load(); - MainLoader.addAfterPostLoad(); + MainLoader.addAfterGregTechPostLoadRunner(); } @Mod.EventHandler diff --git a/src/main/java/com/github/technus/tectech/compatibility/thaumcraft/elementalMatter/definitions/dComplexAspectDefinition.java b/src/main/java/com/github/technus/tectech/compatibility/thaumcraft/elementalMatter/definitions/dComplexAspectDefinition.java index 433a3a2697..95671f2515 100644 --- a/src/main/java/com/github/technus/tectech/compatibility/thaumcraft/elementalMatter/definitions/dComplexAspectDefinition.java +++ b/src/main/java/com/github/technus/tectech/compatibility/thaumcraft/elementalMatter/definitions/dComplexAspectDefinition.java @@ -110,6 +110,10 @@ public final class dComplexAspectDefinition extends cElementalDefinition impleme @Override public NBTTagCompound toNBT() { + return getNbtTagCompound(nbtType, aspectStacks); + } + + public static NBTTagCompound getNbtTagCompound(byte nbtType, cElementalDefinitionStackMap aspectStacks) { NBTTagCompound nbt = new NBTTagCompound(); nbt.setByte("t", nbtType); cElementalDefinitionStack[] quarkStacksValues = aspectStacks.values(); @@ -248,6 +252,10 @@ public final class dComplexAspectDefinition extends cElementalDefinition impleme return -96; } + public static byte getClassTypeStatic(){ + return -96; + } + @Override public int hashCode() { return hash; diff --git a/src/main/java/com/github/technus/tectech/loader/MainLoader.java b/src/main/java/com/github/technus/tectech/loader/MainLoader.java index 48c297c5f9..04b354f737 100644 --- a/src/main/java/com/github/technus/tectech/loader/MainLoader.java +++ b/src/main/java/com/github/technus/tectech/loader/MainLoader.java @@ -244,14 +244,14 @@ public final class MainLoader { //todo add GC GS stuff } - public static void addAfterPostLoad() { + public static void addAfterGregTechPostLoadRunner() { GregTech_API.sAfterGTPostload.add(new Runnable() { @Override public void run() { if(TecTech.configTecTech.NERF_FUSION) { FixBrokenFusionRecipes(); } - GT_MetaTileEntity_EM_collider.heliumPlasmaValue = getFuelValue(Materials.Helium.getPlasma(125)); + GT_MetaTileEntity_EM_collider.setValues(getFuelValue(Materials.Helium.getPlasma(125))); } }); } @@ -290,7 +290,21 @@ public final class MainLoader { if (DEBUG_MODE) { LOGGER.info("Nerfing Recipe " + r.mFluidOutputs[0].getUnlocalizedName()); } - r.mFluidOutputs[0] = new FluidStack(fluid, r.mFluidInputs[0].amount); + r.mFluidOutputs[0] = new FluidStack(fluid, r.mFluidOutputs[0].amount); + } + fluid = binds.get(r.mFluidInputs[0].getFluid()); + if (fluid != null) { + if (DEBUG_MODE) { + LOGGER.info("Fixing plasma use in Recipe " + r.mFluidInputs[0].getUnlocalizedName()); + } + r.mFluidInputs[0] = new FluidStack(fluid, r.mFluidInputs[0].amount); + } + fluid = binds.get(r.mFluidInputs[1].getFluid()); + if (fluid != null) { + if (DEBUG_MODE) { + LOGGER.info("Fixing plasma use in Recipe " + r.mFluidInputs[1].getUnlocalizedName()); + } + r.mFluidInputs[1] = new FluidStack(fluid, r.mFluidInputs[1].amount); } } } diff --git a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/cElementalInstanceStackMap.java b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/cElementalInstanceStackMap.java index 799b1f183f..bfbe93bb4f 100644 --- a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/cElementalInstanceStackMap.java +++ b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/cElementalInstanceStackMap.java @@ -313,7 +313,7 @@ public final class cElementalInstanceStackMap implements Comparable<cElementalIn public cElementalInstanceStack get(int i){ Collection<cElementalInstanceStack> var = map.values(); - return var.toArray(new cElementalInstanceStack[var.size()])[i]; + return var.toArray(new cElementalInstanceStack[0])[i]; } public String[] getElementalInfo() { @@ -339,12 +339,12 @@ public final class cElementalInstanceStackMap implements Comparable<cElementalIn public cElementalInstanceStack[] values() { Collection<cElementalInstanceStack> var = map.values(); - return var.toArray(new cElementalInstanceStack[var.size()]); + return var.toArray(new cElementalInstanceStack[0]); } public iElementalDefinition[] keys() { Set<iElementalDefinition> var = map.keySet(); - return var.toArray(new iElementalDefinition[var.size()]); + return var.toArray(new iElementalDefinition[0]); } public float getMass() { @@ -406,7 +406,6 @@ public final class cElementalInstanceStackMap implements Comparable<cElementalIn removeAmount(false,instance); for (cElementalInstanceStack newInstance : newInstances.values()) { putUnify(newInstance); - newInstance.nextColor(); } } } diff --git a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/cElementalMutableDefinitionStackMap.java b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/cElementalMutableDefinitionStackMap.java index 172067f93b..829af20ca6 100644 --- a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/cElementalMutableDefinitionStackMap.java +++ b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/cElementalMutableDefinitionStackMap.java @@ -53,7 +53,7 @@ public final class cElementalMutableDefinitionStackMap extends cElementalStackMa public cElementalDefinitionStackMap toImmutable() { return new cElementalDefinitionStackMap(map); } - public cElementalDefinitionStackMap toImmutable_unsafeMightLeaveExposedElementalTree() { + public cElementalDefinitionStackMap toImmutable_optimized_unsafeLeavesExposedElementalTree() { return new cElementalDefinitionStackMap(this); } diff --git a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/stacks/cElementalInstanceStack.java b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/stacks/cElementalInstanceStack.java index b0ee3f8460..d97ec5d1f6 100644 --- a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/stacks/cElementalInstanceStack.java +++ b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/stacks/cElementalInstanceStack.java @@ -154,6 +154,22 @@ public final class cElementalInstanceStack implements iHasElementalDefinition { return lifeTimeMult; } + public cElementalInstanceStackMap tickStackByOneSecond(float lifeTimeMult, int postEnergize){ + return tickStack(lifeTimeMult,postEnergize,1); + } + + public cElementalInstanceStackMap tickStack(float lifeTimeMult, int postEnergize, int seconds){ + cElementalInstanceStackMap newInstances = decay(lifeTimeMult, age += seconds, postEnergize); + if (newInstances == null) { + nextColor(); + } else { + for (cElementalInstanceStack newInstance : newInstances.values()) { + newInstance.nextColor(); + } + } + return newInstances; + } + public cElementalInstanceStackMap decay() { return decay(1F, age, 0);//try to decay without changes } diff --git a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/templates/cElementalPrimitive.java b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/templates/cElementalPrimitive.java index 5d0826ffb6..5db86a0349 100644 --- a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/templates/cElementalPrimitive.java +++ b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/templates/cElementalPrimitive.java @@ -201,6 +201,10 @@ public abstract class cElementalPrimitive extends cElementalDefinition { return -128; } + public static byte getClassTypeStatic(){ + return -128; + } + @Override public void addScanResults(ArrayList<String> lines, int capabilities, long energyLevel) { if(Util.areBitsSet(SCAN_GET_CLASS_TYPE, capabilities)) { diff --git a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/transformations/bTransformationInfo.java b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/transformations/bTransformationInfo.java index 01e5571f23..367b412201 100644 --- a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/transformations/bTransformationInfo.java +++ b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/transformations/bTransformationInfo.java @@ -10,6 +10,7 @@ import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.oredict.OreDictionary; import java.util.HashMap; +import java.util.HashSet; /** * Created by Tec on 26.05.2017. @@ -24,11 +25,7 @@ public class bTransformationInfo { public static final HashMap<Integer,aOredictQuantizationInfo> oredictQuantization=new HashMap<>(32); public HashMap<iElementalDefinition,aOredictDequantizationInfo> oredictDequantization; - public bTransformationInfo(){ - fluidDequantization=new HashMap<>(); - itemDequantization=new HashMap<>(); - oredictDequantization=new HashMap<>(); - } + public static final HashSet<iElementalDefinition> stacksRegistered=new HashSet<>(); public bTransformationInfo(int fluidCap,int itemCap, int oreCap){ if(fluidCap>0) { @@ -45,49 +42,58 @@ public class bTransformationInfo { public void addFluid(iHasElementalDefinition em, FluidStack fluidStack){ fluidQuantization.put(fluidStack.getFluidID(),new aFluidQuantizationInfo(fluidStack,em)); fluidDequantization.put(em.getDefinition(),new aFluidDequantizationInfo(em,fluidStack)); + stacksRegistered.add(em.getDefinition()); } public void addFluid(iHasElementalDefinition em ,int fluidID,int fluidAmount) { fluidQuantization.put(fluidID,new aFluidQuantizationInfo(fluidID,fluidAmount,em)); fluidDequantization.put(em.getDefinition(),new aFluidDequantizationInfo(em,fluidID,fluidAmount)); + stacksRegistered.add(em.getDefinition()); } public void addFluid(iHasElementalDefinition em, Fluid fluid, int fluidAmount){ fluidQuantization.put(fluid.getID(),new aFluidQuantizationInfo(fluid,fluidAmount,em)); fluidDequantization.put(em.getDefinition(),new aFluidDequantizationInfo(em,fluid,fluidAmount)); + stacksRegistered.add(em.getDefinition()); } - public void addItemQuantization(aItemQuantizationInfo aIQI){ + private void addItemQuantization(aItemQuantizationInfo aIQI){ itemQuantization.put(aIQI,aIQI); } public void addItem(iHasElementalDefinition em, ItemStack itemStack, boolean skipNBT){ addItemQuantization(new aItemQuantizationInfo(itemStack,skipNBT,em)); itemDequantization.put(em.getDefinition(),new aItemDequantizationInfo(em,itemStack)); + stacksRegistered.add(em.getDefinition()); } public void addItem(iHasElementalDefinition em, OrePrefixes prefix, Materials material, int amount, boolean skipNBT){ addItemQuantization(new aItemQuantizationInfo(prefix,material,amount,skipNBT,em)); itemDequantization.put(em.getDefinition(),new aItemDequantizationInfo(em,prefix,material,amount)); + stacksRegistered.add(em.getDefinition()); } public void addOredict(iHasElementalDefinition em, int id, int qty){ oredictQuantization.put(id,new aOredictQuantizationInfo(id,qty,em)); oredictDequantization.put(em.getDefinition(),new aOredictDequantizationInfo(em,id,qty)); + stacksRegistered.add(em.getDefinition()); } public void addOredict(iHasElementalDefinition em, String name, int qty){ oredictQuantization.put(OreDictionary.getOreID(name),new aOredictQuantizationInfo(name,qty,em)); oredictDequantization.put(em.getDefinition(),new aOredictDequantizationInfo(em,name,qty)); + stacksRegistered.add(em.getDefinition()); } public void addOredict(iHasElementalDefinition em, OrePrefixes prefix, Materials material, int qty){ oredictQuantization.put(OreDictionary.getOreID(prefix.name() + material.mName),new aOredictQuantizationInfo(prefix,material,qty,em)); oredictDequantization.put(em.getDefinition(),new aOredictDequantizationInfo(em,prefix,material,qty)); + stacksRegistered.add(em.getDefinition()); } public void addOredict(iHasElementalDefinition em, OrePrefixes prefix, String materialName, int qty){ oredictQuantization.put(OreDictionary.getOreID(prefix.name() + materialName),new aOredictQuantizationInfo(prefix,materialName,qty,em)); oredictDequantization.put(em.getDefinition(),new aOredictDequantizationInfo(em,prefix,materialName,qty)); + stacksRegistered.add(em.getDefinition()); } } diff --git a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/complex/atom/dAtomDefinition.java b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/complex/atom/dAtomDefinition.java index 16a668dfe3..5f191a4274 100644 --- a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/complex/atom/dAtomDefinition.java +++ b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/complex/atom/dAtomDefinition.java @@ -27,6 +27,7 @@ import net.minecraft.nbt.NBTTagCompound; import java.util.*; import static com.github.technus.tectech.XSTR.XSTR_INSTANCE; +import static com.github.technus.tectech.compatibility.thaumcraft.elementalMatter.definitions.dComplexAspectDefinition.getNbtTagCompound; import static com.github.technus.tectech.loader.TecTechConfig.DEBUG_MODE; import static com.github.technus.tectech.mechanics.elementalMatter.definitions.primitive.eBosonDefinition.boson_Y__; import static com.github.technus.tectech.mechanics.elementalMatter.definitions.primitive.eBosonDefinition.deadEnd; @@ -462,28 +463,28 @@ public final class dAtomDefinition extends cElementalDefinition { case "D": { if (withThis.removeAllAmounts(false, deuterium.definition.getSubParticles())){ withThis.putReplace(deuterium); - decaysList.add(new cElementalDecay(decay.chance,withThis.toImmutable_unsafeMightLeaveExposedElementalTree())); + decaysList.add(new cElementalDecay(decay.chance,withThis.toImmutable_optimized_unsafeLeavesExposedElementalTree())); return true; } } break; case "3H": { if (withThis.removeAllAmounts(false, tritium.definition.getSubParticles())){ withThis.putReplace(tritium); - decaysList.add(new cElementalDecay(decay.chance,withThis.toImmutable_unsafeMightLeaveExposedElementalTree())); + decaysList.add(new cElementalDecay(decay.chance,withThis.toImmutable_optimized_unsafeLeavesExposedElementalTree())); return true; } } break; case "3HE": { if (withThis.removeAllAmounts(false, helium_3.definition.getSubParticles())){ withThis.putReplace(helium_3); - decaysList.add(new cElementalDecay(decay.chance,withThis.toImmutable_unsafeMightLeaveExposedElementalTree())); + decaysList.add(new cElementalDecay(decay.chance,withThis.toImmutable_optimized_unsafeLeavesExposedElementalTree())); return true; } } break; case "8BE": { if (withThis.removeAllAmounts(false, beryllium_8.definition.getSubParticles())){ withThis.putReplace(beryllium_8); - decaysList.add(new cElementalDecay(decay.chance,withThis.toImmutable_unsafeMightLeaveExposedElementalTree())); + decaysList.add(new cElementalDecay(decay.chance,withThis.toImmutable_optimized_unsafeLeavesExposedElementalTree())); return true; } } break; @@ -491,8 +492,8 @@ public final class dAtomDefinition extends cElementalDefinition { if (withThis.removeAllAmounts(false, carbon_14.definition.getSubParticles())){ newStuff.putReplace(carbon_14); try{ - newStuff.putReplace(new dAtomDefinition(withThis.toImmutable_unsafeMightLeaveExposedElementalTree()).getStackForm(1)); - decaysList.add(new cElementalDecay(decay.chance,newStuff.toImmutable_unsafeMightLeaveExposedElementalTree())); + newStuff.putReplace(new dAtomDefinition(withThis.toImmutable_optimized_unsafeLeavesExposedElementalTree()).getStackForm(1)); + decaysList.add(new cElementalDecay(decay.chance,newStuff.toImmutable_optimized_unsafeLeavesExposedElementalTree())); return true; }catch (Exception e){ if(DEBUG_MODE) { @@ -505,8 +506,8 @@ public final class dAtomDefinition extends cElementalDefinition { if (withThis.removeAllAmounts(false, neon_24.definition.getSubParticles())){ newStuff.putReplace(neon_24); try{ - newStuff.putReplace(new dAtomDefinition(withThis.toImmutable_unsafeMightLeaveExposedElementalTree()).getStackForm(1)); - decaysList.add(new cElementalDecay(decay.chance,newStuff.toImmutable_unsafeMightLeaveExposedElementalTree())); + newStuff.putReplace(new dAtomDefinition(withThis.toImmutable_optimized_unsafeLeavesExposedElementalTree()).getStackForm(1)); + decaysList.add(new cElementalDecay(decay.chance,newStuff.toImmutable_optimized_unsafeLeavesExposedElementalTree())); return true; }catch (Exception e){ if(DEBUG_MODE) { @@ -519,8 +520,8 @@ public final class dAtomDefinition extends cElementalDefinition { if (withThis.removeAllAmounts(false, silicon_34.definition.getSubParticles())){ newStuff.putReplace(silicon_34); try{ - newStuff.putReplace(new dAtomDefinition(withThis.toImmutable_unsafeMightLeaveExposedElementalTree()).getStackForm(1)); - decaysList.add(new cElementalDecay(decay.chance,newStuff.toImmutable_unsafeMightLeaveExposedElementalTree())); + newStuff.putReplace(new dAtomDefinition(withThis.toImmutable_optimized_unsafeLeavesExposedElementalTree()).getStackForm(1)); + decaysList.add(new cElementalDecay(decay.chance,newStuff.toImmutable_optimized_unsafeLeavesExposedElementalTree())); return true; }catch (Exception e){ if(DEBUG_MODE) { @@ -533,8 +534,8 @@ public final class dAtomDefinition extends cElementalDefinition { if (withThis.removeAllAmounts(false, dHadronDefinition.hadron_n2,dHadronDefinition.hadron_p2)){ newStuff.putReplace(alpha); try{ - newStuff.putReplace(new dAtomDefinition(withThis.toImmutable_unsafeMightLeaveExposedElementalTree()).getStackForm(1)); - decaysList.add(new cElementalDecay(decay.chance,newStuff.toImmutable_unsafeMightLeaveExposedElementalTree())); + newStuff.putReplace(new dAtomDefinition(withThis.toImmutable_optimized_unsafeLeavesExposedElementalTree()).getStackForm(1)); + decaysList.add(new cElementalDecay(decay.chance,newStuff.toImmutable_optimized_unsafeLeavesExposedElementalTree())); return true; }catch (Exception e){ if(DEBUG_MODE) { @@ -549,8 +550,8 @@ public final class dAtomDefinition extends cElementalDefinition { newStuff.putReplace(eLeptonDefinition.lepton_e_1); newStuff.putReplace(eNeutrinoDefinition.lepton_Ve1); try{ - newStuff.putReplace(new dAtomDefinition(withThis.toImmutable_unsafeMightLeaveExposedElementalTree()).getStackForm(1)); - decaysList.add(new cElementalDecay(decay.chance,newStuff.toImmutable_unsafeMightLeaveExposedElementalTree())); + newStuff.putReplace(new dAtomDefinition(withThis.toImmutable_optimized_unsafeLeavesExposedElementalTree()).getStackForm(1)); + decaysList.add(new cElementalDecay(decay.chance,newStuff.toImmutable_optimized_unsafeLeavesExposedElementalTree())); return true; }catch (Exception e){ if(DEBUG_MODE) { @@ -565,8 +566,8 @@ public final class dAtomDefinition extends cElementalDefinition { newStuff.putReplace(eLeptonDefinition.lepton_e_2); newStuff.putReplace(eNeutrinoDefinition.lepton_Ve2); try{ - newStuff.putReplace(new dAtomDefinition(withThis.toImmutable_unsafeMightLeaveExposedElementalTree()).getStackForm(1)); - decaysList.add(new cElementalDecay(decay.chance,newStuff.toImmutable_unsafeMightLeaveExposedElementalTree())); + newStuff.putReplace(new dAtomDefinition(withThis.toImmutable_optimized_unsafeLeavesExposedElementalTree()).getStackForm(1)); + decaysList.add(new cElementalDecay(decay.chance,newStuff.toImmutable_optimized_unsafeLeavesExposedElementalTree())); return true; }catch (Exception e){ if(DEBUG_MODE) { @@ -581,8 +582,8 @@ public final class dAtomDefinition extends cElementalDefinition { newStuff.putReplace(eLeptonDefinition.lepton_e1); newStuff.putReplace(eNeutrinoDefinition.lepton_Ve_1); try{ - newStuff.putReplace(new dAtomDefinition(withThis.toImmutable_unsafeMightLeaveExposedElementalTree()).getStackForm(1)); - decaysList.add(new cElementalDecay(decay.chance,newStuff.toImmutable_unsafeMightLeaveExposedElementalTree())); + newStuff.putReplace(new dAtomDefinition(withThis.toImmutable_optimized_unsafeLeavesExposedElementalTree()).getStackForm(1)); + decaysList.add(new cElementalDecay(decay.chance,newStuff.toImmutable_optimized_unsafeLeavesExposedElementalTree())); return true; }catch (Exception e){ if(DEBUG_MODE) { @@ -597,8 +598,8 @@ public final class dAtomDefinition extends cElementalDefinition { newStuff.putReplace(eLeptonDefinition.lepton_e2); newStuff.putReplace(eNeutrinoDefinition.lepton_Ve_2); try{ - newStuff.putReplace(new dAtomDefinition(withThis.toImmutable_unsafeMightLeaveExposedElementalTree()).getStackForm(1)); - decaysList.add(new cElementalDecay(decay.chance,newStuff.toImmutable_unsafeMightLeaveExposedElementalTree())); + newStuff.putReplace(new dAtomDefinition(withThis.toImmutable_optimized_unsafeLeavesExposedElementalTree()).getStackForm(1)); + decaysList.add(new cElementalDecay(decay.chance,newStuff.toImmutable_optimized_unsafeLeavesExposedElementalTree())); return true; }catch (Exception e){ if(DEBUG_MODE) { @@ -612,8 +613,8 @@ public final class dAtomDefinition extends cElementalDefinition { withThis.putUnify(dHadronDefinition.hadron_n1); newStuff.putReplace(eNeutrinoDefinition.lepton_Ve1); try{ - newStuff.putReplace(new dAtomDefinition(withThis.toImmutable_unsafeMightLeaveExposedElementalTree()).getStackForm(1)); - decaysList.add(new cElementalDecay(decay.chance,newStuff.toImmutable_unsafeMightLeaveExposedElementalTree())); + newStuff.putReplace(new dAtomDefinition(withThis.toImmutable_optimized_unsafeLeavesExposedElementalTree()).getStackForm(1)); + decaysList.add(new cElementalDecay(decay.chance,newStuff.toImmutable_optimized_unsafeLeavesExposedElementalTree())); return true; }catch (Exception e){ if(DEBUG_MODE) { @@ -627,8 +628,8 @@ public final class dAtomDefinition extends cElementalDefinition { withThis.putUnify(dHadronDefinition.hadron_n2); newStuff.putReplace(eNeutrinoDefinition.lepton_Ve2); try{ - newStuff.putReplace(new dAtomDefinition(withThis.toImmutable_unsafeMightLeaveExposedElementalTree()).getStackForm(1)); - decaysList.add(new cElementalDecay(decay.chance,newStuff.toImmutable_unsafeMightLeaveExposedElementalTree())); + newStuff.putReplace(new dAtomDefinition(withThis.toImmutable_optimized_unsafeLeavesExposedElementalTree()).getStackForm(1)); + decaysList.add(new cElementalDecay(decay.chance,newStuff.toImmutable_optimized_unsafeLeavesExposedElementalTree())); return true; }catch (Exception e){ if(DEBUG_MODE) { @@ -643,8 +644,8 @@ public final class dAtomDefinition extends cElementalDefinition { newStuff.putReplace(eLeptonDefinition.lepton_e_1); newStuff.putReplace(eNeutrinoDefinition.lepton_Ve2); try{ - newStuff.putReplace(new dAtomDefinition(withThis.toImmutable_unsafeMightLeaveExposedElementalTree()).getStackForm(1)); - decaysList.add(new cElementalDecay(decay.chance,newStuff.toImmutable_unsafeMightLeaveExposedElementalTree())); + newStuff.putReplace(new dAtomDefinition(withThis.toImmutable_optimized_unsafeLeavesExposedElementalTree()).getStackForm(1)); + decaysList.add(new cElementalDecay(decay.chance,newStuff.toImmutable_optimized_unsafeLeavesExposedElementalTree())); return true; }catch (Exception e){ if(DEBUG_MODE) { @@ -659,8 +660,8 @@ public final class dAtomDefinition extends cElementalDefinition { newStuff.putReplace(eNeutrinoDefinition.lepton_Ve1); newStuff.putReplace(alpha); try{ - newStuff.putReplace(new dAtomDefinition(withThis.toImmutable_unsafeMightLeaveExposedElementalTree()).getStackForm(1)); - decaysList.add(new cElementalDecay(decay.chance,newStuff.toImmutable_unsafeMightLeaveExposedElementalTree())); + newStuff.putReplace(new dAtomDefinition(withThis.toImmutable_optimized_unsafeLeavesExposedElementalTree()).getStackForm(1)); + decaysList.add(new cElementalDecay(decay.chance,newStuff.toImmutable_optimized_unsafeLeavesExposedElementalTree())); return true; }catch (Exception e){ if(DEBUG_MODE) { @@ -676,8 +677,8 @@ public final class dAtomDefinition extends cElementalDefinition { newStuff.putReplace(eNeutrinoDefinition.lepton_Ve1); newStuff.putReplace(dHadronDefinition.hadron_p1); try{ - newStuff.putReplace(new dAtomDefinition(withThis.toImmutable_unsafeMightLeaveExposedElementalTree()).getStackForm(1)); - decaysList.add(new cElementalDecay(decay.chance,newStuff.toImmutable_unsafeMightLeaveExposedElementalTree())); + newStuff.putReplace(new dAtomDefinition(withThis.toImmutable_optimized_unsafeLeavesExposedElementalTree()).getStackForm(1)); + decaysList.add(new cElementalDecay(decay.chance,newStuff.toImmutable_optimized_unsafeLeavesExposedElementalTree())); return true; }catch (Exception e){ if(DEBUG_MODE) { @@ -693,8 +694,8 @@ public final class dAtomDefinition extends cElementalDefinition { newStuff.putReplace(eNeutrinoDefinition.lepton_Ve1); newStuff.putReplace(dHadronDefinition.hadron_p2); try{ - newStuff.putReplace(new dAtomDefinition(withThis.toImmutable_unsafeMightLeaveExposedElementalTree()).getStackForm(1)); - decaysList.add(new cElementalDecay(decay.chance,newStuff.toImmutable_unsafeMightLeaveExposedElementalTree())); + newStuff.putReplace(new dAtomDefinition(withThis.toImmutable_optimized_unsafeLeavesExposedElementalTree()).getStackForm(1)); + decaysList.add(new cElementalDecay(decay.chance,newStuff.toImmutable_optimized_unsafeLeavesExposedElementalTree())); return true; }catch (Exception e){ if(DEBUG_MODE) { @@ -709,8 +710,8 @@ public final class dAtomDefinition extends cElementalDefinition { newStuff.putReplace(eNeutrinoDefinition.lepton_Ve_1); newStuff.putReplace(alpha); try{ - newStuff.putReplace(new dAtomDefinition(withThis.toImmutable_unsafeMightLeaveExposedElementalTree()).getStackForm(1)); - decaysList.add(new cElementalDecay(decay.chance,newStuff.toImmutable_unsafeMightLeaveExposedElementalTree())); + newStuff.putReplace(new dAtomDefinition(withThis.toImmutable_optimized_unsafeLeavesExposedElementalTree()).getStackForm(1)); + decaysList.add(new cElementalDecay(decay.chance,newStuff.toImmutable_optimized_unsafeLeavesExposedElementalTree())); return true; }catch (Exception e){ if(DEBUG_MODE) { @@ -726,8 +727,8 @@ public final class dAtomDefinition extends cElementalDefinition { newStuff.putReplace(eNeutrinoDefinition.lepton_Ve_1); newStuff.putReplace(dHadronDefinition.hadron_n1); try{ - newStuff.putReplace(new dAtomDefinition(withThis.toImmutable_unsafeMightLeaveExposedElementalTree()).getStackForm(1)); - decaysList.add(new cElementalDecay(decay.chance,newStuff.toImmutable_unsafeMightLeaveExposedElementalTree())); + newStuff.putReplace(new dAtomDefinition(withThis.toImmutable_optimized_unsafeLeavesExposedElementalTree()).getStackForm(1)); + decaysList.add(new cElementalDecay(decay.chance,newStuff.toImmutable_optimized_unsafeLeavesExposedElementalTree())); return true; }catch (Exception e){ if(DEBUG_MODE) { @@ -743,8 +744,8 @@ public final class dAtomDefinition extends cElementalDefinition { newStuff.putReplace(eNeutrinoDefinition.lepton_Ve_1); newStuff.putReplace(dHadronDefinition.hadron_n2); try{ - newStuff.putReplace(new dAtomDefinition(withThis.toImmutable_unsafeMightLeaveExposedElementalTree()).getStackForm(1)); - decaysList.add(new cElementalDecay(decay.chance,newStuff.toImmutable_unsafeMightLeaveExposedElementalTree())); + newStuff.putReplace(new dAtomDefinition(withThis.toImmutable_optimized_unsafeLeavesExposedElementalTree()).getStackForm(1)); + decaysList.add(new cElementalDecay(decay.chance,newStuff.toImmutable_optimized_unsafeLeavesExposedElementalTree())); return true; }catch (Exception e){ if(DEBUG_MODE) { @@ -759,8 +760,8 @@ public final class dAtomDefinition extends cElementalDefinition { newStuff.putReplace(eNeutrinoDefinition.lepton_Ve_1); newStuff.putReplace(dHadronDefinition.hadron_p1); try{ - newStuff.putReplace(new dAtomDefinition(withThis.toImmutable_unsafeMightLeaveExposedElementalTree()).getStackForm(1)); - decaysList.add(new cElementalDecay(decay.chance,newStuff.toImmutable_unsafeMightLeaveExposedElementalTree())); + newStuff.putReplace(new dAtomDefinition(withThis.toImmutable_optimized_unsafeLeavesExposedElementalTree()).getStackForm(1)); + decaysList.add(new cElementalDecay(decay.chance,newStuff.toImmutable_optimized_unsafeLeavesExposedElementalTree())); return true; }catch (Exception e){ if(DEBUG_MODE) { @@ -774,8 +775,8 @@ public final class dAtomDefinition extends cElementalDefinition { newStuff.putReplace(eNeutrinoDefinition.lepton_Ve1); newStuff.putReplace(alpha); try{ - newStuff.putReplace(new dAtomDefinition(withThis.toImmutable_unsafeMightLeaveExposedElementalTree()).getStackForm(1)); - decaysList.add(new cElementalDecay(decay.chance,newStuff.toImmutable_unsafeMightLeaveExposedElementalTree())); + newStuff.putReplace(new dAtomDefinition(withThis.toImmutable_optimized_unsafeLeavesExposedElementalTree()).getStackForm(1)); + decaysList.add(new cElementalDecay(decay.chance,newStuff.toImmutable_optimized_unsafeLeavesExposedElementalTree())); return true; }catch (Exception e){ if(DEBUG_MODE) { @@ -790,8 +791,8 @@ public final class dAtomDefinition extends cElementalDefinition { newStuff.putReplace(eNeutrinoDefinition.lepton_Ve1); newStuff.putReplace(dHadronDefinition.hadron_p1); try{ - newStuff.putReplace(new dAtomDefinition(withThis.toImmutable_unsafeMightLeaveExposedElementalTree()).getStackForm(1)); - decaysList.add(new cElementalDecay(decay.chance,newStuff.toImmutable_unsafeMightLeaveExposedElementalTree())); + newStuff.putReplace(new dAtomDefinition(withThis.toImmutable_optimized_unsafeLeavesExposedElementalTree()).getStackForm(1)); + decaysList.add(new cElementalDecay(decay.chance,newStuff.toImmutable_optimized_unsafeLeavesExposedElementalTree())); return true; }catch (Exception e){ if(DEBUG_MODE) { @@ -806,8 +807,8 @@ public final class dAtomDefinition extends cElementalDefinition { newStuff.putReplace(eNeutrinoDefinition.lepton_Ve1); newStuff.putReplace(dHadronDefinition.hadron_p2); try{ - newStuff.putReplace(new dAtomDefinition(withThis.toImmutable_unsafeMightLeaveExposedElementalTree()).getStackForm(1)); - decaysList.add(new cElementalDecay(decay.chance,newStuff.toImmutable_unsafeMightLeaveExposedElementalTree())); + newStuff.putReplace(new dAtomDefinition(withThis.toImmutable_optimized_unsafeLeavesExposedElementalTree()).getStackForm(1)); + decaysList.add(new cElementalDecay(decay.chance,newStuff.toImmutable_optimized_unsafeLeavesExposedElementalTree())); return true; }catch (Exception e){ if(DEBUG_MODE) { @@ -822,8 +823,8 @@ public final class dAtomDefinition extends cElementalDefinition { newStuff.putReplace(eNeutrinoDefinition.lepton_Ve2); newStuff.putReplace(dHadronDefinition.hadron_p3); try{ - newStuff.putReplace(new dAtomDefinition(withThis.toImmutable_unsafeMightLeaveExposedElementalTree()).getStackForm(1)); - decaysList.add(new cElementalDecay(decay.chance,newStuff.toImmutable_unsafeMightLeaveExposedElementalTree())); + newStuff.putReplace(new dAtomDefinition(withThis.toImmutable_optimized_unsafeLeavesExposedElementalTree()).getStackForm(1)); + decaysList.add(new cElementalDecay(decay.chance,newStuff.toImmutable_optimized_unsafeLeavesExposedElementalTree())); return true; }catch (Exception e){ if(DEBUG_MODE) { @@ -836,8 +837,8 @@ public final class dAtomDefinition extends cElementalDefinition { if (withThis.removeAllAmounts(false, dHadronDefinition.hadron_n1)){ newStuff.putReplace(dHadronDefinition.hadron_n1); try{ - newStuff.putReplace(new dAtomDefinition(withThis.toImmutable_unsafeMightLeaveExposedElementalTree()).getStackForm(1)); - decaysList.add(new cElementalDecay(decay.chance,newStuff.toImmutable_unsafeMightLeaveExposedElementalTree())); + newStuff.putReplace(new dAtomDefinition(withThis.toImmutable_optimized_unsafeLeavesExposedElementalTree()).getStackForm(1)); + decaysList.add(new cElementalDecay(decay.chance,newStuff.toImmutable_optimized_unsafeLeavesExposedElementalTree())); return true; }catch (Exception e){ if(DEBUG_MODE) { @@ -850,8 +851,8 @@ public final class dAtomDefinition extends cElementalDefinition { if (withThis.removeAllAmounts(false, dHadronDefinition.hadron_n2)){ newStuff.putReplace(dHadronDefinition.hadron_n2); try{ - newStuff.putReplace(new dAtomDefinition(withThis.toImmutable_unsafeMightLeaveExposedElementalTree()).getStackForm(1)); - decaysList.add(new cElementalDecay(decay.chance,newStuff.toImmutable_unsafeMightLeaveExposedElementalTree())); + newStuff.putReplace(new dAtomDefinition(withThis.toImmutable_optimized_unsafeLeavesExposedElementalTree()).getStackForm(1)); + decaysList.add(new cElementalDecay(decay.chance,newStuff.toImmutable_optimized_unsafeLeavesExposedElementalTree())); return true; }catch (Exception e){ if(DEBUG_MODE) { @@ -864,8 +865,8 @@ public final class dAtomDefinition extends cElementalDefinition { if (withThis.removeAllAmounts(false, dHadronDefinition.hadron_p1)){ newStuff.putReplace(dHadronDefinition.hadron_p1); try{ - newStuff.putReplace(new dAtomDefinition(withThis.toImmutable_unsafeMightLeaveExposedElementalTree()).getStackForm(1)); - decaysList.add(new cElementalDecay(decay.chance,newStuff.toImmutable_unsafeMightLeaveExposedElementalTree())); + newStuff.putReplace(new dAtomDefinition(withThis.toImmutable_optimized_unsafeLeavesExposedElementalTree()).getStackForm(1)); + decaysList.add(new cElementalDecay(decay.chance,newStuff.toImmutable_optimized_unsafeLeavesExposedElementalTree())); return true; }catch (Exception e){ if(DEBUG_MODE) { @@ -878,8 +879,8 @@ public final class dAtomDefinition extends cElementalDefinition { if (withThis.removeAllAmounts(false, dHadronDefinition.hadron_p2)){ newStuff.putReplace(dHadronDefinition.hadron_p2); try{ - newStuff.putReplace(new dAtomDefinition(withThis.toImmutable_unsafeMightLeaveExposedElementalTree()).getStackForm(1)); - decaysList.add(new cElementalDecay(decay.chance,newStuff.toImmutable_unsafeMightLeaveExposedElementalTree())); + newStuff.putReplace(new dAtomDefinition(withThis.toImmutable_optimized_unsafeLeavesExposedElementalTree()).getStackForm(1)); + decaysList.add(new cElementalDecay(decay.chance,newStuff.toImmutable_optimized_unsafeLeavesExposedElementalTree())); return true; }catch (Exception e){ if(DEBUG_MODE) { @@ -975,8 +976,8 @@ public final class dAtomDefinition extends cElementalDefinition { newStuff.putReplace(eNeutrinoDefinition.lepton_Ve2); newStuff.putReplace(eBosonDefinition.boson_Y__1); try{ - newStuff.putReplace(new dAtomDefinition(withThis.toImmutable_unsafeMightLeaveExposedElementalTree()).getStackForm(1)); - decaysList.add(new cElementalDecay(decay.chance,newStuff.toImmutable_unsafeMightLeaveExposedElementalTree())); + newStuff.putReplace(new dAtomDefinition(withThis.toImmutable_optimized_unsafeLeavesExposedElementalTree()).getStackForm(1)); + decaysList.add(new cElementalDecay(decay.chance,newStuff.toImmutable_optimized_unsafeLeavesExposedElementalTree())); return true; }catch (Exception e){ if(DEBUG_MODE) { @@ -1000,7 +1001,7 @@ public final class dAtomDefinition extends cElementalDefinition { cElementalMutableDefinitionStackMap tree = elementalStacks.toMutable(); if (tree.removeAmount(false, emit)) { try { - decaysList.add(new cElementalDecay((float) 1, new cElementalDefinitionStack(new dAtomDefinition(tree.toImmutable_unsafeMightLeaveExposedElementalTree()), 1), emit)); + decaysList.add(new cElementalDecay((float) 1, new cElementalDefinitionStack(new dAtomDefinition(tree.toImmutable_optimized_unsafeLeavesExposedElementalTree()), 1), emit)); return true; } catch (Exception e) { if (DEBUG_MODE) { @@ -1015,7 +1016,7 @@ public final class dAtomDefinition extends cElementalDefinition { cElementalMutableDefinitionStackMap tree = elementalStacks.toMutable(); if (tree.removeAllAmounts(false, alpha.definition.getSubParticles())) { try { - decaysList.add(new cElementalDecay((float) 1, new cElementalDefinitionStack(new dAtomDefinition(tree.toImmutable_unsafeMightLeaveExposedElementalTree()), 1), alpha)); + decaysList.add(new cElementalDecay((float) 1, new cElementalDefinitionStack(new dAtomDefinition(tree.toImmutable_optimized_unsafeLeavesExposedElementalTree()), 1), alpha)); return true; } catch (Exception e) { if (DEBUG_MODE) { @@ -1031,7 +1032,7 @@ public final class dAtomDefinition extends cElementalDefinition { if (tree.removeAmount(false, dHadronDefinition.hadron_n1)) { try { tree.putUnify(dHadronDefinition.hadron_p1); - decaysList.add(new cElementalDecay((float) 1, new cElementalDefinitionStack(new dAtomDefinition(tree.toImmutable_unsafeMightLeaveExposedElementalTree()), 1), eLeptonDefinition.lepton_e1, eNeutrinoDefinition.lepton_Ve_1)); + decaysList.add(new cElementalDecay((float) 1, new cElementalDefinitionStack(new dAtomDefinition(tree.toImmutable_optimized_unsafeLeavesExposedElementalTree()), 1), eLeptonDefinition.lepton_e1, eNeutrinoDefinition.lepton_Ve_1)); return true; } catch (Exception e) { if (DEBUG_MODE) { @@ -1047,7 +1048,7 @@ public final class dAtomDefinition extends cElementalDefinition { if (tree.removeAmount(false, dHadronDefinition.hadron_p1)) { try { tree.putUnify(dHadronDefinition.hadron_n1); - decaysList.add(new cElementalDecay((float) 1, new cElementalDefinitionStack(new dAtomDefinition(tree.toImmutable_unsafeMightLeaveExposedElementalTree()), 1), eLeptonDefinition.lepton_e_1, eNeutrinoDefinition.lepton_Ve1)); + decaysList.add(new cElementalDecay((float) 1, new cElementalDefinitionStack(new dAtomDefinition(tree.toImmutable_optimized_unsafeLeavesExposedElementalTree()), 1), eLeptonDefinition.lepton_e_1, eNeutrinoDefinition.lepton_Ve1)); return true; } catch (Exception e) { if (DEBUG_MODE) { @@ -1063,7 +1064,7 @@ public final class dAtomDefinition extends cElementalDefinition { if (tree.removeAllAmounts(false, dHadronDefinition.hadron_p1,eLeptonDefinition.lepton_e1)) { try { tree.putUnify(dHadronDefinition.hadron_n1); - decaysList.add(new cElementalDecay((float) 1, new cElementalDefinitionStack(new dAtomDefinition(tree.toImmutable_unsafeMightLeaveExposedElementalTree()), 1), eNeutrinoDefinition.lepton_Ve1)); + decaysList.add(new cElementalDecay((float) 1, new cElementalDefinitionStack(new dAtomDefinition(tree.toImmutable_optimized_unsafeLeavesExposedElementalTree()), 1), eNeutrinoDefinition.lepton_Ve1)); return true; } catch (Exception e) { if (DEBUG_MODE) { @@ -1112,9 +1113,9 @@ public final class dAtomDefinition extends cElementalDefinition { } try { - particles.putReplace(new cElementalDefinitionStack(new dAtomDefinition(fissile.toImmutable_unsafeMightLeaveExposedElementalTree()),1)); - particles.putReplace(new cElementalDefinitionStack(new dAtomDefinition(heavy.toImmutable_unsafeMightLeaveExposedElementalTree()),1)); - decaysList.add(new cElementalDecay(probability, particles.toImmutable_unsafeMightLeaveExposedElementalTree())); + particles.putReplace(new cElementalDefinitionStack(new dAtomDefinition(fissile.toImmutable_optimized_unsafeLeavesExposedElementalTree()),1)); + particles.putReplace(new cElementalDefinitionStack(new dAtomDefinition(heavy.toImmutable_optimized_unsafeLeavesExposedElementalTree()),1)); + decaysList.add(new cElementalDecay(probability, particles.toImmutable_optimized_unsafeLeavesExposedElementalTree())); return true; } catch (Exception e) { if(DEBUG_MODE) { @@ -1276,7 +1277,7 @@ public final class dAtomDefinition extends cElementalDefinition { anti.putReplace(new cElementalDefinitionStack(stack.definition.getAnti(), stack.amount)); } try { - return new dAtomDefinition(anti.toImmutable_unsafeMightLeaveExposedElementalTree()); + return new dAtomDefinition(anti.toImmutable_optimized_unsafeLeavesExposedElementalTree()); } catch (tElementalException e) { if (DEBUG_MODE) { e.printStackTrace(); @@ -1308,14 +1309,7 @@ public final class dAtomDefinition extends cElementalDefinition { @Override public NBTTagCompound toNBT() { - NBTTagCompound nbt = new NBTTagCompound(); - nbt.setByte("t", nbtType); - cElementalDefinitionStack[] elementalStacksValues = elementalStacks.values(); - nbt.setInteger("i", elementalStacksValues.length); - for (int i = 0; i < elementalStacksValues.length; i++) { - nbt.setTag(Integer.toString(i), elementalStacksValues[i].toNBT()); - } - return nbt; + return getNbtTagCompound(nbtType, elementalStacks); } public static dAtomDefinition fromNBT(NBTTagCompound nbt) { @@ -1624,6 +1618,10 @@ public final class dAtomDefinition extends cElementalDefinition { return 64; } + public static byte getClassTypeStatic(){ + return 64; + } + @Override public int hashCode() { return hash; diff --git a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/complex/hadron/dHadronDefinition.java b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/complex/hadron/dHadronDefinition.java index ed2cee8b2f..f24b9f2d82 100644 --- a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/complex/hadron/dHadronDefinition.java +++ b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/complex/hadron/dHadronDefinition.java @@ -19,6 +19,7 @@ import net.minecraftforge.oredict.OreDictionary; import java.util.ArrayList; +import static com.github.technus.tectech.compatibility.thaumcraft.elementalMatter.definitions.dComplexAspectDefinition.getNbtTagCompound; import static com.github.technus.tectech.loader.TecTechConfig.DEBUG_MODE; import static com.github.technus.tectech.mechanics.elementalMatter.definitions.complex.atom.dAtomDefinition.transformation; import static com.github.technus.tectech.mechanics.elementalMatter.definitions.primitive.eBosonDefinition.boson_Y__; @@ -324,7 +325,7 @@ public final class dHadronDefinition extends cElementalDefinition {//TODO Optimi anti.putReplace(new cElementalDefinitionStack(stack.definition.getAnti(), stack.amount)); } try { - return new dHadronDefinition(anti.toImmutable_unsafeMightLeaveExposedElementalTree()); + return new dHadronDefinition(anti.toImmutable_optimized_unsafeLeavesExposedElementalTree()); } catch (tElementalException e) { if (DEBUG_MODE) { e.printStackTrace(); @@ -350,14 +351,7 @@ public final class dHadronDefinition extends cElementalDefinition {//TODO Optimi @Override public NBTTagCompound toNBT() { - NBTTagCompound nbt = new NBTTagCompound(); - nbt.setByte("t", nbtType); - cElementalDefinitionStack[] quarkStacksValues = quarkStacks.values(); - nbt.setInteger("i", quarkStacksValues.length); - for (int i = 0; i < quarkStacksValues.length; i++) { - nbt.setTag(Integer.toString(i), quarkStacksValues[i].toNBT()); - } - return nbt; + return getNbtTagCompound(nbtType, quarkStacks); } public static dHadronDefinition fromNBT(NBTTagCompound nbt) { @@ -429,6 +423,10 @@ public final class dHadronDefinition extends cElementalDefinition {//TODO Optimi return -64; } + public static byte getClassTypeStatic(){ + return -64; + } + @Override public int hashCode() { return hash; 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 2cd6d79d22..1f68163238 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 @@ -4,7 +4,10 @@ import com.github.technus.tectech.CommonValues; import com.github.technus.tectech.Util; import com.github.technus.tectech.mechanics.elementalMatter.core.cElementalInstanceStackMap; import com.github.technus.tectech.mechanics.elementalMatter.core.iElementalInstanceContainer; +import com.github.technus.tectech.mechanics.elementalMatter.core.stacks.cElementalInstanceStack; import com.github.technus.tectech.mechanics.elementalMatter.core.tElementalException; +import com.github.technus.tectech.mechanics.elementalMatter.core.templates.iElementalDefinition; +import com.github.technus.tectech.mechanics.elementalMatter.core.transformations.bTransformationInfo; import cpw.mods.fml.common.registry.GameRegistry; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; @@ -71,6 +74,30 @@ public final class DebugElementalInstanceContainer_EM extends Item { return aPlayer instanceof EntityPlayerMP; } + public ItemStack setContent(ItemStack aStack,cElementalInstanceStackMap content){ + NBTTagCompound tNBT = aStack.getTagCompound(); + if(tNBT==null){ + aStack.setTagCompound(new NBTTagCompound()); + } + if (tNBT.hasKey("content")) { + try { + content.putUnifyAll(cElementalInstanceStackMap.fromNBT(tNBT.getCompoundTag("content"))); + } catch (tElementalException e) { + if (DEBUG_MODE) { + e.printStackTrace(); + } + return aStack; + } + tNBT.removeTag("content"); + tNBT.removeTag("info"); + } else if (content.hasStacks()) { + tNBT.setTag("info", content.getInfoNBT()); + tNBT.setTag("content", content.toNBT()); + content.clear(); + } + return aStack; + } + @Override public void addInformation(ItemStack aStack, EntityPlayer ep, List aList, boolean boo) { aList.add(CommonValues.TEC_MARK_EM); @@ -98,5 +125,10 @@ public final class DebugElementalInstanceContainer_EM extends Item { ItemStack that = new ItemStack(this, 1); that.setTagCompound(new NBTTagCompound()); list.add(that); + for(iElementalDefinition defintion:bTransformationInfo.stacksRegistered){ + list.add(setContent(new ItemStack(this).setStackDisplayName(defintion.getName()+" x"+1),new cElementalInstanceStackMap(new cElementalInstanceStack(defintion,1)))); + list.add(setContent(new ItemStack(this).setStackDisplayName(defintion.getName()+" x"+144),new cElementalInstanceStackMap(new cElementalInstanceStack(defintion,144)))); + list.add(setContent(new ItemStack(this).setStackDisplayName(defintion.getName()+" x"+1000),new cElementalInstanceStackMap(new cElementalInstanceStack(defintion,1000)))); + } } } 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 eb029d8726..dcee60d40b 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 @@ -2,9 +2,19 @@ package com.github.technus.tectech.thing.metaTileEntity.multi; import com.github.technus.tectech.CommonValues; import com.github.technus.tectech.TecTech; +import com.github.technus.tectech.compatibility.thaumcraft.elementalMatter.definitions.dComplexAspectDefinition; +import com.github.technus.tectech.compatibility.thaumcraft.elementalMatter.definitions.ePrimalAspectDefinition; +import com.github.technus.tectech.mechanics.elementalMatter.core.cElementalInstanceStackMap; +import com.github.technus.tectech.mechanics.elementalMatter.core.cElementalMutableDefinitionStackMap; +import com.github.technus.tectech.mechanics.elementalMatter.core.stacks.cElementalInstanceStack; +import com.github.technus.tectech.mechanics.elementalMatter.core.templates.cElementalPrimitive; +import com.github.technus.tectech.mechanics.elementalMatter.definitions.complex.atom.dAtomDefinition; +import com.github.technus.tectech.mechanics.elementalMatter.definitions.complex.hadron.dHadronDefinition; +import com.github.technus.tectech.mechanics.elementalMatter.definitions.primitive.eQuarkDefinition; import com.github.technus.tectech.thing.block.QuantumGlassBlock; import com.github.technus.tectech.thing.casing.TT_Container_Casings; import com.github.technus.tectech.thing.metaTileEntity.IConstructable; +import com.github.technus.tectech.thing.metaTileEntity.hatch.GT_MetaTileEntity_Hatch_InputElemental; import com.github.technus.tectech.thing.metaTileEntity.multi.base.GT_MetaTileEntity_MultiblockBase_EM; import com.github.technus.tectech.thing.metaTileEntity.multi.base.render.TT_RenderedTexture; import cpw.mods.fml.relauncher.Side; @@ -21,6 +31,8 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.EnumChatFormatting; import net.minecraftforge.common.util.ForgeDirection; +import java.util.HashMap; + import static com.github.technus.tectech.Util.StructureBuilderExtreme; import static com.github.technus.tectech.thing.casing.GT_Block_CasingsTT.textureOffset; import static com.github.technus.tectech.thing.casing.GT_Block_CasingsTT.texturePage; @@ -32,12 +44,231 @@ import static com.github.technus.tectech.thing.casing.TT_Container_Casings.sBloc public class GT_MetaTileEntity_EM_collider extends GT_MetaTileEntity_MultiblockBase_EM implements IConstructable { private static Textures.BlockIcons.CustomIcon ScreenOFF; private static Textures.BlockIcons.CustomIcon ScreenON; - public static long heliumPlasmaValue; + private static Textures.BlockIcons.CustomIcon ScreenON_Slave; + private static Textures.BlockIcons.CustomIcon ScreenOFF_Slave; + + private static double MASS_TO_EU_PARTIAL,MASS_TO_EU_INSTANT; + private static int STARTUP_COST,KEEPUP_COST; + + private long plasmaEnergy; + + public static void setValues(int heliumPlasmaValue){ + MASS_TO_EU_PARTIAL = heliumPlasmaValue / 1.75893000478707E07;//mass diff + MASS_TO_EU_INSTANT = MASS_TO_EU_PARTIAL * 20; + STARTUP_COST=-heliumPlasmaValue*10000; + KEEPUP_COST=-heliumPlasmaValue; + } + + //region collision handlers + public static final HashMap<Integer, ColliderHandler> FUSE_HANDLERS =new HashMap<>(); + public static final HashMap<String, PrimitiveColliderHandler> PRIMITIVE_FUSE_HANDLERS =new HashMap<>(); + public interface PrimitiveColliderHandler { + void collide(cElementalInstanceStack in1, cElementalInstanceStack in2, cElementalInstanceStackMap out); + } + public interface ColliderHandler extends PrimitiveColliderHandler { + byte getRequiredTier(); + } + static { + FUSE_HANDLERS.put((dAtomDefinition.getClassTypeStatic() << 16) | dAtomDefinition.getClassTypeStatic(), new ColliderHandler() { + @Override + public void collide(cElementalInstanceStack in1, cElementalInstanceStack in2, cElementalInstanceStackMap out) { + try { + cElementalMutableDefinitionStackMap defs=new cElementalMutableDefinitionStackMap(); + defs.putUnifyAll(in1.definition.getSubParticles()); + defs.putUnifyAll(in2.definition.getSubParticles()); + dAtomDefinition atom = new dAtomDefinition(defs.toImmutable_optimized_unsafeLeavesExposedElementalTree()); + out.putUnify(new cElementalInstanceStack(atom,Math.min(in1.amount,in2.amount))); + }catch (Exception e){ + out.putUnifyAll(in1,in2); + return; + } + if(in1.amount>in2.amount){ + out.putUnify(new cElementalInstanceStack(in1.definition,in1.amount-in2.amount)); + }else if (in2.amount>in1.amount){ + out.putUnify(new cElementalInstanceStack(in2.definition,in2.amount-in1.amount)); + } + } + + @Override + public byte getRequiredTier() { + return 1; + } + }); + registerSimpleAtomFuse(dHadronDefinition.getClassTypeStatic()); + registerSimpleAtomFuse(dComplexAspectDefinition.getClassTypeStatic()); + registerSimpleAtomFuse(cElementalPrimitive.getClassTypeStatic()); + + FUSE_HANDLERS.put((dHadronDefinition.getClassTypeStatic() << 16) | dHadronDefinition.getClassTypeStatic(), new ColliderHandler() { + @Override + public void collide(cElementalInstanceStack in1, cElementalInstanceStack in2, cElementalInstanceStackMap out) { + try { + cElementalMutableDefinitionStackMap defs=new cElementalMutableDefinitionStackMap(); + defs.putUnifyAll(in1.definition.getSubParticles()); + defs.putUnifyAll(in2.definition.getSubParticles()); + dHadronDefinition hadron = new dHadronDefinition(defs.toImmutable_optimized_unsafeLeavesExposedElementalTree()); + out.putUnify(new cElementalInstanceStack(hadron,Math.min(in1.amount,in2.amount))); + }catch (Exception e){ + out.putUnifyAll(in1,in2); + return; + } + if(in1.amount>in2.amount){ + out.putUnify(new cElementalInstanceStack(in1.definition,in1.amount-in2.amount)); + }else if (in2.amount>in1.amount){ + out.putUnify(new cElementalInstanceStack(in2.definition,in2.amount-in1.amount)); + } + } + + @Override + public byte getRequiredTier() { + return 2; + } + }); + FUSE_HANDLERS.put((dHadronDefinition.getClassTypeStatic() << 16) | cElementalPrimitive.getClassTypeStatic(), new ColliderHandler() { + @Override + public void collide(cElementalInstanceStack in1, cElementalInstanceStack in2, cElementalInstanceStackMap out) { + try { + cElementalMutableDefinitionStackMap defs=new cElementalMutableDefinitionStackMap(); + defs.putUnifyAll(in1.definition.getSubParticles()); + defs.putUnify(in2.definition.getStackForm(1)); + dHadronDefinition hadron = new dHadronDefinition(defs.toImmutable_optimized_unsafeLeavesExposedElementalTree()); + out.putUnify(new cElementalInstanceStack(hadron,Math.min(in1.amount,in2.amount))); + }catch (Exception e){ + out.putUnifyAll(in1,in2); + return; + } + if(in1.amount>in2.amount){ + out.putUnify(new cElementalInstanceStack(in1.definition,in1.amount-in2.amount)); + }else if (in2.amount>in1.amount){ + out.putUnify(new cElementalInstanceStack(in2.definition,in2.amount-in1.amount)); + } + } + + @Override + public byte getRequiredTier() { + return 2; + } + }); + + registerSimpleAspectFuse(dComplexAspectDefinition.getClassTypeStatic()); + registerSimpleAspectFuse(cElementalPrimitive.getClassTypeStatic()); + + FUSE_HANDLERS.put((cElementalPrimitive.getClassTypeStatic() << 16) | cElementalPrimitive.getClassTypeStatic(), new ColliderHandler() { + @Override + public void collide(cElementalInstanceStack in1, cElementalInstanceStack in2, cElementalInstanceStackMap out) { + PrimitiveColliderHandler collisionHandler= PRIMITIVE_FUSE_HANDLERS.get(in1.definition.getClass().getName()+'\0'+in2.definition.getClass().getName()); + if (collisionHandler != null) { + collisionHandler.collide(in2, in1, out); + } else { + out.putUnifyAll(in1,in2); + } + } + + @Override + public byte getRequiredTier() { + return 2; + } + }); + + PRIMITIVE_FUSE_HANDLERS.put(eQuarkDefinition.class.getName() + '\0' + eQuarkDefinition.class.getName(), new PrimitiveColliderHandler() { + @Override + public void collide(cElementalInstanceStack in1, cElementalInstanceStack in2, cElementalInstanceStackMap out) { + try { + cElementalMutableDefinitionStackMap defs=new cElementalMutableDefinitionStackMap(); + defs.putUnify(in1.definition.getStackForm(1)); + defs.putUnify(in2.definition.getStackForm(1)); + dHadronDefinition hadron = new dHadronDefinition(defs.toImmutable_optimized_unsafeLeavesExposedElementalTree()); + out.putUnify(new cElementalInstanceStack(hadron,Math.min(in1.amount,in2.amount))); + }catch (Exception e){ + out.putUnifyAll(in1,in2); + return; + } + if(in1.amount>in2.amount){ + out.putUnify(new cElementalInstanceStack(in1.definition,in1.amount-in2.amount)); + }else if (in2.amount>in1.amount){ + out.putUnify(new cElementalInstanceStack(in2.definition,in2.amount-in1.amount)); + } + } + }); + PRIMITIVE_FUSE_HANDLERS.put(ePrimalAspectDefinition.class.getName() + '\0' + ePrimalAspectDefinition.class.getName(), new PrimitiveColliderHandler() { + @Override + public void collide(cElementalInstanceStack in1, cElementalInstanceStack in2, cElementalInstanceStackMap out) { + if (fuseAspects(in1, in2, out)) return; + if(in1.amount>in2.amount){ + out.putUnify(new cElementalInstanceStack(in1.definition,in1.amount-in2.amount)); + }else if (in2.amount>in1.amount){ + out.putUnify(new cElementalInstanceStack(in2.definition,in2.amount-in1.amount)); + } + } + }); + } + + private static boolean fuseAspects(cElementalInstanceStack in1, cElementalInstanceStack in2, cElementalInstanceStackMap out) { + try { + cElementalMutableDefinitionStackMap defs=new cElementalMutableDefinitionStackMap(); + defs.putUnify(in1.definition.getStackForm(1)); + defs.putUnify(in2.definition.getStackForm(1)); + dComplexAspectDefinition aspect = new dComplexAspectDefinition(defs.toImmutable_optimized_unsafeLeavesExposedElementalTree()); + out.putUnify(new cElementalInstanceStack(aspect,Math.min(in1.amount,in2.amount))); + }catch (Exception e){ + out.putUnifyAll(in1,in2); + return true; + } + return false; + } + + private static void registerSimpleAspectFuse(byte classTypeStatic) { + FUSE_HANDLERS.put((dComplexAspectDefinition.getClassTypeStatic() << 16) | classTypeStatic, new ColliderHandler() { + @Override + public void collide(cElementalInstanceStack in1, cElementalInstanceStack in2, cElementalInstanceStackMap out) { + if (fuseAspects(in1, in2, out)) return; + if(in1.amount>in2.amount){ + out.putUnify(new cElementalInstanceStack(in1.definition,in1.amount-in2.amount)); + }else if (in2.amount>in1.amount){ + out.putUnify(new cElementalInstanceStack(in2.definition,in2.amount-in1.amount)); + } + } + + @Override + public byte getRequiredTier() { + return 1; + } + }); + } + + private static void registerSimpleAtomFuse(byte classTypeStatic) { + FUSE_HANDLERS.put((dAtomDefinition.getClassTypeStatic() << 16) | classTypeStatic, new ColliderHandler() { + @Override + public void collide(cElementalInstanceStack in1, cElementalInstanceStack in2, cElementalInstanceStackMap out) { + try { + cElementalMutableDefinitionStackMap defs=new cElementalMutableDefinitionStackMap(); + defs.putUnifyAll(in1.definition.getSubParticles()); + defs.putUnify(in2.definition.getStackForm(1)); + dAtomDefinition atom = new dAtomDefinition(defs.toImmutable_optimized_unsafeLeavesExposedElementalTree()); + out.putUnify(new cElementalInstanceStack(atom,Math.min(in1.amount,in2.amount))); + }catch (Exception e){ + out.putUnifyAll(in1,in2); + return; + } + if(in1.amount>in2.amount){ + out.putUnify(new cElementalInstanceStack(in1.definition,in1.amount-in2.amount)); + }else if (in2.amount>in1.amount){ + out.putUnify(new cElementalInstanceStack(in2.definition,in2.amount-in1.amount)); + } + } - private byte eTier = 0; + @Override + public byte getRequiredTier() { + return 1; + } + }); + } + //endregion + + protected byte eTier = 0; + protected cElementalInstanceStack stack; - protected long startupCost=10_000_000_000L; - protected double currentVelocity=-1,targetVelocity=-1; + protected static final byte FUSE_MODE=0, COLLIDE_MODE =1; + protected boolean started=false; //region Structure //use multi A energy inputs, use less power the longer it runs @@ -106,13 +337,19 @@ public class GT_MetaTileEntity_EM_collider extends GT_MetaTileEntity_MultiblockB public void registerIcons(IIconRegister aBlockIconRegister) { ScreenOFF = new Textures.BlockIcons.CustomIcon("iconsets/EM_COLLIDER"); ScreenON = new Textures.BlockIcons.CustomIcon("iconsets/EM_COLLIDER_ACTIVE"); + ScreenOFF_Slave = new Textures.BlockIcons.CustomIcon("iconsets/EM_COLLIDER_SLAVE"); + ScreenON_Slave = new Textures.BlockIcons.CustomIcon("iconsets/EM_COLLIDER_ACTIVE_SLAVE"); super.registerIcons(aBlockIconRegister); } @Override public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { if (aSide == aFacing) { - return new ITexture[]{Textures.BlockIcons.casingTexturePages[texturePage][4], new TT_RenderedTexture(aActive ? ScreenON : ScreenOFF)}; + if(aFacing%2==0){ + return new ITexture[]{Textures.BlockIcons.casingTexturePages[texturePage][4], new TT_RenderedTexture(aActive ? ScreenON : ScreenOFF)}; + }else{ + return new ITexture[]{Textures.BlockIcons.casingTexturePages[texturePage][4], new TT_RenderedTexture(aActive ? ScreenON_Slave : ScreenOFF_Slave)}; + } } return new ITexture[]{Textures.BlockIcons.casingTexturePages[texturePage][4]}; } @@ -121,16 +358,22 @@ public class GT_MetaTileEntity_EM_collider extends GT_MetaTileEntity_MultiblockB public void saveNBTData(NBTTagCompound aNBT) { super.saveNBTData(aNBT); aNBT.setByte("eTier", eTier);//collider tier - aNBT.setDouble("eCurrentVelocity",currentVelocity); - aNBT.setDouble("eTargetVelocity",targetVelocity); + aNBT.setBoolean("eStarted",started); + if(stack!=null) { + aNBT.setTag("eStack", stack.toNBT()); + } + aNBT.setLong("ePlasmaEnergy",plasmaEnergy); } @Override public void loadNBTData(NBTTagCompound aNBT) { super.loadNBTData(aNBT); eTier = aNBT.getByte("eTier");//collider tier - currentVelocity=aNBT.getDouble("eCurrentVelocity"); - targetVelocity=aNBT.getDouble("eTargetVelocity"); + started=aNBT.getBoolean("eStarted"); + if(aNBT.hasKey("eStack")){ + stack=cElementalInstanceStack.fromNBT(aNBT.getCompoundTag("eStack")); + } + plasmaEnergy=aNBT.getLong("ePlasmaEnergy"); } @Override @@ -195,13 +438,19 @@ public class GT_MetaTileEntity_EM_collider extends GT_MetaTileEntity_MultiblockB } @Override - protected void parametersLoadDefault_EM() { - //setParameterPairIn_ClearOut(0,false,) - } - - @Override public void parametersOutAndStatusesWrite_EM(boolean machineBusy) { - //setStatusOfParameterIn(0,0,); + if(isMaster()) { + double mode = getParameterIn(0, 0); + if (mode == FUSE_MODE || mode == COLLIDE_MODE) { + setStatusOfParameterIn(0, 0, STATUS_OK); + } else if (mode > 1) { + setStatusOfParameterIn(0, 0, STATUS_TOO_HIGH); + } else if (mode < 0) { + setStatusOfParameterIn(0, 0, STATUS_TOO_LOW); + }else{ + setStatusOfParameterIn(0,0,STATUS_WRONG); + } + } } @Override @@ -210,35 +459,126 @@ public class GT_MetaTileEntity_EM_collider extends GT_MetaTileEntity_MultiblockB if(partner==null){ return false; } - if(isMaster()){ - + mEfficiencyIncrease=10000; + if(started) { + if(stack==null) { + for (GT_MetaTileEntity_Hatch_InputElemental inputElemental : eInputHatches) { + cElementalInstanceStackMap container = inputElemental.getContainerHandler(); + if (container.isEmpty()) { + continue; + } + stack = container.remove(container.getFirst().definition); + long eut = KEEPUP_COST+(long)(KEEPUP_COST * Math.abs(stack.getMass() / dAtomDefinition.getSomethingHeavy().getMass()))/2; + if (eut < Integer.MIN_VALUE + 7) { + return false; + } + mMaxProgresstime = 20; + mEUt = (int) eut; + eAmpereFlow = 5; + return true; + } + mMaxProgresstime = 20; + mEUt = KEEPUP_COST; + eAmpereFlow = 1; + return true; + } + mMaxProgresstime = 20; + mEUt = KEEPUP_COST; + eAmpereFlow = 2; + return true; }else{ + started=true; + mMaxProgresstime=20; + mEUt=STARTUP_COST; + eAmpereFlow=10; + return true; + } + } + + protected double fuse(GT_MetaTileEntity_EM_collider partner){ + if(partner.stack!=null && stack!=null) {//todo add single event mode as an option + boolean check=stack.definition.decayMakesEnergy(stack.getEnergy()) && + partner.stack.definition.decayMakesEnergy(partner.stack.getEnergy()); + + cElementalInstanceStack stack2 = partner.stack; + partner.stack = null; + double preMass = stack2.getMass() + stack.getMass(); + //System.out.println("preMass = " + preMass); + + cElementalInstanceStackMap map = new cElementalInstanceStackMap(); + ColliderHandler colliderHandler; + if (stack2.definition.getClassType() > stack.definition.getClassType()) {//always bigger first + colliderHandler = FUSE_HANDLERS.get((stack2.definition.getClassType() << 16) | stack.definition.getClassType()); + if (handleRecipe(stack2, map, colliderHandler)) return 0; + } else { + colliderHandler = FUSE_HANDLERS.get((stack.definition.getClassType() << 16) | stack2.definition.getClassType()); + if (handleRecipe(stack2, map, colliderHandler)) return 0; + } + for (cElementalInstanceStack newStack : map.values()) { + check &= newStack.definition.decayMakesEnergy(newStack.getEnergy()); + } + //System.out.println("outputEM[0].getMass() = " + outputEM[0].getMass()); + outputEM = new cElementalInstanceStackMap[]{map}; + return check ? preMass - map.getMass() : + Math.min(preMass - map.getMass(), 0); + } + return 0; + } + private boolean handleRecipe(cElementalInstanceStack stack2, cElementalInstanceStackMap map, ColliderHandler colliderHandler) { + if (colliderHandler != null && eTier>= colliderHandler.getRequiredTier()) { + colliderHandler.collide(stack2, stack, map); + } else { + map.putUnifyAll(stack,stack2); + outputEM=new cElementalInstanceStackMap[]{map}; + return true; } return false; } @Override protected void afterRecipeCheckFailed() { - currentVelocity=-1; + started=false; + if(stack!=null){ + cleanMassEM_EM(stack.getMass()); + stack=null; + } + getBaseMetaTileEntity().disableWorking(); super.afterRecipeCheckFailed(); } @Override public void stopMachine() { - currentVelocity=-1; + started=false; + if(stack!=null){ + cleanMassEM_EM(stack.getMass()); + stack=null; + } super.stopMachine(); } + @Override + public void onPreTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + if(!aBaseMetaTileEntity.isAllowedToWork()){ + started=false; + } + super.onPreTick(aBaseMetaTileEntity, aTick); + } + protected GT_MetaTileEntity_EM_collider getPartner(){ IGregTechTileEntity iGregTechTileEntity=getBaseMetaTileEntity(); int xDir = ForgeDirection.getOrientation(iGregTechTileEntity.getBackFacing()).offsetX*4; int yDir = ForgeDirection.getOrientation(iGregTechTileEntity.getBackFacing()).offsetY*4; int zDir = ForgeDirection.getOrientation(iGregTechTileEntity.getBackFacing()).offsetZ*4; - IGregTechTileEntity gregTechTileEntity=iGregTechTileEntity.getIGregTechTileEntityOffset(iGregTechTileEntity.getXCoord()+xDir, - iGregTechTileEntity.getYCoord()+yDir, - iGregTechTileEntity.getZCoord()+zDir); - return gregTechTileEntity instanceof GT_MetaTileEntity_EM_collider && ((GT_MetaTileEntity_EM_collider) gregTechTileEntity).mMachine && gregTechTileEntity.getBackFacing()==iGregTechTileEntity.getFrontFacing() ? (GT_MetaTileEntity_EM_collider)gregTechTileEntity:null; + IGregTechTileEntity gregTechBaseTileEntity=iGregTechTileEntity.getIGregTechTileEntityOffset(xDir, yDir, zDir); + if(gregTechBaseTileEntity!=null) { + IMetaTileEntity gregTechMetaTileEntity = gregTechBaseTileEntity.getMetaTileEntity(); + return gregTechMetaTileEntity instanceof GT_MetaTileEntity_EM_collider && + ((GT_MetaTileEntity_EM_collider) gregTechMetaTileEntity).mMachine && + gregTechBaseTileEntity.getBackFacing() == iGregTechTileEntity.getFrontFacing() ? + (GT_MetaTileEntity_EM_collider) gregTechMetaTileEntity : null; + } + return null; } protected final boolean isMaster(){ @@ -247,14 +587,61 @@ public class GT_MetaTileEntity_EM_collider extends GT_MetaTileEntity_MultiblockB @Override public void outputAfterRecipe_EM(){ - if(outputEM!=null) { - for(int i=0,lim=Math.min(outputEM.length,eOutputHatches.size());i<lim;i++){ - if(outputEM[i]!=null) { - eOutputHatches.get(i).getContainerHandler().putUnifyAll(outputEM[i]); - outputEM[i]=null; + GT_MetaTileEntity_EM_collider partner=getPartner(); + if(partner==null){ + if(stack!=null){ + cleanMassEM_EM(stack.getMass()); + stack=null; + } + return; + } + if (isMaster()) { + switch (getParameterInInt(0,0)){ + case FUSE_MODE: + makeEU(fuse(partner)); + break; + case COLLIDE_MODE: + //collide(partner);//todo + break; + default: { + outputEM=new cElementalInstanceStackMap[2]; + outputEM[1]=tickStack(); + if(outputEM[1]==null){ + outputEM[1]=partner.tickStack(); + }else { + cElementalInstanceStackMap map=partner.tickStack(); + if(map!=null){ + outputEM[1].putUnifyAll(map); + } + } } } + if(outputEM!=null) { + for(int i=0,lim=Math.min(outputEM.length,eOutputHatches.size());i<lim;i++){ + if(outputEM[i]!=null) { + eOutputHatches.get(i).getContainerHandler().putUnifyAll(outputEM[i]); + outputEM[i]=null; + } + } + } + } + } + + private void makeEU(double massDiff){ + plasmaEnergy+=massDiff*MASS_TO_EU_INSTANT; + } + + private cElementalInstanceStackMap tickStack(){ + if(stack==null){ + return null; + } + cElementalInstanceStackMap newInstances = stack.decay(1, stack.age += 1, 0); + if (newInstances == null) { + stack.nextColor(); + } else { + stack=newInstances.remove(newInstances.getLast().definition); } + return newInstances; } @Override diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/base/GT_MetaTileEntity_MultiblockBase_EM.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/base/GT_MetaTileEntity_MultiblockBase_EM.java index 7a6d45f726..ebcc0ef622 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/base/GT_MetaTileEntity_MultiblockBase_EM.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/base/GT_MetaTileEntity_MultiblockBase_EM.java @@ -1092,27 +1092,7 @@ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEnt */ @Override public void stopMachine() { - if (outputEM != null) { - float mass = 0; - for (cElementalInstanceStackMap tree : outputEM) { - if (tree != null) { - mass += tree.getMass(); - } - } - if (mass > 0) { - if (eMufflerHatches.size() < 1) { - explodeMultiblock(); - } else { - mass /= eMufflerHatches.size(); - for (GT_MetaTileEntity_Hatch_OverflowElemental dump : eMufflerHatches) { - if (dump.addOverflowMatter(mass)) { - explodeMultiblock(); - } - } - } - } - outputEM = null; - } + cleanOrExplode(); for (GT_MetaTileEntity_Hatch_OutputData data : eOutputData) { data.q = null; @@ -1134,6 +1114,24 @@ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEnt * helper method so i don't have to set that params to nothing at all times */ protected void afterRecipeCheckFailed(){ + cleanOrExplode(); + + for (GT_MetaTileEntity_Hatch_OutputData data : eOutputData) { + data.q = null; + } + + mOutputItems = null; + mOutputFluids = null; + mEfficiency = 0; + mEfficiencyIncrease = 0; + mProgresstime = 0; + mMaxProgresstime = 0; + eAvailableData = 0; + //getBaseMetaTileEntity().disableWorking(); //can add in override + //hatchesStatusUpdate_EM(); //called always after recipe checks + } + + private void cleanOrExplode() { if (outputEM != null) { float mass = 0; for (cElementalInstanceStackMap tree : outputEM) { @@ -1155,20 +1153,6 @@ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEnt } outputEM = null; } - - for (GT_MetaTileEntity_Hatch_OutputData data : eOutputData) { - data.q = null; - } - - mOutputItems = null; - mOutputFluids = null; - mEfficiency = 0; - mEfficiencyIncrease = 0; - mProgresstime = 0; - //mMaxProgresstime = 0; //Done after this - cos it is VITAL! - eAvailableData = 0; - //getBaseMetaTileEntity().disableWorking(); - //hatchesStatusUpdate_EM(); //called always after recipe checks } /** @@ -1689,7 +1673,6 @@ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEnt mEfficiency = Math.max(0, Math.min(mEfficiency + mEfficiencyIncrease, getMaxEfficiency(mInventory[1]) - (getIdealStatus() - getRepairStatus()) * 1000)); }else { afterRecipeCheckFailed(); - mMaxProgresstime=0;//Just to be sure... } updateSlots(); } else { @@ -1705,7 +1688,6 @@ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEnt mEfficiency = Math.max(0, Math.min(mEfficiency + mEfficiencyIncrease, getMaxEfficiency(mInventory[1]) - (getIdealStatus() - getRepairStatus()) * 1000)); }else { afterRecipeCheckFailed(); - mMaxProgresstime=0;//Just to be sure... } updateSlots(); } //else notAllowedToWork_stopMachine_EM(); //it is already stopped here diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/pipe/GT_MetaTileEntity_Pipe_Laser.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/pipe/GT_MetaTileEntity_Pipe_Laser.java new file mode 100644 index 0000000000..4366fe2bbd --- /dev/null +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/pipe/GT_MetaTileEntity_Pipe_Laser.java @@ -0,0 +1,5 @@ +package com.github.technus.tectech.thing.metaTileEntity.pipe; + +public class GT_MetaTileEntity_Pipe_Laser { + +} diff --git a/src/main/resources/assets/gregtech/textures/blocks/iconsets/EM_COLLIDER.png b/src/main/resources/assets/gregtech/textures/blocks/iconsets/EM_COLLIDER.png Binary files differindex 910d8cf7cd..187394cf54 100644 --- a/src/main/resources/assets/gregtech/textures/blocks/iconsets/EM_COLLIDER.png +++ b/src/main/resources/assets/gregtech/textures/blocks/iconsets/EM_COLLIDER.png diff --git a/src/main/resources/assets/gregtech/textures/blocks/iconsets/EM_COLLIDER_ACTIVE.png b/src/main/resources/assets/gregtech/textures/blocks/iconsets/EM_COLLIDER_ACTIVE.png Binary files differindex b9efef601a..9d3bfe7284 100644 --- a/src/main/resources/assets/gregtech/textures/blocks/iconsets/EM_COLLIDER_ACTIVE.png +++ b/src/main/resources/assets/gregtech/textures/blocks/iconsets/EM_COLLIDER_ACTIVE.png diff --git a/src/main/resources/assets/gregtech/textures/blocks/iconsets/EM_COLLIDER_ACTIVE_SLAVE.png b/src/main/resources/assets/gregtech/textures/blocks/iconsets/EM_COLLIDER_ACTIVE_SLAVE.png Binary files differnew file mode 100644 index 0000000000..e76cd31b5e --- /dev/null +++ b/src/main/resources/assets/gregtech/textures/blocks/iconsets/EM_COLLIDER_ACTIVE_SLAVE.png diff --git a/src/main/resources/assets/gregtech/textures/blocks/iconsets/EM_COLLIDER_ACTIVE_SLAVE.png.mcmeta b/src/main/resources/assets/gregtech/textures/blocks/iconsets/EM_COLLIDER_ACTIVE_SLAVE.png.mcmeta new file mode 100644 index 0000000000..97596ba817 --- /dev/null +++ b/src/main/resources/assets/gregtech/textures/blocks/iconsets/EM_COLLIDER_ACTIVE_SLAVE.png.mcmeta @@ -0,0 +1,5 @@ +{ + "animation":{ + "frametime":2 + } +}
\ No newline at end of file diff --git a/src/main/resources/assets/gregtech/textures/blocks/iconsets/EM_COLLIDER_SLAVE.png b/src/main/resources/assets/gregtech/textures/blocks/iconsets/EM_COLLIDER_SLAVE.png Binary files differnew file mode 100644 index 0000000000..58cb0a9573 --- /dev/null +++ b/src/main/resources/assets/gregtech/textures/blocks/iconsets/EM_COLLIDER_SLAVE.png diff --git a/src/main/resources/assets/gregtech/textures/blocks/iconsets/EM_COLLIDER_SLAVE.png.mcmeta b/src/main/resources/assets/gregtech/textures/blocks/iconsets/EM_COLLIDER_SLAVE.png.mcmeta new file mode 100644 index 0000000000..5e86a7cd5f --- /dev/null +++ b/src/main/resources/assets/gregtech/textures/blocks/iconsets/EM_COLLIDER_SLAVE.png.mcmeta @@ -0,0 +1,5 @@ +{ + "animation":{ + "frametime":8 + } +}
\ No newline at end of file |