Skip to content

Commit e12128a

Browse files
committed
Respect attack speed
1 parent 525ac24 commit e12128a

File tree

1 file changed

+5
-14
lines changed
  • papyrus-server/minecraft-patches/sources/net/minecraft/world/entity/player

1 file changed

+5
-14
lines changed

papyrus-server/minecraft-patches/sources/net/minecraft/world/entity/player/Player.java.patch

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
if (damaged) {
2828
this.removeEntitiesOnShoulder();
2929
}
30-
@@ -1174,37 +_,39 @@
30+
@@ -1174,15 +_,15 @@
3131
// Paper start - PlayerAttackEntityEvent
3232
boolean willAttack = target.isAttackable() && !target.skipAttackInteraction(this); // Vanilla logic
3333
io.papermc.paper.event.player.PrePlayerAttackEntityEvent playerAttackEntityEvent = new io.papermc.paper.event.player.PrePlayerAttackEntityEvent(
@@ -47,9 +47,8 @@
4747
+ float f = this.isAutoSpinAttack() ? this.autoSpinAttackDmg : (float) this.getAttributeValue(attackDamageType.advantage); // Papyrus - Add damage type
4848
ItemStack weaponItem = this.getWeaponItem();
4949
DamageSource damageSource = Optional.ofNullable(weaponItem.getItem().getDamageSource(this)).orElse(this.damageSources().playerAttack(this));
50-
- float f1 = this.getEnchantedDamage(target, f, damageSource) - f;
51-
+ float f1 = this.getEnchantedDamage(target, f, damageSource) - f; // Papyrus - Remove attack cooldown
52-
float attackStrengthScale = this.getAttackStrengthScale(0.5F);
50+
float f1 = this.getEnchantedDamage(target, f, damageSource) - f;
51+
@@ -1190,16 +_,18 @@
5352
f *= 0.2F + attackStrengthScale * attackStrengthScale * 0.8F;
5453
f1 *= attackStrengthScale;
5554
// this.resetAttackStrengthTicker(); // CraftBukkit - Moved to EntityLiving to reset the cooldown after the damage is dealt
@@ -77,12 +76,6 @@
7776
}
7877
{
7978
// CraftBukkit end
80-
if (f > 0.0F || f1 > 0.0F) {
81-
- boolean flag = attackStrengthScale > 0.9F;
82-
+ boolean flag = true; //attackStrengthScale > 0.9F; - Papyrus - Remove attack cooldown
83-
boolean flag1;
84-
if (this.isSprinting() && flag) {
85-
this.sendSoundEffect(this, this.getX(), this.getY(), this.getZ(), SoundEvents.PLAYER_ATTACK_KNOCKBACK, this.getSoundSource(), 1.0F, 1.0F); // Paper - send while respecting visibility
8679
@@ -1215,14 +_,14 @@
8780

8881
f += weaponItem.getItem().getAttackDamageBonus(target, f, damageSource);
@@ -106,7 +99,7 @@
10699
flag2 = flag2 && !this.level().paperConfig().entities.behavior.disablePlayerCrits; // Paper - Toggleable player crits
107100
if (flag2) {
108101
damageSource = damageSource.critical(); // Paper - critical damage API
109-
@@ -1245,147 +_,165 @@
102+
@@ -1245,146 +_,165 @@
110103
}
111104

112105
Vec3 deltaMovement = target.getDeltaMovement();
@@ -164,12 +157,11 @@
164157
- && !this.isAlliedTo(livingEntity2)
165158
- && !(livingEntity2 instanceof ArmorStand armorStand && armorStand.isMarker())
166159
- && this.distanceToSqr(livingEntity2) < 9.0) {
167-
- float f6 = this.getEnchantedDamage(livingEntity2, f5, damageSource) * attackStrengthScale;
168160
+ && livingEntity2 != target
169161
+ && !this.isAlliedTo(livingEntity2)
170162
+ && (!(livingEntity2 instanceof ArmorStand) || !((ArmorStand) livingEntity2).isMarker())
171163
+ && this.distanceToSqr(livingEntity2) < 9.0) {
172-
+ float f6 = this.getEnchantedDamage(livingEntity2, f5, damageSource);// * attackStrengthScale; Papyrus - Remove attack cooldown
164+
float f6 = this.getEnchantedDamage(livingEntity2, f5, damageSource) * attackStrengthScale;
173165
// Paper start - Only apply knockback if the event is not cancelled
174166
livingEntity2.lastDamageCancelled = false;
175167
- if (this.level() instanceof ServerLevel serverLevel && livingEntity2.hurtServer(serverLevel, damageSource.knownCause(org.bukkit.event.entity.EntityDamageEvent.DamageCause.ENTITY_SWEEP_ATTACK), f6) && !livingEntity2.lastDamageCancelled) {
@@ -322,7 +314,6 @@
322314
- this.causeFoodExhaustion(this.level().spigotConfig.combatExhaustion, org.bukkit.event.entity.EntityExhaustionEvent.ExhaustionReason.ATTACK); // CraftBukkit - EntityExhaustionEvent // Spigot - Change to use configurable value
323315
- } else {
324316
- sendSoundEffect(this, this.getX(), this.getY(), this.getZ(), SoundEvents.PLAYER_ATTACK_NODAMAGE, this.getSoundSource(), 1.0F, 1.0F); // Paper - send while respecting visibility
325-
- this.containerMenu.sendAllDataToRemote(); // CraftBukkit - resync on cancelled event
326317
+ this.sendSoundEffect(
327318
+ this, this.getX(), this.getY(), this.getZ(), SoundEvents.PLAYER_ATTACK_WEAK, this.getSoundSource(), 1.0F, 1.0F // Paper - send while respecting visibility
328319
+ );

0 commit comments

Comments
 (0)