Class Block
java.lang.Object
marauroa.common.game.Attributes
marauroa.common.game.SlotOwner
marauroa.common.game.RPObject
games.stendhal.server.entity.Entity
games.stendhal.server.entity.ActiveEntity
games.stendhal.server.entity.mapstuff.block.Block
- 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
-
Nested Class Summary
Nested classes/interfaces inherited from class marauroa.common.game.RPObject
RPObject.ID
-
Field Summary
Fields inherited from class marauroa.common.game.RPObject
INVALID_ID
-
Constructor Summary
ConstructorDescriptionBlock(boolean multiPush)
Create a new Block with default style at (startX, startY)Create a new block at startX, startY with a different style at client side -
Method Summary
Modifier and TypeMethodDescriptionvoid
beforeMove(ActiveEntity entity, StendhalRPZone zone, int oldX, int oldY, int newX, int newY)
Invoked before an entity moves while over the object area.static void
getShape()
Get the shape of this Blockint
int
boolean
isObstacle(Entity entity)
Determine if this is an obstacle for another entity.void
onAdded(StendhalRPZone zone)
Called when this object is added to a zone.void
onEntered(ActiveEntity entity, StendhalRPZone zone, int newX, int newY)
Invoked when an entity enters the object area.void
onEntered(RPObject object, StendhalRPZone zone)
Invoked when an entity enters the object area.void
onExited(ActiveEntity entity, StendhalRPZone zone, int oldX, int oldY)
Invoked when an entity leaves the object area.void
onExited(RPObject object, StendhalRPZone zone)
Invoked when an entity leaves the object area.void
onMoved(ActiveEntity entity, StendhalRPZone zone, int oldX, int oldY, int newX, int newY)
Invoked when an entity moves while over the object area.void
onRemoved(StendhalRPZone zone)
Called when this object is removed from a zone.void
onTurnReached(int currentTurn)
This method is called when the turn number is reached.void
Push this Block into a given directionvoid
reset()
Resets the block position to its initial statevoid
setResetBlock(boolean resetBlock)
should the block reset to its original position after some time?Methods inherited from class games.stendhal.server.entity.ActiveEntity
applyMovement, canMoveTo, canMoveTo, faceto, faceToward, getDirection, getDirectionToward, getDirectionToward, getResistance, getSpeed, getStepsTaken, handleLeaveZone, handleObjectCollision, handlePortal, handleSimpleCollision, ignoresCollision, isFacingToward, isGhost, isMoveCompleted, isZoneChangeAllowed, move, onMoved, setDirection, setIgnoresCollision, setSpeed, stop, stopped, update
Methods inherited from class games.stendhal.server.entity.Entity
describe, getAdjacentNodes, getArea, getArea, getCursor, getDescription, getDescriptionName, getEntitySlot, getHeight, getName, getOrigin, getResistance, getTitle, getWidth, getX, getY, getZone, hasDescription, isInSight, nextTo, nextTo, notifyWorldAboutChanges, setCursor, setDescription, setEntityClass, setEntitySubclass, setMenu, setPosition, setResistance, setSize, setVisibility, slotIterator, slots, squaredDistance, squaredDistance
Methods inherited from class marauroa.common.game.RPObject
addEvent, addLink, addLink, addMap, addSlot, addSlot, applyDifferences, clearEvents, clearVisible, clone, containsKey, equals, events, eventsIterator, fill, get, getBaseContainer, getBoolean, getContainer, getContainerBaseOwner, getContainerOwner, getContainerSlot, getDifferences, getDouble, getFromSlots, getID, getInt, getLink, getLinkedObject, getMap, getSlot, has, hashCode, hasLink, hasMap, hasSlot, hide, isContained, isEmpty, isHidden, isStorable, maps, put, put, put, put, readObject, remove, removeLink, removeMap, removeSlot, resetAddedAndDeleted, resetAddedAndDeletedMaps, resetAddedAndDeletedRPLink, resetAddedAndDeletedRPSlot, setAddedMaps, setAddedRPSlot, setContainer, setDeletedMaps, setDeletedRPSlot, setID, size, slots, slotsIterator, store, toString, unhide, unstore, writeObject, writeObject, writeToJson
Methods inherited from class marauroa.common.game.SlotOwner
deserializeRPSlots, fill, serializeRPSlots
Methods inherited from class marauroa.common.game.Attributes
add, applyDifferences, get, getBool, getDouble, getInt, getList, getLong, getRPClass, has, instanceOf, iterator, put, put, put, put, put, readFromMap, remove, resetAddedAndDeletedAttributes, setAddedAttributes, setDeletedAttributes, setRPClass, setRPClass, toAttributeString
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
Methods inherited from interface games.stendhal.server.core.events.MovementListener
getArea
-
Constructor Details
-
Block
public Block(boolean multiPush)Create a new Block with default style at (startX, startY)- Parameters:
startX
- initial x-coordinatestartY
- initial y-coordinatemultiPush
- is pushing multiple times allowed
-
Block
- Parameters:
multiPush
-style
-
-
Block
-
Block
Create a new block at startX, startY with a different style at client side- Parameters:
startX
- initial x-coordinatestartY
- initial y-coordinatemultiPush
- is pushing multiple times allowedstyle
- 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
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
-
getXAfterPush
-
getShape
Get the shape of this Block- Returns:
- the shape or null if this Block has no shape
-
onEntered
Description copied from interface:MovementListener
Invoked when an entity enters the object area.- Specified by:
onEntered
in interfaceMovementListener
- Parameters:
entity
- The entity that moved.zone
- The new zone.newX
- The new X coordinate.newY
- The new Y coordinate.
-
onExited
Description copied from interface:MovementListener
Invoked when an entity leaves the object area.- Specified by:
onExited
in interfaceMovementListener
- 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 interfaceMovementListener
- 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
Description copied from interface:ZoneEnterExitListener
Invoked when an entity enters the object area.- Specified by:
onEntered
in interfaceZoneEnterExitListener
- Parameters:
object
- The object that entered.zone
- The new zone.
-
onExited
Description copied from interface:ZoneEnterExitListener
Invoked when an entity leaves the object area.- Specified by:
onExited
in interfaceZoneEnterExitListener
- Parameters:
object
- The object that exited.zone
- The zone that was exited.
-
isObstacle
Description copied from class:Entity
Determine if this is an obstacle for another entity.- Overrides:
isObstacle
in classEntity
- 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 interfaceMovementListener
- 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 interfaceTurnListener
- Parameters:
currentTurn
- current turn number
-
onAdded
Description copied from class:ActiveEntity
Called when this object is added to a zone.- Overrides:
onAdded
in classActiveEntity
- Parameters:
zone
- The zone this was added to.
-
onRemoved
Description copied from class:ActiveEntity
Called when this object is removed from a zone.- Overrides:
onRemoved
in classActiveEntity
- Parameters:
zone
- The zone this was removed from.
-