Layerable block drops when destroyed by piston

Started by Warwickslave on

Topic category: Help with Minecraft modding (Java Edition)

Joined Oct 2025
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Layerable block drops when destroyed by piston
Thu, 10/16/2025 - 12:20 (edited)

I have a layerable block working similar to candles or pink petals, so I made it stackable using blockstates and its piston interaction is set to "destroy". Is there a way to make it drop items depending on blockstate when pushed by a piston, or should I make them as independent blocks with drops?

Tried to make a procedure with global trigger "when block is destroyed". Works with player destroying the block but with piston still nothing.

Edited by Warwickslave on Thu, 10/16/2025 - 12:20
Joined Dec 2014
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
if you use a loot table for…
Thu, 10/16/2025 - 18:39

if you use a loot table for your block you can lock it, the loot table, and use block state property conditions like how vanilla does it,

{
  "type": "minecraft:block",
  "pools": [
    {
      "bonus_rolls": 0,
      "entries": [
        {
          "type": "minecraft:item",
          "functions": [
            {
              "add": false,
              "conditions": [
                {
                  "block": "minecraft:candle",
                  "condition": "minecraft:block_state_property",
                  "properties": {
                    "candles": "2"
                  }
                }
              ],
              "count": 2,
              "function": "minecraft:set_count"
            },
            {
              "add": false,
              "conditions": [
                {
                  "block": "minecraft:candle",
                  "condition": "minecraft:block_state_property",
                  "properties": {
                    "candles": "3"
                  }
                }
              ],
              "count": 3,
              "function": "minecraft:set_count"
            },
            {
              "add": false,
              "conditions": [
                {
                  "block": "minecraft:candle",
                  "condition": "minecraft:block_state_property",
                  "properties": {
                    "candles": "4"
                  }
                }
              ],
              "count": 4,
              "function": "minecraft:set_count"
            },
            {
              "function": "minecraft:explosion_decay"
            }
          ],
          "name": "minecraft:candle"
        }
      ],
      "rolls": 1
    }
  ],
  "random_sequence": "minecraft:blocks/candle"
}

Misode is a great website for generating all sorts of data related files for minecraft. You can use the presets to base your loot table off

https://misode.github.io/loot-table/?version=1.21.4

 

Joined Oct 2025
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Thank you!!! Saving my day…
Thu, 10/16/2025 - 22:08

Thank you!!! Saving my day one more time 🙂