Posted May 22, 20169 yr Hi! I need to make delay before attack, this is my code: private int attackDelay; private int attackTimer; private Entity attackedEntity = null; public ItemGreatsword(Item.ToolMaterial par1ToolMaterial, int par2AttackDelay) { this.field_150933_b = par1ToolMaterial; this.maxStackSize = 1; this.setMaxDamage(par1ToolMaterial.getMaxUses()); this.setCreativeTab(CreativeTabs.tabCombat); this.field_150934_a = 4.0F + par1ToolMaterial.getDamageVsEntity(); //this.attackDelay = par2AttackDelay; this.attackDelay = 40; } @Override public boolean onLeftClickEntity(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, Entity par3Entity) { if (attackedEntity == null) { this.attackTimer = (this.attackDelay + 1); this.attackedEntity = par3Entity; } return true; } @Override public void onUpdate(ItemStack par1ItemStack, World par2World, Entity par3Entity, int par4, boolean par5) { super.onUpdate(par1ItemStack, par2World, par3Entity, par4, par5); EntityPlayer player = (EntityPlayer)par3Entity; ItemStack equippedItem = player.getCurrentEquippedItem(); if (this.attackTimer > 0) { --this.attackTimer; System.out.println("AttackTimer: " + this.attackTimer); } if (this.attackTimer == 1) { if (!par2World.isRemote) { this.attackedEntity.attackEntityFrom(DamageSource.lava, 6.0F); this.attackedEntity = null; this.attackTimer = 0; System.out.println("Test"); } } if (equippedItem == par1ItemStack) { player.addPotionEffect(new PotionEffect(Potion.digSlowdown.getId(), 0, 3)); } } Part of code (System.out.println("Test")) working, entity != null too, i checked it, but entity wont die. Thanks.
May 22, 20169 yr Every field in an Item class will be shared across all instanced of that Item . You have to store those values in the ItemStack 's NBT. Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support. 1.12 -> 1.13 primer by williewillus. 1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support. http://www.howoldisminecraft1710.today/
May 22, 20169 yr How do you know? Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support. 1.12 -> 1.13 primer by williewillus. 1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support. http://www.howoldisminecraft1710.today/
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.