-
-
Notifications
You must be signed in to change notification settings - Fork 345
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'version/main' into feature/disable_unnecessary_patreon_…
…feature_checks
- Loading branch information
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