diff --git a/src/main/java/me/rigamortis/seppuku/api/event/entity/EventGetMouseOver.java b/src/main/java/me/rigamortis/seppuku/api/event/player/EventGetMouseOver.java similarity index 74% rename from src/main/java/me/rigamortis/seppuku/api/event/entity/EventGetMouseOver.java rename to src/main/java/me/rigamortis/seppuku/api/event/player/EventGetMouseOver.java index 03ce7a4..26a17f6 100644 --- a/src/main/java/me/rigamortis/seppuku/api/event/entity/EventGetMouseOver.java +++ b/src/main/java/me/rigamortis/seppuku/api/event/player/EventGetMouseOver.java @@ -1,4 +1,4 @@ -package me.rigamortis.seppuku.api.event.entity; +package me.rigamortis.seppuku.api.event.player; import me.rigamortis.seppuku.api.event.EventCancellable; diff --git a/src/main/java/me/rigamortis/seppuku/api/event/player/EventHandActive.java b/src/main/java/me/rigamortis/seppuku/api/event/player/EventHandActive.java new file mode 100644 index 0000000..332dcb9 --- /dev/null +++ b/src/main/java/me/rigamortis/seppuku/api/event/player/EventHandActive.java @@ -0,0 +1,9 @@ +package me.rigamortis.seppuku.api.event.player; + +import me.rigamortis.seppuku.api.event.EventCancellable; + +/** + * @author noil + */ +public class EventHandActive extends EventCancellable { +} diff --git a/src/main/java/me/rigamortis/seppuku/api/event/player/EventHittingBlock.java b/src/main/java/me/rigamortis/seppuku/api/event/player/EventHittingBlock.java new file mode 100644 index 0000000..6d1ce18 --- /dev/null +++ b/src/main/java/me/rigamortis/seppuku/api/event/player/EventHittingBlock.java @@ -0,0 +1,9 @@ +package me.rigamortis.seppuku.api.event.player; + +import me.rigamortis.seppuku.api.event.EventCancellable; + +/** + * @author noil + */ +public class EventHittingBlock extends EventCancellable { +} diff --git a/src/main/java/me/rigamortis/seppuku/api/util/FileUtil.java b/src/main/java/me/rigamortis/seppuku/api/util/FileUtil.java index 62d7156..d0d8ec7 100644 --- a/src/main/java/me/rigamortis/seppuku/api/util/FileUtil.java +++ b/src/main/java/me/rigamortis/seppuku/api/util/FileUtil.java @@ -7,6 +7,7 @@ import me.rigamortis.seppuku.Seppuku; import java.io.*; import java.util.ArrayList; import java.util.List; +import java.util.logging.Level; /** * @author noil @@ -22,7 +23,7 @@ public class FileUtil { try { return new FileReader(file); } catch (FileNotFoundException e) { - e.printStackTrace(); + Seppuku.INSTANCE.getLogger().log(Level.WARNING, "Error creating reader: File not found exception"); } } return null; @@ -35,7 +36,7 @@ public class FileUtil { try { reader.close(); } catch (IOException e) { - e.printStackTrace(); + Seppuku.INSTANCE.getLogger().log(Level.WARNING, "Error closing reader: IO exception"); } } @@ -98,7 +99,6 @@ public class FileUtil { } } } catch (IOException e) { - e.printStackTrace(); file.delete(); } } @@ -130,6 +130,7 @@ public class FileUtil { fileReader.close(); } } catch (IOException e) { + System.err.println("IOException thrown, can't close the file reader."); } } @@ -163,7 +164,7 @@ public class FileUtil { fileWriter.close(); } } catch (IOException e) { - message = "IOException thrown while attemping to close the writer."; + message = "IOException thrown while attempting to close the file writer."; } } 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 775c589..6543a68 100644 --- a/src/main/java/me/rigamortis/seppuku/impl/management/ModuleManager.java +++ b/src/main/java/me/rigamortis/seppuku/impl/management/ModuleManager.java @@ -157,6 +157,7 @@ public final class ModuleManager { add(new AutoFarmModule()); add(new NoEffectsModule()); add(new NoEntityTraceModule()); + add(new MultitaskModule()); // p2w experience if (Seppuku.INSTANCE.getCapeManager().hasCape()) diff --git a/src/main/java/me/rigamortis/seppuku/impl/module/combat/CrystalAuraModule.java b/src/main/java/me/rigamortis/seppuku/impl/module/combat/CrystalAuraModule.java index 47ecd75..51240bd 100644 --- a/src/main/java/me/rigamortis/seppuku/impl/module/combat/CrystalAuraModule.java +++ b/src/main/java/me/rigamortis/seppuku/impl/module/combat/CrystalAuraModule.java @@ -42,14 +42,15 @@ import java.util.concurrent.CopyOnWriteArrayList; */ public final class CrystalAuraModule extends Module { - public final Value range = new Value("Range", new String[]{"Dist"}, "The minimum range to attack crystals.", 4.5f, 0.0f, 5.0f, 0.1f); - public final Value attackDelay = new Value("Attack_Delay", new String[]{"AttackDelay", "AttackDel", "Del"}, "The delay to attack in milliseconds.", 50.0f, 0.0f, 1000.0f, 1.0f); - public final Value place = new Value("Place", new String[]{"AutoPlace"}, "Automatically place crystals.", true); - public final Value placeDelay = new Value("Place_Delay", new String[]{"PlaceDelay", "PlaceDel"}, "The delay to place crystals.", 50.0f, 0.0f, 1000.0f, 1.0f); - public final Value minDamage = new Value("Min_Damage", new String[]{"MinDamage", "Min", "MinDmg"}, "The minimum explosion damage calculated to place down a crystal.", 1.0f, 0.0f, 20.0f, 0.5f); - public final Value ignore = new Value("Ignore", new String[]{"Ig"}, "Ignore self damage checks.", false); - public final Value render = new Value("Render", new String[]{"R"}, "Draws information about recently placed crystals from your player.", true); - public final Value renderDamage = new Value("Render_Damage", new String[]{"RD", "RenderDamage", "ShowDamage"}, "Draws calculated explosion damage on recently placed crystals from your player.", true); + public final Value range = new Value("Range", new String[]{"Dist"}, "The minimum range to attack crystals.", 4.0f, 0.0f, 7.0f, 0.1f); + public final Value attackDelay = new Value("Attack_Delay", new String[]{"AttackDelay", "AttackDel", "Del"}, "The delay to attack in milliseconds.", 50.0f, 0.0f, 1000.0f, 1.0f); + public final Value place = new Value("Place", new String[]{"AutoPlace"}, "Automatically place crystals.", true); + public final Value placeDelay = new Value("Place_Delay", new String[]{"PlaceDelay", "PlaceDel"}, "The delay to place crystals.", 50.0f, 0.0f, 1000.0f, 1.0f); + public final Value minDamage = new Value("Min_Damage", new String[]{"MinDamage", "Min", "MinDmg"}, "The minimum explosion damage calculated to place down a crystal.", 1.5f, 0.0f, 20.0f, 0.5f); + public final Value ignore = new Value("Ignore", new String[]{"Ig"}, "Ignore self damage checks.", false); + public final Value render = new Value("Render", new String[]{"R"}, "Draws information about recently placed crystals from your player.", true); + public final Value renderDamage = new Value("Render_Damage", new String[]{"RD", "RenderDamage", "ShowDamage"}, "Draws calculated explosion damage on recently placed crystals from your player.", true); + public final Value offHand = new Value("Offhand", new String[]{"Hand", "otherhand", "off"}, "Use crystals in the off-hand instead of holding them with the main-hand.", false); private final Timer attackTimer = new Timer(); private final Timer placeTimer = new Timer(); @@ -64,10 +65,11 @@ public final class CrystalAuraModule extends Module { public void onWalkingUpdate(EventUpdateWalkingPlayer event) { if (event.getStage() == EventStageable.EventStage.PRE) { final Minecraft mc = Minecraft.getMinecraft(); - - if (mc.player.inventory.getCurrentItem().getItem() != Items.END_CRYSTAL) { + if (mc.player == null || mc.world == null) + return; + + if (mc.player.getHeldItem(this.offHand.getValue() ? EnumHand.OFF_HAND : EnumHand.MAIN_HAND).getItem() != Items.END_CRYSTAL) return; - } if (this.place.getValue()) { if (this.placeTimer.passed(this.placeDelay.getValue())) { @@ -120,7 +122,7 @@ public final class CrystalAuraModule extends Module { if (pos != null && damage > 0) { final float[] angle = MathUtil.calcAngle(mc.player.getPositionEyes(mc.getRenderPartialTicks()), new Vec3d(pos.getX() + 0.5f, pos.getY() + 0.5f, pos.getZ() + 0.5f)); Seppuku.INSTANCE.getRotationManager().setPlayerRotations(angle[0], angle[1]); - mc.player.connection.sendPacket(new CPacketPlayerTryUseItemOnBlock(pos, EnumFacing.UP, EnumHand.MAIN_HAND, 0, 0, 0)); + mc.player.connection.sendPacket(new CPacketPlayerTryUseItemOnBlock(pos, EnumFacing.UP, this.offHand.getValue() ? EnumHand.OFF_HAND : EnumHand.MAIN_HAND, 0, 0, 0)); this.placeLocations.add(new PlaceLocation(pos.getX(), pos.getY(), pos.getZ(), damage)); } @@ -145,7 +147,7 @@ public final class CrystalAuraModule extends Module { final float[] angle = MathUtil.calcAngle(mc.player.getPositionEyes(mc.getRenderPartialTicks()), entity.getPositionVector()); Seppuku.INSTANCE.getRotationManager().setPlayerRotations(angle[0], angle[1]); if (this.attackTimer.passed(this.attackDelay.getValue())) { - mc.player.swingArm(EnumHand.MAIN_HAND); + mc.player.swingArm(this.offHand.getValue() ? EnumHand.OFF_HAND : EnumHand.MAIN_HAND); mc.playerController.attackEntity(mc.player, entity); this.attackTimer.reset(); } @@ -181,6 +183,7 @@ public final class CrystalAuraModule extends Module { final Minecraft mc = Minecraft.getMinecraft(); + RenderUtil.begin3D(); for (PlaceLocation placeLocation : this.placeLocations) { if (placeLocation.alpha <= 0) { this.placeLocations.remove(placeLocation); @@ -213,6 +216,7 @@ public final class CrystalAuraModule extends Module { } } } + RenderUtil.end3D(); } private boolean isLocalImmune() { diff --git a/src/main/java/me/rigamortis/seppuku/impl/module/combat/MultitaskModule.java b/src/main/java/me/rigamortis/seppuku/impl/module/combat/MultitaskModule.java new file mode 100644 index 0000000..ed7cfdc --- /dev/null +++ b/src/main/java/me/rigamortis/seppuku/impl/module/combat/MultitaskModule.java @@ -0,0 +1,32 @@ +package me.rigamortis.seppuku.impl.module.combat; + +import me.rigamortis.seppuku.api.event.player.EventHandActive; +import me.rigamortis.seppuku.api.event.player.EventHittingBlock; +import me.rigamortis.seppuku.api.event.player.EventResetBlockRemoving; +import me.rigamortis.seppuku.api.module.Module; +import team.stiff.pomelo.impl.annotated.handler.annotation.Listener; + +/** + * @author noil + */ +public final class MultitaskModule extends Module { + + public MultitaskModule() { + super("Multitask", new String[]{"multi", "task"}, "Allows the player to perform multiple actions at once. (eating, placing, attacking)", "NONE", -1, ModuleType.COMBAT); + } + + @Listener + public void onActiveHand(EventHandActive event) { + event.setCanceled(true); + } + + @Listener + public void onHittingBlock(EventHittingBlock event) { + event.setCanceled(true); + } + + @Listener + public void onResetBlockRemoving(EventResetBlockRemoving event) { + event.setCanceled(true); + } +} diff --git a/src/main/java/me/rigamortis/seppuku/impl/module/combat/NoEntityTraceModule.java b/src/main/java/me/rigamortis/seppuku/impl/module/combat/NoEntityTraceModule.java index f23de46..fe2e1d2 100644 --- a/src/main/java/me/rigamortis/seppuku/impl/module/combat/NoEntityTraceModule.java +++ b/src/main/java/me/rigamortis/seppuku/impl/module/combat/NoEntityTraceModule.java @@ -1,6 +1,6 @@ package me.rigamortis.seppuku.impl.module.combat; -import me.rigamortis.seppuku.api.event.entity.EventGetMouseOver; +import me.rigamortis.seppuku.api.event.player.EventGetMouseOver; import me.rigamortis.seppuku.api.module.Module; import team.stiff.pomelo.impl.annotated.handler.annotation.Listener; diff --git a/src/main/java/me/rigamortis/seppuku/impl/patch/EntityPlayerSPPatch.java b/src/main/java/me/rigamortis/seppuku/impl/patch/EntityPlayerSPPatch.java index f1c7f71..64d81aa 100644 --- a/src/main/java/me/rigamortis/seppuku/impl/patch/EntityPlayerSPPatch.java +++ b/src/main/java/me/rigamortis/seppuku/impl/patch/EntityPlayerSPPatch.java @@ -382,5 +382,39 @@ public final class EntityPlayerSPPatch extends ClassPatch { methodNode.instructions.insert(insnList); } + @MethodPatch( + mcpName = "isHandActive", + notchName = "cG", + mcpDesc = "()Z") + public void isHandActive(MethodNode methodNode, PatchManager.Environment env) { + //create a list of instructions + final InsnList insnList = new InsnList(); + //call our hook function + insnList.add(new MethodInsnNode(INVOKESTATIC, Type.getInternalName(this.getClass()), "isHandActiveHook", "()Z", false)); + //create a label to jump to + final LabelNode jmp = new LabelNode(); + //add "if equals" + insnList.add(new JumpInsnNode(IFEQ, jmp)); + //add 0 or false + insnList.add(new InsnNode(ICONST_0)); + //return so the rest of the function doesnt get called + insnList.add(new InsnNode(IRETURN)); + //add our label + insnList.add(jmp); + //insert the list of instructs at the top of the function + methodNode.instructions.insert(insnList); + } + + /** + * Our isHandActive hook used to override hand activity + * + * @return + */ + public static boolean isHandActiveHook() { + //dispatch our event + final EventHandActive event = new EventHandActive(); + Seppuku.INSTANCE.getEventManager().dispatchEvent(event); + return event.isCanceled(); + } } diff --git a/src/main/java/me/rigamortis/seppuku/impl/patch/EntityRendererPatch.java b/src/main/java/me/rigamortis/seppuku/impl/patch/EntityRendererPatch.java index 3adef02..0c0f078 100644 --- a/src/main/java/me/rigamortis/seppuku/impl/patch/EntityRendererPatch.java +++ b/src/main/java/me/rigamortis/seppuku/impl/patch/EntityRendererPatch.java @@ -1,7 +1,7 @@ package me.rigamortis.seppuku.impl.patch; import me.rigamortis.seppuku.Seppuku; -import me.rigamortis.seppuku.api.event.entity.EventGetMouseOver; +import me.rigamortis.seppuku.api.event.player.EventGetMouseOver; import me.rigamortis.seppuku.api.event.player.EventFovModifier; import me.rigamortis.seppuku.api.event.render.EventHurtCamEffect; import me.rigamortis.seppuku.api.event.render.EventOrientCamera; @@ -13,13 +13,11 @@ import me.rigamortis.seppuku.api.util.ASMUtil; import me.rigamortis.seppuku.impl.management.PatchManager; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.ScaledResolution; -import net.minecraft.entity.Entity; import org.objectweb.asm.Type; import org.objectweb.asm.tree.*; import team.stiff.pomelo.EventManager; import java.util.ArrayList; -import java.util.List; import static org.objectweb.asm.Opcodes.*; diff --git a/src/main/java/me/rigamortis/seppuku/impl/patch/PlayerControllerMPPatch.java b/src/main/java/me/rigamortis/seppuku/impl/patch/PlayerControllerMPPatch.java index a621b67..dfb893c 100644 --- a/src/main/java/me/rigamortis/seppuku/impl/patch/PlayerControllerMPPatch.java +++ b/src/main/java/me/rigamortis/seppuku/impl/patch/PlayerControllerMPPatch.java @@ -358,4 +358,38 @@ public final class PlayerControllerMPPatch extends ClassPatch { return event.isCanceled(); } + @MethodPatch( + mcpName = "getIsHittingBlock", + notchName = "m", + mcpDesc = "()Z") + public void getIsHittingBlock(MethodNode methodNode, PatchManager.Environment env) { + //create a list of instructions + final InsnList insnList = new InsnList(); + //call our hook function + insnList.add(new MethodInsnNode(INVOKESTATIC, Type.getInternalName(this.getClass()), "getIsHittingBlockHook", "()Z", false)); + //create a label to jump to + final LabelNode jmp = new LabelNode(); + //add "if equals" + insnList.add(new JumpInsnNode(IFEQ, jmp)); + //add 0 or false + insnList.add(new InsnNode(ICONST_0)); + //return so the rest of the function doesnt get called + insnList.add(new InsnNode(IRETURN)); + //add our label + insnList.add(jmp); + //insert the list of instructs at the top of the function + methodNode.instructions.insert(insnList); + } + + /** + * Our getIsHittingBlockHook hook used to override block-hitting hand activity + * + * @return true if the event is cancelled + */ + public static boolean getIsHittingBlockHook() { + //dispatch our event + final EventHittingBlock event = new EventHittingBlock(); + Seppuku.INSTANCE.getEventManager().dispatchEvent(event); + return event.isCanceled(); + } }