Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixes left click interaction #2931

Merged
merged 4 commits into from
Mar 5, 2025
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/main/java/com/gregtechceu/gtceu/api/item/ComponentItem.java
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,18 @@ public InteractionResult onItemUseFirst(ItemStack itemStack, UseOnContext contex
return InteractionResult.PASS;
}

@Override
public boolean onEntitySwing(ItemStack stack, LivingEntity entity) {
for (IItemComponent component : components) {
if (component instanceof IInteractionItem interactionItem) {
// this will cancel the left click animation
return interactionItem.onEntitySwing(stack, entity);
}
}
// normal behavior
return super.onEntitySwing(stack, entity);
}

@Override
public InteractionResult interactLivingEntity(ItemStack stack, Player player, LivingEntity interactionTarget,
InteractionHand usedHand) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,8 @@ default InteractionResult interactLivingEntity(ItemStack stack, Player player, L
default boolean sneakBypassUse(ItemStack stack, LevelReader level, BlockPos pos, Player player) {
return false;
}

default boolean onEntitySwing(ItemStack stack, LivingEntity entity) {
return false;
}
}