All Implemented Interfaces:
MovementListener, TurnListener, ZoneEnterExitListener, Killer, Cloneable, Iterable<String>, Serializable

public class Block extends ActiveEntity implements ZoneEnterExitListener, MovementListener, TurnListener
A solid, movable block on a map. It can have different apearances, for example a farm cart.
Author:
madmetzger
  • Constructor Details

    • Block

      public Block(boolean multiPush)
      Create a new Block with default style at (startX, startY)
      Parameters:
      startX - initial x-coordinate
      startY - initial y-coordinate
      multiPush - is pushing multiple times allowed
    • Block

      public Block(boolean multiPush, String style)
      Parameters:
      multiPush -
      style -
    • Block

      public Block(boolean multiPush, String style, String shape)
    • Block

      public Block(boolean multiPush, String style, String shape, List<String> sounds)
      Create a new block at startX, startY with a different style at client side
      Parameters:
      startX - initial x-coordinate
      startY - initial y-coordinate
      multiPush - is pushing multiple times allowed
      style - what style should the client use?
      shape -
      sounds - what sounds should be played on push?
  • Method Details

    • generateRPClass

      public static void generateRPClass()
    • reset

      public void reset()
      Resets the block position to its initial state
    • push

      public void push(Player p, Direction d)
      Push this Block into a given direction
      Parameters:
      p -
      d - the direction, this block is pushed into
    • setResetBlock

      public void setResetBlock(boolean resetBlock)
      should the block reset to its original position after some time?
      Parameters:
      resetBlock - true, if the block should be reset; false otherwise
    • getYAfterPush

      public int getYAfterPush(Direction d)
    • getXAfterPush

      public int getXAfterPush(Direction d)
    • getShape

      public String getShape()
      Get the shape of this Block
      Returns:
      the shape or null if this Block has no shape
    • onEntered

      public void onEntered(ActiveEntity entity, StendhalRPZone zone, int newX, int newY)
      Description copied from interface: MovementListener
      Invoked when an entity enters the object area.
      Specified by:
      onEntered in interface MovementListener
      Parameters:
      entity - The entity that moved.
      zone - The new zone.
      newX - The new X coordinate.
      newY - The new Y coordinate.
    • onExited

      public void onExited(ActiveEntity entity, StendhalRPZone zone, int oldX, int oldY)
      Description copied from interface: MovementListener
      Invoked when an entity leaves the object area.
      Specified by:
      onExited in interface MovementListener
      Parameters:
      entity - The entity that entered.
      zone - The old zone.
      oldX - The old X coordinate.
      oldY - The old Y coordinate.
    • onMoved

      public void onMoved(ActiveEntity entity, StendhalRPZone zone, int oldX, int oldY, int newX, int newY)
      Description copied from interface: MovementListener
      Invoked when an entity moves while over the object area.
      Specified by:
      onMoved in interface MovementListener
      Parameters:
      entity - The entity that left.
      zone - The zone.
      oldX - The old X coordinate.
      oldY - The old Y coordinate.
      newX - The new X coordinate.
      newY - The new Y coordinate.
    • onEntered

      public void onEntered(RPObject object, StendhalRPZone zone)
      Description copied from interface: ZoneEnterExitListener
      Invoked when an entity enters the object area.
      Specified by:
      onEntered in interface ZoneEnterExitListener
      Parameters:
      object - The object that entered.
      zone - The new zone.
    • onExited

      public void onExited(RPObject object, StendhalRPZone zone)
      Description copied from interface: ZoneEnterExitListener
      Invoked when an entity leaves the object area.
      Specified by:
      onExited in interface ZoneEnterExitListener
      Parameters:
      object - The object that exited.
      zone - The zone that was exited.
    • isObstacle

      public boolean isObstacle(Entity entity)
      Description copied from class: Entity
      Determine if this is an obstacle for another entity.
      Overrides:
      isObstacle in class Entity
      Parameters:
      entity - The entity to check against.
      Returns:
      true if very high resistance.
    • beforeMove

      public void beforeMove(ActiveEntity entity, StendhalRPZone zone, int oldX, int oldY, int newX, int newY)
      Description copied from interface: MovementListener
      Invoked before an entity moves while over the object area.
      Specified by:
      beforeMove in interface MovementListener
      Parameters:
      entity - The entity that left.
      zone - The zone.
      oldX - The old X coordinate.
      oldY - The old Y coordinate.
      newX - The new X coordinate.
      newY - The new Y coordinate.
    • onTurnReached

      public void onTurnReached(int currentTurn)
      Description copied from interface: TurnListener
      This method is called when the turn number is reached.
      Specified by:
      onTurnReached in interface TurnListener
      Parameters:
      currentTurn - current turn number
    • onAdded

      public void onAdded(StendhalRPZone zone)
      Description copied from class: ActiveEntity
      Called when this object is added to a zone.
      Overrides:
      onAdded in class ActiveEntity
      Parameters:
      zone - The zone this was added to.
    • onRemoved

      public void onRemoved(StendhalRPZone zone)
      Description copied from class: ActiveEntity
      Called when this object is removed from a zone.
      Overrides:
      onRemoved in class ActiveEntity
      Parameters:
      zone - The zone this was removed from.