v1.5 new shapes + self culling + caching + coding tools/cleanup #10

Merged
Adrien1106 merged 11 commits from dev into master 2024-03-14 22:30:30 +01:00
8 changed files with 32 additions and 31 deletions
Showing only changes of commit c207fb5ae6 - Show all commits

View File

@ -39,7 +39,7 @@ public class ReFramed implements ModInitializer {
public static final String MODID = "reframed";
public static final ArrayList<Block> BLOCKS = new ArrayList<>();
public static Block CUBE, SMALL_CUBE, DOUBLE_SMALL_CUBE, STAIRS, DOUBLE_STAIRS, SLAB, DOUBLE_SLAB, STEP, DOUBLE_STEP;
public static Block CUBE, SMALL_CUBE, SMALL_CUBES_STEP, STAIR, STAIRS_CUBE, SLAB, SLABS_CUBE, STEP, STEPS_SLAB;
public static ItemGroup ITEM_GROUP;
public static BlockEntityType<ReFramedEntity> REFRAMED_BLOCK_ENTITY;
@ -50,16 +50,17 @@ public class ReFramed implements ModInitializer {
@Override
public void onInitialize() {
CUBE = registerReFramed("cube" , new ReFramedBlock(cp(Blocks.OAK_PLANKS)));
SMALL_CUBE = registerReFramed("small_cube" , new ReFramedSmallBlock(cp(Blocks.OAK_PLANKS)));
DOUBLE_SMALL_CUBE = registerReFramed("double_small_cube" , new ReFramedDoubleSmallBlock(cp(Blocks.OAK_PLANKS)));
STAIRS = registerReFramed("stairs" , new ReFramedStairsBlock(cp(Blocks.OAK_STAIRS)));
DOUBLE_STAIRS = registerReFramed("double_stairs" , new ReFramedDoubleStairsBlock(cp(Blocks.OAK_STAIRS)));
// CUBE = registerReFramed("half_stairs" , new ReFramedBlock(cp(Blocks.OAK_STAIRS))); // TODO
// CUBE = registerReFramed("double_half_stairs", new ReFramedBlock(cp(Blocks.OAK_STAIRS))); // TODO
SMALL_CUBE = registerReFramed("small_cube" , new ReFramedSmallCubeBlock(cp(Blocks.OAK_PLANKS)));
SMALL_CUBES_STEP = registerReFramed("small_cubes_step" , new ReFramedSmallCubesStepBlock(cp(Blocks.OAK_PLANKS)));
STAIR = registerReFramed("stair" , new ReFramedStairBlock(cp(Blocks.OAK_STAIRS)));
STAIRS_CUBE = registerReFramed("stairs_cube" , new ReFramedStairsCubeBlock(cp(Blocks.OAK_STAIRS)));
// CUBE = registerReFramed("half_stair" , new ReFramedBlock(cp(Blocks.OAK_STAIRS))); // TODO
// CUBE = registerReFramed("half_stairs_stair" , new ReFramedBlock(cp(Blocks.OAK_STAIRS))); // TODO
// CUBE = registerReFramed("half_stairs_slab" , new ReFramedBlock(cp(Blocks.OAK_STAIRS))); // TODO
SLAB = registerReFramed("slab" , new ReFramedSlabBlock(cp(Blocks.OAK_SLAB)));
DOUBLE_SLAB = registerReFramed("double_slab" , new ReFramedDoubleSlabBlock(cp(Blocks.OAK_SLAB)));
SLABS_CUBE = registerReFramed("slabs_cube" , new ReFramedSlabsCubeBlock(cp(Blocks.OAK_SLAB)));
STEP = registerReFramed("step" , new ReFramedStepBlock(cp(Blocks.OAK_SLAB)));
DOUBLE_STEP = registerReFramed("double_step" , new ReFramedDoubleStepBlock(cp(Blocks.OAK_SLAB)));
STEPS_SLAB = registerReFramed("steps_slab" , new ReFramedStepsSlabBlock(cp(Blocks.OAK_SLAB)));
REFRAMED_BLOCK_ENTITY = Registry.register(Registries.BLOCK_ENTITY_TYPE, id("camo"),
FabricBlockEntityTypeBuilder.create(

View File

@ -23,9 +23,9 @@ import static net.minecraft.data.client.VariantSettings.Rotation.R0;
import static net.minecraft.data.client.VariantSettings.Rotation.R90;
import static net.minecraft.state.property.Properties.AXIS;
public class ReFramedDoubleSlabBlock extends ReFramedDoubleBlock implements BlockStateProvider {
public class ReFramedSlabsCubeBlock extends ReFramedDoubleBlock implements BlockStateProvider {
public ReFramedDoubleSlabBlock(Settings settings) {
public ReFramedSlabsCubeBlock(Settings settings) {
super(settings);
setDefaultState(getDefaultState().with(AXIS, Direction.Axis.Y));
}

View File

@ -32,11 +32,11 @@ import static fr.adrien1106.reframed.util.blocks.BlockProperties.CORNER;
import static fr.adrien1106.reframed.util.blocks.Corner.*;
import static net.minecraft.data.client.VariantSettings.Rotation.*;
public class ReFramedSmallBlock extends WaterloggableReFramedBlock implements BlockStateProvider {
public class ReFramedSmallCubeBlock extends WaterloggableReFramedBlock implements BlockStateProvider {
public static final List<VoxelShape> SMALL_CUBE_VOXELS = new ArrayList<>(8);
public ReFramedSmallBlock(Settings settings) {
public ReFramedSmallCubeBlock(Settings settings) {
super(settings);
setDefaultState(getDefaultState().with(CORNER, NORTH_EAST_DOWN));
}

View File

@ -1,6 +1,6 @@
package fr.adrien1106.reframed;
package fr.adrien1106.reframed.block;
import fr.adrien1106.reframed.block.WaterloggableReFramedDoubleBlock;
import fr.adrien1106.reframed.ReFramed;
import fr.adrien1106.reframed.generator.BlockStateProvider;
import fr.adrien1106.reframed.generator.GBlockstate;
import fr.adrien1106.reframed.util.blocks.BlockHelper;
@ -23,16 +23,16 @@ import net.minecraft.util.shape.VoxelShape;
import net.minecraft.world.BlockView;
import org.jetbrains.annotations.Nullable;
import static fr.adrien1106.reframed.block.ReFramedSmallBlock.SMALL_CUBE_VOXELS;
import static fr.adrien1106.reframed.block.ReFramedSmallCubeBlock.SMALL_CUBE_VOXELS;
import static fr.adrien1106.reframed.block.ReFramedStepBlock.getStepShape;
import static fr.adrien1106.reframed.util.blocks.BlockProperties.EDGE;
import static fr.adrien1106.reframed.util.blocks.Edge.*;
import static net.minecraft.data.client.VariantSettings.Rotation.*;
import static net.minecraft.util.shape.VoxelShapes.empty;
public class ReFramedDoubleSmallBlock extends WaterloggableReFramedDoubleBlock implements BlockStateProvider {
public class ReFramedSmallCubesStepBlock extends WaterloggableReFramedDoubleBlock implements BlockStateProvider {
public ReFramedDoubleSmallBlock(Settings settings) {
public ReFramedSmallCubesStepBlock(Settings settings) {
super(settings);
setDefaultState(getDefaultState().with(EDGE, Edge.NORTH_DOWN));
}

View File

@ -39,12 +39,12 @@ import static fr.adrien1106.reframed.util.blocks.StairShape.*;
import static net.minecraft.data.client.VariantSettings.Rotation.*;
import static fr.adrien1106.reframed.util.blocks.Edge.*;
public class ReFramedStairsBlock extends WaterloggableReFramedBlock implements BlockStateProvider {
public class ReFramedStairBlock extends WaterloggableReFramedBlock implements BlockStateProvider {
public static final List<VoxelShape> VOXEL_LIST = new ArrayList<>(52);
private record ModelCacheKey(Edge edge, StairShape shape) {}
public ReFramedStairsBlock(Settings settings) {
public ReFramedStairBlock(Settings settings) {
super(settings);
setDefaultState(getDefaultState().with(EDGE, Edge.NORTH_DOWN).with(STAIR_SHAPE, STRAIGHT));
}

View File

@ -27,16 +27,16 @@ import org.jetbrains.annotations.Nullable;
import java.util.ArrayList;
import java.util.List;
import static fr.adrien1106.reframed.block.ReFramedStairsBlock.*;
import static fr.adrien1106.reframed.block.ReFramedStairBlock.*;
import static fr.adrien1106.reframed.util.blocks.BlockProperties.EDGE;
import static fr.adrien1106.reframed.util.blocks.BlockProperties.STAIR_SHAPE;
public class ReFramedDoubleStairsBlock extends ReFramedDoubleBlock implements BlockStateProvider {
public class ReFramedStairsCubeBlock extends ReFramedDoubleBlock implements BlockStateProvider {
private static final List<VoxelShape> COMPLEMENT_LIST = new ArrayList<>(52);
private record ModelCacheKey(Edge edge, StairShape shape) {}
public ReFramedDoubleStairsBlock(Settings settings) {
public ReFramedStairsCubeBlock(Settings settings) {
super(settings);
setDefaultState(getDefaultState().with(EDGE, Edge.NORTH_DOWN).with(STAIR_SHAPE, StairShape.STRAIGHT));
}
@ -207,7 +207,7 @@ public class ReFramedDoubleStairsBlock extends ReFramedDoubleBlock implements Bl
RecipeProvider.offerStonecuttingRecipe(exporter, RecipeCategory.BUILDING_BLOCKS, this, ReFramed.CUBE);
ShapelessRecipeJsonBuilder
.create(RecipeCategory.BUILDING_BLOCKS, this)
.input(ReFramed.STAIRS)
.input(ReFramed.STAIR)
.input(ReFramed.STEP)
.criterion(FabricRecipeProvider.hasItem(ReFramed.CUBE), FabricRecipeProvider.conditionsFromItem(ReFramed.CUBE))
.criterion(FabricRecipeProvider.hasItem(this), FabricRecipeProvider.conditionsFromItem(this))

View File

@ -31,10 +31,10 @@ import static net.minecraft.state.property.Properties.AXIS;
import static net.minecraft.state.property.Properties.FACING;
import static net.minecraft.util.shape.VoxelShapes.empty;
public class ReFramedDoubleStepBlock extends WaterloggableReFramedDoubleBlock implements BlockStateProvider {
public class ReFramedStepsSlabBlock extends WaterloggableReFramedDoubleBlock implements BlockStateProvider {
private record ModelCacheKey(Direction facing, Axis axis) {}
public ReFramedDoubleStepBlock(Settings settings) {
public ReFramedStepsSlabBlock(Settings settings) {
super(settings);
setDefaultState(getDefaultState().with(FACING, Direction.DOWN).with(AXIS, Axis.X));
}

View File

@ -48,13 +48,13 @@ public class ReFramedClient implements ClientModInitializer {
//item model assignments (in lieu of models/item/___.json)
HELPER.assignItemModel("cube_special" , ReFramed.CUBE);
HELPER.assignItemModel("small_cube_special" , ReFramed.SMALL_CUBE);
HELPER.assignItemModel("double_small_cube_special" , ReFramed.DOUBLE_SMALL_CUBE);
HELPER.assignItemModel("double_small_cube_special" , ReFramed.SMALL_CUBES_STEP);
HELPER.assignItemModel("slab_special" , ReFramed.SLAB);
HELPER.assignItemModel("double_slab_special" , ReFramed.DOUBLE_SLAB);
HELPER.assignItemModel("stairs_special" , ReFramed.STAIRS);
HELPER.assignItemModel("double_stairs_special" , ReFramed.DOUBLE_STAIRS);
HELPER.assignItemModel("double_slab_special" , ReFramed.SLABS_CUBE);
HELPER.assignItemModel("stairs_special" , ReFramed.STAIR);
HELPER.assignItemModel("double_stairs_special" , ReFramed.STAIRS_CUBE);
HELPER.assignItemModel("step_special" , ReFramed.STEP);
HELPER.assignItemModel("double_step_special" , ReFramed.DOUBLE_STEP);
HELPER.assignItemModel("double_step_special" , ReFramed.STEPS_SLAB);
}
private void privateInit() {