2020-04-15 14:22:03 +02:00
|
|
|
package com.minelittlepony.unicopia.mixin;
|
2020-01-16 12:35:46 +01:00
|
|
|
|
|
|
|
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;
|
|
|
|
|
2021-03-06 22:11:17 +01:00
|
|
|
import com.minelittlepony.unicopia.entity.Equine;
|
2020-01-16 12:35:46 +01:00
|
|
|
|
|
|
|
import net.minecraft.entity.Entity;
|
|
|
|
import net.minecraft.entity.projectile.ProjectileEntity;
|
|
|
|
import net.minecraft.util.hit.EntityHitResult;
|
|
|
|
|
|
|
|
@Mixin(ProjectileEntity.class)
|
2020-06-26 11:44:47 +02:00
|
|
|
abstract class MixinProjectileEntity extends Entity {
|
2020-04-24 17:10:45 +02:00
|
|
|
private MixinProjectileEntity() { super(null, null); }
|
2020-01-16 12:35:46 +01:00
|
|
|
|
|
|
|
@Inject(method = "onEntityHit(Lnet/minecraft/util/hit/EntityHitResult;)V",
|
|
|
|
at = @At("HEAD"),
|
|
|
|
cancellable = true)
|
|
|
|
private void onOnEntityHit(EntityHitResult hit, CallbackInfo info) {
|
2021-03-06 22:11:17 +01:00
|
|
|
Equine.of(hit.getEntity()).ifPresent(eq -> {
|
|
|
|
if (eq.onProjectileImpact((ProjectileEntity)(Object)this)) {
|
2020-01-16 12:35:46 +01:00
|
|
|
info.cancel();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|