KubeJS

KubeJS

61M Downloads

[KJS6:Fabric] EntityEvents.spawned doesnt work with entity.minecraft.item

TheonlyTazz opened this issue · 1 comments

commented

Minecraft Version

1.19.2

KubeJS Version

kubejs-fabric-1902.6.0-build.112.jar

Rhino Version

rhino-fabric-1902.2.1-build.257.jar

Architectury Version

architectury-6.3.49-fabric.jar

Forge/Fabric Version

0.14.10

Describe your issue

tried making an entitySpawned event that only runs on minecraft:item
adding in the minecraft:item in first line doesnt trigger it (EntityEvents.spawned('minecraft:item', event => {)
running console.log(event.entity.type) outputs entity.minecraft.item
but that also doesnt work

below is my current working script

EntityEvents.spawned(event => {
    // random goat horn chance
    if (event.entity.item == 'minecraft:goat_horn'){
        let nbt = event.entity.fullNBT
        if (nbt.Item.tag?.horncheck == 1) return
        let random = getRandomInt(1, 10)
        if (random <= 1) event.entity.setItem('cashmere:goat_horn')
        if (random > 1){
            nbt.Item.tag['horncheck'] = 1
            event.entity.fullNBT = nbt
        }
    }
    })

Crash report/logs

https://discord.com/channels/303440391124942858/1038807732632952874

commented
EntityEvents.spawned('minecraft:item', event => {
	console.info('Spawned Item ' + event.entity.item + ' @ ' + event.entity.position())
})

should now work

Also this event exists:

ItemEvents.dropped('minecraft:goat_horn', event => {
	console.info('Spawned Item ' + event.item + ' @ ' + event.itemEntity.position()  + ' by ' + event.player.name)
})