Skip to content

Commit a12c27e

Browse files
author
Circulate233
committed
修正拓展合成终端模式下的崩溃bug,优化nbt结构
2 parents 6cea7f0 + 418f3d8 commit a12c27e

1 file changed

Lines changed: 7 additions & 18 deletions

File tree

src/main/java/github/kasuminova/novaeng/common/item/ItemWirelessUniversalTerminal.java

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -192,11 +192,7 @@ public void nbtChange(EntityPlayer player, int mode, EnumHand hand) {
192192
if (item.getTagCompound().hasKey("cache")) {
193193
NBTTagList cache = item.getTagCompound().getCompoundTag("cache").getTagList(String.valueOf(mode), 10);
194194
if (cache.tagCount() != 0) {
195-
if (mode < 6) {
196-
item.getTagCompound().getCompoundTag("craftingGrid").setTag("Items", cache);
197-
} else if (mode < 10){
198-
item.getTagCompound().setTag("crafting", cache);
199-
}
195+
item.getTagCompound().getCompoundTag("craftingGrid").setTag("Items", cache);
200196
item.getTagCompound().getCompoundTag("cache").removeTag(String.valueOf(mode));
201197
} else {
202198
item.getTagCompound().getCompoundTag("cache").removeTag(String.valueOf(mode));
@@ -212,16 +208,12 @@ public void nbtChange(EntityPlayer player, int mode) {
212208
if (item.getTagCompound() != null && item.getItem() == RegistryItems.WIRELESS_UNIVERSAL_TERMINAL) {
213209
item.getTagCompound().setInteger("mode", mode);
214210
item.getTagCompound().setInteger("craft", 1);
215-
if (mode != 0 && mode != 2 && mode != 5) {
211+
if (mode != 0 && mode != 2) {
216212
List<Integer> list = Arrays.stream(item.getTagCompound().getIntArray("modes")).boxed().collect(Collectors.toList());
217213
if (list.contains(mode)) {
218214
NBTTagList cache = item.getTagCompound().getCompoundTag("cache").getTagList(String.valueOf(mode), 10);
219215
if (cache.tagCount() != 0) {
220-
if (mode < 6) {
221-
item.getTagCompound().getCompoundTag("craftingGrid").setTag("Items", cache);
222-
} else if (mode < 10){
223-
item.getTagCompound().setTag("crafting", cache);
224-
}
216+
item.getTagCompound().getCompoundTag("craftingGrid").setTag("Items", cache);
225217
item.getTagCompound().getCompoundTag("cache").removeTag(String.valueOf(mode));
226218
} else {
227219
item.getTagCompound().getCompoundTag("cache").removeTag(String.valueOf(mode));
@@ -241,11 +233,7 @@ public void nbtChange(EntityPlayer player, int mode) {
241233
if (list.contains(mode)) {
242234
NBTTagList cache = item.getTagCompound().getCompoundTag("cache").getTagList(String.valueOf(mode), 10);
243235
if (cache.tagCount() != 0) {
244-
if (mode < 6) {
245-
item.getTagCompound().getCompoundTag("craftingGrid").setTag("Items", cache);
246-
} else if (mode < 10){
247-
item.getTagCompound().setTag("crafting", cache);
248-
}
236+
item.getTagCompound().getCompoundTag("craftingGrid").setTag("Items", cache);
249237
item.getTagCompound().getCompoundTag("cache").removeTag(String.valueOf(mode));
250238
} else {
251239
item.getTagCompound().getCompoundTag("cache").removeTag(String.valueOf(mode));
@@ -342,9 +330,10 @@ public void nbtChangeB(EntityPlayer player) {
342330
}
343331
if (items.tagCount() != 0) {
344332
item.getTagCompound().getCompoundTag("cache").setTag(String.valueOf(mode), items);
333+
item.getTagCompound().getCompoundTag("craftingGrid").removeTag("Items");
334+
} else {
335+
item.getTagCompound().getCompoundTag("craftingGrid").removeTag("Items");
345336
}
346-
item.getTagCompound().getCompoundTag("craftingGrid").removeTag("Items");
347-
item.getTagCompound().removeTag("crafting");
348337
}
349338
}
350339
}

0 commit comments

Comments
 (0)