-
-
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.
Reworked stuck handling, nonsafe destinations are now eligible for pa…
…rtials stuck handling. (#10588) Reworked stuck handling, nonsafe destinations are now eligible for partial stuck handling. Calling .stop on the navigator signals no further entity movement is desired, also reset stuck handling. Fixed a bug causing the stuck handler to not progress further than random moving(outside of global timeout tp) Fixed a bug where citizens started from a wrong position, when they were standing on the edge of a block Citizen info command no longer prints duplicate information, nor sends it to all OP. Now also displays stuck level. Citizen info command now allows teleporting to the displayed coordinates on click
- Loading branch information
1 parent
ebe99bb
commit abbb0d9
Showing
12 changed files
with
355 additions
and
222 deletions.
There are no files selected for viewing
2 changes: 1 addition & 1 deletion
2
...avigation/IDynamicHeuristicNavigator.java → ...thfinding/IDynamicHeuristicNavigator.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
71 changes: 71 additions & 0 deletions
71
src/main/java/com/minecolonies/api/entity/pathfinding/IMinecoloniesNavigator.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,71 @@ | ||
package com.minecolonies.api.entity.pathfinding; | ||
|
||
import com.minecolonies.core.entity.pathfinding.navigation.MinecoloniesAdvancedPathNavigate; | ||
import com.minecolonies.core.entity.pathfinding.pathjobs.AbstractPathJob; | ||
import com.minecolonies.core.entity.pathfinding.pathresults.PathResult; | ||
import net.minecraft.core.BlockPos; | ||
import net.minecraft.world.entity.Mob; | ||
import org.jetbrains.annotations.NotNull; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
/** | ||
* Describes the Navigator used by minecolonies entities | ||
*/ | ||
public interface IMinecoloniesNavigator | ||
{ | ||
/** | ||
* Sets a new pathjob to execute | ||
* | ||
* @param job to run | ||
* @param dest | ||
* @param speedFactor | ||
* @param safeDestination | ||
* @param <T> | ||
* @return null or new pathresult | ||
*/ | ||
@Nullable | ||
<T extends AbstractPathJob> PathResult<T> setPathJob( | ||
@NotNull AbstractPathJob job, | ||
BlockPos dest, | ||
double speedFactor, boolean safeDestination); | ||
|
||
/** | ||
* Indirectly triggers a recalulation, by marking the navigator as done | ||
*/ | ||
void recalc(); | ||
|
||
/** | ||
* Returns the pathresult holding the current pathing task and result | ||
* | ||
* @return | ||
*/ | ||
PathResult getPathResult(); | ||
|
||
/** | ||
* Gets the safe destination the entity wants to travel to | ||
* | ||
* @return | ||
*/ | ||
BlockPos getSafeDestination(); | ||
|
||
/** | ||
* Gets the entity of the navigator | ||
* | ||
* @return | ||
*/ | ||
Mob getOurEntity(); | ||
|
||
/** | ||
* Pauses the navigator for X ticks from starting any new pathing tasks | ||
* | ||
* @param pauseTicks | ||
*/ | ||
void setPauseTicks(int pauseTicks); | ||
|
||
/** | ||
* Returns the stuck handler used by the navigator | ||
* | ||
* @return | ||
*/ | ||
IStuckHandler<MinecoloniesAdvancedPathNavigate> getStuckHandler(); | ||
} |
15 changes: 12 additions & 3 deletions
15
src/main/java/com/minecolonies/api/entity/pathfinding/IStuckHandler.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 |
---|---|---|
@@ -1,16 +1,25 @@ | ||
package com.minecolonies.api.entity.pathfinding; | ||
|
||
import com.minecolonies.core.entity.pathfinding.navigation.AbstractAdvancedPathNavigate; | ||
import net.minecraft.world.entity.ai.navigation.PathNavigation; | ||
|
||
/** | ||
* Stuck handler for pathing, gets called to check/deal with stuck status | ||
*/ | ||
public interface IStuckHandler | ||
public interface IStuckHandler<NAV extends PathNavigation & IMinecoloniesNavigator> | ||
{ | ||
/** | ||
* Checks if the navigator is stuck | ||
* | ||
* @param navigator navigator to check | ||
*/ | ||
void checkStuck(final AbstractAdvancedPathNavigate navigator); | ||
void checkStuck(final NAV navigator); | ||
|
||
void resetGlobalStuckTimers(); | ||
|
||
/** | ||
* Returns the stuck level (0-9) indicating how long the entity is stuck and which stuck actions got used | ||
* | ||
* @return | ||
*/ | ||
public int getStuckLevel(); | ||
} |
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
Oops, something went wrong.