mirror of
https://github.com/Winds-Studio/Leaf.git
synced 2025-12-26 18:39:23 +00:00
44 lines
2.7 KiB
Diff
44 lines
2.7 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: hayanesuru <hayanesuru@outlook.jp>
|
|
Date: Sat, 9 Aug 2025 15:44:06 +0900
|
|
Subject: [PATCH] optimize updateFluidHeightAndDoFluidPushing
|
|
|
|
|
|
diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java
|
|
index 11a0fcf040053f9e84db21b3890cdfdc330755f0..ae8154b4dea055c219797f00f357e56c74bcdace 100644
|
|
--- a/net/minecraft/world/entity/Entity.java
|
|
+++ b/net/minecraft/world/entity/Entity.java
|
|
@@ -4933,12 +4933,12 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
|
final int minChunkZ = minBlockZ >> 4;
|
|
final int maxChunkZ = maxBlockZ >> 4;
|
|
|
|
- final net.minecraft.world.level.chunk.ChunkSource chunkSource = world.getChunkSource();
|
|
+ final net.minecraft.server.level.ServerChunkCache chunkSource = ((ServerLevel) world).chunkSource; // Leaf - optimize get chunk
|
|
|
|
for (int currChunkZ = minChunkZ; currChunkZ <= maxChunkZ; ++currChunkZ) {
|
|
for (int currChunkX = minChunkX; currChunkX <= maxChunkX; ++currChunkX) {
|
|
// Leaf start - Prevent double chunk retrieving in entity fluid pushing check and fluid height updating
|
|
- final net.minecraft.world.level.chunk.ChunkAccess chunk = chunkSource.getChunk(currChunkX, currChunkZ, net.minecraft.world.level.chunk.status.ChunkStatus.FULL, false);
|
|
+ final net.minecraft.world.level.chunk.LevelChunk chunk = chunkSource.fullChunksNonSync.get(ca.spottedleaf.moonrise.common.util.CoordinateUtils.getChunkKey(currChunkX, currChunkZ));
|
|
if (chunk == null) continue;
|
|
final net.minecraft.world.level.chunk.LevelChunkSection[] sections = chunk.getSections();
|
|
// Leaf end - Prevent double chunk retrieving in entity fluid pushing check and fluid height updating
|
|
@@ -4950,7 +4950,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
|
continue;
|
|
}
|
|
final net.minecraft.world.level.chunk.LevelChunkSection section = sections[sectionIdx];
|
|
- if (section.hasOnlyAir()) {
|
|
+ if (section.hasOnlyAir() || (fluid == FluidTags.WATER && section.waterFluidCount == 0) || (fluid == FluidTags.LAVA && section.lavaFluidCount == 0)) {
|
|
// empty
|
|
continue;
|
|
}
|
|
@@ -5007,7 +5007,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
|
|
|
this.fluidHeight.put(fluid, maxHeightDiff);
|
|
|
|
- if (pushVector.lengthSqr() == 0.0) {
|
|
+ if (pushVector == Vec3.ZERO || pushVector.lengthSqr() == 0.0) {
|
|
return inFluid;
|
|
}
|
|
|