Skip to content
This repository has been archived by the owner on May 30, 2022. It is now read-only.

Commit

Permalink
Update stitch + add warning for render regions
Browse files Browse the repository at this point in the history
  • Loading branch information
modmuss50 committed Jun 29, 2019
1 parent d3422f7 commit e431d3a
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 5 deletions.
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,10 @@ dependencies {
include 'org.slf4j:slf4j-api:1.7.26'

//Used only in dev to generate the field names
compile ('net.fabricmc:stitch:0.1.2.49+') {
compile ('net.fabricmc:stitch:0.2.1.61') {
transitive = false
}
include 'net.fabricmc:stitch:0.1.2.49+'
include 'net.fabricmc:stitch:0.2.1.61'
}

import groovy.json.JsonOutput
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
org.gradle.jvmargs=-Xmx1G

minecraft_version=1.14.3
yarn_mappings=1.14.3+build.1
yarn_mappings=1.14.3+build.9
loader_version=0.4.8+build.155

mod_version = 0.3.0
Expand Down
43 changes: 43 additions & 0 deletions src/main/java/me/modmuss50/optifabric/mixin/MixinScreen.java
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());
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ File getDevMappings() throws Exception {
if (fieldMappings.exists()) {
fieldMappings.delete();
}
fieldNames.run(new String[]{getMinecraftJar().normalize().toString(), extractMappings().getAbsolutePath(), fieldMappings.getAbsolutePath(), "--writeAll"});
fieldNames.run(new String[]{getMinecraftJar().normalize().toString(), extractMappings().getAbsolutePath(), fieldMappings.getAbsolutePath()});
return fieldMappings;
}

Expand Down
3 changes: 2 additions & 1 deletion src/main/resources/optifabric.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
"package": "me.modmuss50.optifabric.mixin",
"compatibilityLevel": "JAVA_8",
"mixins": [
"MixinTitleScreen"
"MixinTitleScreen",
"MixinScreen"
],
"injectors": {
"defaultRequire": 1
Expand Down

0 comments on commit e431d3a

Please sign in to comment.