function useItem(x,y,z,itemId,blockId,side,itemDamage,blockDamage) {}
Instead of your unconventional workaround?
EDIT: also no semicolon after Player.getCarriedItem() but I always thought there was a semicolon autoinserter in the blocklauncher code interpretation system, still, you never know
You also need an entity killed handler, simply setting the victims value to a number less has a high chance of setting the value to a negative number, and this WILL ALWAYS result in a crash. After you handle negative values, and set the entity health to 0, you will notice that there are no drops from the victim. This is known, and I recommend setting the health to 1 if victims health-damage<=0, then applying withering/harming/fire onto it. Note that fire will also have a visual change, and cook animal meat drops. Some other people say that simply setting the victims health to 1 should be enough, since the punch will apply 1 more damage and kill the victim, but I have not tried this
Rollback Post to RevisionRollBack
I have nothing to say...
To post a comment, please login or register a new account.
My code:
///M.A.H SWORDS MOD BY SYLVERHAING///
///YOU CAN POST TO ANY PAGES, BUT REMEMBER TO LEAVE MY NAME///
//////////ITEMS
/////////SWORDS
ModPE.setItem(1000,"black_silver_sword",0,"Black Silver Sword",1);
Item.setMaxDamage(1000,1700);
ModPE.setItem(1001,"emerald_sword",0,"Emerald Sword",1);
Item.setMaxDamage(1001,4000);
ModPE.setItem(1002,"lazer_on",0,"Blue Light Saber",1);
Item.setMaxDamage(1002,3500);
////////OTHERS
ModPE.setItem(900,"black_silver",0,"Black Silver",64);
ModPE.setItem(901,"light_source",0,"Blue Light Source",64);
ModPE.setItem(902,"lazer_off",0,"Blue Light Saber",1);
//////////INVENTORY
Player.addItemCreativeInv(900,1,0);
Item.setCategory(900,ItemCategory.FOOD);
Player.addItemCreativeInv(901,1,0);
Item.setCategory(901,ItemCategory.FOOD);
Player.addItemCreativeInv(902,1,0);
Item.setCategory(902,ItemCategory.TOOL);
Player.addItemCreativeInv(1000,1,0);
Item.setCategory(1000,ItemCategory.TOOL);
Player.addItemCreativeInv(1001,1,0);
Item.setCategory(1001,ItemCategory.TOOL);
//////////DAMAGE DEALS
function attackHook(a,v){
var ItemID=Player.getCarriedItem()
if(ItemID==1000){
Entity.setHealth(v,Entity.getHealth(v)-12.5);
if(Level.getGameMode()==0){
if(Player.getCarriedItemData()==1700){
Player.clearInventorySlot(Player.getSelectedSlotId());
Level.playSound(Player.getX(), Player.getY(), Player.getZ(), "random.break", 1.0, 25.0);
}
else{
Entity.setCarriedItem(getPlayerEnt(), Player.getCarriedItem(), 1, Player.getCarriedItemData()+1);
}
}
}
if(ItemID==1001){
Entity.setHealth(v,Entity.getHealth(v)-15);
if(Level.getGameMode()==0){
if(Player.getCarriedItemData()==4000){
Player.clearInventorySlot(Player.getSelectedSlotId());
Level.playSound(Player.getX(), Player.getY(), Player.getZ(), "random.break", 1.0, 25.0);
}
else{
Entity.setCarriedItem(getPlayerEnt(), Player.getCarriedItem(), 1, Player.getCarriedItemData()+1);
}
}
}
if(ItemID==1002){
Entity.setHealth(v,Entity.getHealth(v)-10);
if(Level.getGameMode()==0){
if(Player.getCarriedItemData()==3500){
Player.clearInventorySlot(Player.getSelectedSlotId());
Level.playSound(Player.getX(), Player.getY(), Player.getZ(), "random.break", 1.0, 25.0);
}
else{
Entity.setCarriedItem(getPlayerEnt(), Player.getCarriedItem(), 1, Player.getCarriedItemData()+1);
}
}
}
}
//////////CRAFTING RECIPE
Item.addShapedRecipe(900,1,0,[
" a",
" b"],["a",263,0,"b",265,0]);
Item.addShapedRecipe(901,1,0,[
"aa",
"ab"],["a",348,0,"b",265,0]);
Item.addShapedRecipe(902,1,0,[
"bab",
"bcb",
"bbb"],["a",77,0,"b",900,0,"c",901,0]);
Item.addShapedRecipe(1000,1,0,[
" a ",
" a ",
" b "],["a",900,0,"b",280,0]);
Item.addShapedRecipe(1001,1,0,[
" a ",
" a ",
" b "],["a",388,0,"b",280,0]);
//////////USE ITEM
function useItem(x,y,z,side){
var ItemID=Player.getCarriedItem()
if(ItemID==902){
Player.setInventorySlot(Player.getSelectedSlotId(), 1002, 1, Player.getCarriedItemData());
}
if(ItemID==1002){
Player.setInventorySlot(Player.getSelectedSlotId(), 902, 1, Player.getCarriedItemData());
}
}
//////////OTHERS
Item.setHandEquipped(902,true);
Item.setHandEquipped(1000,true);
Item.setEnchantType(1000,EnchantType.weapon,1);
Item.setHandEquipped(1001,true);
Item.setEnchantType(1001,EnchantType.weapon,1);
Item.setHandEquipped(1002,true);
When I try to use the "Blue Light Saber"(id:902),BlockLauncher crashes...
Why not use
function useItem(x,y,z,itemId,blockId,side,itemDamage,blockDamage) {}
Instead of your unconventional workaround?
EDIT: also no semicolon after Player.getCarriedItem() but I always thought there was a semicolon autoinserter in the blocklauncher code interpretation system, still, you never know
I have nothing to say...
You also need an entity killed handler, simply setting the victims value to a number less has a high chance of setting the value to a negative number, and this WILL ALWAYS result in a crash. After you handle negative values, and set the entity health to 0, you will notice that there are no drops from the victim. This is known, and I recommend setting the health to 1 if victims health-damage<=0, then applying withering/harming/fire onto it. Note that fire will also have a visual change, and cook animal meat drops. Some other people say that simply setting the victims health to 1 should be enough, since the punch will apply 1 more damage and kill the victim, but I have not tried this
I have nothing to say...