Support Mending enchantment
magneticflux- opened this issue ยท 14 comments
Minecolonies version
- Version 0.8.3167, MC 1.12, Forge 14.21.1.2424
Expected behavior
- Fisherman's rod doesn't break due to the XP collected during fishing
Actual behaviour
- The rod deteriorates at the normal rate, as if Mending wasn't applied
Steps to reproduce the problem
- Get a fishing rod with the mending enchantment
- Give to fisherman and watch him fish
- Observe that the durability does not go back up after reeling in a fish and collecting experience
This is being worked on. It is not that simple as its sounds so we will do our best.
when i looked at it, it seemed pretty easy to do, i've asked a new guy to give it a crack ๐
@Asherslab Thanks for the quick response! Now that I think about it, something similar should also probably happen with the miner, farmer, guards, blacksmith(?), and baker(?), since they all have opportunities to earn Vanilla Minecraft experience by smelting, fishing, mining, or killing things. Here's the full list of activities that produce XP orbs: Link.
EDIT: The relevant code for repairing is done in the EntityXPOrb
class, line #237
, in the onCollideWithPlayer
method.
Yeah that is what i was worried about
The actual repair code is not in the Enchantment
But in the XPOrb.
Perhaps if you can figure out a way to route this it could also allow all of the Tinkers effects to also work on NPCs.
@Electrocutor any chance you could make a seperate issues and expand on what you mean by that?
Well, I fixed this issue. The fix will probably be in the next release or so.
@magneticflux- The code is in the Citizen class, not the fisherman class. For some reason (unknown to me atm) fishing rods do not work, but other tools do. I just tested version 1.10.2-0.8.3265 (the code is identical between versions). A fisherman could not mend a fishing rod, but a builder could mend a shovel. I will look into this more later.
There is another bug that I found that may also be your problem. If a citizen's level is maxed out for their hut (lv 2,4,8,16 for hut lv 1,2,3,4), they will not mend tools either. I don't think this is your problem, but you might find it later and think it is the same thing, so I thought I'd mention it.
@Vitridax I'm running version 1.12-0.8.3302 and the fisherman isn't repairing his rod using experience. In the fisherman AI class, it seems to talk about collection XP orbs in a comment. Maybe the fisherman isn't using the usual method of adding XP? My fisherman is level 17, so he's still gaining XP somehow.
@Vitridax My fisherman's hut is level 4, but he's level 17 for some reason... I might be running into both bugs. None of my other workers are that high level right now.
What's the status of this? I looked through where XP flows and this is the path I traced out:
EntityAIWorkFisherman
creates andEntityFishHook
when ready to fishEntityFishHook
is cast and reeled in and spawns the appropriateEntityXPOrb
sEntityCitizen
callsgatherXpOrbs()
regularly and picks up the XP from fishinggatherXpOrbs()
deletes theEntityXpOrb
s and adds half the value using theEntityCitizen
'saddExperience(int)
method- The
addExperience(int)
method callsapplyMending(int)
and removes the appropriate amount of XP
I'm not seeing any bugs, so it looks like a weird edge case that is only triggered by the Fisherman.
EDIT: I was looking at the real EntityFishHook, not the custom one. The custom one still spawns an EntityXPOrb
though.