tutorial:blocks
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
tutorial:blocks [2019/07/05 14:00] – [Registering a BlockItem] itemGroup() -> group() upcraftlp | tutorial:blocks [2020/04/15 22:32] – Fixed loot table directory darthjake | ||
---|---|---|---|
Line 24: | Line 24: | ||
{ | { | ||
// block creation | // block creation | ||
- | […] | + | [...] |
| | ||
@Override | @Override | ||
Line 34: | Line 34: | ||
</ | </ | ||
- | Your block will //not// be accessible as an item, but it can be seen in-game by using / | + | Your block will //not// be accessible as an item, but it can be seen in-game by using '' |
==== Registering a BlockItem ==== | ==== Registering a BlockItem ==== | ||
Line 99: | Line 99: | ||
==== Adding a block loot table ==== | ==== Adding a block loot table ==== | ||
- | The block must have a loot table for any items to drop when the block is broken. Assuming you have created an item for your block and registered it using the same name as the block, the following file will produce regular block drops '' | + | The block must have a loot table for any items to drop when the block is broken. Assuming you have created an item for your block and registered it using the same name as the block, the following file will produce regular block drops '' |
<code JavaScript src/ | <code JavaScript src/ | ||
Line 138: | Line 138: | ||
</ | </ | ||
- | Just like we did in the item tutorial, you can override methods in the block class for custom functionality. | + | Just like we did in the item tutorial, you can override methods in the block class for custom functionality. |
+ | |||
+ | If you want your block to be transparent, in your client mod initializer code, do: | ||
+ | <code java> | ||
+ | BlockRenderLayerMap.putBlock(/ | ||
+ | </ | ||
+ | |||
+ | In versions before 1.15/ | ||
<code java> | <code java> | ||
@Environment(EnvType.CLIENT) | @Environment(EnvType.CLIENT) | ||
+ | @Override | ||
public BlockRenderLayer getRenderLayer() { | public BlockRenderLayer getRenderLayer() { | ||
return BlockRenderLayer.TRANSLUCENT; | return BlockRenderLayer.TRANSLUCENT; | ||
Line 159: | Line 167: | ||
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: | ||
+ | |||
+ | {{: | ||
+ | |||
+ | |||
+ | We have to define the VoxelShape of the new block into one which is not an entire block: | ||
+ | |||
+ | < | ||
+ | @Override | ||
+ | | ||
+ | | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | By doing so we also define getCollisionShape, | ||
+ | |||
+ | {{: | ||
+ | |||
+ | ==== Next Steps ==== | ||
+ | [[tutorial: | ||
+ | |||
+ | [[tutorial: |
tutorial/blocks.txt · Last modified: 2024/04/15 01:52 by solidblock