Skip to content

Commit

Permalink
Make left clicking work on polymorph wand
Browse files Browse the repository at this point in the history
  • Loading branch information
Direwolf20-MC committed Dec 8, 2024
1 parent 2eee62c commit 630f709
Showing 1 changed file with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResult;
import net.minecraft.world.InteractionResultHolder;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
Expand All @@ -21,6 +22,7 @@
import net.neoforged.neoforge.fluids.capability.IFluidHandlerItem;

import java.util.List;
import java.util.Set;

public class PolymorphicWand extends BaseToggleableTool implements LeftClickableTool, FluidContainingItem {
public PolymorphicWand() {
Expand Down Expand Up @@ -49,6 +51,18 @@ public InteractionResult useOn(UseOnContext pContext) {
return super.useOn(pContext);
}

@Override
public boolean onLeftClickEntity(ItemStack stack, Player player, Entity entity) {
Level level = player.level();
if (level.isClientSide) return true;
ItemStack itemStack = player.getMainHandItem();
Set<Ability> abilities = LeftClickableTool.getLeftClickList(itemStack);
if (itemStack.getItem() instanceof ToggleableTool toggleableTool && !abilities.isEmpty()) {
toggleableTool.useAbility(player.level(), player, InteractionHand.MAIN_HAND, false);
}
return true;
}

@Override
public InteractionResultHolder<ItemStack> use(Level level, Player player, InteractionHand hand) {
ItemStack itemStack = player.getItemInHand(hand);
Expand Down

0 comments on commit 630f709

Please sign in to comment.