Block

Creating your first custom block

Create a simple 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.

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/

Alternative textures location

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.

Resourcepack hosting

Getting the block ingame

Run /iaget red_block to get the item.

Download the complete example

Block properties

specific_properties:
  block:
    placed_model:
      type: REAL_NOTE
      break_particles: BLOCK
      rotx: 0
      roty: 0
    cancel_drop: true #default is false. if true the custom block won't be dropped when
                      #player mines it
    light_level: 12 #make block emit light
    #tools you can't use to break block(accepts partial name of material/customitem)
    break_tools_blacklist:
    - WOODEN_PICKAXE
    - STONE_PICKAXE
    - IRON_PICKAXE
    #tools you can use to break block(accepts partial name of material/customitem)
    break_tools_whitelist:
    - DIAMOND_PICKAXE
    - PICKAXE
    - pickaxe
    hardness: 2 #hardness of the block
    blast_resistance: 1 #explosion resistance (by default is hardness*3)
    no_explosion: false #totally immune from explosions, ignoring blast_resistance
    sound: #customizable sounds of the block
      break:
        name: BLOCK_WOOD_BREAK
        volume: 1
        pitch: 0.9
      place:
        name: BLOCK_WOOD_PLACE
        volume: 1
        pitch: 0.9

placed_model

type

this property can have these value:

  • REAL_NOTE

    • uses a real block (note_block), no lag, no entities, 100% real blocks.

    • downsides:

      • no support for transparency.

      • max of 750 blocks in total.

  • REAL

    • uses a real block (mushroom), no lag, no entities, 100% real blocks. (although it's advised to use REAL_NOTE which is more stable).

    • downsides:

      • max of 191 blocks in total

  • REAL_TRANSPARENT

    • uses a real block (chorus), no lag, no entities, 100% real blocks, also with transparency support!

    • downsides:

      • max of 63 blocks in total

  • REAL_WIRE

    • uses a real block (tripwire), no lag, no entities, 100% real blocks.

    • downsides:

      • max of 127 blocks in total.

  • TILE

    • uses tile blocks (modified spawner with custom skin). It's not an entity but it have some downsides. Good thing is that you can create infinite blocks, there is no amount limit like REAL blocks.

    • downsides:

      • not a 100% real block, it's a retextured spawner

      • texture/model vanishes on high distance, so it will reveal the spawner vanilla texture

      • it could cause clientside lag if A LOT of blocks are in the player field of view, but only on lowend PCs.

  • FIRE

    • this is a special type of block, it's the fire block.

    • downsides:

      • only a max of 14 custom fires is possible, so be sure to create only the ones you need.

  • REAL and REAL_NOTE are meant to be used for decorative blocks and ores.

  • TILE blocks for trade machines and machinery/rare decorative blocks. You should not use TILE blocks for ores because it may cause a bit of lag on chunk generation. They are not adviced to be used for populators or decorators.

rotx and roty

This allows you to specify a rotation for a particular model. This is an option for expert users. The specified rotation is STATIC, it's not dynamic. This is useful only if you want to create multiple variants of the same block without having to create a separate model manually.

placeable_on_water

This allows to make some blocks placeable directly on water surface.

placeable_on_lava

This allows to make some blocks placeable directly on lava surface.

shift_up

This allows to make some blocks placed 1 block up. This is useful for REAL_WIRE blocks to create tall plants.

custom_variants

Available on ItemsAdder 3.2.5+

Special property which allows to specify custom variants for that block. Accepts the same properties shown in the Minecraft wiki models page.

Example:

          custom_variants:
            variant1:
              model: "minecraft:block/end_stone_bricks"
              y: 90
            variant2:
              model: "minecraft:block/end_stone_bricks"
              y: 180
              x: 90
            variant3:
              model: "minecraft:block/diamond_block"
              uvlock: true
            variant4:
              model: "minecraft:block/cobblestone"

cancel_drop

Cancel drop when block is broken. Useful if you have any mineral that will drop out of the block (loots), to avoid exploits.

If you use silk touch enchanted tool to break the block you will still get the block but it won't drop any item from its loot

Tools blacklist and whitelist

You can set "_PICKAXE" so every pickaxe will match the list rule, also "_AXE" as the plugin checks if the material name contains the word you set in the rule. It also works for custom items ids, so for example if you set "ruby_" every ruby tool will work (ruby_pickaxe, ruby_axe...)

break_tools_blacklist

Blacklist of tools that cannot break this block

break_tools_whitelist

Whitelist of tools that can break this block

events_tools_blacklist

Blacklist of tools that cannot run events on this block (placed_block.interact)

events_tools_whitelist

Whitelist of tools that cannot run events on this block (placed_block.interact)

Other options

hardness

Hardness of the block, it makes it more difficult to be mined. Refer to my blocks to get some examples (check blocks.yml file inside itemsadder namespace).

blast_resistance

Explosion resistance (by default is hardness * 3)

no_explosion

Totally immune from explosions, ignoring blast_resistance

sounds

hit, step and fall sounds require ItemsAdder 3.6.3b or greater.

You can specify custom sound names instead of vanilla sound. You can specify both Spigot sounds or vanilla Minecraft sounds names.

Stone block sounds will be used if no sound is specified.

Example using vanilla sounds

    specific_properties:
      block:
        placed_model:
          type: REAL_NOTE
          break_particles_material: PRISMARINE_BRICKS
        break_tools_whitelist:
          - PICKAXE
          - pickaxe
        sound:
          break:
            name: minecraft:block.amethyst_block.break
          place:
            name: minecraft:block.amethyst_block.place
          hit:
            name: minecraft:block.amethyst_block.hit
          step:
            name: minecraft:block.amethyst_block.step
          fall:
            name: minecraft:block.amethyst_block.fall

Example using custom sounds

    sound:
      break:
        name: my_sounds:sound_1
      place:
        name: my_sounds:sound_2
      hit:
        name: my_sounds:sound_3
      step:
        name: my_sounds:sound_4
      fall:
        name: my_sounds:sound_5

To add custom sounds to your resourcepack you have to read the sounds tutorial.

permission_suffix

This property allows you to enable permissions for the block place and block break events. This setting is not specified by default because we want players to be able to break and place blocks freely. Players would need explicit permissions if you specify these properties:

  • ia.user.block.break.iasurvival.ruby_ore

  • ia.user.block.place.iasurvival.ruby_ore

info:
  namespace: iasurvival
items:
  ruby_ore:
    enabled: true
    display_name: display-name-ruby_ore
    permission: iasurvival.items.ruby_ore
    resource:
      material: PAPER
      generate: true
      textures:
        - block/ores/ruby_ore
    specific_properties:
      block:
        permission_suffix:
          break: iasurvival.ruby_ore
          place: iasurvival.ruby_ore
        hardness: 4
        placed_model:
          type: REAL_NOTE
          break_particles_material: REDSTONE_ORE
        cancel_drop: true
        break_tools_blacklist:
          - WOODEN_PICKAXE
          - STONE_PICKAXE
        break_tools_whitelist:
          - PICKAXE
          - pickaxe
          - _hammer

Use the official files editor to read all the properties

Files editor

Drop experience from block

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

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

This has a downside, you can only set the experience 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: iasurvival:ruby_ore
      items:
        ruby:
          item: iasurvival:ruby
          min_amount: 1
          max_amount: 2
          chance: 100
      exp:
        exp_1:
          min_amount: 0
          max_amount: 3
          chance: 100

Last updated