97 lines
4.3 KiB
Diff
97 lines
4.3 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Helvetica Volubi <suisuroru@blue-millennium.fun>
|
|
Date: Sat, 26 Jul 2025 12:45:01 +0800
|
|
Subject: [PATCH] Leaves: Vanilla Fluid Pushing
|
|
|
|
Co-authored by: Fortern <blueten.ki@gmail.com>
|
|
As part of: Leaves (https://github.com/LeavesMC/Leaves/blob/d4854b69b2775f6d0929c63db84de45294cdd375/leaves-server/minecraft-patches/features/0129-Vanilla-Fluid-Pushing.patch)
|
|
Licensed under: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html)
|
|
|
|
diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java
|
|
index 76ee76c7c6abeb14f379b73188305903be5d2df6..0a2bdd4cb84abe58ce891cf39a63c658e3cd8298 100644
|
|
--- a/net/minecraft/world/entity/Entity.java
|
|
+++ b/net/minecraft/world/entity/Entity.java
|
|
@@ -5588,8 +5588,82 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
|
return Mth.lerp(partialTick, this.yRotO, this.yRot);
|
|
}
|
|
|
|
+ // Leaves start - vanilla fluid pushing
|
|
+ private boolean vanillaUpdateFluidHeightAndDoFluidPushing(final TagKey<Fluid> fluidTag, final double motionScale) {
|
|
+ if (this.touchingUnloadedChunk()) {
|
|
+ return false;
|
|
+ } else {
|
|
+ AABB aabb = this.getBoundingBox().deflate(0.001);
|
|
+ int floor = Mth.floor(aabb.minX);
|
|
+ int ceil = Mth.ceil(aabb.maxX);
|
|
+ int floor1 = Mth.floor(aabb.minY);
|
|
+ int ceil1 = Mth.ceil(aabb.maxY);
|
|
+ int floor2 = Mth.floor(aabb.minZ);
|
|
+ int ceil2 = Mth.ceil(aabb.maxZ);
|
|
+ double d = 0.0;
|
|
+ boolean isPushedByFluid = this.isPushedByFluid();
|
|
+ boolean flag = false;
|
|
+ Vec3 vec3 = Vec3.ZERO;
|
|
+ int i = 0;
|
|
+ BlockPos.MutableBlockPos mutableBlockPos = new BlockPos.MutableBlockPos();
|
|
+
|
|
+ for (int i1 = floor; i1 < ceil; i1++) {
|
|
+ for (int i2 = floor1; i2 < ceil1; i2++) {
|
|
+ for (int i3 = floor2; i3 < ceil2; i3++) {
|
|
+ mutableBlockPos.set(i1, i2, i3);
|
|
+ FluidState fluidState = this.level().getFluidState(mutableBlockPos);
|
|
+ if (fluidState.is(fluidTag)) {
|
|
+ double d1 = i2 + fluidState.getHeight(this.level(), mutableBlockPos);
|
|
+ if (d1 >= aabb.minY) {
|
|
+ flag = true;
|
|
+ d = Math.max(d1 - aabb.minY, d);
|
|
+ if (isPushedByFluid) {
|
|
+ Vec3 flow = fluidState.getFlow(this.level(), mutableBlockPos);
|
|
+ if (d < 0.4) {
|
|
+ flow = flow.scale(d);
|
|
+ }
|
|
+
|
|
+ vec3 = vec3.add(flow);
|
|
+ i++;
|
|
+ }
|
|
+ }
|
|
+ }
|
|
+ }
|
|
+ }
|
|
+ }
|
|
+
|
|
+ if (vec3.length() > 0.0) {
|
|
+ if (i > 0) {
|
|
+ vec3 = vec3.scale(1.0 / i);
|
|
+ }
|
|
+
|
|
+ if (!(this instanceof Player)) {
|
|
+ vec3 = vec3.normalize();
|
|
+ }
|
|
+
|
|
+ Vec3 deltaMovement = this.getDeltaMovement();
|
|
+ vec3 = vec3.scale(motionScale);
|
|
+ double d2 = 0.003;
|
|
+ if (Math.abs(deltaMovement.x) < 0.003 && Math.abs(deltaMovement.z) < 0.003 && vec3.length() < 0.0045000000000000005) {
|
|
+ vec3 = vec3.normalize().scale(0.0045000000000000005);
|
|
+ }
|
|
+
|
|
+ this.setDeltaMovement(this.getDeltaMovement().add(vec3));
|
|
+ }
|
|
+
|
|
+ this.fluidHeight.put(fluidTag, d);
|
|
+ return flag;
|
|
+ }
|
|
+ }
|
|
+ // Leaves end - vanilla fluid pushing
|
|
+
|
|
// Paper start - optimise collisions
|
|
public boolean updateFluidHeightAndDoFluidPushing(final TagKey<Fluid> fluid, final double flowScale) {
|
|
+ // Leaves start - vanilla fluid pushing
|
|
+ if (me.earthme.luminol.config.modules.fixes.CollisionBehaviorConfig.vanillaFluidPushing) {
|
|
+ return vanillaUpdateFluidHeightAndDoFluidPushing(fluid, flowScale);
|
|
+ }
|
|
+ // Leaves end - vanilla fluid pushing
|
|
if (this.touchingUnloadedChunk()) {
|
|
return false;
|
|
}
|