Skip to content

Commit

Permalink
subprojectify
Browse files Browse the repository at this point in the history
  • Loading branch information
tildejustin committed Jan 9, 2024
1 parent a936bc3 commit 61083bd
Show file tree
Hide file tree
Showing 50 changed files with 769 additions and 169 deletions.
10 changes: 10 additions & 0 deletions 1.13.2/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
plugins {
id "loom"
id "legacy-looming"
}

dependencies {
minecraft "com.mojang:minecraft:$minecraft_version"
mappings(legacy.yarn(minecraft_version, yarn_build))
implementation project(path: ":", configuration: "namedElements")
}
2 changes: 2 additions & 0 deletions 1.13.2/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
minecraft_version=1.13.2
yarn_build=533
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
import org.spongepowered.asm.mixin.injection.*;

@Pseudo
@Mixin(targets = "optifine.Patcher", remap = false)
public class PatcherMixin {
@Mixin(targets = "optifine.Patcher")
public abstract class PatcherMixin {
@SuppressWarnings("UnresolvedMixinReference")
@Redirect(method = "process", at = @At(value = "INVOKE", target = "Ljava/lang/String;equals(Ljava/lang/Object;)Z"))
private static boolean ignoreHashFailure(String instance, Object o) {
// not used for anything at the moment but could fix issues with named mappings?
return true;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package me.modmuss50.optifabric.mixin;

import org.spongepowered.asm.mixin.*;
import org.spongepowered.asm.mixin.injection.*;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

// suppresses some warnings in the log
@Pseudo
@Mixin(targets = "ReflectorClass")
public class ReflectorClassMixin {
@Shadow
private String targetClassName;

@Shadow
private boolean checked;

@SuppressWarnings("UnresolvedMixinReference")
@Inject(method = "getTargetClass", at = @At("HEAD"), remap = false)
private void getTargetClass(CallbackInfoReturnable<Class<?>> infoReturnable) {
if (!checked) { // only check the target if it hasn't been done yet
String name = targetClassName.replaceAll("/", ".");
if (name.startsWith("net.minecraft.launchwrapper") || name.startsWith("net.minecraftforge") || "optifine.OptiFineClassTransformer".equals(name)) {
checked = true;
}
}
}
}
28 changes: 28 additions & 0 deletions 1.13.2/src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"schemaVersion": 1,
"id": "optifabric-mixin",
"version": "${version}",
"name": "Optifabric Mixin",
"description": "Optifabric is a mod that loads Optifine into Fabric",
"authors": [
"Modmuss50",
"Chocohead",
"Hydos",
"RedLime",
"tildejustin"
],
"contact": {
"homepage": "https://modrinth.com/mod/legacy-optifabric",
"sources": "https://github.com/tildejustin/optifabric",
"issues": "https://github.com/tildejustin/optifabric/issues"
},
"mixins": [
"optifabric.mixins.json"
],
"license": "MPL-2.0",
"environment": "client",
"depends": {
"fabricloader": ">=0.14",
"minecraft": ">=1.13 <=1.13.2"
}
}
File renamed without changes.
9 changes: 9 additions & 0 deletions 1.13.2/src/main/resources/optifabric.optifine.mixins.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"required": true,
"package": "me.modmuss50.optifabric.mixin",
"compatibilityLevel": "JAVA_8",
"mixins": [
"PatcherMixin",
"ReflectorClassMixin"
]
}
10 changes: 10 additions & 0 deletions 1.3-1.5.2/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
plugins {
id "loom"
id "legacy-looming"
}

dependencies {
minecraft "com.mojang:minecraft:$minecraft_version"
mappings(legacy.yarn(minecraft_version, yarn_build))
implementation project(path: ":", configuration: "namedElements")
}
2 changes: 2 additions & 0 deletions 1.3-1.5.2/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
minecraft_version=1.3.2
yarn_build=533
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package me.modmuss50.optifabric.mixin;

import me.modmuss50.optifabric.mod.*;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.screen.*;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.*;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

@Mixin(TitleScreen.class)
public abstract class TitleScreenMixin extends Screen {
@Inject(method = "init", at = @At("RETURN"))
private void init(CallbackInfo info) {
if (Optifabric.hasError()) {
System.out.println("an optifabric error has occurred");
}
}

@Inject(method = "render", at = @At("RETURN"))
private void render(CallbackInfo ci) {
if (!Optifabric.hasError()) {
this.drawWithShadow(Minecraft.getMinecraft().textRenderer, OptifineVersion.version, 2, this.height - 20, 0xFFFFFFFF);
}
}
}
29 changes: 29 additions & 0 deletions 1.3-1.5.2/src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"schemaVersion": 1,
"id": "optifabric-mixin",
"version": "${version}",
"name": "Optifabric Mixin",
"description": "Optifabric is a mod that loads Optifine into Fabric",
"authors": [
"Modmuss50",
"Chocohead",
"Hydos",
"RedLime",
"tildejustin"
],
"contact": {
"homepage": "https://modrinth.com/mod/legacy-optifabric",
"sources": "https://github.com/tildejustin/optifabric",
"issues": "https://github.com/tildejustin/optifabric/issues"
},
"mixins": [
"optifabric.mixins.json"
],
"license": "MPL-2.0",
"environment": "client",
"depends": {
"fabricloader": ">=0.14",
"minecraft": ">=1.3 <=1.5.2"
},
"accessWidener": "optifabric.accesswidener"
}
9 changes: 9 additions & 0 deletions 1.3-1.5.2/src/main/resources/optifabric.accesswidener
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
accessWidener v2 named
accessible field net/minecraft/client/gui/widget/ButtonWidget width I
accessible field net/minecraft/client/gui/widget/ButtonWidget height I
accessible field net/minecraft/client/option/GameOptions field_946 Lnet/minecraft/client/Minecraft;
accessible field net/minecraft/client/particle/Particle red F
accessible field net/minecraft/client/particle/Particle green F
accessible field net/minecraft/client/particle/Particle blue F
accessible field net/minecraft/world/World levelProperties Lnet/minecraft/world/level/LevelProperties;
accessible field net/minecraft/client/render/GameRenderer lightmapFlicker F
8 changes: 8 additions & 0 deletions 1.3-1.5.2/src/main/resources/optifabric.mixins.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"required": true,
"package": "me.modmuss50.optifabric.mixin",
"compatibilityLevel": "JAVA_8",
"client": [
"TitleScreenMixin"
]
}
10 changes: 10 additions & 0 deletions 1.6-1.7.10/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
plugins {
id "loom"
id "legacy-looming"
}

dependencies {
minecraft "com.mojang:minecraft:$minecraft_version"
mappings(legacy.yarn(minecraft_version, yarn_build))
implementation project(path: ":", configuration: "namedElements")
}
2 changes: 2 additions & 0 deletions 1.6-1.7.10/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
minecraft_version=1.7.10
yarn_build=533
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,20 @@
import org.spongepowered.asm.mixin.injection.*;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

// suppresses some warnings in the log
// suppresses some warnings in the logs
@Pseudo
@Mixin(targets = "net.optifine.reflect.ReflectorClass", remap = false)
@Mixin(targets = "ReflectorClass")
public class ReflectorClassMixin {
@Shadow
private String targetClassName;

@Shadow
private boolean checked;

@SuppressWarnings("UnresolvedMixinReference")
@Inject(method = "getTargetClass", at = @At("HEAD"), remap = false)
private void getTargetClass(CallbackInfoReturnable<Class<?>> infoReturnable) {
if (!this.checked) {
// only check the target if it hasn't been done yet
if (!this.checked) { // only check the target if it hasn't been done yet
String name = this.targetClassName.replaceAll("/", ".");
if (name.startsWith("net.minecraft.launchwrapper") || name.startsWith("net.minecraftforge") || "optifine.OptiFineClassTransformer".equals(name)) {
this.checked = true;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package me.modmuss50.optifabric.mixin;

import me.modmuss50.optifabric.mod.*;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.screen.*;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.*;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

@Mixin(TitleScreen.class)
public abstract class TitleScreenMixin extends Screen {
@Inject(method = "init", at = @At("RETURN"))
private void init(CallbackInfo info) {
if (Optifabric.hasError()) {
System.out.println("an optifabric error has occurred");
}
}

@Inject(method = "render", at = @At("RETURN"))
private void render(CallbackInfo ci) {
if (!Optifabric.hasError()) {
this.drawWithShadow(MinecraftClient.getInstance().textRenderer, OptifineVersion.version, 2, this.height - 20, 0xFFFFFFFF);
}
}
}
29 changes: 29 additions & 0 deletions 1.6-1.7.10/src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"schemaVersion": 1,
"id": "optifabric-mixin",
"version": "${version}",
"name": "Optifabric Mixin",
"description": "Optifabric is a mod that loads Optifine into Fabric",
"authors": [
"Modmuss50",
"Chocohead",
"Hydos",
"RedLime",
"tildejustin"
],
"contact": {
"homepage": "https://modrinth.com/mod/legacy-optifabric",
"sources": "https://github.com/tildejustin/optifabric",
"issues": "https://github.com/tildejustin/optifabric/issues"
},
"mixins": [
"optifabric.mixins.json"
],
"license": "MPL-2.0",
"environment": "client",
"depends": {
"fabricloader": ">=0.14",
"minecraft": ">=1.6 <=1.7.10"
},
"accessWidener": "optifabric.accesswidener"
}
14 changes: 14 additions & 0 deletions 1.6-1.7.10/src/main/resources/optifabric.accesswidener
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
accessWidener v2 named
accessible method net/minecraft/block/Block setOpacity (I)Lnet/minecraft/block/Block;
accessible field net/minecraft/resource/AbstractFileResourcePack base Ljava/io/File;
accessible field net/minecraft/entity/LivingEntity despawnCounter I
accessible method net/minecraft/entity/mob/MobEntity checkDespawn ()V
accessible method net/minecraft/util/Language getInstance ()Lnet/minecraft/util/Language;
accessible field net/minecraft/client/particle/Particle red F
accessible field net/minecraft/client/particle/Particle green F
accessible field net/minecraft/client/particle/Particle blue F
accessible field net/minecraft/client/gui/widget/ButtonWidget width I
accessible field net/minecraft/client/gui/widget/ButtonWidget height I
accessible method net/minecraft/client/texture/TextureUtil bindTexture (I)V
accessible field net/minecraft/client/render/GameRenderer lightmapFlicker F
accessible method net/minecraft/block/Block method_462 (I)Lnet/minecraft/block/Block;
8 changes: 8 additions & 0 deletions 1.6-1.7.10/src/main/resources/optifabric.mixins.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"required": true,
"package": "me.modmuss50.optifabric.mixin",
"compatibilityLevel": "JAVA_8",
"client": [
"TitleScreenMixin"
]
}
8 changes: 8 additions & 0 deletions 1.6-1.7.10/src/main/resources/optifabric.optifine.mixins.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"required": true,
"package": "me.modmuss50.optifabric.mixin",
"compatibilityLevel": "JAVA_8",
"mixins": [
"ReflectorClassMixin"
]
}
10 changes: 10 additions & 0 deletions 1.8-1.12.2/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
plugins {
id "loom"
id "legacy-looming"
}

dependencies {
minecraft "com.mojang:minecraft:$minecraft_version"
mappings(legacy.yarn(minecraft_version, yarn_build))
implementation project(path: ":", configuration: "namedElements")
}
2 changes: 2 additions & 0 deletions 1.8-1.12.2/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
minecraft_version=1.12.2
yarn_build=533
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
import org.spongepowered.asm.mixin.injection.*;

@Pseudo
@Mixin(targets = "net.optifine.util.NativeMemory", remap = false)
@Mixin(targets = "net.optifine.util.NativeMemory")
public class NativeMemoryMixin {
@SuppressWarnings("UnresolvedMixinReference")
@ModifyArg(method = "<clinit>", at = @At(value = "INVOKE", target = "Lnet/optifine/util/NativeMemory;makeLongSupplier([[Ljava/lang/String;)Ljava/util/function/LongSupplier;", ordinal = 0))
private static String[][] addNewSharedSecretsLocation(String[][] paths) {
// package of SharedSecrets changed in java 12, add the new location
return new String[][]{paths[0], paths[1], {"jdk.internal.access.SharedSecrets", "getJavaNioAccess", "getDirectBufferPool", "getMemoryUsed"}};
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package me.modmuss50.optifabric.mixin;

import org.spongepowered.asm.mixin.*;
import org.spongepowered.asm.mixin.injection.*;

@Pseudo
@Mixin(targets = "optifine.Patcher")
public abstract class PatcherMixin {
@SuppressWarnings("UnresolvedMixinReference")
@Redirect(method = "process", at = @At(value = "INVOKE", target = "Ljava/lang/String;equals(Ljava/lang/Object;)Z"))
private static boolean ignoreHashFailure(String instance, Object o) {
return true;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package me.modmuss50.optifabric.mixin;

import org.spongepowered.asm.mixin.*;
import org.spongepowered.asm.mixin.injection.*;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

// suppresses some warnings in the logs
@Pseudo
@Mixin(targets = "net.optifine.reflect.ReflectorClass")
public class ReflectorClassMixin {
@Shadow
private String targetClassName;

@Shadow
private boolean checked;

@SuppressWarnings("UnresolvedMixinReference")
@Inject(method = "getTargetClass", at = @At("HEAD"), remap = false)
private void getTargetClass(CallbackInfoReturnable<Class<?>> infoReturnable) {
if (!this.checked) { // only check the target if it hasn't been done yet
String name = this.targetClassName.replaceAll("/", ".");
if (name.startsWith("net.minecraft.launchwrapper") || name.startsWith("net.minecraftforge") || "optifine.OptiFineClassTransformer".equals(name)) {
this.checked = true;
}
}
}
}
Loading

0 comments on commit 61083bd

Please sign in to comment.