#/probejs dump isnt working, is there something else I can use?

72 messages · Page 1 of 1 (latest)

tawny hedge
glad iglooBOT
#

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

ionic salmonBOT
#

Paste version of latest.log from @tawny hedge

rugged needle
#

you can try to use kjs borealis

ionic salmonBOT
#

This mod adds a form of "documentation" to KubeJS using the mod Borealis as a means of accessing that documentation.
It adds a homepage to Borealis that allows anyone to get the details of a class file loaded on the client/server.

Mod made by @versed rover

tawny hedge
#

Im having no luck at all

#

just trying to find how to loop through the inventory nd check the item id and nbt

rugged needle
#

you can use e.player.inventory.find(item) to get the slot its in (returns -1 if its not in the inventory)
and you can use e.player.inventory.get(slot) to get the item in that slot

versed rover
rugged needle
#

its taking its sweet time loading

tawny hedge
#

works fine for me

#

does it have getters? I cant find them anywhere

tawny hedge
#

yea, I saw that

rugged needle
#

thats the getter

versed rover
#

KubeJS Offline, and borealis don't show "beans", however they are still there

rugged needle
#

i dont think get(slot) can be beaned

versed rover
#

Anytime you see A.getX, A.setX, A.isX, you can do A.x as a shortcut

versed rover
rugged needle
#

ah

tawny hedge
#

what does inventory.find() return if the item isnt found?

#

-1?

rugged needle
#

yes

#

like i said :p

tawny hedge
#

oh, yes, you did

#

and ive now coded this, which is probably messier than it needs to be, and I havent tested yet

#
onEvent('player.tick',event => {
    if (event.player.inventory.find('kubejs:trader_bucket') == -1) return
    let mainHand = false
    if (event.player.mainHandItem == {item: 'kubejs:trader_bucket', nbt: event.level.time % 20}) {
        mainHand = true
        event.player.playSound('minecraft:entity.wandering_trader.ambient', 20)
    }
    if (event.player.offHandItem.id == 'kubejs:trader_bucket') event.player.playSound('minecraft:entity.wandering_trader.ambient', 20)
    for (let i = 0; i < 9; i++) {
        if (event.player.inventory == {item: 'kubejs:trader_bucket', nbt: event.level.time % 20}) {
            if (mainHand) mainHand = false
            else event.player.playSound('minecraft:entity.wandering_trader.ambient', 15)
        }
    }
    for (let i = 9; i < 36; i++) {
        if (event.player.inventory.get(i) == {item: 'kubejs:trader_bucket', nbt: event.level.time % 20}) event.player.playSound('minecraft:entity.wandering_trader.ambient', 10)
    }
})```
#

I know I like the concept, im porting the event over from ctr

rugged needle
#

that nbt doesnt really make sense to me

#

and you dont write item like that

versed rover
#

Is your goal to play a sound if they hold an item in their main hand?

rugged needle
#

you use Item.of()

#

if (event.player.inventory == {item: 'kubejs:trader_bucket', nbt: event.level.time % 20})
an inventory cannot equal to an item

tawny hedge
tawny hedge
tawny hedge
#

Also that code is from before I add in the random parameter bc I forgot

#

It’s supposed to have a chance of playing a sound once per second

versed rover
tawny hedge
#

Well I need to check every item in the inventory

#

To see if it’s nbt matches

#

I have some already working ctr code that does this(tho for 1.16)

#

And I’m pretty much just trying to port that

rugged needle
#

but why do you check all slots

#

and not just directly the slot with the item in it...?

tawny hedge
#

There could be multiple copies of the item in the inventory

#

.find returns an int, not an int[], so I can’t check multiple slots with it

versed rover
#

Is your goal such that multiple items = higher pitch/duration in the same tick?

tawny hedge
#

It’s multiple items = higher volume

versed rover
#

And each item's slot counts towards the volume?

tawny hedge
#

Yea, each seperate item that triggers should make it louder, I haven’t implemented that yet though

versed rover
#
onEvent('player.tick', event=> {
    if(event.level.time % 20 == 0){
        let volume = 0;
        for(let i=0; i<event.player.inventory.size; i++){
            let slot = event.player.inventory.get(i).id == 'kubejs:trader_bucket' ? i : 0;
            volume += slot;
        }
        event.player.playSound('minecraft:entity.wandering_trader.ambient', volume)
    }
});
rugged needle
#

theres a count method

#

public int count(IngredientJS ingredient)

versed rover
#

That doesn't involve slot numbers, which was what they wanted to affect the volume

rugged needle
#

well they said the number of items influences the volume

#

more items = higher volume

#

number of items is given by count

versed rover
#

If it's number of items, then yes count would be better, if it's slot position, then you must loop through the items

rugged needle
tawny hedge
rugged needle
#

good lord bcePensiveThink

tawny hedge
#

Though with .count I can only loop through the hotbar vs the rest of the inventory too

glad iglooBOT
#

@tawny hedge Unresolved thread still hasn't been closed! If your question was answered, please close this post with </ticket close:1054771505520717835> command!