feat: sound projection
This commit is contained in:
parent
bc8c4425a6
commit
718bcd1c4f
@ -12,6 +12,7 @@ import org.slf4j.LoggerFactory
|
||||
import quaedam.projection.ProjectionCommand
|
||||
import quaedam.projection.ProjectionEffectType
|
||||
import quaedam.projection.SkylightProjection
|
||||
import quaedam.projection.SoundProjection
|
||||
import quaedam.projection.swarm.SwarmProjection
|
||||
import quaedam.projector.Projector
|
||||
|
||||
@ -42,6 +43,7 @@ object Quaedam {
|
||||
ProjectionEffectType
|
||||
SkylightProjection
|
||||
SwarmProjection
|
||||
SoundProjection
|
||||
ProjectionCommand
|
||||
|
||||
creativeModeTabs.register()
|
||||
|
52
common/src/main/kotlin/quaedam/projection/SoundProjection.kt
Normal file
52
common/src/main/kotlin/quaedam/projection/SoundProjection.kt
Normal file
@ -0,0 +1,52 @@
|
||||
package quaedam.projection
|
||||
|
||||
import net.minecraft.core.BlockPos
|
||||
import net.minecraft.nbt.CompoundTag
|
||||
import net.minecraft.server.level.ServerLevel
|
||||
import net.minecraft.world.item.BlockItem
|
||||
import net.minecraft.world.item.Item
|
||||
import net.minecraft.world.level.block.state.BlockState
|
||||
import quaedam.Quaedam
|
||||
|
||||
object SoundProjection {
|
||||
|
||||
const val ID = "sound_projection"
|
||||
const val SHORT_ID = "sound"
|
||||
|
||||
val block = Quaedam.blocks.register(ID) { SoundProjectionBlock }!!
|
||||
|
||||
val item = Quaedam.items.register(ID) {
|
||||
BlockItem(
|
||||
SoundProjectionBlock, Item.Properties()
|
||||
.`arch$tab`(Quaedam.creativeModeTab)
|
||||
)
|
||||
}!!
|
||||
|
||||
val effect = Quaedam.projectionEffects.register(SHORT_ID) {
|
||||
ProjectionEffectType { SoundProjectionEffect }
|
||||
}!!
|
||||
|
||||
}
|
||||
|
||||
object SoundProjectionBlock : ProjectionBlock<SoundProjectionEffect>(createProperties().lightLevel { 3 }) {
|
||||
|
||||
override fun createProjectionEffect(
|
||||
level: ServerLevel,
|
||||
state: BlockState,
|
||||
pos: BlockPos
|
||||
) = SoundProjectionEffect
|
||||
|
||||
}
|
||||
|
||||
object SoundProjectionEffect : ProjectionEffect() {
|
||||
|
||||
override val type
|
||||
get() = SoundProjection.effect.get()!!
|
||||
|
||||
override fun toNbt(tag: CompoundTag) {
|
||||
}
|
||||
|
||||
override fun fromNbt(tag: CompoundTag) {
|
||||
}
|
||||
|
||||
}
|
@ -25,6 +25,7 @@ import net.minecraft.world.entity.npc.InventoryCarrier
|
||||
import net.minecraft.world.level.Level
|
||||
import net.minecraft.world.level.ServerLevelAccessor
|
||||
import quaedam.Quaedam
|
||||
import quaedam.projection.SoundProjection
|
||||
import quaedam.projection.swarm.ai.ProjectedPersonAI
|
||||
import quaedam.projection.swarm.ai.ProjectedPersonNavigation
|
||||
import quaedam.projector.Projector
|
||||
@ -228,4 +229,8 @@ class ProjectedPersonEntity(entityType: EntityType<out PathfinderMob>, level: Le
|
||||
inventory.removeAllItems().forEach(::spawnAtLocation)
|
||||
}
|
||||
|
||||
override fun isSilent() =
|
||||
super.isSilent()
|
||||
&& Projector.findNearbyProjections(level(), blockPosition(), SoundProjection.effect.get()).isNotEmpty()
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user