|
| 1 | +package sunsetsatellite.catalyst.core.mixin; |
| 2 | + |
| 3 | +import net.minecraft.client.render.FontRenderer; |
| 4 | +import net.minecraft.client.render.LightmapHelper; |
| 5 | +import net.minecraft.client.render.tessellator.Tessellator; |
| 6 | +import org.lwjgl.opengl.GL11; |
| 7 | +import org.spongepowered.asm.mixin.Mixin; |
| 8 | +import org.spongepowered.asm.mixin.Unique; |
| 9 | +import org.spongepowered.asm.mixin.injection.At; |
| 10 | +import org.spongepowered.asm.mixin.injection.Inject; |
| 11 | +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; |
| 12 | +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; |
| 13 | +import sunsetsatellite.catalyst.core.util.IColorOverride; |
| 14 | +import sunsetsatellite.catalyst.core.util.Vec4f; |
| 15 | + |
| 16 | +@Mixin(value = FontRenderer.class,remap = false) |
| 17 | +public class FontRendererMixin implements IColorOverride { |
| 18 | + |
| 19 | + @Unique |
| 20 | + private Vec4f colorOverride = new Vec4f(1); |
| 21 | + @Unique |
| 22 | + private boolean fullbright = false; |
| 23 | + |
| 24 | + @Inject(method = "renderStringAtPos",at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/tessellator/Tessellator;startDrawingQuads()V",shift = At.Shift.AFTER)) |
| 25 | + public void disableLightmap(String text, boolean flag, CallbackInfo ci){ |
| 26 | + GL11.glColor4d(colorOverride.x,colorOverride.y,colorOverride.z,colorOverride.w); |
| 27 | + if(LightmapHelper.isLightmapEnabled() && fullbright) Tessellator.instance.setLightmapCoord(LightmapHelper.getLightmapCoord(15,15)); |
| 28 | + } |
| 29 | + |
| 30 | + @Inject(method = "renderDefaultChar",at = @At(value = "INVOKE", target = "Lorg/lwjgl/opengl/GL11;glBegin(I)V",shift = At.Shift.BEFORE)) |
| 31 | + public void disableLightmap2(char c, boolean italic, CallbackInfoReturnable<Float> cir){ |
| 32 | + if(LightmapHelper.isLightmapEnabled() && fullbright) LightmapHelper.setLightmapCoord(15,15); |
| 33 | + } |
| 34 | + |
| 35 | + @Inject(method = "renderUnicodeChar",at = @At(value = "INVOKE", target = "Lorg/lwjgl/opengl/GL11;glBegin(I)V",shift = At.Shift.BEFORE)) |
| 36 | + public void disableLightmap3(char c, boolean italic, CallbackInfoReturnable<Float> cir){ |
| 37 | + if(LightmapHelper.isLightmapEnabled() && fullbright) LightmapHelper.setLightmapCoord(15,15); |
| 38 | + } |
| 39 | + |
| 40 | + @Override |
| 41 | + public void overrideColor(float r, float g, float b, float alpha) { |
| 42 | + colorOverride = new Vec4f(r,g,b,alpha); |
| 43 | + } |
| 44 | + |
| 45 | + @Override |
| 46 | + public void enableFullbright() { |
| 47 | + fullbright = true; |
| 48 | + } |
| 49 | + |
| 50 | + @Override |
| 51 | + public void disableFullbright() { |
| 52 | + fullbright = false; |
| 53 | + } |
| 54 | +} |
0 commit comments