Interface IHackableEntity<T extends net.minecraft.world.entity.Entity>
- Type Parameters:
T- target entity class
- All Known Implementing Classes:
AbstractPersistentEntityHack,AbstractTameableHack,AmadroneEntity,CollectorDroneEntity,DroneEntity,GuardDroneEntity,HackableBat,HackableBlaze,HackableCaveSpider,HackableCow,HackableCreeper,HackableEnderman,HackableGhast,HackableGuardian,HackableHorse,HackableItemFrame,HackableMobDisarm,HackablePainting,HackablePufferfish,HackableSheep,HackableShulker,HackableSquid,HackableTameable,HackableVillager,HackableWitch,HarvestingDroneEntity,LogisticsDroneEntity
public interface IHackableEntity<T extends net.minecraft.world.entity.Entity>
Use this interface to specify any hackable entity. When it's your entity, you can simply implement this interface in
the entity's class. If you don't have access to the entity (i.e. vanilla entities or entities from other mods), you
can implement this interface in a separate class and register it using
ICommonArmorRegistry.addHackable(Class, java.util.function.Supplier).
Either way, there will be an IHackableEntity instance for every entity.-
Method Summary
Modifier and TypeMethodDescriptiondefault void_addHackInfo(net.minecraft.world.entity.Entity e, List<net.minecraft.network.chat.Component> componentList, net.minecraft.world.entity.player.Player p) default void_addPostHackInfo(net.minecraft.world.entity.Entity e, List<net.minecraft.network.chat.Component> componentList, net.minecraft.world.entity.player.Player p) default boolean_afterHackTick(net.minecraft.world.entity.Entity e) Do not use or override any methods below here.default int_getHackTime(net.minecraft.world.entity.Entity e, net.minecraft.world.entity.player.Player p) default void_onHackFinished(net.minecraft.world.entity.Entity e, net.minecraft.world.entity.player.Player p) voidaddHackInfo(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.default booleanafterHackTick(T entity) Called every tick after the hack completed.default booleancanHack(net.minecraft.world.entity.Entity entity, net.minecraft.world.entity.player.Player player) Returning true will allow the player to hack this entity.Get the class of the entity this hack should apply to.net.minecraft.resources.ResourceLocationShould return a unique id to represent this hackable.intgetHackTime(T entity, net.minecraft.world.entity.player.Player player) Return the time it takes to hack this entity in ticks.voidonHackFinished(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.
-
Method Details
-
getHackableId
@Nonnull net.minecraft.resources.ResourceLocation getHackableId()Should return a unique id to represent this hackable.- Returns:
- a unique String id
-
getHackableClass
Get the class of the entity this hack should apply to. All subclasses of this class will also be applicable.- Returns:
- the target entity class
-
canHack
default boolean canHack(net.minecraft.world.entity.Entity entity, net.minecraft.world.entity.player.Player player) Returning 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.- Parameters:
entity- the potential hacking targetplayer- the player who is potentially hacking the target entity
-
addHackInfo
void addHackInfo(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. This is only called ifcanHack(Entity, Player)returned true. Keep this message short; one short phrase is enough.- Parameters:
entity- the potential hack targetcurInfo- a text component list to append info toplayer- the player who is potentially hacking the target entity
-
addPostHackInfo
void addPostHackInfo(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. This is displayed for a second or so after the hack completes.- Parameters:
entity- the hacked targetcurInfo- a text component list to append info toplayer- the player who has hacked the entity
-
getHackTime
Return 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.- Parameters:
entity- the potential hack targetplayer- the player who is potentially hacking the target entity
-
onHackFinished
Called when a player successfully hacks an entity; basicallygetHackTime(Entity)ticks after the hack was initiated.- Parameters:
entity- the hacked entityplayer- the player who has hacked the entity
-
afterHackTick
Called 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.
- Parameters:
entity- the hacked entity- Returns:
- true to keep having this method called each tick for the entity, false to stop ticking
-
_afterHackTick
default boolean _afterHackTick(net.minecraft.world.entity.Entity e) Do not use or override any methods below here. Only here for generics support. -
_getHackTime
default int _getHackTime(net.minecraft.world.entity.Entity e, net.minecraft.world.entity.player.Player p) -
_onHackFinished
default void _onHackFinished(net.minecraft.world.entity.Entity e, net.minecraft.world.entity.player.Player p) -
_addHackInfo
default void _addHackInfo(net.minecraft.world.entity.Entity e, List<net.minecraft.network.chat.Component> componentList, net.minecraft.world.entity.player.Player p) -
_addPostHackInfo
default void _addPostHackInfo(net.minecraft.world.entity.Entity e, List<net.minecraft.network.chat.Component> componentList, net.minecraft.world.entity.player.Player p)
-