Posted August 30, 20178 yr I have this code in a block: @Override public void harvestBlock(World worldIn, EntityPlayer player, BlockPos pos, IBlockState state, @Nullable TileEntity te, @Nullable ItemStack stack) { if(stack != null) { Item i = stack.getItem(); if(i instanceof ItemTool) { stack.damageItem(2, player); } else if(i instanceof ItemHoe) { stack.damageItem(1, player); } } } While in survival mode, breaking the block with a hoe does not result in the item taking damage. When trying to debug, the item sustains the damage, this method returns, and as far as I can tell, no longer has the damage. Any other tool only takes 1 damage (???). I can't figure out what part of vanilla is overriding this effect. I know for a fact that this worked fine in 1.7.10, but I would need to go back and check 1.10 and 1.11 Edited August 30, 20178 yr by Draco18s Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
August 30, 20178 yr The ItemHoe setBlock() method also calls stack.damageItem(1, player) so you're doing same as vanilla use should do. I'm sure you know how to trace the code as well or better than me, but seems like standard stuff would prevent the damage: if the max damage is less than zero, if the NBT tag has unbreakable boolean set true, if the unbreakable enchantment is in effect, if player is in creative mode. One thing though -- what material is your hoe? The ToolMaterial affects much of these fields. Check out my tutorials here: http://jabelarminecraft.blogspot.com/
August 30, 20178 yr Author 8 hours ago, jabelar said: The ItemHoe setBlock() method also calls stack.damageItem(1, player) so you're doing same as vanilla use should do. I'm sure you know how to trace the code as well or better than me, but seems like standard stuff would prevent the damage: if the max damage is less than zero, if the NBT tag has unbreakable boolean set true, if the unbreakable enchantment is in effect, if player is in creative mode. The stack itself takes the damage, at the end of the above function, the stack has the desired 1 damage. When it returns (back to the InteractionManager) it does not. 8 hours ago, jabelar said: One thing though -- what material is your hoe? The ToolMaterial affects much of these fields. The type of hoe didn't matter. I tried wooden, iron, and diamond. Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
August 30, 20178 yr Were you messing around with the BreakEvent or block harvest event and somehow canceling the damage? Check out my tutorials here: http://jabelarminecraft.blogspot.com/
August 30, 20178 yr Author Nope. Looks like I can use removedByPlayer instead and that correctly deals damage to the item. Edited August 30, 20178 yr by Draco18s Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
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.