Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
--- a/net/minecraft/world/entity/ai/behavior/AcquirePoi.java
+++ b/net/minecraft/world/entity/ai/behavior/AcquirePoi.java
@@ -54,6 +_,21 @@
final Optional<Byte> onPoiAcquisitionEvent,
final BiPredicate<ServerLevel, BlockPos> validPoi
) {
+ // Canvas start - configurable scan range and if poi should load
+ return create(poiType, memoryToValidate, memoryToAcquire, onlyIfAdult, onPoiAcquisitionEvent, validPoi, (_) -> SCAN_RANGE, (_) -> ca.spottedleaf.moonrise.patches.poi_lookup.PoiAccess.LOAD_FOR_SEARCHING);
+ }
+
+ public static BehaviorControl<PathfinderMob> create(
+ final Predicate<Holder<PoiType>> poiType,
+ final MemoryModuleType<GlobalPos> memoryToValidate,
+ final MemoryModuleType<GlobalPos> memoryToAcquire,
+ final boolean onlyIfAdult,
+ final Optional<Byte> onPoiAcquisitionEvent,
+ final BiPredicate<ServerLevel, BlockPos> validPoi,
+ final java.util.function.Function<Mob, Integer> scanRange,
+ final java.util.function.Function<Mob, Boolean> shouldLoad
+ ) {
+ // Canvas end - configurable scan range and if poi should load
int batchSize = 5;
int rate = 20;
MutableLong nextScheduledStart = new MutableLong(0L);
@@ -90,7 +_,7 @@
};
// Paper start - optimise POI searches
java.util.List<Pair<Holder<PoiType>, BlockPos>> poiPositionsRaw = new java.util.ArrayList<>();
- ca.spottedleaf.moonrise.patches.poi_lookup.PoiAccess.findNearestPoiPositions(poiManager, poiType, cacheTest, body.blockPosition(), SCAN_RANGE, Double.MAX_VALUE, PoiManager.Occupancy.HAS_SPACE, ca.spottedleaf.moonrise.patches.poi_lookup.PoiAccess.LOAD_FOR_SEARCHING, 5, poiPositionsRaw);
+ ca.spottedleaf.moonrise.patches.poi_lookup.PoiAccess.findNearestPoiPositions(poiManager, poiType, cacheTest, body.blockPosition(), scanRange.apply(body), Double.MAX_VALUE, PoiManager.Occupancy.HAS_SPACE, shouldLoad.apply(body), 5, poiPositionsRaw); // Canvas - configurable scan range and if poi should load
Set<Pair<Holder<PoiType>, BlockPos>> poiPositions = new java.util.HashSet<>(poiPositionsRaw.size());
for (Pair<Holder<PoiType>, BlockPos> pair : poiPositionsRaw) {
if (validPoi.test(level, pair.getSecond())) {
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
--- a/net/minecraft/world/entity/ai/behavior/VillagerGoalPackages.java
+++ b/net/minecraft/world/entity/ai/behavior/VillagerGoalPackages.java
@@ -54,13 +_,15 @@
MemoryModuleType.POTENTIAL_JOB_SITE,
true,
Optional.empty(),
- (l, p) -> true
+ (l, p) -> true, (body) -> body.level().canvasConfig().entities.villagers.reduceJobSitePoiSearchRange ? 16 : 48, (body) -> body.level().canvasConfig().entities.villagers.villagerAcquirePoiTasksLoadChunks // Canvas - configurable scan range and if poi should load
)
),
Pair.of(7, new GoToPotentialJobSite(speedModifier)),
Pair.of(8, YieldJobSite.create(speedModifier)),
- Pair.of(10, AcquirePoi.create(p -> p.is(PoiTypes.HOME), MemoryModuleType.HOME, false, Optional.of((byte)14), VillagerGoalPackages::validateBedPoi)),
- Pair.of(10, AcquirePoi.create(p -> p.is(PoiTypes.MEETING), MemoryModuleType.MEETING_POINT, true, Optional.of((byte)14))),
+ // Canvas start - configurable scan range and if poi should load
+ Pair.of(10, AcquirePoi.create(p -> p.is(PoiTypes.HOME), MemoryModuleType.HOME, MemoryModuleType.HOME, false, Optional.of((byte)14), VillagerGoalPackages::validateBedPoi, (body) -> body.level().canvasConfig().entities.villagers.reduceHomePoiSearchRange ? 16 : 48, (body) -> body.level().canvasConfig().entities.villagers.villagerAcquirePoiTasksLoadChunks)),
+ Pair.of(10, AcquirePoi.create(p -> p.is(PoiTypes.MEETING), MemoryModuleType.MEETING_POINT, MemoryModuleType.MEETING_POINT, true, Optional.of((byte)14), (_, _) -> true, (body) -> body.level().canvasConfig().entities.villagers.reduceMeetingPointPoiSearchRange ? 16 : 48, (body) -> body.level().canvasConfig().entities.villagers.villagerAcquirePoiTasksLoadChunks)),
+ // Canvas end - configurable scan range and if poi should load
Pair.of(10, AssignProfessionFromJobSite.create()),
Pair.of(10, ResetProfession.create())
);
20 changes: 20 additions & 0 deletions canvas-server/src/main/java/io/canvasmc/canvas/WorldConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -380,9 +380,29 @@ public Predicate<Projectile> getDoesProjectileLoadChunksOverridePredicate() {

{
option("skeletonAimAccuracy").docs("Defines the inaccuracy of skeleton bow shots. 14 is Vanilla, higher is more inaccurate and lower is more accurate");
option("villagers")
.docs(
"Options regarding villagers. The options for reducing POI search ranges shrink the search radius(in blocks)",
"from 48 to 16, which can help improve tick times with little Vanilla deviation, however this will prevent Villagers",
"from acquiring POIs between 17-48 blocks away"
);
}

public double skeletonAimAccuracy = 14.0D;

public Villagers villagers = new Villagers();
public static class Villagers extends Part {

{
option("villagerAcquirePoiTasksLoadChunks")
.docs("Whether the server should allow Villagers to load unloaded chunks for Villagers to locate POIs");
}

public boolean villagerAcquirePoiTasksLoadChunks = true;
public boolean reduceJobSitePoiSearchRange = false;
public boolean reduceHomePoiSearchRange = false;
public boolean reduceMeetingPointPoiSearchRange = false;
}
}

public Combat combat = new Combat();
Expand Down