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

  1. Object
  2. LevelEntity
  3. 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

x, y, w, h

Inherited methods

Constructor details

BlockEntity

protected BlockEntity(String id, String type, int x, int y, int w, int h)
Creates a block.

Parameters

id String
the id
type String
the kind
x int
left, fixed point, on a tile edge
y int
top, fixed point, on a tile edge
w int
width, fixed point, whole tiles
h int
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

world PlatformWorld
the world
s boolean
true for solid

Returns

true if the cells now match s

hashState

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

h long
the running hash

Returns

the updated hash