Better error handling in treasure disks

- Return a more sensible string for empty treasure disks (i.e. those
   given by /give). This should help identify packs which are giving
   items in non-supported ways.
 - Fix NPE when the treasure mount doesn't exist.

Fixes #801
This commit is contained in:
Jonathan Coates 2021-05-31 19:23:17 +01:00
parent 7fc55aa9a0
commit 8ff8b78ed8
No known key found for this signature in database
GPG Key ID: B9E431FF07C98D06
1 changed files with 3 additions and 1 deletions

View File

@ -68,6 +68,8 @@ public String getLabel( @Nonnull ItemStack stack )
public IMount createDataMount( @Nonnull ItemStack stack, @Nonnull World world )
{
IMount rootTreasure = getTreasureMount();
if( rootTreasure == null ) return null;
String subPath = getSubPath( stack );
try
{
@ -121,7 +123,7 @@ private static IMount getTreasureMount()
private static String getTitle( @Nonnull ItemStack stack )
{
CompoundNBT nbt = stack.getTag();
return nbt != null && nbt.contains( NBT_TITLE ) ? nbt.getString( NBT_TITLE ) : "'alongtimeago' by dan200";
return nbt != null && nbt.contains( NBT_TITLE ) ? nbt.getString( NBT_TITLE ) : "'missingno' by how did you get this anyway?";
}
@Nonnull