New hook to delegate some liquid related physics to the blocks themselves. (#4604)

This commit is contained in:
CreativeMD 2018-02-02 19:32:37 +01:00 committed by LexManos
parent e1f691617f
commit 094245fe06
2 changed files with 78 additions and 35 deletions

View File

@ -221,7 +221,7 @@
public SoundType func_185467_w()
{
return this.field_149762_H;
@@ -934,6 +952,1331 @@
@@ -934,6 +952,1328 @@
{
}
@ -1389,6 +1389,20 @@
+ {
+ return null;
+ }
+
+ /**
+ * Called when entities are moving to check if they are inside a liquid
+ *
+ * @param world world that is being tested.
+ * @param pos block thats being tested.
+ * @param boundingBox box to test, generally the bounds of an entity that are besting tested.
+ * @return null for default behavior, true if the box is within the material, false if it was not.
+ */
+ @Nullable
+ public Boolean isAABBInsideLiquid(World world, BlockPos pos, AxisAlignedBB boundingBox)
+ {
+ return null;
+ }
+
+ /**
+ * Queries if this block should render in a given layer.
@ -1553,7 +1567,7 @@
public static void func_149671_p()
{
func_176215_a(0, field_176230_a, (new BlockAir()).func_149663_c("air"));
@@ -1230,31 +2573,6 @@
@@ -1230,31 +2570,6 @@
block15.field_149783_u = flag;
}
}

View File

@ -560,7 +560,20 @@
{
return false;
}
@@ -2011,6 +2167,11 @@
@@ -1972,6 +2128,12 @@
{
IBlockState iblockstate1 = this.func_180495_p(blockpos$pooledmutableblockpos.func_181079_c(l3, i4, j4));
+ Boolean result = iblockstate1.func_177230_c().isAABBInsideLiquid(this, blockpos$pooledmutableblockpos, p_72953_1_);
+ if (result != null) {
+ if (!result) continue;
+ blockpos$pooledmutableblockpos.func_185344_t();
+ return true;
+ }
if (iblockstate1.func_185904_a().func_76224_d())
{
blockpos$pooledmutableblockpos.func_185344_t();
@@ -2011,6 +2173,11 @@
blockpos$pooledmutableblockpos.func_185344_t();
return true;
}
@ -572,7 +585,7 @@
}
}
}
@@ -2050,6 +2211,16 @@
@@ -2050,6 +2217,16 @@
IBlockState iblockstate1 = this.func_180495_p(blockpos$pooledmutableblockpos);
Block block = iblockstate1.func_177230_c();
@ -589,7 +602,23 @@
if (iblockstate1.func_185904_a() == p_72918_2_)
{
double d0 = (double)((float)(i4 + 1) - BlockLiquid.func_149801_b(((Integer)iblockstate1.func_177229_b(BlockLiquid.field_176367_b)).intValue()));
@@ -2116,6 +2287,7 @@
@@ -2095,7 +2272,14 @@
{
for (int j4 = j3; j4 < k3; ++j4)
{
- if (this.func_180495_p(blockpos$pooledmutableblockpos.func_181079_c(l3, i4, j4)).func_185904_a() == p_72875_2_)
+ IBlockState iblockstate1 = this.func_180495_p(blockpos$pooledmutableblockpos.func_181079_c(l3, i4, j4));
+ Boolean result = iblockstate1.func_177230_c().isAABBInsideMaterial(this, blockpos$pooledmutableblockpos, p_72875_1_, p_72875_2_);
+ if (result != null) {
+ if (!result) continue;
+ blockpos$pooledmutableblockpos.func_185344_t();
+ return true;
+ }
+ if (iblockstate1.func_185904_a() == p_72875_2_)
{
blockpos$pooledmutableblockpos.func_185344_t();
return true;
@@ -2116,6 +2300,7 @@
public Explosion func_72885_a(@Nullable Entity p_72885_1_, double p_72885_2_, double p_72885_4_, double p_72885_6_, float p_72885_8_, boolean p_72885_9_, boolean p_72885_10_)
{
Explosion explosion = new Explosion(this, p_72885_1_, p_72885_2_, p_72885_4_, p_72885_6_, p_72885_8_, p_72885_9_, p_72885_10_);
@ -597,7 +626,7 @@
explosion.func_77278_a();
explosion.func_77279_a(true);
return explosion;
@@ -2238,6 +2410,7 @@
@@ -2238,6 +2423,7 @@
public void func_175690_a(BlockPos p_175690_1_, @Nullable TileEntity p_175690_2_)
{
@ -605,7 +634,7 @@
if (!this.func_189509_E(p_175690_1_))
{
if (p_175690_2_ != null && !p_175690_2_.func_145837_r())
@@ -2245,6 +2418,8 @@
@@ -2245,6 +2431,8 @@
if (this.field_147481_N)
{
p_175690_2_.func_174878_a(p_175690_1_);
@ -614,7 +643,7 @@
Iterator<TileEntity> iterator1 = this.field_147484_a.iterator();
while (iterator1.hasNext())
@@ -2262,7 +2437,8 @@
@@ -2262,7 +2450,8 @@
}
else
{
@ -624,7 +653,7 @@
this.func_175700_a(p_175690_2_);
}
}
@@ -2277,6 +2453,8 @@
@@ -2277,6 +2466,8 @@
{
tileentity2.func_145843_s();
this.field_147484_a.remove(tileentity2);
@ -633,7 +662,7 @@
}
else
{
@@ -2289,6 +2467,7 @@
@@ -2289,6 +2480,7 @@
this.func_175726_f(p_175713_1_).func_177425_e(p_175713_1_);
}
@ -641,7 +670,7 @@
}
public void func_147457_a(TileEntity p_147457_1_)
@@ -2315,7 +2494,7 @@
@@ -2315,7 +2507,7 @@
if (chunk1 != null && !chunk1.func_76621_g())
{
IBlockState iblockstate1 = this.func_180495_p(p_175677_1_);
@ -650,7 +679,7 @@
}
else
{
@@ -2338,6 +2517,7 @@
@@ -2338,6 +2530,7 @@
{
this.field_72985_G = p_72891_1_;
this.field_72992_H = p_72891_2_;
@ -658,7 +687,7 @@
}
public void func_72835_b()
@@ -2347,6 +2527,11 @@
@@ -2347,6 +2540,11 @@
protected void func_72947_a()
{
@ -670,7 +699,7 @@
if (this.field_72986_A.func_76059_o())
{
this.field_73004_o = 1.0F;
@@ -2360,6 +2545,11 @@
@@ -2360,6 +2558,11 @@
protected void func_72979_l()
{
@ -682,7 +711,7 @@
if (this.field_73011_w.func_191066_m())
{
if (!this.field_72995_K)
@@ -2484,6 +2674,11 @@
@@ -2484,6 +2687,11 @@
public boolean func_175670_e(BlockPos p_175670_1_, boolean p_175670_2_)
{
@ -694,7 +723,7 @@
Biome biome = this.func_180494_b(p_175670_1_);
float f = biome.func_180626_a(p_175670_1_);
@@ -2525,6 +2720,11 @@
@@ -2525,6 +2733,11 @@
public boolean func_175708_f(BlockPos p_175708_1_, boolean p_175708_2_)
{
@ -706,7 +735,7 @@
Biome biome = this.func_180494_b(p_175708_1_);
float f = biome.func_180626_a(p_175708_1_);
@@ -2542,7 +2742,7 @@
@@ -2542,7 +2755,7 @@
{
IBlockState iblockstate1 = this.func_180495_p(p_175708_1_);
@ -715,7 +744,7 @@
{
return true;
}
@@ -2574,10 +2774,11 @@
@@ -2574,10 +2787,11 @@
else
{
IBlockState iblockstate1 = this.func_180495_p(p_175638_1_);
@ -730,7 +759,7 @@
{
k2 = 1;
}
@@ -2683,7 +2884,8 @@
@@ -2683,7 +2897,8 @@
int k6 = k4 + enumfacing.func_96559_d();
int l6 = l4 + enumfacing.func_82599_e();
blockpos$pooledmutableblockpos.func_181079_c(j6, k6, l6);
@ -740,7 +769,7 @@
j5 = this.func_175642_b(p_180500_1_, blockpos$pooledmutableblockpos);
if (j5 == i5 - i7 && k2 < this.field_72994_J.length)
@@ -2791,10 +2993,10 @@
@@ -2791,10 +3006,10 @@
public List<Entity> func_175674_a(@Nullable Entity p_175674_1_, AxisAlignedBB p_175674_2_, @Nullable Predicate <? super Entity > p_175674_3_)
{
List<Entity> list = Lists.<Entity>newArrayList();
@ -755,7 +784,7 @@
for (int j3 = j2; j3 <= k2; ++j3)
{
@@ -2847,10 +3049,10 @@
@@ -2847,10 +3062,10 @@
public <T extends Entity> List<T> func_175647_a(Class <? extends T > p_175647_1_, AxisAlignedBB p_175647_2_, @Nullable Predicate <? super T > p_175647_3_)
{
@ -770,7 +799,7 @@
List<T> list = Lists.<T>newArrayList();
for (int j3 = j2; j3 < k2; ++j3)
@@ -2930,11 +3132,13 @@
@@ -2930,11 +3145,13 @@
public void func_175650_b(Collection<Entity> p_175650_1_)
{
@ -787,7 +816,7 @@
}
}
@@ -2958,7 +3162,7 @@
@@ -2958,7 +3175,7 @@
}
else
{
@ -796,7 +825,7 @@
}
}
@@ -3042,7 +3246,7 @@
@@ -3042,7 +3259,7 @@
public int func_175651_c(BlockPos p_175651_1_, EnumFacing p_175651_2_)
{
IBlockState iblockstate1 = this.func_180495_p(p_175651_1_);
@ -805,7 +834,7 @@
}
public boolean func_175640_z(BlockPos p_175640_1_)
@@ -3208,6 +3412,8 @@
@@ -3208,6 +3425,8 @@
d2 *= ((Double)MoreObjects.firstNonNull(p_184150_11_.apply(entityplayer1), Double.valueOf(1.0D))).doubleValue();
}
@ -814,7 +843,7 @@
if ((p_184150_9_ < 0.0D || Math.abs(entityplayer1.field_70163_u - p_184150_3_) < p_184150_9_ * p_184150_9_) && (p_184150_7_ < 0.0D || d1 < d2 * d2) && (d0 == -1.0D || d1 < d0))
{
d0 = d1;
@@ -3269,7 +3475,7 @@
@@ -3269,7 +3488,7 @@
public long func_72905_C()
{
@ -823,7 +852,7 @@
}
public long func_82737_E()
@@ -3279,17 +3485,17 @@
@@ -3279,17 +3498,17 @@
public long func_72820_D()
{
@ -844,7 +873,7 @@
if (!this.func_175723_af().func_177746_a(blockpos1))
{
@@ -3301,7 +3507,7 @@
@@ -3301,7 +3520,7 @@
public void func_175652_B(BlockPos p_175652_1_)
{
@ -853,7 +882,7 @@
}
@SideOnly(Side.CLIENT)
@@ -3321,12 +3527,18 @@
@@ -3321,12 +3540,18 @@
if (!this.field_72996_f.contains(p_72897_1_))
{
@ -872,7 +901,7 @@
return true;
}
@@ -3428,8 +3640,7 @@
@@ -3428,8 +3653,7 @@
public boolean func_180502_D(BlockPos p_180502_1_)
{
@ -882,7 +911,7 @@
}
@Nullable
@@ -3490,12 +3701,12 @@
@@ -3490,12 +3714,12 @@
public int func_72800_K()
{
@ -897,7 +926,7 @@
}
public Random func_72843_D(int p_72843_1_, int p_72843_2_, int p_72843_3_)
@@ -3539,7 +3750,7 @@
@@ -3539,7 +3763,7 @@
@SideOnly(Side.CLIENT)
public double func_72919_O()
{
@ -906,7 +935,7 @@
}
public void func_175715_c(int p_175715_1_, BlockPos p_175715_2_, int p_175715_3_)
@@ -3573,7 +3784,7 @@
@@ -3573,7 +3797,7 @@
public void func_175666_e(BlockPos p_175666_1_, Block p_175666_2_)
{
@ -915,7 +944,7 @@
{
BlockPos blockpos1 = p_175666_1_.func_177972_a(enumfacing);
@@ -3581,18 +3792,15 @@
@@ -3581,18 +3805,15 @@
{
IBlockState iblockstate1 = this.func_180495_p(blockpos1);
@ -938,7 +967,7 @@
}
}
}
@@ -3658,6 +3866,124 @@
@@ -3658,6 +3879,124 @@
return j2 >= -128 && j2 <= 128 && k2 >= -128 && k2 <= 128;
}