aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/me/xmrvizzy/skyblocker/skyblock/dungeon/DungeonBlaze.java
blob: 621c5cc419423f617ac482e7f684a6b39445d4fb (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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
package me.xmrvizzy.skyblocker.skyblock.dungeon;

import me.xmrvizzy.skyblocker.utils.color.QuadColor;
import me.xmrvizzy.skyblocker.utils.RenderUtils;
import net.fabricmc.fabric.api.client.rendering.v1.WorldRenderContext;
import net.fabricmc.fabric.api.client.rendering.v1.WorldRenderEvents;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.font.TextRenderer;
import net.minecraft.client.render.debug.DebugRenderer;
import net.minecraft.entity.Entity;
import net.minecraft.text.LiteralText;
import net.minecraft.util.Formatting;
import net.minecraft.util.math.Box;

public class DungeonBlaze {
    static Entity highestBlaze = null;
    static Entity lowestBlaze = null;
    static boolean renderHooked = false;
    private static long lastCalculationTime = 0;
	private static boolean lastCalculationExists = false;
	private static int lastCalculationMinX = 0;
	private static int lastCalculationMinY = 0;
	private static int lastCalculationWidth = 0;
	private static int lastCalculationHeight = 0;
    
    public static void DungeonBlaze() {
        MinecraftClient client = MinecraftClient.getInstance();
        if(!renderHooked){
            
            WorldRenderEvents.END.register(DungeonBlaze::blazeRenderer);
            MinecraftClient.getInstance().player.sendMessage(new LiteralText("--- BlazeSolver ---"), false);
            MinecraftClient.getInstance().player.sendMessage(new LiteralText("Blaze Low: ").append(new LiteralText("Red").formatted(Formatting.RED)), false);
            MinecraftClient.getInstance().player.sendMessage(new LiteralText("Blaze High: ").append(new LiteralText("Green").formatted(Formatting.GREEN)), false);
            renderHooked = true;
        }
        Iterable<Entity> entities = client.world.getEntities();
        int highestHealth = 0;
        int lowestHealth = 99999999;

        for (Entity entity : entities) {
            //System.out.println(entity.getName().getString());
            if (entity.getName().getString().contains("Blaze") && entity.getName().getString().contains("/")) {
        
                String blazeName = entity.getName().getString();
                try {
                    
                    int health = Integer.parseInt(blazeName.substring(blazeName.indexOf("/") + 1, blazeName.length() - 1));
                  
                    if (health > highestHealth) {
                        highestHealth = health;
                        
                        highestBlaze = entity;
                        
                    }
                    if (health < lowestHealth) {
                        lowestHealth = health;
                        lowestBlaze = entity;
                    }
                } catch (NumberFormatException ex) {
                    ex.printStackTrace();
                }
            }
        }
    }
    public static void blazeRenderer(WorldRenderContext wrc) {
        QuadColor outlineColorRed = QuadColor.single( 0.0F, 1.0F, 0.0F, 1f);
        QuadColor outlineColorGreen = QuadColor.single(1.0F, 0.0F, 0.0F, 1f);
        try {
        TextRenderer tr = MinecraftClient.getInstance().textRenderer;
        DebugRenderer wc = MinecraftClient.getInstance().debugRenderer;
            
            if(highestBlaze != null){  
                /* Outline */
                Box blaze = highestBlaze.getBoundingBox().expand(1);
                RenderUtils.drawBoxOutline(blaze,outlineColorRed,2.5f);
           }
            if(lowestBlaze != null){

                /* Outline */
                Box blaze = lowestBlaze.getBoundingBox().expand(1);
                RenderUtils.drawBoxOutline(blaze,outlineColorGreen,2.5f);
            }
        }catch(Exception e) {
            //System.out.println("BlazeRenderer: " + e.getStackTrace());
            System.out.println("BlazeRenderer: " + e);
        }
        
    }




}