diff --git a/leaves-server/minecraft-patches/features/0129-Vanilla-Fluid-Pushing.patch b/leaves-server/minecraft-patches/features/0129-Vanilla-Fluid-Pushing.patch index 49bd3038..db255fe2 100644 --- a/leaves-server/minecraft-patches/features/0129-Vanilla-Fluid-Pushing.patch +++ b/leaves-server/minecraft-patches/features/0129-Vanilla-Fluid-Pushing.patch @@ -5,19 +5,89 @@ Subject: [PATCH] Vanilla Fluid Pushing diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java -index 0dde70f12ede6da06a0b9f0e78272a963a167699..a0fc0613bbda652d439215d7d6282ac710c1461d 100644 +index 75dbb580388bb31e0c0367d5595fd18b0d329709..6e7033ceb43acf8afd4c27a4d130e8a3dd8c1eef 100644 --- a/net/minecraft/world/entity/Entity.java +++ b/net/minecraft/world/entity/Entity.java -@@ -4823,8 +4823,10 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess +@@ -4730,8 +4730,82 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess + return Mth.lerp(partialTick, this.yRotO, this.yRot); + } - final Vec3 flow = fluidState.getFlow(world, mutablePos); - -- if (diff < 0.4) { -- pushVector = pushVector.add(flow.scale(diff)); -+ // Leaves start - Vanilla Fluid Pushing -+ if (maxHeightDiff < 0.4) { -+ pushVector = pushVector.add(flow.scale(maxHeightDiff)); -+ // Leaves end - Vanilla Fluid Pushing - } else { - pushVector = pushVector.add(flow); - } ++ // Leaves start - vanilla fluid pushing ++ private boolean vanillaUpdateFluidHeightAndDoFluidPushing(final TagKey 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, 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; + } diff --git a/leaves-server/src/main/java/org/leavesmc/leaves/LeavesConfig.java b/leaves-server/src/main/java/org/leavesmc/leaves/LeavesConfig.java index ffc17589..5c1fd678 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/LeavesConfig.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/LeavesConfig.java @@ -1124,6 +1124,9 @@ public final class LeavesConfig { @GlobalConfig("vanilla-portal-handle") public boolean vanillaPortalHandle = false; + @GlobalConfig("vanilla-fluid-pushing") + public boolean vanillaFluidPushing = false; + @RemovedConfig(name = "collision-behavior", category = "fix") @RemovedConfig(name = "spigot-EndPlatform-destroy", category = "fix") private final boolean removed = false;