Finalement je n’est pas réussi je ne comprend pas trop comment faire, si tu pouvais m’aider un peu plus en modifiant le code ci dessus car j’ai du mal là ^^
Edit : Voilà j’ai trouver une alternative en gros le –stack.stacksize; je les mis après la commande donc quand on veux le réutiliser il disparaît :
package pixelbadge;
import net.minecraft.command.ICommandManager;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.server.MinecraftServer;
import net.minecraft.world.World;
import pixelmonfr.pixelmain;
public class oeufpichu extends Item
{
private int timer;
public oeufpichu(int par1)
{
super(par1);
this.setCreativeTab(pixelmain.pixelitems);
this.setMaxStackSize(1);
}
/**
* Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer
*/
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player)
{
this.timer = 2400;
return stack;
}
/**
* Called each tick as long the item is on a player inventory. Uses by maps to check if is on a player hand and
* update it's contents.
*/
public void onUpdate(ItemStack stack, World world, Entity entity, int id, boolean isCurrent)
{
if(!world.isRemote)
{
if (this.timer > -1 && entity instanceof EntityPlayer)
{
--this.timer;
}
if (this.timer == 0 && entity instanceof EntityPlayer)
{
ICommandManager icommandmanager = MinecraftServer.getServer().getCommandManager();
icommandmanager.executeCommand((EntityPlayer)entity, "/pokegive @p pichu lvl1");
--stack.stackSize;
}
}
}