#rightclick events

8 messages · Page 1 of 1 (latest)

toxic harbor
#

can i get an item to transform in another item when i press right click? if yes how would i do it

terse sirenBOT
#

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

toxic harbor
#

i'm closing it bc chat gpt got it first try.

toxic harbor
#

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

toxic harbor
#

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));
}

});