Compare commits

...

4 Commits

Author SHA1 Message Date
22b1450a72
feat: adjust swarm time table 2023-08-23 14:28:06 +08:00
abb5646959
fix: game crash when no container available 2023-08-21 09:10:13 +08:00
1ee1c7215d
fix: container focus again 2023-08-18 09:34:07 +08:00
d45f8d2a57
fix: signed 32-bits integer overflowed
Use in the wild: Mojang
2023-08-18 09:28:00 +08:00
3 changed files with 10 additions and 6 deletions

View File

@ -34,8 +34,9 @@ class NearestVisibleContainer : Sensor<LivingEntity>() {
if (entity.tickCount and 0b11111 == 0) { // 32gt
val pos = level.getChunksNearby(entity.blockPosition(), 1)
.flatMap { it.blockEntities.filterValues { be -> be is BaseContainerBlockEntity }.keys }
.shuffled(Random(entity.random.nextLong()))
.minByOrNull { it.distManhattan(entity.blockPosition()) / 5 }
.sortedBy { it.distManhattan(entity.blockPosition()) / 5 }
.shuffled(Random(System.currentTimeMillis() / 10000))
.firstOrNull()
entity.brain.setMemory(memory.get(), pos)
}
}

View File

@ -29,8 +29,8 @@ object ProjectedPersonAI {
val defaultSchedule = Quaedam.schedules.register("projected_person_default") {
ScheduleBuilder(Schedule()).changeActivityAt(10, Activity.IDLE)
.changeActivityAt(10, Activity.IDLE)
.changeActivityAt(2000, Activity.WORK)
.changeActivityAt(7300, Activity.IDLE)
.changeActivityAt(900, Activity.WORK)
.changeActivityAt(6300, Activity.IDLE)
.changeActivityAt(9000, Activity.WORK)
.changeActivityAt(10700, Activity.IDLE)
.changeActivityAt(11000, Activity.PLAY)

View File

@ -75,8 +75,11 @@ class ProjectorBlockEntity(pos: BlockPos, state: BlockState) :
val chunk = ChunkPos(SectionPos.blockToSectionCoord(blockPos.x), SectionPos.blockToSectionCoord(blockPos.z))
val minChunk = ChunkPos(chunk.x - radius, chunk.z - radius)
val maxChunk = ChunkPos(chunk.x + radius, chunk.z + radius)
val minBlock = BlockPos(minChunk.minBlockX, Int.MIN_VALUE, minChunk.minBlockZ)
val maxBlock = BlockPos(maxChunk.maxBlockX, Int.MAX_VALUE, maxChunk.maxBlockZ)
// Y is not the limit value of Int because at
// Lnet/minecraft/world/level/entity/EntitySectionStorage;forEachAccessibleNonEmptySection(Lnet/minecraft/world/phys/AABB;Lnet/minecraft/util/AbortableIterationConsumer;)V
// it may get overflow
val minBlock = BlockPos(minChunk.minBlockX, Short.MIN_VALUE.toInt(), minChunk.minBlockZ)
val maxBlock = BlockPos(maxChunk.maxBlockX, Short.MAX_VALUE.toInt(), maxChunk.maxBlockZ)
effectArea = BoundingBox.fromCorners(minBlock, maxBlock)
effectAreaAABB = AABB(minBlock, maxBlock)
}