From bcc322cb26a90494094c2ae9b6a34e8f2ea114c3 Mon Sep 17 00:00:00 2001 From: jackh Date: Fri, 31 Jan 2025 14:31:27 -0700 Subject: [PATCH] t --- .../event/AntiCheatFlagEvent.java | 14 + .../impl/accessor/IAccessorGuiScreen.java | 14 + .../accessor/IAccessorS14PacketEntity.java | 11 + .../keystrokesmod/module/ModuleManager.java | 3 +- .../module/impl/combat/AutoClicker.java | 217 +++++++-------- .../module/impl/combat/KillAura.java | 6 +- .../module/impl/minigames/BedWars.java | 96 ++++++- .../module/impl/minigames/CTWFly.java | 252 ++++++++++++++++++ .../module/impl/minigames/SkyWars.java | 6 +- .../module/impl/movement/NoSlow.java | 7 +- .../module/impl/other/Anticheat.java | 24 +- .../module/impl/player/NoFall.java | 19 +- .../module/impl/player/Scaffold.java | 66 +++-- .../module/impl/player/Tower.java | 2 +- .../java/keystrokesmod/script/Manager.java | 1 + .../java/keystrokesmod/script/Script.java | 112 ++++---- .../keystrokesmod/script/ScriptDefaults.java | 203 +++++++++++--- .../keystrokesmod/script/ScriptEvents.java | 5 + .../keystrokesmod/script/ScriptManager.java | 23 +- .../keystrokesmod/script/classes/Block.java | 9 + .../keystrokesmod/script/classes/Entity.java | 11 +- .../script/classes/PlayerState.java | 7 + .../script/packets/clientbound/S08.java | 34 ++- .../script/packets/clientbound/S23.java | 1 - .../script/packets/clientbound/S27.java | 27 ++ .../script/packets/clientbound/S2A.java | 15 ++ .../script/packets/serverbound/C03.java | 24 +- .../packets/serverbound/PacketHandler.java | 113 ++------ .../keystrokesmod/utility/ModuleUtils.java | 2 +- .../keystrokesmod/utility/NetworkUtils.java | 9 +- .../keystrokesmod/utility/ProfileUtils.java | 4 +- .../java/keystrokesmod/utility/Utils.java | 43 +++ src/main/resources/mixins.raven.json | 2 + 33 files changed, 995 insertions(+), 387 deletions(-) create mode 100644 src/main/java/keystrokesmod/event/AntiCheatFlagEvent.java create mode 100644 src/main/java/keystrokesmod/mixin/impl/accessor/IAccessorGuiScreen.java create mode 100644 src/main/java/keystrokesmod/mixin/impl/accessor/IAccessorS14PacketEntity.java create mode 100644 src/main/java/keystrokesmod/module/impl/minigames/CTWFly.java diff --git a/src/main/java/keystrokesmod/event/AntiCheatFlagEvent.java b/src/main/java/keystrokesmod/event/AntiCheatFlagEvent.java new file mode 100644 index 0000000..acca7c5 --- /dev/null +++ b/src/main/java/keystrokesmod/event/AntiCheatFlagEvent.java @@ -0,0 +1,14 @@ +package keystrokesmod.event; + +import net.minecraft.entity.Entity; +import net.minecraftforge.fml.common.eventhandler.Event; + +public class AntiCheatFlagEvent extends Event { + public String flag; + public Entity entity; + + public AntiCheatFlagEvent(String flag, Entity entity) { + this.flag = flag; + this.entity = entity; + } +} diff --git a/src/main/java/keystrokesmod/mixin/impl/accessor/IAccessorGuiScreen.java b/src/main/java/keystrokesmod/mixin/impl/accessor/IAccessorGuiScreen.java new file mode 100644 index 0000000..03e126b --- /dev/null +++ b/src/main/java/keystrokesmod/mixin/impl/accessor/IAccessorGuiScreen.java @@ -0,0 +1,14 @@ +package keystrokesmod.mixin.impl.accessor; + +import net.minecraft.client.gui.GuiScreen; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.gen.Invoker; + +@SideOnly(Side.CLIENT) +@Mixin(GuiScreen.class) +public interface IAccessorGuiScreen { + @Invoker("mouseClicked") + void callMouseClicked(int mouseX, int mouseY, int mouseButton); +} diff --git a/src/main/java/keystrokesmod/mixin/impl/accessor/IAccessorS14PacketEntity.java b/src/main/java/keystrokesmod/mixin/impl/accessor/IAccessorS14PacketEntity.java new file mode 100644 index 0000000..cb8f623 --- /dev/null +++ b/src/main/java/keystrokesmod/mixin/impl/accessor/IAccessorS14PacketEntity.java @@ -0,0 +1,11 @@ +package keystrokesmod.mixin.impl.accessor; + +import net.minecraft.network.play.server.S14PacketEntity; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.gen.Accessor; + +@Mixin(S14PacketEntity.class) +public interface IAccessorS14PacketEntity { + @Accessor("entityId") + int getEntityId(); +} diff --git a/src/main/java/keystrokesmod/module/ModuleManager.java b/src/main/java/keystrokesmod/module/ModuleManager.java index dbc40d9..76ea83d 100644 --- a/src/main/java/keystrokesmod/module/ModuleManager.java +++ b/src/main/java/keystrokesmod/module/ModuleManager.java @@ -12,7 +12,6 @@ import keystrokesmod.module.impl.other.*; import keystrokesmod.module.impl.player.*; import keystrokesmod.module.impl.render.*; import keystrokesmod.module.impl.world.*; -import keystrokesmod.utility.ModuleUtils; import keystrokesmod.utility.Utils; import keystrokesmod.utility.profile.Manager; @@ -71,6 +70,7 @@ public class ModuleManager { public static Arrows arrows; public static ChatCommands chatCommands; public static LongJump LongJump; + public static CTWFly ctwFly; public static Blink blink; public static Velocity velocity; @@ -170,6 +170,7 @@ public class ModuleManager { this.addModule(new AutoWho()); this.addModule(new Gui()); this.addModule(new Shaders()); + this.addModule(ctwFly = new CTWFly()); antiBot.enable(); Collections.sort(this.modules, Comparator.comparing(Module::getName)); } diff --git a/src/main/java/keystrokesmod/module/impl/combat/AutoClicker.java b/src/main/java/keystrokesmod/module/impl/combat/AutoClicker.java index 4c9e67d..8e05814 100644 --- a/src/main/java/keystrokesmod/module/impl/combat/AutoClicker.java +++ b/src/main/java/keystrokesmod/module/impl/combat/AutoClicker.java @@ -1,5 +1,6 @@ package keystrokesmod.module.impl.combat; +import keystrokesmod.mixin.impl.accessor.IAccessorGuiScreen; import keystrokesmod.module.Module; import keystrokesmod.module.ModuleManager; import keystrokesmod.module.setting.impl.ButtonSetting; @@ -9,12 +10,11 @@ import keystrokesmod.utility.Reflection; import keystrokesmod.utility.Utils; import net.minecraft.block.Block; import net.minecraft.block.BlockLiquid; -import net.minecraft.client.entity.EntityPlayerSP; import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.gui.inventory.GuiInventory; import net.minecraft.client.settings.KeyBinding; import net.minecraft.init.Blocks; -import net.minecraft.item.ItemBlock; +import net.minecraft.item.*; import net.minecraft.util.BlockPos; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.common.gameevent.TickEvent.Phase; @@ -22,8 +22,6 @@ import net.minecraftforge.fml.common.gameevent.TickEvent.RenderTickEvent; import org.lwjgl.input.Keyboard; import org.lwjgl.input.Mouse; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; import java.util.Random; public class AutoClicker extends Module { @@ -38,19 +36,20 @@ public class AutoClicker extends Module { public ButtonSetting weaponOnly; public ButtonSetting blocksOnly; public ButtonSetting disableCreative; + + private long nextReleaseTime; + private long nextPressTime; + private long nextMultiplierUpdateTime; + private long nextExtraDelayUpdateTime; + private double delayMultiplier; + private boolean multiplierActive; + private boolean isHoldingBlockBreak; + private boolean isBlockHitActive; + private Random rand = null; - private Method gs; - private long i; - private long j; - private long k; - private long l; - private double m; - private boolean n; - private boolean hol; - private boolean blocked; public AutoClicker() { - super("AutoClicker", Module.category.combat, 0); + super("AutoClicker", category.combat, 0); this.registerSetting(new DescriptionSetting("Best with delay remover.")); this.registerSetting(minCPS = new SliderSetting("Min CPS", 9.0, 1.0, 20.0, 0.5)); this.registerSetting(maxCPS = new SliderSetting("Max CPS", 12.0, 1.0, 20.0, 0.5)); @@ -64,35 +63,20 @@ public class AutoClicker extends Module { this.registerSetting(blocksOnly = new ButtonSetting("Blocks only", true)); this.registerSetting(disableCreative = new ButtonSetting("Disable in creative", false)); this.closetModule = true; - - try { - this.gs = GuiScreen.class.getDeclaredMethod("func_73864_a", Integer.TYPE, Integer.TYPE, Integer.TYPE); - } catch (Exception var4) { - try { - this.gs = GuiScreen.class.getDeclaredMethod("mouseClicked", Integer.TYPE, Integer.TYPE, Integer.TYPE); - } catch (Exception var3) { - } - } - - if (this.gs != null) { - this.gs.setAccessible(true); - } - } + @Override public void onEnable() { - if (this.gs == null) { - this.disable(); - } - this.blocked = Mouse.isButtonDown(1); + this.isBlockHitActive = Mouse.isButtonDown(1); this.rand = new Random(); } + @Override public void onDisable() { - this.i = 0L; - this.j = 0L; - this.hol = false; - this.blocked = false; + this.nextReleaseTime = 0L; + this.nextPressTime = 0L; + this.isHoldingBlockBreak = false; + this.isBlockHitActive = false; } public void guiUpdate() { @@ -101,160 +85,153 @@ public class AutoClicker extends Module { @SubscribeEvent public void onRenderTick(RenderTickEvent ev) { - if (ev.phase != Phase.END && Utils.nullCheck() && !mc.thePlayer.isEating()) { + if (ev.phase != Phase.END && Utils.nullCheck() && !Utils.isConsuming(mc.thePlayer)) { if (disableCreative.isToggled() && mc.thePlayer.capabilities.isCreativeMode) { return; } - if (ModuleManager.scaffold.isEnabled) { - return; - } if (mc.currentScreen == null && mc.inGameHasFocus) { if (weaponOnly.isToggled() && !Utils.holdingWeapon()) { return; } if (leftClick.isToggled() && Mouse.isButtonDown(0)) { - this.dc(mc.gameSettings.keyBindAttack.getKeyCode(), 0); + this.performClick(mc.gameSettings.keyBindAttack.getKeyCode(), 0); } else if (rightClick.isToggled() && Mouse.isButtonDown(1)) { if (blocksOnly.isToggled() && (mc.thePlayer.getCurrentEquippedItem() == null || !(mc.thePlayer.getCurrentEquippedItem().getItem() instanceof ItemBlock))) { return; } - this.dc(mc.gameSettings.keyBindUseItem.getKeyCode(), 1); + if (mc.thePlayer.getHeldItem() != null && mc.thePlayer.getHeldItem().getItem() instanceof ItemBow) { + return; + } + this.performClick(mc.gameSettings.keyBindUseItem.getKeyCode(), 1); } else { - this.i = 0L; - this.j = 0L; + this.nextReleaseTime = 0L; + this.nextPressTime = 0L; } } else if (inventoryFill.isToggled() && mc.currentScreen instanceof GuiInventory) { - if (!Mouse.isButtonDown(0) || !Keyboard.isKeyDown(54) && !Keyboard.isKeyDown(42)) { - this.i = 0L; - this.j = 0L; - } else if (this.i != 0L && this.j != 0L) { - if (System.currentTimeMillis() > this.j) { - this.gd(); + if (!Mouse.isButtonDown(0) || (!Keyboard.isKeyDown(54) && !Keyboard.isKeyDown(42))) { + this.nextReleaseTime = 0L; + this.nextPressTime = 0L; + } + else if (this.nextReleaseTime != 0L && this.nextPressTime != 0L) { + if (System.currentTimeMillis() > this.nextPressTime) { + this.updateClickDelay(); this.inventoryClick(mc.currentScreen); } - } else { - this.gd(); + } + else { + this.updateClickDelay(); } } - } } - public void dc(int key, int mouse) { + public void performClick(int key, int mouse) { if (breakBlocks.isToggled() && mouse == 0 && mc.objectMouseOver != null) { - BlockPos p = mc.objectMouseOver.getBlockPos(); - if (p != null) { - Block bl = mc.theWorld.getBlockState(p).getBlock(); - if (bl != Blocks.air && !(bl instanceof BlockLiquid)) { - if (!this.hol && (!ModuleManager.killAura.isEnabled() || KillAura.target == null)) { + BlockPos pos = mc.objectMouseOver.getBlockPos(); + if (pos != null) { + Block block = mc.theWorld.getBlockState(pos).getBlock(); + if (block != Blocks.air && !(block instanceof BlockLiquid)) { + if (!this.isHoldingBlockBreak && (!ModuleManager.killAura.isEnabled() || KillAura.target == null)) { KeyBinding.setKeyBindState(key, true); KeyBinding.onTick(key); - this.hol = true; + this.isHoldingBlockBreak = true; } - return; } - - if (this.hol) { + if (this.isHoldingBlockBreak) { KeyBinding.setKeyBindState(key, false); - this.hol = false; + this.isHoldingBlockBreak = false; } } } if (jitter.getInput() > 0.0D) { - double a = jitter.getInput() * 0.45D; - EntityPlayerSP var10000; + double jitterAmount = jitter.getInput() * 0.45D; if (this.rand.nextBoolean()) { - var10000 = mc.thePlayer; - var10000.rotationYaw = (float) ((double) var10000.rotationYaw + (double) this.rand.nextFloat() * a); - } else { - var10000 = mc.thePlayer; - var10000.rotationYaw = (float) ((double) var10000.rotationYaw - (double) this.rand.nextFloat() * a); + mc.thePlayer.rotationYaw += this.rand.nextFloat() * jitterAmount; + } + else { + mc.thePlayer.rotationYaw -= this.rand.nextFloat() * jitterAmount; } - if (this.rand.nextBoolean()) { - var10000 = mc.thePlayer; - var10000.rotationPitch = (float) ((double) var10000.rotationPitch + (double) this.rand.nextFloat() * a * 0.45D); - } else { - var10000 = mc.thePlayer; - var10000.rotationPitch = (float) ((double) var10000.rotationPitch - (double) this.rand.nextFloat() * a * 0.45D); + mc.thePlayer.rotationPitch += this.rand.nextFloat() * jitterAmount * 0.45D; + } + else { + mc.thePlayer.rotationPitch -= this.rand.nextFloat() * jitterAmount * 0.45D; } } - if (this.j > 0L && this.i > 0L) { + if (this.nextPressTime > 0L && this.nextReleaseTime > 0L) { double blockHitC = blockHitChance.getInput(); - if (System.currentTimeMillis() > this.j && (!ModuleManager.killAura.isEnabled() || KillAura.target == null)) { + long currentTime = System.currentTimeMillis(); + if (currentTime > this.nextPressTime && (!ModuleManager.killAura.isEnabled() || KillAura.target == null)) { KeyBinding.setKeyBindState(key, true); KeyBinding.onTick(key); Reflection.setButton(mouse, true); if (mouse == 0 && blockHitC > 0.0 && Mouse.isButtonDown(1) && Math.random() >= (100.0 - blockHitC) / 100.0) { - final int getKeyCode = mc.gameSettings.keyBindUseItem.getKeyCode(); - KeyBinding.setKeyBindState(getKeyCode, true); - KeyBinding.onTick(getKeyCode); + final int useItemKey = mc.gameSettings.keyBindUseItem.getKeyCode(); + KeyBinding.setKeyBindState(useItemKey, true); + KeyBinding.onTick(useItemKey); Reflection.setButton(1, true); - blocked = true; + isBlockHitActive = true; } - this.gd(); + // Recalculate the next press and release times. + this.updateClickDelay(); } - else if (System.currentTimeMillis() > this.i || blocked) { + // If the release time has passed (or a block hit is active), release the key. + else if (currentTime > this.nextReleaseTime || isBlockHitActive) { KeyBinding.setKeyBindState(key, false); Reflection.setButton(mouse, false); if (mouse == 0 && blockHitC > 0.0) { KeyBinding.setKeyBindState(mc.gameSettings.keyBindUseItem.getKeyCode(), false); Reflection.setButton(1, false); - blocked = false; + isBlockHitActive = false; } } } else { - this.gd(); + this.updateClickDelay(); } - } - public void gd() { - double c = Utils.getRandomValue(minCPS, maxCPS, this.rand) + 0.4D * this.rand.nextDouble(); - long d = (long) ((int) Math.round(1000.0D / c)); - if (System.currentTimeMillis() > this.k) { - if (!this.n && this.rand.nextInt(100) >= 85) { - this.n = true; - this.m = 1.1D + this.rand.nextDouble() * 0.15D; + public void updateClickDelay() { + double cps = Utils.getRandomValue(minCPS, maxCPS, this.rand) + 0.4D * this.rand.nextDouble(); + long delay = Math.round(1000.0D / cps); + + long currentTime = System.currentTimeMillis(); + // Updates the delay multiplier periodically. + if (currentTime > this.nextMultiplierUpdateTime) { + if (!multiplierActive && this.rand.nextInt(100) >= 85) { + multiplierActive = true; + delayMultiplier = 1.1D + this.rand.nextDouble() * 0.15D; } else { - this.n = false; + multiplierActive = false; } - - this.k = System.currentTimeMillis() + 500L + (long) this.rand.nextInt(1500); + this.nextMultiplierUpdateTime = currentTime + 500L + this.rand.nextInt(1500); } - - if (this.n) { - d = (long) ((double) d * this.m); - } - - if (System.currentTimeMillis() > this.l) { + // Adds extra delay at randomized intervals + if (currentTime > this.nextExtraDelayUpdateTime) { if (this.rand.nextInt(100) >= 80) { - d += 50L + (long) this.rand.nextInt(100); + delay += 50L + this.rand.nextInt(100); } - - this.l = System.currentTimeMillis() + 500L + (long) this.rand.nextInt(1500); + this.nextExtraDelayUpdateTime = currentTime + 500L + this.rand.nextInt(1500); } - - this.j = System.currentTimeMillis() + d; - this.i = System.currentTimeMillis() + d / 2L - (long) this.rand.nextInt(10); + // If the multiplier is active, adjust the delay + if (multiplierActive) { + delay = (long) (delay * delayMultiplier); + } + // Schedule the next press and release events + this.nextPressTime = currentTime + delay; + this.nextReleaseTime = currentTime + delay / 2L - this.rand.nextInt(10); } - private void inventoryClick(GuiScreen s) { - int x = Mouse.getX() * s.width / mc.displayWidth; - int y = s.height - Mouse.getY() * s.height / mc.displayHeight - 1; - - try { - this.gs.invoke(s, x, y, 0); - } catch (IllegalAccessException | InvocationTargetException var5) { - } - + private void inventoryClick(GuiScreen screen) { + int x = Mouse.getX() * screen.width / mc.displayWidth; + int y = screen.height - Mouse.getY() * screen.height / mc.displayHeight - 1; + ((IAccessorGuiScreen) screen).callMouseClicked(x, y, 0); } -} +} \ No newline at end of file diff --git a/src/main/java/keystrokesmod/module/impl/combat/KillAura.java b/src/main/java/keystrokesmod/module/impl/combat/KillAura.java index 2f41734..a9e520a 100644 --- a/src/main/java/keystrokesmod/module/impl/combat/KillAura.java +++ b/src/main/java/keystrokesmod/module/impl/combat/KillAura.java @@ -228,8 +228,8 @@ public class KillAura extends Module { return; } if (target != null && Utils.holdingSword()) { - if (Mouse.isButtonDown(0)) { - swingItem(); + if (Mouse.isButtonDown(0) && Utils.tabbedIn()) { + mc.thePlayer.swingItem(); } if (blinkAutoBlock() || autoBlockMode.getInput() == 2) { KeyBinding.setKeyBindState(mc.gameSettings.keyBindUseItem.getKeyCode(), false); @@ -1011,7 +1011,7 @@ public class KillAura extends Module { mc.thePlayer.sendQueue.addToSendQueue(new C07PacketPlayerDigging(C07PacketPlayerDigging.Action.RELEASE_USE_ITEM, BlockPos.ORIGIN, DOWN)); } firstEdge++; - if (firstEdge > 3) { + if (firstEdge > 1) { firstEdge = 0; } lag = false; diff --git a/src/main/java/keystrokesmod/module/impl/minigames/BedWars.java b/src/main/java/keystrokesmod/module/impl/minigames/BedWars.java index 8d355df..cd6635f 100644 --- a/src/main/java/keystrokesmod/module/impl/minigames/BedWars.java +++ b/src/main/java/keystrokesmod/module/impl/minigames/BedWars.java @@ -1,21 +1,34 @@ package keystrokesmod.module.impl.minigames; +import keystrokesmod.event.ReceivePacketEvent; +import keystrokesmod.event.SendPacketEvent; import keystrokesmod.module.Module; import keystrokesmod.module.impl.world.AntiBot; import keystrokesmod.module.setting.impl.ButtonSetting; import keystrokesmod.module.setting.impl.DescriptionSetting; +import keystrokesmod.utility.BlockUtils; import keystrokesmod.utility.RenderUtils; import keystrokesmod.utility.Utils; +import net.minecraft.block.BlockBed; import net.minecraft.block.BlockObsidian; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityList; +import net.minecraft.entity.monster.EntityIronGolem; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Items; import net.minecraft.item.ItemEnderPearl; import net.minecraft.item.ItemFireball; +import net.minecraft.item.ItemMonsterPlacer; import net.minecraft.item.ItemStack; +import net.minecraft.network.play.client.C08PacketPlayerBlockPlacement; +import net.minecraft.network.play.server.S23PacketBlockChange; import net.minecraft.util.BlockPos; +import net.minecraft.util.EnumFacing; +import net.minecraft.util.Vec3; import net.minecraftforge.client.event.ClientChatReceivedEvent; import net.minecraftforge.client.event.RenderWorldLastEvent; import net.minecraftforge.event.entity.EntityJoinWorldEvent; +import net.minecraftforge.fml.common.eventhandler.EventPriority; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import java.awt.*; @@ -30,13 +43,19 @@ public class BedWars extends Module { private ButtonSetting enderPearl; private ButtonSetting obsidian; private ButtonSetting shouldPing; + private BlockPos spawnPos; private boolean check; + public static boolean outsideSpawn = true; + private List armoredPlayer = new ArrayList<>(); private Map lastHeldMap = new ConcurrentHashMap<>(); - private Set obsidianPos = new HashSet<>(); - private int obsidianColor = new Color(0, 0,0).getRGB(); + private Map obsidianPos = new HashMap<>(); // blockPos, time received + public List entitySpawnQueue = new ArrayList<>(); + public List spawnedMobs = new ArrayList<>(); // entity id + + private int obsidianColor = new Color(106, 13, 173).getRGB(); public BedWars() { super("Bed Wars", category.minigames); @@ -57,24 +76,30 @@ public class BedWars extends Module { public void onDisable() { outsideSpawn = true; + entitySpawnQueue.clear(); + spawnedMobs.clear(); } - @SubscribeEvent + @SubscribeEvent(priority = EventPriority.HIGHEST) public void onRenderWorld(RenderWorldLastEvent e) { if (Utils.nullCheck()) { if (this.obsidianPos.isEmpty()) { return; } try { - Iterator iterator = this.obsidianPos.iterator(); + Iterator> iterator = this.obsidianPos.entrySet().iterator(); while (iterator.hasNext()) { - BlockPos blockPos = iterator.next(); - if (!(mc.theWorld.getBlockState(blockPos).getBlock() instanceof BlockObsidian)) { + Map.Entry entry = iterator.next(); + BlockPos blockPos = entry.getKey(); + Long receivedMs = entry.getValue(); + + if (!(mc.theWorld.getBlockState(blockPos).getBlock() instanceof BlockObsidian) && Utils.timeBetween(System.currentTimeMillis(), receivedMs) >= 500) { iterator.remove(); continue; } RenderUtils.renderBlock(blockPos, obsidianColor, false, true); } + } catch (Exception exception) {} } @@ -82,13 +107,29 @@ public class BedWars extends Module { @SubscribeEvent public void onEntityJoinWorld(EntityJoinWorldEvent e) { - if (!Utils.nullCheck() || e.entity == null) { - return; - } if (e.entity == mc.thePlayer) { armoredPlayer.clear(); lastHeldMap.clear(); obsidianPos.clear(); + entitySpawnQueue.clear(); + spawnedMobs.clear(); + } + else { + if (e.entity != null && e.entity instanceof EntityIronGolem) { + if (Utils.getBedwarsStatus() != 2) { + return; + } + Vec3 spawnPosition = new Vec3(e.entity.posX, e.entity.posY, e.entity.posZ); + for (SkyWars.SpawnEggInfo eggInfo : entitySpawnQueue) { + if (eggInfo.spawnPos.distanceTo(spawnPosition) > 3 || Utils.timeBetween(mc.thePlayer.ticksExisted, eggInfo.tickSpawned) > 60) { // 3 seconds or not at spawn point then not own mob + return; + } + if (!entitySpawnQueue.remove(eggInfo)) { + return; + } + spawnedMobs.add(e.entity.getEntityId()); + } + } } } @@ -120,7 +161,7 @@ public class BedWars extends Module { if (itemType != null) { lastHeldMap.put(name, itemType); double distance = Math.round(mc.thePlayer.getDistanceToEntity(p)); - handleAlert(itemType, p.getDisplayName().getFormattedText(), Utils.isWholeNumber(distance) ? (int) distance + "" : String.valueOf(distance)); + handleAlert(itemType, p.getDisplayName().getFormattedText(), Utils.asWholeNum(distance)); } } else if (lastHeldMap.containsKey(name)) { String itemType = lastHeldMap.get(name); @@ -148,6 +189,41 @@ public class BedWars extends Module { } } + @SubscribeEvent + public void onSendPacket(SendPacketEvent e) { + if (e.getPacket() instanceof C08PacketPlayerBlockPlacement) { + C08PacketPlayerBlockPlacement p = (C08PacketPlayerBlockPlacement) e.getPacket(); + if (p.getPlacedBlockDirection() != 255 && p.getStack() != null && p.getStack().getItem() != null) { + if (p.getStack().getItem() instanceof ItemMonsterPlacer) { + Class oclass = EntityList.stringToClassMapping.get(ItemMonsterPlacer.getEntityName(p.getStack())); + if (oclass.getSimpleName().equals("EntityIronGolem")) { + entitySpawnQueue.add(new SkyWars.SpawnEggInfo(p.getPosition(), mc.thePlayer.ticksExisted)); + } + } + } + } + } + + @SubscribeEvent + public void onReceivePacket(ReceivePacketEvent e) { + if (e.getPacket() instanceof S23PacketBlockChange) { + S23PacketBlockChange p = (S23PacketBlockChange) e.getPacket(); + if (p.getBlockState() != null && p.getBlockState().getBlock() instanceof BlockObsidian && isNextToBed(p.getBlockPosition())) { + this.obsidianPos.put(p.getBlockPosition(), System.currentTimeMillis()); + } + } + } + + private boolean isNextToBed(BlockPos blockPos) { + for (EnumFacing enumFacing : EnumFacing.values()) { + BlockPos offset = blockPos.offset(enumFacing); + if (BlockUtils.getBlock(offset) instanceof BlockBed) { + return true; + } + } + return false; + } + @SubscribeEvent public void onChat(ClientChatReceivedEvent c) { if (!Utils.nullCheck()) { diff --git a/src/main/java/keystrokesmod/module/impl/minigames/CTWFly.java b/src/main/java/keystrokesmod/module/impl/minigames/CTWFly.java new file mode 100644 index 0000000..2a8b231 --- /dev/null +++ b/src/main/java/keystrokesmod/module/impl/minigames/CTWFly.java @@ -0,0 +1,252 @@ +package keystrokesmod.module.impl.minigames; + +import keystrokesmod.Raven; +import keystrokesmod.event.*; +import keystrokesmod.module.Module; +import keystrokesmod.module.impl.render.HUD; +import keystrokesmod.module.setting.impl.DescriptionSetting; +import keystrokesmod.module.setting.impl.SliderSetting; +import keystrokesmod.utility.BlockUtils; +import keystrokesmod.utility.Theme; +import keystrokesmod.utility.Utils; +import keystrokesmod.utility.command.CommandManager; +import net.minecraft.client.gui.ScaledResolution; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.network.Packet; +import net.minecraft.network.play.client.C02PacketUseEntity; +import net.minecraft.network.play.client.C07PacketPlayerDigging; +import net.minecraft.network.play.client.C08PacketPlayerBlockPlacement; +import net.minecraft.network.play.client.C09PacketHeldItemChange; +import net.minecraft.network.play.server.*; +import net.minecraftforge.client.event.ClientChatReceivedEvent; +import net.minecraftforge.fml.common.eventhandler.EventPriority; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.fml.common.gameevent.TickEvent; + +import java.awt.*; +import java.util.Objects; + +public class CTWFly extends Module { + public static SliderSetting horizontalSpeed; + private SliderSetting verticalSpeed; + private SliderSetting maxFlyTicks; + private boolean d; + private boolean a = false; + + private boolean begin, placed; + private int flyTicks, ticks321; + + private int percent, percentDisplay; + + private static int widthOffset = 55; + private static String get321 = "Waiting for explosion..."; + + private int color = new Color(0, 187, 255, 255).getRGB(); + + public CTWFly() { + super("CTW Fly", category.minigames); + this.registerSetting(new DescriptionSetting("Use TNT to fly")); + this.registerSetting(new DescriptionSetting("(High speed values will dog)")); + this.registerSetting(horizontalSpeed = new SliderSetting("Horizontal speed", 4.0, 1.0, 9.0, 0.1)); + this.registerSetting(verticalSpeed = new SliderSetting("Vertical speed", 2.0, 1.0, 9.0, 0.1)); + this.registerSetting(maxFlyTicks = new SliderSetting("Max fly ticks", 40, 1, 80, 1)); + + } + + public void onDisable() { + if (begin || placed) { + disabled(); + } + } + + @SubscribeEvent + public void onReceivePacket(ReceivePacketEvent e) { + Packet packet = e.getPacket(); + + if (packet instanceof S29PacketSoundEffect) { + S29PacketSoundEffect s29 = (S29PacketSoundEffect) packet; + if (!Objects.equals(String.valueOf(s29.getSoundName()), "random.explode")) { + return; + } + if (mc.thePlayer.getPosition().distanceSq(s29.getX(), s29.getY(), s29.getZ()) <= 30) { + begin = true; + placed = false; + flyTicks = 0; + } + } + } + + @SubscribeEvent + public void onSendPacket(SendPacketEvent e) { + if (!Utils.nullCheck()) { + return; + } + if (e.getPacket() instanceof C08PacketPlayerBlockPlacement && Utils.holdingTNT()) { + placed = true; + } + } + + @SubscribeEvent + public void onChat(ClientChatReceivedEvent e) { + if (!Utils.nullCheck()) { + return; + } + String stripped = Utils.stripColor(e.message.getUnformattedText()); + + if (stripped.contains("You cannot place blocks here!") && placed) { + disabled(); + } + } + + @SubscribeEvent(priority = EventPriority.LOWEST) // called last in order to apply fix + public void onMoveInput(PrePlayerInputEvent e) { + if (!placed) { + return; + } + e.setForward(0); + e.setStrafe(0); + Utils.setSpeed(0); + } + + @SubscribeEvent + public void onPreUpdate(PreUpdateEvent e) { + if (placed) { + if (ticks321 >= 45) { + ticks321 = 0; + } + ++ticks321; + } + if (!begin) { + return; + } + this.d = mc.thePlayer.capabilities.isFlying; + if (++flyTicks >= maxFlyTicks.getInput() + 1) { + disabled(); + } + + double percentCalc = 1000 / maxFlyTicks.getInput(); + if (percent < 1000) percent = percent + (int) percentCalc; + percentDisplay = percent / 10; + if (flyTicks >= maxFlyTicks.getInput()) percentDisplay = 100; + + + } + + @SubscribeEvent + public void onRenderTick(TickEvent.RenderTickEvent ev) { + if (!Utils.nullCheck() || !begin && !placed) { + return; + } + if (ev.phase == TickEvent.Phase.END) { + if (mc.currentScreen != null) { + return; + } + } + color = Theme.getGradient((int) HUD.theme.getInput(), 0); + if (!placed) { + widthOffset = percentDisplay < 10 ? 8 : percentDisplay < 100 ? 12 : 14; + } else { + switch (ticks321) { + case 15: + get321 = "Waiting for explosion."; + widthOffset = 51; + break; + case 30: + get321 = "Waiting for explosion.."; + widthOffset = 53; + break; + case 45: + get321 = "Waiting for explosion..."; + widthOffset = 55; + break; + } + } + String text = placed ? get321 : (percentDisplay + "%"); + int width = mc.fontRendererObj.getStringWidth(text) + Utils.getBoldWidth(text) / 2; + final ScaledResolution scaledResolution = new ScaledResolution(mc); + int[] display = {scaledResolution.getScaledWidth(), scaledResolution.getScaledHeight(), scaledResolution.getScaleFactor()}; + mc.fontRendererObj.drawString(text, display[0] / 2 - width + widthOffset, display[1] / 2 + 8, color, true); + } + + public void onUpdate() { + if (!begin) { + return; + } + if (mc.currentScreen == null) { + if (Utils.jumpDown()) { + mc.thePlayer.motionY = 0.3 * verticalSpeed.getInput(); + } + else if (Utils.sneakDown()) { + mc.thePlayer.motionY = -0.3 * verticalSpeed.getInput(); + } + else { + mc.thePlayer.motionY = 0.0; + } + } + else { + mc.thePlayer.motionY = 0.0; + } + mc.thePlayer.capabilities.setFlySpeed(0.2f); + mc.thePlayer.capabilities.isFlying = true; + setSpeed(0.85 * horizontalSpeed.getInput()); + } + + + + public static void setSpeed(final double n) { + if (n == 0.0) { + mc.thePlayer.motionZ = 0; + mc.thePlayer.motionX = 0; + return; + } + double n3 = mc.thePlayer.movementInput.moveForward; + double n4 = mc.thePlayer.movementInput.moveStrafe; + float rotationYaw = mc.thePlayer.rotationYaw; + if (n3 == 0.0 && n4 == 0.0) { + mc.thePlayer.motionZ = 0; + mc.thePlayer.motionX = 0; + } + else { + if (n3 != 0.0) { + if (n4 > 0.0) { + rotationYaw += ((n3 > 0.0) ? -45 : 45); + } + else if (n4 < 0.0) { + rotationYaw += ((n3 > 0.0) ? 45 : -45); + } + n4 = 0.0; + if (n3 > 0.0) { + n3 = 1.0; + } + else if (n3 < 0.0) { + n3 = -1.0; + } + } + final double radians = Math.toRadians(rotationYaw + 90.0f); + final double sin = Math.sin(radians); + final double cos = Math.cos(radians); + mc.thePlayer.motionX = n3 * n * cos + n4 * n * sin; + mc.thePlayer.motionZ = n3 * n * sin - n4 * n * cos; + } + } + + private void disabled() { + begin = placed = false; + if (mc.thePlayer.capabilities.allowFlying) { + mc.thePlayer.capabilities.isFlying = this.d; + } + else { + mc.thePlayer.capabilities.isFlying = false; + } + this.d = false; + if (flyTicks > 0) { + mc.thePlayer.motionX = 0; + mc.thePlayer.motionY = 0; + mc.thePlayer.motionZ = 0; + } + flyTicks = percent = ticks321 = 0; + + get321 = "Waiting for explosion..."; + widthOffset = 55; + } +} diff --git a/src/main/java/keystrokesmod/module/impl/minigames/SkyWars.java b/src/main/java/keystrokesmod/module/impl/minigames/SkyWars.java index 4b3f76e..ed924a2 100644 --- a/src/main/java/keystrokesmod/module/impl/minigames/SkyWars.java +++ b/src/main/java/keystrokesmod/module/impl/minigames/SkyWars.java @@ -234,9 +234,9 @@ public class SkyWars extends Module { return -1; } - private static class SpawnEggInfo { - Vec3 spawnPos; - int tickSpawned; + public static class SpawnEggInfo { + public Vec3 spawnPos; + public int tickSpawned; public SpawnEggInfo(BlockPos spawnPos, int tickSpawned) { this.spawnPos = new Vec3(spawnPos.getX(), spawnPos.getY(), spawnPos.getZ()); diff --git a/src/main/java/keystrokesmod/module/impl/movement/NoSlow.java b/src/main/java/keystrokesmod/module/impl/movement/NoSlow.java index 3ce895e..53a198a 100644 --- a/src/main/java/keystrokesmod/module/impl/movement/NoSlow.java +++ b/src/main/java/keystrokesmod/module/impl/movement/NoSlow.java @@ -165,14 +165,14 @@ public class NoSlow extends Module { @SubscribeEvent public void onPreMotion(PreMotionEvent e) { - Block blockBelow = BlockUtils.getBlock(new BlockPos(mc.thePlayer.posX, mc.thePlayer.posY - 1, mc.thePlayer.posZ)); + /*Block blockBelow = BlockUtils.getBlock(new BlockPos(mc.thePlayer.posX, mc.thePlayer.posY - 1, mc.thePlayer.posZ)); Block block = BlockUtils.getBlock(new BlockPos(mc.thePlayer.posX, mc.thePlayer.posY, mc.thePlayer.posZ)); if (block instanceof BlockStairs || block instanceof BlockSlab && ModuleUtils.lastTickOnGround && ModuleUtils.lastTickPos1) { ticksOffStairs = 0; } else { ticksOffStairs++; - } + }*/ if (ModuleManager.bedAura.stopAutoblock || mode.getInput() != 4) { resetFloat(); return; @@ -198,7 +198,6 @@ public class NoSlow extends Module { offset = false; return; } - Utils.sendModuleMessage(this, "Offset"); e.setPosY(e.getPosY() + ModuleUtils.offsetValue); offset = true; if (groundSpeedOption.isToggled()) { @@ -273,7 +272,7 @@ public class NoSlow extends Module { speedModifier = 0.37; break; } - return speedModifier; + return speedModifier - 0.005; } private boolean holdingConsumable(ItemStack itemStack) { diff --git a/src/main/java/keystrokesmod/module/impl/other/Anticheat.java b/src/main/java/keystrokesmod/module/impl/other/Anticheat.java index 2b55922..d98699e 100644 --- a/src/main/java/keystrokesmod/module/impl/other/Anticheat.java +++ b/src/main/java/keystrokesmod/module/impl/other/Anticheat.java @@ -1,5 +1,7 @@ package keystrokesmod.module.impl.other; +import keystrokesmod.event.AntiCheatFlagEvent; +import keystrokesmod.event.ReceivePacketEvent; import keystrokesmod.module.Module; import keystrokesmod.module.impl.world.AntiBot; import keystrokesmod.module.setting.impl.ButtonSetting; @@ -9,12 +11,14 @@ import keystrokesmod.utility.BlockUtils; import keystrokesmod.utility.PlayerData; import keystrokesmod.utility.Utils; import net.minecraft.block.BlockAir; +import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.event.ClickEvent; import net.minecraft.item.ItemBlock; import net.minecraft.util.BlockPos; import net.minecraft.util.ChatComponentText; import net.minecraft.util.ChatStyle; +import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.entity.EntityJoinWorldEvent; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; @@ -33,9 +37,13 @@ public class Anticheat extends Module { private ButtonSetting noSlow; private ButtonSetting scaffold; private ButtonSetting legitScaffold; + private HashMap> flags = new HashMap<>(); private HashMap players = new HashMap<>(); + private long lastAlert; + private long lastClientBoundPacket; + public Anticheat() { super("Anticheat", category.other); this.registerSetting(new DescriptionSetting("Tries to detect cheaters.")); @@ -54,6 +62,11 @@ public class Anticheat extends Module { this.closetModule = true; } + @SubscribeEvent + public void onReceivePacket(ReceivePacketEvent e) { + lastClientBoundPacket = System.currentTimeMillis(); + } + private void alert(final EntityPlayer entityPlayer, ButtonSetting mode) { if (Utils.isFriended(entityPlayer) || (ignoreTeammates.isToggled() && Utils.isTeamMate(entityPlayer))) { return; @@ -86,6 +99,7 @@ public class Anticheat extends Module { chatStyle.setChatClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/wdr " + entityPlayer.getName())); chatComponentText.appendSibling(new ChatComponentText(Utils.formatColor(" §7[§cWDR§7]")).setChatStyle(chatStyle)); mc.thePlayer.addChatMessage(chatComponentText); + postAntiCheatFlagEvent(mode.getName(), entityPlayer); if (shouldPing.isToggled() && Utils.timeBetween(lastAlert, currentTimeMillis) >= 1500L) { mc.thePlayer.playSound("note.pling", 1.0f, 1.0f); lastAlert = currentTimeMillis; @@ -144,7 +158,7 @@ public class Anticheat extends Module { alert(entityPlayer, legitScaffold); return; } - if (noSlow.isToggled() && playerData.noSlowTicks >= 11 && playerData.speed >= 0.08) { + if (noSlow.isToggled() && playerData.noSlowTicks == 11 && playerData.speed >= 0.08) { alert(entityPlayer, noSlow); return; } @@ -163,7 +177,7 @@ public class Anticheat extends Module { return; } } - if (noFall.isToggled() && !entityPlayer.capabilities.isFlying) { + if (noFall.isToggled() && !entityPlayer.capabilities.isFlying && Utils.timeBetween(System.currentTimeMillis(), lastClientBoundPacket) <= 150) { double serverPosX = entityPlayer.serverPosX / 32; double serverPosY = entityPlayer.serverPosY / 32; double serverPosZ= entityPlayer.serverPosZ / 32; @@ -177,4 +191,8 @@ public class Anticheat extends Module { } } } -} + + public void postAntiCheatFlagEvent(String flag, Entity entity) { + MinecraftForge.EVENT_BUS.post(new AntiCheatFlagEvent(flag, entity)); + } +} \ No newline at end of file diff --git a/src/main/java/keystrokesmod/module/impl/player/NoFall.java b/src/main/java/keystrokesmod/module/impl/player/NoFall.java index d0cdeb5..ce70972 100644 --- a/src/main/java/keystrokesmod/module/impl/player/NoFall.java +++ b/src/main/java/keystrokesmod/module/impl/player/NoFall.java @@ -23,7 +23,7 @@ public class NoFall extends Module { private SliderSetting minFallDistance; private ButtonSetting disableAdventure; private ButtonSetting ignoreVoid; - private String[] modes = new String[]{"Spoof", "NoGround", "Packet A", "Packet B"}; + private String[] modes = new String[]{"Spoof", "NoGround", "Packet A", "Packet B", "CTW Packet"}; private double initialY; private double dynamic; @@ -56,18 +56,19 @@ public class NoFall extends Module { double predictedY = mc.thePlayer.posY + mc.thePlayer.motionY; double distanceFallen = initialY - predictedY; - if (mc.thePlayer.motionY >= -2.0) { + if (mc.thePlayer.motionY >= -1.0) { dynamic = 3.0; } - if (mc.thePlayer.motionY < -2.0) { + if (mc.thePlayer.motionY < -1.0) { dynamic = 4.0; } - if (mc.thePlayer.motionY < -3.0) { + if (mc.thePlayer.motionY < -2.0) { dynamic = 5.0; } if (isFalling && mode.getInput() == 2) { + Utils.getTimer().timerSpeed = (float) 1; if (distanceFallen >= dynamic) { - Utils.getTimer().timerSpeed = (0.6799789F + (float) Utils.randomizeDouble(-0.012, 0.012)); + Utils.getTimer().timerSpeed = (0.7199789F + (float) Utils.randomizeDouble(-0.012, 0.012)); mc.getNetHandler().addToSendQueue(new C03PacketPlayer(true)); initialY = mc.thePlayer.posY; } @@ -85,6 +86,14 @@ public class NoFall extends Module { initialY = mc.thePlayer.posY; } } + if (isFalling && mode.getInput() == 4) { + Utils.getTimer().timerSpeed = (float) 1; + if (distanceFallen >= 8) { + Utils.getTimer().timerSpeed = (float) Utils.randomizeDouble(0.7, 0.70201); + mc.getNetHandler().addToSendQueue(new C03PacketPlayer(true)); + initialY = mc.thePlayer.posY; + } + } //Utils.print("" + mc.thePlayer.ticksExisted + " " + mc.thePlayer.motionY + " " + edging); } diff --git a/src/main/java/keystrokesmod/module/impl/player/Scaffold.java b/src/main/java/keystrokesmod/module/impl/player/Scaffold.java index 82950e8..b1e38f8 100644 --- a/src/main/java/keystrokesmod/module/impl/player/Scaffold.java +++ b/src/main/java/keystrokesmod/module/impl/player/Scaffold.java @@ -95,6 +95,8 @@ public class Scaffold extends Module { private int disableTicks; private int scaffoldTicks; + private float minOffset; + private long firstStroke, strokeDelay = 575; private float lastEdge, lastEdge2, yawAngle; @@ -251,53 +253,81 @@ public class Scaffold extends Module { float side = MathHelper.wrapAngleTo180_float(getMotionYaw() - yaw); float offset = yawAngle;//(!Utils.scaffoldDiagonal(false)) ? 125.500F : 143.500F; - float minOffset = (!Utils.scaffoldDiagonal(false)) ? 20 : 8; float yawBackwards = MathHelper.wrapAngleTo180_float(mc.thePlayer.rotationYaw) - hardcodedYaw(); float blockYawOffset = MathHelper.wrapAngleTo180_float(yawBackwards - blockYaw); + int quadVal = 0; - float minPitch = 78.650f; + float minPitch = 77.650f; - float firstStraight = 127.50f; - float secondStraight = 129.50f; - float thirdStraight = 133.50f; - float firstDiag = 134.50f; - float secondDiag = 135.50f; - float thirdDiag = 136.50f; - float fourthDiag = 138f; + float firstStraight = 130.50f; + float secondStraight = 132.50f; + float thirdStraight = 134.50f; + float firstDiag = 135.50f; + float secondDiag = 137.50f; + float thirdDiag = 139.50f; + float fourthDiag = 142.50f; + + float firstOffset = 23; + float secondOffset = 20; + float thirdOffset = 17; + float fourthOffset = 14; + float fifthOffset = 11; + float sixthOffset = 8; + float seventhOffset = 6; //first straight if (quad <= 5 || quad >= 85) { yawAngle = firstStraight; + minOffset = firstOffset; + quadVal = 1; } else if (quad > 5 || quad < 85) { //second straight if (quad >= 80 || quad < 10) { yawAngle = secondStraight; + minOffset = secondOffset; + quadVal = 2; - //third straight + //third straight } else if (quad >= 65 || quad < 25) { yawAngle = thirdStraight; + minOffset = thirdOffset; + quadVal = 3; - //first diag + //first diag } else if (quad >= 55 || quad < 35) { yawAngle = firstDiag; + minOffset = fourthOffset; + quadVal = 4; - //second diag + //second diag } else if (quad >= 15 && quad < 45) { yawAngle = secondDiag; + minOffset = fifthOffset; + quadVal = 5; if (quad >= 38) { yawAngle = thirdDiag; + minOffset = sixthOffset; + quadVal = 6; if (quad >= 42) { yawAngle = fourthDiag; + minOffset = seventhOffset; + quadVal = 7; } } } else { yawAngle = secondDiag; + minOffset = fifthOffset; + quadVal = 5; if (quad >= 45 && quad < 52) { yawAngle = thirdDiag; + minOffset = sixthOffset; + quadVal = 6; if (quad < 48) { yawAngle = fourthDiag; + minOffset = seventhOffset; + quadVal = 7; } } } @@ -338,7 +368,7 @@ public class Scaffold extends Module { lastYaw + MathHelper.wrapAngleTo180_float(newYaw - lastYaw) ); - if (firstStroke == 0 && (quad > 5 && quad < 85)) { + if (firstStroke == 0 && quadVal != 1) { if (quad >= 0 && quad < 45) { if (side >= 0) { set2 = false; @@ -357,7 +387,7 @@ public class Scaffold extends Module { double minSwitch = (!Utils.scaffoldDiagonal(false)) ? 0 : 15; if (side >= 0) { - if (quad <= 5 || quad >= 85) { + if (quadVal == 1) { if (yawOffset <= -minSwitch && firstStroke == 0) { set2 = false; firstStroke = Utils.time(); @@ -375,7 +405,7 @@ public class Scaffold extends Module { break; } } else if (side <= -0) { - if (quad <= 5 || quad >= 85) { + if (quadVal == 1) { if (yawOffset >= minSwitch && firstStroke == 0) { set2 = false; firstStroke = Utils.time(); @@ -568,8 +598,8 @@ public class Scaffold extends Module { } //pitch fix - if (e.getPitch() >= 89.9F) { - e.setPitch(89.9F); + if (e.getPitch() >= 89) { + e.setPitch(89); } lastYaw = mc.thePlayer.rotationYaw; @@ -631,7 +661,7 @@ public class Scaffold extends Module { } if (disabledModule) { - if (hasPlaced && (towerEdge || floatStarted && Utils.isMoving() && Utils.isEdgeOfBlock())) { + if (hasPlaced && (towerEdge || floatStarted && Utils.isMoving())) { dontDisable = true; } diff --git a/src/main/java/keystrokesmod/module/impl/player/Tower.java b/src/main/java/keystrokesmod/module/impl/player/Tower.java index ad1bd70..8d0e3e9 100644 --- a/src/main/java/keystrokesmod/module/impl/player/Tower.java +++ b/src/main/java/keystrokesmod/module/impl/player/Tower.java @@ -236,7 +236,7 @@ public class Tower extends Module { if (aligned) { if (placed) { yaw = 0; - pitch = 89.9F; + pitch = 89; } else { yaw = RotationUtils.getRotations(firstX, firstY, firstZ)[0]; diff --git a/src/main/java/keystrokesmod/script/Manager.java b/src/main/java/keystrokesmod/script/Manager.java index fe66d9d..b429bdc 100644 --- a/src/main/java/keystrokesmod/script/Manager.java +++ b/src/main/java/keystrokesmod/script/Manager.java @@ -39,6 +39,7 @@ public class Manager extends Module { Entity.clearCache(); NetworkPlayer.clearCache(); Image.clearCache(); + ScriptDefaults.reloadModules(); if (Raven.currentProfile != null && Raven.currentProfile.getModule() != null) { ((ProfileModule) Raven.currentProfile.getModule()).saved = false; } diff --git a/src/main/java/keystrokesmod/script/Script.java b/src/main/java/keystrokesmod/script/Script.java index aace5ae..762fa50 100644 --- a/src/main/java/keystrokesmod/script/Script.java +++ b/src/main/java/keystrokesmod/script/Script.java @@ -19,7 +19,7 @@ public class Script { public String scriptName; public String codeStr; public boolean error = false; - public int extraLines; + public int STARTING_LINE; public ScriptEvents event; public File file; @@ -28,37 +28,12 @@ public class Script { this.scriptName = "sc_" + name.replace(" ", "").replace(")", "_").replace("(", "_") + "_" + Utils.generateRandomString(5); } - public float[] getFloat(final String s, final Object... array) { - if (this.asClass == null || this.classObject == null) { - return null; - } - Method method = null; - for (final Method method2 : this.asClass.getDeclaredMethods()) { - if (method2.getName().equalsIgnoreCase(s) && method2.getParameterCount() == array.length && method2.getReturnType().equals(float[].class)) { - method = method2; - break; - } - } - if (method != null) { - try { - method.setAccessible(true); - final Object invoke = method.invoke(this.classObject, array); - if (invoke instanceof float[]) { - return (float[])invoke; - } - } - catch (IllegalAccessException ex) {} - catch (InvocationTargetException ex2) {} - } - return null; - } - public boolean run() { try { if (this.scriptName == null || this.codeStr == null) { return false; } - final File file = new File(Raven.scriptManager.tempDir); + final File file = new File(Raven.scriptManager.COMPILED_DIR); if (!file.exists() || !file.isDirectory()) { file.mkdir(); } @@ -66,10 +41,10 @@ public class Script { return false; } final Diagnostic bp = new Diagnostic(); - final StandardJavaFileManager standardFileManager = Raven.scriptManager.compiler.getStandardFileManager(bp, null, null); + final StandardJavaFileManager fileManager = Raven.scriptManager.compiler.getStandardFileManager(bp, null, null); final ArrayList compilationOptions = new ArrayList<>(); compilationOptions.add("-d"); - compilationOptions.add(Raven.scriptManager.tempDir); + compilationOptions.add(Raven.scriptManager.COMPILED_DIR); compilationOptions.add("-XDuseUnsharedTable"); if (!(boolean) Launch.blackboard.get("fml.deobfuscatedEnvironment")) { compilationOptions.add("-classpath"); @@ -80,7 +55,7 @@ public class Script { catch (UnsupportedOperationException ex2) {} compilationOptions.add(s); } - boolean success = Raven.scriptManager.compiler.getTask(null, standardFileManager, bp, compilationOptions, null, Arrays.asList(new ClassObject(this.scriptName, this.codeStr, this.extraLines))).call(); + boolean success = Raven.scriptManager.compiler.getTask(null, fileManager, bp, compilationOptions, null, Arrays.asList(new ClassObject(this.scriptName, this.codeStr, this.STARTING_LINE))).call(); if (!success) { this.error = true; return false; @@ -90,6 +65,7 @@ public class Script { this.asClass = secureClassLoader.loadClass(this.scriptName); this.classObject = this.asClass.newInstance(); secureClassLoader.close(); + fileManager.close(); } catch (Throwable e) { e.printStackTrace(); @@ -124,8 +100,27 @@ public class Script { return ((boolean)invoke) ? 1 : 0; } } - catch (Exception e) { - printRunTimeError(e, s); + catch (IllegalAccessException | InvocationTargetException ex) { + ReflectiveOperationException er = ex; + Utils.sendMessage("&7Runtime error during script &b" + this.name); + if (er.getCause() == null) { + Utils.sendMessage(" &7err: &cThrowable"); + } + else { + Utils.sendMessage(" &7err: &c" + er.getCause().getClass().getSimpleName()); + final StackTraceElement[] stArr = er.getCause().getStackTrace(); + if (stArr.length > 0) { + StackTraceElement st = stArr[0]; + for (final StackTraceElement element : er.getCause().getStackTrace()) { + if (element.getClassName().equalsIgnoreCase(this.scriptName)) { + st = element; + break; + } + } + Utils.sendMessage(" &7line: &c" + (st.getLineNumber() - STARTING_LINE)); + Utils.sendMessage(" &7src: &c" + st.getMethodName()); + } + } } } return -1; @@ -134,29 +129,29 @@ public class Script { public void delete() { this.asClass = null; this.classObject = null; - final File file = new File(Raven.scriptManager.tempDir + File.separator + this.scriptName + ".class"); + final File file = new File(Raven.scriptManager.COMPILED_DIR + File.separator + this.scriptName + ".class"); if (file.exists()) { file.delete(); } } - public void createScript(final String s) { - extraLines = 0; + public void setCode(String code) { + STARTING_LINE = 0; final StringBuilder sb = new StringBuilder(); final Iterator iterator = Raven.scriptManager.imports.iterator(); while (iterator.hasNext()) { - extraLines++; + STARTING_LINE++; sb.append("import ").append(iterator.next()).append(";\n"); } sb.append("import keystrokesmod.script.classes.*;\n"); sb.append("import keystrokesmod.script.packets.clientbound.*;\n"); sb.append("import keystrokesmod.script.packets.serverbound.*;\n"); String name = Utils.extractFileName(this.name); - this.codeStr = sb + "public class " + this.scriptName + " extends " + ScriptDefaults.class.getName() + " {public static final " + ScriptDefaults.modules.class.getName().replace("$", ".") + " modules = new " + ScriptDefaults.modules.class.getName().replace("$", ".") + "(\"" + name + "\");public static final String scriptName = \"" + name + "\";\n" + s + "\n}"; - extraLines += 4; + this.codeStr = sb + "public class " + this.scriptName + " extends " + ScriptDefaults.class.getName() + " {public static final " + ScriptDefaults.modules.class.getName().replace("$", ".") + " modules = new " + ScriptDefaults.modules.class.getName().replace("$", ".") + "(\"" + name + "\");public static final String scriptName = \"" + name + "\";\n" + code + "\n}"; + STARTING_LINE += 4; } - public boolean invokeMethod(final String s, final Object... array) { + public boolean invoke(final String s, final Object... array) { if (this.asClass == null || this.classObject == null) { return false; } @@ -173,26 +168,29 @@ public class Script { method.invoke(this.classObject, array); return true; } - catch (Exception e) { - printRunTimeError(e, s); + catch (IllegalAccessException | InvocationTargetException ex) { + ReflectiveOperationException er = ex; + Utils.sendMessage("&7Runtime error during script &b" + this.name); + if (er.getCause() == null) { + Utils.sendMessage(" &7err: &cThrowable"); + } + else { + Utils.sendMessage(" &7err: &c" + er.getCause().getClass().getSimpleName()); + final StackTraceElement[] stArr = er.getCause().getStackTrace(); + if (stArr.length > 0) { + StackTraceElement st = stArr[0]; + for (final StackTraceElement element : er.getCause().getStackTrace()) { + if (element.getClassName().equalsIgnoreCase(this.scriptName)) { + st = element; + break; + } + } + Utils.sendMessage(" &7line: &c" + (st.getLineNumber() - STARTING_LINE)); + Utils.sendMessage(" &7src: &c" + st.getMethodName()); + } + } } } return false; } - - private int getLine(Throwable e, String name) { - for (StackTraceElement element : e.getStackTrace()) { - if (element.getClassName().equals(name)) { - return element.getLineNumber() - extraLines; - } - } - return 0; - } - - private void printRunTimeError(Exception e, String methodName) { - Utils.sendDebugMessage("§cRuntime error during script §b" + Utils.extractFileName(this.name)); - Utils.sendDebugMessage(" §7err: §c" + e.getCause().getClass().getSimpleName()); - Utils.sendDebugMessage(" §7line: §c" + getLine(e.getCause(), this.scriptName)); - Utils.sendDebugMessage(" §7src: §c" + methodName); - } } diff --git a/src/main/java/keystrokesmod/script/ScriptDefaults.java b/src/main/java/keystrokesmod/script/ScriptDefaults.java index 173de70..6c99384 100644 --- a/src/main/java/keystrokesmod/script/ScriptDefaults.java +++ b/src/main/java/keystrokesmod/script/ScriptDefaults.java @@ -9,9 +9,7 @@ import keystrokesmod.module.Module; import keystrokesmod.module.ModuleManager; import keystrokesmod.module.impl.combat.KillAura; import keystrokesmod.module.setting.Setting; -import keystrokesmod.module.setting.impl.ButtonSetting; -import keystrokesmod.module.setting.impl.DescriptionSetting; -import keystrokesmod.module.setting.impl.SliderSetting; +import keystrokesmod.module.setting.impl.*; import keystrokesmod.script.classes.*; import keystrokesmod.script.classes.Vec3; import keystrokesmod.script.packets.clientbound.SPacket; @@ -21,8 +19,7 @@ import keystrokesmod.utility.*; import keystrokesmod.utility.shader.BlurUtils; import keystrokesmod.utility.shader.RoundedUtils; import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.GuiScreenBook; -import net.minecraft.client.gui.ScaledResolution; +import net.minecraft.client.gui.*; import net.minecraft.client.gui.inventory.*; import net.minecraft.client.network.NetworkPlayerInfo; import net.minecraft.client.renderer.*; @@ -37,6 +34,7 @@ import net.minecraft.init.Blocks; import net.minecraft.inventory.ContainerChest; import net.minecraft.inventory.IInventory; import net.minecraft.network.Packet; +import net.minecraft.realms.RealmsBridge; import net.minecraft.scoreboard.Team; import net.minecraft.util.*; import org.lwjgl.input.Keyboard; @@ -58,6 +56,17 @@ public class ScriptDefaults { private static ExecutorService cachedExecutor; private static final Minecraft mc = Minecraft.getMinecraft(); public static final Bridge bridge = new Bridge(); + private static final LinkedHashMap modulesMap = new LinkedHashMap<>(); + + public static void reloadModules() { + modulesMap.clear(); + for (Module module : Raven.getModuleManager().getModules()) { + modulesMap.put(module.getName(), module); + } + for (Module module : Raven.scriptManager.scripts.values()) { + modulesMap.put(module.getName(), module); + } + } public static class client { public static boolean allowFlying() { @@ -176,6 +185,22 @@ public class ScriptDefaults { mc.thePlayer.renderArmPitch = pitch; } + public static void disconnect() { + boolean isLocal = mc.isIntegratedServerRunning(); + boolean isRealms = mc.isConnectedToRealms(); + mc.theWorld.sendQuittingDisconnectingPacket(); + mc.loadWorld(null); + if (isLocal) { + mc.displayGuiScreen(new GuiMainMenu()); + return; + } + if (isRealms) { + new RealmsBridge().switchToRealms(new GuiMainMenu()); + return; + } + mc.displayGuiScreen(new GuiMultiplayer(new GuiMainMenu())); + } + public static float getRenderArmPitch() { return mc.thePlayer.renderArmPitch; } @@ -564,30 +589,15 @@ public class ScriptDefaults { this.superName = superName; } - private Module getModule(String moduleName) { - for (Module module : Raven.getModuleManager().getModules()) { - if (module.getName().equals(moduleName)) { - return module; - } - } - for (Module module : Raven.scriptManager.scripts.values()) { - if (module.getName().equals(moduleName)) { - return module; - } - } - return null; + private static Module getModule(String moduleName) { + return modulesMap.get(moduleName); } - private Module getScript(String name) { - for (Module module : Raven.scriptManager.scripts.values()) { - if (module.getName().equals(name)) { - return module; - } - } - return null; + private static Module getScript(String name) { + return modulesMap.get(name); } - private Setting getSetting(Module module, String settingName) { + private static Setting getSetting(Module module, String settingName) { if (module == null) { return null; } @@ -599,6 +609,22 @@ public class ScriptDefaults { return null; } + private GroupSetting getGroupForString(String group) { + if (group.isEmpty()) { + return null; + } + List settings = getScript(this.superName).getSettings(); + for (Setting setting : settings) { + if (!(setting instanceof GroupSetting)) { + continue; + } + if (setting.getName().equals(group)) { + return (GroupSetting) setting; + } + } + return null; + } + public void enable(String moduleName) { if (getModule(moduleName) == null) { return; @@ -664,6 +690,14 @@ public class ScriptDefaults { return new Vec3(blockPos.getX(), blockPos.getY(), blockPos.getZ()); } + public boolean isScaffolding() { + return ModuleManager.scaffold.isEnabled(); + } + + public boolean isTowering() { + return ModuleManager.tower.canTower(); + } + public boolean isHidden(String moduleName) { Module module = getModule(moduleName); if (module != null) { @@ -679,24 +713,52 @@ public class ScriptDefaults { return new float[]{0, 0}; } + public void registerGroup(String name) { + getScript(this.superName).registerSetting(new GroupSetting(name)); + } + public void registerButton(String name, boolean defaultValue) { getScript(this.superName).registerSetting(new ButtonSetting(name, defaultValue)); } + public void registerButton(String group, String name, boolean defaultValue) { + getScript(this.superName).registerSetting(new ButtonSetting(getGroupForString(group), name, defaultValue)); + } + + public void registerKey(String group, String name, int defaultKey) { + getScript(this.superName).registerSetting(new KeySetting(getGroupForString(group), name, defaultKey)); + } + + public void registerKey(String name, int defaultKey) { + getScript(this.superName).registerSetting(new KeySetting(name, defaultKey)); + } + + // main slider constructors + + public void registerSlider(String group, String name, String suffix, double defaultValue, double minimum, double maximum, double interval) { + getScript(this.superName).registerSetting(new SliderSetting(getGroupForString(group), name, suffix, defaultValue, minimum, maximum, interval)); + } + + public void registerSlider(String group, String name, String suffix, int defaultValue, String[] stringArray) { + getScript(this.superName).registerSetting(new SliderSetting(getGroupForString(group), name, suffix, defaultValue, stringArray)); + } + + // rest + public void registerSlider(String name, double defaultValue, double minimum, double maximum, double interval) { - this.registerSlider(name, "", defaultValue, minimum, maximum, interval); + this.registerSlider("", name, "", defaultValue, minimum, maximum, interval); } public void registerSlider(String name, int defaultValue, String[] stringArray) { - this.registerSlider(name, "", defaultValue, stringArray); + this.registerSlider("", name, "", defaultValue, stringArray); } public void registerSlider(String name, String suffix, double defaultValue, double minimum, double maximum, double interval) { - getScript(this.superName).registerSetting(new SliderSetting(name, defaultValue, minimum, maximum, interval)); + this.registerSlider("", name, suffix, defaultValue, minimum, maximum, interval); } public void registerSlider(String name, String suffix, int defaultValue, String[] stringArray) { - getScript(this.superName).registerSetting(new SliderSetting(name, defaultValue, stringArray)); + this.registerSlider("", name, suffix, defaultValue, stringArray); } public void registerDescription(String description) { @@ -721,6 +783,14 @@ public class ScriptDefaults { return sliderValue; } + public boolean getKeyPressed(String moduleName, String name) { + KeySetting setting = ((KeySetting) getSetting(getModule(moduleName), name)); + if (setting == null) { + return false; + } + return setting.isPressed(); + } + public void setButton(String moduleName, String name, boolean value) { ButtonSetting setting = (ButtonSetting) getSetting(getModule(moduleName), name); if (setting == null) { @@ -736,6 +806,14 @@ public class ScriptDefaults { } setting.setValue(value); } + + public void setKey(String moduleName, String name, int code) { + KeySetting setting = ((KeySetting) getSetting(getModule(moduleName), name)); + if (setting == null) { + return; + } + setting.setKey(code); + } } public static class gl { @@ -1013,10 +1091,16 @@ public class ScriptDefaults { RenderUtils.drawTracerLine(entity.entity, color, lineWidth, partialTicks); } + public static void showGui() { + mc.displayGuiScreen(new EmptyGuiScreen()); + } + + private static class EmptyGuiScreen extends GuiScreen { + } + public static void item(ItemStack item, float x, float y, float scale) { - GlStateManager.pushMatrix(); - ((IAccessorEntityRenderer) mc.entityRenderer).callSetupCameraTransform(((IAccessorMinecraft) mc).getTimer().renderPartialTicks, 0); mc.entityRenderer.setupOverlayRendering(); + GlStateManager.pushMatrix(); if (scale != 1.0f) { GlStateManager.scale(scale, scale, scale); } @@ -1108,8 +1192,8 @@ public class ScriptDefaults { } public static void text2d(String text, float x, float y, float scale, int color, boolean shadow) { + GlStateManager.pushMatrix(); if (scale != 1.0f) { - GlStateManager.pushMatrix(); GlStateManager.scale(scale, scale, scale); } GlStateManager.enableBlend(); @@ -1118,24 +1202,55 @@ public class ScriptDefaults { GlStateManager.disableBlend(); if (scale != 1.0f) { GlStateManager.scale(1.0f, 1.0f, 1.0f); - GlStateManager.popMatrix(); } + GlStateManager.popMatrix(); } - public static void text3d(String text, float x, float y, float scale, int color, boolean shadow) { - GlStateManager.pushMatrix(); + public static void text3d(String text, Vec3 position, float scale, boolean shadow, boolean depth, boolean background, int color) { ((IAccessorEntityRenderer) mc.entityRenderer).callSetupCameraTransform(((IAccessorMinecraft) mc).getTimer().renderPartialTicks, 0); - mc.entityRenderer.setupOverlayRendering(); - if (scale != 1.0f) { - GlStateManager.scale(scale, scale, scale); + GlStateManager.pushMatrix(); + float partialTicks = ((IAccessorMinecraft) mc).getTimer().renderPartialTicks; + double px = mc.thePlayer.prevPosX + (mc.thePlayer.posX - mc.thePlayer.prevPosX) * partialTicks; + double py = mc.thePlayer.prevPosY + (mc.thePlayer.posY - mc.thePlayer.prevPosY) * partialTicks; + double pz = mc.thePlayer.prevPosZ + (mc.thePlayer.posZ - mc.thePlayer.prevPosZ) * partialTicks; + GlStateManager.translate((float)position.x - px, (float)position.y - py, (float)position.z - pz); + GL11.glNormal3f(0.0F, 1.0F, 0.0F); + GlStateManager.rotate(-mc.getRenderManager().playerViewY, 0.0F, 1.0F, 0.0F); + GlStateManager.rotate(mc.getRenderManager().playerViewX, 1.0f, 0.0f, 0.0f); + float f1 = 0.02666667F; + GlStateManager.scale(-f1, -f1, f1); + if (depth) { + GlStateManager.depthMask(false); + GlStateManager.disableDepth(); } GlStateManager.enableBlend(); GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0); - mc.fontRendererObj.drawString(text, x, y, color, shadow); - GlStateManager.disableBlend(); - if (scale != 1.0f) { - GlStateManager.scale(1.0f, 1.0f, 1.0f); + if (background) { + GlStateManager.disableTexture2D(); + int width = mc.fontRendererObj.getStringWidth(text); + Tessellator tessellator = Tessellator.getInstance(); + WorldRenderer worldrenderer = tessellator.getWorldRenderer(); + worldrenderer.begin(7, DefaultVertexFormats.POSITION_COLOR); + worldrenderer.pos(-1, -1.0, 0.0).color(0.0f, 0.0f, 0.0f, 0.25f).endVertex(); + worldrenderer.pos(-1, 8.0, 0.0).color(0.0f, 0.0f, 0.0f, 0.25f).endVertex(); + worldrenderer.pos(width + 1, 8.0, 0.0).color(0.0f, 0.0f, 0.0f, 0.25f).endVertex(); + worldrenderer.pos(width + 1, -1.0, 0.0).color(0.0f, 0.0f, 0.0f, 0.25f).endVertex(); + tessellator.draw(); + GlStateManager.enableTexture2D(); } + if (scale != 1) { + GlStateManager.scale(scale, scale, scale); + } + mc.fontRendererObj.drawString(text, 0, 0, color, shadow); + if (scale != 1) { + GlStateManager.scale(1, 1, 1); + } + if (depth) { + GlStateManager.enableDepth(); + GlStateManager.depthMask(true); + } + GlStateManager.disableBlend(); + GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); GlStateManager.popMatrix(); } @@ -1402,6 +1517,10 @@ public class ScriptDefaults { public static void leftClick() { ((IAccessorMinecraft) mc).callClickMouse(); } + + public static int getScroll() { + return Mouse.getDWheel(); + } } public static class util { diff --git a/src/main/java/keystrokesmod/script/ScriptEvents.java b/src/main/java/keystrokesmod/script/ScriptEvents.java index 8fca8b5..b2d0bdd 100644 --- a/src/main/java/keystrokesmod/script/ScriptEvents.java +++ b/src/main/java/keystrokesmod/script/ScriptEvents.java @@ -89,6 +89,11 @@ public class ScriptEvents { Raven.scriptManager.invoke("onRenderTick", module, e.renderTickTime); } + @SubscribeEvent(priority = EventPriority.HIGHEST) + public void onAntiCheatFlag(AntiCheatFlagEvent e) { + Raven.scriptManager.invoke("onAntiCheatFlag", module, e.flag, Entity.convert(e.entity)); + } + @SubscribeEvent(priority = EventPriority.HIGHEST) public void onGuiUpdate(GuiUpdateEvent e) { if (e.guiScreen == null) { diff --git a/src/main/java/keystrokesmod/script/ScriptManager.java b/src/main/java/keystrokesmod/script/ScriptManager.java index 245a6e6..2e58263 100644 --- a/src/main/java/keystrokesmod/script/ScriptManager.java +++ b/src/main/java/keystrokesmod/script/ScriptManager.java @@ -6,7 +6,7 @@ import keystrokesmod.module.Module; import keystrokesmod.utility.NetworkUtils; import keystrokesmod.utility.Utils; import net.minecraft.client.Minecraft; -import net.minecraftforge.fml.common.FMLCommonHandler; +import net.minecraftforge.common.MinecraftForge; import javax.tools.JavaCompiler; import javax.tools.ToolProvider; @@ -32,7 +32,7 @@ public class ScriptManager { public boolean deleteTempFiles = true; public File directory; public List imports = Arrays.asList(Color.class.getName(), Collections.class.getName(), List.class.getName(), ArrayList.class.getName(), Arrays.class.getName(), Map.class.getName(), HashMap.class.getName(), HashSet.class.getName(), ConcurrentHashMap.class.getName(), LinkedHashMap.class.getName(), Iterator.class.getName(), Comparator.class.getName(), AtomicInteger.class.getName(), AtomicLong.class.getName(), AtomicBoolean.class.getName(), Random.class.getName(), Matcher.class.getName()); - public String tempDir = System.getProperty("java.io.tmpdir") + "cmF2ZW5fc2NyaXB0cw"; + public String COMPILED_DIR = System.getProperty("java.io.tmpdir") + "cmF2ZW5fc2NyaXB0cw"; public String b = ((String[])ScriptManager.class.getProtectionDomain().getCodeSource().getLocation().getPath().split("\\.jar!"))[0].substring(5) + ".jar"; private Map loadedHashes = new HashMap<>(); @@ -43,9 +43,9 @@ public class ScriptManager { public void onEnable(Script dv) { if (dv.event == null) { dv.event = new ScriptEvents(getModule(dv)); - FMLCommonHandler.instance().bus().register(dv.event); + MinecraftForge.EVENT_BUS.register(dv.event); } - dv.invokeMethod("onEnable"); + dv.invoke("onEnable"); } public Module getModule(Script dv) { @@ -64,7 +64,7 @@ public class ScriptManager { if (deleteTempFiles) { deleteTempFiles = false; - final File tempDirectory = new File(tempDir); + final File tempDirectory = new File(COMPILED_DIR); if (tempDirectory.exists() && tempDirectory.isDirectory()) { final File[] tempFiles = tempDirectory.listFiles(); if (tempFiles != null) { @@ -135,6 +135,8 @@ public class ScriptManager { categoryComponent.reloadModules(false); } } + + ScriptDefaults.reloadModules(); } private boolean parseFile(final File file) { @@ -161,7 +163,7 @@ public class ScriptManager { for (String line : topLevelLines) { if (line.startsWith("load - \"") && line.endsWith("\"")) { String url = line.substring("load - \"".length(), line.length() - 1); - String externalContents = NetworkUtils.getTextFromURL(url, true); + String externalContents = NetworkUtils.getTextFromURL(url, true, true); if (externalContents.isEmpty()) { break; } @@ -173,10 +175,11 @@ public class ScriptManager { } Script script = new Script(scriptName); script.file = file; - script.createScript(scriptContents.toString()); + script.setCode(scriptContents.toString()); script.run(); Module module = new Module(script); Raven.scriptManager.scripts.put(script, module); + ScriptDefaults.reloadModules(); Raven.scriptManager.invoke("onLoad", module); return !script.error; } @@ -184,16 +187,16 @@ public class ScriptManager { public void onDisable(Script script) { if (script.event != null) { - FMLCommonHandler.instance().bus().unregister(script.event); + MinecraftForge.EVENT_BUS.unregister(script.event); script.event = null; } - script.invokeMethod("onDisable"); + script.invoke("onDisable"); } public void invoke(String methodName, Module module, final Object... args) { for (Map.Entry entry : this.scripts.entrySet()) { if (((entry.getValue().canBeEnabled() && entry.getValue().isEnabled()) || methodName.equals("onLoad")) && entry.getValue().equals(module)) { - entry.getKey().invokeMethod(methodName, args); + entry.getKey().invoke(methodName, args); } } } diff --git a/src/main/java/keystrokesmod/script/classes/Block.java b/src/main/java/keystrokesmod/script/classes/Block.java index ec1e7ee..1fc52fe 100644 --- a/src/main/java/keystrokesmod/script/classes/Block.java +++ b/src/main/java/keystrokesmod/script/classes/Block.java @@ -1,6 +1,7 @@ package keystrokesmod.script.classes; import keystrokesmod.utility.BlockUtils; +import keystrokesmod.utility.Utils; import net.minecraft.util.BlockPos; public class Block { @@ -32,6 +33,14 @@ public class Block { this(BlockUtils.getBlock(x, y, z), new BlockPos(x, y, z)); } + protected Block(String name, Vec3 position) { + this(Utils.getBlockFromName(name), Vec3.getBlockPos(position)); + } + + public Block(String name) { + this(name, new Vec3(-1, -1, -1)); + } + public Block(Vec3 position) { this(BlockUtils.getBlock(position.x, position.y, position.z), new BlockPos(position.x, position.y, position.z)); } diff --git a/src/main/java/keystrokesmod/script/classes/Entity.java b/src/main/java/keystrokesmod/script/classes/Entity.java index 1a0a182..c54fe0a 100644 --- a/src/main/java/keystrokesmod/script/classes/Entity.java +++ b/src/main/java/keystrokesmod/script/classes/Entity.java @@ -8,6 +8,7 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.projectile.EntityFishHook; import net.minecraft.item.ItemBlock; import net.minecraft.potion.PotionEffect; +import net.minecraft.util.AxisAlignedBB; import java.util.ArrayList; import java.util.HashMap; @@ -270,11 +271,8 @@ public class Entity { return Utils.getHorizontalSpeed(entity); } - public double getSwingProgress() { - if (!(entity instanceof EntityLivingBase)) { - return -1; - } - return ((EntityLivingBase) entity).swingProgress; + public int getSwingProgress() { + return this.isLiving ? ((EntityLivingBase)this.entity).swingProgressInt : -1; } public int getTicksExisted() { @@ -305,6 +303,9 @@ public class Entity { } public boolean isCollided() { + if (!(entity instanceof EntityPlayer)) { + return Minecraft.getMinecraft().theWorld.checkBlockCollision(this.entity.getEntityBoundingBox().expand(0.05, 0.0, 0.05)); + } return entity.isCollided; } diff --git a/src/main/java/keystrokesmod/script/classes/PlayerState.java b/src/main/java/keystrokesmod/script/classes/PlayerState.java index 0790ec5..7c40177 100644 --- a/src/main/java/keystrokesmod/script/classes/PlayerState.java +++ b/src/main/java/keystrokesmod/script/classes/PlayerState.java @@ -37,4 +37,11 @@ public class PlayerState { public Object[] asArray() { return new Object[] { this.x, this.y, this.z, this.yaw, this.pitch, this.onGround, this.isSprinting, this.isSneaking }; } + + public boolean equals(PlayerState playerState) { + if (playerState == null) { + return false; + } + return this.x == playerState.x && this.y == playerState.y && this.z == playerState.z && this.yaw == playerState.yaw && this.pitch == playerState.pitch && this.onGround == playerState.onGround && this.isSprinting == playerState.isSprinting && this.isSneaking == playerState.isSneaking; + } } diff --git a/src/main/java/keystrokesmod/script/packets/clientbound/S08.java b/src/main/java/keystrokesmod/script/packets/clientbound/S08.java index cc9addf..f31b014 100644 --- a/src/main/java/keystrokesmod/script/packets/clientbound/S08.java +++ b/src/main/java/keystrokesmod/script/packets/clientbound/S08.java @@ -1,17 +1,49 @@ package keystrokesmod.script.packets.clientbound; import keystrokesmod.script.classes.Vec3; +import keystrokesmod.utility.Utils; import net.minecraft.network.play.server.S08PacketPlayerPosLook; +import java.util.EnumSet; +import java.util.HashSet; +import java.util.Set; + public class S08 extends SPacket { public Vec3 position; public float yaw; public float pitch; + public Set enumFlags; public S08(S08PacketPlayerPosLook packet) { super(packet); this.position = new Vec3(packet.getX(), packet.getY(), packet.getZ()); this.yaw = packet.getYaw(); this.pitch = packet.getPitch(); + + Set flags = packet.func_179834_f(); + Set flagsStr = new HashSet<>(flags.size()); + for (S08PacketPlayerPosLook.EnumFlags flag : flags) { + flagsStr.add(flag.name()); + } + this.enumFlags = flagsStr; } -} + + public S08(Vec3 position, float yaw, float pitch, Set enumFlags) { + super(create(position, yaw, pitch, enumFlags)); + this.position = position; + this.yaw = yaw; + this.pitch = pitch; + this.enumFlags = enumFlags; + } + + private static S08PacketPlayerPosLook create(Vec3 position, float yaw, float pitch, Set enumFlags) { + Set enumSet = EnumSet.noneOf(S08PacketPlayerPosLook.EnumFlags.class); + for (String flag : enumFlags) { + S08PacketPlayerPosLook.EnumFlags enumFlag = Utils.getEnum(S08PacketPlayerPosLook.EnumFlags.class, flag); + if (enumFlag != null) { + enumSet.add(enumFlag); + } + } + return new S08PacketPlayerPosLook(position.x, position.y, position.z, yaw, pitch, enumSet); + } +} \ No newline at end of file diff --git a/src/main/java/keystrokesmod/script/packets/clientbound/S23.java b/src/main/java/keystrokesmod/script/packets/clientbound/S23.java index af0582b..f47a9b4 100644 --- a/src/main/java/keystrokesmod/script/packets/clientbound/S23.java +++ b/src/main/java/keystrokesmod/script/packets/clientbound/S23.java @@ -3,7 +3,6 @@ package keystrokesmod.script.packets.clientbound; import keystrokesmod.script.classes.Block; import keystrokesmod.script.classes.Vec3; import net.minecraft.client.Minecraft; -import net.minecraft.network.Packet; import net.minecraft.network.play.server.S23PacketBlockChange; import net.minecraft.util.BlockPos; diff --git a/src/main/java/keystrokesmod/script/packets/clientbound/S27.java b/src/main/java/keystrokesmod/script/packets/clientbound/S27.java index c90a535..21bf629 100644 --- a/src/main/java/keystrokesmod/script/packets/clientbound/S27.java +++ b/src/main/java/keystrokesmod/script/packets/clientbound/S27.java @@ -2,16 +2,43 @@ package keystrokesmod.script.packets.clientbound; import keystrokesmod.script.classes.Vec3; import net.minecraft.network.play.server.S27PacketExplosion; +import net.minecraft.util.BlockPos; + +import java.util.ArrayList; +import java.util.List; public class S27 extends SPacket { public float strength; public Vec3 position; public Vec3 motion; + public List affectedBlockPositions; public S27(S27PacketExplosion packet) { super(packet); this.strength = packet.getStrength(); this.position = new Vec3(packet.getX(), packet.getY(), packet.getZ()); this.motion = new Vec3(packet.func_149149_c(), packet.func_149144_d(), packet.func_149147_e()); + + List affectedBlockPositions = new ArrayList<>(); + for (BlockPos blockPos : packet.getAffectedBlockPositions()) { + affectedBlockPositions.add(Vec3.convert(blockPos)); + } + this.affectedBlockPositions = affectedBlockPositions; + } + + public S27(float strength, Vec3 position, Vec3 motion, List affectedBlockPositions) { + super(create(strength, position, motion, affectedBlockPositions)); + this.strength = strength; + this.position = position; + this.motion = motion; + this.affectedBlockPositions = affectedBlockPositions; + } + + private static S27PacketExplosion create(float strength, Vec3 position, Vec3 motion, List affectedBlockPositions) { + List list = new ArrayList<>(); + for (Vec3 vec3 : affectedBlockPositions) { + list.add(Vec3.getBlockPos(vec3)); + } + return new S27PacketExplosion(position.x, position.y, position.z, strength, list, Vec3.getVec3(motion)); } } diff --git a/src/main/java/keystrokesmod/script/packets/clientbound/S2A.java b/src/main/java/keystrokesmod/script/packets/clientbound/S2A.java index b27ee60..aac05e1 100644 --- a/src/main/java/keystrokesmod/script/packets/clientbound/S2A.java +++ b/src/main/java/keystrokesmod/script/packets/clientbound/S2A.java @@ -1,7 +1,9 @@ package keystrokesmod.script.packets.clientbound; import keystrokesmod.script.classes.Vec3; +import keystrokesmod.utility.Utils; import net.minecraft.network.play.server.S2APacketParticles; +import net.minecraft.util.EnumParticleTypes; public class S2A extends SPacket { public String type; @@ -9,15 +11,28 @@ public class S2A extends SPacket { public Vec3 offset; public float speed; public int count; + public boolean longDistance; public int[] args; public S2A(S2APacketParticles packet) { super(packet); this.type = packet.getParticleType().name(); + this.longDistance = packet.isLongDistance(); this.position = new Vec3(packet.getXCoordinate(), packet.getYCoordinate(), packet.getZCoordinate()); this.offset = new Vec3(packet.getXOffset(), packet.getYOffset(), packet.getZOffset()); this.speed = packet.getParticleSpeed(); this.count = packet.getParticleCount(); this.args = packet.getParticleArgs(); } + + public S2A(String type, boolean longDistance, Vec3 position, Vec3 offset, float speed, int count, int[] args) { + super(new S2APacketParticles(Utils.getEnum(EnumParticleTypes.class, type), longDistance, (float) position.x, (float) position.y, (float) position.z, (float) offset.x, (float) offset.y, (float) offset.z, speed, count, args)); + this.type = type; + this.longDistance = longDistance; + this.position = position; + this.offset = offset; + this.speed = speed; + this.count = count; + this.args = args; + } } diff --git a/src/main/java/keystrokesmod/script/packets/serverbound/C03.java b/src/main/java/keystrokesmod/script/packets/serverbound/C03.java index 49dcd8c..facb06a 100644 --- a/src/main/java/keystrokesmod/script/packets/serverbound/C03.java +++ b/src/main/java/keystrokesmod/script/packets/serverbound/C03.java @@ -9,6 +9,18 @@ public class C03 extends CPacket { public float pitch; public boolean ground; + protected C03(C03PacketPlayer packet, byte f1, byte f2, byte f3, byte f4, byte f5, byte f6) { // goofy asf but cba to + super(packet); + if (packet instanceof C03PacketPlayer.C04PacketPlayerPosition || packet instanceof C03PacketPlayer.C06PacketPlayerPosLook) { + this.position = new Vec3(packet.getPositionX(), packet.getPositionY(), packet.getPositionZ()); + } + if (packet instanceof C03PacketPlayer.C05PacketPlayerLook || packet instanceof C03PacketPlayer.C06PacketPlayerPosLook) { + this.yaw = packet.getYaw(); + this.pitch = packet.getPitch(); + } + this.ground = packet.isOnGround(); + } + public C03(boolean ground) { super(new C03PacketPlayer(ground)); this.ground = ground; @@ -34,16 +46,4 @@ public class C03 extends CPacket { this.pitch = pitch; this.ground = ground; } - - protected C03(C03PacketPlayer packet, byte f1, byte f2, byte f3, byte f4, byte f5, byte f6) { // goofy asf but cba to - super(packet); - if (packet instanceof C03PacketPlayer.C04PacketPlayerPosition || packet instanceof C03PacketPlayer.C06PacketPlayerPosLook) { - this.position = new Vec3(packet.getPositionX(), packet.getPositionY(), packet.getPositionZ()); - } - if (packet instanceof C03PacketPlayer.C05PacketPlayerLook || packet instanceof C03PacketPlayer.C06PacketPlayerPosLook) { - this.yaw = packet.getYaw(); - this.pitch = packet.getPitch(); - } - this.ground = packet.isOnGround(); - } } diff --git a/src/main/java/keystrokesmod/script/packets/serverbound/PacketHandler.java b/src/main/java/keystrokesmod/script/packets/serverbound/PacketHandler.java index a1f5f5c..7a6e8f5 100644 --- a/src/main/java/keystrokesmod/script/packets/serverbound/PacketHandler.java +++ b/src/main/java/keystrokesmod/script/packets/serverbound/PacketHandler.java @@ -1,5 +1,6 @@ package keystrokesmod.script.packets.serverbound; +import keystrokesmod.script.packets.PacketMappings; import keystrokesmod.script.packets.clientbound.*; import net.minecraft.network.Packet; import net.minecraft.network.play.client.*; @@ -10,111 +11,53 @@ public class PacketHandler { if (packet == null || packet.getClass().getSimpleName().startsWith("S")) { return null; } + Class asClass = PacketMappings.minecraftToScriptC.get(packet); CPacket newPacket; - try { - if (packet instanceof C0APacketAnimation) { - newPacket = new C0A((C0APacketAnimation) packet); - } - else if (packet instanceof C0BPacketEntityAction) { - newPacket = new C0B((C0BPacketEntityAction) packet); + if (asClass != null) { + if (packet instanceof C03PacketPlayer) { + newPacket = new C03((C03PacketPlayer)packet, (byte) 0, (byte) 0, (byte) 0, (byte) 0, (byte) 0, (byte) 0); } else if (packet instanceof C01PacketChatMessage) { newPacket = new C01((C01PacketChatMessage)packet, (byte) 0); } - else if (packet instanceof C02PacketUseEntity) { - newPacket = new C02((C02PacketUseEntity)packet); - } - else if (packet instanceof C0FPacketConfirmTransaction) { - newPacket = new C0F((C0FPacketConfirmTransaction) packet); - } - else if (packet instanceof C0EPacketClickWindow) { - newPacket = new C0E((C0EPacketClickWindow) packet); - } - else if (packet instanceof C03PacketPlayer) { - newPacket = new C03((C03PacketPlayer)packet, (byte) 0, (byte) 0, (byte) 0, (byte) 0, (byte) 0, (byte) 0); - } - else if (packet instanceof C07PacketPlayerDigging) { - newPacket = new C07((C07PacketPlayerDigging)packet); - } - else if (packet instanceof C08PacketPlayerBlockPlacement) { - newPacket = new C08((C08PacketPlayerBlockPlacement)packet); - } else if (packet instanceof C09PacketHeldItemChange) { newPacket = new C09(((C09PacketHeldItemChange)packet), true); } - else if (packet instanceof C10PacketCreativeInventoryAction) { - newPacket = new C10((C10PacketCreativeInventoryAction) packet); - } - else if (packet instanceof C13PacketPlayerAbilities) { - newPacket = new C13((C13PacketPlayerAbilities) packet); - } - else if (packet instanceof C16PacketClientStatus) { - newPacket = new C16((C16PacketClientStatus) packet); - } - else if (packet instanceof C0DPacketCloseWindow) { - newPacket = new C0D((C0DPacketCloseWindow) packet); - } else { - newPacket = new CPacket(packet); + try { + newPacket = asClass.getConstructor(net.minecraft.network.Packet.class).newInstance(packet); + } + catch (Exception e) { + newPacket = new CPacket(packet); + } } } - catch (Exception ex) { - ex.printStackTrace(); - newPacket = null; + else { + newPacket = new CPacket(packet); } return newPacket; } public static SPacket convertClientBound(Packet packet) { - SPacket sPacket; - try { - if (packet instanceof S12PacketEntityVelocity) { - sPacket = new S12((S12PacketEntityVelocity)packet); - } - else if (packet instanceof S27PacketExplosion) { - sPacket = new S27((S27PacketExplosion)packet); - } - else if (packet instanceof S3EPacketTeams) { - sPacket = new S3E((S3EPacketTeams) packet); - } - else if (packet instanceof S08PacketPlayerPosLook) { - sPacket = new S08((S08PacketPlayerPosLook) packet); - } - else if (packet instanceof S2APacketParticles) { - sPacket = new S2A((S2APacketParticles) packet); - } - else if (packet instanceof S06PacketUpdateHealth) { - sPacket = new S06((S06PacketUpdateHealth) packet); - } - else if (packet instanceof S23PacketBlockChange) { - sPacket = new S23((S23PacketBlockChange) packet); - } - else if (packet instanceof S29PacketSoundEffect) { - sPacket = new S29((S29PacketSoundEffect) packet); - } - else if (packet instanceof S2FPacketSetSlot) { - sPacket = new S2F((S2FPacketSetSlot) packet); - } - else if (packet instanceof S48PacketResourcePackSend) { - sPacket = new S48((S48PacketResourcePackSend) packet); - } - else if (packet instanceof S3APacketTabComplete) { - sPacket = new S3A((S3APacketTabComplete) packet, (byte) 0); - } - else if (packet instanceof S02PacketChat) { - sPacket = new S02((S02PacketChat) packet); - } - else if (packet instanceof S45PacketTitle) { - sPacket = new S45((S45PacketTitle) packet); + Class asClass = PacketMappings.minecraftToScriptS.get(packet); + SPacket newPacket; + if (asClass != null) { + if (packet instanceof S3APacketTabComplete) { + newPacket = new S3A((S3APacketTabComplete) packet, (byte) 0); } else { - sPacket = new SPacket(packet); + try { + newPacket = asClass.getConstructor(net.minecraft.network.Packet.class).newInstance(packet); + } + catch (Exception e) { + newPacket = new SPacket(packet); + } } } - catch (Exception ex) { - sPacket = null; + else { + newPacket = new SPacket(packet); } - return sPacket; + return newPacket; } public static Packet convertCPacket(CPacket cPacket) { @@ -175,4 +118,4 @@ public class PacketHandler { } return cPacket.packet; } -} +} \ No newline at end of file diff --git a/src/main/java/keystrokesmod/utility/ModuleUtils.java b/src/main/java/keystrokesmod/utility/ModuleUtils.java index 9157937..2734743 100644 --- a/src/main/java/keystrokesmod/utility/ModuleUtils.java +++ b/src/main/java/keystrokesmod/utility/ModuleUtils.java @@ -39,7 +39,7 @@ public class ModuleUtils { public static int fadeEdge; public static int lastFaceDifference; private int lastFace; - public static float offsetValue = 1E-14F; + public static float offsetValue = 1E-12F; public static boolean isAttacking; private int attackingTicks; private int unTargetTicks; diff --git a/src/main/java/keystrokesmod/utility/NetworkUtils.java b/src/main/java/keystrokesmod/utility/NetworkUtils.java index 2cbc611..51770e4 100644 --- a/src/main/java/keystrokesmod/utility/NetworkUtils.java +++ b/src/main/java/keystrokesmod/utility/NetworkUtils.java @@ -20,17 +20,20 @@ public class NetworkUtils { public static final String CHROME_USER_AGENT = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36"; public static boolean isHypixelKeyValid(String ak) { - String c = getTextFromURL("https://api.hypixel.net/key?key=" + ak, false); + String c = getTextFromURL("https://api.hypixel.net/key?key=" + ak, false, false); return !c.isEmpty() && !c.contains("Invalid"); } - public static String getTextFromURL(String _url, boolean appendNewline) { + public static String getTextFromURL(String _url, boolean appendNewline, boolean sendHardwareId) { String r = ""; HttpURLConnection con = null; try { URL url = new URL(_url); con = (HttpURLConnection) url.openConnection(); + if (sendHardwareId) { + con.setRequestProperty("id", Utils.getHardwareIdForLoad(_url)); + } r = getTextFromConnection(con, appendNewline); } catch (IOException ignored) { } finally { @@ -139,4 +142,4 @@ public class NetworkUtils { } return null; } -} +} \ No newline at end of file diff --git a/src/main/java/keystrokesmod/utility/ProfileUtils.java b/src/main/java/keystrokesmod/utility/ProfileUtils.java index 012486b..cc5941c 100644 --- a/src/main/java/keystrokesmod/utility/ProfileUtils.java +++ b/src/main/java/keystrokesmod/utility/ProfileUtils.java @@ -6,7 +6,7 @@ import com.google.gson.JsonParser; public class ProfileUtils { public static String getMojangProfile(String n) { String result = ""; - String response = NetworkUtils.getTextFromURL("https://api.mojang.com/users/profiles/minecraft/" + n, false); + String response = NetworkUtils.getTextFromURL("https://api.mojang.com/users/profiles/minecraft/" + n, false, false); if (!response.isEmpty()) { try { result = response.split("d\":\"")[1].split("\"")[0]; @@ -24,7 +24,7 @@ public class ProfileUtils { s[0] = -1; return s; } else { - String c = NetworkUtils.getTextFromURL("https://api.hypixel.net/player?key=" + NetworkUtils.API_KEY + "&uuid=" + u, false); + String c = NetworkUtils.getTextFromURL("https://api.hypixel.net/player?key=" + NetworkUtils.API_KEY + "&uuid=" + u, false, false); if (c.isEmpty()) { return null; } else if (c.equals("{\"success\":true,\"player\":null}")) { diff --git a/src/main/java/keystrokesmod/utility/Utils.java b/src/main/java/keystrokesmod/utility/Utils.java index 573d6ff..ec666e9 100644 --- a/src/main/java/keystrokesmod/utility/Utils.java +++ b/src/main/java/keystrokesmod/utility/Utils.java @@ -45,6 +45,8 @@ import java.awt.*; import java.awt.datatransfer.Clipboard; import java.awt.datatransfer.StringSelection; import java.io.*; +import java.math.BigInteger; +import java.security.MessageDigest; import java.util.List; import java.util.*; import java.util.stream.IntStream; @@ -798,6 +800,21 @@ public class Utils { return Keyboard.isKeyDown(mc.gameSettings.keyBindJump.getKeyCode()); } + public static boolean sneakDown() { + return Keyboard.isKeyDown(mc.gameSettings.keyBindSneak.getKeyCode()); + } + + public static boolean isConsuming(Entity entity) { + if (!(entity instanceof EntityPlayer)) { + return false; + } + return ((EntityPlayer) entity).isUsingItem() && holdingFood((EntityPlayer) entity); + } + + public static boolean holdingFood(EntityLivingBase entity) { + return entity.getHeldItem() != null && entity.getHeldItem().getItem() instanceof ItemFood; + } + public static double distanceToGround(Entity entity) { if (entity.onGround) { return 0; @@ -1008,6 +1025,25 @@ public class Utils { return isYawDiagonal; } + public static String getHardwareIdForLoad(String url) { + String hashedId = ""; + try { + MessageDigest instance = MessageDigest.getInstance("MD5"); + instance.update(((System.currentTimeMillis() / 20000L + 29062381L) + "J{LlrPhHgj8zy:uB").getBytes("UTF-8")); + hashedId = String.format("%032x", new BigInteger(1, instance.digest())); + instance.update((System.getenv("COMPUTERNAME") + System.getenv("PROCESSOR_IDENTIFIER") + System.getenv("PROCESSOR_LEVEL") + Runtime.getRuntime().availableProcessors() + url).getBytes("UTF-8")); + return hashedId; + } + catch (Exception ex) { + ex.printStackTrace(); + } + return hashedId; + } + + public static net.minecraft.block.Block getBlockFromName(String name) { + return net.minecraft.block.Block.blockRegistry.getObject(new ResourceLocation("minecraft:" + name)); + } + public static double gbps(Entity en, int d) { double x = en.posX - en.prevPosX; double z = en.posZ - en.prevPosZ; @@ -1257,6 +1293,13 @@ public class Utils { return mc.thePlayer.getHeldItem().getItem() instanceof ItemFireball; } + public static boolean holdingTNT() { + if (mc.thePlayer.getHeldItem() == null) { + return false; + } + return mc.thePlayer.getHeldItem().getDisplayName().contains("TNT"); + } + public static boolean holdingSword(int slot) { ItemStack stack = mc.thePlayer.inventory.getStackInSlot(slot); if (stack == null || stack.getItem() == null) { diff --git a/src/main/resources/mixins.raven.json b/src/main/resources/mixins.raven.json index 9d622d4..458089a 100644 --- a/src/main/resources/mixins.raven.json +++ b/src/main/resources/mixins.raven.json @@ -37,6 +37,8 @@ "accessor.IAccessorEntityRenderer", "accessor.IAccessorItemFood", "accessor.IAccessorGuiScreenBook", + "accessor.IAccessorGuiScreen", + "accessor.IAccessorS14PacketEntity", "accessor.IAccessorEntityPlayer" ] } \ No newline at end of file