User Tools

Site Tools


tutorial:blocks

Differences

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

Link to this comparison view

Both sides previous revisionPrevious revision
Next revisionBoth sides next revision
tutorial:blocks [2019/11/14 22:02] fudgetutorial:blocks [2019/12/21 08:46] – [Creating a Block class] bitman
Line 159: Line 159:
  
 Your custom block should now be transparent! Your custom block should now be transparent!
 +
 +
 +==== Custom VoxelShape ====
 +
 +When making custom blocks which do not entirely fill the block, the adjacent blocks might hide their faces. In this case of a custom vertical slab it would look like this:
 +
 +{{:tutorial:voxelshape_wrong.png?200|}}
 +
 +
 +We have to define the VoxelShape of the new block into one which is not an entire block:
 +
 +<code>
 +@Override
 + public VoxelShape getOutlineShape(BlockState state, BlockView view, BlockPos pos, EntityContext ctx) {
 +     return VoxelShapes.cuboid(0f, 0f, 0f, 1f, 1.0f, 0.5f);
 + }
 +</code>
 +
 +By doing so we also define getCollisionShape, because by default it returns the result of OutlineShape.
 +
 +{{:tutorial:voxelshape_fixed.png?200|}}
 +
 ==== Next Steps ==== ==== Next Steps ====
 [[tutorial:blockstate|Adding simple state to a block, like ints and booleans]].  [[tutorial:blockstate|Adding simple state to a block, like ints and booleans]]. 
  
 [[tutorial:blockentity|Giving blocks a block entity so they can have advanced state like inventories and classes]]. Also needed for many things like GUI and custom block rendering. [[tutorial:blockentity|Giving blocks a block entity so they can have advanced state like inventories and classes]]. Also needed for many things like GUI and custom block rendering.
tutorial/blocks.txt · Last modified: 2024/04/15 01:52 by solidblock