Archiviert
13
0
Dieses Repository wurde am 2021-12-14 archiviert. Du kannst Dateien ansehen und es klonen, aber nicht pushen oder Issues/Pull-Requests öffnen.
SteamSpigot/Paper/SteamWar-Patches/0564-Optimize-EntityActivation-for-multiple-players-on-on.patch

83 Zeilen
4.7 KiB
Diff

2021-04-14 17:34:29 +02:00
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Zeanon <thezeanon@gmail.com>
Date: Wed, 14 Apr 2021 16:34:39 +0200
Subject: [PATCH] Optimize EntityActivation for multiple players on one spot
paper
diff --git a/src/main/java/org/spigotmc/ActivationRange.java b/src/main/java/org/spigotmc/ActivationRange.java
2021-04-14 17:34:29 +02:00
index f735217e7a99bf8286ea60158f9fe137e84ad75c..e92a237b841b70ed274352e6dc9bfc2671ae538e 100644
--- a/src/main/java/org/spigotmc/ActivationRange.java
+++ b/src/main/java/org/spigotmc/ActivationRange.java
@@ -1,5 +1,6 @@
package org.spigotmc;
+import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
2021-04-12 19:54:42 +02:00
2021-04-14 17:34:29 +02:00
@@ -203,34 +204,41 @@ public class ActivationRange
2021-04-12 19:54:42 +02:00
// Paper end
maxRange = Math.min( ( ((net.minecraft.server.WorldServer)world).getChunkProvider().playerChunkMap.getEffectiveViewDistance() << 4 ) - 8, maxRange ); // Paper - no-tick view distance
- for ( EntityHuman player : world.getPlayers() )
- {
2021-04-12 19:54:42 +02:00
+ //Steamwar Start
+ List<AxisAlignedBB> boundingBoxes = new ArrayList<>();
+ int i = Integer.MAX_VALUE;
+ int j = Integer.MIN_VALUE;
+ int k = Integer.MAX_VALUE;
+ int l = Integer.MIN_VALUE;
+ for ( EntityHuman player : world.getPlayers() ) {
player.activatedTick = MinecraftServer.currentTick;
- maxBB = player.getBoundingBox().grow( maxRange, 256, maxRange );
- ActivationType.MISC.boundingBox = player.getBoundingBox().grow( miscActivationRange, 256, miscActivationRange );
- ActivationType.RAIDER.boundingBox = player.getBoundingBox().grow( raiderActivationRange, 256, raiderActivationRange );
- ActivationType.ANIMAL.boundingBox = player.getBoundingBox().grow( animalActivationRange, 256, animalActivationRange );
- ActivationType.MONSTER.boundingBox = player.getBoundingBox().grow( monsterActivationRange, 256, monsterActivationRange );
+ maxBB = player.getBoundingBox().grow(maxRange, 256, maxRange);
+ ActivationType.MISC.boundingBox = player.getBoundingBox().grow(miscActivationRange, 256, miscActivationRange);
+ ActivationType.RAIDER.boundingBox = player.getBoundingBox().grow(raiderActivationRange, 256, raiderActivationRange);
+ ActivationType.ANIMAL.boundingBox = player.getBoundingBox().grow(animalActivationRange, 256, animalActivationRange);
+ ActivationType.MONSTER.boundingBox = player.getBoundingBox().grow(monsterActivationRange, 256, monsterActivationRange);
2021-04-12 19:54:42 +02:00
// Paper start
- ActivationType.WATER.boundingBox = player.getBoundingBox().grow( waterActivationRange, 256, waterActivationRange );
- ActivationType.FLYING_MONSTER.boundingBox = player.getBoundingBox().grow( flyingActivationRange, 256, flyingActivationRange );
- ActivationType.VILLAGER.boundingBox = player.getBoundingBox().grow( villagerActivationRange, 256, waterActivationRange );
+ ActivationType.WATER.boundingBox = player.getBoundingBox().grow(waterActivationRange, 256, waterActivationRange);
+ ActivationType.FLYING_MONSTER.boundingBox = player.getBoundingBox().grow(flyingActivationRange, 256, flyingActivationRange);
+ ActivationType.VILLAGER.boundingBox = player.getBoundingBox().grow(villagerActivationRange, 256, waterActivationRange);
// Paper end
- int i = MathHelper.floor( maxBB.minX / 16.0D );
- int j = MathHelper.floor( maxBB.maxX / 16.0D );
- int k = MathHelper.floor( maxBB.minZ / 16.0D );
- int l = MathHelper.floor( maxBB.maxZ / 16.0D );
+ boundingBoxes.add(maxBB);
2021-04-12 19:54:42 +02:00
+ i = MathHelper.floor(maxBB.minX / 16.0D);
+ j = MathHelper.floor(maxBB.maxX / 16.0D);
+ k = MathHelper.floor(maxBB.minZ / 16.0D);
+ l = MathHelper.floor(maxBB.maxZ / 16.0D);
+ }
- for ( int i1 = i; i1 <= j; ++i1 )
- {
- for ( int j1 = k; j1 <= l; ++j1 )
- {
2021-04-12 19:54:42 +02:00
- Chunk chunk = chunkProvider.getChunkAtIfLoadedMainThreadNoCache( i1, j1 ); // Paper
- if ( chunk != null )
- {
2021-04-12 19:54:42 +02:00
- activateChunkEntities( chunk );
+ for ( int i1 = i; i1 <= j; ++i1 ) {
+ for (int j1 = k; j1 <= l; ++j1) {
+ for (AxisAlignedBB bb : boundingBoxes) {
+ if (bb.minX <= i1 && bb.maxX >= i1 && bb.minZ <= j1 && bb.maxZ >= j1) {
+ Chunk chunk = world.getChunkProvider().getChunkAt(i1, j1, false);
2021-04-12 19:54:42 +02:00
+ if (chunk != null)
+ activateChunkEntities(chunk);
+ break;
}
}
}