Migrate some things to DataGen
This commit is contained in:
parent
58f23e8758
commit
1015b36ee5
199 changed files with 237 additions and 2938 deletions
|
@ -82,7 +82,7 @@ public class DeprecatedModBlocks
|
|||
|
||||
public static RegistryObject<Block> registerDeprecated(RegistryObject<Block> blk)
|
||||
{
|
||||
ITEMS.register(blk.getId().getPath(), ()->new DeprecatedBlockItem(blk.get()));
|
||||
CreativeModeTabs.addToOTEModTab(ITEMS.register(blk.getId().getPath(), ()->new DeprecatedBlockItem(blk.get())));
|
||||
|
||||
return blk;
|
||||
}
|
||||
|
|
|
@ -76,7 +76,7 @@ public class ModBlocks {
|
|||
|
||||
public static RegistryObject<Block> registerWithItem(RegistryObject<Block> blk, Item.Properties props)
|
||||
{
|
||||
ITEMS.register(blk.getId().getPath(), ()->new BlockItem(blk.get(), props));
|
||||
CreativeModeTabs.addToOTEModTab(ITEMS.register(blk.getId().getPath(), ()->new BlockItem(blk.get(), props)));
|
||||
|
||||
return blk;
|
||||
}
|
||||
|
|
|
@ -1,62 +0,0 @@
|
|||
package dev.zontreck.otemod.blocks.entity;
|
||||
|
||||
import com.mojang.blaze3d.vertex.VertexConsumer;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import org.joml.Matrix4f;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
public class ParallaxWindowEntity extends BlockEntity
|
||||
{
|
||||
public enum SkyType
|
||||
{
|
||||
Level1
|
||||
}
|
||||
|
||||
public ParallaxWindowEntity(BlockPos pPos, BlockState pBlockState) {
|
||||
super(ModEntities.PARALLAX_WINDOW_ENTITY.get(), pPos, pBlockState);
|
||||
}
|
||||
|
||||
private SkyType skyType = SkyType.Level1;
|
||||
|
||||
public SkyType getSkyType() {
|
||||
return skyType;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void saveAdditional(CompoundTag compoundTag) {
|
||||
compoundTag.putString("skyType", this.skyType.name());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load(CompoundTag compoundTag) {
|
||||
if (!compoundTag.contains("skyType")) {
|
||||
return;
|
||||
}
|
||||
this.skyType = SkyType.valueOf(compoundTag.getString("skyType"));
|
||||
}
|
||||
|
||||
|
||||
private final Boolean[] shouldRender = new Boolean[6];
|
||||
|
||||
public boolean shouldRenderFace(Direction direction) {
|
||||
int index = direction.ordinal();
|
||||
|
||||
if (shouldRender[index] == null) {
|
||||
shouldRender[index] = level == null || Block.shouldRenderFace(getBlockState(), level, getBlockPos(), direction, getBlockPos().relative(direction));
|
||||
}
|
||||
|
||||
return shouldRender[index];
|
||||
}
|
||||
|
||||
public void neighborChanged() {
|
||||
Arrays.fill(shouldRender, null);
|
||||
}
|
||||
}
|
|
@ -1,49 +0,0 @@
|
|||
package dev.zontreck.otemod.client.renderer;
|
||||
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.mojang.blaze3d.vertex.VertexConsumer;
|
||||
import dev.zontreck.otemod.blocks.ParallaxWindow;
|
||||
import dev.zontreck.otemod.blocks.entity.ParallaxWindowEntity;
|
||||
import net.minecraft.client.renderer.MultiBufferSource;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.client.renderer.blockentity.BlockEntityRenderer;
|
||||
import net.minecraft.core.Direction;
|
||||
import org.joml.Matrix4f;
|
||||
|
||||
public class ParallaxWindowEntityRenderer implements BlockEntityRenderer<ParallaxWindowEntity>
|
||||
{
|
||||
|
||||
@Override
|
||||
public void render(ParallaxWindowEntity parallaxWindowEntity, float v, PoseStack poseStack, MultiBufferSource multiBufferSource, int i, int i1) {
|
||||
|
||||
Matrix4f m4f = poseStack.last().pose();
|
||||
var renderType = switch (parallaxWindowEntity.getSkyType()) {
|
||||
|
||||
case Level1 -> RenderType.endPortal();
|
||||
};
|
||||
renderCube(parallaxWindowEntity, m4f, multiBufferSource.getBuffer(renderType));
|
||||
}
|
||||
|
||||
|
||||
private void renderCube(ParallaxWindowEntity entity, Matrix4f matrix, VertexConsumer buffer) {
|
||||
renderFace(entity, matrix, buffer, 0.0f, 1.0f, 0.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, Direction.SOUTH);
|
||||
renderFace(entity, matrix, buffer, 0.0f, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, Direction.NORTH);
|
||||
renderFace(entity, matrix, buffer, 1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 1.0f, 1.0f, 0.0f, Direction.EAST);
|
||||
renderFace(entity, matrix, buffer, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, 1.0f, 0.0f, Direction.WEST);
|
||||
renderFace(entity, matrix, buffer, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 1.0f, Direction.DOWN);
|
||||
renderFace(entity, matrix, buffer, 0.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 0.0f, Direction.UP);
|
||||
}
|
||||
|
||||
private void renderFace(ParallaxWindowEntity entity, Matrix4f matrix, VertexConsumer buffer, float f, float g, float h, float i, float j, float k, float l, float m, Direction direction) {
|
||||
if (entity.shouldRenderFace(direction)) {
|
||||
buffer.vertex(matrix, f, h, j).endVertex();
|
||||
buffer.vertex(matrix, g, h, k).endVertex();
|
||||
buffer.vertex(matrix, g, i, l).endVertex();
|
||||
buffer.vertex(matrix, f, i, m).endVertex();
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public int getViewDistance() {
|
||||
return 256;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
package dev.zontreck.otemod.data;
|
||||
|
||||
import dev.zontreck.otemod.OTEMod;
|
||||
import net.minecraft.data.PackOutput;
|
||||
import net.minecraftforge.client.model.generators.BlockModelBuilder;
|
||||
import net.minecraftforge.client.model.generators.BlockModelProvider;
|
||||
import net.minecraftforge.common.data.ExistingFileHelper;
|
||||
|
||||
public class ModBlockModelsProvider extends BlockModelProvider
|
||||
{
|
||||
public ModBlockModelsProvider(PackOutput output, ExistingFileHelper helper)
|
||||
{
|
||||
super(output, OTEMod.MOD_ID, helper);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerModels() {
|
||||
|
||||
// Model file paths
|
||||
String cubeModel = "block/cube";
|
||||
String sideTexture = "#side";
|
||||
String frontTexture = "#front";
|
||||
|
||||
// Model Builder for your block
|
||||
cubeAll("rotatable", modLoc(cubeModel))
|
||||
.texture("particle", modLoc(sideTexture))
|
||||
.texture("down", modLoc(sideTexture))
|
||||
.texture("up", modLoc(sideTexture))
|
||||
.texture("north", modLoc(frontTexture))
|
||||
.texture("east", modLoc(sideTexture))
|
||||
.texture("south", modLoc(sideTexture))
|
||||
.texture("west", modLoc(sideTexture));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,97 @@
|
|||
package dev.zontreck.otemod.data;
|
||||
|
||||
import dev.zontreck.otemod.OTEMod;
|
||||
import dev.zontreck.otemod.blocks.*;
|
||||
import dev.zontreck.otemod.items.DeprecatedModItems;
|
||||
import net.minecraft.data.PackOutput;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.block.SlabBlock;
|
||||
import net.minecraft.world.level.block.StairBlock;
|
||||
import net.minecraft.world.level.block.state.BlockBehaviour;
|
||||
import net.minecraftforge.client.model.generators.BlockStateProvider;
|
||||
import net.minecraftforge.client.model.generators.ModelFile;
|
||||
import net.minecraftforge.common.data.ExistingFileHelper;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
import net.minecraftforge.registries.RegistryObject;
|
||||
|
||||
public class ModBlockStatesProvider extends BlockStateProvider
|
||||
{
|
||||
public ModBlockStatesProvider(PackOutput output, ExistingFileHelper existingFileHelper) {
|
||||
super(output, OTEMod.MOD_ID, existingFileHelper);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerStatesAndModels() {
|
||||
blockWithItem(ModBlocks.ETERNIUM_ORE_BLOCK);
|
||||
blockWithItem(ModBlocks.VAULT_STEEL_ORE_BLOCK);
|
||||
blockWithItem(ModBlocks.NETHER_VAULT_STEEL_ORE_BLOCK);
|
||||
blockWithItem(ModBlocks.ETERNIUM_BLOCK);
|
||||
blockWithItem(ModBlocks.DEEPSLATE_ETERNIUM_ORE_BLOCK);
|
||||
blockWithItem(ModBlocks.COMPRESSED_OBSIDIAN_BLOCK);
|
||||
blockWithItem(ModBlocks.LAYERED_COMPRESSED_OBSIDIAN_BLOCK);
|
||||
blockWithItem(ModBlocks.POOL_TILE);
|
||||
stairBlock(ModBlocks.POOL_TILE_STAIRS, ModBlocks.POOL_TILE);
|
||||
slabBlock(ModBlocks.POOL_TILE_SLAB, ModBlocks.POOL_TILE);
|
||||
blockWithItem(ModBlocks.POOL_LIGHT);
|
||||
blockWithItem(ModBlocks.DIRTY_POOL_TILE);
|
||||
stairBlock(ModBlocks.DIRTY_POOL_TILE_STAIRS, ModBlocks.DIRTY_POOL_TILE);
|
||||
slabBlock(ModBlocks.DIRTY_POOL_TILE_SLAB, ModBlocks.DIRTY_POOL_TILE);
|
||||
blockWithItem(ModBlocks.DIRTY_POOL_LIGHT);
|
||||
blockWithItem(ModBlocks.FILTHY_POOL_LIGHT);
|
||||
blockWithItem(ModBlocks.DARK_POOL_TILE);
|
||||
blockWithItem(ModBlocks.DARK_POOL_LIGHT);
|
||||
stairBlock(ModBlocks.DARK_POOL_TILE_STAIRS, ModBlocks.DARK_POOL_TILE);
|
||||
slabBlock(ModBlocks.DARK_POOL_TILE_SLAB, ModBlocks.DARK_POOL_TILE);
|
||||
blockWithItem(ModBlocks.BLUE_POOL_TILE);
|
||||
stairBlock(ModBlocks.BLUE_POOL_TILE_STAIRS, ModBlocks.BLUE_POOL_TILE);
|
||||
slabBlock(ModBlocks.BLUE_POOL_TILE_SLAB, ModBlocks.BLUE_POOL_TILE);
|
||||
blockWithItem(ModBlocks.BLUE_POOL_LIGHT);
|
||||
blockWithItem(ModBlocks.DIRTY_BLUE_POOL_TILE);
|
||||
stairBlock(ModBlocks.DIRTY_BLUE_POOL_TILE_STAIRS, ModBlocks.DIRTY_BLUE_POOL_TILE);
|
||||
slabBlock(ModBlocks.DIRTY_BLUE_POOL_TILE_SLAB, ModBlocks.DIRTY_BLUE_POOL_TILE);
|
||||
blockWithItem(ModBlocks.DIRTY_BLUE_POOL_LIGHT);
|
||||
blockWithItem(ModBlocks.FILTHY_BLUE_POOL_LIGHT);
|
||||
blockWithItem(ModBlocks.RED_POOL_TILE);
|
||||
stairBlock(ModBlocks.RED_POOL_TILE_STAIRS, ModBlocks.RED_POOL_TILE);
|
||||
slabBlock(ModBlocks.RED_POOL_TILE_SLAB, ModBlocks.RED_POOL_TILE);
|
||||
blockWithItem(ModBlocks.RED_POOL_LIGHT);
|
||||
blockWithItem(ModBlocks.DIRTY_RED_POOL_LIGHT);
|
||||
blockWithItem(ModBlocks.FILTHY_RED_POOL_LIGHT);
|
||||
blockWithItem(ModBlocks.DIRTY_RED_POOL_TILE);
|
||||
stairBlock(ModBlocks.DIRTY_RED_POOL_TILE_STAIRS, ModBlocks.DIRTY_RED_POOL_TILE);
|
||||
slabBlock(ModBlocks.DIRTY_RED_POOL_TILE_SLAB, ModBlocks.DIRTY_RED_POOL_TILE);
|
||||
}
|
||||
|
||||
private void blockWithItem(RegistryObject<Block> blockRegistryObject)
|
||||
{
|
||||
simpleBlockWithItem(blockRegistryObject.get(), cubeAll(blockRegistryObject.get()));
|
||||
}
|
||||
|
||||
private void stairBlock(RegistryObject<Block> blk, RegistryObject<Block> texture)
|
||||
{
|
||||
stairsBlock((StairBlock) blk.get(), blockTexture(texture.get()));
|
||||
simpleBlockItem(blk.get(), stairsModel(blk.get(), texture.get()));
|
||||
}
|
||||
|
||||
private String name(Block block) {
|
||||
return this.key(block).getPath();
|
||||
}
|
||||
private ResourceLocation key(Block block) {
|
||||
return ForgeRegistries.BLOCKS.getKey(block);
|
||||
}
|
||||
public ModelFile stairsModel(Block block, Block texture) {
|
||||
return this.models().stairs(name(block), blockTexture(texture), blockTexture(texture), blockTexture(texture));
|
||||
}
|
||||
public ModelFile slabModel(Block block, Block texture) {
|
||||
return this.models().slab(name(block), blockTexture(texture), blockTexture(texture), blockTexture(texture));
|
||||
}
|
||||
private void slabBlock(RegistryObject<Block> blk, RegistryObject<Block> texture)
|
||||
{
|
||||
slabBlock((SlabBlock) blk.get(), blockTexture(texture.get()), blockTexture(texture.get()));
|
||||
simpleBlockItem(blk.get(), slabModel(blk.get(), texture.get()));
|
||||
}
|
||||
}
|
26
src/main/java/dev/zontreck/otemod/data/ModDatagen.java
Normal file
26
src/main/java/dev/zontreck/otemod/data/ModDatagen.java
Normal file
|
@ -0,0 +1,26 @@
|
|||
package dev.zontreck.otemod.data;
|
||||
|
||||
|
||||
import dev.zontreck.otemod.OTEMod;
|
||||
import net.minecraft.data.DataGenerator;
|
||||
import net.minecraft.data.PackOutput;
|
||||
import net.minecraftforge.common.data.ExistingFileHelper;
|
||||
import net.minecraftforge.data.event.GatherDataEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
|
||||
@Mod.EventBusSubscriber(modid = OTEMod.MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD)
|
||||
public class ModDatagen
|
||||
{
|
||||
|
||||
@SubscribeEvent
|
||||
public static void gatherData(GatherDataEvent event)
|
||||
{
|
||||
DataGenerator gen = event.getGenerator();
|
||||
PackOutput output = gen.getPackOutput();
|
||||
|
||||
ExistingFileHelper helper = event.getExistingFileHelper();
|
||||
|
||||
gen.addProvider(event.includeClient(), new ModBlockStatesProvider(output, helper));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,4 @@
|
|||
package dev.zontreck.otemod.data.loot;
|
||||
|
||||
public class ModBlockLootTablesProvider {
|
||||
}
|
Reference in a new issue