28 lines
1.2 KiB
Java
28 lines
1.2 KiB
Java
package io.gitlab.jfronny.breakme.breakme.mixin;
|
|
|
|
import io.gitlab.jfronny.breakme.breakme.BreakMe;
|
|
import io.gitlab.jfronny.breakme.breakme.config.CrashCause;
|
|
import net.minecraft.entity.damage.DamageSource;
|
|
import net.minecraft.entity.player.PlayerEntity;
|
|
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(PlayerEntity.class)
|
|
public class MixinPlayerEntity {
|
|
@Inject(at = @At("TAIL"), method = "damage(Lnet/minecraft/entity/damage/DamageSource;F)Z")
|
|
private void onDamage(DamageSource source, float amount, CallbackInfoReturnable<Boolean> info) throws Exception {
|
|
if (info.getReturnValue()) {
|
|
BreakMe.Crash(CrashCause.Damage, (PlayerEntity)(Object)this);
|
|
}
|
|
}
|
|
|
|
//TODO fix this maybe
|
|
@Inject(at = @At("HEAD"), method = "onDeath(Lnet/minecraft/entity/damage/DamageSource;)V")
|
|
public void onDeath(DamageSource source, CallbackInfo info) throws Exception {
|
|
BreakMe.Crash(CrashCause.Death, (PlayerEntity)(Object)this);
|
|
}
|
|
}
|