+ wall/ceiling Flags

hit box fix
This commit is contained in:
Glitchlabs
2026-07-26 11:25:59 +02:00
parent 42d298d7fc
commit 469db156e8
170 changed files with 3208 additions and 317 deletions
@@ -2,61 +2,100 @@ package ovh.glitchlabs.ornamentum.blocks;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.world.item.context.BlockPlaceContext;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.HorizontalDirectionalBlock;
import net.minecraft.world.level.block.Rotation;
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.level.block.state.properties.AttachFace;
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
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)
);
this.stateDefinition.any().setValue(FACING, Direction.NORTH).setValue(BlockStateProperties.ATTACH_FACE, AttachFace.FLOOR));
}
@Override
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> builder) {
builder.add(FACING);
protected void createBlockStateDefinition(
StateDefinition.Builder<Block, BlockState> builder
) {
builder.add(
FACING,
BlockStateProperties.ATTACH_FACE
);
}
@Override
public BlockState getStateForPlacement(BlockPlaceContext context) {
Direction clickedFace = context.getClickedFace();
AttachFace face;
if (clickedFace == Direction.UP) {
face = AttachFace.FLOOR;
}
else if (clickedFace == Direction.DOWN) {
face = AttachFace.CEILING;
}
else {
face = AttachFace.WALL;
}
return this.defaultBlockState()
.setValue(BlockStateProperties.ATTACH_FACE, face)
.setValue(FACING, context.getHorizontalDirection().getOpposite());
}
@Override
public VoxelShape getShape(BlockState state, BlockGetter level, BlockPos pos, CollisionContext context) {
return SHAPE;
}
AttachFace face =
state.getValue(BlockStateProperties.ATTACH_FACE);
Direction facing =
state.getValue(FACING);
return switch (face) {
case FLOOR -> switch (facing) {
case NORTH, SOUTH -> Block.box(7, 0, 7, 9, 16, 9);
case EAST, WEST -> Block.box(7, 0, 7, 9, 16, 9);
default -> Block.box(7, 0, 7, 9, 16, 9);
};
case WALL -> switch (facing) {
case NORTH -> Block.box(7, 5, 9, 9, 16, 16);
case SOUTH -> Block.box(7, 5, 0, 9, 16, 7);
case WEST -> Block.box(9, 5, 7, 16, 16, 9);
case EAST -> Block.box(0, 5, 7, 7, 16, 9);
default -> Block.box(7, 5, 9, 9, 16, 16);
};
case CEILING -> switch (facing) {
case NORTH, SOUTH -> Block.box(0, 10, 7, 16, 16, 9);
case EAST, WEST -> Block.box(7, 10, 0, 9, 16, 16);
default -> Block.box(7, 10, 7, 9, 16, 9);
};
};
}
@Override
public BlockState rotate(BlockState state, Rotation rotation) {
return state.setValue(
FACING,
rotation.rotate(state.getValue(FACING))
return state.setValue(FACING, rotation.rotate(state.getValue(FACING))
);
}
@Override
protected com.mojang.serialization.MapCodec<? extends HorizontalDirectionalBlock> codec() {
return simpleCodec(FlagBlock::new);
@@ -2,7 +2,10 @@ package ovh.glitchlabs.ornamentum.datagen;
import net.minecraft.core.Direction;
import net.minecraft.data.PackOutput;
import net.minecraft.world.level.block.FaceAttachedHorizontalDirectionalBlock;
import net.minecraft.world.level.block.HorizontalDirectionalBlock;
import net.minecraft.world.level.block.state.properties.AttachFace;
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
import net.neoforged.neoforge.client.model.generators.BlockStateProvider;
import net.neoforged.neoforge.client.model.generators.ConfiguredModel;
import net.neoforged.neoforge.client.model.generators.ModelFile;
@@ -386,37 +389,74 @@ public class ModBlockStateProvider extends BlockStateProvider {
String name = block.getId().getPath();
ModelFile model = models()
.withExistingParent(
name,
modLoc("block/template_flag")
)
.texture(
"2",
modLoc("block/flags/" + textureName)
);
ModelFile floor =
models()
.withExistingParent(
name,
modLoc("block/template_flag")
)
.texture(
"2",
modLoc("block/flags/" + textureName)
);
ModelFile wall =
models()
.withExistingParent(
name + "_wall",
modLoc("block/template_flag_wall")
)
.texture(
"2",
modLoc("block/flags/" + textureName)
);
ModelFile ceiling =
models()
.withExistingParent(
name + "_ceiling",
modLoc("block/template_flag_ceiling")
)
.texture(
"2",
modLoc("block/flags/" + textureName)
);
getVariantBuilder(block.get())
.forAllStates(state -> {
Direction direction = state.getValue(HorizontalDirectionalBlock.FACING);
Direction direction =
state.getValue(HorizontalDirectionalBlock.FACING);
AttachFace face =
state.getValue(
BlockStateProperties.ATTACH_FACE
);
ModelFile model = switch (face) {
case WALL -> wall;
case CEILING -> ceiling;
default -> floor;
};
return ConfiguredModel.builder()
.modelFile(model)
.rotationY(switch (direction) {
case NORTH -> 0;
case EAST -> 90;
case SOUTH -> 180;
case WEST -> 270;
default -> 0;
})
.build();
.rotationY(
switch(direction) {
case NORTH -> 0;
case EAST -> 90;
case SOUTH -> 180;
case WEST -> 270;
default -> 0;
}
).build();
});
simpleBlockItem(
block.get(),
model
floor
);
}
}
@@ -0,0 +1,196 @@
{
"format_version": "1.9.0",
"credit": "Made with Blockbench by Ian1337",
"textures": {
"2": "#flag",
"3": "minecraft:block/spruce_planks",
"particle": "minecraft:block/spruce_planks"
},
"elements": [
{
"name": "up",
"from": [1.75, 13.75, 7.5],
"to": [13.75, 14.75, 8.5],
"rotation": {"angle": 0, "axis": "y", "origin": [7.75, 16, 8]},
"faces": {
"north": {"uv": [0, 0, 1, 14], "rotation": 90, "texture": "#3"},
"east": {"uv": [8, 9, 7, 10], "rotation": 270, "texture": "#3"},
"south": {"uv": [2, 0, 3, 14], "rotation": 270, "texture": "#3"},
"west": {"uv": [7, 10, 6, 9], "rotation": 270, "texture": "#3"},
"up": {"uv": [1, 0, 2, 14], "rotation": 270, "texture": "#3"},
"down": {"uv": [3, 0, 4, 14], "rotation": 270, "texture": "#3"}
}
},
{
"name": "halterL",
"from": [0.75, 13.5, 7.25],
"to": [1.75, 16.5, 9.25],
"rotation": {"angle": 0, "axis": "y", "origin": [7.75, 16, 8]},
"faces": {
"north": {"uv": [0, 0, 1, 3], "texture": "#3"},
"east": {"uv": [0, 0, 2, 3], "texture": "#3"},
"south": {"uv": [1, 0, 2, 3], "texture": "#3"},
"west": {"uv": [0, 0, 2, 3], "texture": "#3"},
"up": {"uv": [0, 1, 2, 2], "rotation": 270, "texture": "#3"},
"down": {"uv": [0, 0, 2, 1], "rotation": 90, "texture": "#3"}
}
},
{
"name": "halterR",
"from": [13.75, 13.5, 7.25],
"to": [14.75, 16.5, 9.25],
"rotation": {"angle": 0, "axis": "y", "origin": [7.75, 16, 8]},
"faces": {
"north": {"uv": [0, 4, 1, 7], "texture": "#3"},
"east": {"uv": [5, 4, 7, 7], "texture": "#3"},
"south": {"uv": [1, 3, 2, 6], "texture": "#3"},
"west": {"uv": [7, 4, 9, 7], "texture": "#3"},
"up": {"uv": [3, 4, 5, 5], "rotation": 270, "texture": "#3"},
"down": {"uv": [3, 5, 5, 6], "rotation": 90, "texture": "#3"}
}
},
{
"name": "Flag1",
"from": [3.25, 9.75, 8.25],
"to": [12.25, 13.75, 8.25],
"rotation": {"angle": 0, "axis": "y", "origin": [7.75, 16, 8]},
"faces": {
"north": {"uv": [0, 0, 4, 16], "rotation": 90, "texture": "#2"},
"east": {"uv": [4, 0, 0, 0], "rotation": 270, "texture": "#2"},
"south": {"uv": [4, 0, 0, 16], "rotation": 270, "texture": "#2"},
"west": {"uv": [4, 0, 0, 0], "rotation": 270, "texture": "#2"},
"up": {"uv": [0, 0, 0, 16], "rotation": 270, "texture": "#2"},
"down": {"uv": [0, 0, 0, 16], "rotation": 270, "texture": "#2"}
}
},
{
"name": "Flag1_2",
"from": [3.25, 9.75, 7.75],
"to": [12.25, 13.75, 7.75],
"rotation": {"angle": 0, "axis": "y", "origin": [7.75, 16, 8]},
"faces": {
"north": {"uv": [0, 0, 4, 16], "rotation": 90, "texture": "#2"},
"east": {"uv": [4, 0, 0, 0], "rotation": 270, "texture": "#2"},
"south": {"uv": [0, 0, 4, 16], "rotation": 270, "texture": "#2"},
"west": {"uv": [4, 0, 0, 0], "rotation": 270, "texture": "#2"},
"up": {"uv": [0, 0, 0, 16], "rotation": 270, "texture": "#2"},
"down": {"uv": [0, 0, 0, 16], "rotation": 270, "texture": "#2"}
}
},
{
"name": "Flag2",
"from": [3.25, 5.75, 8],
"to": [12.25, 9.75, 8],
"rotation": {"angle": 0, "axis": "y", "origin": [7.75, 16, 8]},
"faces": {
"north": {"uv": [4, 0, 8, 16], "rotation": 90, "texture": "#2"},
"east": {"uv": [4, 0, 0, 0], "rotation": 270, "texture": "#2"},
"south": {"uv": [8, 0, 4, 16], "rotation": 270, "texture": "#2"},
"west": {"uv": [4, 0, 0, 0], "rotation": 270, "texture": "#2"},
"up": {"uv": [0, 0, 0, 16], "rotation": 270, "texture": "#2"},
"down": {"uv": [0, 0, 0, 16], "rotation": 270, "texture": "#2"}
}
},
{
"name": "Flag3",
"from": [3.25, 1.75, 8.25],
"to": [12.25, 5.75, 8.25],
"rotation": {"angle": 0, "axis": "y", "origin": [7.75, 16, 8]},
"faces": {
"north": {"uv": [8, 0, 12, 16], "rotation": 90, "texture": "#2"},
"east": {"uv": [4, 0, 0, 0], "rotation": 270, "texture": "#2"},
"south": {"uv": [12, 0, 8, 16], "rotation": 270, "texture": "#2"},
"west": {"uv": [4, 0, 0, 0], "rotation": 270, "texture": "#2"},
"up": {"uv": [0, 0, 0, 16], "rotation": 270, "texture": "#2"},
"down": {"uv": [0, 0, 0, 16], "rotation": 270, "texture": "#2"}
}
},
{
"name": "Flag3_2",
"from": [3.25, 1.75, 7.75],
"to": [12.25, 5.75, 7.75],
"rotation": {"angle": 0, "axis": "y", "origin": [7.75, 16, 8]},
"faces": {
"north": {"uv": [8, 0, 12, 16], "rotation": 90, "texture": "#2"},
"east": {"uv": [4, 0, 0, 0], "rotation": 270, "texture": "#2"},
"south": {"uv": [8, 0, 12, 16], "rotation": 270, "texture": "#2"},
"west": {"uv": [4, 0, 0, 0], "rotation": 270, "texture": "#2"},
"up": {"uv": [0, 0, 0, 16], "rotation": 270, "texture": "#2"},
"down": {"uv": [0, 0, 0, 16], "rotation": 270, "texture": "#2"}
}
},
{
"name": "Flag4",
"from": [3.25, -2.25, 8],
"to": [12.25, 1.75, 8],
"rotation": {"angle": 0, "axis": "y", "origin": [7.75, 16, 8]},
"faces": {
"north": {"uv": [12, 0, 16, 16], "rotation": 90, "texture": "#2"},
"east": {"uv": [4, 0, 0, 0], "rotation": 270, "texture": "#2"},
"south": {"uv": [16, 0, 12, 16], "rotation": 270, "texture": "#2"},
"west": {"uv": [4, 0, 0, 0], "rotation": 270, "texture": "#2"},
"up": {"uv": [0, 0, 0, 16], "rotation": 270, "texture": "#2"},
"down": {"uv": [0, 0, 0, 16], "rotation": 270, "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]
}
]
}
@@ -0,0 +1,196 @@
{
"format_version": "1.9.0",
"credit": "Made with Blockbench by Ian1337",
"textures": {
"2": "#flag",
"3": "minecraft:block/spruce_planks",
"particle": "minecraft:block/spruce_planks"
},
"elements": [
{
"name": "top",
"from": [6.75, 23, 15.25],
"to": [8.75, 24, 17.25],
"rotation": {"angle": -22.5, "axis": "x", "origin": [7.75, 5.25, 16]},
"faces": {
"north": {"uv": [8, 8, 10, 9], "texture": "#3"},
"east": {"uv": [6, 8, 8, 9], "texture": "#3"},
"south": {"uv": [8, 6, 10, 7], "texture": "#3"},
"west": {"uv": [8, 7, 10, 8], "texture": "#3"},
"up": {"uv": [10, 2, 8, 0], "rotation": 90, "texture": "#3"},
"down": {"uv": [10, 2, 8, 4], "rotation": 270, "texture": "#3"}
}
},
{
"name": "up",
"from": [7.25, 9, 15.75],
"to": [8.25, 23, 16.75],
"rotation": {"angle": -22.5, "axis": "x", "origin": [7.75, 5.25, 16]},
"faces": {
"north": {"uv": [3, 0, 4, 14], "texture": "#3"},
"east": {"uv": [0, 0, 1, 14], "texture": "#3"},
"south": {"uv": [1, 0, 2, 14], "texture": "#3"},
"west": {"uv": [2, 0, 3, 14], "texture": "#3"},
"up": {"uv": [7, 10, 6, 9], "rotation": 90, "texture": "#3"},
"down": {"uv": [8, 9, 7, 10], "rotation": 270, "texture": "#3"}
}
},
{
"name": "down",
"from": [6.75, 5, 15.25],
"to": [8.75, 9, 17.25],
"rotation": {"angle": -22.5, "axis": "x", "origin": [7.75, 5.25, 16]},
"faces": {
"north": {"uv": [6, 4, 8, 8], "texture": "#3"},
"east": {"uv": [4, 0, 6, 4], "texture": "#3"},
"south": {"uv": [4, 4, 6, 8], "texture": "#3"},
"west": {"uv": [6, 0, 8, 4], "texture": "#3"},
"up": {"uv": [6, 10, 4, 8], "rotation": 90, "texture": "#3"},
"down": {"uv": [10, 4, 8, 6], "rotation": 270, "texture": "#3"}
}
},
{
"name": "Flag1",
"from": [7.5, 14, 11.75],
"to": [7.5, 23, 15.75],
"rotation": {"angle": -22.5, "axis": "x", "origin": [7.75, 5.25, 16]},
"faces": {
"north": {"uv": [0, 0, 0, 16], "texture": "#2"},
"east": {"uv": [0, 0, 4, 16], "texture": "#2"},
"south": {"uv": [0, 0, 0, 16], "texture": "#2"},
"west": {"uv": [4, 0, 0, 16], "texture": "#2"},
"up": {"uv": [4, 0, 0, 0], "rotation": 90, "texture": "#2"},
"down": {"uv": [4, 0, 0, 0], "rotation": 270, "texture": "#2"}
}
},
{
"name": "Flag1_2",
"from": [8, 14, 11.75],
"to": [8, 23, 15.75],
"rotation": {"angle": -22.5, "axis": "x", "origin": [7.75, 5.25, 16]},
"faces": {
"north": {"uv": [0, 0, 0, 16], "texture": "#2"},
"east": {"uv": [0, 0, 4, 16], "texture": "#2"},
"south": {"uv": [0, 0, 0, 16], "texture": "#2"},
"west": {"uv": [0, 0, 4, 16], "texture": "#2"},
"up": {"uv": [4, 0, 0, 0], "rotation": 90, "texture": "#2"},
"down": {"uv": [4, 0, 0, 0], "rotation": 270, "texture": "#2"}
}
},
{
"name": "Flag2",
"from": [7.75, 14, 7.75],
"to": [7.75, 23, 11.75],
"rotation": {"angle": -22.5, "axis": "x", "origin": [7.75, 5.25, 16]},
"faces": {
"north": {"uv": [0, 0, 0, 16], "texture": "#2"},
"east": {"uv": [4, 0, 8, 16], "texture": "#2"},
"south": {"uv": [0, 0, 0, 16], "texture": "#2"},
"west": {"uv": [8, 0, 4, 16], "texture": "#2"},
"up": {"uv": [4, 0, 0, 0], "rotation": 90, "texture": "#2"},
"down": {"uv": [4, 0, 0, 0], "rotation": 270, "texture": "#2"}
}
},
{
"name": "Flag3",
"from": [7.5, 14, 3.75],
"to": [7.5, 23, 7.75],
"rotation": {"angle": -22.5, "axis": "x", "origin": [7.75, 5.25, 16]},
"faces": {
"north": {"uv": [0, 0, 0, 16], "texture": "#2"},
"east": {"uv": [8, 0, 12, 16], "texture": "#2"},
"south": {"uv": [0, 0, 0, 16], "texture": "#2"},
"west": {"uv": [12, 0, 8, 16], "texture": "#2"},
"up": {"uv": [4, 0, 0, 0], "rotation": 90, "texture": "#2"},
"down": {"uv": [4, 0, 0, 0], "rotation": 270, "texture": "#2"}
}
},
{
"name": "Flag3_2",
"from": [8, 14, 3.75],
"to": [8, 23, 7.75],
"rotation": {"angle": -22.5, "axis": "x", "origin": [7.75, 5.25, 16]},
"faces": {
"north": {"uv": [0, 0, 0, 16], "texture": "#2"},
"east": {"uv": [8, 0, 12, 16], "texture": "#2"},
"south": {"uv": [0, 0, 0, 16], "texture": "#2"},
"west": {"uv": [8, 0, 12, 16], "texture": "#2"},
"up": {"uv": [4, 0, 0, 0], "rotation": 90, "texture": "#2"},
"down": {"uv": [4, 0, 0, 0], "rotation": 270, "texture": "#2"}
}
},
{
"name": "Flag4",
"from": [7.75, 14, -0.25],
"to": [7.75, 23, 3.75],
"rotation": {"angle": -22.5, "axis": "x", "origin": [7.75, 5.25, 16]},
"faces": {
"north": {"uv": [0, 0, 0, 16], "texture": "#2"},
"east": {"uv": [12, 0, 16, 16], "texture": "#2"},
"south": {"uv": [0, 0, 0, 16], "texture": "#2"},
"west": {"uv": [16, 0, 12, 16], "texture": "#2"},
"up": {"uv": [4, 0, 0, 0], "rotation": 90, "texture": "#2"},
"down": {"uv": [4, 0, 0, 0], "rotation": 270, "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]
}
]
}