Carpet

Carpet

2M Downloads

Carpet fake players can use item in their hand when looking at an armor stand

Youmiel opened this issue ยท 1 comments

commented

What Happened

Carpet fake players can use items in their hands when looking at an armor stand.

2024-07-28_22-58-57_out.mp4

Expected Behavior

Carpet fake players should not use items in their hands when looking at an armor stand, which is the behavior of vanilla clients.

Possible Causes

case ENTITY:
{
player.resetLastActionTime();
EntityHitResult entityHit = (EntityHitResult) hit;
Entity entity = entityHit.getEntity();
boolean handWasEmpty = player.getItemInHand(hand).isEmpty();
boolean itemFrameEmpty = (entity instanceof ItemFrame) && ((ItemFrame) entity).getItem().isEmpty();
Vec3 relativeHitPos = entityHit.getLocation().subtract(entity.getX(), entity.getY(), entity.getZ());
if (entity.interactAt(player, relativeHitPos, hand).consumesAction())
{
ap.itemUseCooldown = 3;
return true;
}
// fix for SS itemframe always returns CONSUME even if no action is performed
if (player.interactOn(entity, hand).consumesAction() && !(handWasEmpty && itemFrameEmpty))
{
ap.itemUseCooldown = 3;
return true;
}
break;
}
}
ItemStack handItem = player.getItemInHand(hand);
if (player.gameMode.useItem(player, player.level(), handItem, hand).consumesAction())
{
ap.itemUseCooldown = 3;
return true;
}
}
return false;
}

commented

The reason is the interactAt() of armor stand entity would always return CONSUME in client even if not action is performed, while in server it checks.

Another similar issue comes at interact with a boat or minecart when riding any vehicles, etc. So in the server side the check will fail as it unable to ride, while in client side it always return a SUCCESS.