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 d636a7f..be20b28 100644 --- a/common/src/main/kotlin/quaedam/projection/swarm/ai/ProjectedPersonAI.kt +++ b/common/src/main/kotlin/quaedam/projection/swarm/ai/ProjectedPersonAI.kt @@ -159,7 +159,10 @@ object ProjectedPersonAI { brain.addActivity( Activity.WORK, ImmutableList.of( 5 weight ExchangeItem(), + 7 weight WorkPoiAI.createStrollAroundPoi(), + 7 weight WorkPoiAI.createStrollToPoi(), 10 weight createStrollBehavior(), + 10 weight WorkPoiAI.createAcquirePoi(), ) ) } diff --git a/common/src/main/kotlin/quaedam/projection/swarm/ai/WorkPoiAI.kt b/common/src/main/kotlin/quaedam/projection/swarm/ai/WorkPoiAI.kt new file mode 100644 index 0000000..2d244c0 --- /dev/null +++ b/common/src/main/kotlin/quaedam/projection/swarm/ai/WorkPoiAI.kt @@ -0,0 +1,49 @@ +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.PoiTypes +import quaedam.Quaedam +import java.util.* + +object WorkPoiAI { + + const val ID = "work" + + val poiTypes by lazy { + setOf( + PoiTypes.ARMORER, + PoiTypes.BUTCHER, + PoiTypes.CARTOGRAPHER, + PoiTypes.CLERIC, + PoiTypes.FARMER, + PoiTypes.FISHERMAN, + PoiTypes.FLETCHER, + PoiTypes.LEATHERWORKER, + PoiTypes.LIBRARIAN, + PoiTypes.MASON, + PoiTypes.SHEPHERD, + PoiTypes.TOOLSMITH, + PoiTypes.WEAPONSMITH, + PoiTypes.LODESTONE, + PoiTypes.LIGHTNING_ROD, + ) + } + + 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, 4) + + fun createStrollAroundPoi() = + StrollAroundPoi.create(memory.get(), 0.4f, 5) + +} \ No newline at end of file