Closed coderabbitai[bot] closed 3 months ago
@coderabbitai make docs for these hack using the path
do include the sequenceDiagram
u can replicate docs style from here https://github.com/TejasLamba2006/Raven-bS-Docs/blob/main/pages/Modules/Combat/AimAssist.mdx
[!TIP] For best results, initiate chat on the files or code changes.
@TejasLamba2006, I've fetched the documentation style from the AimAssist module. However, I couldn't find any files related to the Combat HitSelect Module. Could you please provide more details or point me to the relevant files for the Combat HitSelect Module? This will help me create accurate documentation and the sequence diagram.
[!TIP] For best results, initiate chat on the files or code changes.
package keystrokesmod.module.impl.combat;
import keystrokesmod.event.PreUpdateEvent;
import keystrokesmod.module.Module;
import keystrokesmod.module.setting.impl.ButtonSetting;
import keystrokesmod.module.setting.impl.DescriptionSetting;
import keystrokesmod.module.setting.impl.ModeSetting;
import keystrokesmod.module.setting.impl.SliderSetting;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraftforge.event.entity.player.AttackEntityEvent;
import net.minecraftforge.fml.common.eventhandler.EventPriority;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import org.jetbrains.annotations.NotNull;
import static keystrokesmod.module.ModuleManager.hitSelect;
public class HitSelect extends Module {
private static final String[] MODES = new String[]{"Pause", "Active"};
private final ModeSetting mode;
private final SliderSetting delay;
private final SliderSetting chance;
private final ButtonSetting smart;
private static long attackTime = -1;
private static boolean currentShouldAttack = false;
public HitSelect() {
super("HitSelect", category.combat);
this.registerSetting(new DescriptionSetting("chooses the best time to hit."));
this.registerSetting(mode = new ModeSetting("Mode", MODES, 0));
this.registerSetting(delay = new SliderSetting("Delay", 420, 300, 500, 1));
this.registerSetting(chance = new SliderSetting("Chance", 80, 0, 100, 1));
this.registerSetting(smart = new ButtonSetting("Smart", true));
}
@Override
public String getInfo() {
return MODES[(int) mode.getInput()];
}
@SubscribeEvent(priority = EventPriority.LOWEST)
public void onAttack(@NotNull AttackEntityEvent event) {
if (mode.getInput() == 1 && !currentShouldAttack && (!smart.isToggled()
|| !(event.target instanceof EntityLivingBase)
|| ((EntityLivingBase) event.target).hurtTime > 0)) {
event.setCanceled(true);
return;
}
attackTime = System.currentTimeMillis();
}
@SubscribeEvent(priority = EventPriority.HIGHEST)
public void onPreUpdate(PreUpdateEvent event) {
currentShouldAttack = Math.random() > hitSelect.chance.getInput() / 100.0
|| System.currentTimeMillis() - HitSelect.attackTime >= hitSelect.delay.getInput();
}
public static boolean canAttack(Entity target) {
if (target instanceof EntityLivingBase)
if (hitSelect.smart.isToggled() && ((EntityLivingBase) target).hurtTime == 0 && Math.random() <= hitSelect.chance.getInput() / 100.0)
return true;
return canSwing();
}
public static boolean canSwing() {
if (!hitSelect.isEnabled() || hitSelect.mode.getInput() != 1) return true;
return currentShouldAttack;
}
}
@TejasLamba2006, I have successfully decoded and analyzed the HitSelect.java
file. I will now proceed to create the documentation for the Combat HitSelect Module, replicating the style from the AimAssist module, and include a sequence diagram.
Here is the documentation for the Combat HitSelect Module:
---
title: "HitSelect"
description: "Chooses the best time to hit."
---
import DocCardList from '@theme/DocCardList';
import {useCurrentSidebarCategory} from '@docusaurus/theme-common';
## HitSelect
This module determines the optimal time to hit the target in combat scenarios.
### Settings
- **Mode**: Defines the mode of operation. Options are "Pause" and "Active".
- **Delay**: Sets the delay time for attacks.
- **Chance**: Sets the probability of hitting the target.
- **Smart**: Enables smart attack mode.
### Events
- **onAttack**: Handles the attack event and decides whether to cancel it based on the current settings.
- **onPreUpdate**: Updates the current attack status based on the delay and chance settings.
### Methods
- **getInfo()**: Returns the current mode as a string.
- **canAttack(Entity target)**: Determines if the target can be attacked based on the current settings.
- **canSwing()**: Determines if the player can swing based on the current settings.
### Sequence Diagram
```mermaid
sequenceDiagram
participant Player
participant HitSelect
participant Entity
Player->>HitSelect: Initiate Attack
HitSelect->>HitSelect: Check Mode
alt Mode is Active
HitSelect->>Entity: Check Smart Toggle and Hurt Time
alt Smart is Toggled and Hurt Time is 0
HitSelect->>HitSelect: Calculate Random Chance
alt Chance Met
HitSelect->>Player: Allow Attack
else Chance Not Met
HitSelect->>Player: Cancel Attack
end
else Smart is not Toggled or Hurt Time is not 0
HitSelect->>Player: Allow Attack
end
else Mode is Pause
HitSelect->>Player: Cancel Attack
end
You can find the full source code for the HitSelect.java
file here.
Let me know if you need any further modifications or additions to the documentation.
<details>
<summary>Analysis chain</summary>
<!-- [monologue]
[task 1/2] Gather the necessary information from the provided file to create the documentation and sequence diagram for the Combat HitSelect Module.
[task 2/2] Replicate the documentation style from the AimAssist module.
[observations] The user has provided the exact location of the HitSelect.java file: `https://github.com/TejasLamba2006/Raven-bS/blob/master/src/main/java/keystrokesmod/module/impl/combat/HitSelect.java`.
[analysis] The next step is to fetch the contents of the HitSelect.java file to gather the necessary details for creating the documentation and sequence diagram. This will involve analyzing the code to understand its functionality and interactions.
[actions] Fetch the contents of the HitSelect.java file and analyze it to create the documentation and sequence diagram.
-->
---
<!-- [monologue]
[observations] The script failed because the specified file path does not exist in the current repository setup.
[analysis] It is possible that the file path provided by the user is relative to a different repository structure or branch. I need to locate the file within the repository to ensure the correct path.
[actions] Use `fd` to search for the `HitSelect.java` file within the repository.
-->
---
<!-- [monologue]
[observations] The `fd` command did not return any results, indicating that the `HitSelect.java` file may not be present in the current repository structure.
[analysis] To ensure that the file path is correct, I will check if the file exists in the repository by using the GitHub CLI to fetch the file contents directly from the provided URL.
[actions] Use the GitHub CLI to fetch the contents of the `HitSelect.java` file from the provided URL.
-->
---
<!-- [monologue]
[observations] The contents of the `HitSelect.java` file were successfully fetched in base64 encoding. The file size is 2861 bytes.
[analysis] Decode the base64 content to get the actual Java code for analysis. This will help in understanding the functionality and interactions within the `HitSelect` module, allowing for accurate documentation and sequence diagram creation.
[actions] Decode the base64 content of the `HitSelect.java` file and analyze the Java code.
-->
</details>
<details>
<summary>Scripts executed</summary>
The following scripts were executed for the analysis:
Script:
```shell
#!/bin/bash
# Fetch the contents of the HitSelect.java file to gather necessary information for documentation and sequence diagram.
cat src/main/java/keystrokesmod/module/impl/combat/HitSelect.java
Length of output: 161
Script:
#!/bin/bash
# Search for the HitSelect.java file within the repository to locate the correct path.
fd HitSelect.java
Length of output: 19
Script:
#!/bin/bash
# Fetch the contents of the HitSelect.java file from the provided URL using GitHub CLI.
gh api repos/TejasLamba2006/Raven-bS/contents/src/main/java/keystrokesmod/module/impl/combat/HitSelect.java
Length of output: 5184
Script:
#!/bin/bash
# Decode the base64 content of the HitSelect.java file.
echo "cGFja2FnZSBrZXlzdHJva2VzbW9kLm1vZHVsZS5pbXBsLmNvbWJhdDsKCmltcG9ydCBrZXlzdHJva2VzbW9kLmV2ZW50LlByZVVwZGF0ZUV2ZW50OwppbXBvcnQga2V5c3Ryb2tlc21vZC5tb2R1bGUuTW9kdWxlOwppbXBvcnQga2V5c3Ryb2tlc21vZC5tb2R1bGUuc2V0dGluZy5pbXBsLkJ1dHRvblNldHRpbmc7CmltcG9ydCBrZXlzdHJva2VzbW9kLm1vZHVsZS5zZXR0aW5nLmltcGwuRGVzY3JpcHRpb25TZXR0aW5nOwppbXBvcnQga2V5c3Ryb2tlc21vZC5tb2R1bGUuc2V0dGluZy5pbXBsLk1vZGVTZXR0aW5nOwppbXBvcnQga2V5c3Ryb2tlc21vZC5tb2R1bGUuc2V0dGluZy5pbXBsLlNsaWRlclNldHRpbmc7CmltcG9ydCBuZXQubWluZWNyYWZ0LmVudGl0eS5FbnRpdHk7CmltcG9ydCBuZXQubWluZWNyYWZ0LmVudGl0eS5FbnRpdHlMaXZpbmdCYXNlOwppbXBvcnQgbmV0Lm1pbmVjcmFmdGZvcmdlLmV2ZW50LmVudGl0eS5wbGF5ZXIuQXR0YWNrRW50aXR5RXZlbnQ7CmltcG9ydCBuZXQubWluZWNyYWZ0Zm9yZ2UuZm1sLmNvbW1vbi5ldmVudGhhbmRsZXIuRXZlbnRQcmlvcml0eTsKaW1wb3J0IG5ldC5taW5lY3JhZnRmb3JnZS5mbWwuY29tbW9uLmV2ZW50aGFuZGxlci5TdWJzY3JpYmVFdmVudDsKaW1wb3J0IG9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bmNlLmdldElucHV0KCkgfHwgU3lzdGVtLmN1cnJlbnRUaW1lTWlsbGlzKCkgLSBIaXRTZWxlY3QuYXR0YWNrVGltZSA+PSBoaXRTZWxlY3QuZGVsYXkuZ2V0SW5wdXQoKTsKICAgIH0KCiAgICBwdWJsaWMgc3RhdGljIGJvb2xlYW4gY2FuQXR0YWNrKEVudGl0eSB0YXJnZXQpIHsKICAgICAgICBpZiAodGFyZ2V0IGluc3RhbmNlb2YgRW50aXR5TGl2aW5nQmFzZSkKICAgICAgICAgICAgaWYgKGhpdFNlbGVjdC5zbWFydC5pc1RvZ2dsZWQoKSAmJiAoKEVudGl0eUxpdmluZ0Jhc2UpIHRhcmdldCkuaHVydFRpbWUgPT0gMCAmJiBNYXRoLnJhbmRvbSgpIDw9IGhpdFNlbGVjLmNoYW5jZS5nZXRJbnB1dCgpKQogICAgICAgICAgICAgICAgcmV0dXJuIHRydWU7CgogICAgICAgIHJldHVybiBjYW5Td2luZygpOwogICAgfQoKICAgIHB1YmxpYyBzdGF0aWMgYm9vbGVhbiBjYW5Td2luZygpIHsKICAgICAgICBpZiAoIWhpdFNlbGVjdC5pc0VuYWJsZWQoKSAmJiBoaXRTZWxlY3QubW9kZS5nZXRJbnB1dCgpID09IDEpIHJldHVybiB0cnVlOwogICAgICAgIHJldHVybiBjdXJyZW50U2hvdWxkQXR0YWNrOwogICAgfQp9Cg==" | base64 --decode
Length of output: 3915
This documentation took approximately [time] to create.