From 91dda36b08c37e2f090971235e01230c261cc83f Mon Sep 17 00:00:00 2001 From: Alex O'Neill <35673674+alcatrazEscapee@users.noreply.github.com> Date: Tue, 22 Sep 2020 14:41:07 -0400 Subject: [PATCH] [1.16] Reimplement ICloudRenderHandler, ISkyRenderHandler and IWeatherRenderHandler (#6994) --- .../client/renderer/WorldRenderer.java.patch | 64 +++++++++++++++---- .../world/DimensionRenderInfo.java.patch | 41 ++++++++++++ .../client/CloudRenderHandler.java | 8 ++- .../client/ICloudRenderHandler.java | 33 ++++++++++ .../minecraftforge/client/IRenderHandler.java | 8 ++- .../client/ISkyRenderHandler.java | 33 ++++++++++ .../client/IWeatherRenderHandler.java | 33 ++++++++++ .../client/SkyRenderHandler.java | 9 ++- .../client/WeatherRenderHandler.java | 8 ++- 9 files changed, 213 insertions(+), 24 deletions(-) create mode 100644 patches/minecraft/net/minecraft/client/world/DimensionRenderInfo.java.patch create mode 100644 src/main/java/net/minecraftforge/client/ICloudRenderHandler.java create mode 100644 src/main/java/net/minecraftforge/client/ISkyRenderHandler.java create mode 100644 src/main/java/net/minecraftforge/client/IWeatherRenderHandler.java diff --git a/patches/minecraft/net/minecraft/client/renderer/WorldRenderer.java.patch b/patches/minecraft/net/minecraft/client/renderer/WorldRenderer.java.patch index 67cc7794e..b18df6d9d 100644 --- a/patches/minecraft/net/minecraft/client/renderer/WorldRenderer.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/WorldRenderer.java.patch @@ -1,6 +1,18 @@ --- a/net/minecraft/client/renderer/WorldRenderer.java +++ b/net/minecraft/client/renderer/WorldRenderer.java -@@ -830,7 +830,7 @@ +@@ -222,6 +222,11 @@ + } + + private void func_228438_a_(LightTexture p_228438_1_, float p_228438_2_, double p_228438_3_, double p_228438_5_, double p_228438_7_) { ++ net.minecraftforge.client.IWeatherRenderHandler renderHandler = field_72769_h.func_239132_a_().getWeatherRenderHandler(); ++ if (renderHandler != null) { ++ renderHandler.render(field_72773_u, p_228438_2_, field_72769_h, field_72777_q, p_228438_1_, p_228438_3_, p_228438_5_, p_228438_7_); ++ return; ++ } + float f = this.field_72777_q.field_71441_e.func_72867_j(p_228438_2_); + if (!(f <= 0.0F)) { + p_228438_1_.func_205109_c(); +@@ -830,7 +835,7 @@ this.field_147595_R = true; BlockPos blockpos2 = chunkrenderdispatcher$chunkrender4.func_178568_j().func_177982_a(8, 8, 8); boolean flag1 = blockpos2.func_177951_i(blockpos) < 768.0D; @@ -9,7 +21,7 @@ this.field_175009_l.add(chunkrenderdispatcher$chunkrender4); } else { this.field_72777_q.func_213239_aq().func_76320_a("build near"); -@@ -915,13 +915,13 @@ +@@ -915,13 +920,13 @@ float f = p_228426_7_.func_205001_m(); boolean flag1 = this.field_72777_q.field_71441_e.func_239132_a_().func_230493_a_(MathHelper.func_76128_c(d0), MathHelper.func_76128_c(d1)) || this.field_72777_q.field_71456_v.func_184046_j().func_184056_f(); if (this.field_72777_q.field_71474_y.field_151451_c >= 4) { @@ -25,7 +37,7 @@ iprofiler.func_219895_b("terrain_setup"); this.func_228437_a_(p_228426_6_, clippinghelper, flag, this.field_228409_ai_++, this.field_72777_q.field_71439_g.func_175149_v()); iprofiler.func_219895_b("updatechunks"); -@@ -942,7 +942,9 @@ +@@ -942,7 +947,9 @@ this.func_174967_a(p_228426_3_ + l1); iprofiler.func_219895_b("terrain"); this.func_228441_a_(RenderType.func_228639_c_(), p_228426_1_, d0, d1, d2); @@ -35,7 +47,7 @@ this.func_228441_a_(RenderType.func_228643_e_(), p_228426_1_, d0, d1, d2); if (this.field_72769_h.func_239132_a_().func_239217_c_()) { RenderHelper.func_237533_a_(p_228426_1_.func_227866_c_().func_227870_a_()); -@@ -1010,6 +1012,7 @@ +@@ -1010,6 +1017,7 @@ List list = worldrenderer$localrenderinformationcontainer.field_178036_a.func_178571_g().func_178485_b(); if (!list.isEmpty()) { for(TileEntity tileentity1 : list) { @@ -43,7 +55,7 @@ BlockPos blockpos3 = tileentity1.func_174877_v(); IRenderTypeBuffer irendertypebuffer1 = irendertypebuffer$impl; p_228426_1_.func_227860_a_(); -@@ -1035,6 +1038,7 @@ +@@ -1035,6 +1043,7 @@ synchronized(this.field_181024_n) { for(TileEntity tileentity : this.field_181024_n) { @@ -51,7 +63,7 @@ BlockPos blockpos2 = tileentity.func_174877_v(); p_228426_1_.func_227860_a_(); p_228426_1_.func_227861_a_((double)blockpos2.func_177958_n() - d0, (double)blockpos2.func_177956_o() - d1, (double)blockpos2.func_177952_p() - d2); -@@ -1084,10 +1088,13 @@ +@@ -1084,10 +1093,13 @@ iprofiler.func_219895_b("outline"); BlockPos blockpos = ((BlockRayTraceResult)raytraceresult).func_216350_a(); BlockState blockstate = this.field_72769_h.func_180495_p(blockpos); @@ -66,7 +78,7 @@ } RenderSystem.pushMatrix(); -@@ -1119,7 +1126,7 @@ +@@ -1119,7 +1131,7 @@ this.field_239224_H_.func_237506_a_(this.field_72777_q.func_147110_a()); RenderState.field_239237_T_.func_228547_a_(); iprofiler.func_219895_b("particles"); @@ -75,7 +87,7 @@ RenderState.field_239237_T_.func_228549_b_(); } else { iprofiler.func_219895_b("translucent"); -@@ -1129,7 +1136,7 @@ +@@ -1129,7 +1141,7 @@ iprofiler.func_219895_b("string"); this.func_228441_a_(RenderType.func_241715_r_(), p_228426_1_, d0, d1, d2); iprofiler.func_219895_b("particles"); @@ -84,7 +96,31 @@ } RenderSystem.pushMatrix(); -@@ -2076,7 +2083,12 @@ +@@ -1481,6 +1493,11 @@ + } + + public void func_228424_a_(MatrixStack p_228424_1_, float p_228424_2_) { ++ net.minecraftforge.client.ISkyRenderHandler renderHandler = field_72769_h.func_239132_a_().getSkyRenderHandler(); ++ if (renderHandler != null) { ++ renderHandler.render(field_72773_u, p_228424_2_, p_228424_1_, field_72769_h, field_72777_q); ++ return; ++ } + if (this.field_72777_q.field_71441_e.func_239132_a_().func_241683_c_() == DimensionRenderInfo.FogType.END) { + this.func_228444_b_(p_228424_1_); + } else if (this.field_72777_q.field_71441_e.func_239132_a_().func_241683_c_() == DimensionRenderInfo.FogType.NORMAL) { +@@ -1609,6 +1626,11 @@ + } + + public void func_228425_a_(MatrixStack p_228425_1_, float p_228425_2_, double p_228425_3_, double p_228425_5_, double p_228425_7_) { ++ net.minecraftforge.client.ICloudRenderHandler renderHandler = field_72769_h.func_239132_a_().getCloudRenderHandler(); ++ if (renderHandler != null) { ++ renderHandler.render(field_72773_u, p_228425_2_, p_228425_1_, field_72769_h, field_72777_q, p_228425_3_, p_228425_5_, p_228425_7_); ++ return; ++ } + float f = this.field_72769_h.func_239132_a_().func_239213_a_(); + if (!Float.isNaN(f)) { + RenderSystem.disableCull(); +@@ -2076,7 +2098,12 @@ this.field_175008_n.func_217628_a(p_215319_1_, p_215319_2_, p_215319_3_, p_215319_4_); } @@ -97,7 +133,7 @@ ISound isound = this.field_147593_P.get(p_184377_2_); if (isound != null) { this.field_72777_q.func_147118_V().func_147683_b(isound); -@@ -2084,7 +2096,7 @@ +@@ -2084,7 +2111,7 @@ } if (p_184377_1_ != null) { @@ -106,7 +142,7 @@ if (musicdiscitem != null) { this.field_72777_q.field_71456_v.func_238451_a_(musicdiscitem.func_234801_g_()); } -@@ -2232,7 +2244,7 @@ +@@ -2232,7 +2259,7 @@ break; case 1010: if (Item.func_150899_d(p_180439_4_) instanceof MusicDiscItem) { @@ -115,7 +151,7 @@ } else { this.func_184377_a((SoundEvent)null, p_180439_3_); } -@@ -2382,8 +2394,8 @@ +@@ -2382,8 +2409,8 @@ break; case 2001: BlockState blockstate = Block.func_196257_b(p_180439_4_); @@ -126,7 +162,7 @@ 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); } -@@ -2531,7 +2543,7 @@ +@@ -2531,7 +2558,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_); @@ -135,7 +171,7 @@ if (j < k) { j = k; } -@@ -2570,6 +2582,11 @@ +@@ -2570,6 +2597,11 @@ return this.field_239226_J_; } diff --git a/patches/minecraft/net/minecraft/client/world/DimensionRenderInfo.java.patch b/patches/minecraft/net/minecraft/client/world/DimensionRenderInfo.java.patch new file mode 100644 index 000000000..d7cdfaec6 --- /dev/null +++ b/patches/minecraft/net/minecraft/client/world/DimensionRenderInfo.java.patch @@ -0,0 +1,41 @@ +--- a/net/minecraft/client/world/DimensionRenderInfo.java ++++ b/net/minecraft/client/world/DimensionRenderInfo.java +@@ -26,6 +26,9 @@ + private final DimensionRenderInfo.FogType field_241680_e_; + private final boolean field_241681_f_; + private final boolean field_239212_e_; ++ private net.minecraftforge.client.IWeatherRenderHandler weatherRenderHandler = null; ++ private net.minecraftforge.client.ISkyRenderHandler skyRenderHandler = null; ++ private net.minecraftforge.client.ICloudRenderHandler cloudRenderHandler = null; + + public DimensionRenderInfo(float p_i241259_1_, boolean p_i241259_2_, DimensionRenderInfo.FogType p_i241259_3_, boolean p_i241259_4_, boolean p_i241259_5_) { + this.field_239210_c_ = p_i241259_1_; +@@ -82,6 +85,28 @@ + return this.field_239212_e_; + } + ++ public void setWeatherRenderHandler(net.minecraftforge.client.IWeatherRenderHandler weatherRenderHandler) { ++ this.weatherRenderHandler = weatherRenderHandler; ++ } ++ public void setSkyRenderHandler(net.minecraftforge.client.ISkyRenderHandler skyRenderHandler) { ++ this.skyRenderHandler = skyRenderHandler; ++ } ++ public void setCloudRenderHandler(net.minecraftforge.client.ICloudRenderHandler cloudRenderHandler) { ++ this.cloudRenderHandler = cloudRenderHandler; ++ } ++ @Nullable ++ public net.minecraftforge.client.ICloudRenderHandler getCloudRenderHandler() { ++ return cloudRenderHandler; ++ } ++ @Nullable ++ public net.minecraftforge.client.IWeatherRenderHandler getWeatherRenderHandler() { ++ return weatherRenderHandler; ++ } ++ @Nullable ++ public net.minecraftforge.client.ISkyRenderHandler getSkyRenderHandler() { ++ return skyRenderHandler; ++ } ++ + @OnlyIn(Dist.CLIENT) + public static class End extends DimensionRenderInfo { + public End() { diff --git a/src/main/java/net/minecraftforge/client/CloudRenderHandler.java b/src/main/java/net/minecraftforge/client/CloudRenderHandler.java index dbf5d9203..d9de9911b 100644 --- a/src/main/java/net/minecraftforge/client/CloudRenderHandler.java +++ b/src/main/java/net/minecraftforge/client/CloudRenderHandler.java @@ -24,12 +24,14 @@ import net.minecraft.client.Minecraft; import net.minecraft.client.world.ClientWorld; /** - * Call {@link net.minecraft.world.dimension.Dimension#setCloudRenderer} with an implementation of this - * to override all cloud rendering with your own. + * Use {@link ICloudRenderHandler} instead. + * + * todo: remove in 1.17 */ +@Deprecated public interface CloudRenderHandler extends IRenderHandler { @Override default void render(int ticks, float partialTicks, ClientWorld world, Minecraft mc) {} void render(int ticks, float partialTicks, MatrixStack matrixStack, ClientWorld world, Minecraft mc); -} +} \ No newline at end of file diff --git a/src/main/java/net/minecraftforge/client/ICloudRenderHandler.java b/src/main/java/net/minecraftforge/client/ICloudRenderHandler.java new file mode 100644 index 000000000..1a9f5ff93 --- /dev/null +++ b/src/main/java/net/minecraftforge/client/ICloudRenderHandler.java @@ -0,0 +1,33 @@ +/* + * Minecraft Forge + * Copyright (c) 2016-2020. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation version 2.1 + * of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +package net.minecraftforge.client; + +import com.mojang.blaze3d.matrix.MatrixStack; +import net.minecraft.client.Minecraft; +import net.minecraft.client.world.ClientWorld; + +/** + * Call {@link net.minecraft.client.world.DimensionRenderInfo#setCloudRenderHandler(ICloudRenderHandler)}, obtained from a {@link ClientWorld} with an implementation of this to override all cloud rendering with your own. + * This is only responsible for rendering clouds. + */ +@FunctionalInterface +public interface ICloudRenderHandler { + void render(int ticks, float partialTicks, MatrixStack matrixStack, ClientWorld world, Minecraft mc, double viewEntityX, double viewEntityY, double viewEntityZ); +} diff --git a/src/main/java/net/minecraftforge/client/IRenderHandler.java b/src/main/java/net/minecraftforge/client/IRenderHandler.java index 1344471ed..78b66ebbc 100644 --- a/src/main/java/net/minecraftforge/client/IRenderHandler.java +++ b/src/main/java/net/minecraftforge/client/IRenderHandler.java @@ -24,9 +24,15 @@ import net.minecraft.client.Minecraft; import net.minecraft.client.world.ClientWorld; import net.minecraftforge.api.distmarker.OnlyIn; +/** +* Use one of {@link IWeatherRenderHandler}, {@link ICloudRenderHandler} or {@link ISkyRenderHandler} instead. +* +* todo: remove in 1.17 +*/ +@Deprecated @FunctionalInterface public interface IRenderHandler { @OnlyIn(Dist.CLIENT) void render(int ticks, float partialTicks, ClientWorld world, Minecraft mc); -} +} \ No newline at end of file diff --git a/src/main/java/net/minecraftforge/client/ISkyRenderHandler.java b/src/main/java/net/minecraftforge/client/ISkyRenderHandler.java new file mode 100644 index 000000000..6dbd27dd0 --- /dev/null +++ b/src/main/java/net/minecraftforge/client/ISkyRenderHandler.java @@ -0,0 +1,33 @@ +/* + * Minecraft Forge + * Copyright (c) 2016-2020. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation version 2.1 + * of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +package net.minecraftforge.client; + +import com.mojang.blaze3d.matrix.MatrixStack; +import net.minecraft.client.Minecraft; +import net.minecraft.client.world.ClientWorld; + +/** + * Call {@link net.minecraft.client.world.DimensionRenderInfo#setSkyRenderHandler(ISkyRenderHandler)}, obtained from a {@link ClientWorld} with an implementation of this to override all sky rendering with your own. + * This includes the sun, moon, stars, and sky-coloring. + */ +@FunctionalInterface +public interface ISkyRenderHandler { + void render(int ticks, float partialTicks, MatrixStack matrixStack, ClientWorld world, Minecraft mc); +} diff --git a/src/main/java/net/minecraftforge/client/IWeatherRenderHandler.java b/src/main/java/net/minecraftforge/client/IWeatherRenderHandler.java new file mode 100644 index 000000000..cf30d9041 --- /dev/null +++ b/src/main/java/net/minecraftforge/client/IWeatherRenderHandler.java @@ -0,0 +1,33 @@ +/* + * Minecraft Forge + * Copyright (c) 2016-2020. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation version 2.1 + * of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +package net.minecraftforge.client; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.LightTexture; +import net.minecraft.client.world.ClientWorld; + +/** + * Call {@link net.minecraft.client.world.DimensionRenderInfo#setWeatherRenderHandler(IWeatherRenderHandler)}, obtained from a {@link ClientWorld} with an implementation of this to override all weather rendering with your own. + * This includes rain and snow. + */ +@FunctionalInterface +public interface IWeatherRenderHandler { + void render(int ticks, float partialTicks, ClientWorld world, Minecraft mc, LightTexture lightmapIn, double xIn, double yIn, double zIn); +} diff --git a/src/main/java/net/minecraftforge/client/SkyRenderHandler.java b/src/main/java/net/minecraftforge/client/SkyRenderHandler.java index bf6aada44..3809aa561 100644 --- a/src/main/java/net/minecraftforge/client/SkyRenderHandler.java +++ b/src/main/java/net/minecraftforge/client/SkyRenderHandler.java @@ -1,3 +1,4 @@ + /* * Minecraft Forge * Copyright (c) 2016-2020. @@ -24,13 +25,15 @@ import net.minecraft.client.Minecraft; import net.minecraft.client.world.ClientWorld; /** - * Call {@link net.minecraft.world.dimension.Dimension#setSkyRenderer} with an implementation of this - * to override all sky rendering with your own. This includes the sun, moon, stars, and sky-coloring. + * Use {@link ISkyRenderHandler} instead. + * + * todo: remove in 1.17 */ +@Deprecated public interface SkyRenderHandler extends IRenderHandler { @Override default void render(int ticks, float partialTicks, ClientWorld world, Minecraft mc) {} void render(int ticks, float partialTicks, MatrixStack matrixStack, ClientWorld world, Minecraft mc); -} +} \ No newline at end of file diff --git a/src/main/java/net/minecraftforge/client/WeatherRenderHandler.java b/src/main/java/net/minecraftforge/client/WeatherRenderHandler.java index 51fbac63c..86cbb752b 100644 --- a/src/main/java/net/minecraftforge/client/WeatherRenderHandler.java +++ b/src/main/java/net/minecraftforge/client/WeatherRenderHandler.java @@ -20,8 +20,10 @@ package net.minecraftforge.client; /** - * Call {@link net.minecraft.world.dimension.Dimension#setWeatherRenderer} with an implementation of this - * to override all weather rendering with your own. This includes rain and snow. + * Use {@link IWeatherRenderHandler} instead. + * + * todo: remove in 1.17 */ +@Deprecated public interface WeatherRenderHandler extends IRenderHandler { -} +} \ No newline at end of file