mirror of
https://github.com/Samsuik/Sakura.git
synced 2025-12-31 04:36:39 +00:00
Start on updating 1.21.4
This commit is contained in:
130
migrate/server/source/0028-Configure-Entity-Knockback.patch
Normal file
130
migrate/server/source/0028-Configure-Entity-Knockback.patch
Normal file
@@ -0,0 +1,130 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Samsuik <40902469+Samsuik@users.noreply.github.com>
|
||||
Date: Wed, 15 Nov 2023 20:52:56 +0000
|
||||
Subject: [PATCH] Configure Entity Knockback
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
index 01179c4b01aa4898d08b392bd682587e3858b822..f1560f5139b3090057950b41c4374ded4c50b3e2 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
@@ -1572,7 +1572,7 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
||||
}
|
||||
// Paper end - Check distance in entity interactions
|
||||
|
||||
- this.knockback(0.4000000059604645D, d0, d1, entity1, entity1 == null ? io.papermc.paper.event.entity.EntityKnockbackEvent.Cause.DAMAGE : io.papermc.paper.event.entity.EntityKnockbackEvent.Cause.ENTITY_ATTACK); // CraftBukkit // Paper - knockback events
|
||||
+ this.knockback((float) this.level().sakuraConfig().players.knockback.baseKnockback, d0, d1, entity1, entity1 == null ? io.papermc.paper.event.entity.EntityKnockbackEvent.Cause.DAMAGE : io.papermc.paper.event.entity.EntityKnockbackEvent.Cause.ENTITY_ATTACK); // CraftBukkit // Paper - knockback events // Sakura - configure entity knockback
|
||||
if (!flag) {
|
||||
this.indicateDamage(d0, d1);
|
||||
}
|
||||
@@ -1685,7 +1685,7 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
||||
}
|
||||
|
||||
protected void blockedByShield(LivingEntity target) {
|
||||
- target.knockback(0.5D, target.getX() - this.getX(), target.getZ() - this.getZ(), this, io.papermc.paper.event.entity.EntityKnockbackEvent.Cause.SHIELD_BLOCK); // CraftBukkit // Paper - fix attacker & knockback events
|
||||
+ target.knockback((float) this.level().sakuraConfig().players.knockback.shieldHitKnockback, target.getX() - this.getX(), target.getZ() - this.getZ(), this, io.papermc.paper.event.entity.EntityKnockbackEvent.Cause.SHIELD_BLOCK); // CraftBukkit // Paper - fix attacker & knockback events // Sakura - configure entity knockback
|
||||
}
|
||||
|
||||
private boolean checkTotemDeathProtection(DamageSource source) {
|
||||
@@ -2035,7 +2035,7 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
||||
}
|
||||
|
||||
public void knockback(double d0, double d1, double d2, @Nullable Entity attacker, io.papermc.paper.event.entity.EntityKnockbackEvent.Cause cause) { // Paper - knockback events
|
||||
- d0 *= 1.0D - this.getAttributeValue(Attributes.KNOCKBACK_RESISTANCE);
|
||||
+ d0 *= 1.0D - this.getAttributeValue(Attributes.KNOCKBACK_RESISTANCE) * this.level().sakuraConfig().players.knockback.knockbackResistanceModifier; // Sakura - configure entity knockback
|
||||
if (true || d0 > 0.0D) { // CraftBukkit - Call event even when force is 0
|
||||
//this.hasImpulse = true; // CraftBukkit - Move down
|
||||
|
||||
@@ -2046,9 +2046,21 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
||||
}
|
||||
|
||||
Vec3 vec3d1 = (new Vec3(d1, 0.0D, d2)).normalize().scale(d0);
|
||||
+ // Sakura start - configure entity knockback
|
||||
+ double velocityX = vec3d.x / 2.0D - vec3d1.x;
|
||||
+ double velocityY = vec3d.y / 2.0D + this.level().sakuraConfig().players.knockback.knockbackVertical.or(d0);
|
||||
+ double velocityZ = vec3d.z / 2.0D - vec3d1.z;
|
||||
+
|
||||
+ // this.onGround() ? Math.min(0.4D, vec3d.y / 2.0D + d0) : vec3d.y
|
||||
+ if (!this.level().sakuraConfig().players.knockback.verticalKnockbackRequireGround || this.onGround()) {
|
||||
+ velocityY = Math.min(this.level().sakuraConfig().players.knockback.knockbackVerticalLimit, velocityY);
|
||||
+ } else {
|
||||
+ velocityY = vec3d.y;
|
||||
+ }
|
||||
+ // Sakura end - configure entity knockback
|
||||
|
||||
// Paper start - knockback events
|
||||
- Vec3 finalVelocity = new Vec3(vec3d.x / 2.0D - vec3d1.x, this.onGround() ? Math.min(0.4D, vec3d.y / 2.0D + d0) : vec3d.y, vec3d.z / 2.0D - vec3d1.z);
|
||||
+ Vec3 finalVelocity = new Vec3(velocityX, velocityY, velocityZ); // Sakura - configure entity knockback
|
||||
Vec3 diff = finalVelocity.subtract(vec3d);
|
||||
io.papermc.paper.event.entity.EntityKnockbackEvent event = CraftEventFactory.callEntityKnockbackEvent((org.bukkit.craftbukkit.entity.CraftLivingEntity) this.getBukkitEntity(), attacker, attacker, cause, d0, diff);
|
||||
// Paper end - knockback events
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/player/Player.java b/src/main/java/net/minecraft/world/entity/player/Player.java
|
||||
index 99133ad27aac31f68101aff4a4c4965c7ff1fd6b..d11f67157c1bf8c14776c56748de3588273c7d45 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/player/Player.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/player/Player.java
|
||||
@@ -200,6 +200,7 @@ public abstract class Player extends LivingEntity {
|
||||
private int currentImpulseContextResetGraceTime;
|
||||
public boolean affectsSpawning = true; // Paper - Affects Spawning API
|
||||
public net.kyori.adventure.util.TriState flyingFallDamage = net.kyori.adventure.util.TriState.NOT_SET; // Paper - flying fall damage
|
||||
+ private long lastSprintKnockback = -1; // Sakura - configure entity knockback
|
||||
|
||||
// CraftBukkit start
|
||||
public boolean fauxSleeping;
|
||||
@@ -1264,7 +1265,7 @@ public abstract class Player extends LivingEntity {
|
||||
boolean flag = f2 > 0.9F;
|
||||
boolean flag1;
|
||||
|
||||
- if (this.isSprinting() && flag) {
|
||||
+ if (this.isSprinting() && (!this.level().sakuraConfig().players.knockback.sprinting.requireFullAttack || flag)) { // Sakura - configure entity knockback
|
||||
sendSoundEffect(this, this.getX(), this.getY(), this.getZ(), SoundEvents.PLAYER_ATTACK_KNOCKBACK, this.getSoundSource(), 1.0F, 1.0F); // Paper - send while respecting visibility
|
||||
flag1 = true;
|
||||
} else {
|
||||
@@ -1307,7 +1308,21 @@ public abstract class Player extends LivingEntity {
|
||||
float f5 = this.getKnockback(target, damagesource) + (flag1 ? 1.0F : 0.0F);
|
||||
|
||||
if (f5 > 0.0F) {
|
||||
- if (target instanceof LivingEntity) {
|
||||
+ // Sakura start - configure entity knockback; extra sprinting knockback
|
||||
+ long millis = System.currentTimeMillis();
|
||||
+ long sinceLastKnockback = millis - this.lastSprintKnockback;
|
||||
+ if (flag1) { // attackHasExtraKnockback
|
||||
+ double knockbackToApply = 0.0;
|
||||
+ if (sinceLastKnockback >= this.level().sakuraConfig().players.knockback.sprinting.knockbackDelay.value().orElse(0)) {
|
||||
+ knockbackToApply = this.level().sakuraConfig().players.knockback.sprinting.extraKnockback;
|
||||
+ this.lastSprintKnockback = millis;
|
||||
+ }
|
||||
+ f5 = (f5 - 1.0f) + ((float) knockbackToApply * 2.0f);
|
||||
+ }
|
||||
+ if (f5 == 0.0f) {
|
||||
+ // required
|
||||
+ } else if (target instanceof LivingEntity) {
|
||||
+ // Sakura end - configure entity knockback; extra sprinting knockback
|
||||
LivingEntity entityliving1 = (LivingEntity) target;
|
||||
|
||||
entityliving1.knockback((double) (f5 * 0.5F), (double) Mth.sin(this.getYRot() * 0.017453292F), (double) (-Mth.cos(this.getYRot() * 0.017453292F)), this, io.papermc.paper.event.entity.EntityKnockbackEvent.Cause.ENTITY_ATTACK); // Paper - knockback events
|
||||
@@ -1340,7 +1355,7 @@ public abstract class Player extends LivingEntity {
|
||||
continue;
|
||||
}
|
||||
// CraftBukkit end
|
||||
- entityliving2.knockback(0.4000000059604645D, (double) Mth.sin(this.getYRot() * 0.017453292F), (double) (-Mth.cos(this.getYRot() * 0.017453292F)), this, io.papermc.paper.event.entity.EntityKnockbackEvent.Cause.SWEEP_ATTACK); // CraftBukkit // Paper - knockback events
|
||||
+ entityliving2.knockback((float) this.level().sakuraConfig().players.knockback.sweepingEdgeKnockback, (double) Mth.sin(this.getYRot() * 0.017453292F), (double) (-Mth.cos(this.getYRot() * 0.017453292F)), this, io.papermc.paper.event.entity.EntityKnockbackEvent.Cause.SWEEP_ATTACK); // Sakura - configure entity knockback // CraftBukkit // Paper - knockback events
|
||||
// entityliving2.hurt(damagesource, f7); // CraftBukkit - moved up
|
||||
Level world = this.level();
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/projectile/FishingHook.java b/src/main/java/net/minecraft/world/entity/projectile/FishingHook.java
|
||||
index 5e6ceb3c3728c0c08a516566c70a5c0d72d59196..1cc44f6626dfff7724e2ea1b41917ae4715b8d4d 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/projectile/FishingHook.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/projectile/FishingHook.java
|
||||
@@ -304,6 +304,12 @@ public class FishingHook extends Projectile {
|
||||
this.setHookedEntity(entityHitResult.getEntity());
|
||||
}
|
||||
|
||||
+ // Sakura start - configure entity knockback
|
||||
+ if (this.level().sakuraConfig().players.knockback.fishingHooksApplyKnockback) {
|
||||
+ Entity entity = entityHitResult.getEntity();
|
||||
+ entity.hurt(this.damageSources().thrown(this, this.getOwner()), 0.0f);
|
||||
+ }
|
||||
+ // Sakura end - configure entity knockback
|
||||
}
|
||||
|
||||
@Override
|
||||
Reference in New Issue
Block a user