Jump to content

Recommended Posts

Posted (edited)

I'm trying to detect a right click on a sword.

 

Did ActionResult change to InteractionResult from 1.16 to 1.17?

I wrote below, but I get an error with hand in getHandSlot (hand)

 

 

public boolean hurtEnemy(ItemStack stack, LivingEntity target, LivingEntity attacker) {

attacker.addEffect(new MobEffectInstance(MobEffects.REGENERATION, 1, 6)); 

target.setDeltaMovement(target.getDeltaMovement().add(0.0D, (double)0.2F, 1.0D));

stack.hurtAndBreak(1, attacker, (entity) -> {

entity.broadcastBreakEvent(EquipmentSlot.MAINHAND); });

return true;

}

public InteractionResult use (BlockState state, Level level, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit)

{

ItemStack itemStack = player.getHandSlots(hand);  this

return InteractionResult.CONSUME;

}

 

I'm struggling to figure out how to solve this problem.

Knowledgeable people, please.

Edited by ocome

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

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