Cast

Denizen-Reflect supports explicit Java type casting. Casting allows you to safely access methods of a specific Java class when the returned value is a generic type such as Object or BlockState.

Example: Casting BlockState to Crafter

crafter:
    type: task
    definitions: location
    script:
    - define state <invoke[(Crafter) loc.getBlock().getState()]>
    - invoke 'state.setSlotDisabled(0, true)'
    - invoke state.update()

Last updated