diff --git a/src/main/java/com/hbm/blocks/generic/BlockStorageCrate.java b/src/main/java/com/hbm/blocks/generic/BlockStorageCrate.java index 5e4a5937f..fa0258417 100644 --- a/src/main/java/com/hbm/blocks/generic/BlockStorageCrate.java +++ b/src/main/java/com/hbm/blocks/generic/BlockStorageCrate.java @@ -157,19 +157,26 @@ public class BlockStorageCrate extends BlockContainer implements IBlockMulti, IT if(!nbt.hasNoTags()) { drop.stackTagCompound = nbt; - - try { - byte[] abyte = CompressedStreamTools.compress(nbt); - - if(abyte.length > 6000) { - player.addChatComponentMessage(new ChatComponentText(EnumChatFormatting.RED + "Warning: Container NBT exceeds 6kB, contents will be ejected!")); - world.spawnEntityInWorld(new EntityItem(world, x + 0.5, y + 0.5, z + 0.5, new ItemStack(this))); - return world.setBlockToAir(x, y, z); - } - - } catch(IOException e) { } } + if(inv instanceof TileEntityCrateBase) { + TileEntityCrateBase crate = (TileEntityCrateBase) inv; + if (crate.hasCustomInventoryName()) { + drop.setStackDisplayName(crate.getInventoryName()); + } + } + + try { + 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!")); + world.spawnEntityInWorld(new EntityItem(world, x + 0.5, y + 0.5, z + 0.5, new ItemStack(this))); + return world.setBlockToAir(x, y, z); + } + + } 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()); + } } }