2024-07-04 12:34:11 +02:00
|
|
|
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
|
2024-07-07 19:27:45 +02:00
|
|
|
Subject: [PATCH] Check distance in entity interactions
|
2024-07-04 12:34:11 +02:00
|
|
|
|
2024-11-09 21:44:55 +01:00
|
|
|
Feature patch
|
2024-07-04 12:34:11 +02:00
|
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/Util.java b/src/main/java/net/minecraft/Util.java
|
2024-12-03 17:58:41 +01:00
|
|
|
index e4048d8f43befe5134222207cdb88f640a875deb..276ad77ecb274b6cd454d0f92457964a8eaa5824 100644
|
2024-07-04 12:34:11 +02:00
|
|
|
--- a/src/main/java/net/minecraft/Util.java
|
|
|
|
+++ b/src/main/java/net/minecraft/Util.java
|
2024-10-24 23:03:27 +02:00
|
|
|
@@ -128,6 +128,7 @@ public class Util {
|
2024-07-04 12:34:11 +02:00
|
|
|
.filter(fileSystemProvider -> fileSystemProvider.getScheme().equalsIgnoreCase("jar"))
|
|
|
|
.findFirst()
|
|
|
|
.orElseThrow(() -> new IllegalStateException("No jar file system provider found"));
|
2024-07-07 19:27:45 +02:00
|
|
|
+ public static final double COLLISION_EPSILON = 1.0E-7; // Paper - Check distance in entity interactions
|
2024-07-04 12:34:11 +02:00
|
|
|
private static Consumer<String> thePauser = message -> {
|
|
|
|
};
|
|
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
Rework async chunk api implementation
Firstly, the old methods all routed to the CompletableFuture method.
However, the CF method could not guarantee that if the caller
was off-main that the future would be "completed" on-main. Since
the callback methods used the CF one, this meant that the callback
methods did not guarantee that the callbacks were to be called on
the main thread.
Now, all methods route to getChunkAtAsync(x, z, gen, urgent, cb)
so that the methods with the callback are guaranteed to invoke
the callback on the main thread. The CF behavior remains unchanged;
it may still appear to complete on main if invoked off-main.
Secondly, remove the scheduleOnMain invocation in the async
chunk completion. This unnecessarily delays the callback
by 1 tick.
Thirdly, add getChunksAtAsync(minX, minZ, maxX, maxZ, ...) which
will load chunks within an area. This method is provided as a helper
as keeping all chunks loaded within an area can be complicated to
implement for plugins (due to the lacking ticket API), and is
already implemented internally anyways.
Fourthly, remove the ticket addition that occured with getChunkAt
and getChunkAtAsync. The ticket addition may delay the unloading
of the chunk unnecessarily. It also fixes a very rare timing bug
where the future/callback would be completed after the chunk
unloads.
2024-11-19 07:34:32 +01:00
|
|
|
index 6a89a9af2ccb82ee1162b14f4be5a868b927a34d..ed26eb5e8cc9a46e4a4d2c58d587463d5571a8e0 100644
|
2024-07-04 12:34:11 +02:00
|
|
|
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
|
|
|
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
2024-10-27 18:11:15 +01:00
|
|
|
@@ -1467,7 +1467,7 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
2024-07-04 12:34:11 +02:00
|
|
|
if (!source.is(DamageTypeTags.IS_PROJECTILE)) {
|
|
|
|
Entity entity = source.getDirectEntity();
|
|
|
|
|
|
|
|
- if (entity instanceof LivingEntity) {
|
2024-07-07 19:27:45 +02:00
|
|
|
+ if (entity instanceof LivingEntity && entity.distanceToSqr(this) <= (200.0D * 200.0D)) { // Paper - Check distance in entity interactions
|
2024-07-04 12:34:11 +02:00
|
|
|
LivingEntity entityliving = (LivingEntity) entity;
|
|
|
|
|
|
|
|
this.blockUsingShield(entityliving);
|
2024-10-27 18:11:15 +01:00
|
|
|
@@ -1591,6 +1591,14 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
2024-07-07 19:27:45 +02:00
|
|
|
d0 = source.getSourcePosition().x() - this.getX();
|
|
|
|
d1 = source.getSourcePosition().z() - this.getZ();
|
|
|
|
}
|
|
|
|
+ // Paper start - Check distance in entity interactions; see for loop in knockback method
|
|
|
|
+ if (Math.abs(d0) > 200) {
|
2024-07-04 12:34:11 +02:00
|
|
|
+ d0 = 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
|
2024-07-04 12:34:11 +02:00
|
|
|
|
2024-07-07 19:27:45 +02:00
|
|
|
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
|
|
|
|
if (!flag) {
|
2024-11-04 18:42:38 +01:00
|
|
|
@@ -2427,7 +2435,7 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
2024-07-04 12:34:11 +02:00
|
|
|
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
|
2024-07-07 19:27:45 +02:00
|
|
|
+ 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
|
2024-07-04 12:34:11 +02:00
|
|
|
this.blockUsingShield((LivingEntity) entity);
|
|
|
|
}
|
|
|
|
}
|
2024-10-24 23:03:27 +02:00
|
|
|
diff --git a/src/main/java/net/minecraft/world/entity/vehicle/AbstractBoat.java b/src/main/java/net/minecraft/world/entity/vehicle/AbstractBoat.java
|
2024-10-25 17:08:48 +02:00
|
|
|
index 3590f4bc1af829cdb6e0cfdc8fa6857197b9219e..1fdbef16cd29c8fc74578ac3328f985eca61088d 100644
|
2024-10-24 23:03:27 +02:00
|
|
|
--- a/src/main/java/net/minecraft/world/entity/vehicle/AbstractBoat.java
|
|
|
|
+++ b/src/main/java/net/minecraft/world/entity/vehicle/AbstractBoat.java
|
|
|
|
@@ -674,7 +674,7 @@ public abstract class AbstractBoat extends VehicleEntity implements Leashable {
|
2024-07-04 12:34:11 +02:00
|
|
|
double d2 = (double) (this.getWaterLevelAbove() - this.getBbHeight()) + 0.101D;
|
|
|
|
|
|
|
|
if (this.level().noCollision(this, this.getBoundingBox().move(0.0D, d2 - this.getY(), 0.0D))) {
|
|
|
|
- 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-07-04 12:34:11 +02:00
|
|
|
this.setDeltaMovement(this.getDeltaMovement().multiply(1.0D, 0.0D, 1.0D));
|
|
|
|
this.lastYd = 0.0D;
|
|
|
|
}
|