Skip to content

Commit

Permalink
Should fix connected texture issues.
Browse files Browse the repository at this point in the history
  • Loading branch information
modmuss50 committed Mar 27, 2020
1 parent c9e0203 commit 068a3bf
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 2 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ fabric_asm_version=v2.0
zt_zip_version=1.14
slf4j_version=1.7.30

mod_version = 1.0.0-beta5
mod_version = 1.0.0-beta6
maven_group = me.modmuss50
archives_base_name = optifabric
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package me.modmuss50.optifabric.mixin;

import me.modmuss50.optifabric.mod.OptifabricSetup;
import me.modmuss50.optifabric.util.OptifineZipResourcePack;
import net.minecraft.client.resource.ClientBuiltinResourcePackProvider;
import net.minecraft.resource.ResourcePackProfile;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

import java.io.File;
import java.util.Map;

@Mixin(ClientBuiltinResourcePackProvider.class)
public class MixinClientBuiltinResourcePackProvider {

@Inject(method = "register", at = @At("RETURN"))
public <T extends ResourcePackProfile> void register(Map<String, T> registry, ResourcePackProfile.Factory<T> factory, CallbackInfo info) {
File file = OptifabricSetup.optifineRuntimeJar;
if (file != null && file.isFile()) {
T optifineResourcePack = ResourcePackProfile.of("optifine", true, OptifineZipResourcePack.getSupplier(file), factory, ResourcePackProfile.InsertionPosition.TOP);
registry.put("optifine", optifineResourcePack);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
public class OptifabricSetup implements Runnable {

public static final String OPTIFABRIC_INCOMPATIBLE = "optifabric:incompatible";
public static File optifineRuntimeJar = null;

//This is called early on to allow us to get the transformers in beofore minecraft starts
@Override
Expand All @@ -37,6 +38,8 @@ public void run() {

OptifineInjector injector = new OptifineInjector(runtime.getRight());
injector.setup();

optifineRuntimeJar = runtime.getLeft();
} catch (Throwable e) {
if(!OptifabricError.hasError()){
OptifineVersion.jarType = OptifineVersion.JarType.INCOMPATIBE;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package me.modmuss50.optifabric.util;

import com.google.gson.JsonObject;
import net.minecraft.resource.ResourcePack;
import net.minecraft.resource.ZipResourcePack;
import net.minecraft.resource.metadata.ResourceMetadataReader;
import net.minecraft.util.Formatting;

import java.io.File;
import java.io.IOException;
import java.util.function.Supplier;

public class OptifineZipResourcePack extends ZipResourcePack {
public OptifineZipResourcePack(File file) {
super(file);
}

@Override
public String getName() {
return "Optifine Internal Resources";
}

@Override
public <T> T parseMetadata(ResourceMetadataReader<T> metaReader) throws IOException {
JsonObject pack = new JsonObject();
pack.addProperty("pack_format", 5);
pack.addProperty("description", "Added by OptiFabric\n" + Formatting.RED.toString() + "Do not disable");
pack.add("pack", new JsonObject());

if (!pack.has(metaReader.getKey())) {
return null;
}

return metaReader.fromJson(pack);
}

public static Supplier<ResourcePack> getSupplier(File file) {
return () -> new OptifineZipResourcePack(file);
}
}
3 changes: 2 additions & 1 deletion src/main/resources/optifabric.optifine.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
"compatibilityLevel": "JAVA_8",
"mixins": [
"MixinReflectorClass",
"MixinScreen"
"MixinScreen",
"MixinClientBuiltinResourcePackProvider"
],
"injectors": {
"defaultRequire": 1
Expand Down

0 comments on commit 068a3bf

Please sign in to comment.