9
0
mirror of https://github.com/Winds-Studio/Leaf.git synced 2025-12-22 16:39:22 +00:00
Files
Leaf/patches/removed/server/0084-Tracking-Optimize-reduce-ArmorStand.patch
2024-08-09 20:38:06 +08:00

80 lines
4.3 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Dreeam <61569423+Dreeam-qwq@users.noreply.github.com>
Date: Thu, 23 May 2024 23:03:10 +0800
Subject: [PATCH] Tracking Optimize: reduce ArmorStand
Removed since 1.21, not good, useless
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
index dced0a22e924838b13edd0c24a7d3fb3de9242d6..05d94bdc6f9c8baafa392fa3e8f2221df999277c 100644
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
@@ -1437,7 +1437,7 @@ public class ServerLevel extends Level implements WorldGenLevel {
return;
}*/ // Paper - comment out EAR 2
// Spigot end
- final boolean isActive = org.spigotmc.ActivationRange.checkIfActive(entity);
+ boolean isActive = shouldActive(entity); // Leaf - Reduce entity tick
entity.setOldPosAndRot();
++entity.tickCount;
@@ -1465,7 +1465,7 @@ public class ServerLevel extends Level implements WorldGenLevel {
if (!passenger.isRemoved() && passenger.getVehicle() == vehicle) {
if (passenger instanceof Player || this.entityTickList.contains(passenger)) {
// Paper - EAR 2
- final boolean isActive = org.spigotmc.ActivationRange.checkIfActive(passenger);
+ final boolean isActive = shouldActive(passenger); // Leaf - Reduce entity tick
passenger.setOldPosAndRot();
++passenger.tickCount;
// Paper start - EAR 2
@@ -1492,6 +1492,12 @@ public class ServerLevel extends Level implements WorldGenLevel {
}
}
+ // Leaf start - Reduce entity tick
+ private boolean shouldActive(Entity entity) {
+ return entity instanceof net.minecraft.world.entity.decoration.ArmorStand ? entity.level().paperConfig().entities.armorStands.tick : org.spigotmc.ActivationRange.checkIfActive(entity);
+ }
+ // Leaf end - Reduce entity tick
+
@Override
public boolean mayInteract(Player player, BlockPos pos) {
return !this.server.isUnderSpawnProtection(this, pos, player) && this.getWorldBorder().isWithinBounds(pos);
diff --git a/src/main/java/org/spigotmc/ActivationRange.java b/src/main/java/org/spigotmc/ActivationRange.java
index 37e35606e3f47325db4da5deeff02aad9d541e87..b3fa485dbf96a5b691f423d004bbe0ff7bde4f9a 100644
--- a/src/main/java/org/spigotmc/ActivationRange.java
+++ b/src/main/java/org/spigotmc/ActivationRange.java
@@ -147,6 +147,13 @@ public class ActivationRange
*/
public static boolean initializeEntityActivationState(Entity entity, SpigotWorldConfig config)
{
+ // Leaf start - Reduce ArmorStand tick
+ if (entity instanceof net.minecraft.world.entity.decoration.ArmorStand
+ && !entity.level().paperConfig().entities.armorStands.tick) {
+ return false;
+ }
+ // Leaf end - Reduce ArmorStand tick
+
if ( ( entity.activationType == ActivationType.MISC && config.miscActivationRange <= 0 )
|| ( entity.activationType == ActivationType.RAIDER && config.raiderActivationRange <= 0 )
|| ( entity.activationType == ActivationType.ANIMAL && config.animalActivationRange <= 0 )
@@ -233,12 +240,18 @@ public class ActivationRange
// Paper start
java.util.List<Entity> entities = world.getEntities((Entity)null, ActivationRange.maxBB, null);
boolean tickMarkers = world.paperConfig().entities.markers.tick; // Paper - Configurable marker ticking
+ boolean tickArmorStands = world.paperConfig().entities.armorStands.tick; // Leaf - Reduce entity tick
for (Entity entity : entities) {
// Paper start - Configurable marker ticking
if (!tickMarkers && entity instanceof net.minecraft.world.entity.Marker) {
continue;
}
// Paper end - Configurable marker ticking
+ // Leaf start - Reduce entity tick
+ if (!tickArmorStands && entity instanceof net.minecraft.world.entity.decoration.ArmorStand) {
+ continue;
+ }
+ // Leaf end - Reduce entity tick
ActivationRange.activateEntity(entity);
// Pufferfish start