aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/moe/ymc/acron/mixin/ServerPlayerEntityMixin.java
diff options
context:
space:
mode:
authorYuuta Liang <yuuta@yuuta.moe>2022-07-13 11:16:27 -0700
committerTrumeet <yuuta@yuuta.moe>2022-07-13 11:16:27 -0700
commit85045e1e4a15e0a5657d189e83dd202a2c37f2b0 (patch)
tree944bc9ee7a86bd413dfc940e210f21d2434ec7d3 /src/main/java/moe/ymc/acron/mixin/ServerPlayerEntityMixin.java
downloadacron-85045e1e4a15e0a5657d189e83dd202a2c37f2b0.tar
acron-85045e1e4a15e0a5657d189e83dd202a2c37f2b0.tar.gz
acron-85045e1e4a15e0a5657d189e83dd202a2c37f2b0.tar.bz2
acron-85045e1e4a15e0a5657d189e83dd202a2c37f2b0.zip
First Commit
Signed-off-by: Trumeet <yuuta@yuuta.moe>
Diffstat (limited to 'src/main/java/moe/ymc/acron/mixin/ServerPlayerEntityMixin.java')
-rw-r--r--src/main/java/moe/ymc/acron/mixin/ServerPlayerEntityMixin.java32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/main/java/moe/ymc/acron/mixin/ServerPlayerEntityMixin.java b/src/main/java/moe/ymc/acron/mixin/ServerPlayerEntityMixin.java
new file mode 100644
index 0000000..17c8517
--- /dev/null
+++ b/src/main/java/moe/ymc/acron/mixin/ServerPlayerEntityMixin.java
@@ -0,0 +1,32 @@
+package moe.ymc.acron.mixin;
+
+import moe.ymc.acron.s2c.EventEntityDeath;
+import moe.ymc.acron.s2c.EventQueue;
+import net.minecraft.entity.EntityType;
+import net.minecraft.entity.LivingEntity;
+import net.minecraft.entity.damage.DamageSource;
+import net.minecraft.server.network.ServerPlayerEntity;
+import net.minecraft.world.World;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+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;
+
+@Mixin(ServerPlayerEntity.class)
+public abstract class ServerPlayerEntityMixin extends LivingEntity {
+ private static final Logger LOGGER = LogManager.getLogger();
+
+ public ServerPlayerEntityMixin(EntityType<? extends LivingEntity> entityType, World world) {
+ super(entityType, world);
+ }
+
+ @Inject(at = @At("HEAD"), method = "onDeath")
+ public void onDeath(DamageSource source, CallbackInfo ci) {
+ LOGGER.debug("onDeath: {}",
+ getUuid());
+ EventQueue.enqueue(new EventEntityDeath(new moe.ymc.acron.s2c.Entity(this),
+ getDamageTracker().getDeathMessage().getString()));
+ }
+} \ No newline at end of file