forked from GeyserMC/Geyser
Check the name tag exists for anvil renaming to prevent an NPE (#936)
* Check the name tag exists for anvil renaming to prevent an NPE * Fix item names being empty if display tag exists with no name
This commit is contained in:
parent
7757913c00
commit
485ba1b8a7
2 changed files with 2 additions and 2 deletions
|
@ -136,7 +136,7 @@ public class AnvilInventoryTranslator extends BlockInventoryTranslator {
|
||||||
CompoundTag tag = item.getNbt();
|
CompoundTag tag = item.getNbt();
|
||||||
if (tag != null) {
|
if (tag != null) {
|
||||||
CompoundTag displayTag = tag.get("display");
|
CompoundTag displayTag = tag.get("display");
|
||||||
if (displayTag != null) {
|
if (displayTag != null && displayTag.contains("Name")) {
|
||||||
String itemName = displayTag.get("Name").getValue().toString();
|
String itemName = displayTag.get("Name").getValue().toString();
|
||||||
TextMessage message = (TextMessage) MessageSerializer.fromString(itemName);
|
TextMessage message = (TextMessage) MessageSerializer.fromString(itemName);
|
||||||
rename = message.getText();
|
rename = message.getText();
|
||||||
|
|
|
@ -157,7 +157,7 @@ public abstract class ItemTranslator {
|
||||||
NbtMap tag = itemData.getTag();
|
NbtMap tag = itemData.getTag();
|
||||||
if (tag != null) {
|
if (tag != null) {
|
||||||
NbtMap display = tag.getCompound("display");
|
NbtMap display = tag.getCompound("display");
|
||||||
if (display != null && !display.isEmpty()) {
|
if (display != null && !display.isEmpty() && display.containsKey("Name")) {
|
||||||
String name = display.getString("Name");
|
String name = display.getString("Name");
|
||||||
|
|
||||||
// If its not a message convert it
|
// If its not a message convert it
|
||||||
|
|
Loading…
Reference in a new issue