GlowstoneMC / Glowstone-Legacy

An open-source server for the Bukkit Minecraft modding interface
Other
363 stars 121 forks source link

Tool durability #627

Open ghost opened 9 years ago

ghost commented 9 years ago

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.

gdude2002 commented 9 years ago

622 doesn't have anything to do with this PR - it would have been better to submit that fix as a separate PR.

445 also has some base durability stuff. #462 is the relevant ticket for this PR.

Tonodus commented 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?

turt2live commented 9 years ago

@CrabeMan Only one issue can be resolved per pull request. Remove one of the implementations for this to be reviewed.

Thanks.

ghost commented 9 years ago

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.

turt2live commented 9 years ago

You override your new method to return 0 and use a hardcoded 1.

ghost commented 9 years ago

Hello, yes the override method in ItemHoe calculateBreakDamage return damage for breaking block. But in rightClickBlock it's damage for using the Hoe.

CrabeMan.

ghost commented 9 years ago

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

turt2live commented 9 years ago

Your PR does not compile.

ghost commented 9 years ago

Fixed.

hibo98 commented 9 years ago

Small hint: The gold tools are missing.

ghost commented 9 years ago

@hibo98 Yes thanks, i will add them this night when i'm back.

CrabeMan.

turt2live commented 9 years ago

Which ticket does this cover?

gdude2002 commented 9 years ago

@turt2live I believe it relates to #462

ghost commented 9 years ago

Currently, this PR cover:

CrabeMan.