|
1 | 1 | package com.github.elenterius.biomancy.inventory;
|
2 | 2 |
|
3 |
| -import com.github.elenterius.biomancy.init.ModItems; |
4 |
| -import com.github.elenterius.biomancy.item.GiftSacItem; |
5 | 3 | import net.minecraft.nbt.CompoundTag;
|
6 | 4 | import net.minecraft.nbt.ListTag;
|
7 | 5 | import net.minecraft.nbt.Tag;
|
8 | 6 | import net.minecraft.world.item.ItemStack;
|
9 | 7 | import net.minecraftforge.items.ItemStackHandler;
|
10 | 8 |
|
11 |
| -import java.util.ArrayList; |
12 |
| -import java.util.List; |
13 |
| - |
14 | 9 | public class FixedSizeItemStackHandler extends ItemStackHandler implements SerializableItemHandler {
|
15 | 10 |
|
16 | 11 | public FixedSizeItemStackHandler(int size) {
|
@@ -40,36 +35,14 @@ public void deserializeNBT(CompoundTag tag) {
|
40 | 35 | setSize(stacks.size()); //fixed size
|
41 | 36 |
|
42 | 37 | ListTag list = tag.getList("Items", Tag.TAG_COMPOUND);
|
43 |
| - boolean isOverloaded = list.size() > stacks.size(); |
44 |
| - |
45 |
| - if (!isOverloaded) { |
46 |
| - for (int i = 0; i < list.size(); i++) { |
47 |
| - CompoundTag itemTag = list.getCompound(i); |
48 |
| - int slotIndex = itemTag.getInt("Slot"); |
49 |
| - |
50 |
| - if (slotIndex >= 0 && slotIndex < stacks.size()) { |
51 |
| - stacks.set(slotIndex, ItemStack.of(itemTag)); |
52 |
| - } |
53 |
| - } |
54 |
| - } |
55 |
| - else { |
56 |
| - List<CompoundTag> overloadedItems = new ArrayList<>(); |
57 |
| - int maxIndex = stacks.size() - 1; |
58 | 38 |
|
59 |
| - for (int i = 0; i < list.size(); i++) { |
60 |
| - CompoundTag itemTag = list.getCompound(i); |
61 |
| - int slotIndex = itemTag.getInt("Slot"); |
| 39 | + for (int i = 0; i < list.size(); i++) { |
| 40 | + CompoundTag itemTag = list.getCompound(i); |
| 41 | + int slotIndex = itemTag.getInt("Slot"); |
62 | 42 |
|
63 |
| - if (slotIndex >= 0 && slotIndex < maxIndex) { |
64 |
| - stacks.set(slotIndex, ItemStack.of(itemTag)); |
65 |
| - } |
66 |
| - else { |
67 |
| - overloadedItems.add(itemTag.copy()); |
68 |
| - } |
| 43 | + if (slotIndex >= 0 && slotIndex < stacks.size()) { |
| 44 | + stacks.set(slotIndex, ItemStack.of(itemTag)); |
69 | 45 | }
|
70 |
| - |
71 |
| - ItemStack giftSac = GiftSacItem.createFromItemTags(ModItems.GIFT_SAC.get(), overloadedItems); |
72 |
| - stacks.set(maxIndex, giftSac); |
73 | 46 | }
|
74 | 47 |
|
75 | 48 | onLoad();
|
|
0 commit comments