Player - AndrewImalion/ModPE-Docs GitHub Wiki
This is a detailed documentation of the Player functions
###addItemCreativeInv
function Player.addItemCreativeInv(id, count, damage);
- No information available
###addItemInventory
function Player.addItemInventory(id, count, damage);
- No information available
###clearInventorySlot
function Player.clearInventorySlot(slot);
- No information available
###getArmorSlot
function Player.getArmorSlot(slot);
- No information available
###getArmorSlotDamage
function Player.getArmorSlotDamage(slot);
- No information available
###getCarriedItem
function Player.getCarriedItem();
- No information available
###getCarriedItemCount
function Player.getCarriedItemCount();
- No information available
###getCarriedItemData
function Player.getCarriedItemData();
- No information available
###getEntity
function Player.getEntity();
- No information available
###getInventorySlot
function Player.getInventorySlot(slot);
- No information available
###getInventorySlotCount
function Player.getInventorySlotCount(slot);
- No information available
###getInventorySlotData
function Player.getInventorySlotData(slot);
- No information available
###getName
function Player.getName(playerName);
- No information available
###getSelectedSlotId
function Player.getSelectedSlotId();
- No information available
###getX
function Player.getX();
- No information available
###getY
function Player.getY();
- No information available
###getZ
function Player.getZ();
- No information available
###isPlayer
function Player.isPlayer(entity);
- No information available
###setArmorSlot
function Player.setArmorSlot(slot, id, damage);
- No information available
###setHealth
function Player.setHealth(health);
- No information available
###setInventorySlot
function Player.setInventorySlot(slot, itemId, count, damage)
- Sets the contents of the player's specified inventory slot.
Example:
Player.setInventorySlot(Player.getSelectedSlotId(), 256 /* iron shovel */, 1, 0);
###enchant
function Player.enchant(slot, enchantment, level)
- Tries to add an enchantment to the item held in
slot. Returns true if the enchantment is added; false if the enchantment is incompatible with the item in the slot.
Example:
if (Player.enchant(Player.getSelectedSlotId(), Enchantment.EFFICIENCY, 1)) {
clientMessage("Added Efficiency:1 enchantment to currently held item");
} else {
clientMessage("Failed to add Efficiency:1 enchantment. You can only apply Efficiency to shovels.");
}
List of enchantments:
- Enchantment.PROTECTION
- Enchantment.FIRE_PROTECTION
- Enchantment.FEATHER_FALLING
- Enchantment.BLAST_PROTECTION
- Enchantment.PROJECTILE_PROTECTION
- Enchantment.THORNS
- Enchantment.RESPIRATION
- Enchantment.AQUA_AFFINITY
- Enchantment.DEPTH_STRIDER
- Enchantment.SHARPNESS
- Enchantment.SMITE
- Enchantment.BANE_OF_ARTHROPODS
- Enchantment.KNOCKBACK
- Enchantment.FIRE_ASPECT
- Enchantment.LOOTING
- Enchantment.EFFICIENCY
- Enchantment.SILK_TOUCH
- Enchantment.UNBREAKING
- Enchantment.FORTUNE
- Enchantment.POWER
- Enchantment.PUNCH
- Enchantment.FLAME
- Enchantment.INFINITY
- Enchantment.LUCK_OF_THE_SEA
- Enchantment.LURE
###getEnchantments
function Player.getEnchantments(slot)
- Returns an array of the enchantments on the item in the slot, or null if there is no item in that slot.
- Each item contains two attributes: type (equal to one of the Enchantment.* constants) and level (the level of the enchantment)
Example:
var enchants = Player.getEnchantments(Player.getSelectedSlotId());
if (enchants == null) {
clientMessage("Hey, you're not holding anything!");
} else {
for (var i = 0; i < enchants.length; i++) {
if (enchants[i].type == Enchantment.FIRE_ASPECT && enchants[i].level == 1) {
clientMessage("You're holding something with fire aspect level 1");
}
}
}
###getItemCustomName
function Player.getItemCustomName(slot)
- Returns the custom name of the item in the specified slot of the player's inventory, or null if there is no custom name set on the item.
Example:
clientMessage(Player.getItemCustomName(Player.getSelectedSlotId());
###setItemCustomName
function Player.setItemCustomName(slot, name)
- Sets a custom name on the item in the specified slot of the player's inventory.
Example:
Player.setItemCustomItem(Player.getSelectedSlotId(), "Ultimate Sword of Ultimate Destiny");
Player.addItemCreativeInv(id, count, damage);
Player.addItemInventory(id, count, damage);
Player.clearInventorySlot(slot);
Player.getArmorSlot(slot);
Player.getArmorSlotDamage(slot);
Player.getCarriedItem();
Player.getCarriedItemCount();
Player.getCarriedItemData();
Player.getEntity();
Player.getInventorySlot(slot);
Player.getInventorySlotCount(slot);
Player.getInventorySlotData(slot);
Player.getName(playerName);
Player.getSelectedSlotId();
Player.getX();
Player.getY();
Player.getZ();
Player.isPlayer(entity);
Player.setArmorSlot(slot, id, damage);
Player.setHealth(health);