aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/com/thatgravyboat/skyblockhud/mixins/MixinEntityArrow.java
blob: dbde075ee7b49ce80366740f9984b4002bb9fd13 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
package com.thatgravyboat.skyblockhud.mixins;

import com.thatgravyboat.skyblockhud.api.KillTracking;
import net.minecraft.client.Minecraft;
import net.minecraft.entity.Entity;
import net.minecraft.entity.projectile.EntityArrow;
import net.minecraft.util.MovingObjectPosition;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.ModifyVariable;

@Mixin(EntityArrow.class)
public class MixinEntityArrow {

    @Shadow
    public Entity shootingEntity;

    @ModifyVariable(method = "onUpdate", at = @At(value = "STORE", ordinal = 1))
    public MovingObjectPosition onUpdate(MovingObjectPosition position) {
        if (position != null && position.entityHit != null && this.shootingEntity != null && this.shootingEntity.getUniqueID().equals(Minecraft.getMinecraft().thePlayer.getUniqueID())) {
            KillTracking.attackedEntities.add(position.entityHit.getUniqueID());
        }
        return position;
    }
}