-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b42a052
commit df0b2ce
Showing
8 changed files
with
70 additions
and
3 deletions.
There are no files selected for viewing
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
43 changes: 43 additions & 0 deletions
43
arcade-events-server/src/main/java/net/casual/arcade/events/server/mixins/EntityMixin.java
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,43 @@ | ||
/* | ||
* Copyright (c) 2025 senseiwells | ||
* Licensed under the MIT License. See LICENSE file in the project root for details. | ||
*/ | ||
package net.casual.arcade.events.server.mixins; | ||
|
||
import net.casual.arcade.events.BuiltInEventPhases; | ||
import net.casual.arcade.events.GlobalEventHandler; | ||
import net.casual.arcade.events.server.entity.EntityTickEvent; | ||
import net.minecraft.world.entity.Entity; | ||
import net.minecraft.world.level.Level; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Shadow; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; | ||
|
||
@Mixin(Entity.class) | ||
public class EntityMixin { | ||
@Shadow private Level level; | ||
|
||
@Inject( | ||
method = "tick", | ||
at = @At("HEAD") | ||
) | ||
private void onTickPre(CallbackInfo ci) { | ||
if (!this.level.isClientSide) { | ||
EntityTickEvent event = new EntityTickEvent((Entity) (Object) this); | ||
GlobalEventHandler.Server.broadcast(event, BuiltInEventPhases.PRE_PHASES); | ||
} | ||
} | ||
|
||
@Inject( | ||
method = "tick", | ||
at = @At("HEAD") | ||
) | ||
private void onTickPost(CallbackInfo ci) { | ||
if (!this.level.isClientSide) { | ||
EntityTickEvent event = new EntityTickEvent((Entity) (Object) this); | ||
GlobalEventHandler.Server.broadcast(event, BuiltInEventPhases.POST_PHASES); | ||
} | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
...e-events-server/src/main/kotlin/net/casual/arcade/events/server/entity/EntityTickEvent.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,11 @@ | ||
/* | ||
* Copyright (c) 2025 senseiwells | ||
* Licensed under the MIT License. See LICENSE file in the project root for details. | ||
*/ | ||
package net.casual.arcade.events.server.entity | ||
|
||
import net.minecraft.world.entity.Entity | ||
|
||
public data class EntityTickEvent( | ||
override val entity: Entity | ||
): EntityEvent |
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
4 changes: 4 additions & 0 deletions
4
arcade-extensions/src/main/kotlin/net/casual/arcade/extensions/EntityExtension.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
4 changes: 4 additions & 0 deletions
4
arcade-extensions/src/main/kotlin/net/casual/arcade/extensions/event/EntityExtensionEvent.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
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