Skip to content

Commit 262c4f2

Browse files
committed
feat: add onNpcCmd #226
1 parent 11aff6b commit 262c4f2

File tree

8 files changed

+297
-292
lines changed

8 files changed

+297
-292
lines changed

docs/apis/EventAPI/EntityEvents.md

Lines changed: 116 additions & 136 deletions
Original file line numberDiff line numberDiff line change
@@ -2,225 +2,205 @@
22

33
#### `"onMobDie"` - Mob/Player Death Event
44

5-
- Listener function prototype
5+
- Listener function prototype
66
`function(mob,source,cause)`
7-
- Parameters:
8-
- mob : `Entity`
9-
Dead entity object.
10-
- source : `Entity`
11-
The entity object that dealt the last damage (may be `Null`).
12-
- cause : `Integer`
13-
Cause of injury
7+
- Parameters:
8+
- mob : `Entity`
9+
Dead entity object.
10+
- source : `Entity`
11+
The entity object that dealt the last damage (may be `Null`).
12+
- cause : `Integer`
13+
Cause of injury
1414
- Intercept event: cannot be intercepted.
1515

1616
Note that when the player dies, in addition to triggering `onPlayerDie` event, this event will also be triggered once.
1717

18-
19-
2018
#### `"onMobHurt"` - Mob/Player Hurt Event
2119

22-
- Listener function prototype
20+
- Listener function prototype
2321
`function(mob,source,damage,cause)`
24-
- Parameters:
25-
- mob : `Entity`
26-
The damaged entity.
27-
- source : `Entity`
28-
The entity that dealt the damage (may be `Null`).
29-
- damage : `Integer`
30-
The amount of damage dealt.
31-
- cause : `Integer`
32-
Cause of injury
22+
- Parameters:
23+
- mob : `Entity`
24+
The damaged entity.
25+
- source : `Entity`
26+
The entity that dealt the damage (may be `Null`).
27+
- damage : `Integer`
28+
The amount of damage dealt.
29+
- cause : `Integer`
30+
Cause of injury
3331

3432
- Intercept events: function returns `false`
3533

36-
37-
3834
#### `"onEntityExplode"` - Entity Explosion Event
3935

40-
- Listener function prototype
36+
- Listener function prototype
4137
`function(source,pos,radius,maxResistance,isDestroy,isFire)`
42-
- Parameters:
43-
- source : `Entity`
44-
The entity object that caused the explosion.
45-
- pos : `FloatPos`
46-
The coordinates of the explosion.
47-
- radius : `Float`
48-
Blast radius.
49-
- maxResistance : `Float`
50-
The maximum resistance of blocks that will break.
51-
- isDestroy : `Boolean`
52-
Does the explosion destroy blocks.
53-
- isFire : `Boolean`
54-
Does the explosion produce flames.
55-
56-
- Intercept events: function returns `false`
57-
38+
- Parameters:
39+
- source : `Entity`
40+
The entity object that caused the explosion.
41+
- pos : `FloatPos`
42+
The coordinates of the explosion.
43+
- radius : `Float`
44+
Blast radius.
45+
- maxResistance : `Float`
46+
The maximum resistance of blocks that will break.
47+
- isDestroy : `Boolean`
48+
Does the explosion destroy blocks.
49+
- isFire : `Boolean`
50+
Does the explosion produce flames.
5851

52+
- Intercept events: function returns `false`
5953

6054
#### `"onTryMobSpawn"` - Mob try Naturally Spawn Event
6155

62-
- Listener function prototype
56+
- Listener function prototype
6357
`function(typeName,pos)`
64-
- Parameters:
65-
- typeName : `string`
66-
Entity Name
67-
- pos : `FloatPos`
68-
The coordinates of the spawn.
69-
70-
- Intercept events: function returns `false`
71-
58+
- Parameters:
59+
- typeName : `string`
60+
Entity Name
61+
- pos : `FloatPos`
62+
The coordinates of the spawn.
7263

64+
- Intercept events: function returns `false`
7365

7466
#### `"onMobSpawned"` - Mob Naturally Spawn Finished Event
7567

76-
- Listener function prototype
68+
- Listener function prototype
7769
`function(entity,pos)`
78-
- Parameters:
79-
- entity: `Entity`
80-
The entity that spawned.
81-
- pos : `FloatPos`
82-
The coordinates of the spawn.
83-
70+
- Parameters:
71+
- entity: `Entity`
72+
The entity that spawned.
73+
- pos : `FloatPos`
74+
The coordinates of the spawn.
75+
8476
- Intercept events: cannot be intercepted.
8577

8678
You can use entity.despawn() or entity.remove() to intercept this event.
8779

88-
89-
9080
#### `"onProjectileHitEntity"` - Entity Hit by Projectile Event
9181

92-
- Listener function prototype
82+
- Listener function prototype
9383
`function(entity,source)`
94-
- Parameters:
95-
- entity: `Entity`
96-
The entity that was hit with a projectile.
97-
- source : `Entity`
98-
The projecticle entity (like arrows).
84+
- Parameters:
85+
- entity: `Entity`
86+
The entity that was hit with a projectile.
87+
- source : `Entity`
88+
The projecticle entity (like arrows).
9989
- Intercept event: cannot be intercepted.
10090

101-
102-
10391
#### `"onWitherBossDestroy"` - Block Broken by Wither Event
10492

105-
- Listener function prototype
93+
- Listener function prototype
10694
`function(witherBoss,AAbb,aaBB)`
107-
- Parameters:
108-
- witherBoss: `Entity`
109-
The Wither entity object.
110-
- AAbb: `IntPos`
111-
The area that the wither will destroy (box), the A coordinate of the diagonal point.
112-
- aaBB: `IntPos`
113-
The area that the wither will destroy (box), the B coordinate of the diagonal point.
114-
95+
- Parameters:
96+
- witherBoss: `Entity`
97+
The Wither entity object.
98+
- AAbb: `IntPos`
99+
The area that the wither will destroy (box), the A coordinate of the diagonal point.
100+
- aaBB: `IntPos`
101+
The area that the wither will destroy (box), the B coordinate of the diagonal point.
102+
115103
- Intercept events: function returns `false`
116104

117105
Note that this event does not include wither explosion damage.
118106

119-
120-
121107
#### `"onRide"` - Mob Ride Event
122108

123-
- Listener function prototype
109+
- Listener function prototype
124110
`function(entity1,entity2)`
125-
- Parameters:
126-
- entity1 : `Entity`
127-
The entity that is riding the other entity.
128-
- entity2 : `Entity`
129-
The entity that is being ridden.
111+
- Parameters:
112+
- entity1 : `Entity`
113+
The entity that is riding the other entity.
114+
- entity2 : `Entity`
115+
The entity that is being ridden.
130116
- Intercept events: function returns `false`
131117

132118
Note: Riding includes minecart, boat, horse, pig, etc.
133119

134-
135-
136120
#### `"onStepOnPressurePlate"` - Pressure Plate Step Event
137121

138-
- Listener function prototype
122+
- Listener function prototype
139123
`function(entity,pressurePlate)`
140-
- Parameters:
141-
- entity : `Entity`
142-
The entity that stepped on the plate.
143-
- pressurePlate : `Block`
144-
The pressed pressure plate block.
124+
- Parameters:
125+
- entity : `Entity`
126+
The entity that stepped on the plate.
127+
- pressurePlate : `Block`
128+
The pressed pressure plate block.
145129
- Intercept events: function returns `false`
146130

147131
Note: When a creature steps on a pressure plate, this event will be triggered repeatedly.
148132

149-
150-
151133
#### `"onSpawnProjectile"` - Projectile Spawn Event
152134

153-
- Listener function prototype
135+
- Listener function prototype
154136
`function(shooter,type)`
155-
- Parameters:
156-
- shooter : `Entity`
157-
The entity that fired the projectile.
158-
- type : `String`
159-
Projectile Standard Type Name.
137+
- Parameters:
138+
- shooter : `Entity`
139+
The entity that fired the projectile.
140+
- type : `String`
141+
Projectile Standard Type Name.
160142

161143
- Intercept events: function returns `false`
162144

163-
Note: Projectiles known to be intercepted are eggs, ender pearls, snowballs, tridents, arrows, and fishing rods (fish hooks).
164-
165-
145+
Note: Projectiles known to be intercepted are eggs, ender pearls, snowballs, tridents, arrows, and fishing rods (fish
146+
hooks).
166147

167148
#### `"onProjectileCreated"` - Projectile Created Event
168149

169-
- Listener function prototype
150+
- Listener function prototype
170151
`function(shooter,entity)`
171-
- Parameters:
172-
- shooter : `Entity`
173-
The entity that created the projectile.
174-
- entity : `Entity`
175-
The projectile entity object being created.
152+
- Parameters:
153+
- shooter : `Entity`
154+
The entity that created the projectile.
155+
- entity : `Entity`
156+
The projectile entity object being created.
176157

177158
- Intercept event: cannot be intercepted.
178159

179-
180-
181160
#### `"onNpcCmd"` - NPC Command Execution Event
182161

183-
- Listener function prototype
162+
!!! warning
163+
This event is only available in 0.9.6 and later versions.
164+
165+
- Listener function prototype
184166
`function(npc,pl,cmd)`
185-
- Parameters:
186-
- npc : `Entity`
187-
The NPC entity that executed the command.
188-
- pl : `Player`
189-
The player that triggered the execution of the NPC command.
190-
- cmd : `String`
191-
The command being executed by NPCs.
167+
- Parameters:
168+
- npc : `Entity`
169+
The NPC entity that executed the command.
170+
- pl : `Player`
171+
The player that triggered the execution of the NPC command.
172+
- cmd : `String`
173+
The command being executed by NPCs. If there are multiple commands, they are separated by `;`.
192174
- Intercept events: function returns `false`
193175

194-
195-
196176
#### `"onChangeArmorStand"` - Armor Stand Change Event
197177

198-
- Listener function prototype
178+
- Listener function prototype
199179
`function(as,pl,slot)`
200180

201-
- Parameters:
181+
- Parameters:
202182

203-
- as: `Entity`
204-
Manipulated Armor Stand entity object.
205-
- pl : `Player`
206-
The player that manipulated the armor stand.
207-
- slot : `Number`
208-
Equipment slot number.
183+
- as: `Entity`
184+
Manipulated Armor Stand entity object.
185+
- pl : `Player`
186+
The player that manipulated the armor stand.
187+
- slot : `Number`
188+
Equipment slot number.
209189

210190
- Intercept events: function returns `false`
211191

212-
213-
214192
#### `"onEntityTransformation"` - Entity Transformation Event
215193

216-
- Listener function prototype
194+
- Listener function prototype
217195
`function(uniqueId,entity)`
218-
- Parameters:
196+
- Parameters:
219197

220-
- uniqueId: `String`
221-
Unique identifer of the pre-transformed entity.
222-
- entity : `Entity`
223-
The transformed entity.
198+
- uniqueId: `String`
199+
Unique identifer of the pre-transformed entity.
200+
- entity : `Entity`
201+
The transformed entity.
224202
- Intercept event: cannot be intercepted.
225203

226-
Note: This event is triggered when the `TransformationComponent` of the entity in `Addons` is activated, and is mostly used for the interaction between the engine and the Addon. Only `UniqueId` is provided since the entity pointer before the transition is destroyed quickly.
204+
Note: This event is triggered when the `TransformationComponent` of the entity in `Addons` is activated, and is mostly
205+
used for the interaction between the engine and the Addon. Only `UniqueId` is provided since the entity pointer before
206+
the transition is destroyed quickly.

0 commit comments

Comments
 (0)