|
| 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