Paste #107251: Unnamed Denizen Script Paste

Date: 2023/03/11 18:45:38 UTC-08:00
Type: Denizen Script

View Raw Paste Download This Paste
Copy Link


entity_manipulator_item:
    debug: false
    type: item
    material: Lead
    display name: Entity Manipulator
    mechanisms:
        unbreakable: true
    flags:
        active_manipulator: false
        power: 15

entity_manipulator_inventory:
    debug: false
    type: inventory
    inventory: chest
    title: <&E><bold>Entity Manipulator
    gui: true
    slots:
    - [rotate_facing_item] [] [] [] [] [] [] [] [inspector_gadget_item]
    - [] [] [] [] [] [] [] [] []

entity_manipulator_command:
    debug: false
    type: command
    name: entitymanipulator
    description: A stick that lets you manipulate targeted entities.
    usage: /entitymanipulator [<&lt>optional_amount<&gt>]
    aliases:
    - em
    permission: give.entitymanipulator
    script:
    - if <context.args.is_empty>:
        - give entity_manipulator_item quantity:1
        - narrate "<&E>Right click while holding to select an active manipulator!"
        - narrate "<&E>Default Power: 15 - Type <&6>'/em <&lt>#<&gt>'<&E> for a different amount!"
    - if !<context.args.is_empty>:
        - if <player.item_in_hand> matches entity_manipulator_item:
            - if <context.args.size> > 1:
                - narrate "<&c>Too many arguments provided.. Did you use the correct format?"
            - if <context.args.size> == 1 && !<context.args.first.is_decimal>:
                - narrate "<&c>Argument provided isn't a number"
            - if <context.args.size> == 1 && <context.args.first.is_decimal>:
                - narrate "<&E>Manipulator Power set to: <&6><context.args.first.round>"
                - inventory flag slot:hand power:<context.args.first.round>
        - else if <player.item_in_hand> !matches entity_manipulator_item:
            - narrate "Hold the Manipulator in your main hand."

entity_manipulator_item_world:
    debug: false
    type: world
    events:
        # - Item Specific Logic
        # Player selects item in toolbar.
        after player scrolls their hotbar item:entity_manipulator_item:
        - narrate "Active Manipulator: <player.inventory.slot[<context.new_slot>].flag[active_manipulator]>"
        # Open Inventory and cancel world interaction.
        on player right clicks block with:entity_manipulator_item:
        - inventory open d:entity_manipulator_inventory
        - determine cancelled
        # Don't break any blocks.
        on player left clicks block with:entity_manipulator_item:
        - determine cancelled
        # Cancel Damage Dealt to Entity. NPC's still receive a damage triggered event though!!
        on player damages entity with:entity_manipulator_item bukkit_priority:high:
        - determine cancelled

entity_manipulator_flagging_world:
    debug: true
    type: world
    events:
        # - Set Active Manipulation Flags:
        # Rotate Item
        after player clicks rotate_facing_item in entity_manipulator_inventory:
        - if <player.item_in_hand> matches entity_manipulator_item:
            - inventory flag slot:hand active_manipulator:rotate_facing
            - narrate "<&E>Active Tool Set: <&6>Rotate Entity Clockwise!"
            - narrate "<&E>Hold `Sneak` to reverse the rotation direction!"
        - inventory close

        after player clicks inspector_gadget_item in entity_manipulator_inventory:
        - if <player.item_in_hand> matches entity_manipulator_item:
            - inventory flag slot:hand active_manipulator:inspector_gadget
            - narrate "<&E>Active Tool Set: <&6>Inspector Gadget!"
        - inventory close


entity_manipulator_triggered_world:
    debug: true
    type: world
    events:
        # - Triggered Logic
        on player animates ARM_SWING with:entity_manipulator_item:
        - define power <player.item_in_hand.flag[power]>
        - define target <player.target>
        - if <player.is_sneaking>:
            - define power -<player.item_in_hand.flag[power]>
        - if <[target].exists>:

            - if !<player.item_in_hand.flag[active_manipulator].is_truthy>:
                - narrate "<&E>Right click to select a manipulator first!"
            # Inspector Gadget Logic
            - if <player.item_in_hand.flag[active_manipulator]> == inspector_gadget:
                - narrate "<&E>Inspection Results:"
                - narrate "<&F>Health: <&6><[target].health.round_to_precision[0.01]>/<[target].health_max>"
                - narrate "<&F>X:<&6><[target].location.x.format_number[0.00].pad_left[6]> <&F>Y:<&6><[target].location.y.format_number[0.00].pad_left[6]> <&F>Z:<&6><[target].location.z.format_number[0.00].pad_left[6]>"
                - narrate "<&F>Body Yaw: <&6><[target].body_yaw>"
                - narrate "<&F>Head Yaw: <&6><[target].location.yaw> <&F>Head Pitch: <&6><[target].location.pitch>"
                - narrate "<&F>Sleeping: <&6><[target].is_sleeping>"
                - narrate "<&F>Sneaking: <&6><[target].is_sneaking>"
                - narrate "<&F>Sitting: <&6><[target].is_sitting>"
                - if <[target].item_in_hand> == <item[air]>:
                    - narrate "<&F>Holding: <&6>Air"
                - else:
                    - if <[target].item_in_hand.has_display>:
                        - narrate "<&F>Holding: <&6><[target].item_in_hand.display>"
                    - else:
                        - narrate "<&F>Holding: <&6><[target].item_in_hand.material.name>"
            # Rotation Tool Logic
            - if <player.item_in_hand.flag[active_manipulator]> == rotate_facing:
                - teleport <[target]> <[target].location.rotate_yaw[<[power]>]>


# Manipulation Item Containers!
inspector_gadget_item:
    type: item
    material: ender_eye
    display name: Inspector Gadget

## adjust <player.target> head_angle:-180 eg
rotate_facing_item:
    type: item
    material: arrow
    display name: Rotate Facing

rotate_body_item:
    type: item
    material: spectral_arrow
    display name: Rotate Body