feat: swarm projection basics

This commit is contained in:
xtex 2023-07-01 10:49:38 +08:00
parent fa0403b3c8
commit 5b22f9087b
Signed by: xtex
GPG Key ID: B918086ED8045B91
10 changed files with 104 additions and 4 deletions

View File

@ -10,6 +10,7 @@ import net.minecraft.world.item.ItemStack
import net.minecraft.world.item.Items
import quaedam.projection.ProjectionEffectType
import quaedam.projection.SkylightProjection
import quaedam.projection.swarm.SwarmProjection
import quaedam.projector.Projector
object Quaedam {
@ -31,6 +32,7 @@ object Quaedam {
fun init() {
Projector
SkylightProjection
SwarmProjection
creativeModeTabs.register()
items.register()

View File

@ -11,6 +11,7 @@ import quaedam.Quaedam
object SkylightProjection {
const val ID = "skylight_projection"
const val SHORT_ID = "skylight"
val block = Quaedam.blocks.register(ID) { SkylightProjectionBlock }!!
@ -21,7 +22,7 @@ object SkylightProjection {
)
}!!
val effect = Quaedam.projectionEffects.register(ID) {
val effect = Quaedam.projectionEffects.register(SHORT_ID) {
ProjectionEffectType { SkylightProjectionEffect() }
}!!
@ -39,15 +40,19 @@ object SkylightProjectionBlock : ProjectionBlock<SkylightProjectionEffect>(creat
data class SkylightProjectionEffect(var factor: Double = 2.0) : ProjectionEffect() {
companion object {
const val TAG_FACTOR = "Factor"
}
override val type
get() = SkylightProjection.effect.get()!!
override fun toNbt(tag: CompoundTag) {
tag.putDouble("Factor", factor)
tag.putDouble(TAG_FACTOR, factor)
}
override fun fromNbt(tag: CompoundTag) {
factor = tag.getDouble("Factor")
factor = tag.getDouble(TAG_FACTOR)
}
}

View File

@ -0,0 +1,26 @@
package quaedam.projection.swarm
import net.minecraft.world.item.BlockItem
import net.minecraft.world.item.Item
import quaedam.Quaedam
import quaedam.projection.ProjectionEffectType
object SwarmProjection {
const val ID = "swarm_projection"
const val SHORT_ID = "swarm"
val block = Quaedam.blocks.register(ID) { SwarmProjectionBlock }!!
val item = Quaedam.items.register(ID) {
BlockItem(
SwarmProjectionBlock, Item.Properties()
.`arch$tab`(Quaedam.creativeModeTab)
)
}!!
val effect = Quaedam.projectionEffects.register(SHORT_ID) {
ProjectionEffectType { SwarmProjectionEffect() }
}!!
}

View File

@ -0,0 +1,16 @@
package quaedam.projection.swarm
import net.minecraft.core.BlockPos
import net.minecraft.server.level.ServerLevel
import net.minecraft.world.level.block.state.BlockState
import quaedam.projection.ProjectionBlock
object SwarmProjectionBlock : ProjectionBlock<SwarmProjectionEffect>() {
override fun createProjectionEffect(
level: ServerLevel,
state: BlockState,
pos: BlockPos
) = SwarmProjectionEffect()
}

View File

@ -0,0 +1,33 @@
package quaedam.projection.swarm
import net.minecraft.nbt.CompoundTag
import quaedam.projection.ProjectionEffect
data class SwarmProjectionEffect(
var maxCount: Int = 10,
var withPlayer: Boolean = true,
var withVillager: Boolean = true
) : ProjectionEffect() {
companion object {
const val TAG_MAX_COUNT = "MaxCount"
const val TAG_WITH_PLAYER = "WithPlayer"
const val TAG_WITH_VILLAGER = "WithVillager"
}
override val type
get() = SwarmProjection.effect.get()!!
override fun toNbt(tag: CompoundTag) {
tag.putInt(TAG_MAX_COUNT, maxCount)
tag.putBoolean(TAG_WITH_PLAYER, withPlayer)
tag.putBoolean(TAG_WITH_VILLAGER, withVillager)
}
override fun fromNbt(tag: CompoundTag) {
maxCount = tag.getInt(TAG_MAX_COUNT)
withPlayer = tag.getBoolean(TAG_WITH_PLAYER)
withVillager = tag.getBoolean(TAG_WITH_VILLAGER)
}
}

View File

@ -0,0 +1,7 @@
{
"variants": {
"": {
"model": "quaedam:block/swarm_projection"
}
}
}

View File

@ -1,4 +1,6 @@
{
"category.quaedam": "Quaedam",
"block.quaedam.projector": "Projector"
"block.quaedam.projector": "Projector",
"block.quaedam.skylight_projection": "Skylight Projection",
"block.quaedam.swarm_projection": "Swarm Projection"
}

View File

@ -0,0 +1,6 @@
{
"parent": "quaedam:block/projection",
"textures": {
"ext": "quaedam:block/swarm_projection"
}
}

View File

@ -0,0 +1,3 @@
{
"parent": "quaedam:block/swarm_projection"
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 400 B