diff --git a/runtime-resources/common/build.gradle b/runtime-resources/common/build.gradle new file mode 100644 index 00000000..3e07de12 --- /dev/null +++ b/runtime-resources/common/build.gradle @@ -0,0 +1,10 @@ +apply from: rootProject.file("gradle/scripts/klib-common.gradle") + +group = "band.kessoku.lib.resources" +base.archivesName = rootProject.name + "-package" + +dependencies { + moduleImplementation(project(":platform-common")) + moduleImplementation(project(":base-common")) + moduleImplementation(project(":event-base-common")) +} diff --git a/runtime-resources/common/src/main/java/band/kessoku/lib/resources/KessokuResourcesManager.java b/runtime-resources/common/src/main/java/band/kessoku/lib/resources/KessokuResourcesManager.java new file mode 100644 index 00000000..6f83a3a2 --- /dev/null +++ b/runtime-resources/common/src/main/java/band/kessoku/lib/resources/KessokuResourcesManager.java @@ -0,0 +1,34 @@ +package band.kessoku.lib.resources; + +import band.kessoku.lib.resources.api.provider.IProvider; +import com.google.common.collect.ImmutableList; + +import java.util.ArrayList; +import java.util.List; + +public class KessokuResourcesManager { + + private final String modid; + + private final List providers = new ArrayList<>(); + + private KessokuResourcesManager(String modid) { + this.modid = modid; + } + + public static KessokuResourcesManager create(String modid) { + return new KessokuResourcesManager(modid); + } + + public void addProvider(IProvider provider) { + providers.add(provider); + } + + public String getModid() { + return modid; + } + + public List getProviders() { + return ImmutableList.copyOf(providers); + } +} diff --git a/runtime-resources/common/src/main/java/band/kessoku/lib/resources/KessokuRuntimeResources.java b/runtime-resources/common/src/main/java/band/kessoku/lib/resources/KessokuRuntimeResources.java new file mode 100644 index 00000000..2338d6ec --- /dev/null +++ b/runtime-resources/common/src/main/java/band/kessoku/lib/resources/KessokuRuntimeResources.java @@ -0,0 +1,9 @@ +package band.kessoku.lib.resources; + +import org.slf4j.Marker; +import org.slf4j.MarkerFactory; + +public class KessokuRuntimeResources { + public static final String MOD_ID = "kessoku_runtime_resources"; + public static final Marker MARKER = MarkerFactory.getMarker("[KessokuRuntimeResources]"); +} diff --git a/runtime-resources/common/src/main/java/band/kessoku/lib/resources/api/lifecycle/Lifecycle.java b/runtime-resources/common/src/main/java/band/kessoku/lib/resources/api/lifecycle/Lifecycle.java new file mode 100644 index 00000000..81009698 --- /dev/null +++ b/runtime-resources/common/src/main/java/band/kessoku/lib/resources/api/lifecycle/Lifecycle.java @@ -0,0 +1,9 @@ +package band.kessoku.lib.resources.api.lifecycle; + +public enum Lifecycle { + + BEFORE_USER, + BEFORE_VANILLA, + AFTER_VANILLA; + +} diff --git a/runtime-resources/common/src/main/java/band/kessoku/lib/resources/api/lifecycle/PackRegistryEvent.java b/runtime-resources/common/src/main/java/band/kessoku/lib/resources/api/lifecycle/PackRegistryEvent.java new file mode 100644 index 00000000..2d82cd58 --- /dev/null +++ b/runtime-resources/common/src/main/java/band/kessoku/lib/resources/api/lifecycle/PackRegistryEvent.java @@ -0,0 +1,34 @@ +package band.kessoku.lib.resources.api.lifecycle; + +import band.kessoku.lib.event.api.Event; +import net.minecraft.resource.ResourcePack; +import net.minecraft.resource.ResourceType; + +import java.util.List; + +public interface PackRegistryEvent { + + Event BEFORE_USER = Event.of((beforeUsers -> ((type, packs) -> { + for (BeforeUser beforeUser : beforeUsers) { + beforeUser.registry(type, packs); + } + }))); + + Event BEFORE_VANILLA = Event.of((beforeVanillas -> ((type, packs) -> { + for (BeforeVanilla beforeVanilla : beforeVanillas) { + beforeVanilla.registry(type, packs); + } + }))); + + Event AFTER_VANILLA = Event.of((afterVanillas -> ((type, packs) -> { + for (AfterVanilla afterVanilla : afterVanillas) { + afterVanilla.registry(type, packs); + } + }))); + + interface BeforeUser extends PackRegistryEvent { } + interface BeforeVanilla extends PackRegistryEvent { } + interface AfterVanilla extends PackRegistryEvent { } + + void registry(ResourceType type, List packs); +} diff --git a/runtime-resources/common/src/main/java/band/kessoku/lib/resources/api/provider/IProvider.java b/runtime-resources/common/src/main/java/band/kessoku/lib/resources/api/provider/IProvider.java new file mode 100644 index 00000000..5304f8d0 --- /dev/null +++ b/runtime-resources/common/src/main/java/band/kessoku/lib/resources/api/provider/IProvider.java @@ -0,0 +1,12 @@ +package band.kessoku.lib.resources.api.provider; + +import band.kessoku.lib.platform.api.Env; +import net.minecraft.util.Identifier; + +public interface IProvider { + + Env[] getEnv(); + + Identifier getId(); + +} diff --git a/runtime-resources/common/src/main/java/band/kessoku/lib/resources/api/resourcepack/DummyResourcePack.java b/runtime-resources/common/src/main/java/band/kessoku/lib/resources/api/resourcepack/DummyResourcePack.java new file mode 100644 index 00000000..f4b273b5 --- /dev/null +++ b/runtime-resources/common/src/main/java/band/kessoku/lib/resources/api/resourcepack/DummyResourcePack.java @@ -0,0 +1,16 @@ +package band.kessoku.lib.resources.api.resourcepack; + +import net.minecraft.resource.ResourcePack; +import net.minecraft.resource.ResourcePackInfo; +import net.minecraft.text.Text; + +public interface DummyResourcePack extends ResourcePack { + + Text getDisplayName(); + + Text getDescription(); + + @Override + ResourcePackInfo getInfo(); + +} diff --git a/runtime-resources/fabric/build.gradle b/runtime-resources/fabric/build.gradle new file mode 100644 index 00000000..e28a3669 --- /dev/null +++ b/runtime-resources/fabric/build.gradle @@ -0,0 +1,9 @@ +apply from: rootProject.file("gradle/scripts/klib-fabric.gradle") + +group = "band.kessoku.lib.resources" +base.archivesName = rootProject.name + "-package" + +dependencies { + common(project(path: ':runtime-resources-common', configuration: 'namedElements')) { transitive false } + shadowBundle(project(path: ':runtime-resources-common', configuration: 'transformProductionFabric')) +} diff --git a/runtime-resources/neo/build.gradle b/runtime-resources/neo/build.gradle new file mode 100644 index 00000000..216fa002 --- /dev/null +++ b/runtime-resources/neo/build.gradle @@ -0,0 +1,9 @@ +apply from: rootProject.file("gradle/scripts/klib-neo.gradle") + +group = "band.kessoku.lib.resources" +base.archivesName = rootProject.name + "-package" + +dependencies { + common(project(path: ':runtime-resources-common', configuration: 'namedElements')) { transitive false } + shadowBundle(project(path: ':runtime-resources-common', configuration: 'transformProductionNeoForge')) +} diff --git a/runtime-resources/neo/gradle.properties b/runtime-resources/neo/gradle.properties new file mode 100644 index 00000000..2914393d --- /dev/null +++ b/runtime-resources/neo/gradle.properties @@ -0,0 +1 @@ +loom.platform=neoforge \ No newline at end of file diff --git a/settings.gradle b/settings.gradle index a328c836..cbe154d6 100644 --- a/settings.gradle +++ b/settings.gradle @@ -22,6 +22,7 @@ includeModule("keybind") // Keybind API includeModule("config") // Config API includeModule("entrypoint") // Entrypoint API includeModule("entity-events") // Entity Events +includeModule("runtime-resources") // Runtime Resources void includeWrapper(String platform) { @@ -38,4 +39,6 @@ void includeModule(String moduleName) { void includePlatform(String moduleName, String platform) { include("$moduleName/$platform") project(":$moduleName/$platform").name = "$moduleName-$platform" -} \ No newline at end of file +} +include 'runtime-resources' +