Class AbstractPersistentEntityHack<T extends net.minecraft.world.entity.Entity>
java.lang.Object
me.desht.pneumaticcraft.api.pneumatic_armor.hacking.AbstractPersistentEntityHack<T>
- Type Parameters:
T- entity class
- All Implemented Interfaces:
IHackableEntity<T>
- Direct Known Subclasses:
HackableBlaze,HackableEnderman,HackableGhast,HackableGuardian,HackableShulker
public abstract class AbstractPersistentEntityHack<T extends net.minecraft.world.entity.Entity>
extends Object
implements IHackableEntity<T>
Convenience base class for hacks which are added as a persistent object to an entity's hack list. Such a hack will
be ticked each client & server tick until the entity dies, or until the hack's
IHackableEntity.afterHackTick(Entity) method returns false.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumSome common hack types which can be passed to theAbstractPersistentEntityHackconstructor, only used for armor HUD display purposes. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractPersistentEntityHack(String infoKey, String postInfoKey) protected -
Method Summary
Modifier and TypeMethodDescriptionvoidaddHackInfo(T entity, List<net.minecraft.network.chat.Component> curInfo, net.minecraft.world.entity.player.Player player) Add info that is displayed on the entity tracker panel, describing what the hack would do to the entity.voidaddPostHackInfo(T entity, List<net.minecraft.network.chat.Component> curInfo, net.minecraft.world.entity.player.Player player) Add info that is displayed on the entity tracker panel, describing what the hack has done to the entity.booleanafterHackTick(T entity) Called every tick after the hack completed.booleancanHack(net.minecraft.world.entity.Entity entity, net.minecraft.world.entity.player.Player player) Returning true will allow the player to hack this entity.intgetHackTime(T entity, net.minecraft.world.entity.player.Player player) Return the time it takes to hack this entity in ticks.static <T extends net.minecraft.world.entity.Entity>
booleanhasPersistentHack(T entity, Class<? extends AbstractPersistentEntityHack<T>> cls) Convenience method to check if an entity has a specific persisting hackvoidonHackFinished(T entity, net.minecraft.world.entity.player.Player player) Called when a player successfully hacks an entity; basicallygetHackTime(Entity)ticks after the hack was initiated.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface me.desht.pneumaticcraft.api.pneumatic_armor.hacking.IHackableEntity
_addHackInfo, _addPostHackInfo, _afterHackTick, _getHackTime, _onHackFinished, getHackableClass, getHackableId
-
Constructor Details
-
AbstractPersistentEntityHack
-
AbstractPersistentEntityHack
-
-
Method Details
-
canHack
public boolean canHack(net.minecraft.world.entity.Entity entity, net.minecraft.world.entity.player.Player player) Description copied from interface:IHackableEntityReturning true will allow the player to hack this entity. This can be used to only allow hacking under certain conditions. Default implementation just checks the entity's class is appropriate and the entity is alive, but this can be overridden to add extract checks. Just be sure to call this super method in your overridden method.- Specified by:
canHackin interfaceIHackableEntity<T extends net.minecraft.world.entity.Entity>- Parameters:
entity- the potential hacking targetplayer- the player who is potentially hacking the target entity
-
addHackInfo
public void addHackInfo(T entity, List<net.minecraft.network.chat.Component> curInfo, net.minecraft.world.entity.player.Player player) Description copied from interface:IHackableEntityAdd info that is displayed on the entity tracker panel, describing what the hack would do to the entity. This is only called ifIHackableEntity.canHack(Entity, Player)returned true. Keep this message short; one short phrase is enough.- Specified by:
addHackInfoin interfaceIHackableEntity<T extends net.minecraft.world.entity.Entity>- Parameters:
entity- the potential hack targetcurInfo- a text component list to append info toplayer- the player who is potentially hacking the target entity
-
addPostHackInfo
public void addPostHackInfo(T entity, List<net.minecraft.network.chat.Component> curInfo, net.minecraft.world.entity.player.Player player) Description copied from interface:IHackableEntityAdd info that is displayed on the entity tracker panel, describing what the hack has done to the entity. This is displayed for a second or so after the hack completes.- Specified by:
addPostHackInfoin interfaceIHackableEntity<T extends net.minecraft.world.entity.Entity>- Parameters:
entity- the hacked targetcurInfo- a text component list to append info toplayer- the player who has hacked the entity
-
getHackTime
Description copied from interface:IHackableEntityReturn the time it takes to hack this entity in ticks. Most builtin PneumaticCraft hacks use a time of 60 ticks, but for more powerful hacks, a longer required hacking time is suggested.- Specified by:
getHackTimein interfaceIHackableEntity<T extends net.minecraft.world.entity.Entity>- Parameters:
entity- the potential hack targetplayer- the player who is potentially hacking the target entity
-
onHackFinished
Description copied from interface:IHackableEntityCalled when a player successfully hacks an entity; basicallygetHackTime(Entity)ticks after the hack was initiated.- Specified by:
onHackFinishedin interfaceIHackableEntity<T extends net.minecraft.world.entity.Entity>- Parameters:
entity- the hacked entityplayer- the player who has hacked the entity
-
afterHackTick
Description copied from interface:IHackableEntityCalled every tick after the hack completed. Return false for one-shot hacks, or true to keep this hack ticking. The majority of hacks are one-shot; see alsoAbstractPersistentEntityHackfor a class to use for persistent hacks.Dead or otherwise removed entities will automatically be removed from the after-hack tick list.
- Specified by:
afterHackTickin interfaceIHackableEntity<T extends net.minecraft.world.entity.Entity>- Parameters:
entity- the hacked entity- Returns:
- true to keep having this method called each tick for the entity, false to stop ticking
-
hasPersistentHack
public static <T extends net.minecraft.world.entity.Entity> boolean hasPersistentHack(T entity, Class<? extends AbstractPersistentEntityHack<T>> cls) Convenience method to check if an entity has a specific persisting hack- Type Parameters:
T- entity type- Parameters:
entity- the entity to checkcls- class of the hack to check for- Returns:
- true if the entity has been hacked, false otherwise
-