User Tools

Site Tools


tutorial:events

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
tutorial:events [2020/06/09 23:16] – formatting changes draylartutorial:events [2021/05/28 00:31] (current) – external edit 127.0.0.1
Line 37: Line 37:
 <code java [enable_line_numbers="false"]> <code java [enable_line_numbers="false"]>
 (listeners) -> (player, sheep) -> { (listeners) -> (player, sheep) -> {
-    for (SheepShearCallback event : listeners) {+    for (SheepShearCallback listener : listeners) {
 </code> </code>
 We then call our method (in this case, ''interact'') on the listener to get its response: We then call our method (in this case, ''interact'') on the listener to get its response:
 <code java [enable_line_numbers="false"]> <code java [enable_line_numbers="false"]>
-ActionResult result = event.interact(player, sheep);+ActionResult result = listener.interact(player, sheep);
 </code> </code>
 If the listener says we have to cancel (''ActionResult.FAIL'') or fully finish (''ActionResult.SUCCESS''), the callback returns the result and finishes the loop. ''ActionResult.PASS'' moves on to the next listener, and in most cases should result in success if there are no more listeners registered: If the listener says we have to cancel (''ActionResult.FAIL'') or fully finish (''ActionResult.SUCCESS''), the callback returns the result and finishes the loop. ''ActionResult.PASS'' moves on to the next listener, and in most cases should result in success if there are no more listeners registered:
tutorial/events.1591744571.txt.gz · Last modified: 2020/06/09 23:16 by draylar