OptionalbeforeOptionalonThis function will be called when a specific block is destroyed. Changes in block permutations will not trigger this event. Fill Command and SetBlock Command can trigger this event when changing a block permutation only when using destroy mode. Custom blocks with the "minecraft:replaceable" component will not trigger the event when replaced.
OptionalonOptionalonOptionalonOptionalonOptionalonOptionalonOptionalonOptionalonOptionalonOptionalon
Contains a set of events that will be raised for a block. This object must be bound using the BlockRegistry.
Example: registerBlockComponent_v1.ts
Example: registerBlockComponent_v2.ts
Custom Components V1
Custom Components V1 is the original implementation of custom components in Minecraft. It allows you to define custom behaviors and properties for blocks, items, and entities using JSON components.
For script implementation, check out registerBlockComponent_v1.ts
JSON Example:
Custom Components V2
Custom Components V2 is a new experiment which must be enabled along with the "Beta APIs" experiment to use the new features for custom components. With the experiment enabled:
minecraft:custom_componentsis deprecated in favor of flattened custom componentsFlattening
In the previous version of custom components, components had to be listed inside the
minecraft:custom_componentscomponent. This is no longer required and theminecraft:custom_componentscomponent is deprecated. Instead, you can write your custom components similar to any other Minecraft component. For example:Parameters
Along with flattening a custom component in JSON, you also can provide parameters to the component. The script bindings for custom components have been upgraded to support a second parameter,
CustomComponentParameters, which grants access to the JSON parameter list for your component. The following example shows how to use custom component parameters in script: