diff options
Diffstat (limited to 'patches/server/0578-Optimize-Biome-Mob-Lookups-for-Mob-Spawning.patch')
-rw-r--r-- | patches/server/0578-Optimize-Biome-Mob-Lookups-for-Mob-Spawning.patch | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/patches/server/0578-Optimize-Biome-Mob-Lookups-for-Mob-Spawning.patch b/patches/server/0578-Optimize-Biome-Mob-Lookups-for-Mob-Spawning.patch index 53a98e7fb8..efeca7582b 100644 --- a/patches/server/0578-Optimize-Biome-Mob-Lookups-for-Mob-Spawning.patch +++ b/patches/server/0578-Optimize-Biome-Mob-Lookups-for-Mob-Spawning.patch @@ -6,14 +6,13 @@ Subject: [PATCH] Optimize Biome Mob Lookups for Mob Spawning Uses an EnumMap as well as a Set paired List for O(1) contains calls. diff --git a/src/main/java/net/minecraft/world/level/biome/MobSpawnSettings.java b/src/main/java/net/minecraft/world/level/biome/MobSpawnSettings.java -index 4f4ef3349f512cc6e1588eb58de5b2558c0bd8b9..b10dfbaef9bde9d94c4971b47d77a1514e476f86 100644 +index c376a6cc04faf8d8545c99c0815682ea7cad98db..ffa24b71400f2041c9154817c6c767bc7dffb176 100644 --- a/src/main/java/net/minecraft/world/level/biome/MobSpawnSettings.java +++ b/src/main/java/net/minecraft/world/level/biome/MobSpawnSettings.java -@@ -61,11 +61,43 @@ public class MobSpawnSettings { +@@ -75,8 +75,40 @@ public class MobSpawnSettings { } public static class Builder { -- private final Map<MobCategory, List<MobSpawnSettings.SpawnerData>> spawners = Stream.of(MobCategory.values()).collect(ImmutableMap.toImmutableMap((mobCategory) -> { + // Paper start - Perf: keep track of data in a pair set to give O(1) contains calls - we have to hook removals incase plugins mess with it + public static class MobList extends java.util.ArrayList<MobSpawnSettings.SpawnerData> { + java.util.Set<MobSpawnSettings.SpawnerData> biomes = new java.util.HashSet<>(); @@ -45,12 +44,9 @@ index 4f4ef3349f512cc6e1588eb58de5b2558c0bd8b9..b10dfbaef9bde9d94c4971b47d77a151 + } + } + // use toImmutableEnumMap collector -+ private final Map<MobCategory, List<MobSpawnSettings.SpawnerData>> spawners = (Map) Stream.of(MobCategory.values()).collect(Maps.toImmutableEnumMap((mobCategory) -> { - return mobCategory; - }, (mobCategory) -> { -- return Lists.newArrayList(); -+ return new MobList(); // Use MobList instead of ArrayList - })); + private final Map<MobCategory, List<MobSpawnSettings.SpawnerData>> spawners = Stream.of(MobCategory.values()) +- .collect(ImmutableMap.toImmutableMap(mobCategory -> (MobCategory)mobCategory, mobCategory -> Lists.newArrayList())); ++ .collect(Maps.toImmutableEnumMap(mobCategory -> (MobCategory)mobCategory, mobCategory -> new MobList())); // Use MobList instead of ArrayList + // Paper end - Perf: keep track of data in a pair set to give O(1) contains calls private final Map<EntityType<?>, MobSpawnSettings.MobSpawnCost> mobSpawnCosts = Maps.newLinkedHashMap(); private float creatureGenerationProbability = 0.1F; |