9
0
mirror of https://github.com/Winds-Studio/Leaf.git synced 2025-12-27 02:49:19 +00:00
Files
Leaf/leaf-server/minecraft-patches/features/0290-optimize-updateFluidHeightAndDoFluidPushing.patch
Dreeam d36ed6c316 Remove OP lock (#486)
Current implementation of OP lock is not an appropriate solution to prevent plugins that contain backdoor or malicious code. There are many ways to bypass this check to manipulate the OP list or permissions. The best way to prevent this kind of grief is to get plugins from valid and trustworthy places.
2025-08-31 23:53:19 -04:00

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 29fa9cfa1aa2d507da852f5fe33ea6e4143da194..0366217ac729a967ba69fb256481479255d347be 100644
--- a/net/minecraft/world/entity/Entity.java
+++ b/net/minecraft/world/entity/Entity.java
@@ -4939,12 +4939,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
@@ -4956,7 +4956,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;
}
@@ -5013,7 +5013,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;
}