Skip to content

Commit bd52779

Browse files
committed
fix: Crash with mist475's unofficial Dynamic Surroundings fork
Closes: #51
1 parent b79d717 commit bd52779

3 files changed

Lines changed: 70 additions & 24 deletions

File tree

src/main/java/com/falsepattern/rple/internal/mixin/Mixin.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ public enum Mixin implements IMixins {
7878
"ChunkCacheMixin",
7979
"EntityMixin",
8080
"EntityRendererMixin",
81+
"EntityRendererMixin_Weather",
8182
"GuiIngameForgeMixin",
8283
"OpenGLHelperMixin",
8384
"RenderBlocksMixin",

src/main/java/com/falsepattern/rple/internal/mixin/mixins/client/EntityRendererMixin.java

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -110,28 +110,4 @@ private void renderLightValueOverlay(float partialTickTime, long expectedFrameDo
110110
if (RGB_LIGHT_OVERLAY)
111111
LightValueOverlayRenderer.renderLightValueOverlay();
112112
}
113-
114-
@WrapOperation(method = "renderRainSnow",
115-
at = @At(value = "INVOKE",
116-
target = "Lnet/minecraft/client/renderer/Tessellator;setBrightness(I)V",
117-
ordinal = 1),
118-
// DynamicSurroundings replaces the whole method
119-
require = 0,
120-
expect = 0)
121-
private void suppressSetBrightness(Tessellator instance, int light, Operation<Void> original) {
122-
123-
}
124-
@WrapOperation(method = "renderRainSnow",
125-
at = @At(value = "INVOKE",
126-
target = "Lnet/minecraft/client/multiplayer/WorldClient;getLightBrightnessForSkyBlocks(IIII)I",
127-
ordinal = 1),
128-
// DynamicSurroundings replaces the whole method
129-
require = 0,
130-
expect = 0)
131-
private int fixSnow1(WorldClient instance, int x, int y, int z, int min, Operation<Integer> original, @Local Tessellator tessellator) {
132-
val brightness = original.call(instance, x, y, z, min);
133-
val shifted = CookieMonster.cookieFromRGB64(ClientColorHelper.RGB64ForEach(CookieMonster.RGB64FromCookie(brightness), c -> (c * 3 + 0xf0) / 4));
134-
tessellator.setBrightness(shifted);
135-
return 0;
136-
}
137113
}
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
/*
2+
* Right Proper Lighting Engine
3+
*
4+
* Copyright (C) 2023-2025 FalsePattern, Ven
5+
* All Rights Reserved
6+
*
7+
* The above copyright notice and this permission notice
8+
* shall be included in all copies or substantial portions of the Software.
9+
*
10+
* This program is free software: you can redistribute it and/or modify
11+
* it under the terms of the GNU Affero General Public License as published by
12+
* the Free Software Foundation, only version 3 of the License.
13+
*
14+
* This program is distributed in the hope that it will be useful,
15+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
16+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17+
* GNU Affero General Public License for more details.
18+
*
19+
* You should have received a copy of the GNU Affero General Public License
20+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
21+
*
22+
* This program comes with additional permissions according to Section 7 of the
23+
* GNU Affero General Public License. See the full LICENSE file for details.
24+
*/
25+
26+
package com.falsepattern.rple.internal.mixin.mixins.client;
27+
28+
import com.falsepattern.rple.api.client.ClientColorHelper;
29+
import com.falsepattern.rple.api.client.CookieMonster;
30+
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
31+
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
32+
import com.llamalad7.mixinextras.sugar.Local;
33+
import lombok.val;
34+
import org.spongepowered.asm.mixin.Mixin;
35+
import org.spongepowered.asm.mixin.injection.At;
36+
37+
import net.minecraft.client.multiplayer.WorldClient;
38+
import net.minecraft.client.renderer.EntityRenderer;
39+
import net.minecraft.client.renderer.Tessellator;
40+
41+
@Mixin(value = EntityRenderer.class,
42+
//For compatibility with mist475 Dynamic Surroundings fork
43+
priority = 1100)
44+
public abstract class EntityRendererMixin_Weather {
45+
@WrapOperation(method = "renderRainSnow",
46+
at = @At(value = "INVOKE",
47+
target = "Lnet/minecraft/client/renderer/Tessellator;setBrightness(I)V",
48+
ordinal = 1),
49+
// DynamicSurroundings replaces the whole method
50+
require = 0,
51+
expect = 0)
52+
private void suppressSetBrightness(Tessellator instance, int light, Operation<Void> original) {
53+
54+
}
55+
@WrapOperation(method = "renderRainSnow",
56+
at = @At(value = "INVOKE",
57+
target = "Lnet/minecraft/client/multiplayer/WorldClient;getLightBrightnessForSkyBlocks(IIII)I",
58+
ordinal = 1),
59+
// DynamicSurroundings replaces the whole method
60+
require = 0,
61+
expect = 0)
62+
private int fixSnow1(WorldClient instance, int x, int y, int z, int min, Operation<Integer> original, @Local
63+
Tessellator tessellator) {
64+
val brightness = original.call(instance, x, y, z, min);
65+
val shifted = CookieMonster.cookieFromRGB64(ClientColorHelper.RGB64ForEach(CookieMonster.RGB64FromCookie(brightness), c -> (c * 3 + 0xf0) / 4));
66+
tessellator.setBrightness(shifted);
67+
return 0;
68+
}
69+
}

0 commit comments

Comments
 (0)