diff --git a/patches/server/0071-Replace-shape-full-block-cache-with-hashtable.patch b/patches/server/0071-Replace-shape-full-block-cache-with-hashtable.patch new file mode 100644 index 0000000..c1f7be8 --- /dev/null +++ b/patches/server/0071-Replace-shape-full-block-cache-with-hashtable.patch @@ -0,0 +1,122 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: MartijnMuijsers +Date: Thu, 1 Dec 2022 14:11:53 +0100 +Subject: [PATCH] Replace shape full block cache with hashtable + +License: LGPL-3.0 (https://www.gnu.org/licenses/lgpl-3.0.html) + +This patch is based on the following mixins and classes: +* "me/jellysquid/mods/lithium/common/util/collections/Object2BooleanCacheTable.java" +* "me/jellysquid/mods/lithium/mixin/shapes/blockstate_cache/BlockMixin.java" +By: Gegy +As part of: Lithium (https://github.com/CaffeineMC/lithium-fabric) +Licensed under: LGPL-3.0 (https://www.gnu.org/licenses/lgpl-3.0.html) + +diff --git a/src/main/java/me/jellysquid/mods/lithium/common/util/collections/Object2BooleanCacheTable.java b/src/main/java/me/jellysquid/mods/lithium/common/util/collections/Object2BooleanCacheTable.java +new file mode 100644 +index 0000000000000000000000000000000000000000..48c32b224095f606669a38f0e200505aff9486c1 +--- /dev/null ++++ b/src/main/java/me/jellysquid/mods/lithium/common/util/collections/Object2BooleanCacheTable.java +@@ -0,0 +1,62 @@ ++// Gale - Lithium - replace shape full block cache with hashtable - cache table utility ++ ++package me.jellysquid.mods.lithium.common.util.collections; ++ ++import it.unimi.dsi.fastutil.HashCommon; ++import net.minecraft.util.Mth; ++ ++import java.util.function.Predicate; ++ ++/** ++ * A lossy hashtable implementation that stores a mapping between an object and a boolean. ++ *

++ * Any hash collisions will result in an overwrite: this is safe because the correct value can always be recomputed, ++ * given that the given operator is deterministic. ++ *

++ * This implementation is safe to use from multiple threads ++ */ ++public final class Object2BooleanCacheTable { ++ ++ private final int mask; ++ private final Node[] nodes; ++ private final Predicate operator; ++ ++ @SuppressWarnings("unchecked") ++ public Object2BooleanCacheTable(int capacity, Predicate operator) { ++ int capacity1 = Mth.smallestEncompassingPowerOfTwo(capacity); ++ this.mask = capacity1 - 1; ++ this.nodes = (Node[]) new Node[capacity1]; ++ this.operator = operator; ++ } ++ ++ private static int hash(T key) { ++ return HashCommon.mix(key.hashCode()); ++ } ++ ++ public boolean get(T key) { ++ int idx = hash(key) & this.mask; ++ ++ Node node = this.nodes[idx]; ++ if (node != null && key.equals(node.key)) { ++ return node.value; ++ } ++ ++ boolean test = this.operator.test(key); ++ this.nodes[idx] = new Node<>(key, test); ++ ++ return test; ++ } ++ ++ static class Node { ++ ++ final T key; ++ final boolean value; ++ ++ Node(T key, boolean value) { ++ this.key = key; ++ this.value = value; ++ } ++ ++ } ++ ++} +diff --git a/src/main/java/net/minecraft/world/level/block/Block.java b/src/main/java/net/minecraft/world/level/block/Block.java +index 2e65b44f10aeb44fd524a58e7eb815a566c1ad61..ee13a217a72a41d103789b66eef70bf351d1e624 100644 +--- a/src/main/java/net/minecraft/world/level/block/Block.java ++++ b/src/main/java/net/minecraft/world/level/block/Block.java +@@ -11,6 +11,8 @@ import java.util.List; + import java.util.function.Function; + import java.util.function.Supplier; + import javax.annotation.Nullable; ++ ++import me.jellysquid.mods.lithium.common.util.collections.Object2BooleanCacheTable; + import net.minecraft.SharedConstants; + import net.minecraft.Util; + import net.minecraft.core.BlockPos; +@@ -70,11 +72,12 @@ public class Block extends BlockBehaviour implements ItemLike { + private static final Logger LOGGER = LogUtils.getLogger(); + private final Holder.Reference builtInRegistryHolder; + public static final IdMapper BLOCK_STATE_REGISTRY = new IdMapper<>(); +- private static final LoadingCache SHAPE_FULL_BLOCK_CACHE = CacheBuilder.newBuilder().maximumSize(512L).weakKeys().build(new CacheLoader() { +- public Boolean load(VoxelShape voxelshape) { +- return !Shapes.joinIsNotEmpty(Shapes.block(), voxelshape, BooleanOp.NOT_SAME); +- } +- }); ++ // Gale start - Lithium - replace shape full block cache with hashtable ++ private static final Object2BooleanCacheTable SHAPE_FULL_BLOCK_CACHE = new Object2BooleanCacheTable<>( ++ 1536, ++ shape -> !Shapes.joinIsNotEmpty(Shapes.block(), shape, BooleanOp.NOT_SAME) ++ ); ++ // Gale end - Lithium - replace shape full block cache with hashtable + public static final int UPDATE_NEIGHBORS = 1; + public static final int UPDATE_CLIENTS = 2; + public static final int UPDATE_INVISIBLE = 4; +@@ -281,7 +284,7 @@ public class Block extends BlockBehaviour implements ItemLike { + } + + public static boolean isShapeFullBlock(VoxelShape shape) { +- return (Boolean) Block.SHAPE_FULL_BLOCK_CACHE.getUnchecked(shape); ++ return Block.SHAPE_FULL_BLOCK_CACHE.get(shape); // Gale - Lithium - replace shape full block cache with hashtable + } + + public boolean propagatesSkylightDown(BlockState state, BlockGetter world, BlockPos pos) { diff --git a/patches/server/0071-Avoid-Class-isAssignableFrom-call-in-ClassInstanceMu.patch b/patches/server/0072-Avoid-Class-isAssignableFrom-call-in-ClassInstanceMu.patch similarity index 100% rename from patches/server/0071-Avoid-Class-isAssignableFrom-call-in-ClassInstanceMu.patch rename to patches/server/0072-Avoid-Class-isAssignableFrom-call-in-ClassInstanceMu.patch diff --git a/patches/server/0072-Cache-BlockStatePairKey-hash.patch b/patches/server/0073-Cache-BlockStatePairKey-hash.patch similarity index 89% rename from patches/server/0072-Cache-BlockStatePairKey-hash.patch rename to patches/server/0073-Cache-BlockStatePairKey-hash.patch index 7ee20d5..1703992 100644 --- a/patches/server/0072-Cache-BlockStatePairKey-hash.patch +++ b/patches/server/0073-Cache-BlockStatePairKey-hash.patch @@ -12,10 +12,10 @@ As part of: Lithium (https://github.com/CaffeineMC/lithium-fabric) Licensed under: LGPL-3.0 (https://www.gnu.org/licenses/lgpl-3.0.html) diff --git a/src/main/java/net/minecraft/world/level/block/Block.java b/src/main/java/net/minecraft/world/level/block/Block.java -index 2e65b44f10aeb44fd524a58e7eb815a566c1ad61..f8fe7b5ae8ef93902c7bb80dddacf790ee56a698 100644 +index ee13a217a72a41d103789b66eef70bf351d1e624..3bb3dd974a74c58dd115f6f1d69e48dc8f6d700c 100644 --- a/src/main/java/net/minecraft/world/level/block/Block.java +++ b/src/main/java/net/minecraft/world/level/block/Block.java -@@ -612,11 +612,18 @@ public class Block extends BlockBehaviour implements ItemLike { +@@ -615,11 +615,18 @@ public class Block extends BlockBehaviour implements ItemLike { private final BlockState first; private final BlockState second; private final Direction direction; @@ -34,7 +34,7 @@ index 2e65b44f10aeb44fd524a58e7eb815a566c1ad61..f8fe7b5ae8ef93902c7bb80dddacf790 } public boolean equals(Object object) { -@@ -632,11 +639,7 @@ public class Block extends BlockBehaviour implements ItemLike { +@@ -635,11 +642,7 @@ public class Block extends BlockBehaviour implements ItemLike { } public int hashCode() { diff --git a/patches/server/0073-Cache-CubeVoxelShape-shape-array.patch b/patches/server/0074-Cache-CubeVoxelShape-shape-array.patch similarity index 100% rename from patches/server/0073-Cache-CubeVoxelShape-shape-array.patch rename to patches/server/0074-Cache-CubeVoxelShape-shape-array.patch diff --git a/patches/server/0074-Replace-division-by-multiplication-in-CubePointRange.patch b/patches/server/0075-Replace-division-by-multiplication-in-CubePointRange.patch similarity index 100% rename from patches/server/0074-Replace-division-by-multiplication-in-CubePointRange.patch rename to patches/server/0075-Replace-division-by-multiplication-in-CubePointRange.patch diff --git a/patches/server/0075-Replace-parts-by-size-in-CubePointRange.patch b/patches/server/0076-Replace-parts-by-size-in-CubePointRange.patch similarity index 100% rename from patches/server/0075-Replace-parts-by-size-in-CubePointRange.patch rename to patches/server/0076-Replace-parts-by-size-in-CubePointRange.patch diff --git a/patches/server/0076-Check-frozen-ticks-before-landing-block.patch b/patches/server/0077-Check-frozen-ticks-before-landing-block.patch similarity index 100% rename from patches/server/0076-Check-frozen-ticks-before-landing-block.patch rename to patches/server/0077-Check-frozen-ticks-before-landing-block.patch diff --git a/patches/server/0077-Faster-chunk-serialization.patch b/patches/server/0078-Faster-chunk-serialization.patch similarity index 100% rename from patches/server/0077-Faster-chunk-serialization.patch rename to patches/server/0078-Faster-chunk-serialization.patch diff --git a/patches/server/0078-Update-boss-bar-within-tick.patch b/patches/server/0079-Update-boss-bar-within-tick.patch similarity index 100% rename from patches/server/0078-Update-boss-bar-within-tick.patch rename to patches/server/0079-Update-boss-bar-within-tick.patch diff --git a/patches/server/0079-Cache-ominous-banner-item.patch b/patches/server/0080-Cache-ominous-banner-item.patch similarity index 100% rename from patches/server/0079-Cache-ominous-banner-item.patch rename to patches/server/0080-Cache-ominous-banner-item.patch diff --git a/patches/server/0080-Precompute-piston-shapes.patch b/patches/server/0081-Precompute-piston-shapes.patch similarity index 100% rename from patches/server/0080-Precompute-piston-shapes.patch rename to patches/server/0081-Precompute-piston-shapes.patch diff --git a/patches/server/0081-Skip-entity-move-if-movement-is-zero.patch b/patches/server/0082-Skip-entity-move-if-movement-is-zero.patch similarity index 100% rename from patches/server/0081-Skip-entity-move-if-movement-is-zero.patch rename to patches/server/0082-Skip-entity-move-if-movement-is-zero.patch diff --git a/patches/server/0082-Store-mob-counts-in-an-array.patch b/patches/server/0083-Store-mob-counts-in-an-array.patch similarity index 100% rename from patches/server/0082-Store-mob-counts-in-an-array.patch rename to patches/server/0083-Store-mob-counts-in-an-array.patch diff --git a/patches/server/0083-Optimize-noise-generation.patch b/patches/server/0084-Optimize-noise-generation.patch similarity index 100% rename from patches/server/0083-Optimize-noise-generation.patch rename to patches/server/0084-Optimize-noise-generation.patch diff --git a/patches/server/0084-Ignore-durability-change-equipment-updates.patch b/patches/server/0085-Ignore-durability-change-equipment-updates.patch similarity index 100% rename from patches/server/0084-Ignore-durability-change-equipment-updates.patch rename to patches/server/0085-Ignore-durability-change-equipment-updates.patch diff --git a/patches/server/0085-Hide-flames-on-entities-with-fire-resistance.patch b/patches/server/0086-Hide-flames-on-entities-with-fire-resistance.patch similarity index 100% rename from patches/server/0085-Hide-flames-on-entities-with-fire-resistance.patch rename to patches/server/0086-Hide-flames-on-entities-with-fire-resistance.patch diff --git a/patches/server/0086-Skip-cloning-advancement-criteria.patch b/patches/server/0087-Skip-cloning-advancement-criteria.patch similarity index 100% rename from patches/server/0086-Skip-cloning-advancement-criteria.patch rename to patches/server/0087-Skip-cloning-advancement-criteria.patch diff --git a/patches/server/0087-Player-canSee-by-entity-UUID.patch b/patches/server/0088-Player-canSee-by-entity-UUID.patch similarity index 100% rename from patches/server/0087-Player-canSee-by-entity-UUID.patch rename to patches/server/0088-Player-canSee-by-entity-UUID.patch diff --git a/patches/server/0088-Spread-out-sending-all-player-info.patch b/patches/server/0089-Spread-out-sending-all-player-info.patch similarity index 100% rename from patches/server/0088-Spread-out-sending-all-player-info.patch rename to patches/server/0089-Spread-out-sending-all-player-info.patch diff --git a/patches/server/0089-Optimize-player-list-for-sending-player-info.patch b/patches/server/0090-Optimize-player-list-for-sending-player-info.patch similarity index 100% rename from patches/server/0089-Optimize-player-list-for-sending-player-info.patch rename to patches/server/0090-Optimize-player-list-for-sending-player-info.patch diff --git a/patches/server/0090-Skip-PlayerCommandSendEvent-if-there-are-no-listener.patch b/patches/server/0091-Skip-PlayerCommandSendEvent-if-there-are-no-listener.patch similarity index 100% rename from patches/server/0090-Skip-PlayerCommandSendEvent-if-there-are-no-listener.patch rename to patches/server/0091-Skip-PlayerCommandSendEvent-if-there-are-no-listener.patch diff --git a/patches/server/0091-Send-multiple-keep-alive-packets.patch b/patches/server/0092-Send-multiple-keep-alive-packets.patch similarity index 100% rename from patches/server/0091-Send-multiple-keep-alive-packets.patch rename to patches/server/0092-Send-multiple-keep-alive-packets.patch diff --git a/patches/server/0092-Prevent-entities-random-strolling-into-non-ticking-c.patch b/patches/server/0093-Prevent-entities-random-strolling-into-non-ticking-c.patch similarity index 100% rename from patches/server/0092-Prevent-entities-random-strolling-into-non-ticking-c.patch rename to patches/server/0093-Prevent-entities-random-strolling-into-non-ticking-c.patch diff --git a/patches/server/0093-Specific-interval-TPS-API.patch b/patches/server/0094-Specific-interval-TPS-API.patch similarity index 100% rename from patches/server/0093-Specific-interval-TPS-API.patch rename to patches/server/0094-Specific-interval-TPS-API.patch diff --git a/patches/server/0094-5-second-TPS-average.patch b/patches/server/0095-5-second-TPS-average.patch similarity index 100% rename from patches/server/0094-5-second-TPS-average.patch rename to patches/server/0095-5-second-TPS-average.patch diff --git a/patches/server/0095-Measure-last-tick-time.patch b/patches/server/0096-Measure-last-tick-time.patch similarity index 100% rename from patches/server/0095-Measure-last-tick-time.patch rename to patches/server/0096-Measure-last-tick-time.patch diff --git a/patches/server/0096-Last-tick-time-API.patch b/patches/server/0097-Last-tick-time-API.patch similarity index 100% rename from patches/server/0096-Last-tick-time-API.patch rename to patches/server/0097-Last-tick-time-API.patch diff --git a/patches/server/0097-Show-last-tick-time-in-tps-command.patch b/patches/server/0098-Show-last-tick-time-in-tps-command.patch similarity index 100% rename from patches/server/0097-Show-last-tick-time-in-tps-command.patch rename to patches/server/0098-Show-last-tick-time-in-tps-command.patch diff --git a/patches/server/0098-Increase-time-statistics-in-intervals.patch b/patches/server/0099-Increase-time-statistics-in-intervals.patch similarity index 100% rename from patches/server/0098-Increase-time-statistics-in-intervals.patch rename to patches/server/0099-Increase-time-statistics-in-intervals.patch diff --git a/patches/server/0099-For-collision-check-has-physics-before-same-vehicle.patch b/patches/server/0100-For-collision-check-has-physics-before-same-vehicle.patch similarity index 100% rename from patches/server/0099-For-collision-check-has-physics-before-same-vehicle.patch rename to patches/server/0100-For-collision-check-has-physics-before-same-vehicle.patch diff --git a/patches/server/0100-Skip-negligible-planar-movement-multiplication.patch b/patches/server/0101-Skip-negligible-planar-movement-multiplication.patch similarity index 100% rename from patches/server/0100-Skip-negligible-planar-movement-multiplication.patch rename to patches/server/0101-Skip-negligible-planar-movement-multiplication.patch diff --git a/patches/server/0101-Variable-main-thread-task-delay.patch b/patches/server/0102-Variable-main-thread-task-delay.patch similarity index 100% rename from patches/server/0101-Variable-main-thread-task-delay.patch rename to patches/server/0102-Variable-main-thread-task-delay.patch diff --git a/patches/server/0102-Reduce-RandomSource-instances.patch b/patches/server/0103-Reduce-RandomSource-instances.patch similarity index 100% rename from patches/server/0102-Reduce-RandomSource-instances.patch rename to patches/server/0103-Reduce-RandomSource-instances.patch diff --git a/patches/server/0103-CPU-cores-estimation.patch b/patches/server/0104-CPU-cores-estimation.patch similarity index 100% rename from patches/server/0103-CPU-cores-estimation.patch rename to patches/server/0104-CPU-cores-estimation.patch diff --git a/patches/server/0104-Add-centralized-AsyncExecutor.patch b/patches/server/0105-Add-centralized-AsyncExecutor.patch similarity index 100% rename from patches/server/0104-Add-centralized-AsyncExecutor.patch rename to patches/server/0105-Add-centralized-AsyncExecutor.patch diff --git a/patches/server/0105-Remove-Paper-async-executor.patch b/patches/server/0106-Remove-Paper-async-executor.patch similarity index 100% rename from patches/server/0105-Remove-Paper-async-executor.patch rename to patches/server/0106-Remove-Paper-async-executor.patch diff --git a/patches/server/0106-Remove-Paper-cleaner-executor.patch b/patches/server/0107-Remove-Paper-cleaner-executor.patch similarity index 100% rename from patches/server/0106-Remove-Paper-cleaner-executor.patch rename to patches/server/0107-Remove-Paper-cleaner-executor.patch diff --git a/patches/server/0107-Remove-background-executor.patch b/patches/server/0108-Remove-background-executor.patch similarity index 100% rename from patches/server/0107-Remove-background-executor.patch rename to patches/server/0108-Remove-background-executor.patch diff --git a/patches/server/0108-Remove-bootstrap-executor.patch b/patches/server/0109-Remove-bootstrap-executor.patch similarity index 100% rename from patches/server/0108-Remove-bootstrap-executor.patch rename to patches/server/0109-Remove-bootstrap-executor.patch diff --git a/patches/server/0109-Remove-world-upgrade-executors.patch b/patches/server/0110-Remove-world-upgrade-executors.patch similarity index 100% rename from patches/server/0109-Remove-world-upgrade-executors.patch rename to patches/server/0110-Remove-world-upgrade-executors.patch diff --git a/patches/server/0110-Remove-tab-complete-executor.patch b/patches/server/0111-Remove-tab-complete-executor.patch similarity index 100% rename from patches/server/0110-Remove-tab-complete-executor.patch rename to patches/server/0111-Remove-tab-complete-executor.patch diff --git a/patches/server/0111-Remove-text-filter-executor.patch b/patches/server/0112-Remove-text-filter-executor.patch similarity index 100% rename from patches/server/0111-Remove-text-filter-executor.patch rename to patches/server/0112-Remove-text-filter-executor.patch