From 2fa46f3ca4c9041b689fa04d7f4b2f1231e351fe Mon Sep 17 00:00:00 2001 From: Old Chum <57156982+Old-Chum@users.noreply.github.com> Date: Fri, 17 Jan 2020 23:23:00 -0800 Subject: [PATCH 01/15] Added QuickCraft --- .../impl/management/ModuleManager.java | 1 + .../impl/module/misc/QuickCraftModule.java | 41 +++++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100644 src/main/java/me/rigamortis/seppuku/impl/module/misc/QuickCraftModule.java diff --git a/src/main/java/me/rigamortis/seppuku/impl/management/ModuleManager.java b/src/main/java/me/rigamortis/seppuku/impl/management/ModuleManager.java index e503a6a..fca4822 100644 --- a/src/main/java/me/rigamortis/seppuku/impl/management/ModuleManager.java +++ b/src/main/java/me/rigamortis/seppuku/impl/management/ModuleManager.java @@ -148,6 +148,7 @@ public final class ModuleManager { add(new ChatSuffixModule()); add(new VisualRangeModule()); add(new HotBarRefillModule()); + add(new QuickCraftModule()); //p2w experience if (Seppuku.INSTANCE.getCapeManager().hasCape()) diff --git a/src/main/java/me/rigamortis/seppuku/impl/module/misc/QuickCraftModule.java b/src/main/java/me/rigamortis/seppuku/impl/module/misc/QuickCraftModule.java new file mode 100644 index 0000000..f9a7019 --- /dev/null +++ b/src/main/java/me/rigamortis/seppuku/impl/module/misc/QuickCraftModule.java @@ -0,0 +1,41 @@ +package me.rigamortis.seppuku.impl.module.misc; + +import me.rigamortis.seppuku.api.event.EventStageable; +import me.rigamortis.seppuku.api.event.network.EventReceivePacket; +import me.rigamortis.seppuku.api.module.Module; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.inventory.GuiCrafting; +import net.minecraft.client.gui.inventory.GuiInventory; +import net.minecraft.init.Items; +import net.minecraft.inventory.ClickType; +import net.minecraft.network.play.server.SPacketSetSlot; +import team.stiff.pomelo.impl.annotated.handler.annotation.Listener; + +/** + * Shift clicks the crafting result into the inventory. + * + * @author Old Chum + * @since 10/18/20 + */ +public final class QuickCraftModule extends Module { + public QuickCraftModule () { + super("QuickCraft", new String[]{"FastCraft", "qcraft"}, "Automatically collects the result when crafting.", "NONE", -1, Module.ModuleType.MISC); + } + + @Listener + public void onReceivePacket (EventReceivePacket event) { + if (event.getStage() == EventStageable.EventStage.PRE) { + if (event.getPacket() instanceof SPacketSetSlot) { + // Check if this packet updates the recipe result and if the result is not empty + if (((SPacketSetSlot) event.getPacket()).getSlot() == 0 && ((SPacketSetSlot) event.getPacket()).getStack().getItem() != Items.AIR) { + Minecraft mc = Minecraft.getMinecraft(); + + if (mc.currentScreen instanceof GuiInventory || mc.currentScreen instanceof GuiCrafting) { + mc.playerController.windowClick(mc.player.openContainer.windowId, 0, 0, ClickType.QUICK_MOVE, mc.player); + mc.playerController.updateController(); + } + } + } + } + } +} From 91db3a849176bdd02abab4416f01e2128ae90ef5 Mon Sep 17 00:00:00 2001 From: Alex <30688640+casKd-dev@users.noreply.github.com> Date: Tue, 21 Apr 2020 23:16:44 +0200 Subject: [PATCH 02/15] Add control mode --- .../impl/module/movement/ElytraFlyModule.java | 38 ++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/src/main/java/me/rigamortis/seppuku/impl/module/movement/ElytraFlyModule.java b/src/main/java/me/rigamortis/seppuku/impl/module/movement/ElytraFlyModule.java index 1d559da..dd38e9b 100644 --- a/src/main/java/me/rigamortis/seppuku/impl/module/movement/ElytraFlyModule.java +++ b/src/main/java/me/rigamortis/seppuku/impl/module/movement/ElytraFlyModule.java @@ -25,7 +25,7 @@ public final class ElytraFlyModule extends Module { public final Value mode = new Value("Mode", new String[]{"Mode", "M"}, "Mode to use for elytra flight.", Mode.VANILLA); private enum Mode { - VANILLA, PACKET, BYPASS + VANILLA, PACKET, BYPASS, CONTROL } public final Value speed = new Value("Speed", new String[]{"Spd"}, "Speed multiplier for elytra flight, higher values equals more speed.", 1.0f, 0.0f, 5.0f, 0.01f); @@ -159,6 +159,42 @@ public final class ElytraFlyModule extends Module { mc.player.motionZ = 0; } break; + case CONTROL: + if (mc.gameSettings.keyBindJump.isKeyDown()) { + mc.player.motionY = this.speed.getValue() / 2; + } else if (mc.gameSettings.keyBindSneak.isKeyDown()) { + mc.player.motionY = -this.speed.getValue() / 2; + } else { + mc.player.motionY = 0; + } + + if (mc.gameSettings.keyBindForward.isKeyDown()) { + mc.player.motionX = -Math.sin(rotationYaw) * this.speed.getValue(); + mc.player.motionZ = Math.cos(rotationYaw) * this.speed.getValue(); + } else if (mc.gameSettings.keyBindBack.isKeyDown()) { + mc.player.motionX = Math.sin(rotationYaw) * this.speed.getValue(); + mc.player.motionZ = -Math.cos(rotationYaw) * this.speed.getValue(); + } else if (mc.gameSettings.keyBindRight.isKeyDown()) { + if (rotationYaw/90%2==1) { + mc.player.motionX = Math.cos(rotationYaw) * this.speed.getValue(); + mc.player.motionZ = Math.sin(rotationYaw) * this.speed.getValue(); + } else { + mc.player.motionX = -Math.cos(rotationYaw) * this.speed.getValue(); + mc.player.motionZ = -Math.sin(rotationYaw) * this.speed.getValue(); + } + } else if (mc.gameSettings.keyBindLeft.isKeyDown()) { + if (rotationYaw/90%2==1) { + mc.player.motionX = -Math.cos(rotationYaw) * this.speed.getValue(); + mc.player.motionZ = -Math.sin(rotationYaw) * this.speed.getValue(); + } else { + mc.player.motionX = Math.cos(rotationYaw) * this.speed.getValue(); + mc.player.motionZ = Math.sin(rotationYaw) * this.speed.getValue(); + } + } else { + mc.player.motionX = 0; + mc.player.motionZ = 0; + } + break; } } From 02e61a4f81f477dd9b34a9978e42dc49cb5d0779 Mon Sep 17 00:00:00 2001 From: Alex <30688640+casKd-dev@users.noreply.github.com> Date: Wed, 22 Apr 2020 00:05:10 +0200 Subject: [PATCH 03/15] Improved logic, average multiple directions and use variables for repeating calculations --- .../impl/module/movement/ElytraFlyModule.java | 57 ++++++++++--------- 1 file changed, 30 insertions(+), 27 deletions(-) diff --git a/src/main/java/me/rigamortis/seppuku/impl/module/movement/ElytraFlyModule.java b/src/main/java/me/rigamortis/seppuku/impl/module/movement/ElytraFlyModule.java index dd38e9b..e2472f3 100644 --- a/src/main/java/me/rigamortis/seppuku/impl/module/movement/ElytraFlyModule.java +++ b/src/main/java/me/rigamortis/seppuku/impl/module/movement/ElytraFlyModule.java @@ -160,41 +160,44 @@ public final class ElytraFlyModule extends Module { } break; case CONTROL: + final double speedHalved = this.speed.getValue() / 2; + mc.player.motionY = 0; if (mc.gameSettings.keyBindJump.isKeyDown()) { - mc.player.motionY = this.speed.getValue() / 2; + mc.player.motionY = speedHalved; } else if (mc.gameSettings.keyBindSneak.isKeyDown()) { - mc.player.motionY = -this.speed.getValue() / 2; - } else { - mc.player.motionY = 0; + mc.player.motionY = -speedHalved; } + final double sinSpeed = Math.sin(rotationYaw) * this.speed.getValue(); + final double cosSpeed = Math.cos(rotationYaw) * this.speed.getValue(); + double Xavg = 0; + double Zavg = 0; + boolean avgbit = false; + final boolean invBit = rotationYaw/90%2==1; if (mc.gameSettings.keyBindForward.isKeyDown()) { - mc.player.motionX = -Math.sin(rotationYaw) * this.speed.getValue(); - mc.player.motionZ = Math.cos(rotationYaw) * this.speed.getValue(); + Xavg = -sinSpeed; + Zavg = cosSpeed; + avgbit = true; } else if (mc.gameSettings.keyBindBack.isKeyDown()) { - mc.player.motionX = Math.sin(rotationYaw) * this.speed.getValue(); - mc.player.motionZ = -Math.cos(rotationYaw) * this.speed.getValue(); - } else if (mc.gameSettings.keyBindRight.isKeyDown()) { - if (rotationYaw/90%2==1) { - mc.player.motionX = Math.cos(rotationYaw) * this.speed.getValue(); - mc.player.motionZ = Math.sin(rotationYaw) * this.speed.getValue(); - } else { - mc.player.motionX = -Math.cos(rotationYaw) * this.speed.getValue(); - mc.player.motionZ = -Math.sin(rotationYaw) * this.speed.getValue(); - } - } else if (mc.gameSettings.keyBindLeft.isKeyDown()) { - if (rotationYaw/90%2==1) { - mc.player.motionX = -Math.cos(rotationYaw) * this.speed.getValue(); - mc.player.motionZ = -Math.sin(rotationYaw) * this.speed.getValue(); - } else { - mc.player.motionX = Math.cos(rotationYaw) * this.speed.getValue(); - mc.player.motionZ = Math.sin(rotationYaw) * this.speed.getValue(); - } - } else { - mc.player.motionX = 0; - mc.player.motionZ = 0; + Xavg = sinSpeed; + Zavg = -cosSpeed; + avgbit = true; } + if ((mc.gameSettings.keyBindRight.isKeyDown() && invBit) || mc.gameSettings.keyBindLeft.isKeyDown()) { + Xavg += cosSpeed; + Zavg += sinSpeed; + } else if ((mc.gameSettings.keyBindLeft.isKeyDown() && invBit) || mc.gameSettings.keyBindRight.isKeyDown()) { + Xavg += -cosSpeed; + Zavg += -sinSpeed; + } + if (avgbit) { + Xavg *= 0.5; + Zavg *= 0.5; + } + mc.player.motionX = Xavg; + mc.player.motionZ = Zavg; break; + } } From db64548d91362dc29828e19dc0e19994851bfc78 Mon Sep 17 00:00:00 2001 From: Alex <30688640+casKd-dev@users.noreply.github.com> Date: Mon, 27 Apr 2020 12:19:55 +0200 Subject: [PATCH 04/15] Add module --- .../impl/module/misc/StorageAlertModule.java | 76 +++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 src/main/java/me/rigamortis/seppuku/impl/module/misc/StorageAlertModule.java diff --git a/src/main/java/me/rigamortis/seppuku/impl/module/misc/StorageAlertModule.java b/src/main/java/me/rigamortis/seppuku/impl/module/misc/StorageAlertModule.java new file mode 100644 index 0000000..b1a78fe --- /dev/null +++ b/src/main/java/me/rigamortis/seppuku/impl/module/misc/StorageAlertModule.java @@ -0,0 +1,76 @@ +package me.rigamortis.seppuku.impl.module.misc; + +import me.rigamortis.seppuku.Seppuku; +import me.rigamortis.seppuku.api.event.EventStageable; +import me.rigamortis.seppuku.api.event.network.EventReceivePacket; +import me.rigamortis.seppuku.api.module.Module; +import me.rigamortis.seppuku.api.value.Value; +import net.minecraft.client.Minecraft; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.network.play.server.SPacketChunkData; +import team.stiff.pomelo.impl.annotated.handler.annotation.Listener; + +/** + * Author Seth + * 8/25/2019 @ 10:27 PM. + */ +public final class StorageAlertModule extends Module { + + public final Value mode = new Value("Mode", new String[]{"Mode", "M"}, "Change between alert modes.", Mode.CHAT); + public final Value chests = new Value("Chests", new String[]{"Chests", "chest"}, "Count chests.", true); + public final Value echests = new Value("EnderChests", new String[]{"EnderChests", "echest"}, "Count ender chests.", false); + public final Value shulkers = new Value("ShulkerBoxes", new String[]{"ShulkerBoxes", "shul"}, "Count shulkers.", false); + public final Value hoppers = new Value("Hoppers", new String[]{"Hoppers", "hopp"}, "Count hoppers.", false); + public final Value droppers = new Value("Droppers", new String[]{"Droppers", "drop"}, "Count droppers.", false); + public final Value dispensers = new Value("Dispensers", new String[]{"Dispensers", "disp"}, "Count dispensers.", false); + public final Value stands = new Value("BrewingStands", new String[]{"BrewingStands", "brew"}, "Count brewing stands.", false); + + private enum Mode { + CHAT, NOTIFICATION, BOTH + } + + public StorageAlertModule() { + super("StorageAlert", new String[]{"StorageAlerts"}, "Alerts you how many storage blocks are in a chunk when it's loaded", "NONE", -1, ModuleType.MISC); + } + + @Listener + public void recievePacket(EventReceivePacket event) { + if (event.getStage() == EventStageable.EventStage.POST) { + if (event.getPacket() instanceof SPacketChunkData) { + final SPacketChunkData packet = (SPacketChunkData) event.getPacket(); + + final Minecraft mc = Minecraft.getMinecraft(); + + int count = 0; + + for(NBTTagCompound tag : packet.getTileEntityTags()) { + final String id = tag.getString("id"); + + if( + (this.chests.getValue() && (id.equals("minecraft:chest") || id.equals("minecraft:trapped_chest"))) || + (this.echests.getValue() && id.equals("minecraft:ender_chest")) || + (this.shulkers.getValue() && id.equals("minecraft:shulker_box")) || + (this.hoppers.getValue() && id.equals("minecraft:hopper")) || + (this.droppers.getValue() && id.equals("minecraft:dropper")) || + (this.dispensers.getValue() && id.equals("minecraft:dispenser")) || + (this.stands.getValue() && id.equals("minecraft:brewing_stand")) + ) { + count++; + } + } + + if(count > 0) { + final String message = count + " storage blocks located at X: " + packet.getChunkX() * 16 + " Z: " + packet.getChunkZ() * 16; + if (this.mode.getValue() == Mode.CHAT || this.mode.getValue() == Mode.BOTH) { + Seppuku.INSTANCE.logChat(message); + } + if (this.mode.getValue() == Mode.NOTIFICATION || this.mode.getValue() == Mode.BOTH) { + Seppuku.INSTANCE.getNotificationManager().addNotification("", message); + } + } + + } + } + } + +} From 21a179676d74687ab1eb60a4e40a6d00aaa5d2bc Mon Sep 17 00:00:00 2001 From: Alex <30688640+casKd-dev@users.noreply.github.com> Date: Mon, 27 Apr 2020 12:20:26 +0200 Subject: [PATCH 05/15] Replace ChestAlert --- .../impl/module/misc/ChestAlertModule.java | 61 ------------------- 1 file changed, 61 deletions(-) delete mode 100644 src/main/java/me/rigamortis/seppuku/impl/module/misc/ChestAlertModule.java diff --git a/src/main/java/me/rigamortis/seppuku/impl/module/misc/ChestAlertModule.java b/src/main/java/me/rigamortis/seppuku/impl/module/misc/ChestAlertModule.java deleted file mode 100644 index 6a653ca..0000000 --- a/src/main/java/me/rigamortis/seppuku/impl/module/misc/ChestAlertModule.java +++ /dev/null @@ -1,61 +0,0 @@ -package me.rigamortis.seppuku.impl.module.misc; - -import me.rigamortis.seppuku.Seppuku; -import me.rigamortis.seppuku.api.event.EventStageable; -import me.rigamortis.seppuku.api.event.network.EventReceivePacket; -import me.rigamortis.seppuku.api.module.Module; -import me.rigamortis.seppuku.api.value.Value; -import net.minecraft.client.Minecraft; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.network.play.server.SPacketChunkData; -import team.stiff.pomelo.impl.annotated.handler.annotation.Listener; - -/** - * Author Seth - * 8/25/2019 @ 10:27 PM. - */ -public final class ChestAlertModule extends Module { - - public final Value mode = new Value("Mode", new String[]{"Mode", "M"}, "Change between alert modes.", Mode.CHAT); - - private enum Mode { - CHAT, NOTIFICATION, BOTH - } - - public ChestAlertModule() { - super("ChestAlert", new String[]{"ChestAlerts"}, "Alerts you how many chests are in a chunk when it's loaded", "NONE", -1, ModuleType.MISC); - } - - @Listener - public void recievePacket(EventReceivePacket event) { - if (event.getStage() == EventStageable.EventStage.POST) { - if (event.getPacket() instanceof SPacketChunkData) { - final SPacketChunkData packet = (SPacketChunkData) event.getPacket(); - - final Minecraft mc = Minecraft.getMinecraft(); - - int count = 0; - - for(NBTTagCompound tag : packet.getTileEntityTags()) { - final String id = tag.getString("id"); - - if(id.equals("minecraft:chest")) { - count++; - } - } - - if(count > 0) { - final String message = count + " Chests located at X: " + packet.getChunkX() * 16 + " Z: " + packet.getChunkZ() * 16; - if (this.mode.getValue() == Mode.CHAT || this.mode.getValue() == Mode.BOTH) { - Seppuku.INSTANCE.logChat(message); - } - if (this.mode.getValue() == Mode.NOTIFICATION || this.mode.getValue() == Mode.BOTH) { - Seppuku.INSTANCE.getNotificationManager().addNotification("", message); - } - } - - } - } - } - -} From 43f3098a823637ca71e8eac31f654eaa45eb1408 Mon Sep 17 00:00:00 2001 From: Alex <30688640+casKd-dev@users.noreply.github.com> Date: Mon, 27 Apr 2020 12:21:44 +0200 Subject: [PATCH 06/15] Replace module in the manager --- .../me/rigamortis/seppuku/impl/management/ModuleManager.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/main/java/me/rigamortis/seppuku/impl/management/ModuleManager.java b/src/main/java/me/rigamortis/seppuku/impl/management/ModuleManager.java index fca4822..6a56424 100644 --- a/src/main/java/me/rigamortis/seppuku/impl/management/ModuleManager.java +++ b/src/main/java/me/rigamortis/seppuku/impl/management/ModuleManager.java @@ -17,8 +17,6 @@ import me.rigamortis.seppuku.impl.module.misc.*; import me.rigamortis.seppuku.impl.module.movement.*; import me.rigamortis.seppuku.impl.module.player.*; import me.rigamortis.seppuku.impl.module.render.*; -import me.rigamortis.seppuku.impl.module.ui.HudEditorModule; -import me.rigamortis.seppuku.impl.module.world.*; import java.io.File; import java.lang.reflect.Field; @@ -134,7 +132,7 @@ public final class ModuleManager { add(new ObsidianReplaceModule()); add(new ChatTimeStampsModule()); add(new HudEditorModule()); - add(new ChestAlertModule()); + add(new StorageAlertModule()); add(new StrafeModule()); add(new MapBypassModule()); add(new NoBossHealthModule()); From b7a1cc34f69d67f8382fd0dd8c11e036c807f4a6 Mon Sep 17 00:00:00 2001 From: Alex <30688640+casKd-dev@users.noreply.github.com> Date: Mon, 27 Apr 2020 12:26:01 +0200 Subject: [PATCH 07/15] Fix accidental deletion --- .../me/rigamortis/seppuku/impl/management/ModuleManager.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/me/rigamortis/seppuku/impl/management/ModuleManager.java b/src/main/java/me/rigamortis/seppuku/impl/management/ModuleManager.java index 6a56424..485ce25 100644 --- a/src/main/java/me/rigamortis/seppuku/impl/management/ModuleManager.java +++ b/src/main/java/me/rigamortis/seppuku/impl/management/ModuleManager.java @@ -17,6 +17,8 @@ import me.rigamortis.seppuku.impl.module.misc.*; import me.rigamortis.seppuku.impl.module.movement.*; import me.rigamortis.seppuku.impl.module.player.*; import me.rigamortis.seppuku.impl.module.render.*; +import me.rigamortis.seppuku.impl.module.ui.HudEditorModule; +import me.rigamortis.seppuku.impl.module.world.*; import java.io.File; import java.lang.reflect.Field; From ad94dc409c31c7dd103646011fc54e79bb663855 Mon Sep 17 00:00:00 2001 From: Alex Date: Wed, 29 Apr 2020 21:51:17 +0200 Subject: [PATCH 08/15] God gave me eyes to see, i don't want them anymore --- .../impl/module/movement/ScaffoldModule.java | 115 +++--------------- 1 file changed, 14 insertions(+), 101 deletions(-) diff --git a/src/main/java/me/rigamortis/seppuku/impl/module/movement/ScaffoldModule.java b/src/main/java/me/rigamortis/seppuku/impl/module/movement/ScaffoldModule.java index 3876772..1252a16 100644 --- a/src/main/java/me/rigamortis/seppuku/impl/module/movement/ScaffoldModule.java +++ b/src/main/java/me/rigamortis/seppuku/impl/module/movement/ScaffoldModule.java @@ -165,107 +165,20 @@ public final class ScaffoldModule extends Module { private void placeBlock(BlockPos pos) { final Minecraft mc = Minecraft.getMinecraft(); + + BlockPos[][] posit = {{pos.add(0, 0, 1), pos.add(0, 0, -1)}, {pos.add(0, 1, 0), pos.add(0, -1, 0)}, {pos.add(1, 0, 0),pos.add(-1, 0, 0)}}; + EnumFacing[][] facing = {{EnumFacing.NORTH, EnumFacing.SOUTH}, {EnumFacing.DOWN, EnumFacing.UP}, {EnumFacing.WEST, EnumFacing.EAST}}; // Facing reversed as blocks are placed while facing in the opposite direction - final Block north = mc.world.getBlockState(pos.add(0, 0, -1)).getBlock(); - final Block south = mc.world.getBlockState(pos.add(0, 0, 1)).getBlock(); - final Block east = mc.world.getBlockState(pos.add(1, 0, 0)).getBlock(); - final Block west = mc.world.getBlockState(pos.add(-1, 0, 0)).getBlock(); - final Block up = mc.world.getBlockState(pos.add(0, 1, 0)).getBlock(); - final Block down = mc.world.getBlockState(pos.add(0, -1, 0)).getBlock(); - - if (up != null && up != Blocks.AIR && !(up instanceof BlockLiquid)) { - final boolean activated = up.onBlockActivated(mc.world, pos, mc.world.getBlockState(pos), mc.player, EnumHand.MAIN_HAND, EnumFacing.DOWN, 0, 0, 0); - - if (activated) { - mc.player.connection.sendPacket(new CPacketEntityAction(mc.player, CPacketEntityAction.Action.START_SNEAKING)); - } - - if (mc.playerController.processRightClickBlock(mc.player, mc.world, pos.add(0, 1, 0), EnumFacing.DOWN, new Vec3d(0d, 0d, 0d), EnumHand.MAIN_HAND) != EnumActionResult.FAIL) { - mc.player.swingArm(EnumHand.MAIN_HAND); - } - - if (activated) { - mc.player.connection.sendPacket(new CPacketEntityAction(mc.player, CPacketEntityAction.Action.STOP_SNEAKING)); - } - } - - if (down != null && down != Blocks.AIR && !(down instanceof BlockLiquid)) { - final boolean activated = down.onBlockActivated(mc.world, pos, mc.world.getBlockState(pos), mc.player, EnumHand.MAIN_HAND, EnumFacing.UP, 0, 0, 0); - - if (activated) { - mc.player.connection.sendPacket(new CPacketEntityAction(mc.player, CPacketEntityAction.Action.START_SNEAKING)); - } - - if (mc.playerController.processRightClickBlock(mc.player, mc.world, pos.add(0, -1, 0), EnumFacing.UP, new Vec3d(0d, 0d, 0d), EnumHand.MAIN_HAND) != EnumActionResult.FAIL) { - mc.player.swingArm(EnumHand.MAIN_HAND); - } - - if (activated) { - mc.player.connection.sendPacket(new CPacketEntityAction(mc.player, CPacketEntityAction.Action.STOP_SNEAKING)); - } - } - - if (north != null && north != Blocks.AIR && !(north instanceof BlockLiquid)) { - final boolean activated = north.onBlockActivated(mc.world, pos, mc.world.getBlockState(pos), mc.player, EnumHand.MAIN_HAND, EnumFacing.UP, 0, 0, 0); - - if (activated) { - mc.player.connection.sendPacket(new CPacketEntityAction(mc.player, CPacketEntityAction.Action.START_SNEAKING)); - } - - if (mc.playerController.processRightClickBlock(mc.player, mc.world, pos.add(0, 0, -1), EnumFacing.SOUTH, new Vec3d(0d, 0d, 0d), EnumHand.MAIN_HAND) != EnumActionResult.FAIL) { - mc.player.swingArm(EnumHand.MAIN_HAND); - } - - if (activated) { - mc.player.connection.sendPacket(new CPacketEntityAction(mc.player, CPacketEntityAction.Action.STOP_SNEAKING)); - } - } - - if (south != null && south != Blocks.AIR && !(south instanceof BlockLiquid)) { - final boolean activated = south.onBlockActivated(mc.world, pos, mc.world.getBlockState(pos), mc.player, EnumHand.MAIN_HAND, EnumFacing.UP, 0, 0, 0); - - if (activated) { - mc.player.connection.sendPacket(new CPacketEntityAction(mc.player, CPacketEntityAction.Action.START_SNEAKING)); - } - - if (mc.playerController.processRightClickBlock(mc.player, mc.world, pos.add(0, 0, 1), EnumFacing.NORTH, new Vec3d(0d, 0d, 0d), EnumHand.MAIN_HAND) != EnumActionResult.FAIL) { - mc.player.swingArm(EnumHand.MAIN_HAND); - } - - if (activated) { - mc.player.connection.sendPacket(new CPacketEntityAction(mc.player, CPacketEntityAction.Action.STOP_SNEAKING)); - } - } - - if (east != null && east != Blocks.AIR && !(east instanceof BlockLiquid)) { - final boolean activated = east.onBlockActivated(mc.world, pos, mc.world.getBlockState(pos), mc.player, EnumHand.MAIN_HAND, EnumFacing.UP, 0, 0, 0); - - if (activated) { - mc.player.connection.sendPacket(new CPacketEntityAction(mc.player, CPacketEntityAction.Action.START_SNEAKING)); - } - - if (mc.playerController.processRightClickBlock(mc.player, mc.world, pos.add(1, 0, 0), EnumFacing.WEST, new Vec3d(0d, 0d, 0d), EnumHand.MAIN_HAND) != EnumActionResult.FAIL) { - mc.player.swingArm(EnumHand.MAIN_HAND); - } - - if (activated) { - mc.player.connection.sendPacket(new CPacketEntityAction(mc.player, CPacketEntityAction.Action.STOP_SNEAKING)); - } - } - - if (west != null && west != Blocks.AIR && !(west instanceof BlockLiquid)) { - final boolean activated = west.onBlockActivated(mc.world, pos, mc.world.getBlockState(pos), mc.player, EnumHand.MAIN_HAND, EnumFacing.UP, 0, 0, 0); - - if (activated) { - mc.player.connection.sendPacket(new CPacketEntityAction(mc.player, CPacketEntityAction.Action.START_SNEAKING)); - } - - if (mc.playerController.processRightClickBlock(mc.player, mc.world, pos.add(-1, 0, 0), EnumFacing.EAST, new Vec3d(0d, 0d, 0d), EnumHand.MAIN_HAND) != EnumActionResult.FAIL) { - mc.player.swingArm(EnumHand.MAIN_HAND); - } - - if (activated) { - mc.player.connection.sendPacket(new CPacketEntityAction(mc.player, CPacketEntityAction.Action.STOP_SNEAKING)); + for (int i=0; i<6; i++) { + final Block block = mc.world.getBlockState(posit[i/2][i%2]).getBlock(); + final boolean activated = block.onBlockActivated(mc.world, pos, mc.world.getBlockState(pos), mc.player, EnumHand.MAIN_HAND, EnumFacing.UP, 0, 0, 0); + if (block != null && block != Blocks.AIR && !(block instanceof BlockLiquid)) { + if (activated) + mc.player.connection.sendPacket(new CPacketEntityAction(mc.player, CPacketEntityAction.Action.START_SNEAKING)); + if (mc.playerController.processRightClickBlock(mc.player, mc.world, posit[i/2][i%2], facing[i/2][i%2], new Vec3d(0d, 0d, 0d), EnumHand.MAIN_HAND) != EnumActionResult.FAIL) + mc.player.swingArm(EnumHand.MAIN_HAND); + if (activated) + mc.player.connection.sendPacket(new CPacketEntityAction(mc.player, CPacketEntityAction.Action.STOP_SNEAKING)); } } } @@ -306,4 +219,4 @@ public final class ScaffoldModule extends Module { return block != Blocks.AIR; } -} \ No newline at end of file +} From 36b547a8ee149f123300e0fa6b13c24cef50757d Mon Sep 17 00:00:00 2001 From: Alex Date: Wed, 29 Apr 2020 22:07:05 +0200 Subject: [PATCH 09/15] Use built-in functions and add disabling of the nohunger module, it conflicts with elytrafly --- .../impl/module/movement/ElytraFlyModule.java | 76 +++++++------------ 1 file changed, 27 insertions(+), 49 deletions(-) diff --git a/src/main/java/me/rigamortis/seppuku/impl/module/movement/ElytraFlyModule.java b/src/main/java/me/rigamortis/seppuku/impl/module/movement/ElytraFlyModule.java index e2472f3..2552c5c 100644 --- a/src/main/java/me/rigamortis/seppuku/impl/module/movement/ElytraFlyModule.java +++ b/src/main/java/me/rigamortis/seppuku/impl/module/movement/ElytraFlyModule.java @@ -1,9 +1,11 @@ package me.rigamortis.seppuku.impl.module.movement; +import me.rigamortis.seppuku.Seppuku; import me.rigamortis.seppuku.api.event.EventStageable; import me.rigamortis.seppuku.api.event.network.EventReceivePacket; import me.rigamortis.seppuku.api.event.player.EventUpdateWalkingPlayer; import me.rigamortis.seppuku.api.module.Module; +import me.rigamortis.seppuku.impl.module.player.NoHungerModule; import me.rigamortis.seppuku.api.util.MathUtil; import me.rigamortis.seppuku.api.util.Timer; import me.rigamortis.seppuku.api.value.Value; @@ -44,6 +46,11 @@ public final class ElytraFlyModule extends Module { @Override public void onEnable() { super.onEnable(); + final NoHungerModule nohunger = (NoHungerModule) Seppuku.INSTANCE.getModuleManager().find(NoHungerModule.class); + if (nohunger != null && nohunger.isEnabled()) { + nohunger.toggle(); + Seppuku.INSTANCE.logChat("Toggled \247c" + nohunger.getDisplayName() + "\247r because it conflicts with \247a" + this.getDisplayName()); + } } @Override @@ -92,24 +99,19 @@ public final class ElytraFlyModule extends Module { switch (this.mode.getValue()) { case VANILLA: final float speedScaled = this.speed.getValue() * 0.05f; // 5/100 of original value - - if (mc.gameSettings.keyBindJump.isKeyDown()) { - mc.player.motionY += speedScaled; + final double[] directionSpeedVanilla = MathUtil.directionSpeed(speedScaled); + if (mc.player.movementInput.jump) { + mc.player.motionY = this.speed.getValue(); } - if (mc.gameSettings.keyBindSneak.isKeyDown()) { - mc.player.motionY -= speedScaled; + if (mc.player.movementInput.sneak) { + mc.player.motionY = -this.speed.getValue(); + } + if (mc.player.movementInput.moveStrafe != 0 || mc.player.movementInput.moveForward != 0) { + mc.player.motionX += directionSpeedVanilla[0]; + mc.player.motionZ += directionSpeedVanilla[1]; } - if (mc.gameSettings.keyBindForward.isKeyDown()) { - mc.player.motionX -= Math.sin(rotationYaw) * speedScaled; - mc.player.motionZ += Math.cos(rotationYaw) * speedScaled; - } - - if (mc.gameSettings.keyBindBack.isKeyDown()) { - mc.player.motionX += Math.sin(rotationYaw) * speedScaled; - mc.player.motionZ -= Math.cos(rotationYaw) * speedScaled; - } break; case PACKET: this.freezePlayer(mc.player); @@ -160,44 +162,20 @@ public final class ElytraFlyModule extends Module { } break; case CONTROL: - final double speedHalved = this.speed.getValue() / 2; - mc.player.motionY = 0; - if (mc.gameSettings.keyBindJump.isKeyDown()) { - mc.player.motionY = speedHalved; - } else if (mc.gameSettings.keyBindSneak.isKeyDown()) { - mc.player.motionY = -speedHalved; + final double[] directionSpeedControl = MathUtil.directionSpeed(this.speed.getValue()); + mc.player.motionY = -this.idlefall.getValue(); + mc.player.motionX = 0; + mc.player.motionZ = 0; + if (mc.player.movementInput.jump) { + mc.player.motionY = this.upspd.getValue(); + } else if (mc.player.movementInput.sneak) { + mc.player.motionY = -this.downspd.getValue(); } - - final double sinSpeed = Math.sin(rotationYaw) * this.speed.getValue(); - final double cosSpeed = Math.cos(rotationYaw) * this.speed.getValue(); - double Xavg = 0; - double Zavg = 0; - boolean avgbit = false; - final boolean invBit = rotationYaw/90%2==1; - if (mc.gameSettings.keyBindForward.isKeyDown()) { - Xavg = -sinSpeed; - Zavg = cosSpeed; - avgbit = true; - } else if (mc.gameSettings.keyBindBack.isKeyDown()) { - Xavg = sinSpeed; - Zavg = -cosSpeed; - avgbit = true; + if (mc.player.movementInput.moveStrafe != 0 || mc.player.movementInput.moveForward != 0) { + mc.player.motionX = directionSpeedControl[0]; + mc.player.motionZ = directionSpeedControl[1]; } - if ((mc.gameSettings.keyBindRight.isKeyDown() && invBit) || mc.gameSettings.keyBindLeft.isKeyDown()) { - Xavg += cosSpeed; - Zavg += sinSpeed; - } else if ((mc.gameSettings.keyBindLeft.isKeyDown() && invBit) || mc.gameSettings.keyBindRight.isKeyDown()) { - Xavg += -cosSpeed; - Zavg += -sinSpeed; - } - if (avgbit) { - Xavg *= 0.5; - Zavg *= 0.5; - } - mc.player.motionX = Xavg; - mc.player.motionZ = Zavg; break; - } } From ebdbe7e44fd7d509d61d443b95a163123d06cce6 Mon Sep 17 00:00:00 2001 From: Alex Date: Sat, 2 May 2020 22:05:36 +0200 Subject: [PATCH 10/15] Improve scaffold logic --- .../impl/module/movement/ScaffoldModule.java | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/main/java/me/rigamortis/seppuku/impl/module/movement/ScaffoldModule.java b/src/main/java/me/rigamortis/seppuku/impl/module/movement/ScaffoldModule.java index 3876772..154d9a7 100644 --- a/src/main/java/me/rigamortis/seppuku/impl/module/movement/ScaffoldModule.java +++ b/src/main/java/me/rigamortis/seppuku/impl/module/movement/ScaffoldModule.java @@ -83,7 +83,7 @@ public final class ScaffoldModule extends Module { } } - if ((mc.player.movementInput.moveForward != 0 || mc.player.movementInput.moveStrafe != 0)) { + if ((mc.player.movementInput.moveForward != 0 || mc.player.movementInput.moveStrafe != 0 || mc.player.movementInput.jump) && !mc.player.movementInput.sneak) { final double[] dir = MathUtil.directionSpeed(1); if (mc.player.getHeldItemMainhand().getItem() != Items.AIR && mc.player.getHeldItemMainhand().getItem() instanceof ItemBlock && canPlace(mc.player.getHeldItemMainhand())) { @@ -280,17 +280,17 @@ public final class ScaffoldModule extends Module { } private Vec3d getFirstBlock(double[] dir) { - for (int i = 0; i <= ((int) 4.5f); i++) { - Vec3d pos = new Vec3d(Minecraft.getMinecraft().player.posX + -dir[0] * i, Minecraft.getMinecraft().player.posY - 1, Minecraft.getMinecraft().player.posZ + -dir[1] * i); - Vec3d before = new Vec3d(Minecraft.getMinecraft().player.posX + -dir[0] * (i - 1), Minecraft.getMinecraft().player.posY - 1, Minecraft.getMinecraft().player.posZ + -dir[1] * (i - 1)); - - final Block firstBlock = Minecraft.getMinecraft().world.getBlockState(new BlockPos(before.x, before.y, before.z)).getBlock(); - final Block secondBlock = Minecraft.getMinecraft().world.getBlockState(new BlockPos(before.x, before.y, before.z)).getBlock(); - - if ((firstBlock != Blocks.AIR) || !(firstBlock instanceof BlockLiquid) && (secondBlock == Blocks.AIR) || (secondBlock instanceof BlockLiquid)) { - return before; + final Minecraft mc = Minecraft.getMinecraft(); + Vec3d pos = new Vec3d(mc.player.posX, mc.player.posY - 1, mc.player.posZ); + Vec3d dirpos = new Vec3d(mc.player.posX + dir[0], mc.player.posY - 1, mc.player.posZ + dir[1]); + if (mc.world.getBlockState(new BlockPos(pos.x, pos.y, pos.z)).getBlock() == Blocks.AIR) + return pos; + if (mc.world.getBlockState(new BlockPos(dirpos.x, dirpos.y, dirpos.z)).getBlock() == Blocks.AIR) + if (mc.world.getBlockState(new BlockPos(pos.x, dirpos.y, dirpos.z)).getBlock() == Blocks.AIR && mc.world.getBlockState(new BlockPos(dirpos.x, dirpos.y, pos.z)).getBlock() == Blocks.AIR) { + return new Vec3d(dirpos.x, pos.y, pos.z); + } else { + return dirpos; } - } return null; } @@ -306,4 +306,4 @@ public final class ScaffoldModule extends Module { return block != Blocks.AIR; } -} \ No newline at end of file +} From 322d76052abd00d3f8a9896f1c31a6a35050bc62 Mon Sep 17 00:00:00 2001 From: noil <33181454+noil755@users.noreply.github.com> Date: Sun, 3 May 2020 12:40:30 -0400 Subject: [PATCH 11/15] Update readme.md --- readme.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/readme.md b/readme.md index cba277e..f9cc41d 100644 --- a/readme.md +++ b/readme.md @@ -1,6 +1,6 @@ # ![Seppuku](res/seppuku_full.png) -Seppuku is a free, lightweight, open-source Minecraft Forge client-side mod for Minecraft 1.12.2. Oriented towards 9B9T, this is a full-featured anarchy mod with an external plugin API, unique exploits, and a solid community. +Seppuku is a free, lightweight, open-source [_Minecraft Forge_](https://files.minecraftforge.net/) mod for Minecraft 1.12.2. Oriented towards 9B9T, this is a full-featured anarchy mod with an external plugin API, unique exploits, and a solid community. # Requirements - **JDK 8** (https://adoptopenjdk.net/, https://aws.amazon.com/corretto/) From db05161777c9c2d09a582f4412caad723be6fe20 Mon Sep 17 00:00:00 2001 From: noil <33181454+noil755@users.noreply.github.com> Date: Sun, 3 May 2020 12:42:16 -0400 Subject: [PATCH 12/15] Update readme.md --- readme.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/readme.md b/readme.md index f9cc41d..c10b03e 100644 --- a/readme.md +++ b/readme.md @@ -1,6 +1,6 @@ # ![Seppuku](res/seppuku_full.png) -Seppuku is a free, lightweight, open-source [_Minecraft Forge_](https://files.minecraftforge.net/) mod for Minecraft 1.12.2. Oriented towards 9B9T, this is a full-featured anarchy mod with an external plugin API, unique exploits, and a solid community. +Seppuku is a free, lightweight, open-source [_Minecraft Forge_](https://files.minecraftforge.net/) mod for Minecraft 1.12.2. Oriented towards the 9B9T anarchy server, this is a fully featured client-side mod with an external plugin API, unique exploits, and a [solid community](https://discord.gg/9SJUfUa). # Requirements - **JDK 8** (https://adoptopenjdk.net/, https://aws.amazon.com/corretto/) From 589accfe6f606424ab50a7f31084c9517058eac8 Mon Sep 17 00:00:00 2001 From: noil <33181454+noil755@users.noreply.github.com> Date: Sun, 3 May 2020 12:44:37 -0400 Subject: [PATCH 13/15] put wrong discord channel in readme lmao --- readme.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/readme.md b/readme.md index c10b03e..03b0645 100644 --- a/readme.md +++ b/readme.md @@ -1,6 +1,6 @@ # ![Seppuku](res/seppuku_full.png) -Seppuku is a free, lightweight, open-source [_Minecraft Forge_](https://files.minecraftforge.net/) mod for Minecraft 1.12.2. Oriented towards the 9B9T anarchy server, this is a fully featured client-side mod with an external plugin API, unique exploits, and a [solid community](https://discord.gg/9SJUfUa). +Seppuku is a free, lightweight, open-source [_Minecraft Forge_](https://files.minecraftforge.net/) mod for Minecraft 1.12.2. Oriented towards the 9B9T anarchy server, this is a fully featured client-side mod with an external plugin API, unique exploits, and a [solid community](https://discord.gg/UzWBZPe). # Requirements - **JDK 8** (https://adoptopenjdk.net/, https://aws.amazon.com/corretto/) From 935460b426d525feb13e2fc8179fae7dc992987c Mon Sep 17 00:00:00 2001 From: noil Date: Thu, 7 May 2020 20:30:20 -0400 Subject: [PATCH 14/15] remove invalid variables --- .../seppuku/impl/module/movement/ElytraFlyModule.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/me/rigamortis/seppuku/impl/module/movement/ElytraFlyModule.java b/src/main/java/me/rigamortis/seppuku/impl/module/movement/ElytraFlyModule.java index 2552c5c..774f0a2 100644 --- a/src/main/java/me/rigamortis/seppuku/impl/module/movement/ElytraFlyModule.java +++ b/src/main/java/me/rigamortis/seppuku/impl/module/movement/ElytraFlyModule.java @@ -163,13 +163,13 @@ public final class ElytraFlyModule extends Module { break; case CONTROL: final double[] directionSpeedControl = MathUtil.directionSpeed(this.speed.getValue()); - mc.player.motionY = -this.idlefall.getValue(); + mc.player.motionY = 0; mc.player.motionX = 0; mc.player.motionZ = 0; if (mc.player.movementInput.jump) { - mc.player.motionY = this.upspd.getValue(); + mc.player.motionY = this.speed.getValue() / 2; } else if (mc.player.movementInput.sneak) { - mc.player.motionY = -this.downspd.getValue(); + mc.player.motionY = -this.speed.getValue() / 2; } if (mc.player.movementInput.moveStrafe != 0 || mc.player.movementInput.moveForward != 0) { mc.player.motionX = directionSpeedControl[0]; From a4e34ef95d0d42cf3fb58ea52776f0a965de2524 Mon Sep 17 00:00:00 2001 From: noil Date: Thu, 7 May 2020 22:04:04 -0400 Subject: [PATCH 15/15] First Launch component, keyTyped method added to hud components, tutorial & popup components also updated --- .../java/me/rigamortis/seppuku/Seppuku.java | 10 ++- .../api/gui/hud/component/HudComponent.java | 4 + .../seppuku/impl/gui/hud/GuiHudEditor.java | 6 ++ .../hud/component/FirstLaunchComponent.java | 73 +++++++++++++++++++ .../gui/hud/component/PopupComponent.java | 9 ++- .../gui/hud/component/TutorialComponent.java | 4 +- .../impl/management/ConfigManager.java | 4 +- .../seppuku/impl/management/HudManager.java | 18 +++++ .../impl/module/hidden/KeybindsModule.java | 1 - .../seppuku/impl/module/render/HudModule.java | 9 +-- 10 files changed, 121 insertions(+), 17 deletions(-) create mode 100644 src/main/java/me/rigamortis/seppuku/impl/gui/hud/component/FirstLaunchComponent.java diff --git a/src/main/java/me/rigamortis/seppuku/Seppuku.java b/src/main/java/me/rigamortis/seppuku/Seppuku.java index f8ba800..771fbce 100644 --- a/src/main/java/me/rigamortis/seppuku/Seppuku.java +++ b/src/main/java/me/rigamortis/seppuku/Seppuku.java @@ -107,7 +107,15 @@ public final class Seppuku { this.getEventManager().dispatchEvent(new EventLoad()); - this.logger.info("Loaded"); + // Add runtime hook to listen for shutdown to save configs + Runtime.getRuntime().addShutdownHook(new Thread("Seppuku Shutdown Hook") { + @Override + public void run() { + getConfigManager().saveAll(); + } + }); + + this.logger.info("Seppuku Loaded Successfully"); } public void errorChat(String message) { diff --git a/src/main/java/me/rigamortis/seppuku/api/gui/hud/component/HudComponent.java b/src/main/java/me/rigamortis/seppuku/api/gui/hud/component/HudComponent.java index 2ea5eb8..b34c873 100644 --- a/src/main/java/me/rigamortis/seppuku/api/gui/hud/component/HudComponent.java +++ b/src/main/java/me/rigamortis/seppuku/api/gui/hud/component/HudComponent.java @@ -41,6 +41,10 @@ public class HudComponent { } + public void keyTyped(char typedChar, int keyCode) { + + } + public boolean collidesWith(HudComponent other) { // Collision x-axis? boolean collisionX = this.x + this.w > other.x && diff --git a/src/main/java/me/rigamortis/seppuku/impl/gui/hud/GuiHudEditor.java b/src/main/java/me/rigamortis/seppuku/impl/gui/hud/GuiHudEditor.java index fa07a28..7aacbd2 100644 --- a/src/main/java/me/rigamortis/seppuku/impl/gui/hud/GuiHudEditor.java +++ b/src/main/java/me/rigamortis/seppuku/impl/gui/hud/GuiHudEditor.java @@ -35,6 +35,12 @@ public final class GuiHudEditor extends GuiScreen { } } } + + for (HudComponent component : Seppuku.INSTANCE.getHudManager().getComponentList()) { + if (component.isVisible()) { + component.keyTyped(typedChar, keyCode); + } + } } @Override diff --git a/src/main/java/me/rigamortis/seppuku/impl/gui/hud/component/FirstLaunchComponent.java b/src/main/java/me/rigamortis/seppuku/impl/gui/hud/component/FirstLaunchComponent.java new file mode 100644 index 0000000..da41183 --- /dev/null +++ b/src/main/java/me/rigamortis/seppuku/impl/gui/hud/component/FirstLaunchComponent.java @@ -0,0 +1,73 @@ +package me.rigamortis.seppuku.impl.gui.hud.component; + +import me.rigamortis.seppuku.Seppuku; +import me.rigamortis.seppuku.api.gui.hud.component.DraggableHudComponent; +import me.rigamortis.seppuku.api.module.Module; +import me.rigamortis.seppuku.api.util.RenderUtil; +import me.rigamortis.seppuku.impl.gui.hud.GuiHudEditor; +import me.rigamortis.seppuku.impl.module.render.HudModule; +import net.minecraft.client.Minecraft; +import org.lwjgl.input.Keyboard; + +import java.security.Key; + +/** + * created by noil on 5/7/2020 + */ +public final class FirstLaunchComponent extends DraggableHudComponent { + + private Module hudModule; + + private String textData; + + public FirstLaunchComponent() { + super("FirstLaunch"); + + final String textData = "Welcome to Seppuku Client!\n\n" + + "Press ~ (tilda/grave) to open the GUI / hud-editor."; + this.setTextData(textData); + + this.setVisible(true); + this.setSnappable(false); + this.setW(200); + this.setH(38); + this.setX(2); + this.setY(2); + + this.hudModule = Seppuku.INSTANCE.getModuleManager().find(HudModule.class); + } + + @Override + public void render(int mouseX, int mouseY, float partialTicks) { + super.render(mouseX, mouseY, partialTicks); + + final Minecraft mc = Minecraft.getMinecraft(); + + // Background + RenderUtil.drawRect(this.getX(), this.getY(), this.getX() + this.getW(), this.getY() + this.getH(), 0xFF202020); + + // Render text data + mc.fontRenderer.drawSplitString(this.textData, (int) this.getX() + 2, (int) this.getY() + 2, 200, 0xFFFFFFFF); + } + + public void onClose() { + if (this.hudModule != null) { + if(this.hudModule.isEnabled()) { + this.hudModule.onEnable(); + }else { + this.hudModule.toggle(); + } + this.hudModule.setEnabled(true); + } + + this.setVisible(false); + } + + public String getTextData() { + return textData; + } + + public void setTextData(String textData) { + this.textData = textData; + } +} diff --git a/src/main/java/me/rigamortis/seppuku/impl/gui/hud/component/PopupComponent.java b/src/main/java/me/rigamortis/seppuku/impl/gui/hud/component/PopupComponent.java index 1257d26..323511a 100644 --- a/src/main/java/me/rigamortis/seppuku/impl/gui/hud/component/PopupComponent.java +++ b/src/main/java/me/rigamortis/seppuku/impl/gui/hud/component/PopupComponent.java @@ -30,9 +30,6 @@ public class PopupComponent extends DraggableHudComponent { final Minecraft mc = Minecraft.getMinecraft(); - if (!(mc.currentScreen instanceof GuiHudEditor)) // ensure we are in the hud editor screen only - return; - // background RenderUtil.drawRect(this.getX(), this.getY(), this.getX() + this.getW(), this.getY() + this.getH(), 0xFF202020); @@ -54,7 +51,7 @@ public class PopupComponent extends DraggableHudComponent { mouseY <= this.getY() + CLOSE_BUTTON_SIZE; if (insideCloseButton && button == 0) { - this.setVisible(false); + this.onCloseButton(); } } @@ -65,4 +62,8 @@ public class PopupComponent extends DraggableHudComponent { public void setTextData(String textData) { this.textData = textData; } + + public void onCloseButton() { + this.setVisible(false); + } } diff --git a/src/main/java/me/rigamortis/seppuku/impl/gui/hud/component/TutorialComponent.java b/src/main/java/me/rigamortis/seppuku/impl/gui/hud/component/TutorialComponent.java index 73d8899..d87442b 100644 --- a/src/main/java/me/rigamortis/seppuku/impl/gui/hud/component/TutorialComponent.java +++ b/src/main/java/me/rigamortis/seppuku/impl/gui/hud/component/TutorialComponent.java @@ -33,13 +33,13 @@ public final class TutorialComponent extends PopupComponent { @Override public void render(int mouseX, int mouseY, float partialTicks) { - super.render(mouseX, mouseY, partialTicks); - final Minecraft mc = Minecraft.getMinecraft(); if (!(mc.currentScreen instanceof GuiHudEditor)) // ensure we are in the hud editor screen only return; + super.render(mouseX, mouseY, partialTicks); + // drag me! mc.fontRenderer.drawStringWithShadow("(drag me!)", this.getX() + this.getW() - 80, this.getY() + 10, 0xFFAAAAAA); } diff --git a/src/main/java/me/rigamortis/seppuku/impl/management/ConfigManager.java b/src/main/java/me/rigamortis/seppuku/impl/management/ConfigManager.java index f6f3d2c..ff64744 100644 --- a/src/main/java/me/rigamortis/seppuku/impl/management/ConfigManager.java +++ b/src/main/java/me/rigamortis/seppuku/impl/management/ConfigManager.java @@ -18,7 +18,7 @@ public final class ConfigManager { private File moduleConfigDir; private File hudComponentConfigDir; - private boolean firstLaunch; + private boolean firstLaunch = false; private List configurableList = new ArrayList<>(); @@ -31,7 +31,7 @@ public final class ConfigManager { private void generateDirectories() { this.configDir = new File(CONFIG_PATH); if (!this.configDir.exists()) { - this.firstLaunch = true; + this.setFirstLaunch(true); this.configDir.mkdirs(); } diff --git a/src/main/java/me/rigamortis/seppuku/impl/management/HudManager.java b/src/main/java/me/rigamortis/seppuku/impl/management/HudManager.java index c2b624e..38ac8e1 100644 --- a/src/main/java/me/rigamortis/seppuku/impl/management/HudManager.java +++ b/src/main/java/me/rigamortis/seppuku/impl/management/HudManager.java @@ -5,11 +5,14 @@ import me.rigamortis.seppuku.api.event.render.EventRender2D; import me.rigamortis.seppuku.api.gui.hud.component.HudComponent; import me.rigamortis.seppuku.api.module.Module; import me.rigamortis.seppuku.api.util.ReflectionUtil; +import me.rigamortis.seppuku.impl.gui.hud.GuiHudEditor; import me.rigamortis.seppuku.impl.gui.hud.anchor.AnchorPoint; import me.rigamortis.seppuku.impl.gui.hud.component.*; import me.rigamortis.seppuku.impl.gui.hud.component.module.ModuleListComponent; +import me.rigamortis.seppuku.impl.module.render.HudModule; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiChat; +import net.minecraft.client.gui.GuiIngame; import net.minecraft.client.gui.ScaledResolution; import team.stiff.pomelo.impl.annotated.handler.annotation.Listener; @@ -29,6 +32,8 @@ public final class HudManager { private List componentList = new CopyOnWriteArrayList<>(); private List anchorPoints = new ArrayList<>(); + private final FirstLaunchComponent firstLaunchComponent; + public HudManager() { final ScaledResolution res = new ScaledResolution(Minecraft.getMinecraft()); @@ -86,6 +91,9 @@ public final class HudManager { // Organize alphabetically this.componentList = this.componentList.stream().sorted((obj1, obj2) -> obj1.getName().compareTo(obj2.getName())).collect(Collectors.toList()); + // Create first launch component + this.firstLaunchComponent = new FirstLaunchComponent(); + Seppuku.INSTANCE.getEventManager().addEventListener(this); } @@ -98,6 +106,16 @@ public final class HudManager { public void onRender(EventRender2D event) { final Minecraft mc = Minecraft.getMinecraft(); + if (this.firstLaunchComponent != null && mc.world != null) { + if (Seppuku.INSTANCE.getConfigManager().isFirstLaunch()) { + if (mc.currentScreen instanceof GuiHudEditor) { + firstLaunchComponent.onClose(); + } else if (firstLaunchComponent.isVisible()) { + firstLaunchComponent.render(0, 0, event.getPartialTicks()); + } + } + } + final int chatHeight = (mc.currentScreen instanceof GuiChat) ? 14 : 0; for (AnchorPoint point : this.anchorPoints) { diff --git a/src/main/java/me/rigamortis/seppuku/impl/module/hidden/KeybindsModule.java b/src/main/java/me/rigamortis/seppuku/impl/module/hidden/KeybindsModule.java index 0dcc249..8f030cd 100644 --- a/src/main/java/me/rigamortis/seppuku/impl/module/hidden/KeybindsModule.java +++ b/src/main/java/me/rigamortis/seppuku/impl/module/hidden/KeybindsModule.java @@ -24,7 +24,6 @@ public final class KeybindsModule extends Module { if(mod != null) { if(mod.getType() != ModuleType.HIDDEN && event.getKey() == Keyboard.getKeyIndex(mod.getKey()) && Keyboard.getKeyIndex(mod.getKey()) != Keyboard.KEY_NONE) { mod.toggle(); - Seppuku.INSTANCE.getConfigManager().saveAll(); } } } diff --git a/src/main/java/me/rigamortis/seppuku/impl/module/render/HudModule.java b/src/main/java/me/rigamortis/seppuku/impl/module/render/HudModule.java index fce1f96..067dda1 100644 --- a/src/main/java/me/rigamortis/seppuku/impl/module/render/HudModule.java +++ b/src/main/java/me/rigamortis/seppuku/impl/module/render/HudModule.java @@ -22,7 +22,7 @@ public final class HudModule extends Module { public final Value hidePotions = new Value("HidePotions", new String[]{"HidePotions", "HidePots", "Hide_Potions"}, "Hides the Vanilla potion hud (at the top right of the screen).", true); public HudModule() { - super("Hud", new String[]{"Overlay"}, "Shows lots of useful info", "NONE", -1, ModuleType.RENDER); + super("Hud", new String[]{"Overlay"}, "Renders hud components on the screen.", "NONE", -1, ModuleType.RENDER); this.setHidden(true); } @@ -30,11 +30,7 @@ public final class HudModule extends Module { public void render(EventRender2D event) { final Minecraft mc = Minecraft.getMinecraft(); - if (mc.gameSettings.showDebugInfo) { - return; - } - - if (mc.currentScreen instanceof GuiHudEditor) { + if (mc.gameSettings.showDebugInfo || mc.currentScreen instanceof GuiHudEditor || mc.player == null) { return; } @@ -42,7 +38,6 @@ public final class HudModule extends Module { GlStateManager.enableBlend(); for (HudComponent component : Seppuku.INSTANCE.getHudManager().getComponentList()) { if (component.isVisible()) { - //dont render components with the TOP_CENTER anchor if we are looking at the tab list if (component instanceof DraggableHudComponent) { final DraggableHudComponent draggableComponent = (DraggableHudComponent) component;