From 824c809485c5c899f1091f3387283f9e9f99257f Mon Sep 17 00:00:00 2001 From: Oganesson897 <101081378+Oganesson897@users.noreply.github.com> Date: Wed, 30 Oct 2024 23:25:36 +0900 Subject: [PATCH 1/2] krr --- runtime-resources/common/build.gradle | 9 +++++ .../resources/KessokuResourcesManager.java | 34 +++++++++++++++++++ .../resources/KessokuRuntimeResources.java | 9 +++++ .../kessoku/lib/resources/api/IProvider.java | 4 +++ runtime-resources/fabric/build.gradle | 9 +++++ runtime-resources/neo/build.gradle | 9 +++++ runtime-resources/neo/gradle.properties | 1 + settings.gradle | 5 ++- 8 files changed, 79 insertions(+), 1 deletion(-) create mode 100644 runtime-resources/common/build.gradle create mode 100644 runtime-resources/common/src/main/java/band/kessoku/lib/resources/KessokuResourcesManager.java create mode 100644 runtime-resources/common/src/main/java/band/kessoku/lib/resources/KessokuRuntimeResources.java create mode 100644 runtime-resources/common/src/main/java/band/kessoku/lib/resources/api/IProvider.java create mode 100644 runtime-resources/fabric/build.gradle create mode 100644 runtime-resources/neo/build.gradle create mode 100644 runtime-resources/neo/gradle.properties diff --git a/runtime-resources/common/build.gradle b/runtime-resources/common/build.gradle new file mode 100644 index 00000000..7aae168d --- /dev/null +++ b/runtime-resources/common/build.gradle @@ -0,0 +1,9 @@ +apply from: rootProject.file("gradle/scripts/klib-common.gradle") + +group = "band.kessoku.lib.resources" +base.archivesName = rootProject.name + "-package" + +// You can delete this section if you need to +dependencies { + +} 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..3407ce45 --- /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.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/IProvider.java b/runtime-resources/common/src/main/java/band/kessoku/lib/resources/api/IProvider.java new file mode 100644 index 00000000..9f8582c0 --- /dev/null +++ b/runtime-resources/common/src/main/java/band/kessoku/lib/resources/api/IProvider.java @@ -0,0 +1,4 @@ +package band.kessoku.lib.resources.api; + +public interface IProvider { +} 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' + From 892fa01741458022c40aab21eb4166e5473d7ff3 Mon Sep 17 00:00:00 2001 From: Oganesson897 <101081378+Oganesson897@users.noreply.github.com> Date: Sat, 2 Nov 2024 09:17:54 +0900 Subject: [PATCH 2/2] a little --- runtime-resources/common/build.gradle | 5 +-- .../resources/KessokuResourcesManager.java | 2 +- .../kessoku/lib/resources/api/IProvider.java | 4 --- .../resources/api/lifecycle/Lifecycle.java | 9 +++++ .../api/lifecycle/PackRegistryEvent.java | 34 +++++++++++++++++++ .../lib/resources/api/provider/IProvider.java | 12 +++++++ .../api/resourcepack/DummyResourcePack.java | 16 +++++++++ 7 files changed, 75 insertions(+), 7 deletions(-) delete mode 100644 runtime-resources/common/src/main/java/band/kessoku/lib/resources/api/IProvider.java create mode 100644 runtime-resources/common/src/main/java/band/kessoku/lib/resources/api/lifecycle/Lifecycle.java create mode 100644 runtime-resources/common/src/main/java/band/kessoku/lib/resources/api/lifecycle/PackRegistryEvent.java create mode 100644 runtime-resources/common/src/main/java/band/kessoku/lib/resources/api/provider/IProvider.java create mode 100644 runtime-resources/common/src/main/java/band/kessoku/lib/resources/api/resourcepack/DummyResourcePack.java diff --git a/runtime-resources/common/build.gradle b/runtime-resources/common/build.gradle index 7aae168d..3e07de12 100644 --- a/runtime-resources/common/build.gradle +++ b/runtime-resources/common/build.gradle @@ -3,7 +3,8 @@ apply from: rootProject.file("gradle/scripts/klib-common.gradle") group = "band.kessoku.lib.resources" base.archivesName = rootProject.name + "-package" -// You can delete this section if you need to 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 index 3407ce45..6f83a3a2 100644 --- 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 @@ -1,6 +1,6 @@ package band.kessoku.lib.resources; -import band.kessoku.lib.resources.api.IProvider; +import band.kessoku.lib.resources.api.provider.IProvider; import com.google.common.collect.ImmutableList; import java.util.ArrayList; diff --git a/runtime-resources/common/src/main/java/band/kessoku/lib/resources/api/IProvider.java b/runtime-resources/common/src/main/java/band/kessoku/lib/resources/api/IProvider.java deleted file mode 100644 index 9f8582c0..00000000 --- a/runtime-resources/common/src/main/java/band/kessoku/lib/resources/api/IProvider.java +++ /dev/null @@ -1,4 +0,0 @@ -package band.kessoku.lib.resources.api; - -public interface IProvider { -} 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(); + +}