Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add click_phase and priority fields to item_on_item power type #229

Merged
merged 5 commits into from
May 20, 2024

Conversation

eggohito
Copy link
Collaborator

@eggohito eggohito commented May 6, 2024

This PR changes the click_type field, and adds the new click_phases and priority fields to the item_on_item power type:

Note

Powers with a priority value of equal or greater than 1 will be executed and override the original action of clicking an item stack with the cursor item stack, or clicking an item stack in a slot...

...while powers with a priority value of equal or less than -1 will only be executed if the original action of clicking an item stack with the cursor item stack, or clicking an item stack in a slot has failed (or if the item doesn't have any.)

Field Type Default Description
click_types Array of Click Types ["secondary"] Determines whether the power should trigger when left-clicking ("primary"), right-clicking ("secondary"), or both, an item.

(This is a replacement for the click_type field, but the power type still supports it.)
click_phases Array of Stack Click Phases "slot" Determines the click phase at which the actions should be executed.
priority Integer 0 Determines the execution priority of the power; powers are executed in the highest-to-lowest priority order.

A stack click phase is a string that determines the phase when clicking an item on a slot in inventories.

Note

The listed values are ordered based on priority, with "cursor" being first and "slot" being last.

Name Description
"cursor" Determines that the item stack held in the cursor is clicked to a slot.
"slot" Determines that the item stack from a slot is being clicked.

Here's an example that overrides the action of placing item stacks in a bundle when using the bundle on an item stack:

{
    type: "apoli:item_on_item",
    using_item_condition: {
        type: "apoli:ingredient",
        ingredient: {
            item: "minecraft:bundle"
        }
    },
    on_item_condition: {
        type: "apoli:empty",
        inverted: true
    },
    entity_action: {
        type: "apoli:execute_command",
        command: "tellraw @s {\"text\": \"Cannot place an item in the held bundle!\", \"color\": \"red\"}"
    },
    click_type: "secondary",
    click_phases: [
        "cursor"
    ],
    priority: 1
}

And another example that would override the action of placing item stacks in a bundle when using an item stack on a bundle:

{
    type: "apoli:item_on_item",
    using_item_condition: {
        type: "apoli:empty",
        inverted: true
    },
    on_item_condition: {
        type: "apoli:ingredient",
        ingredient: {
            item: "minecraft:bundle"
        }
    },
    entity_action: {
        type: "apoli:execute_command",
        command: "tellraw @a {\"text\": \"Cannot put held item into a bundle!\", \"color\": \"red\"}"
    },
    click_type: "secondary",
    click_phases: [
        "slot"
    ],
    priority: 1
}

@eggohito eggohito added this to the 2.12.x milestone May 6, 2024
@eggohito eggohito changed the base branch from 1.20 to 1.20.4/dev May 17, 2024 04:35
eggohito added 2 commits May 19, 2024 20:10
- Removed `ANY` click phase
- Removed `ALL` priority phase
+ Added `click_types` field, which accepts an array of click types, and essentially an alias of the old `click_type` field
+ Added `result_stack` field, which is essentially an alias of the old `result` field
* Changed `click_phase` field to `click_phases`, which now also accepts an array of click phases
* Renamed click phases to:
    * `USING_CURSOR` --> `CURSOR`
    * `ON_SLOT`      --> `SLOT`
@eggohito eggohito added the pending: merge This will be merged soon label May 19, 2024
@eggohito eggohito merged commit 6b9f3b9 into 1.20.4/dev May 20, 2024
@eggohito eggohito deleted the feat/power_types/item_on_item_additions branch May 20, 2024 20:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pending: merge This will be merged soon
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant