Skip to content

Commit

Permalink
Shift Right-Click wrench to clear binding - resolves #211
Browse files Browse the repository at this point in the history
  • Loading branch information
Direwolf20-MC committed Oct 19, 2024
1 parent ee212cf commit 58bd519
Showing 1 changed file with 18 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
import net.minecraft.network.chat.Component;
import net.minecraft.sounds.SoundEvents;
import net.minecraft.sounds.SoundSource;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResult;
import net.minecraft.world.InteractionResultHolder;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
Expand All @@ -28,6 +30,22 @@ public FerricoreWrench() {
.stacksTo(1));
}

@Override
public InteractionResultHolder<ItemStack> use(Level level, Player player, InteractionHand hand) {
ItemStack itemstack = player.getItemInHand(hand);
if (level.isClientSide() || !player.isShiftKeyDown())
return new InteractionResultHolder<>(InteractionResult.PASS, itemstack);

GlobalPos boundPos = getBoundTo(itemstack);
if (boundPos == null)
return new InteractionResultHolder<>(InteractionResult.PASS, itemstack);
removeBoundTo(itemstack);
player.displayClientMessage(Component.translatable("justdirethings.bindremoved"), true);
player.playNotifySound(SoundEvents.ENDER_EYE_DEATH, SoundSource.PLAYERS, 1.0F, 1.0F);

return new InteractionResultHolder<>(InteractionResult.PASS, itemstack);
}

@Override
public InteractionResult useOn(UseOnContext context) {
Level level = context.getLevel();
Expand Down

0 comments on commit 58bd519

Please sign in to comment.