mirror of
https://github.com/LeavesMC/Leaves.git
synced 2025-12-19 14:59:32 +00:00
94 lines
4.0 KiB
Diff
94 lines
4.0 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Fortern <blueten.ki@gmail.com>
|
|
Date: Thu, 19 Jun 2025 00:49:24 +0800
|
|
Subject: [PATCH] Vanilla Fluid Pushing
|
|
|
|
|
|
diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java
|
|
index 0a29cf071cefe14f1862d4bd5ddcacff42fe9f15..05770bb17a37733c83464e1c90ce549d5e7771c5 100644
|
|
--- a/net/minecraft/world/entity/Entity.java
|
|
+++ b/net/minecraft/world/entity/Entity.java
|
|
@@ -4729,8 +4729,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 (org.leavesmc.leaves.LeavesConfig.fix.vanillaFluidPushing) {
|
|
+ return vanillaUpdateFluidHeightAndDoFluidPushing(fluid, flowScale);
|
|
+ }
|
|
+ // Leaves end - vanilla fluid pushing
|
|
if (this.touchingUnloadedChunk()) {
|
|
return false;
|
|
}
|