mirror of
https://github.com/Samsuik/Sakura.git
synced 2025-12-22 16:29:16 +00:00
Upstream has released updates that appear to apply and compile correctly Paper Changes: PaperMC/Paper@914fb08 Fix Entity#updateFluidHeightAndDoFluidPushing inconsistency with Vanilla PaperMC/Paper@e9fa3a7 Use correct queue when blocking on futures PaperMC/Paper@0ff899d Prevent world mutation on copper golem spawn cancel (#13152) PaperMC/Paper@bae47d3 Update to 1.21.10 (#13127) PaperMC/Paper@8339bb3 Update DataConverter constants for 1.21.10 PaperMC/Paper@3982efa Sync Moonrise PaperMC/Paper@fa57d4b Remove Vanilla packet processing at start of tick PaperMC/Paper@fba780d Rebuild patches
54 lines
3.0 KiB
Diff
54 lines
3.0 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Samsuik <kfian294ma4@gmail.com>
|
|
Date: Tue, 20 Feb 2024 19:16:16 +0000
|
|
Subject: [PATCH] Add entity travel distance limits
|
|
|
|
|
|
diff --git a/net/minecraft/server/level/ServerLevel.java b/net/minecraft/server/level/ServerLevel.java
|
|
index 0b9ac2b9e07102babf3c8975cae42841b63f1c63..c94aa1d950a18a29692f9c4e668c8495985ca4c8 100644
|
|
--- a/net/minecraft/server/level/ServerLevel.java
|
|
+++ b/net/minecraft/server/level/ServerLevel.java
|
|
@@ -1343,6 +1343,11 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
|
|
final boolean isActive = io.papermc.paper.entity.activation.ActivationRange.checkIfActive(entity); // Paper - EAR 2
|
|
if (isActive) { // Paper - EAR 2
|
|
entity.tick();
|
|
+ // Sakura start - entity travel distance limits
|
|
+ if (entity.isPastTravelDistanceLimit()) {
|
|
+ entity.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.DESPAWN);
|
|
+ }
|
|
+ // Sakura end - entity travel distance limits
|
|
entity.postTick(); // CraftBukkit
|
|
} else {entity.inactiveTick();} // Paper - EAR 2
|
|
profilerFiller.pop();
|
|
diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java
|
|
index a0e8c5d822c9312054c682d2727d05eb9d885cd5..c5d38a77e28574d54677cd23b690f9ea3994ee63 100644
|
|
--- a/net/minecraft/world/entity/Entity.java
|
|
+++ b/net/minecraft/world/entity/Entity.java
|
|
@@ -603,6 +603,18 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name
|
|
return this.mechanicsTarget;
|
|
}
|
|
// Sakura end - configure server mechanics
|
|
+ // Sakura start - entity travel distance limits
|
|
+ private final double travelDistanceLimit;
|
|
+
|
|
+ public final boolean isPastTravelDistanceLimit() {
|
|
+ if (this.origin == null) {
|
|
+ return false;
|
|
+ }
|
|
+ final double x = Math.pow(this.origin.x() - this.position.x(), 2.0);
|
|
+ final double z = Math.pow(this.origin.z() - this.position.z(), 2.0);
|
|
+ return Math.max(x, z) >= this.travelDistanceLimit;
|
|
+ }
|
|
+ // Sakura end - entity travel distance limits
|
|
|
|
public Entity(EntityType<?> entityType, Level level) {
|
|
this.type = entityType;
|
|
@@ -632,6 +644,7 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name
|
|
this.setPos(0.0, 0.0, 0.0);
|
|
this.eyeHeight = this.dimensions.eyeHeight();
|
|
this.despawnTime = level == null || type == EntityType.PLAYER ? -1 : level.paperConfig().entities.spawning.despawnTime.getOrDefault(type, io.papermc.paper.configuration.type.number.IntOr.Disabled.DISABLED).or(-1); // Paper - entity despawn time limit
|
|
+ this.travelDistanceLimit = level == null ? Integer.MAX_VALUE : Math.pow(level.sakuraConfig().entity.chunkTravelLimit.getOrDefault(entityType, Integer.MAX_VALUE) * 16.0, 2); // Sakura - entity travel distance limits
|
|
}
|
|
|
|
public boolean isColliding(BlockPos pos, BlockState state) {
|