Hearthlings not respecting adjacency regions, harvesting from wrong position

At first I thought the problem was with my regions using decimal values (like 1.5). But even after I round it all to whole numbers, they are harvesting it from very strange (and random) positions, most of the time 3 blocks far from the correct place.

(The correct place to harvest that item is inside the red box. Worked in old versions)

Thanks for reporting, Bruno!
This seems fishy :thinking:

2 Likes

Somebody have too long hands :rofl:

Thanks for sharing your puns instead of being shellfish with them and clamming up.

2 Likes

Does that hearthling have a weapon with long reach, by any chance?

The fishing rod has a slightly longer reach if I recall correctly, then yes

Weapon reach will extend harvesting reach.

Yes, the fishing pole have a higher ranger. That is a shame though, as the harvesting animation used (fiddle) does not even use the item.

Copied the saw range (0.75) to test and it still is offset. (fishing rod was 2.5)

image

1 Like

Copied the saw range (0.75) to test and it still is offset. (fishing rod was 2.5)

The range is the distance to the adjacency region.

1 Like

But this was a change right? In old versions they would step in the red box.

I changed it to 0:
image

Seems like they are ignoring the red and going for the collision region.

1 Like

Yes, it was a change to support some upcoming content. See get_harvest_range() in entities.lua. I’ve changed it to the following for the next release so that it’s easier to achieve closer harvesting distances:

function entities.get_harvest_range(entity)
   local RESOURCE_RADIUS = 0.5 -- distance from the center of a voxel to the edge

   local entity_reach = radiant.entities.get_entity_data(entity, 'stonehearth:entity_reach') or 1
   local tool_reach = 0
   local weapon = stonehearth.combat:get_main_weapon(entity)
   if radiant.entities.exists(weapon) then
      local weapon_data = radiant.entities.get_entity_data(weapon, 'stonehearth:combat:weapon_data')
      if weapon_data and weapon_data.reach then
         tool_reach = weapon_data.reach
      end
   end

   return entity_reach + tool_reach - RESOURCE_RADIUS
end
1 Like