Skip to content

Commit

Permalink
feat: Hopefully partially working log gen implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
Zepalesque committed May 21, 2024
1 parent 554b35d commit 2ae5025
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/main/java/net/zepalesque/zenith/api/WoodSet.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package net.zepalesque.zenith.api;

import net.minecraft.core.Direction;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.SoundType;
Expand All @@ -15,6 +17,8 @@
import net.neoforged.neoforge.registries.DeferredBlock;
import net.neoforged.neoforge.registries.DeferredHolder;
import net.neoforged.neoforge.registries.DeferredRegister;
import net.zepalesque.zenith.util.DataGenUtil;
import org.codehaus.plexus.util.StringUtils;

public class WoodSet extends BaseWoodSet {

Expand Down Expand Up @@ -63,11 +67,14 @@ public void blockGen(BlockStateProvider data) {

@Override
public void itemGen(ItemModelProvider data) {

ResourceLocation logID = DataGenUtil.getId(log, BuiltInRegistries.BLOCK);
data.withExistingParent(logID.getPath(), logID.withPrefix("block/"));
}

@Override
public void langGen(LanguageProvider data) {

data.addBlock(log, DataGenUtil.getNameLocalized(log, BuiltInRegistries.BLOCK));
}


}
25 changes: 25 additions & 0 deletions src/main/java/net/zepalesque/zenith/util/DataGenUtil.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package net.zepalesque.zenith.util;

import net.minecraft.core.Registry;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.level.block.Block;
import net.neoforged.neoforge.registries.NeoForgeRegistries;
import org.codehaus.plexus.util.StringUtils;

import java.util.function.Supplier;

public class DataGenUtil {

public static <T> ResourceLocation getId(Supplier<? extends T> object, Registry<T> registry) {
return registry.getKey(object.get());
}

public static String getNameLocalized(String id) {
return StringUtils.capitalise(id.replace('_', ' '));
}

public static <T> String getNameLocalized(Supplier<? extends T> object, Registry<T> registry) {
return getNameLocalized(getId(object, registry).getPath());
}
}

0 comments on commit 2ae5025

Please sign in to comment.