diff options
author | Jakub <53441451+kuba6000@users.noreply.github.com> | 2023-09-05 08:27:22 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-09-05 08:27:22 +0200 |
commit | 74e1d0964ec002482253384c97fe76de54dc7de1 (patch) | |
tree | 281d159099ec7d2c315a54f89bae6eeb3d5b1873 /src/main/java/kubatech/api/helpers | |
parent | d1f7d54620be77d4e9c413978a6c9497401fc9c2 (diff) | |
download | GT5-Unofficial-74e1d0964ec002482253384c97fe76de54dc7de1.tar.gz GT5-Unofficial-74e1d0964ec002482253384c97fe76de54dc7de1.tar.bz2 GT5-Unofficial-74e1d0964ec002482253384c97fe76de54dc7de1.zip |
Merge identical slots in EIG + MApiary GUI (#93)
* Merge identical slots in EIG GUI
* Mega Apiary
* Update MobHandlerLoader.java
* Update GTHelper.java
* Update GT_MetaTileEntity_ExtremeIndustrialGreenhouse.java
* Update GT_MetaTileEntity_MegaIndustrialApiary.java
* Update build.gradle
* crop
* 99+
Diffstat (limited to 'src/main/java/kubatech/api/helpers')
-rw-r--r-- | src/main/java/kubatech/api/helpers/GTHelper.java | 45 |
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); + } + } } |