Open ghost opened 9 years ago
IMO your current approach is not ideal. A block shouldn't check the tools it's mined with, using multiple instanceof and type checks to apply damage to that tool.
I'd prefer a different attempt: Add a method onBreakBlock(Player, GlowBlock, ItemStack)
to ItemType and override it in ItemTool, which checks for creative player and calls a new method like calculateBreakDamage(GlowBlock)
. That method returns 1 by default, but is overriden by ItemSword to return 2 and by ItemHoe to return 0.
BTW ItemAxe, ItemPickaxe and ItemSpade are pretty useless. You might consider to remove them.
622 doesn't have anything to do with this PR - it would have been better to submit that fix as a separate PR.
Seems like a one-line-change, time for @SpaceManiac?
@CrabeMan Only one issue can be resolved per pull request. Remove one of the implementations for this to be reviewed.
Thanks.
Hello, yes i forgot Iron Spade, Pickaxe and Axe, sorry.
I added damage == 0
because if damage inflicted on tool is equal to 0, we don't need to update durability on it. I have change holding.setAmount(0)
by player.getInventory().remove(holding)
because setAmount(0)
don't remove item.
And for ItemHoe, which one constants do you mean?
CrabeMan.
You override your new method to return 0
and use a hardcoded 1
.
Hello, yes the override method in ItemHoe calculateBreakDamage
return damage for breaking block. But in rightClickBlock
it's damage for using the Hoe.
CrabeMan.
I have implemented Shears. But the time for break a leave with a shears is really fast and DiggingHandler.handle
don't call DiggingMessage.FINISH_DIGGING
. I fix it temporary, but it's horrible and other cases like this one is possible. Maybe Netherrack with Diamond Pickaxe Efficiency V. If someone has an idea of how can i do that more smartly.
Thanks in advance. CrabeMan
Your PR does not compile.
Fixed.
Small hint: The gold tools are missing.
@hibo98 Yes thanks, i will add them this night when i'm back.
CrabeMan.
Which ticket does this cover?
@turt2live I believe it relates to #462
Currently, this PR cover:
CrabeMan.
Hi, In this PR, base durability for Pickaxe, Axe, Shovel, Sword, Hoe is set. Reduce points on breaking blocks and using hoe.
And fix #622 too.CrabeMan.