Move triggers and worldgen to server subpackage

This commit is contained in:
DBotThePony 2025-03-31 08:57:04 +07:00
parent 12241ead12
commit 2b589410f5
Signed by: DBot
GPG Key ID: DCC23B5715498507
34 changed files with 104 additions and 98 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.feature.BlackHolePlacerFeature
private object ConfiguredFeatures {
val TRITANIUM_ORE = key("tritanium_ore")

View File

@ -13,8 +13,8 @@ import ru.dbotthepony.mc.otm.datagen.modLocation
import ru.dbotthepony.mc.otm.registry.MItemTags
import ru.dbotthepony.mc.otm.registry.game.MItems
import ru.dbotthepony.mc.otm.registry.MRegistry
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 java.util.function.Consumer
fun addAdvancements(serializer: Consumer<AdvancementHolder>, lang: MatteryLanguageProvider) {

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

@ -46,7 +46,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

@ -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

@ -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

@ -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.feature.BlackHolePlacerFeature
object MWorldGenFeatures {
private val registry = MDeferredRegister(BuiltInRegistries.FEATURE)

View File

@ -1,4 +1,4 @@
package ru.dbotthepony.mc.otm.worldgen.feature
package ru.dbotthepony.mc.otm.server.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

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
@ -27,7 +27,7 @@ class HurtTrigger(id: ResourceLocation) : MCriterionTrigger<HurtTrigger.Instance
ContextAwarePredicate.CODEC.optionalFieldOf("predicate").forGetter(Instance::predicate),
DamagePredicateCodec.optionalFieldOf("damagePredicate").forGetter(Instance::damagePredicate),
ContextAwarePredicate.CODEC.optionalFieldOf("player").forGetter(Instance::playerPredicate)
).apply(it, ::Instance)
).apply(it, HurtTrigger::Instance)
}
inner class Instance(

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 @@ class ItemTrigger(id: ResourceLocation) : MCriterionTrigger<ItemTrigger.Instance
ItemPredicate.CODEC.fieldOf("predicate").forGetter(Instance::predicate),
Codec.BOOL.optionalFieldOf("invert", false).forGetter(Instance::invert),
ContextAwarePredicate.CODEC.optionalFieldOf("player").forGetter(Instance::playerPredicate)
).apply(it, ::Instance)
).apply(it, ItemTrigger::Instance)
}
inner class Instance(val predicate: ItemPredicate, val invert: Boolean = false, player: Optional<ContextAwarePredicate> = Optional.empty()) : AbstractInstance(player)

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
@ -11,7 +11,7 @@ class SingletonTrigger(id: ResourceLocation) : MCriterionTrigger<SingletonTrigge
override val codec: Codec<Instance> = RecordCodecBuilder.create {
it.group(
ContextAwarePredicate.CODEC.optionalFieldOf("player").forGetter(Instance::playerPredicate)
).apply(it, ::Instance)
).apply(it, SingletonTrigger::Instance)
}
val empty = Instance()