From 9b3bb0cf51a89e4fc9cb90b30e1c6663b71a2db4 Mon Sep 17 00:00:00 2001 From: Spottedleaf Date: Fri, 26 Jun 2020 14:33:49 -0700 Subject: [PATCH] Pass predicate from default get hard colliding entities method --- Spigot-Server-Patches/Anti-Xray.patch | 15 +-- ...plement-EntityKnockbackByEntityEvent.patch | 40 ++++---- ...imise-entity-hard-collision-checking.patch | 2 +- Spigot-Server-Patches/fixup-Anti-Xray.patch | 54 ----------- ...plement-EntityKnockbackByEntityEvent.patch | 93 ------------------- 5 files changed, 26 insertions(+), 178 deletions(-) delete mode 100644 Spigot-Server-Patches/fixup-Anti-Xray.patch delete mode 100644 Spigot-Server-Patches/fixup-Implement-EntityKnockbackByEntityEvent.patch diff --git a/Spigot-Server-Patches/Anti-Xray.patch b/Spigot-Server-Patches/Anti-Xray.patch index 29e5b2e0e2..2ce6dcd9e1 100644 --- a/Spigot-Server-Patches/Anti-Xray.patch +++ b/Spigot-Server-Patches/Anti-Xray.patch @@ -895,13 +895,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + bitInLongIndex += bitsPerObject; + + if (bitInLongIndex > 63) { -+ bitInLongIndex -= 64; ++ bitInLongIndex = 0; + longInDataBitsIndex += 8; + init(); -+ -+ if (bitInLongIndex > 0) { -+ value |= current << bitsPerObject - bitInLongIndex & mask; -+ } + } + + return value; @@ -975,14 +971,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + + if (bitInLongIndex > 63) { + finish(); -+ bitInLongIndex -= 64; ++ bitInLongIndex = 0; + longInDataBitsIndex += 8; + init(); -+ -+ if (bitInLongIndex > 0) { -+ current = current & ~(mask >>> bitsPerObject - bitInLongIndex) | (value & mask) >>> bitsPerObject - bitInLongIndex; -+ dirty = true; -+ } + } + } + @@ -991,7 +982,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + + if (bitInLongIndex > 63) { + finish(); -+ bitInLongIndex -= 64; ++ bitInLongIndex = 0; + longInDataBitsIndex += 8; + init(); + } diff --git a/Spigot-Server-Patches/Implement-EntityKnockbackByEntityEvent.patch b/Spigot-Server-Patches/Implement-EntityKnockbackByEntityEvent.patch index 957fe3c9b1..8b7ed21d67 100644 --- a/Spigot-Server-Patches/Implement-EntityKnockbackByEntityEvent.patch +++ b/Spigot-Server-Patches/Implement-EntityKnockbackByEntityEvent.patch @@ -13,9 +13,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 if (flag5) { if (i > 0) { if (entity instanceof EntityLiving) { -+ ((EntityLiving) entity).knockingBackEntity = this; // Paper - ((EntityLiving) entity).a((float) i * 0.5F, (double) MathHelper.sin(this.yaw * 0.017453292F), (double) (-MathHelper.cos(this.yaw * 0.017453292F))); -+ ((EntityLiving) entity).knockingBackEntity = null; // Paper +- ((EntityLiving) entity).a((float) i * 0.5F, (double) MathHelper.sin(this.yaw * 0.017453292F), (double) (-MathHelper.cos(this.yaw * 0.017453292F))); ++ ((EntityLiving) entity).doKnockback((float) i * 0.5F, (double) MathHelper.sin(this.yaw * 0.017453292F), (double) (-MathHelper.cos(this.yaw * 0.017453292F)), this); // Paper } else { entity.h((double) (-MathHelper.sin(this.yaw * 0.017453292F) * (float) i * 0.5F), 0.1D, (double) (MathHelper.cos(this.yaw * 0.017453292F) * (float) i * 0.5F)); } @@ -23,9 +22,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 if (entityliving != this && entityliving != entity && !this.r(entityliving) && (!(entityliving instanceof EntityArmorStand) || !((EntityArmorStand) entityliving).isMarker()) && this.h((Entity) entityliving) < 9.0D) { // CraftBukkit start - Only apply knockback if the damage hits if (entityliving.damageEntity(DamageSource.playerAttack(this).sweep(), f4)) { -+ ((EntityLiving) entity).knockingBackEntity = this; // Paper - entityliving.a(0.4F, (double) MathHelper.sin(this.yaw * 0.017453292F), (double) (-MathHelper.cos(this.yaw * 0.017453292F))); -+ ((EntityLiving) entity).knockingBackEntity = null; // Paper +- entityliving.a(0.4F, (double) MathHelper.sin(this.yaw * 0.017453292F), (double) (-MathHelper.cos(this.yaw * 0.017453292F))); ++ entityliving.doKnockback(0.4F, (double) MathHelper.sin(this.yaw * 0.017453292F), (double) (-MathHelper.cos(this.yaw * 0.017453292F)), this); } // CraftBukkit end } @@ -37,9 +35,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 if (flag) { if (f1 > 0.0F && entity instanceof EntityLiving) { -+ ((EntityLiving) entity).knockingBackEntity = this; // Paper - ((EntityLiving) entity).a(f1 * 0.5F, (double) MathHelper.sin(this.yaw * 0.017453292F), (double) (-MathHelper.cos(this.yaw * 0.017453292F))); -+ ((EntityLiving) entity).knockingBackEntity = null; // Paper +- ((EntityLiving) entity).a(f1 * 0.5F, (double) MathHelper.sin(this.yaw * 0.017453292F), (double) (-MathHelper.cos(this.yaw * 0.017453292F))); ++ ((EntityLiving) entity).doKnockback(f1 * 0.5F, (double) MathHelper.sin(this.yaw * 0.017453292F), (double) (-MathHelper.cos(this.yaw * 0.017453292F)), this); this.setMot(this.getMot().d(0.6D, 1.0D, 0.6D)); } @@ -51,9 +48,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 } this.aw = (float) (MathHelper.d(d1, d0) * 57.2957763671875D - (double) this.yaw); -+ this.knockingBackEntity = entity1 instanceof EntityLiving ? ((EntityLiving) entity1) : null; // Paper - this.a(0.4F, d0, d1); -+ this.knockingBackEntity = null; // Paper +- this.a(0.4F, d0, d1); ++ this.doKnockback(0.4F, d0, d1, entity1); // Paper } else { this.aw = (float) ((int) (Math.random() * 2.0D) * 180); } @@ -61,12 +57,23 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 } protected void f(EntityLiving entityliving) { -+ ((EntityLiving) entityliving).knockingBackEntity = this; // Paper - entityliving.a(0.5F, entityliving.locX() - this.locX(), entityliving.locZ() - this.locZ()); -+ ((EntityLiving) entityliving).knockingBackEntity = null; // Paper +- entityliving.a(0.5F, entityliving.locX() - this.locX(), entityliving.locZ() - this.locZ()); ++ entityliving.doKnockback(0.5F, entityliving.locX() - this.locX(), entityliving.locZ() - this.locZ(), this); } private boolean f(DamageSource damagesource) { +@@ -0,0 +0,0 @@ public abstract class EntityLiving extends Entity { + } + + public void a(float f, double d0, double d1) { ++ // Paper start - add knockbacking entity parameter ++ this.doKnockback(f, d0, d1, null); ++ } ++ public void doKnockback(float f, double d0, double d1, Entity knockingBackEntity) { ++ // Paper end - add knockbacking entity parameter + f = (float) ((double) f * (1.0D - this.b(GenericAttributes.KNOCKBACK_RESISTANCE))); + if (f > 0.0F) { + this.impulse = true; @@ -0,0 +0,0 @@ public abstract class EntityLiving extends Entity { Vec3D vec3d1 = (new Vec3D(d0, 0.0D, d1)).d().a((double) f); @@ -83,7 +90,4 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + // Paper end } } -+ EntityLiving knockingBackEntity; // Paper - @Nullable - protected SoundEffect getSoundHurt(DamageSource damagesource) { diff --git a/Spigot-Server-Patches/Optimise-entity-hard-collision-checking.patch b/Spigot-Server-Patches/Optimise-entity-hard-collision-checking.patch index e809bb7285..0bd90bb9f8 100644 --- a/Spigot-Server-Patches/Optimise-entity-hard-collision-checking.patch +++ b/Spigot-Server-Patches/Optimise-entity-hard-collision-checking.patch @@ -157,7 +157,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * Not guaranteed to only return hard colliding entites + */ + default List getHardCollidingEntities(@Nullable Entity entity, AxisAlignedBB axisalignedbb, Predicate predicate) { -+ return this.getEntities(entity, axisalignedbb); ++ return this.getEntities(entity, axisalignedbb, predicate); + } + // Paper end - optimise hard collision + diff --git a/Spigot-Server-Patches/fixup-Anti-Xray.patch b/Spigot-Server-Patches/fixup-Anti-Xray.patch deleted file mode 100644 index 7c88ddda14..0000000000 --- a/Spigot-Server-Patches/fixup-Anti-Xray.patch +++ /dev/null @@ -1,54 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Spottedleaf -Date: Fri, 26 Jun 2020 14:10:10 -0700 -Subject: [PATCH] fixup! Anti-Xray - - -diff --git a/src/main/java/com/destroystokyo/paper/antixray/DataBitsReader.java b/src/main/java/com/destroystokyo/paper/antixray/DataBitsReader.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/com/destroystokyo/paper/antixray/DataBitsReader.java -+++ b/src/main/java/com/destroystokyo/paper/antixray/DataBitsReader.java -@@ -0,0 +0,0 @@ public final class DataBitsReader { - bitInLongIndex += bitsPerObject; - - if (bitInLongIndex > 63) { -- bitInLongIndex -= 64; -+ bitInLongIndex = 0; - longInDataBitsIndex += 8; - init(); -- -- if (bitInLongIndex > 0) { -- value |= current << bitsPerObject - bitInLongIndex & mask; -- } - } - - return value; -diff --git a/src/main/java/com/destroystokyo/paper/antixray/DataBitsWriter.java b/src/main/java/com/destroystokyo/paper/antixray/DataBitsWriter.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/com/destroystokyo/paper/antixray/DataBitsWriter.java -+++ b/src/main/java/com/destroystokyo/paper/antixray/DataBitsWriter.java -@@ -0,0 +0,0 @@ public final class DataBitsWriter { - - if (bitInLongIndex > 63) { - finish(); -- bitInLongIndex -= 64; -+ bitInLongIndex = 0; - longInDataBitsIndex += 8; - init(); -- -- if (bitInLongIndex > 0) { -- current = current & ~(mask >>> bitsPerObject - bitInLongIndex) | (value & mask) >>> bitsPerObject - bitInLongIndex; -- dirty = true; -- } - } - } - -@@ -0,0 +0,0 @@ public final class DataBitsWriter { - - if (bitInLongIndex > 63) { - finish(); -- bitInLongIndex -= 64; -+ bitInLongIndex = 0; - longInDataBitsIndex += 8; - init(); - } diff --git a/Spigot-Server-Patches/fixup-Implement-EntityKnockbackByEntityEvent.patch b/Spigot-Server-Patches/fixup-Implement-EntityKnockbackByEntityEvent.patch deleted file mode 100644 index 3420c57883..0000000000 --- a/Spigot-Server-Patches/fixup-Implement-EntityKnockbackByEntityEvent.patch +++ /dev/null @@ -1,93 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Spottedleaf -Date: Fri, 26 Jun 2020 14:28:49 -0700 -Subject: [PATCH] fixup! Implement EntityKnockbackByEntityEvent - - -diff --git a/src/main/java/net/minecraft/server/EntityHuman.java b/src/main/java/net/minecraft/server/EntityHuman.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/net/minecraft/server/EntityHuman.java -+++ b/src/main/java/net/minecraft/server/EntityHuman.java -@@ -0,0 +0,0 @@ public abstract class EntityHuman extends EntityLiving { - if (flag5) { - if (i > 0) { - if (entity instanceof EntityLiving) { -- ((EntityLiving) entity).knockingBackEntity = this; // Paper -- ((EntityLiving) entity).a((float) i * 0.5F, (double) MathHelper.sin(this.yaw * 0.017453292F), (double) (-MathHelper.cos(this.yaw * 0.017453292F))); -- ((EntityLiving) entity).knockingBackEntity = null; // Paper -+ ((EntityLiving) entity).doKnockback((float) i * 0.5F, (double) MathHelper.sin(this.yaw * 0.017453292F), (double) (-MathHelper.cos(this.yaw * 0.017453292F)), this); // Paper - } else { - entity.h((double) (-MathHelper.sin(this.yaw * 0.017453292F) * (float) i * 0.5F), 0.1D, (double) (MathHelper.cos(this.yaw * 0.017453292F) * (float) i * 0.5F)); - } -@@ -0,0 +0,0 @@ public abstract class EntityHuman extends EntityLiving { - if (entityliving != this && entityliving != entity && !this.r(entityliving) && (!(entityliving instanceof EntityArmorStand) || !((EntityArmorStand) entityliving).isMarker()) && this.h((Entity) entityliving) < 9.0D) { - // CraftBukkit start - Only apply knockback if the damage hits - if (entityliving.damageEntity(DamageSource.playerAttack(this).sweep(), f4)) { -- ((EntityLiving) entity).knockingBackEntity = this; // Paper -- entityliving.a(0.4F, (double) MathHelper.sin(this.yaw * 0.017453292F), (double) (-MathHelper.cos(this.yaw * 0.017453292F))); -- ((EntityLiving) entity).knockingBackEntity = null; // Paper -+ entityliving.doKnockback(0.4F, (double) MathHelper.sin(this.yaw * 0.017453292F), (double) (-MathHelper.cos(this.yaw * 0.017453292F)), this); - } - // CraftBukkit end - } -diff --git a/src/main/java/net/minecraft/server/EntityInsentient.java b/src/main/java/net/minecraft/server/EntityInsentient.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/net/minecraft/server/EntityInsentient.java -+++ b/src/main/java/net/minecraft/server/EntityInsentient.java -@@ -0,0 +0,0 @@ public abstract class EntityInsentient extends EntityLiving { - - if (flag) { - if (f1 > 0.0F && entity instanceof EntityLiving) { -- ((EntityLiving) entity).knockingBackEntity = this; // Paper -- ((EntityLiving) entity).a(f1 * 0.5F, (double) MathHelper.sin(this.yaw * 0.017453292F), (double) (-MathHelper.cos(this.yaw * 0.017453292F))); -- ((EntityLiving) entity).knockingBackEntity = null; // Paper -+ ((EntityLiving) entity).doKnockback(f1 * 0.5F, (double) MathHelper.sin(this.yaw * 0.017453292F), (double) (-MathHelper.cos(this.yaw * 0.017453292F)), this); - this.setMot(this.getMot().d(0.6D, 1.0D, 0.6D)); - } - -diff --git a/src/main/java/net/minecraft/server/EntityLiving.java b/src/main/java/net/minecraft/server/EntityLiving.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/net/minecraft/server/EntityLiving.java -+++ b/src/main/java/net/minecraft/server/EntityLiving.java -@@ -0,0 +0,0 @@ public abstract class EntityLiving extends Entity { - } - - this.aw = (float) (MathHelper.d(d1, d0) * 57.2957763671875D - (double) this.yaw); -- this.knockingBackEntity = entity1 instanceof EntityLiving ? ((EntityLiving) entity1) : null; // Paper -- this.a(0.4F, d0, d1); -- this.knockingBackEntity = null; // Paper -+ this.doKnockback(0.4F, d0, d1, entity1); // Paper - } else { - this.aw = (float) ((int) (Math.random() * 2.0D) * 180); - } -@@ -0,0 +0,0 @@ public abstract class EntityLiving extends Entity { - } - - protected void f(EntityLiving entityliving) { -- ((EntityLiving) entityliving).knockingBackEntity = this; // Paper -- entityliving.a(0.5F, entityliving.locX() - this.locX(), entityliving.locZ() - this.locZ()); -- ((EntityLiving) entityliving).knockingBackEntity = null; // Paper -+ entityliving.doKnockback(0.5F, entityliving.locX() - this.locX(), entityliving.locZ() - this.locZ(), this); - } - - private boolean f(DamageSource damagesource) { -@@ -0,0 +0,0 @@ public abstract class EntityLiving extends Entity { - } - - public void a(float f, double d0, double d1) { -+ // Paper start - add knockbacking entity parameter -+ this.doKnockback(f, d0, d1, null); -+ } -+ public void doKnockback(float f, double d0, double d1, Entity knockingBackEntity) { -+ // Paper end - add knockbacking entity parameter - f = (float) ((double) f * (1.0D - this.b(GenericAttributes.KNOCKBACK_RESISTANCE))); - if (f > 0.0F) { - this.impulse = true; -@@ -0,0 +0,0 @@ public abstract class EntityLiving extends Entity { - // Paper end - } - } -- EntityLiving knockingBackEntity; // Paper - - @Nullable - protected SoundEffect getSoundHurt(DamageSource damagesource) {