Jump to content

Turesso

Members
  • Posts

    1
  • Joined

  • Last visited

Turesso's Achievements

Tree Puncher

Tree Puncher (2/8)

0

Reputation

  1. I'm working on my first Minecraft mod, and I've created an item that requires a keybind to activate. However, currently, I need to press my assigned keybind and then hold down the default Minecraft keybind (right mouse button) for the item to function. How can I make it so that the item only requires my custom keybind to work? public InteractionResultHolder<ItemStack> use(Level pLevel, Player pPlayer, InteractionHand pHand) { ItemStack itemstack = pPlayer.getItemInHand(pHand); ItemStack offhandStack = pPlayer.getItemInHand(InteractionHand.OFF_HAND); if (!offhandStack.isEmpty()) { return InteractionResultHolder.fail(itemstack); } if (isCharged(itemstack)) { // Verifica se está usando a mão correta if (pHand == InteractionHand.MAIN_HAND) { performShooting(pLevel, pPlayer, pHand, itemstack, getShootingPower(itemstack), 0F); setCharged(itemstack, false); return InteractionResultHolder.consume(itemstack); } } else if (hasAmmo(pPlayer)) { if(KeyBindings.INSTANCE.examplekey.isDown()){ if (!isCharged(itemstack)) { if (pHand == InteractionHand.MAIN_HAND) { this.startSoundPlayed = false; pPlayer.startUsingItem(pHand); } } } return InteractionResultHolder.consume(itemstack); } else { pLevel.playSound((Player) null, pPlayer.getX(), pPlayer.getY(), pPlayer.getZ(), ModSounds.NOAMMO.get(), SoundSource.PLAYERS, 1.0F, 1.0F); return InteractionResultHolder.fail(itemstack); } return InteractionResultHolder.fail(itemstack); }
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.