mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-25 06:24:43 +00:00
Fixed boat not taking care of block-liquid hooks (#5086)
This commit is contained in:
1 parent
1752e57ea0
commit
6162f438f1
4 files changed
+82
-3
No files matched your search
@@ -1408,6 +1408,20 @@
|
||||
+ {
|
||||
+ return null;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Called when entities are swimming in the given liquid and returns the relative height (used by {@link net.minecraft.entity.item.EntityBoat})
|
||||
+ *
|
||||
+ * @param world world that is being tested.
|
||||
+ * @param pos block thats being tested.
|
||||
+ * @param state state at world/pos
|
||||
+ * @param material liquid thats being tested.
|
||||
+ * @return relative height of the given liquid (material), a value between 0 and 1
|
||||
+ */
|
||||
+ public float getBlockLiquidHeight(World world, BlockPos pos, IBlockState state, Material material)
|
||||
+ {
|
||||
+ return 0;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Queries if this block should render in a given layer.
|
||||
|
||||
@@ -17,7 +17,17 @@
|
||||
this.func_180688_d(p_176365_1_, p_176365_2_);
|
||||
return true;
|
||||
}
|
||||
@@ -452,4 +452,29 @@
|
||||
@@ -448,8 +448,39 @@
|
||||
return (float)p_190972_2_.func_177956_o() + func_190973_f(p_190972_0_, p_190972_1_, p_190972_2_);
|
||||
}
|
||||
|
||||
+ @Override
|
||||
+ public float getBlockLiquidHeight(World world, BlockPos pos, IBlockState state, Material material)
|
||||
+ {
|
||||
+ return BlockLiquid.func_190973_f(state, world, pos);
|
||||
+ }
|
||||
+
|
||||
public BlockFaceShape func_193383_a(IBlockAccess p_193383_1_, IBlockState p_193383_2_, BlockPos p_193383_3_, EnumFacing p_193383_4_)
|
||||
{
|
||||
return BlockFaceShape.UNDEFINED;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,19 @@
|
||||
--- ../src-base/minecraft/net/minecraft/entity/item/EntityBoat.java
|
||||
+++ ../src-work/minecraft/net/minecraft/entity/item/EntityBoat.java
|
||||
@@ -508,7 +508,7 @@
|
||||
@@ -449,6 +449,12 @@
|
||||
blockpos$pooledmutableblockpos.func_181079_c(l1, k1, i2);
|
||||
IBlockState iblockstate = this.field_70170_p.func_180495_p(blockpos$pooledmutableblockpos);
|
||||
|
||||
+ Boolean result = iblockstate.func_177230_c().isAABBInsideMaterial(field_70170_p, blockpos$pooledmutableblockpos, new AxisAlignedBB(blockpos$pooledmutableblockpos), Material.field_151586_h);
|
||||
+ if (result != null) {
|
||||
+ if (!result) continue;
|
||||
+ f = Math.max(f, iblockstate.func_177230_c().getBlockLiquidHeight(field_70170_p, blockpos$pooledmutableblockpos, iblockstate, Material.field_151586_h) + blockpos$pooledmutableblockpos.func_177956_o());
|
||||
+ }
|
||||
+
|
||||
if (iblockstate.func_185904_a() == Material.field_151586_h)
|
||||
{
|
||||
f = Math.max(f, BlockLiquid.func_190973_f(iblockstate, this.field_70170_p, blockpos$pooledmutableblockpos));
|
||||
@@ -508,7 +514,7 @@
|
||||
|
||||
if (!list.isEmpty())
|
||||
{
|
||||
@@ -9,7 +22,42 @@
|
||||
++k1;
|
||||
}
|
||||
|
||||
@@ -980,4 +980,20 @@
|
||||
@@ -551,6 +557,15 @@
|
||||
blockpos$pooledmutableblockpos.func_181079_c(k1, l1, i2);
|
||||
IBlockState iblockstate = this.field_70170_p.func_180495_p(blockpos$pooledmutableblockpos);
|
||||
|
||||
+ Boolean result = iblockstate.func_177230_c().isAABBInsideMaterial(field_70170_p, blockpos$pooledmutableblockpos, axisalignedbb, Material.field_151586_h);
|
||||
+ if (result != null) {
|
||||
+ if (!result) continue;
|
||||
+
|
||||
+ float f = iblockstate.func_177230_c().getBlockLiquidHeight(field_70170_p, blockpos$pooledmutableblockpos, iblockstate, Material.field_151586_h) + blockpos$pooledmutableblockpos.func_177956_o();
|
||||
+ this.field_184465_aD = Math.max((double)f, this.field_184465_aD);
|
||||
+ flag |= axisalignedbb.field_72338_b < (double)f;
|
||||
+ }
|
||||
+
|
||||
if (iblockstate.func_185904_a() == Material.field_151586_h)
|
||||
{
|
||||
float f = BlockLiquid.func_190972_g(iblockstate, this.field_70170_p, blockpos$pooledmutableblockpos);
|
||||
@@ -594,6 +609,18 @@
|
||||
blockpos$pooledmutableblockpos.func_181079_c(k1, l1, i2);
|
||||
IBlockState iblockstate = this.field_70170_p.func_180495_p(blockpos$pooledmutableblockpos);
|
||||
|
||||
+ Boolean result = iblockstate.func_177230_c().isAABBInsideMaterial(field_70170_p, blockpos$pooledmutableblockpos, axisalignedbb, Material.field_151586_h);
|
||||
+ if (result != null) {
|
||||
+ if (!result) continue;
|
||||
+
|
||||
+ if(iblockstate.func_177230_c().getBlockLiquidHeight(field_70170_p, blockpos$pooledmutableblockpos, iblockstate, Material.field_151586_h) > 0)
|
||||
+ {
|
||||
+ blockpos$pooledmutableblockpos.func_185344_t();
|
||||
+ return EntityBoat.Status.UNDER_FLOWING_WATER;
|
||||
+ } else
|
||||
+ continue;
|
||||
+ }
|
||||
+
|
||||
if (iblockstate.func_185904_a() == Material.field_151586_h && d0 < (double)BlockLiquid.func_190972_g(iblockstate, this.field_70170_p, blockpos$pooledmutableblockpos))
|
||||
{
|
||||
if (((Integer)iblockstate.func_177229_b(BlockLiquid.field_176367_b)).intValue() != 0)
|
||||
@@ -980,4 +1007,20 @@
|
||||
return values()[0];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -813,4 +813,11 @@ public abstract class BlockFluidBase extends Block implements IFluidBlock
|
||||
return filled < 0 ? vec.y > pos.getY() + filled + 1
|
||||
: vec.y < pos.getY() + filled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getBlockLiquidHeight(World world, BlockPos pos, IBlockState state, Material material)
|
||||
{
|
||||
float filled = getFilledPercentage(world, pos);
|
||||
return Math.max(filled, 0);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user