-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add event supports: 'SERVER_TICK_TAIL', 'ENTITY_TICK', 'ENTITY_TICKED…
…', 'ITEM_USED_ON_BLOCK'. Make event arise before the source action.
- Loading branch information
Showing
16 changed files
with
329 additions
and
73 deletions.
There are no files selected for viewing
28 changes: 28 additions & 0 deletions
28
src/main/java/com/github/cao/awa/conium/entity/event/tick/ConiumEntityTickEvent.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package com.github.cao.awa.conium.entity.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.ParameterSelective1 | ||
import com.github.cao.awa.conium.parameter.ParameterSelective4 | ||
import net.minecraft.entity.Entity | ||
import net.minecraft.entity.LivingEntity | ||
import net.minecraft.entity.damage.DamageSource | ||
import net.minecraft.world.World | ||
|
||
class ConiumEntityTickEvent : ConiumEvent<ParameterSelective1<Boolean, Entity>>() { | ||
override fun requirement(): ConiumEventContext<out ParameterSelective> { | ||
return requires( | ||
ConiumEventArgTypes.ENTITY | ||
).attach( | ||
forever(ConiumEventType.ENTITY_TICK) | ||
).arise { identity, entity -> | ||
noFailure(identity) { | ||
it.arise(entity) | ||
} | ||
} | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
src/main/java/com/github/cao/awa/conium/entity/event/tick/ConiumEntityTickedEvent.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package com.github.cao.awa.conium.entity.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.ParameterSelective1 | ||
import net.minecraft.entity.Entity | ||
|
||
class ConiumEntityTickedEvent : ConiumEvent<ParameterSelective1<Boolean, Entity>>() { | ||
override fun requirement(): ConiumEventContext<out ParameterSelective> { | ||
return requires( | ||
ConiumEventArgTypes.ENTITY | ||
).attach( | ||
forever(ConiumEventType.ENTITY_TICKED) | ||
).arise { identity, entity -> | ||
noFailure(identity) { | ||
it.arise(entity) | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
src/main/java/com/github/cao/awa/conium/event/server/tick/ConiumServerTickTailEvent.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package com.github.cao.awa.conium.event.server.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.ParameterSelective1 | ||
import net.minecraft.server.MinecraftServer | ||
|
||
class ConiumServerTickTailEvent : ConiumEvent<ParameterSelective1<Boolean, MinecraftServer>>() { | ||
override fun requirement(): ConiumEventContext<out ParameterSelective> { | ||
return requires( | ||
ConiumEventArgTypes.SERVER, | ||
).attach( | ||
forever(ConiumEventType.SERVER_TICK_TAIL) | ||
).arise { identity, server -> | ||
noFailure(identity) { | ||
it.arise(server) | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
src/main/java/com/github/cao/awa/conium/item/event/use/ConiumItemUsedOnBlockEvent.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package com.github.cao.awa.conium.item.event.use | ||
|
||
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.item.event.ConiumItemEvent | ||
import com.github.cao.awa.conium.parameter.ParameterSelective | ||
import com.github.cao.awa.conium.parameter.ParameterSelective3 | ||
import net.minecraft.item.ItemUsageContext | ||
import net.minecraft.server.world.ServerWorld | ||
import net.minecraft.util.ActionResult | ||
|
||
class ConiumItemUsedOnBlockEvent : ConiumItemEvent<ParameterSelective3<Boolean, ServerWorld, ItemUsageContext, ActionResult>>() { | ||
override fun requirement(): ConiumEventContext<out ParameterSelective> { | ||
return requires( | ||
ConiumEventArgTypes.SERVER_WORLD, | ||
ConiumEventArgTypes.ITEM_USAGE_CONTEXT, | ||
ConiumEventArgTypes.ACTION_RESULT | ||
).attach( | ||
forever(ConiumEventType.ITEM_USED_ON_BLOCK) | ||
).arise { identity, world, context, result -> | ||
noFailure(identity) { | ||
it.arise( | ||
world, | ||
context, | ||
result | ||
) | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.