fix
This commit is contained in:
parent
89473d2dcc
commit
c3e8a211ad
@ -9,6 +9,7 @@ import net.minecraft.resources.ResourceLocation
|
||||
import net.minecraft.server.level.ServerLevel
|
||||
import net.minecraft.world.level.Level
|
||||
import net.minecraft.world.level.block.state.BlockState
|
||||
import quaedam.projection.swarm.SwarmProjection
|
||||
|
||||
abstract class ProjectionEffect {
|
||||
|
||||
@ -38,7 +39,9 @@ data class ProjectionEffectType<T : ProjectionEffect>(val constructor: () -> T)
|
||||
|
||||
val registryKey: ResourceKey<Registry<ProjectionEffectType<*>>> =
|
||||
ResourceKey.createRegistryKey(ResourceLocation("quaedam", "projection_effect"))
|
||||
val registry: Registry<ProjectionEffectType<*>> = BuiltInRegistries.registerSimple(registryKey) { null }
|
||||
val registry: Registry<ProjectionEffectType<*>> = BuiltInRegistries.registerSimple(registryKey) {
|
||||
SwarmProjection.effect.get()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -57,12 +57,6 @@ object ProjectedPersonAI {
|
||||
fun provider(): Brain.Provider<out ProjectedPersonEntity> = Brain.provider(memoryTypes, sensorTypes)
|
||||
|
||||
fun initBrain(entity: ProjectedPersonEntity, brain: Brain<ProjectedPersonEntity>) {
|
||||
if (entity.shape.baby) {
|
||||
brain.schedule = babySchedule.get()
|
||||
} else {
|
||||
brain.schedule = defaultSchedule.get()
|
||||
}
|
||||
|
||||
initCoreActivity(brain)
|
||||
initIdleActivity(brain)
|
||||
initPlayActivity(brain)
|
||||
@ -70,9 +64,20 @@ object ProjectedPersonAI {
|
||||
initRestActivity(brain)
|
||||
brain.setCoreActivities(setOf(Activity.CORE))
|
||||
brain.setDefaultActivity(Activity.IDLE)
|
||||
updateSchedule(entity, brain, baby = false)
|
||||
}
|
||||
|
||||
fun updateSchedule(entity: ProjectedPersonEntity, brain: Brain<ProjectedPersonEntity>, baby: Boolean) {
|
||||
if (baby) {
|
||||
brain.schedule = babySchedule.get()
|
||||
} else {
|
||||
brain.schedule = defaultSchedule.get()
|
||||
}
|
||||
brain.updateActivityFromSchedule(entity.level().dayTime, entity.level().gameTime)
|
||||
}
|
||||
|
||||
fun updateSchedule(entity: ProjectedPersonEntity) = updateSchedule(entity, entity.brain, entity.shape.baby)
|
||||
|
||||
private fun initCoreActivity(brain: Brain<ProjectedPersonEntity>) {
|
||||
brain.addActivity(
|
||||
Activity.CORE, 0, ImmutableList.of(
|
||||
|
@ -80,6 +80,7 @@ class ProjectedPersonEntity(entityType: EntityType<out PathfinderMob>, level: Le
|
||||
set(value) {
|
||||
field = value
|
||||
shapeTag = shape.toTag()
|
||||
ProjectedPersonAI.updateSchedule(this)
|
||||
}
|
||||
|
||||
override fun onSyncedDataUpdated(data: EntityDataAccessor<*>) {
|
||||
|
@ -7,14 +7,10 @@ import quaedam.projection.ProjectionEffect
|
||||
|
||||
data class SwarmProjectionEffect(
|
||||
var maxCount: Int = 10,
|
||||
var withPlayer: Boolean = true,
|
||||
var withVillager: Boolean = true
|
||||
) : ProjectionEffect() {
|
||||
|
||||
companion object {
|
||||
const val TAG_MAX_COUNT = "MaxCount"
|
||||
const val TAG_WITH_PLAYER = "WithPlayer"
|
||||
const val TAG_WITH_VILLAGER = "WithVillager"
|
||||
}
|
||||
|
||||
override val type
|
||||
@ -22,14 +18,10 @@ data class SwarmProjectionEffect(
|
||||
|
||||
override fun toNbt(tag: CompoundTag) {
|
||||
tag.putInt(TAG_MAX_COUNT, maxCount)
|
||||
tag.putBoolean(TAG_WITH_PLAYER, withPlayer)
|
||||
tag.putBoolean(TAG_WITH_VILLAGER, withVillager)
|
||||
}
|
||||
|
||||
override fun fromNbt(tag: CompoundTag) {
|
||||
maxCount = tag.getInt(TAG_MAX_COUNT)
|
||||
withPlayer = tag.getBoolean(TAG_WITH_PLAYER)
|
||||
withVillager = tag.getBoolean(TAG_WITH_VILLAGER)
|
||||
}
|
||||
|
||||
override fun randomTick(level: ServerLevel, pos: BlockPos) {
|
||||
|
Loading…
Reference in New Issue
Block a user