Ok, I need help with certain (highlighted) parts of my mod code.
Green: How do I add more than one effect? When I tried to add a second Entity.addEffect function, the mod code wasn't read, and only the first line of effect was accepted, and blocklauncher shut the mod down. Is there's some sort of "and" or "if" statement I'm missing in order to layer the effects? Currently, I can only add one effect at a time on my tool. I want to be able to give the wielder of the tool multiple effect boosts. Also, though the potion effect particle visuals read "false", and shouldn't be seen, I still see them in-game, and it is very annoying because I don't want them to be seen.
Orange: A similar situation, I am unable to give the victim more than one effect at a time because only the first line of effect code is read and the rest is rejected, meaning the code gets shut down. Please help.
Blue: I want to make a neutral chicken mob, one that will attack if prevoked, but I have no idea how to go about doing that. I had thought about simply changing the entitytype to SPIDER, then keeping the EntityRenderType as chicken, but then I have a chicken with glitched wings that makes spider noises and drops spider eyes and webs... I just want a chicken with a temper if provoked, that can deal 8 health points of damage, (spawns in the dark?), and if someone is willing to teach me the code for it, with custom drops. Currently, it is just a chicken with a hundred health points, so yeah...
A few more things I need help with:
My mod consistently crashes if I use the Sword of Light, or the Axe of Light against 1) a creeper, 2) any other mob that can't be killed in one hit. Or, instead of crashing, the mob just disappears, and when I exit and re-enter the world, either the game crashes or the mob is back as if I never did anything. I don't know what the deal is, because a regular diamond sword and axe works fine. I haven't tried the other tools yet, because I stopped trying after the sword and axe failed... I don't know if it is the boosts I have on them (yes, the speed is insane, because the Main character of my story has super speed, which technically should require movementSpeed, 80, but that might have been way ridiculous...), or if it's just a glitch with modded weapons, or something else. I need to fix this problem, but I have been unable to do that so far.
The other issue with the Sword, is that if it does manage to kill a mob (one hit), the mob drops absolutely nothing. Not even experience. Yet a normal native weapon will allow mob drops. Even my axe will produce drops if it kills the mob (most of the time). Please help me.
Also, on a more complicated note, I want my mobs to spawn Naturally: in groups of 3-6 for the "Thanocantian" and "Antileukon" mobs, and groups of 4 for the "Spectrum Guard" mob, and singular spawns for the rest of them. I want all my mobs to be completely separate from the native mobs, so that when I program the mobs to drop something specific, or if I tell them to spawn in specific places only (also how?!?), it doesn't affect native mobs. I know this might require an extensive length of extra coding, but I don't know where to start. I got this far, and I have been coding ModPE for only 2 weeks.
Here is the code (please don't steal this code, I've been working on this for a bit of time, and it is nowhere near complete). if you need more information, ask, and I will try to get it to you:
function newLevel(){
clientMessage(ChatColor.AQUA + "F1a2h Lit3's tools of Light, used to bring down the Antileuko Forces... v0.8.6 for mcpe 0.15.x activated!");
clientMessage(ChatColor.WHITE + "Creator: ...... (aka F1a2h)");
clientMessage(ChatColor.RED + "Survival: Type /knight in chat to add tools and eggs, OR play normal to earn/craft tools -no eggs-");
}
Orange: idk should work as the above but does not work
Blue: Idk how this works :/ but I know about the custom drops:
function deathHook(attacker, victim) {
if (Entity.getEntityTypeId(victim) == EntityType.CHICKEN) { //you can use other methods to detect the entity as getNameTag or skin
//preventDefault(); //use it if you do not want the old drops
Level.dropItem(Entity.getX(victim), Entity.getY(victim), Entity.getZ(victim), 0.0, 264, 1, 0); //(x, y, z, range, id, count, damage)
}
}
About the disappearing mobs I think this is being caused by the explode function. You put 0 in radius. If you put above 0 the problem probably will not happen.
Another thing I noticed is that you put 0 ticks in Entity.setFireTicks function. I think it will have no effect if you put 0
About the mobs do not drop items, this is caused because they drop the item when health is 0. And in your code the health is set to negative numbers. To avoid this you can use:
var dmg = 25;
var health = Entity.getHealth(victim) - dmg;
if (health <= 0) {
Entity.setHealth(victim, 0);
} else {
Entity.setHealth(victim, health);
}
About the mobs spawn naturally I think the best way is using the function entityAddedHook(entity) to detect when a vanilla mob is spawned and spawn your mobs near them.
edit: I also found some missing semicolons. In the cmd function after clientMessage, and in the function useItem after each "var mod_..."
Ok, I need help with certain (highlighted) parts of my mod code.
Green: How do I add more than one effect? When I tried to add a second Entity.addEffect function, the mod code wasn't read, and only the first line of effect was accepted, and blocklauncher shut the mod down. Is there's some sort of "and" or "if" statement I'm missing in order to layer the effects? Currently, I can only add one effect at a time on my tool. I want to be able to give the wielder of the tool multiple effect boosts. Also, though the potion effect particle visuals read "false", and shouldn't be seen, I still see them in-game, and it is very annoying because I don't want them to be seen.
Orange: A similar situation, I am unable to give the victim more than one effect at a time because only the first line of effect code is read and the rest is rejected, meaning the code gets shut down. Please help.
Blue: I want to make a neutral chicken mob, one that will attack if prevoked, but I have no idea how to go about doing that. I had thought about simply changing the entitytype to SPIDER, then keeping the EntityRenderType as chicken, but then I have a chicken with glitched wings that makes spider noises and drops spider eyes and webs... I just want a chicken with a temper if provoked, that can deal 8 health points of damage, (spawns in the dark?), and if someone is willing to teach me the code for it, with custom drops. Currently, it is just a chicken with a hundred health points, so yeah...
A few more things I need help with:
My mod consistently crashes if I use the Sword of Light, or the Axe of Light against 1) a creeper, 2) any other mob that can't be killed in one hit. Or, instead of crashing, the mob just disappears, and when I exit and re-enter the world, either the game crashes or the mob is back as if I never did anything. I don't know what the deal is, because a regular diamond sword and axe works fine. I haven't tried the other tools yet, because I stopped trying after the sword and axe failed... I don't know if it is the boosts I have on them (yes, the speed is insane, because the Main character of my story has super speed, which technically should require movementSpeed, 80, but that might have been way ridiculous...), or if it's just a glitch with modded weapons, or something else. I need to fix this problem, but I have been unable to do that so far.
The other issue with the Sword, is that if it does manage to kill a mob (one hit), the mob drops absolutely nothing. Not even experience. Yet a normal native weapon will allow mob drops. Even my axe will produce drops if it kills the mob (most of the time). Please help me.
Also, on a more complicated note, I want my mobs to spawn Naturally: in groups of 3-6 for the "Thanocantian" and "Antileukon" mobs, and groups of 4 for the "Spectrum Guard" mob, and singular spawns for the rest of them. I want all my mobs to be completely separate from the native mobs, so that when I program the mobs to drop something specific, or if I tell them to spawn in specific places only (also how?!?), it doesn't affect native mobs. I know this might require an extensive length of extra coding, but I don't know where to start. I got this far, and I have been coding ModPE for only 2 weeks.
Here is the code (please don't steal this code, I've been working on this for a bit of time, and it is nowhere near complete). if you need more information, ask, and I will try to get it to you:
function newLevel(){
clientMessage(ChatColor.AQUA + "F1a2h Lit3's tools of Light, used to bring down the Antileuko Forces... v0.8.6 for mcpe 0.15.x activated!");
clientMessage(ChatColor.WHITE + "Creator: ...... (aka F1a2h)");
clientMessage(ChatColor.RED + "Survival: Type /knight in chat to add tools and eggs, OR play normal to earn/craft tools -no eggs-");
}
function procCmd(cmd) {
var com = cmd.split(" ");
if(com[0]=="knight"){
clientMessage("Items added. Good Luck!!!")
Player.addItemInventory(800, 64, 0);
Player.addItemInventory(801, 64, 0);
Player.addItemInventory(802, 64, 0);
Player.addItemInventory(803, 64, 0);
Player.addItemInventory(804, 64, 0);
Player.addItemInventory(1200, 64, 0);
Player.addItemInventory(1202, 64, 0);
Player.addItemInventory(1203, 64, 0);
Player.addItemInventory(1204, 64, 0);
Player.addItemInventory(1205, 64, 0);
Player.addItemInventory(1206, 64, 0);
}
}
ModPE.setItem(800, "sword_of_light", 0, "Sword of Light");
Player.addItemCreativeInv(800,1,0);
Item.setHandEquipped(800,1);
Item.setMaxDamage(800,2000);
ModPE.setItem(801, "axe_of_light", 0, "Axe of Light");
Player.addItemCreativeInv(801,1,0);
Item.setHandEquipped(801,1);
Item.setMaxDamage(801,2000);
ModPE.setItem(802, "pickaxe_knight_class", 0, "Pickaxe - Knight Class");
Player.addItemCreativeInv(802,1,0);
Item.setHandEquipped(802,1);
Item.setMaxDamage(802,2000);
ModPE.setItem(803, "farm_hoe_knight_class", 0, "Farm Hoe - Knight Class");
Player.addItemCreativeInv(803,1,0);
Item.setHandEquipped(803,1);
Item.setMaxDamage(803,2000);
ModPE.setItem(804, "shovel_knight_class", 0, "Shovel - Knight Class");
Player.addItemCreativeInv(804,1,0);
Item.setHandEquipped(804,1);
Item.setMaxDamage(800,2000);
ModPE.setItem(1200, "mob_icon_26", 0, "Spawn Extinguisher");
Player.addItemCreativeInv(1200,1,0);
ModPE.setItem(1202, "mob_icon_17", 0, "Spawn Skadowan");
Player.addItemCreativeInv(1202,1,0);
ModPE.setItem(1203, "mob_icon_13", 0, "Spawn Thanocantian");
Player.addItemCreativeInv(1203,1,0);
ModPE.setItem(1204,"mob_icon_23", 0, "Spawn Antiluekon");
Player.addItemCreativeInv(1204,1,0);
ModPE.setItem(1205, "mob_icon_29", 0, "Spawn Spectrum Guard");
Player.addItemCreativeInv(1205,1,0);
ModPE.setItem(1206, "mob_icon_09", 0, "Spawn The Spy");
Player.addItemCreativeInv(1206,1,0);
Item.addShapedRecipe(800, 1, 0, ["abc", "def", "ghi"], ["b", 264, 0, "c", 331, 0, "e", 264, 0, "f", 403, 0, "h", 276, 0]);
Item.addShapedRecipe(801, 1, 0, ["abc", "def", "ghi"], ["a", 264, 0, "b", 265, 0, "c", 264, 0, "d", 264, 0, "e", 331, 0, "f", 264, 0, "h", 279, 0, "i", 403, 0]);
Item.addShapedRecipe(802, 1, 0, ["abc", "def", "ghi"], ["a", 264, 0, "b", 331, 0, "c", 264, 0, "e", 265, 0, "f", 403, 0, "h", 278, 0]);
Item.addShapedRecipe(803, 1, 0, ["abc", "def", "ghi"], ["a", 264, 0, "b", 264, 0, "c", 331, 0, "e", 265, 0, "f", 403, 0, "h", 293, 0]);
Item.addShapedRecipe(804, 1, 0, ["abc", "def", "ghi"], ["b", 264, 0, "c", 331, 0, "e", 265, 0, "f", 403, 0, "h", 277, 0]);
function attackHook(attacker, victim) {
var dmg = 25;
Entity.setHealth(victim, Entity.getHealth(victim) - dmg);
Entity.addEffect(victim, MobEffect.weakness, 10*20, 2, false, true);
Entity.setFireTicks(victim, 0);
explode(Entity.getX(victim), Entity.getY(victim), Entity.getZ(victim), 0);
}
if (Player.getCarriedItem() == 801) {
var dmg = 25;
Entity.setHealth(victim, Entity.getHealth(victim) - dmg);
Entity.addEffect(victim, MobEffect.weakness, 30*20, 1, false, true);
Entity.setFireTicks(victim, 0);
explode(Entity.getX(victim), Entity.getY(victim), Entity.getZ(victim), 0);
}
if (Player.getCarriedItem() == 802) {
var dmg = 20;
Entity.setHealth(victim, Entity.getHealth(victim) - dmg);
Entity.addEffect(attacker, MobEffect.heal, 20, 1, false, true);
Entity.setFireTicks(victim, 0);
explode(Entity.getX(victim), Entity.getY(victim), Entity.getZ(victim), 0);
}
if (Player.getCarriedItem() == 803) {
var dmg = 14;
Entity.setHealth(victim, Entity.getHealth(victim) - dmg);
Entity.addEffect(attacker, MobEffect.heal, 20, 1, false, true);
Entity.setFireTicks(victim, 0);
explode(Entity.getX(victim), Entity.getY(victim), Entity.getZ(victim), 0);
}
if (Player.getCarriedItem() == 804) {
var dmg = 17;
Entity.setHealth(victim, Entity.getHealth(victim) - dmg);
Entity.addEffect(attacker, MobEffect.heal, 20, 1, false, true);
Entity.setFireTicks(victim, 0);
explode(Entity.getX(victim), Entity.getY(victim), Entity.getZ(victim), 0);
}
}
function useItem(x,y,z,itemId,block,side) {
if (itemId==1200)
{
var mob_201610049201 = Level.spawnMob(x+0.4,y+1,z+0.4, EntityType.ZOMBIE, "mob/mob_texture_107.png")
Entity.setRenderType(mob_201610049201, EntityRenderType.zombie);
Entity.setNameTag(mob_201610049201, "Extinguisher");
Entity.setMaxHealth(mob_201610049201, 60);
Entity.setHealth(mob_201610049201, 60);
}
if(itemId==1202)
{
var mob_201610044146 = Level.spawnMob(x+0.4,y+1,z+0.4, EntityType.ENDERMAN, "mob/mob_texture_31.png")
Entity.setRenderType(mob_201610044146, EntityRenderType.enderman);
Entity.setNameTag(mob_201610044146, "Skadowan");
Entity.setMaxHealth(mob_201610044146, 100);
Entity.setHealth(mob_201610044146, 100);
}
if(itemId==1203)
{
var mob_201610048005 = Level.spawnMob(x+0.4,y+1,z+0.4, EntityType.ZOMBIE, "mob/mob_texture_114.png")
Entity.setRenderType(mob_201610048005, EntityRenderType.zombie);
Entity.setNameTag(mob_201610048005, "Thanocantian");
Entity.setMaxHealth(mob_201610048005, 50);
Entity.setHealth(mob_201610048005, 50);
}
if(itemId==1204)
{
var mob_201610045414 = Level.spawnMob(x+0.4,y+1,z+0.4, EntityType.SKELETON, "mob/mob_texture_45.png")
Entity.setRenderType(mob_201610045414, EntityRenderType.skeleton);
Entity.setNameTag(mob_201610045414, "Antiluekon");
Entity.setMaxHealth(mob_201610045414, 50);
Entity.setHealth(mob_201610045414, 50);
}
if(itemId==1205)
{
var mob_201610044832 = Level.spawnMob(x+0.4,y+1,z+0.4, EntityType.BLAZE, "mob/mob_texture_09.png")
Entity.setRenderType(mob_201610044832, EntityRenderType.blaze);
Entity.setNameTag(mob_201610044832, "Spectrum Guard");
Entity.setMaxHealth(mob_201610044832, 80);
Entity.setHealth(mob_201610044832, 80);
}
if(itemId==1206)
{
var mob_201610046815 = Level.spawnMob(x+0.4,y+1,z+0.4, EntityType.CHICKEN, "mob/mob_texture_18.png")
Entity.setRenderType(mob_201610046815, EntityRenderType.chicken);
Entity.setNameTag(mob_201610046815, "The Spy");
Entity.setMaxHealth(mob_201610046815, 100);
Entity.setHealth(mob_201610046815, 100);
}
}
function modTick() {
if (Player.getCarriedItem() == 800) {
Entity.addEffect(getPlayerEnt(), MobEffect.movementSpeed, 10, 35, false, false);
}
if (Player.getCarriedItem() == 801) {
Entity.addEffect(getPlayerEnt(), MobEffect.damageBoost, 20, 4, false, false);
}
if (Player.getCarriedItem() == 802) {
Entity.addEffect(getPlayerEnt(), MobEffect.digSpeed, 20, 3, false, false);
}
if (Player.getCarriedItem() == 803) {
Entity.addEffect(getPlayerEnt(), MobEffect.regeneration, 20, 2, false, false);
}
if (Player.getCarriedItem() == 804) {
Entity.addEffect(getPlayerEnt(), MobEffect.digSpeed, 20, 3, false, false);
}
}
Green: I tested using it and works:
if (Player.getCarriedItem() == 800) { Entity.addEffect(getPlayerEnt(), MobEffect.movementSpeed, 10, 35, false, false); Entity.addEffect(getPlayerEnt(), MobEffect.damageBoost, 20, 4, false, false); }ps. Hide the particles does not work
Orange: idk should work as the above but does not work
Blue: Idk how this works :/ but I know about the custom drops:
function deathHook(attacker, victim) { if (Entity.getEntityTypeId(victim) == EntityType.CHICKEN) { //you can use other methods to detect the entity as getNameTag or skin //preventDefault(); //use it if you do not want the old drops Level.dropItem(Entity.getX(victim), Entity.getY(victim), Entity.getZ(victim), 0.0, 264, 1, 0); //(x, y, z, range, id, count, damage) } }About the disappearing mobs I think this is being caused by the explode function. You put 0 in radius. If you put above 0 the problem probably will not happen.
Another thing I noticed is that you put 0 ticks in Entity.setFireTicks function. I think it will have no effect if you put 0
About the mobs do not drop items, this is caused because they drop the item when health is 0. And in your code the health is set to negative numbers. To avoid this you can use:
var dmg = 25; var health = Entity.getHealth(victim) - dmg; if (health <= 0) { Entity.setHealth(victim, 0); } else { Entity.setHealth(victim, health); }About the mobs spawn naturally I think the best way is using the function entityAddedHook(entity) to detect when a vanilla mob is spawned and spawn your mobs near them.
edit: I also found some missing semicolons. In the cmd function after clientMessage, and in the function useItem after each "var mod_..."
I was wrong about the mobs drop the item when health is 0, I tested it and they drop when the health is 1. Then you should use it:
var dmg = 25; var health = Entity.getHealth(victim) - dmg; if (health <= 0) { Entity.setHealth(victim, 1); } else { Entity.setHealth(victim, health); }THANK YOU SO MUCH!!! Lol
now to work on coding for Addons 😂... I I only just got ModPE... darn haha