diff --git a/src/main/java/nl/snoworange/cranberry/Main.java b/src/main/java/nl/snoworange/cranberry/Main.java index 2a8e5a3..b8a557e 100644 --- a/src/main/java/nl/snoworange/cranberry/Main.java +++ b/src/main/java/nl/snoworange/cranberry/Main.java @@ -1,11 +1,19 @@ package nl.snoworange.cranberry; +import net.minecraft.advancements.*; +import net.minecraft.client.multiplayer.ClientAdvancementManager; import net.minecraft.client.settings.KeyBinding; +import net.minecraft.client.tutorial.Tutorial; +import net.minecraft.client.tutorial.TutorialSteps; +import net.minecraft.util.ResourceLocation; import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.event.entity.player.AdvancementEvent; import net.minecraftforge.fml.client.registry.ClientRegistry; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.event.FMLInitializationEvent; import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; +import net.minecraftforge.fml.common.registry.ForgeRegistries; +import net.minecraftforge.fml.common.registry.GameRegistry; import nl.snoworange.cranberry.features.command.CommandManager; import nl.snoworange.cranberry.features.friend.Friend; import nl.snoworange.cranberry.features.module.ModuleManager; @@ -20,7 +28,7 @@ public class Main { //Refrences public static final String MOD_ID = "cranberry"; public static final String NAME = "Cranberry"; - public static final String VERSION = "v0.7.4"; + public static final String VERSION = "v0.7.6"; public static final String ACCEPTED_MINECRAFT_VERSIONS = "[1.12.2]"; public static final Logger LOGGER = LogManager.getLogger("Cranberry"); diff --git a/src/main/java/nl/snoworange/cranberry/features/gui/clickgui/CranberryClickGUI.java b/src/main/java/nl/snoworange/cranberry/features/gui/clickgui/CranberryClickGUI.java index 200dfa7..cdd77ca 100644 --- a/src/main/java/nl/snoworange/cranberry/features/gui/clickgui/CranberryClickGUI.java +++ b/src/main/java/nl/snoworange/cranberry/features/gui/clickgui/CranberryClickGUI.java @@ -65,6 +65,7 @@ public void setupItems() { } }); } + }); } this.components.forEach(components -> components.getItems().sort(Comparator.comparing(ComponentFeature::getName))); diff --git a/src/main/java/nl/snoworange/cranberry/features/module/ModuleManager.java b/src/main/java/nl/snoworange/cranberry/features/module/ModuleManager.java index 1b18b52..82ab76a 100644 --- a/src/main/java/nl/snoworange/cranberry/features/module/ModuleManager.java +++ b/src/main/java/nl/snoworange/cranberry/features/module/ModuleManager.java @@ -46,6 +46,7 @@ public ModuleManager() { modules.add(new SelfAnvil()); modules.add(new AutoAnvil()); modules.add(new EntityAura()); + modules.add(new HopperNuker()); modules.add(new SecretClose()); diff --git a/src/main/java/nl/snoworange/cranberry/features/module/modules/combat/AutoTotem.java b/src/main/java/nl/snoworange/cranberry/features/module/modules/combat/AutoTotem.java index 19c64a1..f22ef84 100644 --- a/src/main/java/nl/snoworange/cranberry/features/module/modules/combat/AutoTotem.java +++ b/src/main/java/nl/snoworange/cranberry/features/module/modules/combat/AutoTotem.java @@ -5,8 +5,10 @@ import net.minecraft.init.Items; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; +import nl.snoworange.cranberry.Main; import nl.snoworange.cranberry.features.module.Category; import nl.snoworange.cranberry.features.module.Module; +import nl.snoworange.cranberry.features.module.modules.exploit.SecretClose; import nl.snoworange.cranberry.features.setting.Setting; import nl.snoworange.cranberry.util.minecraft.InventoryUtils; @@ -41,7 +43,7 @@ public void onFastTick() { if (n()) return; - if (mc.currentScreen instanceof GuiHopper) return; + if (mc.currentScreen instanceof GuiHopper || (Main.moduleManager.getModuleByName("SecretClose").isEnabled() && SecretClose.lastGui instanceof GuiHopper)) return; if (mc.player.getHeldItemOffhand().getItem() != Items.TOTEM_OF_UNDYING) { offhandTotemSlot = InventoryUtils.findInv(Items.TOTEM_OF_UNDYING); diff --git a/src/main/java/nl/snoworange/cranberry/features/module/modules/combat/HopperNuker.java b/src/main/java/nl/snoworange/cranberry/features/module/modules/combat/HopperNuker.java new file mode 100644 index 0000000..ed20f5e --- /dev/null +++ b/src/main/java/nl/snoworange/cranberry/features/module/modules/combat/HopperNuker.java @@ -0,0 +1,124 @@ +package nl.snoworange.cranberry.features.module.modules.combat; + +import net.minecraft.block.BlockHopper; +import net.minecraft.block.BlockShulkerBox; +import net.minecraft.network.play.client.*; +import net.minecraft.util.EnumFacing; +import net.minecraft.util.EnumHand; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.Vec3d; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import nl.snoworange.cranberry.event.events.PacketEvent; +import nl.snoworange.cranberry.features.module.Category; +import nl.snoworange.cranberry.features.module.Module; +import nl.snoworange.cranberry.features.setting.Setting; +import nl.snoworange.cranberry.util.minecraft.BlockUtils; +import nl.snoworange.cranberry.util.minecraft.InventoryUtils; +import nl.snoworange.cranberry.util.minecraft.PlayerUtils; + +public class HopperNuker extends Module { + + public HopperNuker() { + super("HopperNuker", + "Nukes hoppers (?)", + Category.COMBAT + ); + } + + public enum BreakMode { + VANILLA, + PACKET + } + + public final Setting rotate = register(new Setting<>("Rotate", true)); + public final Setting swingArm = register(new Setting<>("SwingArm", true)); + public final Setting onlyOnGround = register(new Setting<>("OnlyOnGround", true)); + public final Setting noSelfBreaking = register(new Setting<>("NoSelfBreak", true)); + public final Setting only32kHoppers = register(new Setting<>("Only32kHoppers", true)); + public final Setting breakmode = register(new Setting<>("BreakMode", BreakMode.VANILLA)); + public final Setting range = register(new Setting<>("Range", 5, 1, 7)); + + public BlockPos hopperPos; + public static BlockPos selfPos; + + @Override + public void onEnable() { + super.onEnable(); + + selfPos = null; + } + + @Override + public void onDisable() { + super.onDisable(); + } + + @Override + public void onTick() { + + if (n()) return; + + int pickaxeIndex = InventoryUtils.findHotbarPickaxe(); + + if (pickaxeIndex == -1) return; + + for (BlockPos blockPos : BlockPos.getAllInBox(new BlockPos(mc.player.posX - range.getValue(), mc.player.posY - 3, mc.player.posZ - range.getValue()), new BlockPos(mc.player.posX + range.getValue(), mc.player.posY + 3, mc.player.posZ + range.getValue()))) { + + if (mc.player.getDistance(blockPos.getX(), blockPos.getY(), blockPos.getZ()) <= range.getValue() + && (only32kHoppers.getValue() ? (mc.world.getBlockState(blockPos).getBlock() instanceof BlockHopper + && mc.world.getBlockState(blockPos.up()).getBlock() instanceof BlockShulkerBox) : (mc.world.getBlockState(blockPos).getBlock() instanceof BlockHopper)) + && (!blockPos.equals(selfPos) && noSelfBreaking.getValue())) { + hopperPos = blockPos; + break; + } else { + hopperPos = null; + } + } + + if (hopperPos != null) { + + int oldSlot = mc.player.inventory.currentItem; + + if (onlyOnGround.getValue() && !mc.player.onGround) return; + + mc.player.inventory.currentItem = pickaxeIndex; + mc.playerController.updateController(); + + if (rotate.getValue()) PlayerUtils.faceVector(new Vec3d(hopperPos.getX(), hopperPos.getY(), hopperPos.getZ()), true); + + if (breakmode.getValue().equals(BreakMode.PACKET)) { + + if (!BlockUtils.isEmptyBlock(hopperPos, false)) { + mc.player.connection.sendPacket(new CPacketPlayerDigging(CPacketPlayerDigging.Action.START_DESTROY_BLOCK, hopperPos, mc.player.getAdjustedHorizontalFacing())); + } + + mc.player.connection.sendPacket(new CPacketPlayerDigging(CPacketPlayerDigging.Action.STOP_DESTROY_BLOCK, hopperPos, mc.player.getAdjustedHorizontalFacing())); + } else { + mc.playerController.onPlayerDamageBlock(hopperPos, mc.player.getAdjustedHorizontalFacing()); + } + + if (swingArm.getValue()) mc.player.swingArm(EnumHand.MAIN_HAND); + + mc.player.inventory.currentItem = oldSlot; + + } + } + + @SubscribeEvent + public void onPacketSend(PacketEvent.Send event) { + if (this.isEnabled()) { + + if (n()) return; + + if (event.getPacket() instanceof CPacketPlayerTryUseItemOnBlock) { + + CPacketPlayerTryUseItemOnBlock packet = (CPacketPlayerTryUseItemOnBlock) event.getPacket(); + BlockPos packetPos = packet.getPos(); + + if (mc.world.getBlockState(packetPos).getBlock() instanceof BlockHopper) { + selfPos = packetPos; + } + } + } + } +} diff --git a/src/main/java/nl/snoworange/cranberry/features/module/modules/combat/PistonElevator.java b/src/main/java/nl/snoworange/cranberry/features/module/modules/combat/PistonElevator.java index edaae92..4ca172f 100644 --- a/src/main/java/nl/snoworange/cranberry/features/module/modules/combat/PistonElevator.java +++ b/src/main/java/nl/snoworange/cranberry/features/module/modules/combat/PistonElevator.java @@ -224,6 +224,7 @@ public void searchValidPlacementForPistons(EntityPlayer target) { && box.intersects(target.getEntityBoundingBox()) && target.getDistance(blockPos.getX(), blockPos.getY(), blockPos.getZ()) <= 2 && BlockUtils.isEmptyBlock(blockPos.offset(facing), false) + && BlockUtils.isEmptyBlock(blockPos.offset(facing, 2), false) && !(EnumFacing.getDirectionFromEntityLiving(blockPos, mc.player).equals(EnumFacing.DOWN) || EnumFacing.getDirectionFromEntityLiving(blockPos, mc.player).equals(EnumFacing.UP)) ) { diff --git a/src/main/java/nl/snoworange/cranberry/features/module/modules/exploit/SecretClose.java b/src/main/java/nl/snoworange/cranberry/features/module/modules/exploit/SecretClose.java index 03ca19d..134020c 100644 --- a/src/main/java/nl/snoworange/cranberry/features/module/modules/exploit/SecretClose.java +++ b/src/main/java/nl/snoworange/cranberry/features/module/modules/exploit/SecretClose.java @@ -3,10 +3,13 @@ import net.minecraft.client.gui.GuiHopper; import net.minecraft.client.gui.GuiScreen; import net.minecraft.network.play.client.CPacketCloseWindow; +import net.minecraftforge.client.event.GuiOpenEvent; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import nl.snoworange.cranberry.Main; import nl.snoworange.cranberry.event.events.PacketEvent; import nl.snoworange.cranberry.features.module.Category; import nl.snoworange.cranberry.features.module.Module; +import nl.snoworange.cranberry.features.module.modules.stronkswordmeta.Auto32k; import nl.snoworange.cranberry.features.setting.Setting; public class SecretClose extends Module { @@ -20,7 +23,7 @@ public SecretClose() { public final Setting onlyHopper = register(new Setting<>("OnlyHopper", true)); - private static GuiScreen lastGui; + public static GuiScreen lastGui; @Override public void onEnable() { @@ -32,22 +35,29 @@ public void onDisable() { super.onDisable(); } - @Override - public void onTick() { - if (!n()) return; - - if (mc.currentScreen != null) lastGui = mc.currentScreen; + @SubscribeEvent + public void onGuiSwitch(GuiOpenEvent event) { + if (mc.currentScreen != null) { + lastGui = mc.currentScreen; + } } @SubscribeEvent public void onPacketSend(PacketEvent.Send event) { if (this.isEnabled() && event.getPacket() instanceof CPacketCloseWindow) { if (onlyHopper.getValue()) { + + if (((CPacketCloseWindow) event.getPacket()).windowId == Auto32k.lastHopperGuiID + && Main.moduleManager.getModuleByName("Auto32k").isEnabled()) { + event.setCanceled(true); + } + if (!(lastGui instanceof GuiHopper)) { if (!(mc.currentScreen instanceof GuiHopper)) { return; } } + event.setCanceled(true); } else { event.setCanceled(true); diff --git a/src/main/java/nl/snoworange/cranberry/features/module/modules/render/Tooltip.java b/src/main/java/nl/snoworange/cranberry/features/module/modules/render/Tooltip.java index 1778c98..22530ca 100644 --- a/src/main/java/nl/snoworange/cranberry/features/module/modules/render/Tooltip.java +++ b/src/main/java/nl/snoworange/cranberry/features/module/modules/render/Tooltip.java @@ -146,7 +146,7 @@ public void onDrawScreen(GuiScreenEvent.DrawScreenEvent.Post event) { lastHoveredStack = slot.getStack(); } } else if (lastHoveredStack == null) { - + //empty block } else if (!enteredShulker && lastHoveredStack != slot.getStack()) { lastHoveredStack = null; } diff --git a/src/main/java/nl/snoworange/cranberry/features/module/modules/stronkswordmeta/Aura32k.java b/src/main/java/nl/snoworange/cranberry/features/module/modules/stronkswordmeta/Aura32k.java index 9c0815a..fc9e4c3 100644 --- a/src/main/java/nl/snoworange/cranberry/features/module/modules/stronkswordmeta/Aura32k.java +++ b/src/main/java/nl/snoworange/cranberry/features/module/modules/stronkswordmeta/Aura32k.java @@ -1,8 +1,8 @@ package nl.snoworange.cranberry.features.module.modules.stronkswordmeta; +import net.minecraft.entity.ai.attributes.AttributeModifier; +import net.minecraft.entity.ai.attributes.IAttribute; import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.network.NetworkManager; -import net.minecraft.network.Packet; import net.minecraft.network.play.client.CPacketHeldItemChange; import net.minecraft.network.play.client.CPacketUseEntity; import net.minecraft.util.EnumHand; diff --git a/src/main/java/nl/snoworange/cranberry/features/module/modules/stronkswordmeta/Auto32k.java b/src/main/java/nl/snoworange/cranberry/features/module/modules/stronkswordmeta/Auto32k.java index d1a040e..52f7c95 100644 --- a/src/main/java/nl/snoworange/cranberry/features/module/modules/stronkswordmeta/Auto32k.java +++ b/src/main/java/nl/snoworange/cranberry/features/module/modules/stronkswordmeta/Auto32k.java @@ -15,6 +15,7 @@ import net.minecraft.util.math.Vec3d; import nl.snoworange.cranberry.features.module.Category; import nl.snoworange.cranberry.features.module.Module; +import nl.snoworange.cranberry.features.module.modules.combat.HopperNuker; import nl.snoworange.cranberry.features.setting.Setting; import nl.snoworange.cranberry.util.minecraft.*; import nl.snoworange.cranberry.util.Timer; @@ -37,6 +38,7 @@ public class Auto32k extends Module { public int lastAirIndex = -1; public int tickTimer = 0; public int hopperTimer = 0; + public static int lastHopperGuiID = 0; public boolean firstShulker = false; Timer timer = new Timer(); @@ -113,9 +115,6 @@ public void onDisable() { super.onDisable(); if (!n()) { - if (phase < 7 && mc.currentScreen instanceof GuiDispenser) { - mc.player.closeScreen(); - } if (originalSlot != -1 && !selectSwordSlot.getValue()) update(originalSlot, false); update(mc.player.inventory.currentItem, false); @@ -369,6 +368,8 @@ public void onTick() { && !mc.player.openContainer.inventorySlots.isEmpty() ) { + lastHopperGuiID = mc.player.openContainer.windowId; + for (int i = 0; i < 5; i++) { if (InventoryUtils.is32k(mc.player.openContainer.inventorySlots.get(0).inventory.getStackInSlot(i))) { overenchantedSwordIndex = i; @@ -391,12 +392,12 @@ public void onTick() { lastAirIndex = airIndex; + if (autoClose.getValue() && mc.currentScreen instanceof GuiHopper) mc.player.closeScreen(); + if (selectSwordSlot.getValue() && (!blockShulker.getValue() || placeVertically)) update((airIndex != -1 ? airIndex : (revertedSwordIndex != -1 ? revertedSwordIndex : mc.player.inventory.currentItem)), false); if (debug.getValue()) info("32k found in slot " + overenchantedSwordIndex); - if (autoClose.getValue() && mc.currentScreen instanceof GuiHopper) mc.player.closeScreen(); - if (debug.getValue() && !blockShulker.getValue()) info("Process ended in " + timer.getPassedTimeMs() + " ms / " + tickTimer + "tx"); if (!blockShulker.getValue() || placeVertically) disable(); @@ -436,13 +437,13 @@ public void onTick() { if (phase == 7) { + if (autoClose.getValue() && mc.currentScreen instanceof GuiHopper) mc.player.closeScreen(); + if (selectSwordSlot.getValue()) update((lastAirIndex != -1 ? lastAirIndex : (revertedSwordIndex != -1 ? revertedSwordIndex : mc.player.inventory.currentItem)), false); if (debug.getValue()) info("Process ended in " + timer.getPassedTimeMs() + " ms / " + tickTimer + "tx"); phase = 8; - - disable(); } if (phase == 8) { @@ -549,6 +550,8 @@ public void startDispenser32k(BlockPos blockPos, EnumFacing direction) { basePos = blockPos; dispenserDirection = EnumFacing.UP; //does nothing because down bruh + HopperNuker.selfPos = blockPos.down(2); + phase = 1; for (EnumFacing tempRedstoneFacing : EnumFacing.values()) { @@ -576,6 +579,8 @@ public void startDispenser32k(BlockPos blockPos, EnumFacing direction) { basePos = blockPos; dispenserDirection = direction.getOpposite(); + HopperNuker.selfPos = blockPos.offset(direction); + phase = 1; for (EnumFacing redstoneFacing : EnumFacing.values()) { @@ -601,6 +606,8 @@ public void startHopper32k(BlockPos blockPos) { basePos = blockPos; dispenserDirection = null; + HopperNuker.selfPos = blockPos; + phase = 9; if (debug.getValue()) info("Start placing 32k using hopper"); } diff --git a/src/main/java/nl/snoworange/cranberry/util/minecraft/InventoryUtils.java b/src/main/java/nl/snoworange/cranberry/util/minecraft/InventoryUtils.java index 0e89991..60bd660 100644 --- a/src/main/java/nl/snoworange/cranberry/util/minecraft/InventoryUtils.java +++ b/src/main/java/nl/snoworange/cranberry/util/minecraft/InventoryUtils.java @@ -130,6 +130,16 @@ public static int findHotbarPiston() { return -1; } + public static int findHotbarPickaxe() { + for (int i = 0; i < 9; ++i) { + Item slot = mc.player.inventory.getStackInSlot(i).getItem(); + if (slot instanceof ItemPickaxe) { + return i; + } + } + return -1; + } + public static int findShulkerWith32ksInside() { for (int i = 0; i < 36; ++i) { ItemStack itemStack = mc.player.inventory.getStackInSlot(i); diff --git a/src/main/java/nl/snoworange/cranberry/util/minecraft/PlayerUtils.java b/src/main/java/nl/snoworange/cranberry/util/minecraft/PlayerUtils.java index 9cd63a9..18b53ca 100644 --- a/src/main/java/nl/snoworange/cranberry/util/minecraft/PlayerUtils.java +++ b/src/main/java/nl/snoworange/cranberry/util/minecraft/PlayerUtils.java @@ -10,6 +10,8 @@ import net.minecraft.network.play.client.CPacketPlayer; import net.minecraft.potion.PotionEffect; import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.MathHelper; +import net.minecraft.util.math.Vec3d; import net.minecraft.world.World; import java.util.HashMap; @@ -103,4 +105,24 @@ public static void teleportPlayerToCenter() { mc.player.setPosition(centerX, mc.player.posY, centerZ); mc.player.connection.sendPacket(new CPacketPlayer.Position(centerX, mc.player.posY, centerZ, mc.player.onGround)); } + + public static Vec3d getEyesPos() { + return new Vec3d(mc.player.posX, mc.player.posY + (double) mc.player.getEyeHeight(), mc.player.posZ); + } + + public static float[] getLegitRotations(Vec3d vec) { + Vec3d eyesPos = getEyesPos(); + double diffX = vec.x - eyesPos.x; + double diffY = vec.y - eyesPos.y; + double diffZ = vec.z - eyesPos.z; + double diffXZ = Math.sqrt(diffX * diffX + diffZ * diffZ); + float yaw = (float) Math.toDegrees(Math.atan2(diffZ, diffX)) - 90.0f; + float pitch = (float) (-Math.toDegrees(Math.atan2(diffY, diffXZ))); + return new float[]{mc.player.rotationYaw + MathHelper.wrapDegrees(yaw - mc.player.rotationYaw), mc.player.rotationPitch + MathHelper.wrapDegrees(pitch - mc.player.rotationPitch)}; + } + + public static void faceVector(Vec3d vec, boolean normalizeAngle) { + float[] rotations = getLegitRotations(vec); + mc.player.connection.sendPacket(new CPacketPlayer.Rotation(rotations[0], normalizeAngle ? (float) MathHelper.normalizeAngle((int) rotations[1], 360) : rotations[1], mc.player.onGround)); + } } diff --git a/src/main/resources/mcmod.info b/src/main/resources/mcmod.info index d450129..a14760e 100644 --- a/src/main/resources/mcmod.info +++ b/src/main/resources/mcmod.info @@ -3,11 +3,11 @@ "modid": "cranberry", "name": "Cranberry", "description": "An advanced utility mod for Minecraft 1.12.2", - "version": "0.7.4", + "version": "0.7.6", "mcversion": "1.12.2", "url": "", "updateUrl": "", - "authorList": ["Snoworange", "CinnamonApple"], + "authorList": ["Snoworange", "CinnamonApple", "Huu-bo", "Jonah", "Violentqm"], "credits": "", "logoFile": "", "screenshots": [],