zh_cn:tutorial:directionalblock
Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
zh_cn:tutorial:directionalblock [2020/11/12 13:41] – created solidblock | zh_cn:tutorial:directionalblock [2022/12/16 02:09] (current) – title size solidblock | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ==== 带有方向的方块 ==== | + | ====== 制作带朝向的方块 |
- | 使方块带有方向(朝向特定的方向)也是通过方块状态完成的。 | + | 使方块带有方向(朝向特定的方向)也是通过方块状态完成的。这个例子介绍了垂直版的安山岩台阶。 |
- | 这个例子介绍了垂直版的安山岩台阶。 | + | |
{{: | {{: | ||
<code java> | <code java> | ||
- | public class PolishedAndesiteSideBlock | + | public class VerticalSlabBlock |
- | public | + | public |
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 36: | Line 35: | ||
} | } | ||
+ | @Override | ||
public BlockState getPlacementState(ItemPlacementContext ctx) { | public BlockState getPlacementState(ItemPlacementContext ctx) { | ||
- | return | + | return |
} | } | ||
+ | } | ||
+ | </ | ||
+ | <code java> | ||
+ | public class ExampleMod implements ModInitialzer { | ||
+ | public static final VerticalSlabBlock POLISHED_ANDESITE_VERTICAL_SLAB = Registry.register( | ||
+ | Registries.BLOCK, | ||
+ | new Identifier(" | ||
+ | new VerticalSlabBlock(FabricBlockSettings.copyOf(Blocks.POLISHED_ANDESITE))); | ||
} | } | ||
</ | </ | ||
+ | ==== 定义方块状态 JSON ==== | ||
- | ==== 定义方块状态 ==== | + | < |
- | + | ||
- | polished_andesite_side_block.json | + | |
- | < | + | |
{ | { | ||
" | " | ||
- | " | + | " |
- | " | + | " |
- | " | + | " |
- | " | + | " |
} | } | ||
} | } | ||
</ | </ | ||
- | |||
==== 定义方块模型 ==== | ==== 定义方块模型 ==== | ||
- | + | < | |
- | side.json | + | |
- | < | + | |
{ " | { " | ||
" | " | ||
Line 72: | Line 75: | ||
" | " | ||
" | " | ||
- | " | + | " |
- | " | + | " |
- | " | + | " |
- | " | + | " |
" | " | ||
" | " | ||
Line 84: | Line 87: | ||
</ | </ | ||
- | polished_andesite_side_block.json | + | < |
- | < | + | |
{ | { | ||
- | " | + | " |
" | " | ||
" | " | ||
Line 95: | Line 97: | ||
} | } | ||
</ | </ | ||
+ | |||
+ | ===== 定义方块的旋转和翻转 ===== | ||
+ | 对于带有朝向的方块,你需要覆盖 '' | ||
+ | |||
+ | ===== 下一步 ===== | ||
+ | 尝试让它[[waterloggable|可含水]] | ||
+ |
zh_cn/tutorial/directionalblock.1605188501.txt.gz · Last modified: 2020/11/12 13:41 by solidblock