aboutsummaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
authorTec <daniel112092@gmail.com>2018-03-10 09:33:07 +0100
committerTec <daniel112092@gmail.com>2018-03-10 09:33:07 +0100
commitc0fd973ba6812825160b49db0c59c08ca67eca4d (patch)
treec932c918a49f6d108e95ca3519348069c5d8c8e1 /src/main
parentc1be698ec50095fb887b90011ea8ae0a483dbd93 (diff)
downloadGT5-Unofficial-c0fd973ba6812825160b49db0c59c08ca67eca4d.tar.gz
GT5-Unofficial-c0fd973ba6812825160b49db0c59c08ca67eca4d.tar.bz2
GT5-Unofficial-c0fd973ba6812825160b49db0c59c08ca67eca4d.zip
Changes and draft of Assline data hatches
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/com/github/technus/tectech/dataFramework/DataPacket.java106
-rw-r--r--src/main/java/com/github/technus/tectech/dataFramework/InventoryDataPacket.java59
-rw-r--r--src/main/java/com/github/technus/tectech/dataFramework/QuantumDataPacket.java78
-rw-r--r--src/main/java/com/github/technus/tectech/loader/MachineLoader.java2
-rw-r--r--src/main/java/com/github/technus/tectech/thing/CustomItemList.java2
-rw-r--r--src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_DataConnector.java16
-rw-r--r--src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_InputData.java11
-rw-r--r--src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_InputDataAccess.java181
-rw-r--r--src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_OutputData.java11
-rw-r--r--src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_OutputDataAccess.java135
-rw-r--r--src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_computer.java7
-rw-r--r--src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_switch.java15
-rw-r--r--src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/base/GT_MetaTileEntity_MultiblockBase_EM.java6
13 files changed, 553 insertions, 76 deletions
diff --git a/src/main/java/com/github/technus/tectech/dataFramework/DataPacket.java b/src/main/java/com/github/technus/tectech/dataFramework/DataPacket.java
new file mode 100644
index 0000000000..8a6c610297
--- /dev/null
+++ b/src/main/java/com/github/technus/tectech/dataFramework/DataPacket.java
@@ -0,0 +1,106 @@
+package com.github.technus.tectech.dataFramework;
+
+import com.github.technus.tectech.Vec3pos;
+import net.minecraft.nbt.NBTTagCompound;
+
+import java.util.Collections;
+import java.util.LinkedHashSet;
+import java.util.Set;
+
+/**
+ * Created by Tec on 05.04.2017.
+ */
+public abstract class DataPacket<T>{
+ private static final byte MAX_HISTORY = 64;
+ private Set<Vec3pos> trace = new LinkedHashSet<>();
+
+ protected T content;
+
+ protected DataPacket(T content){
+ this.content=content;
+ }
+
+ protected DataPacket(NBTTagCompound nbt) {
+ content = contentFromNBT(nbt.getCompoundTag("qContent"));
+ for (int i = 0; i < nbt.getByte("qHistory"); i++) {
+ trace.add(new Vec3pos(
+ nbt.getInteger("qX" + i),
+ nbt.getShort("qY" + i),
+ nbt.getInteger("qZ" + i)
+ ));
+ }
+ }
+
+ public final NBTTagCompound toNbt() {
+ NBTTagCompound nbt = new NBTTagCompound();
+ NBTTagCompound contentTag=contentToNBT();
+ if(contentTag!=null) {
+ nbt.setTag("qContent", contentTag);
+ }
+ nbt.setByte("qHistory", (byte) trace.size());
+ int i = 0;
+ for (Vec3pos v : trace) {
+ nbt.setInteger("qX" + i, v.x);
+ nbt.setShort("qY" + i, v.y);
+ nbt.setInteger("qZ" + i, v.z);
+ i++;
+ }
+ return nbt;
+ }
+
+ protected abstract NBTTagCompound contentToNBT();
+
+ protected abstract T contentFromNBT(NBTTagCompound nbt);
+
+ protected abstract T unifyContentWith(T content);
+
+ public final boolean contains(Vec3pos v) {
+ return trace.contains(v);
+ }
+
+ public final boolean check() {
+ return trace.size() <= MAX_HISTORY;
+ }
+
+ public abstract boolean extraCheck();
+
+ protected final DataPacket<T> unifyTrace(Vec3pos... positions) {
+ Collections.addAll(trace,positions);
+ return (check() && extraCheck()) ? this : null;
+ }
+
+ protected final DataPacket<T> unifyTrace(DataPacket<T> p) {
+ if(p==null) return this;
+ trace.addAll(p.trace);
+ return (check() && extraCheck()) ? this : null;
+ }
+
+ protected final DataPacket<T> unifyWith(DataPacket<T> p) {
+ if(p==null) return this;
+ trace.addAll(p.trace);
+ if(check() && extraCheck()){
+ content=unifyContentWith(p.content);
+ return this;
+ }
+ return null;
+ }
+
+ public final T contentIfNotInTrace(Vec3pos pos) {
+ if (trace.contains(pos)) {
+ return null;
+ }
+ return getContent();
+ }
+
+ public T getContent(){
+ return content;
+ }
+
+ public String getContentString(){
+ return content.toString();
+ }
+
+ public final int getTraceSize(){
+ return trace.size();
+ }
+}
diff --git a/src/main/java/com/github/technus/tectech/dataFramework/InventoryDataPacket.java b/src/main/java/com/github/technus/tectech/dataFramework/InventoryDataPacket.java
new file mode 100644
index 0000000000..cb1f94e038
--- /dev/null
+++ b/src/main/java/com/github/technus/tectech/dataFramework/InventoryDataPacket.java
@@ -0,0 +1,59 @@
+package com.github.technus.tectech.dataFramework;
+
+import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTTagCompound;
+
+import java.util.ArrayList;
+
+public class InventoryDataPacket extends DataPacket<ItemStack[]> {
+ public InventoryDataPacket(ItemStack[] content){
+ super(content);
+ }
+
+ public InventoryDataPacket(NBTTagCompound compound){
+ super(compound);
+ }
+
+ @Override
+ protected ItemStack[] contentFromNBT(NBTTagCompound nbt) {
+ int count=nbt.getInteger("count");
+ if(count>0){
+ ArrayList<ItemStack> stacks=new ArrayList<>();
+ for(int i=0;i<count;i++){
+ ItemStack stack=ItemStack.loadItemStackFromNBT(nbt.getCompoundTag(Integer.toString(i)));
+ if(stack!=null){
+ stacks.add(stack);
+ }
+ }
+ return stacks.size()>0?stacks.toArray(new ItemStack[0]):null;
+ }
+ return null;
+ }
+
+ @Override
+ protected NBTTagCompound contentToNBT() {
+ NBTTagCompound compound=new NBTTagCompound();
+ if(content!=null && content.length>0){
+ compound.setInteger("count",content.length);
+ for(int i=0;i<content.length;i++){
+ compound.setTag(Integer.toString(i),content[i].writeToNBT(new NBTTagCompound()));
+ }
+ }
+ return compound;
+ }
+
+ @Override
+ public boolean extraCheck() {
+ return true;
+ }
+
+ @Override
+ protected ItemStack[] unifyContentWith(ItemStack[] content) {
+ throw new NoSuchMethodError("Unavailable to unify item stack data packet");
+ }
+
+ @Override
+ public String getContentString() {
+ return "Stack Count: "+(content==null?0:content.length);
+ }
+}
diff --git a/src/main/java/com/github/technus/tectech/dataFramework/QuantumDataPacket.java b/src/main/java/com/github/technus/tectech/dataFramework/QuantumDataPacket.java
index 56733d0b1d..b28199157f 100644
--- a/src/main/java/com/github/technus/tectech/dataFramework/QuantumDataPacket.java
+++ b/src/main/java/com/github/technus/tectech/dataFramework/QuantumDataPacket.java
@@ -3,76 +3,46 @@ package com.github.technus.tectech.dataFramework;
import com.github.technus.tectech.Vec3pos;
import net.minecraft.nbt.NBTTagCompound;
-import java.util.LinkedHashSet;
-import java.util.Set;
-
-/**
- * Created by Tec on 05.04.2017.
- */
-public class QuantumDataPacket {
- public static byte maxHistory = 64;
-
- public long computation = 0;
- public Set<Vec3pos> trace = new LinkedHashSet<>();
+public class QuantumDataPacket extends DataPacket<Long> {
+ public QuantumDataPacket(Long content){
+ super(content);
+ }
- public QuantumDataPacket(Vec3pos pos, long computation) {
- this.computation = computation;
- trace.add(pos);
+ public QuantumDataPacket(NBTTagCompound compound){
+ super(compound);
}
- public QuantumDataPacket(QuantumDataPacket q, long computation) {
- this.computation = computation;
- trace.addAll(q.trace);
+ @Override
+ protected Long contentFromNBT(NBTTagCompound nbt) {
+ return nbt.getLong("computation");
}
- public QuantumDataPacket(NBTTagCompound nbt) {
- computation = nbt.getLong("qComputation");
- for (int i = 0; i < nbt.getByte("qHistory"); i++) {
- trace.add(new Vec3pos(
- nbt.getInteger("qX" + i),
- nbt.getShort("qY" + i),
- nbt.getInteger("qZ" + i)
- ));
- }
+ @Override
+ protected NBTTagCompound contentToNBT() {
+ NBTTagCompound compound=new NBTTagCompound();
+ compound.setLong("computation",content);
+ return compound;
}
- public NBTTagCompound toNbt() {
- NBTTagCompound nbt = new NBTTagCompound();
- nbt.setLong("qComputation", computation);
- nbt.setByte("qHistory", (byte) trace.size());
- int i = 0;
- for (Vec3pos v : trace) {
- nbt.setInteger("qX" + i, v.x);
- nbt.setShort("qY" + i, v.y);
- nbt.setInteger("qZ" + i, v.z);
- i++;
- }
- return nbt;
+ @Override
+ public boolean extraCheck() {
+ return true;
}
- public boolean contains(Vec3pos v) {
- return trace.contains(v);
+ @Override
+ protected Long unifyContentWith(Long content) {
+ return this.content+content;
}
- public boolean check() {
- return trace.size() <= maxHistory;
+ public QuantumDataPacket unifyTraceWith(Vec3pos... positions) {
+ return (QuantumDataPacket) super.unifyTrace(positions);
}
public QuantumDataPacket unifyTraceWith(QuantumDataPacket p) {
- trace.addAll(p.trace);
- return check() ? this : null;
+ return (QuantumDataPacket) super.unifyTrace(p);
}
public QuantumDataPacket unifyPacketWith(QuantumDataPacket p) {
- computation += p.computation;
- trace.addAll(p.trace);
- return check() ? this : null;
- }
-
- public long computationIfNotContained(Vec3pos pos) {
- if (trace.contains(pos)) {
- return 0;
- }
- return computation;
+ return (QuantumDataPacket) super.unifyWith(p);
}
}
diff --git a/src/main/java/com/github/technus/tectech/loader/MachineLoader.java b/src/main/java/com/github/technus/tectech/loader/MachineLoader.java
index e242ba7670..a977796a76 100644
--- a/src/main/java/com/github/technus/tectech/loader/MachineLoader.java
+++ b/src/main/java/com/github/technus/tectech/loader/MachineLoader.java
@@ -269,6 +269,8 @@ public class MachineLoader implements Runnable {
dataIn_Hatch.set(new GT_MetaTileEntity_Hatch_InputData(15440, "hatch.datain.tier.07", "Optical Slave Connector", 7).getStackForm(1L));
dataOut_Hatch.set(new GT_MetaTileEntity_Hatch_OutputData(15441, "hatch.dataout.tier.07", "Optical Master Connector", 7).getStackForm(1L));
+ dataInAcc_Hatch.set(new GT_MetaTileEntity_Hatch_InputDataAccess(15442, "hatch.datainass.tier.07", "Assembly line Slave Connector", 7).getStackForm(1L));
+ dataOutAcc_Hatch.set(new GT_MetaTileEntity_Hatch_OutputDataAccess(15443, "hatch.dataoutass.tier.07", "Data Bank Master Connector", 7).getStackForm(1L));
rack_Hatch.set(new GT_MetaTileEntity_Hatch_Rack(15450, "hatch.rack.tier.08", "Computer Rack", 8, "4 Slot Rack").getStackForm(1L));
holder_Hatch.set(new GT_MetaTileEntity_Hatch_Holder(15451, "hatch.holder.tier.09", "Object Holder", 8, "For Research Station").getStackForm(1L));
diff --git a/src/main/java/com/github/technus/tectech/thing/CustomItemList.java b/src/main/java/com/github/technus/tectech/thing/CustomItemList.java
index 1259b14d97..5d9823b84a 100644
--- a/src/main/java/com/github/technus/tectech/thing/CustomItemList.java
+++ b/src/main/java/com/github/technus/tectech/thing/CustomItemList.java
@@ -37,7 +37,7 @@ public enum CustomItemList implements IItemContainer {
eM_in_UV, eM_in_UHV, eM_in_UEV, eM_in_UIV, eM_in_UMV, eM_in_UXV,
eM_out_UV, eM_out_UHV, eM_out_UEV, eM_out_UIV, eM_out_UMV, eM_out_UXV,
eM_muffler_UV, eM_muffler_UHV, eM_muffler_UEV, eM_muffler_UIV, eM_muffler_UMV, eM_muffler_UXV,
- Parametrizer_Hatch, ParametrizerX_Hatch, Uncertainty_Hatch, UncertaintyX_Hatch, dataIn_Hatch, dataOut_Hatch,
+ Parametrizer_Hatch, ParametrizerX_Hatch, Uncertainty_Hatch, UncertaintyX_Hatch, dataIn_Hatch, dataOut_Hatch, dataInAcc_Hatch, dataOutAcc_Hatch,
eM_Containment, eM_Containment_Field, eM_Containment_Advanced, eM_Coil, eM_Teleportation, eM_Dimensional, eM_Ultimate_Containment, eM_Ultimate_Containment_Advanced, eM_Ultimate_Containment_Field, eM_Spacetime, eM_Computer_Casing, eM_Computer_Bus, eM_Computer_Vent, eM_Hollow, eM_Power,
debugBlock,
Machine_Multi_Microwave,
diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_DataConnector.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_DataConnector.java
index 16eb50b4e4..a2ffc03b6c 100644
--- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_DataConnector.java
+++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_DataConnector.java
@@ -1,7 +1,7 @@
package com.github.technus.tectech.thing.metaTileEntity.hatch;
import com.github.technus.tectech.CommonValues;
-import com.github.technus.tectech.dataFramework.QuantumDataPacket;
+import com.github.technus.tectech.dataFramework.DataPacket;
import com.github.technus.tectech.thing.metaTileEntity.pipe.iConnectsToDataPipe;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@@ -24,12 +24,12 @@ import static gregtech.api.enums.Dyes.MACHINE_METAL;
/**
* Created by danie_000 on 11.12.2016.
*/
-public abstract class GT_MetaTileEntity_Hatch_DataConnector extends GT_MetaTileEntity_Hatch implements iConnectsToDataPipe {
+public abstract class GT_MetaTileEntity_Hatch_DataConnector<T extends DataPacket> extends GT_MetaTileEntity_Hatch implements iConnectsToDataPipe {
private static Textures.BlockIcons.CustomIcon EM_D_SIDES;
private static Textures.BlockIcons.CustomIcon EM_D_ACTIVE;
private static Textures.BlockIcons.CustomIcon EM_D_CONN;
- public QuantumDataPacket q;
+ public T q;
public short id = -1;
@@ -74,10 +74,12 @@ public abstract class GT_MetaTileEntity_Hatch_DataConnector extends GT_MetaTileE
super.loadNBTData(aNBT);
id = aNBT.getShort("eID");
if (aNBT.hasKey("eDATA")) {
- q = new QuantumDataPacket(aNBT.getCompoundTag("eDATA"));
+ q = loadPacketFromNBT(aNBT.getCompoundTag("eDATA"));
}
}
+ protected abstract T loadPacketFromNBT(NBTTagCompound nbt);
+
@Override
public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) {
if (aBaseMetaTileEntity.isServerSide()) {
@@ -142,11 +144,11 @@ public abstract class GT_MetaTileEntity_Hatch_DataConnector extends GT_MetaTileE
@Override
public String[] getInfoData() {
if (id > 0) {
- return new String[]{"ID: " + EnumChatFormatting.AQUA + id, "Computation: " + EnumChatFormatting.AQUA + (q != null ? q.computation : 0), "PacketHistory: " + EnumChatFormatting.RED + (q != null ? q.trace.size() : 0),};
+ return new String[]{"ID: " + EnumChatFormatting.AQUA + id, "Computation: " + EnumChatFormatting.AQUA + (q != null ? q.getContentString() : 0), "PacketHistory: " + EnumChatFormatting.RED + (q != null ? q.getTraceSize() : 0),};
}
return new String[]{
- "Computation: " + EnumChatFormatting.AQUA + (q != null ? q.computation : 0),
- "PacketHistory: " + EnumChatFormatting.RED + (q != null ? q.trace.size() : 0),
+ "Computation: " + EnumChatFormatting.AQUA + (q != null ? q.getContentString() : 0),
+ "PacketHistory: " + EnumChatFormatting.RED + (q != null ? q.getTraceSize() : 0),
};
}
diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_InputData.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_InputData.java
index 8a3ae77b7f..f239344b6c 100644
--- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_InputData.java
+++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_InputData.java
@@ -1,18 +1,20 @@
package com.github.technus.tectech.thing.metaTileEntity.hatch;
+import com.github.technus.tectech.dataFramework.QuantumDataPacket;
import com.github.technus.tectech.thing.metaTileEntity.pipe.iConnectsToDataPipe;
import gregtech.api.interfaces.ITexture;
import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
import gregtech.api.metatileentity.MetaTileEntity;
+import net.minecraft.nbt.NBTTagCompound;
/**
* Created by danie_000 on 27.10.2016.
*/
-public class GT_MetaTileEntity_Hatch_InputData extends GT_MetaTileEntity_Hatch_DataConnector {
+public class GT_MetaTileEntity_Hatch_InputData extends GT_MetaTileEntity_Hatch_DataConnector<QuantumDataPacket> {
public boolean delDelay = true;
public GT_MetaTileEntity_Hatch_InputData(int aID, String aName, String aNameRegional, int aTier) {
- super(aID, aName, aNameRegional, aTier, "Data Input for Multiblocks");
+ super(aID, aName, aNameRegional, aTier, "Quantum Data Input for Multiblocks");
}
public GT_MetaTileEntity_Hatch_InputData(String aName, int aTier, String aDescription, ITexture[][][] aTextures) {
@@ -25,6 +27,11 @@ public class GT_MetaTileEntity_Hatch_InputData extends GT_MetaTileEntity_Hatch_D
}
@Override
+ protected QuantumDataPacket loadPacketFromNBT(NBTTagCompound nbt) {
+ return new QuantumDataPacket(nbt);
+ }
+
+ @Override
public boolean isInputFacing(byte aSide) {
return aSide == getBaseMetaTileEntity().getFrontFacing();
}
diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_InputDataAccess.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_InputDataAccess.java
new file mode 100644
index 0000000000..ca0c04706b
--- /dev/null
+++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_InputDataAccess.java
@@ -0,0 +1,181 @@
+package com.github.technus.tectech.thing.metaTileEntity.hatch;
+
+import com.github.technus.tectech.CommonValues;
+import com.github.technus.tectech.dataFramework.InventoryDataPacket;
+import com.github.technus.tectech.thing.metaTileEntity.pipe.iConnectsToDataPipe;
+import gregtech.api.interfaces.ITexture;
+import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
+import gregtech.api.metatileentity.MetaTileEntity;
+import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_DataAccess;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.entity.player.InventoryPlayer;
+import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.util.EnumChatFormatting;
+
+import java.util.ArrayList;
+
+import static com.github.technus.tectech.CommonValues.MOVE_AT;
+
+public class GT_MetaTileEntity_Hatch_InputDataAccess extends GT_MetaTileEntity_Hatch_DataAccess implements iConnectsToDataPipe {
+ private final String mDescription;
+ public boolean delDelay;
+ private ItemStack[] stacks;
+
+ public GT_MetaTileEntity_Hatch_InputDataAccess(int aID, String aName, String aNameRegional, int aTier) {
+ super(aID, aName, aNameRegional, aTier);
+ mDescription="ItemStack Data Input for Multiblocks";
+ }
+
+ public GT_MetaTileEntity_Hatch_InputDataAccess(String aName, int aTier, String aDescription, ITexture[][][] aTextures) {
+ super(aName, aTier, aDescription, aTextures);
+ mDescription=aDescription;
+ }
+
+ @Override
+ public boolean isSimpleMachine() {
+ return true;
+ }
+
+ @Override
+ public boolean isFacingValid(byte aFacing) {
+ return true;
+ }
+
+ @Override
+ public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) {
+ return new GT_MetaTileEntity_Hatch_InputDataAccess(this.mName, this.mTier, mDescription, this.mTextures);
+ }
+
+ @Override
+ public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) {
+ if (aBaseMetaTileEntity.isClientSide()) {
+ return true;
+ } else {
+ aBaseMetaTileEntity.openGUI(aPlayer);
+ return true;
+ }
+ }
+
+ @Override
+ public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) {
+ return null;
+ }
+
+ @Override
+ public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) {
+ return null;
+ }
+
+ @Override
+ public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) {
+ return false;
+ }
+
+ @Override
+ public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) {
+ return false;
+ }
+
+ @Override
+ public int getInventoryStackLimit() {
+ return 1;
+ }
+
+ @Override
+ public boolean isOutputFacing(byte aSide) {
+ return false;
+ }
+
+ @Override
+ public boolean isInputFacing(byte aSide) {
+ return aSide == getBaseMetaTileEntity().getFrontFacing();
+ }
+
+ @Override
+ public boolean canConnect(byte side) {
+ return isInputFacing(side);
+ }
+
+ @Override
+ public iConnectsToDataPipe getNext(iConnectsToDataPipe source) {
+ return null;
+ }
+
+ public void setContents(InventoryDataPacket q){
+ if(q==null){
+ stacks=null;
+ }else{
+ if(q.getContent().length>0) {
+ stacks = q.getContent();
+ delDelay=true;
+ }else{
+ stacks=null;
+ }
+ }
+ }
+
+ @Override
+ public void saveNBTData(NBTTagCompound aNBT) {
+ super.saveNBTData(aNBT);
+ NBTTagCompound stacksTag=new NBTTagCompound();
+ if(stacks!=null && stacks.length>0){
+ stacksTag.setInteger("count",stacks.length);
+ for(int i=0;i<stacks.length;i++){
+ stacksTag.setTag(Integer.toString(i),stacks[i].writeToNBT(new NBTTagCompound()));
+ }
+ }
+ aNBT.setTag("data_stacks",stacksTag);
+ }
+
+ @Override
+ public void loadNBTData(NBTTagCompound aNBT) {
+ super.loadNBTData(aNBT);
+ NBTTagCompound stacksTag=new NBTTagCompound();
+ int count=stacksTag.getInteger("count");
+ if(count>0){
+ ArrayList<ItemStack> stacks=new ArrayList<>();
+ for(int i=0;i<count;i++){
+ ItemStack stack=ItemStack.loadItemStackFromNBT(stacksTag.getCompoundTag(Integer.toString(i)));
+ if(stack!=null){
+ stacks.add(stack);
+ }
+ }
+ if(stacks.size()>0) {
+ this.stacks = stacks.toArray(new ItemStack[0]);
+ }
+ }
+ }
+
+ @Override
+ public int getSizeInventory() {
+ return stacks!=null?stacks.length:0;
+ }
+
+ @Override
+ public ItemStack getStackInSlot(int aIndex) {
+ return stacks!=null && aIndex<stacks.length?stacks[aIndex]:null;
+ }
+
+ @Override
+ public void onPreTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) {
+ super.onPreTick(aBaseMetaTileEntity,aTick);
+ if(MOVE_AT == aTick % 20) {
+ if (delDelay) {
+ delDelay = false;
+ } else {
+ setContents(null);
+ }
+ }
+ }
+
+ @Override
+ public String[] getDescription() {
+ return new String[]{
+ CommonValues.TEC_MARK_EM,
+ mDescription,
+ "High speed fibre optics connector.",
+ EnumChatFormatting.AQUA + "Must be painted to work"
+ };
+ }
+}
diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_OutputData.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_OutputData.java
index ef5bc961bb..25449160b1 100644
--- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_OutputData.java
+++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_OutputData.java
@@ -1,5 +1,6 @@
package com.github.technus.tectech.thing.metaTileEntity.hatch;
+import com.github.technus.tectech.dataFramework.QuantumDataPacket;
import com.github.technus.tectech.thing.metaTileEntity.pipe.GT_MetaTileEntity_Pipe_Data;
import com.github.technus.tectech.thing.metaTileEntity.pipe.iConnectsToDataPipe;
import gregtech.api.interfaces.ITexture;
@@ -7,13 +8,14 @@ import gregtech.api.interfaces.metatileentity.IMetaTileEntity;
import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
import gregtech.api.metatileentity.MetaTileEntity;
import gregtech.api.util.GT_Utility;
+import net.minecraft.nbt.NBTTagCompound;
/**
* Created by danie_000 on 27.10.2016.
*/
-public class GT_MetaTileEntity_Hatch_OutputData extends GT_MetaTileEntity_Hatch_DataConnector {
+public class GT_MetaTileEntity_Hatch_OutputData extends GT_MetaTileEntity_Hatch_DataConnector<QuantumDataPacket> {
public GT_MetaTileEntity_Hatch_OutputData(int aID, String aName, String aNameRegional, int aTier) {
- super(aID, aName, aNameRegional, aTier, "Data Output for Multiblocks");
+ super(aID, aName, aNameRegional, aTier, "Quantum Data Output for Multiblocks");
}
public GT_MetaTileEntity_Hatch_OutputData(String aName, int aTier, String aDescription, ITexture[][][] aTextures) {
@@ -26,6 +28,11 @@ public class GT_MetaTileEntity_Hatch_OutputData extends GT_MetaTileEntity_Hatch_
}
@Override
+ protected QuantumDataPacket loadPacketFromNBT(NBTTagCompound nbt) {
+ return new QuantumDataPacket(nbt);
+ }
+
+ @Override
public boolean isOutputFacing(byte aSide) {
return aSide == getBaseMetaTileEntity().getFrontFacing();
}
diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_OutputDataAccess.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_OutputDataAccess.java
new file mode 100644
index 0000000000..5915dff18b
--- /dev/null
+++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_OutputDataAccess.java
@@ -0,0 +1,135 @@
+package com.github.technus.tectech.thing.metaTileEntity.hatch;
+
+import com.github.technus.tectech.dataFramework.InventoryDataPacket;
+import com.github.technus.tectech.thing.metaTileEntity.pipe.GT_MetaTileEntity_Pipe_Data;
+import com.github.technus.tectech.thing.metaTileEntity.pipe.iConnectsToDataPipe;
+import gregtech.api.interfaces.ITexture;
+import gregtech.api.interfaces.metatileentity.IMetaTileEntity;
+import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
+import gregtech.api.metatileentity.MetaTileEntity;
+import gregtech.api.util.GT_Utility;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.entity.player.InventoryPlayer;
+import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTTagCompound;
+
+public class GT_MetaTileEntity_Hatch_OutputDataAccess extends GT_MetaTileEntity_Hatch_DataConnector<InventoryDataPacket> {
+ public GT_MetaTileEntity_Hatch_OutputDataAccess(int aID, String aName, String aNameRegional, int aTier) {
+ super(aID, aName, aNameRegional, aTier, "ItemStack Data Output for Multiblocks");
+ }
+
+ public GT_MetaTileEntity_Hatch_OutputDataAccess(String aName, int aTier, String aDescription, ITexture[][][] aTextures) {
+ super(aName, aTier, aDescription, aTextures);
+ }
+
+ @Override
+ public boolean isSimpleMachine() {
+ return true;
+ }
+
+ @Override
+ public boolean isFacingValid(byte aFacing) {
+ return true;
+ }
+
+ @Override
+ public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) {
+ return new GT_MetaTileEntity_Hatch_OutputDataAccess(this.mName, this.mTier, this.mDescription, this.mTextures);
+ }
+
+ @Override
+ public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) {
+ if (aBaseMetaTileEntity.isClientSide()) {
+ return true;
+ } else {
+ aBaseMetaTileEntity.openGUI(aPlayer);
+ return true;
+ }
+ }
+
+ @Override
+ public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) {
+ return null;
+ }
+
+ @Override
+ public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) {
+ return null;
+ }
+
+ @Override
+ public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) {
+ return false;
+ }
+
+ @Override
+ public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) {
+ return false;
+ }
+
+ @Override
+ public int getInventoryStackLimit() {
+ return 1;
+ }
+
+ @Override
+ public boolean isOutputFacing(byte aSide) {
+ return aSide == getBaseMetaTileEntity().getFrontFacing();
+ }
+
+ @Override
+ public boolean isInputFacing(byte aSide) {
+ return false;
+ }
+
+ @Override
+ public boolean canConnect(byte side) {
+ return isOutputFacing(side);
+ }
+
+ @Override
+ public void moveAround(IGregTechTileEntity aBaseMetaTileEntity) {
+ iConnectsToDataPipe current = this, source = this, next;
+ int range = 0;
+ while ((next = current.getNext(source)) != null && range++ < 1000) {
+ if (next instanceof GT_MetaTileEntity_Hatch_InputDataAccess) {
+ ((GT_MetaTileEntity_Hatch_InputDataAccess) next).setContents(q);
+ break;
+ }
+ source = current;
+ current = next;
+ }
+ q = null;
+ }
+
+ @Override
+ public iConnectsToDataPipe getNext(iConnectsToDataPipe source/*==this*/) {
+ IGregTechTileEntity base = getBaseMetaTileEntity();
+ byte color = base.getColorization();
+ if (color < 0) {
+ return null;
+ }
+ IGregTechTileEntity next = base.getIGregTechTileEntityAtSide(base.getFrontFacing());
+ if (next == null || color != base.getColorization()) {
+ return null;
+ }
+ IMetaTileEntity meta = next.getMetaTileEntity();
+ if (meta instanceof iConnectsToDataPipe) {
+ if (meta instanceof GT_MetaTileEntity_Hatch_InputDataAccess
+ && GT_Utility.getOppositeSide(next.getFrontFacing()) == base.getFrontFacing()) {
+ return (iConnectsToDataPipe) meta;
+ }
+ if (meta instanceof GT_MetaTileEntity_Pipe_Data
+ /*&& ((GT_MetaTileEntity_Pipe_Data) meta).connectionCount==2*/)//Checked later
+ {
+ return (iConnectsToDataPipe) meta;
+ }
+ }
+ return null;
+ }
+
+ @Override
+ protected InventoryDataPacket loadPacketFromNBT(NBTTagCompound nbt) {
+ return new InventoryDataPacket(nbt);
+ }
+}
diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_computer.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_computer.java
index 4ab25671b7..e9a9cfd074 100644
--- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_computer.java
+++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_computer.java
@@ -166,7 +166,10 @@ public class GT_MetaTileEntity_EM_computer extends GT_MetaTileEntity_MultiblockB
public void outputAfterRecipe_EM() {
if (!eOutputData.isEmpty()) {
Vec3pos pos = new Vec3pos(getBaseMetaTileEntity());
- QuantumDataPacket pack = new QuantumDataPacket(pos, eAvailableData);
+ QuantumDataPacket pack = new QuantumDataPacket(eAvailableData / eOutputData.size()).unifyTraceWith(pos);
+ if(pack==null){
+ return;
+ }
for (GT_MetaTileEntity_Hatch_InputData hatch : eInputData) {
if (hatch.q == null || hatch.q.contains(pos)) {
continue;
@@ -177,8 +180,6 @@ public class GT_MetaTileEntity_EM_computer extends GT_MetaTileEntity_MultiblockB
}
}
- pack.computation /= eOutputData.size();
-
for (GT_MetaTileEntity_Hatch_OutputData o : eOutputData) {
o.q = pack;
}
diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_switch.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_switch.java
index bc0f975b8f..7b3a1d13b0 100644
--- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_switch.java
+++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_switch.java
@@ -127,7 +127,10 @@ public class GT_MetaTileEntity_EM_switch extends GT_MetaTileEntity_MultiblockBas
}
Vec3pos pos = new Vec3pos(getBaseMetaTileEntity());
- QuantumDataPacket pack = new QuantumDataPacket(pos, 0);
+ QuantumDataPacket pack = new QuantumDataPacket(0L).unifyTraceWith(pos);
+ if(pack==null) {
+ return;
+ }
for (GT_MetaTileEntity_Hatch_InputData hatch : eInputData) {
if (hatch.q == null || hatch.q.contains(pos)) {
continue;
@@ -138,7 +141,7 @@ public class GT_MetaTileEntity_EM_switch extends GT_MetaTileEntity_MultiblockBas
}
}
- long remaining = pack.computation;
+ long remaining = pack.getContent();
for (int i = 0; i < 10; i++) {
dest= getParameterIn(i,1);
@@ -151,17 +154,17 @@ public class GT_MetaTileEntity_EM_switch extends GT_MetaTileEntity_MultiblockBas
GT_MetaTileEntity_Hatch_OutputData out = eOutputData.get(outIndex);
if(Double.isInfinite(total)){
if(Double.isInfinite(weight)){
- out.q = new QuantumDataPacket(pack, remaining);
+ out.q = new QuantumDataPacket(remaining).unifyTraceWith(pack);
break;
}
}else{
- long part = (long) Math.floor(pack.computation * weight / total);
+ long part = (long) Math.floor(pack.getContent() * weight / total);
if (part > 0) {
remaining -= part;
if (remaining > 0) {
- out.q = new QuantumDataPacket(pack, part);
+ out.q = new QuantumDataPacket(part).unifyTraceWith(pack);
} else if (part + remaining > 0) {
- out.q = new QuantumDataPacket(pack, part + remaining);
+ out.q = new QuantumDataPacket( part + remaining).unifyTraceWith(pack);
break;
} else {
break;
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 17555e022a..b7b61e3cb8 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
@@ -359,6 +359,7 @@ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEnt
case 24:
result[2]=- a;
result[0]=- b;
+ result[0]=- b;
result[1]=+ c;
break;
}
@@ -797,7 +798,10 @@ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEnt
Vec3pos pos = new Vec3pos(getBaseMetaTileEntity());
for (GT_MetaTileEntity_Hatch_InputData in : eInputData) {
if (in.q != null) {
- result += in.q.computationIfNotContained(pos);
+ Long value=in.q.contentIfNotInTrace(pos);
+ if(value!=null) {
+ result += value;
+ }
}
}
return result;