addItemInventory with 256(ironsword),1(#ofswords),(256-1000)(damage, negative int)
Rollback Post to RevisionRollBack
I can be found on Freenode IRC channels #pocketmine, #ModPEScripts, #LegendOfMCPE, #pmplugins or #BeaconMine.
I am a PocketMine-MP plugin developer. I hate it when people think that I love stupid admin positions. Being an admin is nothing compared to being a plugin developer.
I am also a main developer of BlockServer, a work-in-progress MCPE server software. You are welcome to download it, but it so far onlly spawns you in the upther (above the world). You can chat, though.
I do not own this server but I just love to put this banner here:
Then define new item with same functions.
For example, iron sword:
ModPE.setItem(510,[ironswordtexturex],[ironswordtexturey]/*I'm lazy*/,"iron sword");//Or use "iron sword II" to make convenience for debug
//extends function destroyBlock()
function destroyBlock(x,y,z){
if(getCarriedItem()==267){ // on iron sword used; change to iron sword II
preventDefault();
setTile(x,y,z,0);
var damage=getCarriedItemData();
addItemInventory(510,1,damage+751);
addItemInventory(267,-1,damage);
}
else if(getCarriedItem()==510){ // override normal item 510 destroyBlock function into iron sword II functions
preventDefault();
setTile(x,y,z,0);
var damage=getCarriedItemData();//duplicated but I'm lazy
addItemInventory(510,1,damage+2);
addItemInventory(510,-1,damage);
}
}
//extends function attackHook()
function attackHook(a,v){
if(getCarriedItem()==267){ // on iron sword used; change to iron sword II
preventDefault();
var damage=getCarriedItemData();
var health=Entity.getHealth(v);
Entity.setHealth(v,health-7);//no armor, right?
addItemInventory(510,1,damage+750);
addItemInventory(267,-1,damage);
}
else if(getCarriedItem()==510){ // override normal item 510 attack function to iron sword II functions
preventDefault();
var damage=getCarriedItemData();
var health=Entity.getHealth(v);//duplicated, but I'm lazy
Entity.setHealth(v,health-7);
addItemInventory(510,1,damage+1);
addItemInventory(510,-1,damage);
}
}
Debug it yourself.
Of course this code would cause problems like water buckets in 0.7.1. at the first time convert, and also stackable problems, but item damage would solve this problem.
Also strange green durability bar due to ModPE restrictions.
P.S. I suddenly realized that ModPE is capable of making buckets in 0.7.1, just that craft methods are different, and buckets can't touch water or lava sources directly.
P.P.S. Johan if you are reading this don't hate ModPE because of this thing, although it is extremely unlikely this is to happen. (then why did I write this?)
I can be found on Freenode IRC channels #pocketmine, #ModPEScripts, #LegendOfMCPE, #pmplugins or #BeaconMine.
I am a PocketMine-MP plugin developer. I hate it when people think that I love stupid admin positions. Being an admin is nothing compared to being a plugin developer.
I am also a main developer of BlockServer, a work-in-progress MCPE server software. You are welcome to download it, but it so far onlly spawns you in the upther (above the world). You can chat, though.
I do not own this server but I just love to put this banner here:
Then define new item with same functions.
For example, iron sword:
ModPE.setItem(510,[ironswordtexturex],[ironswordtexturey]/*I'm lazy*/,"iron sword");//Or use "iron sword II" to make convenience for debug
//extends function destroyBlock()
function destroyBlock(x,y,z){
if(getCarriedItem()==267){ // on iron sword used; change to iron sword II
preventDefault();
setTile(x,y,z,0);
var damage=getCarriedItemData();
addItemInventory(510,1,damage+751);
addItemInventory(267,-1,damage);
}
else if(getCarriedItem()==510){ // override normal item 510 destroyBlock function into iron sword II functions
preventDefault();
setTile(x,y,z,0);
var damage=getCarriedItemData();//duplicated but I'm lazy
addItemInventory(510,1,damage+2);
addItemInventory(510,-1,damage);
}
}
//extends function attackHook()
function attackHook(a,v){
if(getCarriedItem()==267){ // on iron sword used; change to iron sword II
preventDefault();
var damage=getCarriedItemData();
var health=Entity.getHealth(v);
Entity.setHealth(v,health-7);//no armor, right?
addItemInventory(510,1,damage+750);
addItemInventory(267,-1,damage);
}
else if(getCarriedItem()==510){ // override normal item 510 attack function to iron sword II functions
preventDefault();
var damage=getCarriedItemData();
var health=Entity.getHealth(v);//duplicated, but I'm lazy
Entity.setHealth(v,health-7);
addItemInventory(510,1,damage+1);
addItemInventory(510,-1,damage);
}
}
Debug it yourself.
Of course this code would cause problems like water buckets in 0.7.1. at the first time convert, and also stackable problems, but item damage would solve this problem.
Also strange green durability bar due to ModPE restrictions.
P.S. I suddenly realized that ModPE is capable of making buckets in 0.7.1, just that craft methods are different, and buckets can't touch water or lava sources directly.
P.P.S. Johan if you are reading this don't hate ModPE because of this thing, although it is extremely unlikely this is to happen. (then why did I write this?)
I can be found on Freenode IRC channels #pocketmine, #ModPEScripts, #LegendOfMCPE, #pmplugins or #BeaconMine.
I am a PocketMine-MP plugin developer. I hate it when people think that I love stupid admin positions. Being an admin is nothing compared to being a plugin developer.
I am also a main developer of BlockServer, a work-in-progress MCPE server software. You are welcome to download it, but it so far onlly spawns you in the upther (above the world). You can chat, though.
I do not own this server but I just love to put this banner here:
To post a comment, please login or register a new account.
i use random function to set durability items
but its so lame so i post this topic
if you know how to set durability item
(example=iron sword have 256 uses,change to 1000)
please tell me the function!!!
sincerely
Arqan
Opps,i think you right,so i waiting for the function!!!
that function is to set damage of an item,not change the durability item
For example, iron sword:
ModPE.setItem(510,[ironswordtexturex],[ironswordtexturey]/*I'm lazy*/,"iron sword");//Or use "iron sword II" to make convenience for debug //extends function destroyBlock() function destroyBlock(x,y,z){ if(getCarriedItem()==267){ // on iron sword used; change to iron sword II preventDefault(); setTile(x,y,z,0); var damage=getCarriedItemData(); addItemInventory(510,1,damage+751); addItemInventory(267,-1,damage); } else if(getCarriedItem()==510){ // override normal item 510 destroyBlock function into iron sword II functions preventDefault(); setTile(x,y,z,0); var damage=getCarriedItemData();//duplicated but I'm lazy addItemInventory(510,1,damage+2); addItemInventory(510,-1,damage); } } //extends function attackHook() function attackHook(a,v){ if(getCarriedItem()==267){ // on iron sword used; change to iron sword II preventDefault(); var damage=getCarriedItemData(); var health=Entity.getHealth(v); Entity.setHealth(v,health-7);//no armor, right? addItemInventory(510,1,damage+750); addItemInventory(267,-1,damage); } else if(getCarriedItem()==510){ // override normal item 510 attack function to iron sword II functions preventDefault(); var damage=getCarriedItemData(); var health=Entity.getHealth(v);//duplicated, but I'm lazy Entity.setHealth(v,health-7); addItemInventory(510,1,damage+1); addItemInventory(510,-1,damage); } }Debug it yourself.
Of course this code would cause problems like water buckets in 0.7.1. at the first time convert, and also stackable problems, but item damage would solve this problem.
Also strange green durability bar due to ModPE restrictions.
P.S. I suddenly realized that ModPE is capable of making buckets in 0.7.1, just that craft methods are different, and buckets can't touch water or lava sources directly.
P.P.S. Johan if you are reading this don't hate ModPE because of this thing, although it is extremely unlikely this is to happen. (then why did I write this?)
Wow,its WORK!!! thanks MCPE_modder_for_maps!!!^_^
Remember to add the sword-break-when-damage-is-too-high function.