diff options
| author | Jakub <53441451+kuba6000@users.noreply.github.com> | 2024-09-04 21:45:17 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-09-04 19:45:17 +0000 |
| commit | 5b5311ab6cda52d33d60c23effad8a1f811e2f0f (patch) | |
| tree | 1ac998acc0d1f4b0ac3a6cb8a5ba94ef964c11c4 /src/main/java/kubatech/api | |
| parent | d00d97c5fd41f8c4751249674452425aaad2d5f7 (diff) | |
| download | GT5-Unofficial-5b5311ab6cda52d33d60c23effad8a1f811e2f0f.tar.gz GT5-Unofficial-5b5311ab6cda52d33d60c23effad8a1f811e2f0f.tar.bz2 GT5-Unofficial-5b5311ab6cda52d33d60c23effad8a1f811e2f0f.zip | |
Remove hard dep on mobs-info (#3053)
Co-authored-by: Martin Robertz <dream-master@gmx.net>
Diffstat (limited to 'src/main/java/kubatech/api')
| -rw-r--r-- | src/main/java/kubatech/api/DynamicInventory.java | 22 | ||||
| -rw-r--r-- | src/main/java/kubatech/api/EIGDynamicInventory.java | 8 | ||||
| -rw-r--r-- | src/main/java/kubatech/api/helpers/GTHelper.java | 17 |
3 files changed, 19 insertions, 28 deletions
diff --git a/src/main/java/kubatech/api/DynamicInventory.java b/src/main/java/kubatech/api/DynamicInventory.java index ef89c3a341..f718101384 100644 --- a/src/main/java/kubatech/api/DynamicInventory.java +++ b/src/main/java/kubatech/api/DynamicInventory.java @@ -34,8 +34,8 @@ import com.gtnewhorizons.modularui.common.widget.ChangeableWidget; import com.gtnewhorizons.modularui.common.widget.DynamicPositionedRow; import com.gtnewhorizons.modularui.common.widget.FakeSyncWidget; import com.gtnewhorizons.modularui.common.widget.Scrollable; -import com.kuba6000.mobsinfo.api.utils.ItemID; +import gregtech.api.util.GTUtility.ItemId; import kubatech.api.helpers.GTHelper; import kubatech.api.utils.ModUtils; @@ -117,19 +117,19 @@ public class DynamicInventory<T> { } }), builder) .attachSyncer(new FakeSyncWidget.ListSyncer<>(() -> { - HashMap<ItemID, Integer> itemMap = new HashMap<>(); - HashMap<ItemID, ItemStack> stackMap = new HashMap<>(); - HashMap<ItemID, ArrayList<Integer>> realSlotMap = new HashMap<>(); + HashMap<ItemId, Integer> itemMap = new HashMap<>(); + HashMap<ItemId, ItemStack> stackMap = new HashMap<>(); + HashMap<ItemId, ArrayList<Integer>> realSlotMap = new HashMap<>(); for (int i = 0, mStorageSize = inventory.size(); i < mStorageSize; i++) { ItemStack stack = inventoryGetter.get(inventory.get(i)); - ItemID id = ItemID.createNoCopy(stack, false); + ItemId id = ItemId.createNoCopyWithStackSize(stack); itemMap.merge(id, 1, Integer::sum); stackMap.putIfAbsent(id, stack); realSlotMap.computeIfAbsent(id, unused -> new ArrayList<>()) .add(i); } List<GTHelper.StackableItemSlot> newDrawables = new ArrayList<>(); - for (Map.Entry<ItemID, Integer> entry : itemMap.entrySet()) { + for (Map.Entry<ItemId, Integer> entry : itemMap.entrySet()) { newDrawables.add( new GTHelper.StackableItemSlot( entry.getValue(), @@ -172,19 +172,19 @@ public class DynamicInventory<T> { ArrayList<Widget> buttons = new ArrayList<>(); if (!ModUtils.isClientThreaded()) { - HashMap<ItemID, Integer> itemMap = new HashMap<>(); - HashMap<ItemID, ItemStack> stackMap = new HashMap<>(); - HashMap<ItemID, ArrayList<Integer>> realSlotMap = new HashMap<>(); + HashMap<ItemId, Integer> itemMap = new HashMap<>(); + HashMap<ItemId, ItemStack> stackMap = new HashMap<>(); + HashMap<ItemId, ArrayList<Integer>> realSlotMap = new HashMap<>(); for (int i = 0, inventorySize = inventory.size(); i < inventorySize; i++) { ItemStack stack = inventoryGetter.get(inventory.get(i)); - ItemID id = ItemID.createNoCopy(stack, false); + ItemId id = ItemId.createNoCopyWithStackSize(stack); itemMap.merge(id, 1, Integer::sum); stackMap.putIfAbsent(id, stack); realSlotMap.computeIfAbsent(id, unused -> new ArrayList<>()) .add(i); } drawables = new ArrayList<>(); - for (Map.Entry<ItemID, Integer> entry : itemMap.entrySet()) { + for (Map.Entry<ItemId, Integer> entry : itemMap.entrySet()) { drawables.add( new GTHelper.StackableItemSlot( entry.getValue(), diff --git a/src/main/java/kubatech/api/EIGDynamicInventory.java b/src/main/java/kubatech/api/EIGDynamicInventory.java index 1c703fe2fa..1b709a2654 100644 --- a/src/main/java/kubatech/api/EIGDynamicInventory.java +++ b/src/main/java/kubatech/api/EIGDynamicInventory.java @@ -3,7 +3,6 @@ package kubatech.api; import java.io.IOException; import java.util.ArrayList; import java.util.Collections; -import java.util.HashMap; import java.util.LinkedList; import java.util.List; import java.util.Objects; @@ -33,7 +32,6 @@ import com.gtnewhorizons.modularui.common.widget.ChangeableWidget; import com.gtnewhorizons.modularui.common.widget.DynamicPositionedRow; import com.gtnewhorizons.modularui.common.widget.FakeSyncWidget; import com.gtnewhorizons.modularui.common.widget.Scrollable; -import com.kuba6000.mobsinfo.api.utils.ItemID; import kubatech.api.gui.AutoScalingStackSizeText; import kubatech.api.helpers.GTHelper; @@ -205,9 +203,6 @@ public class EIGDynamicInventory<T> { ArrayList<Widget> buttons = new ArrayList<>(); if (!ModUtils.isClientThreaded()) { - HashMap<ItemID, Integer> itemMap = new HashMap<>(); - HashMap<ItemID, ItemStack> stackMap = new HashMap<>(); - HashMap<ItemID, ArrayList<Integer>> realSlotMap = new HashMap<>(); drawables = new ArrayList<>(); for (int i = 0, inventorySize = inventory.size(); i < inventorySize; i++) { T slot = inventory.get(i); @@ -215,8 +210,7 @@ public class EIGDynamicInventory<T> { continue; } ItemStack stack = inventoryGetter.get(slot); - drawables - .add(new GTHelper.StackableItemSlot(1, stack, new ArrayList<Integer>(Collections.singleton(i)))); + drawables.add(new GTHelper.StackableItemSlot(1, stack, new ArrayList<>(Collections.singleton(i)))); } } diff --git a/src/main/java/kubatech/api/helpers/GTHelper.java b/src/main/java/kubatech/api/helpers/GTHelper.java index fe6a2a6167..645cd49356 100644 --- a/src/main/java/kubatech/api/helpers/GTHelper.java +++ b/src/main/java/kubatech/api/helpers/GTHelper.java @@ -28,16 +28,15 @@ 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.MTEHatchEnergy; import gregtech.api.metatileentity.implementations.MTEMultiBlockBase; +import gregtech.api.util.GTUtility.ItemId; import kubatech.api.implementations.KubaTechGTMultiBlockBase; public class GTHelper { public static long getMaxInputEU(MTEMultiBlockBase mte) { - if (mte instanceof KubaTechGTMultiBlockBase) return ((KubaTechGTMultiBlockBase<?>) mte).getMaxInputEu(); + if (mte instanceof KubaTechGTMultiBlockBase) return mte.getMaxInputEu(); long rEU = 0; for (MTEHatchEnergy tHatch : mte.mEnergyHatches) if (tHatch.isValid()) rEU += tHatch.maxEUInput() * tHatch.maxAmperesIn(); @@ -65,11 +64,14 @@ public class GTHelper { public StackableItemSlot(int count, ItemStack stack, ArrayList<Integer> realSlots) { this.count = count; this.stack = stack; + this.hashcode = ItemId.createNoCopyWithStackSize(stack) + .hashCode(); this.realSlots = realSlots; } public final int count; public final ItemStack stack; + private final int hashcode; public final ArrayList<Integer> realSlots; public void write(PacketBuffer buffer) throws IOException { @@ -87,13 +89,8 @@ public class GTHelper { @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); + if (!(obj instanceof StackableItemSlot other)) return false; + return count == other.count && hashcode == other.hashcode && realSlots.equals(other.realSlots); } } } |
