aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTechnus <daniel112092@gmail.com>2017-12-29 19:34:59 +0100
committerTechnus <daniel112092@gmail.com>2017-12-29 19:34:59 +0100
commit701be18f07ad3562a059cf934c00fa2fb2bb53ef (patch)
tree96940e84b1edb9427c4be69b4799a7574f192044
parent18622e9eeee695ab9b69a326798f903f9371483f (diff)
downloadGT5-Unofficial-701be18f07ad3562a059cf934c00fa2fb2bb53ef.tar.gz
GT5-Unofficial-701be18f07ad3562a059cf934c00fa2fb2bb53ef.tar.bz2
GT5-Unofficial-701be18f07ad3562a059cf934c00fa2fb2bb53ef.zip
First draft of EM centrifuge and electromagnetic separator
-rw-r--r--src/main/java/com/github/technus/tectech/Util.java54
-rw-r--r--src/main/java/com/github/technus/tectech/compatibility/dreamcraft/DreamCraftRecipeLoader.java21
-rw-r--r--src/main/java/com/github/technus/tectech/elementalMatter/core/cElementalInstanceStackMap.java22
-rw-r--r--src/main/java/com/github/technus/tectech/elementalMatter/core/cElementalStackMap.java13
-rw-r--r--src/main/java/com/github/technus/tectech/elementalMatter/definitions/complex/atom/dAtomDefinition.java20
-rw-r--r--src/main/java/com/github/technus/tectech/loader/BloodyRecipeLoader.java37
-rw-r--r--src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_scanner.java2
-rw-r--r--src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/base/MultiblockControl.java15
-rw-r--r--src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/em_machine/Behaviour_Centrifuge.java200
-rw-r--r--src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/em_machine/Behaviour_Electrolyzer.java4
-rw-r--r--src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/em_machine/Behaviour_ElectromagneticSeparator.java203
-rw-r--r--src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/em_machine/Behaviour_Mixer.java4
-rw-r--r--src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/em_machine/Behaviour_PrecisionLaser.java4
-rw-r--r--src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/em_machine/Behaviour_Recycler.java4
-rw-r--r--src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/em_machine/GT_MetaTileEntity_EM_machine.java150
15 files changed, 643 insertions, 110 deletions
diff --git a/src/main/java/com/github/technus/tectech/Util.java b/src/main/java/com/github/technus/tectech/Util.java
index ff9e7f6cb8..e8786e4b84 100644
--- a/src/main/java/com/github/technus/tectech/Util.java
+++ b/src/main/java/com/github/technus/tectech/Util.java
@@ -5,11 +5,14 @@ import cpw.mods.fml.common.registry.GameRegistry;
import gregtech.api.GregTech_API;
import gregtech.api.interfaces.metatileentity.IMetaTileEntity;
import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
+import gregtech.api.objects.GT_ItemStack;
import gregtech.api.util.GT_OreDictUnificator;
import gregtech.api.util.GT_Utility;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.init.Blocks;
+import net.minecraft.init.Items;
+import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
@@ -907,4 +910,55 @@ public final class Util {
public static boolean areBitsSet(int setBits,int testedValue){
return (testedValue&setBits)==setBits;
}
+
+ public static class TT_ItemStack {
+ public final Item mItem;
+ public final int mStackSize;
+ public final int mMetaData;
+
+ public TT_ItemStack(Item aItem, long aStackSize, long aMetaData) {
+ this.mItem = aItem;
+ this.mStackSize = (byte)((int)aStackSize);
+ this.mMetaData = (short)((int)aMetaData);
+ }
+
+ public TT_ItemStack(ItemStack aStack) {
+ if(aStack==null){
+ mItem=null;
+ mStackSize=0;
+ mMetaData=0;
+ }else{
+ mItem=aStack.getItem();
+ mStackSize=aStack.stackSize;
+ mMetaData=aStack.getItemDamage();
+ }
+ }
+
+ public TT_ItemStack(int aHashCode) {
+ this(GT_Utility.intToStack(aHashCode));
+ }
+
+ public final ItemStack toStack() {
+ return this.mItem == null?null:new ItemStack(this.mItem, 1, this.mMetaData);
+ }
+
+ public final boolean isStackEqual(ItemStack aStack) {
+ return GT_Utility.areStacksEqual(this.toStack(), aStack);
+ }
+
+ public final boolean isStackEqual(GT_ItemStack aStack) {
+ return GT_Utility.areStacksEqual(this.toStack(), aStack.toStack());
+ }
+
+ public boolean equals(Object aStack) {
+ return aStack == this ||
+ (aStack instanceof TT_ItemStack &&
+ (((TT_ItemStack) aStack).mItem == this.mItem &&
+ ((TT_ItemStack) aStack).mMetaData == this.mMetaData));
+ }
+
+ public int hashCode() {
+ return GT_Utility.stackToInt(this.toStack());
+ }
+ }
}
diff --git a/src/main/java/com/github/technus/tectech/compatibility/dreamcraft/DreamCraftRecipeLoader.java b/src/main/java/com/github/technus/tectech/compatibility/dreamcraft/DreamCraftRecipeLoader.java
index 8360d9edf7..6cb1b669e9 100644
--- a/src/main/java/com/github/technus/tectech/compatibility/dreamcraft/DreamCraftRecipeLoader.java
+++ b/src/main/java/com/github/technus/tectech/compatibility/dreamcraft/DreamCraftRecipeLoader.java
@@ -4,6 +4,9 @@ import com.github.technus.tectech.recipe.TT_recipeAdder;
import com.github.technus.tectech.thing.CustomItemList;
import com.github.technus.tectech.thing.block.QuantumGlassBlock;
import com.github.technus.tectech.thing.item.ConstructableTriggerItem;
+import com.github.technus.tectech.thing.metaTileEntity.multi.em_machine.Behaviour_Centrifuge;
+import com.github.technus.tectech.thing.metaTileEntity.multi.em_machine.Behaviour_ElectromagneticSeparator;
+import com.github.technus.tectech.thing.metaTileEntity.multi.em_machine.GT_MetaTileEntity_EM_machine;
import gregtech.api.enums.*;
import gregtech.api.util.GT_ModHandler;
import gregtech.api.util.GT_OreDictUnificator;
@@ -410,6 +413,22 @@ public class DreamCraftRecipeLoader implements Runnable {
}
private void register_machine_EM_behaviours(){
-
+ GT_MetaTileEntity_EM_machine.registerBehaviour(new Behaviour_Centrifuge(5),ItemList.Machine_IV_Centrifuge.get(1));
+ GT_MetaTileEntity_EM_machine.registerBehaviour(new Behaviour_Centrifuge(6),com.dreammaster.gthandler.CustomItemList.CentrifugeLuV.get(1));
+ GT_MetaTileEntity_EM_machine.registerBehaviour(new Behaviour_Centrifuge(7),com.dreammaster.gthandler.CustomItemList.CentrifugeZPM.get(1));
+ GT_MetaTileEntity_EM_machine.registerBehaviour(new Behaviour_Centrifuge(8),com.dreammaster.gthandler.CustomItemList.CentrifugeUV.get(1));
+ GT_MetaTileEntity_EM_machine.registerBehaviour(new Behaviour_Centrifuge(9),com.dreammaster.gthandler.CustomItemList.CentrifugeUHV.get(1));
+ GT_MetaTileEntity_EM_machine.registerBehaviour(new Behaviour_Centrifuge(10),com.dreammaster.gthandler.CustomItemList.CentrifugeUEV.get(1));
+ GT_MetaTileEntity_EM_machine.registerBehaviour(new Behaviour_Centrifuge(11),com.dreammaster.gthandler.CustomItemList.CentrifugeUIV.get(1));
+ GT_MetaTileEntity_EM_machine.registerBehaviour(new Behaviour_Centrifuge(12),com.dreammaster.gthandler.CustomItemList.CentrifugeUMV.get(1));
+
+ GT_MetaTileEntity_EM_machine.registerBehaviour(new Behaviour_ElectromagneticSeparator(5),ItemList.Machine_IV_ElectromagneticSeparator.get(1));
+ GT_MetaTileEntity_EM_machine.registerBehaviour(new Behaviour_ElectromagneticSeparator(6),com.dreammaster.gthandler.CustomItemList.ElectromagneticSeparatorLuV.get(1));
+ GT_MetaTileEntity_EM_machine.registerBehaviour(new Behaviour_ElectromagneticSeparator(7),com.dreammaster.gthandler.CustomItemList.ElectromagneticSeparatorZPM.get(1));
+ GT_MetaTileEntity_EM_machine.registerBehaviour(new Behaviour_ElectromagneticSeparator(8),com.dreammaster.gthandler.CustomItemList.ElectromagneticSeparatorUV.get(1));
+ GT_MetaTileEntity_EM_machine.registerBehaviour(new Behaviour_ElectromagneticSeparator(9),com.dreammaster.gthandler.CustomItemList.ElectromagneticSeparatorUHV.get(1));
+ GT_MetaTileEntity_EM_machine.registerBehaviour(new Behaviour_ElectromagneticSeparator(10),com.dreammaster.gthandler.CustomItemList.ElectromagneticSeparatorUEV.get(1));
+ GT_MetaTileEntity_EM_machine.registerBehaviour(new Behaviour_ElectromagneticSeparator(11),com.dreammaster.gthandler.CustomItemList.ElectromagneticSeparatorUIV.get(1));
+ GT_MetaTileEntity_EM_machine.registerBehaviour(new Behaviour_ElectromagneticSeparator(12),com.dreammaster.gthandler.CustomItemList.ElectromagneticSeparatorUMV.get(1));
}
}
diff --git a/src/main/java/com/github/technus/tectech/elementalMatter/core/cElementalInstanceStackMap.java b/src/main/java/com/github/technus/tectech/elementalMatter/core/cElementalInstanceStackMap.java
index fc24a05588..b360a5a997 100644
--- a/src/main/java/com/github/technus/tectech/elementalMatter/core/cElementalInstanceStackMap.java
+++ b/src/main/java/com/github/technus/tectech/elementalMatter/core/cElementalInstanceStackMap.java
@@ -359,6 +359,22 @@ public final class cElementalInstanceStackMap implements Comparable<cElementalIn
return mass;
}
+ public long getCharge() {
+ long charge = 0;
+ for (cElementalInstanceStack stack : map.values()) {
+ charge += stack.getCharge();
+ }
+ return charge;
+ }
+
+ public long getCountOfAllAmounts(){
+ long sum=0;
+ for(cElementalInstanceStack stack:map.values()){
+ sum+=stack.amount;
+ }
+ return sum;
+ }
+
//Tests
public boolean containsDefinition(iElementalDefinition def) {
return map.containsKey(def);
@@ -376,6 +392,10 @@ public final class cElementalInstanceStackMap implements Comparable<cElementalIn
return !map.isEmpty();
}
+ public boolean isEmpty(){
+ return map.isEmpty();
+ }
+
//Tick Content
public void tickContentByOneSecond(float lifeTimeMult, int postEnergize) {
tickContent(lifeTimeMult,postEnergize,1);
@@ -490,7 +510,7 @@ public final class cElementalInstanceStackMap implements Comparable<cElementalIn
return build.toString();
}
- public cElementalInstanceStackMap takeAll(){
+ public cElementalInstanceStackMap takeAllToNewMap(){
TreeMap<iElementalDefinition, cElementalInstanceStack> map=this.map;
this.map=new TreeMap<>();
return new cElementalInstanceStackMap(map);
diff --git a/src/main/java/com/github/technus/tectech/elementalMatter/core/cElementalStackMap.java b/src/main/java/com/github/technus/tectech/elementalMatter/core/cElementalStackMap.java
index 585e47b767..676bdeff02 100644
--- a/src/main/java/com/github/technus/tectech/elementalMatter/core/cElementalStackMap.java
+++ b/src/main/java/com/github/technus/tectech/elementalMatter/core/cElementalStackMap.java
@@ -1,6 +1,7 @@
package com.github.technus.tectech.elementalMatter.core;
import com.github.technus.tectech.elementalMatter.core.stacks.cElementalDefinitionStack;
+import com.github.technus.tectech.elementalMatter.core.stacks.cElementalInstanceStack;
import com.github.technus.tectech.elementalMatter.core.templates.iElementalDefinition;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.EnumChatFormatting;
@@ -56,6 +57,14 @@ abstract class cElementalStackMap implements Comparable<cElementalStackMap> {
return var.toArray(new iElementalDefinition[var.size()]);
}
+ public long getCountOfAllAmounts(){
+ long sum=0;
+ for(cElementalDefinitionStack stack:map.values()){
+ sum+=stack.amount;
+ }
+ return sum;
+ }
+
//Tests
public final boolean containsDefinition(iElementalDefinition def) {
return map.containsKey(def);
@@ -73,6 +82,10 @@ abstract class cElementalStackMap implements Comparable<cElementalStackMap> {
return !map.isEmpty();
}
+ public final boolean isEmpty(){
+ return map.isEmpty();
+ }
+
//NBT
public final NBTTagCompound getInfoNBT() {
NBTTagCompound nbt = new NBTTagCompound();
diff --git a/src/main/java/com/github/technus/tectech/elementalMatter/definitions/complex/atom/dAtomDefinition.java b/src/main/java/com/github/technus/tectech/elementalMatter/definitions/complex/atom/dAtomDefinition.java
index 179d9016e0..df795bd9ed 100644
--- a/src/main/java/com/github/technus/tectech/elementalMatter/definitions/complex/atom/dAtomDefinition.java
+++ b/src/main/java/com/github/technus/tectech/elementalMatter/definitions/complex/atom/dAtomDefinition.java
@@ -51,10 +51,15 @@ public final class dAtomDefinition extends cElementalDefinition {
private static final Map<Integer, dAtomDefinition> unstableAtoms = new HashMap<>();
private static cElementalDefinitionStack alpha,deuterium,tritium,helium_3,beryllium_8,carbon_14,neon_24,silicon_34;
private static final HashMap<dAtomDefinition,Float> lifetimeOverrides = new HashMap<>();
- public static final ArrayList<Runnable> overrides = new ArrayList<>();
public final iaeaNuclide iaea;
+ private static dAtomDefinition somethingHeavy;
+ public static dAtomDefinition getSomethingHeavy() {
+ return somethingHeavy;
+ }
+
+ private static final ArrayList<Runnable> overrides = new ArrayList<>();
public static void addOverride(dAtomDefinition atom, float rawLifeTime){
lifetimeOverrides.put(atom,rawLifeTime);
}
@@ -1543,6 +1548,8 @@ public final class dAtomDefinition extends cElementalDefinition {
);
transformation.addOredict(new cElementalDefinitionStack(temp, 144), dust, Materials.Uranium/*238*/,1);
+ float tempMass=temp.getMass();
+
temp=new dAtomDefinition(
new cElementalDefinitionStack(eLeptonDefinition.lepton_e, 92),
new cElementalDefinitionStack(dHadronDefinition.hadron_p, 92),
@@ -1550,6 +1557,8 @@ public final class dAtomDefinition extends cElementalDefinition {
);
transformation.addOredict(new cElementalDefinitionStack(temp, 144), dust, Materials.Uranium235,1);
+ TecTech.Logger.info("Diff Mass U : "+(temp.getMass()-tempMass));
+
temp=new dAtomDefinition(
new cElementalDefinitionStack(eLeptonDefinition.lepton_e, 94),
new cElementalDefinitionStack(dHadronDefinition.hadron_p, 94),
@@ -1557,12 +1566,17 @@ public final class dAtomDefinition extends cElementalDefinition {
);
transformation.addOredict(new cElementalDefinitionStack(temp, 144), dust, Materials.Plutonium/*239*/,1);
- temp=new dAtomDefinition(
+ somethingHeavy=new dAtomDefinition(
new cElementalDefinitionStack(eLeptonDefinition.lepton_e, 94),
new cElementalDefinitionStack(dHadronDefinition.hadron_p, 94),
new cElementalDefinitionStack(dHadronDefinition.hadron_n, 147)
);
- transformation.addOredict(new cElementalDefinitionStack(temp, 144), dust, Materials.Plutonium241,1);
+ transformation.addOredict(new cElementalDefinitionStack(somethingHeavy, 144), dust, Materials.Plutonium241,1);
+
+ TecTech.Logger.info("Diff Mass Pu: "+(somethingHeavy.getMass()-temp.getMass()));
+
+ TecTech.Logger.info("Neutron Mass: "+dHadronDefinition.hadron_n.getMass());
+
} catch (tElementalException e) {
if (DEBUG_MODE) {
e.printStackTrace();
diff --git a/src/main/java/com/github/technus/tectech/loader/BloodyRecipeLoader.java b/src/main/java/com/github/technus/tectech/loader/BloodyRecipeLoader.java
index b506ec9fc3..67e1eef9a1 100644
--- a/src/main/java/com/github/technus/tectech/loader/BloodyRecipeLoader.java
+++ b/src/main/java/com/github/technus/tectech/loader/BloodyRecipeLoader.java
@@ -4,6 +4,9 @@ import com.github.technus.tectech.recipe.TT_recipeAdder;
import com.github.technus.tectech.thing.CustomItemList;
import com.github.technus.tectech.thing.block.QuantumGlassBlock;
import com.github.technus.tectech.thing.item.ConstructableTriggerItem;
+import com.github.technus.tectech.thing.metaTileEntity.multi.em_machine.Behaviour_Centrifuge;
+import com.github.technus.tectech.thing.metaTileEntity.multi.em_machine.Behaviour_ElectromagneticSeparator;
+import com.github.technus.tectech.thing.metaTileEntity.multi.em_machine.GT_MetaTileEntity_EM_machine;
import gregtech.api.enums.*;
import gregtech.api.util.GT_ModHandler;
import gregtech.api.util.GT_OreDictUnificator;
@@ -358,6 +361,38 @@ public class BloodyRecipeLoader implements Runnable {
}
private void register_machine_EM_behaviours(){
-
+ GT_MetaTileEntity_EM_machine.registerBehaviour(new Behaviour_Centrifuge(6),ItemList.Machine_IV_Centrifuge.get(1));
+ try {
+ GT_MetaTileEntity_EM_machine.registerBehaviour(new Behaviour_Centrifuge(7),ItemList.valueOf("Machine_LuV_Centrifuge").get(1));
+ GT_MetaTileEntity_EM_machine.registerBehaviour(new Behaviour_Centrifuge(8),ItemList.valueOf("Machine_ZPM_Centrifuge").get(1));
+ GT_MetaTileEntity_EM_machine.registerBehaviour(new Behaviour_Centrifuge(9),ItemList.valueOf("Machine_UV_Centrifuge").get(1));
+ GT_MetaTileEntity_EM_machine.registerBehaviour(new Behaviour_Centrifuge(10),ItemList.valueOf("Machine_UV_Centrifuge").get(4));
+ GT_MetaTileEntity_EM_machine.registerBehaviour(new Behaviour_Centrifuge(11),ItemList.valueOf("Machine_UV_Centrifuge").get(16));
+ GT_MetaTileEntity_EM_machine.registerBehaviour(new Behaviour_Centrifuge(12),ItemList.valueOf("Machine_UV_Centrifuge").get(64));
+ }catch (IllegalArgumentException|NullPointerException e){
+ GT_MetaTileEntity_EM_machine.registerBehaviour(new Behaviour_Centrifuge(7),ItemList.Machine_IV_Centrifuge.get(2));
+ GT_MetaTileEntity_EM_machine.registerBehaviour(new Behaviour_Centrifuge(8),ItemList.Machine_IV_Centrifuge.get(4));
+ GT_MetaTileEntity_EM_machine.registerBehaviour(new Behaviour_Centrifuge(9),ItemList.Machine_IV_Centrifuge.get(8));
+ GT_MetaTileEntity_EM_machine.registerBehaviour(new Behaviour_Centrifuge(10),ItemList.Machine_IV_Centrifuge.get(16));
+ GT_MetaTileEntity_EM_machine.registerBehaviour(new Behaviour_Centrifuge(11),ItemList.Machine_IV_Centrifuge.get(32));
+ GT_MetaTileEntity_EM_machine.registerBehaviour(new Behaviour_Centrifuge(12),ItemList.Machine_IV_Centrifuge.get(64));
+ }
+
+ GT_MetaTileEntity_EM_machine.registerBehaviour(new Behaviour_ElectromagneticSeparator(6),ItemList.Machine_IV_ElectromagneticSeparator.get(1));
+ try {
+ GT_MetaTileEntity_EM_machine.registerBehaviour(new Behaviour_ElectromagneticSeparator(7),ItemList.valueOf("Machine_LuV_ElectromagneticSeparator").get(1));
+ GT_MetaTileEntity_EM_machine.registerBehaviour(new Behaviour_ElectromagneticSeparator(8),ItemList.valueOf("Machine_ZPM_ElectromagneticSeparator").get(1));
+ GT_MetaTileEntity_EM_machine.registerBehaviour(new Behaviour_ElectromagneticSeparator(9),ItemList.valueOf("Machine_UV_ElectromagneticSeparator").get(1));
+ GT_MetaTileEntity_EM_machine.registerBehaviour(new Behaviour_ElectromagneticSeparator(10),ItemList.valueOf("Machine_UV_ElectromagneticSeparator").get(4));
+ GT_MetaTileEntity_EM_machine.registerBehaviour(new Behaviour_ElectromagneticSeparator(11),ItemList.valueOf("Machine_UV_ElectromagneticSeparator").get(16));
+ GT_MetaTileEntity_EM_machine.registerBehaviour(new Behaviour_ElectromagneticSeparator(12),ItemList.valueOf("Machine_UV_ElectromagneticSeparator").get(64));
+ }catch (IllegalArgumentException|NullPointerException e){
+ GT_MetaTileEntity_EM_machine.registerBehaviour(new Behaviour_ElectromagneticSeparator(7),ItemList.Machine_IV_ElectromagneticSeparator.get(2));
+ GT_MetaTileEntity_EM_machine.registerBehaviour(new Behaviour_ElectromagneticSeparator(8),ItemList.Machine_IV_ElectromagneticSeparator.get(4));
+ GT_MetaTileEntity_EM_machine.registerBehaviour(new Behaviour_ElectromagneticSeparator(9),ItemList.Machine_IV_ElectromagneticSeparator.get(8));
+ GT_MetaTileEntity_EM_machine.registerBehaviour(new Behaviour_ElectromagneticSeparator(10),ItemList.Machine_IV_ElectromagneticSeparator.get(16));
+ GT_MetaTileEntity_EM_machine.registerBehaviour(new Behaviour_ElectromagneticSeparator(11),ItemList.Machine_IV_ElectromagneticSeparator.get(32));
+ GT_MetaTileEntity_EM_machine.registerBehaviour(new Behaviour_ElectromagneticSeparator(12),ItemList.Machine_IV_ElectromagneticSeparator.get(64));
+ }
}
}
diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_scanner.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_scanner.java
index d5a773e4ad..4672640770 100644
--- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_scanner.java
+++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_scanner.java
@@ -258,7 +258,7 @@ public class GT_MetaTileEntity_EM_scanner extends GT_MetaTileEntity_MultiblockBa
}else if(CustomItemList.scanContainer.isStackEqual(itemStack, false, true)) {
eRecipe=null;
if(researchEM.hasStacks()) {
- objectsScanned = researchEM.takeAll();
+ objectsScanned = researchEM.takeAllToNewMap();
cleanMassEM_EM(objectsScanned.getMass());
totalComputationRequired =0;
diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/base/MultiblockControl.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/base/MultiblockControl.java
index 930d81a21f..41bc0e5a37 100644
--- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/base/MultiblockControl.java
+++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/base/MultiblockControl.java
@@ -6,6 +6,7 @@ package com.github.technus.tectech.thing.metaTileEntity.multi.base;
public class MultiblockControl<T>{
private final int[] controls=new int[7];
+ private final boolean shouldExplode;
private final T values;
public MultiblockControl(T values, int EUt, int amperes, int requiredData, int effIncrease, int maxProgressTime){
@@ -15,8 +16,7 @@ public class MultiblockControl<T>{
controls[2]=requiredData;
controls[3]=effIncrease;
controls[4]=maxProgressTime;
- controls[5]=0;
- controls[6]=Float.floatToIntBits(0);
+ shouldExplode=false;
}
public MultiblockControl(T values, int EUt, int amperes, int requiredData, int effIncrease, int maxProgressTime, int pollutionToAdd, float excessMass){
@@ -28,6 +28,13 @@ public class MultiblockControl<T>{
controls[4]=maxProgressTime;
controls[5]=pollutionToAdd;
controls[6]=Float.floatToIntBits(excessMass);
+ shouldExplode=false;
+ }
+
+ public MultiblockControl(float excessMass){
+ this.values = null;
+ controls[6]=Float.floatToIntBits(excessMass);
+ shouldExplode=true;
}
public T getValue() {
@@ -61,4 +68,8 @@ public class MultiblockControl<T>{
public float getExcessMass(){
return Float.intBitsToFloat(controls[6]);
}
+
+ public boolean shouldExplode() {
+ return shouldExplode;
+ }
}
diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/em_machine/Behaviour_Centrifuge.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/em_machine/Behaviour_Centrifuge.java
index 185e46e074..be582e1d87 100644
--- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/em_machine/Behaviour_Centrifuge.java
+++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/em_machine/Behaviour_Centrifuge.java
@@ -1,24 +1,210 @@
package com.github.technus.tectech.thing.metaTileEntity.multi.em_machine;
+import com.github.technus.tectech.TecTech;
import com.github.technus.tectech.elementalMatter.core.cElementalInstanceStackMap;
+import com.github.technus.tectech.elementalMatter.core.stacks.cElementalInstanceStack;
+import com.github.technus.tectech.elementalMatter.definitions.complex.atom.dAtomDefinition;
+import com.github.technus.tectech.thing.metaTileEntity.multi.base.GT_MetaTileEntity_MultiblockBase_EM;
import com.github.technus.tectech.thing.metaTileEntity.multi.base.MultiblockControl;
+import java.util.Arrays;
+import java.util.Comparator;
+
+import static com.github.technus.tectech.Util.V;
+
/**
* Created by danie_000 on 24.12.2017.
*/
public class Behaviour_Centrifuge implements GT_MetaTileEntity_EM_machine.Behaviour {
- final int tier;
- public Behaviour_Centrifuge(int tier){
- this.tier=tier;
+ private static final double MAX_RCF = (float) (Math.pow(Math.E, 15) * 12);
+ private final float radius, maxRPM, maxForce, maxCapacity;
+ private final byte tier;
+
+ //6 to 12 recommended
+ public Behaviour_Centrifuge(int desiredTier) {
+ tier = (byte) desiredTier;
+ radius = 0.5f - (12 - tier) / 64f;
+ float maxRCF = (float) (Math.pow(Math.E, tier) * 12);
+ maxRPM = (float) Math.sqrt(maxRCF / (0.001118 * radius));
+ float maxSafeMass = dAtomDefinition.getSomethingHeavy().getMass() * (1 << tier);
+ maxForce = maxSafeMass * maxRCF;// (eV/c^2 * m/s) / g
+ maxCapacity = maxSafeMass * 4f * radius;// eV/c^2
}
@Override
- public boolean setAndCheckParametersOutAndStatuses(GT_MetaTileEntity_EM_machine te, double[] parameters) {
- return false;
+ public boolean setAndCheckParametersOutAndStatuses(GT_MetaTileEntity_EM_machine te, double[] parametersToCheckAndFix) {
+ boolean check=true;
+
+ te.setParameterOut(1, 0, radius * 1000);//in mm
+ te.setParameterOut(1, 1, maxRPM);
+ te.setParameterOut(2, 0, maxForce * 9.80665);// (eV/c^2 * m/s)
+ te.setParameterOut(2, 1, maxCapacity);// eV/c^2
+
+ double RPM = parametersToCheckAndFix[0];
+ if (RPM > maxRPM) {
+ te.setStatusOfParameterIn(0, 0, GT_MetaTileEntity_MultiblockBase_EM.STATUS_TOO_HIGH);
+ te.setParameterOut(0, 0, maxRPM);//rpm
+ te.setParameterOut(0, 1, getRCF(maxRPM));//rcf
+ check=false;
+ } else if (RPM > maxRPM / 3f * 2f) {
+ te.setStatusOfParameterIn(0, 0, GT_MetaTileEntity_MultiblockBase_EM.STATUS_HIGH);
+ } else if (RPM > maxRPM / 3f) {
+ te.setStatusOfParameterIn(0, 0, GT_MetaTileEntity_MultiblockBase_EM.STATUS_OK);
+ } else if (RPM > 0) {
+ te.setStatusOfParameterIn(0, 0, GT_MetaTileEntity_MultiblockBase_EM.STATUS_LOW);
+ } else if (RPM <= 0) {
+ te.setStatusOfParameterIn(0, 0, GT_MetaTileEntity_MultiblockBase_EM.STATUS_TOO_LOW);
+ te.setParameterOut(0, 0, 0);//rpm
+ te.setParameterOut(0, 1, 0);//rcf
+ check=false;
+ } else {
+ te.setStatusOfParameterIn(0, 0, GT_MetaTileEntity_MultiblockBase_EM.STATUS_WRONG);
+ te.setParameterOut(0, 0, 0);//rpm
+ te.setParameterOut(0, 1, 0);//rcf
+ check=false;
+ }
+
+ if(check) {
+ te.setParameterOut(0, 0, RPM);
+ te.setParameterOut(0, 1, getRCF(RPM));
+ }
+
+ double fractionCount = parametersToCheckAndFix[1];
+ if (fractionCount > 6) {
+ parametersToCheckAndFix[1] = 6;
+ te.setStatusOfParameterIn(0, 1, GT_MetaTileEntity_MultiblockBase_EM.STATUS_TOO_HIGH);
+ check=false;
+ } else if (fractionCount >= 2) {
+ te.setStatusOfParameterIn(0, 1, GT_MetaTileEntity_MultiblockBase_EM.STATUS_OK);
+ } else if (fractionCount < 2) {
+ parametersToCheckAndFix[1] = 2;
+ te.setStatusOfParameterIn(0, 1, GT_MetaTileEntity_MultiblockBase_EM.STATUS_TOO_LOW);
+ check=false;
+ } else {
+ te.setStatusOfParameterIn(0, 1, GT_MetaTileEntity_MultiblockBase_EM.STATUS_WRONG);
+ check=false;
+ }
+
+ te.setParameterOut(3,0,(int) (Math.pow(parametersToCheckAndFix[0] / maxRPM, 3f) * V[tier]));//max eut
+ te.setParameterOut(3,1,(int) (20 * (MAX_RCF / getRCF(RPM)) * (fractionCount - 1)));//max time
+
+ return check;
}
@Override
- public MultiblockControl<cElementalInstanceStackMap[]> process(cElementalInstanceStackMap[] inputs, double[] parameters) {
- return null;
+ public MultiblockControl<cElementalInstanceStackMap[]> process(cElementalInstanceStackMap[] inputs, double[] checkedAndFixedParameters) {
+ cElementalInstanceStackMap input = inputs[0];
+ if (input == null || input.isEmpty()) return null;//nothing in only valid input
+
+ cElementalInstanceStack[] stacks = input.values();
+
+ float inputMass = input.getMass();
+ float excessMass = 0;
+ while (inputMass > maxCapacity || -inputMass > maxCapacity) {
+ cElementalInstanceStack randomStack = stacks[TecTech.Rnd.nextInt(stacks.length)];
+ int amountToRemove = TecTech.Rnd.nextInt((int) randomStack.getAmount()) + 1;
+ randomStack.amount -= amountToRemove;//mutates the parent InstanceStackMap
+ if (randomStack.amount <= 0) {
+ input.remove(randomStack.definition);
+ }
+ float mass = randomStack.getDefinition().getMass() * amountToRemove;
+ excessMass += mass;
+ inputMass -= mass;
+ }
+
+ inputMass = Math.abs(inputMass);
+
+ double RCF = getRCF(checkedAndFixedParameters[0]);
+ if (inputMass * RCF > maxForce) return new MultiblockControl<>(excessMass);//AND THEN IT EXPLODES
+
+ // how many output hatches to use
+ int fractionCount = (int) checkedAndFixedParameters[1];
+ cElementalInstanceStackMap[] outputs = new cElementalInstanceStackMap[fractionCount];
+ for (int i = 0; i < fractionCount; i++) {
+ outputs[i] = new cElementalInstanceStackMap();
+ }
+
+ int mEut = (int) (Math.pow(checkedAndFixedParameters[0] / maxRPM, 3f) * V[tier]);
+ mEut = Math.max(mEut, 512);
+ mEut = -mEut;
+ int mTicks = (int) (20 * (MAX_RCF / RCF) * (inputMass / maxCapacity) * (fractionCount - 1));
+ mTicks=Math.max(mTicks,20);
+
+
+ //take all from hatch handler and put into new map - this takes from hatch to inner data storage
+ stacks = input.takeAllToNewMap().values();//cleanup stacks
+ if (stacks.length > 1) {
+ Arrays.sort(stacks, new Comparator<cElementalInstanceStack>() {
+ @Override
+ public int compare(cElementalInstanceStack o1, cElementalInstanceStack o2) {
+ float m1 = o1.definition.getMass();
+ float m2 = o2.definition.getMass();
+ if (m1 < m2) return -1;
+ if (m1 > m2) return 1;
+ return o1.compareTo(o2);
+ }
+ });
+
+ double absMassPerOutput = 0;//"volume"
+ for (cElementalInstanceStack stack : stacks) {
+ absMassPerOutput += Math.abs(stack.getMass());
+ }
+ absMassPerOutput /= fractionCount;
+
+ nextFraction:
+ for (int fraction = 0; fraction < fractionCount - 1; fraction++) {
+ double remaining = absMassPerOutput;
+ for (int stackNo = 0; stackNo < stacks.length; stackNo++) {
+ if (stacks[stackNo] != null) {
+ double stackMass = Math.abs(stacks[stackNo].getMass());
+ long amount = (long) (Math.abs(stacks[stackNo].definition.getMass()) / remaining);
+ if (stackMass == 0) {
+ addRandomly(stacks[stackNo], outputs, fractionCount);
+ stacks[stackNo] = null;
+ } else if (amount >= stacks[stackNo].amount) {
+ remaining -= stackMass;
+ outputs[fraction].putReplace(stacks[stackNo]);
+ stacks[stackNo] = null;
+ } else if (amount > 0) {
+ remaining -= amount * stacks[stackNo].definition.getMass();
+ cElementalInstanceStack clone = stacks[stackNo].clone();
+ clone.amount = amount;
+ outputs[fraction].putReplace(clone);
+ } else {
+ continue nextFraction;
+ }
+ }
+ }
+ }
+ //add remaining
+ for (cElementalInstanceStack stack : stacks) {
+ if (stack != null) {
+ outputs[fractionCount - 1].putReplace(stack);
+ }
+ }
+ } else {
+ addRandomly(stacks[0], outputs, fractionCount);
+ }
+ return new MultiblockControl<>(outputs, mEut, 1, 0, 10000, mTicks, 0, excessMass);
+ }
+
+ private double getRCF(double RPM) {
+ return RPM * RPM * radius * 0.001118;
+ }
+
+ private void addRandomly(cElementalInstanceStack me, cElementalInstanceStackMap[] toThis, int fractionCount) {
+ long amountPerFraction = me.amount / fractionCount;
+ cElementalInstanceStack[] stacks = new cElementalInstanceStack[fractionCount];
+ for (int i = 0; i < fractionCount; i++) {
+ stacks[i] = me.clone();
+ stacks[i].amount = amountPerFraction;
+ toThis[i].putReplace(stacks[i]);
+ }
+ int remainingAmount = (int) (me.amount % fractionCount);
+ while (remainingAmount > 0) {
+ int amountToAdd = TecTech.Rnd.nextInt(remainingAmount) + 1;
+ stacks[TecTech.Rnd.nextInt(fractionCount)].amount += amountToAdd;
+ remainingAmount -= amountToAdd;
+ }
}
}
diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/em_machine/Behaviour_Electrolyzer.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/em_machine/Behaviour_Electrolyzer.java
index b922c82fb0..236b79c85b 100644
--- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/em_machine/Behaviour_Electrolyzer.java
+++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/em_machine/Behaviour_Electrolyzer.java
@@ -13,12 +13,12 @@ public class Behaviour_Electrolyzer implements GT_MetaTileEntity_EM_machine.Beha
}
@Override
- public boolean setAndCheckParametersOutAndStatuses(GT_MetaTileEntity_EM_machine te, double[] parameters) {
+ public boolean setAndCheckParametersOutAndStatuses(GT_MetaTileEntity_EM_machine te, double[] parametersToCheckAndFix) {
return false;
}
@Override
- public MultiblockControl<cElementalInstanceStackMap[]> process(cElementalInstanceStackMap[] inputs, double[] parameters) {
+ public MultiblockControl<cElementalInstanceStackMap[]> process(cElementalInstanceStackMap[] inputs, double[] checkedAndFixedParameters) {
return null;
}
}
diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/em_machine/Behaviour_ElectromagneticSeparator.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/em_machine/Behaviour_ElectromagneticSeparator.java
index 97ed34d990..82d8c0d535 100644
--- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/em_machine/Behaviour_ElectromagneticSeparator.java
+++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/em_machine/Behaviour_ElectromagneticSeparator.java
@@ -1,24 +1,213 @@
package com.github.technus.tectech.thing.metaTileEntity.multi.em_machine;
+import com.github.technus.tectech.TecTech;
import com.github.technus.tectech.elementalMatter.core.cElementalInstanceStackMap;
+import com.github.technus.tectech.elementalMatter.core.stacks.cElementalInstanceStack;
+import com.github.technus.tectech.elementalMatter.definitions.complex.atom.dAtomDefinition;
+import com.github.technus.tectech.thing.metaTileEntity.multi.base.GT_MetaTileEntity_MultiblockBase_EM;
import com.github.technus.tectech.thing.metaTileEntity.multi.base.MultiblockControl;
+import static com.github.technus.tectech.Util.V;
+
/**
* Created by danie_000 on 24.12.2017.
*/
public class Behaviour_ElectromagneticSeparator implements GT_MetaTileEntity_EM_machine.Behaviour {
- final int tier;
- public Behaviour_ElectromagneticSeparator(int tier){
- this.tier=tier;
+ private final byte tier;
+ private final int ticks;
+ private final byte precisionFull;
+ private final byte precisionMinimal;
+ private final float maxCapacity;
+ private final long maxCharge;
+ private final int offsetMax;
+
+ public Behaviour_ElectromagneticSeparator(int desiredTier){
+ tier=(byte) desiredTier;
+ ticks =Math.max(20,(1<<(12-desiredTier))*20);
+ maxCapacity= dAtomDefinition.getSomethingHeavy().getMass()*(2<<tier);
+ maxCharge=144*(1<<(tier-6));
+ switch (tier){
+ case 12:
+ precisionFull=1;
+ precisionMinimal =1;
+ break;
+ case 11:
+ precisionFull=2;
+ precisionMinimal =1;
+ break;
+ case 10:
+ precisionFull=3;
+ precisionMinimal =1;
+ break;
+ case 9:
+ precisionFull=3;
+ precisionMinimal =2;
+ break;
+ case 8:
+ precisionFull=3;
+ precisionMinimal =3;
+ break;
+ case 7:
+ precisionFull=6;
+ precisionMinimal =3;
+ break;
+ case 6:
+ precisionFull=12;
+ precisionMinimal =3;
+ break;
+ default: precisionFull= precisionMinimal =Byte.MAX_VALUE;
+ }
+ offsetMax=1<<(tier*2);
}
@Override
- public boolean setAndCheckParametersOutAndStatuses(GT_MetaTileEntity_EM_machine te, double[] parameters) {
- return false;
+ public boolean setAndCheckParametersOutAndStatuses(GT_MetaTileEntity_EM_machine te, double[] parametersToCheckAndFix) {
+ boolean check=true;
+
+ te.setParameterOut(0,0,precisionFull);
+ te.setParameterOut(0,1,precisionMinimal);
+ te.setParameterOut(1,0,offsetMax);
+ te.setParameterOut(2,0,maxCharge);
+ te.setParameterOut(2,1,maxCapacity);
+ te.setParameterOut(3,0,V[tier]);
+ te.setParameterOut(3,1,ticks);
+
+ double full=parametersToCheckAndFix[0];
+ if(Double.isInfinite(full) && full>0) {
+ te.setStatusOfParameterIn(0,0,GT_MetaTileEntity_MultiblockBase_EM.STATUS_TOO_HIGH);
+ check=false;
+ }else if(full>precisionFull){
+ te.setStatusOfParameterIn(0,0, GT_MetaTileEntity_MultiblockBase_EM.STATUS_HIGH);
+ }else if(full==precisionFull){
+ te.setStatusOfParameterIn(0,0,GT_MetaTileEntity_MultiblockBase_EM.STATUS_OK);
+ }else if(full<precisionFull){
+ te.setStatusOfParameterIn(0,0,GT_MetaTileEntity_MultiblockBase_EM.STATUS_TOO_LOW);
+ check=false;
+ }else {
+ te.setStatusOfParameterIn(0,0,GT_MetaTileEntity_MultiblockBase_EM.STATUS_WRONG);
+ check=false;
+ }
+
+ double minimal=parametersToCheckAndFix[1];
+ if(Double.isInfinite(minimal) && minimal>0) {
+ te.setStatusOfParameterIn(0,1,GT_MetaTileEntity_MultiblockBase_EM.STATUS_TOO_HIGH);
+ check=false;
+ }else if(minimal>precisionMinimal){
+ if(minimal>full){
+ te.setStatusOfParameterIn(0,1,GT_MetaTileEntity_MultiblockBase_EM.STATUS_TOO_HIGH);
+ check=false;
+ }else {
+ te.setStatusOfParameterIn(0,1, GT_MetaTileEntity_MultiblockBase_EM.STATUS_HIGH);
+ }
+ }else if(minimal==precisionMinimal){
+ if(minimal>full){
+ te.setStatusOfParameterIn(0,1,GT_MetaTileEntity_MultiblockBase_EM.STATUS_TOO_HIGH);
+ check=false;
+ }else {
+ te.setStatusOfParameterIn(0,1, GT_MetaTileEntity_MultiblockBase_EM.STATUS_OK);
+ }
+ }else if(minimal<precisionMinimal){
+ te.setStatusOfParameterIn(0,1,GT_MetaTileEntity_MultiblockBase_EM.STATUS_TOO_LOW);
+ check=false;
+ }else {
+ te.setStatusOfParameterIn(0,1,GT_MetaTileEntity_MultiblockBase_EM.STATUS_WRONG);
+ check=false;
+ }
+
+ double offset=parametersToCheckAndFix[2];
+ if(offset>offsetMax){
+ te.setStatusOfParameterIn(1,0,GT_MetaTileEntity_MultiblockBase_EM.STATUS_TOO_HIGH);
+ check=false;
+ }else if(offset>0){
+ te.setStatusOfParameterIn(1,0,GT_MetaTileEntity_MultiblockBase_EM.STATUS_HIGH);
+ }else if(offset==0){
+ te.setStatusOfParameterIn(1,0,GT_MetaTileEntity_MultiblockBase_EM.STATUS_OK);
+ }else if(offset>=-offsetMax){
+ te.setStatusOfParameterIn(1,0,GT_MetaTileEntity_MultiblockBase_EM.STATUS_LOW);
+ }else if(offset<-offset){
+ te.setStatusOfParameterIn(1,0,GT_MetaTileEntity_MultiblockBase_EM.STATUS_TOO_LOW);
+ check=false;
+ }else {
+ te.setStatusOfParameterIn(1,0,GT_MetaTileEntity_MultiblockBase_EM.STATUS_WRONG);
+ check=false;
+ }
+
+ return check;
}
@Override
- public MultiblockControl<cElementalInstanceStackMap[]> process(cElementalInstanceStackMap[] inputs, double[] parameters) {
- return null;
+ public MultiblockControl<cElementalInstanceStackMap[]> process(cElementalInstanceStackMap[] inputs, double[] checkedAndFixedParameters) {
+
+ cElementalInstanceStackMap input = inputs[0];
+ if (input == null || input.isEmpty()) return null;//nothing in only valid input
+
+ cElementalInstanceStack[] stacks = input.values();
+
+ float inputMass = input.getMass();
+ float excessMass = 0;
+ while (inputMass > maxCapacity || -inputMass > maxCapacity) {
+ cElementalInstanceStack randomStack = stacks[TecTech.Rnd.nextInt(stacks.length)];
+ int amountToRemove = TecTech.Rnd.nextInt((int) randomStack.getAmount()) + 1;
+ randomStack.amount -= amountToRemove;//mutates the parent InstanceStackMap
+ if (randomStack.amount <= 0) {
+ input.remove(randomStack.definition);
+ }
+ float mass = randomStack.getDefinition().getMass() * amountToRemove;
+ excessMass += mass;
+ inputMass -= mass;
+ }
+
+ long totalCharge=input.getCharge();
+ if (totalCharge>maxCharge) return new MultiblockControl<>(excessMass);//AND THEN IT EXPLODES
+
+ int mEut=(int)(((double)totalCharge/(double) maxCharge)*V[tier]);
+ mEut = Math.max(mEut, 512);
+ int mTicks=(int)(ticks*(inputMass/maxCapacity));
+ mTicks=Math.max(mTicks,20);
+
+ cElementalInstanceStackMap[] outputs = new cElementalInstanceStackMap[3];
+ for (int i = 0; i < 3; i++) {
+ outputs[i] = new cElementalInstanceStackMap();
+ }
+
+ double precisionFullIn=checkedAndFixedParameters[0];
+ double precisionMinimalIn=checkedAndFixedParameters[1];
+ double levelsCount=precisionFullIn-precisionMinimalIn+1;
+ double offset=checkedAndFixedParameters[2];
+
+ //take all from hatch handler and put into new map - this takes from hatch to inner data storage
+ stacks = input.takeAllToNewMap().values();//cleanup stacks
+ for(cElementalInstanceStack stack:stacks){
+ double charge=stack.definition.getCharge()-offset;
+ if(charge<precisionMinimalIn && charge>-precisionMinimalIn){
+ outputs[1].putReplace(stack);
+ }else if(charge>=precisionFullIn){
+ outputs[2].putReplace(stack);
+ }else if(charge<=-precisionFullIn){
+ outputs[0].putReplace(stack);
+ }else{
+ long amount=(long)(stack.amount*((Math.abs(charge)-precisionMinimalIn+1)/levelsCount));
+ if(amount>=stack.amount){
+ if(charge>0){
+ outputs[2].putReplace(stack);
+ }else {
+ outputs[0].putReplace(stack);
+ }
+ }else {
+ cElementalInstanceStack clone=stack.clone();
+ clone.amount-=amount;
+ outputs[1].putReplace(clone);
+
+ stack.amount=amount;
+ if(charge>0){
+ outputs[2].putReplace(stack);
+ }else {
+ outputs[0].putReplace(stack);
+ }
+ }
+ }
+ }
+
+ return new MultiblockControl<>(outputs, mEut, 1, 0, 10000, mTicks, 0, excessMass);
}
}
diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/em_machine/Behaviour_Mixer.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/em_machine/Behaviour_Mixer.java
index 153fd4c4a5..e8b1d7027f 100644
--- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/em_machine/Behaviour_Mixer.java
+++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/em_machine/Behaviour_Mixer.java
@@ -13,12 +13,12 @@ public class Behaviour_Mixer implements GT_MetaTileEntity_EM_machine.Behaviour {
}
@Override
- public boolean setAndCheckParametersOutAndStatuses(GT_MetaTileEntity_EM_machine te, double[] parameters) {
+ public boolean setAndCheckParametersOutAndStatuses(GT_MetaTileEntity_EM_machine te, double[] parametersToCheckAndFix) {
return false;
}
@Override
- public MultiblockControl<cElementalInstanceStackMap[]> process(cElementalInstanceStackMap[] inputs, double[] parameters) {
+ public MultiblockControl<cElementalInstanceStackMap[]> process(cElementalInstanceStackMap[] inputs, double[] checkedAndFixedParameters) {
return null;
}
}
diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/em_machine/Behaviour_PrecisionLaser.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/em_machine/Behaviour_PrecisionLaser.java
index ecd0fb464c..1cca03ec17 100644
--- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/em_machine/Behaviour_PrecisionLaser.java
+++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/em_machine/Behaviour_PrecisionLaser.java
@@ -13,12 +13,12 @@ public class Behaviour_PrecisionLaser implements GT_MetaTileEntity_EM_machine.Be
}
@Override
- public boolean setAndCheckParametersOutAndStatuses(GT_MetaTileEntity_EM_machine te, double[] parameters) {
+ public boolean setAndCheckParametersOutAndStatuses(GT_MetaTileEntity_EM_machine te, double[] parametersToCheckAndFix) {
return false;
}
@Override
- public MultiblockControl<cElementalInstanceStackMap[]> process(cElementalInstanceStackMap[] inputs, double[] parameters) {
+ public MultiblockControl<cElementalInstanceStackMap[]> process(cElementalInstanceStackMap[] inputs, double[] checkedAndFixedParameters) {
return null;
}
}
diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/em_machine/Behaviour_Recycler.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/em_machine/Behaviour_Recycler.java
index 16a2c4d4a6..09249a3d95 100644
--- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/em_machine/Behaviour_Recycler.java
+++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/em_machine/Behaviour_Recycler.java
@@ -13,12 +13,12 @@ public class Behaviour_Recycler implements GT_MetaTileEntity_EM_machine.Behaviou
}
@Override
- public boolean setAndCheckParametersOutAndStatuses(GT_MetaTileEntity_EM_machine te, double[] parameters) {
+ public boolean setAndCheckParametersOutAndStatuses(GT_MetaTileEntity_EM_machine te, double[] parametersToCheckAndFix) {
return false;
}
@Override
- public MultiblockControl<cElementalInstanceStackMap[]> process(cElementalInstanceStackMap[] inputs, double[] parameters) {
+ public MultiblockControl<cElementalInstanceStackMap[]> process(cElementalInstanceStackMap[] inputs, double[] checkedAndFixedParameters) {
return null;
}
}
diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/em_machine/GT_MetaTileEntity_EM_machine.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/em_machine/GT_MetaTileEntity_EM_machine.java
index 16f46023ec..a73548f63c 100644
--- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/em_machine/GT_MetaTileEntity_EM_machine.java
+++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/em_machine/GT_MetaTileEntity_EM_machine.java
@@ -1,6 +1,7 @@
package com.github.technus.tectech.thing.metaTileEntity.multi.em_machine;
import com.github.technus.tectech.CommonValues;
+import com.github.technus.tectech.Util;
import com.github.technus.tectech.elementalMatter.core.cElementalInstanceStackMap;
import com.github.technus.tectech.thing.block.QuantumGlassBlock;
import com.github.technus.tectech.thing.metaTileEntity.IConstructable;
@@ -26,30 +27,17 @@ import static com.github.technus.tectech.thing.casing.TT_Container_Casings.sBloc
*/
public class GT_MetaTileEntity_EM_machine extends GT_MetaTileEntity_MultiblockBase_EM implements IConstructable {
- public static final String machine="EM Machinery";
+ public static final String machine = "EM Machinery";
//region structure
- private static final String[][] shape = new String[][]{
- {"B0","A ","0 - 0","A ","B0",},
- {"A000","00000","00.00","00000","A000",},
- {"A121","1C1","2C2","1C1","A121",},
- {"A131","1C1","3C3","1C1","A131",},
- {"A121","1C1","2C2","1C1","A121",},
- {"A000","00000","00A00","00000","A000",},
- {"B0","A!!!","0!\"!0","A!!!","B0",},
- };
+ private static final String[][] shape = new String[][]{{"B0", "A ", "0 - 0", "A ", "B0",}, {"A000", "00000", "00.00", "00000", "A000",}, {"A121", "1C1", "2C2", "1C1", "A121",}, {"A131", "1C1", "3C3", "1C1", "A131",}, {"A121", "1C1", "2C2", "1C1", "A121",}, {"A000", "00000", "00A00", "00000", "A000",}, {"B0", "A!!!", "0!\"!0", "A!!!", "B0",},};
private static final Block[] blockType = new Block[]{sBlockCasingsTT, QuantumGlassBlock.INSTANCE, sBlockCasingsTT, sBlockCasingsTT};
private static final byte[] blockMeta = new byte[]{4, 0, 5, 6};
private static final String[] addingMethods = new String[]{"addClassicToMachineList", "addElementalToMachineList", "addElementalInputToMachineList"};
private static final short[] casingTextures = new short[]{textureOffset, textureOffset + 4, textureOffset + 4};
private static final Block[] blockTypeFallback = new Block[]{sBlockCasingsTT, sBlockCasingsTT, sBlockCasingsTT};
private static final byte[] blockMetaFallback = new byte[]{0, 4, 4};
- private static final String[] description = new String[]{
- EnumChatFormatting.AQUA+"Hint Details:",
- "1 - Classic Hatches or High Power Casing",
- "2 - Elemental Hatches or Molecular Casing",
- "2 - Elemental Input Hatch",
- };
+ private static final String[] description = new String[]{EnumChatFormatting.AQUA + "Hint Details:", "1 - Classic Hatches or High Power Casing", "2 - Elemental Hatches or Molecular Casing", "2 - Elemental Input Hatch",};
//endregion
public GT_MetaTileEntity_EM_machine(int aID, String aName, String aNameRegional) {
@@ -67,13 +55,12 @@ public class GT_MetaTileEntity_EM_machine extends GT_MetaTileEntity_MultiblockBa
@Override
public boolean checkMachine_EM(IGregTechTileEntity iGregTechTileEntity, ItemStack itemStack) {
- return structureCheck_EM(shape, blockType, blockMeta, addingMethods, casingTextures, blockTypeFallback, blockMetaFallback, 2, 2, 1)
- && eInputHatches.size()==1 && iGregTechTileEntity.getBlockAtSideAndDistance(iGregTechTileEntity.getBackFacing(),5) instanceof GT_Block_Machines;
+ return structureCheck_EM(shape, blockType, blockMeta, addingMethods, casingTextures, blockTypeFallback, blockMetaFallback, 2, 2, 1) && eInputHatches.size() == 1 && iGregTechTileEntity.getBlockAtSideAndDistance(iGregTechTileEntity.getBackFacing(), 5) instanceof GT_Block_Machines;
}
@Override
public void construct(int stackSize, boolean hintsOnly) {
- StructureBuilder(shape, blockType, blockMeta,2, 2, 1, getBaseMetaTileEntity(),hintsOnly);
+ StructureBuilder(shape, blockType, blockMeta, 2, 2, 1, getBaseMetaTileEntity(), hintsOnly);
}
@Override
@@ -83,52 +70,48 @@ public class GT_MetaTileEntity_EM_machine extends GT_MetaTileEntity_MultiblockBa
@Override
public String[] getDescription() {
- return new String[]{
- CommonValues.TEC_MARK_EM,
- "Processing quantum matter since...",
- EnumChatFormatting.AQUA.toString() + EnumChatFormatting.BOLD + "the time u started using it."
- };
+ return new String[]{CommonValues.TEC_MARK_EM, "Processing quantum matter since...", EnumChatFormatting.AQUA.toString() + EnumChatFormatting.BOLD + "the time u started using it."};
}
@Override
public boolean checkRecipe_EM(ItemStack itemStack) {
Behaviour currentBehaviour = GT_MetaTileEntity_EM_machine.map.get(new GT_ItemStack(itemStack));
- if(currentBehaviour ==null) {
+ if (currentBehaviour == null) {
return false;
}
//mux input
- double[] parameters=new double[]{getParameterIn(0,0),getParameterIn(0,1),getParameterIn(1,0),getParameterIn(1,1),
- getParameterIn(2,0),getParameterIn(2,1),getParameterIn(3,0),getParameterIn(3,1)};
- if(!currentBehaviour.setAndCheckParametersOutAndStatuses(this,parameters)) {
+ double[] parameters = new double[]{getParameterIn(0, 0), getParameterIn(0, 1), getParameterIn(1, 0), getParameterIn(1, 1), getParameterIn(2, 0), getParameterIn(2, 1), getParameterIn(3, 0), getParameterIn(3, 1)};
+ if (!currentBehaviour.setAndCheckParametersOutAndStatuses(this, parameters)) {
return false;
}
- cElementalInstanceStackMap[] handles=new cElementalInstanceStackMap[6];
- int pointer= getParameterInInt(4,0)-1;
- if(pointer>=0 && pointer<eInputHatches.size()) {
+ cElementalInstanceStackMap[] handles = new cElementalInstanceStackMap[6];
+ int pointer = getParameterInInt(4, 0) - 1;
+ if (pointer >= 0 && pointer < eInputHatches.size()) {
handles[0] = eInputHatches.get(pointer).getContainerHandler();
}
- pointer= getParameterInInt(4,1)-1;
- if(pointer>=0 && pointer<eInputHatches.size()) {
+ pointer = getParameterInInt(4, 1) - 1;
+ if (pointer >= 0 && pointer < eInputHatches.size()) {
handles[1] = eInputHatches.get(pointer).getContainerHandler();
}
- pointer= getParameterInInt(5,0)-1;
- if(pointer>=0 && pointer<eInputHatches.size()) {
+ pointer = getParameterInInt(5, 0) - 1;
+ if (pointer >= 0 && pointer < eInputHatches.size()) {
handles[2] = eInputHatches.get(pointer).getContainerHandler();
}
- pointer= getParameterInInt(5,1)-1;
- if(pointer>=0 && pointer<eInputHatches.size()) {
+ pointer = getParameterInInt(5, 1) - 1;
+ if (pointer >= 0 && pointer < eInputHatches.size()) {
handles[3] = eInputHatches.get(pointer).getContainerHandler();
}
- pointer= getParameterInInt(6,0)-1;
- if(pointer>=0 && pointer<eInputHatches.size()) {
+ pointer = getParameterInInt(6, 0) - 1;
+ if (pointer >= 0 && pointer < eInputHatches.size()) {
handles[4] = eInputHatches.get(pointer).getContainerHandler();
}
- pointer= getParameterInInt(6,1)-1;
- if(pointer>=0 && pointer<eInputHatches.size()) {
+ pointer = getParameterInInt(6, 1) - 1;
+ if (pointer >= 0 && pointer < eInputHatches.size()) {
handles[5] = eInputHatches.get(pointer).getContainerHandler();
}
- for(int i=1;i<6;i++) {
+
+ for (int i = 1; i < 6; i++) {
if (handles[i] != null) {
for (int j = 0; j < i; j++) {
if (handles[i] == handles[j]) {
@@ -138,52 +121,58 @@ public class GT_MetaTileEntity_EM_machine extends GT_MetaTileEntity_MultiblockBa
}
}
- MultiblockControl<cElementalInstanceStackMap[]> control= currentBehaviour.process(handles,parameters);
- if(control==null) {
+ MultiblockControl<cElementalInstanceStackMap[]> control = currentBehaviour.process(handles, parameters);
+ if (control == null) {
return false;
}
- //update other pare
- outputEM=control.getValue();
- mEUt=control.getEUT();
- eAmpereFlow=control.getAmperage();
- mMaxProgresstime=control.getMaxProgressTime();
- eRequiredData=control.getRequiredData();
- mEfficiencyIncrease=control.getEffIncrease();
cleanMassEM_EM(control.getExcessMass());
+ if (control.shouldExplode()) {
+ explodeMultiblock();
+ return false;
+ }
+ //update other parameters
+ outputEM = control.getValue();
+ mEUt = control.getEUT();
+ eAmpereFlow = control.getAmperage();
+ mMaxProgresstime = control.getMaxProgressTime();
+ eRequiredData = control.getRequiredData();
+ mEfficiencyIncrease = control.getEffIncrease();
return polluteEnvironment(control.getPollutionToAdd());
}
@Override
public void outputAfterRecipe_EM() {
- cElementalInstanceStackMap[] handles=new cElementalInstanceStackMap[6];
- int pointer= getParameterInInt(7,0)-1;
- if(pointer>=0 && pointer<eOutputHatches.size()) {
+ if (outputEM == null) return;
+ cElementalInstanceStackMap[] handles = new cElementalInstanceStackMap[6];
+ int pointer = getParameterInInt(7, 0) - 1;
+ if (pointer >= 0 && pointer < eOutputHatches.size()) {
handles[0] = eOutputHatches.get(pointer).getContainerHandler();
}
- pointer= getParameterInInt(7,1)-1;
- if(pointer>=0 && pointer<eOutputHatches.size()) {
+ pointer = getParameterInInt(7, 1) - 1;
+ if (pointer >= 0 && pointer < eOutputHatches.size()) {
handles[1] = eOutputHatches.get(pointer).getContainerHandler();
}
- pointer= getParameterInInt(8,0)-1;
- if(pointer>=0 && pointer<eOutputHatches.size()) {
+ pointer = getParameterInInt(8, 0) - 1;
+ if (pointer >= 0 && pointer < eOutputHatches.size()) {
handles[2] = eOutputHatches.get(pointer).getContainerHandler();
}
- pointer= getParameterInInt(8,1)-1;
- if(pointer>=0 && pointer<eOutputHatches.size()) {
+ pointer = getParameterInInt(8, 1) - 1;
+ if (pointer >= 0 && pointer < eOutputHatches.size()) {
handles[3] = eOutputHatches.get(pointer).getContainerHandler();
}
- pointer= getParameterInInt(9,0)-1;
- if(pointer>=0 && pointer<eOutputHatches.size()) {
+ pointer = getParameterInInt(9, 0) - 1;
+ if (pointer >= 0 && pointer < eOutputHatches.size()) {
handles[4] = eOutputHatches.get(pointer).getContainerHandler();
}
- pointer= getParameterInInt(9,1)-1;
- if(pointer>=0 && pointer<eOutputHatches.size()) {
+ pointer = getParameterInInt(9, 1) - 1;
+ if (pointer >= 0 && pointer < eOutputHatches.size()) {
handles[5] = eOutputHatches.get(pointer).getContainerHandler();
}
//output
- for(int i=0;i<6;i++) {
- if (handles[i] != null && outputEM[i].hasStacks()) {
- handles[i].putUnifyAll(outputEM[i].takeAll());
+ for (int i = 0; i < 6 && i < outputEM.length; i++) {
+ if (handles[i] != null && outputEM[i] != null && outputEM[i].hasStacks()) {
+ handles[i].putUnifyAll(outputEM[i]);
+ outputEM[i] = null;
}
}
//all other are handled by base multi block code - cleaning is automatic
@@ -191,13 +180,13 @@ public class GT_MetaTileEntity_EM_machine extends GT_MetaTileEntity_MultiblockBa
@Override
protected void parametersLoadDefault_EM() {//default routing table
- setParameterPairIn_ClearOut(4,false,1,2);//I
- setParameterPairIn_ClearOut(5,false,3,4);//I
- setParameterPairIn_ClearOut(6,false,5,6);//I
+ setParameterPairIn_ClearOut(4, false, 1, 2);//I
+ setParameterPairIn_ClearOut(5, false, 3, 4);//I
+ setParameterPairIn_ClearOut(6, false, 5, 6);//I
- setParameterPairIn_ClearOut(7,false,1,2);//O
- setParameterPairIn_ClearOut(8,false,3,4);//O
- setParameterPairIn_ClearOut(9,false,5,6);//O
+ setParameterPairIn_ClearOut(7, false, 1, 2);//O
+ setParameterPairIn_ClearOut(8, false, 3, 4);//O
+ setParameterPairIn_ClearOut(9, false, 5, 6);//O
}
@Override
@@ -212,7 +201,7 @@ public class GT_MetaTileEntity_EM_machine extends GT_MetaTileEntity_MultiblockBa
} else if (pointer <= 0) {
setStatusOfParameterIn(i, 0, GT_MetaTileEntity_MultiblockBase_EM.STATUS_TOO_LOW);
}//else if(pointer==0)
- // setStatusOfParameterIn(i,0,STATUS_LOW);
+ // setStatusOfParameterIn(i,0,STATUS_LOW);
else if (pointer <= eInputHatches.size()) {
if (checkArray.get(pointer)) {
setStatusOfParameterIn(i, 0, GT_MetaTileEntity_MultiblockBase_EM.STATUS_WRONG);
@@ -272,15 +261,18 @@ public class GT_MetaTileEntity_EM_machine extends GT_MetaTileEntity_MultiblockBa
}
}
- private static final HashMap<GT_ItemStack,Behaviour> map=new HashMap<>();
+ private static final HashMap<Util.TT_ItemStack, Behaviour> map = new HashMap<>();
- public static void registerBehaviour(Behaviour behaviour,GT_ItemStack is){
- map.put(is,behaviour);
+ public static void registerBehaviour(Behaviour behaviour, Util.TT_ItemStack is) {
+ map.put(is, behaviour);
+ }
+ public static void registerBehaviour(Behaviour behaviour, ItemStack is) {
+ map.put(new Util.TT_ItemStack(is), behaviour);
}
public interface Behaviour {
- boolean setAndCheckParametersOutAndStatuses(GT_MetaTileEntity_EM_machine te, double[] parameters);
+ boolean setAndCheckParametersOutAndStatuses(GT_MetaTileEntity_EM_machine te, double[] parametersToCheckAndFix);
- MultiblockControl<cElementalInstanceStackMap[]> process(cElementalInstanceStackMap[] inputs, double[] parameters);
+ MultiblockControl<cElementalInstanceStackMap[]> process(cElementalInstanceStackMap[] inputs, double[] checkedAndFixedParameters);
}
}