User Tools

Site Tools


tutorial:directionalblock

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Next revisionBoth sides next revision
tutorial:directionalblock [2019/12/22 09:08] bitmantutorial:directionalblock [2022/01/31 01:08] – [Defining Block Models] solidblock
Line 7: Line 7:
 {{:tutorial:vertslab.png?200|}} {{:tutorial:vertslab.png?200|}}
  
-<code> +<code java
-public class PolishedAndesiteSideBlock extends HorizontalFacingBlock {+public class VerticalSlabBlock extends HorizontalFacingBlock {
  
- public PolishedAndesiteSideBlock(Settings settings) {+ public VerticalSlabBlock(Settings settings) {
  super(settings);  super(settings);
  setDefaultState(this.stateManager.getDefaultState().with(Properties.HORIZONTAL_FACING, Direction.NORTH));  setDefaultState(this.stateManager.getDefaultState().with(Properties.HORIZONTAL_FACING, Direction.NORTH));
Line 21: Line 21:
  
  @Override  @Override
- public VoxelShape getOutlineShape(BlockState state, BlockView view, BlockPos pos, EntityContext ctx) {+ public VoxelShape getOutlineShape(BlockState state, BlockView view, BlockPos pos, ShapeContext ctx) {
  Direction dir = state.get(FACING);  Direction dir = state.get(FACING);
  switch(dir) {  switch(dir) {
Line 37: Line 37:
  }  }
  
 +        @Override
  public BlockState getPlacementState(ItemPlacementContext ctx) {  public BlockState getPlacementState(ItemPlacementContext ctx) {
- return (BlockState)this.getDefaultState().with(FACING, ctx.getPlayerFacing());+ return (BlockState)this.getDefaultState().with(Properties.HORIZONTAL_FACING, ctx.getPlayerFacing().getOpposite());
  }  }
  
Line 51: Line 52:
 { {
   "variants": {   "variants": {
-    "facing=north": { "model": "bitmod:block/polished_andesite_side_block" }, +    "facing=north": { "model": "bitmod:block/polished_andesite_side_block", "uvlock": true }, 
-    "facing=east":  { "model": "bitmod:block/polished_andesite_side_block", "y":  90}, +    "facing=east":  { "model": "bitmod:block/polished_andesite_side_block", "y":  90, "uvlock": true }, 
-    "facing=south": { "model": "bitmod:block/polished_andesite_side_block", "y": 180 }, +    "facing=south": { "model": "bitmod:block/polished_andesite_side_block", "y": 180, "uvlock": true }, 
-    "facing=west":  { "model": "bitmod:block/polished_andesite_side_block", "y": 270 }+    "facing=west":  { "model": "bitmod:block/polished_andesite_side_block", "y": 270, "uvlock": true }
   }   }
 } }
Line 63: Line 64:
  
  
-side.json +<code javascript src/main/resources/assets/tutorial/models/block/side.json>
-<code>+
 {   "parent": "block/block", {   "parent": "block/block",
     "textures": {     "textures": {
Line 73: Line 73:
             "to": [  16, 16, 8 ],             "to": [  16, 16, 8 ],
             "faces": {             "faces": {
-                "down": "uv": [ 0, 8, 16, 16 ], "texture": "#bottom", "cullface": "down" }, +                "down":  { "texture": "#bottom", "cullface": "down" }, 
-                "up":    { "uv": [ 0, 8, 16, 16 ], "texture": "#top",    "cullface": "up" }, +                "up":    { "texture": "#top",    "cullface": "up" }, 
-                "north":"uv": [ 0, 0, 16, 16 ], "texture": "#side",   "cullface": "north" }, +                "north": { "texture": "#side",   "cullface": "north" }, 
-                "south": { "uv": [ 0, 0, 16, 16 ], "texture": "#side },+                "south": { "texture": "#side"  "cullface": "south" },
                 "west":  { "texture": "#side",   "cullface": "west" },                 "west":  { "texture": "#side",   "cullface": "west" },
                 "east":  { "texture": "#side",   "cullface": "east" }                 "east":  { "texture": "#side",   "cullface": "east" }
Line 85: Line 85:
 </code> </code>
  
-polished_andesite_side_block.json +<code javascript src/main/resources/assets/tutorial/models/block/polished_andesite_side_block.json>
-<code>+
 { {
-    "parent": "bitmod:block/side",+    "parent": "tutorial:block/side",
     "textures": {     "textures": {
         "bottom": "block/polished_andesite",         "bottom": "block/polished_andesite",
tutorial/directionalblock.txt · Last modified: 2023/09/26 05:43 by poopooracoocoo