From ad7e4e95aed24a5e0871ca900649a5cd3e8fe578 Mon Sep 17 00:00:00 2001 From: Take Weiland Date: Wed, 22 Jan 2020 20:22:35 +0100 Subject: [PATCH] Use extended version of getLightValue in all places (#6433) --- .../net/minecraft/block/Block.java.patch | 9 +++++++++ .../renderer/BlockModelRenderer.java.patch | 3 ++- .../client/renderer/WorldRenderer.java.patch | 9 +++++++++ .../minecraft/world/IBlockReader.java.patch | 11 +++++++++++ .../world/chunk/ChunkPrimer.java.patch | 18 ++++++++++++++++++ .../chunk/storage/ChunkSerializer.java.patch | 9 +++++++++ .../world/gen/NoiseChunkGenerator.java.patch | 13 +++++++++++++ .../common/extensions/IForgeBlock.java | 2 +- .../common/extensions/IForgeBlockState.java | 2 +- 9 files changed, 73 insertions(+), 3 deletions(-) create mode 100644 patches/minecraft/net/minecraft/world/IBlockReader.java.patch create mode 100644 patches/minecraft/net/minecraft/world/chunk/ChunkPrimer.java.patch create mode 100644 patches/minecraft/net/minecraft/world/gen/NoiseChunkGenerator.java.patch diff --git a/patches/minecraft/net/minecraft/block/Block.java.patch b/patches/minecraft/net/minecraft/block/Block.java.patch index 62a310d62..b40b70e56 100644 --- a/patches/minecraft/net/minecraft/block/Block.java.patch +++ b/patches/minecraft/net/minecraft/block/Block.java.patch @@ -13,6 +13,15 @@ private static final Direction[] field_212556_a = new Direction[]{Direction.WEST, Direction.EAST, Direction.NORTH, Direction.SOUTH, Direction.DOWN, Direction.UP}; private static final LoadingCache field_223006_b = CacheBuilder.newBuilder().maximumSize(512L).weakKeys().build(new CacheLoader() { public Boolean load(VoxelShape p_load_1_) { +@@ -151,7 +152,7 @@ + + @Deprecated + public boolean func_220067_a(BlockState p_220067_1_, IBlockReader p_220067_2_, BlockPos p_220067_3_, EntityType p_220067_4_) { +- return p_220067_1_.func_224755_d(p_220067_2_, p_220067_3_, Direction.UP) && this.field_149784_t < 14; ++ return p_220067_1_.func_224755_d(p_220067_2_, p_220067_3_, Direction.UP) && p_220067_1_.getLightValue(p_220067_2_, p_220067_3_) < 14; + } + + @Deprecated @@ -246,6 +247,10 @@ this.field_149781_w = p_i48440_1_.field_200958_f; this.field_149782_v = p_i48440_1_.field_200959_g; diff --git a/patches/minecraft/net/minecraft/client/renderer/BlockModelRenderer.java.patch b/patches/minecraft/net/minecraft/client/renderer/BlockModelRenderer.java.patch index 4b083cafb..3ca707fa8 100644 --- a/patches/minecraft/net/minecraft/client/renderer/BlockModelRenderer.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/BlockModelRenderer.java.patch @@ -6,10 +6,11 @@ + @Deprecated //Forge: Model data argument public boolean func_228802_a_(ILightReader p_228802_1_, IBakedModel p_228802_2_, BlockState p_228802_3_, BlockPos p_228802_4_, MatrixStack p_228802_5_, IVertexBuilder p_228802_6_, boolean p_228802_7_, Random p_228802_8_, long p_228802_9_, int p_228802_11_) { +- boolean flag = Minecraft.func_71379_u() && p_228802_3_.func_185906_d() == 0 && p_228802_2_.func_177555_b(); + return renderModel(p_228802_1_, p_228802_2_, p_228802_3_, p_228802_4_, p_228802_5_, p_228802_6_, p_228802_7_, p_228802_8_, p_228802_9_, p_228802_11_, net.minecraftforge.client.model.data.EmptyModelData.INSTANCE); + } + public boolean renderModel(ILightReader p_228802_1_, IBakedModel p_228802_2_, BlockState p_228802_3_, BlockPos p_228802_4_, MatrixStack p_228802_5_, IVertexBuilder p_228802_6_, boolean p_228802_7_, Random p_228802_8_, long p_228802_9_, int p_228802_11_, net.minecraftforge.client.model.data.IModelData modelData) { - boolean flag = Minecraft.func_71379_u() && p_228802_3_.func_185906_d() == 0 && p_228802_2_.func_177555_b(); ++ boolean flag = Minecraft.func_71379_u() && p_228802_3_.getLightValue(p_228802_1_, p_228802_4_) == 0 && p_228802_2_.func_177555_b(); Vec3d vec3d = p_228802_3_.func_191059_e(p_228802_1_, p_228802_4_); p_228802_5_.func_227861_a_(vec3d.field_72450_a, vec3d.field_72448_b, vec3d.field_72449_c); + modelData = p_228802_2_.getModelData(p_228802_1_, p_228802_4_, p_228802_3_, modelData); diff --git a/patches/minecraft/net/minecraft/client/renderer/WorldRenderer.java.patch b/patches/minecraft/net/minecraft/client/renderer/WorldRenderer.java.patch index 64e1f088f..f8942da18 100644 --- a/patches/minecraft/net/minecraft/client/renderer/WorldRenderer.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/WorldRenderer.java.patch @@ -96,6 +96,15 @@ this.field_72769_h.func_184156_a(p_180439_3_, soundtype.func_185845_c(), SoundCategory.BLOCKS, (soundtype.func_185843_a() + 1.0F) / 2.0F, soundtype.func_185847_b() * 0.8F, false); } +@@ -2432,7 +2447,7 @@ + } else { + int i = p_228420_0_.func_226658_a_(LightType.SKY, p_228420_2_); + int j = p_228420_0_.func_226658_a_(LightType.BLOCK, p_228420_2_); +- int k = p_228420_1_.func_185906_d(); ++ int k = p_228420_1_.getLightValue(p_228420_0_, p_228420_2_); + if (j < k) { + j = k; + } @@ -2445,6 +2460,11 @@ return this.field_175015_z; } diff --git a/patches/minecraft/net/minecraft/world/IBlockReader.java.patch b/patches/minecraft/net/minecraft/world/IBlockReader.java.patch new file mode 100644 index 000000000..3d612f585 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/IBlockReader.java.patch @@ -0,0 +1,11 @@ +--- a/net/minecraft/world/IBlockReader.java ++++ b/net/minecraft/world/IBlockReader.java +@@ -23,7 +23,7 @@ + IFluidState func_204610_c(BlockPos p_204610_1_); + + default int func_217298_h(BlockPos p_217298_1_) { +- return this.func_180495_p(p_217298_1_).func_185906_d(); ++ return this.func_180495_p(p_217298_1_).getLightValue(this, p_217298_1_); + } + + default int func_201572_C() { diff --git a/patches/minecraft/net/minecraft/world/chunk/ChunkPrimer.java.patch b/patches/minecraft/net/minecraft/world/chunk/ChunkPrimer.java.patch new file mode 100644 index 000000000..e7ecbf746 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/chunk/ChunkPrimer.java.patch @@ -0,0 +1,18 @@ +--- a/net/minecraft/world/chunk/ChunkPrimer.java ++++ b/net/minecraft/world/chunk/ChunkPrimer.java +@@ -136,13 +136,13 @@ + if (this.field_201661_i[j >> 4] == Chunk.field_186036_a && p_177436_2_.func_177230_c() == Blocks.field_150350_a) { + return p_177436_2_; + } else { +- if (p_177436_2_.func_185906_d() > 0) { ++ if (p_177436_2_.getLightValue(this, p_177436_1_) > 0) { + this.field_201663_k.add(new BlockPos((i & 15) + this.func_76632_l().func_180334_c(), j, (k & 15) + this.func_76632_l().func_180333_d())); + } + + ChunkSection chunksection = this.func_217332_a(j >> 4); + BlockState blockstate = chunksection.func_222629_a(i & 15, j & 15, k & 15, p_177436_2_); +- if (this.field_201658_f.func_209003_a(ChunkStatus.field_222613_i) && p_177436_2_ != blockstate && (p_177436_2_.func_200016_a(this, p_177436_1_) != blockstate.func_200016_a(this, p_177436_1_) || p_177436_2_.func_185906_d() != blockstate.func_185906_d() || p_177436_2_.func_215691_g() || blockstate.func_215691_g())) { ++ if (this.field_201658_f.func_209003_a(ChunkStatus.field_222613_i) && p_177436_2_ != blockstate && (p_177436_2_.func_200016_a(this, p_177436_1_) != blockstate.func_200016_a(this, p_177436_1_) || p_177436_2_.getLightValue(this, p_177436_1_) != blockstate.getLightValue(this, p_177436_1_) || p_177436_2_.func_215691_g() || blockstate.func_215691_g())) { + WorldLightManager worldlightmanager = this.func_217307_e(); + worldlightmanager.func_215568_a(p_177436_1_); + } diff --git a/patches/minecraft/net/minecraft/world/chunk/storage/ChunkSerializer.java.patch b/patches/minecraft/net/minecraft/world/chunk/storage/ChunkSerializer.java.patch index ec8afb354..7edd688bf 100644 --- a/patches/minecraft/net/minecraft/world/chunk/storage/ChunkSerializer.java.patch +++ b/patches/minecraft/net/minecraft/world/chunk/storage/ChunkSerializer.java.patch @@ -8,6 +8,15 @@ } else { ChunkPrimer chunkprimer = new ChunkPrimer(p_222656_3_, upgradedata, achunksection, chunkprimerticklist, chunkprimerticklist1); chunkprimer.func_225548_a_(biomecontainer); +@@ -143,7 +144,7 @@ + + if (!flag && chunkprimer.func_201589_g().func_209003_a(ChunkStatus.field_222614_j)) { + for(BlockPos blockpos : BlockPos.func_191531_b(p_222656_3_.func_180334_c(), 0, p_222656_3_.func_180333_d(), p_222656_3_.func_180332_e(), 255, p_222656_3_.func_180330_f())) { +- if (ichunk.func_180495_p(blockpos).func_185906_d() != 0) { ++ if (ichunk.func_180495_p(blockpos).getLightValue(ichunk, blockpos) != 0) { + chunkprimer.func_201637_h(blockpos); + } + } @@ -294,12 +295,22 @@ for(int k = 0; k < chunk.func_177429_s().length; ++k) { for(Entity entity : chunk.func_177429_s()[k]) { diff --git a/patches/minecraft/net/minecraft/world/gen/NoiseChunkGenerator.java.patch b/patches/minecraft/net/minecraft/world/gen/NoiseChunkGenerator.java.patch new file mode 100644 index 000000000..b9ce49b05 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/gen/NoiseChunkGenerator.java.patch @@ -0,0 +1,13 @@ +--- a/net/minecraft/world/gen/NoiseChunkGenerator.java ++++ b/net/minecraft/world/gen/NoiseChunkGenerator.java +@@ -378,8 +378,8 @@ + } + + if (blockstate != field_222562_i) { +- if (blockstate.func_185906_d() != 0) { +- blockpos$mutable.func_181079_c(j3, j2, i4); ++ blockpos$mutable.func_181079_c(j3, j2, i4); ++ if (blockstate.getLightValue(chunkprimer, blockpos$mutable) != 0) { + chunkprimer.func_201637_h(blockpos$mutable); + } + diff --git a/src/main/java/net/minecraftforge/common/extensions/IForgeBlock.java b/src/main/java/net/minecraftforge/common/extensions/IForgeBlock.java index 0c1a9195f..07cfaee77 100644 --- a/src/main/java/net/minecraftforge/common/extensions/IForgeBlock.java +++ b/src/main/java/net/minecraftforge/common/extensions/IForgeBlock.java @@ -117,7 +117,7 @@ public interface IForgeBlock * @param pos * @return The light value */ - default int getLightValue(BlockState state, ILightReader world, BlockPos pos) + default int getLightValue(BlockState state, IBlockReader world, BlockPos pos) { return state.getLightValue(); } diff --git a/src/main/java/net/minecraftforge/common/extensions/IForgeBlockState.java b/src/main/java/net/minecraftforge/common/extensions/IForgeBlockState.java index b22d8f46f..fca5aa956 100644 --- a/src/main/java/net/minecraftforge/common/extensions/IForgeBlockState.java +++ b/src/main/java/net/minecraftforge/common/extensions/IForgeBlockState.java @@ -84,7 +84,7 @@ public interface IForgeBlockState /** * Get a light value for this block, taking into account the given state and coordinates, normal ranges are between 0 and 15 */ - default int getLightValue(ILightReader world, BlockPos pos) + default int getLightValue(IBlockReader world, BlockPos pos) { return getBlockState().getBlock().getLightValue(getBlockState(), world, pos); }