Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[1.21] Fix fluid pushing, update wasTouchingWater flag again #1586

Open
wants to merge 7 commits into
base: 1.21.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 9 additions & 15 deletions patches/net/minecraft/world/entity/Entity.java.patch
Original file line number Diff line number Diff line change
Expand Up @@ -315,25 +315,19 @@
this.dimensions = entitydimensions1;
this.eyeHeight = entitydimensions1.eyeHeight();
this.reapplyPosition();
@@ -3265,9 +_,17 @@
@@ -3265,7 +_,12 @@
return Mth.lerp(p_352259_, this.yRotO, this.yRot);
}

+ @Deprecated // Forge: Use no parameter version instead, only for vanilla Tags
+ @Deprecated // Neo: Use no parameter version instead
public boolean updateFluidHeightAndDoFluidPushing(TagKey<Fluid> p_204032_, double p_204033_) {
+ this.updateFluidHeightAndDoFluidPushing();
+ if(p_204032_ == FluidTags.WATER) return this.isInFluidType(net.neoforged.neoforge.common.NeoForgeMod.WATER_TYPE.value());
+ else if (p_204032_ == FluidTags.LAVA) return this.isInFluidType(net.neoforged.neoforge.common.NeoForgeMod.LAVA_TYPE.value());
+ else return false;
+ return this.updateFluidHeightAndDoFluidPushing();
+ }
+
+ public void updateFluidHeightAndDoFluidPushing() {
+ public boolean updateFluidHeightAndDoFluidPushing() {
if (this.touchingUnloadedChunk()) {
- return false;
+ return;
return false;
} else {
AABB aabb = this.getBoundingBox().deflate(0.001);
int i = Mth.floor(aabb.minX);
@@ -3282,25 +_,36 @@
Vec3 vec3 = Vec3.ZERO;
int k1 = 0;
Expand All @@ -355,9 +349,10 @@
+ if (!fluidType.isAir()) {
double d1 = (double)((float)i2 + fluidstate.getHeight(this.level(), blockpos$mutableblockpos));
if (d1 >= aabb.minY) {
flag1 = true;
- flag1 = true;
- d0 = Math.max(d1 - aabb.minY, d0);
- if (flag) {
+ flag1 = fluidType.actsLikeWater();
+ if (interimCalcs == null) {
+ interimCalcs = new it.unimi.dsi.fastutil.objects.Object2ObjectArrayMap<>();
+ }
Expand All @@ -378,7 +373,7 @@
}
}
}
@@ -3308,27 +_,30 @@
@@ -3308,26 +_,30 @@
}
}

Expand Down Expand Up @@ -412,13 +407,12 @@
}

- this.fluidHeight.put(p_204032_, d0);
- return flag1;
+ this.setFluidTypeHeight(fluidType, interim.fluidHeight);
+ });
+ }
return flag1;
}
}

@@ -3341,7 +_,10 @@
return !this.level().hasChunksAt(i, k, j, l);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,7 @@ public void setItemMovement(ItemEntity entity) {
.sound(SoundActions.BUCKET_EMPTY, SoundEvents.BUCKET_EMPTY)
.sound(SoundActions.FLUID_VAPORIZE, SoundEvents.FIRE_EXTINGUISH)
.canHydrate(true)
.actsLikeWater(true)
.addDripstoneDripping(PointedDripstoneBlock.WATER_TRANSFER_PROBABILITY_PER_RANDOM_TICK, ParticleTypes.DRIPPING_DRIPSTONE_WATER, Blocks.WATER_CAULDRON, SoundEvents.POINTED_DRIPSTONE_DRIP_WATER_INTO_CAULDRON)) {
@Override
public boolean canConvertToSource(FluidState state, LevelReader reader, BlockPos pos) {
Expand Down
27 changes: 27 additions & 0 deletions src/main/java/net/neoforged/neoforge/fluids/FluidType.java
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ public class FluidType {
@Nullable
private final PathType pathType, adjacentPathType;
private final boolean canHydrate;
private final boolean actsLikeWater;
private final int lightLevel;
private final int density;
private final int temperature;
Expand Down Expand Up @@ -115,6 +116,7 @@ public FluidType(final Properties properties) {
this.adjacentPathType = properties.adjacentPathType;
this.sounds = ImmutableMap.copyOf(properties.sounds);
this.canHydrate = properties.canHydrate;
this.actsLikeWater = properties.actsLikeWater;
this.lightLevel = properties.lightLevel;
this.density = properties.density;
this.temperature = properties.temperature;
Expand Down Expand Up @@ -372,6 +374,17 @@ public boolean canHydrate(Entity entity) {
return this.canHydrate;
}

/**
* Returns whether a fluid should be treated like an entity is residing in water.
*
* <p> This sets {@link Entity#isInWater()} to return true, which is used for things like aquatic animal swimming, slowed minecart movement, and conduit functionality.
*
* @return {@code true} if this fluid acts like water, {@code false} otherwise
*/
public boolean actsLikeWater() {
TelepathicGrunt marked this conversation as resolved.
Show resolved Hide resolved
return this.actsLikeWater;
}

/**
* Returns a sound to play when a certain action is performed by the
* entity in the fluid. If no sound is present, then the sound will be
Expand Down Expand Up @@ -863,6 +876,7 @@ public static final class Properties {
adjacentPathType = PathType.WATER_BORDER;
private final Map<SoundAction, SoundEvent> sounds = new HashMap<>();
private boolean canHydrate = false;
private boolean actsLikeWater = false;
private int lightLevel = 0,
density = 1000,
temperature = 300,
Expand Down Expand Up @@ -1031,6 +1045,19 @@ public Properties canHydrate(boolean canHydrate) {
return this;
}

/**
* Returns whether a fluid should be treated like an entity is residing in water.
*
* <p> This sets {@link Entity#isInWater()} to return true when an entity is in this fluid, which is used for things like aquatic animal swimming, slowed minecart movement, and conduit functionality.
*
* @param actsLikeWater if the fluid acts like water
* @return the property holder instance
*/
public Properties actsLikeWater(boolean actsLikeWater) {
this.actsLikeWater = actsLikeWater;
return this;
}

/**
* Sets the light level emitted by the fluid.
*
Expand Down