#how to set item lock when im using and unlock when im not using

1 messages · Page 1 of 1 (latest)

final dune
#

pls help thx

left citrus
#

uh

#

check for item use on event

#

and grab the item stack

#

from there modify the item stack's item lock

final dune
#

when i set item lock it activates the itemstop charge

#

which i dont want it to

left citrus
#

are you using item stop charge as an event?

final dune
#

yes

#

i use it to set lore

wind wraith
#

i still dont see why u even need this

left citrus
#

so basically when you stop interacting with the item it sets a lore?

#

i'm so confused

final dune
#

wait

#

ill tell

#
world.events.beforeItemUse.subscribe(({ source, item }) => {
    item.lockMode = ItemLockMode.item;
});

world.events.itemStopCharge.subscribe(({ source, itemStack }) => {
    itemStack.lockMode = ItemLockMode.slot;
});
#

@left citrus

left citrus
#

let me see

final dune
#

it says 225 error

#

damn

#

im dumb

left citrus
#

lmfao

final dune
#

it says item.lockMode = ItemLockMode.item;

#

doesnt work

#

Native setter cannot be undefined

#

item.lockMode = ItemLockMode.item;

left citrus
#

yes wait let me check docs

#

so you want it to unlock

final dune
#

kk

#

ye

left citrus
#

i gotcchu

#
world.events.beforeItemUse.subscribe(({ source, item }) => {
    item.lockMode = ItemLockMode.slot;
});

world.events.itemStopCharge.subscribe(({ source, itemStack }) => {
    itemStack.lockMode = ItemLockMode.none;
});
#

are they flipped?

final dune
#

wait

#

what was the diff

left citrus
#

so you want it to unlock when you stop holding right

final dune
#

yes

left citrus
#

i just switched itemlockmode

#

to none

#

ans when you use the item it sets it to slot lock

#

i can't test rn but that should be it tbh

final dune
#

kk

#

i tested

#

the item gets locked

#

but doesnt get unlocked

left citrus
#

could be that the event itemstopcharge only works for chargable items like bows and crossbows

#

but i don't know

#

can you try debugging it

final dune
#

kk

left citrus
#

and add console.warn()

#

inside the stopitemcharge

#

event

final dune
#

kk

#

works

#

but doesnt remove the item lock

left citrus
#

hm

#

can you console log the lock mode?

final dune
#

kk

#

nope

#

it works

#

but doesnt unlock

left citrus
#

this should work tho that is really weird

#

@jagged zephyr sorry to bother but m9 do u think you could help us with this?

#

I'm not home rn so i can't really do any debugging

final dune
#

hi

#

@wind wraith

#

you know a fix?

wind wraith
#

yeah

#

just dont use it

final dune
#

if i dont use it

#

people can drop the item and the lore can be set which generates a new item

final dune
#

@jagged zephyr

#

@left citrus

jagged zephyr
#

define 'using'

final dune
#

when u eat the item

#

the item locks

#

and when u stop eating

#

the item unlocks

jagged zephyr
#

does it have a cooldown?

final dune
#

no cooldown

#
world.events.beforeItemUse.subscribe(({ source, item }) => {
    item.lockMode = ItemLockMode.slot;
});

world.events.itemStopCharge.subscribe(({ source, itemStack }) => {
    itemStack.lockMode = ItemLockMode.none;
});

i tried to use this but it didnt unlock the item
jagged zephyr
#

what's the item's components like?

final dune
#
"minecraft:food": {
        "nutrition": 0,
        "saturation_modifier": "supernatural",
        "cooldown_type": "chorusfruit",
        "cooldown_time": 0,
        "can_always_eat": true
      },
"minecraft:hand_equipped": true,
      "minecraft:use_duration": 99999,
jagged zephyr
#

y do u have tha use duration so long

final dune
#

because i dont want the eating sound to be played

#

and i want the item to be lost

jagged zephyr
#

ok, and what's the purpose of locking that item again?

final dune
#

cuz when i stop using the item i setlore

#

if the player uses the item

#

and drops the item by mistake

#

the item falls

#

and another item gets generated

#

i can send that part of the code to u in dms lol

jagged zephyr
#

what's the lore for?

final dune
#

Lore is to set some value inside the item

#

wait

#

imma show sceenshot

jagged zephyr
#

cant u juts setLore on item Use?

final dune
final dune
jagged zephyr
#

ah

final dune
#

ye

#

can i send the entire code to u in dms