├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── src └── main │ ├── java │ └── me │ │ └── bebeli555 │ │ └── autobot │ │ ├── events │ │ ├── TravelEvent.java │ │ ├── PlayerUpdateEvent.java │ │ ├── PlayerMotionUpdateEvent.java │ │ ├── EntityPushEvent.java │ │ ├── PacketEvent.java │ │ ├── PacketPostEvent.java │ │ ├── PlayerMoveEvent.java │ │ └── PlayerDamageBlockEvent.java │ │ ├── gui │ │ ├── Mode.java │ │ ├── Group.java │ │ ├── Keybind.java │ │ ├── GuiSettings.java │ │ ├── SetGuiNodes.java │ │ ├── Setting.java │ │ ├── Settings.java │ │ └── GuiNode.java │ │ ├── utils │ │ ├── Timer.java │ │ ├── EatingUtil.java │ │ ├── PlayerUtil.java │ │ ├── CrystalUtil.java │ │ ├── BaritoneUtil.java │ │ ├── MiningUtil.java │ │ ├── InventoryUtil.java │ │ ├── RotationUtil.java │ │ └── BlockUtil.java │ │ ├── rendering │ │ ├── RenderPath.java │ │ ├── RenderBlock.java │ │ ├── Renderer.java │ │ └── RenderUtil.java │ │ ├── mixin │ │ ├── mixins │ │ │ ├── MixinPlayerControllerMP.java │ │ │ ├── MixinNetworkManager.java │ │ │ ├── MixinEntityPlayer.java │ │ │ └── MixinEntityPlayerSP.java │ │ └── MixinLoader.java │ │ ├── mods │ │ ├── bots │ │ │ ├── elytrabot │ │ │ │ ├── Direction.java │ │ │ │ ├── PacketFly.java │ │ │ │ ├── ElytraFly.java │ │ │ │ └── AStar.java │ │ │ └── crystalpvpbot │ │ │ │ ├── AutoTotem.java │ │ │ │ ├── DisableKnockback.java │ │ │ │ ├── Surround.java │ │ │ │ ├── AutoTrap.java │ │ │ │ ├── Walker.java │ │ │ │ └── AutoCrystal.java │ │ ├── other │ │ │ ├── AutoTrapIndicator.java │ │ │ ├── AutoWeb.java │ │ │ ├── AutoFirework.java │ │ │ ├── CrystalBlock.java │ │ │ ├── AutoEnderChestMiner.java │ │ │ ├── AutoMessager.java │ │ │ ├── AutoTrap.java │ │ │ ├── MiningSpoof.java │ │ │ ├── AutoInventoryManager.java │ │ │ ├── AutoMend.java │ │ │ ├── AutoWither.java │ │ │ ├── Burrow.java │ │ │ └── AutoBuilder.java │ │ └── games │ │ │ └── Snake.java │ │ └── Commands.java │ └── resources │ ├── mixins.autobot.json │ ├── pack.mcmeta │ └── mcmod.info ├── gradle.properties ├── README.md ├── gradlew.bat └── gradlew /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bebeli555/AutoBot/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /src/main/java/me/bebeli555/autobot/events/TravelEvent.java: -------------------------------------------------------------------------------- 1 | package me.bebeli555.autobot.events; 2 | 3 | import me.zero.alpine.type.Cancellable; 4 | 5 | public class TravelEvent extends Cancellable { 6 | 7 | } 8 | -------------------------------------------------------------------------------- /src/main/java/me/bebeli555/autobot/gui/Mode.java: -------------------------------------------------------------------------------- 1 | package me.bebeli555.autobot.gui; 2 | 3 | public enum Mode { 4 | BOOLEAN(), 5 | INTEGER(), 6 | DOUBLE(), 7 | TEXT(), 8 | MODE(), 9 | LABEL(); 10 | } 11 | -------------------------------------------------------------------------------- /src/main/java/me/bebeli555/autobot/events/PlayerUpdateEvent.java: -------------------------------------------------------------------------------- 1 | package me.bebeli555.autobot.events; 2 | 3 | import me.zero.alpine.type.Cancellable; 4 | 5 | public class PlayerUpdateEvent extends Cancellable { 6 | 7 | } 8 | -------------------------------------------------------------------------------- /src/main/java/me/bebeli555/autobot/events/PlayerMotionUpdateEvent.java: -------------------------------------------------------------------------------- 1 | package me.bebeli555.autobot.events; 2 | 3 | import me.zero.alpine.type.Cancellable; 4 | 5 | public class PlayerMotionUpdateEvent extends Cancellable { 6 | 7 | } -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | zipStoreBase=GRADLE_USER_HOME 4 | zipStorePath=wrapper/dists 5 | distributionUrl=https\://services.gradle.org/distributions/gradle-4.9-bin.zip -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Sets default memory used for gradle commands. Can be overridden by user or command line properties. 2 | # This is required to provide enough memory for the Minecraft decompilation process. 3 | org.gradle.jvmargs=-Xmx3G 4 | org.gradle.daemon=false -------------------------------------------------------------------------------- /src/main/resources/mixins.autobot.json: -------------------------------------------------------------------------------- 1 | { 2 | "required": true, 3 | "compatibilityLevel": "JAVA_8", 4 | "package": "me.bebeli555.autobot.mixin.mixins", 5 | "refmap": "mixins.autobot.refmap.json", 6 | "client": [ 7 | "MixinEntityPlayer", 8 | "MixinEntityPlayerSP", 9 | "MixinNetworkManager", 10 | "MixinPlayerControllerMP" 11 | ] 12 | } -------------------------------------------------------------------------------- /src/main/java/me/bebeli555/autobot/events/EntityPushEvent.java: -------------------------------------------------------------------------------- 1 | package me.bebeli555.autobot.events; 2 | 3 | import me.zero.alpine.type.Cancellable; 4 | import net.minecraft.entity.Entity; 5 | 6 | public class EntityPushEvent extends Cancellable { 7 | public Entity entity; 8 | 9 | public EntityPushEvent(Entity entity) { 10 | this.entity = entity; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/main/java/me/bebeli555/autobot/events/PacketEvent.java: -------------------------------------------------------------------------------- 1 | package me.bebeli555.autobot.events; 2 | 3 | import me.zero.alpine.type.Cancellable; 4 | import net.minecraft.network.Packet; 5 | 6 | @SuppressWarnings("rawtypes") 7 | public class PacketEvent extends Cancellable { 8 | public Packet packet; 9 | 10 | public PacketEvent(Packet packet) { 11 | this.packet = packet; 12 | } 13 | } -------------------------------------------------------------------------------- /src/main/java/me/bebeli555/autobot/events/PacketPostEvent.java: -------------------------------------------------------------------------------- 1 | package me.bebeli555.autobot.events; 2 | 3 | import me.zero.alpine.type.Cancellable; 4 | import net.minecraft.network.Packet; 5 | 6 | @SuppressWarnings("rawtypes") 7 | public class PacketPostEvent extends Cancellable { 8 | public Packet packet; 9 | 10 | public PacketPostEvent(Packet packet) { 11 | this.packet = packet; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/me/bebeli555/autobot/utils/Timer.java: -------------------------------------------------------------------------------- 1 | package me.bebeli555.autobot.utils; 2 | 3 | public class Timer { 4 | public long ms; 5 | 6 | public Timer() { 7 | this.ms = 0; 8 | } 9 | 10 | public boolean hasPassed(int ms) { 11 | return System.currentTimeMillis() - this.ms >= ms; 12 | } 13 | 14 | public void reset() { 15 | this.ms = System.currentTimeMillis(); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/main/resources/pack.mcmeta: -------------------------------------------------------------------------------- 1 | { 2 | "pack": { 3 | "description": "examplemod resources", 4 | "pack_format": 3, 5 | "_comment": "A pack_format of 3 should be used starting with Minecraft 1.11. All resources, including language files, should be lowercase (eg: en_us.lang). A pack_format of 2 will load your mod resources with LegacyV2Adapter, which requires language files to have uppercase letters (eg: en_US.lang)." 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /src/main/java/me/bebeli555/autobot/events/PlayerMoveEvent.java: -------------------------------------------------------------------------------- 1 | package me.bebeli555.autobot.events; 2 | 3 | import me.zero.alpine.type.Cancellable; 4 | import net.minecraft.entity.MoverType; 5 | 6 | public class PlayerMoveEvent extends Cancellable { 7 | public MoverType type; 8 | public double x, y, z; 9 | 10 | public PlayerMoveEvent(MoverType type, double x, double y, double z) { 11 | this.type = type; 12 | this.x = x; 13 | this.y = y; 14 | this.z = z; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/me/bebeli555/autobot/events/PlayerDamageBlockEvent.java: -------------------------------------------------------------------------------- 1 | package me.bebeli555.autobot.events; 2 | 3 | import me.zero.alpine.type.Cancellable; 4 | import net.minecraft.util.EnumFacing; 5 | import net.minecraft.util.math.BlockPos; 6 | 7 | public class PlayerDamageBlockEvent extends Cancellable { 8 | public BlockPos pos; 9 | public EnumFacing facing; 10 | 11 | public PlayerDamageBlockEvent(BlockPos pos, EnumFacing facing) { 12 | this.pos = pos; 13 | this.facing = facing; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/me/bebeli555/autobot/gui/Group.java: -------------------------------------------------------------------------------- 1 | package me.bebeli555.autobot.gui; 2 | 3 | public enum Group { 4 | BOTS("Bots", 430 + 55, 50, "The bots"), 5 | GUI("GUI", 190 + 55, 50, "Stuff about the GUI"), 6 | OTHER("Other", 550 + 55, 50, "Other modules"), 7 | GAMES("Games", 310 + 55, 50, "Fun games to play"); 8 | 9 | public String name; 10 | public int x, y; 11 | public String[] description; 12 | Group(String name, int x, int y, String... description) { 13 | this.name = name; 14 | this.x = x; 15 | this.y = y; 16 | this.description = description; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/main/resources/mcmod.info: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "modid": "AutoBot", 4 | "name": "AutoBot", 5 | "description": "AutoBot is a module styled client for anarchy servers that offers bots and auto-modules like ElytraBot which is a pathfinding bot for elytras or AutoBuilder that builds stuff etc.", 6 | "version": "1.06", 7 | "mcversion": "1.12.2", 8 | "url": "https://github.com/bebeli555/AutoBot", 9 | "updateUrl": "https://discord.gg/xSukBcyd8m", 10 | "authorList": ["bebeli555"], 11 | "credits": "bebeli555", 12 | "logoFile": "", 13 | "screenshots": [], 14 | "dependencies": [] 15 | } 16 | ] 17 | -------------------------------------------------------------------------------- /src/main/java/me/bebeli555/autobot/rendering/RenderPath.java: -------------------------------------------------------------------------------- 1 | package me.bebeli555.autobot.rendering; 2 | 3 | import java.awt.Color; 4 | import java.util.ArrayList; 5 | 6 | import net.minecraft.util.math.BlockPos; 7 | 8 | public class RenderPath { 9 | public static ArrayList path = new ArrayList(); 10 | public static Color color; 11 | 12 | public static void setPath(ArrayList path, Color color) { 13 | RenderPath.path = path; 14 | RenderPath.color = color; 15 | } 16 | 17 | public static void clearPath() { 18 | path.clear(); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # AutoBot 2 | [![Discord](https://img.shields.io/discord/463752820026376202.svg?label=&logo=discord&logoColor=ffffff&color=7389D8&labelColor=6A7EC2)](https://discord.gg/xSukBcyd8m) 3 | 4 | AutoBot is a module styled client for anarchy servers that offers bots and auto-modules like ElytraBot which is a pathfinding bot for elytras or AutoBuilder that builds stuff etc. This mod is for 1.12.2 forge. 5 |
Join the discord for more info and updates! 6 |
7 |
8 | You can build the project by running gradlew setupDecompWorkspace and gradlew build. Or you can download the jar from the releases tab or from our discord. 9 |
10 |
11 | You should check out https://github.com/bebeli555/CookieClient. Its a client for anarchy servers that has everything this does and alot more. AutoBot is no longer supported. 12 | -------------------------------------------------------------------------------- /src/main/java/me/bebeli555/autobot/rendering/RenderBlock.java: -------------------------------------------------------------------------------- 1 | package me.bebeli555.autobot.rendering; 2 | 3 | import java.awt.Color; 4 | import java.util.ArrayList; 5 | 6 | import net.minecraft.util.math.BlockPos; 7 | 8 | public class RenderBlock { 9 | public static ArrayList list = new ArrayList(); 10 | 11 | public static void add(BlockPos pos, Color color, float width) { 12 | list.add(new BlockColor(pos, color, width)); 13 | } 14 | 15 | public static void remove(BlockPos pos) { 16 | ArrayList remove = new ArrayList(); 17 | for (BlockColor blockColor : list) { 18 | if (blockColor.pos.equals(pos)) { 19 | remove.add(blockColor); 20 | } 21 | } 22 | 23 | list.removeAll(remove); 24 | } 25 | 26 | public static void clear() { 27 | list.clear(); 28 | } 29 | 30 | public static class BlockColor { 31 | public BlockPos pos; 32 | public Color color; 33 | public float width; 34 | 35 | public BlockColor(BlockPos pos, Color color, float width) { 36 | this.pos = pos; 37 | this.color = color; 38 | this.width = width; 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/me/bebeli555/autobot/mixin/mixins/MixinPlayerControllerMP.java: -------------------------------------------------------------------------------- 1 | package me.bebeli555.autobot.mixin.mixins; 2 | 3 | import org.spongepowered.asm.mixin.Mixin; 4 | import org.spongepowered.asm.mixin.injection.At; 5 | import org.spongepowered.asm.mixin.injection.Inject; 6 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; 7 | import org.spongepowered.asm.mixin.injection.callback.LocalCapture; 8 | 9 | import me.bebeli555.autobot.AutoBot; 10 | import me.bebeli555.autobot.events.PlayerDamageBlockEvent; 11 | import net.minecraft.client.multiplayer.PlayerControllerMP; 12 | import net.minecraft.util.EnumFacing; 13 | import net.minecraft.util.math.BlockPos; 14 | 15 | @Mixin(PlayerControllerMP.class) 16 | public class MixinPlayerControllerMP { 17 | 18 | @Inject(method = "clickBlock", at = @At(value = "HEAD"), locals = LocalCapture.CAPTURE_FAILSOFT, cancellable = true) 19 | private void onPlayerDamageBlock(BlockPos loc, EnumFacing face, CallbackInfoReturnable cir) { 20 | PlayerDamageBlockEvent event = new PlayerDamageBlockEvent(loc, face); 21 | AutoBot.EVENT_BUS.post(event); 22 | 23 | if (event.isCancelled()) { 24 | cir.cancel(); 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/me/bebeli555/autobot/mixin/MixinLoader.java: -------------------------------------------------------------------------------- 1 | package me.bebeli555.autobot.mixin; 2 | 3 | import java.util.Map; 4 | 5 | import javax.annotation.Nullable; 6 | 7 | import org.spongepowered.asm.launch.MixinBootstrap; 8 | import org.spongepowered.asm.mixin.MixinEnvironment; 9 | import org.spongepowered.asm.mixin.Mixins; 10 | 11 | import net.minecraftforge.fml.relauncher.IFMLLoadingPlugin; 12 | 13 | public class MixinLoader implements IFMLLoadingPlugin { 14 | public MixinLoader () { 15 | MixinBootstrap.init(); 16 | Mixins.addConfigurations("mixins.autobot.json", "mixins.baritone.json"); 17 | MixinEnvironment.getDefaultEnvironment().setObfuscationContext("searge"); 18 | } 19 | 20 | @Override 21 | public String[] getASMTransformerClass () { 22 | return new String[0]; 23 | } 24 | 25 | @Override 26 | public String getModContainerClass () { 27 | return null; 28 | } 29 | 30 | @Nullable 31 | @Override 32 | public String getSetupClass () { 33 | return null; 34 | } 35 | 36 | @Override 37 | public void injectData (Map data) { 38 | 39 | } 40 | 41 | @Override 42 | public String getAccessTransformerClass () { 43 | return null; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/me/bebeli555/autobot/gui/Keybind.java: -------------------------------------------------------------------------------- 1 | package me.bebeli555.autobot.gui; 2 | 3 | import java.util.HashMap; 4 | 5 | import org.lwjgl.input.Keyboard; 6 | 7 | import me.bebeli555.autobot.AutoBot; 8 | import me.bebeli555.autobot.Commands; 9 | import net.minecraftforge.common.MinecraftForge; 10 | import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; 11 | import net.minecraftforge.fml.common.gameevent.InputEvent.KeyInputEvent; 12 | 13 | public class Keybind extends AutoBot { 14 | public static HashMap keyBinds = new HashMap(); 15 | 16 | @SubscribeEvent 17 | public void onKeyPress(KeyInputEvent e) { 18 | if (!Keyboard.isKeyDown(Keyboard.getEventKey())) { 19 | return; 20 | } 21 | 22 | String id = keyBinds.get(Keyboard.getKeyName(Keyboard.getEventKey())); 23 | if (id != null) { 24 | if (!AutoBot.initDone) { 25 | sendMessage("Initialization isnt done yet. Try again", true); 26 | return; 27 | } 28 | 29 | if (id.equals("Keybind")) { 30 | Commands.openGui = true; 31 | MinecraftForge.EVENT_BUS.register(Gui.gui); 32 | } else { 33 | GuiNode node = Settings.getGuiNodeFromId(id.replace("Keybind", "")); 34 | node.click(); 35 | } 36 | } 37 | } 38 | 39 | //Sets the hashmap of keybinds so checking them will take less resources than looping all the nodes 40 | public static void setKeybinds() { 41 | keyBinds.clear(); 42 | 43 | for (GuiNode node : GuiNode.all) { 44 | if (node.isKeybind) { 45 | if (!node.stringValue.isEmpty()) { 46 | keyBinds.put(node.stringValue, node.id); 47 | } 48 | } 49 | } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/main/java/me/bebeli555/autobot/mixin/mixins/MixinNetworkManager.java: -------------------------------------------------------------------------------- 1 | package me.bebeli555.autobot.mixin.mixins; 2 | 3 | import org.spongepowered.asm.mixin.Mixin; 4 | import org.spongepowered.asm.mixin.injection.At; 5 | import org.spongepowered.asm.mixin.injection.Inject; 6 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; 7 | 8 | import io.netty.channel.ChannelHandlerContext; 9 | import me.bebeli555.autobot.AutoBot; 10 | import me.bebeli555.autobot.events.PacketEvent; 11 | import me.bebeli555.autobot.events.PacketPostEvent; 12 | import net.minecraft.network.NetworkManager; 13 | import net.minecraft.network.Packet; 14 | 15 | @Mixin(NetworkManager.class) 16 | public class MixinNetworkManager { 17 | 18 | @Inject(method = "sendPacket(Lnet/minecraft/network/Packet;)V", at = @At("HEAD"), cancellable = true) 19 | private void onPacketSend(Packet packet, CallbackInfo callbackInfo) { 20 | PacketEvent event = new PacketEvent(packet); 21 | AutoBot.EVENT_BUS.post(event); 22 | 23 | if (event.isCancelled()) { 24 | callbackInfo.cancel(); 25 | } 26 | } 27 | 28 | @Inject(method = "channelRead0", at = @At("HEAD"), cancellable = true) 29 | private void onChannelRead(ChannelHandlerContext context, Packet packet, CallbackInfo callbackInfo) { 30 | PacketEvent event = new PacketEvent(packet); 31 | AutoBot.EVENT_BUS.post(event); 32 | 33 | if (event.isCancelled()) { 34 | callbackInfo.cancel(); 35 | } 36 | } 37 | 38 | @Inject(method = "sendPacket(Lnet/minecraft/network/Packet;)V", at = @At("RETURN")) 39 | private void onPostSendPacket(Packet packet, CallbackInfo callbackInfo) { 40 | PacketPostEvent event = new PacketPostEvent(packet); 41 | AutoBot.EVENT_BUS.post(event); 42 | } 43 | 44 | @Inject(method = "channelRead0", at = @At("RETURN")) 45 | private void onPostChannelRead(ChannelHandlerContext context, Packet packet, CallbackInfo callbackInfo) { 46 | PacketPostEvent event = new PacketPostEvent(packet); 47 | AutoBot.EVENT_BUS.post(event); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/main/java/me/bebeli555/autobot/mods/bots/elytrabot/Direction.java: -------------------------------------------------------------------------------- 1 | package me.bebeli555.autobot.mods.bots.elytrabot; 2 | 3 | import net.minecraft.client.Minecraft; 4 | import net.minecraft.util.EnumFacing; 5 | 6 | /** 7 | * A list of directions including diagonal directions 8 | * P = Plus 9 | * M = Minus 10 | */ 11 | public enum Direction { 12 | XP("X-Plus"), 13 | XM("X-Minus"), 14 | ZP("Z-Plus"), 15 | ZM("Z-Minus"), 16 | XP_ZP("X-Plus, Z-Plus"), 17 | XM_ZP("X-Minus, Z-Plus"), 18 | XM_ZM("X-Minus, Z-Minus"), 19 | XP_ZM("X-Plus, Z-Minus"); 20 | 21 | public String name; 22 | Direction(String name) { 23 | this.name = name; 24 | } 25 | 26 | /** 27 | * Gets the direction the player is looking at 28 | */ 29 | public static Direction getDirection() { 30 | EnumFacing facing = Minecraft.getMinecraft().player.getHorizontalFacing(); 31 | return facing == EnumFacing.NORTH ? ZM : facing == EnumFacing.WEST ? XM : facing == EnumFacing.SOUTH ? ZP : XP; 32 | } 33 | 34 | /** 35 | * Gets the closest diagonal direction player is looking at 36 | */ 37 | public static Direction getDiagonalDirection() { 38 | EnumFacing facing = Minecraft.getMinecraft().player.getHorizontalFacing(); 39 | 40 | if (facing.equals(EnumFacing.NORTH)) { 41 | double closest = getClosest(135, -135); 42 | return closest == -135 ? XP_ZM : XM_ZM; 43 | } else if (facing.equals(EnumFacing.WEST)) { 44 | double closest = getClosest(135, 45); 45 | return closest == 135 ? XM_ZM : XM_ZP; 46 | } else if (facing.equals(EnumFacing.EAST)) { 47 | double closest = getClosest(-45, -135); 48 | return closest == -135 ? XP_ZM : XP_ZP; 49 | } else { 50 | double closest = getClosest(45, -45); 51 | return closest == 45 ? XM_ZP : XP_ZP; 52 | } 53 | } 54 | 55 | //Returns the closer given yaw to the real yaw from a and b 56 | private static double getClosest(double a, double b) { 57 | double yaw = Minecraft.getMinecraft().player.rotationYaw; 58 | yaw = yaw < -180 ? yaw += 360 : yaw > 180 ? yaw -= 360 : yaw; 59 | 60 | if (Math.abs(yaw - a) < Math.abs(yaw - b)) { 61 | return a; 62 | } else { 63 | return b; 64 | } 65 | } 66 | } -------------------------------------------------------------------------------- /src/main/java/me/bebeli555/autobot/mods/bots/crystalpvpbot/AutoTotem.java: -------------------------------------------------------------------------------- 1 | package me.bebeli555.autobot.mods.bots.crystalpvpbot; 2 | 3 | import me.bebeli555.autobot.AutoBot; 4 | import me.bebeli555.autobot.events.PlayerMoveEvent; 5 | import me.bebeli555.autobot.utils.InventoryUtil; 6 | import me.zero.alpine.listener.EventHandler; 7 | import me.zero.alpine.listener.Listener; 8 | import net.minecraft.init.Items; 9 | import net.minecraftforge.common.MinecraftForge; 10 | import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; 11 | import net.minecraftforge.fml.common.gameevent.TickEvent.ClientTickEvent; 12 | 13 | public class AutoTotem extends AutoBot { 14 | private static AutoTotem autoTotem = new AutoTotem(); 15 | 16 | /** 17 | * Toggle off or on. It will stay on until toggled off 18 | */ 19 | public static void toggle(boolean on) { 20 | if (on) { 21 | MinecraftForge.EVENT_BUS.register(autoTotem); 22 | } else { 23 | MinecraftForge.EVENT_BUS.unregister(autoTotem); 24 | } 25 | } 26 | 27 | @SubscribeEvent 28 | public void onTick(ClientTickEvent e) { 29 | if (mc.player == null) { 30 | return; 31 | } 32 | 33 | if (mc.player.getHeldItemOffhand().getItem() != Items.TOTEM_OF_UNDYING && InventoryUtil.hasItem(Items.TOTEM_OF_UNDYING)) { 34 | if (CrystalPvPBot.autoTotemDontMove.booleanValue()) { 35 | NoMovement.toggle(true); 36 | } 37 | 38 | InventoryUtil.clickSlot(InventoryUtil.getSlot(Items.TOTEM_OF_UNDYING)); 39 | InventoryUtil.clickSlot(45); 40 | } else { 41 | NoMovement.toggle(false); 42 | } 43 | } 44 | 45 | /** 46 | * Cancels all movement 47 | */ 48 | public static class NoMovement { 49 | private static NoMovement noMovement = new NoMovement(); 50 | 51 | /** 52 | * When toggled on it will not allow movement until toggled off. 53 | */ 54 | public static void toggle(boolean on) { 55 | if (on) { 56 | AutoBot.EVENT_BUS.subscribe(noMovement); 57 | } else { 58 | AutoBot.EVENT_BUS.unsubscribe(noMovement); 59 | } 60 | } 61 | 62 | @EventHandler 63 | private Listener moveEvent = new Listener<>(event -> { 64 | event.cancel(); 65 | }); 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /src/main/java/me/bebeli555/autobot/mods/bots/crystalpvpbot/DisableKnockback.java: -------------------------------------------------------------------------------- 1 | package me.bebeli555.autobot.mods.bots.crystalpvpbot; 2 | 3 | import me.bebeli555.autobot.AutoBot; 4 | import me.bebeli555.autobot.events.EntityPushEvent; 5 | import me.bebeli555.autobot.events.PacketEvent; 6 | import me.zero.alpine.listener.EventHandler; 7 | import me.zero.alpine.listener.Listener; 8 | import net.minecraft.entity.Entity; 9 | import net.minecraft.entity.projectile.EntityFishHook; 10 | import net.minecraft.network.play.server.SPacketEntityStatus; 11 | import net.minecraft.network.play.server.SPacketEntityVelocity; 12 | import net.minecraft.network.play.server.SPacketExplosion; 13 | 14 | public class DisableKnockback extends AutoBot { 15 | private static DisableKnockback disableKnockback = new DisableKnockback(); 16 | 17 | /** 18 | * Toggles it on or off. If on then knockback will be disabled until u toggle it off 19 | */ 20 | public static void toggle(boolean on) { 21 | if (on) { 22 | EVENT_BUS.subscribe(disableKnockback); 23 | } else { 24 | EVENT_BUS.unsubscribe(disableKnockback); 25 | } 26 | } 27 | 28 | @EventHandler 29 | private Listener entityPushEvent = new Listener<>(event -> { 30 | event.cancel(); 31 | }); 32 | 33 | @EventHandler 34 | private Listener packetEvent = new Listener<>(event -> { 35 | if (event.packet instanceof SPacketEntityStatus) { 36 | SPacketEntityStatus packet = (SPacketEntityStatus)event.packet; 37 | 38 | if (packet.getOpCode() == 31) { 39 | Entity entity = packet.getEntity(mc.world); 40 | 41 | if (entity != null && entity instanceof EntityFishHook) { 42 | EntityFishHook fishHook = (EntityFishHook) entity; 43 | 44 | if (fishHook.caughtEntity == mc.player) { 45 | event.cancel(); 46 | } 47 | } 48 | } 49 | } else if (event.packet instanceof SPacketEntityVelocity || event.packet instanceof SPacketExplosion) { 50 | event.cancel(); 51 | } 52 | }); 53 | } 54 | -------------------------------------------------------------------------------- /src/main/java/me/bebeli555/autobot/utils/EatingUtil.java: -------------------------------------------------------------------------------- 1 | package me.bebeli555.autobot.utils; 2 | 3 | import me.bebeli555.autobot.AutoBot; 4 | import net.minecraft.client.settings.KeyBinding; 5 | import net.minecraft.item.Item; 6 | import net.minecraft.util.EnumHand; 7 | import net.minecraftforge.event.entity.living.LivingEntityUseItemEvent; 8 | import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; 9 | 10 | public class EatingUtil extends AutoBot { 11 | private static boolean eating; 12 | private static long eatingMs; 13 | 14 | //Eats the given item if u have it 15 | public static boolean eatItem(Item item, boolean sleepUntilDone) { 16 | if (!InventoryUtil.hasItem(item)) { 17 | return false; 18 | } 19 | 20 | InventoryUtil.switchItem(InventoryUtil.getSlot(item), false); 21 | 22 | if (mc.player.inventory.getCurrentItem().getItem() == item) { 23 | if (mc.currentScreen != null) { 24 | mc.playerController.processRightClick(mc.player, mc.world, EnumHand.MAIN_HAND); 25 | } else { 26 | KeyBinding.setKeyBindState(mc.gameSettings.keyBindUseItem.getKeyCode(), true); 27 | } 28 | eating = true; 29 | 30 | //Set eating to false after a timeout in case the event never got called 31 | if (!sleepUntilDone) { 32 | new Thread() { 33 | public void run() { 34 | eatingMs = System.currentTimeMillis(); 35 | long check = eatingMs; 36 | 37 | sleepUntil(() -> !eating, 5000); 38 | if (eatingMs == check) { 39 | eating = false; 40 | } 41 | } 42 | }.start(); 43 | } 44 | 45 | //Sleep this thread if the sleepUntilDone is true 46 | else { 47 | sleepUntil(() -> !eating, 5000); 48 | eating = false; 49 | } 50 | 51 | return true; 52 | } else { 53 | return false; 54 | } 55 | } 56 | 57 | public static boolean isEating() { 58 | return eating; 59 | } 60 | 61 | //Stop pressing key when ate food 62 | @SubscribeEvent 63 | public void finishedEating(LivingEntityUseItemEvent.Finish e) { 64 | if (eating) { 65 | KeyBinding.setKeyBindState(mc.gameSettings.keyBindUseItem.getKeyCode(), false); 66 | eating = false; 67 | } 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /src/main/java/me/bebeli555/autobot/mixin/mixins/MixinEntityPlayer.java: -------------------------------------------------------------------------------- 1 | package me.bebeli555.autobot.mixin.mixins; 2 | 3 | import org.spongepowered.asm.mixin.Mixin; 4 | import org.spongepowered.asm.mixin.injection.At; 5 | import org.spongepowered.asm.mixin.injection.Inject; 6 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; 7 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; 8 | 9 | import me.bebeli555.autobot.AutoBot; 10 | import me.bebeli555.autobot.events.EntityPushEvent; 11 | import me.bebeli555.autobot.events.TravelEvent; 12 | import net.minecraft.entity.Entity; 13 | import net.minecraft.entity.EntityLivingBase; 14 | import net.minecraft.entity.MoverType; 15 | import net.minecraft.entity.player.EntityPlayer; 16 | import net.minecraft.world.World; 17 | 18 | @Mixin(EntityPlayer.class) 19 | public abstract class MixinEntityPlayer extends EntityLivingBase { 20 | 21 | public MixinEntityPlayer(World worldIn) { 22 | super(worldIn); 23 | } 24 | 25 | @Inject(method = "applyEntityCollision", at = @At("HEAD"), cancellable = true) 26 | public void applyEntityCollision(Entity entity, CallbackInfo callbackInfo) { 27 | EntityPushEvent event = new EntityPushEvent(entity); 28 | AutoBot.EVENT_BUS.post(event); 29 | 30 | if (event.isCancelled()) { 31 | callbackInfo.cancel(); 32 | } 33 | } 34 | 35 | @Inject(method = "isPushedByWater()Z", at = @At("HEAD"), cancellable = true) 36 | public void isPushedByWater(CallbackInfoReturnable callbackInfo) { 37 | EntityPushEvent event = new EntityPushEvent(null); 38 | AutoBot.EVENT_BUS.post(event); 39 | 40 | if (event.isCancelled()) { 41 | callbackInfo.cancel(); 42 | } 43 | } 44 | 45 | @Inject(method = "travel", at = @At("HEAD"), cancellable = true) 46 | public void travel(float strafe, float vertical, float forward, CallbackInfo callbackInfo) { 47 | TravelEvent event = new TravelEvent(); 48 | AutoBot.EVENT_BUS.post(event); 49 | 50 | if (event.isCancelled()) { 51 | move(MoverType.SELF, motionX, motionY, motionZ); 52 | callbackInfo.cancel(); 53 | } 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /src/main/java/me/bebeli555/autobot/gui/GuiSettings.java: -------------------------------------------------------------------------------- 1 | package me.bebeli555.autobot.gui; 2 | 3 | import me.bebeli555.autobot.AutoBot; 4 | 5 | public class GuiSettings extends AutoBot { 6 | public GuiSettings() { 7 | super(Group.GUI); 8 | } 9 | 10 | public static Setting guiSettings = new Setting(Mode.LABEL, "GuiSettings", true, "Settings about the GUI design"); 11 | public static Setting width = new Setting(guiSettings, Mode.INTEGER, "Width", 110, "Gui node width"); 12 | public static Setting height = new Setting(guiSettings, Mode.INTEGER, "Height", 18, "Gui node height"); 13 | public static Setting borderColor = new Setting(guiSettings, Mode.TEXT, "Border color", "0xFF32a86d", "Color of the border in hex and with 0xAA"); 14 | public static Setting borderSize = new Setting(guiSettings, Mode.INTEGER, "Border size", 1, "The size of the border in the node"); 15 | public static Setting backgroundColor = new Setting(guiSettings, Mode.TEXT, "Color", "0x36325bc2", "The background color"); 16 | public static Setting textColor = new Setting(guiSettings, Mode.TEXT, "Text Color", "0xFF00ff00", "Text color when module is toggled on"); 17 | public static Setting textColorOff = new Setting(guiSettings, Mode.TEXT, "Text Color Off", "0xFFff0000", "Text color when module is toggled off"); 18 | public static Setting labelColor = new Setting(guiSettings, Mode.TEXT, "Label color", "0xFF6b6b6b", "The color of the label text which is an toggleable module"); 19 | public static Setting extendMove = new Setting(guiSettings, Mode.INTEGER, "Extend Move", 8, "How much to move in x coordinates when parent is extended"); 20 | public static Setting groupTextColor = new Setting(guiSettings, Mode.TEXT, "Group color", "0xFFe3a520", "The text color of the group"); 21 | public static Setting groupScale = new Setting(guiSettings, Mode.DOUBLE, "Group scale", 1.25, "The group text scale"); 22 | public static Setting groupBackground = new Setting(guiSettings, Mode.TEXT, "Group background", "0x3650b57c", "The group background color"); 23 | public static Setting scrollAmount = new Setting(guiSettings, Mode.INTEGER, "ScrollAmount", 35, "How many things to scroll with one wheel scroll"); 24 | public static Setting scrollSave = new Setting(guiSettings, Mode.BOOLEAN, "ScrollSave", false, "Doesnt reset mouse scrolled position if true"); 25 | } -------------------------------------------------------------------------------- /src/main/java/me/bebeli555/autobot/mods/other/AutoTrapIndicator.java: -------------------------------------------------------------------------------- 1 | package me.bebeli555.autobot.mods.other; 2 | 3 | import java.awt.Color; 4 | 5 | import me.bebeli555.autobot.AutoBot; 6 | import me.bebeli555.autobot.gui.Group; 7 | import me.bebeli555.autobot.gui.Mode; 8 | import me.bebeli555.autobot.gui.Setting; 9 | import me.bebeli555.autobot.rendering.RenderBlock.BlockColor; 10 | import me.bebeli555.autobot.rendering.Renderer; 11 | import me.bebeli555.autobot.utils.BlockUtil; 12 | import me.bebeli555.autobot.utils.PlayerUtil; 13 | import net.minecraft.entity.player.EntityPlayer; 14 | import net.minecraft.util.math.BlockPos; 15 | import net.minecraftforge.common.MinecraftForge; 16 | import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; 17 | import net.minecraftforge.fml.common.gameevent.TickEvent.ClientTickEvent; 18 | 19 | public class AutoTrapIndicator extends AutoBot { 20 | public static Setting lineWidth = new Setting(Mode.INTEGER, "LineWidth", 2, "How thicc the rendered rectangles lines are"); 21 | public static Setting radius = new Setting(Mode.INTEGER, "Radius", 30, "The max distance players can be", "For this to work on them"); 22 | 23 | public AutoTrapIndicator() { 24 | super(Group.OTHER, "AutoTrapIndicator", "Indicates if players are standing", "In the middle of the block so they can be trapped", "It draws a red rectangle below them"); 25 | } 26 | 27 | @Override 28 | public void onEnabled() { 29 | MinecraftForge.EVENT_BUS.register(this); 30 | } 31 | 32 | @Override 33 | public void onDisabled() { 34 | MinecraftForge.EVENT_BUS.unregister(this); 35 | Renderer.rectangles.clear(); 36 | } 37 | 38 | @SubscribeEvent 39 | public void onTick(ClientTickEvent e) { 40 | Renderer.rectangles.clear(); 41 | 42 | outer: for (EntityPlayer player : PlayerUtil.getAll()) { 43 | if (mc.player.getDistance(player) > radius.intValue()) { 44 | continue; 45 | } 46 | 47 | BlockPos p = new BlockPos(player.posX, player.posY, player.posZ); 48 | for (BlockPos pos : new BlockPos[]{p.add(1, 0, 0), p.add(-1, 0, 0), p.add(0, 0, 1), p.add(0, 0, -1)}) { 49 | if (!BlockUtil.canPlaceBlock(pos) && !isSolid(pos)) { 50 | continue outer; 51 | } 52 | } 53 | 54 | Renderer.rectangles.add(new BlockColor(p.add(0, -1, 0), Color.RED, lineWidth.intValue())); 55 | } 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /src/main/java/me/bebeli555/autobot/mixin/mixins/MixinEntityPlayerSP.java: -------------------------------------------------------------------------------- 1 | package me.bebeli555.autobot.mixin.mixins; 2 | 3 | import org.spongepowered.asm.mixin.Mixin; 4 | import org.spongepowered.asm.mixin.injection.At; 5 | import org.spongepowered.asm.mixin.injection.Inject; 6 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; 7 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; 8 | 9 | import me.bebeli555.autobot.AutoBot; 10 | import me.bebeli555.autobot.events.EntityPushEvent; 11 | import me.bebeli555.autobot.events.PlayerMotionUpdateEvent; 12 | import me.bebeli555.autobot.events.PlayerMoveEvent; 13 | import me.bebeli555.autobot.events.PlayerUpdateEvent; 14 | import net.minecraft.client.entity.EntityPlayerSP; 15 | import net.minecraft.entity.MoverType; 16 | 17 | @Mixin(EntityPlayerSP.class) 18 | public class MixinEntityPlayerSP { 19 | @Inject(method = "pushOutOfBlocks(DDD)Z", at = @At("HEAD"), cancellable = true) 20 | public void pushOutOfBlocks(double x, double y, double z, CallbackInfoReturnable callbackInfo) { 21 | EntityPushEvent event = new EntityPushEvent(null); 22 | AutoBot.EVENT_BUS.post(event); 23 | 24 | if (event.isCancelled()) { 25 | callbackInfo.cancel(); 26 | } 27 | } 28 | 29 | @Inject(method = "move", at = @At("HEAD"), cancellable = true) 30 | public void move(MoverType type, double x, double y, double z, CallbackInfo callbackInfo) { 31 | PlayerMoveEvent event = new PlayerMoveEvent(type, x, y, z); 32 | AutoBot.EVENT_BUS.post(event); 33 | 34 | if (event.isCancelled()) { 35 | callbackInfo.cancel(); 36 | } 37 | } 38 | 39 | @Inject(method = "onUpdateWalkingPlayer", at = @At("HEAD"), cancellable = true) 40 | public void motionUpdate(CallbackInfo callbackInfo) { 41 | PlayerMotionUpdateEvent event = new PlayerMotionUpdateEvent(); 42 | AutoBot.EVENT_BUS.post(event); 43 | 44 | if (event.isCancelled()) { 45 | callbackInfo.cancel(); 46 | } 47 | } 48 | 49 | @Inject(method = "onUpdate", at = @At("HEAD"), cancellable = true) 50 | public void onUpdate(CallbackInfo callbackInfo) { 51 | PlayerUpdateEvent event = new PlayerUpdateEvent(); 52 | AutoBot.EVENT_BUS.post(event); 53 | 54 | if (event.isCancelled()) { 55 | callbackInfo.cancel(); 56 | } 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /src/main/java/me/bebeli555/autobot/mods/other/AutoWeb.java: -------------------------------------------------------------------------------- 1 | package me.bebeli555.autobot.mods.other; 2 | 3 | import me.bebeli555.autobot.AutoBot; 4 | import me.bebeli555.autobot.gui.Group; 5 | import me.bebeli555.autobot.gui.Mode; 6 | import me.bebeli555.autobot.gui.Setting; 7 | import me.bebeli555.autobot.utils.BlockUtil; 8 | import me.bebeli555.autobot.utils.InventoryUtil; 9 | import me.bebeli555.autobot.utils.PlayerUtil; 10 | import me.bebeli555.autobot.utils.RotationUtil; 11 | import net.minecraft.entity.player.EntityPlayer; 12 | import net.minecraft.init.Blocks; 13 | import net.minecraftforge.common.MinecraftForge; 14 | import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; 15 | import net.minecraftforge.fml.common.gameevent.TickEvent.ClientTickEvent; 16 | 17 | public class AutoWeb extends AutoBot { 18 | public static Setting toggle = new Setting(Mode.BOOLEAN, "Toggle", false, "Toggle the module off after the place"); 19 | public static Setting autoDetect = new Setting(Mode.BOOLEAN, "AutoDetect", false, "Detects when a nearby player is trying", "To enter your hole and then places the web"); 20 | 21 | public AutoWeb() { 22 | super(Group.OTHER, "AutoWeb", "Places a web inside you"); 23 | } 24 | 25 | @Override 26 | public void onEnabled() { 27 | MinecraftForge.EVENT_BUS.register(this); 28 | } 29 | 30 | @Override 31 | public void onDisabled() { 32 | MinecraftForge.EVENT_BUS.unregister(this); 33 | RotationUtil.stopRotating(); 34 | } 35 | 36 | @SubscribeEvent 37 | public void onTick(ClientTickEvent e) { 38 | if (mc.player == null || getBlock(getPlayerPos()) == Blocks.WEB) { 39 | return; 40 | } 41 | 42 | if (!InventoryUtil.hasBlock(Blocks.WEB)) { 43 | sendMessage("You have no webs", true); 44 | toggleModule(); 45 | return; 46 | } 47 | 48 | //Return if autoDetect is true and the player is not trying to enter the hole 49 | if (autoDetect.booleanValue()) { 50 | EntityPlayer player = PlayerUtil.getClosest(); 51 | 52 | if (player == null || player.posY - mc.player.posY < 0.25 || Math.abs(mc.player.posX - player.posX) > 2 || Math.abs(mc.player.posZ - player.posZ) > 2) { 53 | return; 54 | } 55 | } 56 | 57 | //Place web 58 | BlockUtil.placeBlockOnThisThread(Blocks.WEB, getPlayerPos(), true); 59 | RotationUtil.stopRotating(); 60 | 61 | //Toggle off if toggle is true 62 | if (toggle.booleanValue()) { 63 | toggleModule(); 64 | } 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | set DIRNAME=%~dp0 12 | if "%DIRNAME%" == "" set DIRNAME=. 13 | set APP_BASE_NAME=%~n0 14 | set APP_HOME=%DIRNAME% 15 | 16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 17 | set DEFAULT_JVM_OPTS= 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windows variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | 53 | :win9xME_args 54 | @rem Slurp the command line arguments. 55 | set CMD_LINE_ARGS= 56 | set _SKIP=2 57 | 58 | :win9xME_args_slurp 59 | if "x%~1" == "x" goto execute 60 | 61 | set CMD_LINE_ARGS=%* 62 | 63 | :execute 64 | @rem Setup the command line 65 | 66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 67 | 68 | @rem Execute Gradle 69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 70 | 71 | :end 72 | @rem End local scope for the variables with windows NT shell 73 | if "%ERRORLEVEL%"=="0" goto mainEnd 74 | 75 | :fail 76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 77 | rem the _cmd.exe /c_ return code! 78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 79 | exit /b 1 80 | 81 | :mainEnd 82 | if "%OS%"=="Windows_NT" endlocal 83 | 84 | :omega 85 | -------------------------------------------------------------------------------- /src/main/java/me/bebeli555/autobot/mods/other/AutoFirework.java: -------------------------------------------------------------------------------- 1 | package me.bebeli555.autobot.mods.other; 2 | 3 | import me.bebeli555.autobot.AutoBot; 4 | import me.bebeli555.autobot.gui.Group; 5 | import me.bebeli555.autobot.gui.Mode; 6 | import me.bebeli555.autobot.gui.Setting; 7 | import me.bebeli555.autobot.utils.InventoryUtil; 8 | import me.bebeli555.autobot.utils.PlayerUtil; 9 | import net.minecraft.init.Items; 10 | import net.minecraft.util.EnumHand; 11 | 12 | public class AutoFirework extends AutoBot { 13 | private static Thread thread, thread2; 14 | private static boolean lagback; 15 | private static int lagbackCounter; 16 | 17 | public static Setting delay = new Setting(Mode.DOUBLE, "Delay", 2.8, "The delay between clicks on the firework", "In seconds"); 18 | public static Setting antiLagback = new Setting(Mode.BOOLEAN, "AntiLagback", true, "Doesnt click on a firework if ur lagbacking on 2b2t"); 19 | 20 | public AutoFirework() { 21 | super(Group.OTHER, "AutoFirework", "Clicks on fireworks for you when flying with elytra"); 22 | } 23 | 24 | @Override 25 | public void onEnabled() { 26 | thread = new Thread() { 27 | public void run() { 28 | while(thread != null && thread.equals(this)) { 29 | loop(); 30 | 31 | AutoBot.sleep(50); 32 | } 33 | } 34 | }; 35 | thread.start(); 36 | 37 | thread2 = new Thread() { 38 | public void run() { 39 | while (thread2 != null && thread2.equals(this)) { 40 | if (mc.player != null) { 41 | double speed = PlayerUtil.getSpeed(mc.player); 42 | if (speed > 4) { 43 | lagback = true; 44 | } 45 | 46 | if (lagback) { 47 | if (speed < 1) { 48 | lagbackCounter++; 49 | if (lagbackCounter > 4) { 50 | lagback = false; 51 | lagbackCounter = 0; 52 | } 53 | } else { 54 | lagbackCounter = 0; 55 | } 56 | } 57 | } 58 | 59 | AutoBot.sleep(50); 60 | } 61 | } 62 | }; 63 | thread2.start(); 64 | } 65 | 66 | @Override 67 | public void onDisabled() { 68 | thread = null; 69 | thread2 = null; 70 | } 71 | 72 | public void loop() { 73 | if (mc.player == null || !mc.player.isElytraFlying()) { 74 | return; 75 | } 76 | 77 | if (!InventoryUtil.hasItem(Items.FIREWORKS)) { 78 | sendMessage("You have no fireworks in inventory", true); 79 | toggleModule(); 80 | return; 81 | } 82 | 83 | //Put the best firework to hand 84 | if (mc.player.getHeldItemMainhand().getItem() != Items.FIREWORKS) { 85 | InventoryUtil.switchItem(InventoryUtil.getSlot(Items.FIREWORKS), false); 86 | } 87 | 88 | //Click 89 | if (!lagback) { 90 | mc.playerController.processRightClick(mc.player, mc.world, EnumHand.MAIN_HAND); 91 | sleepUntil(() -> !mc.player.isElytraFlying(), (int)(delay.doubleValue() * 1000)); 92 | } 93 | } 94 | } 95 | -------------------------------------------------------------------------------- /src/main/java/me/bebeli555/autobot/mods/other/CrystalBlock.java: -------------------------------------------------------------------------------- 1 | package me.bebeli555.autobot.mods.other; 2 | 3 | import me.bebeli555.autobot.AutoBot; 4 | import me.bebeli555.autobot.gui.Group; 5 | import me.bebeli555.autobot.gui.Mode; 6 | import me.bebeli555.autobot.gui.Setting; 7 | import me.bebeli555.autobot.utils.BlockUtil; 8 | import me.bebeli555.autobot.utils.CrystalUtil; 9 | import me.bebeli555.autobot.utils.InventoryUtil; 10 | import me.bebeli555.autobot.utils.RotationUtil; 11 | import net.minecraft.block.state.IBlockState; 12 | import net.minecraft.entity.item.EntityEnderCrystal; 13 | import net.minecraft.init.Blocks; 14 | import net.minecraft.util.math.BlockPos; 15 | 16 | public class CrystalBlock extends AutoBot { 17 | public static Setting range = new Setting(Mode.INTEGER, "Range", 4, "Range around player to search for", "Spots to place the obby on"); 18 | 19 | public CrystalBlock() { 20 | super(Group.OTHER, "CrystalBlock", true, "Places obsidian to the best spot between", "You and the end crystal to block damage"); 21 | } 22 | 23 | @Override 24 | public void onEnabled() { 25 | //No obsidian 26 | if (!InventoryUtil.hasBlock(Blocks.OBSIDIAN)) { 27 | sendMessage("You need obsidian", true); 28 | toggleModule(); 29 | return; 30 | } 31 | 32 | //Find end crystal thats going to deal the most damage to us 33 | EntityEnderCrystal best = null; 34 | double mostDamage = Integer.MIN_VALUE; 35 | for (EntityEnderCrystal crystal : CrystalUtil.getCrystals(10)) { 36 | double damage = CrystalUtil.calculateDamage(crystal.getPositionVector(), mc.player); 37 | 38 | if (damage > 0 && damage > mostDamage) { 39 | mostDamage = damage; 40 | best = crystal; 41 | } 42 | } 43 | 44 | if (best == null) { 45 | sendMessage("Found no nearby crystals to block", true); 46 | toggleModule(); 47 | return; 48 | } 49 | 50 | //Find best spot to place block on to block damage 51 | BlockPos bestPlace = null; 52 | double lowestDamage = Integer.MAX_VALUE; 53 | for (BlockPos pos : BlockUtil.getAll(range.intValue())) { 54 | if (BlockUtil.canPlaceBlock(pos)) { 55 | IBlockState old = mc.world.getBlockState(pos); 56 | mc.world.setBlockState(pos, Blocks.OBSIDIAN.getDefaultState()); 57 | double damage = CrystalUtil.calculateDamage(best.getPositionVector(), mc.player); 58 | mc.world.setBlockState(pos, old); 59 | 60 | if (damage < lowestDamage) { 61 | lowestDamage = damage; 62 | bestPlace = pos; 63 | } 64 | } 65 | } 66 | 67 | if (bestPlace == null) { 68 | sendMessage("Found no spot to place block on to block dmg", true); 69 | toggleModule(); 70 | return; 71 | } 72 | 73 | //Place block 74 | BlockUtil.placeBlockOnThisThread(Blocks.OBSIDIAN, bestPlace, true); 75 | toggleModule(); 76 | } 77 | 78 | @Override 79 | public void onDisabled() { 80 | RotationUtil.stopRotating(); 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /src/main/java/me/bebeli555/autobot/mods/other/AutoEnderChestMiner.java: -------------------------------------------------------------------------------- 1 | package me.bebeli555.autobot.mods.other; 2 | 3 | import me.bebeli555.autobot.AutoBot; 4 | import me.bebeli555.autobot.gui.Group; 5 | import me.bebeli555.autobot.gui.Mode; 6 | import me.bebeli555.autobot.gui.Setting; 7 | import me.bebeli555.autobot.mods.bots.crystalpvpbot.Surround; 8 | import me.bebeli555.autobot.utils.BlockUtil; 9 | import me.bebeli555.autobot.utils.InventoryUtil; 10 | import me.bebeli555.autobot.utils.MiningUtil; 11 | import net.minecraft.init.Blocks; 12 | import net.minecraft.util.math.BlockPos; 13 | 14 | public class AutoEnderChestMiner extends AutoBot { 15 | private static Thread thread; 16 | 17 | public static Setting delay = new Setting(Mode.INTEGER, "Delay", 350, "Amount to wait after a place/break in milliseconds"); 18 | 19 | public AutoEnderChestMiner() { 20 | super(Group.OTHER, "AutoEnderChestMiner", "Places and mines enderchests for obsidian"); 21 | } 22 | 23 | @Override 24 | public void onEnabled() { 25 | thread = new Thread() { 26 | public void run() { 27 | while(thread != null && thread.equals(this)) { 28 | loop(); 29 | 30 | AutoBot.sleep(50); 31 | } 32 | } 33 | }; 34 | 35 | thread.start(); 36 | } 37 | 38 | @Override 39 | public void onDisabled() { 40 | AutoBot.EVENT_BUS.unsubscribe(MiningUtil.miningUtil); 41 | clearStatus(); 42 | thread = null; 43 | } 44 | 45 | public void loop() { 46 | if (mc.player == null) { 47 | return; 48 | } 49 | 50 | BlockPos[] placements = new BlockPos[] {new BlockPos(1, 0, 0), new BlockPos(-1, 0, 0), new BlockPos(0, 0, 1), new BlockPos(0, 0, -1), 51 | new BlockPos(1, 1, 0), new BlockPos(-1, 1, 0), new BlockPos(0, 1, 1), new BlockPos(0, 1, -1)}; 52 | BlockPos availableSpot = null; 53 | for (BlockPos pos : placements) { 54 | pos = getPlayerPos().add(pos.getX(), pos.getY(), pos.getZ()); 55 | 56 | if (getBlock(pos) == Blocks.ENDER_CHEST) { 57 | setStatus("Mining Enderchest"); 58 | MiningUtil.mine(pos, true); 59 | sleep(delay.intValue()); 60 | return; 61 | } else if (BlockUtil.canPlaceBlock(pos) && isSolid(pos.add(0, -1, 0))) { 62 | availableSpot = pos; 63 | break; 64 | } 65 | } 66 | 67 | if (!InventoryUtil.hasBlock(Blocks.ENDER_CHEST)) { 68 | sendMessage("You dont have any enderchests in your inventory", true); 69 | toggleModule(); 70 | return; 71 | } else if (mc.player.posY > 255) { 72 | sendMessage("Cant place enderchests on the build limit", true); 73 | toggleModule(); 74 | return; 75 | } 76 | 77 | if (availableSpot != null) { 78 | setStatus("Placing Enderchest"); 79 | Surround.center(); 80 | BlockUtil.placeBlock(Blocks.ENDER_CHEST, availableSpot, true); 81 | sleep(delay.intValue()); 82 | } else { 83 | sendMessage("No spot found to place an enderchest nearby", true); 84 | toggleModule(); 85 | } 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /src/main/java/me/bebeli555/autobot/mods/bots/crystalpvpbot/Surround.java: -------------------------------------------------------------------------------- 1 | package me.bebeli555.autobot.mods.bots.crystalpvpbot; 2 | 3 | import me.bebeli555.autobot.AutoBot; 4 | import me.bebeli555.autobot.utils.BaritoneUtil; 5 | import me.bebeli555.autobot.utils.BlockUtil; 6 | import me.bebeli555.autobot.utils.InventoryUtil; 7 | import net.minecraft.init.Blocks; 8 | import net.minecraft.util.math.BlockPos; 9 | 10 | public class Surround extends AutoBot { 11 | private static long lastToggled; 12 | 13 | /** 14 | * Centers the player then builds the surround thing and returns 15 | */ 16 | public static void toggle() { 17 | if (BaritoneUtil.isPathing() || !InventoryUtil.hasBlock(Blocks.OBSIDIAN) || isSurrounded(getPlayerPos())) { 18 | return; 19 | } 20 | 21 | //Only allow toggles every 0.5 seconds 22 | if (System.currentTimeMillis() / 500 == lastToggled) { 23 | return; 24 | } 25 | lastToggled = System.currentTimeMillis() / 500; 26 | 27 | setStatus("Using surround", "CrystalPvPBot"); 28 | center(); 29 | 30 | //Build 31 | for (BlockPos position : getBlocksToPlace()) { 32 | if (BlockUtil.placeBlock(Blocks.OBSIDIAN, position, false)) { 33 | sleep(CrystalPvPBot.surroundDelay.intValue()); 34 | } 35 | } 36 | } 37 | 38 | /** 39 | * Centers the player 40 | */ 41 | public static void center() { 42 | if (isCentered()) { 43 | return; 44 | } 45 | 46 | double[] centerPos = {Math.floor(mc.player.posX) + 0.5, Math.floor(mc.player.posY), Math.floor(mc.player.posZ) + 0.5}; 47 | 48 | mc.player.motionX = (centerPos[0] - mc.player.posX) / 2; 49 | mc.player.motionZ = (centerPos[2] - mc.player.posZ) / 2; 50 | 51 | sleepUntil(() -> Math.abs(centerPos[0] - mc.player.posX) <= 0.1 && Math.abs(centerPos[2] - mc.player.posZ) <= 0.1, 1000); 52 | mc.player.motionX = 0; 53 | mc.player.motionZ = 0; 54 | } 55 | 56 | /** 57 | * Checks if the player is centered on the block 58 | */ 59 | public static boolean isCentered() { 60 | double[] centerPos = {Math.floor(mc.player.posX) + 0.5, Math.floor(mc.player.posY), Math.floor(mc.player.posZ) + 0.5}; 61 | return Math.abs(centerPos[0] - mc.player.posX) <= 0.1 && Math.abs(centerPos[2] - mc.player.posZ) <= 0.1; 62 | } 63 | 64 | /** 65 | * Checks if the given BlockPos is surrounded with obby or bedrock 66 | */ 67 | public static boolean isSurrounded(BlockPos p) { 68 | BlockPos[] positions = {p.add(1, 0, 0), p.add(-1, 0, 0), p.add(0, 0, 1), p.add(0, 0, -1)}; 69 | 70 | for (BlockPos pos : positions) { 71 | if (getBlock(pos) != Blocks.OBSIDIAN && getBlock(pos) != Blocks.BEDROCK) { 72 | return false; 73 | } 74 | } 75 | 76 | return true; 77 | } 78 | 79 | /** 80 | * Get the blockpositions where to place obby 81 | */ 82 | public static BlockPos[] getBlocksToPlace() { 83 | BlockPos p = getPlayerPos(); 84 | return new BlockPos[]{p.add(1, -1, 0), p.add(-1, -1, 0), p.add(0, -1, 1), p.add(0, -1, -1), p.add(1, 0, 0), p.add(-1, 0, 0), p.add(0, 0, 1), p.add(0, 0, -1)}; 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /src/main/java/me/bebeli555/autobot/mods/bots/elytrabot/PacketFly.java: -------------------------------------------------------------------------------- 1 | package me.bebeli555.autobot.mods.bots.elytrabot; 2 | 3 | import me.bebeli555.autobot.AutoBot; 4 | import me.bebeli555.autobot.events.PacketEvent; 5 | import me.bebeli555.autobot.events.PlayerMotionUpdateEvent; 6 | import me.bebeli555.autobot.utils.Timer; 7 | import me.zero.alpine.listener.EventHandler; 8 | import me.zero.alpine.listener.Listener; 9 | import net.minecraft.network.play.client.CPacketConfirmTeleport; 10 | import net.minecraft.network.play.client.CPacketPlayer; 11 | import net.minecraft.network.play.server.SPacketPlayerPosLook; 12 | 13 | public class PacketFly extends AutoBot { 14 | private static PacketFly packetFly = new PacketFly(); 15 | private static Timer antiKickTimer = new Timer(); 16 | private static double startY; 17 | public static boolean toggled; 18 | 19 | public static void toggle(boolean on) { 20 | toggled = on; 21 | 22 | if (on) { 23 | startY = mc.player.posY; 24 | AutoBot.EVENT_BUS.subscribe(packetFly); 25 | } else { 26 | AutoBot.EVENT_BUS.unsubscribe(packetFly); 27 | } 28 | } 29 | 30 | @EventHandler 31 | public Listener playerMotionUpdateEvent = new Listener<>(event -> { 32 | mc.player.setVelocity(0, 0, 0); 33 | event.cancel(); 34 | 35 | float speedY = 0; 36 | if (mc.player.posY < startY) { 37 | if (!antiKickTimer.hasPassed(3000)) { 38 | speedY = mc.player.ticksExisted % 20 == 0 ? -0.1f : 0.031f; 39 | } else { 40 | antiKickTimer.reset(); 41 | speedY = -0.1f; 42 | } 43 | } else if (mc.player.ticksExisted % 4 == 0) { 44 | speedY = -0.1f; 45 | } 46 | 47 | mc.player.motionY = speedY; 48 | mc.player.connection.sendPacket(new CPacketPlayer.PositionRotation(mc.player.posX + mc.player.motionX, mc.player.posY + mc.player.motionY, mc.player.posZ + mc.player.motionZ, mc.player.rotationYaw, mc.player.rotationPitch, mc.player.onGround)); 49 | 50 | double y = mc.player.posY + mc.player.motionY; 51 | y += 1337; 52 | mc.player.connection.sendPacket(new CPacketPlayer.PositionRotation(mc.player.posX + mc.player.motionX, y, mc.player.posZ + mc.player.motionZ, mc.player.rotationYaw, mc.player.rotationPitch, mc.player.onGround)); 53 | }); 54 | 55 | @EventHandler 56 | public Listener onPacket = new Listener<>(event -> { 57 | if (event.packet instanceof SPacketPlayerPosLook && mc.currentScreen == null) { 58 | SPacketPlayerPosLook packet = (SPacketPlayerPosLook)event.packet; 59 | mc.player.connection.sendPacket(new CPacketConfirmTeleport(packet.getTeleportId())); 60 | mc.player.connection.sendPacket(new CPacketPlayer.PositionRotation(packet.getX(), packet.getY(), packet.getZ(), packet.getYaw(), packet.getPitch(), false)); 61 | mc.player.setPosition(packet.getX(), packet.getY(), packet.getZ()); 62 | 63 | event.cancel(); 64 | } 65 | }); 66 | } 67 | -------------------------------------------------------------------------------- /src/main/java/me/bebeli555/autobot/mods/bots/crystalpvpbot/AutoTrap.java: -------------------------------------------------------------------------------- 1 | package me.bebeli555.autobot.mods.bots.crystalpvpbot; 2 | 3 | import me.bebeli555.autobot.AutoBot; 4 | import me.bebeli555.autobot.utils.BaritoneUtil; 5 | import me.bebeli555.autobot.utils.BlockUtil; 6 | import me.bebeli555.autobot.utils.InventoryUtil; 7 | import net.minecraft.entity.player.EntityPlayer; 8 | import net.minecraft.init.Blocks; 9 | import net.minecraft.util.math.BlockPos; 10 | 11 | public class AutoTrap extends AutoBot { 12 | private static long lastToggled; 13 | 14 | /** 15 | * Traps the targeted player with obsidian then returns. 16 | * @delay the ms it will sleep after a successfull place 17 | */ 18 | public static void toggle(EntityPlayer target, int delay) { 19 | if (BaritoneUtil.isPathing() || !InventoryUtil.hasBlock(Blocks.OBSIDIAN) || isTrapped(target, true)) { 20 | return; 21 | } 22 | 23 | //Only allow toggles every 0.5 seconds 24 | if (System.currentTimeMillis() / 500 == lastToggled) { 25 | return; 26 | } 27 | lastToggled = System.currentTimeMillis() / 500; 28 | 29 | setStatus("Trapping target with AutoTrap", "CrystalPvP Bot"); 30 | 31 | for (BlockPos position : getBlocksToPlace(target)) { 32 | if (BlockUtil.placeBlock(Blocks.OBSIDIAN, position, false)) { 33 | sleep(delay); 34 | } 35 | } 36 | } 37 | 38 | /** 39 | * Checks if the target is trapped fully, like has obby all around 40 | */ 41 | public static boolean isTrappedFully(EntityPlayer target) { 42 | for (BlockPos position : getBlocksToPlace(target)) { 43 | if (!isSolid(position)) { 44 | return false; 45 | } 46 | } 47 | 48 | return true; 49 | } 50 | 51 | /** 52 | * Checks if there is no escape from targets current position without mining blocks 53 | * @blocks the blocks the trap must be made of 54 | * @roof if true then trap must have a roof on it 55 | */ 56 | public static boolean isTrapped(EntityPlayer target, boolean roof) { 57 | BlockPos p = new BlockPos(target.posX, target.posY, target.posZ); 58 | 59 | //Roof 60 | if (roof && !isSolid(p.add(0, 2, 0))) { 61 | return false; 62 | } 63 | 64 | //+X 65 | if (!isSolid(p.add(1, 0, 0)) && !isSolid(p.add(1, 1, 0))) { 66 | return false; 67 | } 68 | 69 | //-X 70 | if (!isSolid(p.add(-1, 0, 0)) && !isSolid(p.add(-1, 1, 0))) { 71 | return false; 72 | } 73 | 74 | //+Z 75 | if (!isSolid(p.add(0, 0, 1)) && !isSolid(p.add(0, 1, 1))) { 76 | return false; 77 | } 78 | 79 | //-Z 80 | if (!isSolid(p.add(0, 0, -1)) && !isSolid(p.add(0, 1, -1))) { 81 | return false; 82 | } 83 | 84 | return true; 85 | } 86 | 87 | /** 88 | * Get the blocks to make the AutoTrap place 89 | * @p the target entitys blockpos 90 | */ 91 | public static BlockPos[] getBlocksToPlace(EntityPlayer target) { 92 | BlockPos p = new BlockPos(target.posX, target.posY, target.posZ); 93 | return new BlockPos[]{p.add(1, 0, 0), p.add(-1, 0, 0), p.add(0, 0, 1), p.add(0, 0, -1), 94 | p.add(1, 1, 0), p.add(-1, 1, 0), p.add(0, 1, 1), p.add(0, 1, -1), 95 | p.add(1, 2, 0), p.add(0, 2, 0)}; 96 | } 97 | } 98 | -------------------------------------------------------------------------------- /src/main/java/me/bebeli555/autobot/rendering/Renderer.java: -------------------------------------------------------------------------------- 1 | package me.bebeli555.autobot.rendering; 2 | 3 | import java.awt.Color; 4 | import java.util.ArrayList; 5 | 6 | import me.bebeli555.autobot.AutoBot; 7 | import me.bebeli555.autobot.rendering.RenderBlock.BlockColor; 8 | import net.minecraft.client.gui.GuiScreen; 9 | import net.minecraft.util.math.BlockPos; 10 | import net.minecraft.util.math.Vec3d; 11 | import net.minecraftforge.client.event.RenderGameOverlayEvent; 12 | import net.minecraftforge.client.event.RenderWorldLastEvent; 13 | import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; 14 | 15 | public class Renderer extends AutoBot { 16 | public static String[] status; 17 | public static ArrayList rectangles = new ArrayList(); 18 | 19 | @SubscribeEvent 20 | public void renderText(RenderGameOverlayEvent.Text e) { 21 | //Draw status 22 | if (status != null) { 23 | for (int i = 0; i < status.length; i++) { 24 | if (status[i] == null) { 25 | continue; 26 | } 27 | 28 | GuiScreen.drawRect(((mc.displayWidth / 4) - (mc.fontRenderer.getStringWidth(status[i]) / 2)) - 3, (i * 10) - 1, ((mc.displayWidth / 4) + (mc.fontRenderer.getStringWidth(status[i]) / 2)) + 3, (i + 1) * 10, 0xFF000000); 29 | GuiScreen.drawRect(((mc.displayWidth / 4) - (mc.fontRenderer.getStringWidth(status[i]) / 2)) - 3, (i * 10) + 9, ((mc.displayWidth / 4) + (mc.fontRenderer.getStringWidth(status[i]) / 2)) + 3, (i + 1) * 10, 0xFF27f5be); 30 | GuiScreen.drawRect(((mc.displayWidth / 4) - (mc.fontRenderer.getStringWidth(status[i]) / 2)) - 3, (i * 10) - 1, ((mc.displayWidth / 4) - (mc.fontRenderer.getStringWidth(status[i]) / 2)) - 2, (i + 1) * 10, 0xFF27f5be); 31 | GuiScreen.drawRect(((mc.displayWidth / 4) + (mc.fontRenderer.getStringWidth(status[i]) / 2)) + 2, (i * 10) - 1, ((mc.displayWidth / 4) + (mc.fontRenderer.getStringWidth(status[i]) / 2)) + 3, (i + 1) * 10, 0xFF27f5be); 32 | mc.fontRenderer.drawString(status[i], (mc.displayWidth / 4) - (mc.fontRenderer.getStringWidth(status[i]) / 2), i * 10, 0xFF000000); 33 | } 34 | } 35 | } 36 | 37 | @SubscribeEvent 38 | public void renderWorld(RenderWorldLastEvent event) { 39 | try { 40 | //Render path 41 | BlockPos last = null; 42 | for (BlockPos pos : RenderPath.path) { 43 | if (last != null) { 44 | RenderUtil.drawLine(new Vec3d(pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5), new Vec3d(last.getX() + 0.5, last.getY() + 0.5, last.getZ() + 0.5), 2, RenderPath.color); 45 | } 46 | 47 | last = pos; 48 | } 49 | 50 | //Render block bounding box 51 | for (BlockColor blockColor : RenderBlock.list) { 52 | Color c = blockColor.color; 53 | RenderUtil.drawBoundingBox(RenderUtil.getBB(blockColor.pos), blockColor.width, c.getRed() / 255, c.getGreen() / 255, c.getBlue() / 255, 1f); 54 | } 55 | 56 | //Render 2d rectangles 57 | for (BlockColor rectangle : rectangles) { 58 | Color c = rectangle.color; 59 | RenderUtil.draw2DRec(RenderUtil.getBB(rectangle.pos), rectangle.width, c.getRed() / 255, c.getGreen() / 255, c.getBlue() / 255, 1f); 60 | } 61 | } catch (Exception ignored) { 62 | 63 | } 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /src/main/java/me/bebeli555/autobot/utils/PlayerUtil.java: -------------------------------------------------------------------------------- 1 | package me.bebeli555.autobot.utils; 2 | 3 | import java.util.ArrayList; 4 | import me.bebeli555.autobot.AutoBot; 5 | import net.minecraft.entity.Entity; 6 | import net.minecraft.entity.player.EntityPlayer; 7 | import net.minecraft.util.EnumHand; 8 | import net.minecraft.util.math.BlockPos; 9 | import net.minecraft.util.math.Vec3d; 10 | import net.minecraftforge.common.MinecraftForge; 11 | import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; 12 | import net.minecraftforge.fml.common.gameevent.TickEvent.ClientTickEvent; 13 | 14 | public class PlayerUtil extends AutoBot { 15 | private static PlayerUtil playerUtil = new PlayerUtil(); 16 | 17 | /** 18 | * Gets all the players the client knows except yourself. 19 | */ 20 | public static ArrayList getAll() { 21 | try { 22 | ArrayList players = new ArrayList(); 23 | 24 | for (EntityPlayer player : mc.world.playerEntities) { 25 | if (!player.isEntityEqual(mc.player)) { 26 | players.add(player); 27 | } 28 | } 29 | 30 | return players; 31 | } catch (NullPointerException ignored) { 32 | return new ArrayList(); 33 | } 34 | } 35 | 36 | /** 37 | * Gets a player with the given name 38 | */ 39 | public static EntityPlayer getPlayer(String name) { 40 | for (EntityPlayer player : getAll()) { 41 | if (player.getName().equals(name)) { 42 | return player; 43 | } 44 | } 45 | 46 | return null; 47 | } 48 | 49 | /** 50 | * Gets the closest player 51 | */ 52 | public static EntityPlayer getClosest() { 53 | double lowestDistance = Integer.MAX_VALUE; 54 | EntityPlayer closest = null; 55 | 56 | for (EntityPlayer player : getAll()) { 57 | if (player.getDistance(mc.player) < lowestDistance) { 58 | lowestDistance = player.getDistance(mc.player); 59 | closest = player; 60 | } 61 | } 62 | 63 | return closest; 64 | } 65 | 66 | /** 67 | * Checks if these 2 players are in the same position 68 | * @y how much the y difference can be 69 | */ 70 | public static boolean isInSameBlock(EntityPlayer player, EntityPlayer other, int y) { 71 | BlockPos first = new BlockPos((int)player.posX, (int)player.posY, (int)player.posZ); 72 | BlockPos second = new BlockPos((int)other.posX, (int)other.posY, (int)other.posZ); 73 | 74 | return first.getX() == second.getX() && Math.abs(first.getY() - second.getY()) <= y && first.getZ() == second.getZ(); 75 | } 76 | 77 | /** 78 | * Makes the player do a right click 79 | * Its run on the client thread because otherwise it yeets all kinds of exceptions 80 | */ 81 | public static void rightClick() { 82 | MinecraftForge.EVENT_BUS.register(playerUtil); 83 | } 84 | 85 | /** 86 | * Gets the speed the given entity is moving at 87 | * Like the difference between current and last tick position 88 | */ 89 | public static double getSpeed(Entity entity) { 90 | return new Vec3d(mc.player.posX, mc.player.posY, mc.player.posZ).distanceTo(new Vec3d(mc.player.lastTickPosX, mc.player.lastTickPosY, mc.player.lastTickPosZ)); 91 | } 92 | 93 | public static boolean isMoving(Entity entity) { 94 | return getSpeed(entity) == 0; 95 | } 96 | 97 | @SubscribeEvent 98 | public void onTick(ClientTickEvent e) { 99 | mc.playerController.processRightClick(mc.player, mc.world, EnumHand.MAIN_HAND); 100 | MinecraftForge.EVENT_BUS.unregister(playerUtil); 101 | } 102 | } 103 | -------------------------------------------------------------------------------- /src/main/java/me/bebeli555/autobot/mods/other/AutoMessager.java: -------------------------------------------------------------------------------- 1 | package me.bebeli555.autobot.mods.other; 2 | 3 | import java.util.ArrayList; 4 | 5 | import me.bebeli555.autobot.AutoBot; 6 | import me.bebeli555.autobot.gui.Group; 7 | import me.bebeli555.autobot.gui.Mode; 8 | import me.bebeli555.autobot.gui.Setting; 9 | import net.minecraft.client.network.NetworkPlayerInfo; 10 | import net.minecraft.network.play.client.CPacketChatMessage; 11 | 12 | public class AutoMessager extends AutoBot { 13 | private static Thread thread; 14 | 15 | public static Setting message = new Setting(Mode.TEXT, "Message", "", "The message to send"); 16 | public static Setting mode = new Setting(null, "Mode", "Normal", new String[]{"Normal", "Just sends the message until toggled off"}, new String[]{"Everyone", "Sends a message for every player online.", " in the message will be replaced with the players name", "Example: /msg hi"}); 17 | public static Setting everyoneToggle = new Setting(mode, "Everyone", Mode.BOOLEAN, "Toggle", false, "Toggles the module off after sending the message", "To everyone online if true"); 18 | public static Setting delay = new Setting(Mode.DOUBLE, "Delay", 3.5, "How many seconds to wait between sending the messages"); 19 | public static Setting packet = new Setting(Mode.BOOLEAN, "Packet", false, "Sends a packet instead of using the method to send the message", "If you use this then other clients prefixes wont work usually"); 20 | 21 | public AutoMessager() { 22 | super(Group.OTHER, "AutoMessager", "Sends messages automatically"); 23 | } 24 | 25 | @Override 26 | public void onEnabled() { 27 | thread = new Thread() { 28 | public void run() { 29 | while (thread != null && thread.equals(this)) { 30 | loop(); 31 | 32 | AutoBot.sleep(50); 33 | } 34 | } 35 | }; 36 | 37 | thread.start(); 38 | } 39 | 40 | @Override 41 | public void onDisabled() { 42 | suspend(thread); 43 | thread = null; 44 | } 45 | 46 | public void loop() { 47 | if (mc.player == null) { 48 | return; 49 | } 50 | 51 | if (mode.stringValue().equals("Normal")) { 52 | sendMessage(message.stringValue()); 53 | sleep((int)(delay.doubleValue() * 1000)); 54 | } else if (mode.stringValue().equals("Everyone")) { 55 | ArrayList players = new ArrayList(); 56 | for (NetworkPlayerInfo player : mc.player.connection.getPlayerInfoMap()) { 57 | try { 58 | players.add(player.getGameProfile().getName()); 59 | } catch (Exception e) { 60 | 61 | } 62 | } 63 | 64 | for (String player : players) { 65 | if (mc.player == null || player.equals(mc.player.getName()) || !isOnline(player)) { 66 | continue; 67 | } 68 | 69 | sendMessage(message.stringValue().replace("", player)); 70 | sleep((int)(delay.doubleValue() * 1000)); 71 | } 72 | 73 | if (everyoneToggle.booleanValue()) { 74 | toggleModule(); 75 | } 76 | } 77 | } 78 | 79 | public void sendMessage(String message) { 80 | if (packet.booleanValue()) { 81 | mc.player.connection.sendPacket(new CPacketChatMessage(message)); 82 | } else { 83 | mc.player.sendChatMessage(message); 84 | } 85 | } 86 | 87 | public static boolean isOnline(String playerName) { 88 | for (NetworkPlayerInfo player : mc.player.connection.getPlayerInfoMap()) { 89 | try { 90 | if (player.getGameProfile().getName().equals(playerName)) { 91 | return true; 92 | } 93 | } catch (Exception e) { 94 | 95 | } 96 | } 97 | 98 | return false; 99 | } 100 | } 101 | -------------------------------------------------------------------------------- /src/main/java/me/bebeli555/autobot/mods/bots/elytrabot/ElytraFly.java: -------------------------------------------------------------------------------- 1 | package me.bebeli555.autobot.mods.bots.elytrabot; 2 | 3 | import me.bebeli555.autobot.AutoBot; 4 | import me.bebeli555.autobot.events.TravelEvent; 5 | import me.zero.alpine.listener.EventHandler; 6 | import me.zero.alpine.listener.Listener; 7 | import net.minecraft.util.math.BlockPos; 8 | 9 | public class ElytraFly extends AutoBot { 10 | public static ElytraFly elytraFly = new ElytraFly(); 11 | 12 | public static void toggle(boolean on) { 13 | if (on) { 14 | AutoBot.EVENT_BUS.subscribe(elytraFly); 15 | } else { 16 | AutoBot.EVENT_BUS.unsubscribe(elytraFly); 17 | } 18 | } 19 | 20 | /** 21 | * Sets the players motion so the player will move to the given blockpos from current pos 22 | */ 23 | public static void setMotion(BlockPos pos, BlockPos next, BlockPos previous) { 24 | double x = 0, y = 0, z = 0; 25 | double xDiff = (pos.getX() + 0.5) - mc.player.posX; 26 | double yDiff = (pos.getY() + 0.4) - mc.player.posY; 27 | double zDiff = (pos.getZ() + 0.5) - mc.player.posZ; 28 | 29 | double speed = ElytraBot.elytraFlySpeed.doubleValue(); 30 | 31 | //If the previous pos is not 0 for 2 coords then it will use the slow speed otherwise the target would probably be missed 32 | int amount = 0; 33 | try { 34 | if (Math.abs(next.getX() - previous.getX()) > 0) amount++; 35 | if (Math.abs(next.getY() - previous.getY()) > 0) amount++; 36 | if (Math.abs(next.getZ() - previous.getZ()) > 0) amount++; 37 | if (amount > 1) { 38 | speed = ElytraBot.elytraFlyManuverSpeed.doubleValue(); 39 | 40 | //If the previous and next is both diagonal then use real speed 41 | if (next.getX() - previous.getX() == next.getZ() - previous.getZ() && next.getY() - previous.getY() == 0) { 42 | if (xDiff >= 1 && zDiff >= 1 || xDiff <= -1 && zDiff <= -1) { 43 | speed = ElytraBot.elytraFlySpeed.doubleValue(); 44 | } 45 | } 46 | } 47 | } catch (Exception nullPointerProbablyIdk) { 48 | speed = ElytraBot.elytraFlyManuverSpeed.doubleValue(); 49 | } 50 | 51 | if ((int)xDiff > 0) { 52 | x = speed; 53 | } else if ((int)xDiff < 0) { 54 | x = -speed; 55 | } 56 | 57 | if ((int)yDiff > 0) { 58 | y = ElytraBot.elytraFlyManuverSpeed.doubleValue(); 59 | } else if ((int)yDiff < 0) { 60 | y = -ElytraBot.elytraFlyManuverSpeed.doubleValue(); 61 | } 62 | 63 | if ((int)zDiff > 0) { 64 | z = speed; 65 | } else if ((int)zDiff < 0) { 66 | z = -speed; 67 | } 68 | 69 | mc.player.motionX = x; 70 | mc.player.motionY = y; 71 | mc.player.motionZ = z; 72 | 73 | //Center 74 | double centerSpeed = 0.2; 75 | double centerCheck = 0.1; 76 | if (x == 0) { 77 | if (xDiff > centerCheck) { 78 | mc.player.motionX = centerSpeed; 79 | } else if (xDiff < -centerCheck) { 80 | mc.player.motionX = -centerSpeed; 81 | } else { 82 | mc.player.motionX = 0; 83 | } 84 | } 85 | 86 | if (y == 0) { 87 | if (yDiff > centerCheck) { 88 | mc.player.motionY = centerSpeed; 89 | } else if (yDiff < -centerCheck) { 90 | mc.player.motionY = -centerSpeed; 91 | } else { 92 | mc.player.motionY = 0; 93 | } 94 | } 95 | 96 | if (z == 0) { 97 | if (zDiff > centerCheck) { 98 | mc.player.motionZ = centerSpeed; 99 | } else if (zDiff < -centerCheck) { 100 | mc.player.motionZ = -centerSpeed; 101 | } else { 102 | mc.player.motionZ = 0; 103 | } 104 | } 105 | } 106 | 107 | @EventHandler 108 | private Listener onTravel = new Listener<>(event -> { 109 | event.cancel(); 110 | }); 111 | } 112 | -------------------------------------------------------------------------------- /src/main/java/me/bebeli555/autobot/gui/SetGuiNodes.java: -------------------------------------------------------------------------------- 1 | package me.bebeli555.autobot.gui; 2 | 3 | import java.lang.reflect.Field; 4 | 5 | import me.bebeli555.autobot.AutoBot; 6 | 7 | public class SetGuiNodes { 8 | 9 | //Sets the GuiNodes by looping through the modules 10 | //Then checking all the variables in the class and if its an Setting variable add that as a GuiNode 11 | public static void setGuiNodes() { 12 | try { 13 | for (AutoBot module : AutoBot.modules) { 14 | GuiNode mainNode; 15 | Setting s = null; 16 | 17 | if (module.name.isEmpty()) { 18 | mainNode = new GuiNode(true); 19 | mainNode.group = module.group; 20 | } else { 21 | mainNode = new GuiNode(); 22 | mainNode.group = module.group; 23 | mainNode.name = module.name; 24 | mainNode.description = module.description; 25 | mainNode.group = module.group; 26 | mainNode.isVisible = true; 27 | mainNode.setId(); 28 | s = new Setting(Mode.BOOLEAN, mainNode.name, false, mainNode.description); 29 | } 30 | 31 | for (Field field : module.getClass().getFields()) { 32 | Class myType = Setting.class; 33 | 34 | if (field.getType().isAssignableFrom(myType)) { 35 | Setting setting = (Setting)field.get(module); 36 | if (!mainNode.id.isEmpty()) { 37 | setting.id = mainNode.id + setting.id; 38 | } 39 | 40 | GuiNode node = new GuiNode(); 41 | node.name = setting.name; 42 | node.description = setting.description; 43 | node.defaultValue = String.valueOf(setting.defaultValue); 44 | node.group = mainNode.group; 45 | node.modeName = setting.modeName; 46 | 47 | if (setting.parent != null) { 48 | GuiNode p = Settings.getGuiNodeFromId(setting.parent.id); 49 | node.parent = p; 50 | p.parentedNodes.add(node); 51 | } else if (!mainNode.id.isEmpty()) { 52 | node.parent = mainNode; 53 | mainNode.parentedNodes.add(node); 54 | } else { 55 | node.isVisible = true; 56 | } 57 | 58 | if (setting.mode == Mode.TEXT) { 59 | node.isTypeable = true; 60 | } else if (setting.mode == Mode.INTEGER) { 61 | node.isTypeable = true; 62 | node.onlyNumbers = true; 63 | } else if (setting.mode == Mode.DOUBLE) { 64 | node.isTypeable = true; 65 | node.onlyNumbers = true; 66 | node.acceptDoubleValues = true; 67 | } else if (setting.mode == Mode.LABEL) { 68 | node.isLabel = true; 69 | } else if (setting.modes.size() != 0) { 70 | node.modes = setting.modes; 71 | node.modeDescriptions = setting.modeDescriptions; 72 | } 73 | 74 | if (node.isTypeable || node.modes.size() != 0) { 75 | node.defaultValue = setting.stringValue(); 76 | node.stringValue = setting.stringValue(); 77 | } else { 78 | node.toggled = setting.booleanValue(); 79 | } 80 | 81 | node.setId(); 82 | } 83 | } 84 | 85 | //Keybind setting and node 86 | GuiNode node = new GuiNode(); 87 | node.isVisible = true; 88 | if (s != null) { 89 | mainNode.parentedNodes.add(node); 90 | node.description = new String[]{"Keybind for " + mainNode.name}; 91 | node.parent = mainNode; 92 | node.isVisible = false; 93 | } else { 94 | node.description = new String[]{"Keybind for " + module.group.name}; 95 | } 96 | node.group = module.group; 97 | node.isTypeable = true; 98 | node.isKeybind = true; 99 | node.name = "Keybind"; 100 | node.setId(); 101 | 102 | } 103 | } catch (Exception e) { 104 | System.out.println("AutoBot - Exception setting gui nodes"); 105 | e.printStackTrace(); 106 | } 107 | } 108 | } 109 | -------------------------------------------------------------------------------- /src/main/java/me/bebeli555/autobot/mods/other/AutoTrap.java: -------------------------------------------------------------------------------- 1 | package me.bebeli555.autobot.mods.other; 2 | 3 | import java.util.ArrayList; 4 | 5 | import me.bebeli555.autobot.AutoBot; 6 | import me.bebeli555.autobot.gui.Group; 7 | import me.bebeli555.autobot.gui.Mode; 8 | import me.bebeli555.autobot.gui.Setting; 9 | import me.bebeli555.autobot.utils.BlockUtil; 10 | import me.bebeli555.autobot.utils.InventoryUtil; 11 | import me.bebeli555.autobot.utils.PlayerUtil; 12 | import me.bebeli555.autobot.utils.RotationUtil; 13 | import net.minecraft.entity.player.EntityPlayer; 14 | import net.minecraft.init.Blocks; 15 | import net.minecraft.util.math.BlockPos; 16 | 17 | public class AutoTrap extends AutoBot { 18 | public static Thread thread; 19 | public static int oldSlot = -1; 20 | 21 | public static Setting toggle = new Setting(Mode.BOOLEAN, "Toggle", false, "Toggle the module off after a trap"); 22 | public static Setting range = new Setting(Mode.DOUBLE, "Range", 4, "How far the player can be for autotrap to work"); 23 | public static Setting delay = new Setting(Mode.INTEGER, "Delay", 50, "Delay in ms to wait between placing blocks"); 24 | 25 | public AutoTrap() { 26 | super(Group.OTHER, "AutoTrap", "Traps the nearby player with obsidian"); 27 | } 28 | 29 | @Override 30 | public void onEnabled() { 31 | thread = new Thread() { 32 | public void run() { 33 | while(thread != null && thread.equals(this)) { 34 | loop(); 35 | } 36 | } 37 | }; 38 | 39 | thread.start(); 40 | } 41 | 42 | @Override 43 | public void onDisabled() { 44 | RotationUtil.stopRotating(); 45 | suspend(thread); 46 | thread = null; 47 | } 48 | 49 | public void loop() { 50 | if (mc.player == null) { 51 | return; 52 | } 53 | 54 | if (!InventoryUtil.hasBlock(Blocks.OBSIDIAN)) { 55 | sendMessage("You dont have any obsidian", true); 56 | toggleModule(); 57 | } 58 | 59 | EntityPlayer closest = PlayerUtil.getClosest(); 60 | if (closest != null && mc.player.getDistance(closest) <= range.doubleValue()) { 61 | BlockPos p = new BlockPos(closest.posX, closest.posY, closest.posZ); 62 | 63 | ArrayList positions = new ArrayList(); 64 | positions.add(p.add(1, 0, 0)); 65 | positions.add(p.add(-1, 0, 0)); 66 | positions.add(p.add(0, 0, 1)); 67 | positions.add(p.add(0, 0, -1)); 68 | positions.add(p.add(1, 1, 0)); 69 | positions.add(p.add(-1, 1, 0)); 70 | positions.add(p.add(0, 1, -1)); 71 | positions.add(p.add(0, 1, 1)); 72 | positions.add(p.add(0, 2, 0)); 73 | 74 | if (!isSolid(p.add(0, 3, 0))) { 75 | BlockPos best = null; 76 | double highestDistance = Integer.MIN_VALUE; 77 | 78 | for (BlockPos pos : new BlockPos[]{p.add(1, 2, 0), p.add(-1, 2, 0), p.add(0, 2, 1), p.add(0, 2, -1)}) { 79 | if (mc.player.getDistanceSq(pos) > highestDistance) { 80 | best = pos; 81 | highestDistance = mc.player.getDistanceSq(pos); 82 | } 83 | } 84 | 85 | positions.add(best); 86 | } 87 | 88 | //Find the furthest away placable block and place it 89 | BlockPos best = null; 90 | double highestDistance = Integer.MIN_VALUE; 91 | 92 | for (BlockPos pos : positions) { 93 | if (BlockUtil.canPlaceBlock(pos) && BlockUtil.canBeClicked(pos) && mc.player.getDistanceSq(pos) > highestDistance) { 94 | best = pos; 95 | highestDistance = mc.player.getDistanceSq(pos); 96 | } 97 | } 98 | 99 | if (best != null) { 100 | if (oldSlot == -1) { 101 | oldSlot = mc.player.inventory.currentItem; 102 | } 103 | 104 | BlockUtil.placeBlockNoSleep(Blocks.OBSIDIAN, best, true); 105 | sleep(delay.intValue()); 106 | } else if (toggle.booleanValue()) { 107 | toggleModule(); 108 | } else { 109 | RotationUtil.stopRotating(); 110 | if (oldSlot != -1) mc.player.inventory.currentItem = oldSlot; 111 | oldSlot = -1; 112 | sleep(25); 113 | } 114 | } 115 | } 116 | } 117 | -------------------------------------------------------------------------------- /src/main/java/me/bebeli555/autobot/mods/bots/crystalpvpbot/Walker.java: -------------------------------------------------------------------------------- 1 | package me.bebeli555.autobot.mods.bots.crystalpvpbot; 2 | 3 | import java.util.ArrayList; 4 | 5 | import me.bebeli555.autobot.AutoBot; 6 | import me.bebeli555.autobot.utils.BaritoneUtil; 7 | import me.bebeli555.autobot.utils.BlockUtil; 8 | import net.minecraft.block.Block; 9 | import net.minecraft.entity.player.EntityPlayer; 10 | import net.minecraft.init.Blocks; 11 | import net.minecraft.util.math.BlockPos; 12 | 13 | public class Walker extends AutoBot { 14 | 15 | /** 16 | * Walks to the nearest hole that is made out of bedrock or obby 17 | * @radius The radius where to search holes around the player 18 | */ 19 | public static boolean walkToNearestHole(int radius) { 20 | BlockPos hole = getClosestHole(mc.player, radius, true, Blocks.BEDROCK, Blocks.OBSIDIAN); 21 | 22 | if (hole == null) { 23 | return false; 24 | } else { 25 | setStatus("Walking to a nearby hole", "CrystalPvPBot"); 26 | BaritoneUtil.walkTo(hole, true); 27 | Surround.center(); 28 | return true; 29 | } 30 | } 31 | 32 | /** 33 | * Tries to walk away from the target a bit 34 | */ 35 | public static void backOff(EntityPlayer target) { 36 | setStatus("Backing off from target", "CrystalPvP Bot"); 37 | BlockPos goal = new BlockPos((mc.player.posX - target.posX) + mc.player.posX, mc.player.posY, (mc.player.posZ - target.posZ) + mc.player.posZ); 38 | BaritoneUtil.walkTo(goal, true); 39 | } 40 | 41 | /** 42 | * Get the closest hole to given player 43 | * @canPath if true then will only give a hole where baritone can walk to 44 | */ 45 | public static BlockPos getClosestHole(EntityPlayer player, int radius, boolean canPath, Block... blocks) { 46 | double lowestDistance = Integer.MAX_VALUE; 47 | BlockPos closestHole = null; 48 | ArrayList holes = new ArrayList(); 49 | 50 | //Check some positions to more know if their walkable or not this will make baritone have to check less paths 51 | outer: for (BlockPos pos : getHoles(radius, blocks)) { 52 | BlockPos[] cantBeSolid = {pos.add(0, 1, 0), pos.add(0, 2, 0)}; 53 | 54 | for (BlockPos check : cantBeSolid) { 55 | if (isSolid(check)) { 56 | continue outer; 57 | } 58 | } 59 | 60 | holes.add(pos); 61 | } 62 | 63 | for (BlockPos pos : holes) { 64 | double distance = player.getDistance(pos.getX(), pos.getY(), pos.getZ()); 65 | if (distance < lowestDistance) { 66 | if (canPath) { 67 | if (!BaritoneUtil.canPath(pos)) { 68 | continue; 69 | } 70 | } 71 | 72 | lowestDistance = distance; 73 | closestHole = pos; 74 | } 75 | } 76 | 77 | return closestHole; 78 | } 79 | 80 | /** 81 | * Get all holes in the given radius. 82 | * @return The center BlockPos of the hole 83 | * @blocks The list of blocks the hole can be made of 84 | */ 85 | public static ArrayList getHoles(int radius, Block... blocks) { 86 | ArrayList holes = new ArrayList(); 87 | 88 | outer: for (BlockPos p : BlockUtil.getAll(radius)) { 89 | if (!isSolid(p)) { 90 | BlockPos[] mustBeSolid = {p.add(1, 0, 0), p.add(-1, 0, 0), p.add(0, 0, 1), p.add(0, 0, -1), p.add(0, -1, 0)}; 91 | 92 | outer2: for (BlockPos pos : mustBeSolid) { 93 | for (Block block : blocks) { 94 | if (getBlock(pos).equals(block)) { 95 | continue outer2; 96 | } 97 | } 98 | 99 | continue outer; 100 | } 101 | 102 | holes.add(p); 103 | } 104 | } 105 | 106 | return holes; 107 | } 108 | 109 | /** 110 | * Jumps and places the given block below 111 | */ 112 | public static void jumpAndPlace(Block block) { 113 | if (BaritoneUtil.isPathing()) { 114 | return; 115 | } 116 | 117 | boolean oldValue = AutoCrystal.dontToggle; 118 | AutoCrystal.dontToggle = true; 119 | sleep(150); 120 | mc.player.jump(); 121 | sleep(300); 122 | BlockUtil.placeBlock(block, getPlayerPos().add(0, -1, 0), false); 123 | sleepUntil(() -> mc.player.onGround, 500); 124 | AutoCrystal.dontToggle = oldValue; 125 | } 126 | } 127 | -------------------------------------------------------------------------------- /src/main/java/me/bebeli555/autobot/utils/CrystalUtil.java: -------------------------------------------------------------------------------- 1 | package me.bebeli555.autobot.utils; 2 | 3 | import java.util.ArrayList; 4 | 5 | import me.bebeli555.autobot.AutoBot; 6 | import net.minecraft.block.Block; 7 | import net.minecraft.enchantment.EnchantmentHelper; 8 | import net.minecraft.entity.Entity; 9 | import net.minecraft.entity.SharedMonsterAttributes; 10 | import net.minecraft.entity.item.EntityEnderCrystal; 11 | import net.minecraft.entity.player.EntityPlayer; 12 | import net.minecraft.init.Blocks; 13 | import net.minecraft.potion.Potion; 14 | import net.minecraft.util.CombatRules; 15 | import net.minecraft.util.DamageSource; 16 | import net.minecraft.util.math.AxisAlignedBB; 17 | import net.minecraft.util.math.BlockPos; 18 | import net.minecraft.util.math.Vec3d; 19 | import net.minecraft.world.Explosion; 20 | 21 | public class CrystalUtil extends AutoBot{ 22 | 23 | /** 24 | * Gets all the crystals around you if the distance is lower or equal 25 | * 26 | */ 27 | public static ArrayList getCrystals(double distance) { 28 | ArrayList list = new ArrayList(); 29 | 30 | for (Entity entity : mc.world.loadedEntityList) { 31 | if (entity instanceof EntityEnderCrystal) { 32 | if (entity.getDistance(mc.player) <= distance) { 33 | list.add((EntityEnderCrystal)entity); 34 | } 35 | } 36 | } 37 | 38 | return list; 39 | } 40 | 41 | /** 42 | * Calculates crystal damage if the crystal is on pos to the entity 43 | */ 44 | public static float calculateDamage(Vec3d pos, EntityPlayer entity) { 45 | try { 46 | if (entity.getDistance(pos.x, pos.y, pos.z) > 12) { 47 | return 0; 48 | } 49 | 50 | double blockDensity = entity.world.getBlockDensity(pos, entity.getEntityBoundingBox()); 51 | double power = (1.0D - (entity.getDistance(pos.x, pos.y, pos.z) / 12.0D)) * blockDensity; 52 | float damage = (float) ((int) ((power * power + power) / 2.0D * 7.0D * 12.0D + 1.0D)); 53 | 54 | int difficulty = mc.world.getDifficulty().getId(); 55 | damage *= (difficulty == 0 ? 0 : (difficulty == 2 ? 1 : (difficulty == 1 ? 0.5f : 1.5f))); 56 | 57 | return getReduction(entity, damage, new Explosion(mc.world, null, pos.x, pos.y, pos.z, 6F, false, true)); 58 | } catch (NullPointerException e) { 59 | return 0; 60 | } 61 | } 62 | 63 | public static float calculateDamage(BlockPos pos, EntityPlayer entity) { 64 | try { 65 | return calculateDamage(new Vec3d(pos.getX() + 0.5, pos.getY() + 1, pos.getZ() + 0.5), entity); 66 | } catch (NullPointerException e) { 67 | return 0; 68 | } 69 | } 70 | 71 | public static float getReduction(EntityPlayer player, float damage, Explosion explosion) { 72 | damage = CombatRules.getDamageAfterAbsorb(damage, (float) player.getTotalArmorValue(), (float) player.getEntityAttribute(SharedMonsterAttributes.ARMOR_TOUGHNESS).getAttributeValue()); 73 | damage *= (1.0F - (float) EnchantmentHelper.getEnchantmentModifierDamage(player.getArmorInventoryList(), DamageSource.causeExplosionDamage(explosion)) / 25.0F); 74 | 75 | if(player.isPotionActive(Potion.getPotionById(11))) damage -= damage / 4; 76 | 77 | return damage; 78 | } 79 | 80 | public static boolean canPlaceCrystal(BlockPos pos) { 81 | Block block = getBlock(pos); 82 | 83 | if (block == Blocks.OBSIDIAN || block == Blocks.BEDROCK) { 84 | Block floor = mc.world.getBlockState(pos.add(0, 1, 0)).getBlock(); 85 | Block ceil = mc.world.getBlockState(pos.add(0, 2, 0)).getBlock(); 86 | 87 | if (floor == Blocks.AIR && ceil == Blocks.AIR) { 88 | for (Entity entity : mc.world.getEntitiesWithinAABBExcludingEntity(null, new AxisAlignedBB(pos.add(0, 1, 0)))) { 89 | if (!entity.isDead) { 90 | return false; 91 | } 92 | } 93 | 94 | return true; 95 | } 96 | } 97 | 98 | return false; 99 | } 100 | } 101 | -------------------------------------------------------------------------------- /src/main/java/me/bebeli555/autobot/gui/Setting.java: -------------------------------------------------------------------------------- 1 | package me.bebeli555.autobot.gui; 2 | 3 | import java.util.ArrayList; 4 | 5 | public class Setting { 6 | public Mode mode; 7 | public String name; 8 | public String[] description; 9 | public Object value; 10 | public Object defaultValue; 11 | public Setting parent; 12 | public String id; 13 | public String modeName = ""; 14 | public ArrayList modes = new ArrayList(); 15 | public ArrayList> modeDescriptions = new ArrayList>(); 16 | 17 | public static ArrayList all = new ArrayList(); 18 | 19 | public Setting(Mode mode, String name, Object defaultValue, String... description) { 20 | this.mode = mode; 21 | this.name = name; 22 | this.defaultValue = defaultValue; 23 | this.value = defaultValue; 24 | this.description = description; 25 | setId(); 26 | all.add(this); 27 | } 28 | 29 | public Setting(Setting parent, Mode mode, String name, Object defaultValue, String... description) { 30 | this(mode, name, defaultValue, description); 31 | this.parent = parent; 32 | setId(); 33 | } 34 | 35 | public Setting(Setting parent, String modeName, Mode mode, String name, Object defaultValue, String... description) { 36 | this(mode, name, defaultValue, description); 37 | this.parent = parent; 38 | this.modeName = modeName; 39 | setId(); 40 | } 41 | 42 | /** 43 | * Used for creating a mode thing 44 | * @param modes first string is the name and the others will be description. 45 | */ 46 | public Setting(Setting parent, String name, String defaultValue, String[]... modes) { 47 | for (String[] mode : modes) { 48 | this.modes.add(mode[0]); 49 | 50 | ArrayList descriptions = new ArrayList(); 51 | for (int i = 1; i < mode.length; i++) { 52 | descriptions.add(mode[i]); 53 | } 54 | 55 | this.modeDescriptions.add(descriptions); 56 | } 57 | 58 | this.defaultValue = defaultValue; 59 | this.value = defaultValue; 60 | this.parent = parent; 61 | this.name = name; 62 | setId(); 63 | all.add(this); 64 | } 65 | 66 | public boolean booleanValue() { 67 | return (Boolean)value; 68 | } 69 | 70 | public int intValue() { 71 | if (stringValue().isEmpty()) { 72 | return -1; 73 | } 74 | 75 | try { 76 | return (int)value; 77 | } catch (ClassCastException e) { 78 | try { 79 | return Integer.parseUnsignedInt(((String)value).replace("0x", ""), 16); 80 | } catch (Exception e2) { 81 | return Integer.parseUnsignedInt(((String)defaultValue).replace("0x", ""), 16); 82 | } 83 | } 84 | } 85 | 86 | public void updateGuiNode() { 87 | if (mode == Mode.BOOLEAN) { 88 | Settings.getGuiNodeFromId(id).toggled = booleanValue(); 89 | } else { 90 | Settings.getGuiNodeFromId(id).stringValue = stringValue(); 91 | } 92 | } 93 | 94 | public double doubleValue() { 95 | if (stringValue().isEmpty()) { 96 | return -1; 97 | } 98 | 99 | try { 100 | return (double)value; 101 | } catch (Exception e) { 102 | return (int)value; 103 | } 104 | } 105 | 106 | public String stringValue() { 107 | return String.valueOf(value); 108 | } 109 | 110 | public void setId() { 111 | id = ""; 112 | 113 | if (this.parent != null) { 114 | ArrayList parents = getSettingParents(); 115 | 116 | for (int i = parents.size(); i-- > 0;) { 117 | id += parents.get(i).name; 118 | } 119 | 120 | id += this.name; 121 | } else { 122 | id = this.name; 123 | } 124 | } 125 | 126 | /** 127 | * Get all parents for this setting 128 | */ 129 | public ArrayList getSettingParents() { 130 | ArrayList parents = new ArrayList(); 131 | 132 | Setting parent = this.parent; 133 | while(true) { 134 | if (parent != null) { 135 | parents.add(parent); 136 | 137 | if (parent.parent != null) { 138 | parent = parent.parent; 139 | continue; 140 | } 141 | } 142 | 143 | break; 144 | } 145 | 146 | return parents; 147 | } 148 | 149 | public static Setting getSettingWithId(String id) { 150 | for (Setting setting : all) { 151 | if (setting.id.equals(id)) { 152 | return setting; 153 | } 154 | } 155 | 156 | return null; 157 | } 158 | } 159 | -------------------------------------------------------------------------------- /src/main/java/me/bebeli555/autobot/Commands.java: -------------------------------------------------------------------------------- 1 | package me.bebeli555.autobot; 2 | 3 | import java.util.UUID; 4 | 5 | import com.mojang.authlib.GameProfile; 6 | import com.mojang.realmsclient.gui.ChatFormatting; 7 | 8 | import me.bebeli555.autobot.gui.Gui; 9 | import me.bebeli555.autobot.gui.GuiNode; 10 | import me.bebeli555.autobot.gui.Settings; 11 | import net.minecraft.client.entity.EntityOtherPlayerMP; 12 | import net.minecraftforge.client.event.ClientChatEvent; 13 | import net.minecraftforge.common.MinecraftForge; 14 | import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; 15 | 16 | public class Commands extends AutoBot { 17 | public static boolean openGui; 18 | public static String prefix = "++"; 19 | 20 | @SubscribeEvent 21 | public void onChat(ClientChatEvent e) { 22 | String messageReal = e.getMessage(); 23 | String message = messageReal.toLowerCase(); 24 | 25 | if (message.startsWith(prefix)) { 26 | e.setCanceled(true); 27 | mc.ingameGUI.getChatGUI().addToSentMessages(messageReal); 28 | message = message.replace(prefix, ""); 29 | 30 | if (!AutoBot.initDone) { 31 | sendMessage("Initialization isnt done yet. Try again", true); 32 | return; 33 | } 34 | 35 | //Open gui command 36 | if (message.equals("gui")) { 37 | openGui = true; 38 | MinecraftForge.EVENT_BUS.register(Gui.gui); 39 | } 40 | 41 | //Set settings 42 | else if (message.startsWith("set")) { 43 | String id = ""; 44 | String value = ""; 45 | 46 | try { 47 | String split[] = messageReal.split(" "); 48 | id = split[1].replace("_", " "); 49 | value = split[2]; 50 | } catch (Exception e2) { 51 | sendMessage("Invalid arguments. Working example: ++set Tetris false", true); 52 | return; 53 | } 54 | 55 | GuiNode guiNode = Settings.getGuiNodeFromId(id); 56 | if (guiNode == null) { 57 | sendMessage("Cant find setting with id: " + id, true); 58 | } else { 59 | if (guiNode.isTypeable != Settings.isBoolean(value)) { 60 | if (!guiNode.isTypeable) { 61 | guiNode.toggled = Boolean.parseBoolean(value); 62 | guiNode.setSetting(); 63 | } else { 64 | try { 65 | guiNode.setSetting(); 66 | 67 | guiNode.stringValue = value; 68 | } catch (Exception ex) { 69 | sendMessage("Wrong input. This might be caused if u input a string value and the setting only accepts integer or double", true); 70 | return; 71 | } 72 | } 73 | 74 | sendMessage("Set " + id + " to " + value, false); 75 | 76 | if (Settings.isBoolean(value)) { 77 | try { 78 | AutoBot.toggleMod(id, Boolean.parseBoolean(value)); 79 | } catch (Exception ignored) { 80 | 81 | } 82 | } 83 | } else { 84 | if (guiNode.isTypeable) { 85 | sendMessage("This setting requires a boolean value", true); 86 | } else { 87 | sendMessage("This setting requires a string or integer value", true); 88 | } 89 | } 90 | } 91 | } 92 | 93 | //List of settings 94 | else if (message.equals("list")) { 95 | String list = ""; 96 | for (GuiNode node : GuiNode.all) { 97 | list += node.id.replace(" ", "_") + ", "; 98 | } 99 | 100 | sendMessage(list, false); 101 | } 102 | 103 | //Help 104 | else if (message.equals("help")) { 105 | sendMessage(prefix + "gui - Opens the GUI", false); 106 | sendMessage(prefix + "set settingId value - sets setting with given id to given value", false); 107 | sendMessage(prefix + "list - Gives a list of all the settingIds", false); 108 | } 109 | 110 | //Create a fakeplayer on ur position (Used for development) 111 | else if (message.equals("fkplayer")) { 112 | EntityOtherPlayerMP fakePlayer = new EntityOtherPlayerMP(mc.world, new GameProfile(UUID.fromString("6ab32213-179a-4c41-8ab9-66789121e051"), "bebeli555")); 113 | fakePlayer.copyLocationAndAnglesFrom(mc.player); 114 | fakePlayer.rotationYawHead = mc.player.rotationYawHead; 115 | mc.world.addEntityToWorld(-100, fakePlayer); 116 | sendMessage("Summoned a fake player ", false); 117 | } 118 | 119 | //Set custom render distance 120 | else if (message.startsWith("renderdistance")) { 121 | int value = Integer.parseInt(message.split(" ")[1]); 122 | mc.gameSettings.renderDistanceChunks = value; 123 | sendMessage("Set render distance to " + value, false); 124 | } 125 | 126 | //Unknown command 127 | else { 128 | sendMessage("Unknown command. Type " + ChatFormatting.GREEN + prefix + "help" + ChatFormatting.RED + " for help", true); 129 | } 130 | } 131 | } 132 | } 133 | -------------------------------------------------------------------------------- /src/main/java/me/bebeli555/autobot/mods/other/MiningSpoof.java: -------------------------------------------------------------------------------- 1 | package me.bebeli555.autobot.mods.other; 2 | 3 | import me.bebeli555.autobot.AutoBot; 4 | import me.bebeli555.autobot.events.PacketEvent; 5 | import me.bebeli555.autobot.events.PlayerDamageBlockEvent; 6 | import me.bebeli555.autobot.events.PlayerMotionUpdateEvent; 7 | import me.bebeli555.autobot.gui.Group; 8 | import me.bebeli555.autobot.utils.InventoryUtil; 9 | import me.bebeli555.autobot.utils.RotationUtil; 10 | import me.zero.alpine.listener.EventHandler; 11 | import me.zero.alpine.listener.Listener; 12 | import net.minecraft.init.Items; 13 | import net.minecraft.item.Item; 14 | import net.minecraft.network.play.client.CPacketConfirmTeleport; 15 | import net.minecraft.network.play.client.CPacketPlayer; 16 | import net.minecraft.network.play.server.SPacketPlayerPosLook; 17 | import net.minecraft.util.EnumFacing; 18 | import net.minecraft.util.EnumHand; 19 | import net.minecraft.util.math.Vec3d; 20 | 21 | public class MiningSpoof extends AutoBot { 22 | private static boolean noPick; 23 | 24 | public MiningSpoof() { 25 | super(Group.OTHER, "MiningSpoof", "Allows you to mine blocks with your pickaxe", "Even when your not actually holding it", "Just start mining a block with this enabled", "And it will mine it as u would be using the pickaxe", "But you will not hold the pickaxe server/client side", "You need a pickaxe in ur hotbar for this to work"); 26 | } 27 | 28 | @Override 29 | public void onEnabled() { 30 | AutoBot.EVENT_BUS.subscribe(this); 31 | } 32 | 33 | @Override 34 | public void onDisabled() { 35 | AutoBot.EVENT_BUS.unsubscribe(this); 36 | noPick = false; 37 | } 38 | 39 | @EventHandler 40 | private Listener onMotionUpdate = new Listener<>(event -> { 41 | if (mc.player == null || !mc.gameSettings.keyBindAttack.isKeyDown() || mc.objectMouseOver.getBlockPos() == null) { 42 | return; 43 | } 44 | 45 | //Return if block cant be mined 46 | if (mc.world.getBlockState(mc.objectMouseOver.getBlockPos()).getBlockHardness(mc.world, mc.objectMouseOver.getBlockPos()) <= 0) { 47 | noPick = true; 48 | return; 49 | } 50 | 51 | int pickSlot = getPickaxeSlot(); 52 | if (pickSlot == -1) { 53 | noPick = true; 54 | return; 55 | } else if (pickSlot == mc.player.inventory.currentItem) { 56 | return; 57 | } 58 | 59 | noPick = false; 60 | int oldSlot = mc.player.inventory.currentItem; 61 | 62 | //Switch to pickaxe 63 | mc.player.inventory.currentItem = pickSlot; 64 | mc.playerController.updateController(); 65 | 66 | //Mine block 67 | mc.player.swingArm(EnumHand.MAIN_HAND); 68 | mc.playerController.onPlayerDamageBlock(mc.objectMouseOver.getBlockPos(), mc.objectMouseOver.sideHit); 69 | 70 | //Switch to old slot 71 | mc.player.inventory.currentItem = oldSlot; 72 | mc.playerController.updateController(); 73 | }); 74 | 75 | @EventHandler 76 | private Listener playerDamageBlockEvent = new Listener<>(event -> { 77 | if (mc.player.inventory.currentItem != getPickaxeSlot() && !noPick) { 78 | event.cancel(); 79 | } 80 | }); 81 | 82 | public static int getPickaxeSlot() { 83 | Item[] picks = {Items.DIAMOND_PICKAXE, Items.GOLDEN_PICKAXE, Items.IRON_PICKAXE, Items.STONE_PICKAXE, Items.WOODEN_PICKAXE}; 84 | 85 | for (Item pick : picks) { 86 | if (InventoryUtil.hasHotbarItem(pick)) { 87 | return InventoryUtil.getSlot(pick); 88 | } 89 | } 90 | 91 | return -1; 92 | } 93 | 94 | public static class CancelForceRotation { 95 | public static CancelForceRotation instance = new CancelForceRotation(); 96 | 97 | @EventHandler 98 | private Listener packetEvent = new Listener<>(event -> { 99 | if (mc.player == null) { 100 | return; 101 | } 102 | 103 | if (event.packet instanceof SPacketPlayerPosLook) { 104 | event.cancel(); 105 | 106 | SPacketPlayerPosLook packet = (SPacketPlayerPosLook)event.packet; 107 | mc.player.setPosition(packet.getX(), packet.getY(), packet.getZ()); 108 | mc.player.motionY = 0; 109 | 110 | float[] rotations = RotationUtil.getRotations(new Vec3d(getPlayerPos().add(0, -1, 0)).add(0.5, 0.5, 0.5).add(new Vec3d(EnumFacing.UP.getDirectionVec()).scale(0.5))); 111 | 112 | mc.getConnection().sendPacket(new CPacketConfirmTeleport(packet.getTeleportId())); 113 | mc.getConnection().sendPacket(new CPacketPlayer.PositionRotation(mc.player.posX, mc.player.getEntityBoundingBox().minY, mc.player.posZ, rotations[0], rotations[1], false)); 114 | } 115 | }); 116 | } 117 | } 118 | -------------------------------------------------------------------------------- /src/main/java/me/bebeli555/autobot/utils/BaritoneUtil.java: -------------------------------------------------------------------------------- 1 | package me.bebeli555.autobot.utils; 2 | 3 | import java.util.ArrayList; 4 | import java.util.function.Consumer; 5 | import baritone.api.BaritoneAPI; 6 | import baritone.api.Settings; 7 | import me.bebeli555.autobot.AutoBot; 8 | import net.minecraft.init.Blocks; 9 | import net.minecraft.init.Items; 10 | import net.minecraft.util.math.BlockPos; 11 | import net.minecraft.util.text.ITextComponent; 12 | 13 | public class BaritoneUtil extends AutoBot { 14 | private static Consumer oldValue; 15 | private static long lastCommand; 16 | 17 | /** 18 | * Send a baritone command without the baritone chat message 19 | */ 20 | public static void sendCommand(String command) { 21 | long ms = System.currentTimeMillis(); 22 | lastCommand = ms; 23 | 24 | if (oldValue == null) oldValue = BaritoneAPI.getSettings().logger.value; 25 | BaritoneAPI.getSettings().logger.value = (component) -> {}; 26 | BaritoneAPI.getProvider().getPrimaryBaritone().getCommandManager().execute(command); 27 | 28 | new Thread() { 29 | public void run() { 30 | AutoBot.sleep(250); 31 | if (ms == lastCommand) BaritoneAPI.getSettings().logger.value = oldValue; 32 | } 33 | }.start(); 34 | } 35 | 36 | /** 37 | * Make baritone walk to given goal 38 | * @sleepUntilDone if true, sleeps until baritone has walked to the goal 39 | */ 40 | public static void walkTo(BlockPos goal, boolean sleepUntilDone) { 41 | //Mine web inside us as it will prevent us from moving 42 | if (getBlock(getPlayerPos()) == Blocks.WEB) { 43 | if (InventoryUtil.hasItem(Items.DIAMOND_SWORD)) { 44 | InventoryUtil.switchItem(InventoryUtil.getSlot(Items.DIAMOND_SWORD), true); 45 | MiningUtil.mineWithoutSwitch(getPlayerPos()); 46 | } 47 | } 48 | 49 | sendCommand("goto " + goal.getX() + " " + goal.getY() + " " + goal.getZ()); 50 | 51 | if (sleepUntilDone) { 52 | sleepUntil(() -> BaritoneAPI.getProvider().getPrimaryBaritone().getPathingBehavior().isPathing(), 100); 53 | sleepUntil(() -> !BaritoneAPI.getProvider().getPrimaryBaritone().getPathingBehavior().isPathing(), -1); 54 | } 55 | } 56 | 57 | /** 58 | * Checks if there is a path to the given goal 59 | * Pretty hacky solution but eh 60 | */ 61 | public static boolean canPath(BlockPos goal) { 62 | walkTo(goal, false); 63 | boolean value = false; 64 | for (int i = 0; i < 35; i++) { 65 | if (BaritoneAPI.getProvider().getPrimaryBaritone().getPathingBehavior().isPathing()) { 66 | value = true; 67 | break; 68 | } 69 | 70 | sleep(1); 71 | } 72 | 73 | BaritoneAPI.getProvider().getPrimaryBaritone().getPathingBehavior().forceCancel(); 74 | return value; 75 | } 76 | 77 | /** 78 | * Cancel everything baritone is doing 79 | */ 80 | public static void forceCancel() { 81 | BaritoneAPI.getProvider().getPrimaryBaritone().getPathingBehavior().forceCancel(); 82 | } 83 | 84 | /** 85 | * Checks if baritone is pathing 86 | */ 87 | public static boolean isPathing() { 88 | return BaritoneAPI.getProvider().getPrimaryBaritone().getPathingBehavior().isPathing(); 89 | } 90 | 91 | /** 92 | * Checks if baritone is building something 93 | */ 94 | public static boolean isBuilding() { 95 | return BaritoneAPI.getProvider().getPrimaryBaritone().getBuilderProcess().isActive(); 96 | } 97 | 98 | /** 99 | * Sets a boolean setting to the given value 100 | */ 101 | public static void setSetting(String name, boolean value) { 102 | sendCommand("setting " + name + " " + value); 103 | } 104 | 105 | public static class BaritoneSettings { 106 | public ArrayList names = new ArrayList(); 107 | public ArrayList values = new ArrayList(); 108 | 109 | /** 110 | * Saves the current settings to the object 111 | * Didnt find any better way to do this so it just saves the settings used by the mod 112 | */ 113 | public void saveCurrentSettings() { 114 | ArrayList> settings = new ArrayList>(); 115 | 116 | settings.add(BaritoneAPI.getSettings().allowInventory); 117 | settings.add(BaritoneAPI.getSettings().allowSprint); 118 | settings.add(BaritoneAPI.getSettings().allowBreak); 119 | settings.add(BaritoneAPI.getSettings().allowSprint); 120 | settings.add(BaritoneAPI.getSettings().allowPlace); 121 | 122 | for (Settings.Setting setting : settings) { 123 | names.add(setting.getName()); 124 | values.add(setting.value); 125 | } 126 | } 127 | 128 | /** 129 | * Loads and sets all the settings to the previously saved ones in settings object 130 | */ 131 | public void loadSettings() { 132 | for (int i = 0; i < names.size(); i++) { 133 | setSetting(names.get(i), values.get(i)); 134 | } 135 | } 136 | } 137 | } 138 | -------------------------------------------------------------------------------- /src/main/java/me/bebeli555/autobot/gui/Settings.java: -------------------------------------------------------------------------------- 1 | package me.bebeli555.autobot.gui; 2 | 3 | import java.io.BufferedWriter; 4 | import java.io.File; 5 | import java.io.FileOutputStream; 6 | import java.io.OutputStreamWriter; 7 | import java.util.Scanner; 8 | 9 | import me.bebeli555.autobot.AutoBot; 10 | 11 | public class Settings extends AutoBot { 12 | public static String path = mc.gameDir.getPath() + "/AutoBot"; 13 | public static File settings = new File(path + "/Settings.txt"); 14 | 15 | /** 16 | * Saves the settings from the GUI to a file located at .minecraft/AutoBot/Settings.txt 17 | */ 18 | public static void saveSettings() { 19 | new Thread() { 20 | public void run() { 21 | try { 22 | settings.delete(); 23 | settings.createNewFile(); 24 | 25 | BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(settings))); 26 | for (GuiNode node : GuiNode.all) { 27 | if (node.id.equals("ExecuteCodeCode")) { 28 | continue; 29 | } 30 | 31 | bw.write(node.id + "="); 32 | if (!node.isTypeable && node.modes.size() == 0) { 33 | bw.write("" + node.toggled); 34 | } else { 35 | bw.write("" + node.stringValue); 36 | } 37 | 38 | bw.newLine(); 39 | } 40 | 41 | //Also save the group coordinates 42 | for (Group group : Group.values()) { 43 | bw.write("Group88" + group.name + "=" + group.x + "," + group.y); 44 | bw.newLine(); 45 | } 46 | 47 | bw.close(); 48 | } catch (Exception e) { 49 | System.out.println("AutoBot - Error saving settings"); 50 | e.printStackTrace(); 51 | } 52 | } 53 | }.start(); 54 | } 55 | 56 | /** 57 | * Loads the settings saved in the file 58 | */ 59 | public static void loadSettings() { 60 | try { 61 | if (!settings.exists()) { 62 | return; 63 | } 64 | 65 | Scanner scanner = new Scanner(settings); 66 | while(scanner.hasNextLine()) { 67 | String split[] = scanner.nextLine().split("="); 68 | String id = split[0]; 69 | String value; 70 | try { 71 | value = split[1]; 72 | } catch (IndexOutOfBoundsException e) { 73 | value = ""; 74 | } 75 | 76 | //If setting is group then do this trick. What? Trick. Ok! Haha get tricked. Shut up 77 | if (id.startsWith("Group88")) { 78 | String name = id.replace("Group88", ""); 79 | int x = Integer.parseInt(value.split(",")[0]); 80 | int y = Integer.parseInt(value.split(",")[1]); 81 | 82 | for (Group group : Group.values()) { 83 | if (group.name.equals(name)) { 84 | group.x = x; 85 | group.y = y; 86 | } 87 | } 88 | 89 | continue; 90 | } 91 | 92 | GuiNode node = getGuiNodeFromId(id); 93 | if (node == null) { 94 | continue; 95 | } 96 | 97 | if (isBoolean(value)) { 98 | node.toggled = Boolean.parseBoolean(value); 99 | Setting.getSettingWithId(node.id).value = node.toggled; 100 | 101 | for (AutoBot module : modules) { 102 | if (module.name.equals(id)) { 103 | if (node.toggled) { 104 | module.onEnabled(); 105 | } 106 | } 107 | } 108 | } else { 109 | node.stringValue = value; 110 | try { 111 | node.setSetting(); 112 | } catch (NullPointerException e) { 113 | //Ingore exception bcs its probably caused by the keybind which doesnt have a setting only the node 114 | } 115 | } 116 | } 117 | scanner.close(); 118 | } catch (Exception e) { 119 | System.out.println("AutoBot - Error loading settings"); 120 | e.printStackTrace(); 121 | } 122 | } 123 | 124 | /** 125 | * Checks if the setting with given ID is toggled 126 | */ 127 | public static boolean isOn(String id) { 128 | return getGuiNodeFromId(id).toggled; 129 | } 130 | 131 | /** 132 | * @return String value of GuiNode with given ID 133 | */ 134 | public static String getStringValue(String id) { 135 | return getGuiNodeFromId(id).stringValue; 136 | } 137 | 138 | /** 139 | * String value of this setting turned into integer 140 | */ 141 | public static int getIntValue(String id) { 142 | return Integer.parseInt(getGuiNodeFromId(id).stringValue); 143 | } 144 | 145 | /** 146 | * String value of this setting turned into double 147 | */ 148 | public static double getDoubleValue(String id) { 149 | return Double.parseDouble(getGuiNodeFromId(id).stringValue); 150 | } 151 | 152 | /** 153 | * Get GuiNode with given ID 154 | */ 155 | public static GuiNode getGuiNodeFromId(String id) { 156 | for (GuiNode node : GuiNode.all) { 157 | if (node.id.equals(id)) { 158 | return node; 159 | } 160 | } 161 | 162 | return null; 163 | } 164 | 165 | //Checks if string is boolean 166 | public static boolean isBoolean(String string) { 167 | return "true".equals(string) || "false".equals(string); 168 | } 169 | } 170 | -------------------------------------------------------------------------------- /src/main/java/me/bebeli555/autobot/utils/MiningUtil.java: -------------------------------------------------------------------------------- 1 | package me.bebeli555.autobot.utils; 2 | 3 | import me.bebeli555.autobot.AutoBot; 4 | import me.bebeli555.autobot.events.PlayerMotionUpdateEvent; 5 | import me.zero.alpine.listener.EventHandler; 6 | import me.zero.alpine.listener.Listener; 7 | import net.minecraft.init.Blocks; 8 | import net.minecraft.init.Items; 9 | import net.minecraft.util.EnumFacing; 10 | import net.minecraft.util.EnumHand; 11 | import net.minecraft.util.math.BlockPos; 12 | import net.minecraft.util.math.RayTraceResult; 13 | import net.minecraft.util.math.Vec3d; 14 | 15 | public class MiningUtil extends AutoBot { 16 | public static MiningUtil miningUtil = new MiningUtil(); 17 | public static EnumFacing facing; 18 | public static BlockPos pos; 19 | public static boolean start, spoofRotation, isMining; 20 | 21 | /** 22 | * Switches to pickaxe and mines the block in the given position 23 | */ 24 | public static boolean mine(BlockPos pos, boolean spoofRotation) { 25 | if (!hasPickaxe()) { 26 | return false; 27 | } 28 | 29 | InventoryUtil.switchItem(InventoryUtil.getSlot(Items.DIAMOND_PICKAXE), false); 30 | 31 | if (mc.player.inventory.getCurrentItem().getItem() == Items.DIAMOND_PICKAXE) { 32 | MiningUtil.pos = pos; 33 | facing = getFacing(pos); 34 | start = true; 35 | MiningUtil.spoofRotation = spoofRotation; 36 | 37 | isMining = true; 38 | AutoBot.EVENT_BUS.subscribe(miningUtil); 39 | sleepUntil(() -> !isSolid(pos), 15000); 40 | AutoBot.EVENT_BUS.unsubscribe(miningUtil); 41 | isMining = false; 42 | RotationUtil.stopRotating(); 43 | return !isSolid(pos); 44 | } 45 | 46 | return false; 47 | } 48 | 49 | /** 50 | * Mines the block even if you dont have a pickaxe 51 | */ 52 | public static void mineAnyway(BlockPos pos, boolean spoofRotation) { 53 | if (hasPickaxe()) { 54 | InventoryUtil.switchItem(InventoryUtil.getSlot(Items.DIAMOND_PICKAXE), false); 55 | } 56 | 57 | MiningUtil.pos = pos; 58 | facing = getFacing(pos); 59 | start = true; 60 | MiningUtil.spoofRotation = spoofRotation; 61 | 62 | isMining = true; 63 | AutoBot.EVENT_BUS.subscribe(miningUtil); 64 | sleepUntil(() -> !isSolid(pos), 15000); 65 | AutoBot.EVENT_BUS.unsubscribe(miningUtil); 66 | isMining = false; 67 | RotationUtil.stopRotating(); 68 | } 69 | 70 | /** 71 | * Mines the blockpos without switching items 72 | */ 73 | public static boolean mineWithoutSwitch(BlockPos pos) { 74 | MiningUtil.pos = pos; 75 | facing = getFacing(pos); 76 | start = true; 77 | 78 | AutoBot.EVENT_BUS.subscribe(miningUtil); 79 | sleepUntil(() -> !isSolid(pos) && getBlock(pos) != Blocks.WEB, 6000); 80 | AutoBot.EVENT_BUS.unsubscribe(miningUtil); 81 | return !isSolid(pos); 82 | } 83 | 84 | @EventHandler 85 | private Listener onMotionUpdate = new Listener<>(event -> { 86 | if (mc.player == null || getBlock(pos) == Blocks.AIR) { 87 | return; 88 | } 89 | 90 | if (spoofRotation) { 91 | RotationUtil.rotateSpoof(new Vec3d(pos).add(0.5, 0.5, 0.5).add(new Vec3d(facing.getDirectionVec()).scale(0.5))); 92 | } else { 93 | RotationUtil.rotate(new Vec3d(pos).add(0.5, 0.5, 0.5).add(new Vec3d(facing.getDirectionVec()).scale(0.5)), false); 94 | } 95 | mc.player.swingArm(EnumHand.MAIN_HAND); 96 | 97 | if (start) { 98 | start = false; 99 | if (!spoofRotation) RotationUtil.rotate(new Vec3d(pos).add(0.5, 0.5, 0.5).add(new Vec3d(facing.getDirectionVec()).scale(0.5)), true); 100 | } else { 101 | mc.playerController.onPlayerDamageBlock(pos, facing); 102 | } 103 | }); 104 | 105 | /** 106 | * Check if the player has a diamond pickaxe 107 | */ 108 | public static boolean hasPickaxe() { 109 | return InventoryUtil.hasItem(Items.DIAMOND_PICKAXE); 110 | } 111 | 112 | /** 113 | * Checks if the blockpos can be mined legitimately 114 | */ 115 | public static boolean canMine(BlockPos pos) { 116 | if (!isSolid(pos) || getBlock(pos) == Blocks.BEDROCK || mc.player.getDistanceSq(pos) > 7) { 117 | return false; 118 | } 119 | 120 | Vec3d start = new Vec3d(mc.player.posX, mc.player.posY, mc.player.posZ); 121 | Vec3d end = new Vec3d(pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5); 122 | RayTraceResult result = mc.world.rayTraceBlocks(start, end); 123 | 124 | if (result != null && result.getBlockPos().equals(pos)) { 125 | return true; 126 | } else { 127 | return false; 128 | } 129 | } 130 | 131 | public static EnumFacing getFacing(BlockPos pos) { 132 | EnumFacing closest = null; 133 | double lowestDistance = Integer.MAX_VALUE; 134 | for (EnumFacing facing : EnumFacing.values()) { 135 | BlockPos neighbor = pos.offset(facing); 136 | 137 | if (isSolid(neighbor)) { 138 | continue; 139 | } 140 | 141 | double distance = mc.player.getDistanceSq(neighbor); 142 | if (distance < lowestDistance) { 143 | closest = facing; 144 | lowestDistance = distance; 145 | } 146 | } 147 | 148 | return closest; 149 | } 150 | } 151 | -------------------------------------------------------------------------------- /src/main/java/me/bebeli555/autobot/mods/bots/crystalpvpbot/AutoCrystal.java: -------------------------------------------------------------------------------- 1 | package me.bebeli555.autobot.mods.bots.crystalpvpbot; 2 | 3 | import me.bebeli555.autobot.AutoBot; 4 | import me.bebeli555.autobot.utils.BaritoneUtil; 5 | import me.bebeli555.autobot.utils.BlockUtil; 6 | import me.bebeli555.autobot.utils.CrystalUtil; 7 | import me.bebeli555.autobot.utils.InventoryUtil; 8 | import me.bebeli555.autobot.utils.MiningUtil; 9 | import me.bebeli555.autobot.utils.RotationUtil; 10 | import net.minecraft.entity.item.EntityEnderCrystal; 11 | import net.minecraft.entity.player.EntityPlayer; 12 | import net.minecraft.init.Items; 13 | import net.minecraft.util.EnumHand; 14 | import net.minecraft.util.math.BlockPos; 15 | import net.minecraft.util.math.Vec3d; 16 | 17 | public class AutoCrystal extends AutoBot { 18 | public EntityPlayer target; 19 | public Thread thread; 20 | public static BlockPos placed; 21 | public static boolean dontToggle; 22 | 23 | public AutoCrystal(EntityPlayer target) { 24 | this.target = target; 25 | } 26 | 27 | @SuppressWarnings("deprecation") 28 | public void toggle(boolean on) { 29 | if (on) { 30 | if (thread == null) { 31 | thread = new Thread() { 32 | public void run() { 33 | while(true) { 34 | try { 35 | loop(); 36 | 37 | AutoBot.sleep(35); 38 | } catch (Exception ignored) { 39 | 40 | } 41 | } 42 | } 43 | }; 44 | 45 | thread.start(); 46 | } else { 47 | thread.resume(); 48 | } 49 | } else { 50 | thread.suspend(); 51 | } 52 | } 53 | 54 | public void loop() { 55 | if (mc.player == null) { 56 | return; 57 | } 58 | 59 | if (shouldToggleAutoCrystal()) { 60 | setStatus("Using Auto Crystal to damage target", "CrystalPvPBot"); 61 | placed = null; 62 | 63 | //Break crystals 64 | EntityEnderCrystal breakCrystal = getBestCrystal(); 65 | if (breakCrystal != null) { 66 | breakCrystal(breakCrystal); 67 | AutoBot.sleep(CrystalPvPBot.autoCrystalDelay.intValue()); 68 | } 69 | 70 | //Place crystals. 71 | else { 72 | BlockPos placeCrystal = getBestCrystalSpot(true); 73 | if (placeCrystal != null) { 74 | BlockUtil.placeItem(Items.END_CRYSTAL, placeCrystal, false); 75 | placed = placeCrystal; 76 | AutoBot.sleep(CrystalPvPBot.autoCrystalDelay.intValue()); 77 | } 78 | } 79 | } 80 | } 81 | 82 | //Checks if auto crystal should be toggled on 83 | public boolean shouldToggleAutoCrystal() { 84 | if (target == null || target.isDead || dontToggle || BaritoneUtil.isPathing() || MiningUtil.isMining) { 85 | return false; 86 | } 87 | 88 | if (placed != null) { 89 | return true; 90 | } 91 | 92 | BlockPos bestPos = getBestCrystalSpot(true); 93 | double selfCrystalDamage = CrystalUtil.calculateDamage(bestPos, mc.player); 94 | double targetCrystalDamage = CrystalUtil.calculateDamage(bestPos, target); 95 | double health = mc.player.getHealth() + mc.player.getAbsorptionAmount(); 96 | double targetHealth = target.getHealth() + target.getAbsorptionAmount(); 97 | 98 | int minTargetDmg = CrystalPvPBot.autoCrystalMinTargetDmg.intValue(); 99 | if (targetCrystalDamage > minTargetDmg && selfCrystalDamage <= targetCrystalDamage || targetHealth < targetCrystalDamage) { 100 | if (health > selfCrystalDamage || targetCrystalDamage > targetHealth && InventoryUtil.getAmountOfItem(Items.TOTEM_OF_UNDYING) > 3 && targetHealth != 0) { 101 | return true; 102 | } 103 | } 104 | 105 | return false; 106 | } 107 | 108 | //Break the crystal 109 | public void breakCrystal(EntityEnderCrystal crystal) { 110 | RotationUtil.rotate(new Vec3d(crystal.posX + 0.5, crystal.posY + 0.5, crystal.posZ + 0.5), true); 111 | 112 | mc.playerController.attackEntity(mc.player, crystal); 113 | mc.player.swingArm(EnumHand.MAIN_HAND); 114 | } 115 | 116 | //Calculates the best crystal spot to place on 117 | //It calculates it by calculating the enemy damage - self damage / 2 and the spot with highest dmg is returned 118 | public BlockPos getBestCrystalSpot(boolean calculateSelfDamage) { 119 | double mostDamage = Integer.MIN_VALUE; 120 | BlockPos best = null; 121 | 122 | for (BlockPos pos : BlockUtil.getAll(CrystalPvPBot.autoCrystalRange.intValue() - 1)) { 123 | if (CrystalUtil.canPlaceCrystal(pos)) { 124 | double damage = CrystalUtil.calculateDamage(pos, target); 125 | if (calculateSelfDamage) { 126 | damage -= CrystalUtil.calculateDamage(pos, mc.player) / 2; 127 | } 128 | 129 | if (damage > mostDamage) { 130 | mostDamage = damage; 131 | best = pos; 132 | } 133 | } 134 | } 135 | 136 | return best; 137 | } 138 | 139 | //Gets the best crystal around you to break and to cause dmg to target 140 | //Same calc as getBestCrystalSpot 141 | public EntityEnderCrystal getBestCrystal() { 142 | double mostDamage = Integer.MIN_VALUE; 143 | EntityEnderCrystal best = null; 144 | 145 | for (EntityEnderCrystal crystal : CrystalUtil.getCrystals(CrystalPvPBot.autoCrystalRange.intValue())) { 146 | double damage = CrystalUtil.calculateDamage(crystal.getPositionVector(), target); 147 | damage -= CrystalUtil.calculateDamage(crystal.getPositionVector(), mc.player) / 2; 148 | 149 | if (damage > mostDamage) { 150 | mostDamage = damage; 151 | best = crystal; 152 | } 153 | } 154 | 155 | return best; 156 | } 157 | 158 | /** 159 | * Gets the spot where placing a crystal will deal the most damage to given target 160 | */ 161 | public static BlockPos getMostDamageSpot(EntityPlayer target) { 162 | return new AutoCrystal(target).getBestCrystalSpot(false); 163 | } 164 | } 165 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Attempt to set APP_HOME 10 | # Resolve links: $0 may be a link 11 | PRG="$0" 12 | # Need this for relative symlinks. 13 | while [ -h "$PRG" ] ; do 14 | ls=`ls -ld "$PRG"` 15 | link=`expr "$ls" : '.*-> \(.*\)$'` 16 | if expr "$link" : '/.*' > /dev/null; then 17 | PRG="$link" 18 | else 19 | PRG=`dirname "$PRG"`"/$link" 20 | fi 21 | done 22 | SAVED="`pwd`" 23 | cd "`dirname \"$PRG\"`/" >/dev/null 24 | APP_HOME="`pwd -P`" 25 | cd "$SAVED" >/dev/null 26 | 27 | APP_NAME="Gradle" 28 | APP_BASE_NAME=`basename "$0"` 29 | 30 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 31 | DEFAULT_JVM_OPTS="" 32 | 33 | # Use the maximum available, or set MAX_FD != -1 to use that value. 34 | MAX_FD="maximum" 35 | 36 | warn () { 37 | echo "$*" 38 | } 39 | 40 | die () { 41 | echo 42 | echo "$*" 43 | echo 44 | exit 1 45 | } 46 | 47 | # OS specific support (must be 'true' or 'false'). 48 | cygwin=false 49 | msys=false 50 | darwin=false 51 | nonstop=false 52 | case "`uname`" in 53 | CYGWIN* ) 54 | cygwin=true 55 | ;; 56 | Darwin* ) 57 | darwin=true 58 | ;; 59 | MINGW* ) 60 | msys=true 61 | ;; 62 | NONSTOP* ) 63 | nonstop=true 64 | ;; 65 | esac 66 | 67 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 68 | 69 | # Determine the Java command to use to start the JVM. 70 | if [ -n "$JAVA_HOME" ] ; then 71 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 72 | # IBM's JDK on AIX uses strange locations for the executables 73 | JAVACMD="$JAVA_HOME/jre/sh/java" 74 | else 75 | JAVACMD="$JAVA_HOME/bin/java" 76 | fi 77 | if [ ! -x "$JAVACMD" ] ; then 78 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 79 | 80 | Please set the JAVA_HOME variable in your environment to match the 81 | location of your Java installation." 82 | fi 83 | else 84 | JAVACMD="java" 85 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 86 | 87 | Please set the JAVA_HOME variable in your environment to match the 88 | location of your Java installation." 89 | fi 90 | 91 | # Increase the maximum file descriptors if we can. 92 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then 93 | MAX_FD_LIMIT=`ulimit -H -n` 94 | if [ $? -eq 0 ] ; then 95 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 96 | MAX_FD="$MAX_FD_LIMIT" 97 | fi 98 | ulimit -n $MAX_FD 99 | if [ $? -ne 0 ] ; then 100 | warn "Could not set maximum file descriptor limit: $MAX_FD" 101 | fi 102 | else 103 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 104 | fi 105 | fi 106 | 107 | # For Darwin, add options to specify how the application appears in the dock 108 | if $darwin; then 109 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 110 | fi 111 | 112 | # For Cygwin, switch paths to Windows format before running java 113 | if $cygwin ; then 114 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 115 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 116 | JAVACMD=`cygpath --unix "$JAVACMD"` 117 | 118 | # We build the pattern for arguments to be converted via cygpath 119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 120 | SEP="" 121 | for dir in $ROOTDIRSRAW ; do 122 | ROOTDIRS="$ROOTDIRS$SEP$dir" 123 | SEP="|" 124 | done 125 | OURCYGPATTERN="(^($ROOTDIRS))" 126 | # Add a user-defined pattern to the cygpath arguments 127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 129 | fi 130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 131 | i=0 132 | for arg in "$@" ; do 133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 135 | 136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 138 | else 139 | eval `echo args$i`="\"$arg\"" 140 | fi 141 | i=$((i+1)) 142 | done 143 | case $i in 144 | (0) set -- ;; 145 | (1) set -- "$args0" ;; 146 | (2) set -- "$args0" "$args1" ;; 147 | (3) set -- "$args0" "$args1" "$args2" ;; 148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 154 | esac 155 | fi 156 | 157 | # Escape application args 158 | save () { 159 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done 160 | echo " " 161 | } 162 | APP_ARGS=$(save "$@") 163 | 164 | # Collect all arguments for the java command, following the shell quoting and substitution rules 165 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" 166 | 167 | # by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong 168 | if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then 169 | cd "$(dirname "$0")" 170 | fi 171 | 172 | exec "$JAVACMD" "$@" 173 | -------------------------------------------------------------------------------- /src/main/java/me/bebeli555/autobot/mods/other/AutoInventoryManager.java: -------------------------------------------------------------------------------- 1 | package me.bebeli555.autobot.mods.other; 2 | 3 | import java.io.BufferedWriter; 4 | import java.io.File; 5 | import java.io.FileOutputStream; 6 | import java.io.OutputStreamWriter; 7 | import java.util.ArrayList; 8 | import java.util.Scanner; 9 | import me.bebeli555.autobot.AutoBot; 10 | import me.bebeli555.autobot.gui.Group; 11 | import me.bebeli555.autobot.gui.GuiNode; 12 | import me.bebeli555.autobot.gui.GuiNode.ClickListener; 13 | import me.bebeli555.autobot.gui.Mode; 14 | import me.bebeli555.autobot.gui.Setting; 15 | import me.bebeli555.autobot.gui.Settings; 16 | import me.bebeli555.autobot.utils.InventoryUtil; 17 | import me.bebeli555.autobot.utils.InventoryUtil.ItemStackUtil; 18 | import net.minecraft.init.Items; 19 | import net.minecraft.item.Item; 20 | import net.minecraft.item.ItemStack; 21 | 22 | public class AutoInventoryManager extends AutoBot { 23 | public static Thread thread; 24 | public static ArrayList layout = new ArrayList(); 25 | 26 | public static Setting saveLayout = new Setting(Mode.BOOLEAN, "SaveLayout", false, "Saves the current inventory layout"); 27 | public static Setting delay = new Setting(Mode.INTEGER, "Delay", 150, "Delay in ms between the slot clicks"); 28 | 29 | public AutoInventoryManager() { 30 | super(Group.OTHER, "AutoInventoryManager", "Keeps items in ur inventry in the same layout", "As the one you have saved"); 31 | } 32 | 33 | @Override 34 | public void onPostInit() { 35 | GuiNode node = Settings.getGuiNodeFromId(saveLayout.id); 36 | 37 | node.addClickListener(new ClickListener() { 38 | public void clicked() { 39 | node.toggled = false; 40 | node.setSetting(); 41 | 42 | layout.clear(); 43 | for (ItemStackUtil itemStack : InventoryUtil.getAllItems()) { 44 | layout.add(new ItemUtil(itemStack.itemStack.getItem(), itemStack.slotId)); 45 | } 46 | 47 | saveFile(); 48 | } 49 | }); 50 | } 51 | 52 | @Override 53 | public void onEnabled() { 54 | if (layout.isEmpty()) { 55 | readFile(); 56 | 57 | if (layout.isEmpty()) { 58 | return; 59 | } 60 | } 61 | 62 | thread = new Thread() { 63 | public void run() { 64 | while(thread != null && thread.equals(this)) { 65 | loop(); 66 | 67 | AutoBot.sleep(250); 68 | } 69 | } 70 | }; 71 | 72 | thread.start(); 73 | } 74 | 75 | @Override 76 | public void onDisabled() { 77 | suspend(thread); 78 | thread = null; 79 | } 80 | 81 | public void loop() { 82 | if (mc.player == null) { 83 | return; 84 | } 85 | 86 | for (ItemUtil itemUtil : layout) { 87 | ItemStack current = InventoryUtil.getItemStack(itemUtil.slotId); 88 | 89 | if (itemUtil.item != current.getItem()) { 90 | outer: for (ItemStackUtil itemStack2 : InventoryUtil.getAllItems()) { 91 | if (itemStack2.itemStack.getItem() == itemUtil.item) { 92 | if (itemStack2.slotId != itemUtil.slotId) { 93 | for (ItemUtil itemUtil2 : layout) { 94 | if (itemUtil2.item == itemStack2.itemStack.getItem()) { 95 | if (itemUtil2.slotId == itemStack2.slotId) { 96 | continue outer; 97 | } 98 | } 99 | } 100 | 101 | int otherSlots = mc.player.openContainer.inventorySlots.size() - 46; 102 | if (otherSlots != 0) { 103 | otherSlots++; 104 | } 105 | 106 | //If the player is holding an item then put it to a free slot 107 | if (mc.player.inventory.getCurrentItem().getItem() != Items.AIR) { 108 | int freeSlot = InventoryUtil.getEmptySlot(); 109 | 110 | if (freeSlot != -1) { 111 | InventoryUtil.clickSlot(freeSlot, otherSlots); 112 | } 113 | } 114 | 115 | InventoryUtil.clickSlot(itemStack2.slotId, otherSlots); 116 | InventoryUtil.clickSlot(itemUtil.slotId, otherSlots); 117 | InventoryUtil.clickSlot(itemStack2.slotId, otherSlots); 118 | sleep(delay.intValue()); 119 | break; 120 | } 121 | } 122 | } 123 | } 124 | } 125 | } 126 | 127 | //Saves the layout to a file 128 | //0 = SlotID, 1 = ItemID. 129 | //Prefix change = , 130 | public void saveFile() { 131 | try { 132 | File file = new File(Settings.path + "/AutoInventoryManager.txt"); 133 | file.delete(); 134 | file.createNewFile(); 135 | 136 | BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file))); 137 | for (ItemUtil itemUtil : layout) { 138 | bw.write(itemUtil.slotId + "," + Item.getIdFromItem(itemUtil.item)); 139 | bw.newLine(); 140 | } 141 | 142 | bw.close(); 143 | sendMessage("Layout saved successfully", false); 144 | } catch (Exception e) { 145 | e.printStackTrace(); 146 | sendMessage("Error saving layout. More info in ur games log", true); 147 | } 148 | } 149 | 150 | //Reads the layout file and sets the layout variable 151 | public void readFile() { 152 | try { 153 | File file = new File(Settings.path + "/AutoInventoryManager.txt"); 154 | if (!file.exists()) { 155 | sendMessage("Save a layout first", true); 156 | toggleModule(); 157 | return; 158 | } 159 | 160 | Scanner scanner = new Scanner(file); 161 | layout.clear(); 162 | 163 | while(scanner.hasNextLine()) { 164 | String line = scanner.nextLine(); 165 | 166 | if (!line.isEmpty()) { 167 | String[] split = line.split(","); 168 | layout.add(new ItemUtil(Item.getItemById(Integer.parseInt(split[1])), Integer.parseInt(split[0]))); 169 | } 170 | } 171 | 172 | scanner.close(); 173 | } catch (Exception e) { 174 | sendMessage("Error reading layout file. More info in ur games log", true); 175 | e.printStackTrace(); 176 | } 177 | } 178 | 179 | public static class ItemUtil { 180 | public Item item; 181 | public int slotId; 182 | 183 | public ItemUtil(Item item, int slotId) { 184 | this.item = item; 185 | this.slotId = slotId; 186 | } 187 | } 188 | } 189 | -------------------------------------------------------------------------------- /src/main/java/me/bebeli555/autobot/mods/other/AutoMend.java: -------------------------------------------------------------------------------- 1 | package me.bebeli555.autobot.mods.other; 2 | 3 | import me.bebeli555.autobot.AutoBot; 4 | import me.bebeli555.autobot.gui.Group; 5 | import me.bebeli555.autobot.gui.Mode; 6 | import me.bebeli555.autobot.gui.Setting; 7 | import me.bebeli555.autobot.utils.InventoryUtil; 8 | import me.bebeli555.autobot.utils.InventoryUtil.ItemStackUtil; 9 | import me.bebeli555.autobot.utils.PlayerUtil; 10 | import me.bebeli555.autobot.utils.RotationUtil; 11 | import net.minecraft.entity.EntityLiving; 12 | import net.minecraft.init.Items; 13 | import net.minecraft.inventory.EntityEquipmentSlot; 14 | import net.minecraft.item.ItemArmor; 15 | import net.minecraft.item.ItemStack; 16 | import net.minecraft.item.ItemTool; 17 | import net.minecraft.util.math.Vec3d; 18 | 19 | public class AutoMend extends AutoBot { 20 | public static Thread thread; 21 | 22 | public static Setting armor = new Setting(Mode.BOOLEAN, "Armor", true, "Mends your armor"); 23 | public static Setting tools = new Setting(Mode.BOOLEAN, "Tools", false, "Mends your tools like pickaxe and others", "Remember to disable your AutoTotem if you want to use this"); 24 | public static Setting delay = new Setting(Mode.INTEGER, "Delay", 100, "Delay in ms to wait between the clicks on the XP-Bottle"); 25 | 26 | public AutoMend() { 27 | super(Group.OTHER, "AutoMend", "Mends your armor and tools using xp bottles"); 28 | } 29 | 30 | @Override 31 | public void onEnabled() { 32 | thread = new Thread() { 33 | public void run() { 34 | while(thread != null && thread.equals(this)) { 35 | loop(); 36 | 37 | AutoBot.sleep(50); 38 | } 39 | } 40 | }; 41 | 42 | thread.start(); 43 | } 44 | 45 | @Override 46 | public void onDisabled() { 47 | clearStatus(); 48 | suspend(thread); 49 | thread = null; 50 | } 51 | 52 | public void loop() { 53 | if (mc.player == null) { 54 | return; 55 | } 56 | 57 | if (!InventoryUtil.hasItem(Items.EXPERIENCE_BOTTLE)) { 58 | sendMessage("No xp bottles in inventory", true); 59 | toggleModule(); 60 | return; 61 | } 62 | 63 | if (!isSolid(getPlayerPos().add(0, -1, 0))) { 64 | sendMessage("Block below the player is not solid", true); 65 | toggleModule(); 66 | return; 67 | } 68 | 69 | //Face down so we can do xp and drop items and that kind of stuff 70 | RotationUtil.rotate(new Vec3d(getPlayerPos().add(0, -1, 0)).add(0.5, 0.5, 0.5), false); 71 | 72 | boolean allArmorMended = true; 73 | if (armor.booleanValue()) { 74 | ItemStackUtil[] armor = new ItemStackUtil[]{new ItemStackUtil(InventoryUtil.getItemStack(39), 39), new ItemStackUtil(InventoryUtil.getItemStack(38), 38), 75 | new ItemStackUtil(InventoryUtil.getItemStack(37), 37), new ItemStackUtil(InventoryUtil.getItemStack(36), 36)}; 76 | boolean mended = false; 77 | 78 | //Mend armor or take it off if max durability 79 | for (ItemStackUtil stack : armor) { 80 | if (stack.itemStack.getItem() != Items.AIR) { 81 | if (!isMaxDurability(stack.itemStack)) { 82 | mended = true; 83 | setStatus("Mending armor"); 84 | 85 | for (int i = 0; i < 5; i++) { 86 | clickOnXp(); 87 | } 88 | } else { 89 | int freeSlot = InventoryUtil.getEmptySlot(); 90 | if (freeSlot == -1) { 91 | InventoryUtil.switchItem(8, false); 92 | mc.player.dropItem(true); 93 | freeSlot = 8; 94 | } 95 | 96 | InventoryUtil.clickSlot(stack.slotId); 97 | sleep(100); 98 | InventoryUtil.clickSlot(freeSlot); 99 | sleep(100); 100 | } 101 | } 102 | } 103 | 104 | //Put armor back in to mend it 105 | if (!mended) { 106 | for (ItemStackUtil itemStack : InventoryUtil.getAllItems()) { 107 | if (itemStack.itemStack.getItem() instanceof ItemArmor && !isMaxDurability(itemStack.itemStack)) { 108 | allArmorMended = false; 109 | 110 | int slot = 39; 111 | EntityEquipmentSlot type = EntityLiving.getSlotForItemStack(itemStack.itemStack); 112 | if (type.equals(EntityEquipmentSlot.CHEST)) { 113 | slot = 38; 114 | } else if (type.equals(EntityEquipmentSlot.LEGS)) { 115 | slot = 37; 116 | } else if (type.equals(EntityEquipmentSlot.FEET)) { 117 | slot = 36; 118 | } 119 | 120 | InventoryUtil.clickSlot(itemStack.slotId); 121 | sleep(100); 122 | InventoryUtil.clickSlot(slot); 123 | sleep(100); 124 | } 125 | } 126 | } else { 127 | allArmorMended = false; 128 | } 129 | } 130 | 131 | //Mend tools or if everything is mended then toggle off 132 | if (tools.booleanValue() && allArmorMended) { 133 | ItemStack offHand = InventoryUtil.getItemStack(40); 134 | 135 | if (!isMaxDurability(offHand)) { 136 | setStatus("Mending tools"); 137 | for (int i = 0; i < 5; i++) { 138 | clickOnXp(); 139 | } 140 | } else { 141 | for (ItemStackUtil itemStack : InventoryUtil.getAllItems()) { 142 | if (itemStack.itemStack.getItem() instanceof ItemTool && !isMaxDurability(itemStack.itemStack)) { 143 | InventoryUtil.clickSlot(itemStack.slotId); 144 | sleep(100); 145 | InventoryUtil.clickSlot(40); 146 | sleep(100); 147 | InventoryUtil.clickSlot(itemStack.slotId); 148 | sleep(100); 149 | return; 150 | } 151 | } 152 | 153 | toggleModule(); 154 | } 155 | } else if (allArmorMended) { 156 | toggleModule(); 157 | } 158 | } 159 | 160 | public void clickOnXp() { 161 | if (mc.player.getHeldItemMainhand().getItem() != Items.EXPERIENCE_BOTTLE) { 162 | InventoryUtil.switchItem(InventoryUtil.getSlot(Items.EXPERIENCE_BOTTLE), true); 163 | } 164 | 165 | PlayerUtil.rightClick(); 166 | sleep(delay.intValue()); 167 | } 168 | 169 | public static int getDurability(ItemStack itemStack) { 170 | return itemStack.getMaxDamage() - itemStack.getItemDamage(); 171 | } 172 | 173 | public static boolean isMaxDurability(ItemStack itemStack) { 174 | return itemStack.getItemDamage() == 0; 175 | } 176 | } 177 | -------------------------------------------------------------------------------- /src/main/java/me/bebeli555/autobot/mods/bots/elytrabot/AStar.java: -------------------------------------------------------------------------------- 1 | package me.bebeli555.autobot.mods.bots.elytrabot; 2 | 3 | import java.util.ArrayList; 4 | 5 | import me.bebeli555.autobot.AutoBot; 6 | import me.bebeli555.autobot.utils.BlockUtil; 7 | import net.minecraft.init.Blocks; 8 | import net.minecraft.util.math.BlockPos; 9 | 10 | public class AStar extends AutoBot { 11 | private static boolean check; 12 | 13 | /** 14 | * Generates a path to the given goal. 15 | * @goal The goal it will path to 16 | * @positions The nearby positions that can possibly by added to the open list 17 | * @checkPositions The positions it will check not to be solid when iterating the above list 18 | */ 19 | public static ArrayList generatePath(BlockPos start, BlockPos goal, BlockPos[] positions, ArrayList checkPositions, int loopAmount) { 20 | AStarNode.nodes.clear(); 21 | BlockPos current = start; 22 | BlockPos closest = current; 23 | ArrayList open = new ArrayList(); 24 | ArrayList closed = new ArrayList(); 25 | 26 | int noClosest = 0; 27 | for (int i = 0; i < loopAmount; i++) { 28 | //Check if were in the goal 29 | if (current.equals(goal)) { 30 | check = false; 31 | return getPath(current); 32 | } 33 | 34 | //Get the pos with lowest f cost from open list and put it to closed list 35 | double lowestFCost = Integer.MAX_VALUE; 36 | for (BlockPos pos : open) { 37 | double fCost = fCost(pos, goal, start); 38 | 39 | if (fCost < lowestFCost) { 40 | lowestFCost = fCost; 41 | current = pos; 42 | } 43 | } 44 | 45 | //Update the lists 46 | closed.add(current); 47 | open.remove(current); 48 | 49 | ArrayList addToOpen = addToOpen(positions, checkPositions, current, goal, start, open, closed); 50 | if (addToOpen != null) { 51 | open.addAll(addToOpen); 52 | } else { 53 | break; 54 | } 55 | 56 | //Set the closest pos. 57 | if (lowestFCost < fCost(closest, goal, start)) { 58 | closest = current; 59 | noClosest = 0; 60 | } else { 61 | noClosest++; 62 | 63 | //If there hasent been a closer pos found in x times then break 64 | if (noClosest > 200) { 65 | break; 66 | } 67 | } 68 | } 69 | 70 | //If there was no path found to the goal then return path to the closest pos. 71 | //As the goal is probably out of render distance. 72 | if (!check) { 73 | check = true; 74 | return generatePath(start, closest, positions, checkPositions, loopAmount); 75 | } else { 76 | check = false; 77 | return new ArrayList(); 78 | } 79 | } 80 | 81 | /** 82 | * Adds the nearby positions to the open list. And updates the best parent for the AStarNodes 83 | */ 84 | public static ArrayList addToOpen(BlockPos[] positions, ArrayList checkPositions, BlockPos current, BlockPos goal, BlockPos start, ArrayList open, ArrayList closed) { 85 | ArrayList list = new ArrayList(); 86 | 87 | ArrayList positions2 = new ArrayList(); 88 | for (BlockPos pos : positions) { 89 | positions2.add(current.add(pos.getX(), pos.getY(), pos.getZ())); 90 | } 91 | 92 | outer: for (BlockPos pos : positions2) { 93 | if (!isSolid(pos) && !closed.contains(pos)) { 94 | ArrayList checkPositions2 = new ArrayList(); 95 | for (BlockPos b : checkPositions) { 96 | checkPositions2.add(pos.add(b.getX(), b.getY(), b.getZ())); 97 | } 98 | 99 | for (BlockPos check : checkPositions2) { 100 | if (ElytraBot.mode.stringValue().equals("Highway") && !BlockUtil.isInRenderDistance(check)) { 101 | return null; 102 | } 103 | 104 | if (isSolid(check) || !BlockUtil.isInRenderDistance(check)) { 105 | continue outer; 106 | } 107 | 108 | if (getBlock(check) == Blocks.LAVA && ElytraBot.avoidLava.booleanValue()) { 109 | continue outer; 110 | } 111 | 112 | if (ElytraBot.maxY.intValue() != -1 && check.getY() > ElytraBot.maxY.intValue()) { 113 | continue outer; 114 | } 115 | } 116 | 117 | AStarNode n = AStarNode.getNodeFromBlockpos(pos); 118 | if (n == null) { 119 | n = new AStarNode(pos); 120 | } 121 | 122 | if (!open.contains(pos)) { 123 | list.add(pos); 124 | } 125 | 126 | if (n.parent == null || gCost(current, start) < gCost(n.parent, start)) { 127 | n.parent = current; 128 | } 129 | } 130 | } 131 | 132 | return list; 133 | } 134 | 135 | /** 136 | * Calculates the f cost between pos and goal 137 | */ 138 | public static double fCost(BlockPos pos, BlockPos goal, BlockPos start) { 139 | // H cost 140 | double dx = goal.getX() - pos.getX(); 141 | double dz = goal.getZ() - pos.getZ(); 142 | double h = Math.sqrt(dx * dx + dz * dz); 143 | double fCost = gCost(pos, start) + h; 144 | 145 | return fCost; 146 | } 147 | 148 | /** 149 | * Calculates the G Cost 150 | */ 151 | public static double gCost(BlockPos pos, BlockPos start) { 152 | double dx = start.getX() - pos.getX(); 153 | double dy = start.getY() - pos.getY(); 154 | double dz = start.getZ() - pos.getZ(); 155 | return Math.sqrt(Math.abs(dx) + Math.abs(dy) + Math.abs(dz)); 156 | } 157 | 158 | /** 159 | * Gets the path by backtracing the closed list with the AStarNode things 160 | */ 161 | private static ArrayList getPath(BlockPos current) { 162 | ArrayList path = new ArrayList(); 163 | 164 | try { 165 | AStarNode n = AStarNode.getNodeFromBlockpos(current); 166 | if (n == null) { 167 | n = AStarNode.nodes.get(AStarNode.nodes.size() - 1); 168 | } 169 | path.add(n.pos); 170 | 171 | while (n != null && n.parent != null) { 172 | path.add(n.parent); 173 | n = AStarNode.getNodeFromBlockpos(n.parent); 174 | } 175 | } catch (IndexOutOfBoundsException e) { 176 | //Ingored. The path is zero in lenght 177 | } 178 | 179 | return path; 180 | } 181 | 182 | /** 183 | * Used for backtracing the closed list to get the actual path 184 | */ 185 | public static class AStarNode { 186 | public static ArrayList nodes = new ArrayList(); 187 | public BlockPos pos; 188 | public BlockPos parent; 189 | 190 | public AStarNode(BlockPos pos) { 191 | this.pos = pos; 192 | nodes.add(this); 193 | } 194 | 195 | public static AStarNode getNodeFromBlockpos(BlockPos pos) { 196 | for (AStarNode node : nodes) { 197 | if (node.pos.equals(pos)) { 198 | return node; 199 | } 200 | } 201 | 202 | return null; 203 | } 204 | } 205 | } 206 | -------------------------------------------------------------------------------- /src/main/java/me/bebeli555/autobot/gui/GuiNode.java: -------------------------------------------------------------------------------- 1 | package me.bebeli555.autobot.gui; 2 | 3 | import java.util.ArrayList; 4 | 5 | import com.mojang.realmsclient.gui.ChatFormatting; 6 | 7 | import me.bebeli555.autobot.AutoBot; 8 | 9 | public class GuiNode extends AutoBot { 10 | public static ArrayList all = new ArrayList(); 11 | 12 | public GuiNode parent; 13 | public String name; 14 | public String id = ""; 15 | public String stringValue = ""; 16 | public String defaultValue = ""; 17 | public String modeName = ""; 18 | public boolean isTypeable; 19 | public boolean onlyNumbers; 20 | public boolean acceptDoubleValues; 21 | public boolean isVisible; 22 | public boolean toggled; 23 | public boolean isLabel; 24 | public boolean isKeybind; 25 | public boolean isExtended; 26 | public Group group; 27 | public String[] description; 28 | public ArrayList modes = new ArrayList(); 29 | public ArrayList> modeDescriptions = new ArrayList>(); 30 | public ArrayList parentedNodes = new ArrayList(); 31 | public ArrayList clickListeners = new ArrayList(); 32 | public ArrayList keyListeners = new ArrayList(); 33 | 34 | public GuiNode(boolean dontAdd) { 35 | 36 | } 37 | 38 | public GuiNode() { 39 | all.add(this); 40 | } 41 | 42 | //Sets the setting with the same ID as this GuiNode 43 | public void setSetting() { 44 | if (isTypeable || modes.size() != 0) { 45 | if (acceptDoubleValues) { 46 | try { 47 | Setting.getSettingWithId(id).value = Double.parseDouble(stringValue); 48 | } catch (Exception e) { 49 | stringValue = ""; 50 | Setting.getSettingWithId(id).value = -1; 51 | } 52 | } else if (onlyNumbers) { 53 | try { 54 | Setting.getSettingWithId(id).value = Integer.parseInt(stringValue); 55 | } catch (Exception e) { 56 | stringValue = ""; 57 | Setting.getSettingWithId(id).value = -1; 58 | } 59 | } else { 60 | if (!isKeybind) { 61 | Setting.getSettingWithId(id).value = stringValue; 62 | } 63 | } 64 | } else { 65 | Setting.getSettingWithId(id).value = toggled; 66 | } 67 | } 68 | 69 | //Add click listener 70 | public void addClickListener(ClickListener listener) { 71 | clickListeners.add(listener); 72 | } 73 | 74 | //Add key listener 75 | public void addKeyListener(KeyListener listener) { 76 | keyListeners.add(listener); 77 | } 78 | 79 | //Sets this to the default value 80 | public void setDefaultValue() { 81 | if (this.isTypeable) { 82 | stringValue = defaultValue; 83 | } else { 84 | toggled = Boolean.parseBoolean(defaultValue); 85 | } 86 | } 87 | 88 | //Gets called when this node is clicked on the gui 89 | public void click() { 90 | if (isLabel) { 91 | return; 92 | } 93 | 94 | //Mode 95 | if (modes.size() != 0) { 96 | extend(false); 97 | 98 | try { 99 | stringValue = modes.get(modes.indexOf(stringValue) + 1); 100 | } catch (IndexOutOfBoundsException e) { 101 | stringValue = modes.get(0); 102 | } 103 | } 104 | 105 | //Toggle 106 | if (!this.isTypeable && modes.size() == 0) { 107 | toggled = !toggled; 108 | 109 | for (AutoBot module : modules) { 110 | if (module.name.equals(name)) { 111 | if (toggled) { 112 | if (!module.disableToggleMessage) sendMessage(ChatFormatting.LIGHT_PURPLE + module.name + ChatFormatting.WHITE + " toggled " + ChatFormatting.GREEN + "ON", false); 113 | module.onEnabled(); 114 | module.toggled = true; 115 | } else { 116 | if (!module.disableToggleMessage) sendMessage(ChatFormatting.LIGHT_PURPLE + module.name + ChatFormatting.WHITE + " toggled " + ChatFormatting.RED + "OFF", false); 117 | module.onDisabled(); 118 | module.toggled = false; 119 | } 120 | 121 | break; 122 | } 123 | } 124 | } 125 | 126 | //Notify listeners 127 | setSetting(); 128 | notifyClickListeners(); 129 | } 130 | 131 | /** 132 | * Extend this node and reveal all the nodes that parent this node 133 | * @param extend if true it will extend it if false it will un extend it 134 | */ 135 | public void extend(boolean extend) { 136 | for (GuiNode node : parentedNodes) { 137 | if (!node.modeName.isEmpty() && !node.modeName.equals(stringValue)) { 138 | continue; 139 | } 140 | 141 | node.isVisible = extend; 142 | isExtended = extend; 143 | 144 | //Un extend all the other nodes that parent the extends too 145 | if (extend == false) { 146 | for (GuiNode n : all) { 147 | if (n.id.contains(node.id)) { 148 | n.isVisible = false; 149 | } 150 | } 151 | } 152 | } 153 | } 154 | 155 | //Sets the ID for this node. 156 | public void setId() { 157 | if (this.parent != null) { 158 | ArrayList parents = getAllParents(); 159 | 160 | for (int i = parents.size(); i-- > 0;) { 161 | this.id += parents.get(i).name; 162 | } 163 | 164 | this.id += name; 165 | } else { 166 | this.id = name; 167 | } 168 | } 169 | 170 | //Get text color 171 | public int getTextColor() { 172 | if (isLabel) { 173 | return GuiSettings.labelColor.intValue(); 174 | } else if (toggled) { 175 | return GuiSettings.textColor.intValue(); 176 | } else { 177 | return GuiSettings.textColorOff.intValue(); 178 | } 179 | } 180 | 181 | //Get the top parent of this node 182 | public GuiNode getTopParent() { 183 | ArrayList parents = getAllParents(); 184 | return parents.get(parents.size() - 1); 185 | } 186 | 187 | //Gets all parents from this node. First in list is this objects parent 188 | public ArrayList getAllParents() { 189 | ArrayList parents = new ArrayList(); 190 | 191 | GuiNode parent = this.parent; 192 | while(true) { 193 | if (parent != null) { 194 | parents.add(parent); 195 | 196 | if (parent.parent != null) { 197 | parent = parent.parent; 198 | continue; 199 | } 200 | } 201 | 202 | break; 203 | } 204 | 205 | return parents; 206 | } 207 | 208 | public void notifyClickListeners() { 209 | for (ClickListener listener : clickListeners) { 210 | listener.clicked(); 211 | } 212 | } 213 | 214 | public void notifyKeyListeners() { 215 | for (KeyListener listener : keyListeners) { 216 | listener.pressed(); 217 | } 218 | } 219 | 220 | public static class ClickListener { 221 | public void clicked() { 222 | 223 | } 224 | } 225 | 226 | public static class KeyListener { 227 | public void pressed() { 228 | 229 | } 230 | } 231 | } 232 | -------------------------------------------------------------------------------- /src/main/java/me/bebeli555/autobot/mods/other/AutoWither.java: -------------------------------------------------------------------------------- 1 | package me.bebeli555.autobot.mods.other; 2 | 3 | import me.bebeli555.autobot.AutoBot; 4 | import me.bebeli555.autobot.gui.Group; 5 | import me.bebeli555.autobot.gui.Mode; 6 | import me.bebeli555.autobot.gui.Setting; 7 | import me.bebeli555.autobot.mods.bots.crystalpvpbot.Surround; 8 | import me.bebeli555.autobot.utils.BlockUtil; 9 | import me.bebeli555.autobot.utils.InventoryUtil; 10 | import net.minecraft.init.Blocks; 11 | import net.minecraft.init.Items; 12 | import net.minecraft.util.math.BlockPos; 13 | 14 | /** 15 | * Not in use currently as it doesnt work well on servers with ray tracing and you can just use the AutoBuilder to build withers. 16 | */ 17 | public class AutoWither extends AutoBot { 18 | public static Setting radius = new Setting(Mode.INTEGER, "Radius", 3, "Radius around the player to search for available spot", "Like the place distance"); 19 | public static Setting delay = new Setting(Mode.INTEGER, "Delay", 80, "Delay in ms to wait after a successfull place"); 20 | public static Setting nametag = new Setting(Mode.BOOLEAN, "Nametag", false, "Puts a nametag to the wither after it spawns"); 21 | 22 | public AutoWither() { 23 | super(Group.OTHER, "AutoWither", "Builds a wither to an available spot nearby", "With the best shape and position possible!"); 24 | } 25 | 26 | @Override 27 | public void onEnabled() { 28 | new Thread() { 29 | public void run() { 30 | if (!InventoryUtil.hasBlock(Blocks.SOUL_SAND) || !InventoryUtil.hasItem(Items.SKULL)) { 31 | toggleModule(); 32 | sendMessage("You dont have the required materials to build a wither", true); 33 | return; 34 | } 35 | 36 | BlockPos[][] shapes = new BlockPos[][]{ 37 | new BlockPos[]{new BlockPos(0, 0, 0), new BlockPos(0, 1, 0), new BlockPos(1, 1, 0), new BlockPos(-1, 1, 0), new BlockPos(0, 2, 0), new BlockPos(1, 2, 0), new BlockPos(-1, 2, 0)}, 38 | new BlockPos[]{new BlockPos(0, 0, 0), new BlockPos(0, 1, 0), new BlockPos(0, 1, 1), new BlockPos(0, 1, -1), new BlockPos(0, 2, 0), new BlockPos(0, 2, 1), new BlockPos(0, 2, -1)}, 39 | new BlockPos[]{new BlockPos(0, 0, 0), new BlockPos(0, 0, -1), new BlockPos(1, 0, -1), new BlockPos(-1, 0, -1), new BlockPos(0, 0, -2), new BlockPos(1, 0, -2), new BlockPos(-1, 0, -2)}, 40 | new BlockPos[]{new BlockPos(0, 0, 0), new BlockPos(0, 0, 1), new BlockPos(1, 0, 1), new BlockPos(-1, 0, 1), new BlockPos(0, 0, 2), new BlockPos(1, 0, 2), new BlockPos(-1, 0, 2)}, 41 | new BlockPos[]{new BlockPos(0, 0, 0), new BlockPos(-1, 0, 0), new BlockPos(-1, 0, 1), new BlockPos(-1, 0, -1), new BlockPos(-2, 0, 0), new BlockPos(-2, 0, 1), new BlockPos(-2, 0, -1)}, 42 | new BlockPos[]{new BlockPos(0, 0, 0), new BlockPos(1, 0, 0), new BlockPos(1, 0, 1), new BlockPos(1, 0, -1), new BlockPos(2, 0, 0), new BlockPos(2, 0, 1), new BlockPos(2, 0, -1)} 43 | }; 44 | 45 | BlockPos bestPos = null; 46 | BlockPos[] bestShape = null; 47 | double lowestPosDistance = Integer.MAX_VALUE; 48 | double lowestShapeDistance = Integer.MAX_VALUE; 49 | 50 | //Get the best spot 51 | outer: for (BlockPos pos : BlockUtil.getAll(radius.intValue())) { 52 | //Dont use this pos if its the same as the player or y is lower than 0 53 | if (pos.equals(getPlayerPos()) || pos.getY() <= 0) { 54 | continue outer; 55 | } 56 | 57 | if (getPlayerPos().distanceSq(pos.getX(), pos.getY(), pos.getZ()) >= lowestPosDistance) { 58 | continue outer; 59 | } 60 | 61 | //Check if some shape is compatible with the pos 62 | shape: for (BlockPos[] shape : shapes) { 63 | if (!isSolid(pos.add(shape[0].getX(), shape[0].getY() - 1, shape[0].getZ()))) { 64 | continue shape; 65 | } 66 | 67 | for (BlockPos check : shape) { 68 | if (getBlock(pos.add(check.getX(), check.getY(), check.getZ())) != Blocks.AIR) { 69 | continue shape; 70 | } 71 | 72 | if (getPlayerPos().getX() == pos.add(check.getX(), check.getY(), check.getZ()).getX() && getPlayerPos().getZ() == pos.add(check.getX(), check.getY(), check.getZ()).getZ()) { 73 | continue shape; 74 | } 75 | } 76 | 77 | lowestPosDistance = mc.player.getDistanceSq(pos); 78 | bestPos = pos; 79 | continue outer; 80 | } 81 | } 82 | 83 | //Get the best shape for the best pos 84 | if (bestPos != null) { 85 | shape: for (BlockPos[] shape : shapes) { 86 | //Check if the block below the first one is solid so it can be built 87 | if (!isSolid(bestPos.add(shape[0].getX(), shape[0].getY() - 1, shape[0].getZ()))) { 88 | continue shape; 89 | } 90 | 91 | //check if the pos is all air for the shape 92 | for (BlockPos check : shape) { 93 | if (getBlock(bestPos.add(check.getX(), check.getY(), check.getZ())) != Blocks.AIR) { 94 | continue shape; 95 | } 96 | 97 | //If one of the positions is the player pos then continue as the shape cant be built 98 | if (getPlayerPos().getX() == bestPos.add(check.getX(), check.getY(), check.getZ()).getX() && getPlayerPos().getZ() == bestPos.add(check.getX(), check.getY(), check.getZ()).getZ()) { 99 | continue shape; 100 | } 101 | } 102 | 103 | //Check the highest distance from this shape and set bestPos 104 | double highestDistance = Integer.MIN_VALUE; 105 | for (BlockPos check : shape) { 106 | BlockPos player = getPlayerPos(); 107 | BlockPos pos2 = bestPos.add(check.getX(), 0, check.getZ()); 108 | double distance = player.distanceSq(pos2); 109 | if (distance > highestDistance) { 110 | highestDistance = distance; 111 | } 112 | } 113 | 114 | if (highestDistance < lowestShapeDistance) { 115 | lowestShapeDistance = highestDistance; 116 | bestShape = shape; 117 | } 118 | } 119 | } 120 | 121 | //Then build it if it aint null 122 | if (bestShape != null && bestPos != null) { 123 | Surround.center(); 124 | 125 | for (int i = 0; i < bestShape.length; i++) { 126 | BlockPos build = bestPos.add(bestShape[i].getX(), bestShape[i].getY(), bestShape[i].getZ()); 127 | 128 | if (i > 3) { 129 | BlockUtil.placeItem(Items.SKULL, build, true); 130 | } else { 131 | BlockUtil.placeBlock(Blocks.SOUL_SAND, build, true); 132 | } 133 | 134 | AutoBot.sleep(delay.intValue()); 135 | } 136 | } else { 137 | toggleModule(); 138 | sendMessage("Couldnt find a suitable spot to build wither in the set radius", true); 139 | return; 140 | } 141 | 142 | toggleModule(); 143 | } 144 | }.start(); 145 | } 146 | } 147 | -------------------------------------------------------------------------------- /src/main/java/me/bebeli555/autobot/utils/InventoryUtil.java: -------------------------------------------------------------------------------- 1 | package me.bebeli555.autobot.utils; 2 | 3 | import java.util.ArrayList; 4 | 5 | import me.bebeli555.autobot.AutoBot; 6 | import net.minecraft.block.Block; 7 | import net.minecraft.init.Items; 8 | import net.minecraft.inventory.ClickType; 9 | import net.minecraft.item.Item; 10 | import net.minecraft.item.ItemStack; 11 | 12 | public class InventoryUtil extends AutoBot { 13 | 14 | /** 15 | * Gets the slot id for the slot where the hand is currently 16 | */ 17 | public static int getHandSlot() { 18 | return mc.player.inventory.currentItem; 19 | } 20 | 21 | /** 22 | * Get slot id for this block if its on inventory 23 | */ 24 | public static int getSlot(Block block) { 25 | try { 26 | for (ItemStackUtil itemStack : getAllItems()) { 27 | if (Block.getBlockFromItem(itemStack.itemStack.getItem()).equals(block)) { 28 | return itemStack.slotId; 29 | } 30 | } 31 | } catch (Exception ignored) { 32 | 33 | } 34 | 35 | return -1; 36 | } 37 | 38 | /** 39 | * Get slot id for this item if its on inventory 40 | */ 41 | public static int getSlot(Item item) { 42 | try { 43 | for (ItemStackUtil itemStack : getAllItems()) { 44 | if (itemStack.itemStack.getItem().equals(item)) { 45 | return itemStack.slotId; 46 | } 47 | } 48 | } catch (Exception ignored) { 49 | 50 | } 51 | 52 | return -1; 53 | } 54 | 55 | /** 56 | * Clicks the inventory slot with given id 57 | */ 58 | public static void clickSlot(int id) { 59 | if (id != -1) { 60 | mc.playerController.windowClick(mc.player.openContainer.windowId, getClickSlot(id), 0, ClickType.PICKUP, mc.player); 61 | } 62 | } 63 | 64 | /** 65 | * Clicks the inventory slot with given id 66 | * @otherRows How many other rows is present like shulker has 27 but you gotta put 18 here if shulker because thats how it works. 67 | */ 68 | public static void clickSlot(int id, int otherRows) { 69 | if (id != -1) { 70 | mc.playerController.windowClick(mc.player.openContainer.windowId, getClickSlot(id) + otherRows, 0, ClickType.PICKUP, mc.player); 71 | } 72 | } 73 | 74 | /** 75 | * Returns the click slot because the slots you click and the other slots are with different ids for some reason. 76 | */ 77 | public static int getClickSlot(int id) { 78 | if (id == -1) { 79 | return id; 80 | } 81 | 82 | if (id < 9) { 83 | id += 36; 84 | return id; 85 | } 86 | 87 | if (id == 39) { 88 | id = 5; 89 | } else if (id == 38) { 90 | id = 6; 91 | } else if (id == 37) { 92 | id = 7; 93 | } else if (id == 36) { 94 | id = 8; 95 | } else if (id == 40) { 96 | id = 45; 97 | } 98 | 99 | return id; 100 | } 101 | 102 | /** 103 | * Switches the hand to the given slot or puts the item there if it aint in hotbar 104 | */ 105 | public static void switchItem(int slot, boolean sleep) { 106 | if (slot < 9) { 107 | mc.player.inventory.currentItem = slot; 108 | } else { 109 | clickSlot(slot); 110 | if (sleep) sleep(200); 111 | clickSlot(8); 112 | if (sleep) sleep(200); 113 | clickSlot(slot); 114 | if (sleep) sleep(200); 115 | mc.player.inventory.currentItem = 8; 116 | if (sleep) sleep(100); 117 | } 118 | } 119 | 120 | /** 121 | * @return the ItemStack in the given slotid 122 | */ 123 | public static ItemStack getItemStack(int id) { 124 | try { 125 | return mc.player.inventory.getStackInSlot(id); 126 | } catch (NullPointerException e) { 127 | return null; 128 | } 129 | } 130 | 131 | /** 132 | * Gets the amount of the given items u have in ur inventory 133 | */ 134 | public static int getAmountOfItem(Item item) { 135 | int count = 0; 136 | 137 | for (ItemStackUtil itemStack : getAllItems()) { 138 | if (itemStack.itemStack != null && itemStack.itemStack.getItem().equals(item)) { 139 | count += itemStack.itemStack.getCount(); 140 | } 141 | } 142 | 143 | return count; 144 | } 145 | 146 | /** 147 | * Get the amount of the given blocks u have in inventory 148 | */ 149 | public static int getAmountOfBlock(Block block) { 150 | int count = 0; 151 | 152 | for (ItemStackUtil itemStack : getAllItems()) { 153 | if (Block.getBlockFromItem(itemStack.itemStack.getItem()).equals(block)) { 154 | count += itemStack.itemStack.getCount(); 155 | } 156 | } 157 | 158 | return count; 159 | } 160 | 161 | /** 162 | * Checks if u have the given item 163 | */ 164 | public static boolean hasItem(Item item) { 165 | return getAmountOfItem(item) != 0; 166 | } 167 | 168 | /** 169 | * Check if hotbar has the given item 170 | */ 171 | public static boolean hasHotbarItem(Item item) { 172 | for (int i = 0; i < 9; i++) { 173 | if (getItemStack(i).getItem() == item) { 174 | return true; 175 | } 176 | } 177 | 178 | return false; 179 | } 180 | 181 | /** 182 | * Check if ur inventory contains the given block 183 | */ 184 | public static boolean hasBlock(Block block) { 185 | return getSlot(block) != -1; 186 | } 187 | 188 | /** 189 | * Checks if the players inventory is full 190 | */ 191 | public static boolean isFull() { 192 | for (ItemStackUtil itemStack : getAllItems()) { 193 | if (itemStack.itemStack.getItem() == Items.AIR) { 194 | return false; 195 | } 196 | } 197 | 198 | return true; 199 | } 200 | 201 | /** 202 | * Gets the amount of empty slots in your inventory 203 | */ 204 | public static int getEmptySlots() { 205 | int count = 0; 206 | for (ItemStackUtil itemStack : getAllItems()) { 207 | if (itemStack.itemStack.getItem() == Items.AIR) { 208 | count++; 209 | } 210 | } 211 | 212 | return count; 213 | } 214 | 215 | /** 216 | * Returns the slot id of an empty slot in ur inventory 217 | */ 218 | public static int getEmptySlot() { 219 | for (ItemStackUtil itemStack : getAllItems()) { 220 | if (itemStack.itemStack.getItem() == Items.AIR) { 221 | return itemStack.slotId; 222 | } 223 | } 224 | 225 | return -1; 226 | } 227 | 228 | /** 229 | * @return a list of all items in your inventory 230 | */ 231 | public static ArrayList getAllItems() { 232 | ArrayList items = new ArrayList(); 233 | 234 | for (int i = 0; i < 36; i++) { 235 | items.add(new ItemStackUtil(getItemStack(i), i)); 236 | } 237 | 238 | return items; 239 | } 240 | 241 | public static class ItemStackUtil { 242 | public ItemStack itemStack; 243 | public int slotId; 244 | 245 | public ItemStackUtil(ItemStack itemStack, int slotId) { 246 | this.itemStack = itemStack; 247 | this.slotId = slotId; 248 | } 249 | } 250 | } 251 | -------------------------------------------------------------------------------- /src/main/java/me/bebeli555/autobot/mods/other/Burrow.java: -------------------------------------------------------------------------------- 1 | package me.bebeli555.autobot.mods.other; 2 | 3 | import me.bebeli555.autobot.AutoBot; 4 | import me.bebeli555.autobot.events.PacketEvent; 5 | import me.bebeli555.autobot.gui.Group; 6 | import me.bebeli555.autobot.gui.Mode; 7 | import me.bebeli555.autobot.gui.Setting; 8 | import me.bebeli555.autobot.mods.bots.crystalpvpbot.Surround; 9 | import me.bebeli555.autobot.utils.BlockUtil; 10 | import me.bebeli555.autobot.utils.InventoryUtil; 11 | import me.bebeli555.autobot.utils.InventoryUtil.ItemStackUtil; 12 | import me.bebeli555.autobot.utils.RotationUtil; 13 | import me.zero.alpine.listener.EventHandler; 14 | import me.zero.alpine.listener.Listener; 15 | import net.minecraft.block.Block; 16 | import net.minecraft.init.Blocks; 17 | import net.minecraft.item.ItemBlock; 18 | import net.minecraft.network.play.client.CPacketConfirmTeleport; 19 | import net.minecraft.network.play.client.CPacketPlayer; 20 | import net.minecraft.network.play.server.SPacketPlayerPosLook; 21 | import net.minecraft.util.math.BlockPos; 22 | import net.minecraftforge.common.MinecraftForge; 23 | import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; 24 | import net.minecraftforge.fml.common.gameevent.TickEvent.ClientTickEvent; 25 | 26 | public class Burrow extends AutoBot { 27 | public static Burrow burrow; 28 | private static boolean done; 29 | private static Block placeBlock; 30 | 31 | public static Setting mode = new Setting(null, "Mode", "Instant", new String[]{"Instant", "Places the block instantly"}, new String[]{"Jump", "Jumps and places the block"}); 32 | public static Setting delay = new Setting(mode, "Jump", Mode.INTEGER, "Delay", 250, "Delay in ms to wait after the first jump", "To placing the block and second jump"); 33 | public static Setting height = new Setting(mode, "Instant", Mode.DOUBLE, "Height", 10, "How many blocks to teleport up after placing", "The block to trigger tha anticheat"); 34 | public static Setting center = new Setting(Mode.BOOLEAN, "Center", true, "Centers you in the middle of the block before doing the thing"); 35 | 36 | public Burrow() { 37 | super(Group.OTHER, "Burrow", true, "Glitches you inside obsidian"); 38 | burrow = this; 39 | } 40 | 41 | @Override 42 | public void onEnabled() { 43 | if (mc.player == null) { 44 | toggleModule(); 45 | return; 46 | } 47 | 48 | new Thread() { 49 | public void run() { 50 | if (isSolid(getPlayerPos())) { 51 | sendMessage("You are already burrowed", true); 52 | toggleModule(); 53 | return; 54 | } 55 | 56 | Block block = null; 57 | 58 | //If the player has obsidian then use that as its the best 59 | if (InventoryUtil.hasBlock(Blocks.OBSIDIAN)) { 60 | block = Blocks.OBSIDIAN; 61 | } else { 62 | //First search the hotbar for blocks 63 | for (int i = 0; i < 9; i++) { 64 | if (InventoryUtil.getItemStack(i).getItem() instanceof ItemBlock) { 65 | block = Block.getBlockFromItem(InventoryUtil.getItemStack(i).getItem()); 66 | break; 67 | } 68 | } 69 | 70 | //Then search the entire inventory if no blocks were in hotbar 71 | if (block == null) { 72 | for (ItemStackUtil itemStack : InventoryUtil.getAllItems()) { 73 | if (itemStack.itemStack.getItem() instanceof ItemBlock) { 74 | block = Block.getBlockFromItem(itemStack.itemStack.getItem()); 75 | break; 76 | } 77 | } 78 | } 79 | } 80 | 81 | if (block == null) { 82 | sendMessage("You dont have any placeable block", true); 83 | toggleModule(); 84 | return; 85 | } 86 | 87 | //Switch to block 88 | int oldSlot = mc.player.inventory.currentItem; 89 | InventoryUtil.switchItem(InventoryUtil.getSlot(block), false); 90 | 91 | //Center 92 | if (center.booleanValue()) { 93 | Surround.center(); 94 | } 95 | 96 | //Instant mode. this is run on the minecraft thread. 97 | if (mode.stringValue().equals("Instant")) { 98 | placeBlock = block; 99 | MinecraftForge.EVENT_BUS.register(burrow); 100 | sleepUntil(() -> done, 200, 5); 101 | } 102 | 103 | //Jump mode 104 | else if (mode.stringValue().equals("Jump")) { 105 | BlockPos start = getPlayerPos(); 106 | mc.player.jump(); 107 | AutoBot.sleep(delay.intValue()); 108 | BlockUtil.placeBlock(block, start, true); 109 | mc.player.jump(); 110 | } 111 | 112 | //Put old hotbar slot back 113 | mc.player.inventory.currentItem = oldSlot; 114 | 115 | //Cancel force rotation from server 116 | AutoBot.EVENT_BUS.subscribe(burrow); 117 | toggleModule(); 118 | } 119 | }.start(); 120 | } 121 | 122 | @Override 123 | public void onDisabled() { 124 | RotationUtil.stopRotating(); 125 | done = false; 126 | } 127 | 128 | @SubscribeEvent 129 | public void onTick(ClientTickEvent e) { 130 | BlockPos start = getPlayerPos(); 131 | 132 | mc.player.connection.sendPacket(new CPacketPlayer.Position(mc.player.posX, mc.player.posY + 0.41999998688698D, mc.player.posZ, true)); 133 | mc.player.connection.sendPacket(new CPacketPlayer.Position(mc.player.posX, mc.player.posY + 0.7531999805211997D, mc.player.posZ, true)); 134 | mc.player.connection.sendPacket(new CPacketPlayer.Position(mc.player.posX, mc.player.posY + 1.00133597911214D, mc.player.posZ, true)); 135 | mc.player.connection.sendPacket(new CPacketPlayer.Position(mc.player.posX, mc.player.posY + 1.16610926093821D, mc.player.posZ, true)); 136 | mc.player.setPosition(mc.player.posX, mc.player.posY + 1.16610926093821D, mc.player.posZ); 137 | 138 | BlockUtil.placeBlockOnThisThread(placeBlock, start, true); 139 | mc.player.setPosition(mc.player.posX, start.getY(), mc.player.posZ); 140 | mc.player.connection.sendPacket(new CPacketPlayer.Position(mc.player.posX, mc.player.posY + height.doubleValue(), mc.player.posZ, false)); 141 | 142 | MinecraftForge.EVENT_BUS.unregister(burrow); 143 | done = true; 144 | } 145 | 146 | @EventHandler 147 | private Listener packetEvent = new Listener<>(event -> { 148 | if (mc.player == null) { 149 | AutoBot.EVENT_BUS.unsubscribe(burrow); 150 | return; 151 | } 152 | 153 | if (event.packet instanceof SPacketPlayerPosLook) { 154 | event.cancel(); 155 | 156 | SPacketPlayerPosLook packet = (SPacketPlayerPosLook)event.packet; 157 | mc.player.setPosition(packet.getX(), packet.getY(), packet.getZ()); 158 | mc.player.motionY = 0; 159 | 160 | mc.getConnection().sendPacket(new CPacketConfirmTeleport(packet.getTeleportId())); 161 | mc.getConnection().sendPacket(new CPacketPlayer.PositionRotation(mc.player.posX, mc.player.getEntityBoundingBox().minY, mc.player.posZ, packet.getYaw(), packet.getPitch(), false)); 162 | 163 | AutoBot.EVENT_BUS.unsubscribe(burrow); 164 | } 165 | }); 166 | } 167 | -------------------------------------------------------------------------------- /src/main/java/me/bebeli555/autobot/mods/games/Snake.java: -------------------------------------------------------------------------------- 1 | package me.bebeli555.autobot.mods.games; 2 | 3 | import java.util.ArrayList; 4 | import java.util.Random; 5 | 6 | import org.lwjgl.input.Keyboard; 7 | 8 | import com.mojang.realmsclient.gui.ChatFormatting; 9 | 10 | import me.bebeli555.autobot.AutoBot; 11 | import me.bebeli555.autobot.gui.Group; 12 | import net.minecraft.client.gui.GuiScreen; 13 | import net.minecraft.client.renderer.GlStateManager; 14 | import net.minecraft.init.SoundEvents; 15 | import net.minecraft.util.SoundCategory; 16 | import net.minecraftforge.client.event.GuiScreenEvent; 17 | 18 | public class Snake extends AutoBot { 19 | public static ArrayList bodyX = new ArrayList(); 20 | public static ArrayList bodyY = new ArrayList(); 21 | public static int snakeSize = 0; 22 | public static int snakeX, snakeY; 23 | public static int lastSnakeX, lastSnakeY; 24 | public static int lastBodyX, lastBodyY; 25 | public static boolean gameOver = true; 26 | public static int score = 0; 27 | public static int appleX, appleY; 28 | public static int delay = 0; 29 | public static long lastSec = 0; 30 | public static String direction; 31 | 32 | public static int x = mc.displayWidth / 4; 33 | public static int y = mc.displayHeight / 5; 34 | 35 | public Snake() { 36 | super(Group.GAMES, "Snake", true, "Snake game"); 37 | } 38 | 39 | @Override 40 | public void onGuiDrawScreen(int mouseX, int mouseY, float partialTicks) { 41 | GlStateManager.pushMatrix(); 42 | GlStateManager.scale(1.5F, 1.5F, 1.5F); 43 | GuiScreen.drawRect(x - 1, y - 1, x + 201, y + 201, 0xFF42f5bc); 44 | GuiScreen.drawRect(x, y, x + 200, y + 200, 0xFF000000); 45 | 46 | //Game over. 47 | if (snakeX < x || snakeX >= x + 200 || snakeY < y || snakeY >= y + 200) { 48 | gameOver(); 49 | } 50 | 51 | if (!gameOver) { 52 | //Die if head is colliding in body 53 | for (int i = 0; i < bodyX.size(); i++) { 54 | if (bodyX.get(i) == snakeX) { 55 | if (bodyY.get(i) == snakeY) { 56 | gameOver(); 57 | return; 58 | } 59 | } 60 | } 61 | 62 | //Draw score 63 | mc.fontRenderer.drawStringWithShadow(ChatFormatting.RED + "Score = " + ChatFormatting.GREEN + snakeSize, x + 3, y + 2, 0xffff); 64 | 65 | // Generate apple 66 | if (appleX == 0 || appleY == 0) { 67 | generateApple(); 68 | } 69 | 70 | // Draw apple 71 | GuiScreen.drawRect(appleX, appleY, appleX + 20, appleY + 20, 0xFFff0000); 72 | 73 | long sec = System.currentTimeMillis() / 150; 74 | if (sec != lastSec) { 75 | delay = 0; 76 | // Control snake movement 77 | if (direction.equals("Up")) { 78 | snakeY = snakeY - 20; 79 | } else if (direction.equals("Down")) { 80 | snakeY = snakeY + 20; 81 | } else if (direction.equals("Right")) { 82 | snakeX = snakeX + 20; 83 | } else if (direction.equals("Left")) { 84 | snakeX = snakeX - 20; 85 | } 86 | 87 | if (!bodyX.isEmpty()) { 88 | bodyX.remove(bodyX.get(0)); 89 | bodyY.remove(bodyY.get(0)); 90 | bodyX.add(lastSnakeX); 91 | bodyY.add(lastSnakeY); 92 | } 93 | lastSec = sec; 94 | } 95 | 96 | //Eat apple 97 | if (snakeX == appleX) { 98 | if (snakeY == appleY) { 99 | snakeSize++; 100 | appleX = 0; 101 | appleY = 0; 102 | 103 | //More body for snake bcs he fat and eating all those sugary apples 104 | if (bodyX.isEmpty()) { 105 | bodyX.add(lastSnakeX); 106 | bodyY.add(lastSnakeY); 107 | } else { 108 | bodyX.add(lastBodyX); 109 | bodyY.add(lastBodyY); 110 | } 111 | mc.world.playSound(getPlayerPos(), SoundEvents.ENTITY_PLAYER_LEVELUP, SoundCategory.AMBIENT, 100.0f, 2.0F, true); 112 | } 113 | } 114 | 115 | lastSnakeX = snakeX; 116 | lastSnakeY = snakeY; 117 | if (!bodyX.isEmpty()) { 118 | lastBodyX = bodyX.get(bodyX.size() - 1); 119 | lastBodyY = bodyY.get(bodyY.size() - 1); 120 | } 121 | 122 | // Draw snake 123 | GuiScreen.drawRect(snakeX, snakeY, snakeX + 20, snakeY + 20, 0xFF55ff00); 124 | GuiScreen.drawRect(snakeX + 3, snakeY + 3, snakeX + 8, snakeY + 8, 0xFF000000); 125 | for (int i = 0; i < bodyX.size(); i++) { 126 | if (!bodyX.isEmpty()) { 127 | GuiScreen.drawRect(bodyX.get(i), bodyY.get(i), bodyX.get(i) + 20, bodyY.get(i) + 20, 0xFF55ff00); 128 | } 129 | } 130 | } 131 | 132 | //Game over screen 133 | if (gameOver == true) { 134 | GlStateManager.pushMatrix(); 135 | GlStateManager.scale(3.0F, 3.0F, 3.0F); 136 | mc.fontRenderer.drawStringWithShadow(ChatFormatting.RED + "Game Over!", (x / 3) + 6, (y / 3) + 2, 0xffff); 137 | mc.fontRenderer.drawStringWithShadow(ChatFormatting.LIGHT_PURPLE + "Score = " + ChatFormatting.GREEN + snakeSize, (x / 3) + 9, (y / 3) + 12, 0xffff); 138 | GlStateManager.popMatrix(); 139 | GlStateManager.pushMatrix(); 140 | GlStateManager.scale(2.0F, 2.0F, 2.0F); 141 | mc.fontRenderer.drawStringWithShadow(ChatFormatting.GREEN + "Click to Play!", (x / 2) + 18, (y / 2) + 85, 0xffff); 142 | GlStateManager.popMatrix(); 143 | GlStateManager.pushMatrix(); 144 | GlStateManager.scale(1.5F, 1.5F, 1.5F); 145 | mc.fontRenderer.drawStringWithShadow(ChatFormatting.AQUA + "Use " + ChatFormatting.GREEN + "ARROW KEYS " + ChatFormatting.AQUA + "To play!", (int)(x / 1.5) + 5, (int)(y / 1.5) + 75, 0xffff); 146 | GlStateManager.popMatrix(); 147 | } 148 | 149 | GlStateManager.popMatrix(); 150 | } 151 | 152 | @Override 153 | public void onGuiClick(int x, int y, int button) { 154 | x /= 1.5; 155 | y /= 1.5; 156 | 157 | if (Snake.x < x && (Snake.x + 200) > x && Snake.y < y && (Snake.y + 200) > y) { 158 | if (gameOver == true) { 159 | startGame(); 160 | } 161 | } 162 | } 163 | 164 | @Override 165 | public void onGuiKeyPress(GuiScreenEvent.KeyboardInputEvent.Post e) { 166 | if (Keyboard.isKeyDown(Keyboard.KEY_DOWN)) { 167 | direction = "Down"; 168 | } else if (Keyboard.isKeyDown(Keyboard.KEY_UP)) { 169 | direction = "Up"; 170 | } else if (Keyboard.isKeyDown(Keyboard.KEY_RIGHT)) { 171 | direction = "Right"; 172 | } else if (Keyboard.isKeyDown(Keyboard.KEY_LEFT)) { 173 | direction = "Left"; 174 | } 175 | } 176 | 177 | public static void gameOver() { 178 | if (gameOver == false) { 179 | gameOver = true; 180 | bodyX.clear(); 181 | bodyY.clear(); 182 | lastSnakeX = 0; 183 | lastSnakeY = 0; 184 | appleX = 0; 185 | appleY = 0; 186 | } 187 | } 188 | 189 | public static void startGame() { 190 | gameOver = false; 191 | snakeX = x + 100; 192 | snakeY = y + 180; 193 | direction = "Up"; 194 | snakeSize = 1; 195 | } 196 | 197 | public static void generateApple() { 198 | for (int i = 0; i < 100; i++) { 199 | Random rand = new Random(); 200 | int random = rand.nextInt(10); 201 | int random2 = rand.nextInt(10); 202 | appleX = x + random * 20; 203 | appleY = y + random2 * 20; 204 | 205 | for (int i2 = 0; i2 < bodyX.size(); i2++) { 206 | if (!bodyX.isEmpty()) { 207 | if (bodyX.get(i2) == appleX) { 208 | if (bodyY.get(i2) == appleY) { 209 | appleX = 0; 210 | appleY = 0; 211 | break; 212 | } 213 | } 214 | } 215 | } 216 | 217 | if (snakeX == appleX) { 218 | if (snakeY == appleY) { 219 | appleX = 0; 220 | appleY = 0; 221 | continue; 222 | } 223 | } 224 | if (appleX < 140 || appleX > 340 || appleY < 140 || appleY > 340) { 225 | appleX = 0; 226 | appleY = 0; 227 | continue; 228 | } 229 | 230 | if (appleX != 0 && appleY != 0) { 231 | break; 232 | } 233 | } 234 | } 235 | } 236 | -------------------------------------------------------------------------------- /src/main/java/me/bebeli555/autobot/rendering/RenderUtil.java: -------------------------------------------------------------------------------- 1 | package me.bebeli555.autobot.rendering; 2 | 3 | import static org.lwjgl.opengl.GL11.GL_LINE_SMOOTH; 4 | import static org.lwjgl.opengl.GL11.GL_LINE_SMOOTH_HINT; 5 | import static org.lwjgl.opengl.GL11.GL_LINE_STRIP; 6 | import static org.lwjgl.opengl.GL11.GL_NICEST; 7 | import static org.lwjgl.opengl.GL11.glDisable; 8 | import static org.lwjgl.opengl.GL11.glEnable; 9 | import static org.lwjgl.opengl.GL11.glHint; 10 | import static org.lwjgl.opengl.GL11.glLineWidth; 11 | 12 | import java.awt.Color; 13 | 14 | import org.lwjgl.opengl.GL11; 15 | 16 | import me.bebeli555.autobot.AutoBot; 17 | import net.minecraft.client.renderer.BufferBuilder; 18 | import net.minecraft.client.renderer.GlStateManager; 19 | import net.minecraft.client.renderer.Tessellator; 20 | import net.minecraft.client.renderer.vertex.DefaultVertexFormats; 21 | import net.minecraft.util.math.AxisAlignedBB; 22 | import net.minecraft.util.math.BlockPos; 23 | import net.minecraft.util.math.Vec3d; 24 | 25 | public class RenderUtil extends AutoBot { 26 | 27 | /** 28 | * Draws a line between PosA and PosB 29 | */ 30 | public static void drawLine(Vec3d posA, Vec3d posB, float width, Color c) { 31 | GlStateManager.pushMatrix(); 32 | GlStateManager.enableBlend(); 33 | GlStateManager.disableDepth(); 34 | GlStateManager.tryBlendFuncSeparate(770, 771, 0, 1); 35 | GlStateManager.disableTexture2D(); 36 | GlStateManager.depthMask(false); 37 | GlStateManager.translate(-mc.getRenderManager().viewerPosX, -mc.getRenderManager().viewerPosY, -mc.getRenderManager().viewerPosZ); 38 | glEnable(GL_LINE_SMOOTH); 39 | glHint(GL_LINE_SMOOTH_HINT, GL_NICEST); 40 | glLineWidth(width); 41 | Tessellator tessellator = Tessellator.getInstance(); 42 | BufferBuilder bufferBuilder = tessellator.getBuffer(); 43 | bufferBuilder.begin(GL11.GL_LINES, DefaultVertexFormats.POSITION_COLOR); 44 | 45 | double dx = posB.x - posA.x; 46 | double dy = posB.y - posA.y; 47 | double dz = posB.z - posA.z; 48 | 49 | bufferBuilder.pos(posA.x, posA.y, posA.z).color(c.getRed(), c.getGreen(), c.getBlue(), c.getAlpha()).endVertex(); 50 | bufferBuilder.pos(posA.x + dx, posA.y + dy, posA.z + dz).color(c.getRed(), c.getGreen(), c.getBlue(), c.getAlpha()).endVertex(); 51 | 52 | tessellator.draw(); 53 | glDisable(GL_LINE_SMOOTH); 54 | GlStateManager.depthMask(true); 55 | GlStateManager.enableDepth(); 56 | GlStateManager.enableTexture2D(); 57 | GlStateManager.disableBlend(); 58 | GlStateManager.popMatrix(); 59 | } 60 | 61 | /** 62 | * Draws a box around the bb 63 | */ 64 | public static void drawBoundingBox(AxisAlignedBB bb, float width, float red, float green, float blue, float alpha) { 65 | GlStateManager.pushMatrix(); 66 | GlStateManager.enableBlend(); 67 | GlStateManager.disableDepth(); 68 | GlStateManager.tryBlendFuncSeparate(770, 771, 0, 1); 69 | GlStateManager.disableTexture2D(); 70 | GlStateManager.depthMask(false); 71 | glEnable(GL_LINE_SMOOTH); 72 | glHint(GL_LINE_SMOOTH_HINT, GL_NICEST); 73 | glLineWidth(width); 74 | final Tessellator tessellator = Tessellator.getInstance(); 75 | final BufferBuilder bufferbuilder = tessellator.getBuffer(); 76 | bufferbuilder.begin(GL_LINE_STRIP, DefaultVertexFormats.POSITION_COLOR); 77 | bufferbuilder.pos(bb.minX, bb.minY, bb.minZ).color(red, green, blue, 0.0F).endVertex(); 78 | bufferbuilder.pos(bb.minX, bb.minY, bb.minZ).color(red, green, blue, alpha).endVertex(); 79 | bufferbuilder.pos(bb.maxX, bb.minY, bb.minZ).color(red, green, blue, alpha).endVertex(); 80 | bufferbuilder.pos(bb.maxX, bb.minY, bb.maxZ).color(red, green, blue, alpha).endVertex(); 81 | bufferbuilder.pos(bb.minX, bb.minY, bb.maxZ).color(red, green, blue, alpha).endVertex(); 82 | bufferbuilder.pos(bb.minX, bb.minY, bb.minZ).color(red, green, blue, alpha).endVertex(); 83 | bufferbuilder.pos(bb.minX, bb.maxY, bb.minZ).color(red, green, blue, alpha).endVertex(); 84 | bufferbuilder.pos(bb.maxX, bb.maxY, bb.minZ).color(red, green, blue, alpha).endVertex(); 85 | bufferbuilder.pos(bb.maxX, bb.maxY, bb.maxZ).color(red, green, blue, alpha).endVertex(); 86 | bufferbuilder.pos(bb.minX, bb.maxY, bb.maxZ).color(red, green, blue, alpha).endVertex(); 87 | bufferbuilder.pos(bb.minX, bb.maxY, bb.minZ).color(red, green, blue, alpha).endVertex(); 88 | bufferbuilder.pos(bb.minX, bb.maxY, bb.maxZ).color(red, green, blue, 0.0F).endVertex(); 89 | bufferbuilder.pos(bb.minX, bb.minY, bb.maxZ).color(red, green, blue, alpha).endVertex(); 90 | bufferbuilder.pos(bb.maxX, bb.maxY, bb.maxZ).color(red, green, blue, 0.0F).endVertex(); 91 | bufferbuilder.pos(bb.maxX, bb.minY, bb.maxZ).color(red, green, blue, alpha).endVertex(); 92 | bufferbuilder.pos(bb.maxX, bb.maxY, bb.minZ).color(red, green, blue, 0.0F).endVertex(); 93 | bufferbuilder.pos(bb.maxX, bb.minY, bb.minZ).color(red, green, blue, alpha).endVertex(); 94 | bufferbuilder.pos(bb.maxX, bb.minY, bb.minZ).color(red, green, blue, 0.0F).endVertex(); 95 | tessellator.draw(); 96 | glDisable(GL_LINE_SMOOTH); 97 | GlStateManager.depthMask(true); 98 | GlStateManager.enableDepth(); 99 | GlStateManager.enableTexture2D(); 100 | GlStateManager.disableBlend(); 101 | GlStateManager.popMatrix(); 102 | } 103 | 104 | /** 105 | * Draws a 2d rectangle thing 106 | */ 107 | public static void draw2DRec(AxisAlignedBB bb, float width, float red, float green, float blue, float alpha) { 108 | GlStateManager.pushMatrix(); 109 | GlStateManager.enableBlend(); 110 | GlStateManager.disableDepth(); 111 | GlStateManager.tryBlendFuncSeparate(770, 771, 0, 1); 112 | GlStateManager.disableTexture2D(); 113 | GlStateManager.depthMask(false); 114 | glEnable(GL_LINE_SMOOTH); 115 | glHint(GL_LINE_SMOOTH_HINT, GL_NICEST); 116 | glLineWidth(width); 117 | final Tessellator tessellator = Tessellator.getInstance(); 118 | final BufferBuilder bufferbuilder = tessellator.getBuffer(); 119 | bufferbuilder.begin(GL_LINE_STRIP, DefaultVertexFormats.POSITION_COLOR); 120 | bufferbuilder.pos(bb.minX, bb.maxY, bb.minZ).color(red, green, blue, alpha).endVertex(); 121 | bufferbuilder.pos(bb.maxX, bb.maxY, bb.minZ).color(red, green, blue, alpha).endVertex(); 122 | bufferbuilder.pos(bb.maxX, bb.maxY, bb.maxZ).color(red, green, blue, alpha).endVertex(); 123 | bufferbuilder.pos(bb.minX, bb.maxY, bb.maxZ).color(red, green, blue, alpha).endVertex(); 124 | bufferbuilder.pos(bb.minX, bb.maxY, bb.minZ).color(red, green, blue, alpha).endVertex(); 125 | bufferbuilder.pos(bb.minX, bb.maxY, bb.maxZ).color(red, green, blue, 0.0F).endVertex(); 126 | bufferbuilder.pos(bb.maxX, bb.maxY, bb.maxZ).color(red, green, blue, 0.0F).endVertex(); 127 | bufferbuilder.pos(bb.maxX, bb.maxY, bb.minZ).color(red, green, blue, 0.0F).endVertex(); 128 | tessellator.draw(); 129 | glDisable(GL_LINE_SMOOTH); 130 | GlStateManager.depthMask(true); 131 | GlStateManager.enableDepth(); 132 | GlStateManager.enableTexture2D(); 133 | GlStateManager.disableBlend(); 134 | GlStateManager.popMatrix(); 135 | } 136 | 137 | public static AxisAlignedBB getBB(BlockPos pos) { 138 | return new AxisAlignedBB(pos.getX() - mc.getRenderManager().viewerPosX, pos.getY() - mc.getRenderManager().viewerPosY, pos.getZ() - mc.getRenderManager().viewerPosZ, 139 | pos.getX() + 1 - mc.getRenderManager().viewerPosX, pos.getY() + (1) - mc.getRenderManager().viewerPosY, pos.getZ() + 1 - mc.getRenderManager().viewerPosZ); 140 | } 141 | } 142 | -------------------------------------------------------------------------------- /src/main/java/me/bebeli555/autobot/utils/RotationUtil.java: -------------------------------------------------------------------------------- 1 | package me.bebeli555.autobot.utils; 2 | 3 | import me.bebeli555.autobot.AutoBot; 4 | import me.bebeli555.autobot.events.PlayerMotionUpdateEvent; 5 | import me.zero.alpine.listener.EventHandler; 6 | import me.zero.alpine.listener.Listener; 7 | import net.minecraft.client.entity.EntityPlayerSP; 8 | import net.minecraft.network.play.client.CPacketEntityAction; 9 | import net.minecraft.network.play.client.CPacketPlayer; 10 | import net.minecraft.util.math.AxisAlignedBB; 11 | import net.minecraft.util.math.MathHelper; 12 | import net.minecraft.util.math.Vec3d; 13 | import net.minecraftforge.fml.relauncher.ReflectionHelper; 14 | 15 | public class RotationUtil extends AutoBot { 16 | public static RotationUtil rotationUtil = new RotationUtil(); 17 | public static float yaw, pitch; 18 | 19 | /** 20 | * Rotates to the given vector 21 | * @param sendPacket if true then it will also send a packet to the server 22 | */ 23 | public static void rotate(Vec3d vec, boolean sendPacket) { 24 | float[] rotations = getRotations(vec); 25 | 26 | if (sendPacket) mc.player.connection.sendPacket(new CPacketPlayer.Rotation(rotations[0], rotations[1], mc.player.onGround)); 27 | mc.player.rotationYaw = rotations[0]; 28 | mc.player.rotationPitch = rotations[1]; 29 | } 30 | 31 | /** 32 | * Rotates to the given vector only serverside 33 | */ 34 | public static void rotateSpoof(Vec3d vec) { 35 | float[] rotations = getRotations(vec); 36 | yaw = rotations[0]; 37 | pitch = rotations[1]; 38 | 39 | mc.player.connection.sendPacket(new CPacketPlayer.Rotation(yaw, pitch, mc.player.onGround)); 40 | AutoBot.EVENT_BUS.subscribe(rotationUtil); 41 | } 42 | 43 | /** 44 | * Rotates to the given vector only serverside 45 | * Doesnt send a extra packet when called 46 | */ 47 | public static void rotateSpoofNoPacket(Vec3d vec) { 48 | float[] rotations = getRotations(vec); 49 | yaw = rotations[0]; 50 | pitch = rotations[1]; 51 | AutoBot.EVENT_BUS.subscribe(rotationUtil); 52 | } 53 | 54 | /** 55 | * Stops rotating if you called the rotateSpoof then u need to call this 56 | */ 57 | public static void stopRotating() { 58 | AutoBot.EVENT_BUS.unsubscribe(rotationUtil); 59 | } 60 | 61 | public static float[] getRotations(Vec3d vec) { 62 | Vec3d eyesPos = new Vec3d(mc.player.posX, mc.player.posY + mc.player.getEyeHeight(), mc.player.posZ); 63 | double diffX = vec.x - eyesPos.x; 64 | double diffY = vec.y - eyesPos.y; 65 | double diffZ = vec.z - eyesPos.z; 66 | double diffXZ = Math.sqrt(diffX * diffX + diffZ * diffZ); 67 | float yaw = (float) Math.toDegrees(Math.atan2(diffZ, diffX)) - 90F; 68 | float pitch = (float) -Math.toDegrees(Math.atan2(diffY, diffXZ)); 69 | 70 | return new float[] { mc.player.rotationYaw + MathHelper.wrapDegrees(yaw - mc.player.rotationYaw), mc.player.rotationPitch + MathHelper.wrapDegrees(pitch - mc.player.rotationPitch) }; 71 | } 72 | 73 | @EventHandler 74 | private Listener onMotionUpdate = new Listener<>(event -> { 75 | try { 76 | event.cancel(); 77 | 78 | boolean sprinting = mc.player.isSprinting(); 79 | if (sprinting != (boolean)ReflectionHelper.getPrivateValue(EntityPlayerSP.class, mc.player, "serverSprintState")) { 80 | if (sprinting) { 81 | mc.player.connection.sendPacket(new CPacketEntityAction(mc.player, CPacketEntityAction.Action.START_SPRINTING)); 82 | } else { 83 | mc.player.connection.sendPacket(new CPacketEntityAction(mc.player, CPacketEntityAction.Action.STOP_SPRINTING)); 84 | } 85 | 86 | ReflectionHelper.setPrivateValue(EntityPlayerSP.class, mc.player, sprinting, "serverSprintState"); 87 | } 88 | 89 | boolean sneaking = mc.player.isSneaking(); 90 | if (sneaking != (boolean)ReflectionHelper.getPrivateValue(EntityPlayerSP.class, mc.player, "serverSneakState")) { 91 | if (sneaking) { 92 | mc.player.connection.sendPacket(new CPacketEntityAction(mc.player, CPacketEntityAction.Action.START_SNEAKING)); 93 | } else { 94 | mc.player.connection.sendPacket(new CPacketEntityAction(mc.player, CPacketEntityAction.Action.STOP_SNEAKING)); 95 | } 96 | 97 | ReflectionHelper.setPrivateValue(EntityPlayerSP.class, mc.player, sneaking, "serverSneakState"); 98 | } 99 | 100 | if (mc.getRenderViewEntity() != mc.player) { 101 | return; 102 | } 103 | 104 | AxisAlignedBB axisalignedbb = mc.player.getEntityBoundingBox(); 105 | double posXDifference = mc.player.posX - (double)ReflectionHelper.getPrivateValue(EntityPlayerSP.class, mc.player, "lastReportedPosX"); 106 | double posYDifference = axisalignedbb.minY - (double)ReflectionHelper.getPrivateValue(EntityPlayerSP.class, mc.player, "lastReportedPosY"); 107 | double posZDifference = mc.player.posZ - (double)ReflectionHelper.getPrivateValue(EntityPlayerSP.class, mc.player, "lastReportedPosZ"); 108 | double yawDifference = (double) (yaw - (float)ReflectionHelper.getPrivateValue(EntityPlayerSP.class, mc.player, "lastReportedYaw")); 109 | double rotationDifference = (double) (pitch - (float)ReflectionHelper.getPrivateValue(EntityPlayerSP.class, mc.player, "lastReportedPitch")); 110 | ReflectionHelper.setPrivateValue(EntityPlayerSP.class, mc.player, (int)ReflectionHelper.getPrivateValue(EntityPlayerSP.class, mc.player, "positionUpdateTicks") + 1, "positionUpdateTicks"); 111 | boolean movedXYZ = posXDifference * posXDifference + posYDifference * posYDifference + posZDifference * posZDifference > 9.0E-4D || (int)ReflectionHelper.getPrivateValue(EntityPlayerSP.class, mc.player, "positionUpdateTicks") >= 20; 112 | boolean movedRotation = yawDifference != 0.0D || rotationDifference != 0.0D; 113 | 114 | if (mc.player.isRiding()) { 115 | mc.player.connection.sendPacket(new CPacketPlayer.PositionRotation(mc.player.motionX, -999.0D, mc.player.motionZ, yaw, pitch, mc.player.onGround)); 116 | movedXYZ = false; 117 | } else if (movedXYZ && movedRotation) { 118 | mc.player.connection.sendPacket(new CPacketPlayer.PositionRotation(mc.player.posX, axisalignedbb.minY, mc.player.posZ, yaw, pitch, mc.player.onGround)); 119 | } else if (movedXYZ) { 120 | mc.player.connection.sendPacket(new CPacketPlayer.Position(mc.player.posX, axisalignedbb.minY, mc.player.posZ, mc.player.onGround)); 121 | } else if (movedRotation) { 122 | mc.player.connection.sendPacket(new CPacketPlayer.Rotation(yaw, pitch, mc.player.onGround)); 123 | } else if ((boolean)ReflectionHelper.getPrivateValue(EntityPlayerSP.class, mc.player, "prevOnGround") != mc.player.onGround) { 124 | mc.player.connection.sendPacket(new CPacketPlayer(mc.player.onGround)); 125 | } 126 | 127 | if (movedXYZ) { 128 | ReflectionHelper.setPrivateValue(EntityPlayerSP.class, mc.player, mc.player.posX, "lastReportedPosX"); 129 | ReflectionHelper.setPrivateValue(EntityPlayerSP.class, mc.player, axisalignedbb.minY, "lastReportedPosY"); 130 | ReflectionHelper.setPrivateValue(EntityPlayerSP.class, mc.player, mc.player.posZ, "lastReportedPosZ"); 131 | ReflectionHelper.setPrivateValue(EntityPlayerSP.class, mc.player, 0, "positionUpdateTicks"); 132 | } 133 | 134 | if (movedRotation) { 135 | ReflectionHelper.setPrivateValue(EntityPlayerSP.class, mc.player, yaw, "lastReportedYaw"); 136 | ReflectionHelper.setPrivateValue(EntityPlayerSP.class, mc.player, pitch, "lastReportedPitch"); 137 | } 138 | 139 | ReflectionHelper.setPrivateValue(EntityPlayerSP.class, mc.player, mc.player.onGround, "prevOnGround"); 140 | } catch (Exception e) { 141 | 142 | } 143 | }); 144 | } 145 | -------------------------------------------------------------------------------- /src/main/java/me/bebeli555/autobot/mods/other/AutoBuilder.java: -------------------------------------------------------------------------------- 1 | package me.bebeli555.autobot.mods.other; 2 | 3 | import java.awt.Color; 4 | import java.io.BufferedWriter; 5 | import java.io.File; 6 | import java.io.FileOutputStream; 7 | import java.io.OutputStreamWriter; 8 | import java.util.ArrayList; 9 | import java.util.Scanner; 10 | 11 | import org.lwjgl.input.Mouse; 12 | 13 | import me.bebeli555.autobot.AutoBot; 14 | import me.bebeli555.autobot.events.PlayerUpdateEvent; 15 | import me.bebeli555.autobot.gui.Group; 16 | import me.bebeli555.autobot.gui.GuiNode; 17 | import me.bebeli555.autobot.gui.GuiNode.ClickListener; 18 | import me.bebeli555.autobot.gui.Mode; 19 | import me.bebeli555.autobot.gui.Setting; 20 | import me.bebeli555.autobot.gui.Settings; 21 | import me.bebeli555.autobot.rendering.RenderBlock; 22 | import me.bebeli555.autobot.utils.BaritoneUtil; 23 | import me.bebeli555.autobot.utils.BlockUtil; 24 | import me.bebeli555.autobot.utils.InventoryUtil; 25 | import me.bebeli555.autobot.utils.RotationUtil; 26 | import me.zero.alpine.listener.EventHandler; 27 | import me.zero.alpine.listener.Listener; 28 | import net.minecraft.block.Block; 29 | import net.minecraft.init.Items; 30 | import net.minecraft.util.math.BlockPos; 31 | 32 | public class AutoBuilder extends AutoBot { 33 | private static Thread thread; 34 | private static ArrayList positions = new ArrayList(); 35 | private static boolean check, down; 36 | private static BlockPos playerPos; 37 | private static AutoBuilder autoBuilder; 38 | 39 | public static Setting setStructure = new Setting(Mode.BOOLEAN, "SetStructure", false, "Click this to set the structure", "You can middleclick on blocks while this is on", "to add them to the structure", "When ur done toggle this off and autobuilder", "will now build the structure you made"); 40 | public static Setting delay = new Setting(Mode.INTEGER, "Delay", 50, "Delay in milliseconds between placing blocks"); 41 | public static Setting toggle = new Setting(Mode.BOOLEAN, "Toggle", false, "If true then it will toggle the module off", "After the structure has been built", "Note: This has no effect if you have move on"); 42 | public static Setting move = new Setting(Mode.BOOLEAN, "Move", false, "When the structure has been built it will move", "To the given coordinates below and then build it again", "The coordinates are relative to the player so", "For example X: 1 will make it walk 1 block right"); 43 | public static Setting moveX = new Setting(move, Mode.INTEGER, "X", 0, "X-Coordinate relative to players position"); 44 | public static Setting moveY = new Setting(move, Mode.INTEGER, "Y", 0, "Y-Coordinate relative to players position"); 45 | public static Setting moveZ = new Setting(move, Mode.INTEGER, "Z", 0, "Z-Coordinate relative to players position"); 46 | 47 | public AutoBuilder() { 48 | super(Group.OTHER, "AutoBuilder", "Builds anything you want relative to the players position"); 49 | autoBuilder = this; 50 | } 51 | 52 | @Override 53 | public void onEnabled() { 54 | if (!check) { 55 | check = true; 56 | readFile(); 57 | } 58 | 59 | thread = new Thread() { 60 | public void run() { 61 | while(thread != null && thread.equals(this)) { 62 | loop(); 63 | 64 | AutoBot.sleep(35); 65 | } 66 | } 67 | }; 68 | 69 | thread.start(); 70 | } 71 | 72 | @Override 73 | public void onDisabled() { 74 | clearStatus(); 75 | RotationUtil.stopRotating(); 76 | BaritoneUtil.forceCancel(); 77 | suspend(thread); 78 | thread = null; 79 | } 80 | 81 | @Override 82 | public void onPostInit() { 83 | GuiNode node = Settings.getGuiNodeFromId(setStructure.id); 84 | 85 | node.addClickListener(new ClickListener() { 86 | public void clicked() { 87 | if (!node.toggled) { 88 | AutoBot.EVENT_BUS.unsubscribe(autoBuilder); 89 | RenderBlock.clear(); 90 | saveFile(); 91 | sendMessage("Successfully saved structure!", false); 92 | } else { 93 | positions.clear(); 94 | playerPos = getPlayerPos(); 95 | RenderBlock.add(playerPos, Color.GREEN, 3); 96 | AutoBot.EVENT_BUS.subscribe(autoBuilder); 97 | } 98 | } 99 | }); 100 | } 101 | 102 | public void loop() { 103 | if (mc.player == null) { 104 | return; 105 | } 106 | 107 | for (int i = 0; i < positions.size(); i++) { 108 | BuildPosition buildPosition = positions.get(i); 109 | BlockPos pos = getPlayerPos().add(buildPosition.blockPos.getX(), buildPosition.blockPos.getY(), buildPosition.blockPos.getZ()); 110 | 111 | if (BlockUtil.canPlaceBlock(pos)) { 112 | if (!InventoryUtil.hasBlock(buildPosition.block)) { 113 | if (Block.getIdFromBlock(buildPosition.block) != 144 || Block.getIdFromBlock(buildPosition.block) == 144 && !InventoryUtil.hasItem(Items.SKULL)) { 114 | sendMessage("You dont have the required materials to build this structure", true); 115 | toggleModule(); 116 | return; 117 | } 118 | } 119 | 120 | if (Block.getIdFromBlock(buildPosition.block) == 144) { 121 | setStatus("Placing skull"); 122 | BlockUtil.placeItemNoSleep(Items.SKULL, pos, true); 123 | } else { 124 | setStatus("Placing block"); 125 | BlockUtil.placeBlockNoSleep(buildPosition.block, pos, true); 126 | } 127 | 128 | sleep(delay.intValue()); 129 | } 130 | } 131 | 132 | if (move.booleanValue()) { 133 | BlockPos pos = getPlayerPos().add(moveX.intValue(), moveY.intValue(), moveZ.intValue()); 134 | setStatus("Moving to X: " + pos.getX() + " Y: " + pos.getY() + " Z: " + pos.getZ()); 135 | BaritoneUtil.walkTo(pos, true); 136 | } else if (toggle.booleanValue()) { 137 | toggleModule(); 138 | } 139 | } 140 | 141 | @EventHandler 142 | private Listener onUpdate = new Listener<>(event -> { 143 | if (Mouse.isButtonDown(2)) { 144 | if (down == true) { 145 | return; 146 | } 147 | 148 | down = true; 149 | BlockPos pos = mc.objectMouseOver.getBlockPos(); 150 | 151 | if (pos != null) { 152 | BlockPos relative = new BlockPos(pos.getX() - playerPos.getX(), pos.getY() - playerPos.getY(), pos.getZ() - playerPos.getZ()); 153 | 154 | for (BuildPosition buildPosition : positions) { 155 | if (buildPosition.blockPos.equals(relative)) { 156 | positions.remove(buildPosition); 157 | RenderBlock.remove(pos); 158 | return; 159 | } 160 | } 161 | 162 | positions.add(new BuildPosition(relative, getBlock(pos))); 163 | RenderBlock.add(pos, Color.CYAN, 1); 164 | } 165 | } else { 166 | down = false; 167 | } 168 | }); 169 | 170 | //Reads the file and updates the list 171 | public void readFile() { 172 | try { 173 | File file = new File(Settings.path + "/AutoBuilder.txt"); 174 | if (!file.exists()) { 175 | sendMessage("Create a structure first", true); 176 | toggleModule(); 177 | return; 178 | } 179 | 180 | Scanner scanner = new Scanner(file); 181 | positions.clear(); 182 | 183 | while(scanner.hasNextLine()) { 184 | String line = scanner.nextLine(); 185 | 186 | if (!line.isEmpty()) { 187 | String[] split = line.split(","); 188 | positions.add(new BuildPosition(new BlockPos(Integer.parseInt(split[0]), Integer.parseInt(split[1]), Integer.parseInt(split[2])), Block.getBlockById(Integer.parseInt(split[3])))); 189 | } 190 | } 191 | 192 | scanner.close(); 193 | } catch (Exception e) { 194 | sendMessage("Error reading structure file. More info in your games log", true); 195 | e.printStackTrace(); 196 | } 197 | } 198 | 199 | //Saves the structure into a file 200 | //0 = X. 1 = Y. 2 = Z. 3 = blockid. 201 | //Prefix change: , 202 | public void saveFile() { 203 | try { 204 | File file = new File(Settings.path + "/AutoBuilder.txt"); 205 | file.delete(); 206 | file.createNewFile(); 207 | 208 | BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file))); 209 | for (BuildPosition b : positions) { 210 | bw.write(b.blockPos.getX() + "," + b.blockPos.getY() + "," + b.blockPos.getZ() + "," + Block.getIdFromBlock(b.block)); 211 | bw.newLine(); 212 | } 213 | 214 | bw.close(); 215 | } catch (Exception e) { 216 | sendMessage("Error saving structure. More info in your games log", true); 217 | e.printStackTrace(); 218 | } 219 | } 220 | 221 | public static class BuildPosition { 222 | public BlockPos blockPos; 223 | public Block block; 224 | 225 | public BuildPosition(BlockPos blockPos, Block block) { 226 | this.blockPos = blockPos; 227 | this.block = block; 228 | } 229 | } 230 | } 231 | -------------------------------------------------------------------------------- /src/main/java/me/bebeli555/autobot/utils/BlockUtil.java: -------------------------------------------------------------------------------- 1 | package me.bebeli555.autobot.utils; 2 | 3 | import java.util.ArrayList; 4 | import java.util.Collections; 5 | import java.util.Comparator; 6 | import java.util.ConcurrentModificationException; 7 | import java.util.List; 8 | 9 | import me.bebeli555.autobot.AutoBot; 10 | import net.minecraft.block.Block; 11 | import net.minecraft.entity.Entity; 12 | import net.minecraft.entity.item.EntityItem; 13 | import net.minecraft.init.Blocks; 14 | import net.minecraft.item.Item; 15 | import net.minecraft.network.play.client.CPacketEntityAction; 16 | import net.minecraft.util.EnumFacing; 17 | import net.minecraft.util.EnumHand; 18 | import net.minecraft.util.math.AxisAlignedBB; 19 | import net.minecraft.util.math.BlockPos; 20 | import net.minecraft.util.math.Vec3d; 21 | import net.minecraftforge.common.MinecraftForge; 22 | import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; 23 | import net.minecraftforge.fml.common.gameevent.TickEvent.ClientTickEvent; 24 | 25 | public class BlockUtil extends AutoBot { 26 | 27 | /** 28 | * Searches around the player to find the given block. 29 | * @radius the radius to search around the player 30 | */ 31 | public static BlockPos findBlock(Block block, int radius) { 32 | for (int x = (int) (mc.player.posX - radius); x < mc.player.posX + radius; x++) { 33 | for (int z = (int) (mc.player.posZ - radius); z < mc.player.posZ + radius; z++) { 34 | for (int y = (int) (mc.player.posY + radius); y > mc.player.posY - radius; y--) { 35 | BlockPos pos = new BlockPos(x, y, z); 36 | if (mc.world.getBlockState(pos).getBlock().equals(block)) { 37 | return pos; 38 | } 39 | } 40 | } 41 | } 42 | 43 | return null; 44 | } 45 | 46 | /** 47 | * Gets all the BlockPositions in the given radius around the player 48 | */ 49 | public static List getAll(int radius) { 50 | List list = new ArrayList(); 51 | for (int x = (int) (mc.player.posX - radius); x < mc.player.posX + radius; x++) { 52 | for (int z = (int) (mc.player.posZ - radius); z < mc.player.posZ + radius; z++) { 53 | for (int y = (int) (mc.player.posY + radius); y > mc.player.posY - radius; y--) { 54 | list.add(new BlockPos(x, y, z)); 55 | } 56 | } 57 | } 58 | 59 | Collections.sort(list, new Comparator() { 60 | @Override 61 | public int compare(BlockPos lhs, BlockPos rhs) { 62 | return mc.player.getDistanceSq(lhs) > mc.player.getDistanceSq(rhs) ? 1 : (mc.player.getDistanceSq(lhs) < mc.player.getDistanceSq(rhs)) ? -1 : 0; 63 | } 64 | }); 65 | 66 | return list; 67 | } 68 | 69 | /** 70 | * Gets all the BlockPositions in the given radius around the pos 71 | */ 72 | public static ArrayList getAll(Vec3d pos, int radius) { 73 | ArrayList list = new ArrayList(); 74 | 75 | for (int x = (int) (pos.x - radius); x < pos.x + radius; x++) { 76 | for (int z = (int) (pos.z - radius); z < pos.z + radius; z++) { 77 | for (int y = (int) (pos.y + radius); y > pos.y - radius; y--) { 78 | list.add(new BlockPos(x, y, z)); 79 | } 80 | } 81 | } 82 | 83 | return list; 84 | } 85 | 86 | /** 87 | * Checks if a block can be placed to this position 88 | */ 89 | public static boolean canPlaceBlock(BlockPos pos) { 90 | try { 91 | for (Entity entity : mc.world.getEntitiesWithinAABBExcludingEntity(null, new AxisAlignedBB(pos))) { 92 | if (entity instanceof EntityItem == false) { 93 | return false; 94 | } 95 | } 96 | } catch (ConcurrentModificationException ignored) { 97 | 98 | } 99 | 100 | if (!isSolid(pos) && canBeClicked(pos)) { 101 | return true; 102 | } 103 | 104 | return false; 105 | } 106 | 107 | /** 108 | * Places a block to the given BlockPosition 109 | * This is run on the client thread 110 | * @pos Places the block to this position 111 | * @block The block to place. Must be in ur inventory! 112 | */ 113 | public static boolean placeBlock(Block block, BlockPos pos, boolean spoofRotation) { 114 | Place place = new Place(null, block, pos, spoofRotation); 115 | sleepUntil(() -> place.done, -1); 116 | return place.success; 117 | } 118 | 119 | public static void placeBlockNoSleep(Block block, BlockPos pos, boolean spoofRotation) { 120 | new Place(null, block, pos, spoofRotation); 121 | } 122 | 123 | public static void placeBlockOnThisThread(Block block, BlockPos pos, boolean spoofRotation) { 124 | new Place(null, block, pos, spoofRotation).onTick(null); 125 | } 126 | /** 127 | * Same as the placeBlock but it interacts with the given block with the given item 128 | * This is run on the client thread 129 | */ 130 | public static boolean placeItem(Item item, BlockPos pos, boolean spoofRotation) { 131 | Place place = new Place(item, null, pos, spoofRotation); 132 | sleepUntil(() -> place.done, -1); 133 | return place.success; 134 | } 135 | 136 | public static void placeItemNoSleep(Item item, BlockPos pos, boolean spoofRotation) { 137 | new Place(item, null, pos, spoofRotation); 138 | } 139 | 140 | /** 141 | * Distance between these 2 blockpositions 142 | */ 143 | public static int distance(BlockPos first, BlockPos second) { 144 | return Math.abs(first.getX() - second.getX()) + Math.abs(first.getY() - second.getY()) + Math.abs(first.getZ() - second.getZ()); 145 | } 146 | 147 | /** 148 | * Checks if the block is in render distance or known by the client. 149 | */ 150 | public static boolean isInRenderDistance(BlockPos pos) { 151 | return mc.world.getChunk(pos).isLoaded(); 152 | } 153 | 154 | /** 155 | * Checks if any neighbor block can be right clicked 156 | */ 157 | public static boolean canBeClicked(BlockPos pos) { 158 | for (EnumFacing facing : EnumFacing.values()) { 159 | BlockPos neighbor = pos.offset(facing); 160 | 161 | //If neighbor cant be clicked then continue 162 | if (!mc.world.getBlockState(neighbor).getBlock().canCollideCheck(mc.world.getBlockState(neighbor), false) && getBlock(neighbor) != Blocks.WATER) { 163 | continue; 164 | } 165 | 166 | return true; 167 | } 168 | 169 | return false; 170 | } 171 | 172 | public static class Place { 173 | public boolean done, success, spoofRotation; 174 | public Item item; 175 | public Block block; 176 | public BlockPos pos; 177 | 178 | public Place(Item item, Block block, BlockPos pos, boolean spoofRotation) { 179 | this.item = item; 180 | this.pos = pos; 181 | this.block = block; 182 | this.spoofRotation = spoofRotation; 183 | MinecraftForge.EVENT_BUS.register(this); 184 | } 185 | 186 | @SubscribeEvent 187 | public void onTick(ClientTickEvent e) { 188 | if (block != null || item != null) { 189 | int slot = -1; 190 | if (block != null) { 191 | slot = InventoryUtil.getSlot(block); 192 | } else if (item != null) { 193 | slot = InventoryUtil.getSlot(item); 194 | } 195 | 196 | //If item wasent found on inventory then return false 197 | if (slot == -1) { 198 | done(false); 199 | return; 200 | } 201 | 202 | //Put the given item into the hand so it can be "placed" 203 | if (InventoryUtil.getHandSlot() != slot) { 204 | InventoryUtil.switchItem(slot, false); 205 | } 206 | } 207 | 208 | for (EnumFacing facing : EnumFacing.values()) { 209 | BlockPos neighbor = pos.offset(facing); 210 | EnumFacing side = facing.getOpposite(); 211 | 212 | //If neighbor cant be clicked then continue 213 | if (!mc.world.getBlockState(neighbor).getBlock().canCollideCheck(mc.world.getBlockState(neighbor), false) && getBlock(neighbor) != Blocks.WATER) { 214 | continue; 215 | } 216 | 217 | Vec3d hitVec; 218 | if (item != null) { 219 | hitVec = new Vec3d(pos).add(0.5, 0.5, 0.5).add(new Vec3d(side.getDirectionVec()).scale(0.5)); 220 | } else { 221 | hitVec = new Vec3d(neighbor).add(0.5, 0.5, 0.5).add(new Vec3d(side.getDirectionVec()).scale(0.5)); 222 | } 223 | 224 | if (spoofRotation) { 225 | RotationUtil.rotateSpoof(hitVec); 226 | } else { 227 | RotationUtil.rotate(hitVec, true); 228 | } 229 | mc.player.connection.sendPacket(new CPacketEntityAction(mc.player, CPacketEntityAction.Action.START_SNEAKING)); 230 | if (item != null) { 231 | mc.playerController.processRightClickBlock(mc.player, mc.world, pos, side, hitVec, EnumHand.MAIN_HAND); 232 | } else { 233 | mc.playerController.processRightClickBlock(mc.player, mc.world, neighbor, side, hitVec, EnumHand.MAIN_HAND); 234 | mc.player.swingArm(EnumHand.MAIN_HAND); 235 | } 236 | mc.player.connection.sendPacket(new CPacketEntityAction(mc.player, CPacketEntityAction.Action.STOP_SNEAKING)); 237 | done(true); 238 | return; 239 | } 240 | 241 | done(false); 242 | return; 243 | } 244 | 245 | public void done(boolean success) { 246 | this.done = true; 247 | this.success = success; 248 | MinecraftForge.EVENT_BUS.unregister(this); 249 | RotationUtil.stopRotating(); 250 | } 251 | } 252 | } 253 | --------------------------------------------------------------------------------