Skip to content

Commit 0559f6d

Browse files
authored
Fix: Client crashes when inserting renamed crafting module into chassis. (#82)
1 parent f252745 commit 0559f6d

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

src/main/java/logisticspipes/logisticspipes/ItemModuleInformationManager.java

+14-12
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
package logisticspipes.logisticspipes;
22

33
import java.util.ArrayList;
4-
import java.util.Collection;
54
import java.util.List;
5+
import java.util.Map;
66
import java.util.Random;
77

88
import net.minecraft.item.ItemStack;
9+
import net.minecraft.nbt.NBTBase;
910
import net.minecraft.nbt.NBTTagCompound;
1011
import net.minecraft.nbt.NBTTagList;
1112
import net.minecraft.nbt.NBTTagString;
@@ -78,21 +79,22 @@ public static void readInformation(ItemStack itemStack, LogisticsModule module)
7879
}
7980
}
8081

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()) {
8387
return;
8488
}
85-
if (itemStack.hasTagCompound()) {
86-
NBTTagCompound nbt = itemStack.getTagCompound();
89+
90+
final NBTTagCompound nbtCopy = new NBTTagCompound();
91+
for (Object e : itemStack.getTagCompound().tagMap.entrySet()) {
8792
@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());
9496
}
95-
itemStack.setTagCompound(nbt);
9697
}
98+
itemStack.setTagCompound(nbtCopy);
9799
}
98100
}

0 commit comments

Comments
 (0)