aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/kubatech/api/helpers/GTHelper.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/kubatech/api/helpers/GTHelper.java')
-rw-r--r--src/main/java/kubatech/api/helpers/GTHelper.java45
1 files changed, 45 insertions, 0 deletions
diff --git a/src/main/java/kubatech/api/helpers/GTHelper.java b/src/main/java/kubatech/api/helpers/GTHelper.java
index 201f8b45b7..e368c7b778 100644
--- a/src/main/java/kubatech/api/helpers/GTHelper.java
+++ b/src/main/java/kubatech/api/helpers/GTHelper.java
@@ -23,6 +23,14 @@ package kubatech.api.helpers;
import static gregtech.api.metatileentity.implementations.GT_MetaTileEntity_MultiBlockBase.isValidMetaTileEntity;
import static kubatech.api.Variables.ln4;
+import java.io.IOException;
+import java.util.ArrayList;
+
+import net.minecraft.item.ItemStack;
+import net.minecraft.network.PacketBuffer;
+
+import com.kuba6000.mobsinfo.api.utils.ItemID;
+
import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Energy;
import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_MultiBlockBase;
import kubatech.api.implementations.KubaTechGTMultiBlockBase;
@@ -52,4 +60,41 @@ public class GTHelper {
public static int getVoltageTier(GT_MetaTileEntity_MultiBlockBase mte) {
return (int) getVoltageTierD(mte);
}
+
+ public static class StackableItemSlot {
+
+ public StackableItemSlot(int count, ItemStack stack, ArrayList<Integer> realSlots) {
+ this.count = count;
+ this.stack = stack;
+ this.realSlots = realSlots;
+ }
+
+ public final int count;
+ public final ItemStack stack;
+ public final ArrayList<Integer> realSlots;
+
+ public void write(PacketBuffer buffer) throws IOException {
+ buffer.writeVarIntToBuffer(count);
+ buffer.writeItemStackToBuffer(stack);
+ }
+
+ public static StackableItemSlot read(PacketBuffer buffer) throws IOException {
+ return new StackableItemSlot(
+ buffer.readVarIntFromBuffer(),
+ buffer.readItemStackFromBuffer(),
+ new ArrayList<>());
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) return true;
+ if (!(obj instanceof StackableItemSlot)) return false;
+ StackableItemSlot other = (StackableItemSlot) obj;
+ return count == other.count && ItemID.createNoCopy(stack, false)
+ .hashCode()
+ == ItemID.createNoCopy(other.stack, false)
+ .hashCode()
+ && realSlots.equals(other.realSlots);
+ }
+ }
}