Class HackableMobSpawner

java.lang.Object
me.desht.pneumaticcraft.common.hacking.block.HackableMobSpawner
All Implemented Interfaces:
IHackableBlock

public class HackableMobSpawner extends Object implements IHackableBlock
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    addInfo(net.minecraft.world.level.BlockGetter world, net.minecraft.core.BlockPos pos, List<net.minecraft.network.chat.Component> curInfo, net.minecraft.world.entity.player.Player player)
    Add info that is displayed on the block tracker panel, describing what the hack would do to the block.
    void
    addPostHackInfo(net.minecraft.world.level.BlockGetter world, net.minecraft.core.BlockPos pos, List<net.minecraft.network.chat.Component> curInfo, net.minecraft.world.entity.player.Player player)
    Add info that is displayed on the block tracker panel, describing what the hack has done to the block.
    boolean
    afterHackTick(net.minecraft.world.level.BlockGetter world, net.minecraft.core.BlockPos pos)
    Called every tick after the hack completed.
    boolean
    canHack(net.minecraft.world.level.BlockGetter level, net.minecraft.core.BlockPos pos, net.minecraft.world.level.block.state.BlockState state, net.minecraft.world.entity.player.Player player)
    Can this block actually be hacked? This will normally return true, since the object is registered with the block, but this can be overridden to filter hackability by the actual blockstate (e.g Jukeboxes can only be hacked when they contain a music disc), or by some property of the player.
    net.minecraft.resources.ResourceLocation
    Get a unique id to represent this hackable.
    int
    getHackTime(net.minecraft.world.level.BlockGetter world, net.minecraft.core.BlockPos pos, net.minecraft.world.entity.player.Player player)
    Get the time it takes to hack this block in ticks.
    static boolean
    isHacked(net.minecraft.world.level.BlockGetter world, net.minecraft.core.BlockPos pos)
     
    void
    onHackComplete(net.minecraft.world.level.Level world, net.minecraft.core.BlockPos pos, net.minecraft.world.entity.player.Player player)
    When the player has been hacking the block for IHackableBlock.getHackTime(BlockGetter, BlockPos, Player) ticks, this will be called on both server and client side.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface me.desht.pneumaticcraft.api.pneumatic_armor.hacking.IHackableBlock

    fakeRayTrace
  • Constructor Details

    • HackableMobSpawner

      public HackableMobSpawner()
  • Method Details

    • getHackableId

      public net.minecraft.resources.ResourceLocation getHackableId()
      Description copied from interface: IHackableBlock
      Get a unique id to represent this hackable. Used in NBT saving to be able to trigger the afterHackTime after a server restart.

      The returned ResourceLocation should be in the namespace of the mod which adds the hack (which is not necessarily the mod that adds the hackable block).

      Specified by:
      getHackableId in interface IHackableBlock
      Returns:
      a unique ID for this hack type
    • canHack

      public boolean canHack(net.minecraft.world.level.BlockGetter level, net.minecraft.core.BlockPos pos, net.minecraft.world.level.block.state.BlockState state, net.minecraft.world.entity.player.Player player)
      Description copied from interface: IHackableBlock
      Can this block actually be hacked? This will normally return true, since the object is registered with the block, but this can be overridden to filter hackability by the actual blockstate (e.g Jukeboxes can only be hacked when they contain a music disc), or by some property of the player.

      Note that this can be called on both server and client.

      Specified by:
      canHack in interface IHackableBlock
      Parameters:
      level - the world
      pos - the block pos
      state - the blockstate at the given blockpos
      player - the player potentially hacking the block
    • isHacked

      public static boolean isHacked(net.minecraft.world.level.BlockGetter world, net.minecraft.core.BlockPos pos)
    • addInfo

      public void addInfo(net.minecraft.world.level.BlockGetter world, net.minecraft.core.BlockPos pos, List<net.minecraft.network.chat.Component> curInfo, net.minecraft.world.entity.player.Player player)
      Description copied from interface: IHackableBlock
      Add info that is displayed on the block tracker panel, describing what the hack would do to the block. This is only called when IHackableBlock.canHack(BlockGetter, BlockPos, BlockState, Player) has returned true. Keep this message short; one short phrase is enough.
      Specified by:
      addInfo in interface IHackableBlock
      Parameters:
      world - the world
      pos - the block pos of the to-be-hacked block
      curInfo - text component list to add info to
      player - the player observing the hackable block
    • addPostHackInfo

      public void addPostHackInfo(net.minecraft.world.level.BlockGetter world, net.minecraft.core.BlockPos pos, List<net.minecraft.network.chat.Component> curInfo, net.minecraft.world.entity.player.Player player)
      Description copied from interface: IHackableBlock
      Add info that is displayed on the block tracker panel, describing what the hack has done to the block. This is displayed for a second or so after the hack completes. Keep this message short; one short phrase is enough.
      Specified by:
      addPostHackInfo in interface IHackableBlock
      Parameters:
      world - the world
      pos - the block pos of the hacked block
      curInfo - text component list to add info to
      player - the player observing the hacked block
    • getHackTime

      public int getHackTime(net.minecraft.world.level.BlockGetter world, net.minecraft.core.BlockPos pos, net.minecraft.world.entity.player.Player player)
      Description copied from interface: IHackableBlock
      Get the time it takes to hack this block in ticks. For more powerful hacks, a longer hacking time is recommended.
      Specified by:
      getHackTime in interface IHackableBlock
      Parameters:
      world - the world
      pos - the block pos
      player - the player observing the hackable block
    • onHackComplete

      public void onHackComplete(net.minecraft.world.level.Level world, net.minecraft.core.BlockPos pos, net.minecraft.world.entity.player.Player player)
      Description copied from interface: IHackableBlock
      When the player has been hacking the block for IHackableBlock.getHackTime(BlockGetter, BlockPos, Player) ticks, this will be called on both server and client side.
      Specified by:
      onHackComplete in interface IHackableBlock
      Parameters:
      world - the world
      pos - the block pos
      player - the player observing the hacked block
    • afterHackTick

      public boolean afterHackTick(net.minecraft.world.level.BlockGetter world, net.minecraft.core.BlockPos pos)
      Description copied from interface: IHackableBlock
      Called every tick after the hack completed. Return false for one-shot hacks, or true to keep this hack ticking. Most hacks are fine as one-shot hacks.
      Specified by:
      afterHackTick in interface IHackableBlock
      Parameters:
      world - the world
      pos - the block pos
      Returns:
      true to keep the hack running (e.g. mob spawners), or false for one-shot hacks (e.g. levers/doors)