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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
|
package rosegoldaddons.features;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.inventory.GuiChest;
import net.minecraft.client.settings.GameSettings;
import net.minecraft.init.Blocks;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.ContainerChest;
import net.minecraft.network.play.client.C07PacketPlayerDigging;
import net.minecraft.network.play.server.S2APacketParticles;
import net.minecraft.util.*;
import net.minecraftforge.client.event.GuiScreenEvent;
import net.minecraftforge.client.event.RenderWorldLastEvent;
import net.minecraftforge.event.world.WorldEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.gameevent.TickEvent;
import rosegoldaddons.Main;
import rosegoldaddons.events.ReceivePacketEvent;
import rosegoldaddons.utils.ChatUtils;
import rosegoldaddons.utils.RenderUtils;
import rosegoldaddons.utils.RotationUtils;
import java.awt.*;
import java.util.ArrayList;
public class HardstoneAura {
private ArrayList<Vec3> solved = new ArrayList<>();
private ArrayList<BlockPos> broken = new ArrayList<>();
private static int currentDamage;
private static BlockPos closestStone;
private static Vec3 closestChest;
private boolean stopHardstone = false;
private static int ticks = 0;
@SubscribeEvent
public void onTick(TickEvent.ClientTickEvent event) {
if (!Main.autoHardStone) {
currentDamage = 0;
broken.clear();
return;
}
if (!stopHardstone) {
ticks++;
if(Main.configFile.hardIndex == 0) {
if (broken.size() > 10) {
broken.clear();
}
}
if(Main.configFile.hardIndex == 1) {
if (broken.size() > 4) {
broken.clear();
}
}
if(ticks > 15) {
broken.clear();
ticks = 0;
}
closestStone = closestStone();
if (closestStone != null) {
MovingObjectPosition fake = Minecraft.getMinecraft().objectMouseOver;
fake.hitVec = new Vec3(closestStone);
EnumFacing enumFacing = fake.sideHit;
if (currentDamage == 0 && enumFacing != null && Minecraft.getMinecraft().thePlayer != null) {
Minecraft.getMinecraft().thePlayer.sendQueue.addToSendQueue(new C07PacketPlayerDigging(C07PacketPlayerDigging.Action.START_DESTROY_BLOCK, closestStone, enumFacing));
}
MovingObjectPosition real = Minecraft.getMinecraft().objectMouseOver;
if (real != null && real.entityHit == null && Minecraft.getMinecraft().thePlayer != null) {
Minecraft.getMinecraft().thePlayer.swingItem();
}
broken.add(closestStone);
}
}
}
@SubscribeEvent
public void receivePacket(ReceivePacketEvent event) {
if (!Main.autoHardStone) return;
if (event.packet instanceof S2APacketParticles) {
S2APacketParticles packet = (S2APacketParticles) event.packet;
if (packet.getParticleType().equals(EnumParticleTypes.CRIT)) {
Vec3 particlePos = new Vec3(packet.getXCoordinate(), packet.getYCoordinate() - 0.7, packet.getZCoordinate());
if (closestChest != null) {
stopHardstone = true;
double dist = closestChest.distanceTo(particlePos);
if (dist < 1) {
particlePos = particlePos.add(new Vec3(0, -1, 0));
int drill = PowderMacro.findItemInHotbar("X655");
if (drill != -1) Minecraft.getMinecraft().thePlayer.inventory.currentItem = drill;
RotationUtils.facePos(particlePos);
}
}
}
}
}
@SubscribeEvent
public void guiDraw(GuiScreenEvent.BackgroundDrawnEvent event) {
if(Main.configFile.guilag) {
Minecraft.getMinecraft().gameSettings.setOptionFloatValue(GameSettings.Options.FRAMERATE_LIMIT, 1);
}
if(!Main.autoHardStone) return;
if (event.gui instanceof GuiChest) {
Container container = ((GuiChest) event.gui).inventorySlots;
if (container instanceof ContainerChest) {
String chestName = ((ContainerChest) container).getLowerChestInventory().getDisplayName().getUnformattedText();
if (chestName.contains("Treasure")) {
solved.add(closestChest);
stopHardstone = false;
Minecraft.getMinecraft().thePlayer.closeScreen();
}
}
}
}
@SubscribeEvent
public void renderWorld(RenderWorldLastEvent event) {
if (!Main.autoHardStone) return;
closestStone = closestStone();
closestChest = closestChest();
if (closestStone != null) {
RenderUtils.drawBlockBox(closestStone, new Color(128, 128, 128), true, event.partialTicks);
}
if (closestChest != null) {
RenderUtils.drawBlockBox(new BlockPos(closestChest.xCoord, closestChest.yCoord, closestChest.zCoord), new Color(255, 128, 0), true, event.partialTicks);
} else {
stopHardstone = false;
}
}
@SubscribeEvent
public void clear(WorldEvent.Load event) {
solved.clear();
}
private BlockPos closestStone() {
if(Minecraft.getMinecraft().theWorld == null) return null;
if(Minecraft.getMinecraft().thePlayer == null) return null;
int r = 6;
BlockPos playerPos = Minecraft.getMinecraft().thePlayer.getPosition();
playerPos.add(0, 1, 0);
Vec3 playerVec = Minecraft.getMinecraft().thePlayer.getPositionVector();
Vec3i vec3i = new Vec3i(r, 1 + Main.configFile.hardrange, r);
Vec3i vec3i2 = new Vec3i(r, 0, r);
ArrayList<Vec3> stones = new ArrayList<Vec3>();
if (playerPos != null) {
for (BlockPos blockPos : BlockPos.getAllInBox(playerPos.add(vec3i), playerPos.subtract(vec3i2))) {
IBlockState blockState = Minecraft.getMinecraft().theWorld.getBlockState(blockPos);
if(Main.configFile.hardIndex == 0) {
if (blockState.getBlock() == Blocks.stone && !broken.contains(blockPos)) {
stones.add(new Vec3(blockPos.getX() + 0.5, blockPos.getY(), blockPos.getZ() + 0.5));
}
if (Main.configFile.includeOres) {
if (blockState.getBlock() == Blocks.coal_ore || blockState.getBlock() == Blocks.diamond_ore || blockState.getBlock() == Blocks.gold_ore || blockState.getBlock() == Blocks.redstone_ore || blockState.getBlock() == Blocks.iron_ore || blockState.getBlock() == Blocks.lapis_ore || blockState.getBlock() == Blocks.emerald_ore || blockState.getBlock() == Blocks.netherrack && !broken.contains(blockPos)) {
stones.add(new Vec3(blockPos.getX() + 0.5, blockPos.getY(), blockPos.getZ() + 0.5));
}
}
}
if(Main.configFile.hardIndex == 1) {
EnumFacing dir = Minecraft.getMinecraft().thePlayer.getHorizontalFacing();
int x = (int) Math.floor(Minecraft.getMinecraft().thePlayer.posX);
int z = (int) Math.floor(Minecraft.getMinecraft().thePlayer.posZ);
switch (dir) {
case NORTH:
if(blockPos.getZ() < z && blockPos.getX() == x) {
if (blockState.getBlock() == Blocks.stone && !broken.contains(blockPos)) {
stones.add(new Vec3(blockPos.getX() + 0.5, blockPos.getY(), blockPos.getZ() + 0.5));
}
if (Main.configFile.includeOres) {
if (blockState.getBlock() == Blocks.coal_ore || blockState.getBlock() == Blocks.diamond_ore || blockState.getBlock() == Blocks.gold_ore || blockState.getBlock() == Blocks.redstone_ore || blockState.getBlock() == Blocks.iron_ore || blockState.getBlock() == Blocks.lapis_ore || blockState.getBlock() == Blocks.emerald_ore || blockState.getBlock() == Blocks.netherrack && !broken.contains(blockPos)) {
stones.add(new Vec3(blockPos.getX() + 0.5, blockPos.getY(), blockPos.getZ() + 0.5));
}
}
}
break;
case SOUTH:
if(blockPos.getZ() > z && blockPos.getX() == x) {
if (blockState.getBlock() == Blocks.stone && !broken.contains(blockPos)) {
stones.add(new Vec3(blockPos.getX() + 0.5, blockPos.getY(), blockPos.getZ() + 0.5));
}
if (Main.configFile.includeOres) {
if (blockState.getBlock() == Blocks.coal_ore || blockState.getBlock() == Blocks.diamond_ore || blockState.getBlock() == Blocks.gold_ore || blockState.getBlock() == Blocks.redstone_ore || blockState.getBlock() == Blocks.iron_ore || blockState.getBlock() == Blocks.lapis_ore || blockState.getBlock() == Blocks.emerald_ore || blockState.getBlock() == Blocks.netherrack && !broken.contains(blockPos)) {
stones.add(new Vec3(blockPos.getX() + 0.5, blockPos.getY(), blockPos.getZ() + 0.5));
}
}
}
break;
case WEST:
if(blockPos.getX() < x && blockPos.getZ() == z) {
if (blockState.getBlock() == Blocks.stone && !broken.contains(blockPos)) {
stones.add(new Vec3(blockPos.getX() + 0.5, blockPos.getY(), blockPos.getZ() + 0.5));
}
if (Main.configFile.includeOres) {
if (blockState.getBlock() == Blocks.coal_ore || blockState.getBlock() == Blocks.diamond_ore || blockState.getBlock() == Blocks.gold_ore || blockState.getBlock() == Blocks.redstone_ore || blockState.getBlock() == Blocks.iron_ore || blockState.getBlock() == Blocks.lapis_ore || blockState.getBlock() == Blocks.emerald_ore || blockState.getBlock() == Blocks.netherrack && !broken.contains(blockPos)) {
stones.add(new Vec3(blockPos.getX() + 0.5, blockPos.getY(), blockPos.getZ() + 0.5));
}
}
}
break;
case EAST:
if(blockPos.getX() > x && blockPos.getZ() == z) {
if (blockState.getBlock() == Blocks.stone && !broken.contains(blockPos)) {
stones.add(new Vec3(blockPos.getX() + 0.5, blockPos.getY(), blockPos.getZ() + 0.5));
}
if (Main.configFile.includeOres) {
if (blockState.getBlock() == Blocks.coal_ore || blockState.getBlock() == Blocks.diamond_ore || blockState.getBlock() == Blocks.gold_ore || blockState.getBlock() == Blocks.redstone_ore || blockState.getBlock() == Blocks.iron_ore || blockState.getBlock() == Blocks.lapis_ore || blockState.getBlock() == Blocks.emerald_ore || blockState.getBlock() == Blocks.netherrack && !broken.contains(blockPos)) {
stones.add(new Vec3(blockPos.getX() + 0.5, blockPos.getY(), blockPos.getZ() + 0.5));
}
}
}
break;
}
}
}
}
double smallest = 9999;
Vec3 closest = null;
for (Vec3 stone : stones) {
double dist = stone.distanceTo(playerVec);
if (dist < smallest) {
smallest = dist;
closest = stone;
}
}
if (closest != null && smallest < 5) {
return new BlockPos(closest.xCoord, closest.yCoord, closest.zCoord);
}
return null;
}
private Vec3 closestChest() {
if(Minecraft.getMinecraft().theWorld == null) return null;
if(Minecraft.getMinecraft().thePlayer == null) return null;
int r = 6;
BlockPos playerPos = Minecraft.getMinecraft().thePlayer.getPosition();
playerPos.add(0, 1, 0);
Vec3 playerVec = Minecraft.getMinecraft().thePlayer.getPositionVector();
Vec3i vec3i = new Vec3i(r, r, r);
ArrayList<Vec3> chests = new ArrayList<>();
if (playerPos != null) {
for (BlockPos blockPos : BlockPos.getAllInBox(playerPos.add(vec3i), playerPos.subtract(vec3i))) {
IBlockState blockState = Minecraft.getMinecraft().theWorld.getBlockState(blockPos);
//Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(blockState.getBlock().toString()));
if (blockState.getBlock() == Blocks.chest) {
chests.add(new Vec3(blockPos.getX() + 0.5, blockPos.getY(), blockPos.getZ() + 0.5));
}
}
}
double smallest = 9999;
Vec3 closest = null;
for (Vec3 chest : chests) {
if (!solved.contains(chest)) {
double dist = chest.distanceTo(playerVec);
if (dist < smallest) {
smallest = dist;
closest = chest;
}
}
}
return closest;
}
}
|