@@ -116,6 +116,15 @@ public class ChunkCoordIntPair {
return a(new ChunkCoordIntPair(chunkcoordintpair.x - i, chunkcoordintpair.z - i), new ChunkCoordIntPair(chunkcoordintpair.x + i, chunkcoordintpair.z + i));
}
+ // Yatopia start
+ public static java.util.List<ChunkCoordIntPair> streamList(ChunkCoordIntPair center, int radius) {
- java.util.List<VillagePlaceRecord> list = villageplace.b(type -> type == VillagePlaceType.v, blockposition, i, VillagePlace.Occupancy.ANY).collect(java.util.stream.Collectors.toList());
+ java.util.List<VillagePlaceRecord> list = villageplace.bList(type -> type == VillagePlaceType.v, blockposition, i, VillagePlace.Occupancy.ANY); // Yatopia
// Yatopia start - fix portal bug
if (world.origamiConfig.useBlockDistanceInPortalSearchRadius) {
+ public java.util.List<VillagePlaceRecord> cList(Predicate<VillagePlaceType> predicate, BlockPosition pos, int i, VillagePlace.Occupancy occupancy) {
+ int j = i * i;
+ java.util.List<VillagePlaceRecord> ret = new java.util.ArrayList<>();
+ for (VillagePlaceRecord record : this.bList(predicate, pos, i, occupancy)) {
+ if (record.getPosition().distanceSquared(pos) <= j) { ret.add(record); }
+ }
+ return ret;
+ }
+
public Stream<VillagePlaceRecord> c(Predicate<VillagePlaceType> predicate, BlockPosition blockposition, int i, VillagePlace.Occupancy villageplace_occupancy) {
int j = i * i;
@@ -83,10 +105,27 @@ public class VillagePlace extends RegionFileSection<VillagePlaceSection> {
});
}
+ // Yatopia start
+ public java.util.List<BlockPosition> aList(Predicate<VillagePlaceType> predicate, Predicate<BlockPosition> posFilter, BlockPosition pos, int i, VillagePlace.Occupancy occupancy) {
+ java.util.List<BlockPosition> ret = new java.util.ArrayList<>();
+ for (VillagePlaceRecord record : this.cList(predicate, pos, i, occupancy)) {
+ if (posFilter.test(recordPosition)) ret.add(recordPosition);
+ }
+ return ret;
+ }
+ // Yatopia end
public Stream<BlockPosition> a(Predicate<VillagePlaceType> predicate, Predicate<BlockPosition> predicate1, BlockPosition blockposition, int i, VillagePlace.Occupancy villageplace_occupancy) {
return this.c(predicate, blockposition, i, villageplace_occupancy).map(VillagePlaceRecord::f).filter(predicate1);
}
+ // Yatopia start
+ public java.util.List<BlockPosition> bList(Predicate<VillagePlaceType> predicate, Predicate<BlockPosition> posFilter, BlockPosition pos, int i, VillagePlace.Occupancy occupancy) {
+ java.util.List<BlockPosition> ret = aList(predicate, posFilter, pos, i, occupancy);
public Stream<BlockPosition> b(Predicate<VillagePlaceType> predicate, Predicate<BlockPosition> predicate1, BlockPosition blockposition, int i, VillagePlace.Occupancy villageplace_occupancy) {
return this.a(predicate, predicate1, blockposition, i, villageplace_occupancy).sorted(Comparator.comparingDouble((blockposition1) -> {
return blockposition1.j(blockposition);
@@ -94,26 +133,53 @@ public class VillagePlace extends RegionFileSection<VillagePlaceSection> {
}
public Optional<BlockPosition> c(Predicate<VillagePlaceType> predicate, Predicate<BlockPosition> predicate1, BlockPosition blockposition, int i, VillagePlace.Occupancy villageplace_occupancy) {
- return this.a(predicate, predicate1, blockposition, i, villageplace_occupancy).findFirst();
+ // Yatopia start
+ java.util.List<BlockPosition> posList = aList(predicate, predicate1, blockposition, i, villageplace_occupancy);
public Optional<BlockPosition> d(Predicate<VillagePlaceType> predicate, BlockPosition blockposition, int i, VillagePlace.Occupancy villageplace_occupancy) {
+ // Yatopia start
+ VillagePlaceRecord best = null;
+ for (VillagePlaceRecord record : cList(predicate, blockposition, i, villageplace_occupancy)) {
+ if (best == null || (record.getPosition().distanceSquared(blockposition) < best.getPosition().distanceSquared(blockposition))) {
+ best = record;
+ }
+ }
+ return best == null ? Optional.empty() : Optional.of(best.getPosition());
+ /*
return this.c(predicate, blockposition, i, villageplace_occupancy).map(VillagePlaceRecord::f).min(Comparator.comparingDouble((blockposition1) -> {
return blockposition1.j(blockposition);
}));
+ */ // Yatopia end
}
public Optional<BlockPosition> a(Predicate<VillagePlaceType> predicate, Predicate<BlockPosition> predicate1, BlockPosition blockposition, int i) {
+ // Yatopia start
+ java.util.List<VillagePlaceRecord> list = this.cList(predicate, blockposition, i, VillagePlace.Occupancy.HAS_SPACE);
+ java.util.List<VillagePlaceRecord> filtered = new java.util.ArrayList<>();
+ for (VillagePlaceRecord record : list) {
+ if (predicate1.test(record.getPosition())) {
+ filtered.add(record);
+ }
+ }
+ if (filtered.isEmpty()) return Optional.empty();
+ VillagePlaceRecord first = filtered.get(0);
+ first.b();
+ return Optional.of(first.getPosition());
+ /*
return this.c(predicate, blockposition, i, VillagePlace.Occupancy.HAS_SPACE).filter((villageplacerecord) -> {
return predicate1.test(villageplacerecord.f());
}).findFirst().map((villageplacerecord) -> {
villageplacerecord.b();
return villageplacerecord.f();
});
+ */ // Yatopia end
}
public Optional<BlockPosition> a(Predicate<VillagePlaceType> predicate, Predicate<BlockPosition> predicate1, VillagePlace.Occupancy villageplace_occupancy, BlockPosition blockposition, int i, Random random) {
- List<VillagePlaceRecord> list = (List) this.c(predicate, blockposition, i, villageplace_occupancy).collect(Collectors.toList());
+ List<VillagePlaceRecord> list = this.cList(predicate, blockposition, i, villageplace_occupancy); // Yatopia
Collections.shuffle(list, random);
for (VillagePlaceRecord villageplacerecord : list) {
@@ -214,7 +280,7 @@ public class VillagePlace extends RegionFileSection<VillagePlaceSection> {