2022-07-28 03:57:50 +00:00
|
|
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
2022-12-11 06:04:11 +00:00
|
|
|
From: Telesphoreo <me@telesphoreo.me>
|
|
|
|
Date: Sat, 10 Dec 2022 23:44:05 -0600
|
2022-07-28 03:57:50 +00:00
|
|
|
Subject: [PATCH] Limit amount of vehicle collision checks to 3 and discard
|
|
|
|
vehicles if they collide with more than 15 other entities
|
|
|
|
|
|
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecart.java b/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecart.java
|
2023-06-09 00:58:46 +00:00
|
|
|
index 9948a28dae4edba877c13ef0156be5ff58df3fa2..93f359c71659c0b2fdf25b1c76c072bf9209db2a 100644
|
2022-07-28 03:57:50 +00:00
|
|
|
--- a/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecart.java
|
|
|
|
+++ b/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecart.java
|
|
|
|
@@ -8,6 +8,7 @@ import com.mojang.datafixers.util.Pair;
|
|
|
|
import java.util.Iterator;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.Map;
|
|
|
|
+import java.util.concurrent.TimeUnit;
|
|
|
|
import javax.annotation.Nullable;
|
|
|
|
import net.minecraft.BlockUtil;
|
|
|
|
import net.minecraft.Util;
|
2023-06-09 00:58:46 +00:00
|
|
|
@@ -107,6 +108,7 @@ public abstract class AbstractMinecart extends Entity {
|
2022-07-28 03:57:50 +00:00
|
|
|
private double flyingX = 0.949999988079071D; // Paper - restore vanilla precision
|
|
|
|
private double flyingY = 0.949999988079071D; // Paper - restore vanilla precision
|
|
|
|
private double flyingZ = 0.949999988079071D; // Paper - restore vanilla precision
|
|
|
|
+ private long lastLargeCollision = 0L; // Scissors - Add a collision debounce
|
|
|
|
public double maxSpeed = 0.4D;
|
|
|
|
// CraftBukkit end
|
|
|
|
|
2023-06-09 00:58:46 +00:00
|
|
|
@@ -434,8 +436,10 @@ public abstract class AbstractMinecart extends Entity {
|
2022-07-28 03:57:50 +00:00
|
|
|
if (this.getMinecartType() == AbstractMinecart.Type.RIDEABLE && this.getDeltaMovement().horizontalDistanceSqr() > 0.01D) {
|
2023-06-09 00:58:46 +00:00
|
|
|
List<Entity> list = this.level().getEntities((Entity) this, this.getBoundingBox().inflate(0.20000000298023224D, 0.0D, 0.20000000298023224D), EntitySelector.pushableBy(this));
|
2022-07-28 03:57:50 +00:00
|
|
|
|
|
|
|
- if (!list.isEmpty()) {
|
|
|
|
- for (int l = 0; l < list.size(); ++l) {
|
|
|
|
+ // Scissors - Add a collision debounce
|
|
|
|
+ if (!list.isEmpty() && (System.currentTimeMillis() - lastLargeCollision) >= TimeUnit.SECONDS.toMillis(5)) { // Using TimeUnit for better code readability
|
|
|
|
+ // Scissors - Limit amount of vehicle collision checks to 3 maximum
|
|
|
|
+ for (int l = 0; l < Math.min(3, list.size()); ++l) {
|
|
|
|
Entity entity = (Entity) list.get(l);
|
|
|
|
|
|
|
|
if (!(entity instanceof Player) && !(entity instanceof IronGolem) && !(entity instanceof AbstractMinecart) && !this.isVehicle() && !entity.isPassenger()) {
|
2023-06-09 00:58:46 +00:00
|
|
|
@@ -462,6 +466,16 @@ public abstract class AbstractMinecart extends Entity {
|
2022-07-28 03:57:50 +00:00
|
|
|
entity.push(this);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
+
|
|
|
|
+ // Scissors - Add a collision debounce
|
|
|
|
+ if (list.size() > 3) {
|
|
|
|
+ lastLargeCollision = System.currentTimeMillis();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // Scissors - Delete entity if the collision amount is over 15
|
|
|
|
+ if (list.size() > 15) {
|
|
|
|
+ this.discard();
|
|
|
|
+ }
|
|
|
|
}
|
|
|
|
} else {
|
2023-06-09 00:58:46 +00:00
|
|
|
Iterator iterator = this.level().getEntities(this, this.getBoundingBox().inflate(0.20000000298023224D, 0.0D, 0.20000000298023224D)).iterator();
|
2022-07-28 03:57:50 +00:00
|
|
|
diff --git a/src/main/java/net/minecraft/world/entity/vehicle/Boat.java b/src/main/java/net/minecraft/world/entity/vehicle/Boat.java
|
2023-06-09 00:58:46 +00:00
|
|
|
index 35aeba4e8430e6419caa9db4a0b931a994228618..11b337298ac824adce04cf0608f8f960e59640c9 100644
|
2022-07-28 03:57:50 +00:00
|
|
|
--- a/src/main/java/net/minecraft/world/entity/vehicle/Boat.java
|
|
|
|
+++ b/src/main/java/net/minecraft/world/entity/vehicle/Boat.java
|
2022-12-11 06:04:11 +00:00
|
|
|
@@ -5,6 +5,7 @@ import com.google.common.collect.UnmodifiableIterator;
|
2022-07-28 03:57:50 +00:00
|
|
|
import java.util.Iterator;
|
|
|
|
import java.util.List;
|
2022-12-11 06:04:11 +00:00
|
|
|
import java.util.function.IntFunction;
|
2022-07-28 03:57:50 +00:00
|
|
|
+import java.util.concurrent.TimeUnit;
|
|
|
|
import javax.annotation.Nullable;
|
|
|
|
import net.minecraft.BlockUtil;
|
|
|
|
import net.minecraft.core.BlockPos;
|
2023-05-13 02:30:27 +00:00
|
|
|
@@ -109,6 +110,7 @@ public class Boat extends Entity implements VariantHolder<Boat.Type> {
|
2022-07-28 03:57:50 +00:00
|
|
|
public double unoccupiedDeceleration = -1;
|
|
|
|
public boolean landBoats = false;
|
|
|
|
// CraftBukkit end
|
|
|
|
+ private long lastLargeCollision = 0L; // Scissors - Add a collision debounce
|
|
|
|
|
|
|
|
public Boat(EntityType<? extends Boat> type, Level world) {
|
|
|
|
super(type, world);
|
2023-05-13 02:30:27 +00:00
|
|
|
@@ -421,10 +423,12 @@ public class Boat extends Entity implements VariantHolder<Boat.Type> {
|
2022-07-28 03:57:50 +00:00
|
|
|
this.checkInsideBlocks();
|
2023-06-09 00:58:46 +00:00
|
|
|
List<Entity> list = this.level().getEntities((Entity) this, this.getBoundingBox().inflate(0.20000000298023224D, -0.009999999776482582D, 0.20000000298023224D), EntitySelector.pushableBy(this));
|
2022-07-28 03:57:50 +00:00
|
|
|
|
|
|
|
- if (!list.isEmpty()) {
|
|
|
|
+ // Scissors - Add collision debounce
|
|
|
|
+ if (!list.isEmpty() && (System.currentTimeMillis() - lastLargeCollision) >= TimeUnit.SECONDS.toMillis(5)) { // Using TimeUnit for better code readability
|
2023-06-09 00:58:46 +00:00
|
|
|
boolean flag = !this.level().isClientSide && !(this.getControllingPassenger() instanceof Player);
|
2022-07-28 03:57:50 +00:00
|
|
|
|
|
|
|
- for (int j = 0; j < list.size(); ++j) {
|
|
|
|
+ // Scissors - Limit amount of vehicle collision checks to 3 maximum
|
|
|
|
+ for (int j = 0; j < Math.min(3, list.size()); ++j) {
|
|
|
|
Entity entity = (Entity) list.get(j);
|
|
|
|
|
|
|
|
if (!entity.hasPassenger((Entity) this)) {
|
2023-05-13 02:30:27 +00:00
|
|
|
@@ -435,6 +439,16 @@ public class Boat extends Entity implements VariantHolder<Boat.Type> {
|
2022-07-28 03:57:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
+
|
|
|
|
+ // Scissors - Add collision debounce
|
|
|
|
+ if (list.size() > 3) {
|
|
|
|
+ lastLargeCollision = System.currentTimeMillis();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // Scissors - Delete entity if the collision amount is over 15
|
|
|
|
+ if (list.size() > 15) {
|
|
|
|
+ this.discard();
|
|
|
|
+ }
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|