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

Fix fake players using wrong reach values #1883

Open
wants to merge 2 commits into
base: 1.20.2
Choose a base branch
from

Conversation

TheobaldTheBird
Copy link

The bots still have a 4.5 block range while interacting with blocks, but entity interaction range has been reduced to 3 blocks, fixing #1882

Player attacking is more realistic now. Using /player attack once will swing even while not targeting an entity, and will properly reset attack cooldown

#1881 is also fixed, as players will properly lower their movement speed while using slow items

The bots still have a 4.5 block range while interacting with blocks, but entity interaction range has been reduced to 3 blocks, fixing gnembon#1882

Player attacking is more realistic now. Using /player <player> attack once will swing even while not targeting an entity, and will properly reset attack cooldown

gnembon#1881 is also fixed, as players will properly lower their movement speed while using slow items
if (player.isUsingItem())
{
ItemStack item = player.getUseItem();
((ServerPlayerInterface) player).getActionPack().setSlowed(item.isEdible() || item.is(Items.SHIELD) || item.is(Items.BRUSH) || item.is(Items.BOW) || item.is(Items.CROSSBOW) || item.is(Items.TRIDENT) || item.is(Items.GOAT_HORN) || item.is(Items.SPYGLASS));
Copy link
Collaborator

@altrisi altrisi Apr 28, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't there an equivalent method for wherever vanilla does this, maybe just isUsingItem (tho I may be missing some)? Or is that client only?

Also given nothing else is using slowed, it could be a local.

Haven't checked more of the code yet, sorry.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, looks like player.isUsingItem() is only true while using any of those listed items, most of that was completely unneeded. I'll commit a cleaned up version

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants