blob: 8b47fcb2821a259a510525a1029f4d84caa43320 (
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
|
package rosegoldaddons.features;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.Minecraft;
import net.minecraft.client.settings.KeyBinding;
import net.minecraft.init.Blocks;
import net.minecraft.util.*;
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.commands.WartSetup;
import rosegoldaddons.utils.RenderUtils;
import java.awt.*;
import java.util.ArrayList;
public class WartMacro {
private boolean breaking = false;
private boolean walking = false;
private double savex = -999;
private double savez = -999;
private Thread thread;
private Thread thread2;
@SubscribeEvent
public void move(TickEvent.ClientTickEvent event) {
if (!Main.wartToggle || Minecraft.getMinecraft().currentScreen != null) {
if (walking) {
KeyBinding.setKeyBindState(Minecraft.getMinecraft().gameSettings.keyBindForward.getKeyCode(), false);
walking = false;
}
return;
}
if (thread == null || !thread.isAlive()) {
thread = new Thread(() -> {
try {
//if (event.phase.toString().equals("START")) {
if (!walking) {
KeyBinding.setKeyBindState(Minecraft.getMinecraft().gameSettings.keyBindForward.getKeyCode(), true);
walking = true;
}
float prevYaw = Minecraft.getMinecraft().thePlayer.rotationYaw;
float nextYaw = -1;
if (WartSetup.cardinal.equals("east")) {
if (Minecraft.getMinecraft().thePlayer.getPosition().getZ() == WartSetup.wartEnd) {
nextYaw = 230;
} else if (Minecraft.getMinecraft().thePlayer.getPosition().getZ() == -WartSetup.wartEnd) {
nextYaw = 310;
}
} else if (WartSetup.cardinal.equals("north")) {
if (Minecraft.getMinecraft().thePlayer.getPosition().getX() == WartSetup.wartEnd) {
nextYaw = 140;
} else if (Minecraft.getMinecraft().thePlayer.getPosition().getX() == -WartSetup.wartEnd) {
nextYaw = 220;
}
} else if (WartSetup.cardinal.equals("west")) {
if (Minecraft.getMinecraft().thePlayer.getPosition().getZ() == WartSetup.wartEnd) {
nextYaw = 130;
} else if (Minecraft.getMinecraft().thePlayer.getPosition().getZ() == -WartSetup.wartEnd) {
nextYaw = 50;
}
} else if (WartSetup.cardinal.equals("south")) {
if (Minecraft.getMinecraft().thePlayer.getPosition().getX() == WartSetup.wartEnd) {
nextYaw = 40;
} else if (Minecraft.getMinecraft().thePlayer.getPosition().getX() == -WartSetup.wartEnd) {
nextYaw = 320;
}
}
if(nextYaw != -1) {
for (int i = 0; i < 50; i++) {
Minecraft.getMinecraft().thePlayer.rotationYaw += (nextYaw - prevYaw) / 50;
Thread.sleep(10);
}
}
//}
} catch (Exception e) {
e.printStackTrace();
}
}, "Wart Rotation");
thread.start();
}
}
@SubscribeEvent
public void click(TickEvent.ClientTickEvent event) {
if (!Main.wartToggle || Minecraft.getMinecraft().currentScreen != null) {
if (breaking) {
KeyBinding.setKeyBindState(Minecraft.getMinecraft().gameSettings.keyBindAttack.getKeyCode(), false);
breaking = false;
}
return;
}
if (event.phase.toString().equals("START")) {
MovingObjectPosition objectMouseOver = Minecraft.getMinecraft().objectMouseOver;
if (objectMouseOver != null && objectMouseOver.typeOfHit.toString() == "BLOCK") {
BlockPos pos = objectMouseOver.getBlockPos();
Block gem = Minecraft.getMinecraft().theWorld.getBlockState(pos).getBlock();
if (gem == Blocks.nether_wart) {
if (!breaking) {
KeyBinding.setKeyBindState(Minecraft.getMinecraft().gameSettings.keyBindAttack.getKeyCode(), true);
breaking = true;
}
} else {
if (breaking) {
KeyBinding.setKeyBindState(Minecraft.getMinecraft().gameSettings.keyBindAttack.getKeyCode(), false);
breaking = false;
}
}
}
}
}
@SubscribeEvent
public void antiStuck(TickEvent.ClientTickEvent event) {
if (!Main.wartToggle || Minecraft.getMinecraft().currentScreen != null) return;
if (event.phase.toString().equals("START")) {
if (thread2 == null || !thread2.isAlive()) {
thread2 = new Thread(() -> {
try {
Thread.sleep(1500);
double xdiff = Math.abs(savex - Minecraft.getMinecraft().thePlayer.posX);
double zdiff = Math.abs(savez - Minecraft.getMinecraft().thePlayer.posZ);
if(xdiff < 2 && zdiff < 2) {
Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText("stuck detected."));
KeyBinding.setKeyBindState(Minecraft.getMinecraft().gameSettings.keyBindLeft.getKeyCode(), true);
Thread.sleep(500);
KeyBinding.setKeyBindState(Minecraft.getMinecraft().gameSettings.keyBindLeft.getKeyCode(), false);
Thread.sleep(1000);
KeyBinding.setKeyBindState(Minecraft.getMinecraft().gameSettings.keyBindRight.getKeyCode(), true);
Thread.sleep(500);
KeyBinding.setKeyBindState(Minecraft.getMinecraft().gameSettings.keyBindRight.getKeyCode(), false);
}
savex = Minecraft.getMinecraft().thePlayer.posX;
savez = Minecraft.getMinecraft().thePlayer.posZ;
} catch (InterruptedException e) {
e.printStackTrace();
}
}, "Anti Stuck");
thread2.start();
}
}
}
}
|