Skip to content

Commit

Permalink
Initial commit v12: nothing really changed
Browse files Browse the repository at this point in the history
  • Loading branch information
Snoworange420 committed Mar 17, 2023
1 parent 1fc17e6 commit 8041187
Show file tree
Hide file tree
Showing 14 changed files with 180 additions and 95 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Advanced utility 1.12.2 forge mod, aimed at use in anarchy environments.
## Installation
1. Install Minecraft 1.12.2
2. Install the latest Forge for 1.12.2 [(download)](https://files.minecraftforge.net/net/minecraftforge/forge/index_1.12.2.html)
3. Get the latest Cranberry version here [(download)](https://github.com/Snoworange420/Cranberry/releases/download/v0.7.8/Cranberry-v0.7.8.jar)
3. Get the latest Cranberry version here [(download)](https://github.com/Snoworange420/Cranberry/releases/download/v0.8.0/Cranberry-v0.8.0.jar)
4. Put the file in your `.minecraft/mods` folder

## FAQ (not even frequent asked)
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/nl/snoworange/cranberry/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,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.8";
public static final String VERSION = "v0.8.0";
public static final String ACCEPTED_MINECRAFT_VERSIONS = "[1.12.2]";
public static final Logger LOGGER = LogManager.getLogger("Cranberry");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import net.minecraftforge.fml.common.gameevent.InputEvent;
import net.minecraftforge.fml.common.gameevent.TickEvent;
import nl.snoworange.cranberry.Main;
import nl.snoworange.cranberry.event.events.BozoJustDiedEvent;
import nl.snoworange.cranberry.features.gui.clickgui.CranberryClickGUI;
import nl.snoworange.cranberry.features.module.modules.combat.*;
import nl.snoworange.cranberry.features.module.modules.exploit.SecretClose;
Expand Down Expand Up @@ -115,6 +116,12 @@ public void onLivingUpdateEvent(LivingEvent.LivingUpdateEvent event) {
}
}
});

if (event.getEntityLiving() instanceof EntityPlayer) {
if (event.getEntityLiving().deathTime == 1) {
MinecraftForge.EVENT_BUS.post(new BozoJustDiedEvent((EntityPlayer) event.getEntityLiving()));
}
}
}

@SubscribeEvent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ public AutoAnvil() {
public final Setting<Boolean> swing = register(new Setting<>("SwingArm", true));
public final Setting<Boolean> autoDisable = register(new Setting<>("AutoDisable", true));
public final Setting<Boolean> placeSecond = register(new Setting<>("Place2ndAnvil", true));
public final Setting<Integer> secondAnvilDelay = register(new Setting<>("SecondAnvilDelay", 20, 0, 75, v -> placeSecond.getValue()));
public final Setting<Integer> maxAnvilsOnEnemy = register(new Setting<>("MaxAnvilsOnEnemy", 3, 3, 6));
public final Setting<Integer> secondAnvilDelay = register(new Setting<>("SecondAnvilDelay", 20, 0, 75));
public final Setting<Double> maxRange = register(new Setting<>("MaxTargetRange", 5.5, 0.1, 7.0));
public final Setting<Double> maxAnvilRange = register(new Setting<>("MaxAnvilRange", 5.0, 1.0, 7.0));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,14 @@
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.network.play.client.CPacketCloseWindow;
import net.minecraft.network.play.client.CPacketPlayerTryUseItemOnBlock;
import net.minecraft.network.play.server.SPacketCloseWindow;
import net.minecraft.network.play.server.SPacketOpenWindow;
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.exploit.SecretClose;
Expand All @@ -15,14 +22,17 @@
public class AutoTotem extends Module {

public final Setting<Integer> slot = register(new Setting<>("MainhandSlot", -1, -1, 8));
public final Setting<Boolean> ignoreHopper = register(new Setting<>("IgnoreHopper", false, v -> slot.getValue() != -1));

public AutoTotem() {
super("FastTotem", Category.COMBAT);
super("AutoTotem", Category.COMBAT);
}

public int offhandTotemSlot;
public int mainhandTotemSlot;

public static boolean isInHopper;

@Override
public void onEnable() {
super.onEnable();
Expand All @@ -38,29 +48,42 @@ public void init() {
this.setModuleStack(new ItemStack(Items.TOTEM_OF_UNDYING));
}

@SubscribeEvent
public void onGuiSwitch(GuiOpenEvent event) {
if (event.getGui() instanceof GuiHopper) {
isInHopper = true;
}
}

@Override
public void onFastTick() {

if (n()) return;

if (mc.currentScreen instanceof GuiHopper || (Main.moduleManager.getModuleByName("SecretClose").isEnabled() && SecretClose.lastGui instanceof GuiHopper)) return;
isInHopper = mc.currentScreen instanceof GuiHopper;

if (mc.player.getHeldItemOffhand().getItem() != Items.TOTEM_OF_UNDYING) {
if (mc.player.getHeldItemOffhand().getItem() != Items.TOTEM_OF_UNDYING && !isInHopper) {
offhandTotemSlot = InventoryUtils.findInv(Items.TOTEM_OF_UNDYING);

if (offhandTotemSlot != -1) InventoryUtils.swapItem(offhandTotemSlot, 45);
}

if (slot.getValue() == -1) return;

if (mc.player.inventory.mainInventory.get(slot.getValue()).getItem() != Items.TOTEM_OF_UNDYING) {
if (mc.player.inventory.mainInventory.get(slot.getValue()).getItem() != Items.TOTEM_OF_UNDYING && !(ignoreHopper.getValue() && isInHopper)) {
mainhandTotemSlot = InventoryUtils.findInv(Items.TOTEM_OF_UNDYING);

if (mainhandTotemSlot == 45) return;

if (mainhandTotemSlot != -1) {
InventoryUtils.swapItem(mainhandTotemSlot, slot.getValue() + 36);
}
if (mainhandTotemSlot != -1) InventoryUtils.swapItem(isInHopper ? mainhandTotemSlot - 4 : mainhandTotemSlot, slot.getValue() + (isInHopper ? 36 - 4 : 36));

}
}

@SubscribeEvent
public void onPacketRecieve(PacketEvent.Receive event) {
if (event.getPacket() instanceof SPacketOpenWindow || event.getPacket() instanceof SPacketCloseWindow) {
isInHopper = false;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import net.minecraft.block.BlockHopper;
import net.minecraft.block.BlockShulkerBox;
import net.minecraft.init.Blocks;
import net.minecraft.item.Item;
import net.minecraft.network.play.client.*;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
Expand All @@ -14,6 +16,7 @@
import nl.snoworange.cranberry.features.module.modules.stronkswordmeta.Auto32k;
import nl.snoworange.cranberry.features.setting.Setting;
import nl.snoworange.cranberry.util.minecraft.BlockUtils;
import nl.snoworange.cranberry.util.minecraft.ChatUtils;
import nl.snoworange.cranberry.util.minecraft.InventoryUtils;
import nl.snoworange.cranberry.util.minecraft.PlayerUtils;

Expand Down Expand Up @@ -65,14 +68,16 @@ public void onTick() {

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 (!(blockPos.equals(selfPos) && noSelfBreaking.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))) {
hopperPos = blockPos;
break;
} else {
hopperPos = null;
}
}
}

Expand Down Expand Up @@ -116,9 +121,12 @@ public void onPacketSend(PacketEvent.Send event) {

CPacketPlayerTryUseItemOnBlock packet = (CPacketPlayerTryUseItemOnBlock) event.getPacket();
BlockPos packetPos = packet.getPos();
BlockPos resultPos = packet.getPos().offset(packet.getDirection()); //doesnt work bruh

if (mc.world.getBlockState(packetPos).getBlock() instanceof BlockHopper) {
selfPos = packetPos;
} else if (mc.objectMouseOver.getBlockPos().equals(resultPos) && mc.player.getHeldItemMainhand().getItem().equals(Item.getItemFromBlock(Blocks.HOPPER))) {
selfPos = resultPos;
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ public PistonElevator() {
public final Setting<Boolean> swingArm = register(new Setting<>("SwingArm", true));
public final Setting<Boolean> silent = register(new Setting<>("Silent", true));
public final Setting<Boolean> fillHole = register(new Setting<>("FillHole", true));
public final Setting<Integer> fillDelayTicks = register(new Setting<>("FillDelayTicks", 3, 0, 20, v -> fillHole.getValue()));
public final Setting<Integer> redstoneDelayTicks = register(new Setting<>("RedstoneDelayTicks", 3, 0, 20));
public final Setting<Integer> fillDelayTicks = register(new Setting<>("FillDelayTicks", 3, 0, 20));
public final Setting<Boolean> autoDisable = register(new Setting<>("AutoDisable", true));
public final Setting<Double> maxRange = register(new Setting<>("MaxTargetRange", 5.5, 0.1, 7.0));
public final Setting<Double> maxPlaceRange = register(new Setting<>("MaxPlaceRange", 6.0, 0.1, 7.0));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import net.minecraft.client.gui.GuiHopper;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.network.play.client.CPacketCloseWindow;
import net.minecraft.network.play.server.SPacketCloseWindow;
import net.minecraft.network.play.server.SPacketOpenWindow;
import net.minecraftforge.client.event.GuiOpenEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import nl.snoworange.cranberry.Main;
Expand Down Expand Up @@ -35,32 +37,27 @@ public void onDisable() {
super.onDisable();
}

@SubscribeEvent
public void onGuiSwitch(GuiOpenEvent event) {
if (mc.currentScreen != null) {
lastGui = mc.currentScreen;
}
@Override
public void onFastTick() {
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
&& Auto32k.getInstance().isEnabled()) {
event.setCanceled(true);
}
if (this.isEnabled()) {
if (event.getPacket() instanceof CPacketCloseWindow) {
if (onlyHopper.getValue()) {

if (!(lastGui instanceof GuiHopper)) {
if (!(mc.currentScreen instanceof GuiHopper)) {
return;
if (!(lastGui instanceof GuiHopper)) {
if (!(mc.currentScreen instanceof GuiHopper)) {
return;
}
}
}

event.setCanceled(true);
} else {
event.setCanceled(true);
event.setCanceled(true);
} else {
event.setCanceled(true);
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ public enum FreezeMode {
}

public final Setting<Boolean> autoTakeoff = register(new Setting<>("AutoTakeoff", true));
public final Setting<Enum> takeoffMode = register(new Setting<>("TakeoffMode", TakeoffMode.KEYBINDDETECTION));
public final Setting<Integer> takeoffDelayTicks = register(new Setting<>("TakeoffDelayTicks", 33, 0, 100));
public final Setting<Enum> takeoffMode = register(new Setting<>("TakeoffMode", TakeoffMode.KEYBINDDETECTION, v -> autoTakeoff.getValue()));
public final Setting<Integer> takeoffDelayTicks = register(new Setting<>("TakeoffDelayTicks", 33, 0, 100, v -> autoTakeoff.getValue()));
public final Setting<Double> horizontalSpeed = register(new Setting<>("HorizontalSpeed", 1.0, 0.0, 10.0));
public final Setting<Double> verticalSpeed = register(new Setting<>("VerticalSpeed", 1.0, 0.0, 10.0));
public final Setting<Boolean> lockY = register(new Setting<>("LockY", false));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public void init() {
public void onFastTick() {
if (mc.player.getHeldItemMainhand().getItem() instanceof ItemExpBottle
|| mc.player.getHeldItemOffhand().getItem() instanceof ItemExpBottle) {
if(((IMinecraft) mc).getRightClickDelayTimer() != 0) {
if (((IMinecraft) mc).getRightClickDelayTimer() != 0) {
((IMinecraft) mc).setRightClickDelayTimer(0);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,25 +38,25 @@ 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;

private static Auto32k instance;

Timer timer = new Timer();

public final Setting<Meta> meta = register(new Setting<>("Meta", Meta.DISPENSER));
public final Setting<Boolean> skipShulkerCheck = register(new Setting<>("SkipShulkerCheck", true));
public final Setting<Boolean> skipShulkerCheck = register(new Setting<>("SkipShulkerCheck", true, v -> meta.getValue().equals(Meta.DISPENSER)));
public final Setting<Boolean> silent = register(new Setting<>("Silent", true));
public final Setting<Boolean> rotate = register(new Setting<>("Rotate", true));
public final Setting<Boolean> swingArm = register(new Setting<>("SwingArm", true));
public final Setting<Boolean> autoClose = register(new Setting<>("AutoClose", true));
public final Setting<Boolean> secretClose = register(new Setting<>("SecretClose", true, v -> autoClose.getValue()));
public final Setting<SearchMode> searchMode = register(new Setting<>("SearchMode", SearchMode.FROMUP));
public final Setting<Boolean> timeout = register(new Setting<>("Timeout", true));
public final Setting<Long> timeoutMs = register(new Setting<>("TimeoutMillis", 1250L, 49L, 3200L));
public final Setting<Long> timeoutMs = register(new Setting<>("TimeoutMillis", 1250L, 49L, 3200L, v -> timeout.getValue()));
public final Setting<Boolean> blockShulker = register(new Setting<>("BlockShulker", true));
public final Setting<Boolean> allowObsidian = register(new Setting<>("AllowObsidian", true));
public final Setting<Integer> hopperDelayTicks = register(new Setting<>("HopperDelayTicks", 5, 0, 20));
public final Setting<Integer> hopperDelayTicks = register(new Setting<>("HopperDelayTicks", 5, 0, 20, v -> meta.getValue().equals(Meta.HOPPER)));
public final Setting<Integer> horizontalRange = register(new Setting<>("HorizontalRange", 6, 1, 7));
public final Setting<Integer> plusVerticalRange = register(new Setting<>("+VerticalRange", 6, -7, 7));
public final Setting<Integer> minusVerticalRange = register(new Setting<>("-VerticalRange", 6, -7, 7));
Expand Down Expand Up @@ -378,8 +378,6 @@ 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;
Expand All @@ -402,7 +400,13 @@ public void onTick() {

lastAirIndex = airIndex;

if (autoClose.getValue() && mc.currentScreen instanceof GuiHopper) mc.player.closeScreen();
if (autoClose.getValue() && mc.currentScreen instanceof GuiHopper) {
if (secretClose.getValue()) {
mc.player.closeScreenAndDropStack();
} else {
mc.player.closeScreen();
}
}

if (selectSwordSlot.getValue() && (!blockShulker.getValue() || placeVertically)) update((airIndex != -1 ? airIndex : (revertedSwordIndex != -1 ? revertedSwordIndex : mc.player.inventory.currentItem)), false);

Expand Down Expand Up @@ -447,7 +451,13 @@ public void onTick() {

if (phase == 7) {

if (autoClose.getValue() && mc.currentScreen instanceof GuiHopper) mc.player.closeScreen();
if (autoClose.getValue() && mc.currentScreen instanceof GuiHopper) {
if (secretClose.getValue()) {
mc.player.closeScreenAndDropStack();
} else {
mc.player.closeScreen();
}
}

if (selectSwordSlot.getValue()) update((lastAirIndex != -1 ? lastAirIndex : (revertedSwordIndex != -1 ? revertedSwordIndex : mc.player.inventory.currentItem)), false);

Expand All @@ -463,7 +473,7 @@ public void onTick() {
}

//phase for hopper32k
if (phase == 9) {
if (phase == 420) {

hopperTimer++;

Expand All @@ -484,10 +494,10 @@ public void onTick() {
}
}

if (hopperTimer >= hopperDelayTicks.getValue()) phase = 10;
if (hopperTimer >= hopperDelayTicks.getValue()) phase = 421;
}

if (phase == 10) {
if (phase == 421) {

if (firstShulker) {

Expand Down Expand Up @@ -618,7 +628,8 @@ public void startHopper32k(BlockPos blockPos) {

HopperNuker.selfPos = blockPos;

phase = 9;
phase = 420;

if (debug.getValue()) info("Start placing 32k using hopper");
}
}
Expand Down
Loading

0 comments on commit 8041187

Please sign in to comment.