Posted July 29, 201411 yr I am trying to make it so my sword places redstone, and damages the sword on use. Code: public boolean onItemUse(ItemStack p_77648_1_, EntityPlayer p_77648_2_, World p_77648_3_, int p_77648_4_, int p_77648_5_, int p_77648_6_, int p_77648_7_, float p_77648_8_, float p_77648_9_, float p_77648_10_) { if (p_77648_3_.getBlock(p_77648_4_, p_77648_5_, p_77648_6_) != Blocks.snow_layer) { if (p_77648_7_ == 0) { --p_77648_5_; } if (p_77648_7_ == 1) { ++p_77648_5_; } if (p_77648_7_ == 2) { --p_77648_6_; } if (p_77648_7_ == 3) { ++p_77648_6_; } if (p_77648_7_ == 4) { --p_77648_4_; } if (p_77648_7_ == 5) { ++p_77648_4_; } if (!p_77648_3_.isAirBlock(p_77648_4_, p_77648_5_, p_77648_6_)) { return false; } } if (!p_77648_2_.canPlayerEdit(p_77648_4_, p_77648_5_, p_77648_6_, p_77648_7_, p_77648_1_)) { return false; } else { if (Blocks.redstone_wire.canPlaceBlockAt(p_77648_3_, p_77648_4_, p_77648_5_, p_77648_6_)) { p_77648_1_.damageItem(-1, p_77648_2_); p_77648_3_.setBlock(p_77648_4_, p_77648_5_, p_77648_6_, Blocks.redstone_wire); } return true; } }
July 29, 201411 yr I believe damage is positive. Try using damageItem(1, ...) instead. GitHub|Recipe API Proposal
July 29, 201411 yr damage is a positive number that increases with each use until maxDamage is reached. P.S.: you should really start renaming your variables to make them more readable for other people and for you in the future, you'll appreciate that later on, An easy way in eclipse is pointing on variable the pressing CTRL + 2 then R then rename to whatever
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.