Posted September 14, 201312 yr Hello! I know this is a very noob question, but getEnumAction() doesn't work...it doesn't do the action I set it to do. Here is my code: package MysticRealms.Items; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.item.EnumAction; import net.minecraft.item.EnumToolMaterial; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.potion.Potion; import net.minecraft.potion.PotionEffect; import net.minecraft.world.World; import MysticRealms.MysticRealms; public class ItemWeapon extends Item { int swingSpeed; public ItemWeapon(int id, EnumToolMaterial material, int speed, String name /*String ability*/) { super(id); this.setCreativeTab(MysticRealms.mysticTab); this.setUnlocalizedName(name); swingSpeed = speed; } public void onUpdate(ItemStack stack, World world, Entity entity, int par4, boolean par5) { if(entity instanceof EntityPlayer) { EntityPlayer player = (EntityPlayer) entity; ItemStack equipped = player.getCurrentEquippedItem(); if(equipped == stack) { if(swingSpeed == 0) { } else if (swingSpeed == 1) { player.addPotionEffect(new PotionEffect(Potion.digSpeed.id, 1, 0)); } else if (swingSpeed == 2) { player.addPotionEffect(new PotionEffect(Potion.digSpeed.id, 1, 1)); } else if (swingSpeed == 3) { player.addPotionEffect(new PotionEffect(Potion.digSpeed.id, 1, 2)); } else if (swingSpeed == -1) { player.addPotionEffect(new PotionEffect(Potion.digSlowdown.id, 1, 0)); } else if (swingSpeed == -2) { player.addPotionEffect(new PotionEffect(Potion.digSlowdown.id, 1, 1)); } else if (swingSpeed == -3) { player.addPotionEffect(new PotionEffect(Potion.digSlowdown.id, 1, 2)); } else if (swingSpeed == -4) { player.addPotionEffect(new PotionEffect(Potion.digSlowdown.id, 1, 3)); } } } } public EnumAction getItemUseAction(ItemStack par1ItemStack) { return EnumAction.block; } } Thanks!
September 15, 201312 yr Author I can't figure this out...here's my code: public EnumAction getItemUseAction(ItemStack par1ItemStack) { return EnumAction.block; } public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { par3EntityPlayer.setItemInUse(par1ItemStack, this.getMaxItemUseDuration(par1ItemStack)); return par1ItemStack; } It does nothing on right click...
September 15, 201312 yr You also have to set a max use duration for your item, or it cannot be used. If you don't override this method, the default value from Item is 0. @Override public int getMaxItemUseDuration(ItemStack par1ItemStack) { return 72000; // however long your item can be used, in ticks } http://i.imgur.com/NdrFdld.png[/img]
September 15, 201312 yr Author You also have to set a max use duration for your item, or it cannot be used. If you don't override this method, the default value from Item is 0. @Override public int getMaxItemUseDuration(ItemStack par1ItemStack) { return 72000; // however long your item can be used, in ticks } It worked! Thanks! And I didn't know you moved here from MCForums
September 15, 201312 yr You also have to set a max use duration for your item, or it cannot be used. If you don't override this method, the default value from Item is 0. @Override public int getMaxItemUseDuration(ItemStack par1ItemStack) { return 72000; // however long your item can be used, in ticks } It worked! Thanks! And I didn't know you moved here from MCForums Great! Yeah, I just signed up with some problems of my own http://i.imgur.com/NdrFdld.png[/img]
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.