Fixed exception with empty dictionary
This commit is contained in:
parent
578db63b88
commit
29ff7c3b3b
1 changed files with 10 additions and 14 deletions
|
@ -585,25 +585,21 @@ public class Dictionary {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static NBTBase writeItemsToNBT(final HashSet<Item> hashSetItem) {
|
public static NBTBase writeItemsToNBT(final HashSet<Item> hashSetItem) {
|
||||||
if ( hashSetItem != null
|
final NBTTagList nbtTagList = new NBTTagList();
|
||||||
&& !hashSetItem.isEmpty() ) {
|
assert(hashSetItem != null);
|
||||||
final NBTTagList nbtTagList = new NBTTagList();
|
for (final Item item : hashSetItem) {
|
||||||
|
final String registryName = Item.itemRegistry.getNameForObject(item);
|
||||||
for (final Item item : hashSetItem) {
|
nbtTagList.appendTag(new NBTTagString(registryName));
|
||||||
final String registryName = Item.itemRegistry.getNameForObject(item);
|
|
||||||
nbtTagList.appendTag(new NBTTagString(registryName));
|
|
||||||
}
|
|
||||||
|
|
||||||
return nbtTagList;
|
|
||||||
}
|
}
|
||||||
return null;
|
return nbtTagList;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static HashSet<Item> readItemsFromNBT(final NBTTagList nbtTagList) {
|
public static HashSet<Item> readItemsFromNBT(final NBTTagList nbtTagList) {
|
||||||
final HashSet<Item> hashSetItem = new HashSet<>(nbtTagList == null ? 8 : nbtTagList.tagCount());
|
assert(nbtTagList != null);
|
||||||
|
final int size = nbtTagList.tagCount();
|
||||||
|
final HashSet<Item> hashSetItem = new HashSet<>(Math.max(8, size));
|
||||||
|
|
||||||
if ( nbtTagList != null
|
if (size > 0) {
|
||||||
&& nbtTagList.tagCount() > 0 ) {
|
|
||||||
for (int index = 0; index < nbtTagList.tagCount(); index++) {
|
for (int index = 0; index < nbtTagList.tagCount(); index++) {
|
||||||
final String registryName = nbtTagList.getStringTagAt(index);
|
final String registryName = nbtTagList.getStringTagAt(index);
|
||||||
final Item item = GameData.getItemRegistry().getObject(registryName);
|
final Item item = GameData.getItemRegistry().getObject(registryName);
|
||||||
|
|
Loading…
Reference in a new issue