CCBlueX Forum

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups

    AutoGapple(re-upload) (Legacy)

    Scripts
    8
    19
    1626
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • LolMC
      LolMC last edited by LolMC

      AutoGapple
      Version:1.3;1.4
      Description:Auto eat Gapple when your health too low
      Changlog:

      • 1.0 : first release(no more release old code lol)
      • 1.1 : fix script lock the hotbar when regen effect active
        fix script sometime block the sword(i think i doesn't fix that)
        -1.2:make by commandblock2(but cant unblock when no Gapple)
        -1.3:fix unable to block manully when no gapple in inventory(iam too lazy to writing code without Core)
        -1.4:update eat slient mode(i learn it from jigsaw src),iam lazy to covert 1.3 to 1.4(someone can do that help me)
      //Copyright 2020 commandblock2 distributed under AGPL-3.0-or-later
      GuiInventory = Java.type("net.minecraft.client.gui.inventory.GuiInventory")
      Potion = Java.type('net.minecraft.potion.Potion')
      
      var originalIndex = null
      var inventoryIndex = null
      module =
      {
          name: "AutoGapple",
          description: "Eat gapple when your health is low",
          author: "commandblock2 && Lolmc",
          category: "combat",
          values:
              [
                  health = value.createFloat("Health", 10, 1, 20),
                  itemSwitchDelay = value.createInteger("SwitchDelayms", 100, 0, 1000)
              ],
      
          onUpdate: function () {
              if (mc.thePlayer.getHealth() <= health.get() && !mc.thePlayer.isPotionActive(Potion.regeneration)) {
                  gAppleIndex = InventoryUtils.findItem(36, 45, Items.golden_apple)
                  gAppleIndex = gAppleIndex == -1 ? InventoryUtils.findItem(9, 36, Items.golden_apple) : gAppleIndex
      
                  if (originalIndex == null) { // wtffffff have to check null because if (originalIndex) doesn't work when it equas to 0
                      originalIndex = mc.thePlayer.inventory.currentItem
                  }
      
      
                  if (gAppleIndex >= 36 && gAppleIndex < 45) {
                      //switch to gapple
                      mc.thePlayer.inventory.currentItem = gAppleIndex - 36
      
                  } else if (gAppleIndex >= 9 && gAppleIndex < 36 && !(mc.currentScreen instanceof GuiInventory)) {
                      //switch gapple and 36 (first slot)
                      inventoryIndex = gAppleIndex
                      switchGapple(inventoryIndex)
                  }
                  if(gAppleIndex != -1) {    // fix block when no gapple
                  mc.gameSettings.keyBindUseItem.pressed = true
             }
      
              }
              else {
                  reset()
              }
          }
      }
      function reset() {
          if (originalIndex != null || inventoryIndex != null)
              mc.gameSettings.keyBindUseItem.pressed = false
      
          if (originalIndex != null ) {
              mc.thePlayer.inventory.currentItem = originalIndex;
              originalIndex = null
          }
      
          if (inventoryIndex != null) {
              switchGapple(inventoryIndex)
              inventoryIndex = null
          }
      
      }
      
      function switchGapple(index) {
          //open inventory (I don't care about when you are on horse, implement it yourself)
          mc.getNetHandler().addToSendQueue(new C16PacketClientStatus(C16PacketClientStatus.EnumState.OPEN_INVENTORY_ACHIEVEMENT));
          mc.displayGuiScreen(new GuiInventory(mc.thePlayer));
      
          timeout(itemSwitchDelay.get(), function () {
              slot = mc.thePlayer.inventoryContainer.getSlot(index)
      
              mc.playerController.windowClick(mc.currentScreen.inventorySlots.windowId, slot.slotNumber, 0, 2, mc.thePlayer)
              mc.thePlayer.closeScreen()
          })
      }
      
      script.import("Core.lib")
      
      

      1.4 code:

      //Copyright 2020 commandblock2 distributed under AGPL-3.0-or-later
      GuiInventory = Java.type("net.minecraft.client.gui.inventory.GuiInventory")
      Potion = Java.type('net.minecraft.potion.Potion')
      C09PacketHeldItemChange = Java.type('net.minecraft.network.play.client.C09PacketHeldItemChange')
      C03PacketPlayer = Java.type('net.minecraft.network.play.client.C03PacketPlayer')
      C08PacketPlayerBlockPlacement = Java.type('net.minecraft.network.play.client.C08PacketPlayerBlockPlacement')
      MStimer = Java.type('net.ccbluex.liquidbounce.utils.timer.MSTimer')
      var tick = 0
      var originalIndex = null
      var inventoryIndex = null
      module =
      {
          name: "AutoGapplev2",
          description: "Eat gapple when your health is low",
          author: "Lolmc",
          category: "Player",
          values:
              [
                  health = value.createFloat("Health", 10, 1, 20),
                  itemSwitchDelay = value.createInteger("Tick", 100, 0, 1000)
              ],
      
          onUpdate: function () {
              var timer = new MSTimer()
              //if(!timer.hasTimePassed(itemSwitchDelay.get())) 
                // return;
                tick++
                if (mc.thePlayer.getHealth() > health.get()) {
                  tick = 0
              }
      
              if (mc.thePlayer.getHealth() <= health.get() && tick == itemSwitchDelay.get()) {
                   
                 
                 
                  gAppleIndex = InventoryUtils.findItem(36, 45, Items.golden_apple)
                  gAppleIndex = gAppleIndex == -1 ? InventoryUtils.findItem(9, 36, Items.golden_apple) : gAppleIndex
      
                  if(gAppleIndex != -1) {
                  mc.thePlayer.sendQueue.addToSendQueue(new C09PacketHeldItemChange(gAppleIndex - 36));
                  mc.thePlayer.sendQueue.addToSendQueue(new C08PacketPlayerBlockPlacement(mc.thePlayer.inventory.mainInventory[gAppleIndex - 36]));
                  for (var i = 0; i < 32; i++) {
                  mc.thePlayer.sendQueue.addToSendQueue(new C03PacketPlayer());
                  }
                  //mc.playerController.onStoppedUsingItem(mc.thePlayer);
                  mc.thePlayer.stopUsingItem();
                  mc.thePlayer.sendQueue.addToSendQueue(new C09PacketHeldItemChange(mc.thePlayer.inventory.currentItem));
                  tick = 0
                  }
                  
                  } else if (gAppleIndex >= 9 && gAppleIndex < 36 && !(mc.currentScreen instanceof GuiInventory)) {
                      //switch gapple and 36 (first slot)
                      inventoryIndex = gAppleIndex
                      switchGapple(inventoryIndex)
                      tick = 0
                      return;
                  }
              }
          }
      
      
      function reset() {
          if (originalIndex != null || inventoryIndex != null)
              mc.gameSettings.keyBindUseItem.pressed = false
      
          if (originalIndex != null ) {
              mc.thePlayer.inventory.currentItem = originalIndex;
              originalIndex = null
          }
      
          if (inventoryIndex != null) {
              switchGapple(inventoryIndex)
              inventoryIndex = null
          }
      
      }
      
      function switchGapple(index) {
          //open inventory (I don't care about when you are on horse, implement it yourself)
          mc.getNetHandler().addToSendQueue(new C16PacketClientStatus(C16PacketClientStatus.EnumState.OPEN_INVENTORY_ACHIEVEMENT));
          mc.displayGuiScreen(new GuiInventory(mc.thePlayer));
      
          timeout(itemSwitchDelay.get(), function () {
              slot = mc.thePlayer.inventoryContainer.getSlot(index)
      
              mc.playerController.windowClick(mc.currentScreen.inventorySlots.windowId, slot.slotNumber, 0, 2, mc.thePlayer)
              mc.thePlayer.closeScreen()
          })
      }
      
      script.import("Core.lib")
      

      Core: Download

      1 Reply Last reply Reply Quote 1
      • ChocoPie_isme
        ChocoPie_isme Banned last edited by

        it's in my script bag

        1 Reply Last reply Reply Quote 0
        • C
          commandblock2 last edited by commandblock2

          Many thanks to Lolmc, his ideas inspired me of how I can make a AutoGapple
          I have rewritten this using scriptAPIv1/Core.lib with 2 more function.

          • Automatically go back to the original slot instead of the fixed slot in setting
          • Can find the apple in the inventory (not limited to hotbar).

          https://github.com/commandblock2/scripts/blob/master/combat/AutoGapple.js

          //Copyright 2020 commandblock2 distributed under AGPL-3.0-or-later
          GuiInventory = Java.type("net.minecraft.client.gui.inventory.GuiInventory")
          Potion = Java.type('net.minecraft.potion.Potion')
          
          var originalIndex = null
          var inventoryIndex = null
          module =
          {
              name: "AutoGapple",
              description: "Eat gapple when your health is low",
              author: "commandblock2",
              category: "combat",
              values:
                  [
                      health = value.createFloat("Health", 10, 1, 20),
                      itemSwitchDelay = value.createInteger("SwitchDelayms", 100, 0, 1000)
                  ],
          
              onUpdate: function () {
                  if (mc.thePlayer.getHealth() <= health.get() && !mc.thePlayer.isPotionActive(Potion.regeneration)) {
                      gAppleIndex = InventoryUtils.findItem(36, 45, Items.golden_apple)
                      gAppleIndex = gAppleIndex == -1 ? InventoryUtils.findItem(9, 36, Items.golden_apple) : gAppleIndex
          
                      if (originalIndex == null) { // wtffffff have to check null because if (originalIndex) doesn't work when it equas to 0
                          originalIndex = mc.thePlayer.inventory.currentItem
                      }
          
          
                      if (gAppleIndex >= 36 && gAppleIndex < 45) {
                          //switch to gapple
                          mc.thePlayer.inventory.currentItem = gAppleIndex - 36
          
                      } else if (gAppleIndex >= 9 && gAppleIndex < 36 && !(mc.currentScreen instanceof GuiInventory)) {
                          //switch gapple and 36 (first slot)
                          inventoryIndex = gAppleIndex
                          switchGapple(inventoryIndex)
                      }
          
                      mc.gameSettings.keyBindUseItem.pressed = true
          
                  }
                  else {
                      reset()
                  }
              }
          }
          function reset() {
              if (originalIndex != null || inventoryIndex != null)
                  mc.gameSettings.keyBindUseItem.pressed = false
          
              if (originalIndex != null ) {
                  mc.thePlayer.inventory.currentItem = originalIndex;
                  originalIndex = null
              }
          
              if (inventoryIndex != null) {
                  switchGapple(inventoryIndex)
                  inventoryIndex = null
              }
          
          }
          
          function switchGapple(index) {
              //open inventory (I don't care about when you are on horse, implement it yourself)
              mc.getNetHandler().addToSendQueue(new C16PacketClientStatus(C16PacketClientStatus.EnumState.OPEN_INVENTORY_ACHIEVEMENT));
              mc.displayGuiScreen(new GuiInventory(mc.thePlayer));
          
              timeout(itemSwitchDelay.get(), function () {
                  slot = mc.thePlayer.inventoryContainer.getSlot(index)
          
                  mc.playerController.windowClick(mc.currentScreen.inventorySlots.windowId, slot.slotNumber, 0, 2, mc.thePlayer)
                  mc.thePlayer.closeScreen()
              })
          }
          
          script.import("Core.lib")
          
          
          

          Edit: The first version will make u unable to block manully.

          1 Reply Last reply Reply Quote 0
          • LolMC
            LolMC last edited by

            thanks
            you have teach me how to use InventoryUtils
            i have try that before but not work 😄

            C 1 Reply Last reply Reply Quote 0
            • ChocoPie_isme
              ChocoPie_isme Banned last edited by

              you can send C09 packet for changing the slot silently, and maybe use C08 for eating, C07 for stop eating (didn't test C08 and C07)

              LolMC 1 Reply Last reply Reply Quote 0
              • LolMC
                LolMC @ChocoPie_isme last edited by

                @ChocoPie_isme said in AutoGapple(re-upload):

                you can send C09 packet for changing the slot silently, and maybe use C08 for eating, C07 for stop eating (didn't test C08 and C07)

                why do u need a autogapple silently?

                ChocoPie_isme 1 Reply Last reply Reply Quote 0
                • ChocoPie_isme
                  ChocoPie_isme Banned @LolMC last edited by

                  @LolMC said in AutoGapple(re-upload):

                  @ChocoPie_isme said in AutoGapple(re-upload):

                  you can send C09 packet for changing the slot silently, and maybe use C08 for eating, C07 for stop eating (didn't test C08 and C07)

                  why do u need a autogapple silently?

                  bcz some noobs think that silent things is cool and only pros can do it (and it's cool)

                  A 1 Reply Last reply Reply Quote 0
                  • A
                    Aftery @ChocoPie_isme last edited by

                    This post is deleted!
                    1 Reply Last reply Reply Quote 0
                    • C
                      commandblock2 @LolMC last edited by

                      @LolMC said in AutoGapple(re-upload):

                      thanks
                      you have teach me how to use InventoryUtils
                      i have try that before but not work 😄

                      It was kind of skidded from AutoSoup xDDDDDD

                      @ChocoPie_isme said in AutoGapple(re-upload):

                      you can send C09 packet for changing the slot silently, and maybe use C08 for eating, C07 for stop eating (didn't test C08 and C07)

                      Indeed you are correct, C07/C08/C09 packets should work. It would take more time for me to code a silent yet legit and working one. But most importantly the none silent one is naturally compatible to the FastEat(conditionally C03 packet sender), a silent one could take extra work.

                      1 Reply Last reply Reply Quote 0
                      • Azure
                        Azure last edited by

                        pzo and I dont know why I wrote this because the limit is 8 characters

                        1 Reply Last reply Reply Quote 0
                        • LolMC
                          LolMC last edited by

                          new 1.3 update

                          1 Reply Last reply Reply Quote 0
                          • C
                            Cu6eSu9ar. last edited by

                            Bro,you know since me attack other player eat Gapple.I died

                            1 Reply Last reply Reply Quote 0
                            • LolMC
                              LolMC last edited by

                              just turn on fastuse instant 🙂
                              but it not work on hypixel and some server

                              1 Reply Last reply Reply Quote 0
                              • A
                                Aftery last edited by

                                This post is deleted!
                                1 Reply Last reply Reply Quote 0
                                • LolMC
                                  LolMC last edited by

                                  This post is deleted!
                                  1 Reply Last reply Reply Quote 0
                                  • LolMC
                                    LolMC last edited by

                                    ok
                                    i have done autogapple slient
                                    i will release the code after add it to main code

                                    1 Reply Last reply Reply Quote 0
                                    • ?
                                      A Former User last edited by

                                      I think it's better to avoid nullable variables.

                                      //Copyright 2020 commandblock2 distributed under AGPL-3.0-or-later
                                      GuiInventory = Java.type("net.minecraft.client.gui.inventory.GuiInventory");
                                      Potion = Java.type('net.minecraft.potion.Potion');
                                      
                                      var originalIndex = -1;
                                      
                                      module = {
                                          name: "AutoGapple",
                                          description: "Eat gapple when your health is low",
                                          author: "commandblock2 && Lolmc",
                                          category: "combat",
                                          values: [
                                              health = value.createFloat("Health", 10, 1, 20),
                                              itemSwitchDelay = value.createInteger("SwitchDelayms", 100, 0, 1000)
                                          ],
                                          onDisable: function() {
                                              originalIndex = -1;
                                          },
                                          onUpdate: function () {
                                              if (mc.thePlayer.getHealth() <= health.get() && !mc.thePlayer.isPotionActive(Potion.regeneration)) {
                                                  var gAppleIndex = InventoryUtils.findItem(9, 36, Items.golden_apple);
                                      
                                                  if ((gAppleIndex - 9 | 35 - gAppleIndex) >= 0 && InventoryUtils.hasSpaceHotbar()) {
                                                      if (!(mc.currentScreen instanceof GuiInventory))
                                                          mc.getNetHandler().addToSendQueue(new C16PacketClientStatus(C16PacketClientStatus.EnumState.OPEN_INVENTORY_ACHIEVEMENT));
                                                      
                                                      mc.playerController.windowClick(0, gAppleIndex, 0, 1, mc.thePlayer);//Shift + left mouse click
                                      
                                                      if (!(mc.currentScreen instanceof GuiInventory))
                                                          mc.getNetHandler().addToSendQueue(new C0DPacketCloseWindow());
                                      
                                                      return;
                                                  } else if ((gAppleIndex - 36 | 44 - gAppleIndex) >= 0 && gAppleIndex != mc.thePlayer.inventory.currentItem) {
                                                      if (!~originalIndex) 
                                                          originalIndex = mc.thePlayer.inventory.currentItem;
                                                      mc.thePlayer.inventory.currentItem = gAppleIndex - 36;
                                                  }
                                      
                                                  if (!~gAppleIndex)// fix block when no gapple
                                                      mc.gameSettings.keyBindUseItem.pressed = true;
                                      
                                              } else if (!~originalIndex) {
                                                  mc.gameSettings.keyBindUseItem.pressed = false;
                                                  mc.thePlayer.inventory.currentItem = originalIndex;
                                                  originalIndex = -1;
                                              }
                                          }
                                      }
                                      
                                      script.import("Core.lib")
                                      
                                      1 Reply Last reply Reply Quote 0
                                      • LolMC
                                        LolMC last edited by

                                        -1.4:update eat slient mode(i learn it from jigsaw src),iam lazy to covert 1.3 to 1.4(someone can do that help me)

                                        1 Reply Last reply Reply Quote 0
                                        • Facundo
                                          Facundo last edited by

                                          when i use it i always eat 2 apple is there any way i can eat only 1?

                                          1 Reply Last reply Reply Quote 0
                                          • First post
                                            Last post
                                          About
                                          • Terms of Service
                                          • Privacy Policy
                                          • Status
                                          • Contact Us
                                          Downloads
                                          • Releases
                                          • Source code
                                          • License
                                          Docs
                                          • Tutorials
                                          • CustomHUD
                                          • AutoSettings
                                          • ScriptAPI
                                          Community
                                          • Forum
                                          • Guilded
                                          • YouTube
                                          • Twitter
                                          • D.Tube