More backporting
This commit is contained in:
parent
3dab053420
commit
df15bd2f69
@ -9,20 +9,20 @@ import java.util.*
|
|||||||
|
|
||||||
class ExtendedReachFeature(android: MatteryPlayerCapability) : AndroidFeature(AndroidFeatures.EXTENDED_REACH, android) {
|
class ExtendedReachFeature(android: MatteryPlayerCapability) : AndroidFeature(AndroidFeatures.EXTENDED_REACH, android) {
|
||||||
override fun applyModifiers() {
|
override fun applyModifiers() {
|
||||||
if (!ForgeMod.BLOCK_REACH.isPresent)
|
if (!ForgeMod.REACH_DISTANCE.isPresent)
|
||||||
return
|
return
|
||||||
|
|
||||||
val reach = ply.getAttribute(ForgeMod.BLOCK_REACH.get()) ?: return
|
val reach = ply.getAttribute(ForgeMod.REACH_DISTANCE.get()) ?: return
|
||||||
|
|
||||||
reach.removePermanentModifier(MODIFIER_ID)
|
reach.removePermanentModifier(MODIFIER_ID)
|
||||||
reach.addPermanentModifier(AttributeModifier(MODIFIER_ID, type.displayName.toString(), level + 1.0, AttributeModifier.Operation.ADDITION))
|
reach.addPermanentModifier(AttributeModifier(MODIFIER_ID, type.displayName.toString(), level + 1.0, AttributeModifier.Operation.ADDITION))
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun removeModifiers() {
|
override fun removeModifiers() {
|
||||||
if (!ForgeMod.BLOCK_REACH.isPresent)
|
if (!ForgeMod.REACH_DISTANCE.isPresent)
|
||||||
return
|
return
|
||||||
|
|
||||||
ply.getAttribute(ForgeMod.BLOCK_REACH.get())?.removePermanentModifier(MODIFIER_ID)
|
ply.getAttribute(ForgeMod.REACH_DISTANCE.get())?.removePermanentModifier(MODIFIER_ID)
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
@ -61,7 +61,7 @@ class ItemMagnetFeature(capability: MatteryPlayerCapability) : AndroidSwitchable
|
|||||||
private data class ItemPos(var position: Vector, var ticksSinceActivity: Int)
|
private data class ItemPos(var position: Vector, var ticksSinceActivity: Int)
|
||||||
private val rememberPositions = WeakHashMap<ItemEntity, ItemPos>()
|
private val rememberPositions = WeakHashMap<ItemEntity, ItemPos>()
|
||||||
|
|
||||||
private val serverPredicate = Predicate<Entity> { it is ItemEntity && !it.hasPickUpDelay() && (it.owner == null || it.owner != ply || it.lifespan - it.age <= 200) }
|
private val serverPredicate = Predicate<Entity> { it is ItemEntity && !it.hasPickUpDelay() && (it.owner == null || it.owner != ply.uuid || it.lifespan - it.age <= 200) }
|
||||||
private val clientPredicate = Predicate<Entity> { it is ItemEntity && (datatable[it] ?: SharedItemEntityData.EMPTY).let { !it.hasPickupDelay && (it.owner == null || it.owner != ply.uuid || it.lifespan - it.age <= 200) } }
|
private val clientPredicate = Predicate<Entity> { it is ItemEntity && (datatable[it] ?: SharedItemEntityData.EMPTY).let { !it.hasPickupDelay && (it.owner == null || it.owner != ply.uuid || it.lifespan - it.age <= 200) } }
|
||||||
|
|
||||||
private fun doTick(server: Boolean) {
|
private fun doTick(server: Boolean) {
|
||||||
@ -79,7 +79,7 @@ class ItemMagnetFeature(capability: MatteryPlayerCapability) : AndroidSwitchable
|
|||||||
ent as ItemEntity
|
ent as ItemEntity
|
||||||
|
|
||||||
if (server) {
|
if (server) {
|
||||||
GenericNetworkChannel.send(ply, ItemEntityDataPacket(ent.id, ent.owner?.uuid, ent.age, ent.lifespan, ent.hasPickUpDelay()))
|
GenericNetworkChannel.send(ply, ItemEntityDataPacket(ent.id, ent.owner, ent.age, ent.lifespan, ent.hasPickUpDelay()))
|
||||||
|
|
||||||
if (!serverPredicate.test(ent)) {
|
if (!serverPredicate.test(ent)) {
|
||||||
continue
|
continue
|
||||||
|
@ -11,16 +11,13 @@ import net.minecraft.world.item.ItemStack
|
|||||||
import net.minecraft.world.item.TooltipFlag
|
import net.minecraft.world.item.TooltipFlag
|
||||||
import net.minecraft.world.level.BlockGetter
|
import net.minecraft.world.level.BlockGetter
|
||||||
import net.minecraft.world.level.Level
|
import net.minecraft.world.level.Level
|
||||||
import net.minecraft.world.level.LevelAccessor
|
|
||||||
import net.minecraft.world.level.block.BasePressurePlateBlock
|
import net.minecraft.world.level.block.BasePressurePlateBlock
|
||||||
import net.minecraft.world.level.block.Block
|
import net.minecraft.world.level.block.Block
|
||||||
import net.minecraft.world.level.block.SoundType
|
import net.minecraft.world.level.block.SoundType
|
||||||
import net.minecraft.world.level.block.state.BlockState
|
import net.minecraft.world.level.block.state.BlockState
|
||||||
import net.minecraft.world.level.block.state.StateDefinition
|
import net.minecraft.world.level.block.state.StateDefinition
|
||||||
import net.minecraft.world.level.block.state.properties.BlockSetType
|
|
||||||
import net.minecraft.world.level.block.state.properties.BlockStateProperties
|
import net.minecraft.world.level.block.state.properties.BlockStateProperties
|
||||||
import net.minecraft.world.level.material.Material
|
import net.minecraft.world.level.material.Material
|
||||||
import net.minecraft.world.level.material.PushReaction
|
|
||||||
import ru.dbotthepony.mc.otm.core.TranslatableComponent
|
import ru.dbotthepony.mc.otm.core.TranslatableComponent
|
||||||
import ru.dbotthepony.mc.otm.core.get
|
import ru.dbotthepony.mc.otm.core.get
|
||||||
|
|
||||||
|
@ -70,12 +70,8 @@ class Panel2Widget<out S: Screen, out P : EditablePanel<S>>(
|
|||||||
return panel.isMouseOver(p_94748_, p_94749_)
|
return panel.isMouseOver(p_94748_, p_94749_)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun setFocused(p_265728_: Boolean) {
|
override fun changeFocus(p_265728_: Boolean): Boolean {
|
||||||
// no op
|
// no op
|
||||||
}
|
|
||||||
|
|
||||||
override fun isFocused(): Boolean {
|
|
||||||
// ага, щас
|
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -44,14 +44,14 @@ class MatteryChestMenu(
|
|||||||
companion object {
|
companion object {
|
||||||
private val registrar = DeferredRegister.create(Registries.MENU, OverdriveThatMatters.MOD_ID)
|
private val registrar = DeferredRegister.create(Registries.MENU, OverdriveThatMatters.MOD_ID)
|
||||||
|
|
||||||
private val GENERIC_9x1 by registrar.register("generic_9x1") { MenuType(::c9x1, FeatureFlags.VANILLA_SET) }
|
private val GENERIC_9x1 by registrar.register("generic_9x1") { MenuType(::c9x1) }
|
||||||
private val GENERIC_9x2 by registrar.register("generic_9x2") { MenuType(::c9x2, FeatureFlags.VANILLA_SET) }
|
private val GENERIC_9x2 by registrar.register("generic_9x2") { MenuType(::c9x2) }
|
||||||
private val GENERIC_9x3 by registrar.register("generic_9x3") { MenuType(::c9x3, FeatureFlags.VANILLA_SET) }
|
private val GENERIC_9x3 by registrar.register("generic_9x3") { MenuType(::c9x3) }
|
||||||
private val GENERIC_9x4 by registrar.register("generic_9x4") { MenuType(::c9x4, FeatureFlags.VANILLA_SET) }
|
private val GENERIC_9x4 by registrar.register("generic_9x4") { MenuType(::c9x4) }
|
||||||
private val GENERIC_9x5 by registrar.register("generic_9x5") { MenuType(::c9x5, FeatureFlags.VANILLA_SET) }
|
private val GENERIC_9x5 by registrar.register("generic_9x5") { MenuType(::c9x5) }
|
||||||
private val GENERIC_9x6 by registrar.register("generic_9x6") { MenuType(::c9x6, FeatureFlags.VANILLA_SET) }
|
private val GENERIC_9x6 by registrar.register("generic_9x6") { MenuType(::c9x6) }
|
||||||
private val GENERIC_3x3 by registrar.register("generic_3x3") { MenuType(::c3x3, FeatureFlags.VANILLA_SET) }
|
private val GENERIC_3x3 by registrar.register("generic_3x3") { MenuType(::c3x3) }
|
||||||
private val HOPPER by registrar.register("hopper") { MenuType(::hopper, FeatureFlags.VANILLA_SET) }
|
private val HOPPER by registrar.register("hopper") { MenuType(::hopper) }
|
||||||
|
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
@JvmOverloads
|
@JvmOverloads
|
||||||
|
@ -100,10 +100,6 @@ open class MatteryCraftingContainer private constructor(private val listener: Ma
|
|||||||
return parent.canPlaceItem(p_18952_, p_18953_)
|
return parent.canPlaceItem(p_18952_, p_18953_)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun canTakeItem(p_273520_: Container, p_272681_: Int, p_273702_: ItemStack): Boolean {
|
|
||||||
return parent.canTakeItem(p_273520_, p_272681_, p_273702_)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun countItem(p_18948_: Item): Int {
|
override fun countItem(p_18948_: Item): Int {
|
||||||
return parent.countItem(p_18948_)
|
return parent.countItem(p_18948_)
|
||||||
}
|
}
|
||||||
|
@ -4,21 +4,14 @@ import com.google.gson.JsonElement
|
|||||||
import com.google.gson.JsonSyntaxException
|
import com.google.gson.JsonSyntaxException
|
||||||
import com.mojang.serialization.Codec
|
import com.mojang.serialization.Codec
|
||||||
import com.mojang.serialization.JsonOps
|
import com.mojang.serialization.JsonOps
|
||||||
import net.minecraft.core.Holder
|
|
||||||
import net.minecraft.core.RegistryAccess
|
|
||||||
import net.minecraft.core.registries.Registries
|
|
||||||
import net.minecraft.nbt.NbtOps
|
import net.minecraft.nbt.NbtOps
|
||||||
import net.minecraft.nbt.Tag
|
import net.minecraft.nbt.Tag
|
||||||
import net.minecraft.network.FriendlyByteBuf
|
import net.minecraft.network.FriendlyByteBuf
|
||||||
import net.minecraft.network.chat.MutableComponent
|
import net.minecraft.network.chat.MutableComponent
|
||||||
import net.minecraft.network.chat.contents.LiteralContents
|
import net.minecraft.network.chat.contents.LiteralContents
|
||||||
import net.minecraft.network.chat.contents.TranslatableContents
|
import net.minecraft.network.chat.contents.TranslatableContents
|
||||||
import net.minecraft.resources.ResourceKey
|
|
||||||
import net.minecraft.resources.ResourceLocation
|
import net.minecraft.resources.ResourceLocation
|
||||||
import net.minecraft.sounds.SoundEvent
|
import net.minecraft.sounds.SoundEvent
|
||||||
import net.minecraft.tags.DamageTypeTags
|
|
||||||
import net.minecraft.world.damagesource.DamageSource
|
|
||||||
import net.minecraft.world.damagesource.DamageType
|
|
||||||
import net.minecraft.world.item.Item
|
import net.minecraft.world.item.Item
|
||||||
import net.minecraft.world.level.block.Block
|
import net.minecraft.world.level.block.Block
|
||||||
import net.minecraft.world.level.material.Fluid
|
import net.minecraft.world.level.material.Fluid
|
||||||
@ -90,13 +83,3 @@ fun FriendlyByteBuf.writeRegistryId(value: Item) = writeRegistryId(ForgeRegistri
|
|||||||
|
|
||||||
// 1.19.3 lol
|
// 1.19.3 lol
|
||||||
inline val SoundEvent.holder get() = ForgeRegistries.SOUND_EVENTS.getHolder(this).orElse(null) ?: throw NoSuchElementException("$this is missing from ${ForgeRegistries.SOUND_EVENTS}")
|
inline val SoundEvent.holder get() = ForgeRegistries.SOUND_EVENTS.getHolder(this).orElse(null) ?: throw NoSuchElementException("$this is missing from ${ForgeRegistries.SOUND_EVENTS}")
|
||||||
|
|
||||||
// 1.19.4 :thonkang:
|
|
||||||
inline val DamageSource.isFall get() = `is`(DamageTypeTags.IS_FALL)
|
|
||||||
inline val DamageSource.isBypassArmor get() = `is`(DamageTypeTags.BYPASSES_ARMOR)
|
|
||||||
inline val DamageSource.isExplosion get() = `is`(DamageTypeTags.IS_EXPLOSION)
|
|
||||||
inline val DamageSource.isFire get() = `is`(DamageTypeTags.IS_FIRE)
|
|
||||||
|
|
||||||
fun RegistryAccess.damageType(key: ResourceKey<DamageType>): Holder<DamageType> {
|
|
||||||
return registryOrThrow(Registries.DAMAGE_TYPE).getHolderOrThrow(key)
|
|
||||||
}
|
|
||||||
|
@ -56,7 +56,7 @@ object CreativeMenuItemComparator : Comparator<Item> {
|
|||||||
if (item2index.isEmpty()) {
|
if (item2index.isEmpty()) {
|
||||||
val player = minecraft.player ?: return
|
val player = minecraft.player ?: return
|
||||||
// creative tabs were not populated yet
|
// creative tabs were not populated yet
|
||||||
CreativeModeTabs.tryRebuildTabContents(player.connection.enabledFeatures(), false /* operator tabs */, player.level.registryAccess())
|
CreativeModeTabs.tryRebuildTabContents(player.connection.enabledFeatures(), false /* operator tabs */)
|
||||||
|
|
||||||
doRebuild()
|
doRebuild()
|
||||||
}
|
}
|
||||||
|
@ -195,11 +195,11 @@ class EnumValueCodec<V : Enum<V>>(clazz: Class<out V>) : IStreamCodec<V>, Codec<
|
|||||||
override fun <T : Any> decode(ops: DynamicOps<T>, input: T): DataResult<Pair<V, T>> {
|
override fun <T : Any> decode(ops: DynamicOps<T>, input: T): DataResult<Pair<V, T>> {
|
||||||
if (ops.compressMaps()) {
|
if (ops.compressMaps()) {
|
||||||
return ops.getNumberValue(input)
|
return ops.getNumberValue(input)
|
||||||
.flatMap { values.getOrNull(it.toInt())?.let { DataResult.success(Pair(it, ops.empty())) } ?: DataResult.error { "No such enum with ordinal index $it" } }
|
.flatMap { values.getOrNull(it.toInt())?.let { DataResult.success(Pair(it, ops.empty())) } ?: DataResult.error("No such enum with ordinal index $it") }
|
||||||
}
|
}
|
||||||
|
|
||||||
return ops.getStringValue(input)
|
return ops.getStringValue(input)
|
||||||
.flatMap { valuesMap[it]?.let { DataResult.success(Pair(it, ops.empty())) } ?: DataResult.error { "No such enum value $it" } }
|
.flatMap { valuesMap[it]?.let { DataResult.success(Pair(it, ops.empty())) } ?: DataResult.error("No such enum value $it") }
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
@ -32,9 +32,9 @@ class CodecList<S : Any>(codecs: Stream<Codec<S>>) : Codec<S> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return DataResult.error {
|
return DataResult.error (
|
||||||
"None of codecs encoded the input:\n " + results.joinToString(";\n ") { it.error().get().message() }
|
"None of codecs encoded the input:\n " + results.joinToString(";\n ") { it.error().get().message() }
|
||||||
}
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun <T : Any> decode(ops: DynamicOps<T>, input: T): DataResult<Pair<S, T>> {
|
override fun <T : Any> decode(ops: DynamicOps<T>, input: T): DataResult<Pair<S, T>> {
|
||||||
@ -50,9 +50,9 @@ class CodecList<S : Any>(codecs: Stream<Codec<S>>) : Codec<S> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return DataResult.error {
|
return DataResult.error (
|
||||||
"None of codecs decoded the input:\n " + results.joinToString(";\n ") { it.error().get().message() }
|
"None of codecs decoded the input:\n " + results.joinToString(";\n ") { it.error().get().message() }
|
||||||
}
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -83,13 +83,13 @@ class PredicatedCodecList<S : Any>(codecs: Stream<kotlin.Pair<Codec<S>, Predicat
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
val i2 = i
|
val i2 = i
|
||||||
results.add(DataResult.error { "Codec #$i2 predicate tested false" })
|
results.add(DataResult.error("Codec #$i2 predicate tested false"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return DataResult.error {
|
return DataResult.error (
|
||||||
"None of codecs encoded the input:\n " + results.joinToString(";\n ") { it.error().get().message() }
|
"None of codecs encoded the input:\n " + results.joinToString(";\n ") { it.error().get().message() }
|
||||||
}
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun <T : Any> decode(ops: DynamicOps<T>, input: T): DataResult<Pair<S, T>> {
|
override fun <T : Any> decode(ops: DynamicOps<T>, input: T): DataResult<Pair<S, T>> {
|
||||||
@ -105,8 +105,8 @@ class PredicatedCodecList<S : Any>(codecs: Stream<kotlin.Pair<Codec<S>, Predicat
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return DataResult.error {
|
return DataResult.error (
|
||||||
"None of codecs decoded the input:\n " + results.joinToString(";\n ") { it.error().get().message() }
|
"None of codecs decoded the input:\n " + results.joinToString(";\n ") { it.error().get().message() }
|
||||||
}
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,11 +10,11 @@ class ComparableCodec<S : Comparable<S>>(val parent: Codec<S>, val min: S? = nul
|
|||||||
if (min != null) {
|
if (min != null) {
|
||||||
if (minExclusive) {
|
if (minExclusive) {
|
||||||
if (input <= min) {
|
if (input <= min) {
|
||||||
return DataResult.error { "Value $input is smaller or equal to minimal $min" }
|
return DataResult.error("Value $input is smaller or equal to minimal $min")
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (input < min) {
|
if (input < min) {
|
||||||
return DataResult.error { "Value $input is smaller than minimal $min" }
|
return DataResult.error("Value $input is smaller than minimal $min")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -22,11 +22,11 @@ class ComparableCodec<S : Comparable<S>>(val parent: Codec<S>, val min: S? = nul
|
|||||||
if (max != null) {
|
if (max != null) {
|
||||||
if (maxExclusive) {
|
if (maxExclusive) {
|
||||||
if (input >= max) {
|
if (input >= max) {
|
||||||
return DataResult.error { "Value $input is bigger or equal to maximal $max" }
|
return DataResult.error("Value $input is bigger or equal to maximal $max")
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (input > max) {
|
if (input > max) {
|
||||||
return DataResult.error { "Value $input is bigger than maximal $max" }
|
return DataResult.error("Value $input is bigger than maximal $max")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,7 @@ object ComponentCodec : Codec<Component> {
|
|||||||
try {
|
try {
|
||||||
return DataResult.success(Pair(Component.Serializer.fromJson(value), ops.empty()))
|
return DataResult.success(Pair(Component.Serializer.fromJson(value), ops.empty()))
|
||||||
} catch (err: JsonSyntaxException) {
|
} catch (err: JsonSyntaxException) {
|
||||||
return DataResult.error { "Error decoding component: ${err.message}" }
|
return DataResult.error("Error decoding component: ${err.message}")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -25,7 +25,7 @@ object DecimalCodec : Codec<Decimal> {
|
|||||||
try {
|
try {
|
||||||
DataResult.success(Pair(Decimal(it), ops.empty()))
|
DataResult.success(Pair(Decimal(it), ops.empty()))
|
||||||
} catch (err: NumberFormatException) {
|
} catch (err: NumberFormatException) {
|
||||||
DataResult.error { "Not a valid number for converting into Decimal: $it" }
|
DataResult.error("Not a valid number for converting into Decimal: $it")
|
||||||
}
|
}
|
||||||
}.get().map(
|
}.get().map(
|
||||||
{
|
{
|
||||||
@ -40,7 +40,7 @@ object DecimalCodec : Codec<Decimal> {
|
|||||||
.toByteArray()
|
.toByteArray()
|
||||||
), ops.empty()))
|
), ops.empty()))
|
||||||
} catch (err: NumberFormatException) {
|
} catch (err: NumberFormatException) {
|
||||||
DataResult.error { "Failed to convert array of bytes into Decimal: $it" }
|
DataResult.error("Failed to convert array of bytes into Decimal: $it")
|
||||||
}
|
}
|
||||||
}.get().map(
|
}.get().map(
|
||||||
{
|
{
|
||||||
@ -54,7 +54,7 @@ object DecimalCodec : Codec<Decimal> {
|
|||||||
DataResult.success(it)
|
DataResult.success(it)
|
||||||
},
|
},
|
||||||
{ e2 ->
|
{ e2 ->
|
||||||
DataResult.error { "None of attempts at decoding Decimal were successful: ${e0.message()}; ${e1.message()}; ${e2.message()}" }
|
DataResult.error("None of attempts at decoding Decimal were successful: ${e0.message()}; ${e1.message()}; ${e2.message()}")
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,7 @@ object IngredientCodec : Codec<Ingredient> {
|
|||||||
try {
|
try {
|
||||||
return DataResult.success(Pair(Ingredient.fromJson(ops.convertTo(JsonOps.INSTANCE, input)), ops.empty()))
|
return DataResult.success(Pair(Ingredient.fromJson(ops.convertTo(JsonOps.INSTANCE, input)), ops.empty()))
|
||||||
} catch (err: JsonSyntaxException) {
|
} catch (err: JsonSyntaxException) {
|
||||||
return DataResult.error { "Error decoding Ingredient: ${err.message}" }
|
return DataResult.error("Error decoding Ingredient: ${err.message}")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -39,13 +39,13 @@ class IngredientMatrixCodec(ingredientCodec: Codec<Ingredient>) : Codec<IIngredi
|
|||||||
Codec.list(Codec.STRING)
|
Codec.list(Codec.STRING)
|
||||||
.flatXmap(
|
.flatXmap(
|
||||||
{ DataResult.success(it) },
|
{ DataResult.success(it) },
|
||||||
{ if (it.iterator().map { it.length }.allEqual()) DataResult.success(it) else DataResult.error { "One or more of patten strings differ in length" } }
|
{ if (it.iterator().map { it.length }.allEqual()) DataResult.success(it) else DataResult.error("One or more of patten strings differ in length") }
|
||||||
)
|
)
|
||||||
.fieldOf("pattern").forGetter(Handwritten::pattern),
|
.fieldOf("pattern").forGetter(Handwritten::pattern),
|
||||||
Codec.unboundedMap(
|
Codec.unboundedMap(
|
||||||
Codec.STRING
|
Codec.STRING
|
||||||
.flatXmap(
|
.flatXmap(
|
||||||
{ if (it.length == 1) DataResult.success(it[0]) else DataResult.error { "Ingredient key must be exactly 1 symbol in length, '$it' is invalid" } },
|
{ if (it.length == 1) DataResult.success(it[0]) else DataResult.error("Ingredient key must be exactly 1 symbol in length, '$it' is invalid") },
|
||||||
{ DataResult.success(it.toString()) }
|
{ DataResult.success(it.toString()) }
|
||||||
), ingredientCodec).fieldOf("key").forGetter(Handwritten::key)
|
), ingredientCodec).fieldOf("key").forGetter(Handwritten::key)
|
||||||
).apply(it, ::Handwritten)
|
).apply(it, ::Handwritten)
|
||||||
@ -69,11 +69,11 @@ class IngredientMatrixCodec(ingredientCodec: Codec<Ingredient>) : Codec<IIngredi
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (errors.isNotEmpty()) {
|
if (errors.isNotEmpty()) {
|
||||||
DataResult.error { "Failed to decode ingredient matrix: ${errors.joinToString { it.get() }}" }
|
DataResult.error("Failed to decode ingredient matrix: ${errors.joinToString { it.get() }}")
|
||||||
} else if (ingredients.isEmpty()) {
|
} else if (ingredients.isEmpty()) {
|
||||||
DataResult.error { "Ingredient list is empty" }
|
DataResult.error("Ingredient list is empty")
|
||||||
} else if (!ingredients.iterator().map { it.size }.allEqual()) {
|
} else if (!ingredients.iterator().map { it.size }.allEqual()) {
|
||||||
DataResult.error { "Ingredient list is not a matrix (one or multiple of rows are mismatched size)" }
|
DataResult.error("Ingredient list is not a matrix (one or multiple of rows are mismatched size)")
|
||||||
} else {
|
} else {
|
||||||
val result = IngredientMatrix(ingredients.first().size, ingredients.size)
|
val result = IngredientMatrix(ingredients.first().size, ingredients.size)
|
||||||
|
|
||||||
@ -92,7 +92,7 @@ class IngredientMatrixCodec(ingredientCodec: Codec<Ingredient>) : Codec<IIngredi
|
|||||||
DataResult.success(it)
|
DataResult.success(it)
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
DataResult.error { "Failed to decode ingredients as list: ${err1.message()} and as pattern/dictionary: ${it.message()}" }
|
DataResult.error("Failed to decode ingredients as list: ${err1.message()} and as pattern/dictionary: ${it.message()}")
|
||||||
}
|
}
|
||||||
).flatMap {
|
).flatMap {
|
||||||
val handwritten = it.first
|
val handwritten = it.first
|
||||||
@ -100,7 +100,7 @@ class IngredientMatrixCodec(ingredientCodec: Codec<Ingredient>) : Codec<IIngredi
|
|||||||
|
|
||||||
for ((row, pattern) in handwritten.pattern.withIndex()) {
|
for ((row, pattern) in handwritten.pattern.withIndex()) {
|
||||||
for ((column, symbol) in pattern.withIndex()) {
|
for ((column, symbol) in pattern.withIndex()) {
|
||||||
val ingredient = if (symbol == ' ') handwritten.key[symbol] ?: Ingredient.EMPTY else handwritten.key[symbol] ?: return@flatMap DataResult.error { "Unknown ingredient with index '$symbol'" }
|
val ingredient = if (symbol == ' ') handwritten.key[symbol] ?: Ingredient.EMPTY else handwritten.key[symbol] ?: return@flatMap DataResult.error("Unknown ingredient with index '$symbol'")
|
||||||
result[column, row] = ingredient
|
result[column, row] = ingredient
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,9 +19,9 @@ object ItemPredicateCodec : Codec<ItemPredicate> {
|
|||||||
return try {
|
return try {
|
||||||
DataResult.success(Pair(ItemPredicate.fromJson(ops.convertTo(JsonOps.INSTANCE, input)), ops.empty()))
|
DataResult.success(Pair(ItemPredicate.fromJson(ops.convertTo(JsonOps.INSTANCE, input)), ops.empty()))
|
||||||
} catch (err: JsonSyntaxException) {
|
} catch (err: JsonSyntaxException) {
|
||||||
DataResult.error { "Failed to deserialize ItemPredicate: ${err.message}" }
|
DataResult.error("Failed to deserialize ItemPredicate: ${err.message}")
|
||||||
} catch (err: JsonParseException) {
|
} catch (err: JsonParseException) {
|
||||||
DataResult.error { "Failed to deserialize ItemPredicate: ${err.message}" }
|
DataResult.error("Failed to deserialize ItemPredicate: ${err.message}")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,7 @@ object UUIDCodec : Codec<UUID> {
|
|||||||
} else if (l.size == 2) {
|
} else if (l.size == 2) {
|
||||||
DataResult.success(Pair(UUID(l[0], l[1]), ops.empty()))
|
DataResult.success(Pair(UUID(l[0], l[1]), ops.empty()))
|
||||||
} else {
|
} else {
|
||||||
DataResult.error { "Can't construct UUID from ${l.size} elements" }
|
DataResult.error("Can't construct UUID from ${l.size} elements")
|
||||||
}
|
}
|
||||||
}.get().map(
|
}.get().map(
|
||||||
{
|
{
|
||||||
@ -43,7 +43,7 @@ object UUIDCodec : Codec<UUID> {
|
|||||||
DataResult.success(it)
|
DataResult.success(it)
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
DataResult.error { "Unable to deserialize UUID: ${e0.message()}; ${it.message()}" }
|
DataResult.error("Unable to deserialize UUID: ${e0.message()}; ${it.message()}")
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -67,7 +67,7 @@ class LootPoolAppender(conditions: Array<out LootItemCondition>, pools: Stream<L
|
|||||||
deque.push(lootTableContextConstructor.newInstance(notExistingLocation, true))
|
deque.push(lootTableContextConstructor.newInstance(notExistingLocation, true))
|
||||||
DataResult.success(serializer.fromJson(it.convert(JsonOps.INSTANCE).value, LootPool::class.java))
|
DataResult.success(serializer.fromJson(it.convert(JsonOps.INSTANCE).value, LootPool::class.java))
|
||||||
} catch(err: JsonSyntaxException) {
|
} catch(err: JsonSyntaxException) {
|
||||||
DataResult.error { err.message }
|
DataResult.error(err.message)
|
||||||
} finally {
|
} finally {
|
||||||
deque.pop()
|
deque.pop()
|
||||||
}
|
}
|
||||||
@ -75,7 +75,7 @@ class LootPoolAppender(conditions: Array<out LootItemCondition>, pools: Stream<L
|
|||||||
try {
|
try {
|
||||||
DataResult.success(Dynamic(JsonOps.INSTANCE, serializer.toJsonTree(it)))
|
DataResult.success(Dynamic(JsonOps.INSTANCE, serializer.toJsonTree(it)))
|
||||||
} catch(err: JsonSyntaxException) {
|
} catch(err: JsonSyntaxException) {
|
||||||
DataResult.error { err.message }
|
DataResult.error(err.message)
|
||||||
}
|
}
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
@ -42,7 +42,7 @@ class EssenceCapsuleItem(private val digital: Boolean) : Item(Properties().stack
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun getUseAnimation(itemStack: ItemStack): UseAnim {
|
override fun getUseAnimation(itemStack: ItemStack): UseAnim {
|
||||||
return if (digital) UseAnim.BOW else UseAnim.BRUSH
|
return UseAnim.BOW
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getUseDuration(itemStack: ItemStack): Int {
|
override fun getUseDuration(itemStack: ItemStack): Int {
|
||||||
|
@ -102,7 +102,7 @@ class PortableCondensationDriveItem(capacity: Int) :
|
|||||||
const val FILTER_PATH = "filter"
|
const val FILTER_PATH = "filter"
|
||||||
|
|
||||||
fun onPickupEvent(event: EntityItemPickupEvent) {
|
fun onPickupEvent(event: EntityItemPickupEvent) {
|
||||||
if (event.item.owner != null && event.item.owner != event.entity && event.item.age < 200 || event.item.item.isEmpty) {
|
if (event.item.owner != null && event.item.owner != event.entity.uuid && event.item.age < 200 || event.item.item.isEmpty) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,8 +17,8 @@ import ru.dbotthepony.mc.otm.client.model.GravitationStabilizerModel
|
|||||||
import java.util.function.Consumer
|
import java.util.function.Consumer
|
||||||
|
|
||||||
private object GravitationStabilizerArmorMaterial : ArmorMaterial {
|
private object GravitationStabilizerArmorMaterial : ArmorMaterial {
|
||||||
override fun getDurabilityForType(p_40410_: ArmorItem.Type) = 0
|
override fun getDurabilityForSlot(p_40410_: EquipmentSlot) = 0
|
||||||
override fun getDefenseForType(p_40411_: ArmorItem.Type) = 3
|
override fun getDefenseForSlot(p_40411_: EquipmentSlot) = 3
|
||||||
override fun getEnchantmentValue() = 0
|
override fun getEnchantmentValue() = 0
|
||||||
override fun getEquipSound(): SoundEvent = SoundEvents.ARMOR_EQUIP_GENERIC
|
override fun getEquipSound(): SoundEvent = SoundEvents.ARMOR_EQUIP_GENERIC
|
||||||
override fun getRepairIngredient(): Ingredient = Ingredient.EMPTY
|
override fun getRepairIngredient(): Ingredient = Ingredient.EMPTY
|
||||||
@ -41,7 +41,7 @@ private object GravitationStabilizerArmorRenderProperties : IClientItemExtension
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class PortableGravitationStabilizerItem : ArmorItem(GravitationStabilizerArmorMaterial, Type.CHESTPLATE, Properties().stacksTo(1).rarity(Rarity.RARE)) {
|
class PortableGravitationStabilizerItem : ArmorItem(GravitationStabilizerArmorMaterial, EquipmentSlot.CHEST, Properties().stacksTo(1).rarity(Rarity.RARE)) {
|
||||||
override fun initializeClient(consumer: Consumer<IClientItemExtensions>) {
|
override fun initializeClient(consumer: Consumer<IClientItemExtensions>) {
|
||||||
super.initializeClient(consumer)
|
super.initializeClient(consumer)
|
||||||
consumer.accept(GravitationStabilizerArmorRenderProperties)
|
consumer.accept(GravitationStabilizerArmorRenderProperties)
|
||||||
|
Loading…
Reference in New Issue
Block a user