RenderGlobalMixin.java (2027B)
1 package ambos.vanillafixes.mixin; 2 3 import org.lwjgl.opengl.GL11; 4 import org.spongepowered.asm.mixin.Mixin; 5 import org.spongepowered.asm.mixin.Shadow; 6 import org.spongepowered.asm.mixin.injection.At; 7 import org.spongepowered.asm.mixin.injection.Inject; 8 import org.spongepowered.asm.mixin.injection.Redirect; 9 import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; 10 11 import ambos.vanillafixes.VanillaFixes; 12 import net.minecraft.client.render.RenderGlobal; 13 14 @Mixin(value = RenderGlobal.class, remap = false) 15 final class RenderGlobalMixin { 16 @Shadow 17 private int countEntitiesTotal; 18 @Shadow 19 private int countEntitiesRendered; 20 @Shadow 21 private int renderersLoaded; 22 @Shadow 23 private int renderersBeingRendered; 24 25 @Inject(method = "getRendererDebugInfo", at = @At("HEAD"), require = 0, cancellable = true) 26 private void changeFormatting(CallbackInfoReturnable<String> cir) { 27 if (VanillaFixes.F3_MENU) { 28 cir.setReturnValue("Renderers: " + this.renderersBeingRendered + "/" + this.renderersLoaded); 29 } 30 } 31 32 @Inject(method = "getEntityDebugInfo", at = @At("HEAD"), require = 0, cancellable = true) 33 private void changeFormatting2(CallbackInfoReturnable<String> cir) { 34 if (VanillaFixes.F3_MENU) { 35 cir.setReturnValue("Entities: " + this.countEntitiesRendered + "/" + this.countEntitiesTotal); 36 } 37 } 38 39 @Redirect(method = "renderSortedRenderers", at = @At(value = "INVOKE", target = "Lorg/lwjgl/opengl/GL11;glEnable(I)V", ordinal = 0)) 40 private void cancelCallglEnable(int cap) { 41 // Fix fog rendering underwater. 42 if (!VanillaFixes.FOG) { 43 GL11.glEnable(cap); 44 } 45 } 46 47 @Redirect(method = "renderSortedRenderers", at = @At(value = "INVOKE", target = "Lorg/lwjgl/opengl/GL11;glDisable(I)V", ordinal = 0)) 48 private void cancelCallglDisable(int cap) { 49 // Fix fog rendering underwater. 50 if (!VanillaFixes.FOG) { 51 GL11.glDisable(cap); 52 } 53 } 54 }