forked from modmuss50/OptiFabric
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Should fix connected texture issues.
- Loading branch information
Showing
5 changed files
with
72 additions
and
2 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
26 changes: 26 additions & 0 deletions
26
src/main/java/me/modmuss50/optifabric/mixin/MixinClientBuiltinResourcePackProvider.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,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); | ||
} | ||
} | ||
} |
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
40 changes: 40 additions & 0 deletions
40
src/main/java/me/modmuss50/optifabric/util/OptifineZipResourcePack.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,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); | ||
} | ||
} |
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