SpongeAPI
SpongeAPI copied to clipboard
Add a new Key to represent shulker box contents
Right now, I don't think we have a way to know which items are inside a Shulker Box ItemStack, only getting the items from the TileEntity. It'd be useful to have a Keys.SHULKER_CONTENTS
or something so we know the items that are in the shulker box.
Keys.REPRESENTED_TILEENTITY
?
would then handle all items with BlockEntityTag
on them
Wouldn't the TileEntity data be not accurate or invalid if there's no TileEntity in the world?
Well its position would probably not be correct
This should be implemented by the InventoryItemData, which so far is not implemented as of yet. Since @Faithcaio knows a great deal about the inventory implementation, that would be the best route. Of course, we can also offer to provide an Optional<TileEntityArchetype>
and potentially expose it as a possible carrier where you can also do Optional<Inventory>
to retrieve a direct indexed inventory. Allowing the creation of a "fake" TileEntity
otherwise is a really bad idea as it would require a world and position when there is no tile entity involved (not to mention that mod tile entities could screw up a great deal on this premise).
I think TileEntityArchetype makes sense for 'middle ctrl click creative' shulker boxes, but not for regular shulker boxes. Basically whenever attached NBT
is on the item, as opposed to just an item holding an inventory?
@gabizou usually (at least for vanilla) the TileEntity itself is also the inventory. Quick try loading a fake TE worked see: https://github.com/SpongePowered/SpongeCommon/pull/1801 Opening the fake TileEntity Inventory works too.
The other option would be to create a "custom" inventory and fill it with the items from nbt (Similar to what I did for offline User Inventory), but which may be different for different TileEntities.
@ryantheleach I think it is the same NBT Tag that is used for that.
You might be right faith, I havn't looked at the code, just basing it off instinct from vanilla.
{
Slot: 7B
id: "minecraft:red_shulker_box"
Count: 1B
tag: {
BlockEntityTag: {
Items: [
{
Slot: 0B
id: "minecraft:sandstone"
Count: 1B
Damage: 0S
},
]
}
}
Damage: 0S
},
{
Slot: 8B
id: "minecraft:red_shulker_box"
Count: 1B
tag: {
BlockEntityTag: {
Items: [
{
Slot: 0B
id: "minecraft:sandstone"
Count: 1B
Damage: 0S
},
]
id: "minecraft:shulker_box"
Lock: ""
}
display: {
Lore: [ "(+NBT)", ]
}
}
Damage: 0S
},
Just to link this: https://github.com/SpongePowered/SpongeCommon/pull/1801