Interface IHackableEntity

All Known Implementing Classes:
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
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 IPneumaticHelmetRegistry.addHackable(Class, java.util.function.Supplier). Either way, there will be an IHackableEntity instance for every entity.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    addHackInfo(net.minecraft.world.entity.Entity entity, List<net.minecraft.network.chat.Component> curInfo, net.minecraft.world.entity.player.Player player)
    Add info that is displayed on the tracker tooltip here.
    void
    addPostHackInfo(net.minecraft.world.entity.Entity entity, List<net.minecraft.network.chat.Component> curInfo, net.minecraft.world.entity.player.Player player)
    Add info that is being displayed after hacking, as long as 'afterHackTick' is returning true.
    boolean
    afterHackTick(net.minecraft.world.entity.Entity entity)
    Called every tick after the hacking finished.
    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.
    net.minecraft.resources.ResourceLocation
    Should return a unique id to represent this hackable.
    int
    getHackTime(net.minecraft.world.entity.Entity entity, net.minecraft.world.entity.player.Player player)
    Return the time it takes to hack this entity in ticks.
    void
    onHackFinished(net.minecraft.world.entity.Entity 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

      @Nullable net.minecraft.resources.ResourceLocation getHackableId()
      Should return a unique id to represent this hackable. Used in NBT saving to be able to trigger the afterHackTime after a server restart. Null is a valid return: afterHackTick will not be triggered at all in that case.
      Returns:
      a unique String id
    • canHack

      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.
      Parameters:
      entity - the potential hacking target
      player - the player who is looking at the entity
    • addHackInfo

      void addHackInfo(net.minecraft.world.entity.Entity entity, List<net.minecraft.network.chat.Component> curInfo, net.minecraft.world.entity.player.Player player)
      Add info that is displayed on the tracker tooltip here. Text like "Hack to explode" can be added. This method is only called when canHack(Entity) returned true.
      Parameters:
      entity - the potential hack target
      curInfo - a text component list to append info to
      player - the player who is looking at the entity
    • addPostHackInfo

      void addPostHackInfo(net.minecraft.world.entity.Entity entity, List<net.minecraft.network.chat.Component> curInfo, net.minecraft.world.entity.player.Player player)
      Add info that is being displayed after hacking, as long as 'afterHackTick' is returning true. Things like "Neutralized".
      Parameters:
      entity - the hacked entity
      curInfo - a text component list to append info to
      player - the player who has hacked the entity
    • getHackTime

      int getHackTime(net.minecraft.world.entity.Entity entity, net.minecraft.world.entity.player.Player player)
      Return the time it takes to hack this entity in ticks. For more powerful hacks, a longer required hacking time is recommended.
      Parameters:
      entity - the potential hack target
      player - the player who is looking at the entity
    • onHackFinished

      void onHackFinished(net.minecraft.world.entity.Entity 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

      boolean afterHackTick(net.minecraft.world.entity.Entity entity)
      Called every tick after the hacking finished. Returning true will keep this going (e.g. for endermen, to suppress their teleportation) or false for one-shot hacks (e.g. hacking a cow turns it into a mooshroom, and that is all)
      Parameters:
      entity - the hacked entity