Skip to content

Commit 47bb2e9

Browse files
committed
don't write empty name strings to nbt
1 parent 7740330 commit 47bb2e9

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/main/java/gregtech/api/metatileentity/GTBaseTileEntity.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,9 @@ public void notifyBlockUpdate() {
8181
@Override
8282
public final void readFromNBT(@NotNull NBTTagCompound compound) {
8383
super.readFromNBT(compound);
84-
customName = compound.getString(GregtechDataCodes.CUSTOM_NAME);
84+
if (compound.hasKey(GregtechDataCodes.CUSTOM_NAME, Constants.NBT.TAG_STRING)) {
85+
customName = compound.getString(GregtechDataCodes.CUSTOM_NAME);
86+
}
8587
if (compound.hasKey("MetaId", Constants.NBT.TAG_STRING)) {
8688
readMTETag(compound.getCompoundTag("MetaTileEntity"));
8789
if (Mods.AppliedEnergistics2.isModLoaded()) {
@@ -94,7 +96,9 @@ public final void readFromNBT(@NotNull NBTTagCompound compound) {
9496
@Override
9597
public final NBTTagCompound writeToNBT(@NotNull NBTTagCompound compound) {
9698
super.writeToNBT(compound);
97-
compound.setString(GregtechDataCodes.CUSTOM_NAME, getName());
99+
if (hasCustomName()) {
100+
compound.setString(GregtechDataCodes.CUSTOM_NAME, getName());
101+
}
98102
compound.setString("MetaId", getMetaID().toString());
99103
NBTTagCompound metaTileEntityData = new NBTTagCompound();
100104
writeMTETag(metaTileEntityData);

0 commit comments

Comments
 (0)