include the deathHook to add your own drops
this example will make the zombies drop backed potato (Id = 393, damage = 0)
just change the Id and damage to the values of your rottne flesh
function deathHook(murderer, victim) {
// victim = zombie AND the random number smaller than 0.5 (50% chance)
if (Entity.getEntityTypeId(victim) === 32 && Math.random() < 0.5) {
//Level.dropItem(x, y, z, radius, ID, amount, amount, damage);
Level.dropItem(Entity.getX(victim), Entity.getY(victim), Entity.getZ(victim), 1, 393, 1, 1, 0);
}
}
with the following code the zombies will drop 0-2 rotten flesh
the zombies still drops their normal drops (carrot, feather, potato). I don't know how to prevent these drops because preventDefault() does not work with the deathHook.
//store the id in a variable for later use
var rottenFleshId = 394;
//create new Food item
//ModPE.setFoodItem(ID, textureName, type, halfHeartsHealed, name, stackLimit);
ModPE.setFoodItem(rottenFleshId, "rotten_flesh", 0, 4, "rotten flesh", 64);
function deathHook(murderer, victim) {
//if victim = zombie
if (Entity.getEntityTypeId(victim) === 32) {
//generate a random number 0, 1 or 2
var amount = Math.floor(Math.random() * 3);
//if amount is not equal 0 drop the item
if (amount) {
//Level.dropItem(x, y, z, radius, ID, amount, amount, damage);
Level.dropItem(Entity.getX(victim), Entity.getY(victim), Entity.getZ(victim), 1, rottenFleshId, amount, 0, 0);
}
}
}
this example will make the zombies drop backed potato (Id = 393, damage = 0)
just change the Id and damage to the values of your rottne flesh
function deathHook(murderer, victim) { // victim = zombie AND the random number smaller than 0.5 (50% chance) if (Entity.getEntityTypeId(victim) === 32 && Math.random() < 0.5) { //Level.dropItem(x, y, z, radius, ID, amount, amount, damage); Level.dropItem(Entity.getX(victim), Entity.getY(victim), Entity.getZ(victim), 1, 393, 1, 1, 0); } }I was having hard time finding an answer
Can you help me one more time??
In Minecraft PC you get 0~2 rotten flesh, i am trying to add it in my script
the zombies still drops their normal drops (carrot, feather, potato). I don't know how to prevent these drops because preventDefault() does not work with the deathHook.
//store the id in a variable for later use var rottenFleshId = 394; //create new Food item //ModPE.setFoodItem(ID, textureName, type, halfHeartsHealed, name, stackLimit); ModPE.setFoodItem(rottenFleshId, "rotten_flesh", 0, 4, "rotten flesh", 64); function deathHook(murderer, victim) { //if victim = zombie if (Entity.getEntityTypeId(victim) === 32) { //generate a random number 0, 1 or 2 var amount = Math.floor(Math.random() * 3); //if amount is not equal 0 drop the item if (amount) { //Level.dropItem(x, y, z, radius, ID, amount, amount, damage); Level.dropItem(Entity.getX(victim), Entity.getY(victim), Entity.getZ(victim), 1, rottenFleshId, amount, 0, 0); } } }i finally made version 2.0 of my More items mod
i could'nt have done it without your help
thanks again