More backporting
This commit is contained in:
parent
7683cacc29
commit
422ae92303
@ -668,11 +668,11 @@ class ExplosionQueue(private val level: ServerLevel) : SavedData() {
|
||||
@JvmStatic
|
||||
fun queueForLevel(level: ServerLevel): ExplosionQueue {
|
||||
return level.dataStorage.computeIfAbsent(
|
||||
Factory({ ExplosionQueue(level) }, {
|
||||
{
|
||||
val factory = ExplosionQueue(level)
|
||||
factory.load(it)
|
||||
factory
|
||||
}, DataFixTypes.LEVEL),
|
||||
}, { ExplosionQueue(level) },
|
||||
"otm_blackhole_explosion_queue"
|
||||
)
|
||||
}
|
||||
|
@ -46,7 +46,7 @@ class Panel2Widget<out S: Screen, out P : EditablePanel<S>>(
|
||||
return panel.mouseDraggedChecked(p_94740_, p_94741_, p_94742_, p_94743_, p_94744_)
|
||||
}
|
||||
|
||||
override fun mouseScrolled(mouseX: Double, mouseY: Double, scrollX: Double, scrollY: Double): Boolean {
|
||||
override fun mouseScrolled(mouseX: Double, mouseY: Double, scrollY: Double): Boolean {
|
||||
return panel.mouseScrolledChecked(mouseX, mouseY, scrollY)
|
||||
}
|
||||
|
||||
|
@ -35,7 +35,7 @@ fun onCuriosSlotModifiersUpdated(event: SlotModifiersUpdatedEvent) {
|
||||
}
|
||||
|
||||
fun openCuriosScreen(carriedStack: ItemStack = ItemStack.EMPTY) {
|
||||
if (FMLEnvironment.dist.isClient) NetworkHandler.INSTANCE.send(CPacketOpenCurios(carriedStack), PacketDistributor.SERVER.noArg())
|
||||
if (FMLEnvironment.dist.isClient) NetworkHandler.INSTANCE.send(PacketDistributor.SERVER.noArg(), CPacketOpenCurios(carriedStack))
|
||||
}
|
||||
|
||||
private fun Player.getCuriosSlotsImpl(): List<PlayerSlot<Slot, Slot>> {
|
||||
|
@ -56,7 +56,7 @@ object MatterBottlerProvider : IBlockComponentProvider, IServerDataProvider<Bloc
|
||||
data.getFloat("workProgress"),
|
||||
null,
|
||||
elementHelper.progressStyle().color(RGBAColor.WHITE.toARGB()),
|
||||
BoxStyle.getNestedBox(),
|
||||
BoxStyle.DEFAULT,
|
||||
true
|
||||
)
|
||||
)
|
||||
|
@ -57,7 +57,7 @@ object MatterReconstructorProvider : IBlockComponentProvider, IServerDataProvide
|
||||
maxDamage
|
||||
),
|
||||
elementHelper.progressStyle().color(RGBAColor.DARK_GREEN.toARGB()).textColor(RGBAColor.WHITE.toARGB()),
|
||||
BoxStyle.getNestedBox(),
|
||||
BoxStyle.DEFAULT,
|
||||
true
|
||||
)
|
||||
)
|
||||
|
@ -69,7 +69,7 @@ object MatterStorageProvider : IBlockComponentProvider, IServerDataProvider<Bloc
|
||||
maxStoredMatter.formatMatter()
|
||||
),
|
||||
elementHelper.progressStyle().color(JadeColors.MATTER_COLOR.toARGB()).textColor(RGBAColor.WHITE.toARGB()),
|
||||
BoxStyle.getNestedBox(),
|
||||
BoxStyle.DEFAULT,
|
||||
true
|
||||
)
|
||||
)
|
||||
|
@ -67,7 +67,7 @@ object MatteryEnergyProvider : IBlockComponentProvider, IServerDataProvider<Bloc
|
||||
maxBatteryLevel.formatPower()
|
||||
),
|
||||
elementHelper.progressStyle().color(JadeColors.ENERGY_COLOR.toARGB(), JadeColors.ENERGY_COLOR2.toARGB()).textColor(RGBAColor.WHITE.toARGB()),
|
||||
BoxStyle.getNestedBox(),
|
||||
BoxStyle.DEFAULT,
|
||||
true
|
||||
)
|
||||
)
|
||||
|
@ -75,7 +75,7 @@ object MatteryWorkerProvider : IBlockComponentProvider, IServerDataProvider<Bloc
|
||||
progress,
|
||||
null,
|
||||
if (isUnableToProcess) styleError else style,
|
||||
BoxStyle.getNestedBox(),
|
||||
BoxStyle.DEFAULT,
|
||||
true
|
||||
)
|
||||
)
|
||||
|
@ -14,15 +14,14 @@ import net.minecraft.world.entity.player.Player
|
||||
import net.minecraft.world.inventory.MenuType
|
||||
import net.minecraft.world.inventory.Slot
|
||||
import net.minecraft.world.item.crafting.CraftingRecipe
|
||||
import net.minecraft.world.item.crafting.RecipeHolder
|
||||
import ru.dbotthepony.mc.otm.core.TranslatableComponent
|
||||
import ru.dbotthepony.mc.otm.core.toImmutableList
|
||||
import ru.dbotthepony.mc.otm.menu.ExopackInventoryMenu
|
||||
import java.util.*
|
||||
import kotlin.collections.ArrayList
|
||||
|
||||
class ExopackInventoryTransferHandler(private val helper: IRecipeTransferHandlerHelper) : IRecipeTransferHandler<ExopackInventoryMenu, RecipeHolder<CraftingRecipe>> {
|
||||
private val transfer = helper.createUnregisteredRecipeTransferHandler(object : IRecipeTransferInfo<ExopackInventoryMenu, RecipeHolder<CraftingRecipe>> {
|
||||
class ExopackInventoryTransferHandler(private val helper: IRecipeTransferHandlerHelper) : IRecipeTransferHandler<ExopackInventoryMenu, CraftingRecipe> {
|
||||
private val transfer = helper.createUnregisteredRecipeTransferHandler(object : IRecipeTransferInfo<ExopackInventoryMenu, CraftingRecipe> {
|
||||
override fun getContainerClass(): Class<out ExopackInventoryMenu> {
|
||||
return ExopackInventoryMenu::class.java
|
||||
}
|
||||
@ -31,24 +30,24 @@ class ExopackInventoryTransferHandler(private val helper: IRecipeTransferHandler
|
||||
return Optional.empty()
|
||||
}
|
||||
|
||||
override fun getRecipeType(): mezz.jei.api.recipe.RecipeType<RecipeHolder<CraftingRecipe>> {
|
||||
override fun getRecipeType(): mezz.jei.api.recipe.RecipeType<CraftingRecipe> {
|
||||
return RecipeTypes.CRAFTING
|
||||
}
|
||||
|
||||
override fun canHandle(container: ExopackInventoryMenu, recipe: RecipeHolder<CraftingRecipe>): Boolean {
|
||||
override fun canHandle(container: ExopackInventoryMenu, recipe: CraftingRecipe): Boolean {
|
||||
return true
|
||||
}
|
||||
|
||||
override fun getRecipeSlots(
|
||||
container: ExopackInventoryMenu,
|
||||
recipe: RecipeHolder<CraftingRecipe>
|
||||
recipe: CraftingRecipe
|
||||
): List<Slot> {
|
||||
return container.craftingSlots
|
||||
}
|
||||
|
||||
override fun getInventorySlots(
|
||||
container: ExopackInventoryMenu,
|
||||
recipe: RecipeHolder<CraftingRecipe>
|
||||
recipe: CraftingRecipe
|
||||
): List<Slot> {
|
||||
return container.playerInventorySlots
|
||||
}
|
||||
@ -62,7 +61,7 @@ class ExopackInventoryTransferHandler(private val helper: IRecipeTransferHandler
|
||||
return Optional.empty()
|
||||
}
|
||||
|
||||
override fun getRecipeType(): mezz.jei.api.recipe.RecipeType<RecipeHolder<CraftingRecipe>> {
|
||||
override fun getRecipeType(): mezz.jei.api.recipe.RecipeType<CraftingRecipe> {
|
||||
return RecipeTypes.CRAFTING
|
||||
}
|
||||
|
||||
@ -89,7 +88,7 @@ class ExopackInventoryTransferHandler(private val helper: IRecipeTransferHandler
|
||||
|
||||
override fun transferRecipe(
|
||||
container: ExopackInventoryMenu,
|
||||
recipe: RecipeHolder<CraftingRecipe>,
|
||||
recipe: CraftingRecipe,
|
||||
recipeSlots: IRecipeSlotsView,
|
||||
player: Player,
|
||||
maxTransfer: Boolean,
|
||||
|
@ -32,6 +32,8 @@ import net.minecraft.world.level.block.Blocks
|
||||
import net.minecraft.world.level.block.state.BlockState
|
||||
import net.minecraft.world.level.block.state.StateHolder
|
||||
import net.minecraft.world.level.block.state.properties.Property
|
||||
import net.minecraft.world.level.saveddata.SavedData
|
||||
import net.minecraft.world.level.storage.DimensionDataStorage
|
||||
import net.minecraft.world.phys.Vec3
|
||||
import net.minecraftforge.common.ForgeHooks
|
||||
import net.minecraftforge.common.util.LazyOptional
|
||||
@ -55,6 +57,7 @@ import java.util.Arrays
|
||||
import java.util.Spliterators
|
||||
import java.util.UUID
|
||||
import java.util.function.Consumer
|
||||
import java.util.function.Function
|
||||
import java.util.function.Supplier
|
||||
import java.util.stream.Stream
|
||||
import java.util.stream.StreamSupport
|
||||
|
@ -117,7 +117,7 @@ fun CompoundTag.putJson(key: String, json: JsonElement) {
|
||||
putByteArray(key, bytes.array.copyOfRange(0, bytes.length))
|
||||
}
|
||||
|
||||
fun CompoundTag.getJson(key: String, sizeLimit: NbtAccounter = NbtAccounter(1 shl 18, 512)): JsonElement? {
|
||||
fun CompoundTag.getJson(key: String, sizeLimit: NbtAccounter = NbtAccounter(1 shl 18)): JsonElement? {
|
||||
val bytes = getByteArray(key)
|
||||
|
||||
if (bytes.isEmpty())
|
||||
|
@ -8,6 +8,7 @@ import com.mojang.serialization.Codec
|
||||
import com.mojang.serialization.DataResult
|
||||
import com.mojang.serialization.DynamicOps
|
||||
import com.mojang.serialization.JsonOps
|
||||
import io.netty.buffer.Unpooled
|
||||
import net.minecraft.data.recipes.FinishedRecipe
|
||||
import net.minecraft.network.FriendlyByteBuf
|
||||
import net.minecraft.resources.ResourceLocation
|
||||
|
@ -0,0 +1,37 @@
|
||||
package ru.dbotthepony.mc.otm.data
|
||||
|
||||
import com.google.gson.JsonDeserializationContext
|
||||
import com.google.gson.JsonObject
|
||||
import com.google.gson.JsonSerializationContext
|
||||
import com.google.gson.JsonSyntaxException
|
||||
import com.mojang.serialization.Codec
|
||||
import net.minecraft.world.level.storage.loot.Serializer
|
||||
import ru.dbotthepony.mc.otm.core.fromJsonStrict
|
||||
import ru.dbotthepony.mc.otm.core.set
|
||||
import ru.dbotthepony.mc.otm.core.toJsonStrict
|
||||
|
||||
class Codec2Serializer<T : Any>(val codec: Codec<T>, val embed: Boolean = true) : Serializer<T> {
|
||||
override fun serialize(data: JsonObject, value: T, context: JsonSerializationContext) {
|
||||
if (embed) {
|
||||
val result = codec.toJsonStrict(value, data)
|
||||
|
||||
if (result !is JsonObject) {
|
||||
throw RuntimeException("Expected JsonObject from codec, got ${result::class.qualifiedName}")
|
||||
}
|
||||
|
||||
val keys = ArrayList(data.keySet())
|
||||
for (k in keys) data.remove(k)
|
||||
for ((k, v) in result.entrySet()) data[k] = v
|
||||
} else {
|
||||
data["value"] = codec.toJsonStrict(value)
|
||||
}
|
||||
}
|
||||
|
||||
override fun deserialize(data: JsonObject, context: JsonDeserializationContext): T {
|
||||
if (embed) {
|
||||
return codec.fromJsonStrict(data)
|
||||
} else {
|
||||
return codec.fromJsonStrict(data["value"] ?: throw JsonSyntaxException("Missing 'value' element"))
|
||||
}
|
||||
}
|
||||
}
|
@ -16,6 +16,7 @@ import ru.dbotthepony.mc.otm.core.nbt.getJson
|
||||
import ru.dbotthepony.mc.otm.core.nbt.set
|
||||
import ru.dbotthepony.mc.otm.core.stream
|
||||
import ru.dbotthepony.mc.otm.core.tagNotNull
|
||||
import ru.dbotthepony.mc.otm.data.Codec2Serializer
|
||||
import ru.dbotthepony.mc.otm.registry.MItemFunctionTypes
|
||||
import java.util.Optional
|
||||
import java.util.stream.Stream
|
||||
@ -73,15 +74,17 @@ class CopyTileNbtFunction(filter: Stream<out String> = Stream.empty()) : LootIte
|
||||
}
|
||||
|
||||
companion object {
|
||||
val CODEC: Codec<CopyTileNbtFunction> by lazy {
|
||||
RecordCodecBuilder.create {
|
||||
it.group(
|
||||
Codec.STRING.listOf()
|
||||
.optionalFieldOf("filter")
|
||||
.xmap({ it.orElseGet { listOf() } }, { if (it.isEmpty()) Optional.empty() else Optional.of(it) })
|
||||
.forGetter(CopyTileNbtFunction::filter),
|
||||
).apply(it, ::CopyTileNbtFunction)
|
||||
}
|
||||
val CODEC by lazy {
|
||||
Codec2Serializer<CopyTileNbtFunction>(
|
||||
RecordCodecBuilder.create {
|
||||
it.group(
|
||||
Codec.STRING.listOf()
|
||||
.optionalFieldOf("filter")
|
||||
.xmap({ it.orElseGet { listOf() } }, { if (it.isEmpty()) Optional.empty() else Optional.of(it) })
|
||||
.forGetter(CopyTileNbtFunction::filter),
|
||||
).apply(it, ::CopyTileNbtFunction)
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -24,6 +24,7 @@ import ru.dbotthepony.mc.otm.core.math.Decimal
|
||||
import ru.dbotthepony.mc.otm.core.math.set
|
||||
import ru.dbotthepony.mc.otm.core.nbt.mapPresent
|
||||
import ru.dbotthepony.mc.otm.core.tagNotNull
|
||||
import ru.dbotthepony.mc.otm.data.Codec2Serializer
|
||||
import ru.dbotthepony.mc.otm.data.DecimalProvider
|
||||
import ru.dbotthepony.mc.otm.registry.MItemFunctionTypes
|
||||
import java.util.Optional
|
||||
@ -119,15 +120,17 @@ class ProceduralBatteryItem : Item(Properties().stacksTo(1)) {
|
||||
}
|
||||
|
||||
companion object {
|
||||
val CODEC: Codec<Randomizer> by lazy {
|
||||
RecordCodecBuilder.create {
|
||||
it.group(
|
||||
DecimalProvider.CODEC.fieldOf("maxBatteryLevel").forGetter(Randomizer::maxBatteryLevel),
|
||||
DecimalProvider.CODEC.optionalFieldOf("batteryLevel").forGetter(Randomizer::batteryLevel),
|
||||
DecimalProvider.CODEC.fieldOf("maxInput").forGetter(Randomizer::maxInput),
|
||||
DecimalProvider.CODEC.optionalFieldOf("maxOutput").forGetter(Randomizer::maxOutput),
|
||||
).apply(it, ::Randomizer)
|
||||
}
|
||||
val CODEC by lazy {
|
||||
Codec2Serializer<Randomizer>(
|
||||
RecordCodecBuilder.create {
|
||||
it.group(
|
||||
DecimalProvider.CODEC.fieldOf("maxBatteryLevel").forGetter(Randomizer::maxBatteryLevel),
|
||||
DecimalProvider.CODEC.optionalFieldOf("batteryLevel").forGetter(Randomizer::batteryLevel),
|
||||
DecimalProvider.CODEC.fieldOf("maxInput").forGetter(Randomizer::maxInput),
|
||||
DecimalProvider.CODEC.optionalFieldOf("maxOutput").forGetter(Randomizer::maxOutput),
|
||||
).apply(it, ::Randomizer)
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -30,8 +30,10 @@ import ru.dbotthepony.mc.otm.capability.energy.getBarColor
|
||||
import ru.dbotthepony.mc.otm.capability.energy.getBarWidth
|
||||
import ru.dbotthepony.mc.otm.capability.matteryEnergy
|
||||
import ru.dbotthepony.mc.otm.config.EnergyBalanceValues
|
||||
import ru.dbotthepony.mc.otm.core.Factory
|
||||
import ru.dbotthepony.mc.otm.core.TranslatableComponent
|
||||
import ru.dbotthepony.mc.otm.core.collect.filter
|
||||
import ru.dbotthepony.mc.otm.core.computeIfAbsent
|
||||
import ru.dbotthepony.mc.otm.core.getID
|
||||
import ru.dbotthepony.mc.otm.core.getValue
|
||||
import ru.dbotthepony.mc.otm.core.isNotEmpty
|
||||
@ -153,7 +155,7 @@ class QuantumBatteryItem(val savedataID: String, val balanceValues: EnergyBalanc
|
||||
val clientData = Object2ObjectOpenHashMap<UUID, IValues>()
|
||||
|
||||
val serverData: Data by lazyPerServer {
|
||||
it.overworld().dataStorage.computeIfAbsent(SavedData.Factory(::Data, ::Data, DataFixTypes.SAVED_DATA_MAP_DATA), "otm_$savedataID")
|
||||
it.overworld().dataStorage.computeIfAbsent(::Data, ::Data, "otm_$savedataID")
|
||||
}
|
||||
|
||||
private inner class Power(private val stack: ItemStack) : IMatteryEnergyStorage, ICapabilityProvider {
|
||||
|
@ -15,6 +15,7 @@ import net.minecraft.world.level.storage.loot.functions.LootItemFunctionType
|
||||
import ru.dbotthepony.mc.otm.core.TranslatableComponent
|
||||
import ru.dbotthepony.mc.otm.core.nbt.set
|
||||
import ru.dbotthepony.mc.otm.core.tagNotNull
|
||||
import ru.dbotthepony.mc.otm.data.Codec2Serializer
|
||||
import ru.dbotthepony.mc.otm.registry.MItemFunctionTypes
|
||||
import java.util.*
|
||||
|
||||
@ -34,11 +35,15 @@ class ProceduralExopackSlotUpgradeItem : AbstractExopackSlotUpgradeItem(defaultP
|
||||
}
|
||||
|
||||
companion object {
|
||||
val CODEC: Codec<Randomizer> = RecordCodecBuilder.create {
|
||||
it.group(
|
||||
IntProvider.CODEC.fieldOf("slots").forGetter(Randomizer::slots),
|
||||
IntProvider.CODEC.optionalFieldOf("luck_bias", ConstantInt.ZERO).forGetter(Randomizer::luckBias),
|
||||
).apply(it, ::Randomizer)
|
||||
val CODEC by lazy {
|
||||
Codec2Serializer<Randomizer>(
|
||||
RecordCodecBuilder.create {
|
||||
it.group(
|
||||
IntProvider.CODEC.fieldOf("slots").forGetter(Randomizer::slots),
|
||||
IntProvider.CODEC.optionalFieldOf("luck_bias", ConstantInt.ZERO).forGetter(Randomizer::luckBias),
|
||||
).apply(it, ::Randomizer)
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -242,7 +242,7 @@ class NetworkedItemView(val ply: Player, val menu: MatteryMenu, val isRemote: Bo
|
||||
|
||||
fun network() {
|
||||
check(!isRemote) { "Not a server" }
|
||||
val consumer = PacketDistributor.PLAYER.with(ply as ServerPlayer)
|
||||
val consumer = PacketDistributor.PLAYER.with { ply as ServerPlayer }
|
||||
|
||||
for (packet in networkBacklog) {
|
||||
MenuNetworkChannel.send(consumer, packet)
|
||||
|
@ -13,6 +13,7 @@ import ru.dbotthepony.mc.otm.container.ShadowCraftingContainer
|
||||
import ru.dbotthepony.mc.otm.container.get
|
||||
import ru.dbotthepony.mc.otm.container.set
|
||||
import ru.dbotthepony.mc.otm.core.isNotEmpty
|
||||
import ru.dbotthepony.mc.otm.core.value
|
||||
import ru.dbotthepony.mc.otm.item.IQuantumLinked
|
||||
import ru.dbotthepony.mc.otm.menu.OutputSlot
|
||||
import ru.dbotthepony.mc.otm.menu.MatteryMenu
|
||||
|
@ -123,11 +123,11 @@ object GenericNetworkChannel : MatteryNetworkChannel(
|
||||
name = "generic"
|
||||
) {
|
||||
fun makeSmoke(x: Double, y: Double, z: Double, level: Level) {
|
||||
send(PacketDistributor.NEAR.with(PacketDistributor.TargetPoint(x, y, z, 64.0, level.dimension())), SmokeParticlesPacket(x, y, z))
|
||||
send(PacketDistributor.NEAR.with { PacketDistributor.TargetPoint(x, y, z, 64.0, level.dimension()) }, SmokeParticlesPacket(x, y, z))
|
||||
}
|
||||
|
||||
fun makeSmoke(excluded: ServerPlayer, x: Double, y: Double, z: Double) {
|
||||
send(PacketDistributor.NEAR.with(PacketDistributor.TargetPoint(excluded, x, y, z, 64.0, excluded.level().dimension())), SmokeParticlesPacket(x, y, z))
|
||||
send(PacketDistributor.NEAR.with { PacketDistributor.TargetPoint(excluded, x, y, z, 64.0, excluded.level().dimension()) }, SmokeParticlesPacket(x, y, z))
|
||||
}
|
||||
|
||||
fun register() {
|
||||
|
@ -42,6 +42,7 @@ interface IMatterEntanglerRecipe : IMatteryRecipe<CraftingContainer> {
|
||||
}
|
||||
|
||||
open class MatterEntanglerRecipe(
|
||||
val id: ResourceLocation,
|
||||
override val ingredients: IIngredientMatrix,
|
||||
override val matter: Decimal,
|
||||
override val ticks: Double,
|
||||
@ -50,6 +51,10 @@ open class MatterEntanglerRecipe(
|
||||
val uuidKey: String = "uuid",
|
||||
val fixedUuid: Optional<UUID> = Optional.empty()
|
||||
) : IMatterEntanglerRecipe {
|
||||
override fun getId(): ResourceLocation {
|
||||
return id
|
||||
}
|
||||
|
||||
override fun matches(container: CraftingContainer, level: Level): Boolean {
|
||||
if (isIncomplete) return false
|
||||
return ingredients.test(container)
|
||||
@ -98,8 +103,8 @@ open class MatterEntanglerRecipe(
|
||||
return ItemStack(MItems.MATTER_ENTANGLER)
|
||||
}
|
||||
|
||||
fun toFinished(id: ResourceLocation): FinishedRecipe {
|
||||
return SERIALIZER.toFinished(this, id)
|
||||
fun toFinished(): FinishedRecipe {
|
||||
return SERIALIZER.toFinished(this)
|
||||
}
|
||||
|
||||
fun energetic() = Energy(this)
|
||||
@ -114,8 +119,8 @@ open class MatterEntanglerRecipe(
|
||||
}
|
||||
}
|
||||
|
||||
fun toFinished(id: ResourceLocation): FinishedRecipe {
|
||||
return ENERGY_SERIALIZER.toFinished(this, id)
|
||||
fun toFinished(): FinishedRecipe {
|
||||
return ENERGY_SERIALIZER.toFinished(this)
|
||||
}
|
||||
|
||||
override fun getSerializer(): RecipeSerializer<*> {
|
||||
@ -132,8 +137,8 @@ open class MatterEntanglerRecipe(
|
||||
}
|
||||
}
|
||||
|
||||
fun toFinished(id: ResourceLocation): FinishedRecipe {
|
||||
return MATTER_SERIALIZER.toFinished(this, id)
|
||||
fun toFinished(): FinishedRecipe {
|
||||
return MATTER_SERIALIZER.toFinished(this)
|
||||
}
|
||||
|
||||
override fun getSerializer(): RecipeSerializer<*> {
|
||||
@ -152,7 +157,7 @@ open class MatterEntanglerRecipe(
|
||||
Codec.FLOAT.minRange(0f).optionalFieldOf("experience", 0f).forGetter(MatterEntanglerRecipe::experience),
|
||||
Codec.STRING.optionalFieldOf("uuidKey", "uuid").forGetter(MatterEntanglerRecipe::uuidKey),
|
||||
UUIDUtil.STRING_CODEC.optionalFieldOf("fixedUuid").forGetter(MatterEntanglerRecipe::fixedUuid)
|
||||
).apply(it, ::MatterEntanglerRecipe)
|
||||
).apply(it) { a, b, c, d, e, f, g -> MatterEntanglerRecipe(context.id, a, b, c, d, e, f, g) }
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -24,12 +24,17 @@ import ru.dbotthepony.mc.otm.registry.MItems
|
||||
import ru.dbotthepony.mc.otm.registry.MRecipes
|
||||
|
||||
abstract class MatteryCookingRecipe(
|
||||
val id: ResourceLocation,
|
||||
val input: Ingredient,
|
||||
val output: Ingredient,
|
||||
val count: Int = 1,
|
||||
val workTime: Int = 200,
|
||||
val experience: FloatProvider = ConstantFloat.ZERO
|
||||
) : Recipe<Container> {
|
||||
override fun getId(): ResourceLocation {
|
||||
return id
|
||||
}
|
||||
|
||||
override fun matches(container: Container, level: Level): Boolean {
|
||||
if (isIncomplete)
|
||||
return false
|
||||
@ -69,20 +74,21 @@ abstract class MatteryCookingRecipe(
|
||||
|
||||
override fun getResultItem(registry: RegistryAccess): ItemStack = outputStack
|
||||
|
||||
abstract fun toFinished(id: ResourceLocation): FinishedRecipe
|
||||
abstract fun toFinished(): FinishedRecipe
|
||||
}
|
||||
|
||||
class MicrowaveRecipe(
|
||||
id: ResourceLocation,
|
||||
input: Ingredient,
|
||||
output: Ingredient,
|
||||
count: Int = 1,
|
||||
workTime: Int = 200,
|
||||
experience: FloatProvider = ConstantFloat.ZERO
|
||||
) : MatteryCookingRecipe(input, output, count, workTime, experience) {
|
||||
) : MatteryCookingRecipe(id, input, output, count, workTime, experience) {
|
||||
override fun getType(): RecipeType<*> = MRecipes.MICROWAVE
|
||||
override fun getToastSymbol(): ItemStack = ItemStack(MItems.POWERED_SMOKER)
|
||||
override fun getSerializer(): RecipeSerializer<*> = SERIALIZER
|
||||
override fun toFinished(id: ResourceLocation): FinishedRecipe = SERIALIZER.toFinished(this, id)
|
||||
override fun toFinished(): FinishedRecipe = SERIALIZER.toFinished(this)
|
||||
|
||||
companion object {
|
||||
val SERIALIZER = Codec2RecipeSerializer<MicrowaveRecipe> { context ->
|
||||
@ -93,7 +99,7 @@ class MicrowaveRecipe(
|
||||
Codec.INT.minRange(1).optionalFieldOf("count", 1).forGetter(MicrowaveRecipe::count),
|
||||
Codec.INT.minRange(0).optionalFieldOf("workTime", 200).forGetter(MicrowaveRecipe::workTime),
|
||||
FloatProvider.CODEC.optionalFieldOf("experience", ConstantFloat.ZERO).forGetter(MicrowaveRecipe::experience)
|
||||
).apply(it, ::MicrowaveRecipe)
|
||||
).apply(it) { a, b, c, d, e -> MicrowaveRecipe(context.id, a, b, c, d, e) }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -15,7 +15,7 @@ import ru.dbotthepony.mc.otm.OverdriveThatMatters
|
||||
import java.util.function.Consumer
|
||||
|
||||
object MFluids {
|
||||
private val types: DeferredRegister<FluidType> = DeferredRegister.create(ForgeRegistries.FLUID_TYPES, OverdriveThatMatters.MOD_ID)
|
||||
private val types: DeferredRegister<FluidType> = DeferredRegister.create(ForgeRegistries.Keys.FLUID_TYPES, OverdriveThatMatters.MOD_ID)
|
||||
private val fluids: DeferredRegister<Fluid> = DeferredRegister.create(ForgeRegistries.FLUIDS, OverdriveThatMatters.MOD_ID)
|
||||
|
||||
internal fun register(bus: IEventBus) {
|
||||
|
@ -6,6 +6,7 @@ import net.minecraft.world.level.storage.loot.predicates.LootItemConditionType
|
||||
import net.minecraftforge.eventbus.api.IEventBus
|
||||
import net.minecraftforge.registries.DeferredRegister
|
||||
import ru.dbotthepony.mc.otm.OverdriveThatMatters
|
||||
import ru.dbotthepony.mc.otm.data.Codec2Serializer
|
||||
import ru.dbotthepony.mc.otm.data.SingletonCodec
|
||||
import ru.dbotthepony.mc.otm.data.condition.ChanceWithPlaytimeCondition
|
||||
import ru.dbotthepony.mc.otm.data.condition.HasExoPackCondition
|
||||
@ -17,12 +18,12 @@ import ru.dbotthepony.mc.otm.data.condition.ChanceCondition
|
||||
object MLootItemConditions {
|
||||
private val registry = DeferredRegister.create(Registries.LOOT_CONDITION_TYPE, OverdriveThatMatters.MOD_ID)
|
||||
|
||||
val HAS_EXOPACK: LootItemConditionType by registry.register("has_exopack") { LootItemConditionType(SingletonCodec(HasExoPackCondition)) }
|
||||
val CHANCE_WITH_PLAYTIME: LootItemConditionType by registry.register("chance_with_playtime") { LootItemConditionType(ChanceWithPlaytimeCondition.CODEC) }
|
||||
val ITEM_IN_INVENTORY: LootItemConditionType by registry.register("item_in_inventory") { LootItemConditionType(ItemInInventoryCondition.CODEC) }
|
||||
val KILLED_BY_REAL_PLAYER: LootItemConditionType by registry.register("killed_by_real_player") { LootItemConditionType(SingletonCodec(KilledByRealPlayer)) }
|
||||
val KILLED_BY_REAL_PLAYER_OR_INDIRECTLY: LootItemConditionType by registry.register("killed_by_real_player_or_indirectly") { LootItemConditionType(SingletonCodec(KilledByRealPlayerOrIndirectly)) }
|
||||
val CHANCE: LootItemConditionType by registry.register("chance") { LootItemConditionType(ChanceCondition.CODEC) }
|
||||
val HAS_EXOPACK: LootItemConditionType by registry.register("has_exopack") { LootItemConditionType(Codec2Serializer(SingletonCodec(HasExoPackCondition))) }
|
||||
val CHANCE_WITH_PLAYTIME: LootItemConditionType by registry.register("chance_with_playtime") { LootItemConditionType(Codec2Serializer(ChanceWithPlaytimeCondition.CODEC)) }
|
||||
val ITEM_IN_INVENTORY: LootItemConditionType by registry.register("item_in_inventory") { LootItemConditionType(Codec2Serializer(ItemInInventoryCondition.CODEC)) }
|
||||
val KILLED_BY_REAL_PLAYER: LootItemConditionType by registry.register("killed_by_real_player") { LootItemConditionType(Codec2Serializer(SingletonCodec(KilledByRealPlayer))) }
|
||||
val KILLED_BY_REAL_PLAYER_OR_INDIRECTLY: LootItemConditionType by registry.register("killed_by_real_player_or_indirectly") { LootItemConditionType(Codec2Serializer(SingletonCodec(KilledByRealPlayerOrIndirectly))) }
|
||||
val CHANCE: LootItemConditionType by registry.register("chance") { LootItemConditionType(Codec2Serializer(ChanceCondition.CODEC)) }
|
||||
|
||||
internal fun register(bus: IEventBus) {
|
||||
registry.register(bus)
|
||||
|
@ -297,28 +297,28 @@ object MRegistry {
|
||||
NanobotsArmorFeature.Companion
|
||||
EnderTeleporterFeature.Companion
|
||||
|
||||
CriteriaTriggers.register(BlackHoleTrigger.id.toString(), BlackHoleTrigger)
|
||||
CriteriaTriggers.register(BecomeAndroidTrigger.id.toString(), BecomeAndroidTrigger)
|
||||
CriteriaTriggers.register(BecomeAndroidDeathTrigger.id.toString(), BecomeAndroidDeathTrigger)
|
||||
CriteriaTriggers.register(BecomeAndroidSleepTrigger.id.toString(), BecomeAndroidSleepTrigger)
|
||||
CriteriaTriggers.register(BecomeHumaneTrigger.id.toString(), BecomeHumaneTrigger)
|
||||
CriteriaTriggers.register(AndroidResearchTrigger.id.toString(), AndroidResearchTrigger)
|
||||
CriteriaTriggers.register(ShockwaveDamageMobTrigger.id.toString(), ShockwaveDamageMobTrigger)
|
||||
CriteriaTriggers.register(ShockwaveTrigger.id.toString(), ShockwaveTrigger)
|
||||
CriteriaTriggers.register(AndroidBatteryTrigger.id.toString(), AndroidBatteryTrigger)
|
||||
CriteriaTriggers.register(NanobotsArmorTrigger.id.toString(), NanobotsArmorTrigger)
|
||||
CriteriaTriggers.register(FallDampenersSaveTrigger.id.toString(), FallDampenersSaveTrigger)
|
||||
CriteriaTriggers.register(EnderTeleporterFallDeathTrigger.id.toString(), EnderTeleporterFallDeathTrigger)
|
||||
CriteriaTriggers.register(KillAsAndroidTrigger.id.toString(), KillAsAndroidTrigger)
|
||||
CriteriaTriggers.register(AndroidTravelUnderwater.id.toString(), AndroidTravelUnderwater)
|
||||
CriteriaTriggers.register(NailedEntityTrigger.id.toString(), NailedEntityTrigger)
|
||||
CriteriaTriggers.register(ExopackObtainedTrigger.id.toString(), ExopackObtainedTrigger)
|
||||
CriteriaTriggers.register(ExopackGainedSmeltingTrigger.id.toString(), ExopackGainedSmeltingTrigger)
|
||||
CriteriaTriggers.register(ExopackGainedCraftingTrigger.id.toString(), ExopackGainedCraftingTrigger)
|
||||
CriteriaTriggers.register(ExopackGainedEnderAccessTrigger.id.toString(), ExopackGainedEnderAccessTrigger)
|
||||
CriteriaTriggers.register(ExopackSlotsExpandedTrigger.id.toString(), ExopackSlotsExpandedTrigger)
|
||||
CriteriaTriggers.register(ExopackBatterySlotTrigger.id.toString(), ExopackBatterySlotTrigger)
|
||||
CriteriaTriggers.register(TakeItemOutOfReplicatorTrigger.id.toString(), TakeItemOutOfReplicatorTrigger)
|
||||
CriteriaTriggers.register(BlackHoleTrigger)
|
||||
CriteriaTriggers.register(BecomeAndroidTrigger)
|
||||
CriteriaTriggers.register(BecomeAndroidDeathTrigger)
|
||||
CriteriaTriggers.register(BecomeAndroidSleepTrigger)
|
||||
CriteriaTriggers.register(BecomeHumaneTrigger)
|
||||
CriteriaTriggers.register(AndroidResearchTrigger)
|
||||
CriteriaTriggers.register(ShockwaveDamageMobTrigger)
|
||||
CriteriaTriggers.register(ShockwaveTrigger)
|
||||
CriteriaTriggers.register(AndroidBatteryTrigger)
|
||||
CriteriaTriggers.register(NanobotsArmorTrigger)
|
||||
CriteriaTriggers.register(FallDampenersSaveTrigger)
|
||||
CriteriaTriggers.register(EnderTeleporterFallDeathTrigger)
|
||||
CriteriaTriggers.register(KillAsAndroidTrigger)
|
||||
CriteriaTriggers.register(AndroidTravelUnderwater)
|
||||
CriteriaTriggers.register(NailedEntityTrigger)
|
||||
CriteriaTriggers.register(ExopackObtainedTrigger)
|
||||
CriteriaTriggers.register(ExopackGainedSmeltingTrigger)
|
||||
CriteriaTriggers.register(ExopackGainedCraftingTrigger)
|
||||
CriteriaTriggers.register(ExopackGainedEnderAccessTrigger)
|
||||
CriteriaTriggers.register(ExopackSlotsExpandedTrigger)
|
||||
CriteriaTriggers.register(ExopackBatterySlotTrigger)
|
||||
CriteriaTriggers.register(TakeItemOutOfReplicatorTrigger)
|
||||
}
|
||||
|
||||
private fun initializeCommon(event: FMLCommonSetupEvent) {
|
||||
|
Loading…
Reference in New Issue
Block a user