mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-23 21:49:46 +00:00
Properly Handle Fluid Updates while in a Boat #9428
This commit is contained in:
1 parent
a4bef82836
commit
55aa419100
6 files changed
+98
-4
No files matched your search
@@ -146,7 +146,7 @@
|
||||
this.m_5496_(soundtype.m_56776_(), soundtype.m_56773_() * 0.15F, soundtype.m_56774_());
|
||||
}
|
||||
|
||||
@@ -1176,19 +_,22 @@
|
||||
@@ -1176,31 +_,38 @@
|
||||
|
||||
public void m_5844_() {
|
||||
if (this.m_6069_()) {
|
||||
@@ -174,6 +174,24 @@
|
||||
}
|
||||
|
||||
void m_20074_() {
|
||||
Entity entity = this.m_20202_();
|
||||
+ java.util.function.BooleanSupplier updateFluidHeight = () -> this.m_204031_(FluidTags.f_13131_, 0.014D);
|
||||
if (entity instanceof Boat boat) {
|
||||
if (!boat.m_5842_()) {
|
||||
this.f_19798_ = false;
|
||||
- return;
|
||||
+ updateFluidHeight = () -> {
|
||||
+ this.updateFluidHeightAndDoFluidPushing(state -> this.shouldUpdateFluidWhileBoating(state, boat));
|
||||
+ return false;
|
||||
+ };
|
||||
}
|
||||
}
|
||||
|
||||
- if (this.m_204031_(FluidTags.f_13131_, 0.014D)) {
|
||||
+ if (updateFluidHeight.getAsBoolean()) {
|
||||
if (!this.f_19798_ && !this.f_19803_) {
|
||||
this.m_5841_();
|
||||
}
|
||||
@@ -1217,6 +_,7 @@
|
||||
private void m_20323_() {
|
||||
this.f_19800_ = this.m_204029_(FluidTags.f_13131_);
|
||||
@@ -449,11 +467,11 @@
|
||||
}
|
||||
|
||||
public final float m_20192_() {
|
||||
@@ -2980,9 +_,17 @@
|
||||
@@ -2980,9 +_,22 @@
|
||||
this.f_19859_ = this.m_146908_();
|
||||
}
|
||||
|
||||
+ @Deprecated // Forge: Use no parameter version instead, only for vanilla Tags
|
||||
+ @Deprecated // Forge: Use predicate version instead, only for vanilla Tags
|
||||
public boolean m_204031_(TagKey<Fluid> p_204032_, double p_204033_) {
|
||||
+ this.updateFluidHeightAndDoFluidPushing();
|
||||
+ if(p_204032_ == FluidTags.f_13131_) return this.isInFluidType(net.minecraftforge.common.ForgeMod.WATER_TYPE.get());
|
||||
@@ -461,7 +479,12 @@
|
||||
+ else return false;
|
||||
+ }
|
||||
+
|
||||
+ @Deprecated(forRemoval = true, since = "1.20.1")
|
||||
+ public void updateFluidHeightAndDoFluidPushing() {
|
||||
+ this.updateFluidHeightAndDoFluidPushing(com.google.common.base.Predicates.alwaysTrue());
|
||||
+ }
|
||||
+
|
||||
+ public void updateFluidHeightAndDoFluidPushing(Predicate<FluidState> shouldUpdate) {
|
||||
if (this.m_146899_()) {
|
||||
- return false;
|
||||
+ return;
|
||||
@@ -481,7 +504,7 @@
|
||||
FluidState fluidstate = this.m_9236_().m_6425_(blockpos$mutableblockpos);
|
||||
- if (fluidstate.m_205070_(p_204032_)) {
|
||||
+ net.minecraftforge.fluids.FluidType fluidType = fluidstate.getFluidType();
|
||||
+ if (!fluidType.isAir()) {
|
||||
+ if (!fluidType.isAir() && shouldUpdate.test(fluidstate)) {
|
||||
double d1 = (double)((float)i2 + fluidstate.m_76155_(this.m_9236_(), blockpos$mutableblockpos));
|
||||
if (d1 >= aabb.f_82289_) {
|
||||
flag1 = true;
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
|
||||
package net.minecraftforge.common.extensions;
|
||||
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.vehicle.Boat;
|
||||
import net.minecraft.world.level.material.FluidState;
|
||||
import net.minecraftforge.fluids.FluidType;
|
||||
@@ -37,4 +38,17 @@ public interface IForgeBoat
|
||||
{
|
||||
return type.supportsBoating(self());
|
||||
}
|
||||
|
||||
/**
|
||||
* When {@code false}, the fluid will no longer update its height value while
|
||||
* within a boat while it is not within a fluid ({@link Boat#isUnderWater()}.
|
||||
*
|
||||
* @param state the state of the fluid the rider is within
|
||||
* @param rider the rider of the boat
|
||||
* @return {@code true} if the fluid height should be updated, {@code false} otherwise
|
||||
*/
|
||||
default boolean shouldUpdateFluidWhileRiding(FluidState state, Entity rider)
|
||||
{
|
||||
return state.shouldUpdateWhileBoating(self(), rider);
|
||||
}
|
||||
}
|
||||
@@ -13,6 +13,7 @@ import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.entity.ai.attributes.AttributeInstance;
|
||||
import net.minecraft.world.entity.boss.enderdragon.EnderDragon;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.entity.vehicle.Boat;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
@@ -444,4 +445,17 @@ public interface IForgeEntity extends ICapabilitySerializable<CompoundTag>
|
||||
MinecraftForge.EVENT_BUS.post(evt);
|
||||
return evt.getNewEyeHeight();
|
||||
}
|
||||
|
||||
/**
|
||||
* When {@code false}, the fluid will no longer update its height value while
|
||||
* within a boat while it is not within a fluid ({@link Boat#isUnderWater()}.
|
||||
*
|
||||
* @param state the state of the fluid the rider is within
|
||||
* @param boat the boat the rider is within that is not inside a fluid
|
||||
* @return {@code true} if the fluid height should be updated, {@code false} otherwise
|
||||
*/
|
||||
default boolean shouldUpdateFluidWhileBoating(FluidState state, Boat boat)
|
||||
{
|
||||
return boat.shouldUpdateFluidWhileRiding(state, self());
|
||||
}
|
||||
}
|
||||
@@ -6,6 +6,7 @@
|
||||
package net.minecraftforge.common.extensions;
|
||||
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.entity.Mob;
|
||||
import net.minecraft.world.entity.vehicle.Boat;
|
||||
@@ -94,6 +95,20 @@ public interface IForgeFluid
|
||||
return getFluidType().supportsBoating(state, boat);
|
||||
}
|
||||
|
||||
/**
|
||||
* When {@code false}, the fluid will no longer update its height value while
|
||||
* within a boat while it is not within a fluid ({@link Boat#isUnderWater()}.
|
||||
*
|
||||
* @param state the state of the fluid the rider is within
|
||||
* @param boat the boat the rider is within that is not inside a fluid
|
||||
* @param rider the rider of the boat
|
||||
* @return {@code true} if the fluid height should be updated, {@code false} otherwise
|
||||
*/
|
||||
default boolean shouldUpdateWhileBoating(FluidState state, Boat boat, Entity rider)
|
||||
{
|
||||
return getFluidType().shouldUpdateWhileBoating(state, boat, rider);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the path type of this fluid when an entity is pathfinding. When
|
||||
* {@code null}, uses vanilla behavior.
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
package net.minecraftforge.common.extensions;
|
||||
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.entity.Mob;
|
||||
import net.minecraft.world.entity.vehicle.Boat;
|
||||
@@ -88,6 +89,19 @@ public interface IForgeFluidState
|
||||
return self().getType().supportsBoating(self(), boat);
|
||||
}
|
||||
|
||||
/**
|
||||
* When {@code false}, the fluid will no longer update its height value while
|
||||
* within a boat while it is not within a fluid ({@link Boat#isUnderWater()}.
|
||||
*
|
||||
* @param boat the boat the rider is within that is not inside a fluid
|
||||
* @param rider the rider of the boat
|
||||
* @return {@code true} if the fluid height should be updated, {@code false} otherwise
|
||||
*/
|
||||
default boolean shouldUpdateWhileBoating(Boat boat, Entity rider)
|
||||
{
|
||||
return self().getType().shouldUpdateWhileBoating(self(), boat, rider);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the path type of this fluid when an entity is pathfinding. When
|
||||
* {@code null}, uses vanilla behavior.
|
||||
|
||||
@@ -355,6 +355,20 @@ public class FluidType
|
||||
return this.supportsBoating(boat);
|
||||
}
|
||||
|
||||
/**
|
||||
* When {@code false}, the fluid will no longer update its height value while
|
||||
* within a boat while it is not within a fluid ({@link Boat#isUnderWater()}.
|
||||
*
|
||||
* @param state the state of the fluid the rider is within
|
||||
* @param boat the boat the rider is within that is not inside a fluid
|
||||
* @param rider the rider of the boat
|
||||
* @return {@code true} if the fluid height should be updated, {@code false} otherwise
|
||||
*/
|
||||
public boolean shouldUpdateWhileBoating(FluidState state, Boat boat, Entity rider)
|
||||
{
|
||||
return !this.supportsBoating(state, boat);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the entity can ride in this vehicle under the fluid.
|
||||
*
|
||||
|
||||
Reference in new issue
Block a user