#enchantment registry

73 messages · Page 1 of 1 (latest)

unique fulcrum
#

how do I make a custom enchantment that also has particles when the item is being held and such

last magnetBOT
#

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

marsh elk
#

Can you give a vanilla example of a particle effect from an enchantment?

#

because I'm going to lean towards.... you don't

west swan
#

that needs player tick to check if the item in hand has this enchantment

unique fulcrum
unique fulcrum
marsh elk
west swan
#
PlayerEvents.tick(e=>{
    if(e.player.mainHandItem.hasEnchantment('idk', 1) || e.player.offHandItem.hasEnchantment('idk', 1)){
        //code
    }
})
#

or

PlayerEvents.tick(e=>{
    e.player.handSlots.some(item => {
        if(!item.hasEnchantment('idk', 1)) return;
        //code
    })
})
west swan
#

yes

unique fulcrum
#

and now, the particle

west swan
#

what kind of particle

#

spreading ring?

#

static circle?

#

gathering ring?

unique fulcrum
#

it's not showing up

#

Ohh there we go

west swan
#

.weapon()

#

for example:

    e.create('asd')
        .maxLevel(1)
        .weapon()
        .veryRare()
unique fulcrum
#

Ohh okay

#

lemme reload mc

#

what level is diamond sword

#

this should work

unique fulcrum
unique fulcrum
west swan
#

then don't add the "basic"

#

never seen anybody do that

unique fulcrum
#

going to try this now

west swan
#

oh wait, it's the player tick

unique fulcrum
#

yeah...

west swan
#

use forEach then

#
let executed = false;
e.player.handSlots.forEach(item => {
    if(executed || !item.hasEnchantment('idk', 1)) return;
    executed = true;
    //code
})
west swan
#

i'm making it over complicated

unique fulcrum
#

I'll just use that

#

so it does get executed, but no particles

upper karma
#

Oh definitely want to optimize that down the line by flagging players who contain the item rather than iterating through slots every tick.

upper karma
#

I think

#

Because you are running as server but I could be wrong

west swan
#

yes

upper karma
#

Try running the command in a command block first

west swan
#

~ should be ${e.player.x}

unique fulcrum
#

So I have it at

event.server.runCommandSilent(`execute as ${event.player.name} at ${event.player.name} run particle minecraft:soul ${event.player.x} ${event.player.y + 0.5} ${event.player.z} 0.5 0.5 0.5 0.01 3`)
west swan
#

add this check to first line of player tick would be faster, i'm just being lazy:

if(e.player.age % 10) return;
unique fulcrum
#
PlayerEvents.tick(event => {
    event.player.handSlots.forEach(item => {
        if(event.player.age % 10 || !item.hasEnchantment('kubejs:spectral_touch', 1)) return;
        event.server.runCommandSilent(`execute as ${event.player.name} at ${event.player.name} run particle minecraft:soul ${event.player.x} ${event.player.y + 0.5} ${event.player.z} 0.5 0.5 0.5 0.01 3`)
    })
})

No particles (but it does get called)

west swan
#
const {x, eyeY:y, z} = e.player
event.server.runCommandSilent(`particle soul ${x} ${y} ${z} 0.5 0.5 0.5 0.01 3`)
#

don't run that check in iteration

#
PlayerEvents.tick(event => {
    if(event.player.age % 10) return;
    const {x, eyeY:y, z} = e.player

    if(!e.player.mainHandItem.hasEnchantment('kubejs:spectral_touch', 1) && !e.player.offHandItem.hasEnchantment('kubejs:spectral_touch', 1)) return;
    event.server.runCommandSilent(`particle soul ${x} ${y} ${z} 0.5 0.5 0.5 0.01 3`)
})
unique fulcrum
west swan
#

runCommandSilent → runCommand , check the log

unique fulcrum
clear gullBOT
#

Paste version of server.log from @unique fulcrum

unique fulcrum
#

OHHH

#

I get particles

#

yet it told me it was okay

#

Now how can it be like a ring around the player

west swan
#
function particleRing(mode, count, delay, dist, x, y, z, particleId, speed) {
    const modeMap = {
        'static': '',
        'spread': '10000000000000',
        'gather': '-10000000000000'
    };
    for(let i = 0, counter = 0; i < count; i++) {
        Utils.server.scheduleInTicks(delay*i, () => {
            counter++;
            Utils.server.runCommandSilent(`execute rotated ${counter * 360/count} 0 positioned ${x} ${y} ${z} run particle ${particleId} ^ ^ ^${dist} ^ ^ ^${modeMap[mode]} ${(speed*0.00000000000001).toFixed(18)} 0 force`)
        });
    };
};
unique fulcrum
#

You just have those three ready?

#

what do I put for mode

west swan
#

example use:

particleRing('spread', 20, 0, 0, px, py+0.8, pz, 'cloud', 4);
unique fulcrum
#

There is nothing

#

Ohh wait

#

nope

#

wa

#

it

#

not a particle

upper karma
#

It’s a bit late to ask but do you have particles enabled in your options?