-
Notifications
You must be signed in to change notification settings - Fork 1
Use‐Behaviors
JadenXgamer edited this page Dec 4, 2024
·
8 revisions
Use-Behaviors are data-driven registries which fire when a block has been right-clicked it allows you to easily add new interaction functionality to any block and have it do custom behaviors afterwards
Note
doing /reload does not work as it's a datapack-registry and requires relogging into a world
use-behaviors are stored inside data/<namespace>/elysium/block/use-behaviors as jsons and get loaded when the world starts
here's an example use-behavior which makes it so flowers can be duplicated with bone-meal similar to bedrock edition
{
"blocks": "#minecraft:small_flowers",
"item_condition": "minecraft:bone_meal",
"chance_to_fail": 2,
"behaviors": {
"type": "place_itself",
"pos": "random_horizontal",
"pos_offset": 0,
"after_use_item": "consume",
"can_replace_solids": false,
"particles": {
"particle_type": "minecraft:happy_villager",
"x_velocity": 0.0,
"y_velocity": 0.0,
"z_velocity": 0.0
},
"sounds": {
"sound_event": "minecraft:item.bone_meal.use",
"volume": 1.0,
"pitch": 1.0
}
}
}| Variable | Description | Takes In | Required |
|---|---|---|---|
| blocks | This use-behavior will work for all blocks defined here | Tags, Single Block-ids or an Array of Block-ids | required |
| item_condition | only fires if you're holding this item when interacting with it | Tags, Single Block-ids or an Array of Block-ids | required |
| chance_to_fail | odds for this use-behavior to fail, higher values fail more often | Integer | optional |
| Variable | Description | Takes In | Required |
|---|---|---|---|
| type | defines what should happen when the use-behavior is triggered |
place place_itself drop drop_itself feature
|
required |
| place | contains information for what gets placed or dropped depending on what type is set to, this variable doesn't get used if type is set to any of the "itself" ones |
Block-id, Item-id or Configured Feature Location | optional* |
| after_use_item | defines what happens to the item in hand once the use-behavior is done, none is default |
none damage consume
|
optional |
| pos | the position where behaviors get triggered |
noop above below north east south west random_horizontal
|
optional |
| pos_offset | offsets the position by a defined number of blocks in the direction specified in pos
|
Integer | optional |
| can_replace_solids | normally the use-behavior would fail if the block in pos is not replaceable but this overrides that |
Boolean | optional |
| Variable | Description | Takes In | Required |
|---|---|---|---|
| particle_type | spawns the defined particle type | ParticleType-id | required |
| x_velocity | defines the X-axis velocity of the spawned particle | Double | optional |
| y_velocity | defines the Y-axis velocity of the spawned particle | Double | optional |
| z_velocity | defines the Z-axis velocity of the spawned particle | Double | optional |
| Variable | Description | Takes In | Required |
|---|---|---|---|
| sound_event | plays a sound when the use-behavior is fired | SoundEvent | required |
| volume | controls the volume of played sound | Float | optional |
| pitch | controls the pitch of played sound | Float | optional |