public class LuaEntity
extends java.lang.Object
Constructor and Description |
---|
LuaEntity() |
Modifier and Type | Method and Description |
---|---|
static AnyDeathListener |
addAnyDeathListener(LuaClosure closure)
Adds a listener which is triggered when any entity dies.
|
DeathListener |
addDeathListener(Entity entity,
LuaClosure closure)
Adds a listener which is triggered when the entity dies.
|
DisposeListener |
addDisposeListener(Entity entity,
LuaClosure closure)
Adds a listener which is triggered when the entity is disposed.
|
static void |
addInventoryItems(Entity entity,
LuaTable inventoryTable) |
static void |
delete(Entity entity)
Deletes the provided entity without triggering kill effects.
|
static void |
die(Entity entity)
Immediately kill the provided entity.
|
static void |
dispose() |
static int |
getDepth(PhysicalEntity physicalEntity)
Returns the entity depth in meters below surface level.
|
static LuaTable |
getEntities()
Returns all the entities
|
static LuaTable |
getEntitiesByType(java.lang.String type)
Returns all the entities by type
|
static LuaTable |
getEntitiesOfTypeInRange(Entity entity,
java.lang.String type,
float range)
Returns a lua table of entities of a specific type within a range from this entity
|
static LuaTable |
getEntitiesOfTypeInRange(Vector2 worldPosition,
java.lang.String type,
float range,
PhysicalEntity ignoreEntity) |
static Entity |
getEntityById(int id) |
static float |
getNearestPlayer(Vector2 position)
Returns the distance to the nearest player
|
static Peer |
getPeer() |
static Entity |
getPlayer() |
static Vector2 |
getRandomBotSpawn(PhysicalEntity physicalEntity,
java.lang.String entityTypeToSpawn,
boolean allowUndergroundSpawn) |
static void |
hurt(Entity entity,
float damage)
Applies damage to an entity.
|
static boolean |
isA(Entity entity,
java.lang.String type)
Returns true if the entity is of the type provided.
|
static boolean |
isUnderground(PhysicalEntity physicalEntity) |
static PhysicalEntity |
prepareNewPhysicalEntity(java.lang.String type,
Vector2 position,
LuaTable inventoryTable) |
static void |
register(Entity entity)
Spawns the entity into the world.
|
static void |
setAI(Living living,
java.lang.String ai,
float viewRange) |
static void |
setBaseAI(Living living) |
static void |
setSheepAI(Living living) |
static void |
setZombieAI(Living living) |
static Entity |
spawnPhysicalEntity(java.lang.String type,
Vector2 position)
Spawns an entity into the level
|
static Entity |
spawnPhysicalEntity(java.lang.String type,
Vector2 position,
LuaTable inventoryTable) |
static Entity |
spawnPhysicalEntity(java.lang.String type,
Vector2 position,
LuaTable inventoryTable,
Peer peer)
Spawns an entity into the level
|
static Entity |
spawnPhysicalEntityLuaPeer(java.lang.String type,
Vector2 position,
LuaTable inventoryTable,
Peer peer) |
static Shop |
spawnShop(Vector2 position,
Vector2 size,
LuaTable inventoryTable,
boolean hasInfiniteSupply,
boolean receivesPayments,
java.lang.String title)
Spawns a shop into the level
|
static void |
updateSkin(Peer peer,
PhysicalEntity physicalEntity) |
public static Entity spawnPhysicalEntity(java.lang.String type, Vector2 position)
type
- A string such as "Player", "Sheep", "Zombie"position
- Where the entity is spawnedpublic static Entity spawnPhysicalEntity(java.lang.String type, Vector2 position, LuaTable inventoryTable)
public static Entity spawnPhysicalEntityLuaPeer(java.lang.String type, Vector2 position, LuaTable inventoryTable, Peer peer)
public static Entity spawnPhysicalEntity(java.lang.String type, Vector2 position, LuaTable inventoryTable, Peer peer)
type
- A string such as "Player", "Sheep", "Zombie"position
- Where the entity is spawnedinventoryTable
- Provide a custom inventorypublic static void updateSkin(Peer peer, PhysicalEntity physicalEntity)
public static Shop spawnShop(Vector2 position, Vector2 size, LuaTable inventoryTable, boolean hasInfiniteSupply, boolean receivesPayments, java.lang.String title)
position
- Where the shop is spawnedsize
- The size of the shopinventoryTable
- The inventory of the shophasInfiniteSupply
- If the shop has an infinite supply or notreceivesPayments
- If the shop receives payments from buyers or nottitle
- Title of the shoppublic static PhysicalEntity prepareNewPhysicalEntity(java.lang.String type, Vector2 position, LuaTable inventoryTable) throws ReflectionException
ReflectionException
public static void register(Entity entity)
entity
- public static void addInventoryItems(Entity entity, LuaTable inventoryTable)
public static AnyDeathListener addAnyDeathListener(LuaClosure closure)
closure
- The callback function to be triggered upon an entity death. The first argument passed will be the entity who killed this entity, if applicable, the second argument is the victim.public DeathListener addDeathListener(Entity entity, LuaClosure closure)
closure
- The callback function to be triggered upon the entity death. The first argument passed will be the entity who killed this entity, if applicable.public DisposeListener addDisposeListener(Entity entity, LuaClosure closure)
closure
- The callback function to be triggered upon the entity disposal.public static void setZombieAI(Living living)
public static void setSheepAI(Living living)
public static void setBaseAI(Living living)
public static void setAI(Living living, java.lang.String ai, float viewRange)
public static void dispose()
public static LuaTable getEntities()
public static Peer getPeer()
public static Entity getPlayer()
public static LuaTable getEntitiesByType(java.lang.String type)
public static Entity getEntityById(int id)
id
- public static boolean isA(Entity entity, java.lang.String type)
type
- public static LuaTable getEntitiesOfTypeInRange(Entity entity, java.lang.String type, float range) throws ReflectionException
type
- The entity typerange
- The max rangeReflectionException
public static LuaTable getEntitiesOfTypeInRange(Vector2 worldPosition, java.lang.String type, float range, PhysicalEntity ignoreEntity) throws ReflectionException
ReflectionException
public static Vector2 getRandomBotSpawn(PhysicalEntity physicalEntity, java.lang.String entityTypeToSpawn, boolean allowUndergroundSpawn)
public static boolean isUnderground(PhysicalEntity physicalEntity)
public static int getDepth(PhysicalEntity physicalEntity)
physicalEntity
- public static void die(Entity entity)
entity
- public static void delete(Entity entity)
entity
- public static void hurt(Entity entity, float damage)
entity
- damage
- public static float getNearestPlayer(Vector2 position)
position
- The position to check against