feat: idle activities
This commit is contained in:
parent
0fceb397d1
commit
9aa47128c7
@ -39,6 +39,7 @@ object Quaedam {
|
|||||||
val memoryTypes = DeferredRegister.create(ID, Registries.MEMORY_MODULE_TYPE)!!
|
val memoryTypes = DeferredRegister.create(ID, Registries.MEMORY_MODULE_TYPE)!!
|
||||||
val sensors = DeferredRegister.create(ID, Registries.SENSOR_TYPE)!!
|
val sensors = DeferredRegister.create(ID, Registries.SENSOR_TYPE)!!
|
||||||
val soundEvents = DeferredRegister.create(ID, Registries.SOUND_EVENT)!!
|
val soundEvents = DeferredRegister.create(ID, Registries.SOUND_EVENT)!!
|
||||||
|
val poiTypes = DeferredRegister.create(ID, Registries.POINT_OF_INTEREST_TYPE)!!
|
||||||
val projectionEffects by lazy { DeferredRegister.create(ID, ProjectionEffectType.registryKey)!! }
|
val projectionEffects by lazy { DeferredRegister.create(ID, ProjectionEffectType.registryKey)!! }
|
||||||
|
|
||||||
val creativeModeTab: RegistrySupplier<CreativeModeTab> = creativeModeTabs.register("quaedam") {
|
val creativeModeTab: RegistrySupplier<CreativeModeTab> = creativeModeTabs.register("quaedam") {
|
||||||
@ -72,6 +73,7 @@ object Quaedam {
|
|||||||
memoryTypes.register()
|
memoryTypes.register()
|
||||||
sensors.register()
|
sensors.register()
|
||||||
soundEvents.register()
|
soundEvents.register()
|
||||||
|
poiTypes.register()
|
||||||
projectionEffects.register()
|
projectionEffects.register()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -0,0 +1,58 @@
|
|||||||
|
package quaedam.projection.swarm.ai
|
||||||
|
|
||||||
|
import net.minecraft.core.GlobalPos
|
||||||
|
import net.minecraft.world.entity.ai.behavior.AcquirePoi
|
||||||
|
import net.minecraft.world.entity.ai.behavior.StrollAroundPoi
|
||||||
|
import net.minecraft.world.entity.ai.behavior.StrollToPoi
|
||||||
|
import net.minecraft.world.entity.ai.memory.MemoryModuleType
|
||||||
|
import net.minecraft.world.entity.ai.village.poi.PoiType
|
||||||
|
import net.minecraft.world.entity.ai.village.poi.PoiTypes
|
||||||
|
import net.minecraft.world.level.block.Blocks
|
||||||
|
import quaedam.Quaedam
|
||||||
|
import quaedam.projection.music.SmartInstrumentBlock
|
||||||
|
import java.util.*
|
||||||
|
|
||||||
|
object AmusementAI {
|
||||||
|
|
||||||
|
const val ID = "amusement"
|
||||||
|
|
||||||
|
val poiType = Quaedam.poiTypes.register(ID) {
|
||||||
|
PoiType(
|
||||||
|
setOf(
|
||||||
|
Blocks.NOTE_BLOCK,
|
||||||
|
SmartInstrumentBlock,
|
||||||
|
Blocks.HONEY_BLOCK,
|
||||||
|
Blocks.TARGET,
|
||||||
|
).flatMap { it.stateDefinition.possibleStates }.toSet(),
|
||||||
|
16, 10
|
||||||
|
)
|
||||||
|
}!!
|
||||||
|
|
||||||
|
val poiTypes by lazy {
|
||||||
|
setOf(
|
||||||
|
poiType.key,
|
||||||
|
PoiTypes.LIBRARIAN,
|
||||||
|
PoiTypes.MEETING,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
val memory = Quaedam.memoryTypes.register(ID) {
|
||||||
|
MemoryModuleType(Optional.of(GlobalPos.CODEC))
|
||||||
|
}!!
|
||||||
|
|
||||||
|
fun createAcquirePoi() =
|
||||||
|
AcquirePoi.create({ it.`is` { key -> key in poiTypes } }, memory.get(), false, Optional.empty())
|
||||||
|
|
||||||
|
fun createStrollToPoi() =
|
||||||
|
StrollToPoi.create(memory.get(), 0.4f, 7, 15)
|
||||||
|
|
||||||
|
fun createStrollToPoiBaby() =
|
||||||
|
StrollToPoi.create(memory.get(), 0.7f, 5, 10)
|
||||||
|
|
||||||
|
fun createStrollAroundPoi() =
|
||||||
|
StrollAroundPoi.create(memory.get(), 0.4f, 10)
|
||||||
|
|
||||||
|
fun createStrollAroundPoiBaby() =
|
||||||
|
StrollAroundPoi.create(memory.get(), 0.55f, 8)
|
||||||
|
|
||||||
|
}
|
@ -1,6 +1,7 @@
|
|||||||
package quaedam.projection.swarm.ai
|
package quaedam.projection.swarm.ai
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableList
|
import com.google.common.collect.ImmutableList
|
||||||
|
import net.minecraft.core.Holder
|
||||||
import net.minecraft.core.registries.Registries
|
import net.minecraft.core.registries.Registries
|
||||||
import net.minecraft.tags.TagKey
|
import net.minecraft.tags.TagKey
|
||||||
import net.minecraft.world.entity.LivingEntity
|
import net.minecraft.world.entity.LivingEntity
|
||||||
@ -10,6 +11,8 @@ import net.minecraft.world.entity.ai.memory.MemoryModuleType
|
|||||||
import net.minecraft.world.entity.ai.memory.MemoryStatus
|
import net.minecraft.world.entity.ai.memory.MemoryStatus
|
||||||
import net.minecraft.world.entity.ai.memory.NearestVisibleLivingEntities
|
import net.minecraft.world.entity.ai.memory.NearestVisibleLivingEntities
|
||||||
import net.minecraft.world.entity.ai.sensing.SensorType
|
import net.minecraft.world.entity.ai.sensing.SensorType
|
||||||
|
import net.minecraft.world.entity.ai.village.poi.PoiType
|
||||||
|
import net.minecraft.world.entity.ai.village.poi.PoiTypes
|
||||||
import net.minecraft.world.entity.monster.Monster
|
import net.minecraft.world.entity.monster.Monster
|
||||||
import net.minecraft.world.entity.schedule.Activity
|
import net.minecraft.world.entity.schedule.Activity
|
||||||
import net.minecraft.world.entity.schedule.Schedule
|
import net.minecraft.world.entity.schedule.Schedule
|
||||||
@ -51,6 +54,7 @@ object ProjectedPersonAI {
|
|||||||
|
|
||||||
init {
|
init {
|
||||||
BedInChunkSensor
|
BedInChunkSensor
|
||||||
|
AmusementAI
|
||||||
NearestVisibleContainer
|
NearestVisibleContainer
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -129,6 +133,9 @@ object ProjectedPersonAI {
|
|||||||
private fun initIdleActivity(brain: Brain<ProjectedPersonEntity>) {
|
private fun initIdleActivity(brain: Brain<ProjectedPersonEntity>) {
|
||||||
brain.addActivity(
|
brain.addActivity(
|
||||||
Activity.IDLE, ImmutableList.of(
|
Activity.IDLE, ImmutableList.of(
|
||||||
|
5 weight AmusementAI.createStrollAroundPoi(),
|
||||||
|
7 weight AmusementAI.createStrollToPoi(),
|
||||||
|
9 weight AmusementAI.createAcquirePoi(),
|
||||||
10 weight createStrollBehavior(),
|
10 weight createStrollBehavior(),
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
@ -137,7 +144,10 @@ object ProjectedPersonAI {
|
|||||||
private fun initPlayActivity(brain: Brain<ProjectedPersonEntity>) {
|
private fun initPlayActivity(brain: Brain<ProjectedPersonEntity>) {
|
||||||
brain.addActivity(
|
brain.addActivity(
|
||||||
Activity.PLAY, ImmutableList.of(
|
Activity.PLAY, ImmutableList.of(
|
||||||
7 weight GoToWantedItem.create(1.75f, true, 32),
|
3 weight GoToWantedItem.create(1.75f, true, 32),
|
||||||
|
5 weight AmusementAI.createStrollAroundPoiBaby(),
|
||||||
|
7 weight AmusementAI.createStrollToPoiBaby(),
|
||||||
|
9 weight AmusementAI.createAcquirePoi(),
|
||||||
10 weight JumpOnBed(1.0f),
|
10 weight JumpOnBed(1.0f),
|
||||||
10 weight createStrollBehavior(),
|
10 weight createStrollBehavior(),
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user