Static methods for the Level API
Methods
-
staticLevel.addParticle(
particleType, blockX, blockY, blockZ, velocityX, velocityY, velocityZ, size
) -
add particle effects to a block
Name Type Description particleType
int the particle type
blockX
double the block's x coordinate
blockY
double the block's y coordinate
blockZ
double the block's z coordinate
velocityX
double particle velocity along the x axis
velocityY
double particle velocity along the y axis
velocityZ
double particle velocity along the z axis
size
int the particle size (smoke and ink require 100 or greater; itemBreak requires 256 or greater)
Example
// add hearts to the block you're looking at var x = Player.getPointedBlockX(); var y = Player.getPointedBlockY(); var z = Player.getPointedBlockZ(); Level.addParticle(ParticleType.heart, x, y, z, 0, 0, 0, 1);
-
staticLevel.biomeIdToName(
)
-
-
staticLevel.canSeeSky(
)
-
-
staticLevel.destroyBlock(
)
-
-
staticLevel.dropItem(
){long}
-
Returns:
Type Description long -
staticLevel.explode(
x, y, z, radius, hasFire
) -
Cause an explosion of the specified
radius
with the center located at the specifiedx
,y
andz
coordinates.Name Type Description x
double the x coordinate
y
double the y coordinate
z
double the z coordinate
radius
double the radius
hasFire
boolean if true the explosion produces fire, false otherwise
Example
// underground nuclear warhead testing Level.explode(127, 8, 45, 256, false);
-
staticLevel.getAddress(
){Object}
-
THIS THROWS AN ERROR ON ANDROID; IS IT iOS ONLY???_
Returns:
Type Description Object unknown
- figure out what this does
-
staticLevel.getBiome(
)
-
-
staticLevel.getBiomeName(
)
-
-
staticLevel.getBrightness(
)
-
-
staticLevel.getChestSlot(
)
-
-
staticLevel.getChestSlotCount(
)
-
-
staticLevel.getChestSlotData(
)
-
-
staticLevel.getData(
)
-
-
staticLevel.getFurnaceSlot(
)
-
-
staticLevel.getFurnaceSlotCount(
)
-
-
staticLevel.getFurnaceSlotData(
)
-
-
staticLevel.getGameMode(
)
-
-
staticLevel.getGrassColor(
)
-
-
staticLevel.getLightningLevel(
)
-
-
staticLevel.getRainLevel(
)
-
-
staticLevel.getSignText(
)
-
-
staticLevel.getSpawnerEntityType(
)
-
-
staticLevel.getTile(
x, y, z
){int} -
return the id of the block located at the specified
x
,y
, andz
coordinatesName Type Description x
double the x coordinate
y
double the y coordinate
z
double the z coordinate
Returns:
Type Description int - the block id
Example
// what did I just step in? function modTick() { var x = Player.getX(); var y = Player.getY() - 2; // -2 = feet, not head var z = Player.getZ(); var tileId = Level.getTile(x, y, z); if (tileId > 0 && tileId < 256) { var poo = Item.getName(tileId, 0, false); ModPE.showTipMessage("You just stepped in poo! (or " + poo + ")"); } }
-
staticLevel.getTime(
)
-
-
staticLevel.getWorldDir(
)
-
-
staticLevel.getWorldName(
)
-
-
staticLevel.playSound(
)
-
-
staticLevel.playSoundEnt(
)
-
-
staticLevel.setChestSlot(
)
-
-
staticLevel.setFurnaceSlot(
)
-
-
staticLevel.setGameMode(
)
-
-
staticLevel.setGrassColor(
)
-
-
staticLevel.setLightningLevel(
level
) -
BL 1.10.4-beta
Name Type Description level
double The lighting level?
-
staticLevel.setNightMode(
)
-
-
staticLevel.setRainLevel(
level
) -
BL 1.10.4-beta
Name Type Description level
double The rain level?
-
staticLevel.setSignText(
)
-
-
staticLevel.setSpawn(
)
-
-
staticLevel.setSpawnerEntityType(
)
-
-
staticLevel.setTile(
)
-
-
staticLevel.setTime(
)
-
-
staticLevel.spawnChicken(
x, y, z, skin
){long} -
Spawn a chicken entity at the specified
x
,y
, andz
coordinates using the specifiedskin
image.Name Type Description x
double the x coordinate
y
double the y coordinate
z
double the z coordinate
skin
string the skin image path (usually an image found in the
../assets/images
folder of the MCPE apk)Returns:
Type Description long - the native entity ID of the spawned mob
Example
var tb = false; function useItem(x, y, z, itemId, blockId, side) { if (itemId == 280 && !tb) { // if the item is a stick and items hasn't been initialized ModPE.setItem(392, "stick", 0, "Wand"); ModPE.setFoodItem(393, "cookie", 0, 5, "Cookie"); Player.addItemInventory(392, 5); Player.addItemInventory(393, 1); tb = true; } else if (itemId == 280) { // else: if the item is a stick Player.addItemInventory(392, 5); Player.addItemInventory(393, 1); } else if (itemId == 392) { // else: if the item is a wand Level.spawnChicken(x, y + 1, z, "mob/chicken.png"); } }
-
staticLevel.spawnCow(
x, y, z, skin
){long} -
Spawn a cow entity at the specified
x
,y
, andz
coordinates using the specifiedskin
image.Name Type Description x
double the x coordinate
y
double the y coordinate
z
double the z coordinate
skin
string the skin image path (usually an image found in the
../assets/images
folder of the MCPE apk)Returns:
Type Description long - the native entity ID of the spawned mob
Example
var tb = false; function useItem(x, y, z, itemId, blockId, side) { if (itemId == 280 && !tb) { // if the item is a stick and items hasn't been initialized ModPE.setItem(392, "stick", 0, "Wand"); ModPE.setFoodItem(393, "cookie", 0, 5, "Cookie"); Player.addItemInventory(392, 5); Player.addItemInventory(393, 1); tb = true; } else if (itemId == 280) { // else: if the item is a stick Player.addItemInventory(392, 5); Player.addItemInventory(393, 1); } else if (itemId == 392) { // else: if the item is a wand Level.spawnChicken(x, y + 1, z, "mob/cow.png"); } }
-
staticLevel.spawnMob(
x, y, z, id, skin
) -
Spawn a valid MCPE entity with the specified
id
at the givenx
,y
, andz
coordinates using the specifiedskin
image.Name Type Description x
double the x coordinate
y
double the y coordinate
z
double the z coordinate
id
int the entity ID (see: EntityType)
skin
string the skin image path (an image found in the
../assets/images
folder of the MCPE apk)Example
// spawn a skeleton Level.spawnMob(152, 48, 73, EntityType.SKELETON, "mob/skeleton.png");