This repository has been archived by the owner on May 30, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 183
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update stitch + add warning for render regions
- Loading branch information
Showing
5 changed files
with
49 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
src/main/java/me/modmuss50/optifabric/mixin/MixinScreen.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package me.modmuss50.optifabric.mixin; | ||
|
||
import me.modmuss50.optifabric.mod.ShaderHelper; | ||
import net.minecraft.client.MinecraftClient; | ||
import net.minecraft.client.font.TextRenderer; | ||
import net.minecraft.client.gui.DrawableHelper; | ||
import net.minecraft.client.gui.screen.Screen; | ||
import net.minecraft.client.options.CyclingOption; | ||
import net.minecraft.client.options.Option; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Shadow; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; | ||
|
||
import java.awt.*; | ||
import java.lang.reflect.Field; | ||
|
||
@Mixin(Screen.class) | ||
public class MixinScreen extends DrawableHelper { | ||
|
||
@Shadow protected TextRenderer font; | ||
|
||
private static CyclingOption RENDER_REGIONS; | ||
|
||
@Inject(method = "render", at = @At("RETURN"), remap = false) | ||
private void render(int int_1, int int_2, float float_1, CallbackInfo ci){ | ||
if(RENDER_REGIONS == null){ | ||
try { | ||
Field field = Option.class.getDeclaredField("RENDER_REGIONS"); | ||
RENDER_REGIONS = (CyclingOption) field.get(null); | ||
} catch (NoSuchFieldException | IllegalAccessException e) { | ||
throw new RuntimeException(e); | ||
} | ||
|
||
} | ||
boolean enabled = RENDER_REGIONS.getMessage(MinecraftClient.getInstance().options).endsWith("ON"); | ||
if(!ShaderHelper.isShadersEnabled() && enabled){ | ||
drawString(font, "OptiFabric: Render Regions is not supported!", 10, 5, Color.RED.getRGB()); | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters