Item qui a un cooldown
-
Non quand le mec clique dessus sa fait l’effet après il ne peut pas l’effectuer pendant 10 seconde ansi de suite
-
Ouep c’est ce que je dis …
Je t’envois le code
-
Tu es un coeur Merci =p
-
Voilà, je t’ai même ajouté quelque commentaires =D
package fr.mrplaigon.testmod.common.item; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.potion.Potion; import net.minecraft.potion.PotionEffect; import net.minecraft.util.ChatComponentTranslation; import net.minecraft.world.World; public class StrengthStick extends Item { public StrengthStick() { this.setMaxDamage(16); this.setMaxStackSize(1); } @Override public void onUpdate(ItemStack item, World world, Entity player, int slotIndex, boolean inHand) { if(item.hasTagCompound())//Si ton item n'a pas de tag alors on ne fait rien { if(item.stackTagCompound.getInteger("timer") > 0)//si ton timer est supérieur à 0 (après un clic droit logiquement) { item.stackTagCompound.setInteger("timer", (int) (item.stackTagCompound.getInteger("timer") + 1));//On l'incrémente de 1 à chaque tick } if(item.stackTagCompound.getInteger("timer") >= (int) (6*20))//Remplace 6 par le nombre de secondes du timer souhaité { item.stackTagCompound.setInteger("timer", 0);//On remet à 0 si le timer est arrivé à la limite souhaitée } } super.onUpdate(item, world, player, slotIndex, inHand); } public ItemStack onItemRightClick(ItemStack item, World world, EntityPlayer player) { if(!item.hasTagCompound())//Même condition, si ton item n'a pas de tag on lui en ajoute avec l'int timer en + { item.setTagCompound(new NBTTagCompound()); item.stackTagCompound.setInteger("timer", 0); } if(item.stackTagCompound.getInteger("timer") == 0) { player.addPotionEffect(new PotionEffect(Potion.damageBoost.id, 120, 2)); item.stackTagCompound.setInteger("timer", 1);//On le met à 1 pour pouvoir rentrer dans la condition de onUpdate() } else { if(world.isRemote) player.addChatComponentMessage(new ChatComponentTranslation("Tu dois attendre que le baton se recharge !"));//On indique au joueur via ce message si le timer n'est pas encore arrivé à la limite souhaitée } return item; } @SideOnly(Side.CLIENT) public boolean hasEffect(ItemStack item) { return true; } }N’oublie pas le petit + stp
-
Si tu me dis ou il est je veux bien =p
Edit : Juste j’ai essayer de mon coter de faire que l’item ne soit pas enchanter si l’item est inutilisable et enchanter quand il l’es sauf que je crash a chaque fois =/
-
Juste j’ai essayer de mon coter de faire que l’item ne soit pas enchanter si l’item est inutilisable et enchanter quand il l’es sauf que je crash a chaque fois =/
-
Ok voici le code =D
@SideOnly(Side.CLIENT) public boolean hasEffect(ItemStack item) { return item.hasTagCompound() ? (item.stackTagCompound.getInteger("timer") == 0 ? true : false) : false;//On vérifie déjà si l'ItemStack a set un NBTTagCompound si oui, on vérifie si Timer en fait partie et si il est égal à 0, si oui, on return true à la méthode } -
Merci =p
-
N’oublie pas la balise résolue

-
Merci! Grâce à toi, Deleted, j’ai enfin réussie à développer mon item! Merci beaucoup!