#How to get block inventory?

16 messages · Page 1 of 1 (latest)

royal ledge
#

Hello to anyone reading this! I'm trying to fix a bug with my mod (and such), and inventory stuff is not working.

I was given the following code from the person who reported this bug:

StartupEvents.registry('block', event => {
    event.create('ht_wireless_user')//.model("kubejs:block/teleporter_ht").renderType("cutout")
        .box(0,0,0,16,16,16)
        .mapColor('metal').hardness(4.0).displayName('wireless user').requiresTool(true).tagBlock("mineable/pickaxe").tagBlock('minecraft:needs_iron_tool').stoneSoundType()
        .blockEntity((e) =>{
            e.inventory(9,3)
            e.rightClickOpensInventory()
            //e.enableSync()
        })
})

ComputerCraftEvents.peripheral(event => {
    event.registerPeripheral("w_user", "kubejs:ht_wireless_user")
        .mainThreadMethod("break_block", (container, direction, arguments) => {
            //let max_range = global[type].max_range || 1000
            //let over_dim = global[type].over_dim || false

            let level = container.getLevel ? container.getLevel() : null;

            console.log("level: "+Object.keys(level).toString())

            console.log("container: "+Object.keys(container).toString())
            console.log("ed: "+Object.keys(container.entityData).toString())
            try{console.log("inv: "+Object.keys(container.inventory).toString())}catch(e){console.error("Error: " + e)}
            try{console.log("inv: "+Object.keys(container.entityData.inventory).toString())}catch(e){console.error("Error: " + e)}
            try{console.log("inv: " + Object.keys(container.entityData.get("attachments").toString()))} catch(e) {console.error("Error: " + e)}
        })
})

(I modified it a bit)

I would get the following logs: https://pastebin.com/U4jDw4mF

Any idea on how to fix this?

median cloudBOT
#

Once your ticket has been resolved, please close it with </ticket close:1054771505520717835> command!

mighty sapphire
#
container.entityData.Inventory
container.inventory
royal ledge
mighty sapphire
#

can you get the entitydata of that block

#

and send it out

royal ledge
#

lemme get the data

royal ledge
mighty sapphire
#
entityData.attachments[0].items
royal ledge
royal ledge
mighty sapphire
#

what about entityData.attachments[0]

royal ledge
mighty sapphire
#

then entityData.attachments[0].items should work

royal ledge
#

[{Count:1b,Slot:0b,id:"minecraft:jungle_button"}]