Events for Vampire Blood Drinking #1295
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This adds three new events,
PlayerDrinkBloodEvent
,EntityDrinkBloodEvent
andBiteFeedEvent
.PlayerDrinkBloodEvent
is fired whenever a Vampire Player drinks blood from any source which includes blood bottles, mob biting and vampire food items such as human hearts. The amount of blood gained, saturation and whether the remaining blood is used or not can be changed when the event is caught.EntityDrinkBloodEvent
is fired whenever a non-player Vampire Entity drinks blood from any source, although this will always be from mob biting under regular circumstance.BiteFeedEvent
is fired whenever a Vampire Player drinks blood from a mob, which exposes the entity being drained from in the event. Only the amount of blood gained and saturation can be changed here when the event is caught, thePlayerDrinkBloodEvent
will be fired after this asdrinkBlood
is called.The potential use case of these events are to decrease the amount of blood a vampire may get under some conditions, or to check how much blood a vampire is draining. (This would be the use case in the Vampiric Ageing addon, which currently uses a mixin to handle this).
The final commit includes some slightly larger changes as it includes an enum for blood sources which contains 5 values:
BITE_FEED
refers to any source that came from drinking another mob's blood.VAMPIRE_FOOD
refers to any source that came from eating vampire food such as human hearts.BLOOD_BOTTLE
refers to drinking from a blood bottle.CONTAINER
refers to blood drunk from containers.OTHER
refers to blood drunk from any source not covered by the previous ones, such as the blood given by the level up ritual.These enum values are then available through the event, allowing to check for specific cases. For example, under some circumstances a modder may want a vampire to gain less blood from human hearts and have them gain more from directly feeding from mobs. The use case for this is mainly for something I am planning to do with a future addon, although I imagine it could be useful for other purposes.