private static class BlockHostObject extends ScriptableObject {
private NativeEntity playerEnt = new NativeEntity(0);
@Override
public String getClassName() {
return "BlockHostObject";
}
@JSFunction
public void print(String str) {
scriptPrint(str);
}
@JSFunction
public double getPlayerX() {
return nativeGetPlayerLoc(AXIS_X);
}
@JSFunction
public double getPlayerY() {
return nativeGetPlayerLoc(AXIS_Y);
}
@JSFunction
public double getPlayerZ() {
return nativeGetPlayerLoc(AXIS_Z);
}
@JSFunction
public NativeEntity getPlayerEnt() {
playerEnt.entityId = nativeGetPlayerEnt();
return playerEnt;
}
@JSFunction
public NativePointer getLevel() {
return new NativePointer(nativeGetLevel()); //TODO: WTF does this do?
}
@JSFunction
public void setPosition(NativeEntity ent, double x, double y, double z) {
nativeSetPosition(ent.entityId, (float) x, (float) y, (float) z);
}
//standard methods introduced in API level 0.3
@JSFunction
public double getPitch(NativeEntity ent) {
if (ent == null) ent = getPlayerEnt();
return nativeGetPitch(ent.entityId);
}
@JSFunction
public double getYaw(NativeEntity ent) {
if (ent == null) ent = getPlayerEnt();
return nativeGetYaw(ent.entityId);
}
//standard methods introduced in 0.4 and 0.5
@JSFunction
public NativeEntity spawnPigZombie(double x, double y, double z, int item, String tex) { //Textures not supported yet
if (invalidTexName(tex)) {
tex = "mob/pigzombie.png";
}
int entityId = nativeSpawnEntity((float) x, (float) y, (float) z, 36, tex);
nativeSetCarriedItem(entityId, item, 1, 0);
return new NativeEntity(entityId);
}
//nonstandard methods
@JSFunction
public NativeEntity bl_spawnMob(double x, double y, double z, int typeId, String tex) {
print("Nag: update to Level.spawnMob");
if (invalidTexName(tex)) {
tex = null;
}
int entityId = nativeSpawnEntity((float) x, (float) y, (float) z, typeId, tex);
return new NativeEntity(entityId);
}
@JSFunction
public void bl_setMobSkin(NativeEntity entity, String tex) {
print("Nag: update to Entity.setMobSkin");
nativeSetMobSkin(entity.entityId, tex);
}
}
private static class NativePointer extends ScriptableObject {
public long value;
public NativePointer(long value) {
this.value = value;
}
@Override
public String getClassName() {
return "NativePointer";
}
}
private static class NativeEntity extends ScriptableObject {
public int entityId;
public NativeEntity(int entityId) {
this.entityId = entityId;
}
@Override
public String getClassName() {
return "NativeEntity";
}
@Override
public boolean equals(Object obj) {
if (obj == this) return true;
if (obj instanceof NativeEntity) {
return ((NativeEntity) obj).entityId == this.entityId;
}
return false;
}
}
private static class NativeLevelApi extends ScriptableObject {
public NativeLevelApi() {
super();
}
@JSStaticFunction
public static void setNightMode(boolean isNight) {
nativeSetNightMode(isNight);
}
@JSStaticFunction
public static int getTile(int x, int y, int z) {
return nativeGetTile(x, y, z);
}
@JSStaticFunction
public static void explode(double x, double y, double z, double radius) {
nativeExplode((float) x, (float) y, (float) z, (float) radius);
}
@JSStaticFunction
public static void setTile(int x, int y, int z, int id) {
nativeSetTile(x, y, z, id, 0);
}
@JSStaticFunction
public static NativePointer getAddress() {
return new NativePointer(nativeGetLevel()); //TODO: I still don't know WTF this does.
}
@JSStaticFunction
public static NativeEntity spawnChicken(double x, double y, double z, String tex) { //Textures not supported
if (invalidTexName(tex)) {
tex = "mob/chicken.png";
}
int entityId = nativeSpawnEntity((float) x, (float) y, (float) z, 10, tex);
return new NativeEntity(entityId);
}
@JSStaticFunction
public static NativeEntity spawnCow(double x, double y, double z, String tex) { //Textures not supported
if (invalidTexName(tex)) {
tex = "mob/cow.png";
}
int entityId = nativeSpawnEntity((float) x, (float) y, (float) z, 11, tex);
return new NativeEntity(entityId);
}
//nonstandard methods
@JSStaticFunction
public static NativeEntity spawnMob(double x, double y, double z, int typeId, String tex) {
if (invalidTexName(tex)) {
tex = null;
}
int entityId = nativeSpawnEntity((float) x, (float) y, (float) z, typeId, tex);
return new NativeEntity(entityId);
}
//thanks to MrARM
@JSStaticFunction
public static int getData(int x, int y, int z) {
return nativeGetData(x, y, z);
}
@JSStaticFunction
public static String getWorldName() {
return worldName;
}
@JSStaticFunction
public static String getWorldDir() {
return worldDir;
}
@JSStaticFunction
public static void dropItem(double x, double y, double z, double range, int id, int count, int damage) {
nativeDropItem((float) x, (float) y, (float) z, (float)range, id, count, damage);
}
@JSStaticFunction
public static void setGameType(int type) {
nativeSetGameType(type);
}
@JSStaticFunction
public static int getGameType() {
return nativeGetGameType();
}
@JSStaticFunction
public static int getTime() {
return (int)nativeGetTime();
}
@JSStaticFunction
public static void setTime(int time) {
nativeSetTime((long)time);
}
@JSStaticFunction
public static void setSpawn(int x, int y, int z) {
nativeSetSpawn(x, y, z);
}
@JSStaticFunction
public static void destroyBlock(int x, int y, int z, boolean shouldDrop) {
int itmId = getTile(x, y, z);
int itmDmg = getData(x, y, z);
nativeDestroyBlock(x, y, z);
if(shouldDrop) dropItem(((double)x)+0.5, y, ((double)z)+0.5, 1, itmId, 1, itmDmg);
}
@JSStaticFunction
public static void setChestSlot(int x, int y, int z, int slot, int id, int damage, int amount) {
nativeAddItemChest(x, y, z, slot, id, damage, amount);
}
@JSStaticFunction
public static int getChestSlot(int x, int y, int z, int slot) {
return nativeGetItemChest(x, y, z, slot);
}
@JSStaticFunction
public static int getChestSlotData(int x, int y, int z, int slot) {
return nativeGetItemDataChest(x, y, z, slot);
}
@JSStaticFunction
public static int getChestSlotCount(int x, int y, int z, int slot) {
return nativeGetItemCountChest(x, y, z, slot);
}
@JSStaticFunction
public static void setCarriedItem(NativeEntity ent, int id, int count, int damage) {
nativeSetCarriedItem(ent.entityId, id, 1, damage);
}
@JSStaticFunction
public static int getEntityTypeId(NativeEntity ent) {
return nativeGetEntityTypeId(ent.entityId);
}
@JSStaticFunction
public static NativeEntity spawnMob(double x, double y, double z, int typeId, String tex) {
scriptPrint("Nag: update to Level.spawnMob");
if (invalidTexName(tex)) {
tex = null;
}
int entityId = nativeSpawnEntity((float) x, (float) y, (float) z, typeId, tex);
return new NativeEntity(entityId);
}
@JSStaticFunction
public static void setAnimalAge(NativeEntity animal, int age) {
nativeSetAnimalAge(animal.entityId, age);
}
@JSStaticFunction
public static int getAnimalAge(NativeEntity animal) {
return nativeGetAnimalAge(animal.entityId);
}
can we have a list of modIds for Entity.getEntityTypeId? And can you change it and related to Entity.getEnitityById because its easier to remember and getElementById is another method used in programming websites. hoping to upgrade to tree puncher!
Do anyone of you guys know how we can use these functions. My point is, for example, function getPlayerX() is not a function that i don't even created, and I want to know how you can use those functions if they are not even on your project/mod. Cause I know those functions are not internal. So if anyone of you guys know how this works please let me know.
Do anyone of you guys know how we can use these functions. My point is, for example, function getPlayerX() is not a function that i don't even created, and I want to know how you can use those functions if they are not even on your project/mod. Cause I know those functions are not internal. So if anyone of you guys know how this works please let me know.
No... no... no.
These functions are only internal if:
A. You have BlockLauncher (Android)
B. You have ModPE installed on you JailBroken iOS device
Afterwards, they are built-in. Don't believe me? Look at some scripts that people have created. The functions are not created in the Script but are already built-in.
Here's a really badly edited (And I do mean REALLY BADLY EDITED: I literally did a find-and-replace on the source to make it look more JavaScript-y) ModPE functions list:
function useItem(x, y, z, itemid, blockid, side, itemDamage, blockDamage);
function destroyBlock(x, y, z, side);
function newLevel(hasLevel);
function selectLevelHook()
function leaveGame()
function attackHook(new NativeEntity(attacker), new NativeEntity(victim));
function modTick()
function procCmd(str.substring(1));
function deathHook(attacker == -1? null: new NativeEntity(attacker), new NativeEntity(victim));
function entityRemovedHook(new NativeEntity(entity));
function entityAddedHook(new NativeEntity(entity));
function levelEventHook(new NativeEntity(player), eventType, x, y, z, data);
function blockEventHook(x, y, z, type, data);
print(str)
getPlayerX()
getPlayerY()
getPlayerZ()
getPlayerEnt()
getLevel()
setPosition(ent, x, y, z)
setVelX(ent, amount)
setVelY(ent, amount)
setVelZ(ent, amount)
explode(x, y, z, radius)
addItemInventory(id, amount, damage)
rideAnimal(/*Flynn*/rider, mount)
spawnChicken(x, y, z, tex)
spawnCow(x, y, z, tex)
getCarriedItem()
preventDefault()
setTile(x, y, z, id, damage)
clientMessage(text)
setNightMode(isNight)
getTile(x, y, z)
setPositionRelative(ent, x, y, z)
setRot(ent, yaw, pitch)
getPitch(ent)
getYaw(ent)
spawnPigZombie(x, y, z, item, tex)
bl_spawnMob(x, y, z, typeId, tex)
bl_setMobSkin(entity, tex)
Level.setNightMode(isNight)
Level.getTile(x, y, z)
Level.explode(x, y, z, radius)
Level.setTile(x, y, z, id, damage)
Level.getAddress()
Level.spawnChicken(x, y, z, tex)
Level.spawnCow(x, y, z, tex)
Level.spawnMob(x, y, z, typeId, tex)
Level.getSignText(x, y, z, line)
Level.setSignText(x, y, z, line, newText)
Level.getData(x, y, z)
Level.getWorldName()
Level.getWorldDir()
Level.dropItem(x, y, z, range, id, count, damage)
Level.setGameMode(type)
Level.getGameMode()
Level.getTime()
Level.setTime(time)
Level.setSpawn(x, y, z)
Level.destroyBlock(x, y, z, shouldDrop)
Level.setChestSlot(x, y, z, slot, id, damage, amount)
Level.getChestSlot(x, y, z, slot)
Level.getChestSlotData(x, y, z, slot)
Level.getChestSlotCount(x, y, z, slot)
Level.playSound(x, y, z, sound, volume, pitch)
Level.playSoundEnt(ent, sound, volume, pitch)
Level.extinguishFire(x, y, z, side)
Player.getX()
Player.getY()
Player.getZ()
Player.getEntity()
Player.getCarriedItem()
Player.addItemInventory(id, amount, damage)
Player.setHealth(value)
Player.getSelectedSlotId()
Player.clearInventorySlot(slot)
Player.getInventorySlot(slot)
Player.getInventorySlotData(slot)
Player.getInventorySlotCount(slot)
Player.getCarriedItemData()
Player.getCarriedItemCount()
Player.getArmorSlot(slot)
Player.getArmorSlotDamage(slot)
Player.setArmorSlot(slot, id, damage)
Player.getName(ent)
Entity.setVelX(ent, amount)
Entity.setVelY(ent, amount)
Entity.setVelZ(ent, amount)
Entity.setRot(ent, yaw, pitch)
Entity.rideAnimal(/*insert, mount)
Entity.setPosition(ent, x, y, z)
Entity.setPositionRelative(ent, x, y, z)
Entity.getPitch(ent)
Entity.getYaw(ent)
Entity.setFireTicks(ent, howLong)
Entity.getX(ent)
Entity.getY(ent)
Entity.getZ(ent)
Entity.setCarriedItem(ent, id, count, damage)
Entity.getEntityTypeId(ent)
Entity.spawnMob(x, y, z, typeId, tex)
Entity.setAnimalAge(animal, age)
Entity.getAnimalAge(animal)
Entity.setMobSkin(entity, tex)
Entity.remove(ent)
Entity.getAllEntities()
Entity.getHealth(ent)
Entity.setHealth(ent, halfhearts)
Entity.setRenderType(ent, renderType)
Entity.setSneaking(ent, doIt)
ModPE.log(str)
ModPE.setTerrain(url)
ModPE.setItems(url)
ModPE.setGuiBlocks(url)
ModPE.overrideTexture(theOverridden, url)
ModPE.resetImages()
ModPE.setItem(id, icony, iconx, name)
ModPE.setFoodItem(id, icony, iconx, halfhearts, name)
ModPE.selectLevel(levelDir, levelName, levelSeed, gamemode)
ModPE.readData(prefName)
ModPE.saveData(prefName, prefValue)
ModPE.removeData(prefName)
ModPE.leaveGame()
ModPE.joinServer(serverAddress, port)
ModPE.setGameSpeed(ticksPerSecond)
ModPE.takeScreenshot(fileName)
Block.defineBlock(blockId, name, textures, materialSourceIdSrc, opaqueSrc, renderTypeSrc)
Block.setDestroyTime(blockId, time)
Block.setExplosionResistance(blockId, resist)
Block.setShape(blockId, v1, v2, v3, v4, v5, v6)
Block.setStepSound(blockId, sourceId)
Block.setLightLevel(blockId, lightLevel)
Block.setColor(blockId, colorArray)
Block.setRenderLayer(blockId, layer)
Again, just reading it, I see a few methods that were commented out that made it into the list, and the callbacks still have their original Java code instead of the proper parameters, but good enough.
Who knows how to use the function saveFile(directory, filename) and readFile(directory, filename) ? cause i saw it in a template but i dont know how to use it. Oh and can u add ModPE.setArmorItem(id,coord,coord,part(helmet, chestplate, leggings, boots,durability,"name",directory(armor/name.png)) please?
use Entity.getX,Entity.getY,Entity.getZ
and use Entity.remove to delete that entity and use Level.dropItem
Actually some of these don't work yet.
If you want a more updated version (along with some mods) come to my ModPE page.
http://www.minecraftforum.net/topic/2008334-themcpegamers-modpe-page-new-layman-mod-maker-beta-10-released/#entry24700877
Lead developer of Dragonet!
Check out my game, Adventuria!
Dev of (IMO the best server ever) TwilightGamez!
No... no... no.
These functions are only internal if:
A. You have BlockLauncher (Android)
B. You have ModPE installed on you JailBroken iOS device
Afterwards, they are built-in. Don't believe me? Look at some scripts that people have created. The functions are not created in the Script but are already built-in.
Back to modding! Follow me on Twitter @byteandahalf
-
View User Profile
-
View Posts
-
Send Message
Curse PremiumAgain, just reading it, I see a few methods that were commented out that made it into the list, and the callbacks still have their original Java code instead of the proper parameters, but good enough.
Want GUI Templates? Done!
https://github.com/BeATz-UnKNoWN/ModPE_Scripts/wiki/ModPE-Script-Templates
P.S. Feel free to follow me so you know when I post "awesome" content and make the MCForums a brighter place (totally).
If you need to contact me you can either shoot a Kik message to beatz_unknown or send an email to [email protected]
Want GUI Templates? Done!
https://github.com/BeATz-UnKNoWN/ModPE_Scripts/wiki/ModPE-Script-Templates
P.S. Feel free to follow me so you know when I post "awesome" content and make the MCForums a brighter place (totally).
If you need to contact me you can either shoot a Kik message to beatz_unknown or send an email to [email protected]
just bit different. new level means your map gets loaded, and select level means you clicked(selected) your world
Want GUI Templates? Done!
https://github.com/BeATz-UnKNoWN/ModPE_Scripts/wiki/ModPE-Script-Templates
P.S. Feel free to follow me so you know when I post "awesome" content and make the MCForums a brighter place (totally).
If you need to contact me you can either shoot a Kik message to beatz_unknown or send an email to [email protected]
:D: <--- That's a happy and a sad face