#Custom Healing Wand

20 messages · Page 1 of 1 (latest)

gaunt comet
#

It won't work, can someone help? I changed it a little, it used to be AI generated.
Startup Scripts:

StartupEvents.registry('item', e => {
    // --> something else, not relavent e.create('wraith_shard').texture('kjs:item/shard').maxStackSize(64)
    e.create('woh1')
      .displayName('Wand of Healing I')
      .rarity('rare')
      .texture('kjs:item/wand-of-healing1')
      .maxStackSize(1);
    e.create('woh2')
      .displayName('Wand of Healing II')
      .rarity('rare')
      .texture('kjs:item/wand-of-healing2')
      .maxStackSize(1);
    e.create('woh3')
      .displayName('Wand of Healing III')
      .rarity('rare')
      .texture('kjs:item/wand-of-healing3')
      .maxStackSize(1);
  });

Server Scripts (Wand Functionality, Main Issue):
Can be found here because of character limit: [Functionality](#1279828927749296200 message)

I want the cooldown to be the one like you would see on a shield when attacked with an axe or an enderpearl after use

Also i need help with something else so if you want, here it is: Post

jovial zealotBOT
#

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

cunning birchBOT
#

NEVER use any AI to generate KubeJS code. They currently know very little about it, and what they do know is often outdated or false. You can instead look at the KubeJS wiki or ask for help in #1047320998199955458.

gaunt comet
#

bump

gaunt comet
#

@scenic lion I don't mean to ping you, but I've been waiting for someone to give a response to this for 4 hours now and i only got 1 and it's useless. Could you help me or do you not feel like it? Its fine if you don't.

lilac violet
#

wdym useless

#
  1. do not the ai
#

second

#

??patience

cunning birchBOT
# lilac violet ??patience

Please be patient, we're helping as fast as we can
We volunteer our time and knowledge to help people as we can.
Not everyone here will have your answer the moment you want it.
Time zones, work/life/schedules etc. also change when people are available to help.

TL;DR: Please have patience. IF and WHEN someone knows, they will assist you.

lilac violet
#

if u want I can use the 2nd macro while at it trol

#

??volunteering

cunning birchBOT
# lilac violet ??volunteering

Support

Support is ran entirely by volunteers - people that use their free time to help you. They don't have to do it, they do it because they like helping others.

The wiki

The wiki - similarly to support - is mostly written by volunteers. Both the new wiki and the bookstack one are not complete, however the new one is there to fix that.
If you find a page that's missing, why not make a PR to the new wiki's repo adding it?

gaunt comet
#
const wandProperties = {
    'kubejs:woh1': { regenerationTime: 100, amplifier: 0, cooldownTime: 140 },
    'kubejs:woh2': { regenerationTime: 200, amplifier: 1, cooldownTime: 240 },
    'kubejs:woh3': { regenerationTime: 300, amplifier: 2, cooldownTime: 340 }
};

ItemEvents.rightClicked(event => {
    const itemId = event.item.id;
    
    if (!wandProperties.hasOwnProperty(itemId)){
        return;
    }
    
    const properties = wandProperties[itemId];
    const player = event.player;
    
    if (player.getCooldown(itemId) > 0) {
        player.tell(`Cooldown is active for ${itemId}`);
        event.cancel();
        return;
    }

    player.addEffect('minecraft:regeneration', properties.regenerationTime, properties.amplifier);
    player.setCooldown(itemId, properties.cooldownTime);
    player.tell(`Used ${itemId}. Cooldown set for ${properties.cooldownTime / 20} seconds.`);
    event.server.schedule(1, () => player.swing(event.hand));
});
#

this was generated by ChatGPT with some editing, and it still doesnt work, although I found out none of the items can find their properties based on the object above

#

so for example woh3 will fail to do something because properties doesnt evaluate to " 'kubejs:woh3': { regenerationTime: 300, amplifier: 2, cooldownTime: 340 } "

gaunt comet
#

bump

oblique ridge
#

here. Edit: sended only one because message limit, but you just need to copy for the other two, add the constant for cooldown time and stuff like that

StartupEvents.registry('item', e => {
    // --> something else, not relavent e.create('wraith_shard').texture('kjs:item/shard').maxStackSize(64)
    e.create('wand_reg1')
        .displayName('Wand of Healing I')
        .rarity('rare')
        .texture('kjs:item/wand-of-healing1')
        .unstackable()
        .use((level, player, hand) => true)
        .useDuration(itemStack => 40)
        .useAnimation('spear')
        .finishUsing(
            /**
             * 
             * @param {Internal.ItemStack} itemstack 
             * @param {Internal.ServerLevel} level 
             * @param {Internal.LivingEntity} entity 
             */
            (itemstack, level, entity) => {
                if(!level.isClientSide()){
                    entity.potionEffects.add('minecraft:regeneration', 300, 0)
                    entity.swing()
                }else{
                    entity.tell(`Used ${itemstack.displayName}. Cooldown set for ${60 / 20} seconds.`);
                }

                entity.addItemCooldown(itemstack, 60)
                return itemstack
        })
gaunt comet
gaunt comet