ForgePatch/patches/minecraft/net/minecraft/world/ChunkCache.java.patch

75 lines
3 KiB
Diff

--- ../src-base/minecraft/net/minecraft/world/ChunkCache.java
+++ ../src-work/minecraft/net/minecraft/world/ChunkCache.java
@@ -61,7 +61,7 @@
@Nullable
public TileEntity func_175625_s(BlockPos p_175625_1_)
{
- return this.func_190300_a(p_175625_1_, Chunk.EnumCreateEntityType.IMMEDIATE);
+ return this.func_190300_a(p_175625_1_, Chunk.EnumCreateEntityType.CHECK); // Forge: don't modify world from other threads
}
@Nullable
@@ -69,6 +69,7 @@
{
int i = (p_190300_1_.func_177958_n() >> 4) - this.field_72818_a;
int j = (p_190300_1_.func_177952_p() >> 4) - this.field_72816_b;
+ if (!withinBounds(i, j)) return null;
return this.field_72817_c[i][j].func_177424_a(p_190300_1_, p_190300_2_);
}
@@ -112,6 +113,7 @@
{
int i = (p_180494_1_.func_177958_n() >> 4) - this.field_72818_a;
int j = (p_180494_1_.func_177952_p() >> 4) - this.field_72816_b;
+ if (!withinBounds(i, j)) return net.minecraft.init.Biomes.field_76772_c;
return this.field_72817_c[i][j].func_177411_a(p_180494_1_, this.field_72815_e.func_72959_q());
}
@@ -149,6 +151,7 @@
{
int i = (p_175629_2_.func_177958_n() >> 4) - this.field_72818_a;
int j = (p_175629_2_.func_177952_p() >> 4) - this.field_72816_b;
+ if (!withinBounds(i, j)) return p_175629_1_.field_77198_c;
return this.field_72817_c[i][j].func_177413_a(p_175629_1_, p_175629_2_);
}
}
@@ -160,7 +163,8 @@
public boolean func_175623_d(BlockPos p_175623_1_)
{
- return this.func_180495_p(p_175623_1_).func_185904_a() == Material.field_151579_a;
+ IBlockState state = this.func_180495_p(p_175623_1_);
+ return state.func_177230_c().isAir(state, this, p_175623_1_);
}
@SideOnly(Side.CLIENT)
@@ -170,6 +174,7 @@
{
int i = (p_175628_2_.func_177958_n() >> 4) - this.field_72818_a;
int j = (p_175628_2_.func_177952_p() >> 4) - this.field_72816_b;
+ if (!withinBounds(i, j)) return p_175628_1_.field_77198_c;
return this.field_72817_c[i][j].func_177413_a(p_175628_1_, p_175628_2_);
}
else
@@ -188,4 +193,21 @@
{
return this.field_72815_e.func_175624_G();
}
+
+ @Override
+ public boolean isSideSolid(BlockPos pos, EnumFacing side, boolean _default)
+ {
+ int x = (pos.func_177958_n() >> 4) - this.field_72818_a;
+ int z = (pos.func_177952_p() >> 4) - this.field_72816_b;
+ if (pos.func_177956_o() < 0 || pos.func_177956_o() >= 256) return _default;
+ if (!withinBounds(x, z)) return _default;
+
+ IBlockState state = func_180495_p(pos);
+ return state.func_177230_c().isSideSolid(state, this, pos, side);
+ }
+
+ private boolean withinBounds(int x, int z)
+ {
+ return x >= 0 && x < field_72817_c.length && z >= 0 && z < field_72817_c[x].length && field_72817_c[x][z] != null;
+ }
}