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@9aea240 Properly lookup plugin classes when looked up by spark PaperMC/Paper@7e91a2c Update the bundled spark version PaperMC/Paper@3a47518 Deprecate more Timings things for removal (#11126) PaperMC/Paper@aa36ae6 Fix EntityUnleashEvent cancellation on distance cause (#11131) PaperMC/Paper@73a863b Fix horse inventories indices (#11139) PaperMC/Paper@5512af7 [ci skip] remove timings from issue templates (#11127) PaperMC/Paper@5a5035b Fix a couple of ItemMeta related NPEs (#11149) PaperMC/Paper@e1462a9 Bump MCUtils#asyncExecutor core size PaperMC/Paper@645a677 Make max interaction range configurable (#11164) PaperMC/Paper@66165f7 Fix PickupStatus getting reset (#11154) PaperMC/Paper@dcbd99d Fix Owen's typos (#11179) PaperMC/Paper@f82bea6 Add argument for FinePosition to brig API (#11094) PaperMC/Paper@694b120 Remove Entity tracker field PaperMC/Paper@f774787 Copy missed changes to chunk system from Folia PaperMC/Paper@50bdfc3 Null check tracker in Entity#resendPossiblyDesyncedEntityData PaperMC/Paper@3234b20 Do not allow chunk unloading outside of the regular tick loop PaperMC/Paper@0246a9d Add mob bucket items to item id to entity map in DataConverter PaperMC/Paper@438863c Shutdown L4J cordially if the server stops before it's even started (#11172) PaperMC/Paper@100d75a Don't entirely die just because a plugin jar was bad PaperMC/Paper@227544c Move TickThread changes from Moonrise patch to MCUtils PaperMC/Paper@67d414a Allow plugin aliases to override vanilla commands (#11186) PaperMC/Paper@58c7ea3 Preserve command node when re-registering modern commands through old API (#11184) PaperMC/Paper@0a1be9a Make loadChunksForMoveAsync use new chunk system load calls PaperMC/Paper@df3b654 ConcurrentUtil: Fix concurrent long map resize chain pull function PaperMC/Paper@5a5c3a4 Remove chunk unload trace debug PaperMC/Paper@7e44684 Fix wrong assumption about locale being null in the login phase (#11204) PaperMC/Paper@042f15f [ci skip] chore: fix incorrect commit hash in PR builds (#11198) PaperMC/Paper@4e6a2a1 Check for block type in SculkSensorBlock#canActivate
55 lines
2.8 KiB
Diff
55 lines
2.8 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/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
|
index d9495f6585c13ed2b1cdbe971a721d5b717920aa..2eb0d27a9fa7795f5b0973179a23a3edb61ef75a 100644
|
|
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
|
|
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
|
@@ -1256,6 +1256,11 @@ public class ServerLevel extends Level implements WorldGenLevel, ca.spottedleaf.
|
|
if (isActive) { // Paper - EAR 2
|
|
TimingHistory.activatedEntityTicks++;
|
|
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
|
|
this.getProfiler().pop();
|
|
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
|
|
index 38bd2af86bf1c15bb8d062630e9853dea9d32deb..33ba8ba3168425268825c24f0d9b7c9778b5b292 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/Entity.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
|
|
@@ -619,6 +619,19 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
|
return this.physics;
|
|
}
|
|
// Sakura end - physics version api
|
|
+ // Sakura start - entity travel distance limits
|
|
+ private final double travelDistanceLimit;
|
|
+
|
|
+ public final boolean isPastTravelDistanceLimit() {
|
|
+ if (this.origin == null) {
|
|
+ return false;
|
|
+ }
|
|
+
|
|
+ double x = Math.pow(this.origin.getX() - this.position.x(), 2);
|
|
+ double z = Math.pow(this.origin.getZ() - this.position.z(), 2);
|
|
+ return Math.max(x, z) >= this.travelDistanceLimit;
|
|
+ }
|
|
+ // Sakura end - entity travel distance limits
|
|
|
|
public Entity(EntityType<?> type, Level world) {
|
|
this.id = Entity.ENTITY_COUNTER.incrementAndGet();
|
|
@@ -668,6 +681,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
|
this.entityData = datawatcher_a.build();
|
|
this.setPos(0.0D, 0.0D, 0.0D);
|
|
this.eyeHeight = this.dimensions.eyeHeight();
|
|
+ this.travelDistanceLimit = Math.pow(this.level.sakuraConfig().entity.chunkTravelLimit.getOrDefault(type, Integer.MAX_VALUE) * 16.0, 2); // Sakura - entity travel distance limits
|
|
}
|
|
|
|
public boolean isColliding(BlockPos pos, BlockState state) {
|