SpongeAPI icon indicating copy to clipboard operation
SpongeAPI copied to clipboard

Add a new Key to represent shulker box contents

Open Eufranio opened this issue 7 years ago • 8 comments

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.

Eufranio avatar Feb 13 '18 15:02 Eufranio

Keys.REPRESENTED_TILEENTITY ? would then handle all items with BlockEntityTag on them

Faithcaio avatar Feb 13 '18 17:02 Faithcaio

Wouldn't the TileEntity data be not accurate or invalid if there's no TileEntity in the world?

Eufranio avatar Feb 13 '18 17:02 Eufranio

Well its position would probably not be correct

Faithcaio avatar Feb 13 '18 17:02 Faithcaio

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).

gabizou avatar Feb 13 '18 20:02 gabizou

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?

ryantheleach avatar Feb 14 '18 00:02 ryantheleach

@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.

Faithcaio avatar Feb 14 '18 07:02 Faithcaio

You might be right faith, I havn't looked at the code, just basing it off instinct from vanilla.

image

image

{
                    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
                },

ryantheleach avatar Feb 14 '18 12:02 ryantheleach

Just to link this: https://github.com/SpongePowered/SpongeCommon/pull/1801

dualspiral avatar Jun 09 '20 10:06 dualspiral