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
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
|
package rosegoldaddons.features;
import net.minecraft.block.BlockStainedGlass;
import net.minecraft.block.BlockStainedGlassPane;
import net.minecraft.block.BlockStone;
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.item.EnumDyeColor;
import net.minecraft.network.play.client.C07PacketPlayerDigging;
import net.minecraft.network.play.server.S2APacketParticles;
import net.minecraft.util.*;
import net.minecraftforge.client.event.ClientChatReceivedEvent;
import net.minecraftforge.client.event.GuiScreenEvent;
import net.minecraftforge.client.event.RenderWorldLastEvent;
import net.minecraftforge.event.world.WorldEvent;
import net.minecraftforge.fml.common.eventhandler.EventPriority;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.gameevent.TickEvent;
import rosegoldaddons.Main;
import rosegoldaddons.events.PlayerMoveEvent;
import rosegoldaddons.events.ReceivePacketEvent;
import rosegoldaddons.events.ScreenClosedEvent;
import rosegoldaddons.utils.*;
import scala.concurrent.impl.CallbackRunnable;
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 static Vec3 particlePos;
private boolean stopHardstone = false;
private static int ticks = 0;
private static BlockPos gemstone;
private static BlockPos lastGem;
@SubscribeEvent
public void onTick(TickEvent.ClientTickEvent event) {
if (!Main.autoHardStone) {
currentDamage = 0;
broken.clear();
return;
}
if (!stopHardstone) {
particlePos = null;
ticks++;
if (Main.configFile.hardIndex == 0) {
if (broken.size() > 10) {
broken.clear();
}
}
if (Main.configFile.hardIndex == 1) {
if (broken.size() > 6) {
broken.clear();
}
}
if (ticks > 30) {
broken.clear();
ticks = 0;
}
closestStone = closestStone();
if (currentDamage > 200) {
currentDamage = 0;
}
if (gemstone != null && Main.mc.thePlayer != null) {
if (lastGem != null && !lastGem.equals(gemstone)) {
currentDamage = 0;
}
lastGem = gemstone;
if (currentDamage == 0) {
Main.mc.thePlayer.sendQueue.addToSendQueue(new C07PacketPlayerDigging(C07PacketPlayerDigging.Action.START_DESTROY_BLOCK, gemstone, EnumFacing.DOWN));
}
PlayerUtils.swingItem();
currentDamage++;
}
if (closestStone != null && gemstone == null) {
currentDamage = 0;
MovingObjectPosition fake = Main.mc.objectMouseOver;
fake.hitVec = new Vec3(closestStone);
EnumFacing enumFacing = fake.sideHit;
if (enumFacing != null && Main.mc.thePlayer != null) {
Main.mc.thePlayer.sendQueue.addToSendQueue(new C07PacketPlayerDigging(C07PacketPlayerDigging.Action.START_DESTROY_BLOCK, closestStone, enumFacing));
}
PlayerUtils.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(), packet.getZCoordinate());
if (closestChest != null) {
stopHardstone = true;
double dist = closestChest.distanceTo(particlePos);
if (dist < 1) {
if (!Main.configFile.serverSideChest) {
ShadyRotation.smoothLook(ShadyRotation.vec3ToRotation(particlePos), Main.configFile.smoothLookVelocity, () -> {
});
} else {
HardstoneAura.particlePos = particlePos;
}
}
}
}
}
}
@SubscribeEvent(priority = EventPriority.NORMAL)
public void onUpdatePre(PlayerMoveEvent.Pre pre) {
if (particlePos != null && Main.configFile.serverSideChest) {
ShadyRotation.smoothLook(ShadyRotation.vec3ToRotation(particlePos), 0, () -> {
});
}
}
@SubscribeEvent(priority = EventPriority.HIGHEST)
public void chat(ClientChatReceivedEvent event) {
if (event.type != 0) return;
String message = event.message.getUnformattedText();
if(message.contains("You have successfully picked the lock on this chest!")) {
if(particlePos != null && stopHardstone) {
solved.add(closestChest);
particlePos = null;
stopHardstone = false;
}
}
}
@SubscribeEvent
public void guiDraw(GuiScreenEvent.BackgroundDrawnEvent event) {
if (Main.configFile.guilag) {
Main.mc.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);
particlePos = null;
stopHardstone = false;
Main.mc.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), Main.configFile.lineWidth, event.partialTicks);
}
if (closestChest != null) {
RenderUtils.drawBlockBox(new BlockPos(closestChest.xCoord, closestChest.yCoord, closestChest.zCoord), new Color(255, 128, 0), Main.configFile.lineWidth, event.partialTicks);
} else {
stopHardstone = false;
}
if (gemstone != null) {
IBlockState blockState = Main.mc.theWorld.getBlockState(gemstone);
EnumDyeColor dyeColor = null;
Color color = Color.BLACK;
if (blockState.getBlock() == Blocks.stained_glass) {
dyeColor = blockState.getValue(BlockStainedGlass.COLOR);
}
if (blockState.getBlock() == Blocks.stained_glass_pane) {
dyeColor = blockState.getValue(BlockStainedGlassPane.COLOR);
}
if (dyeColor == EnumDyeColor.RED) {
color = new Color(188, 3, 29);
} else if (dyeColor == EnumDyeColor.PURPLE) {
color = new Color(137, 0, 201);
} else if (dyeColor == EnumDyeColor.LIME) {
color = new Color(157, 249, 32);
} else if (dyeColor == EnumDyeColor.LIGHT_BLUE) {
color = new Color(60, 121, 224);
} else if (dyeColor == EnumDyeColor.ORANGE) {
color = new Color(237, 139, 35);
} else if (dyeColor == EnumDyeColor.YELLOW) {
color = new Color(249, 215, 36);
} else if (dyeColor == EnumDyeColor.MAGENTA) {
color = new Color(214, 15, 150);
}
RenderUtils.drawBlockBox(gemstone, color, Main.configFile.lineWidth, event.partialTicks);
}
}
@SubscribeEvent
public void clear(WorldEvent.Load event) {
solved.clear();
}
private BlockPos closestStone() {
if (Main.mc.theWorld == null) return null;
if (Main.mc.thePlayer == null) return null;
int r = 4;
BlockPos playerPos = Main.mc.thePlayer.getPosition();
playerPos.add(0, 1, 0);
Vec3 playerVec = Main.mc.thePlayer.getPositionVector();
Vec3i vec3i = new Vec3i(r, 1 + Main.configFile.hardrange, r);
Vec3i vec3i2 = new Vec3i(r, Main.configFile.hardrangeDown, r);
ArrayList<Vec3> stones = new ArrayList<Vec3>();
ArrayList<Vec3> gemstones = new ArrayList<Vec3>();
if (playerPos != null) {
for (BlockPos blockPos : BlockPos.getAllInBox(playerPos.add(vec3i), playerPos.subtract(vec3i2))) {
IBlockState blockState = Main.mc.theWorld.getBlockState(blockPos);
if (Main.configFile.hardIndex == 0) {
if (!Main.configFile.includeExcavatable && 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
|| blockState.getBlock() == Blocks.lit_redstone_ore)
&& !broken.contains(blockPos)) {
stones.add(new Vec3(blockPos.getX() + 0.5, blockPos.getY(), blockPos.getZ() + 0.5));
}
}
if (Main.configFile.includeExcavatable) {
if ((blockState.getBlock() == Blocks.gravel || blockState.getBlock() == Blocks.sand) && !broken.contains(blockPos)) {
stones.add(new Vec3(blockPos.getX() + 0.5, blockPos.getY(), blockPos.getZ() + 0.5));
}
}
}
if (Main.configFile.hardIndex == 1) {
EnumFacing dir = Main.mc.thePlayer.getHorizontalFacing();
int x = (int) Math.floor(Main.mc.thePlayer.posX);
int z = (int) Math.floor(Main.mc.thePlayer.posZ);
switch (dir) {
case NORTH:
if (blockPos.getZ() <= z && blockPos.getX() == x) {
if (isSlow(blockState)) {
gemstones.add(new Vec3(blockPos.getX() + 0.5, blockPos.getY(), blockPos.getZ() + 0.5));
} else if (!Main.configFile.includeExcavatable && 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
|| blockState.getBlock() == Blocks.lit_redstone_ore)
&& !broken.contains(blockPos)) {
stones.add(new Vec3(blockPos.getX() + 0.5, blockPos.getY(), blockPos.getZ() + 0.5));
}
}
if (Main.configFile.includeExcavatable) {
if ((blockState.getBlock() == Blocks.gravel || blockState.getBlock() == Blocks.sand) && !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 (isSlow(blockState)) {
gemstones.add(new Vec3(blockPos.getX() + 0.5, blockPos.getY(), blockPos.getZ() + 0.5));
} else if (!Main.configFile.includeExcavatable && 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
|| blockState.getBlock() == Blocks.lit_redstone_ore)
&& !broken.contains(blockPos)) {
stones.add(new Vec3(blockPos.getX() + 0.5, blockPos.getY(), blockPos.getZ() + 0.5));
}
}
if (Main.configFile.includeExcavatable) {
if ((blockState.getBlock() == Blocks.gravel || blockState.getBlock() == Blocks.sand) && !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 (isSlow(blockState)) {
gemstones.add(new Vec3(blockPos.getX() + 0.5, blockPos.getY(), blockPos.getZ() + 0.5));
} else if (!Main.configFile.includeExcavatable && 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
|| blockState.getBlock() == Blocks.lit_redstone_ore)
&& !broken.contains(blockPos)) {
stones.add(new Vec3(blockPos.getX() + 0.5, blockPos.getY(), blockPos.getZ() + 0.5));
}
}
if (Main.configFile.includeExcavatable) {
if ((blockState.getBlock() == Blocks.gravel || blockState.getBlock() == Blocks.sand) && !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 (isSlow(blockState)) {
gemstones.add(new Vec3(blockPos.getX() + 0.5, blockPos.getY(), blockPos.getZ() + 0.5));
} else if (!Main.configFile.includeExcavatable && 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
|| blockState.getBlock() == Blocks.lit_redstone_ore)
&& !broken.contains(blockPos)) {
stones.add(new Vec3(blockPos.getX() + 0.5, blockPos.getY(), blockPos.getZ() + 0.5));
}
}
if (Main.configFile.includeExcavatable) {
if ((blockState.getBlock() == Blocks.gravel || blockState.getBlock() == Blocks.sand) && !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;
}
}
double smallestgem = 9999;
Vec3 closestgem = null;
for (Vec3 gem : gemstones) {
double dist = gem.distanceTo(playerVec);
if (dist < smallestgem) {
smallestgem = dist;
closestgem = gem;
}
}
if (closestgem != null) {
gemstone = new BlockPos(closestgem.xCoord, closestgem.yCoord, closestgem.zCoord);
} else {
gemstone = null;
}
if (closest != null && smallest < 5) {
return new BlockPos(closest.xCoord, closest.yCoord, closest.zCoord);
}
return null;
}
private Vec3 closestChest() {
if (Main.mc.theWorld == null) return null;
if (Main.mc.thePlayer == null) return null;
int r = 6;
BlockPos playerPos = Main.mc.thePlayer.getPosition();
playerPos.add(0, 1, 0);
Vec3 playerVec = Main.mc.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 = Main.mc.theWorld.getBlockState(blockPos);
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;
}
private boolean isSlow(IBlockState blockState) {
if (blockState.getBlock() == Blocks.prismarine) {
return true;
} else if (blockState.getBlock() == Blocks.wool) {
return true;
} else if (blockState.getBlock() == Blocks.stained_hardened_clay) {
return true;
} else if (!Main.configFile.ignoreTitanium && blockState.getBlock() == Blocks.stone && blockState.getValue(BlockStone.VARIANT) == BlockStone.EnumType.DIORITE_SMOOTH) {
return true;
} else if (blockState.getBlock() == Blocks.gold_block) {
return true;
} else if (blockState.getBlock() == Blocks.stained_glass_pane || blockState.getBlock() == Blocks.stained_glass) {
return true;
}
return false;
}
}
|