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@b4f04ff Add Plugin#getDataPath (#11080) PaperMC/Paper@05e5865 Add ItemType#getItemRarity (#11049) PaperMC/Paper@aa929d6 Call PlayerLaunchProjectileEvent for wind charge (#10911) PaperMC/Paper@8b23018 Avoid collision shapes outside world border in findFreePosition PaperMC/Paper@3b45454 Port random ticking optimisation from Moonrise PaperMC/Paper@77fcb29 Apply incremental player/level saving patch PaperMC/Paper@9fd7710 Apply automatic regionfile header recalculation patch PaperMC/Paper@b57b24d Do not try to stop main thread during watchdog shutdown PaperMC/Paper@2cd8c46 Add OMINOUS_ITEM_SPAWNER SpawnReason (#10897) PaperMC/Paper@ef96a69 Fire EntityChangeBlockEvent for weaving potion effect (#11087) PaperMC/Paper@a6ceda1 distinguish between null and empty map in API (#10829) PaperMC/Paper@506f165 Don't store removed components in multiple places (#11091) PaperMC/Paper@ceeb8c1 Disable timings by default (#11095) PaperMC/Paper@05ed6a6 Fix priority scheduling logic PaperMC/Paper@967f98a Optimise chunk tick checking during chunk tick PaperMC/Paper@00b949f Remove Moonrise utils to MCUtils, remove duplicated/unused utils PaperMC/Paper@4efd24b Remove unused chunk system hooks in MCUtils PaperMC/Paper@b653276 Finish chunk tick iteration optimisation port from Moonrise PaperMC/Paper@2df5bba Log throwable when failing to save chunk/poi/entity data PaperMC/Paper@44c3dd0 fix exact choice shapeless recipes (#10973) PaperMC/Paper@dd11ef8 Updated Upstream (Bukkit/CraftBukkit/Spigot) (#11102) PaperMC/Paper@3c8a7fe Re-add missing chunk event calls (#11104) PaperMC/Paper@a8db527 Even more cleanup of mcutil patch PaperMC/Paper@d08e8d1 Add total time to done message (#11109) PaperMC/Paper@2a39276 Add CrafterCraftEvent (#11082) PaperMC/Paper@75af62b Split rewriting flag into `paper.disableOldApiSupport` and `paper.disablePluginRemapping` (#11108) PaperMC/Paper@7ea4039 Fixup startup time log message PaperMC/Paper@e71c1df Call PlayerChunkUnloadEvent PaperMC/Paper@968bdeb Make CraftComplexRecipe extend CraftingRecipe (#11114) PaperMC/Paper@f1f01a1 Adjust done message again (#11118)
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 3982f8feeac19ba8f3563b24466f97e099e5158d..da324b6bea6fb5732351104297a2d41de893d3c4 100644
|
|
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
|
|
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
|
@@ -1299,6 +1299,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 1ad28885b14420d44458be1504eadf3e4d8a4e2e..290a94c1c094019592255e8536de39111973bbfe 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/Entity.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
|
|
@@ -620,6 +620,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();
|
|
@@ -669,6 +682,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) {
|