|
1 | 1 | package logisticspipes.logisticspipes;
|
2 | 2 |
|
3 | 3 | import java.util.ArrayList;
|
4 |
| -import java.util.Collection; |
5 | 4 | import java.util.List;
|
| 5 | +import java.util.Map; |
6 | 6 | import java.util.Random;
|
7 | 7 |
|
8 | 8 | import net.minecraft.item.ItemStack;
|
| 9 | +import net.minecraft.nbt.NBTBase; |
9 | 10 | import net.minecraft.nbt.NBTTagCompound;
|
10 | 11 | import net.minecraft.nbt.NBTTagList;
|
11 | 12 | import net.minecraft.nbt.NBTTagString;
|
@@ -78,21 +79,22 @@ public static void readInformation(ItemStack itemStack, LogisticsModule module)
|
78 | 79 | }
|
79 | 80 | }
|
80 | 81 |
|
81 |
| - public static void removeInformation(ItemStack itemStack) { |
82 |
| - if (itemStack == null) { |
| 82 | + /** |
| 83 | + * Remove mod-specific NBT tags from the given ItemStack. |
| 84 | + */ |
| 85 | + public static void removeInformation(final ItemStack itemStack) { |
| 86 | + if (itemStack == null || !itemStack.hasTagCompound()) { |
83 | 87 | return;
|
84 | 88 | }
|
85 |
| - if (itemStack.hasTagCompound()) { |
86 |
| - NBTTagCompound nbt = itemStack.getTagCompound(); |
| 89 | + |
| 90 | + final NBTTagCompound nbtCopy = new NBTTagCompound(); |
| 91 | + for (Object e : itemStack.getTagCompound().tagMap.entrySet()) { |
87 | 92 | @SuppressWarnings("unchecked")
|
88 |
| - Collection<String> collection = nbt.tagMap.keySet(); |
89 |
| - nbt = new NBTTagCompound(); |
90 |
| - for (String key : collection) { |
91 |
| - if (!ItemModuleInformationManager.Filter.contains(key)) { |
92 |
| - nbt.setTag(key, nbt.getTag(key)); |
93 |
| - } |
| 93 | + final Map.Entry<String, NBTBase> entry = (Map.Entry<String, NBTBase>) e; |
| 94 | + if (!ItemModuleInformationManager.Filter.contains(entry.getKey())) { |
| 95 | + nbtCopy.setTag(entry.getKey(), entry.getValue()); |
94 | 96 | }
|
95 |
| - itemStack.setTagCompound(nbt); |
96 | 97 | }
|
| 98 | + itemStack.setTagCompound(nbtCopy); |
97 | 99 | }
|
98 | 100 | }
|
0 commit comments