Links

Block

Creating your first custom block

My first custom block

Creating the blocks file

This is an example block (remember to change myitems namespace to the one you want).
For example I created a file which will contain all my custom blocks. I created it in the folder: plugins/ItemsAdder/contents/myitems/configs/
In this file (blocks.yml) I start creating a simple block called red_block.
info:
namespace: myitems
items:
red_block:
display_name: Red Block
permission: red_block
resource:
material: PAPER
It's very important to use a non placeable vanilla material. For example PAPER. If you use a block (like STONE or DIRT) it will result a bit glitchy when placed.

Block textures

Creating the textures files

Now the fun part, let's set the textures! To do that you have to put the .png textures file inside the correct folder.
In this case your namespace is myitems so you have to put them in this folder: plugins/ItemsAdder/contents/myitems/textures/block/
Alternatively you can put them in this folder too: plugins/ItemsAdder/contents/myitems/resourcepack/assets/myitems/textures/block/
Read more here: folders structure

Applying the textures files to your item

Now open blocks.yml file again and add the resource part as I did. As you can see I set generate: true and I set the textures for the item. This tells the plugin to generate the 3D model automatically using your texture.
info:
namespace: myitems
items:
red_block:
display_name: Red Block
permission: red_block
resource:
generate: true
material: PAPER

Using different texture for each face

Important: keep the correct cardinal directions order as shown in the example.
info:
namespace: myitems
items:
red_block:
display_name: Red Block
permission: red_block
resource:
generate: true
material: PAPER
textures:
- block/red_block_down.png
- block/red_block_east.png
- block/red_block_north.png
- block/red_block_south.png
- block/red_block_up.png
- block/red_block_west.png

Using the same texture for each face

info:
namespace: myitems
items:
red_block:
display_name: Red Block
permission: red_block
resource:
generate: true
material: PAPER
textures:
- block/red_block.png

Final complete configuration

Adding the block placing functionality

You have to add the specific_properties attribute.
info:
namespace: myitems
items:
red_block:
display_name: Red Block
permission: red_block
resource:
generate: true
material: PAPER
textures:
- block/red_block.png
specific_properties:
block:
placed_model:
type: REAL_NOTE
break_particles: ITEM
Click on the bottom link if you want to specify tools which can break the block, add hardness and other attributes.

Final part

Now you just need to tell the plugin to load your just added block. Make sure to read the hosting tutorial or you won't see the block correctly.

Getting the block ingame

Run /iaget red_block to get the item.

Download the complete example

Drop exp from block

There are 2 ways to drop exp from your custom blocks.

1. Add the exp drop directly in the custom block creation

This has a downside, you can only set the exp drop to custom blocks, not to vanilla blocks.
ruby_block:
display_name: display-name-ruby_block
permission: ruby_block
resource:
material: PAPER
generate: true
textures:
- block/ruby_block.png
specific_properties:
block:
placed_model:
type: REAL_NOTE
break_particles_material: REDSTONE_BLOCK
break_tools_whitelist:
- PICKAXE
- pickaxe
events:
placed_block:
break:
drop_exp:
chance: 100
min_amount: 0
max_amount: 3

2. Add the exp drop to loots

This is the best way because you can also apply this to vanilla blocks types and you can add as many as exp settings you want. This allows you to add more randomness and dynamicity to your drops.
loots:
blocks:
ruby_ore:
type: itemsadder:ruby_ore
items:
ruby:
item: itemsadder:ruby
min_amount: 1
max_amount: 2
chance: 100
exp:
exp_1:
min_amount: 0
max_amount: 3
chance: 100
Last modified 1mo ago