PaperMC / Paper

The most widely used, high performance Minecraft server that aims to fix gameplay and mechanics inconsistencies
https://papermc.io/
Other
9.74k stars 2.27k forks source link

.damage with damagesource has no way to not knockback #10851

Open ghost opened 4 months ago

ghost commented 4 months ago

Expected behavior

entity.damage() applies no knockback, .damage() with damagesource always applies knockback, even if you leave out location or set locaiton to entities location, there should be a way to have no knockback from it

Observed/Actual behavior

N/A

Steps/models to reproduce

livingEntity.damage(0.1);

.damage() with no damage source params, vs .damage() with damage source

livingEntity.damage(0.1, DamageSource.builder(DamageType.MOB_PROJECTILE) .withCausingEntity(shooter) .withDirectEntity(projectile) .build());

Plugin and Datapack List

N/A

Paper version

Paper 1.20.4

Other

No response

Doc94 commented 4 months ago

The knockback is based in the rules of NMS. In the case of the damage method with not DamageSource is handled by the generic DamageSource that not include knockback, the method with the DamageSource is "parsed" to the NMS DamageSource if you pass a entity making de damage (withDirect..) then this make a knockback, in NMS the logic for knockback (ignoring a thing about the last damage/invulnerability) is if the damage is not included in the tag for no_knockback and exists a entity making the damage. image that is what i check unless i missing something.

ghost commented 4 months ago

The knockback is based in the rules of NMS. In the case of the damage method with not DamageSource is handled by the generic DamageSource that not include knockback, the method with the DamageSource is "parsed" to the NMS DamageSource if you pass a entity making de damage (withDirect..) then this make a knockback, in NMS the logic for knockback (ignoring a thing about the last damage/invulnerability) is if the damage is not included in the tag for no_knockback and exists a entity making the damage. image that is what i check unless i missing something.

Im pretty sure you can do .damage(double, entity) to give the damage a cause but without giving knockback.

Doc94 commented 4 months ago

The knockback is based in the rules of NMS. In the case of the damage method with not DamageSource is handled by the generic DamageSource that not include knockback, the method with the DamageSource is "parsed" to the NMS DamageSource if you pass a entity making de damage (withDirect..) then this make a knockback, in NMS the logic for knockback (ignoring a thing about the last damage/invulnerability) is if the damage is not included in the tag for no_knockback and exists a entity making the damage. image that is what i check unless i missing something.

Im pretty sure you can do .damage(double, entity) to give the damage a cause but without giving knockback.

can you provide a example? because that method works in the same way only change the DamageSource from generic if the entity passed is HumanEntity (PLAYER_ATTACK) or a simple LivingEntity (MOB_ATTACK)