diff --git a/Plan/fabric/src/main/java/net/playeranalytics/plan/gathering/listeners/events/mixin/ServerPlayerEntityMixin.java b/Plan/fabric/src/main/java/net/playeranalytics/plan/gathering/listeners/events/mixin/ServerPlayerEntityMixin.java index c57ced148..506f27a9e 100644 --- a/Plan/fabric/src/main/java/net/playeranalytics/plan/gathering/listeners/events/mixin/ServerPlayerEntityMixin.java +++ b/Plan/fabric/src/main/java/net/playeranalytics/plan/gathering/listeners/events/mixin/ServerPlayerEntityMixin.java @@ -16,12 +16,14 @@ */ package net.playeranalytics.plan.gathering.listeners.events.mixin; +import net.minecraft.entity.damage.DamageSource; import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.world.GameMode; import net.playeranalytics.plan.gathering.listeners.events.PlanFabricEvents; 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 org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; @Mixin(ServerPlayerEntity.class) @@ -32,4 +34,11 @@ public class ServerPlayerEntityMixin { PlanFabricEvents.ON_GAMEMODE_CHANGE.invoker().onGameModeChange((ServerPlayerEntity) (Object) this, gameMode); } + @Inject(method = "onDeath", at = @At(value = "TAIL")) + public void onKillSelf(DamageSource source, CallbackInfo ci) { + if (source.getAttacker() == null) { + PlanFabricEvents.ON_KILLED.invoker().onKilled((ServerPlayerEntity) (Object) this, null); + } + } + }