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
|
|
|
|
Subject: [PATCH] Improve boat collision performance
|
|
|
|
|
|
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/Util.java b/src/main/java/net/minecraft/Util.java
|
2024-01-23 12:06:27 +01:00
|
|
|
index edf937591abf62416bd692e40b7b7a6badbe877d..b40864e41e1506884fdefefbf3cf4833a8f706c3 100644
|
2021-08-02 10:32:53 +02:00
|
|
|
--- a/src/main/java/net/minecraft/Util.java
|
|
|
|
+++ b/src/main/java/net/minecraft/Util.java
|
2023-12-06 04:57:46 +01:00
|
|
|
@@ -121,6 +121,7 @@ public class Util {
|
2021-08-02 10:32:53 +02:00
|
|
|
}).findFirst().orElseThrow(() -> {
|
|
|
|
return new IllegalStateException("No jar file system provider found");
|
|
|
|
});
|
2024-01-19 13:22:30 +01:00
|
|
|
+ public static final double COLLISION_EPSILON = 1.0E-7; // Paper - Improve boat collision performance
|
2022-03-01 06:43:03 +01:00
|
|
|
private static Consumer<String> thePauser = (message) -> {
|
2021-11-25 00:46:26 +01:00
|
|
|
};
|
2021-08-02 10:32:53 +02:00
|
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
Updated Upstream (Bukkit/CraftBukkit/Spigot) (#10277)
Upstream has released updates that appear to apply and compile correctly.
This update has not been tested by PaperMC and as with ANY update, please do your own testing
Bukkit Changes:
9a80d38c SPIGOT-336, SPIGOT-3366, SPIGOT-5768, SPIGOT-6409, SPIGOT-6861, PR-722: Add EntityRemoveEvent
258086d9 SPIGOT-7417, PR-967: Add Sign#getTargetSide and Sign#getAllowedEditor
ffaba051 SPIGOT-7584: Add missing Tag.ITEMS_NON_FLAMMABLE_WOOD
CraftBukkit Changes:
98b6c1ac7 SPIGOT-7589 Fix NullPointerException when bans expire
a2736ddb0 SPIGOT-336, SPIGOT-3366, SPIGOT-5768, SPIGOT-6409, SPIGOT-6861, PR-1008: Add EntityRemoveEvent
5bf12cb89 SPIGOT-7565: Throw a more descriptive error message when a developer tries to spawn an entity from a CraftBukkit class
76d95fe7e SPIGOT-7417, PR-1343: Add Sign#getTargetSide and Sign#getAllowedEditor
Spigot Changes:
e9ec5485 Rebuild patches
f1b62e0c Rebuild patches
2024-02-23 14:37:33 +01:00
|
|
|
index 6b58292469b5507e0e000455146a7ee1852571c5..5cedbe57f15024e6b1c278de1b3cf3e1fd84de06 100644
|
2021-08-02 10:32:53 +02:00
|
|
|
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
|
|
|
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
Updated Upstream (Bukkit/CraftBukkit/Spigot) (#10277)
Upstream has released updates that appear to apply and compile correctly.
This update has not been tested by PaperMC and as with ANY update, please do your own testing
Bukkit Changes:
9a80d38c SPIGOT-336, SPIGOT-3366, SPIGOT-5768, SPIGOT-6409, SPIGOT-6861, PR-722: Add EntityRemoveEvent
258086d9 SPIGOT-7417, PR-967: Add Sign#getTargetSide and Sign#getAllowedEditor
ffaba051 SPIGOT-7584: Add missing Tag.ITEMS_NON_FLAMMABLE_WOOD
CraftBukkit Changes:
98b6c1ac7 SPIGOT-7589 Fix NullPointerException when bans expire
a2736ddb0 SPIGOT-336, SPIGOT-3366, SPIGOT-5768, SPIGOT-6409, SPIGOT-6861, PR-1008: Add EntityRemoveEvent
5bf12cb89 SPIGOT-7565: Throw a more descriptive error message when a developer tries to spawn an entity from a CraftBukkit class
76d95fe7e SPIGOT-7417, PR-1343: Add Sign#getTargetSide and Sign#getAllowedEditor
Spigot Changes:
e9ec5485 Rebuild patches
f1b62e0c Rebuild patches
2024-02-23 14:37:33 +01:00
|
|
|
@@ -1446,7 +1446,7 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
2023-03-14 21:25:13 +01:00
|
|
|
if (!source.is(DamageTypeTags.IS_PROJECTILE)) {
|
2021-08-02 10:32:53 +02:00
|
|
|
Entity entity = source.getDirectEntity();
|
|
|
|
|
|
|
|
- if (entity instanceof LivingEntity) {
|
2024-01-19 13:22:30 +01:00
|
|
|
+ if (entity instanceof LivingEntity && entity.distanceToSqr(this) <= (200.0D * 200.0D)) { // Paper - Improve boat collision performance
|
2022-12-07 21:16:54 +01:00
|
|
|
LivingEntity entityliving = (LivingEntity) entity;
|
|
|
|
|
|
|
|
this.blockUsingShield(entityliving);
|
Updated Upstream (Bukkit/CraftBukkit/Spigot) (#10277)
Upstream has released updates that appear to apply and compile correctly.
This update has not been tested by PaperMC and as with ANY update, please do your own testing
Bukkit Changes:
9a80d38c SPIGOT-336, SPIGOT-3366, SPIGOT-5768, SPIGOT-6409, SPIGOT-6861, PR-722: Add EntityRemoveEvent
258086d9 SPIGOT-7417, PR-967: Add Sign#getTargetSide and Sign#getAllowedEditor
ffaba051 SPIGOT-7584: Add missing Tag.ITEMS_NON_FLAMMABLE_WOOD
CraftBukkit Changes:
98b6c1ac7 SPIGOT-7589 Fix NullPointerException when bans expire
a2736ddb0 SPIGOT-336, SPIGOT-3366, SPIGOT-5768, SPIGOT-6409, SPIGOT-6861, PR-1008: Add EntityRemoveEvent
5bf12cb89 SPIGOT-7565: Throw a more descriptive error message when a developer tries to spawn an entity from a CraftBukkit class
76d95fe7e SPIGOT-7417, PR-1343: Add Sign#getTargetSide and Sign#getAllowedEditor
Spigot Changes:
e9ec5485 Rebuild patches
f1b62e0c Rebuild patches
2024-02-23 14:37:33 +01:00
|
|
|
@@ -1540,11 +1540,12 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
2021-08-02 10:32:53 +02:00
|
|
|
}
|
|
|
|
|
2023-09-22 14:22:24 +02:00
|
|
|
if (entity1 != null && !source.is(DamageTypeTags.NO_KNOCKBACK)) {
|
2021-08-02 10:32:53 +02:00
|
|
|
- double d0 = entity1.getX() - this.getX();
|
2024-01-19 13:22:30 +01:00
|
|
|
+ final boolean far = entity1.distanceToSqr(this) > (200.0 * 200.0); // Paper - Improve boat collision performance
|
|
|
|
+ double d0 = far ? (Math.random() - Math.random()) : entity1.getX() - this.getX(); // Paper - Improve boat collision performance
|
2021-08-02 10:32:53 +02:00
|
|
|
|
|
|
|
double d1;
|
|
|
|
|
|
|
|
- for (d1 = entity1.getZ() - this.getZ(); d0 * d0 + d1 * d1 < 1.0E-4D; d1 = (Math.random() - Math.random()) * 0.01D) {
|
2024-01-19 13:22:30 +01:00
|
|
|
+ for (d1 = far ? Math.random() - Math.random() : entity1.getZ() - this.getZ(); d0 * d0 + d1 * d1 < 1.0E-4D; d1 = (Math.random() - Math.random()) * 0.01D) { // Paper - Improve boat collision performance
|
2021-08-02 10:32:53 +02:00
|
|
|
d0 = (Math.random() - Math.random()) * 0.01D;
|
|
|
|
}
|
|
|
|
|
Updated Upstream (Bukkit/CraftBukkit/Spigot) (#10277)
Upstream has released updates that appear to apply and compile correctly.
This update has not been tested by PaperMC and as with ANY update, please do your own testing
Bukkit Changes:
9a80d38c SPIGOT-336, SPIGOT-3366, SPIGOT-5768, SPIGOT-6409, SPIGOT-6861, PR-722: Add EntityRemoveEvent
258086d9 SPIGOT-7417, PR-967: Add Sign#getTargetSide and Sign#getAllowedEditor
ffaba051 SPIGOT-7584: Add missing Tag.ITEMS_NON_FLAMMABLE_WOOD
CraftBukkit Changes:
98b6c1ac7 SPIGOT-7589 Fix NullPointerException when bans expire
a2736ddb0 SPIGOT-336, SPIGOT-3366, SPIGOT-5768, SPIGOT-6409, SPIGOT-6861, PR-1008: Add EntityRemoveEvent
5bf12cb89 SPIGOT-7565: Throw a more descriptive error message when a developer tries to spawn an entity from a CraftBukkit class
76d95fe7e SPIGOT-7417, PR-1343: Add Sign#getTargetSide and Sign#getAllowedEditor
Spigot Changes:
e9ec5485 Rebuild patches
f1b62e0c Rebuild patches
2024-02-23 14:37:33 +01:00
|
|
|
@@ -2287,7 +2288,7 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
2021-08-02 10:32:53 +02:00
|
|
|
this.hurtCurrentlyUsedShield((float) -event.getDamage(DamageModifier.BLOCKING));
|
|
|
|
Entity entity = damagesource.getDirectEntity();
|
|
|
|
|
|
|
|
- if (entity instanceof LivingEntity) {
|
2024-01-19 13:22:30 +01:00
|
|
|
+ if (entity instanceof LivingEntity && entity.distanceToSqr(this) <= (200.0D * 200.0D)) { // Paper - Improve boat collision performance
|
2021-08-02 10:32:53 +02:00
|
|
|
this.blockUsingShield((LivingEntity) entity);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
diff --git a/src/main/java/net/minecraft/world/entity/vehicle/Boat.java b/src/main/java/net/minecraft/world/entity/vehicle/Boat.java
|
2024-01-20 23:13:41 +01:00
|
|
|
index 1ced6d60a74fac028804b3c2d938e89af4706823..db6aa75d642f4a7258f197933671907faf79c8f2 100644
|
2021-08-02 10:32:53 +02:00
|
|
|
--- a/src/main/java/net/minecraft/world/entity/vehicle/Boat.java
|
|
|
|
+++ b/src/main/java/net/minecraft/world/entity/vehicle/Boat.java
|
2024-01-20 23:13:41 +01:00
|
|
|
@@ -689,7 +689,7 @@ public class Boat extends VehicleEntity implements VariantHolder<Boat.Type> {
|
2021-08-02 10:43:56 +02:00
|
|
|
this.invFriction = 0.05F;
|
2021-08-02 10:32:53 +02:00
|
|
|
if (this.oldStatus == Boat.Status.IN_AIR && this.status != Boat.Status.IN_AIR && this.status != Boat.Status.ON_LAND) {
|
|
|
|
this.waterLevel = this.getY(1.0D);
|
2021-08-02 10:43:56 +02:00
|
|
|
- this.setPos(this.getX(), (double) (this.getWaterLevelAbove() - this.getBbHeight()) + 0.101D, this.getZ());
|
2024-01-19 13:22:30 +01:00
|
|
|
+ this.move(MoverType.SELF, new Vec3(0.0, ((double) (this.getWaterLevelAbove() - this.getBbHeight()) + 0.101D) - this.getY(), 0.0)); // Paper - Improve boat collision performance
|
2024-01-20 23:13:41 +01:00
|
|
|
this.setDeltaMovement(this.getDeltaMovement().multiply(1.0D, 0.0D, 1.0D));
|
2021-08-02 10:32:53 +02:00
|
|
|
this.lastYd = 0.0D;
|
|
|
|
this.status = Boat.Status.IN_WATER;
|