aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/rosegoldaddons/features/BloodTriggerBot.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/rosegoldaddons/features/BloodTriggerBot.java')
-rw-r--r--src/main/java/rosegoldaddons/features/BloodTriggerBot.java59
1 files changed, 12 insertions, 47 deletions
diff --git a/src/main/java/rosegoldaddons/features/BloodTriggerBot.java b/src/main/java/rosegoldaddons/features/BloodTriggerBot.java
index 9df02e9..7f5909d 100644
--- a/src/main/java/rosegoldaddons/features/BloodTriggerBot.java
+++ b/src/main/java/rosegoldaddons/features/BloodTriggerBot.java
@@ -2,54 +2,33 @@ package rosegoldaddons.features;
import net.minecraft.client.Minecraft;
import net.minecraft.client.entity.EntityOtherPlayerMP;
-import net.minecraft.client.gui.GuiChat;
-import net.minecraft.client.gui.GuiIngameMenu;
-import net.minecraft.client.gui.inventory.GuiChest;
import net.minecraft.entity.Entity;
import net.minecraft.entity.boss.EntityWither;
import net.minecraft.util.AxisAlignedBB;
-import net.minecraft.util.MovingObjectPosition;
import net.minecraft.util.Vec3;
-import net.minecraftforge.client.event.RenderWorldLastEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
+import net.minecraftforge.fml.common.gameevent.TickEvent;
import rosegoldaddons.Main;
-import rosegoldaddons.utils.ChatUtils;
-import rosegoldaddons.utils.RenderUtils;
-import rosegoldaddons.utils.RotationUtils;
-import java.awt.*;
-import java.lang.reflect.Method;
import java.util.ArrayList;
public class BloodTriggerBot {
- private static String[] names = {"Bonzo", "Revoker", "Psycho", "Reaper", "Cannibal", "Mute", "Ooze", "Putrid", "Freak", "Leech", "Tear", "Parasite", "Flamer", "Skull", "Mr. Dead", "Vader", "Frost", "Walker", "WanderingSoul", "Shadow Assassin", "Lost Adventurer", "Livid", "Professor", "Spirit Bear"};
- private static ArrayList<Entity> bloodMobs = null;
- private Thread thread;
+ private static final String[] names = {"Bonzo", "Revoker", "Psycho", "Reaper", "Cannibal", "Mute", "Ooze", "Putrid", "Freak", "Leech", "Tear", "Parasite", "Flamer", "Skull", "Mr. Dead", "Vader", "Frost", "Walker", "WanderingSoul", "Shadow Assassin", "Lost Adventurer", "Livid", "Professor", "Spirit Bear"};
@SubscribeEvent
- public void renderWorld(RenderWorldLastEvent event) {
+ public void renderWorld(TickEvent.ClientTickEvent event) {
if (!Main.bloodTriggerBot) return;
- bloodMobs = getAllBloodMobs();
- if (thread == null || !thread.isAlive()) {
- thread = new Thread(() -> {
- try {
- for (Entity entity : bloodMobs) {
- if (isLookingAtAABB(entity.getEntityBoundingBox(), event)) {
- click();
- Thread.sleep(100);
- }
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- }, "Blood room thingy");
- thread.start();
+ if (event.phase == TickEvent.Phase.END) return;
+ for (Entity entity : getAllBloodMobs()) {
+ if (isLookingAtAABB(entity.getEntityBoundingBox(), 1F)) {
+ Minecraft.getMinecraft().thePlayer.swingItem();
+ }
}
}
- private static boolean isLookingAtAABB(AxisAlignedBB aabb, RenderWorldLastEvent event) {
+ private static boolean isLookingAtAABB(AxisAlignedBB aabb, float partialTicks) {
Vec3 position = new Vec3(Minecraft.getMinecraft().thePlayer.posX, (Minecraft.getMinecraft().thePlayer.posY + Minecraft.getMinecraft().thePlayer.getEyeHeight()), Minecraft.getMinecraft().thePlayer.posZ);
- Vec3 look = Minecraft.getMinecraft().thePlayer.getLook(event.partialTicks);
+ Vec3 look = Minecraft.getMinecraft().thePlayer.getLook(partialTicks);
look = scaleVec(look, 0.5F);
for (int i = 0; i < 64; i++) {
if (aabb.minX <= position.xCoord && aabb.maxX >= position.xCoord && aabb.minY <= position.yCoord && aabb.maxY >= position.yCoord && aabb.minZ <= position.zCoord && aabb.maxZ >= position.zCoord) {
@@ -63,6 +42,7 @@ public class BloodTriggerBot {
private static ArrayList<Entity> getAllBloodMobs() {
ArrayList<Entity> bloodMobs = new ArrayList<>();
+ if (Minecraft.getMinecraft().theWorld == null) return bloodMobs;
for (Entity entity1 : (Minecraft.getMinecraft().theWorld.loadedEntityList)) {
if (entity1 instanceof EntityOtherPlayerMP && !entity1.isDead) {
for (String name : names) {
@@ -79,21 +59,6 @@ public class BloodTriggerBot {
}
private static Vec3 scaleVec(Vec3 vec, float f) {
- return new Vec3(vec.xCoord * (double)f, vec.yCoord * (double)f, vec.zCoord * (double)f);
- }
-
- public static void click() {
- try {
- Method clickMouse;
- try {
- clickMouse = Minecraft.class.getDeclaredMethod("func_147116_af");
- } catch (NoSuchMethodException e) {
- clickMouse = Minecraft.class.getDeclaredMethod("clickMouse");
- }
- clickMouse.setAccessible(true);
- clickMouse.invoke(Minecraft.getMinecraft());
- } catch (Exception e) {
- e.printStackTrace();
- }
+ return new Vec3(vec.xCoord * (double) f, vec.yCoord * (double) f, vec.zCoord * (double) f);
}
}