#damaging player when they unequip curios

56 messages · Page 1 of 1 (latest)

crimson wharf
#

how do you damage the player when they un equip something i cant find an event on the wiki for something beng unequipped this is to fix a health bug ive encountered with one of my curios items where the extra health stays even though the item has been removed

bleak ridgeBOT
#

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

crimson wharf
#

.

crimson wharf
#

.

crimson wharf
#

its okay ill be on in like 20ish about to start coming home

fallow minnow
#
ForgeEvents.onEvent('com.top.theillusivec4.curios.api.event.CurioUnequipEvent', (event) => {
  // code here
})

Placed in startup_scripts, this is the event that triggers when a curio is unequipped

#

as for referencing the player unequipping it or retrieving the item's ID? not 100% sure tbh, I'd just test at that point

#
ForgeEvents.onEvent('top.theillusivec4.curios.api.event.CurioUnequipEvent', (event) => {
  console.log(event.getStack())
  console.log(event.item)
  console.log(event.player)
  
  /* if ((event.getStack() != 'curio_item_id')) return
  event.player.<methodNameForDamagingPlayer>() */
})
#

I'd play around with this

crimson wharf
crimson wharf
#

okay 1 sec its loading

#

gonna try reloading it idk why but its taking ages sorry qq

fallow minnow
#

do it in a minimal instance

#

just curios and the mod that adds the curio you want to affect the player

crimson wharf
#

didnt change anything qq

fallow minnow
#

what's your code? your startup log?

crimson wharf
#

StartupEvents.registry('item', event => {
event.create('health')
.maxStackSize(1)
.attachCapability(CuriosCapabilityBuilder.CURIOS.itemStack()
.canEquip(((item, context) => true))
.canUnequip(((item, context) => true))
.modifyAttribute("minecraft:generic.max_health", "max_health", 10, "addition")
)
.tag("curios:body")
}),

ForgeEvents.onEvent('top.theillusivec4.curios.api.event.CurioUnequipEvent', (event) => {
console.log(event.getStack())
console.log(event.health)
console.log(event.player)

/* if ((event.getStack() != 'curio_item_id')) return
event.player.<methodNameForDamagingPlayer>() */

}),

#

trying to get it to work small instance rn and it keeps giving me errors

#

this is all i have in the script

vestal echoBOT
#

Please send your KubeJS startup log. It can be found at /minecraft/logs/kubejs/startup.log.
If you are on 1.18 or 1.16 it will be called startup.txt.
Please send the file directly, without links or snippets.

crimson wharf
vestal echoBOT
#

Paste version of latest.log from @crimson wharf

crimson wharf
#

im tring to find what im missing from the modpack

#

idk why but the generic attributes arnt working

fallow minnow
#
1) curios.js.js#10: Error in 'StartupEvents.registry': TypeError: Cannot find function attachCapability in object BasicItemJS$Builder[kubejs:health].```
#

do you have PowerfulJS installed?

#

unless this is in reference to the um

crimson wharf
#

i dont

fallow minnow
#

unless powerfulJS is needed for the function

#

this was from a quick search history

#

for some reason it cant find the function

crimson wharf
#

it works on the main one but not the testing one

fallow minnow
#

oh?

#

I wonder if you're missing some particular mod

#

in the test instance

crimson wharf
#

yea it just modifies the max health to be +10

crimson wharf
fallow minnow
#

so you tested the script in your main instance correct?

#

hmm

crimson wharf
#

yea it just takes a few minuets to load

fallow minnow
#

but I have no experience with that

crimson wharf
#

idk

#

idk if i've used the wrong attribute for it

#

just gonna load the main thing again and try having a look through it

fallow minnow
#

Hopefully somebody knows how to go about this

crimson wharf
#

yea just looking through the max health thing now