Fix Binding::fromStack returning null on stacks with binding tags

Added Binding::toString
This commit is contained in:
TeamDman 2018-12-05 16:25:58 -05:00 committed by Nick Ignoffo
parent 259b631f7d
commit 54a2b053d0

View file

@ -57,9 +57,12 @@ public class Binding implements INBTSerializable<NBTTagCompound> {
@Nullable
public static Binding fromStack(ItemStack stack) {
if (!stack.hasTagCompound()) // Definitely hasn't been bound yet.
// if (!stack.hasTagCompound()) // Definitely hasn't been bound yet.
// return null;
if (stack.getTagCompound() == null) // hasTagCompound doesn't work on empty stacks with tags
return null;
NBTBase bindingTag = stack.getTagCompound().getTag("binding");
if (bindingTag == null || bindingTag.getId() != 10 || bindingTag.hasNoTags()) // Make sure it's both a tag compound and that it has actual data.
return null;
@ -68,4 +71,9 @@ public class Binding implements INBTSerializable<NBTTagCompound> {
binding.deserializeNBT((NBTTagCompound) bindingTag);
return binding;
}
@Override
public String toString() {
return "Binding{" + "uuid=" + uuid + ", name='" + name + '\'' + '}';
}
}