style: format code

This commit is contained in:
xtex 2023-07-30 21:19:41 +08:00
parent 68c90c8f8a
commit e18b4d78fb
Signed by: xtex
GPG Key ID: B918086ED8045B91

View File

@ -32,30 +32,32 @@ class ExchangeItem<E> : Behavior<E>(
entity.brain.eraseMemory(MemoryModuleType.CANT_REACH_WALK_TARGET_SINCE) entity.brain.eraseMemory(MemoryModuleType.CANT_REACH_WALK_TARGET_SINCE)
} }
override fun canStillUse(level: ServerLevel, entity: E, l: Long) = override fun canStillUse(level: ServerLevel, owner: E, gameTime: Long) =
entity.brain.getMemory(MemoryModuleType.WALK_TARGET).isPresent || entity.brain.getMemory(MemoryModuleType.CANT_REACH_WALK_TARGET_SINCE).isEmpty || (closeAt != null && closeAt!! < l) owner.brain.getMemory(MemoryModuleType.WALK_TARGET).isPresent
|| owner.brain.getMemory(MemoryModuleType.CANT_REACH_WALK_TARGET_SINCE).isEmpty
|| (closeAt != null && closeAt!! < gameTime)
override fun tick(level: ServerLevel, entity: E, l: Long) { override fun tick(level: ServerLevel, owner: E, gameTime: Long) {
if (closeAt == null) { if (closeAt == null) {
if (entity.brain.getMemory(MemoryModuleType.WALK_TARGET).isEmpty) { if (owner.brain.getMemory(MemoryModuleType.WALK_TARGET).isEmpty) {
// reached // reached
val chest = level.getBlockEntity(target!!) as BaseContainerBlockEntity val chest = level.getBlockEntity(target!!) as BaseContainerBlockEntity
if (chest is ChestBlockEntity) { if (chest is ChestBlockEntity) {
ChestBlockEntity.playSound(level, target!!, level.getBlockState(target!!), SoundEvents.CHEST_OPEN) ChestBlockEntity.playSound(level, target!!, level.getBlockState(target!!), SoundEvents.CHEST_OPEN)
} }
if (chest.isEmpty && level.random.nextBoolean()) { if (chest.isEmpty && level.random.nextBoolean()) {
closeAt = l + 7 closeAt = gameTime + 7
} else { } else {
closeAt = l + 10 + level.random.nextInt(100) closeAt = gameTime + 10 + level.random.nextInt(100)
exchangeItems(level, entity) exchangeItems(level, owner)
} }
} }
} }
} }
override fun stop(level: ServerLevel, entity: E, l: Long) { override fun stop(level: ServerLevel, owner: E, gameTime: Long) {
entity.brain.eraseMemory(MemoryModuleType.WALK_TARGET) owner.brain.eraseMemory(MemoryModuleType.WALK_TARGET)
entity.brain.eraseMemory(MemoryModuleType.CANT_REACH_WALK_TARGET_SINCE) owner.brain.eraseMemory(MemoryModuleType.CANT_REACH_WALK_TARGET_SINCE)
if (closeAt != null) { if (closeAt != null) {
// opened // opened
val chest = level.getBlockEntity(target!!)!! val chest = level.getBlockEntity(target!!)!!