diff options
Diffstat (limited to 'src/main')
20 files changed, 658 insertions, 374 deletions
diff --git a/src/main/java/rosegoldaddons/Config.java b/src/main/java/rosegoldaddons/Config.java index f3394e1..2886ec2 100644 --- a/src/main/java/rosegoldaddons/Config.java +++ b/src/main/java/rosegoldaddons/Config.java @@ -13,7 +13,23 @@ public class Config extends Vigilant { @Property(type = PropertyType.SWITCH, name = "Auto Start Dungeon + Ready", description = "Automatically starts the dungeon and gets ready.", category = "Dungeons", subcategory = "General") - public boolean AutoReady = true; + public boolean AutoReady = false; + + @Property(type = PropertyType.SELECTOR, name = "Auto Ghost Block", description = "Choose which mode auto ghost block will follow", + category = "Dungeons", subcategory = "General", options = {"While Held", "On Press"}) + public int ghostIndex = 0; + + @Property(type = PropertyType.SWITCH, name = "Auto Ghost Block Stairs", description = "Automatically ghost block stairs you are standing on when you sneak", + category = "Dungeons", subcategory = "General") + public boolean AutoGB = false; + + @Property(type = PropertyType.SWITCH, name = "Add Flipped Stairs", description = "Ghost Block upside-down stair when jumped into", + category = "Dungeons", subcategory = "General") + public boolean AutoGBTopStair = false; + + @Property(type = PropertyType.SWITCH, name = "Add Misc. Blocks", description = "Adds other phase-able blocks to Auto Ghost Block", + category = "Dungeons", subcategory = "General") + public boolean AutoGBMisc = false; public boolean autoArrowAlign = true; @@ -41,9 +57,9 @@ public class Config extends Vigilant { category = "RoseGoldAddons", subcategory = "General", max = 2000) public int swapFrequency = 500; - @Property(type = PropertyType.SLIDER, name = "Smooth Look Velocity", description = "How fast should head rotation changes be (in miliseconds)", - category = "RoseGoldAddons", subcategory = "General", min = 1, max = 200) - public int smoothLookVelocity = 50; + @Property(type = PropertyType.SLIDER, name = "Smooth Look Velocity", description = "How fast should head rotation changes be (in ticks)", + category = "RoseGoldAddons", subcategory = "General", min = 1, max = 40) + public int smoothLookVelocity = 5; @Property(type = PropertyType.SLIDER, name = "Macro Range", description = "Look for entities only in radius of the player, 0 = unlimited", category = "RoseGoldAddons", subcategory = "General", max = 300) @@ -75,7 +91,7 @@ public class Config extends Vigilant { @Property(type = PropertyType.SWITCH, name = "Radomize Delay", description = "Add slight randomization to delay", category = "Foraging", subcategory = "General") - public boolean randomizeForaging = true; + public boolean randomizeForaging = false; @Property(type = PropertyType.SWITCH, name = "Admin Antisus", description = "Act as if you're there when you get AFK checked (not recommended to leave on)", category = "Foraging", subcategory = "General") @@ -86,9 +102,13 @@ public class Config extends Vigilant { public boolean prioblocks = false; @Property(type = PropertyType.SLIDER, name = "Hardstone Nuker Height", description = "Range to break above the player", - category = "Mining", subcategory = "General", max = 5) + category = "Mining", subcategory = "General",max = 5) public int hardrange = 0; + @Property(type = PropertyType.SLIDER, name = "Hardstone Nuker Depth", description = "Range to break below the player", + category = "Mining", subcategory = "General",max = 3) + public int hardrangeDown = 0; + @Property(type = PropertyType.SELECTOR, name = "Hardstone Nuker Shape", description = "Choose which pattern hardstone nuker will follow", category = "Mining", subcategory = "General", options = {"Closest Block", "Facing Axis"}) public int hardIndex = 0; @@ -125,10 +145,18 @@ public class Config extends Vigilant { category = "Mining", subcategory = "General") public boolean ignoreTitanium = false; - @Property(type = PropertyType.SWITCH, name = "Include Ores", description = "Hardstone & Mithril Nukers will also nuke ores", + @Property(type = PropertyType.SWITCH, name = "Include Ores", description = "Hardstone Nuker, Mithril Nuker and Mithril Macro will also target ores", category = "Mining", subcategory = "General") public boolean includeOres = false; + @Property(type = PropertyType.SWITCH, name = "Include Sand & Gravel", description = "Hardstone Nuker will also target sand and gravel", + category = "Mining", subcategory = "General") + public boolean includeExcavatable = false; + + @Property(type = PropertyType.SWITCH, name = "Only Ores", description = "Mithril Macro will only target ores", + category = "Mining", subcategory = "General") + public boolean onlyOres = false; + @Property(type = PropertyType.SELECTOR, name = "Mithril Macro Priority", description = "Determine the order the macro will breaks blocks in", category = "Mining", subcategory = "General", options = {"Highest value to lowest", "Lowest value to highest","Any"}) public int mithrilMacroPrio = 0; diff --git a/src/main/java/rosegoldaddons/Main.java b/src/main/java/rosegoldaddons/Main.java index 120e944..def14cd 100644 --- a/src/main/java/rosegoldaddons/Main.java +++ b/src/main/java/rosegoldaddons/Main.java @@ -1,6 +1,8 @@ package rosegoldaddons; +import com.google.gson.JsonArray; import com.google.gson.JsonElement; +import com.google.gson.JsonObject; import com.google.gson.JsonParser; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiScreen; @@ -20,24 +22,17 @@ import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.common.gameevent.InputEvent; import net.minecraftforge.fml.common.gameevent.TickEvent; -import net.minecraftforge.fml.common.network.FMLNetworkEvent; import org.lwjgl.input.Keyboard; import rosegoldaddons.commands.*; import rosegoldaddons.features.*; -import rosegoldaddons.utils.ChatUtils; -import rosegoldaddons.utils.OpenSkyblockGui; -import rosegoldaddons.utils.PlayerUtils; -import rosegoldaddons.utils.RotationUtils; +import rosegoldaddons.utils.*; import java.io.*; import java.net.URL; import java.net.URLConnection; import java.nio.file.Files; import java.nio.file.Paths; -import java.util.Base64; -import java.util.HashMap; -import java.util.Objects; -import java.util.Random; +import java.util.*; @Mod(modid = "timechanger", name = "RoseGoldAddons", version = "2.1") public class Main { @@ -64,14 +59,20 @@ public class Main { private static boolean oldanim = false; public static boolean init = false; public static boolean mithrilMacro = false; + private boolean issue = false; public static final Minecraft mc = Minecraft.getMinecraft(); + public static JsonObject rga; - //Hello decompiler and / or source code checker! this is just some funny stuff, you do not have to worry about it! + String info = "Hello decompiler! this is just some funny stuff, you do not have to worry about it!"; private String[] cumsters = null; private String[] ILILILLILILLILILILL = null; - public static HashMap<String, String> resp = new HashMap<>(); + public static HashMap<String, String> nameCache = new HashMap<>(); + public static HashMap<String, String> rankCache = new HashMap<>(); + public static ArrayList<String> hashedCache = new ArrayList<>(); + public static HashMap<String, String> names = new HashMap<>(); + public static HashMap<String, String> ranks = new HashMap<>(); @Mod.EventHandler public void onFMLInitialization(FMLPreInitializationEvent event) { @@ -79,10 +80,18 @@ public class Main { if (!directory.exists()) { directory.mkdirs(); } + + try { + rga = getJson("https://gist.githubusercontent.com/RoseGoldIsntGay/2d15ef10d53629455a40f5c027db1dfb/raw/").getAsJsonObject(); + } catch (Exception e) { + e.printStackTrace(); + issue = true; + } } @Mod.EventHandler public void init(FMLInitializationEvent event) { + if (issue) return; MinecraftForge.EVENT_BUS.register(this); MinecraftForge.EVENT_BUS.register(new AutoReady()); MinecraftForge.EVENT_BUS.register(new OpenSkyblockGui()); @@ -107,11 +116,11 @@ public class Main { MinecraftForge.EVENT_BUS.register(new ForagingNuker()); MinecraftForge.EVENT_BUS.register(new AutoSlayer()); MinecraftForge.EVENT_BUS.register(new PlayerUtils()); - MinecraftForge.EVENT_BUS.register(new CanePlanter()); MinecraftForge.EVENT_BUS.register(new ArmorStandESPs()); MinecraftForge.EVENT_BUS.register(new PinglessMining()); MinecraftForge.EVENT_BUS.register(new MithrilMacro()); - MinecraftForge.EVENT_BUS.register(new RotationUtils()); + MinecraftForge.EVENT_BUS.register(new AutoGhostBlock()); + MinecraftForge.EVENT_BUS.register(new ShadyRotation()); configFile.initialize(); ClientCommandHandler.instance.registerCommand(new OpenSettings()); ClientCommandHandler.instance.registerCommand(new Rosedrobe()); @@ -122,22 +131,42 @@ public class Main { ClientCommandHandler.instance.registerCommand(new AllEntities()); ClientCommandHandler.instance.registerCommand(new SexPlayer()); - String[] temp = getUrlContents("https://gist.github.com/RoseGoldIsntGay/6fa79111ae8efe3f5d269a095d748aa5/raw").split("\n"); - for(String str : temp) { - if(str.contains(":")) { - resp.put(str.substring(0, str.indexOf(":")), str.substring(str.indexOf(": ") + 2).replace("&", "§")); - } else { - System.out.println(str); - } + JsonArray funnynames = rga.get("funnynames").getAsJsonArray(); + cumsters = new String[funnynames.size()]; + Iterator<JsonElement> fn = funnynames.iterator(); + int count = 0; + while(fn.hasNext()) { + JsonElement name = fn.next(); + cumsters[count] = name.getAsString(); + count++; } - init = true; - - cumsters = getUrlContents("https://gist.githubusercontent.com/RoseGoldIsntGay/14108940b5c97d01de20213e567b7b9c/raw/").split("\n"); - ILILILLILILLILILILL = getUrlContents("https://gist.githubusercontent.com/RoseGoldIsntGay/2534fa591573120a5f71bbca2ccf0af2/raw/").split("\n"); - for(String str : ILILILLILILLILILILL) { - System.out.println(str); + JsonArray funnymessages = rga.get("funnymessages").getAsJsonArray(); + ILILILLILILLILILILL = new String[funnymessages.size()]; + Iterator<JsonElement> fm = funnymessages.iterator(); + count = 0; + while(fm.hasNext()) { + JsonElement message = fm.next(); + ILILILLILILLILILILL[count] = message.getAsString(); + count++; } + JsonObject replacions = rga.get("replacions").getAsJsonObject(); + Set<Map.Entry<String, JsonElement>> set = replacions.entrySet(); + + set.forEach(stringJsonElementEntry -> { + names.put(stringJsonElementEntry.getKey(), stringJsonElementEntry.getValue().getAsString().replace("&", "§")); + System.out.println(stringJsonElementEntry.getKey()+": "+stringJsonElementEntry.getValue().getAsString().replace("&", "§")); + }); + + replacions = rga.get("ranks").getAsJsonObject(); + set = replacions.entrySet(); + + set.forEach(stringJsonElementEntry -> { + ranks.put(stringJsonElementEntry.getKey(), stringJsonElementEntry.getValue().getAsString().replace("&", "§")); + System.out.println(stringJsonElementEntry.getKey()+": "+stringJsonElementEntry.getValue().getAsString().replace("&", "§")); + }); + init = true; + try { Reader reader = Files.newBufferedReader(Paths.get("./config/rosegoldaddons/rcmacros.json")); int data = reader.read(); @@ -146,9 +175,7 @@ public class Main { str += (char) data; data = reader.read(); } - str = str.replace("\"",""); - str = str.replace("{",""); - str = str.replace("}",""); + str = str.replace("\"","").replace("{","").replace("}",""); String[] arr = str.split(","); for(int i = 0; i < arr.length; i++) { String[] arr2 = arr[i].split(":"); @@ -163,9 +190,7 @@ public class Main { str2 += (char) data2; data2 = reader.read(); } - str2 = str2.replace("\"",""); - str2 = str2.replace("{",""); - str2 = str2.replace("}",""); + str2 = str2.replace("\"","").replace("{","").replace("}",""); String[] arr3 = str2.split(","); for(int i = 0; i < arr3.length; i++) { String[] arr4 = arr3[i].split(":"); @@ -211,58 +236,41 @@ public class Main { }); } - - @SubscribeEvent - public void onConnect(FMLNetworkEvent.ClientConnectedToServerEvent event) { - if(firstLoginThisSession) { - new Thread(() -> { - try { - Thread.sleep(4000); - ChatComponentText msg1 = new ChatComponentText("§0§7Thanks to ShadyAddons:§b https://cheatersgetbanned.me"); - msg1.setChatStyle(ChatUtils.createClickStyle(ClickEvent.Action.OPEN_URL, "https://cheatersgetbanned.me")); - ChatComponentText msg2 = new ChatComponentText("§0§7Thanks to Harry282 (SBClient):§b https://github.com/Harry282/Skyblock-Client"); - msg2.setChatStyle(ChatUtils.createClickStyle(ClickEvent.Action.OPEN_URL, "https://github.com/Harry282/Skyblock-Client")); - ChatComponentText msg3 = new ChatComponentText("§0§7Thanks to pizza boy (Pizza Client):§b https://github.com/PizzaboiBestLegit/Pizza-Client"); - msg3.setChatStyle(ChatUtils.createClickStyle(ClickEvent.Action.OPEN_URL, "https://github.com/PizzaboiBestLegit/Pizza-Client")); - ChatComponentText msg4 = new ChatComponentText("§0§7Check out the RoseGoldAddons §bDiscord Server!"); - msg4.setChatStyle(ChatUtils.createClickStyle(ClickEvent.Action.OPEN_URL, "https://discord.gg/Tmk2hwzdxm")); - mc.thePlayer.addChatMessage(msg1); - mc.thePlayer.addChatMessage(msg2); - mc.thePlayer.addChatMessage(msg3); - mc.thePlayer.addChatMessage(msg4); - firstLoginThisSession = false; - } catch (Exception e) { - e.printStackTrace(); - } - }).start(); - } - if(oldanim) { - new Thread(() -> { - try { - Thread.sleep(6000); - ChatUtils.sendMessage("§l§4Old Animations Mod was detected in your mods folder. This mod breaks some key RoseGoldAddons features, please uninstall it before asking for support as it is known to cause a lot of issues. Thanks."); - } catch (Exception e) { - e.printStackTrace(); - } - }).start(); - } - } - @SubscribeEvent public void onWorldChange(WorldEvent.Unload event) { - if(forageOnIsland || nukeWood || nukeCrops || mithrilNuker || gemNukeToggle) { + if(forageOnIsland || nukeWood || nukeCrops || mithrilNuker || gemNukeToggle || mithrilMacro) { ChatUtils.sendMessage("§cDetected World Change, Stopping All Macros"); forageOnIsland = false; nukeWood = false; nukeCrops = false; mithrilNuker = false; gemNukeToggle = false; + mithrilMacro = false; } } @SubscribeEvent public void tick(TickEvent.ClientTickEvent event) { if (event.phase != TickEvent.Phase.START) return; + if(mc.thePlayer == null || mc.theWorld == null) return; + if(firstLoginThisSession) { + ChatComponentText msg1 = new ChatComponentText("§0§7Thanks to ShadyAddons:§b https://cheatersgetbanned.me"); + msg1.setChatStyle(ChatUtils.createClickStyle(ClickEvent.Action.OPEN_URL, "https://cheatersgetbanned.me")); + ChatComponentText msg2 = new ChatComponentText("§0§7Thanks to Harry282 (SBClient):§b https://github.com/Harry282/Skyblock-Client"); + msg2.setChatStyle(ChatUtils.createClickStyle(ClickEvent.Action.OPEN_URL, "https://github.com/Harry282/Skyblock-Client")); + ChatComponentText msg3 = new ChatComponentText("§0§7Thanks to pizza boy (Pizza Client):§b https://github.com/PizzaboiBestLegit/Pizza-Client"); + msg3.setChatStyle(ChatUtils.createClickStyle(ClickEvent.Action.OPEN_URL, "https://github.com/PizzaboiBestLegit/Pizza-Client")); + ChatComponentText msg4 = new ChatComponentText("§0§7Check out the RoseGoldAddons §bDiscord Server!"); + msg4.setChatStyle(ChatUtils.createClickStyle(ClickEvent.Action.OPEN_URL, "https://discord.gg/Tmk2hwzdxm")); + mc.thePlayer.addChatMessage(msg1); + mc.thePlayer.addChatMessage(msg2); + mc.thePlayer.addChatMessage(msg3); + mc.thePlayer.addChatMessage(msg4); + if(oldanim) { + ChatUtils.sendMessage("§l§4Old Animations Mod was detected in your mods folder. This mod breaks some key RoseGoldAddons features, please uninstall it before asking for support as it is known to cause a lot of issues. Thanks."); + } + firstLoginThisSession = false; + } if(mc.gameSettings.limitFramerate == 1) { mc.gameSettings.setOptionFloatValue(GameSettings.Options.FRAMERATE_LIMIT, 260.0F); } diff --git a/src/main/java/rosegoldaddons/OpenSettings.java b/src/main/java/rosegoldaddons/OpenSettings.java index 0e79b74..73a562d 100644 --- a/src/main/java/rosegoldaddons/OpenSettings.java +++ b/src/main/java/rosegoldaddons/OpenSettings.java @@ -28,10 +28,7 @@ public class OpenSettings implements ICommand { @Override public void processCommand(ICommandSender sender, String[] args) { - /*EntityPlayerSP player = (EntityPlayerSP) sender; - player.addChatMessage(new ChatComponentText("hi "+player.getName()+"!"));*/ Main.display = Main.configFile.gui(); - return; } @Override diff --git a/src/main/java/rosegoldaddons/features/AutoGhostBlock.java b/src/main/java/rosegoldaddons/features/AutoGhostBlock.java new file mode 100644 index 0000000..76ca185 --- /dev/null +++ b/src/main/java/rosegoldaddons/features/AutoGhostBlock.java @@ -0,0 +1,143 @@ +package rosegoldaddons.features; + +import net.minecraft.block.state.BlockState; +import net.minecraft.block.state.IBlockState; +import net.minecraft.client.Minecraft; +import net.minecraft.client.settings.KeyBinding; +import net.minecraft.init.Blocks; +import net.minecraft.util.BlockPos; +import net.minecraft.util.Vec3; +import net.minecraft.util.Vec3i; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.fml.common.gameevent.InputEvent; +import net.minecraftforge.fml.common.gameevent.TickEvent; +import rosegoldaddons.Main; + +public class AutoGhostBlock { + private final KeyBinding sneakBind = Minecraft.getMinecraft().gameSettings.keyBindSneak; + private final KeyBinding jumpBind = Minecraft.getMinecraft().gameSettings.keyBindJump; + + @SubscribeEvent + public void onPlayerTick(TickEvent.PlayerTickEvent event) { + if(Main.mc.thePlayer == null || Main.mc.theWorld == null) return; + if(Main.configFile.ghostIndex == 0) { + if (!Main.configFile.AutoGB || !Main.configFile.AutoGBTopStair) return; + if (sneakBind.isKeyDown() && Main.configFile.AutoGB) { + BlockPos playerPos = Main.mc.thePlayer.getPosition(); + Vec3 playerVec = Main.mc.thePlayer.getPositionVector(); + Vec3i vec3i = new Vec3i(3, 1, 3); + Vec3i vec3i2 = new Vec3i(3, 2, 3); + for (BlockPos blockPos : BlockPos.getAllInBox(playerPos.add(vec3i), playerPos.subtract(vec3i2))) { + double diffX = Math.abs(blockPos.getX() + 0.5D - playerVec.xCoord); + double diffZ = Math.abs(blockPos.getZ() + 0.5D - playerVec.zCoord); + double diffY = blockPos.getY() - playerVec.yCoord; + if (diffX < 1 && diffZ < 1) { + IBlockState blockState = Main.mc.theWorld.getBlockState(blockPos); + if (isStair(blockState) && diffY == -0.5) { + Main.mc.theWorld.setBlockToAir(blockPos); + } + if (Main.configFile.AutoGBMisc) { + if (blockState.getBlock() == Blocks.skull && diffY == 0 && diffX < 0.5 && diffZ < 0.5) { + Main.mc.theWorld.setBlockToAir(blockPos); + } else if (blockState.getBlock() == Blocks.hopper && diffY == -0.625) { + Main.mc.theWorld.setBlockToAir(blockPos); + } else if (isFence(blockState) && diffY <= 0 && diffX < 0.5 && diffZ < 0.5) { + Main.mc.theWorld.setBlockToAir(blockPos); + } + } + } + } + } + } + if(jumpBind.isKeyDown() && Main.configFile.AutoGBTopStair) { + BlockPos playerPos = Main.mc.thePlayer.getPosition(); + Vec3 playerVec = Main.mc.thePlayer.getPositionVector(); + Vec3i vec3i = new Vec3i(3, 2, 3); + Vec3i vec3i2 = new Vec3i(3, 0, 3); + for (BlockPos blockPos : BlockPos.getAllInBox(playerPos.add(vec3i), playerPos.subtract(vec3i2))) { + double diffX = Math.abs(blockPos.getX() + 0.5D - playerVec.xCoord); + double diffZ = Math.abs(blockPos.getZ() + 0.5D - playerVec.zCoord); + double diffY = blockPos.getY() - playerVec.yCoord; + if(diffX < 1 && diffZ < 1) { + IBlockState blockState = Main.mc.theWorld.getBlockState(blockPos); + if(isStair(blockState) && diffY > 1.2 && diffY < 1.3) { + Main.mc.theWorld.setBlockToAir(blockPos); + } + } + } + } + } + + @SubscribeEvent + public void onKeyPress(InputEvent.KeyInputEvent event) { + if(Main.mc.thePlayer == null || Main.mc.theWorld == null) return; + if(Main.configFile.ghostIndex == 0) return; + if(!Main.configFile.AutoGB || !Main.configFile.AutoGBTopStair) return; + if(sneakBind.isPressed() && Main.configFile.AutoGB) { + BlockPos playerPos = Main.mc.thePlayer.getPosition(); + Vec3 playerVec = Main.mc.thePlayer.getPositionVector(); + Vec3i vec3i = new Vec3i(3, 1, 3); + Vec3i vec3i2 = new Vec3i(3, 2, 3); + for (BlockPos blockPos : BlockPos.getAllInBox(playerPos.add(vec3i), playerPos.subtract(vec3i2))) { + double diffX = Math.abs(blockPos.getX() + 0.5D - playerVec.xCoord); + double diffZ = Math.abs(blockPos.getZ() + 0.5D - playerVec.zCoord); + double diffY = blockPos.getY() - playerVec.yCoord; + if(diffX < 1 && diffZ < 1) { + IBlockState blockState = Main.mc.theWorld.getBlockState(blockPos); + if(isStair(blockState) && diffY == -0.5) { + Main.mc.theWorld.setBlockToAir(blockPos); + } + if(Main.configFile.AutoGBMisc) { + if(blockState.getBlock() == Blocks.skull && diffY == 0 && diffX < 0.5 && diffZ < 0.5) { + Main.mc.theWorld.setBlockToAir(blockPos); + } + else if(blockState.getBlock() == Blocks.hopper && diffY == -0.625) { + Main.mc.theWorld.setBlockToAir(blockPos); + } + else if(isFence(blockState) && diffY <= 0 && diffX < 0.5 && diffZ < 0.5) { + Main.mc.theWorld.setBlockToAir(blockPos); + } + } + } + } + } + if(jumpBind.isPressed() && Main.configFile.AutoGBTopStair) { + BlockPos playerPos = Main.mc.thePlayer.getPosition(); + Vec3 playerVec = Main.mc.thePlayer.getPositionVector(); + Vec3i vec3i = new Vec3i(3, 2, 3); + Vec3i vec3i2 = new Vec3i(3, 0, 3); + for (BlockPos blockPos : BlockPos.getAllInBox(playerPos.add(vec3i), playerPos.subtract(vec3i2))) { + double diffX = Math.abs(blockPos.getX() + 0.5D - playerVec.xCoord); + double diffZ = Math.abs(blockPos.getZ() + 0.5D - playerVec.zCoord); + double diffY = blockPos.getY() - playerVec.yCoord; + if(diffX < 1 && diffZ < 1) { + IBlockState blockState = Main.mc.theWorld.getBlockState(blockPos); + if(isStair(blockState) && diffY > 1.2 && diffY < 1.3) { + Main.mc.theWorld.setBlockToAir(blockPos); + } + } + } + } + } + + private boolean isStair(IBlockState blockState) { + if(blockState.getBlock() == Blocks.acacia_stairs || blockState.getBlock() == Blocks.birch_stairs || + blockState.getBlock() == Blocks.brick_stairs || blockState.getBlock() == Blocks.stone_brick_stairs || + blockState.getBlock() == Blocks.stone_stairs || blockState.getBlock() == Blocks.dark_oak_stairs || + blockState.getBlock() == Blocks.jungle_stairs || blockState.getBlock() == Blocks.spruce_stairs || + blockState.getBlock() == Blocks.red_sandstone_stairs || blockState.getBlock() == Blocks.sandstone_stairs || + blockState.getBlock() == Blocks.nether_brick_stairs || blockState.getBlock() == Blocks.oak_stairs || + blockState.getBlock() == Blocks.quartz_stairs) + return true; + return false; + } + + private boolean isFence(IBlockState blockState) { + if(blockState.getBlock() == Blocks.acacia_fence || blockState.getBlock() == Blocks.birch_fence || + blockState.getBlock() == Blocks.cobblestone_wall || blockState.getBlock() == Blocks.dark_oak_fence || + blockState.getBlock() == Blocks.jungle_fence || blockState.getBlock() == Blocks.spruce_fence || + blockState.getBlock() == Blocks.oak_fence || blockState.getBlock() == Blocks.nether_brick_fence) + return true; + return false; + } +} diff --git a/src/main/java/rosegoldaddons/features/CanePlanter.java b/src/main/java/rosegoldaddons/features/CanePlanter.java deleted file mode 100644 index 5f656d9..0000000 --- a/src/main/java/rosegoldaddons/features/CanePlanter.java +++ /dev/null @@ -1,78 +0,0 @@ -package rosegoldaddons.features; - -import net.minecraft.block.state.IBlockState; -import net.minecraft.client.Minecraft; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.init.Blocks; -import net.minecraft.item.ItemStack; -import net.minecraft.util.BlockPos; -import net.minecraft.util.EnumFacing; -import net.minecraft.util.Vec3; -import net.minecraft.util.Vec3i; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; -import net.minecraftforge.fml.common.gameevent.TickEvent; -import rosegoldaddons.Main; - -import java.util.ArrayList; - -public class CanePlanter { - //when you're down bad - @SubscribeEvent - public void onTick(TickEvent.ClientTickEvent event) { - if (!Main.placeCane || event.phase == TickEvent.Phase.END) { - return; - } - int cane = findItemInHotbar("Cane"); - BlockPos dirt = furthestEmptyDirt(); - if (cane != -1 && dirt != null) { - ItemStack item = Main.mc.thePlayer.inventory.getStackInSlot(cane); - Main.mc.thePlayer.inventory.currentItem = cane; - Main.mc.playerController.onPlayerRightClick(Main.mc.thePlayer, Main.mc.theWorld, item, dirt, EnumFacing.UP, Main.mc.thePlayer.getLookVec()); - } - } - - private BlockPos furthestEmptyDirt() { - int r = 5; - BlockPos playerPos = Main.mc.thePlayer.getPosition(); - playerPos.add(0, 1, 0); - Vec3 playerVec = Main.mc.thePlayer.getPositionVector(); - Vec3i vec3i = new Vec3i(r, r, r); - ArrayList<Vec3> dirts = new ArrayList<Vec3>(); - if (playerPos != null) { - for (BlockPos blockPos : BlockPos.getAllInBox(playerPos.add(vec3i), playerPos.subtract(vec3i))) { - IBlockState blockState = Main.mc.theWorld.getBlockState(blockPos); - IBlockState blockState2 = Main.mc.theWorld.getBlockState(blockPos.add(0, 1, 0)); - //Main.mc.thePlayer.addChatMessage(new ChatComponentText(blockState.getBlock().toString())); - if (blockState.getBlock() == Blocks.dirt && blockState2.getBlock() == Blocks.air) { - dirts.add(new Vec3(blockPos.getX() + 0.5, blockPos.getY(), blockPos.getZ() + 0.5)); - } - } - } - double biggest = -1; - Vec3 furthest = null; - for (int i = 0; i < dirts.size(); i++) { - double dist = dirts.get(i).distanceTo(playerVec); - if (dist > biggest) { - biggest = dist; - furthest = dirts.get(i); - } - } - if (furthest != null && biggest < 4) { - return new BlockPos(furthest.xCoord, furthest.yCoord, furthest.zCoord); - } - return null; - } - - private static int findItemInHotbar(String name) { - InventoryPlayer inv = Main.mc.thePlayer.inventory; - for (int i = 0; i < 9; i++) { - ItemStack curStack = inv.getStackInSlot(i); - if (curStack != null) { - if (curStack.getDisplayName().contains(name)) { - return i; - } - } - } - return -1; - } -} diff --git a/src/main/java/rosegoldaddons/features/CustomItemMacro.java b/src/main/java/rosegoldaddons/features/CustomItemMacro.java index b776f86..37b4ce3 100644 --- a/src/main/java/rosegoldaddons/features/CustomItemMacro.java +++ b/src/main/java/rosegoldaddons/features/CustomItemMacro.java @@ -16,13 +16,16 @@ import java.lang.reflect.Method; public class CustomItemMacro { private Thread thread; private int milis = 0; + private boolean working = false; @SubscribeEvent - public void onRender(RenderWorldLastEvent event) { + public void onTick(TickEvent.ClientTickEvent event) { + if(event.phase == TickEvent.Phase.END || working) return; if (!Main.autoUseItems) return; if (thread == null || !thread.isAlive()) { thread = new Thread(() -> { try { + working = true; int prevItem = Main.mc.thePlayer.inventory.currentItem; for (String i : UseCooldown.RCitems.keySet()) { if (milis % Math.floor(UseCooldown.RCitems.get(i)/100) == 0) { @@ -46,6 +49,7 @@ public class CustomItemMacro { Main.mc.thePlayer.inventory.currentItem = prevItem; milis++; Thread.sleep(100); + working = false; } catch (Exception e) { e.printStackTrace(); } diff --git a/src/main/java/rosegoldaddons/features/EndermanMacro.java b/src/main/java/rosegoldaddons/features/EndermanMacro.java index b0ff72a..c0f3c6a 100644 --- a/src/main/java/rosegoldaddons/features/EndermanMacro.java +++ b/src/main/java/rosegoldaddons/features/EndermanMacro.java @@ -1,14 +1,16 @@ package rosegoldaddons.features; -import net.minecraft.client.Minecraft; +import net.minecraft.client.network.NetHandlerPlayClient; +import net.minecraft.client.settings.KeyBinding; import net.minecraft.entity.Entity; import net.minecraft.entity.monster.EntityEnderman; +import net.minecraft.network.play.client.C0BPacketEntityAction; import net.minecraftforge.client.event.RenderWorldLastEvent; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.common.gameevent.TickEvent; import rosegoldaddons.Main; import rosegoldaddons.utils.RenderUtils; -import rosegoldaddons.utils.RotationUtils; +import rosegoldaddons.utils.ShadyRotation; import java.awt.*; @@ -18,9 +20,21 @@ public class EndermanMacro { @SubscribeEvent public void onTick(TickEvent.ClientTickEvent event) { if (!Main.configFile.EndermanESP && !Main.endermanMacro) return; + if(event.phase == TickEvent.Phase.END) return; enderman = getClosestEnderman(); - if(enderman != null && Main.endermanMacro) { - RotationUtils.faceEntity(enderman); + if(enderman != null && Main.endermanMacro && !ShadyRotation.running) { + ShadyRotation.smoothLook(ShadyRotation.getRotationToEntity(enderman), Main.configFile.smoothLookVelocity, () -> { + KeyBinding.setKeyBindState(Main.mc.gameSettings.keyBindSneak.getKeyCode(), true); + KeyBinding.setKeyBindState(Main.mc.gameSettings.keyBindSneak.getKeyCode(), false); + + if(!Main.mc.thePlayer.movementInput.sneak) { + Main.mc.getNetHandler().addToSendQueue(new C0BPacketEntityAction(Main.mc.thePlayer, C0BPacketEntityAction.Action.START_SNEAKING)); + Main.mc.thePlayer.movementInput.sneak = true; + } else { + Main.mc.getNetHandler().addToSendQueue(new C0BPacketEntityAction(Main.mc.thePlayer, C0BPacketEntityAction.Action.STOP_SNEAKING)); + Main.mc.thePlayer.movementInput.sneak = false; + } + }); } } diff --git a/src/main/java/rosegoldaddons/features/EntityReach.java b/src/main/java/rosegoldaddons/features/EntityReach.java index 21a4691..97a1c09 100644 --- a/src/main/java/rosegoldaddons/features/EntityReach.java +++ b/src/main/java/rosegoldaddons/features/EntityReach.java @@ -55,6 +55,7 @@ public class EntityReach { @SubscribeEvent public void renderWorld(RenderWorldLastEvent event) { + if(Main.mc.thePlayer == null || Main.mc.theWorld == null) return; if (!Main.configFile.entityReach) return; if (toInteract != null) { Entity stand = getClosestArmorStand(toInteract); diff --git a/src/main/java/rosegoldaddons/features/ForagingIslandMacro.java b/src/main/java/rosegoldaddons/features/ForagingIslandMacro.java index e06d7ea..bf37569 100644 --- a/src/main/java/rosegoldaddons/features/ForagingIslandMacro.java +++ b/src/main/java/rosegoldaddons/features/ForagingIslandMacro.java @@ -10,9 +10,11 @@ import net.minecraft.item.ItemStack; import net.minecraft.util.*; import net.minecraftforge.client.event.RenderWorldLastEvent; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.fml.common.gameevent.TickEvent; import rosegoldaddons.Main; import rosegoldaddons.utils.ChatUtils; import rosegoldaddons.utils.RotationUtils; +import rosegoldaddons.utils.ShadyRotation; import java.lang.reflect.Method; import java.util.ArrayList; @@ -24,7 +26,7 @@ public class ForagingIslandMacro { private final String[] responses = {"wtf??", "hello?", "hi?", "uhhhhhh", "what the", "??????"}; @SubscribeEvent - public void renderWorld(RenderWorldLastEvent event) { + public void onTick(TickEvent.ClientTickEvent event) { if (Main.forageOnIsland) { if (thread == null || !thread.isAlive()) { thread = new Thread(() -> { @@ -57,8 +59,8 @@ public class ForagingIslandMacro { return; } if (furthestDirt != null) { - RotationUtils.facePos(new Vec3(furthestDirt.getX() + 0.5, furthestDirt.getY() - 0.5, furthestDirt.getZ() + 0.5)); - Thread.sleep(Main.configFile.smoothLookVelocity * 2L); + ShadyRotation.smoothLook(ShadyRotation.vec3ToRotation(new Vec3(furthestDirt.getX() +0.5, furthestDirt.getY() + 1, furthestDirt.getZ() + 0.5)), Main.configFile.smoothLookVelocity, () -> {}); + Thread.sleep(Main.configFile.smoothLookVelocity * 40L); if (sapling != -1) { if (Main.mc.objectMouseOver.typeOfHit.toString().equals("BLOCK")) { BlockPos pos = Main.mc.objectMouseOver.getBlockPos(); @@ -75,7 +77,8 @@ public class ForagingIslandMacro { } else { BlockPos dirt = closestDirt(); if (dirt != null) { - RotationUtils.facePos(new Vec3(dirt.getX() + 0.5, dirt.getY(), dirt.getZ() + 0.5)); + ShadyRotation.smoothLook(ShadyRotation.vec3ToRotation(new Vec3(dirt.getX() + 0.5, dirt.getY() + 1, dirt.getZ() + 0.5)), Main.configFile.smoothLookVelocity, () -> {}); + Thread.sleep(Main.configFile.smoothLookVelocity * 40L); if (bonemeal != -1 && treecap != -1) { Main.mc.thePlayer.inventory.currentItem = bonemeal; Random rand = new Random(); @@ -84,19 +87,19 @@ public class ForagingIslandMacro { toAdd = rand.nextInt(20); } //ChatUtils.sendMessage("extra delay: "+toAdd+"%"); - Thread.sleep(Math.round(150*(1+(toAdd/100)))); + Thread.sleep(Math.round(150*(1+(toAdd/100F)))); rightClick(); rightClick(); Main.mc.thePlayer.inventory.currentItem = treecap; - Thread.sleep(Math.round(Main.configFile.treecapDelay*(1+(toAdd/100)))); + Thread.sleep(Math.round(Main.configFile.treecapDelay*(1+(toAdd/100F)))); KeyBinding.setKeyBindState(Main.mc.gameSettings.keyBindAttack.getKeyCode(), true); - Thread.sleep(Math.round(150*(1+(toAdd/100)))); + Thread.sleep(Math.round(150*(1+(toAdd/100F)))); KeyBinding.setKeyBindState(Main.mc.gameSettings.keyBindAttack.getKeyCode(), false); - Thread.sleep(Math.round(25*(1+(toAdd/100)))); + Thread.sleep(Math.round(25*(1+(toAdd/100F)))); Main.mc.thePlayer.inventory.currentItem = rod; - Thread.sleep(Math.round(Main.configFile.prerodDelay*(1+(toAdd/100)))); + Thread.sleep(Math.round(Main.configFile.prerodDelay*(1+(toAdd/100F)))); rightClick(); - Thread.sleep(Math.round(Main.configFile.postrodDelay*(1+(toAdd/100)))); + Thread.sleep(Math.round(Main.configFile.postrodDelay*(1+(toAdd/100F)))); } } } diff --git a/src/main/java/rosegoldaddons/features/GemstoneAura.java b/src/main/java/rosegoldaddons/features/GemstoneAura.java index 28f30af..af919f9 100644 --- a/src/main/java/rosegoldaddons/features/GemstoneAura.java +++ b/src/main/java/rosegoldaddons/features/GemstoneAura.java @@ -1,23 +1,16 @@ package rosegoldaddons.features; -import net.minecraft.block.Block; -import net.minecraft.block.BlockAir; import net.minecraft.block.BlockStainedGlass; import net.minecraft.block.BlockStainedGlassPane; import net.minecraft.block.state.IBlockState; -import net.minecraft.client.Minecraft; -import net.minecraft.client.multiplayer.PlayerControllerMP; import net.minecraft.init.Blocks; import net.minecraft.item.EnumDyeColor; import net.minecraft.network.play.client.C07PacketPlayerDigging; -import net.minecraft.network.play.client.C0APacketAnimation; import net.minecraft.util.*; import net.minecraftforge.client.event.RenderWorldLastEvent; -import net.minecraftforge.event.world.BlockEvent; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.common.gameevent.TickEvent; import rosegoldaddons.Main; -import rosegoldaddons.utils.ChatUtils; import rosegoldaddons.utils.PlayerUtils; import rosegoldaddons.utils.RenderUtils; @@ -35,8 +28,8 @@ public class GemstoneAura { currentDamage = 0; return; } - if (event.phase == TickEvent.Phase.END) { - if (PlayerUtils.pickaxeAbilityReady && Main.mc.thePlayer != null) { + if (event.phase == TickEvent.Phase.END && Main.mc.theWorld != null && Main.mc.thePlayer != null) { + if (PlayerUtils.pickaxeAbilityReady) { Main.mc.playerController.sendUseItem(Main.mc.thePlayer, Main.mc.theWorld, Main.mc.thePlayer.inventory.getStackInSlot(Main.mc.thePlayer.inventory.currentItem)); } if (currentDamage > 100) { @@ -109,7 +102,7 @@ public class GemstoneAura { playerPos = playerPos.add(0, 1, 0); Vec3 playerVec = Main.mc.thePlayer.getPositionVector(); Vec3i vec3i = new Vec3i(r, r, r); - ArrayList<Vec3> chests = new ArrayList<Vec3>(); + ArrayList<Vec3> chests = new ArrayList<>(); if (playerPos != null) { for (BlockPos blockPos : BlockPos.getAllInBox(playerPos.add(vec3i), playerPos.subtract(vec3i))) { IBlockState blockState = Main.mc.theWorld.getBlockState(blockPos); @@ -133,11 +126,11 @@ public class GemstoneAura { } double smallest = 9999; Vec3 closest = null; - for (int i = 0; i < chests.size(); i++) { - double dist = chests.get(i).distanceTo(playerVec); + for (Vec3 chest : chests) { + double dist = chest.distanceTo(playerVec); if (dist < smallest) { smallest = dist; - closest = chests.get(i); + closest = chest; } } if (closest != null && smallest < 5) { diff --git a/src/main/java/rosegoldaddons/features/HardstoneAura.java b/src/main/java/rosegoldaddons/features/HardstoneAura.java index 8cecae7..4f92056 100644 --- a/src/main/java/rosegoldaddons/features/HardstoneAura.java +++ b/src/main/java/rosegoldaddons/features/HardstoneAura.java @@ -21,10 +21,8 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.common.gameevent.TickEvent; import rosegoldaddons.Main; import rosegoldaddons.events.ReceivePacketEvent; -import rosegoldaddons.utils.ChatUtils; -import rosegoldaddons.utils.PlayerUtils; -import rosegoldaddons.utils.RenderUtils; -import rosegoldaddons.utils.RotationUtils; +import rosegoldaddons.utils.*; +import scala.concurrent.impl.CallbackRunnable; import java.awt.*; import java.util.ArrayList; @@ -100,7 +98,7 @@ public class HardstoneAura { stopHardstone = true; double dist = closestChest.distanceTo(particlePos); if (dist < 1) { - RotationUtils.facePos(particlePos); + ShadyRotation.smoothLook(ShadyRotation.vec3ToRotation(particlePos), Main.configFile.smoothLookVelocity, () -> {}); } } } @@ -176,23 +174,32 @@ public class HardstoneAura { private BlockPos closestStone() { if(Main.mc.theWorld == null) return null; if(Main.mc.thePlayer == null) return null; - int r = 6; + int r = 5; BlockPos playerPos = Main.mc.thePlayer.getPosition(); playerPos.add(0, 1, 0); Vec3 playerVec = Main.mc.thePlayer.getPositionVector(); Vec3i vec3i = new Vec3i(r, 1 + Main.configFile.hardrange, r); - Vec3i vec3i2 = new Vec3i(r, 0, r); + Vec3i vec3i2 = new Vec3i(r, Main.configFile.hardrangeDown, r); ArrayList<Vec3> stones = new ArrayList<Vec3>(); ArrayList<Vec3> gemstones = new ArrayList<Vec3>(); if (playerPos != null) { for (BlockPos blockPos : BlockPos.getAllInBox(playerPos.add(vec3i), playerPos.subtract(vec3i2))) { IBlockState blockState = Main.mc.theWorld.getBlockState(blockPos); if(Main.configFile.hardIndex == 0) { - if (blockState.getBlock() == Blocks.stone && !broken.contains(blockPos)) { + if (!Main.configFile.includeExcavatable && blockState.getBlock() == Blocks.stone && !broken.contains(blockPos)) { stones.add(new Vec3(blockPos.getX() + 0.5, blockPos.getY(), blockPos.getZ() + 0.5)); } if (Main.configFile.includeOres) { - if (blockState.getBlock() == Blocks.coal_ore || blockState.getBlock() == Blocks.diamond_ore || blockState.getBlock() == Blocks.gold_ore || blockState.getBlock() == Blocks.redstone_ore || blockState.getBlock() == Blocks.iron_ore || blockState.getBlock() == Blocks.lapis_ore || blockState.getBlock() == Blocks.emerald_ore || blockState.getBlock() == Blocks.netherrack && !broken.contains(blockPos)) { + if (blockState.getBlock() == Blocks.coal_ore || blockState.getBlock() == Blocks.diamond_ore + || blockState.getBlock() == Blocks.gold_ore || blockState.getBlock() == Blocks.redstone_ore + || blockState.getBlock() == Blocks.iron_ore || blockState.getBlock() == Blocks.lapis_ore + || blockState.getBlock() == Blocks.emerald_ore || blockState.getBlock() == Blocks.netherrack + && !broken.contains(blockPos)) { + stones.add(new Vec3(blockPos.getX() + 0.5, blockPos.getY(), blockPos.getZ() + 0.5)); + } + } + if(Main.configFile.includeExcavatable) { + if (blockState.getBlock() == Blocks.gravel || blockState.getBlock() == Blocks.sand && !broken.contains(blockPos)) { stones.add(new Vec3(blockPos.getX() + 0.5, blockPos.getY(), blockPos.getZ() + 0.5)); } } @@ -207,11 +214,20 @@ public class HardstoneAura { if(isSlow(blockState)) { gemstones.add(new Vec3(blockPos.getX() + 0.5, blockPos.getY(), blockPos.getZ() + 0.5)); } - else if (blockState.getBlock() == Blocks.stone && !broken.contains(blockPos)) { + else if (!Main.configFile.includeExcavatable && blockState.getBlock() == Blocks.stone && !broken.contains(blockPos)) { stones.add(new Vec3(blockPos.getX() + 0.5, blockPos.getY(), blockPos.getZ() + 0.5)); } if (Main.configFile.includeOres) { - if (blockState.getBlock() == Blocks.coal_ore || blockState.getBlock() == Blocks.diamond_ore || blockState.getBlock() == Blocks.gold_ore || blockState.getBlock() == Blocks.redstone_ore || blockState.getBlock() == Blocks.iron_ore || blockState.getBlock() == Blocks.lapis_ore || blockState.getBlock() == Blocks.emerald_ore || blockState.getBlock() == Blocks.netherrack && !broken.contains(blockPos)) { + if (blockState.getBlock() == Blocks.coal_ore || blockState.getBlock() == Blocks.diamond_ore + || blockState.getBlock() == Blocks.gold_ore || blockState.getBlock() == Blocks.redstone_ore + || blockState.getBlock() == Blocks.iron_ore || blockState.getBlock() == Blocks.lapis_ore + || blockState.getBlock() == Blocks.emerald_ore || blockState.getBlock() == Blocks.netherrack + && !broken.contains(blockPos)) { + stones.add(new Vec3(blockPos.getX() + 0.5, blockPos.getY(), blockPos.getZ() + 0.5)); + } + } + if(Main.configFile.includeExcavatable) { + if (blockState.getBlock() == Blocks.gravel || blockState.getBlock() == Blocks.sand && !broken.contains(blockPos)) { stones.add(new Vec3(blockPos.getX() + 0.5, blockPos.getY(), blockPos.getZ() + 0.5)); } } @@ -222,11 +238,20 @@ public class HardstoneAura { if(isSlow(blockState)) { gemstones.add(new Vec3(blockPos.getX() + 0.5, blockPos.getY(), blockPos.getZ() + 0.5)); } - else if (blockState.getBlock() == Blocks.stone && !broken.contains(blockPos)) { + else if (!Main.configFile.includeExcavatable && blockState.getBlock() == Blocks.stone && !broken.contains(blockPos)) { stones.add(new Vec3(blockPos.getX() + 0.5, blockPos.getY(), blockPos.getZ() + 0.5)); } if (Main.configFile.includeOres) { - if (blockState.getBlock() == Blocks.coal_ore || blockState.getBlock() == Blocks.diamond_ore || blockState.getBlock() == Blocks.gold_ore || blockState.getBlock() == Blocks.redstone_ore || blockState.getBlock() == Blocks.iron_ore || blockState.getBlock() == Blocks.lapis_ore || blockState.getBlock() == Blocks.emerald_ore || blockState.getBlock() == Blocks.netherrack && !broken.contains(blockPos)) { + if (blockState.getBlock() == Blocks.coal_ore || blockState.getBlock() == Blocks.diamond_ore + || blockState.getBlock() == Blocks.gold_ore || blockState.getBlock() == Blocks.redstone_ore + || blockState.getBlock() == Blocks.iron_ore || blockState.getBlock() == Blocks.lapis_ore + || blockState.getBlock() == Blocks.emerald_ore || blockState.getBlock() == Blocks.netherrack + && !broken.contains(blockPos)) { + stones.add(new Vec3(blockPos.getX() + 0.5, blockPos.getY(), blockPos.getZ() + 0.5)); + } + } + if(Main.configFile.includeExcavatable) { + if (blockState.getBlock() == Blocks.gravel || blockState.getBlock() == Blocks.sand && !broken.contains(blockPos)) { stones.add(new Vec3(blockPos.getX() + 0.5, blockPos.getY(), blockPos.getZ() + 0.5)); } } @@ -237,11 +262,20 @@ public class HardstoneAura { if(isSlow(blockState)) { gemstones.add(new Vec3(blockPos.getX() + 0.5, blockPos.getY(), blockPos.getZ() + 0.5)); } - else if (blockState.getBlock() == Blocks.stone && !broken.contains(blockPos)) { + else if (!Main.configFile.includeExcavatable && blockState.getBlock() == Blocks.stone && !broken.contains(blockPos)) { stones.add(new Vec3(blockPos.getX() + 0.5, blockPos.getY(), blockPos.getZ() + 0.5)); } if (Main.configFile.includeOres) { - if (blockState.getBlock() == Blocks.coal_ore || blockState.getBlock() == Blocks.diamond_ore || blockState.getBlock() == Blocks.gold_ore || blockState.getBlock() == Blocks.redstone_ore || blockState.getBlock() == Blocks.iron_ore || blockState.getBlock() == Blocks.lapis_ore || blockState.getBlock() == Blocks.emerald_ore || blockState.getBlock() == Blocks.netherrack && !broken.contains(blockPos)) { + if (blockState.getBlock() == Blocks.coal_ore || blockState.getBlock() == Blocks.diamond_ore + || blockState.getBlock() == Blocks.gold_ore || blockState.getBlock() == Blocks.redstone_ore + || blockState.getBlock() == Blocks.iron_ore || blockState.getBlock() == Blocks.lapis_ore + || blockState.getBlock() == Blocks.emerald_ore || blockState.getBlock() == Blocks.netherrack + && !broken.contains(blockPos)) { + stones.add(new Vec3(blockPos.getX() + 0.5, blockPos.getY(), blockPos.getZ() + 0.5)); + } + } + if(Main.configFile.includeExcavatable) { + if (blockState.getBlock() == Blocks.gravel || blockState.getBlock() == Blocks.sand && !broken.contains(blockPos)) { stones.add(new Vec3(blockPos.getX() + 0.5, blockPos.getY(), blockPos.getZ() + 0.5)); } } @@ -252,11 +286,20 @@ public class HardstoneAura { if(isSlow(blockState)) { gemstones.add(new Vec3(blockPos.getX() + 0.5, blockPos.getY(), blockPos.getZ() + 0.5)); } - else if (blockState.getBlock() == Blocks.stone && !broken.contains(blockPos)) { + else if (!Main.configFile.includeExcavatable && blockState.getBlock() == Blocks.stone && !broken.contains(blockPos)) { stones.add(new Vec3(blockPos.getX() + 0.5, blockPos.getY(), blockPos.getZ() + 0.5)); } if (Main.configFile.includeOres) { - if (blockState.getBlock() == Blocks.coal_ore || blockState.getBlock() == Blocks.diamond_ore || blockState.getBlock() == Blocks.gold_ore || blockState.getBlock() == Blocks.redstone_ore || blockState.getBlock() == Blocks.iron_ore || blockState.getBlock() == Blocks.lapis_ore || blockState.getBlock() == Blocks.emerald_ore || blockState.getBlock() == Blocks.netherrack && !broken.contains(blockPos)) { + if (blockState.getBlock() == Blocks.coal_ore || blockState.getBlock() == Blocks.diamond_ore + || blockState.getBlock() == Blocks.gold_ore || blockState.getBlock() == Blocks.redstone_ore + || blockState.getBlock() == Blocks.iron_ore || blockState.getBlock() == Blocks.lapis_ore + || blockState.getBlock() == Blocks.emerald_ore || blockState.getBlock() == Blocks.netherrack + && !broken.contains(blockPos)) { + stones.add(new Vec3(blockPos.getX() + 0.5, blockPos.getY(), blockPos.getZ() + 0.5)); + } + } + if(Main.configFile.includeExcavatable) { + if (blockState.getBlock() == Blocks.gravel || blockState.getBlock() == Blocks.sand && !broken.contains(blockPos)) { stones.add(new Vec3(blockPos.getX() + 0.5, blockPos.getY(), blockPos.getZ() + 0.5)); } } diff --git a/src/main/java/rosegoldaddons/features/MithrilMacro.java b/src/main/java/rosegoldaddons/features/MithrilMacro.java index ce9509b..e2645c5 100644 --- a/src/main/java/rosegoldaddons/features/MithrilMacro.java +++ b/src/main/java/rosegoldaddons/features/MithrilMacro.java @@ -1,10 +1,13 @@ package rosegoldaddons.features; +import net.minecraft.block.BlockHardenedClay; +import net.minecraft.block.BlockStainedGlass; import net.minecraft.block.BlockStone; import net.minecraft.block.state.IBlockState; import net.minecraft.client.Minecraft; import net.minecraft.client.settings.KeyBinding; import net.minecraft.init.Blocks; +import net.minecraft.item.EnumDyeColor; import net.minecraft.network.play.client.C07PacketPlayerDigging; import net.minecraft.util.*; import net.minecraftforge.client.event.RenderWorldLastEvent; @@ -29,6 +32,7 @@ public class MithrilMacro { @SubscribeEvent public void onTick(TickEvent.ClientTickEvent event) { if (event.phase == TickEvent.Phase.END) return; + if(Main.mc.thePlayer == null || Main.mc.theWorld == null) return; if (Main.mc.currentScreen != null) return; if (!Main.mithrilMacro) { if (holdingLeft) { @@ -50,7 +54,6 @@ public class MithrilMacro { lastBlockPos = blockPos; blockPos = closestMithril(); if (lastBlockPos != null && blockPos != null && !lastBlockPos.equals(blockPos)) { - ChatUtils.sendMessage("Block pos was changed."); currentDamage = 0; } if (blockPos != null) { @@ -58,7 +61,7 @@ public class MithrilMacro { if (vec3s.size() > 0) { vec = vec3s.get(0); if (vec != null) { - RotationUtils.facePos(vec); + ShadyRotation.smoothLook(ShadyRotation.vec3ToRotation(vec), Main.configFile.smoothLookVelocity, () -> {}); lastVec = vec; KeyBinding.setKeyBindState(lc.getKeyCode(), true); holdingLeft = true; @@ -117,17 +120,24 @@ public class MithrilMacro { } private boolean isMithril(IBlockState blockState) { - if (blockState.getBlock() == Blocks.prismarine) { - return true; - } else if (blockState.getBlock() == Blocks.wool) { - return true; - } else if (blockState.getBlock() == Blocks.stained_hardened_clay) { - return true; - } else if (!Main.configFile.ignoreTitanium && blockState.getBlock() == Blocks.stone && blockState.getValue(BlockStone.VARIANT) == BlockStone.EnumType.DIORITE_SMOOTH) { - return true; - } else if (blockState.getBlock() == Blocks.gold_block) { - return true; + if (!Main.configFile.onlyOres) { + if (blockState.getBlock() == Blocks.prismarine) { + return true; + } else if (blockState.getBlock() == Blocks.wool && (blockState.getValue(BlockStainedGlass.COLOR) == EnumDyeColor.LIGHT_BLUE || blockState.getValue(BlockStainedGlass.COLOR) == EnumDyeColor.GRAY)) { + return true; + } else if (blockState.getBlock() == Blocks.stained_hardened_clay && blockState.getValue(BlockStainedGlass.COLOR) == EnumDyeColor.CYAN) { + return true; + } else if (!Main.configFile.ignoreTitanium && blockState.getBlock() == Blocks.stone && blockState.getValue(BlockStone.VARIANT) == BlockStone.EnumType.DIORITE_SMOOTH) { + return true; + } else if (blockState.getBlock() == Blocks.gold_block) { + return true; + } + } + + if (Main.configFile.includeOres || Main.configFile.onlyOres) { + return blockState.getBlock() == Blocks.coal_ore || blockState.getBlock() == Blocks.diamond_ore || blockState.getBlock() == Blocks.gold_ore || blockState.getBlock() == Blocks.redstone_ore || blockState.getBlock() == Blocks.iron_ore || blockState.getBlock() == Blocks.lapis_ore || blockState.getBlock() == Blocks.emerald_ore || blockState.getBlock() == Blocks.netherrack; } + return false; } } diff --git a/src/main/java/rosegoldaddons/features/MithrilNuker.java b/src/main/java/rosegoldaddons/features/MithrilNuker.java index 2e2e9e5..2e7a36a 100644 --- a/src/main/java/rosegoldaddons/features/MithrilNuker.java +++ b/src/main/java/rosegoldaddons/features/MithrilNuker.java @@ -13,6 +13,7 @@ import rosegoldaddons.Main; import rosegoldaddons.utils.PlayerUtils; import rosegoldaddons.utils.RenderUtils; import rosegoldaddons.utils.RotationUtils; +import rosegoldaddons.utils.ShadyRotation; import java.awt.*; import java.util.ArrayList; @@ -21,15 +22,17 @@ public class MithrilNuker { private static int currentDamage; private static byte blockHitDelay = 0; private static BlockPos blockPos; + private BlockPos lastBlockPos = null; @SubscribeEvent public void onTick(TickEvent.ClientTickEvent event) { - if (!Main.mithrilNuker || Main.mc.thePlayer == null || Main.mc.theWorld == null) { + if(Main.mc.thePlayer == null || Main.mc.theWorld == null) return; + if (!Main.mithrilNuker) { currentDamage = 0; return; } if (event.phase == TickEvent.Phase.END) { - if(PlayerUtils.pickaxeAbilityReady) { + if(PlayerUtils.pickaxeAbilityReady && Main.mc.playerController != null) { Main.mc.playerController.sendUseItem(Main.mc.thePlayer, Main.mc.theWorld, Main.mc.thePlayer.inventory.getStackInSlot(Main.mc.thePlayer.inventory.currentItem)); } if(currentDamage > 100) { @@ -42,6 +45,7 @@ public class MithrilNuker { } } if(currentDamage == 0) { + lastBlockPos = blockPos; blockPos = closestMithril(); } if (blockPos != null) { @@ -52,7 +56,7 @@ public class MithrilNuker { if (currentDamage == 0) { Main.mc.thePlayer.sendQueue.addToSendQueue(new C07PacketPlayerDigging(C07PacketPlayerDigging.Action.START_DESTROY_BLOCK, blockPos, EnumFacing.DOWN)); if(Main.configFile.mithrilLook) { - RotationUtils.facePos(new Vec3(blockPos.getX() + 0.5, blockPos.getY() - 1, blockPos.getZ() + 0.5)); + ShadyRotation.smoothLook(ShadyRotation.getRotationToBlock(blockPos), Main.configFile.smoothLookVelocity, () -> {}); } } PlayerUtils.swingItem(); diff --git a/src/main/java/rosegoldaddons/features/PowderMacro.java b/src/main/java/rosegoldaddons/features/PowderMacro.java index b4d0937..61555a3 100644 --- a/src/main/java/rosegoldaddons/features/PowderMacro.java +++ b/src/main/java/rosegoldaddons/features/PowderMacro.java @@ -16,6 +16,7 @@ import rosegoldaddons.Main; import rosegoldaddons.events.ReceivePacketEvent; import rosegoldaddons.utils.RenderUtils; import rosegoldaddons.utils.RotationUtils; +import rosegoldaddons.utils.ShadyRotation; import java.awt.*; import java.util.ArrayList; @@ -29,14 +30,11 @@ public class PowderMacro { if (event.packet instanceof S2APacketParticles) { S2APacketParticles packet = (S2APacketParticles) event.packet; if (packet.getParticleType().equals(EnumParticleTypes.CRIT)) { - Vec3 particlePos = new Vec3(packet.getXCoordinate(), packet.getYCoordinate() - 0.7, packet.getZCoordinate()); + Vec3 particlePos = new Vec3(packet.getXCoordinate(), packet.getYCoordinate(), packet.getZCoordinate()); if (closestChest != null) { double dist = closestChest.distanceTo(particlePos); if (dist < 1) { - particlePos = particlePos.add(new Vec3(0, -1, 0)); - int drill = findItemInHotbar("X655"); - if(drill != -1) Main.mc.thePlayer.inventory.currentItem = drill; - RotationUtils.facePos(particlePos); + ShadyRotation.smoothLook(ShadyRotation.vec3ToRotation(particlePos), Main.configFile.smoothLookVelocity, () -> {}); } } } diff --git a/src/main/java/rosegoldaddons/features/SexAura.java b/src/main/java/rosegoldaddons/features/SexAura.java index 54e88f2..543915f 100644 --- a/src/main/java/rosegoldaddons/features/SexAura.java +++ b/src/main/java/rosegoldaddons/features/SexAura.java @@ -1,15 +1,10 @@ package rosegoldaddons.features; -import net.minecraft.entity.EntityLivingBase; import net.minecraft.util.ChatComponentText; import net.minecraftforge.client.event.ClientChatReceivedEvent; -import net.minecraftforge.event.entity.EntityJoinWorldEvent; import net.minecraftforge.fml.common.eventhandler.EventPriority; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import rosegoldaddons.Main; -import rosegoldaddons.events.RenderLivingEntityEvent; - -import java.util.Map; public class SexAura { @SubscribeEvent(priority = EventPriority.HIGHEST) @@ -32,21 +27,6 @@ public class SexAura { } } - @SubscribeEvent - public void onEntityRender(RenderLivingEntityEvent event) { - if (Main.init) { - String text = event.entity.getDisplayName().getFormattedText(); - for (Map.Entry<String, String> entry : Main.resp.entrySet()) { - String key = entry.getKey(); - String value = entry.getValue(); - if (text.contains(key) && !text.contains(value)) { - event.entity.setCustomNameTag(text.replace(key, value)); - break; - } - } - } - } - private static void playAlert() { Main.mc.thePlayer.playSound("random.orb", 1, 0.5F); } diff --git a/src/main/java/rosegoldaddons/mixins/MixinRenderString.java b/src/main/java/rosegoldaddons/mixins/MixinRenderString.java index f7b0e8d..e4888e0 100644 --- a/src/main/java/rosegoldaddons/mixins/MixinRenderString.java +++ b/src/main/java/rosegoldaddons/mixins/MixinRenderString.java @@ -1,32 +1,98 @@ package rosegoldaddons.mixins; import net.minecraft.client.gui.FontRenderer; +import net.minecraft.util.StringUtils; +import org.apache.commons.codec.digest.DigestUtils; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.ModifyVariable; import rosegoldaddons.Main; -import java.util.Map; - @Mixin(FontRenderer.class) public abstract class MixinRenderString { - @ModifyVariable(method = "renderString", at = @At(value = "FIELD")) + @ModifyVariable(method = "drawString(Ljava/lang/String;FFIZ)I", at = @At(value = "FIELD")) private String replaceName(String text) { - if(Main.configFile.wydsi && text.contains("727")) { + if (Main.mc.theWorld == null || Main.mc.thePlayer == null) return text; + if (Main.configFile.wydsi && text.contains("727")) { text = text.replace("727", "726"); } - if (Main.init) { - for (Map.Entry<String, String> entry : Main.resp.entrySet()) { - String key = entry.getKey(); - String value = entry.getValue(); - - if (text.contains(key) && !text.contains(value)) { - text = text.replace(key, value)+"§r"; - break; + if (Main.init && Main.configFile.alchsleep != 88 || Main.configFile.skiblock != 263) { + String[] words = stripString(text).replace(":"," ").replace("'"," ").split(" "); + String[] formatteds = text.replace(":"," ").replace("'"," ").split(" "); + for (String word : words) { + if (Main.hashedCache.contains(word)) continue; + if(Main.rankCache.containsKey(word)) { + String rank = getRank(text, word); + if(rank != null) { + text = text.replace(rank, Main.rankCache.get(word)); + } + } else { + String hashed = DigestUtils.sha256Hex(word + word); + if (Main.ranks.containsKey(hashed)) { + String rank = getRank(text, word); + if(rank != null) { + Main.rankCache.put(word, Main.ranks.get(hashed)); + System.out.println(word+":"+Main.ranks.get(hashed)); + } + } + } + } + for (String word : words) { + if (Main.hashedCache.contains(word)) continue; + if (Main.nameCache.containsKey(word)) { + String[] replaces = Main.nameCache.get(word).split(" "); + for (String replace : replaces) { + for (String formatted : formatteds) { + if (replace.equals(formatted)) return text; + } + } + String color = getColorBeforeIndex(text, text.indexOf(word)); + text = text.replace(word, Main.nameCache.get(word) + color); + } else { + String hashed = DigestUtils.sha256Hex(word + word); + if (Main.names.containsKey(hashed)) { + Main.nameCache.put(word, Main.names.get(hashed)); + } else { + Main.hashedCache.add(word); + } } } } return text; } + + private String getRank(String str, String sub) { + if(!str.contains("[") || !str.contains("]")) return null; + if(sub.contains("[") || sub.contains("]")) return null; + if(str.indexOf(sub)-sub.length() >= str.indexOf("]")) return null; + if(str.indexOf(sub) < str.indexOf("[")) return null; + + return str.substring(str.indexOf("["), str.indexOf("]")+1); + } + + private String getColorBeforeIndex(String str, int index) { + String lastColor = ""; + for (int i = 0; i < str.length(); i++) { + if (i == index) break; + if (str.charAt(i) == '§' && i + 1 < str.length() && str.charAt(i + 1) != 'r' && str.charAt(i + 1) != 'l' && str.charAt(i + 1) != 'k' + && str.charAt(i + 1) != 'm' && str.charAt(i + 1) != 'n' && str.charAt(i + 1) != 'o') { + lastColor = str.charAt(i) + "" + str.charAt(i + 1); + } + } + return lastColor; + } + + private String stripString(String s) { + char[] nonValidatedString = StringUtils.stripControlCodes(s).toCharArray(); + StringBuilder validated = new StringBuilder(); + + for (char a : nonValidatedString) { + if ((int) a < 127 && (int) a > 20) { + validated.append(a); + } + } + + return validated.toString(); + } } diff --git a/src/main/java/rosegoldaddons/mixins/MixinRendererLivingEntity.java b/src/main/java/rosegoldaddons/mixins/MixinRendererLivingEntity.java index ae85419..25f1a2e 100644 --- a/src/main/java/rosegoldaddons/mixins/MixinRendererLivingEntity.java +++ b/src/main/java/rosegoldaddons/mixins/MixinRendererLivingEntity.java @@ -1,11 +1,10 @@ package rosegoldaddons.mixins; -import net.minecraft.client.Minecraft; import net.minecraft.client.model.ModelBase; import net.minecraft.client.renderer.entity.RendererLivingEntity; import net.minecraft.entity.EntityLivingBase; -import net.minecraft.entity.item.EntityArmorStand; import net.minecraft.util.IChatComponent; +import net.minecraft.util.StringUtils; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; @@ -15,13 +14,12 @@ import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.Redirect; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import rosegoldaddons.Main; import rosegoldaddons.events.RenderLivingEntityEvent; -import rosegoldaddons.utils.ChatUtils; @Mixin(value = RendererLivingEntity.class, priority = 1001) @SideOnly(Side.CLIENT) public abstract class MixinRendererLivingEntity { - @Shadow protected ModelBase mainModel; @@ -30,4 +28,51 @@ public abstract class MixinRendererLivingEntity { if (MinecraftForge.EVENT_BUS.post(new RenderLivingEntityEvent(entity, p_77036_2_, p_77036_3_, p_77036_4_, p_77036_5_, p_77036_6_, scaleFactor, mainModel))) ci.cancel(); } + + @Redirect(method = "renderName(Lnet/minecraft/entity/EntityLivingBase;DDD)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/IChatComponent;getFormattedText()Ljava/lang/String;")) + public String redirectGetFormattedText(IChatComponent instance) { + if (Main.init && Main.configFile.alchsleep == 63 && Main.configFile.skiblock == 263) return instance.getFormattedText(); + String unformatted = stripString(instance.getUnformattedText()).replace(":"," ").replace("'"," "); + String[] words = unformatted.split(" "); + String[] formatteds = instance.getUnformattedText().replace(":"," ").replace("'"," ").split(" "); + for(String word : words) { + if (Main.nameCache.containsKey(word)) { + String[] replaces = Main.nameCache.get(word).split(" "); + for(String replace : replaces) { + for(String formatted : formatteds) { + if(replace.equals(formatted)) return instance.getFormattedText(); + } + } + String color = getColorBeforeIndex(instance.getUnformattedText(), instance.getUnformattedText().indexOf(word)); + return instance.getUnformattedText().replace(word, Main.nameCache.get(word) + color); + } + } + return instance.getFormattedText(); + } + + + private String getColorBeforeIndex(String str, int index) { + String lastColor = ""; + for (int i = 0; i < str.length(); i++) { + if (i == index) break; + if (str.charAt(i) == '§' && i + 1 < str.length() && str.charAt(i + 1) != 'r' && str.charAt(i + 1) != 'l' && str.charAt(i + 1) != 'k' + && str.charAt(i + 1) != 'm' && str.charAt(i + 1) != 'n' && str.charAt(i + 1) != 'o') { + lastColor = str.charAt(i) + "" + str.charAt(i + 1); + } + } + return lastColor; + } + + private String stripString(String s) { + char[] nonValidatedString = StringUtils.stripControlCodes(s).toCharArray(); + StringBuilder validated = new StringBuilder(); + + for (char a : nonValidatedString) { + if ((int) a < 127 && (int) a > 20) { + validated.append(a); + } + } + + return validated.toString(); + } } diff --git a/src/main/java/rosegoldaddons/utils/RotationUtils.java b/src/main/java/rosegoldaddons/utils/RotationUtils.java index 2ead71f..874f238 100644 --- a/src/main/java/rosegoldaddons/utils/RotationUtils.java +++ b/src/main/java/rosegoldaddons/utils/RotationUtils.java @@ -15,64 +15,6 @@ import rosegoldaddons.Main; public class RotationUtils { static boolean working = false; static boolean snek = false; - public static Rotation startRot; - public static Rotation neededChange; - public static Rotation endRot; - public static long startTime; - public static long endTime; - - @SubscribeEvent - public void onRender(RenderWorldLastEvent event) { - update(); - } - - //bing chilling thx apfel - public static void update() { - if (System.currentTimeMillis() <= endTime) { - if(startRot != null && endRot != null) { - Main.mc.thePlayer.rotationYaw = interpolate(startRot.getYaw(), endRot.getYaw()); - Main.mc.thePlayer.rotationPitch = interpolate(startRot.getPitch(), endRot.getPitch()); - } - } else { - if(startRot != null && endRot != null) { - Main.mc.thePlayer.rotationYaw = endRot.getYaw(); - Main.mc.thePlayer.rotationPitch = endRot.getPitch(); - reset(); - } - } - } - - private static void reset() { - startRot = null; - neededChange = null; - endRot = null; - } - - private static float interpolate(float f, float t) { - float x = System.currentTimeMillis() - startTime; - float u = (f - t) / 2.0f; - return (float) (u * Math.cos((float) (x * Math.PI / (endTime - startTime))) - u + f); - } - - public static void setup(Rotation rot, Long aimTime) { - startRot = new Rotation(Main.mc.thePlayer.rotationYaw, Main.mc.thePlayer.rotationPitch); - neededChange = getNeededChange(startRot, rot); - endRot = new Rotation(startRot.getYaw() + neededChange.getYaw(), startRot.getPitch() + neededChange.getPitch()); - startTime = System.currentTimeMillis(); - endTime = System.currentTimeMillis() + aimTime; - } - - public static Rotation getNeededChange(Rotation startRot, Rotation endRot) { - float yawChng = (float) (wrapAngleTo180(endRot.getYaw()) - wrapAngleTo180(startRot.getYaw())); - if (yawChng <= -180.0F) { - yawChng += 360.0F; - } else if (yawChng > 180.0F) { - yawChng += -360.0F; - } - - return new Rotation(yawChng, endRot.getPitch() - startRot.getPitch()); - } - public static void shootEman() { if (Main.mc.currentScreen != null) { @@ -136,23 +78,6 @@ public class RotationUtils { }).start(); } - public static void faceAngles(double yaw, double pitch) { - if (working) return; - new Thread(() -> { - try { - working = true; - for (int i = 0; i < Main.configFile.smoothLookVelocity; i++) { - Main.mc.thePlayer.rotationYaw += yaw / Main.configFile.smoothLookVelocity; - Main.mc.thePlayer.rotationPitch += pitch / Main.configFile.smoothLookVelocity; - Thread.sleep(1); - } - working = false; - } catch (Exception e) { - e.printStackTrace(); - } - }).start(); - } - public static void faceEntity(Entity en) { if (en instanceof EntityCreeper) { facePos(new Vec3(en.posX, en.posY, en.posZ)); @@ -160,44 +85,4 @@ public class RotationUtils { facePos(new Vec3(en.posX, en.posY + Main.mc.thePlayer.getEyeHeight(), en.posZ)); } } - - public static void packetFaceEntity(Entity en) { - if (en == null) return; - Vec3 vector = new Vec3(en.posX, en.posY - 1.5, en.posZ); - if (Main.mc.currentScreen != null) { - if (Main.mc.currentScreen instanceof GuiIngameMenu || Main.mc.currentScreen instanceof GuiChat) { - } else { - return; - } - } - - double diffX = vector.xCoord - (Main.mc).thePlayer.posX; - double diffY = vector.yCoord - (Main.mc).thePlayer.posY; - double diffZ = vector.zCoord - (Main.mc).thePlayer.posZ; - double dist = Math.sqrt(diffX * diffX + diffZ * diffZ); - - float pitch = (float) -Math.atan2(dist, diffY); - float yaw = (float) Math.atan2(diffZ, diffX); - pitch = (float) wrapAngleTo180((pitch * 180F / Math.PI + 90) * -1 - Main.mc.thePlayer.rotationPitch); - yaw = (float) wrapAngleTo180((yaw * 180 / Math.PI) - 90 - Main.mc.thePlayer.rotationYaw); - - Main.mc.thePlayer.sendQueue.addToSendQueue(new C03PacketPlayer.C05PacketPlayerLook(yaw, pitch, Main.mc.thePlayer.onGround)); - - } - - public static void faceEntity2(Entity en) { - facePos(new Vec3(en.posX, en.posY + en.getEyeHeight() - en.height / 1.5D, en.posZ)); - } - - private static double wrapAngleTo180(double angle) { - angle %= 360; - while (angle >= 180) { - angle -= 360; - } - while (angle < -180) { - angle += 360; - } - return angle; - } - } diff --git a/src/main/java/rosegoldaddons/utils/ScoreboardUtils.java b/src/main/java/rosegoldaddons/utils/ScoreboardUtils.java index 38312a7..a9d7d63 100644 --- a/src/main/java/rosegoldaddons/utils/ScoreboardUtils.java +++ b/src/main/java/rosegoldaddons/utils/ScoreboardUtils.java @@ -8,6 +8,8 @@ import net.minecraft.scoreboard.ScoreObjective; import net.minecraft.scoreboard.ScorePlayerTeam; import net.minecraft.scoreboard.Scoreboard; import net.minecraft.util.StringUtils; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.fml.common.gameevent.TickEvent; import rosegoldaddons.Main; import java.util.ArrayList; @@ -20,6 +22,7 @@ import java.util.stream.Collectors; */ public class ScoreboardUtils { + public static boolean inSkyblock = false; public static String cleanSB(String scoreboard) { char[] nvString = StringUtils.stripControlCodes(scoreboard).toCharArray(); StringBuilder cleaned = new StringBuilder(); @@ -61,4 +64,23 @@ public class ScoreboardUtils { return lines; } + + public static String removeFormatting(String input) { + return input.replaceAll("§[0-9a-fk-or]", ""); + } + + private int ticks = 0; + @SubscribeEvent + public void onTick(TickEvent.ClientTickEvent event) { + if(ticks % 20 == 0) { + if(Main.mc.thePlayer != null && Main.mc.theWorld != null) { + ScoreObjective scoreboardObj = Main.mc.theWorld.getScoreboard().getObjectiveInDisplaySlot(1); + if(scoreboardObj != null) { + inSkyblock = removeFormatting(scoreboardObj.getDisplayName()).contains("SKYBLOCK"); + } + } + ticks = 0; + } + ticks++; + } } diff --git a/src/main/java/rosegoldaddons/utils/ShadyRotation.java b/src/main/java/rosegoldaddons/utils/ShadyRotation.java new file mode 100644 index 0000000..fdacc59 --- /dev/null +++ b/src/main/java/rosegoldaddons/utils/ShadyRotation.java @@ -0,0 +1,118 @@ +package rosegoldaddons.utils; + +import net.minecraft.entity.Entity; +import net.minecraft.util.BlockPos; +import net.minecraft.util.Vec3; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.fml.common.gameevent.TickEvent; +import rosegoldaddons.Main; + +public class ShadyRotation { + private static float pitchDifference; + public static float yawDifference; + private static int ticks = -1; + private static int tickCounter = 0; + private static Runnable callback = null; + + public static boolean running = false; + + public static class Rotation { + public float pitch; + public float yaw; + + public Rotation(float pitch, float yaw) { + this.pitch = pitch; + this.yaw = yaw; + } + } + + private static double wrapAngleTo180(double angle) { + return angle - Math.floor(angle / 360 + 0.5) * 360; + } + + public static Rotation getRotationToBlock(BlockPos block) { + double diffX = block.getX() - Main.mc.thePlayer.posX + 0.5; + double diffY = block.getY() - Main.mc.thePlayer.posY + 0.5 - Main.mc.thePlayer.getEyeHeight(); + double diffZ = block.getZ() - Main.mc.thePlayer.posZ + 0.5; + double dist = Math.sqrt(diffX * diffX + diffZ * diffZ); + + float pitch = (float) -Math.atan2(dist, diffY); + float yaw = (float) Math.atan2(diffZ, diffX); + pitch = (float) wrapAngleTo180((pitch * 180F / Math.PI + 90)*-1); + yaw = (float) wrapAngleTo180((yaw * 180 / Math.PI) - 90); + + return new Rotation(pitch, yaw); + } + + public static Rotation getRotationToEntity(Entity entity) { + double diffX = entity.posX - Main.mc.thePlayer.posX; + double diffY = entity.posY + entity.getEyeHeight() - Main.mc.thePlayer.posY - Main.mc.thePlayer.getEyeHeight(); + double diffZ = entity.posZ - Main.mc.thePlayer.posZ; + double dist = Math.sqrt(diffX * diffX + diffZ * diffZ); + + float pitch = (float) -Math.atan2(dist, diffY); + float yaw = (float) Math.atan2(diffZ, diffX); + pitch = (float) wrapAngleTo180((pitch * 180F / Math.PI + 90)*-1); + yaw = (float) wrapAngleTo180((yaw * 180 / Math.PI) - 90); + + return new Rotation(pitch, yaw); + } + + public static Rotation vec3ToRotation(Vec3 vec) { + double diffX = vec.xCoord - Main.mc.thePlayer.posX; + double diffY = vec.yCoord - Main.mc.thePlayer.posY - Main.mc.thePlayer.getEyeHeight(); + double diffZ = vec.zCoord - Main.mc.thePlayer.posZ; + double dist = Math.sqrt(diffX * diffX + diffZ * diffZ); + + float pitch = (float) -Math.atan2(dist, diffY); + float yaw = (float) Math.atan2(diffZ, diffX); + pitch = (float) wrapAngleTo180((pitch * 180F / Math.PI + 90)*-1); + yaw = (float) wrapAngleTo180((yaw * 180 / Math.PI) - 90); + + return new Rotation(pitch, yaw); + } + + public static void smoothLook(Rotation rotation, int ticks, Runnable callback) { + if(ticks == 0) { + look(rotation); + callback.run(); + return; + } + + ShadyRotation.callback = callback; + + pitchDifference = rotation.pitch - Main.mc.thePlayer.rotationPitch; + yawDifference = rotation.yaw - Main.mc.thePlayer.rotationYaw; + + ShadyRotation.ticks = ticks * 20; + ShadyRotation.tickCounter = 0; + } + + public static void smartLook(Rotation rotation, int ticksPer180, Runnable callback) { + float rotationDifference = Math.max( + Math.abs(rotation.pitch - Main.mc.thePlayer.rotationPitch), + Math.abs(rotation.yaw - Main.mc.thePlayer.rotationYaw) + ); + smoothLook(rotation, (int) (rotationDifference / 180 * ticksPer180), callback); + } + + public static void look(Rotation rotation) { + Main.mc.thePlayer.rotationPitch = rotation.pitch; + Main.mc.thePlayer.rotationYaw = rotation.yaw; + } + + @SubscribeEvent + public void onTick(TickEvent event) { + if(Main.mc.thePlayer == null) return; + if(tickCounter < ticks) { + running = true; + Main.mc.thePlayer.rotationPitch += pitchDifference / ticks; + Main.mc.thePlayer.rotationYaw += yawDifference / ticks; + tickCounter++; + } else if(callback != null) { + running = false; + callback.run(); + callback = null; + } + } +} |