diff --git a/README.md b/README.md index d06914f..f6cce99 100644 --- a/README.md +++ b/README.md @@ -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) diff --git a/src/main/java/nl/snoworange/cranberry/Main.java b/src/main/java/nl/snoworange/cranberry/Main.java index c266d47..f978a9b 100644 --- a/src/main/java/nl/snoworange/cranberry/Main.java +++ b/src/main/java/nl/snoworange/cranberry/Main.java @@ -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"); 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 82ab76a..a9b1f76 100644 --- a/src/main/java/nl/snoworange/cranberry/features/module/ModuleManager.java +++ b/src/main/java/nl/snoworange/cranberry/features/module/ModuleManager.java @@ -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; @@ -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 diff --git a/src/main/java/nl/snoworange/cranberry/features/module/modules/combat/AutoAnvil.java b/src/main/java/nl/snoworange/cranberry/features/module/modules/combat/AutoAnvil.java index 84dc711..dd20831 100644 --- a/src/main/java/nl/snoworange/cranberry/features/module/modules/combat/AutoAnvil.java +++ b/src/main/java/nl/snoworange/cranberry/features/module/modules/combat/AutoAnvil.java @@ -37,8 +37,8 @@ public AutoAnvil() { public final Setting swing = register(new Setting<>("SwingArm", true)); public final Setting autoDisable = register(new Setting<>("AutoDisable", true)); public final Setting placeSecond = register(new Setting<>("Place2ndAnvil", true)); + public final Setting secondAnvilDelay = register(new Setting<>("SecondAnvilDelay", 20, 0, 75, v -> placeSecond.getValue())); public final Setting maxAnvilsOnEnemy = register(new Setting<>("MaxAnvilsOnEnemy", 3, 3, 6)); - public final Setting secondAnvilDelay = register(new Setting<>("SecondAnvilDelay", 20, 0, 75)); public final Setting maxRange = register(new Setting<>("MaxTargetRange", 5.5, 0.1, 7.0)); public final Setting maxAnvilRange = register(new Setting<>("MaxAnvilRange", 5.0, 1.0, 7.0)); 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 f22ef84..532fb9f 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,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; @@ -15,14 +22,17 @@ public class AutoTotem extends Module { public final Setting slot = register(new Setting<>("MainhandSlot", -1, -1, 8)); + public final Setting 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(); @@ -38,14 +48,21 @@ 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); @@ -53,14 +70,20 @@ public void onFastTick() { 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; } } } \ No newline at end of file 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 index 9405099..0ee3384 100644 --- 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 @@ -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; @@ -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; @@ -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; + } } } @@ -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; } } } 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 4ca172f..9d86373 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 @@ -46,8 +46,8 @@ public PistonElevator() { public final Setting swingArm = register(new Setting<>("SwingArm", true)); public final Setting silent = register(new Setting<>("Silent", true)); public final Setting fillHole = register(new Setting<>("FillHole", true)); + public final Setting fillDelayTicks = register(new Setting<>("FillDelayTicks", 3, 0, 20, v -> fillHole.getValue())); public final Setting redstoneDelayTicks = register(new Setting<>("RedstoneDelayTicks", 3, 0, 20)); - public final Setting fillDelayTicks = register(new Setting<>("FillDelayTicks", 3, 0, 20)); public final Setting autoDisable = register(new Setting<>("AutoDisable", true)); public final Setting maxRange = register(new Setting<>("MaxTargetRange", 5.5, 0.1, 7.0)); public final Setting maxPlaceRange = register(new Setting<>("MaxPlaceRange", 6.0, 0.1, 7.0)); 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 b08fb82..d52822b 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,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; @@ -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); + } } } } diff --git a/src/main/java/nl/snoworange/cranberry/features/module/modules/movement/ElytraFly.java b/src/main/java/nl/snoworange/cranberry/features/module/modules/movement/ElytraFly.java index 6b4708d..e6d526b 100644 --- a/src/main/java/nl/snoworange/cranberry/features/module/modules/movement/ElytraFly.java +++ b/src/main/java/nl/snoworange/cranberry/features/module/modules/movement/ElytraFly.java @@ -38,8 +38,8 @@ public enum FreezeMode { } public final Setting autoTakeoff = register(new Setting<>("AutoTakeoff", true)); - public final Setting takeoffMode = register(new Setting<>("TakeoffMode", TakeoffMode.KEYBINDDETECTION)); - public final Setting takeoffDelayTicks = register(new Setting<>("TakeoffDelayTicks", 33, 0, 100)); + public final Setting takeoffMode = register(new Setting<>("TakeoffMode", TakeoffMode.KEYBINDDETECTION, v -> autoTakeoff.getValue())); + public final Setting takeoffDelayTicks = register(new Setting<>("TakeoffDelayTicks", 33, 0, 100, v -> autoTakeoff.getValue())); public final Setting horizontalSpeed = register(new Setting<>("HorizontalSpeed", 1.0, 0.0, 10.0)); public final Setting verticalSpeed = register(new Setting<>("VerticalSpeed", 1.0, 0.0, 10.0)); public final Setting lockY = register(new Setting<>("LockY", false)); diff --git a/src/main/java/nl/snoworange/cranberry/features/module/modules/player/FastXP.java b/src/main/java/nl/snoworange/cranberry/features/module/modules/player/FastXP.java index 7907434..7bd650f 100644 --- a/src/main/java/nl/snoworange/cranberry/features/module/modules/player/FastXP.java +++ b/src/main/java/nl/snoworange/cranberry/features/module/modules/player/FastXP.java @@ -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); } } 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 2c97898..4c2ce65 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 @@ -38,7 +38,6 @@ 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; @@ -46,17 +45,18 @@ public class Auto32k extends Module { Timer timer = new Timer(); public final Setting meta = register(new Setting<>("Meta", Meta.DISPENSER)); - public final Setting skipShulkerCheck = register(new Setting<>("SkipShulkerCheck", true)); + public final Setting skipShulkerCheck = register(new Setting<>("SkipShulkerCheck", true, v -> meta.getValue().equals(Meta.DISPENSER))); public final Setting silent = register(new Setting<>("Silent", true)); public final Setting rotate = register(new Setting<>("Rotate", true)); public final Setting swingArm = register(new Setting<>("SwingArm", true)); public final Setting autoClose = register(new Setting<>("AutoClose", true)); + public final Setting secretClose = register(new Setting<>("SecretClose", true, v -> autoClose.getValue())); public final Setting searchMode = register(new Setting<>("SearchMode", SearchMode.FROMUP)); public final Setting timeout = register(new Setting<>("Timeout", true)); - public final Setting timeoutMs = register(new Setting<>("TimeoutMillis", 1250L, 49L, 3200L)); + public final Setting timeoutMs = register(new Setting<>("TimeoutMillis", 1250L, 49L, 3200L, v -> timeout.getValue())); public final Setting blockShulker = register(new Setting<>("BlockShulker", true)); public final Setting allowObsidian = register(new Setting<>("AllowObsidian", true)); - public final Setting hopperDelayTicks = register(new Setting<>("HopperDelayTicks", 5, 0, 20)); + public final Setting hopperDelayTicks = register(new Setting<>("HopperDelayTicks", 5, 0, 20, v -> meta.getValue().equals(Meta.HOPPER))); public final Setting horizontalRange = register(new Setting<>("HorizontalRange", 6, 1, 7)); public final Setting plusVerticalRange = register(new Setting<>("+VerticalRange", 6, -7, 7)); public final Setting minusVerticalRange = register(new Setting<>("-VerticalRange", 6, -7, 7)); @@ -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; @@ -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); @@ -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); @@ -463,7 +473,7 @@ public void onTick() { } //phase for hopper32k - if (phase == 9) { + if (phase == 420) { hopperTimer++; @@ -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) { @@ -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"); } } diff --git a/src/main/java/nl/snoworange/cranberry/features/module/modules/stronkswordmeta/HopperRadius.java b/src/main/java/nl/snoworange/cranberry/features/module/modules/stronkswordmeta/HopperRadius.java index 43e9148..c4e8660 100644 --- a/src/main/java/nl/snoworange/cranberry/features/module/modules/stronkswordmeta/HopperRadius.java +++ b/src/main/java/nl/snoworange/cranberry/features/module/modules/stronkswordmeta/HopperRadius.java @@ -9,6 +9,7 @@ import net.minecraft.network.play.server.SPacketCloseWindow; import net.minecraft.network.play.server.SPacketOpenWindow; 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; @@ -29,15 +30,24 @@ public class HopperRadius extends Module { private static HopperRadius instance; + public enum DrawMode { + ONLYSELF, + EXCLUDESELF, + BOTH; + } + public final Setting ignoreRecievedPackets = register(new Setting<>("IgnoreRPackets", false)); public final Setting ignoreSentPackets = register(new Setting<>("IgnoreSPackets", false)); + public final Setting drawHitRange = register(new Setting<>("DrawHitRange", true)); + public final Setting drawMode = register(new Setting<>("DrawMode", DrawMode.ONLYSELF)); + public final Setting range = register(new Setting<>("Range", 7, 1, 20, v -> !drawMode.getValue().equals(DrawMode.ONLYSELF))); public final Setting sync32kHopper = register(new Setting<>("Sync32kHopper", true)); public final Setting height = register(new Setting<>("Height", 0.5, 0.0, 3.0)); public final Setting spreadSpeed = register(new Setting<>("SpreadSpeed", 0.1, 0.0, 1.0)); public HopperRadius() { super("HopperRadius", - "renders in what hopper you're at server side", + "renders what the maximum hopper range is where you can stay in the hopper gui server-side", Category.STRONKSWORDMETA ); @@ -107,13 +117,11 @@ public void onPacketReceive(PacketEvent.Receive event) { if (n() || ignoreRecievedPackets.getValue()) return; - if (!(event.getPacket() instanceof SPacketCloseWindow)) { - if (event.getPacket() instanceof SPacketOpenWindow) { - if (((SPacketOpenWindow) event.getPacket()).getWindowTitle().getUnformattedText().equalsIgnoreCase("Item Hopper")) { - return; - } - hopperPos = null; + if (event.getPacket() instanceof SPacketOpenWindow) { + if (((SPacketOpenWindow) event.getPacket()).getWindowTitle().getUnformattedText().equalsIgnoreCase("Item Hopper")) { + return; } + hopperPos = null; } } } @@ -123,43 +131,65 @@ public void onRender3d() { if (n()) return; - if (wallHeight < height.getValue()) { - wallHeight += 0.005 * height.getValue(); - } else if (wallHeight > height.getValue()) { - wallHeight -= 0.01; - } - - if (hopperPos != null) { - RenderUtils.drawCircle(hopperPos, 8, wallHeight, color); - RenderUtils.drawCircle(hopperPos, 8 + 7, wallHeight, color); + if (drawMode.getValue().equals(DrawMode.ONLYSELF) + || drawMode.getValue().equals(DrawMode.BOTH)) { - oldHopperPos = hopperPos; + if (wallHeight < height.getValue()) { + wallHeight += 0.005 * height.getValue(); + } else if (wallHeight > height.getValue()) { + wallHeight -= 0.01; + } - radius = 7.5; - hitradius = radius + 7; + if (hopperPos != null) { + RenderUtils.drawCircle(hopperPos, 8, wallHeight, color); + if (drawHitRange.getValue()) RenderUtils.drawCircle(hopperPos, 8 + 7, wallHeight, color); - return; - } + oldHopperPos = hopperPos; - if (oldHopperPos != null) { - RenderUtils.drawCircle(oldHopperPos, radius, wallHeight, color); - RenderUtils.drawCircle(oldHopperPos, hitradius, wallHeight, color); + radius = 7.5; + hitradius = radius + 7; - if (wallHeight > 0) { - wallHeight -= 0.1; return; } - if (radius > 0) { - radius -= spreadSpeed.getValue(); - } else { - radius = 0; + if (oldHopperPos != null) { + RenderUtils.drawCircle(oldHopperPos, radius, wallHeight, color); + if (drawHitRange.getValue()) RenderUtils.drawCircle(oldHopperPos, hitradius, wallHeight, color); + + if (wallHeight > 0) { + wallHeight -= 0.1; + return; + } + + if (radius > 0) { + radius -= spreadSpeed.getValue(); + } else { + radius = 0; + } + + if (hitradius > 0) { + hitradius -= spreadSpeed.getValue() * 2; + } else { + hitradius = 0; + } } + } + + if (drawMode.getValue().equals(DrawMode.EXCLUDESELF) + || drawMode.getValue().equals(DrawMode.BOTH)) { + + //draw hoppers in a range + for (int y = -range.getValue(); y < range.getValue(); ++y) { + for (int x = -range.getValue(); x < range.getValue(); ++x) { + for (int z = -range.getValue(); z < range.getValue(); ++z) { + BlockPos blockPos = new BlockPos(new Vec3d(x + mc.player.posX, y + mc.player.posY, z + mc.player.posZ)); - if (hitradius > 0) { - hitradius -= spreadSpeed.getValue() * 2; - } else { - hitradius = 0; + if (mc.world.getBlockState(blockPos).getBlock() instanceof BlockHopper) { + RenderUtils.drawCircle(blockPos, 7.5, wallHeight, color); + if (drawHitRange.getValue()) RenderUtils.drawCircle(blockPos, 7.5 + 7, wallHeight, color); + } + } + } } } } diff --git a/src/main/java/nl/snoworange/cranberry/features/setting/Setting.java b/src/main/java/nl/snoworange/cranberry/features/setting/Setting.java index cb5b9eb..b9ba253 100644 --- a/src/main/java/nl/snoworange/cranberry/features/setting/Setting.java +++ b/src/main/java/nl/snoworange/cranberry/features/setting/Setting.java @@ -1,8 +1,11 @@ package nl.snoworange.cranberry.features.setting; import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.event.terraingen.OreGenEvent; import nl.snoworange.cranberry.util.EnumConverter; +import java.util.function.Predicate; + public class Setting { public String name; @@ -11,7 +14,7 @@ public class Setting { public T plannedValue; public T min; public T max; - public boolean isVisible; + public Predicate visible; public boolean hasRestriction; public Setting(String name, T defaultValue) { @@ -19,7 +22,6 @@ public Setting(String name, T defaultValue) { this.value = defaultValue; this.defaultValue = defaultValue; this.plannedValue = defaultValue; - this.isVisible = true; this.hasRestriction = false; } @@ -30,27 +32,26 @@ public Setting(String name, T defaultValue, T min, T max) { this.plannedValue = defaultValue; this.min = min; this.max = max; - this.isVisible = true; this.hasRestriction = true; } - public Setting(String name, T defaultValue, T min, T max, boolean isVisible) { + public Setting(String name, T defaultValue, T min, T max, Predicate visible) { this.name = name; this.value = defaultValue; this.defaultValue = defaultValue; this.plannedValue = defaultValue; this.min = min; this.max = max; - this.isVisible = isVisible; + this.visible = visible; this.hasRestriction = true; } - public Setting(String name, T defaultValue, boolean isVisible) { + public Setting(String name, T defaultValue, Predicate visible) { this.name = name; this.value = defaultValue; this.defaultValue = defaultValue; this.plannedValue = defaultValue; - this.isVisible = false; + this.visible = visible; this.hasRestriction = false; } @@ -160,8 +161,15 @@ public boolean hasRestriction() { return this.hasRestriction; } + public void setVisible(Predicate visible) { + this.visible = visible; + } + public boolean isVisible() { - return this.isVisible; + if (this.visible == null) { + return true; + } + return this.visible.test(this.getValue()); } public T getMin() { diff --git a/src/main/java/nl/snoworange/cranberry/util/minecraft/RenderUtils.java b/src/main/java/nl/snoworange/cranberry/util/minecraft/RenderUtils.java index ac59146..cc3c431 100644 --- a/src/main/java/nl/snoworange/cranberry/util/minecraft/RenderUtils.java +++ b/src/main/java/nl/snoworange/cranberry/util/minecraft/RenderUtils.java @@ -51,6 +51,7 @@ public static void drawCircle(BlockPos blockPos, double radius, double height, C GlStateManager.popMatrix(); } + //a4bva98738va38098j5vja35v35ai public static void renderCircle(AxisAlignedBB axisAlignedBB, double n, double n2, Color color) { final float red = color.getRed() / 255f;