#custom item spawns entity not working

87 messages · Page 1 of 1 (latest)

tulip magnet
#

my code:
event.create('energized_orbee').maxStackSize(1).rarity('rare').glow(true) .finishUsing((itemstack, level, entity) => { let summonGhow = level.createEntity("ghastcow:ghast_cow") summonGhow.y += 10 summonGhow.spawn() itemstack.itemstack.shrink(1) })

viral tartanBOT
#

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

tulip magnet
#

its in onEvent('item.registry', event => {

woeful owl
#

you didnt give the mob a position

#
let entity = level.createEntity('adventurez:piglin_beast')
entity.x = x
entity.y = y
entity.z = z
entity.spawn()
#

as an example

tulip magnet
#

Oh wow so I need to specify the position?

#

Didn’t think I needed too I’ll fix it tomorrow

woeful owl
#

Well it won't know where to spawn it :p

tulip magnet
#

Can I just put x, y, z in?

woeful owl
#

Best case it will default to 0 0 0

tulip magnet
#

So is it summoning to relative position or natural coordinates

woeful owl
#

I can check in a bit if there's other ways, but with that example you can just put your players xyz

#

Or any xyz that you calculate

tulip magnet
#

So for example if I wanted to spawn it ten blocks above the player

#

I would make x 0 y 10 and z 0?

woeful owl
#

Then it's just player.y + 10

#

And x/z is player.x/z

tulip magnet
#

Oh I see

woeful owl
#

Can't leave it zero

#

That's world coordinates

tulip magnet
#

So entity.y = player.y + 10

woeful owl
#

Ye

#

Something like that

tulip magnet
#

Awesome thank you I will test tomorrow as I am currently in bed

woeful owl
#

Can't really check exactly, cuz I'm on phone

tulip magnet
#

Same lol

woeful owl
#

But that would be the basic idea

tulip magnet
#

doesnt seem to have worked

#

event.create('energized_orbee').maxStackSize(1).rarity('rare').glow(true) .finishUsing((itemstack, level, entity) => { let summonGhow = level.createEntity("ghastcow:ghast_cow") summonGhow.x = player.x summonGhow.y = player.y + 10 summonGhow.z = player.z summonGhow.spawn() itemstack.itemstack.shrink(1) })

marsh jay
#

player is not defined there anywhere.... use entity as that's what you're passed in the function

tulip magnet
#

still not working :C

#

im not getting any errors thrown though

#

new code
`onEvent('item.registry', event => {
event.create('crystal_clump').maxStackSize(1).rarity('rare').tooltip('Oooo, Shiny!')
event.create('glow_goop').maxStackSize(3).rarity('rare').tooltip('Very Sticky!')
event.create('plate').maxStackSize(2).rarity('rare').tooltip('I wonder where this goes?')
event.create('giant_head').maxStackSize(1).rarity('rare').tooltip("WOAH, It's huge!")
event.create('udder').maxStackSize(1).rarity('rare').tooltip("Uhm")
event.create('ghast_eye').maxStackSize(4).rarity('rare')
event.create('ghasts_sadness').maxStackSize(1).rarity('rare')
event.create('orbee').maxStackSize(1).rarity('rare')
event.create('energized_orbee').maxStackSize(1).rarity('rare').glow(true)
.finishUsing((itemstack, level, entity) => {
let summonGhow = level.createEntity("ghastcow:ghast_cow")
summonGhow.x = entity.x
summonGhow.y = entity.y + 10
summonGhow.z = entity.z
summonGhow.spawn()
itemstack.itemstack.shrink(1)
})

// Register new items here
// event.create('example_item',).displayName('Example Item').maxStackSize(1)

})`

#

i think i forgot to specify in the code that the item is useable gimme a sec

hushed furnaceBOT
#

You can write your code in a codeblock by typing it between the codeblock delimiters:

```js
onEvent('recipes', e => {
e.smelting('minecraft:glass', '#forge:sand').xp(.1)
})
```

As an example, :arrow_up: will look like this:

onEvent('recipes', e => {
  e.smelting('minecraft:glass', '#forge:sand').xp(.1)
})
tulip magnet
#
adsa ```
#
onEVent
#

i see

#

everything is working now just fixing a crash here is new code

#
onEvent('item.registry', event => {
    event.create('crystal_clump').maxStackSize(1).rarity('rare').tooltip('Oooo, Shiny!')
    event.create('glow_goop').maxStackSize(3).rarity('rare').tooltip('Very Sticky!')
    event.create('plate').maxStackSize(2).rarity('rare').tooltip('I wonder where this goes?')
    event.create('giant_head').maxStackSize(1).rarity('rare').tooltip("WOAH, It's huge!")
    event.create('udder').maxStackSize(1).rarity('rare').tooltip("Uhm")
    event.create('ghast_eye').maxStackSize(4).rarity('rare')
    event.create('ghasts_sadness').maxStackSize(1).rarity('rare')
    event.create('orbee').maxStackSize(1).rarity('rare')
    event.create('energized_orbee').maxStackSize(1).rarity('rare').glow(true)
        .useDuration((itemstack) => 1)
        .use((level, player, hand) => true)
        .finishUsing((itemstack, level, entity) => {
            let summonGhow = level.createEntity("ghastcow:ghast_cow")
            summonGhow.fullNBT = {Attributes: [{Base: 1d, Name: "minecraft:generic.movement_speed"}, {Base:1000d, Name: "minecraft:generic.max_health"}, {Base:10d, Name: "minecraft:generic.armor"}], HandItems: [{id: "minecraft:diamond", Count: 1b}, {}]},
            summonGhow.x = entity.x,
            summonGhow.y = entity.y + 10,
            summonGhow.z = entity.z,
            summonGhow.spawn(),
            itemstack.itemStack.shrink(1)
        })

    // Register new items here
    // event.create('example_item',).displayName('Example Item').maxStackSize(1)
})
woeful owl
#

whats the crash

tulip magnet
woeful owl
#

not that xD

#

either a crash log or startup log

tulip magnet
#

logs say nathing

hushed furnaceBOT
#

Paste version of startup.txt, latest.log from @tulip magnet

woeful owl
#

what do you mean says nothing

#

its literally first line

#

missing } after property list (startup_scripts:script.js#18)

#

how did you miss a bracket NotLikeThis

tulip magnet
#

yep but where is it missing

woeful owl
#

is your editor not giving you a warning?

#

or an error rather

tulip magnet
#

nope

woeful owl
#

what

#

what are you using

tulip magnet
#

vscode

woeful owl
#

then somethings wrong with your install

#

mine is giving me errors

tulip magnet
#

what

woeful owl
#

4 errors

#
onEvent('item.registry', event => {
    event.create('crystal_clump').maxStackSize(1).rarity('rare').tooltip('Oooo, Shiny!')
    event.create('glow_goop').maxStackSize(3).rarity('rare').tooltip('Very Sticky!')
    event.create('plate').maxStackSize(2).rarity('rare').tooltip('I wonder where this goes?')
    event.create('giant_head').maxStackSize(1).rarity('rare').tooltip('WOAH, It\'s huge!')
    event.create('udder').maxStackSize(1).rarity('rare').tooltip('Uhm')
    event.create('ghast_eye').maxStackSize(4).rarity('rare')
    event.create('ghasts_sadness').maxStackSize(1).rarity('rare')
    event.create('orbee').maxStackSize(1).rarity('rare')
    event.create('energized_orbee').maxStackSize(1).rarity('rare').glow(true)
        .useDuration((itemstack) => 1)
        .use((level, player, hand) => true)
        .finishUsing((itemstack, level, entity) => {
            let summonGhow = level.createEntity('ghastcow:ghast_cow')
            summonGhow.fullNBT = { Attributes: [{ Base: '1d', Name: 'minecraft:generic.movement_speed' }, { Base: '1000d', Name: 'minecraft:generic.max_health' }, { Base: '10d', Name: 'minecraft:generic.armor' }], HandItems: [{ id: 'minecraft:diamond', Count: '1b' }, {}] },
                summonGhow.x = entity.x,
                summonGhow.y = entity.y + 10,
                summonGhow.z = entity.z,
                summonGhow.spawn(),
                itemstack.itemStack.shrink(1)
        })
})
tulip magnet
#

bruh i forgot a ,

woeful owl
#

wha

tulip magnet
#

i got rid of all the ,

#

im so confused

#

all my errors are

[{
    "resource": "/D:/CurseForge/Minecraft/Instances/ShipTest/kubejs/startup_scripts/script.js",
    "owner": "typescript",
    "code": "1351",
    "severity": 8,
    "message": "An identifier or keyword cannot immediately follow a numeric literal.",
    "source": "ts",
    "startLineNumber": 18,
    "startColumn": 47,
    "endLineNumber": 18,
    "endColumn": 48
},{
    "resource": "/D:/CurseForge/Minecraft/Instances/ShipTest/kubejs/startup_scripts/script.js",
    "owner": "typescript",
    "code": "1351",
    "severity": 8,
    "message": "An identifier or keyword cannot immediately follow a numeric literal.",
    "source": "ts",
    "startLineNumber": 18,
    "startColumn": 103,
    "endLineNumber": 18,
    "endColumn": 104
},{
    "resource": "/D:/CurseForge/Minecraft/Instances/ShipTest/kubejs/startup_scripts/script.js",
    "owner": "typescript",
    "code": "1351",
    "severity": 8,
    "message": "An identifier or keyword cannot immediately follow a numeric literal.",
    "source": "ts",
    "startLineNumber": 18,
    "startColumn": 153,
    "endLineNumber": 18,
    "endColumn": 154
},{
    "resource": "/D:/CurseForge/Minecraft/Instances/ShipTest/kubejs/startup_scripts/script.js",
    "owner": "typescript",
    "code": "1351",
    "severity": 8,
    "message": "An identifier or keyword cannot immediately follow a numeric literal.",
    "source": "ts",
    "startLineNumber": 18,
    "startColumn": 237,
    "endLineNumber": 18,
    "endColumn": 238
}]```
#

i cant find any errors concerning this bracket

woeful owl
#

what the hell is that confused_dog_lex

tulip magnet
#

tats the errors

woeful owl
#

given by what

tulip magnet
#

that vsc

woeful owl
#

ive never seen a list like that before

tulip magnet
#

ok gimme a sec

#
onEvent('item.registry', event => {
    event.create('crystal_clump').maxStackSize(1).rarity('rare').tooltip('Oooo, Shiny!')
    event.create('glow_goop').maxStackSize(3).rarity('rare').tooltip('Very Sticky!')
    event.create('plate').maxStackSize(2).rarity('rare').tooltip('I wonder where this goes?')
    event.create('giant_head').maxStackSize(1).rarity('rare').tooltip("WOAH, It's huge!")
    event.create('udder').maxStackSize(1).rarity('rare').tooltip("Uhm")
    event.create('ghast_eye').maxStackSize(4).rarity('rare')
    event.create('ghasts_sadness').maxStackSize(1).rarity('rare')
    event.create('orbee').maxStackSize(1).rarity('rare')
    event.create('energized_orbee').maxStackSize(1).rarity('rare').glow(true)
        .useDuration((itemstack) => 1)
        .use((level, player, hand) => true)
        .finishUsing((itemstack, level, entity) => {
            let summonGhow = level.createEntity("ghastcow:ghast_cow")
            summonGhow.fullNBT = {
                Attributes: [{Base: 1d, Name: "minecraft:generic.movement_speed"}, {Base:1000d, Name: "minecraft:generic.max_health"}, {Base:10d, Name: "minecraft:generic.armor"}], HandItems: [{id: "minecraft:diamond", Count: 1b}, {}] 
            },
            summonGhow.x = entity.x
            summonGhow.y = entity.y + 10
            summonGhow.z = entity.z
            summonGhow.spawn()
            itemstack.itemStack.shrink(1)
        })

    // Register new items here
    // event.create('example_item',).displayName('Example Item').maxStackSize(1)
})

this is my current code

woeful owl
#

you didnt copy mine

tulip magnet
#

no... ill check it now...

#

now the ghow is being summoned with 0 health etc

#

but the crash is fixed ty

woeful owl
#

try this

onEvent('item.registry', event => {
    event.create('crystal_clump').maxStackSize(1).rarity('rare').tooltip('Oooo, Shiny!')
    event.create('glow_goop').maxStackSize(3).rarity('rare').tooltip('Very Sticky!')
    event.create('plate').maxStackSize(2).rarity('rare').tooltip('I wonder where this goes?')
    event.create('giant_head').maxStackSize(1).rarity('rare').tooltip('WOAH, It\'s huge!')
    event.create('udder').maxStackSize(1).rarity('rare').tooltip('Uhm')
    event.create('ghast_eye').maxStackSize(4).rarity('rare')
    event.create('ghasts_sadness').maxStackSize(1).rarity('rare')
    event.create('orbee').maxStackSize(1).rarity('rare')
    event.create('energized_orbee').maxStackSize(1).rarity('rare').glow(true)
        .useDuration((itemstack) => 1)
        .use((level, player, hand) => true)
        .finishUsing((itemstack, level, entity) => {
            let summonGhow = level.createEntity('ghastcow:ghast_cow')
            summonGhow.fullNBT = { Attributes: [{ Base: 1, Name: 'minecraft:generic.movement_speed' }, { Base: 1000, Name: 'minecraft:generic.max_health' }, { Base: 10, Name: 'minecraft:generic.armor' }], HandItems: [{ id: 'minecraft:diamond', Count: 1 }, {}] },
                summonGhow.x = entity.x,
                summonGhow.y = entity.y + 10,
                summonGhow.z = entity.z,
                summonGhow.spawn(),
                itemstack.itemStack.shrink(1)
        })
})
tulip magnet
#

okey

#

awsome everything is fixed ty for your patience with me enjoy the rest of your day

woeful owl
#

ah nice cute_clap_lex