Railcraft

Railcraft

34M Downloads

Tunnel Bore does not respect enchanted bore heads

skyboy opened this issue ยท 5 comments

commented

Vanilla behaviors permit any item that can be damaged to be enchanted with unbreaking, however the Tunnel Bore subverts the normal damage procedure and so a bore head enchanted as such will still take the full damage.

This could be implemented by simplifying here: if (head.attemptDamageItem(1, rand)) setInventorySlotContents(0, null);

Somewhat related, not sure if I should make a separate issue for it however; it would be nice if at the same place, the Bore would attempt to replace its head from the attached minecarts inside the same conditional, such that the bore can have a stock of the fuel, tracks, and heads it needs to make it to a destination, barring it running into any other trouble.

commented

Yeah, you can enchant it with unbreaking, which applies to anything that can take damage, as defined by ItemStack.isItemStackDamageable().

If you wanted to also allow the pickaxe enchants such as fortune/silk touch you could add the method public int cofh_canEnchantApply(ItemStack stack, Enchantment ench) to your Item. In 1.7.10 it will be called if CoFHCore is installed and allow the item to override what enchantments it can take; return 1 to force allow, 0 to force disallow, and -1 to use the default behavior of the enchantment. It adds no dependency on CoFHCore.
You might have some luck opening an issue for similar functionality being added to forge for 1.8+.

commented

Heads should always require manual replacement, but supporting enchantments is ok.

Can you actually enchant a Bore Head with anything? Doesn't that require some code in the item/enchant?

commented

... or he could just apply them himself. There's an event for that or two. Or maybe we'll just stick with Unbreaking.

commented

I just checked and there are no forge hooks or events for applying enchantments to items. There is an event for altering anvil output, but "you may only apply these enchantments at an anvil" is unappealing design.

commented

Or you could just make new ones, like I did with the crowbar, no need to rely on someone else's code.