diff --git a/build.gradle b/build.gradle index 4e70812..c93c5aa 100644 --- a/build.gradle +++ b/build.gradle @@ -35,7 +35,7 @@ minecraft { version = "1.8.9-11.15.1.2318-1.8.9" runDir = "run" - mappings = "stable_20" + mappings = "stable_22" makeObfSourceJar = false clientJvmArgs += '-Dfml.coreMods.load=keystrokesmod.mixins.MixinLoader' } diff --git a/src/main/java/keystrokesmod/Raven.java b/src/main/java/keystrokesmod/Raven.java index 62cb0be..7d728b9 100644 --- a/src/main/java/keystrokesmod/Raven.java +++ b/src/main/java/keystrokesmod/Raven.java @@ -9,6 +9,8 @@ import keystrokesmod.keystroke.keystrokeCommand; import keystrokesmod.module.Module; import keystrokesmod.clickgui.ClickGui; import keystrokesmod.module.ModuleManager; +import keystrokesmod.script.classes.Entity; +import keystrokesmod.script.classes.NetworkPlayer; import keystrokesmod.utility.ModuleUtils; import keystrokesmod.script.ScriptManager; import keystrokesmod.utility.*; @@ -84,6 +86,10 @@ public class Raven { public void onTick(ClientTickEvent e) { if (e.phase == Phase.END) { if (Utils.nullCheck()) { + if (mc.thePlayer.ticksExisted % 6000 == 0) { // reset cache every 5 minutes + Entity.clearCache(); + NetworkPlayer.clearCache(); + } if (Reflection.sendMessage) { Utils.sendMessage("&cThere was an error, relaunch the game."); Reflection.sendMessage = false; @@ -119,9 +125,13 @@ public class Raven { @SubscribeEvent public void onEntityJoinWorld(EntityJoinWorldEvent e) { - if (e.entity == mc.thePlayer && !firstLoad) { - firstLoad = true; - scriptManager.loadScripts(); + if (e.entity == mc.thePlayer) { + if (!firstLoad) { + firstLoad = true; + scriptManager.loadScripts(); + } + Entity.clearCache(); + NetworkPlayer.clearCache(); } } diff --git a/src/main/java/keystrokesmod/clickgui/components/Component.java b/src/main/java/keystrokesmod/clickgui/components/Component.java index acc94f1..39a9114 100644 --- a/src/main/java/keystrokesmod/clickgui/components/Component.java +++ b/src/main/java/keystrokesmod/clickgui/components/Component.java @@ -1,6 +1,14 @@ package keystrokesmod.clickgui.components; public class Component { + + public boolean isVisible = true; + + public boolean isVisible() { + + return isVisible; + } + public void render() { } diff --git a/src/main/java/keystrokesmod/clickgui/components/impl/BindComponent.java b/src/main/java/keystrokesmod/clickgui/components/impl/BindComponent.java index c8df042..932d85a 100644 --- a/src/main/java/keystrokesmod/clickgui/components/impl/BindComponent.java +++ b/src/main/java/keystrokesmod/clickgui/components/impl/BindComponent.java @@ -39,6 +39,9 @@ public class BindComponent extends Component { } public void render() { + if (!isVisible()) { + this.o = this.o - 12; + } GL11.glPushMatrix(); GL11.glScaled(0.5D, 0.5D, 0.5D); if (keySetting == null) { @@ -136,4 +139,10 @@ public class BindComponent extends Component { public void onGuiClosed() { this.isBinding = false; } -} + + @Override + public boolean isVisible() { + return keySetting == null || keySetting.isVisible; + } + +} \ No newline at end of file diff --git a/src/main/java/keystrokesmod/clickgui/components/impl/ButtonComponent.java b/src/main/java/keystrokesmod/clickgui/components/impl/ButtonComponent.java index 584697d..7b36847 100644 --- a/src/main/java/keystrokesmod/clickgui/components/impl/ButtonComponent.java +++ b/src/main/java/keystrokesmod/clickgui/components/impl/ButtonComponent.java @@ -29,6 +29,9 @@ public class ButtonComponent extends Component { } public void render() { + if (!isVisible()) { + this.o = this.o - 12; + } GL11.glPushMatrix(); GL11.glScaled(0.5D, 0.5D, 0.5D); Minecraft.getMinecraft().fontRendererObj.drawString((this.buttonSetting.isMethodButton ? "[=] " : (this.buttonSetting.isToggled() ? "[+] " : "[-] ")) + this.buttonSetting.getName(), (float) ((this.p.categoryComponent.getX() + 4) * 2), (float) ((this.p.categoryComponent.getY() + this.o + 4) * 2), this.buttonSetting.isToggled() ? this.c : -1, false); @@ -62,4 +65,10 @@ public class ButtonComponent extends Component { public boolean i(int x, int y) { return x > this.x && x < this.x + this.p.categoryComponent.getWidth() && y > this.y && y < this.y + 11; } -} + + @Override + public boolean isVisible() { + return buttonSetting == null || buttonSetting.isVisible; + } + +} \ No newline at end of file diff --git a/src/main/java/keystrokesmod/clickgui/components/impl/ModuleComponent.java b/src/main/java/keystrokesmod/clickgui/components/impl/ModuleComponent.java index f9e1d22..cb5b929 100644 --- a/src/main/java/keystrokesmod/clickgui/components/impl/ModuleComponent.java +++ b/src/main/java/keystrokesmod/clickgui/components/impl/ModuleComponent.java @@ -51,24 +51,36 @@ public class ModuleComponent extends Component { if (v instanceof SliderSetting) { SliderSetting n = (SliderSetting) v; SliderComponent s = new SliderComponent(n, this, y); + if (!s.isVisible()) { + continue; + } this.settings.add(s); y += 12; } else if (v instanceof ButtonSetting) { ButtonSetting b = (ButtonSetting) v; ButtonComponent c = new ButtonComponent(mod, b, this, y); + if (!c.isVisible()) { + continue; + } this.settings.add(c); y += 12; } else if (v instanceof DescriptionSetting) { DescriptionSetting d = (DescriptionSetting) v; DescriptionComponent m = new DescriptionComponent(d, this, y); + if (!m.isVisible()) { + continue; + } this.settings.add(m); y += 12; } else if (v instanceof KeySetting) { KeySetting setting = (KeySetting) v; BindComponent keyComponent = new BindComponent(this, setting, y); + if (!keyComponent.isVisible()) { + continue; + } this.settings.add(keyComponent); y += 12; } @@ -85,6 +97,9 @@ public class ModuleComponent extends Component { while (true) { while (var3.hasNext()) { Component co = (Component) var3.next(); + if (!co.isVisible()) { + continue; + } co.updateHeight(y); if (co instanceof SliderComponent) { y += 16; @@ -190,6 +205,9 @@ public class ModuleComponent extends Component { if (this.isOpened || smoothTimer != null) { for (Component settingComponent : this.settings) { + if (!settingComponent.isVisible()) { + continue; + } settingComponent.render(); } } @@ -214,6 +232,9 @@ public class ModuleComponent extends Component { while (true) { while (var2.hasNext()) { Component c = (Component) var2.next(); + if (!c.isVisible()) { + continue; + } if (c instanceof SliderComponent) { h += 16; } @@ -234,6 +255,9 @@ public class ModuleComponent extends Component { while (true) { while (var2.hasNext()) { Component c = (Component) var2.next(); + if (!c.isVisible()) { + continue; + } if (c instanceof SliderComponent) { h += 16; } diff --git a/src/main/java/keystrokesmod/clickgui/components/impl/SliderComponent.java b/src/main/java/keystrokesmod/clickgui/components/impl/SliderComponent.java index 436b3c9..80f2cb2 100644 --- a/src/main/java/keystrokesmod/clickgui/components/impl/SliderComponent.java +++ b/src/main/java/keystrokesmod/clickgui/components/impl/SliderComponent.java @@ -33,6 +33,9 @@ public class SliderComponent extends Component { } public void render() { + if (!isVisible()) { + this.o = this.o - 12; + } RenderUtils.drawRoundedRectangle(this.moduleComponent.categoryComponent.getX() + 4, this.moduleComponent.categoryComponent.getY() + this.o + 11, this.moduleComponent.categoryComponent.getX() + 4 + this.moduleComponent.categoryComponent.getWidth() - 8, this.moduleComponent.categoryComponent.getY() + this.o + 15, 4, -12302777); int l = this.moduleComponent.categoryComponent.getX() + 4; int r = this.moduleComponent.categoryComponent.getX() + 4 + (int) this.w; @@ -129,4 +132,10 @@ public class SliderComponent extends Component { public void onGuiClosed() { this.heldDown = false; } -} + + @Override + public boolean isVisible() { + return sliderSetting == null || sliderSetting.isVisible; + } + +} \ No newline at end of file diff --git a/src/main/java/keystrokesmod/mixins/impl/entity/MixinEntityPlayer.java b/src/main/java/keystrokesmod/mixins/impl/entity/MixinEntityPlayer.java index 605442f..c187b2e 100644 --- a/src/main/java/keystrokesmod/mixins/impl/entity/MixinEntityPlayer.java +++ b/src/main/java/keystrokesmod/mixins/impl/entity/MixinEntityPlayer.java @@ -4,26 +4,13 @@ import keystrokesmod.module.ModuleManager; import keystrokesmod.module.impl.combat.Reduce; import keystrokesmod.module.impl.movement.KeepSprint; import net.minecraft.client.Minecraft; -import net.minecraft.enchantment.EnchantmentHelper; import net.minecraft.entity.*; -import net.minecraft.entity.boss.EntityDragonPart; import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.item.ItemStack; -import net.minecraft.network.play.server.S12PacketEntityVelocity; -import net.minecraft.potion.Potion; -import net.minecraft.stats.AchievementList; -import net.minecraft.stats.StatBase; -import net.minecraft.stats.StatList; -import net.minecraft.util.DamageSource; -import net.minecraft.util.MathHelper; import net.minecraft.world.World; -import net.minecraftforge.common.ForgeHooks; import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Overwrite; import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.*; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; @Mixin(EntityPlayer.class) @@ -31,144 +18,26 @@ public abstract class MixinEntityPlayer extends EntityLivingBase { public MixinEntityPlayer(World p_i1594_1_) { super(p_i1594_1_); } - @Shadow public abstract ItemStack getHeldItem(); - @Shadow - public abstract void onCriticalHit(Entity p_onCriticalHit_1_); - - @Shadow - public abstract void onEnchantmentCritical(Entity p_onEnchantmentCritical_1_); - - @Shadow - public abstract void triggerAchievement(StatBase p_triggerAchievement_1_); - - @Shadow - public abstract ItemStack getCurrentEquippedItem(); - - @Shadow - public abstract void destroyCurrentEquippedItem(); - - @Shadow - public abstract void addStat(StatBase p_addStat_1_, int p_addStat_2_); - - @Shadow - public abstract void addExhaustion(float p_addExhaustion_1_); - @Shadow - private ItemStack itemInUse; - @Shadow - public abstract boolean isUsingItem(); - - @Overwrite - public void attackTargetEntityWithCurrentItem(Entity p_attackTargetEntityWithCurrentItem_1_) { - if (ForgeHooks.onPlayerAttackTarget(((EntityPlayer) (Object) this), p_attackTargetEntityWithCurrentItem_1_)) { - if (p_attackTargetEntityWithCurrentItem_1_.canAttackWithItem() && !p_attackTargetEntityWithCurrentItem_1_.hitByEntity(this)) { - float f = (float) this.getEntityAttribute(SharedMonsterAttributes.attackDamage).getAttributeValue(); - int i = 0; - float f1 = 0.0F; - if (p_attackTargetEntityWithCurrentItem_1_ instanceof EntityLivingBase) { - f1 = EnchantmentHelper.func_152377_a(this.getHeldItem(), ((EntityLivingBase) p_attackTargetEntityWithCurrentItem_1_).getCreatureAttribute()); - } else { - f1 = EnchantmentHelper.func_152377_a(this.getHeldItem(), EnumCreatureAttribute.UNDEFINED); - } - - i += EnchantmentHelper.getKnockbackModifier(this); - if (this.isSprinting()) { - ++i; - } - - if (f > 0.0F || f1 > 0.0F) { - boolean flag = this.fallDistance > 0.0F && !this.onGround && !this.isOnLadder() && !this.isInWater() && !this.isPotionActive(Potion.blindness) && this.ridingEntity == null && p_attackTargetEntityWithCurrentItem_1_ instanceof EntityLivingBase; - if (flag && f > 0.0F) { - f *= 1.5F; - } - - f += f1; - boolean flag1 = false; - int j = EnchantmentHelper.getFireAspectModifier(this); - if (p_attackTargetEntityWithCurrentItem_1_ instanceof EntityLivingBase && j > 0 && !p_attackTargetEntityWithCurrentItem_1_.isBurning()) { - flag1 = true; - p_attackTargetEntityWithCurrentItem_1_.setFire(1); - } - - double d0 = p_attackTargetEntityWithCurrentItem_1_.motionX; - double d1 = p_attackTargetEntityWithCurrentItem_1_.motionY; - double d2 = p_attackTargetEntityWithCurrentItem_1_.motionZ; - boolean flag2 = p_attackTargetEntityWithCurrentItem_1_.attackEntityFrom(DamageSource.causePlayerDamage(((EntityPlayer) (Object) this)), f); - if (flag2) { - if (i > 0) { - p_attackTargetEntityWithCurrentItem_1_.addVelocity((double) (-MathHelper.sin(this.rotationYaw * 3.1415927F / 180.0F) * (float) i * 0.5F), 0.1, (double) (MathHelper.cos(this.rotationYaw * 3.1415927F / 180.0F) * (float) i * 0.5F)); - if (ModuleManager.reduce != null && ModuleManager.reduce.isEnabled()) { - Reduce.reduce(p_attackTargetEntityWithCurrentItem_1_); - } - else if (ModuleManager.keepSprint != null && ModuleManager.keepSprint.isEnabled()) { - KeepSprint.keepSprint(p_attackTargetEntityWithCurrentItem_1_); - } - else { - this.motionX *= 0.6D; - this.motionZ *= 0.6D; - this.setSprinting(false); - } - } - - if (p_attackTargetEntityWithCurrentItem_1_ instanceof EntityPlayerMP && p_attackTargetEntityWithCurrentItem_1_.velocityChanged) { - ((EntityPlayerMP) p_attackTargetEntityWithCurrentItem_1_).playerNetServerHandler.sendPacket(new S12PacketEntityVelocity(p_attackTargetEntityWithCurrentItem_1_)); - p_attackTargetEntityWithCurrentItem_1_.velocityChanged = false; - p_attackTargetEntityWithCurrentItem_1_.motionX = d0; - p_attackTargetEntityWithCurrentItem_1_.motionY = d1; - p_attackTargetEntityWithCurrentItem_1_.motionZ = d2; - } - - if (flag) { - this.onCriticalHit(p_attackTargetEntityWithCurrentItem_1_); - } - - if (f1 > 0.0F) { - this.onEnchantmentCritical(p_attackTargetEntityWithCurrentItem_1_); - } - - if (f >= 18.0F) { - this.triggerAchievement(AchievementList.overkill); - } - - this.setLastAttacker(p_attackTargetEntityWithCurrentItem_1_); - if (p_attackTargetEntityWithCurrentItem_1_ instanceof EntityLivingBase) { - EnchantmentHelper.applyThornEnchantments((EntityLivingBase) p_attackTargetEntityWithCurrentItem_1_, this); - } - - EnchantmentHelper.applyArthropodEnchantments(this, p_attackTargetEntityWithCurrentItem_1_); - ItemStack itemstack = this.getCurrentEquippedItem(); - Entity entity = p_attackTargetEntityWithCurrentItem_1_; - if (p_attackTargetEntityWithCurrentItem_1_ instanceof EntityDragonPart) { - IEntityMultiPart ientitymultipart = ((EntityDragonPart) p_attackTargetEntityWithCurrentItem_1_).entityDragonObj; - if (ientitymultipart instanceof EntityLivingBase) { - entity = (EntityLivingBase) ientitymultipart; - } - } - - if (itemstack != null && entity instanceof EntityLivingBase) { - itemstack.hitEntity((EntityLivingBase) entity, ((EntityPlayer) (Object) this)); - if (itemstack.stackSize <= 0) { - this.destroyCurrentEquippedItem(); - } - } - - if (p_attackTargetEntityWithCurrentItem_1_ instanceof EntityLivingBase) { - this.addStat(StatList.damageDealtStat, Math.round(f * 10.0F)); - if (j > 0) { - p_attackTargetEntityWithCurrentItem_1_.setFire(j * 4); - } - } - - this.addExhaustion(0.3F); - } else if (flag1) { - p_attackTargetEntityWithCurrentItem_1_.extinguish(); - } - } - } - + @ModifyConstant(method = "attackTargetEntityWithCurrentItem", constant = @Constant(doubleValue = 0.6)) + private double multiplyMotion(final double originalValue) { + if (ModuleManager.reduce != null && ModuleManager.reduce.isEnabled()) { + return Reduce.getReduceMotion(); } + else if (ModuleManager.keepSprint != null && ModuleManager.keepSprint.isEnabled()) { + return KeepSprint.getKeepSprintMotion(); + } + return originalValue; + } + + @Redirect(method = "attackTargetEntityWithCurrentItem", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/player/EntityPlayer;setSprinting(Z)V")) + public void setSprinting(final EntityPlayer entityPlayer, final boolean sprinting) { + if (ModuleManager.keepSprint != null && ModuleManager.keepSprint.isEnabled()) { + return; + } + entityPlayer.setSprinting(sprinting); } @Inject(method = "isBlocking", at = @At("RETURN"), cancellable = true) @@ -179,4 +48,4 @@ public abstract class MixinEntityPlayer extends EntityLivingBase { cir.setReturnValue(cir.getReturnValue()); } -} +} \ No newline at end of file diff --git a/src/main/java/keystrokesmod/mixins/impl/entity/MixinEntityPlayerSP.java b/src/main/java/keystrokesmod/mixins/impl/entity/MixinEntityPlayerSP.java index 7b3bbe9..cab9554 100644 --- a/src/main/java/keystrokesmod/mixins/impl/entity/MixinEntityPlayerSP.java +++ b/src/main/java/keystrokesmod/mixins/impl/entity/MixinEntityPlayerSP.java @@ -289,7 +289,7 @@ public abstract class MixinEntityPlayerSP extends AbstractClientPlayer { this.setSprinting(true); } - if (this.isSprinting() && (!ModuleManager.sprint.omniSprint() && !NoSlow.groundSpeed() && (this.movementInput.moveForward < f || !flag3)) || this.isCollidedHorizontally || this.mc.gameSettings.keyBindSneak.isKeyDown() || (ModuleManager.scaffold != null && ModuleManager.scaffold.isEnabled && (!ModuleManager.scaffold.sprint() || ModuleManager.tower.canTower())) || (ModuleManager.wTap.isEnabled() && WTap.stopSprint)) { + if (this.isSprinting() && (!ModuleManager.sprint.omniSprint() && !NoSlow.groundSpeed() && (this.movementInput.moveForward < f || !flag3)) || this.isCollidedHorizontally || ModuleManager.sprint.disableBack || this.mc.gameSettings.keyBindSneak.isKeyDown() || (ModuleManager.scaffold != null && ModuleManager.scaffold.isEnabled && (!ModuleManager.scaffold.sprint() || ModuleManager.tower.canTower())) || (ModuleManager.wTap.isEnabled() && WTap.stopSprint)) { this.setSprinting(false); WTap.stopSprint = false; } diff --git a/src/main/java/keystrokesmod/module/impl/combat/KillAura.java b/src/main/java/keystrokesmod/module/impl/combat/KillAura.java index 56358c5..9878b1b 100644 --- a/src/main/java/keystrokesmod/module/impl/combat/KillAura.java +++ b/src/main/java/keystrokesmod/module/impl/combat/KillAura.java @@ -64,7 +64,7 @@ public class KillAura extends Module { private ButtonSetting silentSwing; private ButtonSetting weaponOnly; - private String[] autoBlockModes = new String[] { "Manual", "Vanilla", "Partial", "Interact A", "Interact B", "Hypixel", "Hypixel 2" }; + private String[] autoBlockModes = new String[] { "Manual", "Vanilla", "Partial", "Interact A", "Interact B", "Hypixel A", "Hypixel B" }; private String[] rotationModes = new String[] { "Silent", "Lock view", "None" }; private String[] sortModes = new String[] { "Distance", "Health", "Hurttime", "Yaw" }; @@ -90,6 +90,8 @@ public class KillAura extends Module { private int partialTicks; private int firstEdge; private boolean blocked; + private boolean canUse; + private boolean canBlockServerside; // blink related private ConcurrentLinkedQueue blinkedPackets = new ConcurrentLinkedQueue<>(); @@ -110,6 +112,7 @@ public class KillAura extends Module { private boolean lastPressedLeft; private boolean lastPressedRight; private boolean sendDig = true; + private boolean usedWhileTargeting; public KillAura() { super("KillAura", category.combat); @@ -178,10 +181,39 @@ public class KillAura extends Module { @SubscribeEvent public void onPreUpdate(PreUpdateEvent e) { - if (sendDig && !isTargeting) { - sendDigPacket(); - sendDig = false; + + if (blinkAutoBlock()) { + EntityLivingBase g = Utils.raytrace(3); + if ((g != null || BlockUtils.isInteractable(mc.objectMouseOver)) && Utils.holdingSword()) { + canUse = Mouse.isButtonDown(1); + } + else if (canUse) { + KeyBinding.setKeyBindState(mc.gameSettings.keyBindUseItem.getKeyCode(), false); + canUse = false; + } + if (Utils.holdingSword()) { + if (Mouse.isButtonDown(1) && Utils.tabbedIn()) { + Reflection.setItemInUse(this.blockingClient = true); + canBlockServerside = (target == null); + } + else if (canBlockServerside) { + Reflection.setItemInUse(this.blockingClient = false); + canBlockServerside = false; + } + } + if (target == null) { + if (usedWhileTargeting) { + if (!Utils.holdingSword()) KeyBinding.setKeyBindState(mc.gameSettings.keyBindUseItem.getKeyCode(), Mouse.isButtonDown(1)); + usedWhileTargeting = false; + } + } + else { + KeyBinding.setKeyBindState(mc.gameSettings.keyBindUseItem.getKeyCode(), false); + usedWhileTargeting = Mouse.isButtonDown(1); + canBlockServerside = false; + } } + if (mc.currentScreen == null || mc.currentScreen.allowUserInput) { boolean pressedLeft = Mouse.isButtonDown(0); if (pressedLeft && !lastPressedLeft) { @@ -202,6 +234,10 @@ public class KillAura extends Module { } lastPressedLeft = pressedLeft; } + if (sendDig && !isTargeting && !ModuleManager.bedAura.stopAutoblock) { + sendDigPacket(); + sendDig = false; + } /*if (sendUnBlock) { Reflection.setItemInUse(blockingClient = false); sendDigPacket(); @@ -378,7 +414,7 @@ public class KillAura extends Module { } } if (blinking.get() && !e.isCanceled()) { // blink - if (packet instanceof C00PacketLoginStart || packet instanceof C00Handshake) { + if (packet instanceof C00PacketKeepAlive || packet instanceof C00PacketLoginStart || packet instanceof C00Handshake) { return; } blinkedPackets.add(packet); @@ -389,12 +425,16 @@ public class KillAura extends Module { @SubscribeEvent public void onMouse(MouseEvent e) { if (e.button == 0 || e.button == 1) { + if (e.button == 1) { + EntityLivingBase g = Utils.raytrace(3); + if (blinkAutoBlock() && Utils.holdingSword() && g == null && !BlockUtils.isInteractable(mc.objectMouseOver)) { + e.setCanceled(true); + } + } if (!Utils.holdingWeapon() || target == null) { return; } e.setCanceled(true); - KeyBinding.setKeyBindState(mc.gameSettings.keyBindUseItem.getKeyCode(), false); - //hypixUtils.print("Set false?"); } } @@ -467,7 +507,7 @@ public class KillAura extends Module { private void setTarget(Entity entity) { if (entity == null || !(entity instanceof EntityLivingBase)) { if (blockingClient) { - Reflection.setItemInUse(blockingClient = false); + //Reflection.setItemInUse(blockingClient = false); sendUnBlock = true; } if (blinking.get() || lag) { @@ -665,11 +705,11 @@ public class KillAura extends Module { } return; } - if (this.blockingClient == blockState && autoBlockMode.getInput() != 3) { + if (blinkAutoBlock() && target == null) { return; } if (autoBlockMode.getInput() != previousAutoBlockMode) { - if (previousAutoBlockMode == 4 || previousAutoBlockMode == 5 || previousAutoBlockMode == 6) { // if == interact + if (previousAutoBlockMode == 3 || previousAutoBlockMode == 4 || previousAutoBlockMode == 5 || previousAutoBlockMode == 6) { // if == interact resetBlinkState(true); } } @@ -698,8 +738,8 @@ public class KillAura extends Module { break; case 3: // interact a case 4: // interact b - case 5: // hypixel - case 6: // hypixel 2 + case 5: // hypixel a + case 6: // hypixel b Reflection.setItemInUse(this.blockingClient = blockState); break; } @@ -724,7 +764,7 @@ public class KillAura extends Module { } public boolean blinkAutoBlock() { - return (autoBlockMode.getInput() == 4 || autoBlockMode.getInput() == 5 || autoBlockMode.getInput() == 6); + return (autoBlockMode.getInput() == 3 || autoBlockMode.getInput() == 4 || autoBlockMode.getInput() == 5 || autoBlockMode.getInput() == 6); } private float unwrapYaw(float yaw, float prevYaw) { @@ -763,13 +803,13 @@ public class KillAura extends Module { interactTicks++; switch (interactTicks) { case 1: + blinking.set(true); if (lag) { mc.thePlayer.sendQueue.addToSendQueue(new C07PacketPlayerDigging(C07PacketPlayerDigging.Action.RELEASE_USE_ITEM, BlockPos.ORIGIN, DOWN)); blocked = false; } break; case 2: - blinking.set(true); handleInteractAndAttack(distance, true, true, swung); sendBlockPacket(); blocked = true; @@ -785,17 +825,18 @@ public class KillAura extends Module { interactTicks++; switch (interactTicks) { case 1: + blinking.set(true); if (lag) { setSwapSlot(); - swapped = blocked = false; + blocked = false; + swapped = true; } break; case 2: if (lag) { setCurrentSlot(); - swapped = true; + swapped = false; } - blinking.set(true); handleInteractAndAttack(distance, true, true, swung); sendBlockPacket(); blocked = true; @@ -804,20 +845,20 @@ public class KillAura extends Module { break; } break; - case 5: // hypixel + case 5: // hypixel a if (interactTicks >= 3) { interactTicks = 0; } interactTicks++; switch (interactTicks) { case 1: + blinking.set(true); if (lag) { mc.thePlayer.sendQueue.addToSendQueue(new C07PacketPlayerDigging(C07PacketPlayerDigging.Action.RELEASE_USE_ITEM, BlockPos.ORIGIN, DOWN)); blocked = false; } break; case 2: - blinking.set(true); handleInteractAndAttack(distance, true, true, swung); sendBlockPacket(); blocked = true; @@ -826,7 +867,7 @@ public class KillAura extends Module { break; } break; - case 6: // hypixel 2 + case 6: // hypixel b if (interactTicks >= 3) { interactTicks = 0; } @@ -834,13 +875,13 @@ public class KillAura extends Module { if (!firstCycle) { switch (interactTicks) { case 1: + blinking.set(true); if (lag) { mc.thePlayer.sendQueue.addToSendQueue(new C07PacketPlayerDigging(C07PacketPlayerDigging.Action.RELEASE_USE_ITEM, BlockPos.ORIGIN, DOWN)); blocked = false; } break; case 2: - blinking.set(true); handleInteractAndAttack(distance, true, true, swung); sendBlockPacket(); blocked = true; @@ -848,27 +889,33 @@ public class KillAura extends Module { lag = true; break; case 3: - firstCycle = true; + ++firstEdge; + if (firstEdge > 1) { + firstCycle = true; + if (firstEdge > 5) { + firstEdge = 0; + } + } break; } } else { switch (interactTicks) { case 1: + blinking.set(true); if (lag) { mc.thePlayer.sendQueue.addToSendQueue(new C07PacketPlayerDigging(C07PacketPlayerDigging.Action.RELEASE_USE_ITEM, BlockPos.ORIGIN, DOWN)); blocked = false; } break; case 2: - blinking.set(true); handleInteractAndAttack(distance, true, true, swung); sendBlockPacket(); blocked = true; releasePackets(); // release lag = true; - firstCycle = false; interactTicks = 0; + firstCycle = false; break; } } @@ -1096,18 +1143,19 @@ public class KillAura extends Module { public void resetBlinkState(boolean unblock) { //Utils.print("blink state reset"); blockingServer = false; - interactTicks = 0; blinking.set(false); releasePackets(); if (Raven.packetsHandler.playerSlot.get() != mc.thePlayer.inventory.currentItem && swapped) { mc.thePlayer.sendQueue.addToSendQueue(new C09PacketHeldItemChange(mc.thePlayer.inventory.currentItem)); Raven.packetsHandler.playerSlot.set(mc.thePlayer.inventory.currentItem); } - else if (unblock && lag && !ModuleManager.scaffold.isEnabled && blocked) { + else if (unblock && lag && !ModuleManager.scaffold.isEnabled) { sendDig = true; } swapped = blocked = false; lag = false; + firstEdge = interactTicks = 0; + firstCycle = false; } public void sendDigPacket() { @@ -1175,6 +1223,7 @@ public class KillAura extends Module { golems.put(entityCreature.getEntityId(), isTeam); return !isTeam; } + return true; } else { return !golems.getOrDefault(entityCreature.getEntityId(), false); diff --git a/src/main/java/keystrokesmod/module/impl/combat/Reduce.java b/src/main/java/keystrokesmod/module/impl/combat/Reduce.java index d0e2253..0200911 100644 --- a/src/main/java/keystrokesmod/module/impl/combat/Reduce.java +++ b/src/main/java/keystrokesmod/module/impl/combat/Reduce.java @@ -3,7 +3,6 @@ package keystrokesmod.module.impl.combat; import keystrokesmod.module.Module; import keystrokesmod.module.setting.impl.DescriptionSetting; import keystrokesmod.module.setting.impl.SliderSetting; -import net.minecraft.entity.Entity; public class Reduce extends Module { private static SliderSetting chance; @@ -17,17 +16,13 @@ public class Reduce extends Module { this.closetModule = true; } - public static void reduce(Entity entity) { + public static double getReduceMotion() { if (chance.getInput() == 0) { - return; + return 0.6; } if (chance.getInput() != 100.0 && Math.random() >= chance.getInput() / 100.0) { - mc.thePlayer.motionX *= 0.6; - mc.thePlayer.motionZ *= 0.6; - return; + return 0.6; } - double n = (100.0 - (float)reduction.getInput()) / 100.0; - mc.thePlayer.motionX *= n; - mc.thePlayer.motionZ *= n; + return (100.0 - (float)reduction.getInput()) / 100.0; } -} +} \ No newline at end of file diff --git a/src/main/java/keystrokesmod/module/impl/movement/Bhop.java b/src/main/java/keystrokesmod/module/impl/movement/Bhop.java index 8f3b133..830f512 100644 --- a/src/main/java/keystrokesmod/module/impl/movement/Bhop.java +++ b/src/main/java/keystrokesmod/module/impl/movement/Bhop.java @@ -27,7 +27,7 @@ public class Bhop extends Module { this.registerSetting(speedSetting = new SliderSetting("Speed", 2.0, 0.5, 8.0, 0.1)); this.registerSetting(liquidDisable = new ButtonSetting("Disable in liquid", true)); this.registerSetting(sneakDisable = new ButtonSetting("Disable while sneaking", true)); - this.registerSetting(rotateYawOption = new ButtonSetting("Rotate Yaw", false)); + this.registerSetting(rotateYawOption = new ButtonSetting("Rotate yaw", false)); } @Override @@ -62,17 +62,17 @@ public class Bhop extends Module { if (mc.thePlayer.onGround) { mc.thePlayer.jump(); double horizontalSpeed = Utils.getHorizontalSpeed(); - double speedModifier = 0.4847; + double speedModifier = 0.48; final int speedAmplifier = Utils.getSpeedAmplifier(); switch (speedAmplifier) { case 1: - speedModifier = 0.515200; + speedModifier = 0.5; break; case 2: - speedModifier = 0.587; + speedModifier = 0.52; break; case 3: - speedModifier = 0.6289; + speedModifier = 0.58; break; } double additionalSpeed = speedModifier * ((speedSetting.getInput() - 1.0) / 3.0 + 1.0); diff --git a/src/main/java/keystrokesmod/module/impl/movement/KeepSprint.java b/src/main/java/keystrokesmod/module/impl/movement/KeepSprint.java index b9092f5..f377a2a 100644 --- a/src/main/java/keystrokesmod/module/impl/movement/KeepSprint.java +++ b/src/main/java/keystrokesmod/module/impl/movement/KeepSprint.java @@ -6,11 +6,10 @@ import keystrokesmod.module.impl.combat.KillAura; import keystrokesmod.module.setting.impl.ButtonSetting; import keystrokesmod.module.setting.impl.DescriptionSetting; import keystrokesmod.module.setting.impl.SliderSetting; -import net.minecraft.entity.Entity; +import keystrokesmod.utility.Utils; import net.minecraft.util.Vec3; public class KeepSprint extends Module { - private DescriptionSetting description; public static SliderSetting slow; public static ButtonSetting disableWhileJump; public static ButtonSetting reduceReachHits; @@ -23,31 +22,29 @@ public class KeepSprint extends Module { this.registerSetting(reduceReachHits = new ButtonSetting("Only reduce reach hits", false)); } - public static void keepSprint(Entity en) { + public static double getKeepSprintMotion() { boolean vanilla = false; if (disableWhileJump.isToggled() && !mc.thePlayer.onGround) { vanilla = true; } else if (reduceReachHits.isToggled() && !mc.thePlayer.capabilities.isCreativeMode) { - double n = -1.0; + double distance = -1.0; final Vec3 getPositionEyes = mc.thePlayer.getPositionEyes(1.0f); if (ModuleManager.killAura != null && ModuleManager.killAura.isEnabled() && KillAura.target != null) { - n = getPositionEyes.distanceTo(KillAura.target.getPositionEyes(1.0f)); + distance = getPositionEyes.distanceTo(KillAura.target.getPositionEyes(Utils.getTimer().renderPartialTicks)); } else if (ModuleManager.reach != null && ModuleManager.reach.isEnabled()) { - n = getPositionEyes.distanceTo(mc.objectMouseOver.hitVec); + distance = getPositionEyes.distanceTo(mc.objectMouseOver.hitVec); } - if (n != -1.0 && n <= 3.0) { + if (distance != -1.0 && distance <= 3.0) { vanilla = true; } } if (vanilla) { - mc.thePlayer.motionX *= 0.6; - mc.thePlayer.motionZ *= 0.6; - } else { - float n2 = (100.0f - (float) slow.getInput()) / 100.0f; - mc.thePlayer.motionX *= n2; - mc.thePlayer.motionZ *= n2; + return 0.6; + } + else { + return (100.0f - (float) slow.getInput()) / 100.0f; } } -} +} \ No newline at end of file diff --git a/src/main/java/keystrokesmod/module/impl/movement/LongJump.java b/src/main/java/keystrokesmod/module/impl/movement/LongJump.java index 6f177d1..ccd820c 100644 --- a/src/main/java/keystrokesmod/module/impl/movement/LongJump.java +++ b/src/main/java/keystrokesmod/module/impl/movement/LongJump.java @@ -17,9 +17,12 @@ import net.minecraft.network.play.server.*; import net.minecraft.potion.PotionEffect; import net.minecraftforge.fml.common.eventhandler.EventPriority; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.fml.common.gameevent.TickEvent; import org.lwjgl.input.Keyboard; public class LongJump extends Module { + private SliderSetting mode; + private SliderSetting boostSetting; private SliderSetting motionTicks; private SliderSetting verticalMotion; @@ -33,6 +36,8 @@ public class LongJump extends Module { private KeySetting temporaryFlightKey; private SliderSetting pitchVal; + public String[] modes = new String[]{"Floyd", "Boost"}; + private float yaw; private float pitch; @@ -55,10 +60,12 @@ public class LongJump extends Module { public static boolean slotReset; public static int slotResetTicks; - private String[] modes = new String[]{"Fireball", "Fireball Auto"}; public LongJump() { super("Long Jump", category.movement); + this.registerSetting(mode = new SliderSetting("Mode", 0, modes)); + this.registerSetting(boostSetting = new SliderSetting("Horizontal boost", 1.7, 0.0, 2.0, 0.05)); + this.registerSetting(verticalMotion = new SliderSetting("Vertical motion", 0, 0.4, 0.9, 0.01)); this.registerSetting(motionDecay = new SliderSetting("Motion decay", 17, 1, 40, 1)); this.registerSetting(allowStrafe = new ButtonSetting("Allow strafe", false)); @@ -67,9 +74,10 @@ public class LongJump extends Module { this.registerSetting(hideExplosion = new ButtonSetting("Hide explosion", false)); this.registerSetting(temporaryFlightKey = new KeySetting("Vertical key", Keyboard.KEY_SPACE)); + } - //this.registerSetting(new DescriptionSetting("Dev:")); - //this.registerSetting(pitchVal = new SliderSetting("Stop movement Pitch", 55, 55, 80, 0.1)); + public void guiUpdate() { + //temporaryFlightKey.isVisible = mode.getInput() == 0; } public void onEnable() { @@ -136,12 +144,14 @@ public class LongJump extends Module { disable(); return; } - if (boostTicks > 0) { - modifyVertical(); // has to be onPreUpdate - //Utils.print("Modifying vertical"); - if (allowStrafe.isToggled()) { - Utils.setSpeed(Utils.getHorizontalSpeed(mc.thePlayer)); - //Utils.print("Speed"); + if (mode.getInput() == 0) { + if (boostTicks > 0) { + modifyVertical(); // has to be onPreUpdate + //Utils.print("Modifying vertical"); + if (allowStrafe.isToggled()) { + Utils.setSpeed(Utils.getHorizontalSpeed(mc.thePlayer)); + //Utils.print("Speed"); + } } } @@ -190,6 +200,8 @@ public class LongJump extends Module { mc.thePlayer.inventory.currentItem = fireballSlot; // we are probably already on the slot but make sure fireballTime = System.currentTimeMillis(); Reflection.rightClick(); + mc.thePlayer.swingItem(); + mc.getItemRenderer().resetEquippedProgress(); stopVelocity = true; //Utils.print("Right click"); } diff --git a/src/main/java/keystrokesmod/module/impl/movement/NoSlow.java b/src/main/java/keystrokesmod/module/impl/movement/NoSlow.java index 460e616..448e6bf 100644 --- a/src/main/java/keystrokesmod/module/impl/movement/NoSlow.java +++ b/src/main/java/keystrokesmod/module/impl/movement/NoSlow.java @@ -8,6 +8,7 @@ import keystrokesmod.module.setting.impl.ButtonSetting; import keystrokesmod.module.setting.impl.DescriptionSetting; import keystrokesmod.module.setting.impl.SliderSetting; import keystrokesmod.utility.*; +import net.minecraft.client.settings.KeyBinding; import net.minecraft.item.*; import net.minecraft.network.play.client.C08PacketPlayerBlockPlacement; import net.minecraft.util.BlockPos; @@ -73,17 +74,7 @@ public class NoSlow extends Module { } break; case 4: - if (reSendConsume) { - if (mc.thePlayer.onGround) { - mc.thePlayer.jump(); - break; - } - else { - mc.playerController.sendUseItem(mc.thePlayer, mc.theWorld, mc.thePlayer.getHeldItem()); - canFloat = true; - reSendConsume = false; - } - } + // break; } } @@ -101,8 +92,9 @@ public class NoSlow extends Module { @SubscribeEvent public void onPostPlayerInput(PostPlayerInputEvent e) { if ((canFloat && mc.thePlayer.onGround)) { - if (groundSpeedOption.isToggled() && !Utils.jumpDown() && !ModuleManager.bhop.isEnabled() && Utils.isMoving() && !Utils.bowBackwards()) { + if (groundSpeedOption.isToggled() && !Utils.jumpDown() && !ModuleManager.bhop.isEnabled() && Utils.keysDown() && !Utils.bowBackwards()) { Utils.setSpeed(getSpeedModifier()); + //Utils.print("ground speed"); } } } @@ -114,20 +106,26 @@ public class NoSlow extends Module { return; } postPlace = false; - if (!Mouse.isButtonDown(1)) { + if (!Mouse.isButtonDown(1) || (mc.thePlayer.getHeldItem() == null || !holdingConsumable(mc.thePlayer.getHeldItem()))) { resetFloat(); noSlowing = false; //Utils.print("!Noslowing"); return; } + if (reSendConsume) { + if (!mc.thePlayer.onGround) { + if (ModuleUtils.inAirTicks > 1) { + mc.playerController.sendUseItem(mc.thePlayer, mc.theWorld, mc.thePlayer.getHeldItem()); + canFloat = true; + reSendConsume = false; + } + } + } if (!canFloat) { return; } - if (canFloat) { - e.setPosY(e.getPosY() + 1E-14); - noSlowing = true; - //Utils.print("Noslowing"); - } + e.setPosY(e.getPosY() + 1E-11); + noSlowing = true; if (mc.thePlayer.onGround) { if (mc.thePlayer.moveStrafing == 0 && mc.thePlayer.moveForward <= 0 && Utils.isMoving()) { setRotation = true; @@ -138,7 +136,7 @@ public class NoSlow extends Module { if (Utils.noSlowingBackWithBow()) setRotation = false; if (groundSpeedOption.isToggled()) { if (setRotation) { - if (!ModuleManager.killAura.isTargeting && !Utils.noSlowingBackWithBow()) { + if (!ModuleManager.killAura.isTargeting && !Utils.noSlowingBackWithBow() && !Utils.jumpDown()) { float playerYaw = mc.thePlayer.rotationYaw; e.setYaw(playerYaw -= 55); } @@ -149,14 +147,14 @@ public class NoSlow extends Module { @SubscribeEvent public void onPacketSend(SendPacketEvent e) { if (e.getPacket() instanceof C08PacketPlayerBlockPlacement && mode.getInput() == 4 && getSlowed() != 0.2f && holdingConsumable(((C08PacketPlayerBlockPlacement) e.getPacket()).getStack()) && !BlockUtils.isInteractable(mc.objectMouseOver) && Utils.holdingEdible(((C08PacketPlayerBlockPlacement) e.getPacket()).getStack())) { - if (ModuleManager.skyWars.isEnabled() && Utils.getSkyWarsStatus() == 1 || canFloat) { + if (ModuleManager.skyWars.isEnabled() && Utils.getSkyWarsStatus() == 1 || canFloat || reSendConsume) { return; } if (!mc.thePlayer.onGround) { canFloat = true; } else { - if (mc.thePlayer.onGround) { + if (!Utils.jumpDown()) { mc.thePlayer.jump(); } reSendConsume = true; @@ -193,7 +191,7 @@ public class NoSlow extends Module { } public static boolean groundSpeed() { - return groundSpeedOption.isToggled() && noSlowing; + return groundSpeedOption.isToggled() && noSlowing && Utils.isMoving() && !Utils.jumpDown(); } @Override diff --git a/src/main/java/keystrokesmod/module/impl/movement/Sprint.java b/src/main/java/keystrokesmod/module/impl/movement/Sprint.java index 9561da0..13199bb 100644 --- a/src/main/java/keystrokesmod/module/impl/movement/Sprint.java +++ b/src/main/java/keystrokesmod/module/impl/movement/Sprint.java @@ -1,6 +1,8 @@ package keystrokesmod.module.impl.movement; import keystrokesmod.event.PreMotionEvent; +import keystrokesmod.event.PreUpdateEvent; +import keystrokesmod.mixins.impl.entity.IAccessorEntityPlayerSP; import keystrokesmod.module.Module; import keystrokesmod.module.ModuleManager; import keystrokesmod.module.setting.impl.ButtonSetting; @@ -12,6 +14,7 @@ import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.gui.ScaledResolution; import net.minecraft.client.settings.KeyBinding; +import net.minecraft.util.MathHelper; import net.minecraftforge.fml.client.config.GuiButtonExt; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.common.gameevent.TickEvent; @@ -22,9 +25,12 @@ public class Sprint extends Module { private ButtonSetting displayText; private ButtonSetting rainbow; public SliderSetting omniDirectional; + public ButtonSetting disableBackwards; public String text = "[Sprint (Toggled)]"; public float posX = 5; public float posY = 5; + private float limit; + public boolean disableBack; private String[] omniDirectionalModes = new String[] { "Disabled", "Vanilla", "Hypixel" }; @@ -37,19 +43,19 @@ public class Sprint extends Module { this.registerSetting(displayText = new ButtonSetting("Display text", false)); this.registerSetting(rainbow = new ButtonSetting("Rainbow", false)); this.registerSetting(omniDirectional = new SliderSetting("Omni-Directional", 0, omniDirectionalModes)); + this.registerSetting(disableBackwards = new ButtonSetting("Disable backwards", false)); this.closetModule = true; } @SubscribeEvent public void onPreMotion(PreMotionEvent e) { - if (Utils.noSlowingBackWithBow()) { ModuleManager.bhop.setRotation = false; return; } if (ModuleManager.sprint.isEnabled() && ModuleManager.sprint.omniDirectional.getInput() == 2) { if (mc.thePlayer.onGround && mc.thePlayer.moveStrafing == 0 && mc.thePlayer.moveForward <= -0.5 && !Utils.jumpDown()) { - if (!ModuleManager.killAura.isTargeting && !Utils.noSlowingBackWithBow() && !ModuleManager.safeWalk.canSafeWalk() && !ModuleManager.scaffold.isEnabled && !ModuleManager.bhop.isEnabled()) { + if (!ModuleManager.killAura.isTargeting && !Utils.noSlowingBackWithBow() && !ModuleManager.safeWalk.canSafeWalk() && !ModuleManager.scaffold.isEnabled && !ModuleManager.bhop.isEnabled() && !mc.thePlayer.isCollidedHorizontally) { float playerYaw = mc.thePlayer.rotationYaw; e.setYaw(playerYaw -= 55); } @@ -57,6 +63,29 @@ public class Sprint extends Module { } } + @SubscribeEvent + public void onPreUpdate(PreUpdateEvent e) { + limit = MathHelper.wrapAngleTo180_float(mc.thePlayer.rotationYaw - ((IAccessorEntityPlayerSP) mc.thePlayer).getLastReportedYaw() ); + //Utils.print("" + limit); + + double limitVal = 135; + if (!disableBackwards.isToggled()) { + disableBack = false; + return; + } + if (exceptions()) { + disableBack = false; + return; + } + if ((limit <= -limitVal || limit >= limitVal) || omniSprint() && ModuleManager.killAura.isTargeting && mc.thePlayer.moveForward <= 0.5) { + disableBack = true; + //Utils.print("Disable sprint"); + } + else { + disableBack = false; + } + } + public void onUpdate() { if (Utils.nullCheck() && mc.inGameHasFocus) { KeyBinding.setKeyBindState(mc.gameSettings.keyBindSprint.getKeyCode(), true); @@ -87,6 +116,10 @@ public class Sprint extends Module { return false; } + private boolean exceptions() { + return ModuleManager.scaffold.isEnabled || mc.thePlayer.hurtTime > 0; + } + static class EditScreen extends GuiScreen { GuiButtonExt resetPosition; boolean d = false; diff --git a/src/main/java/keystrokesmod/module/impl/player/BedAura.java b/src/main/java/keystrokesmod/module/impl/player/BedAura.java index 85b9b83..5b6fb19 100644 --- a/src/main/java/keystrokesmod/module/impl/player/BedAura.java +++ b/src/main/java/keystrokesmod/module/impl/player/BedAura.java @@ -175,7 +175,7 @@ public class BedAura extends Module { aiming = false; if ((rotate || breakProgress >= 1 || breakProgress == 0) && (currentBlock != null || rotateLastBlock != null)) { float[] rotations = RotationUtils.getRotations(currentBlock == null ? rotateLastBlock : currentBlock, e.getYaw(), e.getPitch()); - if (currentBlock != null && !RotationUtils.inRange(currentBlock, range.getInput())) { + if (currentBlock == null || !RotationUtils.inRange(currentBlock, range.getInput())) { return; } e.setYaw(RotationUtils.applyVanilla(rotations[0])); @@ -338,6 +338,7 @@ public class BedAura extends Module { stopAutoblock = false; noAutoBlockTicks = 0; rotateLastBlock = null; + previousBlockBroken = null; } public void setPacketSlot(int slot) { @@ -352,6 +353,7 @@ public class BedAura extends Module { Utils.sendModuleMessage(this, "sending c07 &astart &7break &7(&b" + mc.thePlayer.ticksExisted + "&7)"); } mc.thePlayer.sendQueue.addToSendQueue(new C07PacketPlayerDigging(C07PacketPlayerDigging.Action.START_DESTROY_BLOCK, blockPos, EnumFacing.UP)); + stopAutoblock = true; } private void stopBreak(BlockPos blockPos) { @@ -359,6 +361,7 @@ public class BedAura extends Module { Utils.sendModuleMessage(this, "sending c07 &cstop &7break &7(&b" + mc.thePlayer.ticksExisted + "&7)"); } mc.thePlayer.sendQueue.addToSendQueue(new C07PacketPlayerDigging(C07PacketPlayerDigging.Action.STOP_DESTROY_BLOCK, blockPos, EnumFacing.UP)); + stopAutoblock = false; } private void swing() { @@ -425,7 +428,6 @@ public class BedAura extends Module { if (!disableBreakEffects.isToggled()) { mc.playerController.onPlayerDestroyBlock(blockPos, EnumFacing.UP); } - rotate = true; rotateLastBlock = previousBlockBroken; return; } @@ -448,7 +450,7 @@ public class BedAura extends Module { stopAutoblock = true; // if blocking then return and stop autoblocking } if (breakProgress >= lastProgress) { - rotate = true; + } } breakProgress += progress; diff --git a/src/main/java/keystrokesmod/module/impl/player/Blink.java b/src/main/java/keystrokesmod/module/impl/player/Blink.java index f097247..6d430b1 100644 --- a/src/main/java/keystrokesmod/module/impl/player/Blink.java +++ b/src/main/java/keystrokesmod/module/impl/player/Blink.java @@ -91,7 +91,7 @@ public class Blink extends Module { if (packet.getClass().getSimpleName().startsWith("S")) { return; } - if (packet instanceof C00PacketLoginStart || packet instanceof C00Handshake) { + if (packet instanceof C00PacketKeepAlive || packet instanceof C00PacketLoginStart || packet instanceof C00Handshake) { return; } started = true; diff --git a/src/main/java/keystrokesmod/module/impl/player/DelayRemover.java b/src/main/java/keystrokesmod/module/impl/player/DelayRemover.java index 8ef744e..42ec1a0 100644 --- a/src/main/java/keystrokesmod/module/impl/player/DelayRemover.java +++ b/src/main/java/keystrokesmod/module/impl/player/DelayRemover.java @@ -2,18 +2,21 @@ package keystrokesmod.module.impl.player; import keystrokesmod.module.Module; import keystrokesmod.module.setting.impl.ButtonSetting; +import keystrokesmod.module.setting.impl.SliderSetting; import keystrokesmod.utility.Reflection; import keystrokesmod.utility.Utils; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.common.gameevent.TickEvent; public class DelayRemover extends Module { - public static ButtonSetting oldReg, removeJumpTicks; + public static ButtonSetting oldReg; + public static SliderSetting removeJumpTicks; + private String[] removeJumpTicksModes = new String[] { "Disabled", "0", "Hypixel" }; public DelayRemover() { super("Delay Remover", category.player, 0); this.registerSetting(oldReg = new ButtonSetting("1.7 hitreg", true)); - this.registerSetting(removeJumpTicks = new ButtonSetting("Remove jump ticks", false)); + this.registerSetting(removeJumpTicks = new SliderSetting("Remove jump ticks", 0, removeJumpTicksModes)); this.closetModule = true; } @@ -29,7 +32,7 @@ public class DelayRemover extends Module { } catch (IndexOutOfBoundsException ex2) { } } - if (removeJumpTicks.isToggled()) { + if (removeJumpTicks.getInput() == 1 || removeJumpTicks.getInput() == 2 && removeJumpDelay()) { try { Reflection.jumpTicks.set(mc.thePlayer, 0); } catch (IllegalAccessException ex3) { @@ -37,4 +40,8 @@ public class DelayRemover extends Module { } } } + + private boolean removeJumpDelay() { + return !mc.thePlayer.onGround && mc.thePlayer.isCollidedVertically; + } } diff --git a/src/main/java/keystrokesmod/module/impl/player/NoFall.java b/src/main/java/keystrokesmod/module/impl/player/NoFall.java index 74d3eb7..ddbfa4e 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", "Packet", "NoGround"}; + private String[] modes = new String[]{"Spoof", "NoGround", "Packet A", "Packet B"}; private double initialY; private double dynamic; @@ -32,7 +32,7 @@ public class NoFall extends Module { public NoFall() { super("NoFall", category.player); - this.registerSetting(mode = new SliderSetting("Mode", 0, modes)); + this.registerSetting(mode = new SliderSetting("Mode", 2, modes)); this.registerSetting(disableAdventure = new ButtonSetting("Disable adventure", false)); this.registerSetting(minFallDistance = new SliderSetting("Minimum fall distance", 3, 0, 10, 0.1)); this.registerSetting(ignoreVoid = new ButtonSetting("Ignore void", true)); @@ -70,16 +70,21 @@ public class NoFall extends Module { if (mc.thePlayer.motionY < -2.4) { dynamic = 4.5; } - if (isFalling || mode.getInput() == 2) { - switch ((int) mode.getInput()) { - case 1: - if (distanceFallen >= dynamic) { - Utils.getTimer().timerSpeed = (float) 0.72; - mc.getNetHandler().addToSendQueue(new C03PacketPlayer(true)); - initialY = mc.thePlayer.posY; - edging = "nofall packet"; - } - break; + if (isFalling && mode.getInput() == 2) { + if (distanceFallen >= dynamic) { + Utils.getTimer().timerSpeed = (float) 0.72; + mc.getNetHandler().addToSendQueue(new C03PacketPlayer(true)); + initialY = mc.thePlayer.posY; + edging = "nofall packet"; + } + } + if (isFalling && mode.getInput() == 3) { + Utils.getTimer().timerSpeed = (float) 1; + if (distanceFallen >= 3) { + Utils.getTimer().timerSpeed = (float) 0.5; + mc.getNetHandler().addToSendQueue(new C03PacketPlayer(true)); + initialY = mc.thePlayer.posY; + edging = "nofall packet"; } } edging += " " + dynamic; @@ -92,7 +97,7 @@ public class NoFall extends Module { case 0: e.setOnGround(true); break; - case 2: + case 1: e.setOnGround(false); break; } diff --git a/src/main/java/keystrokesmod/module/impl/player/NoRotate.java b/src/main/java/keystrokesmod/module/impl/player/NoRotate.java index 2da170b..ffab4fa 100644 --- a/src/main/java/keystrokesmod/module/impl/player/NoRotate.java +++ b/src/main/java/keystrokesmod/module/impl/player/NoRotate.java @@ -15,7 +15,7 @@ public class NoRotate extends Module { if (!this.isEnabled()) { return; } - if (mc.thePlayer == null || (mc.thePlayer.rotationPitch % 1 == 0f && mc.thePlayer.rotationYaw % 1 == 0f)) { + if (mc.thePlayer == null || mc.thePlayer.rotationPitch == 0) { return; } prevPitch = mc.thePlayer.rotationPitch % 360; @@ -26,7 +26,7 @@ public class NoRotate extends Module { if (!this.isEnabled()) { return; } - if (packet.getPitch() % 1.0f == 0.0f || mc.thePlayer == null) { + if (packet.getPitch() == 0 || mc.thePlayer == null) { return; } mc.thePlayer.prevRotationYaw = prevYaw; diff --git a/src/main/java/keystrokesmod/module/impl/player/Scaffold.java b/src/main/java/keystrokesmod/module/impl/player/Scaffold.java index 6b433fe..fe19cf8 100644 --- a/src/main/java/keystrokesmod/module/impl/player/Scaffold.java +++ b/src/main/java/keystrokesmod/module/impl/player/Scaffold.java @@ -30,27 +30,23 @@ import java.util.*; import java.util.concurrent.atomic.AtomicInteger; public class Scaffold extends Module { - private static SliderSetting motion; - public static SliderSetting rotation; - private static SliderSetting sprint; - private static SliderSetting fastScaffold; - private static SliderSetting multiPlace; - public static ButtonSetting autoSwap; - private static ButtonSetting cancelKnockBack; - private static ButtonSetting fastOnRMB; - public static ButtonSetting highlightBlocks; - private static ButtonSetting jumpFacingForward; - public static ButtonSetting safeWalk; - public static ButtonSetting showBlockCount; - private static ButtonSetting silentSwing; - public static ButtonSetting tower; + private SliderSetting motion; + public SliderSetting rotation; + private SliderSetting sprint; + private SliderSetting fastScaffold; + private SliderSetting multiPlace; + public ButtonSetting autoSwap; + private ButtonSetting cancelKnockBack; + private ButtonSetting fastOnRMB; + public ButtonSetting highlightBlocks; + private ButtonSetting jumpFacingForward; + public ButtonSetting safeWalk; + public ButtonSetting showBlockCount; + private ButtonSetting silentSwing; - private static SliderSetting yaww2; - private static SliderSetting minO; - - private static String[] rotationModes = new String[] { "None", "Simple", "Offset", "Precise" }; - private static String[] sprintModes = new String[] { "None", "Vanilla", "Float" }; - private static String[] fastScaffoldModes = new String[] { "None", "Jump B", "Jump B Low", "Jump E", "Keep-Y", "Keep-Y Low" }; + private String[] rotationModes = new String[] { "None", "Simple", "Offset", "Precise" }; + private String[] sprintModes = new String[] { "None", "Vanilla", "Float" }; + private String[] fastScaffoldModes = new String[] { "None", "Jump B", "Jump B Low", "Jump E", "Keep-Y", "Keep-Y Low" }; private String[] multiPlaceModes = new String[] { "Disabled", "1 extra", "2 extra" }; public Map highlight = new HashMap<>(); @@ -115,7 +111,6 @@ public class Scaffold extends Module { this.registerSetting(safeWalk = new ButtonSetting("Safewalk", true)); this.registerSetting(showBlockCount = new ButtonSetting("Show block count", true)); this.registerSetting(silentSwing = new ButtonSetting("Silent swing", false)); - this.registerSetting(tower = new ButtonSetting("Tower", false)); //this.registerSetting(yaww2 = new SliderSetting("yaw offset", "", 138, 110, 160, 1)); //this.registerSetting(minO = new SliderSetting("min offset", "", 30, 1, 90, 1)); @@ -211,7 +206,7 @@ public class Scaffold extends Module { if (floatStarted && mc.thePlayer.onGround) { floatKeepY = false; startYPos = -1; - if (moduleEnabled && !Utils.jumpDown()) e.setPosY(e.getPosY() + 1E-14); + if (moduleEnabled && !Utils.jumpDown()) e.setPosY(e.getPosY() + 1E-11); if (Utils.isMoving()) Utils.setSpeed(getFloatSpeed(getSpeedLevel())); } } else if (floatWasEnabled) { @@ -239,8 +234,8 @@ public class Scaffold extends Module { float main = MathHelper.wrapAngleTo180_float(getMotionYaw() - yaw); float mainOffset = MathHelper.wrapAngleTo180_float(yawBackwards - lastBlockYaw); float mainOffset2 = MathHelper.wrapAngleTo180_float(yawBackwards - lastBlockYaw); - rotOffset = (!Utils.scaffoldDiagonal(false)) ? 125F : 142F; - float minOffset = 40; + rotOffset = (!Utils.scaffoldDiagonal(false)) ? 132F : 140F; + float minOffset = (!Utils.scaffoldDiagonal(false)) ? 40 : 15; if (blockRotations != null) { e.setYaw(blockRotations[0]); e.setPitch(blockRotations[1]); @@ -304,10 +299,6 @@ public class Scaffold extends Module { } } - if (rotation.getInput() == 1) { - e.setYaw(MathHelper.wrapAngleTo180_float(mc.thePlayer.rotationYaw) - hardcodedYaw()); - } - if (e.getPitch() > 89) { e.setPitch(89); } @@ -318,14 +309,22 @@ public class Scaffold extends Module { else { lastBlockYaw = lastYaw; if (rotation.getInput() == 2) { - //e.setYaw(offsetRotation() - mainOffset); - e.setYaw(MathHelper.wrapAngleTo180_float(mc.thePlayer.rotationYaw) - hardcodedYaw() - 165); + /*if (main >= 0) { + mainOffset2 = 25; + } + else if (main <= -0) { + mainOffset2 = -25; + }*/ + e.setYaw(offsetRotation()); } else { e.setYaw(MathHelper.wrapAngleTo180_float(mc.thePlayer.rotationYaw) - hardcodedYaw()); } e.setPitch(getPitch); } + if (rotation.getInput() == 1) { + e.setYaw(MathHelper.wrapAngleTo180_float(mc.thePlayer.rotationYaw) - hardcodedYaw()); + } } } else { @@ -344,6 +343,9 @@ public class Scaffold extends Module { private float yaw; private float offsetRotation() { + if (!Utils.isMoving() || Utils.getHorizontalSpeed() == 0.0D) { + return yaw; + } float newYaw = getMotionYaw() - rotOffset * Math.signum( MathHelper.wrapAngleTo180_float(getMotionYaw() - yaw) diff --git a/src/main/java/keystrokesmod/module/impl/player/Tower.java b/src/main/java/keystrokesmod/module/impl/player/Tower.java index bdc986b..38d18ef 100644 --- a/src/main/java/keystrokesmod/module/impl/player/Tower.java +++ b/src/main/java/keystrokesmod/module/impl/player/Tower.java @@ -277,7 +277,7 @@ public class Tower extends Module { } private boolean modulesEnabled() { - return (ModuleManager.scaffold.moduleEnabled && ModuleManager.scaffold.holdingBlocks() && ModuleManager.scaffold.tower.isToggled() && ModuleManager.scaffold.hasSwapped && !ModuleManager.LongJump.isEnabled()); + return (ModuleManager.scaffold.moduleEnabled && ModuleManager.scaffold.holdingBlocks() && ModuleManager.scaffold.hasSwapped && !ModuleManager.LongJump.isEnabled()); } private int getSpeedLevel() { diff --git a/src/main/java/keystrokesmod/module/setting/Setting.java b/src/main/java/keystrokesmod/module/setting/Setting.java index 0213cca..7c10c61 100644 --- a/src/main/java/keystrokesmod/module/setting/Setting.java +++ b/src/main/java/keystrokesmod/module/setting/Setting.java @@ -3,6 +3,9 @@ package keystrokesmod.module.setting; import com.google.gson.JsonObject; public abstract class Setting { + + public boolean isVisible = true; + public String n; public Setting(String n) { @@ -14,4 +17,4 @@ public abstract class Setting { } public abstract void loadProfile(JsonObject data); -} +} \ No newline at end of file diff --git a/src/main/java/keystrokesmod/script/Manager.java b/src/main/java/keystrokesmod/script/Manager.java index 5a8c64e..fe66d9d 100644 --- a/src/main/java/keystrokesmod/script/Manager.java +++ b/src/main/java/keystrokesmod/script/Manager.java @@ -4,6 +4,8 @@ import keystrokesmod.Raven; import keystrokesmod.module.Module; import keystrokesmod.module.setting.impl.ButtonSetting; import keystrokesmod.script.classes.Entity; +import keystrokesmod.script.classes.Image; +import keystrokesmod.script.classes.NetworkPlayer; import keystrokesmod.utility.Utils; import keystrokesmod.utility.profile.ProfileModule; import org.lwjgl.Sys; @@ -32,9 +34,11 @@ public class Manager extends Module { } else { double timeTaken = Utils.round((System.currentTimeMillis() - currentTimeMillis) / 1000.0, 1); - Utils.sendMessage("&7Loaded &b" + Raven.scriptManager.scripts.size() + " &7script" + ((Raven.scriptManager.scripts.size() == 1) ? "" : "s") + " in &b" + (Utils.isWholeNumber(timeTaken) ? (int) timeTaken + "" : timeTaken) + "&7s."); + Utils.sendMessage("&7Loaded &b" + Raven.scriptManager.scripts.size() + " &7script" + ((Raven.scriptManager.scripts.size() == 1) ? "" : "s") + " in &b" + Utils.asWholeNum(timeTaken) + "&7s."); } Entity.clearCache(); + NetworkPlayer.clearCache(); + Image.clearCache(); 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 d2fde2d..aace5ae 100644 --- a/src/main/java/keystrokesmod/script/Script.java +++ b/src/main/java/keystrokesmod/script/Script.java @@ -9,7 +9,6 @@ import java.io.File; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.net.URL; -import java.net.URLClassLoader; import java.net.URLDecoder; import java.util.*; diff --git a/src/main/java/keystrokesmod/script/ScriptDefaults.java b/src/main/java/keystrokesmod/script/ScriptDefaults.java index 6d0e6dd..925b85a 100644 --- a/src/main/java/keystrokesmod/script/ScriptDefaults.java +++ b/src/main/java/keystrokesmod/script/ScriptDefaults.java @@ -28,7 +28,6 @@ import net.minecraft.client.renderer.*; import net.minecraft.client.renderer.texture.DynamicTexture; import net.minecraft.client.renderer.vertex.DefaultVertexFormats; import net.minecraft.client.resources.I18n; -import net.minecraft.client.resources.IResourcePack; import net.minecraft.client.resources.ResourcePackRepository; import net.minecraft.client.settings.KeyBinding; import net.minecraft.creativetab.CreativeTabs; @@ -45,17 +44,19 @@ import org.lwjgl.opengl.Display; import org.lwjgl.opengl.GL11; import org.lwjgl.util.glu.GLU; +import java.io.File; import java.io.IOException; import java.nio.FloatBuffer; import java.nio.IntBuffer; +import java.nio.file.*; import java.util.*; +import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; -import java.util.concurrent.ScheduledExecutorService; public class ScriptDefaults { + private static ExecutorService cachedExecutor; private static final Minecraft mc = Minecraft.getMinecraft(); public static final Bridge bridge = new Bridge(); - private static final ScheduledExecutorService executor = Executors.newScheduledThreadPool(2); public static class client { public static boolean allowFlying() { @@ -85,8 +86,11 @@ public class ScriptDefaults { Utils.addFriend(username); } - public static void async(Runnable method) { - executor.execute(method); + public static void async(final Runnable method) { + if (cachedExecutor == null) { + cachedExecutor = Executors.newCachedThreadPool(); + } + cachedExecutor.execute(method); } public static int getFPS() { @@ -110,10 +114,6 @@ public class ScriptDefaults { return Utils.isDiagonal(false); } - public static boolean isHoldingWeapon() { - return Utils.holdingWeapon(); - } - public static void setTimer(float timer) { Utils.getTimer().timerSpeed = timer; } @@ -130,6 +130,30 @@ public class ScriptDefaults { PacketUtils.receivePacketNoEvent(packet.packet); } + public static String getTitle() { + try { + return (String) Reflection.displayedTitle.get(mc.ingameGUI); + } + catch (IllegalAccessException ignored) {} + return ""; + } + + public static String getSubTitle() { + try { + return (String) Reflection.displayedSubTitle.get(mc.ingameGUI); + } + catch (IllegalAccessException ignored) {} + return ""; + } + + public static String getRecordPlaying() { + try { + return (String) Reflection.recordPlaying.get(mc.ingameGUI); + } + catch (IllegalAccessException ignored) {} + return ""; + } + public static boolean isFlying() { return mc.thePlayer.capabilities.isFlying; } @@ -212,18 +236,22 @@ public class ScriptDefaults { return mc.thePlayer.capabilities.allowEdit; } + public static void setItemInUseCount(int count) { + Reflection.setItemInUseCount(count); + } + + public static int getItemInUseCount() { + return mc.thePlayer.getItemInUseCount(); + } + + public static int getItemInUseDuration() { + return mc.thePlayer.getItemInUseDuration(); + } + public static void log(String message) { System.out.println(message); } - public static boolean isMouseDown(int button) { - return Mouse.isButtonDown(button); - } - - public static boolean isKeyDown(int key) { - return Keyboard.isKeyDown(key); - } - public static void setSneaking(boolean sneak) { mc.thePlayer.setSneaking(sneak); } @@ -263,8 +291,7 @@ public class ScriptDefaults { try { Thread.sleep(ms); } - catch (InterruptedException e) { - } + catch (InterruptedException ignored) {} } public static void ping() { @@ -296,6 +323,23 @@ public class ScriptDefaults { } } + public static String getTabHeader() { + try { + return (String) Reflection.tabHeader.get(mc.ingameGUI.getTabList()); + } + catch (IllegalAccessException ignored) {} + return ""; + } + + public static String getTabFooter() { + try { + return (String) Reflection.tabFooter.get(mc.ingameGUI.getTabList()); + } + catch (IllegalAccessException ignored) { + } + return ""; + } + public static float getForward() { return mc.thePlayer.movementInput.moveForward; } @@ -366,7 +410,7 @@ public class ScriptDefaults { return new int[]{scaledResolution.getScaledWidth(), scaledResolution.getScaledHeight(), scaledResolution.getScaleFactor()}; } - public float getServerDirection(PlayerState state) { + public static float getServerDirection(PlayerState state) { return state.yaw; } @@ -374,6 +418,10 @@ public class ScriptDefaults { return raycastBlock(distance, mc.thePlayer.rotationYaw, mc.thePlayer.rotationPitch, true); } + public static Object[] raycastBlock(double distance, float yaw, float pitch) { + return raycastBlock(distance, mc.thePlayer.rotationYaw, mc.thePlayer.rotationPitch, true); + } + public static Object[] raycastBlock(double distance, float yaw, float pitch, boolean collisionCheck) { MovingObjectPosition hit = RotationUtils.rayCast(distance, yaw, pitch, collisionCheck); if (hit == null || hit.typeOfHit != MovingObjectPosition.MovingObjectType.BLOCK) { @@ -469,7 +517,7 @@ public class ScriptDefaults { public static List getNetworkPlayers() { List entities = new ArrayList<>(); for (NetworkPlayerInfo networkPlayerInfo : Utils.getTablist(false)) { - entities.add(new NetworkPlayer(networkPlayerInfo)); + entities.add(NetworkPlayer.convert(networkPlayerInfo)); } return entities; } @@ -517,18 +565,16 @@ public class ScriptDefaults { public modules(String superName) { this.superName = superName; } + private Module getModule(String moduleName) { - boolean found = false; for (Module module : Raven.getModuleManager().getModules()) { if (module.getName().equals(moduleName)) { return module; } } - if (!found) { - for (Module module : Raven.scriptManager.scripts.values()) { - if (module.getName().equals(moduleName)) { - return module; - } + for (Module module : Raven.scriptManager.scripts.values()) { + if (module.getName().equals(moduleName)) { + return module; } } return null; @@ -620,14 +666,6 @@ public class ScriptDefaults { return new Vec3(blockPos.getX(), blockPos.getY(), blockPos.getZ()); } - public boolean isScaffolding() { - return ModuleManager.scaffold.isEnabled && ModuleManager.scaffold.tower.isToggled(); - } - - public boolean isTowering() { - return ModuleManager.tower.canTower(); - } - public boolean isHidden(String moduleName) { Module module = getModule(moduleName); if (module != null) { @@ -852,13 +890,74 @@ public class ScriptDefaults { } } + public static class config { + private static String CONFIG_DIR = mc.mcDataDir + File.separator + "keystrokes" + File.separator + "script_config.txt"; + private static String SEPARATOR = ":"; + private static String SEPARATOR_FULL = config.SEPARATOR + " "; + + private static void ensureConfigFileExists() throws IOException { + final Path configPath = Paths.get(config.CONFIG_DIR); + if (Files.notExists(configPath)) { + Files.createDirectories(configPath.getParent()); + Files.createFile(configPath); + } + } + + public static boolean set(String key, final String value) { + if (key == null || key.isEmpty()) { + return false; + } + key = key.replace(config.SEPARATOR, ""); + final String entry = key + config.SEPARATOR_FULL + value; + try { + ensureConfigFileExists(); + final Path configPath = new File(config.CONFIG_DIR).toPath(); + final List lines = new ArrayList<>(Files.readAllLines(configPath)); + boolean keyExists = false; + for (int i = 0; i < lines.size(); ++i) { + final String line = lines.get(i); + if (line.startsWith(key + config.SEPARATOR_FULL)) { + lines.set(i, entry); + keyExists = true; + break; + } + } + if (!keyExists) { + lines.add(entry); + } + Files.write(configPath, lines); + return true; + } + catch (IOException ex) { + return false; + } + } + + public static String get(final String key) { + if (key == null || key.isEmpty()) { + return null; + } + try { + ensureConfigFileExists(); + final Path configPath = new File(config.CONFIG_DIR).toPath(); + final List lines = Files.readAllLines(configPath); + for (final String line : lines) { + if (line.startsWith(key + config.SEPARATOR_FULL)) { + return line.substring((key + config.SEPARATOR_FULL).length()); + } + } + } + catch (IOException ex) {} + return null; + } + } + public static class render { private static final IntBuffer VIEWPORT = GLAllocation.createDirectIntBuffer(16); private static final FloatBuffer MODELVIEW = GLAllocation.createDirectFloatBuffer(16); private static final FloatBuffer PROJECTION = GLAllocation.createDirectFloatBuffer(16); private static final FloatBuffer SCREEN_COORDS = GLAllocation.createDirectFloatBuffer(3); - public static void block(Vec3 position, int color, boolean outline, boolean shade) { RenderUtils.renderBlock(new BlockPos(position.x, position.y, position.z), color, outline, shade); } @@ -908,10 +1007,6 @@ public class ScriptDefaults { GL11.glPopMatrix(); } - public static void text(String text, float x, float y, int color, boolean shadow) { - mc.fontRendererObj.drawString(text, x, y, color, shadow); - } - public static void resetEquippedProgress() { mc.getItemRenderer().resetEquippedProgress(); } @@ -985,6 +1080,14 @@ public class ScriptDefaults { RoundedUtils.drawRoundedRectRise(startX, startY, Math.abs(startX - endX), Math.abs(startY - endY), radius, color); } + public static void gradientRect(float startX, float startY, float endX, float endY, int leftColor, int rightColor) { + gradientRect(startX, startY, endX, endY, leftColor, leftColor, rightColor, rightColor); + } + + public static void gradientRect(float startX, float startY, float endX, float endY, int topLeftColor, int bottomLeftColor, int topRightColor, int bottomRightColor) { + RenderUtils.drawRoundedGradientRect(startX, startY, endX, endY, 0, topLeftColor, bottomLeftColor, topRightColor, bottomRightColor); + } + public static double[] getRotations() { return new double[] { mc.getRenderManager().playerViewY, mc.getRenderManager().playerViewX }; } @@ -1006,7 +1109,7 @@ public class ScriptDefaults { return new Vec3(position); } - public static void text(String text, float x, float y, float scale, int color, boolean shadow) { + public static void text2d(String text, float x, float y, float scale, int color, boolean shadow) { if (scale != 1.0f) { GlStateManager.pushMatrix(); GlStateManager.scale(scale, scale, scale); @@ -1021,8 +1124,54 @@ public class ScriptDefaults { } } - public static void rect(float startX, float startY, float endX, float endY, int color) { - RenderUtils.drawRectangleGL(startX, startY, endX, endY, color); + public static void text3d(String text, float x, float y, float scale, int color, boolean shadow) { + GlStateManager.pushMatrix(); + Reflection.setupCameraTransform(mc.entityRenderer, Utils.getTimer().renderPartialTicks, 0); + mc.entityRenderer.setupOverlayRendering(); + if (scale != 1.0f) { + GlStateManager.scale(scale, scale, scale); + } + 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); + } + GlStateManager.popMatrix(); + } + + public static void rect(float startX, float startY, float endX, float endY, final int color) { + if (startX < endX) { + final float i = startX; + startX = endX; + endX = i; + } + if (startY < endY) { + final float j = startY; + startY = endY; + endY = j; + } + final float f3 = (color >> 24 & 0xFF) / 255.0f; + final float f4 = (color >> 16 & 0xFF) / 255.0f; + final float f5 = (color >> 8 & 0xFF) / 255.0f; + final float f6 = (color & 0xFF) / 255.0f; + final Tessellator tessellator = Tessellator.getInstance(); + final WorldRenderer worldrenderer = tessellator.getWorldRenderer(); + GL11.glPushMatrix(); + GlStateManager.enableBlend(); + GlStateManager.disableTexture2D(); + GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0); + GlStateManager.color(f4, f5, f6, f3); + worldrenderer.begin(7, DefaultVertexFormats.POSITION); + worldrenderer.pos((double)startX, (double)endY, 0.0).endVertex(); + worldrenderer.pos((double)endX, (double)endY, 0.0).endVertex(); + worldrenderer.pos((double)endX, (double)startY, 0.0).endVertex(); + worldrenderer.pos((double)startX, (double)startY, 0.0).endVertex(); + tessellator.draw(); + GlStateManager.enableTexture2D(); + GlStateManager.disableBlend(); + GL11.glPopMatrix(); } public static void line2D(double startX, double startY, double endX, double endY, float lineWidth, int color) { @@ -1219,27 +1368,30 @@ public class ScriptDefaults { return new int[] { Mouse.getX(), Mouse.getY() }; } - public static boolean isPressed(String key) { - for (Map.Entry map : Reflection.keyBindings.entrySet()) { - if (map.getValue().equals(key)) { - return map.getKey().isKeyDown(); - } - } - return false; + public static boolean isPressed(final String key) { + KeyBinding keyBind = Reflection.keybinds.get(key); + return keyBind != null && keyBind.isKeyDown(); } - public static void setPressed(String key, boolean pressed) { - for (Map.Entry map : Reflection.keyBindings.entrySet()) { - if (map.getValue().equals(key)) { - KeyBinding.setKeyBindState(map.getKey().getKeyCode(), pressed); - if (pressed) { - KeyBinding.onTick(map.getKey().getKeyCode()); - } + public static void setPressed(final String key, final boolean pressed) { + KeyBinding keyBind = Reflection.keybinds.get(key); + if (keyBind != null) { + KeyBinding.setKeyBindState(keyBind.getKeyCode(), pressed); + if (pressed) { + KeyBinding.onTick(keyBind.getKeyCode()); } } } - public static int getKeyCode(String key) { + public static int getKeyCode(final String key) { + final KeyBinding keyBind = Reflection.keybinds.get(key); + if (keyBind != null) { + return keyBind.getKeyCode(); + } + return -1; + } + + public static int getKeyIndex(String key) { return Keyboard.getKeyIndex(key); } diff --git a/src/main/java/keystrokesmod/script/ScriptEvents.java b/src/main/java/keystrokesmod/script/ScriptEvents.java index a181ba5..8fca8b5 100644 --- a/src/main/java/keystrokesmod/script/ScriptEvents.java +++ b/src/main/java/keystrokesmod/script/ScriptEvents.java @@ -13,6 +13,7 @@ import net.minecraftforge.client.event.ClientChatReceivedEvent; import net.minecraftforge.client.event.MouseEvent; 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 net.minecraftforge.fml.common.gameevent.TickEvent; @@ -23,7 +24,7 @@ public class ScriptEvents { this.module = module; } - @SubscribeEvent + @SubscribeEvent(priority = EventPriority.HIGHEST) public void onChat(ClientChatReceivedEvent e) { if (e.type == 2 || !Utils.nullCheck()) { return; @@ -37,7 +38,7 @@ public class ScriptEvents { } } - @SubscribeEvent + @SubscribeEvent(priority = EventPriority.HIGHEST) public void onSendPacket(SendPacketEvent e) { if (e.isCanceled() || e.getPacket() == null) { return; @@ -51,7 +52,7 @@ public class ScriptEvents { } } - @SubscribeEvent + @SubscribeEvent(priority = EventPriority.HIGHEST) public void onReceivePacket(ReceivePacketEvent e) { if (e.isCanceled() || e.getPacket() == null) { return; @@ -62,7 +63,7 @@ public class ScriptEvents { } } - @SubscribeEvent + @SubscribeEvent(priority = EventPriority.LOWEST) public void onRenderWorldLast(RenderWorldLastEvent e) { if (!Utils.nullCheck()) { return; @@ -70,17 +71,17 @@ public class ScriptEvents { Raven.scriptManager.invoke("onRenderWorld", module, e.partialTicks); } - @SubscribeEvent + @SubscribeEvent(priority = EventPriority.HIGHEST) public void onPreUpdate(PreUpdateEvent e) { Raven.scriptManager.invoke("onPreUpdate", module); } - @SubscribeEvent + @SubscribeEvent(priority = EventPriority.HIGHEST) public void onPostUpdate(PostUpdateEvent e) { Raven.scriptManager.invoke("onPostUpdate", module); } - @SubscribeEvent + @SubscribeEvent(priority = EventPriority.HIGHEST) public void onRenderTick(TickEvent.RenderTickEvent e) { if (e.phase != TickEvent.Phase.END || !Utils.nullCheck()) { return; @@ -88,7 +89,7 @@ public class ScriptEvents { Raven.scriptManager.invoke("onRenderTick", module, e.renderTickTime); } - @SubscribeEvent + @SubscribeEvent(priority = EventPriority.HIGHEST) public void onGuiUpdate(GuiUpdateEvent e) { if (e.guiScreen == null) { return; @@ -96,7 +97,7 @@ public class ScriptEvents { Raven.scriptManager.invoke("onGuiUpdate", module, e.guiScreen.getClass().getSimpleName(), e.opened); } - @SubscribeEvent + @SubscribeEvent(priority = EventPriority.HIGHEST) public void onPreMotion(PreMotionEvent e) { PlayerState playerState = new PlayerState(e, (byte) 0); Raven.scriptManager.invoke("onPreMotion", module, playerState); @@ -115,7 +116,7 @@ public class ScriptEvents { e.setSneaking(playerState.isSneaking); } - @SubscribeEvent + @SubscribeEvent(priority = EventPriority.HIGHEST) public void onWorldJoin(EntityJoinWorldEvent e) { if (e.entity == null) { return; @@ -123,17 +124,17 @@ public class ScriptEvents { Raven.scriptManager.invoke("onWorldJoin", module, Entity.convert(e.entity)); } - @SubscribeEvent + @SubscribeEvent(priority = EventPriority.HIGHEST) public void onPostInput(PostPlayerInputEvent e) { Raven.scriptManager.invoke("onPostPlayerInput", module); } - @SubscribeEvent + @SubscribeEvent(priority = EventPriority.HIGHEST) public void onPostMotion(PostMotionEvent e) { Raven.scriptManager.invoke("onPostMotion", module); } - @SubscribeEvent + @SubscribeEvent(priority = EventPriority.HIGHEST) public void onMouse(MouseEvent e) { if (Raven.scriptManager.invokeBoolean("onMouse", module, e.button, e.buttonstate) == 0) { e.setCanceled(true); diff --git a/src/main/java/keystrokesmod/script/ScriptManager.java b/src/main/java/keystrokesmod/script/ScriptManager.java index 30f0ded..33b0a62 100644 --- a/src/main/java/keystrokesmod/script/ScriptManager.java +++ b/src/main/java/keystrokesmod/script/ScriptManager.java @@ -77,19 +77,24 @@ public class ScriptManager { } } else { - Iterator> iterator = scripts.entrySet().iterator(); - while (iterator.hasNext()) { - Map.Entry entry = iterator.next(); - String fileName = entry.getKey().file.getName(); - String hash = calculateHash(entry.getKey().file); + if (!this.scripts.isEmpty()) { + Iterator> iterator = scripts.entrySet().iterator(); + while (iterator.hasNext()) { + Map.Entry entry = iterator.next(); + String fileName = entry.getKey().file.getName(); + String hash = calculateHash(entry.getKey().file); - String cachedHash = loadedHashes.get(fileName); - if (cachedHash != null && cachedHash.equals(hash) && !entry.getKey().error) { - continue; // No changes detected, skip reloading + String cachedHash = loadedHashes.get(fileName); + if (cachedHash != null && cachedHash.equals(hash) && !entry.getKey().error) { + continue; // no changes detected, skip loading + } + entry.getKey().delete(); + iterator.remove(); + loadedHashes.remove(fileName); } - entry.getKey().delete(); - iterator.remove(); - loadedHashes.remove(fileName, hash); + } + else { + loadedHashes.clear(); } } diff --git a/src/main/java/keystrokesmod/script/classes/Bridge.java b/src/main/java/keystrokesmod/script/classes/Bridge.java index f02cfe7..a3c5687 100644 --- a/src/main/java/keystrokesmod/script/classes/Bridge.java +++ b/src/main/java/keystrokesmod/script/classes/Bridge.java @@ -4,7 +4,7 @@ import java.util.HashMap; import java.util.Map; public class Bridge { - private static final Map map = new HashMap<>();; + private static final Map map = new HashMap<>(); public void add(String key, Object value) { map.put(key, value); diff --git a/src/main/java/keystrokesmod/script/classes/Entity.java b/src/main/java/keystrokesmod/script/classes/Entity.java index 7827390..1a0a182 100644 --- a/src/main/java/keystrokesmod/script/classes/Entity.java +++ b/src/main/java/keystrokesmod/script/classes/Entity.java @@ -5,6 +5,7 @@ import net.minecraft.client.Minecraft; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.projectile.EntityFishHook; import net.minecraft.item.ItemBlock; import net.minecraft.potion.PotionEffect; @@ -74,10 +75,11 @@ public class Entity { } public boolean isHoldingBlock() { - if (this.isLiving) { - return ((EntityLivingBase) this.entity).getHeldItem() != null && ((EntityLivingBase) this.entity).getHeldItem().getItem() instanceof ItemBlock; - } - return false; + return this.isLiving && ((EntityLivingBase)this.entity).getHeldItem() != null && ((EntityLivingBase)this.entity).getHeldItem().getItem() instanceof ItemBlock; + } + + public boolean isHoldingWeapon() { + return this.isLiving && Utils.holdingWeapon((EntityLivingBase)this.entity); } public float getAbsorption() { @@ -132,6 +134,10 @@ public class Entity { return this.entity.getUniqueID().toString(); } + public String getCustomNameTag() { + return this.entity.getCustomNameTag(); + } + public double getBPS() { if (!this.isLiving) { return 0.0; @@ -230,7 +236,7 @@ public class Entity { } public NetworkPlayer getNetworkPlayer() { - return new NetworkPlayer(Minecraft.getMinecraft().getNetHandler().getPlayerInfo(this.entity.getUniqueID())); + return NetworkPlayer.convert(Minecraft.getMinecraft().getNetHandler().getPlayerInfo(this.entity.getUniqueID())); } public float getPitch() { @@ -314,6 +320,24 @@ public class Entity { return this.entity.isDead || (this.isLiving && ((EntityLivingBase)this.entity).deathTime > 0); } + public int getHunger() { + if (!this.isPlayer || ((EntityPlayer) this.entity).getFoodStats() == null) { + return 0; + } + return ((EntityPlayer) this.entity).getFoodStats().getFoodLevel(); + } + + public float getSaturation() { + if (!this.isPlayer || ((EntityPlayer) this.entity).getFoodStats() == null) { + return 0.0f; + } + return ((EntityPlayer) this.entity).getFoodStats().getSaturationLevel(); + } + + public float getAir() { + return this.entity.getAir(); + } + public boolean isInvisible() { return entity.isInvisible(); } @@ -326,6 +350,13 @@ public class Entity { return entity.isInLava(); } + public Entity getFisher() { + if (this.entity instanceof EntityFishHook) { + return convert(((EntityFishHook) this.entity).angler); + } + return null; + } + public boolean isInLiquid() { return !this.entity.isOffsetPositionInLiquid(0, 0, 0); } diff --git a/src/main/java/keystrokesmod/script/classes/Image.java b/src/main/java/keystrokesmod/script/classes/Image.java index 71c2203..c9ca7ce 100644 --- a/src/main/java/keystrokesmod/script/classes/Image.java +++ b/src/main/java/keystrokesmod/script/classes/Image.java @@ -51,6 +51,10 @@ public class Image { return this.bufferedImage != null; } + public static void clearCache() { + imageCache.clear(); + } + @Override public String toString() { return "Image(" + this.height + "," + this.width + "," + this.url + ")"; diff --git a/src/main/java/keystrokesmod/script/classes/ItemStack.java b/src/main/java/keystrokesmod/script/classes/ItemStack.java index 50ab8be..d3c8cf8 100644 --- a/src/main/java/keystrokesmod/script/classes/ItemStack.java +++ b/src/main/java/keystrokesmod/script/classes/ItemStack.java @@ -5,7 +5,6 @@ import net.minecraft.enchantment.Enchantment; import net.minecraft.enchantment.EnchantmentHelper; import net.minecraft.item.Item; import net.minecraft.item.ItemBlock; -import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.ResourceLocation; import net.minecraft.util.StatCollector; diff --git a/src/main/java/keystrokesmod/script/classes/NetworkPlayer.java b/src/main/java/keystrokesmod/script/classes/NetworkPlayer.java index bfbb535..208b833 100644 --- a/src/main/java/keystrokesmod/script/classes/NetworkPlayer.java +++ b/src/main/java/keystrokesmod/script/classes/NetworkPlayer.java @@ -2,45 +2,46 @@ package keystrokesmod.script.classes; import com.google.common.collect.Iterables; import com.mojang.authlib.properties.Property; +import net.minecraft.client.Minecraft; import net.minecraft.client.network.NetworkPlayerInfo; import net.minecraft.scoreboard.ScorePlayerTeam; import java.nio.charset.StandardCharsets; import java.util.Base64; +import java.util.HashMap; public class NetworkPlayer { - private NetworkPlayerInfo networkPlayerInfo; - public NetworkPlayer(NetworkPlayerInfo networkPlayerInfo) { - this.networkPlayerInfo = networkPlayerInfo; + private NetworkPlayerInfo playerInfo; + private static HashMap cache = new HashMap<>(); + + public NetworkPlayer(NetworkPlayerInfo playerInfo) { + this.playerInfo = playerInfo; } public String getCape() { - return networkPlayerInfo.getLocationCape().getResourcePath(); + return playerInfo.getLocationCape().getResourcePath(); } public String getDisplayName() { - if (networkPlayerInfo == null) { - return ""; - } - return networkPlayerInfo.getDisplayName() != null ? networkPlayerInfo.getDisplayName().getFormattedText() : ScorePlayerTeam.formatPlayerName(networkPlayerInfo.getPlayerTeam(), networkPlayerInfo.getGameProfile().getName()); + return (this.playerInfo.getGameProfile() == Minecraft.getMinecraft().thePlayer.getGameProfile()) ? Minecraft.getMinecraft().thePlayer.getDisplayName().getUnformattedText() : ScorePlayerTeam.formatPlayerName(this.playerInfo.getPlayerTeam(), this.getName()); } public String getName() { - if (networkPlayerInfo == null) { + if (playerInfo == null) { return ""; } - return networkPlayerInfo.getGameProfile().getName(); + return playerInfo.getGameProfile().getName(); } public int getPing() { - if (networkPlayerInfo == null) { + if (playerInfo == null) { return 0; } - return networkPlayerInfo.getResponseTime(); + return playerInfo.getResponseTime(); } public String getSkinData() { - final Property texture = (Property) Iterables.getFirst(networkPlayerInfo.getGameProfile().getProperties().get("textures"), (Object)null); + final Property texture = (Property) Iterables.getFirst(playerInfo.getGameProfile().getProperties().get("textures"), (Object)null); if (texture == null) { return null; } @@ -48,9 +49,27 @@ public class NetworkPlayer { } public String getUUID() { - if (networkPlayerInfo == null) { + if (playerInfo == null) { return ""; } - return networkPlayerInfo.getGameProfile().getId().toString(); + return playerInfo.getGameProfile().getId().toString(); + } + + public static NetworkPlayer convert(NetworkPlayerInfo networkPlayerInfo) { + if (networkPlayerInfo == null) { + return null; + } + String id = networkPlayerInfo.getGameProfile().getId().toString(); + NetworkPlayer cachedEntity = cache.get(id); + + if (cachedEntity == null) { + cachedEntity = new NetworkPlayer(networkPlayerInfo); + cache.put(id, cachedEntity); + } + return cachedEntity; + } + + public static void clearCache() { + cache.clear(); } } diff --git a/src/main/java/keystrokesmod/script/classes/Request.java b/src/main/java/keystrokesmod/script/classes/Request.java index b54030a..c6e8159 100644 --- a/src/main/java/keystrokesmod/script/classes/Request.java +++ b/src/main/java/keystrokesmod/script/classes/Request.java @@ -1,9 +1,11 @@ package keystrokesmod.script.classes; -import java.io.IOException; -import java.io.OutputStream; +import keystrokesmod.utility.NetworkUtils; + +import java.io.*; import java.net.HttpURLConnection; import java.net.URL; +import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.List; @@ -30,8 +32,11 @@ public class Request { } - public void addHeader(String header, String value) { - this.headers.add(new String[]{header, value}); + public void addHeader(final String header, final String value) { + if (this.headers == null) { + this.headers = new ArrayList<>(); + } + this.headers.add(new String[] { header, value }); } public void setUserAgent(String userAgent) { @@ -51,44 +56,104 @@ public class Request { } public Response fetch() { - HttpURLConnection con = null; - try { - URL url = new URL(this.url); - con = (HttpURLConnection) url.openConnection(); - con.setRequestMethod(this.method); - if (!userAgent.isEmpty()) { - con.setRequestProperty("User-Agent", this.userAgent); + if (!this.url.isEmpty()) { + HttpURLConnection con = null; + try { + final URL url = new URL(this.url); + con = (HttpURLConnection)url.openConnection(); + con.setRequestMethod(this.method); + con.setConnectTimeout(this.connectionTimeout); + con.setReadTimeout(this.readTimeout); + con.setRequestProperty("User-Agent", this.userAgent.isEmpty() ? NetworkUtils.CHROME_USER_AGENT : this.userAgent); + if (this.headers != null && !this.headers.isEmpty()) { + for (final String[] header : this.headers) { + con.setRequestProperty(header[0], header[1]); + } + } + if (this.method.equals("POST") && !this.content.isEmpty()) { + con.setDoOutput(true); + final byte[] out = this.content.getBytes(StandardCharsets.UTF_8); + con.setFixedLengthStreamingMode(out.length); + con.setRequestProperty("Content-Type", "application/json; charset=UTF-8"); + con.connect(); + final OutputStream os = con.getOutputStream(); + try { + os.write(out); + if (os != null) { + os.close(); + } + } + catch (Throwable t) { + if (os != null) { + try { + os.close(); + } + catch (Throwable t2) { + t.addSuppressed(t2); + } + } + throw t; + } + } + String contents = ""; + try { + final BufferedReader br = new BufferedReader(new InputStreamReader(con.getInputStream())); + try { + final StringBuilder sb = new StringBuilder(); + String input; + while ((input = br.readLine()) != null) { + sb.append(input); + } + contents = sb.toString(); + br.close(); + } + catch (Throwable t3) { + try { + br.close(); + } + catch (Throwable t4) { + t3.addSuppressed(t4); + } + throw t3; + } + } + catch (IOException er1) { + InputStream errorStream = con.getErrorStream(); + if (errorStream != null) { + try { + final BufferedReader errorReader = new BufferedReader(new InputStreamReader(errorStream)); + try { + final StringBuilder sb2 = new StringBuilder(); + String input2; + while ((input2 = errorReader.readLine()) != null) { + sb2.append(input2); + } + contents = sb2.toString(); + errorReader.close(); + } + catch (Throwable t5) { + try { + errorReader.close(); + } + catch (Throwable t6) { + t5.addSuppressed(t6); + } + throw t5; + } + } + catch (IOException ex) {} + } + } + return new Response(con.getResponseCode(), contents); } - if (headers != null && !headers.isEmpty()) { - for (String[] header : headers) { - con.setRequestProperty(header[0], header[1]); + catch (IOException ex2) {} + finally { + if (con != null) { + con.disconnect(); } } - if (connectionTimeout > 0) { - con.setConnectTimeout(connectionTimeout); - } - if (readTimeout > 0) { - con.setReadTimeout(readTimeout); - } - if (!content.isEmpty() && method.equals("POST")) { - con.setDoOutput(true); - OutputStream stream = con.getOutputStream(); - stream.write(content.getBytes()); - stream.close(); - con.getInputStream().close(); - } - } catch (IOException iOException) { - iOException.printStackTrace(); } - finally { - if (con != null) { - con.disconnect(); - } - } - if (con == null) { - return null; - } - return new Response(con); + return null; } @Override diff --git a/src/main/java/keystrokesmod/script/classes/Response.java b/src/main/java/keystrokesmod/script/classes/Response.java index 305415b..0fa24aa 100644 --- a/src/main/java/keystrokesmod/script/classes/Response.java +++ b/src/main/java/keystrokesmod/script/classes/Response.java @@ -1,37 +1,28 @@ package keystrokesmod.script.classes; -import com.google.gson.JsonParser; -import keystrokesmod.utility.NetworkUtils; - -import java.io.IOException; -import java.net.HttpURLConnection; - public class Response { - private HttpURLConnection connection; + private int responseCode; + private String contents; - protected Response(HttpURLConnection connection) { - this.connection = connection; + public Response(int responseCode, String contents) { + this.responseCode = responseCode; + this.contents = contents; } public int code() { - try { - return this.connection.getResponseCode(); - } - catch (IOException e) { - return 0; - } + return this.responseCode; } public String string() { - return NetworkUtils.getTextFromConnection(this.connection, false); + return this.contents; } public Json json() { - return new Json((new JsonParser()).parse(NetworkUtils.getTextFromConnection(this.connection, false)).getAsJsonObject(), (byte) 0); + return (this.contents == null) ? null : new Json(this.contents); } @Override public String toString() { - return "Response(" + this.code() + ")"; + return "Response(" + this.responseCode + ")"; } } diff --git a/src/main/java/keystrokesmod/script/classes/TileEntity.java b/src/main/java/keystrokesmod/script/classes/TileEntity.java index 10f6841..3fec9a1 100644 --- a/src/main/java/keystrokesmod/script/classes/TileEntity.java +++ b/src/main/java/keystrokesmod/script/classes/TileEntity.java @@ -21,16 +21,18 @@ public class TileEntity { } public Object[] getSkullData() { - if (!(this.tileEntity instanceof TileEntitySkull)) { - return null; + if (this.tileEntity instanceof TileEntitySkull) { + final TileEntitySkull skull = (TileEntitySkull)this.tileEntity; + final Object[] skullData = { skull.getSkullType(), skull.getSkullRotation(), null, null, null }; + if (skull.getPlayerProfile() == null) { + skullData[2] = (skullData[3] = null); + } + else { + skullData[2] = skull.getPlayerProfile().getName(); + skullData[3] = skull.getPlayerProfile().getId(); + } + return skullData; } - TileEntitySkull skull = (TileEntitySkull) this.tileEntity; - String name = ""; - String uuid = ""; - if (skull.getPlayerProfile() != null) { - name = skull.getPlayerProfile().getName(); - uuid = skull.getPlayerProfile().getId().toString(); - } - return new Object[] { skull.getSkullType(), skull.getSkullRotation(), name, uuid }; + return null; } } diff --git a/src/main/java/keystrokesmod/script/classes/World.java b/src/main/java/keystrokesmod/script/classes/World.java deleted file mode 100644 index ef3eee5..0000000 --- a/src/main/java/keystrokesmod/script/classes/World.java +++ /dev/null @@ -1,100 +0,0 @@ -package keystrokesmod.script.classes; - -import keystrokesmod.utility.BlockUtils; -import keystrokesmod.utility.Utils; -import net.minecraft.client.Minecraft; -import net.minecraft.client.network.NetworkPlayerInfo; -import net.minecraft.init.Blocks; -import net.minecraft.scoreboard.Team; -import net.minecraft.util.BlockPos; - -import java.util.*; - -public class World { - private Minecraft mc = Minecraft.getMinecraft(); - - public Block getBlockAt(int x, int y, int z) { - net.minecraft.block.Block block = BlockUtils.getBlock(new BlockPos(x, y, z)); - if (block == null) { - return new Block(Blocks.air, new BlockPos(x, y, z)); - } - return new Block(block, new BlockPos(x, y, z)); - - } - - public Block getBlockAt(Vec3 pos) { - net.minecraft.block.Block block = BlockUtils.getBlock(new BlockPos(pos.x, pos.y, pos.z)); - if (block == null) { - return new Block(Blocks.air, new BlockPos(pos.x, pos.y, pos.z)); - } - return new Block(block, new BlockPos(pos.x, pos.y, pos.z)); - } - - public String getDimension() { - if (mc.theWorld == null) { - return ""; - } - return mc.theWorld.provider.getDimensionName(); - } - - public List getEntities() { - List entities = new ArrayList<>(); - for (net.minecraft.entity.Entity entity : mc.theWorld.loadedEntityList) { - entities.add(Entity.convert(entity)); - } - return entities; - } - - public Entity getEntityById(int entityId) { - for (net.minecraft.entity.Entity entity : mc.theWorld.loadedEntityList) { - if (entity.getEntityId() == entityId) { - return Entity.convert(entity); - } - } - return null; - } - - public List getNetworkPlayers() { - List entities = new ArrayList<>(); - for (NetworkPlayerInfo networkPlayerInfo : Utils.getTablist(false)) { - entities.add(new NetworkPlayer(networkPlayerInfo)); - } - return entities; - } - - public List getPlayerEntities() { - List entities = new ArrayList<>(); - for (net.minecraft.entity.Entity entity : mc.theWorld.playerEntities) { - entities.add(Entity.convert(entity)); - } - return entities; - } - - public List getScoreboard() { - List sidebarLines = Utils.getSidebarLines(); - if (sidebarLines.isEmpty()) { - return null; - } - return sidebarLines; - } - - public Map> getTeams() { - Map> teams = new HashMap<>(); - for (Team team : mc.theWorld.getScoreboard().getTeams()) { - List members = new ArrayList<>(); - for (String member : team.getMembershipCollection()) { - members.add(member); - } - teams.put(team.getRegisteredName(), members); - } - return teams; - } - - public List getTileEntities() { - List tileEntities = new ArrayList<>(); - for (net.minecraft.tileentity.TileEntity entity : mc.theWorld.loadedTileEntityList) { - tileEntities.add(new TileEntity(entity)); - } - return tileEntities; - } -} diff --git a/src/main/java/keystrokesmod/script/packets/clientbound/S3E.java b/src/main/java/keystrokesmod/script/packets/clientbound/S3E.java index 7f4dd9e..18d683b 100644 --- a/src/main/java/keystrokesmod/script/packets/clientbound/S3E.java +++ b/src/main/java/keystrokesmod/script/packets/clientbound/S3E.java @@ -18,15 +18,15 @@ public class S3E extends SPacket { public S3E(S3EPacketTeams packet) { super(packet); - this.name = packet.func_149312_c(); - this.displayName = packet.func_149306_d(); - this.prefix = packet.func_149311_e(); - this.suffix = packet.func_149309_f(); - this.nametagVisibility = packet.func_179814_i(); - this.playerList = packet.func_149310_g(); - this.action = packet.func_149307_h(); - this.friendlyFlags = packet.func_149308_i(); - this.color = packet.func_179813_h(); + this.name = packet.getName(); + this.displayName = packet.getDisplayName(); + this.prefix = packet.getPrefix(); + this.suffix = packet.getSuffix(); + this.nametagVisibility = packet.getNameTagVisibility(); + this.playerList = packet.getPlayers(); + this.action = packet.getAction(); + this.friendlyFlags = packet.getFriendlyFlags(); + this.color = packet.getColor(); } public S3E(Packet packet, String name, String displayName, String prefix, String suffix, String nametagVisibility, Collection playerList, int action, int friendlyFlags, int color) { diff --git a/src/main/java/keystrokesmod/script/packets/serverbound/PacketHandler.java b/src/main/java/keystrokesmod/script/packets/serverbound/PacketHandler.java index a5cbf2e..a1f5f5c 100644 --- a/src/main/java/keystrokesmod/script/packets/serverbound/PacketHandler.java +++ b/src/main/java/keystrokesmod/script/packets/serverbound/PacketHandler.java @@ -101,6 +101,12 @@ public class PacketHandler { 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); + } else { sPacket = new SPacket(packet); } diff --git a/src/main/java/keystrokesmod/utility/BlockUtils.java b/src/main/java/keystrokesmod/utility/BlockUtils.java index 1359d4f..bea71e5 100644 --- a/src/main/java/keystrokesmod/utility/BlockUtils.java +++ b/src/main/java/keystrokesmod/utility/BlockUtils.java @@ -29,7 +29,7 @@ public class BlockUtils { } public static boolean isInteractable(Block block) { - return block instanceof BlockFurnace || block instanceof BlockTrapDoor || block instanceof BlockDoor || block instanceof BlockContainer || block instanceof BlockJukebox || block instanceof BlockFenceGate || block instanceof BlockChest || block instanceof BlockEnderChest || block instanceof BlockEnchantmentTable || block instanceof BlockBrewingStand || block instanceof BlockBed || block instanceof BlockDropper || block instanceof BlockDispenser || block instanceof BlockHopper || block instanceof BlockAnvil || block instanceof BlockNote || block instanceof BlockWorkbench; + return block instanceof BlockFurnace || block instanceof BlockTrapDoor || block instanceof BlockDoor || block instanceof BlockContainer || block instanceof BlockJukebox || block instanceof BlockFenceGate || block instanceof BlockChest || block instanceof BlockEnderChest || block instanceof BlockEnchantmentTable || block instanceof BlockBrewingStand || block instanceof BlockBed || block instanceof BlockDropper || block instanceof BlockDispenser || block instanceof BlockHopper || block instanceof BlockAnvil || block instanceof BlockNote || block instanceof BlockWorkbench || block instanceof BlockButton; } public static boolean isInteractable(MovingObjectPosition mv) { @@ -38,8 +38,7 @@ public class BlockUtils { } IBlockState iblockstate = mc.theWorld.getBlockState(mv.getBlockPos()); if (!mc.thePlayer.isSneaking() || mc.thePlayer.getHeldItem() == null || mc.thePlayer.getHeldItem().getItem().doesSneakBypassUse(mc.theWorld, mv.getBlockPos(), mc.thePlayer)) { - Vec3 hitVec = getHitVec(mv.hitVec, mv.getBlockPos()); - return iblockstate.getBlock().onBlockActivated(mc.theWorld, mv.getBlockPos(), iblockstate, mc.thePlayer, mv.sideHit, (float) hitVec.xCoord, (float) hitVec.yCoord, (float) hitVec.zCoord); + return isInteractable(iblockstate.getBlock()); } return false; } diff --git a/src/main/java/keystrokesmod/utility/ModuleUtils.java b/src/main/java/keystrokesmod/utility/ModuleUtils.java index 4e59929..838fcb7 100644 --- a/src/main/java/keystrokesmod/utility/ModuleUtils.java +++ b/src/main/java/keystrokesmod/utility/ModuleUtils.java @@ -61,8 +61,6 @@ public class ModuleUtils { @SubscribeEvent public void onPreUpdate(PreUpdateEvent e) { - inAirTicks = mc.thePlayer.onGround ? 0 : ++inAirTicks; - if (LongJump.slotReset && ++LongJump.slotResetTicks >= 2) { LongJump.stopKillAura = false; LongJump.stopScaffold = false; @@ -94,6 +92,8 @@ public class ModuleUtils { @SubscribeEvent public void onPreMotion(PreMotionEvent e) { + inAirTicks = mc.thePlayer.onGround ? 0 : ++inAirTicks; + // 7 tick needs to always finish the motion or itll lag back if (!ModuleManager.bhop.isEnabled() && ModuleManager.bhop.mode.getInput() == 3 && ModuleManager.bhop.didMove) { int simpleY = (int) Math.round((e.posY % 1) * 10000); @@ -127,7 +127,7 @@ public class ModuleUtils { } if (ModuleManager.bhop.rotateYawOption.isToggled()) { if (ModuleManager.bhop.setRotation) { - if (!ModuleManager.killAura.isTargeting && !Utils.noSlowingBackWithBow() && !ModuleManager.scaffold.isEnabled) { + if (!ModuleManager.killAura.isTargeting && !Utils.noSlowingBackWithBow() && !ModuleManager.scaffold.isEnabled && !mc.thePlayer.isCollidedHorizontally) { float playerYaw = mc.thePlayer.rotationYaw; e.setYaw(playerYaw -= 55); } diff --git a/src/main/java/keystrokesmod/utility/NetworkUtils.java b/src/main/java/keystrokesmod/utility/NetworkUtils.java index 216cee5..2cbc611 100644 --- a/src/main/java/keystrokesmod/utility/NetworkUtils.java +++ b/src/main/java/keystrokesmod/utility/NetworkUtils.java @@ -17,7 +17,7 @@ public class NetworkUtils { public static String API_KEY = ""; private static final Pattern OGP_IMAGE_REGEX = Pattern.compile(".+?)\".*?/?>"); private static final Pattern IMG_TAG_REGEX = Pattern.compile(".+?)\".*?>"); - private 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 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); diff --git a/src/main/java/keystrokesmod/utility/Reflection.java b/src/main/java/keystrokesmod/utility/Reflection.java index 4c44195..aaa0609 100644 --- a/src/main/java/keystrokesmod/utility/Reflection.java +++ b/src/main/java/keystrokesmod/utility/Reflection.java @@ -3,6 +3,7 @@ package keystrokesmod.utility; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiEnchantment; import net.minecraft.client.gui.GuiIngame; +import net.minecraft.client.gui.GuiPlayerTabOverlay; import net.minecraft.client.gui.GuiScreenBook; import net.minecraft.client.gui.inventory.GuiBrewingStand; import net.minecraft.client.gui.inventory.GuiDispenser; @@ -20,7 +21,6 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.projectile.EntityArrow; import net.minecraft.inventory.*; import net.minecraft.item.ItemFood; -import net.minecraft.network.Packet; import net.minecraft.network.play.client.C01PacketChatMessage; import net.minecraft.network.play.client.C02PacketUseEntity; import net.minecraft.network.play.server.S08PacketPlayerPosLook; @@ -37,7 +37,6 @@ import java.nio.ByteBuffer; import java.util.*; public class Reflection { - public static Field title; public static Field button; public static Field buttonstate; public static Field buttons; @@ -56,23 +55,24 @@ public class Reflection { public static Field inGround; public static Method getFOVModifier; public static Field itemInUseCount; + public static Field displayedTitle; + public static Field displayedSubTitle; public static Field S08PacketPlayerPosLookYaw; public static Field S08PacketPlayerPosLookPitch; public static Field C02PacketUseEntityEntityId; + public static Field recordPlaying; public static Field bookContents; - public static Field classTarget; public static Field fallDistance; + public static Field tabHeader; + public static Field tabFooter; public static Field thirdPersonDistance; public static Field alwaysEdible; public static Field mcGuiInGame; - public static Field targetEntity; - public static Field targetTasks; - public static Field executingTaskEntries; public static Field C01PacketChatMessageMessage; public static HashMap containerInventoryPlayer = new HashMap<>(); private static List containerClasses = Arrays.asList(GuiFurnace.class, GuiBrewingStand.class, GuiEnchantment.class, ContainerHopper.class, GuiDispenser.class, ContainerWorkbench.class, ContainerMerchant.class, ContainerHorseInventory.class); public static boolean sendMessage = false; - public static Map keyBindings = new HashMap<>(); + public static Map keybinds = new HashMap<>(); public static void getFields() { try { @@ -86,12 +86,6 @@ public class Reflection { leftClickCounter.setAccessible(true); } - title = ReflectionHelper.findField(GuiIngame.class, "field_175201_x", "screenTitle"); - - if (title != null) { - title.setAccessible(true); - } - jumpTicks = ReflectionHelper.findField(EntityLivingBase.class, "field_70773_bE", "jumpTicks"); if (jumpTicks != null) { @@ -104,37 +98,49 @@ public class Reflection { rightClickDelayTimerField.setAccessible(true); } + displayedTitle = ReflectionHelper.findField(GuiIngame.class, "field_175201_x", "displayedTitle"); + + if (displayedTitle != null) { + displayedTitle.setAccessible(true); + } + + displayedSubTitle = ReflectionHelper.findField(GuiIngame.class, "field_175200_y", "displayedSubTitle"); + + if (displayedSubTitle != null) { + displayedSubTitle.setAccessible(true); + } + + tabHeader = ReflectionHelper.findField(GuiPlayerTabOverlay.class, "header", "field_175256_i"); + if (tabHeader != null) { + tabHeader.setAccessible(true); + } + + tabFooter = ReflectionHelper.findField(GuiPlayerTabOverlay.class, "footer", "field_175255_h"); + if (tabFooter != null) { + tabFooter.setAccessible(true); + } + C01PacketChatMessageMessage = ReflectionHelper.findField(C01PacketChatMessage.class, "field_149440_a", "message"); if (C01PacketChatMessageMessage != null) { C01PacketChatMessageMessage.setAccessible(true); } + recordPlaying = ReflectionHelper.findField(GuiIngame.class, "recordPlaying", "field_73838_g"); + if (recordPlaying != null) { + recordPlaying.setAccessible(true); + } + curBlockDamageMP = ReflectionHelper.findField(PlayerControllerMP.class, "field_78770_f", "curBlockDamageMP"); // fastmine and mining related stuff if (curBlockDamageMP != null) { curBlockDamageMP.setAccessible(true); } - classTarget = ReflectionHelper.findField(EntityAIAttackOnCollide.class, "field_75444_h", "classTarget"); - if (classTarget != null) { - classTarget.setAccessible(true); - } - blockHitDelay = ReflectionHelper.findField(PlayerControllerMP.class, "field_78781_i", "blockHitDelay"); if (blockHitDelay != null) { blockHitDelay.setAccessible(true); } - targetEntity = ReflectionHelper.findField(EntityAINearestAttackableTarget.class, "targetEntity", "field_75309_a"); - if (targetEntity != null) { - targetEntity.setAccessible(true); - } - - targetTasks = ReflectionHelper.findField(EntityLiving.class, "targetTasks", "field_70715_bh"); - if (targetTasks != null) { - targetTasks.setAccessible(true); - } - fallDistance = ReflectionHelper.findField(Entity.class, "fallDistance", "field_70143_R"); if (fallDistance != null) { fallDistance.setAccessible(true); @@ -145,11 +151,6 @@ public class Reflection { mcGuiInGame.setAccessible(true); } - executingTaskEntries = ReflectionHelper.findField(EntityAITasks.class, "executingTaskEntries", "field_75780_b"); - if (executingTaskEntries != null) { - executingTaskEntries.setAccessible(true); - } - shaderResourceLocations = ReflectionHelper.findField(EntityRenderer.class, "shaderResourceLocations", "field_147712_ad"); if (shaderResourceLocations != null) { shaderResourceLocations.setAccessible(true); @@ -219,8 +220,9 @@ public class Reflection { } public static void setKeyBindings() { - for (KeyBinding keyBinding : Minecraft.getMinecraft().gameSettings.keyBindings) { - keyBindings.put(keyBinding, keyBinding.getKeyDescription().substring(4)); + for (KeyBinding keyBind : Minecraft.getMinecraft().gameSettings.keyBindings) { + String keyName = keyBind.getKeyDescription().replaceFirst("key\\.", ""); + keybinds.put(keyName, keyBind); } } @@ -338,6 +340,15 @@ public class Reflection { return blocking; } + public static void setItemInUseCount(int count) { + try { + itemInUseCount.set(Minecraft.getMinecraft().thePlayer, count); + } + catch (Exception e) { + e.printStackTrace(); + } + } + public static boolean setupCameraTransform(EntityRenderer entityRenderer, float partialTicks, int eyeIndex) { try { if (setupCameraTransform == null) { @@ -351,17 +362,4 @@ public class Reflection { } return false; } - - public static Entity getClassTarget(EntityAIAttackOnCollide task) { - try { - if (classTarget != null) { - Entity targetEntity = (Entity) classTarget.get(task); - return targetEntity; - } - } - catch (Exception e) { - e.printStackTrace(); - } - return null; - } } diff --git a/src/main/java/keystrokesmod/utility/Utils.java b/src/main/java/keystrokesmod/utility/Utils.java index 5b1f2df..ee747f9 100644 --- a/src/main/java/keystrokesmod/utility/Utils.java +++ b/src/main/java/keystrokesmod/utility/Utils.java @@ -589,7 +589,7 @@ public class Utils { public static String getTitle() { try { - return (String) Reflection.title.get(mc.ingameGUI); + return (String) Reflection.displayedTitle.get(mc.ingameGUI); } catch (IllegalAccessException ex) { ex.printStackTrace(); } @@ -1194,10 +1194,14 @@ public class Utils { } public static boolean holdingWeapon() { - if (mc.thePlayer.getHeldItem() == null) { + return holdingWeapon(mc.thePlayer); + } + + public static boolean holdingWeapon(EntityLivingBase entityLivingBase) { + if (entityLivingBase.getHeldItem() == null) { return false; } - Item getItem = mc.thePlayer.getHeldItem().getItem(); + Item getItem = entityLivingBase.getHeldItem().getItem(); return getItem instanceof ItemSword || (Settings.weaponAxe.isToggled() && getItem instanceof ItemAxe) || (Settings.weaponRod.isToggled() && getItem instanceof ItemFishingRod) || (Settings.weaponStick.isToggled() && getItem == Items.stick); } @@ -1340,26 +1344,6 @@ public class Utils { return new int[] { Mouse.getX(), Mouse.getY() }; } - public static boolean isPressed(String key) { - for (Map.Entry map : Reflection.keyBindings.entrySet()) { - if (map.getValue().equals(key)) { - return map.getKey().isKeyDown(); - } - } - return false; - } - - public static void setPressed(String key, boolean pressed) { - for (Map.Entry map : Reflection.keyBindings.entrySet()) { - if (map.getValue().equals(key)) { - KeyBinding.setKeyBindState(map.getKey().getKeyCode(), pressed); - if (pressed) { - KeyBinding.onTick(map.getKey().getKeyCode()); - } - } - } - } - public static int getKeyCode(String key) { return Keyboard.getKeyIndex(key); } @@ -1394,6 +1378,10 @@ public class Utils { return false; } + public static String asWholeNum(double input) { + return isWholeNumber(input) ? (int) input + "" : String.valueOf(input); + } + public static boolean isBedwarsPractice() { if (Utils.isHypixel()) { if (!Utils.nullCheck()) {