-
-
Notifications
You must be signed in to change notification settings - Fork 348
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix npe with bad crafting recipes after e.g. mod removal (#10163)
Fix npe with bad crafting recipes after e.g. mod removal Fix pathing to consider pathblocks again(no those are not diving) Adjust cost calculation to add randomness first, so those cannot overshadow cost reductions Improve builder work position to not go too close to the placed block, avoiding to place a block inside itself Improve Study and - Research pathing to bookcases, they now have a bigger valid range, still try to move close though
- Loading branch information
1 parent
95bb1de
commit 4f972e8
Showing
11 changed files
with
89 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
src/main/java/com/minecolonies/core/entity/pathfinding/navigation/PathfindingAIHelper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package com.minecolonies.core.entity.pathfinding.navigation; | ||
|
||
import com.minecolonies.api.entity.other.AbstractFastMinecoloniesEntity; | ||
import com.minecolonies.api.util.BlockPosUtil; | ||
import com.minecolonies.core.entity.pathfinding.pathjobs.PathJobMoveCloseToXNearY; | ||
import net.minecraft.core.BlockPos; | ||
|
||
public class PathfindingAIHelper | ||
{ | ||
/** | ||
* Tries to walk close to a given pos, staying near another position. | ||
* | ||
* @param entity | ||
* @param desiredPosition | ||
* @param nearbyPosition | ||
* @param distToDesired | ||
* @return True while walking, false when reached | ||
*/ | ||
public static boolean walkCloseToXNearY( | ||
final AbstractFastMinecoloniesEntity entity, final BlockPos desiredPosition, | ||
final BlockPos nearbyPosition, | ||
final int distToDesired) | ||
{ | ||
final MinecoloniesAdvancedPathNavigate nav = ((MinecoloniesAdvancedPathNavigate) entity.getNavigation()); | ||
|
||
if (nav.isDone() || (nav.getPathResult() != null | ||
&& !(nav.getPathResult().getJob() instanceof PathJobMoveCloseToXNearY job | ||
&& job.nearbyPosition.equals(nearbyPosition) | ||
&& job.desiredPosition.equals(desiredPosition) | ||
&& job.distToDesired == distToDesired))) | ||
{ | ||
// Check distance once navigation is done, to let the entity walk | ||
if (BlockPosUtil.dist(entity.blockPosition(), desiredPosition) < distToDesired) | ||
{ | ||
return false; | ||
} | ||
|
||
PathJobMoveCloseToXNearY pathJob = new PathJobMoveCloseToXNearY(entity.level, desiredPosition, nearbyPosition, distToDesired, entity); | ||
nav.setPathJob(pathJob, desiredPosition, 1.0, false); | ||
} | ||
|
||
return true; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters