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

Commit

Permalink
Allow disabling of the internal resources, should allow for better re…
Browse files Browse the repository at this point in the history
…source pack compatibility. Closes #156
  • Loading branch information
modmuss50 committed Mar 29, 2020
1 parent f39aa9d commit 20e6511
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 4 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-beta7-test1
mod_version = 1.0.0-beta8
maven_group = me.modmuss50
archives_base_name = optifabric
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class MixinClientBuiltinResourcePackProvider {
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);
T optifineResourcePack = ResourcePackProfile.of("optifine", false, OptifineZipResourcePack.getSupplier(file), factory, ResourcePackProfile.InsertionPosition.TOP);
registry.put("optifine", optifineResourcePack);
}
}
Expand Down
39 changes: 39 additions & 0 deletions src/main/java/me/modmuss50/optifabric/mixin/MixinGameOptions.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package me.modmuss50.optifabric.mixin;

import net.minecraft.client.options.GameOptions;
import org.spongepowered.asm.mixin.Final;
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.io.File;
import java.io.IOException;
import java.util.List;

@Mixin(GameOptions.class)
public class MixinGameOptions {

@Shadow public List<String> resourcePacks;

@Shadow @Final private File optionsFile;

@Inject(method = "load", at = @At("RETURN"))
private void load(CallbackInfo info) {
File optifabricOptions = new File(optionsFile.getParent(), "optifabric.txt");
if (!optifabricOptions.exists()) {

//Add optifine to resource packs if optifabric.txt doesnt exist, makes it default on, but can be disabled.
if (!resourcePacks.contains("optifine")) {
resourcePacks.add("optifine");
}

try {
optifabricOptions.createNewFile();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public String getName() {
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.addProperty("description", "Added by OptiFabric\n" + Formatting.RED.toString() + "Disable if you have issues.");
pack.add("pack", new JsonObject());

if (!pack.has(metaReader.getKey())) {
Expand Down
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 @@ -6,7 +6,8 @@
"MixinReflectorClass",
"MixinScreen",
"MixinClientBuiltinResourcePackProvider",
"MixinOptifineConfig"
"MixinOptifineConfig",
"MixinGameOptions"
],
"injectors": {
"defaultRequire": 1
Expand Down

0 comments on commit 20e6511

Please sign in to comment.