Compare commits
2 Commits
296fe1efc2
...
db74d07155
Author | SHA1 | Date | |
---|---|---|---|
db74d07155 | |||
d578db6fb2 |
@ -62,7 +62,7 @@ class ExchangeItem<E> : Behavior<E>(
|
||||
owner.brain.eraseMemory(MemoryModuleType.CANT_REACH_WALK_TARGET_SINCE)
|
||||
if (closeAt != null) {
|
||||
// opened
|
||||
val chest = level.getBlockEntity(target!!)!!
|
||||
val chest = level.getBlockEntity(target!!) ?: return
|
||||
if (chest is ChestBlockEntity) {
|
||||
ChestBlockEntity.playSound(level, target!!, level.getBlockState(target!!), SoundEvents.CHEST_CLOSE)
|
||||
}
|
||||
|
@ -10,6 +10,7 @@ import net.minecraft.world.level.block.entity.BaseContainerBlockEntity
|
||||
import quaedam.Quaedam
|
||||
import quaedam.utils.getChunksNearby
|
||||
import java.util.*
|
||||
import kotlin.random.Random
|
||||
|
||||
class NearestVisibleContainer : Sensor<LivingEntity>() {
|
||||
|
||||
@ -33,7 +34,8 @@ 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 }
|
||||
.minByOrNull { it.distManhattan(entity.blockPosition()) }
|
||||
.shuffled(Random(entity.random.nextLong()))
|
||||
.minByOrNull { it.distManhattan(entity.blockPosition()) / 5 }
|
||||
entity.brain.setMemory(memory.get(), pos)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user