tutorial:directionalblock
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
tutorial:directionalblock [2022/01/31 01:23] – [Defining rotation and mirroring of blocks] solidblock | tutorial:directionalblock [2023/09/26 05:43] (current) – Fix typo [Making a Directional Block] poopooracoocoo | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== Making a Directional Block ====== | ====== Making a Directional Block ====== | ||
- | |||
Making blocks directional (facing into certain directions) is also done using block states. | Making blocks directional (facing into certain directions) is also done using block states. | ||
Line 12: | Line 11: | ||
public VerticalSlabBlock(Settings settings) { | public VerticalSlabBlock(Settings settings) { | ||
super(settings); | super(settings); | ||
- | setDefaultState(this.stateManager.getDefaultState().with(Properties.HORIZONTAL_FACING, | + | setDefaultState(getDefaultState().with(Properties.HORIZONTAL_FACING, |
} | } | ||
@Override | @Override | ||
- | protected void appendProperties(StateManager.Builder< | + | protected void appendProperties(StateManager.Builder< |
- | stateManager.add(Properties.HORIZONTAL_FACING); | + | builder.add(Properties.HORIZONTAL_FACING); |
} | } | ||
@Override | @Override | ||
- | public VoxelShape getOutlineShape(BlockState state, BlockView | + | public VoxelShape getOutlineShape(BlockState state, BlockView |
Direction dir = state.get(FACING); | Direction dir = state.get(FACING); | ||
switch(dir) { | switch(dir) { | ||
Line 39: | Line 38: | ||
@Override | @Override | ||
public BlockState getPlacementState(ItemPlacementContext ctx) { | public BlockState getPlacementState(ItemPlacementContext ctx) { | ||
- | return | + | return |
} | } | ||
+ | } | ||
+ | </ | ||
+ | <code java> | ||
+ | public class ExampleMod implements ModInitializer { | ||
+ | public static final VerticalSlabBlock POLISHED_ANDESITE_VERTICAL_SLAB = Registry.register( | ||
+ | Registries.BLOCK, | ||
+ | new Identifier(" | ||
+ | new VerticalSlabBlock(FabricBlockSettings.copyOf(Blocks.POLISHED_ANDESITE))); | ||
} | } | ||
</ | </ | ||
+ | ===== Defining Blockstate JSON ===== | ||
- | ===== Defining Blockstate ===== | + | <code javascript src/ |
- | + | ||
- | <code javascript src/ | + | |
{ | { | ||
" | " | ||
- | " | + | " |
- | " | + | " |
- | " | + | " |
- | " | + | " |
} | } | ||
} | } | ||
</ | </ | ||
- | |||
===== Defining Block Models ===== | ===== Defining Block Models ===== | ||
- | + | <code javascript src/ | |
- | <code javascript src/ | + | |
{ " | { " | ||
" | " | ||
Line 84: | Line 88: | ||
</ | </ | ||
- | <code javascript src/ | + | <code javascript src/ |
{ | { | ||
- | " | + | " |
" | " | ||
" | " | ||
Line 96: | Line 100: | ||
===== Defining rotation and mirroring of blocks ===== | ===== Defining rotation and mirroring of blocks ===== | ||
- | For directional blocks, you may have to override '' | + | For directional blocks, you may have to override '' |
+ | |||
+ | ===== Next ===== | ||
+ | Try to make it [[waterloggable]]. |
tutorial/directionalblock.1643592192.txt.gz · Last modified: 2022/01/31 01:23 by solidblock