Retain names for storage crates

This commit is contained in:
abel1502 2025-06-02 20:39:44 +03:00
parent 7ef016ccce
commit 169f1666e7
No known key found for this signature in database
GPG Key ID: 076926596A536338

View File

@ -157,9 +157,17 @@ public class BlockStorageCrate extends BlockContainer implements IBlockMulti, IT
if(!nbt.hasNoTags()) {
drop.stackTagCompound = nbt;
}
if(inv instanceof TileEntityCrateBase) {
TileEntityCrateBase crate = (TileEntityCrateBase) inv;
if (crate.hasCustomInventoryName()) {
drop.setStackDisplayName(crate.getInventoryName());
}
}
try {
byte[] abyte = CompressedStreamTools.compress(nbt);
byte[] abyte = CompressedStreamTools.compress(drop.stackTagCompound);
if(abyte.length > 6000) {
player.addChatComponentMessage(new ChatComponentText(EnumChatFormatting.RED + "Warning: Container NBT exceeds 6kB, contents will be ejected!"));
@ -168,7 +176,6 @@ public class BlockStorageCrate extends BlockContainer implements IBlockMulti, IT
}
} catch(IOException e) { }
}
world.spawnEntityInWorld(new EntityItem(world, x + 0.5, y + 0.5, z + 0.5, drop));
}
@ -220,8 +227,14 @@ public class BlockStorageCrate extends BlockContainer implements IBlockMulti, IT
lockable.lock();
}
}
if(inv instanceof TileEntityCrateBase) {
((TileEntityCrateBase) inv).hasSpiders = stack.stackTagCompound.getBoolean("spiders");
TileEntityCrateBase crate = (TileEntityCrateBase) inv;
crate.hasSpiders = stack.stackTagCompound.getBoolean("spiders");
if (stack.hasDisplayName()) {
crate.setCustomName(stack.getDisplayName());
}
}
}