|
3 | 3 | import com.mojang.blaze3d.vertex.*; |
4 | 4 | import com.mojang.math.Matrix4f; |
5 | 5 | import gdavid.psionicutilities.PsionicUtilities; |
| 6 | +import net.minecraft.client.gui.screens.Screen; |
6 | 7 | import net.minecraft.client.renderer.MultiBufferSource; |
7 | 8 | import net.minecraft.client.resources.model.Material; |
| 9 | +import net.minecraft.network.chat.Component; |
8 | 10 | import net.minecraft.network.chat.TextColor; |
9 | 11 | import net.minecraft.resources.ResourceLocation; |
10 | 12 | import org.spongepowered.asm.mixin.Mixin; |
11 | | -import org.spongepowered.asm.mixin.injection.At; |
12 | | -import org.spongepowered.asm.mixin.injection.Inject; |
13 | | -import org.spongepowered.asm.mixin.injection.Redirect; |
| 13 | +import org.spongepowered.asm.mixin.injection.*; |
14 | 14 |
|
15 | 15 | import gdavid.psionicutilities.Util; |
16 | 16 | import net.minecraftforge.api.distmarker.Dist; |
|
23 | 23 |
|
24 | 24 | import java.util.Arrays; |
25 | 25 | import java.util.Optional; |
| 26 | +import java.util.List; |
26 | 27 |
|
27 | 28 | @Mixin(value = SpellPiece.class, remap = false) |
28 | 29 | public abstract class SpellPieceMixin { |
@@ -56,6 +57,26 @@ private void drawBackground(PoseStack ms, MultiBufferSource buffers, int light, |
56 | 57 | } |
57 | 58 | } |
58 | 59 |
|
| 60 | + @OnlyIn(Dist.CLIENT) |
| 61 | + @Inject(method = "drawComment", at = @At("HEAD"), cancellable = true) |
| 62 | + private void drawComment(PoseStack ms, MultiBufferSource buffers, int light, CallbackInfo callback) { |
| 63 | + SpellPiece self = (SpellPiece) (Object) this; |
| 64 | + if (self.comment != null) { |
| 65 | + String prefix = "@color="; |
| 66 | + if (Arrays.stream(self.comment.split(";")).allMatch(ln -> |
| 67 | + ln.startsWith(prefix) && TextColor.parseColor(ln.substring(prefix.length())) != null |
| 68 | + )) callback.cancel(); |
| 69 | + } |
| 70 | + } |
| 71 | + |
| 72 | + @OnlyIn(Dist.CLIENT) |
| 73 | + @Inject(method = "drawCommentText", at = @At("HEAD")) |
| 74 | + private void visibleCommentText(PoseStack ms, int tooltipX, int tooltipY, List<Component> commentText, Screen screen, CallbackInfo callback) { |
| 75 | + String prefix = "@color="; |
| 76 | + commentText.stream().filter(ln -> ln.getString().startsWith(prefix)).findFirst().ifPresent(commentText::remove); |
| 77 | + } |
| 78 | + |
| 79 | + @OnlyIn(Dist.CLIENT) |
59 | 80 | private void drawHighlight(PoseStack ms, MultiBufferSource buffers, int light, int value) { |
60 | 81 | int r = (value >> 16) & 0xFF; |
61 | 82 | int g = (value >> 8) & 0xFF; |
|
0 commit comments