diff options
Diffstat (limited to 'src/main/java/rosegoldaddons/utils')
-rw-r--r-- | src/main/java/rosegoldaddons/utils/BlockUtils.java | 155 | ||||
-rw-r--r-- | src/main/java/rosegoldaddons/utils/ChatUtils.java | 5 | ||||
-rw-r--r-- | src/main/java/rosegoldaddons/utils/OpenSkyblockGui.java | 14 | ||||
-rw-r--r-- | src/main/java/rosegoldaddons/utils/PlayerUtils.java | 10 | ||||
-rw-r--r-- | src/main/java/rosegoldaddons/utils/RenderUtils.java | 54 | ||||
-rw-r--r-- | src/main/java/rosegoldaddons/utils/Rotation.java | 44 | ||||
-rw-r--r-- | src/main/java/rosegoldaddons/utils/RotationUtils.java | 141 | ||||
-rw-r--r-- | src/main/java/rosegoldaddons/utils/ScoreboardUtils.java | 5 |
8 files changed, 343 insertions, 85 deletions
diff --git a/src/main/java/rosegoldaddons/utils/BlockUtils.java b/src/main/java/rosegoldaddons/utils/BlockUtils.java new file mode 100644 index 0000000..12ad293 --- /dev/null +++ b/src/main/java/rosegoldaddons/utils/BlockUtils.java @@ -0,0 +1,155 @@ +package rosegoldaddons.utils; + +import net.minecraft.block.Block; +import net.minecraft.block.state.IBlockState; +import net.minecraft.client.Minecraft; +import net.minecraft.util.*; +import rosegoldaddons.Main; + +import java.util.ArrayList; + +public class BlockUtils { + public static Vec3 bp = null; + + public static ArrayList<Vec3> whereToMineBlock(BlockPos pos) { + Vec3 center = new Vec3(pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5); + ArrayList<Vec3> vec3s = new ArrayList<>(); + MovingObjectPosition position = rayTrace(center, 4.5F); + if (position != null && position.getBlockPos().equals(pos)) + //return position.hitVec; + vec3s.add(position.hitVec); + for (int x = 1; x < 5; x++) { + for (int y = 1; y < 5; y++) { + for (int z = 1; z < 5; z++) { + Vec3 vec = new Vec3(pos.getX() + x / 4.0D - 0.125D, pos.getY() + y / 4.0D - 0.125D, pos.getZ() + z / 4.0D - 0.125D); + position = rayTrace(vec, 4.5F); + if (position != null) { + bp = position.hitVec; + if (position.getBlockPos().equals(pos)) + //return position.hitVec; + vec3s.add(position.hitVec); + } + } + } + } + return vec3s; + } + + + public static MovingObjectPosition rayTrace(Vec3 target, float range) { + Vec3 vec3 = Main.mc.thePlayer.getPositionEyes(1f); + Vec3 vec31 = getLook(target); + return fastRayTrace(vec3, vec3.addVector(vec31.xCoord * (double)range, vec31.yCoord * (double)range, vec31.zCoord * (double)range)); + } + + public static Vec3 getLook(Vec3 vec) { + double diffX = vec.xCoord - Main.mc.thePlayer.posX; + double diffY = vec.yCoord - (Main.mc.thePlayer.posY + (double)Main.mc.thePlayer.getEyeHeight()); + double diffZ = vec.zCoord - Main.mc.thePlayer.posZ; + double dist = Math.sqrt(diffX * diffX + diffZ * diffZ); + return getVectorForRotation((float)(-(Math.atan2(diffY, dist) * 180.0 / Math.PI)), (float)(Math.atan2(diffZ, diffX) * 180.0 / Math.PI - 90.0)); + } + + public static Vec3 getVectorForRotation(float pitch, float yaw) { + double f2 = -Math.cos(-pitch * ((float)Math.PI / 180)); + return new Vec3(Math.sin(-yaw * ((float)Math.PI / 180) - (float)Math.PI) * f2, Math.sin(-pitch * ((float)Math.PI / 180)), Math.cos(-yaw * ((float)Math.PI / 180) - (float)Math.PI) * f2); + } + + private static MovingObjectPosition fastRayTrace(Vec3 vec31, Vec3 vec32) { + MovingObjectPosition movingobjectposition; + int j1; + int i1; + int i = (int) Math.floor(vec32.xCoord); + int j = (int) Math.floor(vec32.yCoord); + int k = (int) Math.floor(vec32.zCoord); + int l = (int) Math.floor(vec31.xCoord); + BlockPos blockpos = new BlockPos(l, i1 = (int) Math.floor(vec31.yCoord), j1 = (int) Math.floor(vec31.zCoord)); + IBlockState iblockstate = Main.mc.theWorld.getBlockState(blockpos); + Block block = iblockstate.getBlock(); + if (block.canCollideCheck(iblockstate, false) && (movingobjectposition = block.collisionRayTrace(Main.mc.theWorld, blockpos, vec31, vec32)) != null) { + return movingobjectposition; + } + MovingObjectPosition movingobjectposition2 = null; + int k1 = 200; + while (k1-- >= 0) { + EnumFacing enumfacing; + if (l == i && i1 == j && j1 == k) { + return movingobjectposition2; + } + boolean flag2 = true; + boolean flag = true; + boolean flag1 = true; + double d0 = 999.0; + double d1 = 999.0; + double d2 = 999.0; + if (i > l) { + d0 = (double)l + 1.0; + } else if (i < l) { + d0 = (double)l + 0.0; + } else { + flag2 = false; + } + if (j > i1) { + d1 = (double)i1 + 1.0; + } else if (j < i1) { + d1 = (double)i1 + 0.0; + } else { + flag = false; + } + if (k > j1) { + d2 = (double)j1 + 1.0; + } else if (k < j1) { + d2 = (double)j1 + 0.0; + } else { + flag1 = false; + } + double d3 = 999.0; + double d4 = 999.0; + double d5 = 999.0; + double d6 = vec32.xCoord - vec31.xCoord; + double d7 = vec32.yCoord - vec31.yCoord; + double d8 = vec32.zCoord - vec31.zCoord; + if (flag2) { + d3 = (d0 - vec31.xCoord) / d6; + } + if (flag) { + d4 = (d1 - vec31.yCoord) / d7; + } + if (flag1) { + d5 = (d2 - vec31.zCoord) / d8; + } + if (d3 == -0.0) { + d3 = -1.0E-4; + } + if (d4 == -0.0) { + d4 = -1.0E-4; + } + if (d5 == -0.0) { + d5 = -1.0E-4; + } + if (d3 < d4 && d3 < d5) { + enumfacing = i > l ? EnumFacing.WEST : EnumFacing.EAST; + vec31 = new Vec3(d0, vec31.yCoord + d7 * d3, vec31.zCoord + d8 * d3); + } else if (d4 < d5) { + enumfacing = j > i1 ? EnumFacing.DOWN : EnumFacing.UP; + vec31 = new Vec3(vec31.xCoord + d6 * d4, d1, vec31.zCoord + d8 * d4); + } else { + enumfacing = k > j1 ? EnumFacing.NORTH : EnumFacing.SOUTH; + vec31 = new Vec3(vec31.xCoord + d6 * d5, vec31.yCoord + d7 * d5, d2); + } + l = MathHelper.floor_double((double)vec31.xCoord) - (enumfacing == EnumFacing.EAST ? 1 : 0); + i1 = MathHelper.floor_double((double)vec31.yCoord) - (enumfacing == EnumFacing.UP ? 1 : 0); + j1 = MathHelper.floor_double((double)vec31.zCoord) - (enumfacing == EnumFacing.SOUTH ? 1 : 0); + blockpos = new BlockPos(l, i1, j1); + IBlockState iblockstate1 = Main.mc.theWorld.getBlockState(blockpos); + Block block1 = iblockstate1.getBlock(); + if (block1.canCollideCheck(iblockstate1, false)) { + MovingObjectPosition movingobjectposition1 = block1.collisionRayTrace(Main.mc.theWorld, blockpos, vec31, vec32); + if (movingobjectposition1 == null) continue; + return movingobjectposition1; + } + movingobjectposition2 = new MovingObjectPosition(MovingObjectPosition.MovingObjectType.MISS, vec31, enumfacing, blockpos); + } + return movingobjectposition2; + } +} diff --git a/src/main/java/rosegoldaddons/utils/ChatUtils.java b/src/main/java/rosegoldaddons/utils/ChatUtils.java index 43107eb..26ac190 100644 --- a/src/main/java/rosegoldaddons/utils/ChatUtils.java +++ b/src/main/java/rosegoldaddons/utils/ChatUtils.java @@ -8,6 +8,7 @@ import net.minecraft.util.ChatStyle; import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.IChatComponent; import org.jetbrains.annotations.NotNull; +import rosegoldaddons.Main; import java.util.Iterator; import java.util.List; @@ -18,8 +19,8 @@ public class ChatUtils { /* § */ public static void sendMessage(String message) { - if (Minecraft.getMinecraft().thePlayer != null) { - Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText("§f[§aRoseGoldAddons§f] " + message)); + if (Main.mc.thePlayer != null) { + Main.mc.thePlayer.addChatMessage(new ChatComponentText("§f[§aRoseGoldAddons§f] " + message)); } } diff --git a/src/main/java/rosegoldaddons/utils/OpenSkyblockGui.java b/src/main/java/rosegoldaddons/utils/OpenSkyblockGui.java index b0760a0..2e574fb 100644 --- a/src/main/java/rosegoldaddons/utils/OpenSkyblockGui.java +++ b/src/main/java/rosegoldaddons/utils/OpenSkyblockGui.java @@ -8,6 +8,7 @@ import net.minecraft.inventory.ContainerChest; import net.minecraft.inventory.Slot; import net.minecraftforge.client.event.GuiScreenEvent; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import rosegoldaddons.Main; import rosegoldaddons.commands.Rosedrobe; import rosegoldaddons.commands.Rosepet; import scala.Int; @@ -21,7 +22,6 @@ public class OpenSkyblockGui { @SubscribeEvent public void guiDraw(GuiScreenEvent.BackgroundDrawnEvent event) { if(!Rosedrobe.openWardrobe && !openTrades && !Rosepet.openPetS) return; - ChatUtils.sendMessage("OpenSkyblockGui"); if (event.gui instanceof GuiChest) { Container container = ((GuiChest) event.gui).inventorySlots; if (container instanceof ContainerChest) { @@ -32,7 +32,7 @@ public class OpenSkyblockGui { clickSlot(32, 0, 1); if (Rosedrobe.slot > 0) { clickSlot(Rosedrobe.slot + 35, 0, 2); - Minecraft.getMinecraft().thePlayer.closeScreen(); + Main.mc.thePlayer.closeScreen(); } Rosedrobe.openWardrobe = false; } @@ -59,12 +59,12 @@ public class OpenSkyblockGui { return; } if (!petName.equals("")) { - List<Slot> chestInventory = ((GuiChest) Minecraft.getMinecraft().currentScreen).inventorySlots.inventorySlots; + List<Slot> chestInventory = ((GuiChest) Main.mc.currentScreen).inventorySlots.inventorySlots; for (Slot slot : chestInventory) { if (!slot.getHasStack()) continue; if (slot.getStack().getDisplayName().contains(petName)) { clickSlot(slot.slotNumber, 0, 0); - Minecraft.getMinecraft().thePlayer.closeScreen(); + Main.mc.thePlayer.closeScreen(); Rosepet.openPetS = false; return; } @@ -73,7 +73,7 @@ public class OpenSkyblockGui { clickSlot(53, 0, 0); } else { Rosepet.openPetS = false; - Minecraft.getMinecraft().thePlayer.closeScreen(); + Main.mc.thePlayer.closeScreen(); ChatUtils.sendMessage("No pet named "+petName+" found."); } } else { @@ -89,10 +89,10 @@ public class OpenSkyblockGui { public static void openTradesMenu() { openTrades = true; - Minecraft.getMinecraft().thePlayer.sendChatMessage("/pets"); + Main.mc.thePlayer.sendChatMessage("/pets"); } private void clickSlot(int slot, int type, int windowAdd) { - Minecraft.getMinecraft().playerController.windowClick(Minecraft.getMinecraft().thePlayer.openContainer.windowId + windowAdd, slot, type, 0, Minecraft.getMinecraft().thePlayer); + Main.mc.playerController.windowClick(Main.mc.thePlayer.openContainer.windowId + windowAdd, slot, type, 0, Main.mc.thePlayer); } } diff --git a/src/main/java/rosegoldaddons/utils/PlayerUtils.java b/src/main/java/rosegoldaddons/utils/PlayerUtils.java index b41d047..f0662c0 100644 --- a/src/main/java/rosegoldaddons/utils/PlayerUtils.java +++ b/src/main/java/rosegoldaddons/utils/PlayerUtils.java @@ -12,9 +12,9 @@ public class PlayerUtils { public static boolean pickaxeAbilityReady = false; public static void swingItem() { - MovingObjectPosition movingObjectPosition = Minecraft.getMinecraft().objectMouseOver; + MovingObjectPosition movingObjectPosition = Main.mc.objectMouseOver; if (movingObjectPosition != null && movingObjectPosition.entityHit == null) { - Minecraft.getMinecraft().thePlayer.swingItem(); + Main.mc.thePlayer.swingItem(); } } @@ -26,10 +26,10 @@ public class PlayerUtils { @SubscribeEvent public void chat(ClientChatReceivedEvent event) { String message = StringUtils.stripControlCodes(event.message.getUnformattedText()); - if (message.contains(":")) return; - if(message.contains("You used your")) { + if (message.contains(":") || message.contains(">")) return; + if(message.startsWith("You used your")) { pickaxeAbilityReady = false; - } else if(message.contains("is now available!")) { + } else if(message.endsWith("is now available!")) { pickaxeAbilityReady = true; } } diff --git a/src/main/java/rosegoldaddons/utils/RenderUtils.java b/src/main/java/rosegoldaddons/utils/RenderUtils.java index 37c6e98..cf83c28 100644 --- a/src/main/java/rosegoldaddons/utils/RenderUtils.java +++ b/src/main/java/rosegoldaddons/utils/RenderUtils.java @@ -12,12 +12,10 @@ import net.minecraft.client.renderer.vertex.DefaultVertexFormats; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.util.AxisAlignedBB; -import net.minecraft.util.BlockPos; -import net.minecraft.util.EnumChatFormatting; -import net.minecraft.util.ResourceLocation; +import net.minecraft.util.*; import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL14; +import rosegoldaddons.Main; import java.awt.*; import java.util.HashMap; @@ -30,7 +28,7 @@ public class RenderUtils { private static final Map<Integer, Boolean> glCapMap = new HashMap<>(); private static final int[] DISPLAY_LISTS_2D = new int[4]; - private static final Minecraft mc = Minecraft.getMinecraft(); + private static final Minecraft mc = Main.mc; static { for (int i = 0; i < DISPLAY_LISTS_2D.length; i++) { @@ -119,6 +117,34 @@ public class RenderUtils { resetCaps(); } + public static void drawPixelBox(final Vec3 vec, final Color color, final double size, float partialTicks) { + final RenderManager renderManager = mc.getRenderManager(); + + final double x = vec.xCoord - renderManager.viewerPosX; + final double y = vec.yCoord - renderManager.viewerPosY; + final double z = vec.zCoord - renderManager.viewerPosZ; + + AxisAlignedBB axisAlignedBB = new AxisAlignedBB(x, y, z, x + size, y + size, z + size); + + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + enableGlCap(GL_BLEND); + disableGlCap(GL_TEXTURE_2D, GL_DEPTH_TEST); + glDepthMask(false); + + glColor(color.getRed(), color.getGreen(), color.getBlue(), 35); + //drawFilledBox(axisAlignedBB); + + glLineWidth(3F); + enableGlCap(GL_LINE_SMOOTH); + glColor(color); + + drawSelectionBoundingBox(axisAlignedBB); + + GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f); + glDepthMask(true); + resetCaps(); + } + public static void drawSelectionBoundingBox(AxisAlignedBB boundingBox) { Tessellator tessellator = Tessellator.getInstance(); WorldRenderer worldrenderer = tessellator.getWorldRenderer(); @@ -637,7 +663,7 @@ public class RenderUtils { GlStateManager.pushMatrix(); - Entity viewer = Minecraft.getMinecraft().getRenderViewEntity(); + Entity viewer = Main.mc.getRenderViewEntity(); double viewerX = viewer.lastTickPosX + (viewer.posX - viewer.lastTickPosX) * partialTicks; double viewerY = viewer.lastTickPosY + (viewer.posY - viewer.lastTickPosY) * partialTicks; double viewerZ = viewer.lastTickPosZ + (viewer.posZ - viewer.lastTickPosZ) * partialTicks; @@ -648,7 +674,7 @@ public class RenderUtils { double distSq = x * x + y * y + z * z; double dist = Math.sqrt(distSq); - if(distSq > 144) { + if (distSq > 144) { x *= 12 / dist; y *= 12 / dist; z *= 12 / dist; @@ -658,11 +684,11 @@ public class RenderUtils { drawNametag(str); - GlStateManager.rotate(-Minecraft.getMinecraft().getRenderManager().playerViewY, 0.0F, 1.0F, 0.0F); - GlStateManager.rotate(Minecraft.getMinecraft().getRenderManager().playerViewX, 1.0F, 0.0F, 0.0F); + GlStateManager.rotate(-Main.mc.getRenderManager().playerViewY, 0.0F, 1.0F, 0.0F); + GlStateManager.rotate(Main.mc.getRenderManager().playerViewX, 1.0F, 0.0F, 0.0F); GlStateManager.translate(0, -0.25f, 0); - GlStateManager.rotate(-Minecraft.getMinecraft().getRenderManager().playerViewX, 1.0F, 0.0F, 0.0F); - GlStateManager.rotate(Minecraft.getMinecraft().getRenderManager().playerViewY, 0.0F, 1.0F, 0.0F); + GlStateManager.rotate(-Main.mc.getRenderManager().playerViewX, 1.0F, 0.0F, 0.0F); + GlStateManager.rotate(Main.mc.getRenderManager().playerViewY, 0.0F, 1.0F, 0.0F); drawNametag(EnumChatFormatting.YELLOW.toString() + Math.round(dist) + " blocks"); @@ -672,13 +698,13 @@ public class RenderUtils { } public static void drawNametag(String str) { - FontRenderer fontrenderer = Minecraft.getMinecraft().fontRendererObj; + FontRenderer fontrenderer = Main.mc.fontRendererObj; float f = 1.6F; float f1 = 0.016666668F * f; GlStateManager.pushMatrix(); GL11.glNormal3f(0.0F, 1.0F, 0.0F); - GlStateManager.rotate(-Minecraft.getMinecraft().getRenderManager().playerViewY, 0.0F, 1.0F, 0.0F); - GlStateManager.rotate(Minecraft.getMinecraft().getRenderManager().playerViewX, 1.0F, 0.0F, 0.0F); + GlStateManager.rotate(-Main.mc.getRenderManager().playerViewY, 0.0F, 1.0F, 0.0F); + GlStateManager.rotate(Main.mc.getRenderManager().playerViewX, 1.0F, 0.0F, 0.0F); GlStateManager.scale(-f1, -f1, f1); GlStateManager.disableLighting(); GlStateManager.depthMask(false); diff --git a/src/main/java/rosegoldaddons/utils/Rotation.java b/src/main/java/rosegoldaddons/utils/Rotation.java new file mode 100644 index 0000000..f18d5ef --- /dev/null +++ b/src/main/java/rosegoldaddons/utils/Rotation.java @@ -0,0 +1,44 @@ +package rosegoldaddons.utils; + + +public class Rotation { + private float yaw; + private float pitch; + + public Rotation(float yaw, float pitch) { + this.yaw = yaw; + this.pitch = pitch; + } + + public float getYaw() { + return this.yaw; + } + + public void setYaw(float yaw) { + this.yaw = yaw; + } + + public float getPitch() { + return this.pitch; + } + + public void setPitch(float pitch) { + this.pitch = pitch; + } + + public void addYaw(float yaw) { + this.yaw += yaw; + } + + public void addPitch(float pitch) { + this.pitch += pitch; + } + + public float getValue() { + return Math.abs(this.yaw) + Math.abs(this.pitch); + } + + public String toString() { + return "Rotation{yaw=" + this.yaw + ", pitch=" + this.pitch + '}'; + } +} diff --git a/src/main/java/rosegoldaddons/utils/RotationUtils.java b/src/main/java/rosegoldaddons/utils/RotationUtils.java index a9b2e78..2ead71f 100644 --- a/src/main/java/rosegoldaddons/utils/RotationUtils.java +++ b/src/main/java/rosegoldaddons/utils/RotationUtils.java @@ -1,52 +1,82 @@ package rosegoldaddons.utils; -import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiChat; import net.minecraft.client.gui.GuiIngameMenu; import net.minecraft.client.settings.KeyBinding; import net.minecraft.entity.Entity; import net.minecraft.entity.monster.EntityCreeper; import net.minecraft.network.play.client.C03PacketPlayer; -import net.minecraft.util.ChatComponentText; import net.minecraft.util.MathHelper; import net.minecraft.util.Vec3; +import net.minecraftforge.client.event.RenderWorldLastEvent; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import rosegoldaddons.Main; -import java.security.Key; - public class RotationUtils { static boolean working = false; static boolean snek = false; - static boolean antiafking = 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(); + } - public static void antiAfk() { - if (Minecraft.getMinecraft().currentScreen != null) { - if (Minecraft.getMinecraft().currentScreen instanceof GuiIngameMenu || Minecraft.getMinecraft().currentScreen instanceof GuiChat) { - } else { - return; + //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()); } - } - if (snek) return; - KeyBinding right = Minecraft.getMinecraft().gameSettings.keyBindRight; - KeyBinding left = Minecraft.getMinecraft().gameSettings.keyBindLeft; - new Thread(() -> { - try { - KeyBinding.setKeyBindState(right.getKeyCode(), true); - Thread.sleep(50); - KeyBinding.setKeyBindState(right.getKeyCode(), false); - Thread.sleep(200); - KeyBinding.setKeyBindState(left.getKeyCode(), true); - Thread.sleep(50); - KeyBinding.setKeyBindState(left.getKeyCode(), false); - } catch (InterruptedException e) { - e.printStackTrace(); + } else { + if(startRot != null && endRot != null) { + Main.mc.thePlayer.rotationYaw = endRot.getYaw(); + Main.mc.thePlayer.rotationPitch = endRot.getPitch(); + reset(); } - }).start(); + } } + 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 (Minecraft.getMinecraft().currentScreen != null) { - if (Minecraft.getMinecraft().currentScreen instanceof GuiIngameMenu || Minecraft.getMinecraft().currentScreen instanceof GuiChat) { + if (Main.mc.currentScreen != null) { + if (Main.mc.currentScreen instanceof GuiIngameMenu || Main.mc.currentScreen instanceof GuiChat) { } else { return; } @@ -55,13 +85,13 @@ public class RotationUtils { new Thread(() -> { try { snek = true; - KeyBinding.setKeyBindState(Minecraft.getMinecraft().gameSettings.keyBindSneak.getKeyCode(), true); + KeyBinding.setKeyBindState(Main.mc.gameSettings.keyBindSneak.getKeyCode(), true); Thread.sleep(50); - KeyBinding.setKeyBindState(Minecraft.getMinecraft().gameSettings.keyBindSneak.getKeyCode(), false); + KeyBinding.setKeyBindState(Main.mc.gameSettings.keyBindSneak.getKeyCode(), false); Thread.sleep(50); - KeyBinding.setKeyBindState(Minecraft.getMinecraft().gameSettings.keyBindSneak.getKeyCode(), true); + KeyBinding.setKeyBindState(Main.mc.gameSettings.keyBindSneak.getKeyCode(), true); Thread.sleep(50); - KeyBinding.setKeyBindState(Minecraft.getMinecraft().gameSettings.keyBindSneak.getKeyCode(), false); + KeyBinding.setKeyBindState(Main.mc.gameSettings.keyBindSneak.getKeyCode(), false); snek = false; } catch (Exception e) { e.printStackTrace(); @@ -70,8 +100,8 @@ public class RotationUtils { } public static void facePos(Vec3 vector) { - if (Minecraft.getMinecraft().currentScreen != null) { - if (Minecraft.getMinecraft().currentScreen instanceof GuiIngameMenu || Minecraft.getMinecraft().currentScreen instanceof GuiChat) { + if (Main.mc.currentScreen != null) { + if (Main.mc.currentScreen instanceof GuiIngameMenu || Main.mc.currentScreen instanceof GuiChat) { } else { return; } @@ -80,21 +110,22 @@ public class RotationUtils { new Thread(() -> { try { working = true; - double diffX = vector.xCoord - (Minecraft.getMinecraft()).thePlayer.posX; - double diffY = vector.yCoord - (Minecraft.getMinecraft()).thePlayer.posY; - double diffZ = vector.zCoord - (Minecraft.getMinecraft()).thePlayer.posZ; + double diffX = vector.xCoord - Main.mc.thePlayer.posX; + double diffY = vector.yCoord - (Main.mc.thePlayer.posY + Main.mc.thePlayer.getEyeHeight()); + 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 - Minecraft.getMinecraft().thePlayer.rotationPitch); - yaw = (float) wrapAngleTo180((yaw * 180 / Math.PI) - 90 - Minecraft.getMinecraft().thePlayer.rotationYaw); + float pitch = (float) -(Math.atan2(diffY, dist) * 180.0D / Math.PI); + float yaw = (float) (Math.atan2(diffZ, diffX) * 180.0D / Math.PI - 90.0D); + pitch = MathHelper.wrapAngleTo180_float(pitch - Main.mc.thePlayer.rotationPitch); + yaw = MathHelper.wrapAngleTo180_float(yaw - Main.mc.thePlayer.rotationYaw); for (int i = 0; i < Main.configFile.smoothLookVelocity; i++) { - Minecraft.getMinecraft().thePlayer.rotationYaw += yaw / Main.configFile.smoothLookVelocity; - Minecraft.getMinecraft().thePlayer.rotationPitch += pitch / Main.configFile.smoothLookVelocity; + Main.mc.thePlayer.rotationYaw += yaw / Main.configFile.smoothLookVelocity; + Main.mc.thePlayer.rotationPitch += pitch / Main.configFile.smoothLookVelocity; Thread.sleep(1); } + //setup(new Rotation(yaw, pitch), (long) Main.configFile.smoothLookVelocity); working = false; if (Main.endermanMacro) { shootEman(); @@ -111,8 +142,8 @@ public class RotationUtils { try { working = true; for (int i = 0; i < Main.configFile.smoothLookVelocity; i++) { - Minecraft.getMinecraft().thePlayer.rotationYaw += yaw / Main.configFile.smoothLookVelocity; - Minecraft.getMinecraft().thePlayer.rotationPitch += pitch / Main.configFile.smoothLookVelocity; + Main.mc.thePlayer.rotationYaw += yaw / Main.configFile.smoothLookVelocity; + Main.mc.thePlayer.rotationPitch += pitch / Main.configFile.smoothLookVelocity; Thread.sleep(1); } working = false; @@ -124,33 +155,33 @@ public class RotationUtils { public static void faceEntity(Entity en) { if (en instanceof EntityCreeper) { - facePos(new Vec3(en.posX, en.posY - 1.5, en.posZ)); - } else { facePos(new Vec3(en.posX, en.posY, en.posZ)); + } else { + 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 (Minecraft.getMinecraft().currentScreen != null) { - if (Minecraft.getMinecraft().currentScreen instanceof GuiIngameMenu || Minecraft.getMinecraft().currentScreen instanceof GuiChat) { + if (Main.mc.currentScreen != null) { + if (Main.mc.currentScreen instanceof GuiIngameMenu || Main.mc.currentScreen instanceof GuiChat) { } else { return; } } - double diffX = vector.xCoord - (Minecraft.getMinecraft()).thePlayer.posX; - double diffY = vector.yCoord - (Minecraft.getMinecraft()).thePlayer.posY; - double diffZ = vector.zCoord - (Minecraft.getMinecraft()).thePlayer.posZ; + 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 - Minecraft.getMinecraft().thePlayer.rotationPitch); - yaw = (float) wrapAngleTo180((yaw * 180 / Math.PI) - 90 - Minecraft.getMinecraft().thePlayer.rotationYaw); + 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); - Minecraft.getMinecraft().thePlayer.sendQueue.addToSendQueue(new C03PacketPlayer.C05PacketPlayerLook(yaw, pitch, Minecraft.getMinecraft().thePlayer.onGround)); + Main.mc.thePlayer.sendQueue.addToSendQueue(new C03PacketPlayer.C05PacketPlayerLook(yaw, pitch, Main.mc.thePlayer.onGround)); } diff --git a/src/main/java/rosegoldaddons/utils/ScoreboardUtils.java b/src/main/java/rosegoldaddons/utils/ScoreboardUtils.java index 3dd677a..38312a7 100644 --- a/src/main/java/rosegoldaddons/utils/ScoreboardUtils.java +++ b/src/main/java/rosegoldaddons/utils/ScoreboardUtils.java @@ -8,6 +8,7 @@ import net.minecraft.scoreboard.ScoreObjective; import net.minecraft.scoreboard.ScorePlayerTeam; import net.minecraft.scoreboard.Scoreboard; import net.minecraft.util.StringUtils; +import rosegoldaddons.Main; import java.util.ArrayList; import java.util.Collection; @@ -34,8 +35,8 @@ public class ScoreboardUtils { public static List<String> getSidebarLines() { List<String> lines = new ArrayList<>(); - if (Minecraft.getMinecraft().theWorld == null) return lines; - Scoreboard scoreboard = Minecraft.getMinecraft().theWorld.getScoreboard(); + if (Main.mc.theWorld == null) return lines; + Scoreboard scoreboard = Main.mc.theWorld.getScoreboard(); if (scoreboard == null) return lines; ScoreObjective objective = scoreboard.getObjectiveInDisplaySlot(1); |