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

Fake Players take no knockback #745

Closed
poombus opened this issue Feb 26, 2021 · 3 comments
Closed

Fake Players take no knockback #745

poombus opened this issue Feb 26, 2021 · 3 comments
Labels
lo priority Likely won't fix

Comments

@poombus
Copy link

poombus commented Feb 26, 2021

Intentional? If so, could you consider adding the option to enable it?

@altrisi
Copy link
Collaborator

altrisi commented Feb 26, 2021

Knockback is client-side IIRC. Therefore the server is expecting the fake players to make their own knock back, that won't because they are server-side.

Therefore, the knockback would need to be reimplemented (unless it's available in the server-side) (possible, just maybe not the most important thing)

@gnembon
Copy link
Owner

gnembon commented Apr 5, 2021

not the most important thing. I was aware of that, but knew that knockback is a client thing, that's why everyone is so laggy in uhcs. Likely noones gonna work towards it. Feel free to close it.

@gnembon gnembon added the lo priority Likely won't fix label Apr 5, 2021
@Fallen-Breath
Copy link
Contributor

Knockback is not a client-side only thing.

The reason why fake player doesnt take knockback from player is that there's a ServerPlayerEntity type check when a player dealt damage and knockback to the target

// in net.minecraft.entity.player.PlayerEntity#attack
if (target instanceof ServerPlayerEntity && target.velocityModified) {
   ((ServerPlayerEntity)target).networkHandler.sendPacket(new EntityVelocityUpdateS2CPacket(target));
   target.velocityModified = false;
   target.setVelocity(vec3d);  // reset the target's velocity
}

Since fake player (EntityPlayerMPFake) is also a ServerPlayerEntity, it will go into the if statement and reset the velocity of the fake player, that's what we don't want to see

It's not hard to be fixed. It can be fixed by a redirect mixin for example:

@Mixin(PlayerEntity.class)
public abstract class PlayerEntityMixin
{
	@Redirect(
			method = "attack",
			at = @At(
					value = "FIELD",
					target = "Lnet/minecraft/entity/Entity;velocityModified:Z",
					ordinal = 0
			)
	)
	private boolean velocityModifiedAndNotCarpetFakePlayer(Entity target)
	{
		return target.velocityModified && !(target instanceof EntityPlayerMPFake);
	}
}

Fallen-Breath added a commit to TISUnion/Carpet-TIS-Addition that referenced this issue Apr 15, 2021
Fallen-Breath added a commit to TISUnion/TISCarpet113 that referenced this issue Apr 15, 2021
Fallen-Breath added a commit to Fallen-Breath/fabric-carpet that referenced this issue Apr 16, 2021
gnembon added a commit that referenced this issue Apr 16, 2021
Fixed #745 (Fake Players take no knockback)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lo priority Likely won't fix
Projects
None yet
Development

No branches or pull requests

4 participants