aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/com/thatgravyboat/skyblockhud/mixins/MixinEntityArrow.java
blob: 3641876536063dec94bd7c953551ef0e5c5b0640 (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
27
28
29
30
31
32
33
34
35
package com.thatgravyboat.skyblockhud.mixins;

import com.thatgravyboat.skyblockhud.tracker.KillTrackerHandler;
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 {

    //Disabled as kill tracker stuff not fully added yet.
    @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())
        ) {
            KillTrackerHandler.attackedEntities.add(
                position.entityHit.getUniqueID()
            );
        }
        return position;
    }
}