aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/me/Danker/features/HighlightSkeletonMasters.java
blob: 72259dbff8f9794ae8630a5d4500cc00b5dbacbb (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
36
37
38
39
40
41
42
43
package me.Danker.features;

import me.Danker.commands.ToggleCommand;
import me.Danker.utils.RenderUtils;
import me.Danker.utils.Utils;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.monster.EntitySkeleton;
import net.minecraft.item.ItemStack;
import net.minecraftforge.client.event.RenderLivingEvent;
import net.minecraftforge.client.event.RenderWorldLastEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;

import java.util.ArrayList;
import java.util.List;

public class HighlightSkeletonMasters {

    static List<Entity> skeletonMasters = new ArrayList<>();
    public static int SKELETON_MASTER_COLOUR;

    @SubscribeEvent
    public void onRenderEntity(RenderLivingEvent.Pre<EntityLivingBase> event) {
        if (ToggleCommand.highlightSkeletonMasters && event.entity instanceof EntitySkeleton && Utils.inDungeons) {
            ItemStack helmet = event.entity.getCurrentArmor(3);
            if (helmet != null && helmet.getDisplayName().endsWith("Skeleton Master Helmet")) {
                skeletonMasters.add(event.entity);
            }
        }
    }

    @SubscribeEvent
    public void onWorldRender(RenderWorldLastEvent event) {
        if (ToggleCommand.highlightSkeletonMasters) {
            for (Entity skeletonMaster : skeletonMasters) {
                if (!skeletonMaster.isDead)
                    RenderUtils.draw3DBox(skeletonMaster.getEntityBoundingBox(), SKELETON_MASTER_COLOUR, event.partialTicks);
            }
            skeletonMasters.clear();
        }
    }

}