diff --git a/common/src/main/kotlin/quaedam/Quaedam.kt b/common/src/main/kotlin/quaedam/Quaedam.kt index ee3ad81..3755efe 100644 --- a/common/src/main/kotlin/quaedam/Quaedam.kt +++ b/common/src/main/kotlin/quaedam/Quaedam.kt @@ -39,6 +39,7 @@ object Quaedam { val memoryTypes = DeferredRegister.create(ID, Registries.MEMORY_MODULE_TYPE)!! val sensors = DeferredRegister.create(ID, Registries.SENSOR_TYPE)!! 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 creativeModeTab: RegistrySupplier = creativeModeTabs.register("quaedam") { @@ -72,6 +73,7 @@ object Quaedam { memoryTypes.register() sensors.register() soundEvents.register() + poiTypes.register() projectionEffects.register() } diff --git a/common/src/main/kotlin/quaedam/projection/swarm/ai/AmusementAI.kt b/common/src/main/kotlin/quaedam/projection/swarm/ai/AmusementAI.kt new file mode 100644 index 0000000..e4793b9 --- /dev/null +++ b/common/src/main/kotlin/quaedam/projection/swarm/ai/AmusementAI.kt @@ -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) + +} \ No newline at end of file diff --git a/common/src/main/kotlin/quaedam/projection/swarm/ai/ProjectedPersonAI.kt b/common/src/main/kotlin/quaedam/projection/swarm/ai/ProjectedPersonAI.kt index b216402..4f086fd 100644 --- a/common/src/main/kotlin/quaedam/projection/swarm/ai/ProjectedPersonAI.kt +++ b/common/src/main/kotlin/quaedam/projection/swarm/ai/ProjectedPersonAI.kt @@ -1,6 +1,7 @@ package quaedam.projection.swarm.ai import com.google.common.collect.ImmutableList +import net.minecraft.core.Holder import net.minecraft.core.registries.Registries import net.minecraft.tags.TagKey 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.NearestVisibleLivingEntities 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.schedule.Activity import net.minecraft.world.entity.schedule.Schedule @@ -51,6 +54,7 @@ object ProjectedPersonAI { init { BedInChunkSensor + AmusementAI NearestVisibleContainer } @@ -129,6 +133,9 @@ object ProjectedPersonAI { private fun initIdleActivity(brain: Brain) { brain.addActivity( Activity.IDLE, ImmutableList.of( + 5 weight AmusementAI.createStrollAroundPoi(), + 7 weight AmusementAI.createStrollToPoi(), + 9 weight AmusementAI.createAcquirePoi(), 10 weight createStrollBehavior(), ) ) @@ -137,7 +144,10 @@ object ProjectedPersonAI { private fun initPlayActivity(brain: Brain) { brain.addActivity( 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 createStrollBehavior(), )