mirror of
https://github.com/Samsuik/Sakura.git
synced 2025-12-23 00:39:20 +00:00
Upstream has released updates that appear to apply and compile correctly Paper Changes: PaperMC/Paper@5e2a3bc Call EntityChangeBlockEvent with correct block when waxing (#12154) PaperMC/Paper@ab984a0 Always pass event block to damage source (#12158) PaperMC/Paper@7b4d44f Revert "Always pass event block to damage source (#12158)" PaperMC/Paper@e5a8ee8 Hide soul speed particles for vanished players (#12152) PaperMC/Paper@fcb2e81 Clear lastSection on game event listener removal PaperMC/Paper@636ae0c Add missing Paper comments to player movement patch PaperMC/Paper@9be4e07 Pin snapshot dependencies (#12185) PaperMC/Paper@f12d33f Track codec writing PaperMC/Paper@1d9b399 Add config option for failed beehive release cooldowns (#12186) PaperMC/Paper@5f2ee83 Fix first execution of async delayed/repeating tasks being sync (#12166) PaperMC/Paper@b00875f Add a method on Registry to get the size (#12182) PaperMC/Paper@ca26109 Don't process empty rcon commands (#12188) PaperMC/Paper@a501c45 Deprecate server config getters (#12189) PaperMC/Paper@7f3d359 Use MiniMessage#deserialize(String, Pointered) in sendRichMessage for send messages (#12177) PaperMC/Paper@9b9f046 Remove broken code (#12171) PaperMC/Paper@fc56c72 Add methods for Creaking (#12094) PaperMC/Paper@f63dbea Fix cancelled HangingPlaceEvent inventory desync (#12161) PaperMC/Paper@9421f22 Make CustomArgumentType use parse(reader,source) (#12191) PaperMC/Paper@0a6e743 Fix invulnerability damage and armour (#12190) PaperMC/Paper@b506626 Remove unused light queue size option (#12201) PaperMC/Paper@1d5e5a5 Document replacement for Skull owner profile methods (#12195) PaperMC/Paper@8de7e35 Add null check to level ref in Entity constructor (#12218) PaperMC/Paper@a866e36 Fix MenuType.SMITHING JavaDocs (#12226) PaperMC/Paper@5538d24 Fix "DEFAULT" SpawnReason of fish spawned by bucket (#12227)
55 lines
2.9 KiB
Diff
55 lines
2.9 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 512486514d2279c377b0fb6fd2a90b03c89d2209..0b575c9acf7e211bf62fde3bf9e82d6bdeb0f643 100644
|
|
--- a/net/minecraft/server/level/ServerLevel.java
|
|
+++ b/net/minecraft/server/level/ServerLevel.java
|
|
@@ -1296,6 +1296,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 15e54f3ddb12c392d4527661a2672a6856b14215..01c43ee5497037cb059255cc31d85f04dbfa78ed 100644
|
|
--- a/net/minecraft/world/entity/Entity.java
|
|
+++ b/net/minecraft/world/entity/Entity.java
|
|
@@ -589,6 +589,19 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
|
return this.physics;
|
|
}
|
|
// Sakura end - configure cannon physics
|
|
+ // 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<?> entityType, Level level) {
|
|
this.type = entityType;
|
|
@@ -618,6 +631,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
|
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) {
|