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