mirror of
https://github.com/Samsuik/Sakura.git
synced 2026-01-04 15:31:43 +00:00
Update feaure patches
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
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 effdd0e1382fc59b9d8a709c18a652fbd4e94e6d..8f17606889b767539c19015ae7f1cb7795616b88 100644
|
||||
--- a/net/minecraft/server/level/ServerLevel.java
|
||||
+++ b/net/minecraft/server/level/ServerLevel.java
|
||||
@@ -1295,6 +1295,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 47ecc1ed0170e24b41b0a010307cc2bcab339a3a..06e919ddb07faa72721fd5660895abb3ad749dee 100644
|
||||
--- a/net/minecraft/world/entity/Entity.java
|
||||
+++ b/net/minecraft/world/entity/Entity.java
|
||||
@@ -581,6 +581,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.x() - this.position.x(), 2);
|
||||
+ double z = Math.pow(this.origin.z() - 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;
|
||||
@@ -610,6 +623,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) {
|
||||
Reference in New Issue
Block a user