Merge branch '1.21' of https://git.dbotthepony.ru/DBot/overdrive_that_matters into 1.21
This commit is contained in:
commit
09320efa73
@ -112,6 +112,9 @@ private fun sounds(provider: MatteryLanguageProvider) {
|
||||
sound("rifle_shot", "Plasma rifle fires")
|
||||
sound("plasma_weapon_overheat", "Plasma weapon overheats")
|
||||
sound("player_become_android", "Player became android")
|
||||
sound("projectile_parry", "Projectile parried")
|
||||
sound("jump_boost", "Jump boost")
|
||||
sound("shockwave", "Landing shockwave")
|
||||
|
||||
sound(MSoundEvents.CARGO_CRATE_OPEN, "Cargo crate opened")
|
||||
}
|
||||
|
@ -121,6 +121,9 @@ private fun sounds(provider: MatteryLanguageProvider) {
|
||||
sound("rifle_shot", "Выстрел плазменной винтовки")
|
||||
sound("plasma_weapon_overheat", "Плазменное оружие перегрелось")
|
||||
sound("player_become_android", "Игрок превратился в андроида")
|
||||
sound("projectile_parry", "Снаряд парирован")
|
||||
sound("jump_boost", "Усиленный прыжок")
|
||||
sound("shockwave", "Ударная волна от приземления")
|
||||
|
||||
sound(MSoundEvents.CARGO_CRATE_OPEN, "Открыт грузовой ящик")
|
||||
}
|
||||
|
@ -363,7 +363,7 @@ abstract class MatteryBlockEntity(p_155228_: BlockEntityType<*>, p_155229_: Bloc
|
||||
{ !isRemoved || creationVersion != currentVersion },
|
||||
// IllegalStateException("Do not call getCapability on an invalid cache or from the invalidation listener!")
|
||||
// what a shame.
|
||||
{ onceServer { if (!isRemoved && creationVersion == currentVersion) listeners.accept(cache?.capability) } })
|
||||
{ if (SERVER_IS_LIVE) onceServer { if (!isRemoved && creationVersion == currentVersion) listeners.accept(cache?.capability) } })
|
||||
|
||||
onceServer {
|
||||
if (!isRemoved && creationVersion == currentVersion) listeners.accept(cache?.capability)
|
||||
|
@ -35,6 +35,7 @@ import ru.dbotthepony.mc.otm.storage.*
|
||||
import java.math.BigInteger
|
||||
import java.util.*
|
||||
import java.util.function.Consumer
|
||||
import java.util.function.Supplier
|
||||
import java.util.stream.Stream
|
||||
|
||||
private data class SlotTuple(val slot: Int, val stack: ItemStack)
|
||||
@ -130,7 +131,7 @@ class StorageBusBlockEntity(blockPos: BlockPos, blockState: BlockState) : Matter
|
||||
}
|
||||
|
||||
init {
|
||||
savetables.codec(::filter, ItemFilter.CODEC, FILTER_KEY)
|
||||
savetables.codec(::filter, ItemFilter.CODEC, FILTER_KEY, Supplier { ItemFilter(MAX_FILTERS) })
|
||||
}
|
||||
|
||||
override fun setLevel(level: Level) {
|
||||
|
@ -38,6 +38,7 @@ import ru.dbotthepony.mc.otm.storage.ItemStorageStack
|
||||
import ru.dbotthepony.mc.otm.storage.StorageStack
|
||||
import java.math.BigInteger
|
||||
import java.util.*
|
||||
import java.util.function.Supplier
|
||||
|
||||
abstract class AbstractStorageImportExport(
|
||||
blockType: BlockEntityType<*>,
|
||||
@ -111,7 +112,7 @@ abstract class AbstractStorageImportExport(
|
||||
}
|
||||
|
||||
init {
|
||||
savetables.codec(::filter, ItemFilter.CODEC, FILTER_KEY)
|
||||
savetables.codec(::filter, ItemFilter.CODEC, FILTER_KEY, Supplier { ItemFilter(MAX_FILTERS) })
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
@ -27,7 +27,7 @@ class ItemFilter private constructor(private val filter: Array<ItemStack>, val i
|
||||
get() = filter.size
|
||||
|
||||
fun set(index: Int, value: ItemStack): ItemFilter {
|
||||
if (ItemStack.isSameItemSameComponents(filter[index], value) || filter.any { ItemStack.isSameItemSameComponents(it, value) })
|
||||
if (ItemStack.isSameItemSameComponents(filter[index], value) || !value.isEmpty && filter.any { ItemStack.isSameItemSameComponents(it, value) })
|
||||
return this
|
||||
|
||||
return copy(filter.copyOf().also { it[index] = value })
|
||||
|
@ -24,6 +24,7 @@ import ru.dbotthepony.mc.otm.core.math.Decimal
|
||||
import ru.dbotthepony.mc.otm.core.math.Vector
|
||||
import ru.dbotthepony.mc.otm.core.nbt.set
|
||||
import java.util.function.Supplier
|
||||
import kotlin.jvm.optionals.getOrNull
|
||||
import kotlin.reflect.KMutableProperty0
|
||||
import kotlin.reflect.KProperty0
|
||||
|
||||
@ -174,8 +175,8 @@ class Savetables : INBTSerializable<CompoundTag?> {
|
||||
|
||||
fun <T : Any> codecNullable(prop: Delegate<T?>, codec: Codec<T>, name: String): Stateless<T?, Tag> {
|
||||
return Stateless(prop, name, Tag::class.java)
|
||||
.withSerializer { prop.get()?.let { codec.encode(it, NbtOps.INSTANCE, NbtOps.INSTANCE.empty()).getOrThrow() { throw IllegalStateException("Failed to write NBT data for $name: $it") } } }
|
||||
.withDeserializer { codec.decode(NbtOps.INSTANCE, it).getOrThrow() { throw IllegalStateException("Failed to read NBT data for $name: $it") }.first }
|
||||
.withSerializer { prop.get()?.let { codec.encode(it, NbtOps.INSTANCE, NbtOps.INSTANCE.empty()).getOrThrow { throw IllegalStateException("Failed to write save data for '$name': $it") } } }
|
||||
.withDeserializer { codec.decode(NbtOps.INSTANCE, it).resultOrPartial { throw IllegalStateException("Failed to read save data for '$name'", RuntimeException(it)) }.getOrNull()?.first }
|
||||
}
|
||||
|
||||
fun <T : Any> codecNullable(prop: KMutableProperty0<T?>, codec: Codec<T>, name: String = prop.name): Stateless<T?, Tag> {
|
||||
@ -184,8 +185,8 @@ class Savetables : INBTSerializable<CompoundTag?> {
|
||||
|
||||
fun <T : Any> codecNullable(prop: Delegate<T?>, codec: Codec<T>, name: String, default: T?): Stateless<T?, Tag> {
|
||||
return Stateless(prop, name, Tag::class.java)
|
||||
.withSerializer { prop.get()?.let { codec.encode(it, NbtOps.INSTANCE, NbtOps.INSTANCE.empty()).getOrThrow { throw IllegalStateException("Failed to write NBT data for $name: $it") } } }
|
||||
.withDeserializer { codec.decode(NbtOps.INSTANCE, it).mapOrElse({ it.first }, { LOGGER.error("Failed to read NBT data for $name", RuntimeException(it.message())); default }) }
|
||||
.withSerializer { prop.get()?.let { codec.encode(it, NbtOps.INSTANCE, NbtOps.INSTANCE.empty()).getOrThrow { throw IllegalStateException("Failed to write save data for '$name': $it") } } }
|
||||
.withDeserializer { codec.decode(NbtOps.INSTANCE, it).resultOrPartial { LOGGER.error("Failed to read save data for '$name'", RuntimeException(it)) }.map { it.first }.orElse(default) }
|
||||
.withDefault { default }
|
||||
}
|
||||
|
||||
@ -195,15 +196,28 @@ class Savetables : INBTSerializable<CompoundTag?> {
|
||||
|
||||
fun <T : Any> codec(prop: Delegate<T>, codec: Codec<T>, name: String): Stateless<T, Tag> {
|
||||
return Stateless(prop, name, Tag::class.java)
|
||||
.withSerializer { codec.encode(prop.get(), NbtOps.INSTANCE, NbtOps.INSTANCE.empty()).getOrThrow { throw IllegalStateException("Failed to write NBT data for $name: $it") } }
|
||||
.withDeserializer { codec.decode(NbtOps.INSTANCE, it).getOrThrow() { throw IllegalStateException("Failed to read NBT data for $name: $it") }.first }
|
||||
.withSerializer { codec.encode(prop.get(), NbtOps.INSTANCE, NbtOps.INSTANCE.empty()).getOrThrow { throw IllegalStateException("Failed to write save data for '$name': $it") } }
|
||||
.withDeserializer {
|
||||
codec.decode(NbtOps.INSTANCE, it).let { res ->
|
||||
res
|
||||
.resultOrPartial { LOGGER.error("Failed to read save data for '$name'", RuntimeException(it)) }
|
||||
.map { it.first }
|
||||
.orElseThrow { throw RuntimeException("Failed to read save data for '$name': ${res.error().get().message()}") }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun <T : Any> codec(prop: Delegate<T>, codec: Codec<T>, name: String, default: T): Stateless<T, Tag> {
|
||||
fun <T : Any> codec(prop: Delegate<T>, codec: Codec<T>, name: String, default: Supplier<T>): Stateless<T, Tag> {
|
||||
return Stateless(prop, name, Tag::class.java)
|
||||
.withSerializer { codec.encode(prop.get(), NbtOps.INSTANCE, NbtOps.INSTANCE.empty()).getOrThrow { throw IllegalStateException("Failed to write NBT data for $name: $it") } }
|
||||
.withDeserializer { codec.decode(NbtOps.INSTANCE, it).mapOrElse({ it.first }, { LOGGER.error("Failed to read NBT data for $name", RuntimeException(it.message())); default }) }
|
||||
.withDefault { default }
|
||||
.withSerializer { codec.encode(prop.get(), NbtOps.INSTANCE, NbtOps.INSTANCE.empty()).getOrThrow { throw IllegalStateException("Failed to write save data for '$name': $it") } }
|
||||
.withDeserializer {
|
||||
codec
|
||||
.decode(NbtOps.INSTANCE, it)
|
||||
.resultOrPartial { LOGGER.error("Failed to read save data for '$name'", RuntimeException(it)) }
|
||||
.map { it.first }
|
||||
.orElseGet(default)
|
||||
}
|
||||
.withDefault { default.get() }
|
||||
}
|
||||
|
||||
fun <T : Any> codec(prop: KMutableProperty0<T>, codec: Codec<T>, name: String = prop.name): Stateless<T, Tag> {
|
||||
@ -211,10 +225,22 @@ class Savetables : INBTSerializable<CompoundTag?> {
|
||||
}
|
||||
|
||||
fun <T : Any> codec(prop: KMutableProperty0<T>, codec: Codec<T>, name: String = prop.name, default: T): Stateless<T, Tag> {
|
||||
return codec(Delegate.Of(prop), codec, name, Supplier { default })
|
||||
}
|
||||
|
||||
fun <T : Any> codec(prop: KMutableProperty0<T>, codec: Codec<T>, name: String = prop.name, default: Supplier<T>): Stateless<T, Tag> {
|
||||
return codec(Delegate.Of(prop), codec, name, default)
|
||||
}
|
||||
|
||||
fun <T : Any> codec(prop: KMutableProperty0<T>, codec: Codec<T>, default: Supplier<T>): Stateless<T, Tag> {
|
||||
return codec(Delegate.Of(prop), codec, prop.name, default)
|
||||
}
|
||||
|
||||
fun vector(prop: Delegate<Vector>, name: String, default: Vector = Vector.ZERO): Stateless<Vector, Tag> {
|
||||
return codec(prop, Vector.CODEC, name, Supplier { default })
|
||||
}
|
||||
|
||||
fun vector(prop: Delegate<Vector>, name: String, default: Supplier<Vector>): Stateless<Vector, Tag> {
|
||||
return codec(prop, Vector.CODEC, name, default)
|
||||
}
|
||||
|
||||
|
@ -197,7 +197,7 @@ abstract class MatteryMenu(
|
||||
fun decimalInput(allowSpectators: Boolean = false, handler: (Decimal) -> Unit) = PlayerInput(StreamCodecs.DECIMAL, allowSpectators, handler)
|
||||
fun booleanInput(allowSpectators: Boolean = false, handler: (Boolean) -> Unit) = PlayerInput(StreamCodecs.BOOLEAN, allowSpectators, handler)
|
||||
fun itemInput(allowSpectators: Boolean = false, handler: (Item) -> Unit) = PlayerInput(StreamCodecs.ITEM_TYPE, allowSpectators, handler)
|
||||
fun itemStackInput(allowSpectators: Boolean = false, handler: (ItemStack) -> Unit) = PlayerInput(ItemStack.STREAM_CODEC.wrap(), allowSpectators, handler)
|
||||
fun itemStackInput(allowSpectators: Boolean = false, handler: (ItemStack) -> Unit) = PlayerInput(ItemStack.OPTIONAL_STREAM_CODEC.wrap(), allowSpectators, handler)
|
||||
fun nullableItemInput(allowSpectators: Boolean = false, handler: (Item?) -> Unit) = PlayerInput(StreamCodecs.ITEM_TYPE.nullable(), allowSpectators, handler)
|
||||
fun stringInput(allowSpectators: Boolean = false, handler: (String) -> Unit) = PlayerInput(StreamCodecs.STRING, allowSpectators, handler)
|
||||
fun floatInput(allowSpectators: Boolean = false, handler: (Float) -> Unit) = PlayerInput(StreamCodecs.FLOAT, allowSpectators, handler)
|
||||
|
@ -1,5 +1,5 @@
|
||||
{
|
||||
"loader": "forge:composite",
|
||||
"loader": "neoforge:composite",
|
||||
"parts": {
|
||||
"body": {
|
||||
"parent": "overdrive_that_matters:block/energy_servo_body",
|
||||
|
Loading…
Reference in New Issue
Block a user