From 50851b736ae1317c3426e2cb8ee0507a89a1a372 Mon Sep 17 00:00:00 2001 From: cao-awa Date: Wed, 20 Nov 2024 23:54:59 +0800 Subject: [PATCH] Add events supported: 'FLUID_SCHEDULE_TICK', 'FLUID_SCHEDULE_TICKED', 'BLOCK_SCHEDULE_TICK', 'BLOCK_SCHEDULE_TICKED'. Fix script unresolved reference: 'ENTITY_TICK', 'ENTITY_TICKED' Add event context args: 'RANDOM', 'SCHEDULE_TICK_VIEW', 'FLUID_STATE'. Add method 'preRequest' in 'ConiumEventContextBuilder', used to make 'presage' trigger. Methods 'request' in 'ConiumEventContextBuilder' can input two lambdas now, first is 'arise', seconds is 'presage'. --- document/script/kotlin/event/README.md | 38 +- .../tick/ConiumBlockScheduleTickEvent.kt | 32 ++ .../tick/ConiumBlockScheduleTickedEvent.kt | 32 ++ .../fluid/ConiumFluidScheduleTickEvent.kt | 32 ++ .../fluid/ConiumFluidScheduleTickedEvent.kt | 32 ++ .../cao/awa/conium/event/ConiumEvent.kt | 40 ++ .../context/ConiumEventContextBuilder.kt | 491 +++++++++++++++++- .../conium/event/type/ConiumEventArgTypes.kt | 38 +- .../awa/conium/event/type/ConiumEventType.kt | 13 + .../kotlin/extent/innate/ConiumInnate.kt | 5 + .../mixin/server/world/ServerWorldMixin.java | 83 +++ .../assets/conium/scripts/conium.commons.kts | 17 + 12 files changed, 828 insertions(+), 25 deletions(-) create mode 100644 src/main/java/com/github/cao/awa/conium/block/event/tick/ConiumBlockScheduleTickEvent.kt create mode 100644 src/main/java/com/github/cao/awa/conium/block/event/tick/ConiumBlockScheduleTickedEvent.kt create mode 100644 src/main/java/com/github/cao/awa/conium/block/event/tick/fluid/ConiumFluidScheduleTickEvent.kt create mode 100644 src/main/java/com/github/cao/awa/conium/block/event/tick/fluid/ConiumFluidScheduleTickedEvent.kt create mode 100644 src/main/java/com/github/cao/awa/conium/kotlin/extent/innate/ConiumInnate.kt diff --git a/document/script/kotlin/event/README.md b/document/script/kotlin/event/README.md index 619e1fb..7a6dcbf 100644 --- a/document/script/kotlin/event/README.md +++ b/document/script/kotlin/event/README.md @@ -2,23 +2,27 @@ ## Event types -| Key | Notes | Environment | Cancelable | Cascade events | Input instance | -|-------------------:|:--------------------------------------:|------------:|-----------:|--------------------------------------:|:---------------:| -| SERVER_TICK | Trigger in every server tick | SERVER | false | Too many events | MinecraftServer | -| SERVER_TICK_TAIL | Trigger in every server tick completed | SERVER | false | * | MinecraftServer | -| ITEM_USE_ON_BLOCK | Trigger when an item use on a block | ALL | true | * | Item | -| ITEM_USED_ON_BLOCK | Trigger when an item used on a block | ALL | true | * | Item | -| BREAKING_BLOCK | Trigger when breaking block | ALL | true | ```BREAK_BLOCK``` ```BROKEN_BLOCK``` | Block | -| BREAK_BLOCK | Trigger when broking block | SERVER | true | ```BROKEN_BLOCK``` | Block | -| BROKEN_BLOCK | Trigger when broken block | ALL | false | * | Block | -| PLACE_BLOCK | Trigger when placing block | ALL | true | ```PLACED_BLOCK``` | Block | -| PLACED_BLOCK | Trigger when block placed | ALL | false | * | Block | -| USE_BLOCK | Trigger when using block | ALL | true | ```USED_BLOCK``` | Block | -| USED_BLOCK | Trigger when block used | ALL | false | * | Block | -| ENTITY_DAMAGE | Trigger when entity damaging | ALL | true | ```ENTITY_DAMAGED``` | EntityType<*> | -| ENTITY_DAMAGED | Trigger when entity damaged | ALL | false | * | EntityType<*> | -| ENTITY_DIE | Trigger when entity dying | ALL | true | ```ENTITY_DEAD``` | EntityType<*> | -| ENTITY_DIED | Trigger when entity died | ALL | false | * | EntityType<*> | +| Key | Notes | Environment | Cancelable | Cascade events | Input instance | +|----------------------:|:--------------------------------------:|------------:|-----------:|--------------------------------------:|:---------------:| +| SERVER_TICK | Trigger in every server tick | SERVER | false | Too many events | MinecraftServer | +| SERVER_TICK_TAIL | Trigger in every server tick completed | SERVER | false | * | MinecraftServer | +| ITEM_USE_ON_BLOCK | Trigger when an item use on a block | ALL | true | * | Item | +| ITEM_USED_ON_BLOCK | Trigger when an item used on a block | ALL | true | * | Item | +| BREAKING_BLOCK | Trigger when breaking block | ALL | true | ```BREAK_BLOCK``` ```BROKEN_BLOCK``` | Block | +| BREAK_BLOCK | Trigger when broking block | SERVER | true | ```BROKEN_BLOCK``` | Block | +| BROKEN_BLOCK | Trigger when broken block | ALL | false | * | Block | +| PLACE_BLOCK | Trigger when placing block | ALL | true | ```PLACED_BLOCK``` | Block | +| PLACED_BLOCK | Trigger when block placed | ALL | false | * | Block | +| USE_BLOCK | Trigger when using block | ALL | true | ```USED_BLOCK``` | Block | +| USED_BLOCK | Trigger when block used | ALL | false | * | Block | +| ENTITY_DAMAGE | Trigger when entity damaging | ALL | true | ```ENTITY_DAMAGED``` | EntityType<*> | +| ENTITY_DAMAGED | Trigger when entity damaged | ALL | false | * | EntityType<*> | +| ENTITY_DIE | Trigger when entity dying | ALL | true | ```ENTITY_DEAD``` | EntityType<*> | +| ENTITY_DIED | Trigger when entity died | ALL | false | * | EntityType<*> | +| BLOCK_SCHEDULE_TICK | Trigger when schedule ticking block | SERVER | true | ```BLOCK_SCHEDULE_TICKED``` | Block | +| BLOCK_SCHEDULE_TICKED | Trigger when block ticked | SERVER | false | * | Block | +| FLUID_SCHEDULE_TICK | Trigger when schedule ticking fluid | SERVER | true | ```FLUID_SCHEDULE_TICKED``` | Fluid | +| FLUID_SCHEDULE_TICKED | Trigger when fluid ticked | SERVER | false | * | Fluid | ### Cascade events diff --git a/src/main/java/com/github/cao/awa/conium/block/event/tick/ConiumBlockScheduleTickEvent.kt b/src/main/java/com/github/cao/awa/conium/block/event/tick/ConiumBlockScheduleTickEvent.kt new file mode 100644 index 0000000..e5aa182 --- /dev/null +++ b/src/main/java/com/github/cao/awa/conium/block/event/tick/ConiumBlockScheduleTickEvent.kt @@ -0,0 +1,32 @@ +package com.github.cao.awa.conium.block.event.tick + +import com.github.cao.awa.conium.event.ConiumEvent +import com.github.cao.awa.conium.event.context.ConiumEventContext +import com.github.cao.awa.conium.event.context.ConiumEventContextBuilder.requires +import com.github.cao.awa.conium.event.type.ConiumEventArgTypes +import com.github.cao.awa.conium.event.type.ConiumEventType +import com.github.cao.awa.conium.parameter.ParameterSelective +import com.github.cao.awa.conium.parameter.ParameterSelective5 +import net.minecraft.block.AbstractBlock.AbstractBlockState +import net.minecraft.server.world.ServerWorld +import net.minecraft.util.math.BlockPos +import net.minecraft.util.math.random.Random +import net.minecraft.world.tick.ScheduledTickView + +class ConiumBlockScheduleTickEvent : ConiumEvent>() { + override fun requirement(): ConiumEventContext { + return requires( + ConiumEventArgTypes.SERVER_WORLD, + ConiumEventArgTypes.BLOCK_POS, + ConiumEventArgTypes.BLOCK_STATE, + ConiumEventArgTypes.SCHEDULE_TICK_VIEW, + ConiumEventArgTypes.RANDOM + ).attach( + forever(ConiumEventType.BLOCK_SCHEDULE_TICK) + ).arise { identity, world, pos, blockState, scheduler, random -> + noFailure(identity) { + it.arise(world, pos, blockState, scheduler, random) + } + } + } +} diff --git a/src/main/java/com/github/cao/awa/conium/block/event/tick/ConiumBlockScheduleTickedEvent.kt b/src/main/java/com/github/cao/awa/conium/block/event/tick/ConiumBlockScheduleTickedEvent.kt new file mode 100644 index 0000000..cc48b6d --- /dev/null +++ b/src/main/java/com/github/cao/awa/conium/block/event/tick/ConiumBlockScheduleTickedEvent.kt @@ -0,0 +1,32 @@ +package com.github.cao.awa.conium.block.event.tick + +import com.github.cao.awa.conium.event.ConiumEvent +import com.github.cao.awa.conium.event.context.ConiumEventContext +import com.github.cao.awa.conium.event.context.ConiumEventContextBuilder.requires +import com.github.cao.awa.conium.event.type.ConiumEventArgTypes +import com.github.cao.awa.conium.event.type.ConiumEventType +import com.github.cao.awa.conium.parameter.ParameterSelective +import com.github.cao.awa.conium.parameter.ParameterSelective5 +import net.minecraft.block.AbstractBlock.AbstractBlockState +import net.minecraft.server.world.ServerWorld +import net.minecraft.util.math.BlockPos +import net.minecraft.util.math.random.Random +import net.minecraft.world.tick.ScheduledTickView + +class ConiumBlockScheduleTickedEvent : ConiumEvent>() { + override fun requirement(): ConiumEventContext { + return requires( + ConiumEventArgTypes.SERVER_WORLD, + ConiumEventArgTypes.BLOCK_POS, + ConiumEventArgTypes.BLOCK_STATE, + ConiumEventArgTypes.SCHEDULE_TICK_VIEW, + ConiumEventArgTypes.RANDOM + ).attach( + forever(ConiumEventType.BLOCK_SCHEDULE_TICKED) + ).arise { identity, world, pos, blockState, scheduler, random -> + noFailure(identity) { + it.arise(world, pos, blockState, scheduler, random) + } + } + } +} diff --git a/src/main/java/com/github/cao/awa/conium/block/event/tick/fluid/ConiumFluidScheduleTickEvent.kt b/src/main/java/com/github/cao/awa/conium/block/event/tick/fluid/ConiumFluidScheduleTickEvent.kt new file mode 100644 index 0000000..be30d67 --- /dev/null +++ b/src/main/java/com/github/cao/awa/conium/block/event/tick/fluid/ConiumFluidScheduleTickEvent.kt @@ -0,0 +1,32 @@ +package com.github.cao.awa.conium.block.event.tick.fluid + +import com.github.cao.awa.conium.event.ConiumEvent +import com.github.cao.awa.conium.event.context.ConiumEventContext +import com.github.cao.awa.conium.event.context.ConiumEventContextBuilder.requires +import com.github.cao.awa.conium.event.type.ConiumEventArgTypes +import com.github.cao.awa.conium.event.type.ConiumEventType +import com.github.cao.awa.conium.parameter.ParameterSelective +import com.github.cao.awa.conium.parameter.ParameterSelective5 +import net.minecraft.block.AbstractBlock.AbstractBlockState +import net.minecraft.fluid.FluidState +import net.minecraft.server.world.ServerWorld +import net.minecraft.util.math.BlockPos +import net.minecraft.world.tick.ScheduledTickView + +class ConiumFluidScheduleTickEvent : ConiumEvent>() { + override fun requirement(): ConiumEventContext { + return requires( + ConiumEventArgTypes.SERVER_WORLD, + ConiumEventArgTypes.BLOCK_POS, + ConiumEventArgTypes.BLOCK_STATE, + ConiumEventArgTypes.FLUID_STATE, + ConiumEventArgTypes.SCHEDULE_TICK_VIEW + ).attach( + forever(ConiumEventType.FLUID_SCHEDULE_TICK) + ).arise { identity, world, pos, blockState, fluidState, scheduler -> + noFailure(identity) { + it.arise(world, pos, blockState, fluidState, scheduler) + } + } + } +} diff --git a/src/main/java/com/github/cao/awa/conium/block/event/tick/fluid/ConiumFluidScheduleTickedEvent.kt b/src/main/java/com/github/cao/awa/conium/block/event/tick/fluid/ConiumFluidScheduleTickedEvent.kt new file mode 100644 index 0000000..d11218f --- /dev/null +++ b/src/main/java/com/github/cao/awa/conium/block/event/tick/fluid/ConiumFluidScheduleTickedEvent.kt @@ -0,0 +1,32 @@ +package com.github.cao.awa.conium.block.event.tick.fluid + +import com.github.cao.awa.conium.event.ConiumEvent +import com.github.cao.awa.conium.event.context.ConiumEventContext +import com.github.cao.awa.conium.event.context.ConiumEventContextBuilder.requires +import com.github.cao.awa.conium.event.type.ConiumEventArgTypes +import com.github.cao.awa.conium.event.type.ConiumEventType +import com.github.cao.awa.conium.parameter.ParameterSelective +import com.github.cao.awa.conium.parameter.ParameterSelective5 +import net.minecraft.block.AbstractBlock.AbstractBlockState +import net.minecraft.fluid.FluidState +import net.minecraft.server.world.ServerWorld +import net.minecraft.util.math.BlockPos +import net.minecraft.world.tick.ScheduledTickView + +class ConiumFluidScheduleTickedEvent : ConiumEvent>() { + override fun requirement(): ConiumEventContext { + return requires( + ConiumEventArgTypes.SERVER_WORLD, + ConiumEventArgTypes.BLOCK_POS, + ConiumEventArgTypes.BLOCK_STATE, + ConiumEventArgTypes.FLUID_STATE, + ConiumEventArgTypes.SCHEDULE_TICK_VIEW + ).attach( + forever(ConiumEventType.FLUID_SCHEDULE_TICKED) + ).arise { identity, world, pos, blockState, fluidState, scheduler -> + noFailure(identity) { + it.arise(world, pos, blockState, fluidState, scheduler) + } + } + } +} diff --git a/src/main/java/com/github/cao/awa/conium/event/ConiumEvent.kt b/src/main/java/com/github/cao/awa/conium/event/ConiumEvent.kt index 20175be..a029345 100644 --- a/src/main/java/com/github/cao/awa/conium/event/ConiumEvent.kt +++ b/src/main/java/com/github/cao/awa/conium/event/ConiumEvent.kt @@ -5,6 +5,10 @@ import com.github.cao.awa.conium.block.event.breaking.ConiumBreakingBlockEvent import com.github.cao.awa.conium.block.event.breaking.ConiumBrokenBlockEvent import com.github.cao.awa.conium.block.event.place.ConiumPlaceBlockEvent import com.github.cao.awa.conium.block.event.place.ConiumPlacedBlockEvent +import com.github.cao.awa.conium.block.event.tick.ConiumBlockScheduleTickEvent +import com.github.cao.awa.conium.block.event.tick.ConiumBlockScheduleTickedEvent +import com.github.cao.awa.conium.block.event.tick.fluid.ConiumFluidScheduleTickEvent +import com.github.cao.awa.conium.block.event.tick.fluid.ConiumFluidScheduleTickedEvent import com.github.cao.awa.conium.block.event.use.ConiumUseBlockEvent import com.github.cao.awa.conium.block.event.use.ConiumUsedBlockEvent import com.github.cao.awa.conium.entity.event.damage.ConiumEntityDamageEvent @@ -14,9 +18,11 @@ import com.github.cao.awa.conium.entity.event.die.ConiumEntityDieEvent import com.github.cao.awa.conium.entity.event.tick.ConiumEntityTickEvent import com.github.cao.awa.conium.entity.event.tick.ConiumEntityTickedEvent import com.github.cao.awa.conium.event.context.ConiumEventContext +import com.github.cao.awa.conium.event.context.ConiumEventContextBuilder import com.github.cao.awa.conium.event.server.tick.ConiumServerTickEvent import com.github.cao.awa.conium.event.server.tick.ConiumServerTickTailEvent import com.github.cao.awa.conium.event.trigger.ListTriggerable +import com.github.cao.awa.conium.event.type.ConiumEventArgTypes import com.github.cao.awa.conium.event.type.ConiumEventType import com.github.cao.awa.conium.item.event.use.ConiumItemUseOnBlockEvent import com.github.cao.awa.conium.item.event.use.ConiumItemUsedOnBlockEvent @@ -80,6 +86,18 @@ abstract class ConiumEvent

: ListTriggerable

() { @JvmField val entityDead = ConiumEntityDeadEvent() + @JvmField + val fluidScheduleTick = ConiumFluidScheduleTickEvent() + + @JvmField + val fluidScheduleTicked = ConiumFluidScheduleTickedEvent() + + @JvmField + val blockScheduleTick = ConiumBlockScheduleTickEvent() + + @JvmField + val blockScheduleTicked = ConiumBlockScheduleTickedEvent() + /** * Before event fires, create event context by requirements. * @@ -127,13 +145,24 @@ abstract class ConiumEvent

: ListTriggerable

() { this.events[ConiumEventType.ENTITY_DIE] = this.entityDie this.events[ConiumEventType.ENTITY_DEAD] = this.entityDead + this.events[ConiumEventType.FLUID_SCHEDULE_TICK] = this.fluidScheduleTick + this.events[ConiumEventType.FLUID_SCHEDULE_TICKED] = this.fluidScheduleTicked + this.events[ConiumEventType.BLOCK_SCHEDULE_TICK] = this.blockScheduleTick + this.events[ConiumEventType.BLOCK_SCHEDULE_TICKED] = this.blockScheduleTicked } fun clearEntitySubscribes() { + this.entityTick.clearSubscribes() + this.entityTicked.clearSubscribes() + this.entityDamage.clearSubscribes() + this.entityDamaged.clearSubscribes() + this.entityDie.clearSubscribes() + this.entityDead.clearSubscribes() } fun clearItemSubscribes() { this.itemUseOnBlockEvent.clearSubscribes() + this.itemUsedOnBlockEvent.clearSubscribes() } fun clearServerTickSubscribes() { @@ -141,7 +170,18 @@ abstract class ConiumEvent

: ListTriggerable

() { } fun clearBlockSubscribes() { + this.breakingBlock.clearSubscribes() this.breakBlock.clearSubscribes() + this.brokenBlock.clearSubscribes() + this.placeBlock.clearSubscribes() + this.placedBlock.clearSubscribes() + this.useBlock.clearSubscribes() + this.usedBlock.clearSubscribes() + + this.fluidScheduleTick.clearSubscribes() + this.fluidScheduleTicked.clearSubscribes() + this.blockScheduleTick.clearSubscribes() + this.blockScheduleTicked.clearSubscribes() } } diff --git a/src/main/java/com/github/cao/awa/conium/event/context/ConiumEventContextBuilder.kt b/src/main/java/com/github/cao/awa/conium/event/context/ConiumEventContextBuilder.kt index d20d24b..2d41031 100644 --- a/src/main/java/com/github/cao/awa/conium/event/context/ConiumEventContextBuilder.kt +++ b/src/main/java/com/github/cao/awa/conium/event/context/ConiumEventContextBuilder.kt @@ -87,6 +87,25 @@ object ConiumEventContextBuilder { return ConiumEventContext(DynamicArgsBuilder.requires(arg1, arg2, arg3, arg4, arg5, arg6, arg7, true)) } + @JvmStatic + @SuppressWarnings("UNCHECKED_CAST") + fun preRequest( + eventType: ConiumEventType, + presaging: ParameterSelective1 = ParameterSelective1 { _ -> true } + ): ConiumEventContext> { + val context = ConiumEventContext( + DynamicArgsBuilder.requires(true).lifecycle(DynamicArgsLifecycle.FOREVER) + ) + + ConiumEvent.forever(eventType, context) + + context.presage { + (it as? I)?.let(presaging::arise) ?: true + } + + return context + } + @JvmStatic @SuppressWarnings("UNCHECKED_CAST") fun request( @@ -106,6 +125,53 @@ object ConiumEventContextBuilder { return context } + @JvmStatic + @SuppressWarnings("UNCHECKED_CAST") + fun request( + eventType: ConiumEventType, + arising: ParameterSelective1 = ParameterSelective1 { _ -> true }, + presaging: ParameterSelective1 = ParameterSelective1 { _ -> true }, + ): ConiumEventContext> { + val context = ConiumEventContext( + DynamicArgsBuilder.requires(true).lifecycle(DynamicArgsLifecycle.FOREVER) + ) + + ConiumEvent.forever(eventType, context) + + context.arise { + (it as? I)?.let(arising::arise) ?: true + } + + context.presage { + (it as? I)?.let(presaging::arise) ?: true + } + + return context + } + + @JvmStatic + @SuppressWarnings("UNCHECKED_CAST") + fun preRequest( + eventType: ConiumEventType, + arg1: DynamicArgType, + presaging: ParameterSelective2 = ParameterSelective2 { _, _ -> true } + ): ConiumEventContext> { + val context = ConiumEventContext( + DynamicArgsBuilder.requires( + arg1, + true + ).lifecycle(DynamicArgsLifecycle.FOREVER) + ) + + ConiumEvent.forever(eventType, context) + + context.presage { i, p1 -> + (i as? I)?.let { presaging(it, p1) } ?: true + } + + return context + } + @JvmStatic @SuppressWarnings("UNCHECKED_CAST") fun request( @@ -123,7 +189,60 @@ object ConiumEventContextBuilder { ConiumEvent.forever(eventType, context) context.arise { i, p1 -> - (i as? I)?.let { arising.arise(it, p1) } ?: true + (i as? I)?.let { arising(it, p1) } ?: true + } + + return context + } + + @JvmStatic + @SuppressWarnings("UNCHECKED_CAST") + fun request( + eventType: ConiumEventType, + arg1: DynamicArgType, + arising: ParameterSelective2 = ParameterSelective2 { _, _ -> true }, + presaging: ParameterSelective2 = ParameterSelective2 { _, _ -> true } + ): ConiumEventContext> { + val context = ConiumEventContext( + DynamicArgsBuilder.requires( + arg1, + true + ).lifecycle(DynamicArgsLifecycle.FOREVER) + ) + + ConiumEvent.forever(eventType, context) + + context.arise { i, p1 -> + (i as? I)?.let { arising(it, p1) } ?: true + } + + context.presage { i, p1 -> + (i as? I)?.let { presaging(it, p1) } ?: true + } + + return context + } + + @JvmStatic + @SuppressWarnings("UNCHECKED_CAST") + fun preRequest( + eventType: ConiumEventType, + arg1: DynamicArgType, + arg2: DynamicArgType, + presaging: ParameterSelective3 = ParameterSelective3 { _, _, _ -> true } + ): ConiumEventContext> { + val context = ConiumEventContext( + DynamicArgsBuilder.requires( + arg1, + arg2, + true + ).lifecycle(DynamicArgsLifecycle.FOREVER) + ) + + ConiumEvent.forever(eventType, context) + + context.presage { i, p1, p2 -> + (i as? I)?.let { presaging(it, p1, p2) } ?: true } return context @@ -148,7 +267,64 @@ object ConiumEventContextBuilder { ConiumEvent.forever(eventType, context) context.arise { i, p1, p2 -> - (i as? I)?.let { arising.arise(it, p1, p2) } ?: true + (i as? I)?.let { arising(it, p1, p2) } ?: true + } + + return context + } + + @JvmStatic + @SuppressWarnings("UNCHECKED_CAST") + fun request( + eventType: ConiumEventType, + arg1: DynamicArgType, + arg2: DynamicArgType, + arising: ParameterSelective3 = ParameterSelective3 { _, _, _ -> true }, + presaging: ParameterSelective3 = ParameterSelective3 { _, _, _ -> true }, + ): ConiumEventContext> { + val context = ConiumEventContext( + DynamicArgsBuilder.requires( + arg1, + arg2, + true + ).lifecycle(DynamicArgsLifecycle.FOREVER) + ) + + ConiumEvent.forever(eventType, context) + + context.arise { i, p1, p2 -> + (i as? I)?.let { arising(it, p1, p2) } ?: true + } + + context.presage { i, p1, p2 -> + (i as? I)?.let { presaging(it, p1, p2) } ?: true + } + + return context + } + + @JvmStatic + @SuppressWarnings("UNCHECKED_CAST") + fun preRequest( + eventType: ConiumEventType, + arg1: DynamicArgType, + arg2: DynamicArgType, + arg3: DynamicArgType, + presaging: ParameterSelective4 = ParameterSelective4 { _, _, _, _ -> true } + ): ConiumEventContext> { + val context = ConiumEventContext( + DynamicArgsBuilder.requires( + arg1, + arg2, + arg3, + true + ).lifecycle(DynamicArgsLifecycle.FOREVER) + ) + + ConiumEvent.forever(eventType, context) + + context.presage { i, p1, p2, p3 -> + (i as? I)?.let { presaging(it, p1, p2, p3) } ?: true } return context @@ -181,6 +357,68 @@ object ConiumEventContextBuilder { return context } + @JvmStatic + @SuppressWarnings("UNCHECKED_CAST") + fun request( + eventType: ConiumEventType, + arg1: DynamicArgType, + arg2: DynamicArgType, + arg3: DynamicArgType, + arising: ParameterSelective4 = ParameterSelective4 { _, _, _, _ -> true }, + presaging: ParameterSelective4 = ParameterSelective4 { _, _, _, _ -> true } + ): ConiumEventContext> { + val context = ConiumEventContext( + DynamicArgsBuilder.requires( + arg1, + arg2, + arg3, + true + ).lifecycle(DynamicArgsLifecycle.FOREVER) + ) + + ConiumEvent.forever(eventType, context) + + context.arise { i, p1, p2, p3 -> + (i as? I)?.let { arising(it, p1, p2, p3) } ?: true + } + + context.presage { i, p1, p2, p3 -> + (i as? I)?.let { presaging(it, p1, p2, p3) } ?: true + } + + return context + } + + @JvmStatic + @SuppressWarnings("UNCHECKED_CAST") + fun preRequest( + eventType: ConiumEventType, + arg1: DynamicArgType, + arg2: DynamicArgType, + arg3: DynamicArgType, + arg4: DynamicArgType, + presaging: ParameterSelective5 = ParameterSelective5 { _, _, _, _, _ -> true } + ): ConiumEventContext> { + val context = ConiumEventContext( + DynamicArgsBuilder.requires( + arg1, + arg2, + arg3, + arg4, + true + ).lifecycle(DynamicArgsLifecycle.FOREVER) + ) + + ConiumEvent.forever(eventType, context) + + context.presage { i, p1, p2, p3, p4 -> + (i as? I)?.let { presaging(it, p1, p2, p3, p4) } ?: true + } + + return context + } + + @JvmStatic @SuppressWarnings("UNCHECKED_CAST") fun request( @@ -204,7 +442,72 @@ object ConiumEventContextBuilder { ConiumEvent.forever(eventType, context) context.arise { i, p1, p2, p3, p4 -> - (i as? I)?.let { arising.arise(it, p1, p2, p3, p4) } ?: true + (i as? I)?.let { arising(it, p1, p2, p3, p4) } ?: true + } + + return context + } + + @JvmStatic + @SuppressWarnings("UNCHECKED_CAST") + fun request( + eventType: ConiumEventType, + arg1: DynamicArgType, + arg2: DynamicArgType, + arg3: DynamicArgType, + arg4: DynamicArgType, + arising: ParameterSelective5 = ParameterSelective5 { _, _, _, _, _ -> true }, + presaging: ParameterSelective5 = ParameterSelective5 { _, _, _, _, _ -> true } + ): ConiumEventContext> { + val context = ConiumEventContext( + DynamicArgsBuilder.requires( + arg1, + arg2, + arg3, + arg4, + true + ).lifecycle(DynamicArgsLifecycle.FOREVER) + ) + + ConiumEvent.forever(eventType, context) + + context.arise { i, p1, p2, p3, p4 -> + (i as? I)?.let { arising(it, p1, p2, p3, p4) } ?: true + } + + context.presage { i, p1, p2, p3, p4 -> + (i as? I)?.let { presaging(it, p1, p2, p3, p4) } ?: true + } + + return context + } + + @JvmStatic + @SuppressWarnings("UNCHECKED_CAST") + fun preRequest( + eventType: ConiumEventType, + arg1: DynamicArgType, + arg2: DynamicArgType, + arg3: DynamicArgType, + arg4: DynamicArgType, + arg5: DynamicArgType, + presaging: ParameterSelective6 = ParameterSelective6 { _, _, _, _, _, _ -> true } + ): ConiumEventContext> { + val context = ConiumEventContext( + DynamicArgsBuilder.requires( + arg1, + arg2, + arg3, + arg4, + arg5, + true + ).lifecycle(DynamicArgsLifecycle.FOREVER) + ) + + ConiumEvent.forever(eventType, context) + + context.presage { i, p1, p2, p3, p4, p5 -> + (i as? I)?.let { presaging(it, p1, p2, p3, p4, p5) } ?: true } return context @@ -241,6 +544,75 @@ object ConiumEventContextBuilder { return context } + @JvmStatic + @SuppressWarnings("UNCHECKED_CAST") + fun request( + eventType: ConiumEventType, + arg1: DynamicArgType, + arg2: DynamicArgType, + arg3: DynamicArgType, + arg4: DynamicArgType, + arg5: DynamicArgType, + arising: ParameterSelective6 = ParameterSelective6 { _, _, _, _, _, _ -> true }, + presaging: ParameterSelective6 = ParameterSelective6 { _, _, _, _, _, _ -> true } + ): ConiumEventContext> { + val context = ConiumEventContext( + DynamicArgsBuilder.requires( + arg1, + arg2, + arg3, + arg4, + arg5, + true + ).lifecycle(DynamicArgsLifecycle.FOREVER) + ) + + ConiumEvent.forever(eventType, context) + + context.arise { i, p1, p2, p3, p4, p5 -> + (i as? I)?.let { arising(it, p1, p2, p3, p4, p5) } ?: true + } + + context.presage { i, p1, p2, p3, p4, p5 -> + (i as? I)?.let { presaging(it, p1, p2, p3, p4, p5) } ?: true + } + + return context + } + + @JvmStatic + @SuppressWarnings("UNCHECKED_CAST") + fun preRequest( + eventType: ConiumEventType, + arg1: DynamicArgType, + arg2: DynamicArgType, + arg3: DynamicArgType, + arg4: DynamicArgType, + arg5: DynamicArgType, + arg6: DynamicArgType, + presaging: ParameterSelective7 = ParameterSelective7 { _, _, _, _, _, _, _ -> true } + ): ConiumEventContext> { + val context = ConiumEventContext( + DynamicArgsBuilder.requires( + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + true + ).lifecycle(DynamicArgsLifecycle.FOREVER) + ) + + ConiumEvent.forever(eventType, context) + + context.presage { i, p1, p2, p3, p4, p5, p6 -> + (i as? I)?.let { presaging(it, p1, p2, p3, p4, p5, p6) } ?: true + } + + return context + } + @JvmStatic @SuppressWarnings("UNCHECKED_CAST") fun request( @@ -274,6 +646,79 @@ object ConiumEventContextBuilder { return context } + @JvmStatic + @SuppressWarnings("UNCHECKED_CAST") + fun request( + eventType: ConiumEventType, + arg1: DynamicArgType, + arg2: DynamicArgType, + arg3: DynamicArgType, + arg4: DynamicArgType, + arg5: DynamicArgType, + arg6: DynamicArgType, + arising: ParameterSelective7 = ParameterSelective7 { _, _, _, _, _, _, _ -> true }, + presaging: ParameterSelective7 = ParameterSelective7 { _, _, _, _, _, _, _ -> true } + ): ConiumEventContext> { + val context = ConiumEventContext( + DynamicArgsBuilder.requires( + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + true + ).lifecycle(DynamicArgsLifecycle.FOREVER) + ) + + ConiumEvent.forever(eventType, context) + + context.arise { i, p1, p2, p3, p4, p5, p6 -> + (i as? I)?.let { arising(it, p1, p2, p3, p4, p5, p6) } ?: true + } + + context.presage { i, p1, p2, p3, p4, p5, p6 -> + (i as? I)?.let { presaging(it, p1, p2, p3, p4, p5, p6) } ?: true + } + + return context + } + + @JvmStatic + @SuppressWarnings("UNCHECKED_CAST") + fun preRequest( + eventType: ConiumEventType, + arg1: DynamicArgType, + arg2: DynamicArgType, + arg3: DynamicArgType, + arg4: DynamicArgType, + arg5: DynamicArgType, + arg6: DynamicArgType, + arg7: DynamicArgType, + presaging: ParameterSelective8 = ParameterSelective8 { _, _, _, _, _, _, _, _ -> true } + ): ConiumEventContext> { + val context = ConiumEventContext( + DynamicArgsBuilder.requires( + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + true + ).lifecycle(DynamicArgsLifecycle.FOREVER) + ) + + ConiumEvent.forever(eventType, context) + + context.presage { i, p1, p2, p3, p4, p5, p6, p7 -> + (i as? I)?.let { presaging(it, p1, p2, p3, p4, p5, p6, p7) } ?: true + } + + return context + } + @JvmStatic @SuppressWarnings("UNCHECKED_CAST") fun request( @@ -308,4 +753,44 @@ object ConiumEventContextBuilder { return context } + + @JvmStatic + @SuppressWarnings("UNCHECKED_CAST") + fun request( + eventType: ConiumEventType, + arg1: DynamicArgType, + arg2: DynamicArgType, + arg3: DynamicArgType, + arg4: DynamicArgType, + arg5: DynamicArgType, + arg6: DynamicArgType, + arg7: DynamicArgType, + arising: ParameterSelective8 = ParameterSelective8 { _, _, _, _, _, _, _, _ -> true }, + presaging: ParameterSelective8 = ParameterSelective8 { _, _, _, _, _, _, _, _ -> true } + ): ConiumEventContext> { + val context = ConiumEventContext( + DynamicArgsBuilder.requires( + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + true + ).lifecycle(DynamicArgsLifecycle.FOREVER) + ) + + ConiumEvent.forever(eventType, context) + + context.arise { i, p1, p2, p3, p4, p5, p6, p7 -> + (i as? I)?.let { arising(it, p1, p2, p3, p4, p5, p6, p7) } ?: true + } + + context.presage { i, p1, p2, p3, p4, p5, p6, p7 -> + (i as? I)?.let { presaging(it, p1, p2, p3, p4, p5, p6, p7) } ?: true + } + + return context + } } diff --git a/src/main/java/com/github/cao/awa/conium/event/type/ConiumEventArgTypes.kt b/src/main/java/com/github/cao/awa/conium/event/type/ConiumEventArgTypes.kt index 1d8a325..50d6498 100644 --- a/src/main/java/com/github/cao/awa/conium/event/type/ConiumEventArgTypes.kt +++ b/src/main/java/com/github/cao/awa/conium/event/type/ConiumEventArgTypes.kt @@ -1,5 +1,6 @@ package com.github.cao.awa.conium.event.type +import com.github.cao.awa.conium.kotlin.extent.innate.asIt import com.github.cao.awa.conium.parameter.DynamicArgType import com.github.cao.awa.conium.parameter.DynamicArgsBuilder.Companion.transform import com.github.cao.awa.conium.parameter.type.DynamicArgTypeBuilder.arg @@ -12,6 +13,7 @@ import net.minecraft.entity.EntityType import net.minecraft.entity.LivingEntity import net.minecraft.entity.damage.DamageSource import net.minecraft.entity.player.PlayerEntity +import net.minecraft.fluid.FluidState import net.minecraft.item.Item import net.minecraft.item.ItemPlacementContext import net.minecraft.item.ItemStack @@ -22,7 +24,9 @@ import net.minecraft.server.world.ServerWorld import net.minecraft.util.ActionResult import net.minecraft.util.hit.BlockHitResult import net.minecraft.util.math.BlockPos +import net.minecraft.util.math.random.Random import net.minecraft.world.World +import net.minecraft.world.tick.ScheduledTickView object ConiumEventArgTypes { @JvmField @@ -40,9 +44,15 @@ object ConiumEventArgTypes { @JvmField val ACTION_RESULT: DynamicArgType + @JvmField + val RANDOM: DynamicArgType + @JvmField val SERVER: DynamicArgType + @JvmField + val SCHEDULE_TICK_VIEW: DynamicArgType + @JvmField val WORLD: DynamicArgType @@ -61,6 +71,9 @@ object ConiumEventArgTypes { @JvmField val BLOCK_STATE: DynamicArgType + @JvmField + val FLUID_STATE: DynamicArgType + @JvmField val BLOCK_HIT_RESULT: DynamicArgType @@ -115,12 +128,22 @@ object ConiumEventArgTypes { ACTION_RESULT = arg("action_result") + RANDOM = arg( + "random", + transform(::WORLD, World::getRandom) + ) + SERVER = arg( "server", transform(::SERVER_PLAYER, ServerPlayerEntity::server), transform(::SERVER_WORLD, ServerWorld::getServer) ) + SCHEDULE_TICK_VIEW = arg( + "schedule_tick_view", + transform(::WORLD, World::asIt) + ) + WORLD = arg( "world", transform(::PLAYER, PlayerEntity::getWorld) @@ -148,7 +171,12 @@ object ConiumEventArgTypes { transform(::ITEM_PLACEMENT_CONTEXT, ItemPlacementContext::getBlockPos) ) - BLOCK_STATE = arg("block_state") + BLOCK_STATE = arg( + "block_state", + transform(::FLUID_STATE, FluidState::getBlockState) + ) + + FLUID_STATE = arg("fluid_state") BLOCK_HIT_RESULT = arg("block_hit_result") @@ -159,21 +187,21 @@ object ConiumEventArgTypes { ENTITY = arg( "entity", - transform(::LIVING_ENTITY) { entity -> entity } + transform(::LIVING_ENTITY, LivingEntity::asIt) ) LIVING_ENTITY = arg( "living_entity", transform(::ENTITY) { entity -> entity as? LivingEntity }, - transform(::PLAYER) { player -> player } + transform(::PLAYER, PlayerEntity::asIt) ) PLAYER = arg( "player", transform(::ITEM_PLACEMENT_CONTEXT, ItemPlacementContext::getPlayer), transform(::LIVING_ENTITY) { entity -> entity as? PlayerEntity }, - transform(::SERVER_PLAYER) { player -> player }, - transform(::CLIENT_PLAYER) { player -> player } + transform(::SERVER_PLAYER, ServerPlayerEntity::asIt), + transform(::CLIENT_PLAYER, ClientPlayerEntity::asIt) ) SERVER_PLAYER = arg( diff --git a/src/main/java/com/github/cao/awa/conium/event/type/ConiumEventType.kt b/src/main/java/com/github/cao/awa/conium/event/type/ConiumEventType.kt index 2c3266d..6cefba0 100644 --- a/src/main/java/com/github/cao/awa/conium/event/type/ConiumEventType.kt +++ b/src/main/java/com/github/cao/awa/conium/event/type/ConiumEventType.kt @@ -5,6 +5,7 @@ import com.github.cao.awa.conium.mixin.client.interaction.ClientPlayerInteractio import com.github.cao.awa.conium.mixin.server.interaction.ServerPlayerInteractionManagerMixin import net.minecraft.block.Block import net.minecraft.entity.EntityType +import net.minecraft.fluid.Fluid import net.minecraft.item.Item import net.minecraft.server.MinecraftServer @@ -108,5 +109,17 @@ class ConiumEventType { */ @JvmField val ENTITY_DEAD: ConiumEventType> = ConiumEventType() + + @JvmField + val BLOCK_SCHEDULE_TICK: ConiumEventType = ConiumEventType() + + @JvmField + val BLOCK_SCHEDULE_TICKED: ConiumEventType = ConiumEventType() + + @JvmField + val FLUID_SCHEDULE_TICK: ConiumEventType = ConiumEventType() + + @JvmField + val FLUID_SCHEDULE_TICKED: ConiumEventType = ConiumEventType() } } diff --git a/src/main/java/com/github/cao/awa/conium/kotlin/extent/innate/ConiumInnate.kt b/src/main/java/com/github/cao/awa/conium/kotlin/extent/innate/ConiumInnate.kt new file mode 100644 index 0000000..49493e7 --- /dev/null +++ b/src/main/java/com/github/cao/awa/conium/kotlin/extent/innate/ConiumInnate.kt @@ -0,0 +1,5 @@ +@file:Suppress("unchecked_cast") + +package com.github.cao.awa.conium.kotlin.extent.innate + +fun T.asIt(): T = this diff --git a/src/main/java/com/github/cao/awa/conium/mixin/server/world/ServerWorldMixin.java b/src/main/java/com/github/cao/awa/conium/mixin/server/world/ServerWorldMixin.java index ca6a5e5..50e9a20 100644 --- a/src/main/java/com/github/cao/awa/conium/mixin/server/world/ServerWorldMixin.java +++ b/src/main/java/com/github/cao/awa/conium/mixin/server/world/ServerWorldMixin.java @@ -4,13 +4,20 @@ import com.github.cao.awa.conium.event.context.ConiumEventContext; import com.github.cao.awa.conium.event.type.ConiumEventArgTypes; import com.github.cao.awa.conium.event.type.ConiumEventType; +import net.minecraft.block.Block; +import net.minecraft.block.BlockState; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityType; +import net.minecraft.fluid.Fluid; +import net.minecraft.fluid.FluidState; import net.minecraft.server.world.ServerWorld; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.random.Random; import net.minecraft.world.World; 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.Redirect; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; @Mixin(ServerWorld.class) @@ -64,4 +71,80 @@ public void tickedEntity(Entity entity, CallbackInfo ci) { tickedContext.arising(type); } } + + @Redirect( + method = "tickFluid", + at = @At( + value = "INVOKE", + target = "Lnet/minecraft/fluid/FluidState;onScheduledTick(Lnet/minecraft/server/world/ServerWorld;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;)V" + ) + ) + private void scheduledFluidTick(FluidState instance, ServerWorld world, BlockPos pos, BlockState blockState) { + // Request the fluid ticking context. + ConiumEventContext tickingContext = ConiumEvent.request(ConiumEventType.FLUID_SCHEDULE_TICK); + + Fluid fluid = instance.getFluid(); + + // Fill the context args. + tickingContext.put(ConiumEventArgTypes.WORLD, world) + .put(ConiumEventArgTypes.SCHEDULE_TICK_VIEW, world) + .put(ConiumEventArgTypes.BLOCK_POS, pos) + .put(ConiumEventArgTypes.BLOCK_STATE, blockState) + .put(ConiumEventArgTypes.FLUID_STATE, instance); + + if (tickingContext.presaging(fluid)) { + // Only presaging state is true can be continued. + tickingContext.arising(fluid); + + instance.onScheduledTick(world, pos, blockState); + + // Request the fluid ticked context. + ConiumEventContext tickedContext = ConiumEvent.request(ConiumEventType.FLUID_SCHEDULE_TICKED); + + tickedContext.inherit(tickingContext); + + // The ticked context cannot to cancels. + if (tickedContext.presaging(fluid)) { + tickedContext.arising(fluid); + } + } + } + + @Redirect( + method = "tickBlock", + at = @At( + value = "INVOKE", + target = "Lnet/minecraft/block/BlockState;scheduledTick(Lnet/minecraft/server/world/ServerWorld;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/util/math/random/Random;)V" + ) + ) + private void tickBlock(BlockState instance, ServerWorld world, BlockPos pos, Random random) { + // Request the block ticking context. + ConiumEventContext tickingContext = ConiumEvent.request(ConiumEventType.BLOCK_SCHEDULE_TICK); + + Block block = instance.getBlock(); + + // Fill the context args. + tickingContext.put(ConiumEventArgTypes.WORLD, world) + .put(ConiumEventArgTypes.SCHEDULE_TICK_VIEW, world) + .put(ConiumEventArgTypes.BLOCK_POS, pos) + .put(ConiumEventArgTypes.BLOCK_STATE, instance) + .put(ConiumEventArgTypes.RANDOM, random); + + if (tickingContext.presaging(block)) { + // Only presaging state is true can be continued. + tickingContext.arising(block); + + instance.scheduledTick(world, pos, random); + + // Request the block ticked context. + ConiumEventContext tickedContext = ConiumEvent.request(ConiumEventType.BLOCK_SCHEDULE_TICKED); + + tickedContext.inherit(tickingContext); + + // The ticked context cannot to cancels. + if (tickedContext.presaging(block)) { + tickedContext.arising(block); + } + } + } } diff --git a/src/main/resources/assets/conium/scripts/conium.commons.kts b/src/main/resources/assets/conium/scripts/conium.commons.kts index 202883a..42729b2 100644 --- a/src/main/resources/assets/conium/scripts/conium.commons.kts +++ b/src/main/resources/assets/conium/scripts/conium.commons.kts @@ -1,11 +1,14 @@ import com.github.cao.awa.conium.bedrock.event.context.BedrockEventContext import com.github.cao.awa.conium.event.context.ConiumEventContextBuilder.request +import com.github.cao.awa.conium.event.context.ConiumEventContextBuilder.preRequest import com.github.cao.awa.conium.event.context.ConiumEventContext import com.github.cao.awa.conium.event.context.ConiumEventContextBuilder import com.github.cao.awa.conium.event.type.ConiumEventArgTypes +import com.github.cao.awa.conium.event.type.ConiumEventArgTypes.RANDOM import com.github.cao.awa.conium.event.type.ConiumEventArgTypes.SERVER +import com.github.cao.awa.conium.event.type.ConiumEventArgTypes.SCHEDULE_TICK_VIEW import com.github.cao.awa.conium.event.type.ConiumEventArgTypes.WORLD import com.github.cao.awa.conium.event.type.ConiumEventArgTypes.CLIENT_WORLD import com.github.cao.awa.conium.event.type.ConiumEventArgTypes.SERVER_WORLD @@ -14,16 +17,20 @@ import com.github.cao.awa.conium.event.type.ConiumEventArgTypes.PLAYER import com.github.cao.awa.conium.event.type.ConiumEventArgTypes.CLIENT_PLAYER import com.github.cao.awa.conium.event.type.ConiumEventArgTypes.SERVER_PLAYER import com.github.cao.awa.conium.event.type.ConiumEventArgTypes.BLOCK_POS +import com.github.cao.awa.conium.event.type.ConiumEventArgTypes.FLUID_STATE import com.github.cao.awa.conium.event.type.ConiumEventArgTypes.BLOCK_STATE import com.github.cao.awa.conium.event.type.ConiumEventArgTypes.ITEM_USAGE_CONTEXT import com.github.cao.awa.conium.event.type.ConiumEventArgTypes.ITEM_PLACEMENT_CONTEXT import com.github.cao.awa.conium.event.type.ConiumEventArgTypes.BLOCK_HIT_RESULT import com.github.cao.awa.conium.event.type.ConiumEventArgTypes.ACTION_RESULT +// Events import com.github.cao.awa.conium.event.type.ConiumEventType.Companion.SERVER_TICK import com.github.cao.awa.conium.event.type.ConiumEventType.Companion.SERVER_TICK_TAIL + import com.github.cao.awa.conium.event.type.ConiumEventType.Companion.ITEM_USE_ON_BLOCK import com.github.cao.awa.conium.event.type.ConiumEventType.Companion.ITEM_USED_ON_BLOCK + import com.github.cao.awa.conium.event.type.ConiumEventType.Companion.BREAKING_BLOCK import com.github.cao.awa.conium.event.type.ConiumEventType.Companion.BREAK_BLOCK import com.github.cao.awa.conium.event.type.ConiumEventType.Companion.BROKEN_BLOCK @@ -31,11 +38,21 @@ import com.github.cao.awa.conium.event.type.ConiumEventType.Companion.PLACE_BLOC import com.github.cao.awa.conium.event.type.ConiumEventType.Companion.PLACED_BLOCK import com.github.cao.awa.conium.event.type.ConiumEventType.Companion.USE_BLOCK import com.github.cao.awa.conium.event.type.ConiumEventType.Companion.USED_BLOCK + +import com.github.cao.awa.conium.event.type.ConiumEventType.Companion.ENTITY_TICK +import com.github.cao.awa.conium.event.type.ConiumEventType.Companion.ENTITY_TICKED import com.github.cao.awa.conium.event.type.ConiumEventType.Companion.ENTITY_DAMAGE import com.github.cao.awa.conium.event.type.ConiumEventType.Companion.ENTITY_DAMAGED import com.github.cao.awa.conium.event.type.ConiumEventType.Companion.ENTITY_DIE import com.github.cao.awa.conium.event.type.ConiumEventType.Companion.ENTITY_DEAD +import com.github.cao.awa.conium.event.type.ConiumEventType.Companion.FLUID_SCHEDULE_TICK +import com.github.cao.awa.conium.event.type.ConiumEventType.Companion.FLUID_SCHEDULE_TICKED +import com.github.cao.awa.conium.event.type.ConiumEventType.Companion.BLOCK_SCHEDULE_TICK +import com.github.cao.awa.conium.event.type.ConiumEventType.Companion.BLOCK_SCHEDULE_TICKED + +import net.minecraft.world.tick.ScheduledTickView + import com.github.cao.awa.conium.script.ScriptExport import com.github.cao.awa.conium.script.ScriptExport.Companion.accessExportedField