Compare commits

..

No commits in common. "mistress" and "owlsys/datagen" have entirely different histories.

106 changed files with 758 additions and 335 deletions

View file

@ -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,126 +6,116 @@ plugins {
}
group = "dev.frogmc"
version =
"0.0.1-alpha.4+" + libs.versions.minecraft.get() +
("-local".takeUnless { project.hasProperty("FrogMCSnapshotsMavenPassword") } ?: "")
version = "0.0.1-alpha.2"
phytotelma {
minecraft {
version = libs.versions.minecraft
mappings = mojmapParchment {
gameVersion = "1.21"
}
}
loader {
version = libs.versions.frogloader
subprojects {
if (!project.projectDir.resolve("src/main/resources/frog.mod.toml").exists()) {
return@subprojects
}
project.group = "dev.frogmc.froglib"
project.version = rootProject.version
}
tasks.processResources {
inputs.property("version", version)
inputs.property("game_version", libs.versions.minecraft.get())
filesMatching("frog.mod.toml") {
expand(
"version" to version,
"game_version" to libs.versions.minecraft.get()
)
allprojects {
if (!project.projectDir.resolve("src/main/resources/frog.mod.toml").exists()) {
return@allprojects
}
val s = generateDatagenAWs()
filesMatching("froglib.accesswidener") {
filter { l ->
if (l == "# (Generated)") {
return@filter s
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 {
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 {
inputs.property("version", version)
inputs.property("game_version", libs.versions.minecraft.get())
filesMatching("frog.mod.toml") {
expand("version" to version,
"game_version" to libs.versions.minecraft.get())
}
}
tasks.processTestResources {
inputs.property("version", version)
inputs.property("game_version", libs.versions.minecraft.get())
filesMatching("frog.mod.toml") {
expand("version" to version,
"game_version" to libs.versions.minecraft.get())
}
}
tasks.runClient {
classpath(sourceSets.test.get().runtimeClasspath)
}
tasks.test {
enabled = false
}
publishing {
publications {
create<MavenPublication>("mavenJava") {
artifactId = project.name
from(components["java"])
}
}
repositories {
maven {
name = "FrogMCSnapshotsMaven"
url = uri("https://maven.frogmc.dev/snapshots")
credentials(PasswordCredentials::class)
authentication {
create<BasicAuthentication>("basic")
}
}
maven {
name = "FrogMCReleasesMaven"
url = uri("https://maven.frogmc.dev/releases")
credentials(PasswordCredentials::class)
authentication {
create<BasicAuthentication>("basic")
}
}
return@filter l
}
}
}
tasks.processTestResources {
inputs.property("version", version)
inputs.property("game_version", libs.versions.minecraft.get())
filesMatching("frog.mod.toml") {
expand(
"version" to version,
"game_version" to libs.versions.minecraft.get()
)
}
}
evaluationDependsOnChildren()
tasks.runClient {
classpath(sourceSets.test.get().runtimeClasspath)
}
tasks.test {
enabled = false
}
publishing {
publications {
create<MavenPublication>("mavenJava") {
artifactId = project.name
from(components["java"])
}
}
repositories {
maven {
name = "FrogMCSnapshotsMaven"
url = uri("https://maven.frogmc.dev/snapshots")
credentials(PasswordCredentials::class)
authentication {
create<BasicAuthentication>("basic")
}
}
maven {
name = "FrogMCReleasesMaven"
url = uri("https://maven.frogmc.dev/releases")
credentials(PasswordCredentials::class)
authentication {
create<BasicAuthentication>("basic")
}
}
project.subprojects.filter {
it.projectDir.resolve("src/main/resources/frog.mod.toml").exists()
}.forEach {
classpath(it.sourceSets.test.get().output)
}
}
fun generateDatagenAWs(): String {
val classes = listOf(
"net/minecraft/data/models/BlockModelGenerators",
"net/minecraft/data/models/ItemModelGenerators"
)
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")
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}")
}
}
}
dependencies {
project.subprojects.filter {
it.projectDir.resolve("src/main/resources/frog.mod.toml").exists()
}.forEach {
project.tasks.jar {
dependsOn(it.tasks.build)
}
return text
api(it)
include(it)
}
}
}

View file

@ -1 +0,0 @@
org.gradle.parallel = true

View file

@ -1,7 +1,7 @@
[versions]
minecraft = "1.21.1"
frogloader = "0.0.1-alpha.30"
phytotelma = "0.0.1-alpha.25"
minecraft = "1.21"
frogloader = "0.0.1-alpha.14"
phytotelma = "0.0.1-alpha.16+local"
lombok = "8.6"

View file

@ -0,0 +1,65 @@
package dev.frogmc.froglib.block.api;
import dev.frogmc.froglib.block.api.listener.OnPlayerDestroy;
import dev.frogmc.froglib.block.api.listener.OnRemove;
import net.minecraft.core.BlockPos;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.state.BlockBehaviour;
import net.minecraft.world.level.block.state.BlockState;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
public class FrogBlockBuilder {
private final BlockBehaviour.Properties properties;
private OnRemove removalListener = (block, state, level, pos, newState, movedByPiston) -> {};
private OnPlayerDestroy playerDestroy = (block, level, player, pos, state, blockEntity, tool) -> {};
private FrogBlockBuilder(BlockBehaviour.Properties properties) {
this.properties = properties;
}
public static FrogBlockBuilder of(BlockBehaviour.Properties properties) {
return new FrogBlockBuilder(properties);
}
public FrogBlockBuilder onRemove(OnRemove listener) {
removalListener = listener;
return this;
}
public FrogBlockBuilder onPlayerDestroy(OnPlayerDestroy onPlayerDestroy) {
this.playerDestroy = onPlayerDestroy;
return this;
}
public Block build() {
return new Block(properties) {
@Override
public @NotNull BlockState playerWillDestroy(@NotNull Level level, @NotNull BlockPos pos, @NotNull BlockState state, @NotNull Player player) {
return super.playerWillDestroy(level, pos, state, player);
}
@Override
protected void spawnDestroyParticles(@NotNull Level level, @NotNull Player player, @NotNull BlockPos pos, @NotNull BlockState state) {
super.spawnDestroyParticles(level, player, pos, state);
}
@Override
protected void onRemove(@NotNull BlockState state, @NotNull Level level, @NotNull BlockPos pos, @NotNull BlockState newState, boolean movedByPiston) {
removalListener.onRemove(this, state, level, pos, newState, movedByPiston);
super.onRemove(state, level, pos, newState, movedByPiston);
}
@Override
public void playerDestroy(@NotNull Level level, @NotNull Player player, @NotNull BlockPos pos, @NotNull BlockState state, @Nullable BlockEntity blockEntity, @NotNull ItemStack tool) {
playerDestroy.onPlayerDestroy(this, level, player, pos, state, blockEntity, tool);
super.playerDestroy(level, player, pos, state, blockEntity, tool);
}
};
}
}

View file

@ -0,0 +1,66 @@
package dev.frogmc.froglib.block.api;
import java.util.HashMap;
import java.util.Map;
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;
public class FrogBlockModel implements JsonProvider {
private final String parent;
private final Map<String, String> textures;
private FrogBlockModel(String parent, Map<String, String> textures) {
this.parent = parent;
this.textures = textures;
}
/*public static FrogBlockModel.Builder ofTemplate(ModelTemplate template) {
}*/
public static FrogBlockModel.Builder builder() {
return new Builder();
}
public void register(ResourceLocation block) {
RuntimeDatagen.getInstance().addBlockModel(block, this);
}
public static class Builder {
private String parent = null;
private final Map<String, String> textures = new HashMap<>();
public Builder parent(String parent) {
this.parent = parent;
return this;
}
public Builder texture(String name, String location) {
textures.put(name, location);
return this;
}
public FrogBlockModel build() {
return new FrogBlockModel(parent, textures);
}
}
@ApiStatus.Internal
public String getJson() {
Config c = Config.inMemory();
if (parent != null) {
c.add("parent", parent);
}
if (!textures.isEmpty()) {
textures.forEach((s, s2) -> c.add("textures." + s, s2));
}
return JsonFormat.fancyInstance().createWriter().writeToString(c);
}
}

View file

@ -0,0 +1,29 @@
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 {
/*public static FrogBlockstate multipart() {
}
public static FrogBlockstate variants() {
}
public static FrogBlockstate ofGenerator(BlockStateGenerator generator) {
generator.get().toString();
}*/
@ApiStatus.Internal
public String getJson() {
Config c = Config.inMemory();
return JsonFormat.fancyInstance().createWriter().writeToString(c);
}
}

View file

@ -0,0 +1,13 @@
package dev.frogmc.froglib.block.api.listener;
import net.minecraft.core.BlockPos;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.state.BlockState;
public interface OnPlayerDestroy {
void onPlayerDestroy(Block block, Level level, Player player, BlockPos pos, BlockState state, BlockEntity blockEntity, ItemStack tool);
}

View file

@ -0,0 +1,11 @@
package dev.frogmc.froglib.block.api.listener;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
public interface OnRemove {
void onRemove(Block block, BlockState state, Level level, BlockPos pos, BlockState newState, boolean movedByPiston);
}

View file

@ -0,0 +1,4 @@
package dev.frogmc.froglib.block.impl;
public class BlockImpl {
}

View file

@ -0,0 +1,5 @@
package dev.frogmc.froglib.block.impl;
public interface JsonProvider {
String getJson();
}

View file

@ -0,0 +1,94 @@
package dev.frogmc.froglib.block.impl;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Collections;
import java.util.List;
import java.util.Optional;
import dev.frogmc.froglib.block.api.FrogBlockModel;
import dev.frogmc.froglib.block.api.FrogBlockstate;
import dev.frogmc.frogloader.api.FrogLoader;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.packs.PackLocationInfo;
import net.minecraft.server.packs.PackSelectionConfig;
import net.minecraft.server.packs.PathPackResources;
import net.minecraft.server.packs.repository.Pack;
import net.minecraft.server.packs.repository.PackCompatibility;
import net.minecraft.server.packs.repository.PackSource;
import net.minecraft.world.flag.FeatureFlagSet;
import org.jetbrains.annotations.NotNull;
@Slf4j
public class RuntimeDatagen {
@Getter
private static final RuntimeDatagen instance = new RuntimeDatagen();
private final Path target = FrogLoader.getInstance().getGameDir().resolve(".frogmc").resolve("datagen");
private RuntimeDatagen(){
try {
Files.createDirectories(target);
} catch (IOException e) {
log.error("Failed to create datagen target dir!", e);
}
}
public void inject(List<Pack> packs) {
packs.add(new Pack(new PackLocationInfo("runtime_datagen", Component.literal("Generated Resources"),
new PackSource() {
@Override
public @NotNull Component decorate(@NotNull Component component) {
return component;
}
@Override
public boolean shouldAddAutomatically() {
return true;
}
}, Optional.empty()), new PathPackResources.PathResourcesSupplier(target),
new Pack.Metadata(Component.empty(), PackCompatibility.COMPATIBLE, FeatureFlagSet.of(), Collections.emptyList()),
new PackSelectionConfig(true, Pack.Position.TOP, true)));
}
public void addBlockstate(ResourceLocation target, FrogBlockstate state) {
Path file = this.target.resolve("assets")
.resolve(target.getNamespace())
.resolve("blockstates")
.resolve(target.getPath()+".json");
try {
Files.writeString(file, state.getJson());
} catch (IOException e) {
log.error("Failed to write genrated blockstate to {}!", file, e);
}
}
public void addBlockModel(ResourceLocation target, FrogBlockModel model) {
Path file = this.target.resolve("assets")
.resolve(target.getNamespace())
.resolve("models/block")
.resolve(target.getPath()+".json");
try {
Files.writeString(file, model.getJson());
} catch (IOException e) {
log.error("Failed to write genrated block model to {}!", file, e);
}
}
private void add(String type, String path, ResourceLocation loc, JsonProvider provider) {
Path file = this.target.resolve(type)
.resolve(loc.getNamespace())
.resolve(path)
.resolve(loc.getPath()+".json");
try {
Files.writeString(file, provider.getJson());
} catch (IOException e) {
log.error("Failed to write genrated block model to {}!", file, e);
}
}
}

View file

@ -0,0 +1,22 @@
package dev.frogmc.froglib.block.impl.mixin;
import java.util.Collection;
import java.util.List;
import com.llamalad7.mixinextras.sugar.Local;
import dev.frogmc.froglib.block.impl.RuntimeDatagen;
import net.minecraft.server.packs.repository.Pack;
import net.minecraft.server.packs.repository.PackRepository;
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(PackRepository.class)
public class PackRepositoryMixin {
@Inject(method = "rebuildSelected", at = @At(value = "INVOKE", target = "Lcom/google/common/collect/ImmutableList;copyOf(Ljava/util/Collection;)Lcom/google/common/collect/ImmutableList;"))
private void injectModResources(Collection<String> ids, CallbackInfoReturnable<List<Pack>> cir, @Local List<Pack> packs) {
RuntimeDatagen.getInstance().inject(packs);
}
}

View file

@ -0,0 +1,21 @@
[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",
]

View file

@ -0,0 +1,17 @@
{
"required": true,
"minVersion": "0.8",
"package": "dev.frogmc.froglib.block.impl.mixin",
"compatibilityLevel": "JAVA_21",
"mixins": [
"PackRepositoryMixin"
],
"server": [
],
"client": [
],
"injectors": {
"defaultRequire": 1
}
}

View file

View 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",
]

View file

View 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"
]

View file

@ -0,0 +1,14 @@
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) {}
}

View file

@ -4,17 +4,12 @@ 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 dev.frogmc.froglib.datagen.api.providers.TranslationProvider;
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 {
@ -22,8 +17,9 @@ 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 modId = 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() {
}
@ -31,19 +27,17 @@ public final class 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);
FrogGenerator generator = new FrogGenerator(output, modId);
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);
pack.addProvider(TranslationProvider::new);
extension.addProviders(pack, providerFuture);
generator.run();
} catch (Throwable e) {

View file

@ -10,8 +10,10 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin(BlockModelGenerators.class)
public class BlockModelGeneratorsMixin {
@Inject(method = "run", at = @At("HEAD"))
@Inject(method = "run", at = @At("HEAD"), cancellable = true)
private void generateModBlockModels(CallbackInfo ci){
FrogDatagen.extension.generateBlockModels((BlockModelGenerators)(Object)this);
ci.cancel();
}
}

View file

@ -10,8 +10,10 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin(ItemModelGenerators.class)
public class ItemModelGeneratorsMixin {
@Inject(method = "run", at = @At("HEAD"))
@Inject(method = "run", at = @At("HEAD"), cancellable = true)
private void generateItemModels(CallbackInfo ci) {
FrogDatagen.extension.generateItemModels((ItemModelGenerators) (Object) this);
ci.cancel();
}
}

View file

@ -0,0 +1,22 @@
[frog]
format_version = "1.0.0"
[frog.mod]
id = "froglib_datagen"
name = "FrogLib Datagen"
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.datagen.mixins.json"
]
accesswidener = "froglib.datagen.accesswidener"

View file

@ -0,0 +1,11 @@
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

View file

@ -6,8 +6,7 @@
"mixins": [
"BlockModelGeneratorsMixin",
"ItemModelGeneratorsMixin",
"MainMixin",
"ModelProviderMixin"
"MainMixin"
],
"server": [
],

View file

@ -0,0 +1,4 @@
dependencies {
api(project(":library:resourceloader"))
}

View 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"

View file

@ -0,0 +1,3 @@
accessWidener v2 named
mutable field net/minecraft/client/Options keyMappings [Lnet/minecraft/client/KeyMapping;

View file

@ -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,10 +6,9 @@ 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) {
KeyMappings.register(new KeyMapping("key.froglib.test", InputConstants.KEY_O, "category.froglib"));
}
}
}

View file

@ -0,0 +1,4 @@
{
"key.froglib.test": "FrogLib Test Keybind",
"category.froglib": "FrogLib Test Category"
}

View 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"

View file

View file

View 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"

View file

@ -0,0 +1,4 @@
dependencies {
api(project(":library:resourceloader"))
}

View 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"

View file

@ -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)
));
}
}

View file

@ -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());
}

View file

@ -0,0 +1,7 @@
{
"variants": {
"": {
"model": "minecraft:block/anvil"
}
}
}

View file

@ -0,0 +1,3 @@
{
"block.froglib_block_test.testblock": "Test Block"
}

View file

@ -0,0 +1,3 @@
{
"parent": "minecraft:block/anvil"
}

View 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"

View file

View 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"
]

View file

@ -1,6 +1,5 @@
pluginManagement {
repositories {
mavenLocal()
maven {
name = "FrogMC Maven Releases"
url = uri("https://maven.frogmc.dev/releases")
@ -13,4 +12,24 @@ pluginManagement {
}
}
rootProject.name = "froglib"
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"

View file

@ -1,35 +0,0 @@
package dev.frogmc.froglib.datagen.api;
import java.util.concurrent.CompletableFuture;
import java.util.function.BiFunction;
import dev.frogmc.froglib.datagen.api.generators.TranslationGenerator;
import net.minecraft.core.HolderLookup;
import net.minecraft.core.RegistrySetBuilder;
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) {}
default void generateTranslations(TranslationGenerator generator) {}
default void generateRegistries(RegistrySetBuilder builder) {
}
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);
}
}

View file

@ -1,26 +0,0 @@
package dev.frogmc.froglib.datagen.api.generators;
import java.util.function.Function;
import com.google.gson.JsonObject;
public class TranslationGenerator {
private final Function<String, JsonObject> translation;
private String currentLang;
public TranslationGenerator(Function<String, JsonObject> translation) {
this.translation = translation;
}
public void setLanguage(String langCode) {
currentLang = langCode;
}
public void add(String key, String translation) {
if (currentLang == null) {
throw new IllegalArgumentException("No language has been set!");
}
this.translation.apply(currentLang).addProperty(key, translation);
}
}

View file

@ -1,45 +0,0 @@
package dev.frogmc.froglib.datagen.api.providers;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.CompletableFuture;
import com.google.gson.JsonObject;
import dev.frogmc.froglib.datagen.api.generators.TranslationGenerator;
import dev.frogmc.froglib.datagen.impl.FrogDatagen;
import net.minecraft.data.CachedOutput;
import net.minecraft.data.DataProvider;
import net.minecraft.data.PackOutput;
import net.minecraft.resources.ResourceLocation;
import org.jetbrains.annotations.NotNull;
public class TranslationProvider implements DataProvider {
private final PackOutput.PathProvider langProvider;
public TranslationProvider(PackOutput output) {
langProvider = output.createPathProvider(PackOutput.Target.RESOURCE_PACK, "lang");
}
@Override
public @NotNull CompletableFuture<?> run(@NotNull CachedOutput cachedOutput) {
List<CompletableFuture<?>> futures = new ArrayList<>();
Map<String, JsonObject> translations = new HashMap<>();
TranslationGenerator generator = new TranslationGenerator(s -> translations.computeIfAbsent(s, a -> new JsonObject()));
FrogDatagen.extension.generateTranslations(generator);
translations.forEach((lang, object) -> {
futures.add(DataProvider.saveStable(cachedOutput,
object,
langProvider.json(ResourceLocation.fromNamespaceAndPath(FrogDatagen.MOD_ID, lang))
));
});
return CompletableFuture.allOf(futures.toArray(CompletableFuture[]::new));
}
@Override
public String getName() {
return "FrogMC:Translations";
}
}

Some files were not shown because too many files have changed in this diff Show more