diff options
author | Linnea Gräf <nea@nea.moe> | 2024-10-18 16:35:18 +0200 |
---|---|---|
committer | Linnea Gräf <nea@nea.moe> | 2024-10-18 16:35:18 +0200 |
commit | c71fca6cc633416162b2dd010c52182662ceff85 (patch) | |
tree | 71b13f7f666d6b3ade6cded1266b5856a47e3c21 /src/main/java | |
parent | c89b663acad487caeb15f7521be3dd14342dd4e7 (diff) | |
download | Firmament-c71fca6cc633416162b2dd010c52182662ceff85.tar.gz Firmament-c71fca6cc633416162b2dd010c52182662ceff85.tar.bz2 Firmament-c71fca6cc633416162b2dd010c52182662ceff85.zip |
Add custom inventory text color texture pack support
Diffstat (limited to 'src/main/java')
-rw-r--r-- | src/main/java/moe/nea/firmament/mixins/ReplaceTextColorInHandledScreen.java | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/src/main/java/moe/nea/firmament/mixins/ReplaceTextColorInHandledScreen.java b/src/main/java/moe/nea/firmament/mixins/ReplaceTextColorInHandledScreen.java new file mode 100644 index 0000000..190fda0 --- /dev/null +++ b/src/main/java/moe/nea/firmament/mixins/ReplaceTextColorInHandledScreen.java @@ -0,0 +1,43 @@ +package moe.nea.firmament.mixins; + + +import com.llamalad7.mixinextras.injector.wrapoperation.Operation; +import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; +import moe.nea.firmament.features.texturepack.CustomTextColors; +import net.minecraft.client.font.TextRenderer; +import net.minecraft.client.gui.DrawContext; +import net.minecraft.client.gui.screen.ingame.AnvilScreen; +import net.minecraft.client.gui.screen.ingame.BeaconScreen; +import net.minecraft.client.gui.screen.ingame.CreativeInventoryScreen; +import net.minecraft.client.gui.screen.ingame.HandledScreen; +import net.minecraft.client.gui.screen.ingame.InventoryScreen; +import net.minecraft.client.gui.screen.ingame.MerchantScreen; +import net.minecraft.text.Text; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; + +@Mixin({HandledScreen.class, InventoryScreen.class, CreativeInventoryScreen.class, MerchantScreen.class, + AnvilScreen.class, BeaconScreen.class}) +public class ReplaceTextColorInHandledScreen { + + @WrapOperation( + method = "drawForeground", + at = @At( + value = "INVOKE", + target = "Lnet/minecraft/client/gui/DrawContext;drawText(Lnet/minecraft/client/font/TextRenderer;Lnet/minecraft/text/Text;IIIZ)I"), + expect = 0) + private int replaceTextColorWithVariableShadow(DrawContext instance, TextRenderer textRenderer, Text text, int x, int y, int color, boolean shadow, Operation<Integer> original) { + return original.call(instance, textRenderer, text, x, y, CustomTextColors.INSTANCE.mapTextColor(text, color), shadow); + } + + @WrapOperation( + method = "drawForeground", + at = @At( + value = "INVOKE", + target = "Lnet/minecraft/client/gui/DrawContext;drawTextWithShadow(Lnet/minecraft/client/font/TextRenderer;Lnet/minecraft/text/Text;III)I"), + expect = 0) + private int replaceTextColorWithShadow(DrawContext instance, TextRenderer textRenderer, Text text, int x, int y, int color, Operation<Integer> original) { + return original.call(instance, textRenderer, text, x, y, CustomTextColors.INSTANCE.mapTextColor(text, color)); + } + +} |