mirror of
https://github.com/Winds-Studio/Leaf.git
synced 2025-12-19 15:09:25 +00:00
optimize chunk map (#438)
* rebase * optimize LivingEntity#travel * cleanup * Replace fluid height map * reuse array list in Entity#collide * cleanup * fix fire and liquid collision shape * fix checkInside * inline betweenClosed * cleanup * optimize getOnPos * optimize equals in getOnPos * update mainSupportingBlockPos on dirty * cleanup * rename * merge same patch * rebase and remove properly * [ci skip] cleanup * rebase and rebuild * fix async locator * remove async locator * cleanup * rebase --------- Co-authored-by: Taiyou06 <kaandindar21@gmail.com>
This commit is contained in:
@@ -3,6 +3,7 @@ From: Taiyou06 <kaandindar21@gmail.com>
|
||||
Date: Sat, 8 Feb 2025 05:32:30 +0100
|
||||
Subject: [PATCH] Cache supporting block check
|
||||
|
||||
Removed since 1.21.8
|
||||
|
||||
diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java
|
||||
index e563b636a05a299d860a334987594dbd5c7d3511..428b2114749780770cc617d5e1aedea7f1b28b2d 100644
|
||||
|
||||
@@ -12,7 +12,7 @@ As part of: Lithium (https://github.com/CaffeineMC/lithium)
|
||||
Licensed under: LGPL-3.0 (https://www.gnu.org/licenses/lgpl-3.0.html)
|
||||
|
||||
diff --git a/net/minecraft/world/entity/LivingEntity.java b/net/minecraft/world/entity/LivingEntity.java
|
||||
index de4d13e7c6f57d6cc3a78b1b9ca914157820186c..32f754a4c1d7a91bbbbf4995559ac2858ef10e1c 100644
|
||||
index 4f0b903945860e518ebf3c858722f28df9394b3d..0a253607733d7f31d0264931b20676c62a289e15 100644
|
||||
--- a/net/minecraft/world/entity/LivingEntity.java
|
||||
+++ b/net/minecraft/world/entity/LivingEntity.java
|
||||
@@ -2825,6 +2825,7 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin
|
||||
@@ -173,16 +173,3 @@ index 0376a10ee0544b13e8fd629a7b13f78811e57a30..aa6b900347635857b84460fa8435b81f
|
||||
// Paper end - Anti-Xray
|
||||
// Paper start - PlayerChunkLoadEvent
|
||||
if (io.papermc.paper.event.packet.PlayerChunkLoadEvent.getHandlerList().getRegisteredListeners().length > 0) {
|
||||
diff --git a/net/minecraft/world/level/chunk/LevelChunkSection.java b/net/minecraft/world/level/chunk/LevelChunkSection.java
|
||||
index df717c545472006b99532280c38c1fbef12bcf82..7689e005a7de17fa0411a346f595f40b06bb5ca4 100644
|
||||
--- a/net/minecraft/world/level/chunk/LevelChunkSection.java
|
||||
+++ b/net/minecraft/world/level/chunk/LevelChunkSection.java
|
||||
@@ -18,7 +18,7 @@ public class LevelChunkSection implements ca.spottedleaf.moonrise.patches.block_
|
||||
public static final int SECTION_HEIGHT = 16;
|
||||
public static final int SECTION_SIZE = 4096;
|
||||
public static final int BIOME_CONTAINER_BITS = 2;
|
||||
- short nonEmptyBlockCount; // Paper - package private
|
||||
+ volatile short nonEmptyBlockCount; // Paper - package private // Leaf - Async chunk sending - volatile
|
||||
private short tickingBlockCount;
|
||||
private short tickingFluidCount;
|
||||
public final PalettedContainer<BlockState> states;
|
||||
@@ -411,7 +411,7 @@ index 77f11179836636424927843f5f10c3fd23d2b2d4..9b8d119116b0c3a51d3fe2ff7efb33cc
|
||||
|
||||
// Gale start - Pufferfish - SIMD support
|
||||
diff --git a/net/minecraft/server/level/ServerChunkCache.java b/net/minecraft/server/level/ServerChunkCache.java
|
||||
index 8f41326fda8c5f9f6926038508be6c6529b051bc..f76da1dc0874493ce71fce19e02e68da5f3ff50d 100644
|
||||
index eaaa66c4d86d4ebda0acf8f1dbe8ecb55aa28285..3a6c894178829cec8daa08ea9f0294f7f39a8efe 100644
|
||||
--- a/net/minecraft/server/level/ServerChunkCache.java
|
||||
+++ b/net/minecraft/server/level/ServerChunkCache.java
|
||||
@@ -175,6 +175,7 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon
|
||||
@@ -159,7 +159,7 @@ index 4ca68a903e67606fc4ef0bfa9862a73797121c8b..bed3a64388bb43e47c2ba4e67f7dde5b
|
||||
|
||||
public static final class SaveState {
|
||||
diff --git a/net/minecraft/world/level/chunk/LevelChunkSection.java b/net/minecraft/world/level/chunk/LevelChunkSection.java
|
||||
index 7689e005a7de17fa0411a346f595f40b06bb5ca4..5c5d51d5341dac68f89253c5181e1a099c305fac 100644
|
||||
index df717c545472006b99532280c38c1fbef12bcf82..abb7c8b4ffc73cedd5e03597fe82c71e51161a1b 100644
|
||||
--- a/net/minecraft/world/level/chunk/LevelChunkSection.java
|
||||
+++ b/net/minecraft/world/level/chunk/LevelChunkSection.java
|
||||
@@ -23,6 +23,7 @@ public class LevelChunkSection implements ca.spottedleaf.moonrise.patches.block_
|
||||
@@ -4,80 +4,6 @@ Date: Sat, 17 May 2025 08:25:33 +0800
|
||||
Subject: [PATCH] Optimize isEyeInFluid
|
||||
|
||||
|
||||
diff --git a/net/minecraft/core/Holder.java b/net/minecraft/core/Holder.java
|
||||
index 6c7edbbf3935c40ccb78bee680ea75431718b9bd..fd2f79d976c9587b00380f8b8f784b32ca294673 100644
|
||||
--- a/net/minecraft/core/Holder.java
|
||||
+++ b/net/minecraft/core/Holder.java
|
||||
@@ -29,6 +29,8 @@ public interface Holder<T> {
|
||||
|
||||
Stream<TagKey<T>> tags();
|
||||
|
||||
+ TagKey<T>[] tagArray(); // Leaf - Optimize isEyeInFluid
|
||||
+
|
||||
Either<ResourceKey<T>, T> unwrap();
|
||||
|
||||
Optional<ResourceKey<T>> unwrapKey();
|
||||
@@ -105,6 +107,13 @@ public interface Holder<T> {
|
||||
public Stream<TagKey<T>> tags() {
|
||||
return Stream.of();
|
||||
}
|
||||
+
|
||||
+ // Leaf start - Optimize isEyeInFluid
|
||||
+ @Override
|
||||
+ public TagKey<T>[] tagArray() {
|
||||
+ return me.titaniumtown.ArrayConstants.emptyTagKeyArray;
|
||||
+ }
|
||||
+ // Leaf end - Optimize isEyeInFluid
|
||||
}
|
||||
|
||||
public static enum Kind {
|
||||
@@ -116,6 +125,7 @@ public interface Holder<T> {
|
||||
private final HolderOwner<T> owner;
|
||||
@Nullable
|
||||
private Set<TagKey<T>> tags;
|
||||
+ @Nullable private TagKey<T>[] tagArray; // Leaf - Optimize isEyeInFluid
|
||||
private final Holder.Reference.Type type;
|
||||
@Nullable
|
||||
private ResourceKey<T> key;
|
||||
@@ -173,6 +183,16 @@ public interface Holder<T> {
|
||||
}
|
||||
}
|
||||
|
||||
+ // Leaf start - Optimize isEyeInFluid
|
||||
+ private TagKey<T>[] boundTagArray() {
|
||||
+ if (this.tags == null || this.tagArray == null) {
|
||||
+ throw new IllegalStateException("Tags not bound");
|
||||
+ } else {
|
||||
+ return this.tagArray;
|
||||
+ }
|
||||
+ }
|
||||
+ // Leaf end - Optimize isEyeInFluid
|
||||
+
|
||||
@Override
|
||||
public boolean is(TagKey<T> tagKey) {
|
||||
return this.boundTags().contains(tagKey);
|
||||
@@ -231,6 +251,7 @@ public interface Holder<T> {
|
||||
|
||||
void bindTags(Collection<TagKey<T>> tags) {
|
||||
this.tags = it.unimi.dsi.fastutil.objects.ReferenceSets.unmodifiable(new it.unimi.dsi.fastutil.objects.ReferenceOpenHashSet<>(tags)); // Paper - use reference set because TagKey are interned
|
||||
+ this.tagArray = this.tags.toArray(new TagKey[0]); // Leaf - Optimize isEyeInFluid
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -238,6 +259,13 @@ public interface Holder<T> {
|
||||
return this.boundTags().stream();
|
||||
}
|
||||
|
||||
+ // Leaf start - Optimize isEyeInFluid
|
||||
+ @Override
|
||||
+ public TagKey<T>[] tagArray() {
|
||||
+ return this.boundTagArray();
|
||||
+ }
|
||||
+ // Leaf end - Optimize isEyeInFluid
|
||||
+
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Reference{" + this.key + "=" + this.value + "}";
|
||||
diff --git a/net/minecraft/server/level/ServerPlayer.java b/net/minecraft/server/level/ServerPlayer.java
|
||||
index f2ec8dafb133999bed21eb48b118ab5d382bc962..a26943a7c70ac8b8eb3be5cd1f9838e4fcc6e04e 100644
|
||||
--- a/net/minecraft/server/level/ServerPlayer.java
|
||||
@@ -92,7 +18,7 @@ index f2ec8dafb133999bed21eb48b118ab5d382bc962..a26943a7c70ac8b8eb3be5cd1f9838e4
|
||||
if (rounded > 0) {
|
||||
this.awardStat(Stats.WALK_UNDER_WATER_ONE_CM, rounded);
|
||||
diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java
|
||||
index b694c7c1837fd4facb16d6bcf93245da9d18a56d..2f9304c4fc7ac9f42493bc19748ee6c0f57208ee 100644
|
||||
index b694c7c1837fd4facb16d6bcf93245da9d18a56d..48c2aeee828c1b79d8d6c5f5fd88fae1ef4befc8 100644
|
||||
--- a/net/minecraft/world/entity/Entity.java
|
||||
+++ b/net/minecraft/world/entity/Entity.java
|
||||
@@ -288,7 +288,14 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
||||
@@ -122,19 +48,18 @@ index b694c7c1837fd4facb16d6bcf93245da9d18a56d..2f9304c4fc7ac9f42493bc19748ee6c0
|
||||
double eyeY = this.getEyeY();
|
||||
if (!(
|
||||
this.getVehicle() instanceof AbstractBoat abstractBoat
|
||||
@@ -2051,7 +2058,10 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
||||
@@ -2051,7 +2058,9 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
||||
FluidState fluidState = this.level().getFluidState(blockPos);
|
||||
double d = blockPos.getY() + fluidState.getHeight(this.level(), blockPos);
|
||||
if (d > eyeY) {
|
||||
- fluidState.getTags().forEach(this.fluidOnEyes::add);
|
||||
+ // Leaf start - Optimize isEyeInFluid
|
||||
+ TagKey<Fluid>[] tags = fluidState.getTagArray();
|
||||
+ this.isInWaterOrLava = tags.length == 0 ? 0 : tags[0] == FluidTags.WATER ? 1 : 2;
|
||||
+ this.isInWaterOrLava = fluidState.isEmpty() ? 0 : fluidState.is(FluidTags.WATER) ? 1 : 2;
|
||||
+ // Leaf end - Optimize isEyeInFluid
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2131,9 +2141,25 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
||||
@@ -2131,9 +2140,25 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
||||
}
|
||||
}
|
||||
|
||||
@@ -297,20 +222,3 @@ index d947801b616af5b5dcdcc8bb70b36f97d6a69fdd..678badf7622b81e94c973bed2082fbfa
|
||||
}
|
||||
|
||||
protected int getMaxPassengers() {
|
||||
diff --git a/net/minecraft/world/level/material/FluidState.java b/net/minecraft/world/level/material/FluidState.java
|
||||
index 0a5ae623a636923f3bbd3c01974497f39b7c4b62..cc6f2f756c407630aa4e99be329f643c9994af29 100644
|
||||
--- a/net/minecraft/world/level/material/FluidState.java
|
||||
+++ b/net/minecraft/world/level/material/FluidState.java
|
||||
@@ -167,6 +167,12 @@ public final class FluidState extends StateHolder<Fluid, FluidState> implements
|
||||
return this.owner.builtInRegistryHolder().tags();
|
||||
}
|
||||
|
||||
+ // Leaf start - Optimize isEyeInFluid
|
||||
+ public TagKey<Fluid>[] getTagArray() {
|
||||
+ return this.owner.builtInRegistryHolder().tagArray();
|
||||
+ }
|
||||
+ // Leaf end - Optimize isEyeInFluid
|
||||
+
|
||||
public void entityInside(Level level, BlockPos pos, Entity entity, InsideBlockEffectApplier effectApplier) {
|
||||
this.getType().entityInside(level, pos, entity, effectApplier);
|
||||
}
|
||||
@@ -26,7 +26,7 @@ index 5c369b3d94e369c3f240821ad90b9d96223f24ca..9803c395fce103cb7bc746f43a017ff9
|
||||
}
|
||||
// Paper end - Optional per player mob spawns
|
||||
diff --git a/net/minecraft/server/level/ServerChunkCache.java b/net/minecraft/server/level/ServerChunkCache.java
|
||||
index f76da1dc0874493ce71fce19e02e68da5f3ff50d..8b9d7129da577d7b613c0e21ee075e68edef7b12 100644
|
||||
index 3a6c894178829cec8daa08ea9f0294f7f39a8efe..8bf770fd490634787e794efec9f0d6a10d97e42f 100644
|
||||
--- a/net/minecraft/server/level/ServerChunkCache.java
|
||||
+++ b/net/minecraft/server/level/ServerChunkCache.java
|
||||
@@ -70,11 +70,11 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon
|
||||
@@ -5,7 +5,7 @@ Subject: [PATCH] optimize random tick
|
||||
|
||||
|
||||
diff --git a/net/minecraft/server/level/ServerChunkCache.java b/net/minecraft/server/level/ServerChunkCache.java
|
||||
index 8b9d7129da577d7b613c0e21ee075e68edef7b12..8d074d2adf36827bc7c38a5f4efe4771453631b8 100644
|
||||
index 8bf770fd490634787e794efec9f0d6a10d97e42f..7e84b94a4602801e8cc713b28d0d93052589fd5e 100644
|
||||
--- a/net/minecraft/server/level/ServerChunkCache.java
|
||||
+++ b/net/minecraft/server/level/ServerChunkCache.java
|
||||
@@ -666,7 +666,13 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user