2021-08-02 10:32:53 +02:00
|
|
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
2022-09-26 10:02:51 +02:00
|
|
|
From: Spottedleaf <Spottedleaf@users.noreply.github.com>
|
2021-08-02 10:32:53 +02:00
|
|
|
Date: Mon, 2 Aug 2021 10:10:40 +0200
|
2024-07-07 19:27:45 +02:00
|
|
|
Subject: [PATCH] Check distance in entity interactions
|
2021-08-02 10:32:53 +02:00
|
|
|
|
|
|
|
|
2024-12-16 10:43:57 +01:00
|
|
|
diff --git a/net/minecraft/Util.java b/net/minecraft/Util.java
|
|
|
|
index 60952bd49a89b8d6247d0c8bac837e5b3d586a76..fe84fe69a2a9ed95ec45a9e5af6e6f5a5a74edda 100644
|
|
|
|
--- a/net/minecraft/Util.java
|
|
|
|
+++ b/net/minecraft/Util.java
|
|
|
|
@@ -130,6 +130,7 @@ public class Util {
|
2024-04-12 21:14:06 +02:00
|
|
|
.findFirst()
|
|
|
|
.orElseThrow(() -> new IllegalStateException("No jar file system provider found"));
|
2024-12-16 10:43:57 +01:00
|
|
|
private static Consumer<String> thePauser = string -> {};
|
2024-07-07 19:27:45 +02:00
|
|
|
+ public static final double COLLISION_EPSILON = 1.0E-7; // Paper - Check distance in entity interactions
|
2021-08-02 10:32:53 +02:00
|
|
|
|
2024-12-16 10:43:57 +01:00
|
|
|
public static <K, V> Collector<Entry<? extends K, ? extends V>, ?, Map<K, V>> toMap() {
|
|
|
|
return Collectors.toMap(Entry::getKey, Entry::getValue);
|
|
|
|
diff --git a/net/minecraft/world/entity/LivingEntity.java b/net/minecraft/world/entity/LivingEntity.java
|
|
|
|
index 88f8d462728231627c3ee7557518a2e04b4fd199..e118fd567427064c6ad6637f874ed146e67b2ee8 100644
|
|
|
|
--- a/net/minecraft/world/entity/LivingEntity.java
|
|
|
|
+++ b/net/minecraft/world/entity/LivingEntity.java
|
|
|
|
@@ -1392,7 +1392,7 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
|
|
|
this.hurtCurrentlyUsedShield(amount);
|
|
|
|
f1 = amount;
|
|
|
|
amount = 0.0F;
|
|
|
|
- if (!damageSource.is(DamageTypeTags.IS_PROJECTILE) && damageSource.getDirectEntity() instanceof LivingEntity livingEntity) {
|
|
|
|
+ if (!damageSource.is(DamageTypeTags.IS_PROJECTILE) && damageSource.getDirectEntity() instanceof LivingEntity livingEntity && livingEntity.distanceToSqr(this) <= (200.0D * 200.0D)) { // Paper - Check distance in entity interactions
|
|
|
|
this.blockUsingShield(livingEntity);
|
|
|
|
}
|
2022-12-07 21:16:54 +01:00
|
|
|
|
2024-12-16 10:43:57 +01:00
|
|
|
@@ -1477,6 +1477,14 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
|
|
|
d = damageSource.getSourcePosition().x() - this.getX();
|
|
|
|
d1 = damageSource.getSourcePosition().z() - this.getZ();
|
2024-07-07 19:27:45 +02:00
|
|
|
}
|
|
|
|
+ // Paper start - Check distance in entity interactions; see for loop in knockback method
|
2024-12-16 10:43:57 +01:00
|
|
|
+ if (Math.abs(d) > 200) {
|
|
|
|
+ d = Math.random() - Math.random();
|
2024-07-07 19:27:45 +02:00
|
|
|
+ }
|
|
|
|
+ if (Math.abs(d1) > 200) {
|
2024-07-04 12:34:11 +02:00
|
|
|
+ d1 = Math.random() - Math.random();
|
2024-07-07 19:27:45 +02:00
|
|
|
+ }
|
|
|
|
+ // Paper end - Check distance in entity interactions
|
2021-08-02 10:32:53 +02:00
|
|
|
|
2024-12-16 10:43:57 +01:00
|
|
|
this.knockback(0.4F, d, d1, damageSource.getDirectEntity(), damageSource.getDirectEntity() == null ? io.papermc.paper.event.entity.EntityKnockbackEvent.Cause.DAMAGE : io.papermc.paper.event.entity.EntityKnockbackEvent.Cause.ENTITY_ATTACK); // CraftBukkit // Paper - knockback events
|
2024-07-07 19:27:45 +02:00
|
|
|
if (!flag) {
|
2024-12-16 10:43:57 +01:00
|
|
|
@@ -2352,7 +2360,7 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
2021-08-02 10:32:53 +02:00
|
|
|
this.hurtCurrentlyUsedShield((float) -event.getDamage(DamageModifier.BLOCKING));
|
2024-12-16 10:43:57 +01:00
|
|
|
Entity entity = damageSource.getDirectEntity();
|
2021-08-02 10:32:53 +02:00
|
|
|
|
2024-12-16 10:43:57 +01:00
|
|
|
- if (!damageSource.is(DamageTypeTags.IS_PROJECTILE) && entity instanceof LivingEntity) { // Paper - Fix shield disable inconsistency
|
|
|
|
+ if (!damageSource.is(DamageTypeTags.IS_PROJECTILE) && entity instanceof LivingEntity && entity.distanceToSqr(this) <= (200.0D * 200.0D)) { // Paper - Fix shield disable inconsistency & Check distance in entity interactions
|
2021-08-02 10:32:53 +02:00
|
|
|
this.blockUsingShield((LivingEntity) entity);
|
|
|
|
}
|
|
|
|
}
|
2024-12-16 10:43:57 +01:00
|
|
|
diff --git a/net/minecraft/world/entity/vehicle/AbstractBoat.java b/net/minecraft/world/entity/vehicle/AbstractBoat.java
|
|
|
|
index 5cd65e94ac7830aaa2a64057fc2a81478b55ea41..b9cb86717d7e6c05eb97f3b1bbf1d0111a0ba6ed 100644
|
|
|
|
--- a/net/minecraft/world/entity/vehicle/AbstractBoat.java
|
|
|
|
+++ b/net/minecraft/world/entity/vehicle/AbstractBoat.java
|
|
|
|
@@ -641,7 +641,7 @@ public abstract class AbstractBoat extends VehicleEntity implements Leashable {
|
|
|
|
this.waterLevel = this.getY(1.0);
|
|
|
|
double d2 = this.getWaterLevelAbove() - this.getBbHeight() + 0.101;
|
|
|
|
if (this.level().noCollision(this, this.getBoundingBox().move(0.0, d2 - this.getY(), 0.0))) {
|
2024-07-04 12:34:11 +02:00
|
|
|
- this.setPos(this.getX(), d2, this.getZ());
|
2024-10-24 23:03:27 +02:00
|
|
|
+ this.move(MoverType.SELF, new Vec3(0.0D, d2 - this.getY(), 0.0D)); // Paper - Check distance in entity interactions // TODO Still needed??
|
2024-12-16 10:43:57 +01:00
|
|
|
this.setDeltaMovement(this.getDeltaMovement().multiply(1.0, 0.0, 1.0));
|
|
|
|
this.lastYd = 0.0;
|
2024-07-04 12:34:11 +02:00
|
|
|
}
|