merge modules (2)
Some checks failed
Publish to snapshot maven / build (push) Failing after 16s

This commit is contained in:
moehreag 2024-08-05 15:36:25 +02:00
parent 2426bb9c0c
commit cb8958877b
38 changed files with 12 additions and 600 deletions

View file

@ -15,7 +15,7 @@ plugins {
group = "dev.frogmc"
version =
"0.0.1-alpha.3+" + libs.versions.minecraft.get() +
("+local".takeUnless { project.hasProperty("FrogMCSnapshotsMavenPassword") } ?: "")
("-local".takeUnless { project.hasProperty("FrogMCSnapshotsMavenPassword") } ?: "")
phytotelma {
minecraft {

View file

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

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

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

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

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

View file

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

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

View file

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

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

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

View file

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

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

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

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

View file

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

View file

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

View file

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

@ -1,27 +0,0 @@
[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.impl.resources.ResourceLoaderClient"
]
server = [
"dev.frogmc.froglib.impl.resources.ResourceLoaderServer"
]
mixin = [
"froglib.resources.mixins.json"
]

View file

@ -1,65 +0,0 @@
package dev.frogmc.froglib.block.api;
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;
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

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

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

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

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

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

View file

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

View file

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

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

@ -27,7 +27,6 @@ server = [
]
accesswidener = "froglib.accesswidener"
mixin = [
"froglib.block.mixins.json",
"froglib.branding.mixins.json",
"froglib.datagen.mixins.json",
"froglib.entrypoints.mixins.json",

View file

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

View file

@ -1,4 +1,4 @@
package dev.frogmc.froglib.keybinds.test;
package dev.frogmc.froglib.test.keybinds;
import com.mojang.blaze3d.platform.InputConstants;
import dev.frogmc.froglib.entrypoints.api.ClientExtension;
@ -6,9 +6,10 @@ 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,5 @@
{
"key.froglib.test": "FrogLib Test Keybind",
"category.froglib": "FrogLib Test Category",
"block.froglib_block_test.testblock": "Test Block"
}

View file

@ -18,4 +18,7 @@ depends = [
[frog.extensions]
main = [
"dev.frogmc.froglib.test.FroglibTest"
]
client = [
"dev.frogmc.froglib.test.keybinds.KeybindsTest"
]