Interface PettingHandler<P extends net.minecraft.world.entity.Entity>
- Type Parameters:
P- The type of entity that should handle being pet.
- All Known Implementing Classes:
AnythingLivingPettingHandler,VanillaMobsPettingHandler
public interface PettingHandler<P extends net.minecraft.world.entity.Entity>
An object that defines how an entity should handle being pet. Can be registered in the
Consumer provided to
ImmersiveMCRegistration.addPettingHandlerRegistrationHandler(Consumer).
Note that the actual pet detection is handled by ImmersiveMC, only the methods provided here need implementation.- Since:
- 1.6.0-alpha1
-
Method Summary
Modifier and TypeMethodDescriptionintdoPetEffect(net.minecraft.server.level.ServerPlayer playerPetting, P petEntity, net.minecraft.world.phys.Vec3 handPosition) Perform effects from an entity being pet.booleanmatchesEntity(net.minecraft.server.level.ServerPlayer playerPetting, net.minecraft.world.entity.Entity possibleEntityToPet) Whether the entity provided matches being pet by this handler.
-
Method Details
-
matchesEntity
boolean matchesEntity(net.minecraft.server.level.ServerPlayer playerPetting, net.minecraft.world.entity.Entity possibleEntityToPet) Whether the entity provided matches being pet by this handler. Any entity that matches here will not be handled by handlers that were registered after this one.- Parameters:
playerPetting- The player that is petting the potential pet.possibleEntityToPet- The entity that may be a pet for this handler.- Returns:
- Whether the entity provided has petting handled by this handler.
-
doPetEffect
int doPetEffect(net.minecraft.server.level.ServerPlayer playerPetting, P petEntity, net.minecraft.world.phys.Vec3 handPosition) Perform effects from an entity being pet. This happens randomly as determined by ImmersiveMC, not every tick or some other consistent metric! Note that displaying hearts is automatically performed by ImmersiveMC and does not need to be replicated here.- Parameters:
playerPetting- The player performing the petting.petEntity- The entity being pet.handPosition- The position of the hand performing the petting.- Returns:
- A cooldown to wait in ticks until the entity pet effect can trigger again. Note that ImmersiveMC's hearts can still trigger on the next tick. A value of 0 or less is treated as no cooldown.
-