Skip to content

Commit

Permalink
Pawns will now mostly stay around the campfire during the day
Browse files Browse the repository at this point in the history
  • Loading branch information
remmintan committed Apr 15, 2024
1 parent ce36001 commit d83c5d1
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ public interface IServerFortressManager {
boolean isSurvival();

boolean isCreative();
Optional<BlockPos> getRandomPosWithinFortress();
List<ITargetedPawn> getAllTargetedPawns();

void increaseMaxColonistsCount();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public boolean canStart() {
if(colonist.getEatControl().map(IEatControl::isEating).orElse(false)) return false;
if(!isDay() || colonist.getTaskControl().hasTask()) return false;
final var posOptional = colonist.getServerFortressManager()
.flatMap(IServerFortressManager::getRandomPosWithinFortress);
.flatMap(IServerFortressManager::getRandomPositionAroundCampfire);
if(posOptional.isPresent()) {
goal = posOptional.get();
return true;
Expand Down
17 changes: 0 additions & 17 deletions src/main/java/org/minefortress/fortress/ServerFortressManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -633,23 +633,6 @@ public BlockPos getFortressCenter() {
return fortressCenter!=null?fortressCenter.toImmutable():null;
}

public Optional<BlockPos> getRandomPosWithinFortress(){
if(minX == Integer.MAX_VALUE) return Optional.empty();

final int x = getWorld().random.nextInt(maxX - minX) + minX;
final int z = getWorld().random.nextInt(maxZ - minZ) + minZ;
final int y = getWorld().getTopY(Heightmap.Type.WORLD_SURFACE, x, z);

final BlockPos fortressPos = new BlockPos(x, y, z);
if(getBuildingsManager().isPartOfAnyBuilding(fortressPos)) return Optional.empty();
boolean isFluid = getWorld().getBlockState(fortressPos).isOf(Blocks.WATER);
if(isFluid) return Optional.empty();
boolean isFluidAbove = getWorld().getBlockState(fortressPos.down()).isOf(Blocks.WATER);
if(isFluidAbove) return Optional.empty();

return Optional.of(fortressPos.up());
}

public boolean isPositionWithinFortress(BlockPos pos) {
if(minX == Integer.MAX_VALUE) {
return false;
Expand Down

0 comments on commit d83c5d1

Please sign in to comment.