#Create event from crafting

12 messages · Page 1 of 1 (latest)

grizzled coyote
#

I'm trying to see how I can organize the code, honestly I'm just getting started. I would like to know if it is possible to create an event from crafting a specific item.

After a diamond sword is crafted, all hostile mobs increase their statistics, and from there, when creating another item, the statistics multiply, as a progression. I am using the EntityJS addon to upload the statistics.

It is easier to create it with in-control, however I am modifying many recipes with KubeJS and I would like to see if it is possible to do it here. Thanks

strong geyserBOT
#

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

sullen carbon
#

is your pack focused on singleplayer? that rescaling mechanic doesn't fit multiplayer environment

ocean sandal
#

??code

chrome zenithBOT
# ocean sandal ??code

🗒️**Send the code!**🗒️
You may have an issue with a KubeJS script and you explain it to the best of your ability yet without the actual code in question we have very little to go off of in trying to assist you.

spare holly
#

so you want to have an item crafted event?

#

that exists as a forge event

#

at least in 1.16 (thats the only dev env i have open rn)

ocean sandal
#

i believe the kubejs script is the same as the forge event iirc js ItemEvents.crafted(event => { const {entity,item} = event console.log(item.id) })

#

this in server scripts

grizzled coyote
#

I'm not sure if this is right, but it's what I have and it doesn't work. The wiki lacks a lot of information

grizzled coyote
# ocean sandal i believe the kubejs script is the same as the forge event iirc ```js ItemEvents...

    if (event.id === 'minecraft:diamond_sword') {
   
    const hostileMobsLevel1 = world.getEntities(entity => entity.isAlive() && entity.getType().getCategory() === 'MONSTER');
    
    
    hostileMobsLevel1.forEach(mob => {
     
        mob.setAttackDamage(mob.getAttackDamage() * 1.5);
        mob.setMaxHealth(mob.getMaxHealth() * 1.5);
      });
  
      const playerName = event.player.getName();
      player(playerName).sendMessage('¡Hostile mobs are now stronger!');
    }
}
)```