feat: swarm noise
This commit is contained in:
parent
81853396cd
commit
e3cdc60d22
@ -5,6 +5,7 @@ import dev.architectury.registry.registries.DeferredRegister
|
|||||||
import dev.architectury.registry.registries.RegistrySupplier
|
import dev.architectury.registry.registries.RegistrySupplier
|
||||||
import net.minecraft.core.registries.Registries
|
import net.minecraft.core.registries.Registries
|
||||||
import net.minecraft.network.chat.Component
|
import net.minecraft.network.chat.Component
|
||||||
|
import net.minecraft.resources.ResourceLocation
|
||||||
import net.minecraft.world.item.CreativeModeTab
|
import net.minecraft.world.item.CreativeModeTab
|
||||||
import net.minecraft.world.item.ItemStack
|
import net.minecraft.world.item.ItemStack
|
||||||
import net.minecraft.world.item.Items
|
import net.minecraft.world.item.Items
|
||||||
@ -27,6 +28,7 @@ object Quaedam {
|
|||||||
val schedules = DeferredRegister.create(ID, Registries.SCHEDULE)!!
|
val schedules = DeferredRegister.create(ID, Registries.SCHEDULE)!!
|
||||||
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 projectionEffects = DeferredRegister.create(ID, ProjectionEffectType.registryKey)!!
|
val projectionEffects = DeferredRegister.create(ID, ProjectionEffectType.registryKey)!!
|
||||||
|
|
||||||
val creativeModeTab: RegistrySupplier<CreativeModeTab> = creativeModeTabs.register("quaedam") {
|
val creativeModeTab: RegistrySupplier<CreativeModeTab> = creativeModeTabs.register("quaedam") {
|
||||||
@ -52,7 +54,10 @@ object Quaedam {
|
|||||||
schedules.register()
|
schedules.register()
|
||||||
memoryTypes.register()
|
memoryTypes.register()
|
||||||
sensors.register()
|
sensors.register()
|
||||||
|
soundEvents.register()
|
||||||
projectionEffects.register()
|
projectionEffects.register()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun resource(path: String) = ResourceLocation(ID, path)
|
||||||
|
|
||||||
}
|
}
|
@ -12,6 +12,7 @@ import net.minecraft.network.syncher.EntityDataAccessor
|
|||||||
import net.minecraft.network.syncher.EntityDataSerializers
|
import net.minecraft.network.syncher.EntityDataSerializers
|
||||||
import net.minecraft.network.syncher.SynchedEntityData
|
import net.minecraft.network.syncher.SynchedEntityData
|
||||||
import net.minecraft.server.level.ServerLevel
|
import net.minecraft.server.level.ServerLevel
|
||||||
|
import net.minecraft.sounds.SoundEvent
|
||||||
import net.minecraft.world.DifficultyInstance
|
import net.minecraft.world.DifficultyInstance
|
||||||
import net.minecraft.world.SimpleContainer
|
import net.minecraft.world.SimpleContainer
|
||||||
import net.minecraft.world.entity.*
|
import net.minecraft.world.entity.*
|
||||||
@ -52,6 +53,11 @@ class ProjectedPersonEntity(entityType: EntityType<out PathfinderMob>, level: Le
|
|||||||
val dataShape =
|
val dataShape =
|
||||||
SynchedEntityData.defineId(ProjectedPersonEntity::class.java, EntityDataSerializers.COMPOUND_TAG)
|
SynchedEntityData.defineId(ProjectedPersonEntity::class.java, EntityDataSerializers.COMPOUND_TAG)
|
||||||
|
|
||||||
|
const val SOUND_NOISE_ID = "entity.projected_person.noise"
|
||||||
|
val soundNoise = Quaedam.soundEvents.register(SOUND_NOISE_ID) {
|
||||||
|
SoundEvent.createVariableRangeEvent(Quaedam.resource(SOUND_NOISE_ID))
|
||||||
|
}!!
|
||||||
|
|
||||||
init {
|
init {
|
||||||
EntityAttributeRegistry.register(entity, ::createAttributes)
|
EntityAttributeRegistry.register(entity, ::createAttributes)
|
||||||
if (Platform.getEnv() == EnvType.CLIENT) ProjectedPersonRenderer
|
if (Platform.getEnv() == EnvType.CLIENT) ProjectedPersonRenderer
|
||||||
@ -233,4 +239,18 @@ class ProjectedPersonEntity(entityType: EntityType<out PathfinderMob>, level: Le
|
|||||||
super.isSilent()
|
super.isSilent()
|
||||||
&& Projector.findNearbyProjections(level(), blockPosition(), SoundProjection.effect.get()).isNotEmpty()
|
&& Projector.findNearbyProjections(level(), blockPosition(), SoundProjection.effect.get()).isNotEmpty()
|
||||||
|
|
||||||
|
override fun getAmbientSound(): SoundEvent? {
|
||||||
|
if (Projector.findNearbyProjections(level(), blockPosition(), SoundProjection.effect.get()).isNotEmpty()) {
|
||||||
|
// sound projection available
|
||||||
|
return soundNoise.get()
|
||||||
|
}
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun getSoundVolume() = super.getSoundVolume() * (random.nextFloat() * 0.5f + 0.6f)
|
||||||
|
|
||||||
|
override fun getVoicePitch() = super.getVoicePitch() * (random.nextFloat() * 0.4f + 0.8f)
|
||||||
|
|
||||||
|
override fun getAmbientSoundInterval() = -(160 + random.nextInt(1000 - 160))
|
||||||
|
|
||||||
}
|
}
|
@ -0,0 +1,61 @@
|
|||||||
|
{
|
||||||
|
"entity.projected_person.noise": {
|
||||||
|
"sounds": [
|
||||||
|
{
|
||||||
|
"name": "entity.villager.ambient",
|
||||||
|
"weight": 4,
|
||||||
|
"type": "event"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "entity.villager.yes",
|
||||||
|
"weight": 2,
|
||||||
|
"type": "event"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "entity.villager.no",
|
||||||
|
"weight": 1,
|
||||||
|
"type": "event"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "entity.villager.trade",
|
||||||
|
"weight": 3,
|
||||||
|
"type": "event"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "entity.villager.work_librarian",
|
||||||
|
"weight": 2,
|
||||||
|
"type": "event"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "entity.villager.work_cleric",
|
||||||
|
"weight": 2,
|
||||||
|
"type": "event"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "entity.villager.work_mason",
|
||||||
|
"weight": 2,
|
||||||
|
"type": "event"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "entity.villager.work_shepherd",
|
||||||
|
"weight": 2,
|
||||||
|
"type": "event"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "entity.wandering_trader.drink_milk",
|
||||||
|
"weight": 1,
|
||||||
|
"type": "event"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "entity.wandering_trader.no",
|
||||||
|
"weight": 2,
|
||||||
|
"type": "event"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "entity.wandering_trader.yes",
|
||||||
|
"weight": 3,
|
||||||
|
"type": "event"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user