Triggers
A trigger is a mechanism for 'learning' a draft when a certain condition is met.
The mod already has some built-in triggers, but if you want to add your own, you can use the extension method DraftsModSystem.TryLearnDraft(IPlayer player, AssetLocation draftCode)
.
List of built-in triggers
All built-in triggers are behaviors and are added via a list of behaviors in json.
Item triggers
Json structure:
{
...
"behaviors": [
{
"name": "TRIGGER_NAME",
"properties": {
"draft": "...",
"target": {
"type": "...",
"code": "...",
"allowedVariants": ["..."],
},
}
}
],
...
}
pomdrafts:trigger-item-interact
- triggers when using an item (RMB). Properties:draft
- draft code to be learned.target
- optional parameter indicating the target to be interacted with.type
- type of target for interaction,"block"
or"entity"
.code
- block or entity code, may be wildcard.allowedVariants
- list of allowed wildcard variants.
pomdrafts:trigger-item-attack
- triggers when attacking with an item (LMB). Properties:draft
- draft code to be learned.target
- optional parameter indicating the target to be interacted with.type
- type of target for interaction,"block"
or"entity"
.code
- block or entity code, may be wildcard.allowedVariants
- list of allowed wildcard variants.
pomdrafts:trigger-item-mining
- triggers when a block is broken by the item. Properties:draft
- draft code to be learned.target
- optional parameter indicating the target to be interacted with.code
- block code, may be wildcard.allowedVariants
- list of allowed wildcard variants.
Block triggers
Json structure:
{
...
"behaviors": [
{
"name": "TRIGGER_NAME",
"properties": {
"draft": "...",
"byItem": {
"type": "...",
"code": "...",
...
},
}
}
],
...
}
pomdrafts:trigger-block-interact
- triggers when interacting with a block in the world (RMB). Properties:draft
- draft code to be learned.byItem
- optional itemstack describing the item that should be used to interact with the block.
pomdrafts:trigger-block-break
- triggers when a block is broken by a player. Properties:draft
- draft code to be learned.byItem
- optional itemstack describing the item that should be used to break the block.
pomdrafts:trigger-block-place
- triggers when a block is placed by a player. Properties:draft
- draft code to be learned.byItem
- optional itemstack describing the item that should be used to place the block.
Entity triggers
Json structure:
{
...
"behaviors": [
{
"code": "TRIGGER_NAME",
"draft": "...",
"byItem": {
"type": "...",
"code": "...",
...
},
}
],
...
}
pomdrafts:trigger-entity-interact
- triggers when interacting with an entity in the world (RMB). Properties:draft
- draft code to be learned.byItem
- optional itemstack describing the item that should be used to interact with an entity.
pomdrafts:trigger-entity-attack
- triggers when player attacks the entity. Properties:draft
- draft code to be learned.byItem
- optional itemstack describing the item that should be used to attack the entity.
pomdrafts:trigger-entity-death
- triggers when an entity dies from a player. Properties:draft
- draft code to be learned.byItem
- optional itemstack describing the item that should be used to kill the entity.
pomdrafts:trigger-player-attack
- triggers when the entity attacks the player.pomdrafts:trigger-dialogue
- adds the ability to use dialogue triggers for NPCs.
Dialogue trigger
Learns the draft when executing a trigger placed in the dialogue. Requires pomdrafts:trigger-dialogue
behavior on the entity.
Json structure:
{
components: [
...
{
...
trigger: "pomdrafts:givedraft",
triggerdata: {
"draft": "..."
},
},
...
]
}