mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-29 15:49:00 +01:00
68 lines
4.6 KiB
Diff
68 lines
4.6 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Spottedleaf <Spottedleaf@users.noreply.github.com>
|
|
Date: Mon, 2 Aug 2021 10:10:40 +0200
|
|
Subject: [PATCH] Check distance in entity interactions
|
|
|
|
|
|
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 {
|
|
.findFirst()
|
|
.orElseThrow(() -> new IllegalStateException("No jar file system provider found"));
|
|
private static Consumer<String> thePauser = string -> {};
|
|
+ public static final double COLLISION_EPSILON = 1.0E-7; // Paper - Check distance in entity interactions
|
|
|
|
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 9de400977ec33e485e87cdf1cf145588527e1e10..c83aeaf4e50dd7290c608dfe260a3bd2404b6004 100644
|
|
--- a/net/minecraft/world/entity/LivingEntity.java
|
|
+++ b/net/minecraft/world/entity/LivingEntity.java
|
|
@@ -1385,7 +1385,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);
|
|
}
|
|
|
|
@@ -1470,6 +1470,14 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
|
d = damageSource.getSourcePosition().x() - this.getX();
|
|
d1 = damageSource.getSourcePosition().z() - this.getZ();
|
|
}
|
|
+ // Paper start - Check distance in entity interactions; see for loop in knockback method
|
|
+ if (Math.abs(d) > 200) {
|
|
+ d = Math.random() - Math.random();
|
|
+ }
|
|
+ if (Math.abs(d1) > 200) {
|
|
+ d1 = Math.random() - Math.random();
|
|
+ }
|
|
+ // Paper end - Check distance in entity interactions
|
|
|
|
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
|
|
if (!flag) {
|
|
@@ -2345,7 +2353,7 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
|
this.hurtCurrentlyUsedShield((float) -event.getDamage(DamageModifier.BLOCKING));
|
|
Entity entity = damageSource.getDirectEntity();
|
|
|
|
- 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
|
|
this.blockUsingShield((LivingEntity) entity);
|
|
}
|
|
}
|
|
diff --git a/net/minecraft/world/entity/vehicle/AbstractBoat.java b/net/minecraft/world/entity/vehicle/AbstractBoat.java
|
|
index 3bdb3b0984d0fee21b2c094e1d4c1f917ab68f92..54a4bf2f7df87b4a694187ade81ba158f83f0246 100644
|
|
--- a/net/minecraft/world/entity/vehicle/AbstractBoat.java
|
|
+++ b/net/minecraft/world/entity/vehicle/AbstractBoat.java
|
|
@@ -638,7 +638,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))) {
|
|
- this.setPos(this.getX(), d2, this.getZ());
|
|
+ this.move(MoverType.SELF, new Vec3(0.0D, d2 - this.getY(), 0.0D)); // Paper - Check distance in entity interactions // TODO Still needed??
|
|
this.setDeltaMovement(this.getDeltaMovement().multiply(1.0, 0.0, 1.0));
|
|
this.lastYd = 0.0;
|
|
}
|