aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/com
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 /src/main/java/com
parent18622e9eeee695ab9b69a326798f903f9371483f (diff)
downloadGT5-Unofficial-701be18f07ad3562a059cf934c00fa2fb2bb53ef.tar.gz
GT5-Unofficial-701be18f07ad3562a059cf934c00fa2fb2bb53ef.tar.bz2
GT5-Unofficial-701be18f07ad3562a059cf934c00fa2fb2bb53ef.zip
First draft of EM centrifuge and electromagnetic separator
Diffstat (limited to 'src/main/java/com')
-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&