Merge branch '1.21' into world-structures

This commit is contained in:
DBotThePony 2025-03-31 20:58:28 +07:00
commit 0fefe81858
Signed by: DBot
GPG Key ID: DCC23B5715498507
43 changed files with 147 additions and 107 deletions

View File

@ -29,7 +29,7 @@ import ru.dbotthepony.mc.otm.data.world.EllipsoidPlacement
import ru.dbotthepony.mc.otm.data.world.StandardDeviationHeightProvider
import ru.dbotthepony.mc.otm.registry.game.MBlocks
import ru.dbotthepony.mc.otm.registry.data.MWorldGenFeatures
import ru.dbotthepony.mc.otm.worldgen.feature.BlackHolePlacerFeature
import ru.dbotthepony.mc.otm.server.world.feature.BlackHolePlacerFeature
private object ConfiguredFeatures {
val TRITANIUM_ORE = key("tritanium_ore")

View File

@ -12,8 +12,8 @@ import ru.dbotthepony.mc.otm.datagen.modLocation
import ru.dbotthepony.mc.otm.registry.MItemTags
import ru.dbotthepony.mc.otm.registry.MRegistry
import ru.dbotthepony.mc.otm.registry.game.MItems
import ru.dbotthepony.mc.otm.triggers.BlackHoleTrigger
import ru.dbotthepony.mc.otm.triggers.NailedEntityTrigger
import ru.dbotthepony.mc.otm.server.triggers.BlackHoleTrigger
import ru.dbotthepony.mc.otm.server.triggers.NailedEntityTrigger
import ru.dbotthepony.mc.otm.util.registryName
import java.util.function.Consumer

View File

@ -16,19 +16,19 @@ import ru.dbotthepony.mc.otm.datagen.modLocation
import ru.dbotthepony.mc.otm.registry.game.AndroidFeatures
import ru.dbotthepony.mc.otm.registry.game.MItems
import ru.dbotthepony.mc.otm.registry.MNames
import ru.dbotthepony.mc.otm.triggers.AndroidBatteryTrigger
import ru.dbotthepony.mc.otm.triggers.AndroidResearchTrigger
import ru.dbotthepony.mc.otm.triggers.AndroidTravelUnderwater
import ru.dbotthepony.mc.otm.triggers.BecomeAndroidDeathTrigger
import ru.dbotthepony.mc.otm.triggers.BecomeAndroidSleepTrigger
import ru.dbotthepony.mc.otm.triggers.BecomeAndroidTrigger
import ru.dbotthepony.mc.otm.triggers.BecomeHumaneTrigger
import ru.dbotthepony.mc.otm.triggers.EnderTeleporterFallDeathTrigger
import ru.dbotthepony.mc.otm.triggers.FallDampenersSaveTrigger
import ru.dbotthepony.mc.otm.triggers.KillAsAndroidTrigger
import ru.dbotthepony.mc.otm.triggers.NanobotsArmorTrigger
import ru.dbotthepony.mc.otm.triggers.ShockwaveDamageMobTrigger
import ru.dbotthepony.mc.otm.triggers.ShockwaveTrigger
import ru.dbotthepony.mc.otm.server.triggers.AndroidBatteryTrigger
import ru.dbotthepony.mc.otm.server.triggers.AndroidResearchTrigger
import ru.dbotthepony.mc.otm.server.triggers.AndroidTravelUnderwater
import ru.dbotthepony.mc.otm.server.triggers.BecomeAndroidDeathTrigger
import ru.dbotthepony.mc.otm.server.triggers.BecomeAndroidSleepTrigger
import ru.dbotthepony.mc.otm.server.triggers.BecomeAndroidTrigger
import ru.dbotthepony.mc.otm.server.triggers.BecomeHumaneTrigger
import ru.dbotthepony.mc.otm.server.triggers.EnderTeleporterFallDeathTrigger
import ru.dbotthepony.mc.otm.server.triggers.FallDampenersSaveTrigger
import ru.dbotthepony.mc.otm.server.triggers.KillAsAndroidTrigger
import ru.dbotthepony.mc.otm.server.triggers.NanobotsArmorTrigger
import ru.dbotthepony.mc.otm.server.triggers.ShockwaveDamageMobTrigger
import ru.dbotthepony.mc.otm.server.triggers.ShockwaveTrigger
import java.util.*
import java.util.function.Consumer

View File

@ -8,12 +8,12 @@ import net.minecraft.world.item.Items
import ru.dbotthepony.mc.otm.datagen.lang.MatteryLanguageProvider
import ru.dbotthepony.mc.otm.datagen.modLocation
import ru.dbotthepony.mc.otm.registry.game.MItems
import ru.dbotthepony.mc.otm.triggers.ExopackBatterySlotTrigger
import ru.dbotthepony.mc.otm.triggers.ExopackGainedCraftingTrigger
import ru.dbotthepony.mc.otm.triggers.ExopackGainedEnderAccessTrigger
import ru.dbotthepony.mc.otm.triggers.ExopackGainedSmeltingTrigger
import ru.dbotthepony.mc.otm.triggers.ExopackObtainedTrigger
import ru.dbotthepony.mc.otm.triggers.ExopackSlotsExpandedTrigger
import ru.dbotthepony.mc.otm.server.triggers.ExopackBatterySlotTrigger
import ru.dbotthepony.mc.otm.server.triggers.ExopackGainedCraftingTrigger
import ru.dbotthepony.mc.otm.server.triggers.ExopackGainedEnderAccessTrigger
import ru.dbotthepony.mc.otm.server.triggers.ExopackGainedSmeltingTrigger
import ru.dbotthepony.mc.otm.server.triggers.ExopackObtainedTrigger
import ru.dbotthepony.mc.otm.server.triggers.ExopackSlotsExpandedTrigger
import java.util.function.Consumer
fun addExopackAdvancements(serializer: Consumer<AdvancementHolder>, lang: MatteryLanguageProvider, root: AdvancementHolder, zpm: AdvancementHolder) {

View File

@ -13,7 +13,7 @@ import ru.dbotthepony.mc.otm.util.registryName
import ru.dbotthepony.mc.otm.datagen.lang.MatteryLanguageProvider
import ru.dbotthepony.mc.otm.datagen.modLocation
import ru.dbotthepony.mc.otm.registry.game.MItems
import ru.dbotthepony.mc.otm.triggers.TakeItemOutOfReplicatorTrigger
import ru.dbotthepony.mc.otm.server.triggers.TakeItemOutOfReplicatorTrigger
import java.util.function.Consumer
data class CraftEntry(

View File

@ -6,7 +6,7 @@ import net.minecraft.world.entity.player.Inventory;
import net.minecraft.world.item.ItemStack;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite;
import ru.dbotthepony.mc.otm.triggers.MatteryInventoryChangeTrigger;
import ru.dbotthepony.mc.otm.server.triggers.MatteryInventoryChangeTrigger;
@Mixin(InventoryChangeTrigger.class)
public abstract class InventoryChangeTriggerMixin {

View File

@ -9,7 +9,7 @@ import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import ru.dbotthepony.mc.otm.triggers.MatteryInventoryChangeTrigger;
import ru.dbotthepony.mc.otm.server.triggers.MatteryInventoryChangeTrigger;
// i tried to mixin into InventoryChangeTrigger with extends SimpleCriterionTrigger and @Overwrite+@Override
// while also defining SimpleCriterionTrigger methods non final in accesstransfoer

View File

@ -93,7 +93,7 @@ import ru.dbotthepony.mc.otm.registry.data.MPlacementModifiers
import ru.dbotthepony.mc.otm.registry.data.MWorldGenFeatures
import ru.dbotthepony.mc.otm.server.MCommands
import ru.dbotthepony.mc.otm.storage.StorageStack
import ru.dbotthepony.mc.otm.triggers.KillAsAndroidTrigger
import ru.dbotthepony.mc.otm.server.triggers.KillAsAndroidTrigger
import thedarkcolour.kotlinforforge.neoforge.forge.DIST
import thedarkcolour.kotlinforforge.neoforge.forge.FORGE_BUS
import thedarkcolour.kotlinforforge.neoforge.forge.LOADING_CONTEXT

View File

@ -18,6 +18,7 @@ import ru.dbotthepony.mc.otm.util.math.weakGreaterThan
import ru.dbotthepony.mc.otm.util.math.weakLessThan
import ru.dbotthepony.mc.otm.util.set
import ru.dbotthepony.mc.otm.data.codec.DecimalCodec
import ru.dbotthepony.mc.otm.data.codec.EnhancedItemStackCodecs
private fun isReason(status: Any?, reason: Any) = status == null || status == reason
private val LOGGER = LogManager.getLogger()
@ -67,7 +68,7 @@ open class ItemJob(
) : Job(ticks, power, experience) {
companion object {
fun <T : ItemJob> itemCodec(builder: RecordCodecBuilder.Instance<T>): Products.P4<RecordCodecBuilder.Mu<T>, ItemStack, Double, Decimal, Float> {
return builder.group(ItemStack.CODEC.fieldOf("Item").forGetter(ItemJob::itemStack)).and(basicCodec(builder))
return builder.group(EnhancedItemStackCodecs.CODEC.fieldOf("Item").forGetter(ItemJob::itemStack)).and(basicCodec(builder))
}
val CODEC: Codec<ItemJob> by lazy {

View File

@ -48,7 +48,7 @@ import ru.dbotthepony.mc.otm.util.otmRandom
import ru.dbotthepony.mc.otm.matter.MatterManager
import ru.dbotthepony.mc.otm.registry.MDamageTypes
import ru.dbotthepony.mc.otm.registry.MatteryDamageSource
import ru.dbotthepony.mc.otm.triggers.BlackHoleTrigger
import ru.dbotthepony.mc.otm.server.triggers.BlackHoleTrigger
import kotlin.math.pow
import kotlin.math.roundToInt
import kotlin.math.sqrt

View File

@ -38,6 +38,7 @@ import ru.dbotthepony.mc.otm.util.math.Decimal
import ru.dbotthepony.mc.otm.container.ItemStackKey
import ru.dbotthepony.mc.otm.container.asKey
import ru.dbotthepony.mc.otm.data.codec.DecimalCodec
import ru.dbotthepony.mc.otm.data.codec.EnhancedItemStackCodecs
import ru.dbotthepony.mc.otm.data.codec.minRange
import ru.dbotthepony.mc.otm.graph.matter.MatterNode
import ru.dbotthepony.mc.otm.menu.matter.MatterEntanglerMenu
@ -53,7 +54,7 @@ class MatterEntanglerBlockEntity(blockPos: BlockPos, blockState: BlockState) : M
companion object {
val CODEC: Codec<Job> = RecordCodecBuilder.create {
it.group(
ItemStack.CODEC.fieldOf("itemStack").forGetter(ItemJob::itemStack),
EnhancedItemStackCodecs.CODEC.fieldOf("itemStack").forGetter(ItemJob::itemStack),
DecimalCodec.minRange(Decimal.ZERO).fieldOf("matter").forGetter(Job::matter),
Codec.DOUBLE.minRange(0.0).fieldOf("ticks").forGetter(ItemJob::ticks),
Codec.FLOAT.minRange(0f).optionalFieldOf("experience", 0f).forGetter(Job::experience)

View File

@ -30,6 +30,7 @@ import ru.dbotthepony.mc.otm.container.slotted.SlottedContainer
import ru.dbotthepony.mc.otm.util.math.Decimal
import ru.dbotthepony.mc.otm.util.otmRandom
import ru.dbotthepony.mc.otm.data.codec.DecimalCodec
import ru.dbotthepony.mc.otm.data.codec.EnhancedItemStackCodecs
import ru.dbotthepony.mc.otm.data.codec.minRange
import ru.dbotthepony.mc.otm.graph.matter.MatterNode
import ru.dbotthepony.mc.otm.matter.MatterManager
@ -55,7 +56,7 @@ class MatterReplicatorBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) :
val CODEC: Codec<ReplicatorJob> by lazy {
RecordCodecBuilder.create {
it.group(
ItemStack.CODEC.fieldOf("Item").forGetter(ReplicatorJob::itemStack),
EnhancedItemStackCodecs.CODEC.fieldOf("Item").forGetter(ReplicatorJob::itemStack),
DecimalCodec.minRange(Decimal.ZERO).fieldOf("matterPerTick").forGetter(ReplicatorJob::matterPerTick),
UUIDUtil.CODEC.fieldOf("task").forGetter(ReplicatorJob::task),
DecimalCodec.minRange(Decimal.ZERO).fieldOf("matterValue").forGetter(ReplicatorJob::matterValue),

View File

@ -18,8 +18,8 @@ import ru.dbotthepony.mc.otm.util.math.Decimal
import ru.dbotthepony.mc.otm.util.getDecimal
import ru.dbotthepony.mc.otm.util.set
import ru.dbotthepony.mc.otm.registry.StatNames
import ru.dbotthepony.mc.otm.triggers.AndroidBatteryTrigger
import ru.dbotthepony.mc.otm.triggers.ExopackBatterySlotTrigger
import ru.dbotthepony.mc.otm.server.triggers.AndroidBatteryTrigger
import ru.dbotthepony.mc.otm.server.triggers.ExopackBatterySlotTrigger
class BatteryBackedEnergyStorage(
private val ply: Player,

View File

@ -13,6 +13,7 @@ import net.minecraft.world.item.ItemStack
import net.neoforged.neoforge.common.util.INBTSerializable
import org.apache.logging.log4j.LogManager
import ru.dbotthepony.mc.otm.container.slotted.SlottedContainer
import ru.dbotthepony.mc.otm.data.codec.EnhancedItemStackCodecs
import ru.dbotthepony.mc.otm.util.isNotEmpty
import ru.dbotthepony.mc.otm.util.set
@ -133,7 +134,7 @@ abstract class EnhancedContainer<out S : IContainerSlot>(private val size: Int)
if (items[i].isNotEmpty) {
attached = true
tag["item"] = ItemStack.OPTIONAL_CODEC.encodeStart(ops, items[i])
tag["item"] = EnhancedItemStackCodecs.OPTIONAL_CODEC.encodeStart(ops, items[i])
.getOrThrow { RuntimeException("Unable to serialize item ${items[i]} at slot $i: $it") }
}
@ -165,7 +166,7 @@ abstract class EnhancedContainer<out S : IContainerSlot>(private val size: Int)
if (!seenSlots.add(slot)) continue
if ("item" in element) {
ItemStack.OPTIONAL_CODEC.decode(ops, element["item"])
EnhancedItemStackCodecs.OPTIONAL_CODEC.decode(ops, element["item"])
.map { it.first }
.ifError { LOGGER.error("Failed to deserialize item stack in slot $slot: ${it.message()}") }
.ifSuccess {

View File

@ -8,6 +8,7 @@ import net.minecraft.world.item.ItemStack
import net.neoforged.neoforge.common.util.INBTSerializable
import org.apache.logging.log4j.LogManager
import ru.dbotthepony.mc.otm.container.IAutomatedContainerSlot
import ru.dbotthepony.mc.otm.data.codec.EnhancedItemStackCodecs
import ru.dbotthepony.mc.otm.util.isNotEmpty
import ru.dbotthepony.mc.otm.util.set
import ru.dbotthepony.mc.otm.data.getOrNull
@ -97,13 +98,13 @@ open class ContainerSlot(
override fun serializeNBT(provider: HolderLookup.Provider): CompoundTag {
return CompoundTag().also {
it["item"] = ItemStack.OPTIONAL_CODEC.encodeStart(provider.createSerializationContext(NbtOps.INSTANCE), item)
it["item"] = EnhancedItemStackCodecs.OPTIONAL_CODEC.encodeStart(provider.createSerializationContext(NbtOps.INSTANCE), item)
.getOrThrow { RuntimeException("Unable to serialize $item in slot $slot: $it") }
}
}
override fun deserializeNBT(provider: HolderLookup.Provider, nbt: CompoundTag) {
_item = ItemStack.OPTIONAL_CODEC.decode(provider.createSerializationContext(NbtOps.INSTANCE), nbt["item"])
_item = EnhancedItemStackCodecs.OPTIONAL_CODEC.decode(provider.createSerializationContext(NbtOps.INSTANCE), nbt["item"])
.ifError { LOGGER.error("Unable to deserialize item at slot $slot: ${it.message()}") }
.getOrNull()?.first ?: ItemStack.EMPTY

View File

@ -23,6 +23,7 @@ import ru.dbotthepony.mc.otm.container.IAutomatedContainer
import ru.dbotthepony.mc.otm.container.IFilteredContainerSlot
import ru.dbotthepony.mc.otm.container.ItemFilter
import ru.dbotthepony.mc.otm.container.balance
import ru.dbotthepony.mc.otm.data.codec.EnhancedItemStackCodecs
import ru.dbotthepony.mc.otm.util.isNotEmpty
import ru.dbotthepony.mc.otm.util.set
import ru.dbotthepony.mc.otm.data.codec.minRange
@ -183,7 +184,7 @@ class SlottedContainer(
companion object {
val CODEC: Codec<LegacySerializedItem> = RecordCodecBuilder.create {
it.group(
ItemStack.OPTIONAL_CODEC.fieldOf("item").forGetter { it.item },
EnhancedItemStackCodecs.OPTIONAL_CODEC.fieldOf("item").forGetter { it.item },
Codec.INT.minRange(0).fieldOf("slot").forGetter { it.slot },
).apply(it, SlottedContainer::LegacySerializedItem)
}
@ -227,7 +228,7 @@ class SlottedContainer(
for (entry in lostItems) {
if ("item" in entry) {
ItemStack.OPTIONAL_CODEC.decode(provider, entry["item"])
EnhancedItemStackCodecs.OPTIONAL_CODEC.decode(provider, entry["item"])
.ifError { LOGGER.warn("Unable to deserialize 'lost' item: ${it.message()}") }
.ifSuccess { if (it.first.isNotEmpty) result.add(it.first) }
}
@ -275,7 +276,7 @@ class SlottedContainer(
slots[slot].item = item
bitmap[slot] = item.isNotEmpty
} else if (item.isNotEmpty) {
ItemStack.CODEC.encodeStart(provider.createSerializationContext(NbtOps.INSTANCE), item)
EnhancedItemStackCodecs.CODEC.encodeStart(provider.createSerializationContext(NbtOps.INSTANCE), item)
.ifError { LOGGER.warn("Unable to serialize 'lost' item: ${it.message()}") }
.ifSuccess { s ->
this.provider = provider

View File

@ -0,0 +1,26 @@
package ru.dbotthepony.mc.otm.data.codec
import com.mojang.serialization.Codec
import com.mojang.serialization.codecs.RecordCodecBuilder
import net.minecraft.core.component.DataComponentPatch
import net.minecraft.util.ExtraCodecs
import net.minecraft.world.item.ItemStack
import java.util.*
import kotlin.jvm.optionals.getOrElse
object EnhancedItemStackCodecs {
val CODEC: Codec<ItemStack> by lazy {
RecordCodecBuilder.create {
it.group(
ItemStack.ITEM_NON_AIR_CODEC.fieldOf("id").forGetter(ItemStack::getItemHolder),
Codec.INT.minRange(1).fieldOf("count").orElse(1).forGetter(ItemStack::getCount),
DataComponentPatch.CODEC.optionalFieldOf("components", DataComponentPatch.EMPTY).forGetter(ItemStack::getComponentsPatch)
).apply(it, ::ItemStack)
}
}
val OPTIONAL_CODEC: Codec<ItemStack> by lazy {
ExtraCodecs.optionalEmptyMap(CODEC)
.xmap({ it.getOrElse { ItemStack.EMPTY } }, { if (it.isEmpty) Optional.empty() else Optional.of(it) })
}
}

View File

@ -10,6 +10,7 @@ import net.minecraft.world.level.storage.loot.predicates.LootItemCondition
import net.minecraft.world.level.storage.loot.predicates.LootItemConditionType
import ru.dbotthepony.mc.otm.capability.items
import ru.dbotthepony.kommons.collect.filter
import ru.dbotthepony.mc.otm.data.codec.EnhancedItemStackCodecs
import ru.dbotthepony.mc.otm.data.get
import ru.dbotthepony.mc.otm.registry.data.MLootItemConditions
@ -48,7 +49,7 @@ data class ItemInInventoryCondition(
val CODEC: MapCodec<ItemInInventoryCondition> by lazy {
RecordCodecBuilder.mapCodec {
it.group(
ItemStack.CODEC.fieldOf("item").forGetter(ItemInInventoryCondition::item),
EnhancedItemStackCodecs.CODEC.fieldOf("item").forGetter(ItemInInventoryCondition::item),
Codec.BOOL.optionalFieldOf("matchComponents", false).forGetter(ItemInInventoryCondition::matchComponents),
Codec.BOOL.optionalFieldOf("matchCosmetics", false).forGetter(ItemInInventoryCondition::matchCosmetics),
).apply(it, ::ItemInInventoryCondition)

View File

@ -24,7 +24,7 @@ import ru.dbotthepony.mc.otm.util.nextUUID
import ru.dbotthepony.mc.otm.util.otmRandom
import ru.dbotthepony.mc.otm.registry.game.MItems
import ru.dbotthepony.mc.otm.runIfClient
import ru.dbotthepony.mc.otm.triggers.ExopackSlotsExpandedTrigger
import ru.dbotthepony.mc.otm.server.triggers.ExopackSlotsExpandedTrigger
import java.util.UUID
abstract class AbstractExopackSlotUpgradeItem(properties: Properties = defaultProperties()) : Item(properties) {

View File

@ -40,7 +40,7 @@ import ru.dbotthepony.mc.otm.util.math.*
import ru.dbotthepony.mc.otm.registry.MDamageTypes
import ru.dbotthepony.mc.otm.registry.game.MDataComponentTypes
import ru.dbotthepony.mc.otm.registry.MatteryDamageSource
import ru.dbotthepony.mc.otm.triggers.NailedEntityTrigger
import ru.dbotthepony.mc.otm.server.triggers.NailedEntityTrigger
import ru.dbotthepony.mc.otm.util.TranslatableComponent
import ru.dbotthepony.mc.otm.util.damageType
import ru.dbotthepony.mc.otm.util.getExplosionResistance

View File

@ -17,7 +17,7 @@ import ru.dbotthepony.mc.otm.menu.input.ItemConfigPlayerInput
import ru.dbotthepony.mc.otm.menu.makeUpgradeSlots
import ru.dbotthepony.mc.otm.menu.widget.ProfiledLevelGaugeWidget
import ru.dbotthepony.mc.otm.registry.game.MMenus
import ru.dbotthepony.mc.otm.triggers.TakeItemOutOfReplicatorTrigger
import ru.dbotthepony.mc.otm.server.triggers.TakeItemOutOfReplicatorTrigger
class MatterReplicatorMenu @JvmOverloads constructor(
p_38852_: Int,

View File

@ -7,7 +7,7 @@ import ru.dbotthepony.mc.otm.container.EnhancedContainer
import ru.dbotthepony.mc.otm.container.IContainerSlot
import ru.dbotthepony.mc.otm.container.IEnhancedContainer
import ru.dbotthepony.mc.otm.container.ItemFilter
import ru.dbotthepony.mc.otm.triggers.MatteryInventoryChangeTrigger
import ru.dbotthepony.mc.otm.server.triggers.MatteryInventoryChangeTrigger
class ExopackContainer(size: Int, val player: MatteryPlayer) : EnhancedContainer<IPlayerInventorySlot>(size) {
private inner class Slot(slot: Int) : IContainerSlot.Simple(slot, this@ExopackContainer), IPlayerInventorySlot {

View File

@ -101,17 +101,17 @@ import ru.dbotthepony.mc.otm.registry.game.AndroidFeatures
import ru.dbotthepony.mc.otm.registry.MDamageTypes
import ru.dbotthepony.mc.otm.registry.game.MItems
import ru.dbotthepony.mc.otm.registry.MatteryDamageSource
import ru.dbotthepony.mc.otm.triggers.AndroidResearchTrigger
import ru.dbotthepony.mc.otm.triggers.AndroidTravelUnderwater
import ru.dbotthepony.mc.otm.triggers.BecomeAndroidDeathTrigger
import ru.dbotthepony.mc.otm.triggers.BecomeAndroidSleepTrigger
import ru.dbotthepony.mc.otm.triggers.BecomeAndroidTrigger
import ru.dbotthepony.mc.otm.triggers.BecomeHumaneTrigger
import ru.dbotthepony.mc.otm.triggers.ExopackGainedCraftingTrigger
import ru.dbotthepony.mc.otm.triggers.ExopackGainedEnderAccessTrigger
import ru.dbotthepony.mc.otm.triggers.ExopackGainedSmeltingTrigger
import ru.dbotthepony.mc.otm.triggers.ExopackObtainedTrigger
import ru.dbotthepony.mc.otm.triggers.ExopackSlotsExpandedTrigger
import ru.dbotthepony.mc.otm.server.triggers.AndroidResearchTrigger
import ru.dbotthepony.mc.otm.server.triggers.AndroidTravelUnderwater
import ru.dbotthepony.mc.otm.server.triggers.BecomeAndroidDeathTrigger
import ru.dbotthepony.mc.otm.server.triggers.BecomeAndroidSleepTrigger
import ru.dbotthepony.mc.otm.server.triggers.BecomeAndroidTrigger
import ru.dbotthepony.mc.otm.server.triggers.BecomeHumaneTrigger
import ru.dbotthepony.mc.otm.server.triggers.ExopackGainedCraftingTrigger
import ru.dbotthepony.mc.otm.server.triggers.ExopackGainedEnderAccessTrigger
import ru.dbotthepony.mc.otm.server.triggers.ExopackGainedSmeltingTrigger
import ru.dbotthepony.mc.otm.server.triggers.ExopackObtainedTrigger
import ru.dbotthepony.mc.otm.server.triggers.ExopackSlotsExpandedTrigger
import ru.dbotthepony.mc.otm.util.ResourceLocation
import ru.dbotthepony.mc.otm.util.TranslatableComponent
import ru.dbotthepony.mc.otm.util.damageType

View File

@ -20,7 +20,7 @@ import ru.dbotthepony.mc.otm.util.TranslatableComponent
import ru.dbotthepony.mc.otm.util.registryName
import ru.dbotthepony.mc.otm.util.set
import ru.dbotthepony.mc.otm.milliTime
import ru.dbotthepony.mc.otm.triggers.AndroidResearchTrigger
import ru.dbotthepony.mc.otm.server.triggers.AndroidResearchTrigger
import kotlin.math.absoluteValue
class AndroidResearch(val type: AndroidResearchType, val capability: MatteryPlayer) : INBTSerializable<CompoundTag> {

View File

@ -52,7 +52,7 @@ import ru.dbotthepony.mc.otm.util.math.times
import ru.dbotthepony.mc.otm.util.otmRandom
import ru.dbotthepony.mc.otm.milliTime
import ru.dbotthepony.mc.otm.registry.game.AndroidFeatures
import ru.dbotthepony.mc.otm.triggers.EnderTeleporterFallDeathTrigger
import ru.dbotthepony.mc.otm.server.triggers.EnderTeleporterFallDeathTrigger
import java.util.*
import kotlin.math.sin

View File

@ -7,7 +7,7 @@ import ru.dbotthepony.mc.otm.player.MatteryPlayer
import ru.dbotthepony.mc.otm.config.PlayerConfig
import ru.dbotthepony.mc.otm.util.isFall
import ru.dbotthepony.mc.otm.registry.game.AndroidFeatures
import ru.dbotthepony.mc.otm.triggers.FallDampenersSaveTrigger
import ru.dbotthepony.mc.otm.server.triggers.FallDampenersSaveTrigger
class FallDampenersFeature(capability: MatteryPlayer) : AndroidFeature(AndroidFeatures.FALL_DAMPENERS, capability) {
override fun onHurt(event: LivingIncomingDamageEvent) {

View File

@ -16,7 +16,7 @@ import ru.dbotthepony.mc.otm.registry.game.AndroidFeatures
import ru.dbotthepony.mc.otm.registry.StatNames
import ru.dbotthepony.mc.otm.util.set
import ru.dbotthepony.mc.otm.onceServer
import ru.dbotthepony.mc.otm.triggers.NanobotsArmorTrigger
import ru.dbotthepony.mc.otm.server.triggers.NanobotsArmorTrigger
import kotlin.math.roundToInt
class NanobotsArmorFeature(android: MatteryPlayer) : AndroidFeature(AndroidFeatures.NANOBOTS_ARMOR, android) {

View File

@ -30,8 +30,8 @@ import ru.dbotthepony.mc.otm.registry.game.AndroidFeatures
import ru.dbotthepony.mc.otm.registry.MDamageTypes
import ru.dbotthepony.mc.otm.registry.game.MSoundEvents
import ru.dbotthepony.mc.otm.registry.MatteryDamageSource
import ru.dbotthepony.mc.otm.triggers.ShockwaveDamageMobTrigger
import ru.dbotthepony.mc.otm.triggers.ShockwaveTrigger
import ru.dbotthepony.mc.otm.server.triggers.ShockwaveDamageMobTrigger
import ru.dbotthepony.mc.otm.server.triggers.ShockwaveTrigger
import kotlin.math.pow
import kotlin.math.roundToInt

View File

@ -22,6 +22,7 @@ import ru.dbotthepony.kommons.collect.filterNotNull
import ru.dbotthepony.kommons.collect.map
import ru.dbotthepony.mc.otm.util.math.Decimal
import ru.dbotthepony.mc.otm.data.codec.DecimalCodec
import ru.dbotthepony.mc.otm.data.codec.EnhancedItemStackCodecs
import ru.dbotthepony.mc.otm.data.codec.minRange
import ru.dbotthepony.mc.otm.network.StreamCodecs
import ru.dbotthepony.mc.otm.network.optional
@ -168,7 +169,7 @@ open class MatterEntanglerRecipe(
ShapedRecipePattern.MAP_CODEC.fieldOf("ingredients").forGetter(MatterEntanglerRecipe::ingredients),
DecimalCodec.minRange(Decimal.ZERO).fieldOf("matter").forGetter(MatterEntanglerRecipe::matter),
Codec.DOUBLE.minRange(0.0).fieldOf("ticks").forGetter(MatterEntanglerRecipe::ticks),
ItemStack.CODEC.fieldOf("result").forGetter(MatterEntanglerRecipe::result),
EnhancedItemStackCodecs.CODEC.fieldOf("result").forGetter(MatterEntanglerRecipe::result),
Codec.FLOAT.minRange(0f).optionalFieldOf("experience", 0f).forGetter(MatterEntanglerRecipe::experience),
(DataComponentType.CODEC as Codec<DataComponentType<UUID>>).optionalFieldOf("uuidKey").forGetter(MatterEntanglerRecipe::uuidKey),
UUIDUtil.STRING_CODEC.optionalFieldOf("fixedUuid").forGetter(MatterEntanglerRecipe::fixedUuid)

View File

@ -2,28 +2,28 @@ package ru.dbotthepony.mc.otm.registry
import net.minecraft.core.registries.BuiltInRegistries
import net.neoforged.bus.api.IEventBus
import ru.dbotthepony.mc.otm.triggers.AndroidBatteryTrigger
import ru.dbotthepony.mc.otm.triggers.AndroidResearchTrigger
import ru.dbotthepony.mc.otm.triggers.AndroidTravelUnderwater
import ru.dbotthepony.mc.otm.triggers.BecomeAndroidDeathTrigger
import ru.dbotthepony.mc.otm.triggers.BecomeAndroidSleepTrigger
import ru.dbotthepony.mc.otm.triggers.BecomeAndroidTrigger
import ru.dbotthepony.mc.otm.triggers.BecomeHumaneTrigger
import ru.dbotthepony.mc.otm.triggers.BlackHoleTrigger
import ru.dbotthepony.mc.otm.triggers.EnderTeleporterFallDeathTrigger
import ru.dbotthepony.mc.otm.triggers.ExopackBatterySlotTrigger
import ru.dbotthepony.mc.otm.triggers.ExopackGainedCraftingTrigger
import ru.dbotthepony.mc.otm.triggers.ExopackGainedEnderAccessTrigger
import ru.dbotthepony.mc.otm.triggers.ExopackGainedSmeltingTrigger
import ru.dbotthepony.mc.otm.triggers.ExopackObtainedTrigger
import ru.dbotthepony.mc.otm.triggers.ExopackSlotsExpandedTrigger
import ru.dbotthepony.mc.otm.triggers.FallDampenersSaveTrigger
import ru.dbotthepony.mc.otm.triggers.KillAsAndroidTrigger
import ru.dbotthepony.mc.otm.triggers.NailedEntityTrigger
import ru.dbotthepony.mc.otm.triggers.NanobotsArmorTrigger
import ru.dbotthepony.mc.otm.triggers.ShockwaveDamageMobTrigger
import ru.dbotthepony.mc.otm.triggers.ShockwaveTrigger
import ru.dbotthepony.mc.otm.triggers.TakeItemOutOfReplicatorTrigger
import ru.dbotthepony.mc.otm.server.triggers.AndroidBatteryTrigger
import ru.dbotthepony.mc.otm.server.triggers.AndroidResearchTrigger
import ru.dbotthepony.mc.otm.server.triggers.AndroidTravelUnderwater
import ru.dbotthepony.mc.otm.server.triggers.BecomeAndroidDeathTrigger
import ru.dbotthepony.mc.otm.server.triggers.BecomeAndroidSleepTrigger
import ru.dbotthepony.mc.otm.server.triggers.BecomeAndroidTrigger
import ru.dbotthepony.mc.otm.server.triggers.BecomeHumaneTrigger
import ru.dbotthepony.mc.otm.server.triggers.BlackHoleTrigger
import ru.dbotthepony.mc.otm.server.triggers.EnderTeleporterFallDeathTrigger
import ru.dbotthepony.mc.otm.server.triggers.ExopackBatterySlotTrigger
import ru.dbotthepony.mc.otm.server.triggers.ExopackGainedCraftingTrigger
import ru.dbotthepony.mc.otm.server.triggers.ExopackGainedEnderAccessTrigger
import ru.dbotthepony.mc.otm.server.triggers.ExopackGainedSmeltingTrigger
import ru.dbotthepony.mc.otm.server.triggers.ExopackObtainedTrigger
import ru.dbotthepony.mc.otm.server.triggers.ExopackSlotsExpandedTrigger
import ru.dbotthepony.mc.otm.server.triggers.FallDampenersSaveTrigger
import ru.dbotthepony.mc.otm.server.triggers.KillAsAndroidTrigger
import ru.dbotthepony.mc.otm.server.triggers.NailedEntityTrigger
import ru.dbotthepony.mc.otm.server.triggers.NanobotsArmorTrigger
import ru.dbotthepony.mc.otm.server.triggers.ShockwaveDamageMobTrigger
import ru.dbotthepony.mc.otm.server.triggers.ShockwaveTrigger
import ru.dbotthepony.mc.otm.server.triggers.TakeItemOutOfReplicatorTrigger
object MCriteriaTriggers {
private val registrar = MDeferredRegister(BuiltInRegistries.TRIGGER_TYPES)

View File

@ -3,7 +3,7 @@ package ru.dbotthepony.mc.otm.registry.data
import net.minecraft.core.registries.BuiltInRegistries
import net.neoforged.bus.api.IEventBus
import ru.dbotthepony.mc.otm.registry.MDeferredRegister
import ru.dbotthepony.mc.otm.worldgen.feature.BlackHolePlacerFeature
import ru.dbotthepony.mc.otm.server.world.feature.BlackHolePlacerFeature
object MWorldGenFeatures {
private val registry = MDeferredRegister(BuiltInRegistries.FEATURE)

View File

@ -1,4 +1,4 @@
package ru.dbotthepony.mc.otm.triggers
package ru.dbotthepony.mc.otm.server.triggers
import com.mojang.serialization.Codec
import com.mojang.serialization.codecs.RecordCodecBuilder
@ -20,7 +20,7 @@ object AndroidResearchTrigger : MCriterionTrigger<AndroidResearchTrigger.Instanc
it.group(
ResourceLocation.CODEC.optionalFieldOf("research").forGetter(Instance::research),
ContextAwarePredicate.CODEC.optionalFieldOf("player").forGetter(Instance::playerPredicate)
).apply(it, ::Instance)
).apply(it, AndroidResearchTrigger::Instance)
}
class Instance(val research: Optional<ResourceLocation>, player: Optional<ContextAwarePredicate> = Optional.empty()) : AbstractInstance(player), Predicate<AndroidResearchType> {

View File

@ -1,4 +1,4 @@
package ru.dbotthepony.mc.otm.triggers
package ru.dbotthepony.mc.otm.server.triggers
import com.mojang.serialization.Codec
import com.mojang.serialization.codecs.RecordCodecBuilder
@ -19,7 +19,7 @@ object AndroidTravelUnderwater : MCriterionTrigger<AndroidTravelUnderwater.Insta
it.group(
Codec.DOUBLE.minRange(0.0).fieldOf("distanceToTravel").forGetter(Instance::distanceToTravel),
ContextAwarePredicate.CODEC.optionalFieldOf("player").forGetter(Instance::playerPredicate)
).apply(it, ::Instance)
).apply(it, AndroidTravelUnderwater::Instance)
}
class Instance(val distanceToTravel: Double, playerPredicate: Optional<ContextAwarePredicate> = Optional.empty()) : AbstractInstance(playerPredicate)

View File

@ -1,4 +1,4 @@
package ru.dbotthepony.mc.otm.triggers
package ru.dbotthepony.mc.otm.server.triggers
import com.mojang.serialization.Codec
import com.mojang.serialization.codecs.RecordCodecBuilder
@ -22,7 +22,7 @@ object ExopackSlotsExpandedTrigger : MCriterionTrigger<ExopackSlotsExpandedTrigg
Codec.intRange(0, Int.MAX_VALUE).optionalFieldOf("minGained", 0).forGetter(Instance::minGained),
Codec.intRange(0, Int.MAX_VALUE).optionalFieldOf("minTotal", 0).forGetter(Instance::minTotal),
ContextAwarePredicate.CODEC.optionalFieldOf("player").forGetter(Instance::playerPredicate)
).apply(it, ::Instance)
).apply(it, ExopackSlotsExpandedTrigger::Instance)
}
fun trigger(player: ServerPlayer, gained: Int, total: Int) {

View File

@ -1,4 +1,4 @@
package ru.dbotthepony.mc.otm.triggers
package ru.dbotthepony.mc.otm.server.triggers
import com.mojang.serialization.Codec
import com.mojang.serialization.codecs.RecordCodecBuilder

View File

@ -1,4 +1,4 @@
package ru.dbotthepony.mc.otm.triggers
package ru.dbotthepony.mc.otm.server.triggers
import com.mojang.serialization.Codec
import com.mojang.serialization.codecs.RecordCodecBuilder

View File

@ -1,4 +1,4 @@
package ru.dbotthepony.mc.otm.triggers
package ru.dbotthepony.mc.otm.server.triggers
import com.google.common.collect.ImmutableList
import com.mojang.serialization.Codec
@ -28,7 +28,7 @@ object KillAsAndroidTrigger : MCriterionTrigger<KillAsAndroidTrigger.Instance>(R
ContextAwarePredicate.CODEC.optionalFieldOf("entityPredicate").forGetter(Instance::predicate),
FEATURE_CODEC.fieldOf("featurePredicate").forGetter(Instance::featurePredicate),
ContextAwarePredicate.CODEC.optionalFieldOf("player").forGetter(Instance::playerPredicate)
).apply(it, ::Instance)
).apply(it, KillAsAndroidTrigger::Instance)
}
enum class PredicateType(codec: Lazy<MapCodec<out FeaturePredicate>>) : StringRepresentable {
@ -37,22 +37,28 @@ object KillAsAndroidTrigger : MCriterionTrigger<KillAsAndroidTrigger.Instance>(R
}),
HAS(lazy {
RecordCodecBuilder.mapCodec<Has> {
it.group(ResourceLocation.CODEC.fieldOf("name").forGetter(Has::name)).apply(it, ::Has)
it.group(ResourceLocation.CODEC.fieldOf("name").forGetter(Has::name)).apply(it,
KillAsAndroidTrigger::Has
)
}
}),
NOT(lazy {
RecordCodecBuilder.mapCodec<Not> {
it.group(FEATURE_CODEC.fieldOf("parent").forGetter(Not::parent)).apply(it, ::Not)
it.group(FEATURE_CODEC.fieldOf("parent").forGetter(Not::parent)).apply(it, KillAsAndroidTrigger::Not)
}
}),
AND(lazy {
RecordCodecBuilder.mapCodec<And> {
it.group(FEATURE_CODEC.listOf().fieldOf("children").forGetter(And::children)).apply(it, ::And)
it.group(FEATURE_CODEC.listOf().fieldOf("children").forGetter(And::children)).apply(it,
KillAsAndroidTrigger::And
)
}
}),
OR(lazy {
RecordCodecBuilder.mapCodec<OrPredicate> {
it.group(FEATURE_CODEC.listOf().fieldOf("children").forGetter(OrPredicate::children)).apply(it, ::OrPredicate)
it.group(FEATURE_CODEC.listOf().fieldOf("children").forGetter(OrPredicate::children)).apply(it,
KillAsAndroidTrigger::OrPredicate
)
}
});

View File

@ -1,4 +1,4 @@
package ru.dbotthepony.mc.otm.triggers
package ru.dbotthepony.mc.otm.server.triggers
import com.mojang.serialization.Codec
import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet

View File

@ -1,4 +1,4 @@
package ru.dbotthepony.mc.otm.triggers
package ru.dbotthepony.mc.otm.server.triggers
import com.mojang.serialization.Codec
import it.unimi.dsi.fastutil.objects.ObjectArrayList

View File

@ -1,4 +1,4 @@
package ru.dbotthepony.mc.otm.triggers
package ru.dbotthepony.mc.otm.server.triggers
import com.mojang.serialization.Codec
import com.mojang.serialization.codecs.RecordCodecBuilder
@ -14,7 +14,7 @@ object NanobotsArmorTrigger : MCriterionTrigger<NanobotsArmorTrigger.Instance>(R
it.group(
Doubles.CODEC.fieldOf("predicate").forGetter(Instance::predicate),
ContextAwarePredicate.CODEC.optionalFieldOf("player").forGetter(Instance::playerPredicate),
).apply(it, ::Instance)
).apply(it, NanobotsArmorTrigger::Instance)
}
fun trigger(player: ServerPlayer, damageAbsorbed: Double) {

View File

@ -1,4 +1,4 @@
package ru.dbotthepony.mc.otm.triggers
package ru.dbotthepony.mc.otm.server.triggers
import ru.dbotthepony.mc.otm.OverdriveThatMatters
import ru.dbotthepony.mc.otm.util.ResourceLocation

View File

@ -1,4 +1,4 @@
package ru.dbotthepony.mc.otm.triggers
package ru.dbotthepony.mc.otm.server.triggers
import com.mojang.serialization.Codec
import com.mojang.serialization.codecs.RecordCodecBuilder

View File

@ -1,4 +1,4 @@
package ru.dbotthepony.mc.otm.worldgen.feature
package ru.dbotthepony.mc.otm.server.world.feature
import com.mojang.serialization.codecs.RecordCodecBuilder
import net.minecraft.world.level.levelgen.feature.Feature
@ -16,7 +16,7 @@ object BlackHolePlacerFeature : Feature<BlackHolePlacerFeature.Config>(
it.group(
DecimalCodec.fieldOf("matter_min").forGetter(Config::minMatter),
DecimalCodec.fieldOf("matter_max").forGetter(Config::maxMatter)
).apply(it, ::Config)
).apply(it, BlackHolePlacerFeature::Config)
}
) {
data class Config(val minMatter: Decimal, val maxMatter: Decimal) : FeatureConfiguration