I am trying to make a mod and I am making custom weapon. I have most of it done and I need a few more things. The main thing I need is the code for making my item --with the id of 5000-- have durability and a visible durability bar. If anyone knows how to do this can you type up the code for it.
I dont see anything wrong with it. try making the dmg interger even more.
Rollback Post to RevisionRollBack
Heard of an app called AppNana? It's an app that rewards you for installing games, testing apps, watching adds, with Google Play, Amazon, and iTunes gift cards, and more! And the app, is completely free!
An easy way of earning Nanas is to add other people's Invite Codes. Whenever you invite someone or get invited, you get 2.5k nanas!
My code is t3305123, pm me your codes so we can just keep gettin nanas for doing pretty much nothing at all!
function modTick(){
if(Player.getCarriedItem()==yourId){
Block.setDestroyTime(Id, time); //set the destroy time if the Player holds the Item, use this method for all blocks you want another time, for example stone and all ores
}else{
Block.setDestroyTime(Id, time); //reeset the destroy time if the Player don´t holds the Item, you can see all destroy times in the Minecraft Wiki
}
}
I am trying to make a mod and I am making custom weapon. I have most of it done and I need a few more things. The main thing I need is the code for making my item --with the id of 5000-- have durability and a visible durability bar. If anyone knows how to do this can you type up the code for it.
I'm so frustrated.
Item.setMaxDamage("your Item's ID", "your Item's Health/Durability");
function attackHook(a, v){ if(getCarriedItem()=="your Item's ID"){
if(Player.getCarriedItemData()<"your Item's Health/Durability"){ Entity.setCarriedItem(Player.getEntity(), "your Item's ID", Player.getCarriedItemCount(), Player.getCarriedItemData() + 1);
} else{ Level.playSound(x, y, z, "random.break", 100, 100); Player.clearInventorySlot(Player.getSelectedSlotId()); } } }
if it did'nt work, show me the code and tell me the problem of it.
thank you so much. it worked!
it worked on the first try?
cuz sometimes mine broke in one hit..
but anyways your welcome
ask if you need more help...
Try it like this...
function destroyBlock(x, y, z, side){
if(getCarriedItem()==504 && getTile(x, y, z)==1){
Level.destroyBlock(x, y, z, false);
Level.dropItem(x, y, z, 0, 4, 1);
if(getCarriedItem==504){
if(Player.getCarriedItemData() < 882)
Entity.setCarriedItem(getPlayerEnt(), 504, Player.getCarriedItemCount(), Player.getCarriedItemData()+1);
} else{
Level.playSoundEnt(getPlayerEnt(), "random.break", 100, 100);
Player.clearInventorySlot(Player.getSelectedSlotId());}}}
function destroyBlock(x, y, z, side){
if(getCarriedItem()==504 && getTile(x, y, z)==1){
preventDefault();
Level.destroyBlock(x, y, z, false);
Level.dropItem(x, y, z, 0, 4, 1);
}
if(getCarriedItem()==504) {
if(Player.getCarriedItemData() < 882) {
Entity.setCarriedItem(getPlayerEnt(), 504, Player.getCarriedItemCount(), Player.getCarriedItemData() + 1);
} else{
Level.playSound(x, y, z, "random.break", 100, 100);
Player.clearInventorySlot(Player.getSelectedSlotId()); } } }
I copied the code of my amethyst pickaxe
cause it works perfectly fine on it
so let's see if it works on that too.
function attackHook(a, v){ if(getCarriedItem()=="your Item's ID"){
if(Player.getCarriedItemData()<"your Item's Health/Durability"){ Entity.setCarriedItem(Player.getEntity(), "your Item's ID", Player.getCarriedItemCount(), Player.getCarriedItemData() + 1);
} else{ Level.playSoundEnt(getPlayerEnt(), "random.break", 100, 100); Player.clearInventorySlot(Player.getSelectedSlotId()); } } }
this is for the attackHook sorry
i put the wrong code..
but test it
I dont see anything wrong with it. try making the dmg interger even more.
function modTick(){
if(Player.getCarriedItem()==yourId){
Block.setDestroyTime(Id, time); //set the destroy time if the Player holds the Item, use this method for all blocks you want another time, for example stone and all ores
}else{
Block.setDestroyTime(Id, time); //reeset the destroy time if the Player don´t holds the Item, you can see all destroy times in the Minecraft Wiki
}
}
That seems like coding is simple.
Hey what's going on guys? My name is TheEnderstar!
http://www.minecraftforum.net/members/TheEnderstar
have you tried if(getCarriedItem()==id&&getTile()==blocks you destoyed) {
Level.dropItem(something);
?????
cuz the code on one of your reply is only effecting the stone when destoyed.