Compare commits
No commits in common. "cb8958877b2ae58bf4c48bd6d0ac631507429cd8" and "ba83b48e817b18ba26fdc7cb156e89563b25c4f7" have entirely different histories.
cb8958877b
...
ba83b48e81
120
build.gradle.kts
120
build.gradle.kts
|
@ -1,10 +1,3 @@
|
|||
import dev.frogmc.phytotelma.ProjectStorage
|
||||
import org.objectweb.asm.ClassReader
|
||||
import org.objectweb.asm.Opcodes
|
||||
import org.objectweb.asm.tree.ClassNode
|
||||
import java.nio.file.FileSystems
|
||||
import kotlin.io.path.readBytes
|
||||
|
||||
plugins {
|
||||
`java-library`
|
||||
`maven-publish`
|
||||
|
@ -13,17 +6,36 @@ plugins {
|
|||
}
|
||||
|
||||
group = "dev.frogmc"
|
||||
version =
|
||||
"0.0.1-alpha.3+" + libs.versions.minecraft.get() +
|
||||
("-local".takeUnless { project.hasProperty("FrogMCSnapshotsMavenPassword") } ?: "")
|
||||
version = "0.0.1-alpha.2"
|
||||
|
||||
subprojects {
|
||||
if (!project.projectDir.resolve("src/main/resources/frog.mod.toml").exists()) {
|
||||
return@subprojects
|
||||
}
|
||||
|
||||
project.group = "dev.frogmc.froglib"
|
||||
project.version = rootProject.version
|
||||
}
|
||||
|
||||
allprojects {
|
||||
if (!project.projectDir.resolve("src/main/resources/frog.mod.toml").exists()) {
|
||||
return@allprojects
|
||||
}
|
||||
|
||||
apply(plugin = "java-library")
|
||||
apply(plugin = "dev.frogmc.phytotelma")
|
||||
apply(plugin = "maven-publish")
|
||||
apply(plugin = "io.freefair.lombok")
|
||||
|
||||
if (project.name != "core") {
|
||||
dependencies {
|
||||
api(project(":library:core"))
|
||||
}
|
||||
}
|
||||
|
||||
phytotelma {
|
||||
minecraft {
|
||||
version = libs.versions.minecraft
|
||||
}
|
||||
loader {
|
||||
version = libs.versions.frogloader
|
||||
}
|
||||
loader(rootProject.libs.versions.frogloader)
|
||||
minecraft(rootProject.libs.versions.minecraft, provider { "1.20.6" }) // since parchment isn't published for 1.21 yet
|
||||
}
|
||||
|
||||
tasks.processResources {
|
||||
|
@ -31,20 +43,8 @@ tasks.processResources {
|
|||
inputs.property("game_version", libs.versions.minecraft.get())
|
||||
|
||||
filesMatching("frog.mod.toml") {
|
||||
expand(
|
||||
"version" to version,
|
||||
"game_version" to libs.versions.minecraft.get()
|
||||
)
|
||||
}
|
||||
|
||||
val s = generateDatagenAWs()
|
||||
filesMatching("froglib.accesswidener") {
|
||||
filter { l ->
|
||||
if (l == "# (Generated)") {
|
||||
return@filter s
|
||||
}
|
||||
return@filter l
|
||||
}
|
||||
expand("version" to version,
|
||||
"game_version" to libs.versions.minecraft.get())
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -53,10 +53,8 @@ tasks.processTestResources {
|
|||
inputs.property("game_version", libs.versions.minecraft.get())
|
||||
|
||||
filesMatching("frog.mod.toml") {
|
||||
expand(
|
||||
"version" to version,
|
||||
"game_version" to libs.versions.minecraft.get()
|
||||
)
|
||||
expand("version" to version,
|
||||
"game_version" to libs.versions.minecraft.get())
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -96,40 +94,28 @@ publishing {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun generateDatagenAWs(): String {
|
||||
val classes = listOf(
|
||||
"net/minecraft/data/models/BlockModelGenerators",
|
||||
"net/minecraft/data/models/ItemModelGenerators"
|
||||
)
|
||||
evaluationDependsOnChildren()
|
||||
|
||||
val mc = ProjectStorage.get(project).remappedGameJarPath!!
|
||||
FileSystems.newFileSystem(mc).use { fs ->
|
||||
val text = buildString {
|
||||
appendLine("# Generated AccessWideners")
|
||||
classes.forEach { s ->
|
||||
val classFile = fs.getPath("$s.class")
|
||||
tasks.runClient {
|
||||
classpath(sourceSets.test.get().runtimeClasspath)
|
||||
project.subprojects.filter {
|
||||
it.projectDir.resolve("src/main/resources/frog.mod.toml").exists()
|
||||
}.forEach {
|
||||
classpath(it.sourceSets.test.get().output)
|
||||
}
|
||||
}
|
||||
|
||||
appendLine()
|
||||
appendLine("# File: $s")
|
||||
val node = ClassNode()
|
||||
ClassReader(classFile.readBytes()).accept(
|
||||
node,
|
||||
ClassReader.SKIP_CODE or ClassReader.SKIP_DEBUG or ClassReader.SKIP_FRAMES
|
||||
)
|
||||
dependencies {
|
||||
project.subprojects.filter {
|
||||
it.projectDir.resolve("src/main/resources/frog.mod.toml").exists()
|
||||
}.forEach {
|
||||
project.tasks.jar {
|
||||
dependsOn(it.tasks.build)
|
||||
}
|
||||
api(it)
|
||||
include(it)
|
||||
}
|
||||
}
|
||||
|
||||
node.innerClasses.forEach { inner ->
|
||||
if (inner.outerName == s) {
|
||||
appendLine("transitive-accessible class ${inner.outerName}$${inner.innerName}")
|
||||
}
|
||||
}
|
||||
node.methods.forEach { method ->
|
||||
if (method.access and (Opcodes.ACC_PUBLIC or Opcodes.ACC_SYNTHETIC) == 0 && method.name != "<clinit>") {
|
||||
appendLine("transitive-accessible method $s ${method.name} ${method.desc}")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return text
|
||||
}
|
||||
}
|
|
@ -1 +0,0 @@
|
|||
org.gradle.parallel = true
|
|
@ -1,7 +1,7 @@
|
|||
[versions]
|
||||
|
||||
minecraft = "1.21"
|
||||
frogloader = "0.0.1-alpha.15"
|
||||
phytotelma = "0.0.1-alpha.16"
|
||||
frogloader = "0.0.1-alpha.7"
|
||||
phytotelma = "0.0.1-alpha.10"
|
||||
lombok = "8.6"
|
||||
|
||||
|
|
0
library/branding/build.gradle.kts
Normal file
0
library/branding/build.gradle.kts
Normal file
21
library/branding/src/main/resources/frog.mod.toml
Normal file
21
library/branding/src/main/resources/frog.mod.toml
Normal file
|
@ -0,0 +1,21 @@
|
|||
[frog]
|
||||
format_version = "1.0.0"
|
||||
|
||||
[frog.mod]
|
||||
id = "froglib_branding"
|
||||
name = "FrogLib Branding"
|
||||
version = "$version"
|
||||
license = "Apache-2.0"
|
||||
credits = [
|
||||
{ name = "FrogMC Team", roles = ["author"] }
|
||||
]
|
||||
|
||||
[frog.dependencies]
|
||||
depends = [
|
||||
{ id = "minecraft", versions = "~$game_version", name = "Minecraft" }
|
||||
]
|
||||
|
||||
[frog.extensions]
|
||||
mixin = [
|
||||
"froglib.branding.mixins.json",
|
||||
]
|
0
library/core/build.gradle.kts
Normal file
0
library/core/build.gradle.kts
Normal file
22
library/core/src/main/resources/frog.mod.toml
Normal file
22
library/core/src/main/resources/frog.mod.toml
Normal file
|
@ -0,0 +1,22 @@
|
|||
[frog]
|
||||
format_version = "1.0.0"
|
||||
|
||||
[frog.mod]
|
||||
id = "froglib_core"
|
||||
name = "FrogLib Core"
|
||||
version = "$version"
|
||||
license = "Apache-2.0"
|
||||
credits = [
|
||||
{ name = "FrogMC Team", roles = ["author"] }
|
||||
]
|
||||
|
||||
[frog.dependencies]
|
||||
depends = [
|
||||
{ id = "minecraft", versions = "~$game_version", name = "Minecraft" }
|
||||
]
|
||||
|
||||
[frog.extensions]
|
||||
mixin = [
|
||||
"froglib.entrypoints.mixins.json",
|
||||
"froglib.events.mixins.json"
|
||||
]
|
|
@ -16,7 +16,7 @@ depends = [
|
|||
]
|
||||
|
||||
[frog.extensions]
|
||||
# prelaunch = "net.frogmc.froglib.gen.impl.FrogGenPrelaunch"
|
||||
prelaunch = "net.frogmc.froglib.gen.impl.FrogGenPrelaunch"
|
||||
mixin = [
|
||||
"froglib.gen.mixins.json"
|
||||
]
|
||||
|
|
4
library/keybinds/build.gradle.kts
Normal file
4
library/keybinds/build.gradle.kts
Normal file
|
@ -0,0 +1,4 @@
|
|||
|
||||
dependencies {
|
||||
api(project(":library:resourceloader"))
|
||||
}
|
22
library/keybinds/src/main/resources/frog.mod.toml
Normal file
22
library/keybinds/src/main/resources/frog.mod.toml
Normal file
|
@ -0,0 +1,22 @@
|
|||
[frog]
|
||||
format_version = "1.0.0"
|
||||
|
||||
[frog.mod]
|
||||
id = "froglib_keybinds"
|
||||
name = "FrogLib Keybinds"
|
||||
version = "$version"
|
||||
license = "Apache-2.0"
|
||||
credits = [
|
||||
{ name = "FrogMC Team", roles = ["author"] }
|
||||
]
|
||||
|
||||
[frog.dependencies]
|
||||
depends = [
|
||||
{ id = "minecraft", versions = "~$game_version", name = "Minecraft" }
|
||||
]
|
||||
|
||||
[frog.extensions]
|
||||
mixin = [
|
||||
"froglib.keybinds.mixins.json"
|
||||
]
|
||||
accesswidener = "froglib.keybinds.accesswidener"
|
|
@ -0,0 +1,3 @@
|
|||
accessWidener v2 named
|
||||
|
||||
mutable field net/minecraft/client/Options keyMappings [Lnet/minecraft/client/KeyMapping;
|
|
@ -1,4 +1,4 @@
|
|||
package dev.frogmc.froglib.test.keybinds;
|
||||
package dev.frogmc.froglib.keybinds.test;
|
||||
|
||||
import com.mojang.blaze3d.platform.InputConstants;
|
||||
import dev.frogmc.froglib.entrypoints.api.ClientExtension;
|
||||
|
@ -6,7 +6,6 @@ import dev.frogmc.froglib.keybinds.api.KeyMappings;
|
|||
import dev.frogmc.frogloader.api.mod.ModProperties;
|
||||
import net.minecraft.client.KeyMapping;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class KeybindsTest implements ClientExtension {
|
||||
@Override
|
||||
public void onClientInit(ModProperties mod) {
|
|
@ -0,0 +1,4 @@
|
|||
{
|
||||
"key.froglib.test": "FrogLib Test Keybind",
|
||||
"category.froglib": "FrogLib Test Category"
|
||||
}
|
19
library/keybinds/src/test/resources/frog.mod.toml
Normal file
19
library/keybinds/src/test/resources/frog.mod.toml
Normal file
|
@ -0,0 +1,19 @@
|
|||
[frog]
|
||||
format_version = "1.0.0"
|
||||
|
||||
[frog.mod]
|
||||
id = "froglib_keybinds_test"
|
||||
name = "FrogLib Keybinds Test Mod"
|
||||
version = "$version"
|
||||
license = "Apache-2.0"
|
||||
credits = [
|
||||
{ name = "FrogMC Team", roles = ["author"] }
|
||||
]
|
||||
|
||||
[frog.dependencies]
|
||||
depends = [
|
||||
{ id = "minecraft", versions = "~$game_version", name = "Minecraft" }
|
||||
]
|
||||
|
||||
[frog.extensions]
|
||||
client = "dev.frogmc.froglib.keybinds.test.KeybindsTest"
|
0
library/networking/build.gradle.kts
Normal file
0
library/networking/build.gradle.kts
Normal file
0
library/player/build.gradle.kts
Normal file
0
library/player/build.gradle.kts
Normal file
19
library/player/src/main/resources/frog.mod.toml
Normal file
19
library/player/src/main/resources/frog.mod.toml
Normal file
|
@ -0,0 +1,19 @@
|
|||
[frog]
|
||||
format_version = "1.0.0"
|
||||
|
||||
[frog.mod]
|
||||
id = "froglib_player"
|
||||
name = "FrogLib Player"
|
||||
version = "$version"
|
||||
license = "Apache-2.0"
|
||||
credits = [
|
||||
{ name = "FrogMC Team", roles = ["author"] }
|
||||
]
|
||||
|
||||
[frog.dependencies]
|
||||
depends = [
|
||||
{ id = "minecraft", versions = "~$game_version", name = "Minecraft" }
|
||||
]
|
||||
|
||||
[frog.extensions]
|
||||
mixin = "froglib.player.mixins.json"
|
4
library/registries/build.gradle.kts
Normal file
4
library/registries/build.gradle.kts
Normal file
|
@ -0,0 +1,4 @@
|
|||
|
||||
dependencies {
|
||||
api(project(":library:resourceloader"))
|
||||
}
|
|
@ -1,14 +1,10 @@
|
|||
package dev.frogmc.froglib.registries.api;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import dev.frogmc.froglib.events.api.Event;
|
||||
import net.minecraft.world.item.alchemy.PotionBrewing;
|
||||
|
||||
public final class RegistryEvents {
|
||||
public static final Event<Runnable> REGISTRY_INIT = Event.runnable();
|
||||
public static final Event<BlockRegistration> BLOCK_REGISTRATION = Event.of(list -> () -> list.stream().map(BlockRegistration::register).flatMap(Collection::stream).toList());
|
||||
public static final Event<ItemRegistration> ITEM_REGISTRATION = Event.of(list -> () -> list.stream().map(ItemRegistration::register).flatMap(Collection::stream).toList());
|
||||
public static final Event<Consumer<PotionBrewing.Builder>> POTION_BREWING = Event.consumer();
|
||||
}
|
|
@ -1,6 +1,5 @@
|
|||
package dev.frogmc.froglib.registries.impl.mixin;
|
||||
|
||||
import dev.frogmc.froglib.registries.api.RegistryEvents;
|
||||
import dev.frogmc.froglib.registries.impl.RegistrationImpl;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
|
@ -13,7 +12,6 @@ public abstract class BuiltinRegistriesMixin {
|
|||
|
||||
@Inject(method = "bootStrap", at = @At(value = "INVOKE", target = "Lnet/minecraft/core/registries/BuiltInRegistries;createContents()V"))
|
||||
private static void inject(CallbackInfo ci) {
|
||||
RegistryEvents.REGISTRY_INIT.invoker().run();
|
||||
RegistrationImpl.register();
|
||||
}
|
||||
}
|
19
library/registries/src/main/resources/frog.mod.toml
Normal file
19
library/registries/src/main/resources/frog.mod.toml
Normal file
|
@ -0,0 +1,19 @@
|
|||
[frog]
|
||||
format_version = "1.0.0"
|
||||
|
||||
[frog.mod]
|
||||
id = "froglib_block"
|
||||
name = "FrogLib Block"
|
||||
version = "$version"
|
||||
license = "Apache-2.0"
|
||||
credits = [
|
||||
{ name = "FrogMC Team", roles = ["author"] }
|
||||
]
|
||||
|
||||
[frog.dependencies]
|
||||
depends = [
|
||||
{ id = "minecraft", versions = "~$game_version", name = "Minecraft" }
|
||||
]
|
||||
|
||||
[frog.extensions]
|
||||
mixin = "froglib.block.mixins.json"
|
|
@ -4,8 +4,7 @@
|
|||
"package": "dev.frogmc.froglib.registries.impl.mixin",
|
||||
"compatibilityLevel": "JAVA_21",
|
||||
"mixins": [
|
||||
"BuiltinRegistriesMixin",
|
||||
"PotionBrewingMixin"
|
||||
"BuiltinRegistriesMixin"
|
||||
],
|
||||
"server": [
|
||||
],
|
|
@ -0,0 +1,21 @@
|
|||
package dev.frogmc.froglib.registries.test;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import dev.frogmc.froglib.registries.api.RegistryEvents;
|
||||
import dev.frogmc.frogloader.api.extensions.PreLaunchExtension;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
public class BlockTest implements PreLaunchExtension {
|
||||
|
||||
|
||||
@Override
|
||||
public void onPreLaunch() {
|
||||
RegistryEvents.BLOCK_REGISTRATION.register(() -> List.of(
|
||||
Pair.of(BlockTestBlocks.loc, BlockTestBlocks.b)
|
||||
));
|
||||
RegistryEvents.ITEM_REGISTRATION.register(() -> List.of(
|
||||
Pair.of(BlockTestBlocks.loc, BlockTestBlocks.bItem)
|
||||
));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
package dev.frogmc.froglib.registries.test;
|
||||
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.item.BlockItem;
|
||||
import net.minecraft.world.item.DyeColor;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.StainedGlassBlock;
|
||||
import net.minecraft.world.level.block.state.BlockBehaviour;
|
||||
|
||||
public class BlockTestBlocks {
|
||||
public static final ResourceLocation loc = ResourceLocation.fromNamespaceAndPath("froglib_block_test", "testblock");
|
||||
public static final Block b = new StainedGlassBlock(DyeColor.MAGENTA, BlockBehaviour.Properties.of());
|
||||
public static final Item bItem = new BlockItem(b, new Item.Properties());
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
"variants": {
|
||||
"": {
|
||||
"model": "minecraft:block/anvil"
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"block.froglib_block_test.testblock": "Test Block"
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"parent": "minecraft:block/anvil"
|
||||
}
|
19
library/registries/src/test/resources/frog.mod.toml
Normal file
19
library/registries/src/test/resources/frog.mod.toml
Normal file
|
@ -0,0 +1,19 @@
|
|||
[frog]
|
||||
format_version = "1.0.0"
|
||||
|
||||
[frog.mod]
|
||||
id = "froglib_block_test"
|
||||
name = "FrogLib Block Test"
|
||||
version = "$version"
|
||||
license = "Apache-2.0"
|
||||
credits = [
|
||||
{ name = "FrogMC Team", roles = ["author"] }
|
||||
]
|
||||
|
||||
[frog.dependencies]
|
||||
depends = [
|
||||
{ id = "minecraft", versions = "~$game_version", name = "Minecraft" }
|
||||
]
|
||||
|
||||
[frog.extensions]
|
||||
prelaunch = "dev.frogmc.froglib.registries.test.BlockTest"
|
0
library/resourceloader/build.gradle.kts
Normal file
0
library/resourceloader/build.gradle.kts
Normal file
27
library/resourceloader/src/main/resources/frog.mod.toml
Normal file
27
library/resourceloader/src/main/resources/frog.mod.toml
Normal file
|
@ -0,0 +1,27 @@
|
|||
[frog]
|
||||
format_version = "1.0.0"
|
||||
|
||||
[frog.mod]
|
||||
id = "froglib_resourceloader"
|
||||
name = "FrogLib Resource Loader"
|
||||
version = "$version"
|
||||
license = "Apache-2.0"
|
||||
credits = [
|
||||
{ name = "FrogMC Team", roles = ["author"] }
|
||||
]
|
||||
|
||||
[frog.dependencies]
|
||||
depends = [
|
||||
{ id = "minecraft", versions = "~$game_version", name = "Minecraft" }
|
||||
]
|
||||
|
||||
[frog.extensions]
|
||||
client = [
|
||||
"dev.frogmc.froglib.resources.impl.ResourceLoaderClient"
|
||||
]
|
||||
server = [
|
||||
"dev.frogmc.froglib.resources.impl.ResourceLoaderServer"
|
||||
]
|
||||
mixin = [
|
||||
"froglib.resources.mixins.json"
|
||||
]
|
|
@ -1,6 +1,5 @@
|
|||
pluginManagement {
|
||||
repositories {
|
||||
mavenLocal()
|
||||
maven {
|
||||
name = "FrogMC Maven Releases"
|
||||
url = uri("https://maven.frogmc.dev/releases")
|
||||
|
@ -14,3 +13,19 @@ pluginManagement {
|
|||
}
|
||||
|
||||
rootProject.name = "froglib"
|
||||
include("library:networking")
|
||||
findProject(":library:networking")?.name = "networking"
|
||||
include("library:branding")
|
||||
findProject(":library:branding")?.name = "branding"
|
||||
include("library:core")
|
||||
findProject(":library:core")?.name = "core"
|
||||
include("library:keybinds")
|
||||
findProject(":library:keybinds")?.name = "keybinds"
|
||||
include("library:resourceloader")
|
||||
findProject(":library:resourceloader")?.name = "resourceloader"
|
||||
include("library:registries")
|
||||
findProject(":library:registries")?.name = "registries"
|
||||
include("library:player")
|
||||
findProject(":library:player")?.name = "player"
|
||||
include("library:gen")
|
||||
findProject(":library:gen")?.name = "gen"
|
||||
|
|
|
@ -1,27 +0,0 @@
|
|||
package dev.frogmc.froglib.datagen.api;
|
||||
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.function.BiFunction;
|
||||
|
||||
import net.minecraft.core.HolderLookup;
|
||||
import net.minecraft.data.DataGenerator;
|
||||
import net.minecraft.data.DataProvider;
|
||||
import net.minecraft.data.PackOutput;
|
||||
import net.minecraft.data.models.BlockModelGenerators;
|
||||
import net.minecraft.data.models.ItemModelGenerators;
|
||||
|
||||
public interface DatagenExtension {
|
||||
|
||||
default void addProviders(DataGenerator.PackGenerator pack, CompletableFuture<HolderLookup.Provider> providerFuture) {}
|
||||
|
||||
default void generateBlockModels(BlockModelGenerators generators) {}
|
||||
|
||||
default void generateItemModels(ItemModelGenerators generators) {}
|
||||
|
||||
static <T extends DataProvider> DataProvider.Factory<T> bindRegistries(
|
||||
BiFunction<PackOutput, CompletableFuture<HolderLookup.Provider>, T> factory,
|
||||
CompletableFuture<HolderLookup.Provider> lookupProviderFuture
|
||||
) {
|
||||
return output -> factory.apply(output, lookupProviderFuture);
|
||||
}
|
||||
}
|
|
@ -1,58 +0,0 @@
|
|||
package dev.frogmc.froglib.datagen.impl;
|
||||
|
||||
import java.lang.invoke.MethodHandles;
|
||||
import java.lang.invoke.MethodType;
|
||||
import java.nio.file.Path;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
import dev.frogmc.froglib.datagen.api.DatagenExtension;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.minecraft.SharedConstants;
|
||||
import net.minecraft.Util;
|
||||
import net.minecraft.core.HolderLookup;
|
||||
import net.minecraft.data.DataGenerator;
|
||||
import net.minecraft.data.models.ModelProvider;
|
||||
import net.minecraft.data.registries.VanillaRegistries;
|
||||
|
||||
@Slf4j
|
||||
public final class FrogDatagen {
|
||||
|
||||
public static final boolean ENABLED = Boolean.getBoolean("frog.datagen.enabled");
|
||||
public static DatagenExtension extension;
|
||||
|
||||
public static final String MOD_ID = System.getProperty("frog.datagen.modid");
|
||||
private static final String generatorClass = System.getProperty("frog.datagen.generator");
|
||||
|
||||
private FrogDatagen() {
|
||||
}
|
||||
|
||||
public static void run() {
|
||||
|
||||
SharedConstants.tryDetectVersion();
|
||||
Path output = Path.of(Objects.requireNonNull(System.getProperty("frog.datagen.output"), "No output path provided!"));
|
||||
FrogGenerator generator = new FrogGenerator(output, MOD_ID);
|
||||
|
||||
DataGenerator.PackGenerator pack = generator.getPackGenerator();
|
||||
CompletableFuture<HolderLookup.Provider> providerFuture = CompletableFuture.supplyAsync(VanillaRegistries::createLookup, Util.backgroundExecutor());
|
||||
|
||||
|
||||
try {
|
||||
extension = getExtension();
|
||||
|
||||
pack.addProvider(ModelProvider::new);
|
||||
extension.addProviders(pack, providerFuture);
|
||||
|
||||
generator.run();
|
||||
} catch (Throwable e) {
|
||||
log.error("Failed to run datagen: ", e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static DatagenExtension getExtension() throws Throwable {
|
||||
return (DatagenExtension) MethodHandles.lookup()
|
||||
.findConstructor(Class.forName(generatorClass), MethodType.methodType(void.class))
|
||||
.invoke();
|
||||
}
|
||||
}
|
|
@ -1,28 +0,0 @@
|
|||
package dev.frogmc.froglib.datagen.impl;
|
||||
|
||||
import java.nio.file.Path;
|
||||
|
||||
import net.minecraft.SharedConstants;
|
||||
import net.minecraft.data.DataGenerator;
|
||||
import net.minecraft.data.PackOutput;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class FrogGenerator extends DataGenerator {
|
||||
private final PackOutput output;
|
||||
private final String modId;
|
||||
|
||||
public FrogGenerator(Path rootOutputFolder, String modId) {
|
||||
super(rootOutputFolder, SharedConstants.getCurrentVersion(), true);
|
||||
output = new PackOutput(rootOutputFolder);
|
||||
this.modId = modId;
|
||||
}
|
||||
|
||||
public PackGenerator getPackGenerator(){
|
||||
return new PackGenerator(true, modId, output);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull PackGenerator getVanillaPack(boolean toRun) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
}
|
|
@ -1,19 +0,0 @@
|
|||
package dev.frogmc.froglib.datagen.impl.mixin;
|
||||
|
||||
import dev.frogmc.froglib.datagen.impl.FrogDatagen;
|
||||
import net.minecraft.data.models.BlockModelGenerators;
|
||||
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;
|
||||
|
||||
@Mixin(BlockModelGenerators.class)
|
||||
public class BlockModelGeneratorsMixin {
|
||||
|
||||
@Inject(method = "run", at = @At("HEAD"), cancellable = true)
|
||||
private void generateModBlockModels(CallbackInfo ci){
|
||||
FrogDatagen.extension.generateBlockModels((BlockModelGenerators)(Object)this);
|
||||
|
||||
ci.cancel();
|
||||
}
|
||||
}
|
|
@ -1,19 +0,0 @@
|
|||
package dev.frogmc.froglib.datagen.impl.mixin;
|
||||
|
||||
import dev.frogmc.froglib.datagen.impl.FrogDatagen;
|
||||
import net.minecraft.data.models.ItemModelGenerators;
|
||||
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;
|
||||
|
||||
@Mixin(ItemModelGenerators.class)
|
||||
public class ItemModelGeneratorsMixin {
|
||||
|
||||
@Inject(method = "run", at = @At("HEAD"), cancellable = true)
|
||||
private void generateItemModels(CallbackInfo ci) {
|
||||
FrogDatagen.extension.generateItemModels((ItemModelGenerators) (Object) this);
|
||||
|
||||
ci.cancel();
|
||||
}
|
||||
}
|
|
@ -1,20 +0,0 @@
|
|||
package dev.frogmc.froglib.datagen.impl.mixin;
|
||||
|
||||
import dev.frogmc.froglib.datagen.impl.FrogDatagen;
|
||||
import net.minecraft.server.Main;
|
||||
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;
|
||||
|
||||
@Mixin(Main.class)
|
||||
public class MainMixin {
|
||||
|
||||
@Inject(method = "main", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/Bootstrap;validate()V", shift = At.Shift.AFTER), cancellable = true)
|
||||
private static void datagenHook(String[] args, CallbackInfo ci){
|
||||
if (FrogDatagen.ENABLED) {
|
||||
FrogDatagen.run();
|
||||
ci.cancel();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,37 +0,0 @@
|
|||
package dev.frogmc.froglib.datagen.impl.mixin;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Supplier;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import com.google.gson.JsonElement;
|
||||
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
|
||||
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
|
||||
import dev.frogmc.froglib.datagen.impl.FrogDatagen;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.data.models.ModelProvider;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
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;
|
||||
|
||||
@Mixin(ModelProvider.class)
|
||||
public class ModelProviderMixin {
|
||||
|
||||
@WrapOperation(method = "run", at = @At(value = "INVOKE", target = "Ljava/util/stream/Stream;map(Ljava/util/function/Function;)Ljava/util/stream/Stream;"))
|
||||
private <R extends Block, T extends Map.Entry<net.minecraft.resources.ResourceKey<R>, R>> Stream<T> filterModOnly(Stream<T> instance, Function<? super T, ? extends T> function, Operation<Stream<T>> original){
|
||||
return original.call(instance.filter(b -> b.getKey().location().getNamespace().equals(FrogDatagen.MOD_ID)), function);
|
||||
}
|
||||
|
||||
@Inject(method = "lambda$run$4", at = @At("HEAD"), cancellable = true)
|
||||
private static void filterModOnlyBlocks(Set<Item> set, Map<ResourceLocation, Supplier<JsonElement>> map, Block block, CallbackInfo ci){
|
||||
if (BuiltInRegistries.BLOCK.getKey(block).getNamespace().equals(FrogDatagen.MOD_ID)) {
|
||||
ci.cancel();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,19 +0,0 @@
|
|||
package dev.frogmc.froglib.registries.impl.mixin;
|
||||
|
||||
import com.llamalad7.mixinextras.sugar.Local;
|
||||
import dev.frogmc.froglib.registries.api.RegistryEvents;
|
||||
import net.minecraft.world.flag.FeatureFlagSet;
|
||||
import net.minecraft.world.item.alchemy.PotionBrewing;
|
||||
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.CallbackInfoReturnable;
|
||||
|
||||
@Mixin(PotionBrewing.class)
|
||||
public abstract class PotionBrewingMixin {
|
||||
|
||||
@Inject(method = "bootstrap", at = @At("TAIL"))
|
||||
private static void injectPotionMixes(FeatureFlagSet enabledFeatures, CallbackInfoReturnable<PotionBrewing> cir, @Local PotionBrewing.Builder builder) {
|
||||
RegistryEvents.POTION_BREWING.invoker().accept(builder);
|
||||
}
|
||||
}
|
|
@ -1,11 +0,0 @@
|
|||
package dev.frogmc.froglib.resources.api;
|
||||
|
||||
import dev.frogmc.froglib.events.api.Event;
|
||||
import net.minecraft.server.packs.PackType;
|
||||
|
||||
public class ResourceLoader {
|
||||
|
||||
public static Event<ResourceLoaderEvent> get(PackType type) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
}
|
|
@ -16,23 +16,3 @@ depends = [
|
|||
]
|
||||
|
||||
[frog.extensions]
|
||||
init = [
|
||||
|
||||
]
|
||||
client = [
|
||||
"dev.frogmc.froglib.resources.impl.ResourceLoaderClient"
|
||||
]
|
||||
server = [
|
||||
"dev.frogmc.froglib.impl.resources.ResourceLoaderServer"
|
||||
]
|
||||
accesswidener = "froglib.accesswidener"
|
||||
mixin = [
|
||||
"froglib.branding.mixins.json",
|
||||
"froglib.datagen.mixins.json",
|
||||
"froglib.entrypoints.mixins.json",
|
||||
"froglib.events.mixins.json",
|
||||
"froglib.keybinds.mixins.json",
|
||||
"froglib.player.mixins.json",
|
||||
"froglib.registries.mixins.json",
|
||||
"froglib.resources.mixins.json"
|
||||
]
|
|
@ -1,9 +0,0 @@
|
|||
accessWidener v2 named
|
||||
|
||||
# Keybinds
|
||||
mutable field net/minecraft/client/Options keyMappings [Lnet/minecraft/client/KeyMapping;
|
||||
|
||||
# Datagen
|
||||
accessible method net/minecraft/data/DataGenerator$PackGenerator <init> (Lnet/minecraft/data/DataGenerator;ZLjava/lang/String;Lnet/minecraft/data/PackOutput;)V
|
||||
|
||||
# (Generated)
|
|
@ -1,19 +0,0 @@
|
|||
{
|
||||
"required": true,
|
||||
"minVersion": "0.8",
|
||||
"package": "dev.frogmc.froglib.datagen.impl.mixin",
|
||||
"compatibilityLevel": "JAVA_21",
|
||||
"mixins": [
|
||||
"BlockModelGeneratorsMixin",
|
||||
"ItemModelGeneratorsMixin",
|
||||
"MainMixin",
|
||||
"ModelProviderMixin"
|
||||
],
|
||||
"server": [
|
||||
],
|
||||
"client": [
|
||||
],
|
||||
"injectors": {
|
||||
"defaultRequire": 1
|
||||
}
|
||||
}
|
|
@ -1,5 +0,0 @@
|
|||
{
|
||||
"key.froglib.test": "FrogLib Test Keybind",
|
||||
"category.froglib": "FrogLib Test Category",
|
||||
"block.froglib_block_test.testblock": "Test Block"
|
||||
}
|
|
@ -19,6 +19,3 @@ depends = [
|
|||
main = [
|
||||
"dev.frogmc.froglib.test.FroglibTest"
|
||||
]
|
||||
client = [
|
||||
"dev.frogmc.froglib.test.keybinds.KeybindsTest"
|
||||
]
|
Loading…
Reference in a new issue