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 Type
    Method
    Description
    default 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)
     
    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)
     
    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.
    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.
    default boolean
    afterHackTick(T entity)
    Called every tick after the hack completed.
    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.
    Get the class of the entity this hack should apply to.
    net.minecraft.resources.ResourceLocation
    Should return a unique id to represent this hackable.
    int
    getHackTime(T entity, net.minecraft.world.entity.player.Player player)
    Return the time it takes to hack this entity in ticks.
    void
    onHackFinished(T entity, net.minecraft.world.entity.player.Player player)
    Called when a player successfully hacks an entity; basically getHackTime(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

      @Nonnull Class<T> 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 target
      player - 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 if canHack(Entity, Player) returned true. Keep this message short; one short phrase is enough.
      Parameters:
      entity - the potential hack target
      curInfo - a text component list to append info to
      player - 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 target
      curInfo - a text component list to append info to
      player - the player who has hacked the entity
    • getHackTime

      int getHackTime(T entity, net.minecraft.world.entity.player.Player player)
      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 target
      player - the player who is potentially hacking the target entity
    • onHackFinished

      void onHackFinished(T entity, net.minecraft.world.entity.player.Player player)
      Called when a player successfully hacks an entity; basically getHackTime(Entity) ticks after the hack was initiated.
      Parameters:
      entity - the hacked entity
      player - the player who has hacked the entity
    • afterHackTick

      default boolean afterHackTick(T entity)
      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 also AbstractPersistentEntityHack for 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

      @Internal default boolean _afterHackTick(net.minecraft.world.entity.Entity e)
    • _getHackTime

      @Internal default int _getHackTime(net.minecraft.world.entity.Entity e, net.minecraft.world.entity.player.Player p)
    • _onHackFinished

      @Internal default void _onHackFinished(net.minecraft.world.entity.Entity e, net.minecraft.world.entity.player.Player p)
    • _addHackInfo

      @Internal default void _addHackInfo(net.minecraft.world.entity.Entity e, List<net.minecraft.network.chat.Component> componentList, net.minecraft.world.entity.player.Player p)
    • _addPostHackInfo

      @Internal default void _addPostHackInfo(net.minecraft.world.entity.Entity e, List<net.minecraft.network.chat.Component> componentList, net.minecraft.world.entity.player.Player p)