merge modules
This commit is contained in:
parent
e3a2545963
commit
2426bb9c0c
120
build.gradle.kts
120
build.gradle.kts
|
@ -1,3 +1,10 @@
|
|||
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`
|
||||
|
@ -6,36 +13,17 @@ plugins {
|
|||
}
|
||||
|
||||
group = "dev.frogmc"
|
||||
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"))
|
||||
}
|
||||
}
|
||||
version =
|
||||
"0.0.1-alpha.3+" + libs.versions.minecraft.get() +
|
||||
("+local".takeUnless { project.hasProperty("FrogMCSnapshotsMavenPassword") } ?: "")
|
||||
|
||||
phytotelma {
|
||||
loader(rootProject.libs.versions.frogloader)
|
||||
minecraft(rootProject.libs.versions.minecraft, provider { "1.20.6" }) // since parchment isn't published for 1.21 yet
|
||||
minecraft {
|
||||
version = libs.versions.minecraft
|
||||
}
|
||||
loader {
|
||||
version = libs.versions.frogloader
|
||||
}
|
||||
}
|
||||
|
||||
tasks.processResources {
|
||||
|
@ -43,8 +31,20 @@ allprojects {
|
|||
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()
|
||||
)
|
||||
}
|
||||
|
||||
val s = generateDatagenAWs()
|
||||
filesMatching("froglib.accesswidener") {
|
||||
filter { l ->
|
||||
if (l == "# (Generated)") {
|
||||
return@filter s
|
||||
}
|
||||
return@filter l
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -53,8 +53,10 @@ allprojects {
|
|||
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()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -94,28 +96,40 @@ allprojects {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
evaluationDependsOnChildren()
|
||||
fun generateDatagenAWs(): String {
|
||||
val classes = listOf(
|
||||
"net/minecraft/data/models/BlockModelGenerators",
|
||||
"net/minecraft/data/models/ItemModelGenerators"
|
||||
)
|
||||
|
||||
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)
|
||||
}
|
||||
}
|
||||
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")
|
||||
|
||||
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)
|
||||
}
|
||||
}
|
||||
appendLine()
|
||||
appendLine("# File: $s")
|
||||
val node = ClassNode()
|
||||
ClassReader(classFile.readBytes()).accept(
|
||||
node,
|
||||
ClassReader.SKIP_CODE or ClassReader.SKIP_DEBUG or ClassReader.SKIP_FRAMES
|
||||
)
|
||||
|
||||
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
gradle.properties
Normal file
1
gradle.properties
Normal file
|
@ -0,0 +1 @@
|
|||
org.gradle.parallel = true
|
|
@ -1,7 +1,7 @@
|
|||
[versions]
|
||||
|
||||
minecraft = "1.21"
|
||||
frogloader = "0.0.1-alpha.14"
|
||||
phytotelma = "0.0.1-alpha.16+local"
|
||||
frogloader = "0.0.1-alpha.15"
|
||||
phytotelma = "0.0.1-alpha.16"
|
||||
lombok = "8.6"
|
||||
|
||||
|
|
|
@ -1,14 +0,0 @@
|
|||
package dev.frogmc.froglib.datagen.api;
|
||||
|
||||
import net.minecraft.data.DataGenerator;
|
||||
import net.minecraft.data.models.BlockModelGenerators;
|
||||
import net.minecraft.data.models.ItemModelGenerators;
|
||||
|
||||
public interface DatagenExtension {
|
||||
|
||||
default void addProviders(DataGenerator.PackGenerator pack) {}
|
||||
|
||||
default void generateBlockModels(BlockModelGenerators generators) {}
|
||||
|
||||
default void generateItemModels(ItemModelGenerators generators) {}
|
||||
}
|
|
@ -1,11 +0,0 @@
|
|||
accessWidener v2 named
|
||||
|
||||
accessible method net/minecraft/data/DataGenerator$PackGenerator <init> (Lnet/minecraft/data/DataGenerator;ZLjava/lang/String;Lnet/minecraft/data/PackOutput;)V
|
||||
|
||||
# transitive-accessible class net/minecraft/data/models/BlockModelGenerators$BlockEntityModelGenerator
|
||||
# transitive-accessible class net/minecraft/data/models/BlockModelGenerators$BlockFamilyProvider
|
||||
# transitive-accessible class net/minecraft/data/models/BlockModelGenerators$BlockStateGeneratorSupplier
|
||||
# transitive-accessible class net/minecraft/data/models/BlockModelGenerators$TintState
|
||||
# transitive-accessible class net/minecraft/data/models/BlockModelGenerators$WoodProvider
|
||||
|
||||
### generated aws
|
|
@ -1,3 +0,0 @@
|
|||
accessWidener v2 named
|
||||
|
||||
mutable field net/minecraft/client/Options keyMappings [Lnet/minecraft/client/KeyMapping;
|
|
@ -17,10 +17,10 @@ depends = [
|
|||
|
||||
[frog.extensions]
|
||||
client = [
|
||||
"dev.frogmc.froglib.resources.impl.ResourceLoaderClient"
|
||||
"dev.frogmc.froglib.impl.resources.ResourceLoaderClient"
|
||||
]
|
||||
server = [
|
||||
"dev.frogmc.froglib.resources.impl.ResourceLoaderServer"
|
||||
"dev.frogmc.froglib.impl.resources.ResourceLoaderServer"
|
||||
]
|
||||
mixin = [
|
||||
"froglib.resources.mixins.json"
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
pluginManagement {
|
||||
repositories {
|
||||
mavenLocal()
|
||||
maven {
|
||||
name = "FrogMC Maven Releases"
|
||||
url = uri("https://maven.frogmc.dev/releases")
|
||||
|
@ -13,23 +14,3 @@ 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:block")
|
||||
findProject(":library:block")?.name = "block"
|
||||
include("library:gen")
|
||||
findProject(":library:gen")?.name = "gen"
|
||||
include("library:datagen")
|
||||
findProject(":library:datagen")?.name = "datagen"
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package dev.frogmc.froglib.block.api;
|
||||
|
||||
import dev.frogmc.froglib.block.api.listener.OnPlayerDestroy;
|
||||
import dev.frogmc.froglib.block.api.listener.OnRemove;
|
||||
import dev.frogmc.froglib.block.api.listener.OnPlayerDestroy;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.ItemStack;
|
|
@ -7,7 +7,6 @@ import com.electronwill.nightconfig.core.Config;
|
|||
import com.electronwill.nightconfig.json.JsonFormat;
|
||||
import dev.frogmc.froglib.block.impl.JsonProvider;
|
||||
import dev.frogmc.froglib.block.impl.RuntimeDatagen;
|
||||
import net.minecraft.data.models.model.ModelTemplate;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
|
|
@ -3,7 +3,6 @@ package dev.frogmc.froglib.block.api;
|
|||
import com.electronwill.nightconfig.core.Config;
|
||||
import com.electronwill.nightconfig.json.JsonFormat;
|
||||
import dev.frogmc.froglib.block.impl.JsonProvider;
|
||||
import net.minecraft.data.models.blockstates.BlockStateGenerator;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
|
||||
public abstract class FrogBlockstate implements JsonProvider {
|
|
@ -0,0 +1,27 @@
|
|||
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);
|
||||
}
|
||||
}
|
|
@ -4,12 +4,16 @@ 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 {
|
||||
|
@ -17,9 +21,8 @@ public final class FrogDatagen {
|
|||
public static final boolean ENABLED = Boolean.getBoolean("frog.datagen.enabled");
|
||||
public static DatagenExtension extension;
|
||||
|
||||
private static final String modId = System.getProperty("frog.datagen.modid");
|
||||
public static final String MOD_ID = System.getProperty("frog.datagen.modid");
|
||||
private static final String generatorClass = System.getProperty("frog.datagen.generator");
|
||||
private static final Path output = Path.of(Objects.requireNonNull(System.getProperty("frog.datagen.output"), "No output path provided!"));
|
||||
|
||||
private FrogDatagen() {
|
||||
}
|
||||
|
@ -27,17 +30,18 @@ public final class FrogDatagen {
|
|||
public static void run() {
|
||||
|
||||
SharedConstants.tryDetectVersion();
|
||||
FrogGenerator generator = new FrogGenerator(output, modId);
|
||||
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();
|
||||
|
||||
extension.addProviders(pack);
|
||||
pack.addProvider(ModelProvider::new);
|
||||
|
||||
extension.addProviders(pack, providerFuture);
|
||||
|
||||
generator.run();
|
||||
} catch (Throwable e) {
|
|
@ -0,0 +1,37 @@
|
|||
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();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
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,3 +16,24 @@ depends = [
|
|||
]
|
||||
|
||||
[frog.extensions]
|
||||
init = [
|
||||
|
||||
]
|
||||
client = [
|
||||
"dev.frogmc.froglib.resources.impl.ResourceLoaderClient"
|
||||
]
|
||||
server = [
|
||||
"dev.frogmc.froglib.impl.resources.ResourceLoaderServer"
|
||||
]
|
||||
accesswidener = "froglib.accesswidener"
|
||||
mixin = [
|
||||
"froglib.block.mixins.json",
|
||||
"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"
|
||||
]
|
9
src/main/resources/froglib.accesswidener
Normal file
9
src/main/resources/froglib.accesswidener
Normal file
|
@ -0,0 +1,9 @@
|
|||
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)
|
|
@ -4,7 +4,7 @@
|
|||
"package": "dev.frogmc.froglib.block.impl.mixin",
|
||||
"compatibilityLevel": "JAVA_21",
|
||||
"mixins": [
|
||||
"PackRepositoryMixin"
|
||||
"block.impl.mixin.PackRepositoryMixin"
|
||||
],
|
||||
"server": [
|
||||
],
|
|
@ -6,7 +6,8 @@
|
|||
"mixins": [
|
||||
"BlockModelGeneratorsMixin",
|
||||
"ItemModelGeneratorsMixin",
|
||||
"MainMixin"
|
||||
"MainMixin",
|
||||
"ModelProviderMixin"
|
||||
],
|
||||
"server": [
|
||||
],
|
Loading…
Reference in a new issue