Commit Graph

1 Commits

Author SHA1 Message Date
BillyGalbreath
56569f7812 1.13: Slime Patherfinder Events (#1246)
Replaces PR #1161 for 1.13

Resolves #930 

Adds new slime pathfinder related events. All events can be cancelled.
- `SlimePathfindEvent` is the base event of all added events. Cancelling this event will cancel all pathfinders.
- `SlimeWanderEvent` is called when slimes wander around by either swimming or moving/jumping forward. Cancelling this event will prevent slimes from moving around and jumping, but they will still look around and target players.
- `SlimeSwimEvent`is called when slimes are swimming in water/lava. Cancelling will prevent the slimes from moving/jumping in water/lava.
- `SlimeChangeDirectionEvent` is called when a slime changes directions. It contains the new `yaw` position the slime wants to change to, and it can be set to another value. Cancelling this event will prevent slimes from changing directions (except for when targeting players).
- `SlimeTargetLivingEntityEvent` is called when a slime targets a player. NMS uses EntityLiving here so it is named this. Contains the LivingEntity the slime has targeted. Cancelling this event will prevent the slime from targeting the entity and will make it lose current focus.

Adds `Slime#canWander()` and `Slime#setWander(boolean)` for a more persistent control (does not persist server restarts) over all 4 pathfinder types without the spammy event having to be cancelled a bajillion times a second.

Video demonstration: https://youtu.be/8hcLqazmO28

Test plugin: https://pastebin.com/cFgcgdWV
2018-08-24 10:40:14 -04:00