Skip to content

Commit

Permalink
fix lava fluid pushing, change actsLikeWater usage
Browse files Browse the repository at this point in the history
  • Loading branch information
GizmoTheMoonPig committed Nov 10, 2024
1 parent 3c8d47a commit 6ca62c5
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 10 deletions.
30 changes: 20 additions & 10 deletions patches/net/minecraft/world/entity/Entity.java.patch
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@
this.playSound(soundtype.getStepSound(), soundtype.getVolume() * 0.15F, soundtype.getPitch());
}

@@ -1294,20 +_,23 @@
@@ -1294,20 +_,25 @@

public void updateSwimming() {
if (this.isSwimming()) {
Expand All @@ -118,8 +118,8 @@
this.fluidHeight.clear();
+ this.forgeFluidTypeHeight.clear();
this.updateInWaterStateAndDoWaterCurrentPushing();
- double d0 = this.level().dimensionType().ultraWarm() ? 0.007 : 0.0023333333333333335;
- boolean flag = this.updateFluidHeightAndDoFluidPushing(FluidTags.LAVA, d0);
double d0 = this.level().dimensionType().ultraWarm() ? 0.007 : 0.0023333333333333335;
boolean flag = this.updateFluidHeightAndDoFluidPushing(FluidTags.LAVA, d0);
- return this.isInWater() || flag;
+ if (this.isInFluidType() && !(this.getVehicle() instanceof AbstractBoat)) {
+ this.fallDistance *= this.forgeFluidTypeHeight.object2DoubleEntrySet().stream().filter(e -> !e.getKey().isAir() && !e.getKey().isVanilla()).map(e -> this.getFluidFallDistanceModifier(e.getKey())).min(Float::compare).orElse(1F);
Expand All @@ -129,6 +129,15 @@
}

void updateInWaterStateAndDoWaterCurrentPushing() {
@@ -1316,7 +_,7 @@
return;
}

- if (this.updateFluidHeightAndDoFluidPushing(FluidTags.WATER, 0.014)) {
+ if (this.updateFluidHeightAndDoFluidPushing(FluidTags.WATER, 0.014) || this.isInFluidType((type, d) -> type.actsLikeWater())) {
if (!this.wasTouchingWater && !this.firstTick) {
this.doWaterSplashEffect();
}
@@ -1332,6 +_,7 @@
private void updateFluidOnEyes() {
this.wasEyeInWater = this.isEyeInFluid(FluidTags.WATER);
Expand Down Expand Up @@ -315,16 +324,18 @@
this.dimensions = entitydimensions1;
this.eyeHeight = entitydimensions1.eyeHeight();
this.reapplyPosition();
@@ -3265,7 +_,12 @@
@@ -3265,7 +_,14 @@
return Mth.lerp(p_352259_, this.yRotO, this.yRot);
}

+ @Deprecated // Neo: Use no parameter version instead
+ @Deprecated // Neo: Use type version instead
public boolean updateFluidHeightAndDoFluidPushing(TagKey<Fluid> p_204032_, double p_204033_) {
+ return this.updateFluidHeightAndDoFluidPushing();
+ if(p_204032_ == FluidTags.WATER) return this.updateFluidHeightAndDoFluidPushing(net.neoforged.neoforge.common.NeoForgeMod.WATER_TYPE.value());
+ else if (p_204032_ == FluidTags.LAVA) return this.updateFluidHeightAndDoFluidPushing(net.neoforged.neoforge.common.NeoForgeMod.LAVA_TYPE.value());
+ else return false;
+ }
+
+ public boolean updateFluidHeightAndDoFluidPushing() {
+ public boolean updateFluidHeightAndDoFluidPushing(net.neoforged.neoforge.fluids.FluidType type) {
if (this.touchingUnloadedChunk()) {
return false;
} else {
Expand All @@ -346,13 +357,12 @@
FluidState fluidstate = this.level().getFluidState(blockpos$mutableblockpos);
- if (fluidstate.is(p_204032_)) {
+ net.neoforged.neoforge.fluids.FluidType fluidType = fluidstate.getFluidType();
+ if (!fluidType.isAir()) {
+ if (fluidType == type) {
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 Down
20 changes: 20 additions & 0 deletions patches/net/minecraft/world/entity/LivingEntity.java.patch
Original file line number Diff line number Diff line change
Expand Up @@ -512,6 +512,17 @@
}

protected float getWaterSlowDown() {
@@ -2184,8 +_,8 @@
public void travel(Vec3 p_21280_) {
if (this.isControlledByLocalInstance()) {
FluidState fluidstate = this.level().getFluidState(this.blockPosition());
- if ((this.isInWater() || this.isInLava()) && this.isAffectedByFluids() && !this.canStandOnFluid(fluidstate)) {
- this.travelInFluid(p_21280_);
+ if ((this.isInWater() || (this.isInFluidType(fluidstate) && fluidstate.getFluidType() != net.neoforged.neoforge.common.NeoForgeMod.LAVA_TYPE.value())) && this.isAffectedByFluids() && !this.canStandOnFluid(fluidstate)) {
+ this.travelInFluid(p_21280_, fluidstate);
} else if (this.isFallFlying()) {
this.travelFallFlying();
} else {
@@ -2196,7 +_,7 @@

private void travelInAir(Vec3 p_362457_) {
Expand Down Expand Up @@ -550,6 +561,15 @@
this.moveRelative(f1, p_365480_);
this.move(MoverType.SELF, this.getDeltaMovement());
Vec3 vec3 = this.getDeltaMovement();
@@ -2249,7 +_,7 @@

vec3 = vec3.multiply((double)f, 0.8F, (double)f);
this.setDeltaMovement(this.getFluidFallingAdjustedMovement(d1, flag, vec3));
- } else {
+ } else if (this.isInLava() && this.isAffectedByFluids() && !this.canStandOnFluid(fluidState)) {
this.moveRelative(0.02F, p_365480_);
this.move(MoverType.SELF, this.getDeltaMovement());
if (this.getFluidHeight(FluidTags.LAVA) <= this.getFluidJumpThreshold()) {
@@ -2389,7 +_,7 @@
double d0 = Mth.clamp(p_21298_.x, -0.15F, 0.15F);
double d1 = Mth.clamp(p_21298_.z, -0.15F, 0.15F);
Expand Down

0 comments on commit 6ca62c5

Please sign in to comment.