feat: PSH for more projections
This commit is contained in:
parent
968c885dba
commit
5a41bf0665
@ -8,6 +8,8 @@ import quaedam.projection.EntityProjectionBlock
|
||||
import quaedam.projection.ProjectionEffect
|
||||
import quaedam.projection.ProjectionEffectType
|
||||
import quaedam.projection.SimpleProjectionEntity
|
||||
import quaedam.shell.ProjectionEffectShell
|
||||
import quaedam.shell.buildProjectionEffectShell
|
||||
import kotlin.math.min
|
||||
|
||||
object NoiseProjection {
|
||||
@ -40,7 +42,7 @@ object NoiseProjectionBlock : EntityProjectionBlock<NoiseProjectionEffect>(creat
|
||||
|
||||
}
|
||||
|
||||
data class NoiseProjectionEffect(var amount: Int = 5) : ProjectionEffect() {
|
||||
data class NoiseProjectionEffect(var amount: Int = 5) : ProjectionEffect(), ProjectionEffectShell.Provider {
|
||||
|
||||
companion object {
|
||||
const val TAG_AMOUNT = "Amount"
|
||||
@ -60,4 +62,8 @@ data class NoiseProjectionEffect(var amount: Int = 5) : ProjectionEffect() {
|
||||
}
|
||||
}
|
||||
|
||||
override fun createShell() = buildProjectionEffectShell(this) {
|
||||
intSlider("quaedam.shell.noise.amount", ::amount, 0..8)
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -8,6 +8,8 @@ import quaedam.projection.EntityProjectionBlock
|
||||
import quaedam.projection.ProjectionEffect
|
||||
import quaedam.projection.ProjectionEffectType
|
||||
import quaedam.projection.SimpleProjectionEntity
|
||||
import quaedam.shell.ProjectionEffectShell
|
||||
import quaedam.shell.buildProjectionEffectShell
|
||||
|
||||
object SoundProjection {
|
||||
|
||||
@ -39,7 +41,7 @@ object SoundProjectionBlock : EntityProjectionBlock<SoundProjectionEffect>(creat
|
||||
|
||||
}
|
||||
|
||||
object SoundProjectionEffect : ProjectionEffect() {
|
||||
object SoundProjectionEffect : ProjectionEffect(), ProjectionEffectShell.Provider {
|
||||
|
||||
override val type
|
||||
get() = SoundProjection.effect.get()!!
|
||||
@ -50,4 +52,7 @@ object SoundProjectionEffect : ProjectionEffect() {
|
||||
override fun fromNbt(tag: CompoundTag, trusted: Boolean) {
|
||||
}
|
||||
|
||||
override fun createShell() = buildProjectionEffectShell(this) {
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -7,11 +7,13 @@ import net.minecraft.world.entity.MobSpawnType
|
||||
import net.minecraft.world.level.levelgen.Heightmap
|
||||
import quaedam.projection.ProjectionEffect
|
||||
import quaedam.projector.ProjectorBlockEntity
|
||||
import quaedam.shell.ProjectionEffectShell
|
||||
import quaedam.shell.buildProjectionEffectShell
|
||||
import kotlin.math.min
|
||||
|
||||
data class SwarmProjectionEffect(
|
||||
var maxCount: Int = 180,
|
||||
) : ProjectionEffect() {
|
||||
) : ProjectionEffect(), ProjectionEffectShell.Provider {
|
||||
|
||||
companion object {
|
||||
const val TAG_MAX_COUNT = "MaxCount"
|
||||
@ -50,4 +52,8 @@ data class SwarmProjectionEffect(
|
||||
}
|
||||
}
|
||||
|
||||
override fun createShell() = buildProjectionEffectShell(this) {
|
||||
intSlider("quaedam.shell.swarm.max_count", ::maxCount, 0..180 step 5)
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -29,11 +29,13 @@ class ProjectionEffectShell(val effect: ProjectionEffect) {
|
||||
|
||||
fun text(key: String, value: Component) = row(key) { StringWidget(value, it.font) }
|
||||
|
||||
fun doubleSlider(key: String, property: KMutableProperty0<Double>, range: ClosedRange<Double>, step: Double) =
|
||||
fun doubleSlider(key: String, property: KMutableProperty0<Double>, range: ClosedRange<Double>, step: Double) {
|
||||
val len = range.endInclusive - range.start
|
||||
val step = step / len
|
||||
row(key) {
|
||||
object : AbstractSliderButton(
|
||||
0, 0, width, height,
|
||||
Component.literal(property.get().toString()), property.get()
|
||||
Component.literal(property.get().toString()), (property.get() - range.start).toDouble() / len
|
||||
) {
|
||||
override fun updateMessage() {
|
||||
message = Component.literal(value.toString())
|
||||
@ -41,7 +43,28 @@ class ProjectionEffectShell(val effect: ProjectionEffect) {
|
||||
|
||||
override fun applyValue() {
|
||||
value = floor(value / step) * step
|
||||
property.set(value)
|
||||
property.set(range.start + floor(value * len))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun intSlider(key: String, property: KMutableProperty0<Int>, range: IntProgression) {
|
||||
val len = range.last - range.first
|
||||
val step = range.step / len
|
||||
row(key) {
|
||||
object : AbstractSliderButton(
|
||||
0, 0, width, height,
|
||||
Component.literal(property.get().toString()), (property.get() - range.first).toDouble() / len
|
||||
) {
|
||||
override fun updateMessage() {
|
||||
message = Component.literal(value.toString())
|
||||
}
|
||||
|
||||
override fun applyValue() {
|
||||
value = floor(value / step) * step
|
||||
property.set((range.first + floor(value * len)).toInt())
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,6 @@
|
||||
{
|
||||
"parent": "item/generated",
|
||||
"textures": {
|
||||
"layer0": "quaedam:item/projection_shell"
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user