Client and backend. This class is shared: the same code is compiled into your app and into your server, so everything on this page works in both.
public abstract class BlockEntity
- Object
- LevelEntity
- BlockEntity
Known subtypesCrumbleBlock, Door, Gate, PushBlock
Base for entities that are made of solid tiles which come and go: doors, gates
and crumbling blocks. The rectangle must be aligned to whole tiles.
Constructors
protected BlockEntity(String id, String type, int x, int y, int w, int h) | Creates a block. |
Methods
public int getTouchMargin() | How far outside its rectangle the entity still counts as touched. |
public boolean isSolid() | Whether the block’s cells are currently solid. |
protected boolean setSolid(PlatformWorld world, boolean s) | Makes the cells solid or empty. |
public long hashState(long h) | Mixes the entity’s play-relevant state into a hash. |
Inherited fields
From LevelEntity
Inherited methods
From LevelEntity
getId, getType, isActive, deactivate, getPhase, onAdded, step, onTouch
Constructor details
BlockEntity
protected BlockEntity(String id, String type, int x, int y, int w, int h)Creates a block.
Parameters
idString- the id
typeString- the kind
xint- left, fixed point, on a tile edge
yint- top, fixed point, on a tile edge
wint- width, fixed point, whole tiles
hint- height, fixed point, whole tiles
Method details
getTouchMargin
public int getTouchMargin()How far outside its rectangle the entity still counts as touched. An entity
that writes solid cells (a door) needs a margin, since an actor can never
overlap a solid cell. The default is 0.
Returns
the margin, fixed point
isSolid
public boolean isSolid()Whether the block’s cells are currently solid.
Returns
true while solid
setSolid
protected boolean setSolid(PlatformWorld world, boolean s)Makes the cells solid or empty. Becoming solid waits while an actor is
inside, so nobody is ever trapped in a wall.
Parameters
worldPlatformWorld- the world
sboolean- true for solid
Returns
true if the cells now match
shashState
public long hashState(long h)Mixes the entity’s play-relevant state into a hash. The default mixes the
position and whether it is active.
Parameters
hlong- the running hash
Returns
the updated hash