MineColonies

MineColonies

57M Downloads

Support Mending enchantment

magneticflux- opened this issue ยท 14 comments

commented

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

  1. Get a fishing rod with the mending enchantment
  2. Give to fisherman and watch him fish
  3. Observe that the durability does not go back up after reeling in a fish and collecting experience
commented

This was added a while ago =D

commented

This is being worked on. It is not that simple as its sounds so we will do our best.

commented

when i looked at it, it seemed pretty easy to do, i've asked a new guy to give it a crack ๐Ÿ˜„

commented

@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.

commented

Yeah that is what i was worried about
The actual repair code is not in the Enchantment
But in the XPOrb.

commented

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.

commented

@Electrocutor any chance you could make a seperate issues and expand on what you mean by that?

commented

Well, I fixed this issue. The fix will probably be in the next release or so.

commented

@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.

commented

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.

commented

@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.

commented

@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.

commented

@Vitridax are you still working on this?

commented

What's the status of this? I looked through where XP flows and this is the path I traced out:

  1. EntityAIWorkFisherman creates and EntityFishHook when ready to fish
  2. EntityFishHook is cast and reeled in and spawns the appropriate EntityXPOrbs
  3. EntityCitizen calls gatherXpOrbs() regularly and picks up the XP from fishing
  4. gatherXpOrbs() deletes the EntityXpOrbs and adds half the value using the EntityCitizen's addExperience(int) method
  5. The addExperience(int) method calls applyMending(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.