diff --git a/common/src/main/kotlin/quaedam/Quaedam.kt b/common/src/main/kotlin/quaedam/Quaedam.kt index 1c87334..5d60431 100644 --- a/common/src/main/kotlin/quaedam/Quaedam.kt +++ b/common/src/main/kotlin/quaedam/Quaedam.kt @@ -9,10 +9,7 @@ import net.minecraft.world.item.CreativeModeTab import net.minecraft.world.item.ItemStack import net.minecraft.world.item.Items import org.slf4j.LoggerFactory -import quaedam.projection.ProjectionCommand -import quaedam.projection.ProjectionEffectType -import quaedam.projection.SkylightProjection -import quaedam.projection.SoundProjection +import quaedam.projection.* import quaedam.projection.swarm.SwarmProjection import quaedam.projector.Projector @@ -44,6 +41,7 @@ object Quaedam { SkylightProjection SwarmProjection SoundProjection + NoiseProjection ProjectionCommand creativeModeTabs.register() diff --git a/common/src/main/kotlin/quaedam/projection/NoiseProjection.kt b/common/src/main/kotlin/quaedam/projection/NoiseProjection.kt new file mode 100644 index 0000000..a70ab76 --- /dev/null +++ b/common/src/main/kotlin/quaedam/projection/NoiseProjection.kt @@ -0,0 +1,58 @@ +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 NoiseProjection { + + const val ID = "noise_projection" + const val SHORT_ID = "noise" + + val block = Quaedam.blocks.register(ID) { NoiseProjectionBlock }!! + + val item = Quaedam.items.register(ID) { + BlockItem( + NoiseProjectionBlock, Item.Properties() + .`arch$tab`(Quaedam.creativeModeTab) + ) + }!! + + val effect = Quaedam.projectionEffects.register(SHORT_ID) { + ProjectionEffectType { NoiseProjectionEffect() } + }!! + +} + +object NoiseProjectionBlock : ProjectionBlock(createProperties().lightLevel { 3 }) { + + override fun createProjectionEffect( + level: ServerLevel, + state: BlockState, + pos: BlockPos + ) = NoiseProjectionEffect() + +} + +data class NoiseProjectionEffect(var amount: Int = 5) : ProjectionEffect() { + + companion object { + const val TAG_AMOUNT = "Amount" + } + + override val type + get() = SoundProjection.effect.get()!! + + override fun toNbt(tag: CompoundTag) { + tag.putInt(TAG_AMOUNT, amount) + } + + override fun fromNbt(tag: CompoundTag) { + amount = tag.getInt(TAG_AMOUNT) + } + +}