feat: more configurations
This commit is contained in:
parent
07455f2091
commit
40ed66d76e
@ -20,6 +20,7 @@ data class QuaedamConfig(
|
|||||||
val valuesInt: Map<String, Int> = mapOf(),
|
val valuesInt: Map<String, Int> = mapOf(),
|
||||||
val valuesFloat: Map<String, Float> = mapOf(),
|
val valuesFloat: Map<String, Float> = mapOf(),
|
||||||
val valuesDouble: Map<String, Double> = mapOf(),
|
val valuesDouble: Map<String, Double> = mapOf(),
|
||||||
|
val valuesBoolean: Map<String, Boolean> = mapOf(),
|
||||||
) {
|
) {
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
@ -80,12 +81,14 @@ data class QuaedamConfig(
|
|||||||
const val TAG_VALUES_INT = "ValuesInt"
|
const val TAG_VALUES_INT = "ValuesInt"
|
||||||
const val TAG_VALUES_FLOAT = "ValuesFloat"
|
const val TAG_VALUES_FLOAT = "ValuesFloat"
|
||||||
const val TAG_VALUES_DOUBLE = "ValuesDouble"
|
const val TAG_VALUES_DOUBLE = "ValuesDouble"
|
||||||
|
const val TAG_VALUES_BOOLEAN = "ValuesBoolean"
|
||||||
|
|
||||||
fun fromPushNbt(tag: CompoundTag): QuaedamConfig {
|
fun fromPushNbt(tag: CompoundTag): QuaedamConfig {
|
||||||
return QuaedamConfig(
|
return QuaedamConfig(
|
||||||
valuesInt = pushJson.decodeFromString(tag.getString(TAG_VALUES_INT)),
|
valuesInt = pushJson.decodeFromString(tag.getString(TAG_VALUES_INT)),
|
||||||
valuesFloat = pushJson.decodeFromString(tag.getString(TAG_VALUES_FLOAT)),
|
valuesFloat = pushJson.decodeFromString(tag.getString(TAG_VALUES_FLOAT)),
|
||||||
valuesDouble = pushJson.decodeFromString(tag.getString(TAG_VALUES_DOUBLE)),
|
valuesDouble = pushJson.decodeFromString(tag.getString(TAG_VALUES_DOUBLE)),
|
||||||
|
valuesBoolean = pushJson.decodeFromString(tag.getString(TAG_VALUES_BOOLEAN)),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -94,6 +97,7 @@ data class QuaedamConfig(
|
|||||||
tag.putString(TAG_VALUES_INT, pushJson.encodeToString(valuesInt))
|
tag.putString(TAG_VALUES_INT, pushJson.encodeToString(valuesInt))
|
||||||
tag.putString(TAG_VALUES_FLOAT, pushJson.encodeToString(valuesFloat))
|
tag.putString(TAG_VALUES_FLOAT, pushJson.encodeToString(valuesFloat))
|
||||||
tag.putString(TAG_VALUES_DOUBLE, pushJson.encodeToString(valuesDouble))
|
tag.putString(TAG_VALUES_DOUBLE, pushJson.encodeToString(valuesDouble))
|
||||||
|
tag.putString(TAG_VALUES_BOOLEAN, pushJson.encodeToString(valuesBoolean))
|
||||||
}
|
}
|
||||||
|
|
||||||
fun toPushNbt() = CompoundTag().also { toPushNbt(it) }
|
fun toPushNbt() = CompoundTag().also { toPushNbt(it) }
|
||||||
|
@ -13,6 +13,7 @@ import net.minecraft.util.RandomSource
|
|||||||
import net.minecraft.world.item.BlockItem
|
import net.minecraft.world.item.BlockItem
|
||||||
import net.minecraft.world.item.Item
|
import net.minecraft.world.item.Item
|
||||||
import quaedam.Quaedam
|
import quaedam.Quaedam
|
||||||
|
import quaedam.config.QuaedamConfig
|
||||||
import quaedam.projection.EntityProjectionBlock
|
import quaedam.projection.EntityProjectionBlock
|
||||||
import quaedam.projection.ProjectionEffect
|
import quaedam.projection.ProjectionEffect
|
||||||
import quaedam.projection.ProjectionEffectType
|
import quaedam.projection.ProjectionEffectType
|
||||||
@ -107,6 +108,9 @@ data class NoiseProjectionEffect(var rate: Int = 250, var amount: Int = 3) : Pro
|
|||||||
companion object {
|
companion object {
|
||||||
const val TAG_RATE = "Rate"
|
const val TAG_RATE = "Rate"
|
||||||
const val TAG_AMOUNT = "Amount"
|
const val TAG_AMOUNT = "Amount"
|
||||||
|
|
||||||
|
val maxAmount get() = QuaedamConfig.current.valuesInt["projection.noise.max_amount"] ?: 8
|
||||||
|
val maxRate get() = QuaedamConfig.current.valuesInt["projection.noise.max_rate"] ?: 300
|
||||||
}
|
}
|
||||||
|
|
||||||
override val type
|
override val type
|
||||||
@ -121,14 +125,14 @@ data class NoiseProjectionEffect(var rate: Int = 250, var amount: Int = 3) : Pro
|
|||||||
rate = tag.getInt(TAG_RATE)
|
rate = tag.getInt(TAG_RATE)
|
||||||
amount = tag.getInt(TAG_AMOUNT)
|
amount = tag.getInt(TAG_AMOUNT)
|
||||||
if (!trusted) {
|
if (!trusted) {
|
||||||
amount = min(amount, 8)
|
amount = min(amount, maxAmount)
|
||||||
rate = min(rate, 500)
|
rate = min(rate, maxRate)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun createShell() = buildProjectionEffectShell(this) {
|
override fun createShell() = buildProjectionEffectShell(this) {
|
||||||
intSlider("quaedam.shell.noise.rate", ::rate, 0..300 step 5)
|
intSlider("quaedam.shell.noise.rate", ::rate, 0..maxRate step 5)
|
||||||
intSlider("quaedam.shell.noise.amount", ::amount, 0..8)
|
intSlider("quaedam.shell.noise.amount", ::amount, 0..maxAmount)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@ import net.minecraft.nbt.CompoundTag
|
|||||||
import net.minecraft.world.item.BlockItem
|
import net.minecraft.world.item.BlockItem
|
||||||
import net.minecraft.world.item.Item
|
import net.minecraft.world.item.Item
|
||||||
import quaedam.Quaedam
|
import quaedam.Quaedam
|
||||||
|
import quaedam.config.QuaedamConfig
|
||||||
import quaedam.projection.EntityProjectionBlock
|
import quaedam.projection.EntityProjectionBlock
|
||||||
import quaedam.projection.ProjectionEffect
|
import quaedam.projection.ProjectionEffect
|
||||||
import quaedam.projection.ProjectionEffectType
|
import quaedam.projection.ProjectionEffectType
|
||||||
@ -46,6 +47,8 @@ data class SkylightProjectionEffect(var factor: Double = 2.0) : ProjectionEffect
|
|||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
const val TAG_FACTOR = "Factor"
|
const val TAG_FACTOR = "Factor"
|
||||||
|
|
||||||
|
val maxFactor get() = QuaedamConfig.current.valuesDouble["projection.skylight.max_factor"] ?: 5.0
|
||||||
}
|
}
|
||||||
|
|
||||||
override val type
|
override val type
|
||||||
@ -58,12 +61,12 @@ data class SkylightProjectionEffect(var factor: Double = 2.0) : ProjectionEffect
|
|||||||
override fun fromNbt(tag: CompoundTag, trusted: Boolean) {
|
override fun fromNbt(tag: CompoundTag, trusted: Boolean) {
|
||||||
factor = tag.getDouble(TAG_FACTOR)
|
factor = tag.getDouble(TAG_FACTOR)
|
||||||
if (!trusted) {
|
if (!trusted) {
|
||||||
factor = min(factor, 5.0)
|
factor = min(factor, maxFactor)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun createShell() = buildProjectionEffectShell(this) {
|
override fun createShell() = buildProjectionEffectShell(this) {
|
||||||
doubleSlider("quaedam.shell.skylight.factor", ::factor, 0.0..5.0, 0.1)
|
doubleSlider("quaedam.shell.skylight.factor", ::factor, 0.0..maxFactor, 0.1)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@ import net.minecraft.nbt.CompoundTag
|
|||||||
import net.minecraft.world.item.BlockItem
|
import net.minecraft.world.item.BlockItem
|
||||||
import net.minecraft.world.item.Item
|
import net.minecraft.world.item.Item
|
||||||
import quaedam.Quaedam
|
import quaedam.Quaedam
|
||||||
|
import quaedam.config.QuaedamConfig
|
||||||
import quaedam.projection.EntityProjectionBlock
|
import quaedam.projection.EntityProjectionBlock
|
||||||
import quaedam.projection.ProjectionEffect
|
import quaedam.projection.ProjectionEffect
|
||||||
import quaedam.projection.ProjectionEffectType
|
import quaedam.projection.ProjectionEffectType
|
||||||
@ -46,6 +47,8 @@ data class SoundProjectionEffect(var rate: Int = 60) : ProjectionEffect(), Proje
|
|||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
const val TAG_RATE = "Rate"
|
const val TAG_RATE = "Rate"
|
||||||
|
|
||||||
|
val maxRate get() = QuaedamConfig.current.valuesInt["projection.sound.max_rate"] ?: 210
|
||||||
}
|
}
|
||||||
|
|
||||||
override val type
|
override val type
|
||||||
@ -58,12 +61,12 @@ data class SoundProjectionEffect(var rate: Int = 60) : ProjectionEffect(), Proje
|
|||||||
override fun fromNbt(tag: CompoundTag, trusted: Boolean) {
|
override fun fromNbt(tag: CompoundTag, trusted: Boolean) {
|
||||||
rate = tag.getInt(TAG_RATE)
|
rate = tag.getInt(TAG_RATE)
|
||||||
if (!trusted) {
|
if (!trusted) {
|
||||||
rate = min(rate, 210)
|
rate = min(rate, maxRate)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun createShell() = buildProjectionEffectShell(this) {
|
override fun createShell() = buildProjectionEffectShell(this) {
|
||||||
intSlider("quaedam.shell.sound.rate", ::rate, 0..210)
|
intSlider("quaedam.shell.sound.rate", ::rate, 0..maxRate)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@ import net.minecraft.nbt.CompoundTag
|
|||||||
import net.minecraft.world.item.BlockItem
|
import net.minecraft.world.item.BlockItem
|
||||||
import net.minecraft.world.item.Item
|
import net.minecraft.world.item.Item
|
||||||
import quaedam.Quaedam
|
import quaedam.Quaedam
|
||||||
|
import quaedam.config.QuaedamConfig
|
||||||
import quaedam.projection.EntityProjectionBlock
|
import quaedam.projection.EntityProjectionBlock
|
||||||
import quaedam.projection.ProjectionEffect
|
import quaedam.projection.ProjectionEffect
|
||||||
import quaedam.projection.ProjectionEffectType
|
import quaedam.projection.ProjectionEffectType
|
||||||
@ -52,6 +53,9 @@ data class MusicProjectionEffect(var volumeFactor: Float = 1.0f, var particle: B
|
|||||||
companion object {
|
companion object {
|
||||||
const val TAG_VOLUME_FACTOR = "VolumeFactor"
|
const val TAG_VOLUME_FACTOR = "VolumeFactor"
|
||||||
const val TAG_PARTICLE = "Particle"
|
const val TAG_PARTICLE = "Particle"
|
||||||
|
|
||||||
|
val maxVolumeFactor get() = QuaedamConfig.current.valuesFloat["projection.music.max_volume_factor"] ?: 5.0f
|
||||||
|
val enforceParticle get() = QuaedamConfig.current.valuesBoolean["projection.music.enforce_particle"]
|
||||||
}
|
}
|
||||||
|
|
||||||
override val type
|
override val type
|
||||||
@ -66,13 +70,16 @@ data class MusicProjectionEffect(var volumeFactor: Float = 1.0f, var particle: B
|
|||||||
volumeFactor = tag.getFloat(TAG_VOLUME_FACTOR)
|
volumeFactor = tag.getFloat(TAG_VOLUME_FACTOR)
|
||||||
particle = tag.getBoolean(TAG_PARTICLE)
|
particle = tag.getBoolean(TAG_PARTICLE)
|
||||||
if (!trusted) {
|
if (!trusted) {
|
||||||
volumeFactor = min(volumeFactor, 5.0f)
|
volumeFactor = min(volumeFactor, maxVolumeFactor)
|
||||||
|
particle = enforceParticle ?: particle
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun createShell() = buildProjectionEffectShell(this) {
|
override fun createShell() = buildProjectionEffectShell(this) {
|
||||||
floatSlider("quaedam.shell.music.volume_factor", ::volumeFactor, 0.0f..5.0f, 0.1f)
|
floatSlider("quaedam.shell.music.volume_factor", ::volumeFactor, 0.0f..maxVolumeFactor, 0.1f)
|
||||||
boolean("quaedam.shell.music.particle", ::particle)
|
if (enforceParticle == null) {
|
||||||
|
boolean("quaedam.shell.music.particle", ::particle)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@ import net.minecraft.nbt.CompoundTag
|
|||||||
import net.minecraft.server.level.ServerLevel
|
import net.minecraft.server.level.ServerLevel
|
||||||
import net.minecraft.world.entity.MobSpawnType
|
import net.minecraft.world.entity.MobSpawnType
|
||||||
import net.minecraft.world.level.levelgen.Heightmap
|
import net.minecraft.world.level.levelgen.Heightmap
|
||||||
|
import quaedam.config.QuaedamConfig
|
||||||
import quaedam.projection.ProjectionEffect
|
import quaedam.projection.ProjectionEffect
|
||||||
import quaedam.projector.Projector
|
import quaedam.projector.Projector
|
||||||
import quaedam.projector.ProjectorBlockEntity
|
import quaedam.projector.ProjectorBlockEntity
|
||||||
@ -18,6 +19,8 @@ data class SwarmProjectionEffect(
|
|||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
const val TAG_MAX_COUNT = "MaxCount"
|
const val TAG_MAX_COUNT = "MaxCount"
|
||||||
|
|
||||||
|
val maxMaxCount get() = QuaedamConfig.current.valuesInt["projection.swarm.max_max_count"] ?: 250
|
||||||
}
|
}
|
||||||
|
|
||||||
override val type
|
override val type
|
||||||
@ -30,7 +33,7 @@ data class SwarmProjectionEffect(
|
|||||||
override fun fromNbt(tag: CompoundTag, trusted: Boolean) {
|
override fun fromNbt(tag: CompoundTag, trusted: Boolean) {
|
||||||
maxCount = tag.getInt(TAG_MAX_COUNT)
|
maxCount = tag.getInt(TAG_MAX_COUNT)
|
||||||
if (!trusted) {
|
if (!trusted) {
|
||||||
maxCount = min(maxCount, 250)
|
maxCount = min(maxCount, maxMaxCount)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -60,7 +63,7 @@ data class SwarmProjectionEffect(
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun createShell() = buildProjectionEffectShell(this) {
|
override fun createShell() = buildProjectionEffectShell(this) {
|
||||||
intSlider("quaedam.shell.swarm.max_count", ::maxCount, 0..250 step 5)
|
intSlider("quaedam.shell.swarm.max_count", ::maxCount, 0..maxMaxCount step 5)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user