feat: register noise projection

This commit is contained in:
xtex 2023-07-10 16:12:30 +08:00
parent 718bcd1c4f
commit e15a099678
Signed by: xtex
GPG Key ID: B918086ED8045B91
2 changed files with 60 additions and 4 deletions

View File

@ -9,10 +9,7 @@ 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
import org.slf4j.LoggerFactory import org.slf4j.LoggerFactory
import quaedam.projection.ProjectionCommand import quaedam.projection.*
import quaedam.projection.ProjectionEffectType
import quaedam.projection.SkylightProjection
import quaedam.projection.SoundProjection
import quaedam.projection.swarm.SwarmProjection import quaedam.projection.swarm.SwarmProjection
import quaedam.projector.Projector import quaedam.projector.Projector
@ -44,6 +41,7 @@ object Quaedam {
SkylightProjection SkylightProjection
SwarmProjection SwarmProjection
SoundProjection SoundProjection
NoiseProjection
ProjectionCommand ProjectionCommand
creativeModeTabs.register() creativeModeTabs.register()

View File

@ -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<NoiseProjectionEffect>(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)
}
}