+ flag
This commit is contained in:
@@ -0,0 +1,64 @@
|
||||
package ovh.glitchlabs.ornamentum.blocks;
|
||||
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.world.level.BlockGetter;
|
||||
import net.minecraft.world.level.block.HorizontalDirectionalBlock;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.state.StateDefinition;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.Rotation;
|
||||
import net.minecraft.world.phys.shapes.CollisionContext;
|
||||
import net.minecraft.world.phys.shapes.Shapes;
|
||||
import net.minecraft.world.phys.shapes.VoxelShape;
|
||||
import net.minecraft.world.item.context.BlockPlaceContext;
|
||||
|
||||
public class FlagBlock extends HorizontalDirectionalBlock {
|
||||
|
||||
private static final VoxelShape SHAPE = Shapes.or(
|
||||
Block.box(7, 0, 7, 9, 16, 9)
|
||||
);
|
||||
|
||||
public FlagBlock(Properties properties) {
|
||||
super(properties);
|
||||
|
||||
this.registerDefaultState(
|
||||
this.stateDefinition.any()
|
||||
.setValue(FACING, Direction.NORTH)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> builder) {
|
||||
builder.add(FACING);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public BlockState getStateForPlacement(BlockPlaceContext context) {
|
||||
return this.defaultBlockState()
|
||||
.setValue(FACING, context.getHorizontalDirection().getOpposite());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public VoxelShape getShape(BlockState state, BlockGetter level, BlockPos pos, CollisionContext context) {
|
||||
return SHAPE;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public BlockState rotate(BlockState state, Rotation rotation) {
|
||||
return state.setValue(
|
||||
FACING,
|
||||
rotation.rotate(state.getValue(FACING))
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected com.mojang.serialization.MapCodec<? extends HorizontalDirectionalBlock> codec() {
|
||||
return simpleCodec(FlagBlock::new);
|
||||
}
|
||||
}
|
||||
@@ -16,6 +16,9 @@ public class ModBlocks {
|
||||
public static final DeferredRegister.Blocks BLOCKS =
|
||||
DeferredRegister.createBlocks(Ornamentum.MODID);
|
||||
|
||||
public static final DeferredBlock<Block> TEST_FLAG = registerBlock("test_flag",
|
||||
() -> new FlagBlock(BlockBehaviour.Properties.of().strength(1.0f)));
|
||||
|
||||
// Pattern Blocks
|
||||
|
||||
public static final DeferredBlock<Block> WHITE_PATTERN_BLOCK = registerBlock("white_pattern_block",
|
||||
|
||||
@@ -17,6 +17,9 @@ public class ModBlockLootTableProvider extends BlockLootSubProvider {
|
||||
@Override
|
||||
protected void generate() {
|
||||
|
||||
dropSelf(ModBlocks.TEST_FLAG.get());
|
||||
|
||||
|
||||
dropSelf(ModBlocks.RED_PATTERN_BLOCK.get());
|
||||
dropSelf(ModBlocks.RED_PATTERN_BLOCK_STAIRS.get());
|
||||
dropSelf(ModBlocks.RED_PATTERN_BLOCK_SLAB.get());
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
package ovh.glitchlabs.ornamentum.datagen;
|
||||
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.data.PackOutput;
|
||||
import net.minecraft.world.level.block.HorizontalDirectionalBlock;
|
||||
import net.neoforged.neoforge.client.model.generators.BlockStateProvider;
|
||||
import net.neoforged.neoforge.client.model.generators.ConfiguredModel;
|
||||
import net.neoforged.neoforge.client.model.generators.ModelFile;
|
||||
import net.neoforged.neoforge.common.data.ExistingFileHelper;
|
||||
import net.neoforged.neoforge.registries.DeferredBlock;
|
||||
@@ -16,6 +19,9 @@ public class ModBlockStateProvider extends BlockStateProvider {
|
||||
@Override
|
||||
protected void registerStatesAndModels() {
|
||||
|
||||
// FLAGS
|
||||
createFlag(ModBlocks.TEST_FLAG, "test_flag");
|
||||
|
||||
blockWithItem(ModBlocks.WHITE_PATTERN_BLOCK);
|
||||
createStairsAndSlab(ModBlocks.WHITE_PATTERN_BLOCK_STAIRS, ModBlocks.WHITE_PATTERN_BLOCK_SLAB, "white_pattern_block");
|
||||
|
||||
@@ -318,8 +324,41 @@ public class ModBlockStateProvider extends BlockStateProvider {
|
||||
simpleBlockWithItem(deferredBlock.get(), model);
|
||||
}
|
||||
|
||||
private void paneModelWithItem(DeferredBlock<?> deferredBlock, String textureName) {
|
||||
simpleBlockWithItem(deferredBlock.get(), models().withExistingParent(deferredBlock.getId().getPath(), mcLoc("block/thin_block"))
|
||||
.texture("texture", modLoc("block/" + textureName)));
|
||||
private void createFlag(DeferredBlock<?> block, String textureName) {
|
||||
|
||||
String name = block.getId().getPath();
|
||||
|
||||
ModelFile model = models()
|
||||
.withExistingParent(
|
||||
name,
|
||||
modLoc("block/template_flag")
|
||||
)
|
||||
.texture(
|
||||
"2",
|
||||
modLoc("block/flags/" + textureName)
|
||||
);
|
||||
|
||||
|
||||
getVariantBuilder(block.get())
|
||||
.forAllStates(state -> {
|
||||
Direction direction = state.getValue(HorizontalDirectionalBlock.FACING);
|
||||
|
||||
return ConfiguredModel.builder()
|
||||
.modelFile(model)
|
||||
.rotationY(switch (direction) {
|
||||
case NORTH -> 0;
|
||||
case EAST -> 90;
|
||||
case SOUTH -> 180;
|
||||
case WEST -> 270;
|
||||
default -> 0;
|
||||
})
|
||||
.build();
|
||||
});
|
||||
|
||||
|
||||
simpleBlockItem(
|
||||
block.get(),
|
||||
model
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,196 @@
|
||||
{
|
||||
"format_version": "1.9.0",
|
||||
"credit": "Made with Blockbench by Ian1337",
|
||||
"textures": {
|
||||
"1": "minecraft:block/spruce_planks",
|
||||
"2": "#flag",
|
||||
"particle": "minecraft:block/spruce_planks"
|
||||
},
|
||||
"elements": [
|
||||
{
|
||||
"name": "top",
|
||||
"from": [7, 18, 7],
|
||||
"to": [9, 19, 9],
|
||||
"rotation": {"angle": 0, "axis": "y", "origin": [7, 6, 0]},
|
||||
"faces": {
|
||||
"north": {"uv": [6, 8, 8, 9], "texture": "#1"},
|
||||
"east": {"uv": [8, 6, 10, 7], "texture": "#1"},
|
||||
"south": {"uv": [8, 7, 10, 8], "texture": "#1"},
|
||||
"west": {"uv": [8, 8, 10, 9], "texture": "#1"},
|
||||
"up": {"uv": [10, 2, 8, 0], "texture": "#1"},
|
||||
"down": {"uv": [10, 2, 8, 4], "texture": "#1"}
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "up",
|
||||
"from": [7.5, 4, 7.5],
|
||||
"to": [8.5, 18, 8.5],
|
||||
"rotation": {"angle": 0, "axis": "y", "origin": [6.5, 0, -0.5]},
|
||||
"faces": {
|
||||
"north": {"uv": [0, 0, 1, 14], "texture": "#1"},
|
||||
"east": {"uv": [1, 0, 2, 14], "texture": "#1"},
|
||||
"south": {"uv": [2, 0, 3, 14], "texture": "#1"},
|
||||
"west": {"uv": [3, 0, 4, 14], "texture": "#1"},
|
||||
"up": {"uv": [7, 10, 6, 9], "texture": "#1"},
|
||||
"down": {"uv": [8, 9, 7, 10], "texture": "#1"}
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "down",
|
||||
"from": [7, 0, 7],
|
||||
"to": [9, 4, 9],
|
||||
"rotation": {"angle": 0, "axis": "y", "origin": [7, -12, 0]},
|
||||
"faces": {
|
||||
"north": {"uv": [4, 0, 6, 4], "texture": "#1"},
|
||||
"east": {"uv": [4, 4, 6, 8], "texture": "#1"},
|
||||
"south": {"uv": [6, 0, 8, 4], "texture": "#1"},
|
||||
"west": {"uv": [6, 4, 8, 8], "texture": "#1"},
|
||||
"up": {"uv": [6, 10, 4, 8], "texture": "#1"},
|
||||
"down": {"uv": [10, 4, 8, 6], "texture": "#1"}
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "Flag1",
|
||||
"from": [3.5, 9, 8.25],
|
||||
"to": [7.5, 18, 8.25],
|
||||
"rotation": {"angle": 0, "axis": "y", "origin": [5.5, 0, -0.75]},
|
||||
"faces": {
|
||||
"north": {"uv": [0, 0, 4, 9], "texture": "#2"},
|
||||
"east": {"uv": [0, 0, 0, 9], "texture": "#2"},
|
||||
"south": {"uv": [4, 0, 0, 9], "texture": "#2"},
|
||||
"west": {"uv": [0, 0, 0, 9], "texture": "#2"},
|
||||
"up": {"uv": [4, 0, 0, 0], "texture": "#2"},
|
||||
"down": {"uv": [4, 0, 0, 0], "texture": "#2"}
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "Flag1_2",
|
||||
"from": [3.5, 9, 7.75],
|
||||
"to": [7.5, 18, 7.75],
|
||||
"rotation": {"angle": 0, "axis": "y", "origin": [5.5, 0, -1.25]},
|
||||
"faces": {
|
||||
"north": {"uv": [0, 0, 4, 9], "texture": "#2"},
|
||||
"east": {"uv": [0, 0, 0, 9], "texture": "#2"},
|
||||
"south": {"uv": [0, 0, 4, 9], "texture": "#2"},
|
||||
"west": {"uv": [0, 0, 0, 9], "texture": "#2"},
|
||||
"up": {"uv": [4, 0, 0, 0], "texture": "#2"},
|
||||
"down": {"uv": [4, 0, 0, 0], "texture": "#2"}
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "Flag2",
|
||||
"from": [-0.5, 9, 8],
|
||||
"to": [3.5, 18, 8],
|
||||
"rotation": {"angle": 0, "axis": "y", "origin": [1.5, 0, -1]},
|
||||
"faces": {
|
||||
"north": {"uv": [4, 0, 8, 9], "texture": "#2"},
|
||||
"east": {"uv": [0, 0, 0, 9], "texture": "#2"},
|
||||
"south": {"uv": [8, 0, 4, 9], "texture": "#2"},
|
||||
"west": {"uv": [0, 0, 0, 9], "texture": "#2"},
|
||||
"up": {"uv": [4, 0, 0, 0], "texture": "#2"},
|
||||
"down": {"uv": [4, 0, 0, 0], "texture": "#2"}
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "Flag3",
|
||||
"from": [-4.5, 9, 8.25],
|
||||
"to": [-0.5, 18, 8.25],
|
||||
"rotation": {"angle": 0, "axis": "y", "origin": [-2.5, 0, -0.75]},
|
||||
"faces": {
|
||||
"north": {"uv": [8, 0, 12, 9], "texture": "#2"},
|
||||
"east": {"uv": [0, 0, 0, 9], "texture": "#2"},
|
||||
"south": {"uv": [12, 0, 8, 9], "texture": "#2"},
|
||||
"west": {"uv": [0, 0, 0, 9], "texture": "#2"},
|
||||
"up": {"uv": [4, 0, 0, 0], "texture": "#2"},
|
||||
"down": {"uv": [4, 0, 0, 0], "texture": "#2"}
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "Flag3_2",
|
||||
"from": [-4.5, 9, 7.75],
|
||||
"to": [-0.5, 18, 7.75],
|
||||
"rotation": {"angle": 0, "axis": "y", "origin": [-2.5, 0, -1.25]},
|
||||
"faces": {
|
||||
"north": {"uv": [8, 0, 12, 9], "texture": "#2"},
|
||||
"east": {"uv": [0, 0, 0, 9], "texture": "#2"},
|
||||
"south": {"uv": [8, 0, 12, 9], "texture": "#2"},
|
||||
"west": {"uv": [0, 0, 0, 9], "texture": "#2"},
|
||||
"up": {"uv": [4, 0, 0, 0], "texture": "#2"},
|
||||
"down": {"uv": [4, 0, 0, 0], "texture": "#2"}
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "Flag4",
|
||||
"from": [-8.5, 9, 8],
|
||||
"to": [-4.5, 18, 8],
|
||||
"rotation": {"angle": 0, "axis": "y", "origin": [-6.5, 0, -1]},
|
||||
"faces": {
|
||||
"north": {"uv": [12, 0, 16, 9], "texture": "#2"},
|
||||
"east": {"uv": [0, 0, 0, 9], "texture": "#2"},
|
||||
"south": {"uv": [16, 0, 12, 9], "texture": "#2"},
|
||||
"west": {"uv": [0, 0, 0, 9], "texture": "#2"},
|
||||
"up": {"uv": [4, 0, 0, 0], "texture": "#2"},
|
||||
"down": {"uv": [4, 0, 0, 0], "texture": "#2"}
|
||||
}
|
||||
}
|
||||
],
|
||||
"display": {
|
||||
"thirdperson_righthand": {
|
||||
"rotation": [0, -59, 0],
|
||||
"translation": [0, 3.75, 1.75],
|
||||
"scale": [0.75, 0.75, 0.75]
|
||||
},
|
||||
"thirdperson_lefthand": {
|
||||
"rotation": [0, 59, 0],
|
||||
"translation": [0, 3.75, 1.75],
|
||||
"scale": [0.75, 0.75, 0.75]
|
||||
},
|
||||
"firstperson_righthand": {
|
||||
"rotation": [-124.29, -82.79, -90.44],
|
||||
"translation": [2.5, 4.25, 0],
|
||||
"scale": [0.75, 0.75, 0.75]
|
||||
},
|
||||
"firstperson_lefthand": {
|
||||
"rotation": [-17.81, 88.48, -7.82],
|
||||
"translation": [2.5, 4.25, 0],
|
||||
"scale": [0.75, 0.75, 0.75]
|
||||
},
|
||||
"ground": {
|
||||
"rotation": [-27.16, 17.05, 13.6],
|
||||
"translation": [0, 3.25, 0],
|
||||
"scale": [0.75, 0.75, 0.75]
|
||||
},
|
||||
"gui": {
|
||||
"rotation": [28.96, -37.02, 18.48],
|
||||
"translation": [4.5, -1.5, 0],
|
||||
"scale": [0.75, 0.75, 0.75]
|
||||
},
|
||||
"head": {
|
||||
"rotation": [1.5, 1, 18.75],
|
||||
"translation": [-8, 5.75, 0]
|
||||
},
|
||||
"fixed": {
|
||||
"translation": [7.25, -1.75, -0.5]
|
||||
},
|
||||
"on_shelf": {
|
||||
"rotation": [22.75, 90, 0],
|
||||
"translation": [0, 0, -1.25]
|
||||
}
|
||||
},
|
||||
"groups": [
|
||||
{
|
||||
"name": "flag_pol",
|
||||
"origin": [6.5, 0, -0.5],
|
||||
"scope": 0,
|
||||
"color": 0,
|
||||
"children": [0, 1, 2]
|
||||
},
|
||||
{
|
||||
"name": "Flag",
|
||||
"origin": [6.5, 0, -0.5],
|
||||
"scope": 0,
|
||||
"color": 0,
|
||||
"children": [3, 4, 5, 6, 7, 8]
|
||||
}
|
||||
]
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 205 B |
Reference in New Issue
Block a user