Proper mods metadata

This commit is contained in:
shedaniel
2020-11-08 00:35:50 +08:00
parent c14c78f6ee
commit cd595fc55a
5 changed files with 68 additions and 1 deletions

View File

@@ -20,10 +20,12 @@ import me.shedaniel.architectury.Architectury;
import me.shedaniel.architectury.ArchitecturyPopulator;
import me.shedaniel.architectury.Populatable;
import net.fabricmc.api.EnvType;
import net.minecraft.SharedConstants;
import org.jetbrains.annotations.NotNull;
import java.nio.file.Path;
import java.util.Collection;
import java.util.Optional;
public final class Platform {
private Platform() {}
@@ -39,6 +41,11 @@ public final class Platform {
return Architectury.getModLoader();
}
@NotNull
public static String getMinecraftVersion() {
return SharedConstants.getCurrentVersion().getId();
}
@NotNull
public static Path getGameFolder() {
return IMPL.getGameFolder();
@@ -63,11 +70,29 @@ public final class Platform {
return IMPL.getMod(id);
}
@NotNull
public static Optional<Mod> getOptionalMod(String id) {
try {
return Optional.of(IMPL.getMod(id));
} catch (NullPointerException e) {
return Optional.empty();
}
}
@NotNull
public static Collection<Mod> getMods() {
return IMPL.getMods();
}
@NotNull
public static Collection<String> getModIds() {
return IMPL.getModIds();
}
public static boolean isDevelopmentEnvironment() {
return IMPL.isDevelopmentEnvironment();
}
public interface Impl {
Path getGameFolder();
@@ -82,6 +107,10 @@ public final class Platform {
Mod getMod(String id);
Collection<Mod> getMods();
Collection<String> getModIds();
boolean isDevelopmentEnvironment();
}
static {