diff --git a/src/main/java/com/gamesense/api/util/player/InventoryUtil.java b/src/main/java/com/gamesense/api/util/player/InventoryUtil.java index 4b1df84fd..af3f109fa 100644 --- a/src/main/java/com/gamesense/api/util/player/InventoryUtil.java +++ b/src/main/java/com/gamesense/api/util/player/InventoryUtil.java @@ -1,5 +1,7 @@ package com.gamesense.api.util.player; +import com.gamesense.client.module.ModuleManager; +import com.gamesense.client.module.modules.combat.AutoCrystal; import com.gamesense.client.module.modules.combat.OffHand; import net.minecraft.block.Block; import net.minecraft.block.BlockObsidian; @@ -24,9 +26,9 @@ public static int findObsidianSlot(boolean offHandActived, boolean activeBefore) int slot = -1; List mainInventory = mc.player.inventory.mainInventory; - if (offHandActived && OffHand.isActive()) { + if (offHandActived && ModuleManager.isModuleEnabled(OffHand.class)) { if (!activeBefore) { - OffHand.requestObsidian(); + OffHand.requestItems(0); } return 9; } @@ -53,7 +55,7 @@ public static int findSkullSlot(boolean offHandActived, boolean activeBefore) { if (offHandActived) { if (!activeBefore) - OffHand.requestSkull(); + OffHand.requestItems(1); return 9; } diff --git a/src/main/java/com/gamesense/api/util/player/NameUtil.java b/src/main/java/com/gamesense/api/util/player/NameUtil.java index ff7c597f3..0426dd02d 100644 --- a/src/main/java/com/gamesense/api/util/player/NameUtil.java +++ b/src/main/java/com/gamesense/api/util/player/NameUtil.java @@ -33,7 +33,7 @@ public static String resolveName(String uuid) { } } } - } catch (IOException | ParseException e) { + } catch (Exception e) { e.printStackTrace(); } diff --git a/src/main/java/com/gamesense/client/module/modules/combat/AutoAnvil.java b/src/main/java/com/gamesense/client/module/modules/combat/AutoAnvil.java index b9631b3d8..ecc391c8f 100644 --- a/src/main/java/com/gamesense/client/module/modules/combat/AutoAnvil.java +++ b/src/main/java/com/gamesense/client/module/modules/combat/AutoAnvil.java @@ -126,7 +126,7 @@ public void onDisable() { AutoCrystal.stopAC = false; // If offHand was enabled if (slot_mat[0] == -2) { - OffHand.removeObsidian(); + OffHand.removeItem(0); } } @@ -307,7 +307,7 @@ private boolean placeBlock(BlockPos pos, int step) { return false; // If it's step of the obsidian and we have offHandMode - if (offHandObby.getValue() && OffHand.isActive() && slot_mat[utilSlot] == -2) { + if (offHandObby.getValue() && ModuleManager.isModuleEnabled(OffHand.class) && slot_mat[utilSlot] == -2) { // Check if we have the obby in our offhand if (mc.player.getHeldItemOffhand().getItem() instanceof ItemBlock && ((ItemBlock) mc.player.getHeldItemOffhand().getItem()).getBlock() instanceof BlockObsidian) { // We can continue @@ -462,9 +462,9 @@ private boolean getMaterialsSlot() { } } // offHand obsidian - if (offHandObby.getValue() && OffHand.isActive()) { + if (offHandObby.getValue() && ModuleManager.isModuleEnabled(OffHand.class)) { slot_mat[0] = -2; - OffHand.requestObsidian(); + OffHand.requestItems(0); } // Count what we found int count = 0; diff --git a/src/main/java/com/gamesense/client/module/modules/combat/AutoSkull.java b/src/main/java/com/gamesense/client/module/modules/combat/AutoSkull.java index 8160cb03e..2e921646f 100644 --- a/src/main/java/com/gamesense/client/module/modules/combat/AutoSkull.java +++ b/src/main/java/com/gamesense/client/module/modules/combat/AutoSkull.java @@ -82,7 +82,7 @@ public void onEnable() { disable(); return; } - noObby = firstShift = alrPlaced = false; + noObby = firstShift = alrPlaced = activedBefore = false; lastHitVec = null; preRotationTick = afterRotationTick = 0; } @@ -106,7 +106,7 @@ public void onDisable() { } if (noObby) setDisabledMessage("Skull not found... Blocker turned OFF!"); - if (offHandSkull.getValue()) OffHand.removeSkull(); + if (offHandSkull.getValue()) OffHand.removeItem(1); } private boolean firstShift; @@ -202,7 +202,6 @@ private void placeBlock() { } if (skullSlot == 9) { - activedBefore = true; if (mc.player.getHeldItemOffhand().getItem() instanceof ItemSkull) { // We can continue handSwing = EnumHand.OFF_HAND; @@ -234,9 +233,9 @@ private void placeBlock() { oldSlot = -1; } firstShift = true; - activedBefore = alrPlaced = false; + activedBefore = alrPlaced = true; if (offHandSkull.getValue()) - OffHand.removeSkull(); + OffHand.removeItem(1); if (disableAfter.getValue()) { disable(); diff --git a/src/main/java/com/gamesense/client/module/modules/combat/AutoTrap.java b/src/main/java/com/gamesense/client/module/modules/combat/AutoTrap.java index 580abfa5b..e58682798 100644 --- a/src/main/java/com/gamesense/client/module/modules/combat/AutoTrap.java +++ b/src/main/java/com/gamesense/client/module/modules/combat/AutoTrap.java @@ -10,6 +10,7 @@ import com.gamesense.api.util.player.PlayerUtil; import com.gamesense.client.module.Category; import com.gamesense.client.module.Module; +import com.gamesense.client.module.ModuleManager; import net.minecraft.block.BlockObsidian; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; @@ -70,8 +71,8 @@ public void onDisable() { AutoCrystal.stopAC = false; - if (offhandObby.getValue() && OffHand.isActive()) { - OffHand.removeObsidian(); + if (offhandObby.getValue() && ModuleManager.isModuleEnabled(OffHand.class)) { + OffHand.removeItem(0); activedOff = false; } diff --git a/src/main/java/com/gamesense/client/module/modules/combat/Blocker.java b/src/main/java/com/gamesense/client/module/modules/combat/Blocker.java index 7ca20ad99..529b95bac 100644 --- a/src/main/java/com/gamesense/client/module/modules/combat/Blocker.java +++ b/src/main/java/com/gamesense/client/module/modules/combat/Blocker.java @@ -156,7 +156,7 @@ private void blockAnvil() { if (!found) { if (activedBefore) { activedBefore = false; - OffHand.removeObsidian(); + OffHand.removeItem(0); } } } diff --git a/src/main/java/com/gamesense/client/module/modules/combat/HoleFill.java b/src/main/java/com/gamesense/client/module/modules/combat/HoleFill.java index 81d2f75ba..f7f6737db 100644 --- a/src/main/java/com/gamesense/client/module/modules/combat/HoleFill.java +++ b/src/main/java/com/gamesense/client/module/modules/combat/HoleFill.java @@ -11,6 +11,7 @@ import com.gamesense.api.util.world.HoleUtil; import com.gamesense.client.module.Category; import com.gamesense.client.module.Module; +import com.gamesense.client.module.ModuleManager; import net.minecraft.block.*; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; @@ -81,8 +82,8 @@ public void onDisable() { } recentPlacements.clear(); - if (offHandObby.getValue() && OffHand.isActive()) { - OffHand.removeObsidian(); + if (offHandObby.getValue() && ModuleManager.isModuleEnabled(OffHand.class)) { + OffHand.removeItem(0); activedOff = false; } } diff --git a/src/main/java/com/gamesense/client/module/modules/combat/OffHand.java b/src/main/java/com/gamesense/client/module/modules/combat/OffHand.java index c1da69396..0e1e14eb7 100644 --- a/src/main/java/com/gamesense/client/module/modules/combat/OffHand.java +++ b/src/main/java/com/gamesense/client/module/modules/combat/OffHand.java @@ -69,9 +69,7 @@ public class OffHand extends Module { boolean returnBack, stepChanging, firstChange; - private static boolean activeT = false; - private static int forceObby; - private static int forceSkull; + private static String forceItem; private final ArrayList switchDone = new ArrayList<>(); private final ArrayList ignoreNoSword = new ArrayList() { { @@ -82,24 +80,36 @@ public class OffHand extends Module { } }; - public static boolean isActive() { - return activeT; - } - - public static void requestObsidian() { - forceObby++; - } - public static void requestSkull() { - forceSkull = 1; - } - - public static void removeSkull() { - forceSkull = 0; + public static void requestItems(int want) { + switch (want) { + case 0: + forceItem = "Obby"; + break; + case 1: + forceItem = "Skull"; + break; + case 2: + forceItem = "EChest"; + break; + } } - public static void removeObsidian() { - if (forceObby != 0) forceObby--; + public static void removeItem(int want) { + String check = ""; + switch (want) { + case 0: + check = "Obby"; + break; + case 1: + check = "Skull"; + break; + case 2: + check = "EChest"; + break; + } + if (forceItem.equals(check)) + forceItem = ""; } // Create maps of allowed items @@ -117,23 +127,23 @@ public static void removeObsidian() { put("Plates", Blocks.WOODEN_PRESSURE_PLATE); put("Skull", Blocks.SKULL); put("Obby", Blocks.OBSIDIAN); + put("Anvil", Blocks.ANVIL); + put("EChest", Blocks.ENDER_CHEST); } }; @Override public void onEnable() { // Enable it - activeT = firstChange = true; + firstChange = true; // If they are gonna force us obby - forceObby = 0; - + forceItem = ""; returnBack = false; } @Override public void onDisable() { - activeT = false; - forceObby = forceSkull = 0; + forceItem = ""; } @Override @@ -237,15 +247,14 @@ private String getItem() { normalOffHand = false; itemCheck = "Totem"; } - // If forceSkull - if (forceSkull == 1) { - itemCheck = "Skull"; + // If force items + if (!forceItem.equals("")) { + itemCheck = forceItem; normalOffHand = false; } // If crystal obby Item mainHandItem = mc.player.getHeldItemMainhand().getItem(); - if (forceObby > 0 - || (normalOffHand && ( + if ((normalOffHand && ( (crystObby.getValue() && mc.gameSettings.keyBindSneak.isKeyDown() && mainHandItem == Items.END_CRYSTAL) || (pickObby.getValue() && mainHandItem == Items.DIAMOND_PICKAXE && (!pickObbyShift.getValue() || mc.gameSettings.keyBindSneak.isKeyDown()))))) { diff --git a/src/main/java/com/gamesense/client/module/modules/combat/SelfTrap.java b/src/main/java/com/gamesense/client/module/modules/combat/SelfTrap.java index 9ce1ef740..1e19faba5 100644 --- a/src/main/java/com/gamesense/client/module/modules/combat/SelfTrap.java +++ b/src/main/java/com/gamesense/client/module/modules/combat/SelfTrap.java @@ -11,6 +11,7 @@ import com.gamesense.api.util.world.BlockUtil; import com.gamesense.client.module.Category; import com.gamesense.client.module.Module; +import com.gamesense.client.module.ModuleManager; import net.minecraft.block.BlockObsidian; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; @@ -77,8 +78,8 @@ public void onDisable() { AutoCrystal.stopAC = false; - if (offhandObby.getValue() && OffHand.isActive()) { - OffHand.removeObsidian(); + if (offhandObby.getValue() && ModuleManager.isModuleEnabled(OffHand.class)) { + OffHand.removeItem(0); activedOff = false; } diff --git a/src/main/java/com/gamesense/client/module/modules/combat/Surround.java b/src/main/java/com/gamesense/client/module/modules/combat/Surround.java index 25e8d2dc5..fbed46a2e 100644 --- a/src/main/java/com/gamesense/client/module/modules/combat/Surround.java +++ b/src/main/java/com/gamesense/client/module/modules/combat/Surround.java @@ -11,6 +11,7 @@ import com.gamesense.api.util.world.BlockUtil; import com.gamesense.client.module.Category; import com.gamesense.client.module.Module; +import com.gamesense.client.module.ModuleManager; import net.minecraft.block.BlockObsidian; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; @@ -78,8 +79,8 @@ public void onDisable() { AutoCrystal.stopAC = false; - if (offhandObby.getValue() && OffHand.isActive()) { - OffHand.removeObsidian(); + if (offhandObby.getValue() && ModuleManager.isModuleEnabled(OffHand.class)) { + OffHand.removeItem(0); activedOff = false; } diff --git a/src/main/java/com/gamesense/client/module/modules/exploits/FastBreak.java b/src/main/java/com/gamesense/client/module/modules/exploits/FastBreak.java index 771734f2a..b69a16ee9 100644 --- a/src/main/java/com/gamesense/client/module/modules/exploits/FastBreak.java +++ b/src/main/java/com/gamesense/client/module/modules/exploits/FastBreak.java @@ -16,6 +16,7 @@ import com.gamesense.client.module.Category; import com.gamesense.client.module.Module; import com.gamesense.client.module.modules.combat.CevBreaker; +import com.gamesense.client.module.modules.combat.PistonCrystal; import me.zero.alpine.listener.EventHandler; import me.zero.alpine.listener.Listener; import net.minecraft.block.Block; @@ -62,14 +63,16 @@ public class FastBreak extends Module { IntegerSetting resetTickDestroy = registerInteger("Tick Reset Destroy", 0, 0, 50); IntegerSetting pickTickSwitch = registerInteger("Pick Switch Destroy", 75, 0, 90); IntegerSetting pickStill = registerInteger("Pick Switch Still", 20, 0, 30); - IntegerSetting spammerTickDelay = registerInteger("Spammer Delay", 0, 0, 20); - IntegerSetting breakerTickDelay = registerInteger("Breaker Delay", 0, 0, 20); + IntegerSetting spammerTickDelay = registerInteger("Spammer Delay", 0, 0, 75); + IntegerSetting breakerTickDelay = registerInteger("Breaker Delay", 0, 0, 75); BooleanSetting forceRotation = registerBoolean("Force Rotation", false); IntegerSetting rangeDisableBreaker = registerInteger("Range Disable Breaker", 15, 6, 50); BooleanSetting display = registerBoolean("Display", false); - ColorSetting blockColor = registerColor("Block Color", new GSColor(102, 51, 153)); + ColorSetting blockColor = registerColor("Block Color", new GSColor(255, 0, 0)); + ColorSetting doneColor = registerColor("Done Color", new GSColor(0, 255, 0)); ModeSetting renderMode = registerMode("Render", Arrays.asList("Outline", "Fill", "Both"), "Both"); IntegerSetting width = registerInteger("Width", 1, 1, 10); + BooleanSetting debugChat = registerBoolean("Debug Chat", false); private int tick = 99; private int tickSpammer = 0; private int oldslot; @@ -78,7 +81,8 @@ public class FastBreak extends Module { private BlockPos lastBlock = null; - private boolean pickStillBol = false; + private boolean pickStillBol = false, + ready = false; private EnumFacing direction; private boolean minedBefore = false; private int reseTick; @@ -104,8 +108,9 @@ public void onUpdate() { if (tick++ >= wait) { // Save slot in case of switch back int prev = mc.player.inventory.currentItem; + ready = true; // If oldslot != -1 (who know, i dont wanna random crashes) - if (oldslot != -1) { + if (switchPick.getValue() && oldslot != -1) { // Change mc.player.inventory.currentItem = oldslot; oldslot = -1; @@ -155,17 +160,27 @@ public void onUpdate() { if (lastBlock != null && ((spammer.getValue() && tickSpammer++ >= spammerTickDelay.getValue()))) { // Reset timer tickSpammer = 0; + // If it's air, reset + if (BlockUtil.getBlock(lastBlock) instanceof BlockAir) { + minedBefore = true; + reseTick = 0; + lastHitVec = null; + } // If we have mined it before if (minedBefore) { if (resetTickDestroy.getValue() != 0 && reseTick++ >= resetTickDestroy.getValue() && !(BlockUtil.getBlock(lastBlock) instanceof BlockAir)) { mc.player.connection.sendPacket(new CPacketPlayerDigging(CPacketPlayerDigging.Action.START_DESTROY_BLOCK, lastBlock, direction)); - mc.player.connection.sendPacket(new CPacketPlayerDigging(CPacketPlayerDigging.Action.STOP_DESTROY_BLOCK, lastBlock, direction)); + breakerBreak(); reseTick = 0; minedBefore = false; + if (debugChat.getValue()) + PistonCrystal.printDebug("Reset Block", false); return; } // Here, we check if it's air in case we have choose to not spam it every time if (ignoreChecks.getValue() || !(BlockUtil.getBlock(lastBlock) instanceof BlockAir)) { + if (forceRotation.getValue()) + setVec3d(lastBlock, direction); // Get distance, if it's >=, then delete it if (mc.player.getDistanceSq(lastBlock) >= rangeDisableBreaker.getValue()) lastBlock = null; @@ -174,10 +189,6 @@ public void onUpdate() { breakerBreak(); } } - // This is for checking if it's air, if yes, then we have mined it (maybe) - } else if (BlockUtil.getBlock(lastBlock) instanceof BlockAir) { - minedBefore = true; - reseTick = 0; } } } @@ -240,6 +251,7 @@ private void breakerBreak() { oldslot = InventoryUtil.findFirstItemSlot(ItemPickaxe.class, 0, 9); tick = 0; wait = pickTickSwitch.getValue(); + ready = false; pickStillBol = false; break; } @@ -296,11 +308,12 @@ private void breakerAlgo(DamageBlockEvent event) { event.cancel(); breakTick = 0; } + wait = pickTickSwitch.getValue(); + ready = false; + tick = 0; // Switch to pick, dont run if cevbreaker if (!CevBreaker.isActive && switchPick.getValue()) { oldslot = InventoryUtil.findFirstItemSlot(ItemPickaxe.class, 0, 9); - tick = 0; - wait = pickTickSwitch.getValue(); pickStillBol = !switchBack.getValue(); } } @@ -331,8 +344,9 @@ public void onWorldRender(RenderEvent event) { // Render box private void renderBox(BlockPos blockPos) { - GSColor gsColor1 = new GSColor(blockColor.getValue(), 255); - GSColor gsColor2 = new GSColor(blockColor.getValue(), 50); + GSColor color = ready ? doneColor.getValue() : blockColor.getValue(); + GSColor gsColor1 = new GSColor(color, 255); + GSColor gsColor2 = new GSColor(color, 50); switch (renderMode.getValue()) { case "Both": { diff --git a/src/main/java/com/gamesense/client/module/modules/misc/EchestFarmer.java b/src/main/java/com/gamesense/client/module/modules/misc/EchestFarmer.java new file mode 100644 index 000000000..356e461f1 --- /dev/null +++ b/src/main/java/com/gamesense/client/module/modules/misc/EchestFarmer.java @@ -0,0 +1,279 @@ +package com.gamesense.client.module.modules.misc; + +import com.gamesense.api.event.Phase; +import com.gamesense.api.event.events.OnUpdateWalkingPlayerEvent; +import com.gamesense.api.setting.values.BooleanSetting; +import com.gamesense.api.setting.values.IntegerSetting; +import com.gamesense.api.setting.values.ModeSetting; +import com.gamesense.api.util.player.*; +import com.gamesense.api.util.world.BlockUtil; +import com.gamesense.client.manager.managers.PlayerPacketManager; +import com.gamesense.client.module.Category; +import com.gamesense.client.module.Module; +import com.gamesense.client.module.modules.combat.OffHand; +import com.gamesense.client.module.modules.combat.PistonCrystal; +import me.zero.alpine.listener.EventHandler; +import me.zero.alpine.listener.Listener; +import net.minecraft.block.BlockAir; +import net.minecraft.block.BlockObsidian; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.item.ItemBlock; +import net.minecraft.item.ItemStack; +import net.minecraft.network.play.client.CPacketHeldItemChange; +import net.minecraft.network.play.client.CPacketPlayerDigging; +import net.minecraft.util.EnumFacing; +import net.minecraft.util.EnumHand; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.Vec2f; +import net.minecraft.util.math.Vec3d; + +import java.util.ArrayList; +import java.util.Arrays; + +import static com.gamesense.api.util.player.SpoofRotationUtil.ROTATION_UTIL; + +@Module.Declaration(name = "EchestFarmer", category = Category.Misc) +public class EchestFarmer extends Module { + + ModeSetting breakBlock = registerMode("Break Block", Arrays.asList("Normal", "Packet"), "Packet"); + ModeSetting HowplaceBlock = registerMode("Place Block", Arrays.asList("Near", "Looking"), "Looking"); + IntegerSetting stackCount = registerInteger("N^Stack", 0, 0, 64); + IntegerSetting tickDelay = registerInteger("Tick Delay", 5, 0, 10); + BooleanSetting offHandEchest = registerBoolean("OffHand echest", false); + BooleanSetting rotate = registerBoolean("Rotate", false); + BooleanSetting forceRotation = registerBoolean("ForceRotation", false); + + private int delayTimeTicks, + echestToMine, + slotObby, + slotPick; + BlockPos blockAim; + private boolean looking, + noSpace, + materialsNeeded, + prevBreak; + private ArrayList sides = new ArrayList<>(); + + + Vec3d lastHitVec; + + // This is for the force rotation, strict servers + @EventHandler + private final Listener onUpdateWalkingPlayerEventListener = new Listener<>(event -> { + if (event.getPhase() != Phase.PRE || !rotate.getValue() || lastHitVec == null || !forceRotation.getValue()) + return; + Vec2f rotation = RotationUtil.getRotationTo(lastHitVec); + PlayerPacket packet = new PlayerPacket(this, rotation); + PlayerPacketManager.INSTANCE.addPacket(packet); + }); + + @Override + public void onEnable() { + ROTATION_UTIL.onEnable(); + // Init of values + initValues(); + } + + private void initValues() { + prevBreak = noSpace = looking = false; + delayTimeTicks = 0; + materialsNeeded = true; + int obbyCount = mc.player.inventory.mainInventory.stream().filter(itemStack -> itemStack.getItem() instanceof ItemBlock && ((ItemBlock) itemStack.getItem()).getBlock() == Blocks.OBSIDIAN).mapToInt(ItemStack::getCount).sum(); + int stackWanted = ( stackCount.getValue() == 0 ? -1 : stackCount.getValue() * 64 ); + echestToMine = (stackWanted - obbyCount) / 8; + + if (HowplaceBlock.getValue().equals("Looking")) { + blockAim = mc.objectMouseOver.getBlockPos(); + blockAim.y += 1; + + if (BlockUtil.getPlaceableSide(blockAim) == null) { + looking = false; + return; + } + sides.clear(); + sides.add(EnumFacing.getDirectionFromEntityLiving(blockAim, mc.player)); + } else { + + for(int[] sur : new int[][] { + {1, 0}, + {-1, 0}, + {0, 1}, + {0, -1}, + {1, 1}, + {1, -1}, + {-1, 1}, + {-1, -1} + }) { + for(int h : new int[] { + 1, + 0 + }) { + if (BlockUtil.getBlock(mc.player.posX + sur[0], mc.player.posY + h, mc.player.posZ + sur[1]) instanceof BlockAir && BlockUtil.getPlaceableSide(new BlockPos(mc.player.posX + sur[0], mc.player.posY + h, mc.player.posZ + sur[1])) != null) { + if (!PistonCrystal.someoneInCoords(mc.player.posX + sur[0], mc.player.posZ + sur[1])) { + blockAim = new BlockPos(mc.player.posX + sur[0], mc.player.posY + h, mc.player.posZ + sur[1]); + break; + } + } + } + if (blockAim != null) + break; + } + if (blockAim == null) { + noSpace = false; + return; + } + } + + if (isToggleMsg()) { + if (stackCount.getValue() == 0) + PistonCrystal.printDebug("Starting farming obby", false); + else + PistonCrystal.printDebug(String.format("N^obby: %d, N^stack: %d, echest needed: %d", obbyCount, stackWanted, echestToMine), false); + } + + slotPick = InventoryUtil.findFirstItemSlot(Items.DIAMOND_PICKAXE.getClass(), 0, 9); + + if (offHandEchest.getValue()) { + slotObby = 11; + OffHand.requestItems(2); + mc.player.inventory.currentItem = slotPick; + mc.playerController.updateController(); + } else slotObby = InventoryUtil.findFirstBlockSlot(Blocks.ENDER_CHEST.getClass(), 0, 9); + + if (slotObby == -1 || slotPick == -1) + materialsNeeded = false; + } + + @Override + public void onDisable() { + + String output = ""; + + if (!materialsNeeded) { + output = "No materials detected... " + (slotObby == -1 ? "No Echest detected " : "") + (slotPick == -1 ? "No Pick detected" : ""); + } else if(noSpace) { + output = "Not enough space"; + } else if (looking) { + output = "Impossible to place"; + } + + if (!output.equals("")) + PistonCrystal.printDebug(output, true); + else if (echestToMine == 0) + PistonCrystal.printDebug("Mined every echest", false); + + + + if (offHandEchest.getValue()) + OffHand.removeItem(2); + } + + @Override + public void onUpdate() { + + if (mc.player == null) { + disable(); + return; + } + + if (delayTimeTicks < tickDelay.getValue()) { + delayTimeTicks++; + return; + } else { + delayTimeTicks = 0; + } + + if (blockAim == null || !materialsNeeded || slotPick == -1 || looking || noSpace) { + disable(); + return; + } + + if (BlockUtil.getBlock(blockAim) instanceof BlockAir) { + if (prevBreak) { + if (--echestToMine == 0) { + disable(); + return; + } + } + placeBlock(blockAim); + prevBreak = false; + } else { + if (mc.player.inventory.currentItem != slotPick) { + mc.player.connection.sendPacket(new CPacketHeldItemChange(slotPick)); + mc.player.inventory.currentItem = slotPick; + mc.playerController.updateController(); + } + + // Get side + EnumFacing sideBreak = BlockUtil.getPlaceableSide(blockAim); + // If it's != null + if (sideBreak != null) { + // Switch break values + switch (breakBlock.getValue()) { + // Normal Packet + case "Packet": + if (!prevBreak) { + + mc.player.swingArm(EnumHand.MAIN_HAND); + mc.player.connection.sendPacket(new CPacketPlayerDigging( + CPacketPlayerDigging.Action.START_DESTROY_BLOCK, blockAim, sideBreak + )); + mc.player.connection.sendPacket(new CPacketPlayerDigging( + CPacketPlayerDigging.Action.STOP_DESTROY_BLOCK, blockAim, sideBreak + )); + + prevBreak = true; + } + break; + // Vanilla + case "Normal": + mc.player.swingArm(EnumHand.MAIN_HAND); + mc.playerController.onPlayerDamageBlock(blockAim, sideBreak); + prevBreak = true; + break; + } + } + + } + + } + + private void placeBlock(BlockPos pos) { + EnumHand handSwing; + + if (slotObby == 11) { + handSwing = EnumHand.OFF_HAND; + } else { + handSwing = EnumHand.MAIN_HAND; + if (mc.player.inventory.currentItem != slotObby) { + mc.player.inventory.currentItem = slotObby; + mc.playerController.updateController(); + } + } + + if (mc.player.getHeldItemMainhand().getItem() instanceof ItemBlock && ((ItemBlock) mc.player.getHeldItemMainhand().getItem()).getBlock() != Blocks.ENDER_CHEST || mc.player.getHeldItemOffhand().getItem() instanceof ItemBlock && ((ItemBlock) mc.player.getHeldItemOffhand().getItem()).getBlock() != Blocks.ENDER_CHEST) { + return; + } + + if (forceRotation.getValue()) { + EnumFacing side = BlockUtil.getPlaceableSide(blockAim); + + if (side == null) { + return; + } + + BlockPos neighbour = blockAim.offset(side); + EnumFacing opposite = side.getOpposite(); + + if (!BlockUtil.canBeClicked(neighbour)) { + return; + } + + lastHitVec = new Vec3d(neighbour).add(0.5, 0.5, 0.5).add(new Vec3d(opposite.getDirectionVec()).scale(0.5)); + } + + PlacementUtil.place(pos, handSwing, rotate.getValue(), true); + } + +} diff --git a/src/main/java/com/gamesense/client/module/modules/misc/FastShulker.java b/src/main/java/com/gamesense/client/module/modules/misc/FastShulker.java new file mode 100644 index 000000000..41da93520 --- /dev/null +++ b/src/main/java/com/gamesense/client/module/modules/misc/FastShulker.java @@ -0,0 +1,215 @@ +package com.gamesense.client.module.modules.misc; + +import com.gamesense.api.event.Phase; +import com.gamesense.api.event.events.OnUpdateWalkingPlayerEvent; +import com.gamesense.api.setting.values.BooleanSetting; +import com.gamesense.api.setting.values.IntegerSetting; +import com.gamesense.api.setting.values.ModeSetting; +import com.gamesense.api.util.player.PlacementUtil; +import com.gamesense.api.util.player.PlayerPacket; +import com.gamesense.api.util.player.RotationUtil; +import com.gamesense.api.util.world.BlockUtil; +import com.gamesense.client.manager.managers.PlayerPacketManager; +import com.gamesense.client.module.Category; +import com.gamesense.client.module.Module; +import com.gamesense.client.module.modules.combat.PistonCrystal; +import me.zero.alpine.listener.EventHandler; +import me.zero.alpine.listener.Listener; +import net.minecraft.block.BlockAir; +import net.minecraft.block.BlockShulkerBox; +import net.minecraft.inventory.ClickType; +import net.minecraft.item.ItemBlock; +import net.minecraft.util.EnumFacing; +import net.minecraft.util.EnumHand; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.Vec2f; +import net.minecraft.util.math.Vec3d; + +import java.util.Arrays; + +import static com.gamesense.api.util.player.SpoofRotationUtil.ROTATION_UTIL; + +@Module.Declaration(name = "FastShulker", category = Category.Misc) +public class FastShulker extends Module { + + ModeSetting HowplaceBlock = registerMode("Place Block", Arrays.asList("Near", "Looking"), "Looking"); + IntegerSetting tickDelay = registerInteger("Tick Delay", 5, 0, 10); + BooleanSetting rotate = registerBoolean("Rotate", false); + BooleanSetting forceRotation = registerBoolean("ForceRotation", false); + + private int delayTimeTicks; + BlockPos blockAim; + private boolean looking, + noSpace, + materialsNeeded; + + + Vec3d lastHitVec; + + // This is for the force rotation, strict servers + @EventHandler + private final Listener onUpdateWalkingPlayerEventListener = new Listener<>(event -> { + if (event.getPhase() != Phase.PRE || !rotate.getValue() || lastHitVec == null || !forceRotation.getValue()) + return; + Vec2f rotation = RotationUtil.getRotationTo(lastHitVec); + PlayerPacket packet = new PlayerPacket(this, rotation); + PlayerPacketManager.INSTANCE.addPacket(packet); + }); + + @Override + public void onEnable() { + ROTATION_UTIL.onEnable(); + // Init of values + initValues(); + } + + private int getShulkerSlot() { + for(int i = 0; i < mc.player.inventory.mainInventory.size(); i++) { + if (mc.player.inventory.getStackInSlot(i).getItem() instanceof ItemBlock && ((ItemBlock) mc.player.inventory.getStackInSlot(i).getItem()).getBlock() instanceof BlockShulkerBox) { + return i; + } + + } + return -1; + } + int slot; + boolean swapped = false; + + private void initValues() { + if ((slot = getShulkerSlot()) == -1) { + materialsNeeded = false; + return; + } else materialsNeeded = true; + + if (HowplaceBlock.getValue().equals("Looking")) { + blockAim = mc.objectMouseOver.getBlockPos(); + blockAim.y += 1; + + if (BlockUtil.getPlaceableSide(blockAim) == null) { + looking = false; + return; + } + } else { + + for(int[] sur : new int[][] { + {1, 0}, + {-1, 0}, + {0, 1}, + {0, -1}, + {1, 1}, + {1, -1}, + {-1, 1}, + {-1, -1} + }) { + for(int h : new int[] { + 1, + 0 + }) { + if (BlockUtil.getBlock(mc.player.posX + sur[0], mc.player.posY + h, mc.player.posZ + sur[1]) instanceof BlockAir && BlockUtil.getPlaceableSide(new BlockPos(mc.player.posX + sur[0], mc.player.posY + h, mc.player.posZ + sur[1])) != null && BlockUtil.getBlock(mc.player.posX + sur[0], mc.player.posY + h + 1, mc.player.posZ + sur[1]) instanceof BlockAir) { + if (!PistonCrystal.someoneInCoords(mc.player.posX + sur[0], mc.player.posZ + sur[1])) { + blockAim = new BlockPos(mc.player.posX + sur[0], mc.player.posY + h, mc.player.posZ + sur[1]); + break; + } + } + } + if (blockAim != null) + break; + } + if (blockAim == null) { + noSpace = false; + return; + } + } + + EnumFacing side = EnumFacing.getDirectionFromEntityLiving(blockAim, mc.player); + BlockPos neighbour = blockAim.offset(side); + EnumFacing opposite = side.getOpposite(); + + + lastHitVec = new Vec3d(neighbour).add(0.5, 0.5, 0.5).add(new Vec3d(opposite.getDirectionVec()).scale(0.5)); + + } + + @Override + public void onDisable() { + + String output = ""; + + if (!materialsNeeded) { + output = "No materials detected... Shulker not found"; + } else if(noSpace) { + output = "Not enough space"; + } else if (looking) { + output = "Impossible to place"; + } + + if (!output.equals("")) + PistonCrystal.printDebug(output, true); + else + PistonCrystal.printDebug("Shulker placed and opened", false); + + } + + @Override + public void onUpdate() { + + if (mc.player == null) { + disable(); + return; + } + + if (delayTimeTicks < tickDelay.getValue()) { + delayTimeTicks++; + return; + } else { + delayTimeTicks = 0; + } + + if (blockAim == null || !materialsNeeded|| looking || noSpace) { + disable(); + return; + } + + if (slot > 9 && !swapped) { + mc.playerController.windowClick(0, 9, 0, ClickType.PICKUP, mc.player); + mc.playerController.windowClick(0, slot, 0, ClickType.PICKUP, mc.player); + mc.playerController.windowClick(0, 9, 0, ClickType.PICKUP, mc.player); + swapped = true; + if (tickDelay.getValue() != 0) + return; + } + + if (BlockUtil.getBlock(blockAim) instanceof BlockAir) { + if (slot > 9) { + if (mc.player.inventory.currentItem != 9) { + mc.player.inventory.currentItem = 9; + mc.playerController.updateController(); + } + } else if (mc.player.inventory.currentItem != slot) + mc.player.inventory.currentItem = slot; + + PlacementUtil.place(blockAim, EnumHand.MAIN_HAND, rotate.getValue(), true); + + if (tickDelay.getValue() == 0) + openBlock(); + + } else { + openBlock(); + } + + } + + private void openBlock() { + EnumFacing side = EnumFacing.getDirectionFromEntityLiving(blockAim, mc.player); + BlockPos neighbour = blockAim.offset(side); + EnumFacing opposite = side.getOpposite(); + + + Vec3d hitVec = new Vec3d(neighbour).add(0.5, 0.5, 0.5).add(new Vec3d(opposite.getDirectionVec()).scale(0.5)); + mc.playerController.processRightClickBlock(mc.player, mc.world, blockAim, opposite, hitVec, EnumHand.MAIN_HAND); + + disable(); + } + + +}