forked from RedLime/OptiFabric-Pre1.14
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
optifine mod metadata (borrowed from optibabric)
- Loading branch information
1 parent
8b71328
commit 0d53f1b
Showing
9 changed files
with
325 additions
and
12 deletions.
There are no files selected for viewing
32 changes: 32 additions & 0 deletions
32
src/main/java/me/modmuss50/optifabric/metadata/OptifineContactInformation.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,32 @@ | ||
package me.modmuss50.optifabric.metadata; | ||
|
||
import net.fabricmc.loader.api.metadata.ContactInformation; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
import java.util.Optional; | ||
|
||
class OptifineContactInformation implements ContactInformation { | ||
static final OptifineContactInformation INSTANCE = new OptifineContactInformation(); | ||
private static final Map<String, String> OPTIFINE_CONTACTS = new HashMap<>(); | ||
|
||
static { | ||
OPTIFINE_CONTACTS.put("email", "optifinex@gmail.com"); | ||
OPTIFINE_CONTACTS.put("homepage", "https://optifine.net"); | ||
OPTIFINE_CONTACTS.put("issues", "https://github.com/sp614x/optifine/issues"); | ||
OPTIFINE_CONTACTS.put("sources", "https://github.com/sp614x/optifine"); | ||
} | ||
|
||
private OptifineContactInformation() { | ||
} | ||
|
||
@Override | ||
public Optional<String> get(String key) { | ||
return Optional.ofNullable(OPTIFINE_CONTACTS.get(key)); | ||
} | ||
|
||
@Override | ||
public Map<String, String> asMap() { | ||
return OPTIFINE_CONTACTS; | ||
} | ||
} |
63 changes: 63 additions & 0 deletions
63
src/main/java/me/modmuss50/optifabric/metadata/OptifineContainer.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,63 @@ | ||
package me.modmuss50.optifabric.metadata; | ||
|
||
import net.fabricmc.loader.api.FabricLoader; | ||
import net.fabricmc.loader.api.ModContainer; | ||
import net.fabricmc.loader.api.Version; | ||
import net.fabricmc.loader.api.metadata.ModMetadata; | ||
import net.fabricmc.loader.impl.util.FileSystemUtil; | ||
|
||
import java.io.IOException; | ||
import java.nio.file.Path; | ||
import java.util.*; | ||
|
||
public class OptifineContainer implements ModContainer { | ||
private final Path ofPath; | ||
private final List<Path> rootPaths; | ||
private final ModMetadata ofMetadata; | ||
|
||
public OptifineContainer(Path ofPath, Version version) { | ||
try { | ||
this.ofPath = FileSystemUtil.getJarFileSystem(ofPath, true).get().getRootDirectories().iterator().next(); | ||
} catch (IOException e) { | ||
throw new RuntimeException(e); | ||
} | ||
rootPaths = new ArrayList<>(); | ||
rootPaths.add(this.ofPath); | ||
this.ofMetadata = new OptifineMetadata(version); | ||
} | ||
|
||
@Override | ||
public ModMetadata getMetadata() { | ||
return ofMetadata; | ||
} | ||
|
||
@Override | ||
public List<Path> getRootPaths() { | ||
return Collections.unmodifiableList(rootPaths); | ||
} | ||
|
||
@Override | ||
public OptifineOrigin getOrigin() { | ||
return this::getRootPaths; | ||
} | ||
|
||
@Override | ||
public Optional<ModContainer> getContainingMod() { | ||
return FabricLoader.getInstance().getModContainer("optifabric"); | ||
} | ||
|
||
@Override | ||
public Collection<ModContainer> getContainedMods() { | ||
return new HashSet<>(); | ||
} | ||
|
||
@Override | ||
public Path getRootPath() { | ||
return ofPath; | ||
} | ||
|
||
@Override | ||
public Path getPath(String file) { | ||
return findPath(file).orElse(null); | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
src/main/java/me/modmuss50/optifabric/metadata/OptifineIcon.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,22 @@ | ||
package me.modmuss50.optifabric.metadata; | ||
|
||
import me.modmuss50.optifabric.IOUtils; | ||
|
||
import java.io.IOException; | ||
|
||
@SuppressWarnings("DataFlowIssue") | ||
public class OptifineIcon { | ||
public static final String DATA; | ||
|
||
static { | ||
try { | ||
DATA = new String(IOUtils.toByteArray(OptifineIcon.class.getResourceAsStream("/assets/optifabric/optifine_icon"))); | ||
} catch (IOException e) { | ||
throw new RuntimeException(e); | ||
} | ||
} | ||
|
||
private OptifineIcon() { | ||
throw new UnsupportedOperationException(); | ||
} | ||
} |
106 changes: 106 additions & 0 deletions
106
src/main/java/me/modmuss50/optifabric/metadata/OptifineMetadata.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,106 @@ | ||
package me.modmuss50.optifabric.metadata; | ||
|
||
import me.modmuss50.optifabric.mod.OptifineVersion; | ||
import net.fabricmc.loader.api.Version; | ||
import net.fabricmc.loader.api.metadata.*; | ||
|
||
import java.util.*; | ||
|
||
public class OptifineMetadata implements ModMetadata { | ||
private final Version version; | ||
|
||
OptifineMetadata(Version version) { | ||
this.version = version; | ||
} | ||
|
||
@Override | ||
public String getType() { | ||
return "mcp"; | ||
} | ||
|
||
@Override | ||
public String getId() { | ||
return "optifine"; | ||
} | ||
|
||
@Override | ||
public Collection<String> getProvides() { | ||
return new ArrayList<>(); | ||
} | ||
|
||
@Override | ||
public Version getVersion() { | ||
return version; | ||
} | ||
|
||
@Override | ||
public ModEnvironment getEnvironment() { | ||
return ModEnvironment.CLIENT; | ||
} | ||
|
||
@Override | ||
public Collection<ModDependency> getDependencies() { | ||
return new ArrayList<>(); | ||
} | ||
|
||
@Override | ||
public String getName() { | ||
return OptifineVersion.version; | ||
} | ||
|
||
@Override | ||
public String getDescription() { | ||
return "Chasing the Minecraft Performance. This mod adds support for HD textures and a lot of options for better looks and performance. Doubling the FPS is common."; | ||
} | ||
|
||
@Override | ||
public Collection<Person> getAuthors() { | ||
HashSet<Person> authors = new HashSet<>(); | ||
authors.add(OptifinePerson.INSTANCE); | ||
return authors; | ||
} | ||
|
||
@Override | ||
public Collection<Person> getContributors() { | ||
HashSet<Person> contributors = new HashSet<>(); | ||
contributors.add(OptifinePerson.INSTANCE); | ||
return contributors; | ||
} | ||
|
||
@Override | ||
public ContactInformation getContact() { | ||
return OptifineContactInformation.INSTANCE; | ||
} | ||
|
||
@Override | ||
public Collection<String> getLicense() { | ||
HashSet<String> licenses = new HashSet<>(); | ||
licenses.add("All rights reserved"); | ||
return licenses; | ||
} | ||
|
||
@Override | ||
public Optional<String> getIconPath(int size) { | ||
return Optional.of("assets/optifine/icon.png"); | ||
} | ||
|
||
@Override | ||
public boolean containsCustomValue(String key) { | ||
return false; | ||
} | ||
|
||
@Override | ||
public CustomValue getCustomValue(String key) { | ||
return null; | ||
} | ||
|
||
@Override | ||
public Map<String, CustomValue> getCustomValues() { | ||
return new HashMap<>(); | ||
} | ||
|
||
@Override | ||
public boolean containsCustomElement(String key) { | ||
return false; | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
src/main/java/me/modmuss50/optifabric/metadata/OptifineOrigin.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,20 @@ | ||
package me.modmuss50.optifabric.metadata; | ||
|
||
import net.fabricmc.loader.api.metadata.ModOrigin; | ||
|
||
public interface OptifineOrigin extends ModOrigin { | ||
@Override | ||
default Kind getKind() { | ||
return Kind.UNKNOWN; | ||
} | ||
|
||
@Override | ||
default String getParentModId() { | ||
return "optifabric"; | ||
} | ||
|
||
@Override | ||
default String getParentSubLocation() { | ||
throw new UnsupportedOperationException("kind " + getKind().name() + " doesn't have a parent sub-location"); | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
src/main/java/me/modmuss50/optifabric/metadata/OptifinePerson.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,21 @@ | ||
package me.modmuss50.optifabric.metadata; | ||
|
||
import net.fabricmc.loader.api.metadata.ContactInformation; | ||
import net.fabricmc.loader.api.metadata.Person; | ||
|
||
public class OptifinePerson implements Person { | ||
static final OptifinePerson INSTANCE = new OptifinePerson(); | ||
|
||
private OptifinePerson() { | ||
} | ||
|
||
@Override | ||
public String getName() { | ||
return "sp614x"; | ||
} | ||
|
||
@Override | ||
public ContactInformation getContact() { | ||
return ContactInformation.EMPTY; | ||
} | ||
} |
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
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
Large diffs are not rendered by default.
Oops, something went wrong.