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 particleTypeint the particle type
blockXdouble the block's x coordinate
blockYdouble the block's y coordinate
blockZdouble the block's z coordinate
velocityXdouble particle velocity along the x axis
velocityYdouble particle velocity along the y axis
velocityZdouble particle velocity along the z axis
sizeint 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
radiuswith the center located at the specifiedx,yandzcoordinates.Name Type Description xdouble the x coordinate
ydouble the y coordinate
zdouble the z coordinate
radiusdouble the radius
hasFireboolean 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, andzcoordinatesName Type Description xdouble the x coordinate
ydouble the y coordinate
zdouble 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 leveldouble The lighting level?
-
staticLevel.setNightMode(
) -
-
staticLevel.setRainLevel(
level) -
BL 1.10.4-beta
Name Type Description leveldouble 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, andzcoordinates using the specifiedskinimage.Name Type Description xdouble the x coordinate
ydouble the y coordinate
zdouble the z coordinate
skinstring the skin image path (usually an image found in the
../assets/imagesfolder of the MCPE apk)Returns:
Type Description long - the native entity ID of the spawned mob
Example
credit: 'Treebl' via Zhuowei Zhang
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, andzcoordinates using the specifiedskinimage.Name Type Description xdouble the x coordinate
ydouble the y coordinate
zdouble the z coordinate
skinstring the skin image path (usually an image found in the
../assets/imagesfolder of the MCPE apk)Returns:
Type Description long - the native entity ID of the spawned mob
Example
credit: 'Treebl' via Zhuowei Zhang
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
idat the givenx,y, andzcoordinates using the specifiedskinimage.Name Type Description xdouble the x coordinate
ydouble the y coordinate
zdouble the z coordinate
idint the entity ID (see: EntityType)
skinstring the skin image path (an image found in the
../assets/imagesfolder of the MCPE apk)Example
// spawn a skeleton Level.spawnMob(152, 48, 73, EntityType.SKELETON, "mob/skeleton.png");