Properly log fabric deaths where killer is null (#2184)

Affects issues:
- Fixed #2182
This commit is contained in:
Antti Koponen 2021-12-03 15:47:34 +02:00 committed by GitHub
parent 2dadf249f0
commit f096d456c6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -16,12 +16,14 @@
*/ */
package net.playeranalytics.plan.gathering.listeners.events.mixin; package net.playeranalytics.plan.gathering.listeners.events.mixin;
import net.minecraft.entity.damage.DamageSource;
import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.world.GameMode; import net.minecraft.world.GameMode;
import net.playeranalytics.plan.gathering.listeners.events.PlanFabricEvents; import net.playeranalytics.plan.gathering.listeners.events.PlanFabricEvents;
import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
@Mixin(ServerPlayerEntity.class) @Mixin(ServerPlayerEntity.class)
@ -32,4 +34,11 @@ public class ServerPlayerEntityMixin {
PlanFabricEvents.ON_GAMEMODE_CHANGE.invoker().onGameModeChange((ServerPlayerEntity) (Object) this, gameMode); 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);
}
}
} }