#rightclick events
8 messages · Page 1 of 1 (latest)
Once your ticket has been resolved, please close it with </ticket close:1054771505520717835> command!
i'm closing it bc chat gpt got it first try.
Ticket re-opened!
ItemEvents.rightClicked(event => {
// Oggetti da trasformare (sostituisci con quelli che vuoi)
const ITEM1 = 'minecraft:stone'; // Oggetto iniziale
const ITEM2 = 'minecraft:gold_ingot'; // Oggetto trasformato
const heldItem = event.item; // L'oggetto attualmente nella mano del giocatore
if (heldItem.id === ITEM1) {
// Trasforma ITEM1 in ITEM2
event.player.setHeldItem(event.hand, Item.of(ITEM2));
event.player.swing(event.hand); // Anima l'azione
} else if (heldItem.id === ITEM2) {
// Trasforma ITEM2 in ITEM1
event.player.setHeldItem(event.hand, Item.of(ITEM1));
event.player.swing(event.hand); // Anima l'azione
}
});
if anyone needs it
gpt got it first try again here is an updated version
ItemEvents.rightClicked(event => {
// Oggetti da trasformare
const notrick = 'kubejs:saw_cleaver'; // Oggetto iniziale
const trick = 'kubejs:elongated_saw_cleaver'; // Oggetto trasformato
// Verifica se la mano attivata è la mano principale
if (event.hand !== 'MAIN_HAND') return;
const heldItem = event.item; // L'oggetto attualmente nella mano del giocatore
if (heldItem.id === notrick) {
// Trasforma ITEM1 in ITEM2
event.player.setHeldItem(event.hand, Item.of(trick));
} else if (heldItem.id === trick) {
// Trasforma ITEM2 in ITEM1
event.player.setHeldItem(event.hand, Item.of(notrick));
}
});