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
ConstructorsConstructorDescriptionBlock(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 TypeMethodDescriptionvoidbeforeMove(ActiveEntity entity, StendhalRPZone zone, int oldX, int oldY, int newX, int newY) Invoked before an entity moves while over the object area.static voidgetShape()Get the shape of this BlockintintbooleanisObstacle(Entity entity) Determine if this is an obstacle for another entity.voidonAdded(StendhalRPZone zone) Called when this object is added to a zone.voidonEntered(ActiveEntity entity, StendhalRPZone zone, int newX, int newY) Invoked when an entity enters the object area.voidonEntered(RPObject object, StendhalRPZone zone) Invoked when an entity enters the object area.voidonExited(ActiveEntity entity, StendhalRPZone zone, int oldX, int oldY) Invoked when an entity leaves the object area.voidonExited(RPObject object, StendhalRPZone zone) Invoked when an entity leaves the object area.voidonMoved(ActiveEntity entity, StendhalRPZone zone, int oldX, int oldY, int newX, int newY) Invoked when an entity moves while over the object area.voidonRemoved(StendhalRPZone zone) Called when this object is removed from a zone.voidonTurnReached(int currentTurn) This method is called when the turn number is reached.voidPush this Block into a given directionvoidreset()Resets the block position to its initial statevoidsetResetBlock(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, updateMethods 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, squaredDistanceMethods 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, writeToJsonMethods inherited from class marauroa.common.game.SlotOwner
deserializeRPSlots, fill, serializeRPSlotsMethods 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, toAttributeStringMethods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliteratorMethods 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:MovementListenerInvoked when an entity enters the object area.- Specified by:
onEnteredin 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:MovementListenerInvoked when an entity leaves the object area.- Specified by:
onExitedin 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:MovementListenerInvoked when an entity moves while over the object area.- Specified by:
onMovedin 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:ZoneEnterExitListenerInvoked when an entity enters the object area.- Specified by:
onEnteredin interfaceZoneEnterExitListener- Parameters:
object- The object that entered.zone- The new zone.
-
onExited
Description copied from interface:ZoneEnterExitListenerInvoked when an entity leaves the object area.- Specified by:
onExitedin interfaceZoneEnterExitListener- Parameters:
object- The object that exited.zone- The zone that was exited.
-
isObstacle
Description copied from class:EntityDetermine if this is an obstacle for another entity.- Overrides:
isObstaclein classEntity- Parameters:
entity- The entity to check against.- Returns:
trueif very high resistance.
-
beforeMove
public void beforeMove(ActiveEntity entity, StendhalRPZone zone, int oldX, int oldY, int newX, int newY) Description copied from interface:MovementListenerInvoked before an entity moves while over the object area.- Specified by:
beforeMovein 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:TurnListenerThis method is called when the turn number is reached.- Specified by:
onTurnReachedin interfaceTurnListener- Parameters:
currentTurn- current turn number
-
onAdded
Description copied from class:ActiveEntityCalled when this object is added to a zone.- Overrides:
onAddedin classActiveEntity- Parameters:
zone- The zone this was added to.
-
onRemoved
Description copied from class:ActiveEntityCalled when this object is removed from a zone.- Overrides:
onRemovedin classActiveEntity- Parameters:
zone- The zone this was removed from.
-