Skip to content

Commit 2ca80cf

Browse files
committed
Add CombatModule#DISABLE_BLOCK_MISS_PENALTY
1 parent f7f216f commit 2ca80cf

7 files changed

Lines changed: 83 additions & 2 deletions

File tree

api/src/main/java/com/lunarclient/apollo/module/combat/CombatModule.java

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,29 @@ public final class CombatModule extends ApolloModule {
4545
* @since 1.0.4
4646
*/
4747
public static final SimpleOption<Boolean> DISABLE_MISS_PENALTY = Option.<Boolean>builder()
48-
.comment("Set to 'true' to remove the miss penalty on all versions 1.8 and above, otherwise 'false'. Enabling this option may cause compatibility issues with anti-cheats.")
48+
.comment(
49+
"Set to 'true' to remove the miss penalty on all versions 1.8 and above, otherwise 'false'.",
50+
"Enabling this option may cause compatibility issues with anti-cheats."
51+
)
4952
.node("disable-miss-penalty").type(TypeToken.get(Boolean.class))
5053
.defaultValue(false).notifyClient().build();
5154

55+
/**
56+
* Whether the player gets a hit delay for a missed hit while
57+
* targeting a block. Applies to all versions 1.8 and above.
58+
*
59+
* <p>Enabling this option may cause compatibility issues with anti-cheats.</p>
60+
*
61+
* @since 1.2.8
62+
*/
63+
public static final SimpleOption<Boolean> DISABLE_BLOCK_MISS_PENALTY = Option.<Boolean>builder()
64+
.comment(
65+
"Set to 'true' to remove the miss penalty when targeting a block on all versions 1.8 and above, otherwise 'false'.",
66+
"Enabling this option may cause compatibility issues with anti-cheats."
67+
)
68+
.node("disable-block-miss-penalty").type(TypeToken.get(Boolean.class))
69+
.defaultValue(false).notifyClient().build();
70+
5271
/**
5372
* Whether the player can dig and use an item at the same time,
5473
* like in 1.7. Applies to all versions 1.8 and above.
@@ -58,13 +77,17 @@ public final class CombatModule extends ApolloModule {
5877
* @since 1.2.8
5978
*/
6079
public static final SimpleOption<Boolean> ALLOW_DIG_AND_USE = Option.<Boolean>builder()
61-
.comment("Set to 'true' to allow digging and using an item at the same time on all versions 1.8 and above, otherwise 'false'. Enabling this option may cause compatibility issues with anti-cheats.")
80+
.comment(
81+
"Set to 'true' to allow digging and using an item at the same time on all versions 1.8 and above, otherwise 'false'.",
82+
"Enabling this option may cause compatibility issues with anti-cheats."
83+
)
6284
.node("allow-dig-and-use").type(TypeToken.get(Boolean.class))
6385
.defaultValue(false).notifyClient().build();
6486

6587
CombatModule() {
6688
this.registerOptions(
6789
CombatModule.DISABLE_MISS_PENALTY,
90+
CombatModule.DISABLE_BLOCK_MISS_PENALTY,
6891
CombatModule.ALLOW_DIG_AND_USE
6992
);
7093
}

api/src/main/java/com/lunarclient/apollo/option/OptionBuilder.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,22 @@ public M comment(@Nullable String comment) {
8686
return (M) this;
8787
}
8888

89+
/**
90+
* Sets the option comment to the provided lines, joined with a newline, and
91+
* returns this builder.
92+
*
93+
* <p>Each provided line is rendered as its own comment line in the
94+
* configuration.</p>
95+
*
96+
* @param lines the comment lines
97+
* @return this builder
98+
* @since 1.2.8
99+
*/
100+
public M comment(@NonNull String... lines) {
101+
this.comment = String.join("\n", lines);
102+
return (M) this;
103+
}
104+
89105
/**
90106
* Sets the option default value to the provided {@code T} value and
91107
* returns this builder.

docs/developers/lightweight/json/packet-util.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ static {
3535
// While using the Apollo plugin this would be equivalent to modifying the config.yml
3636
CONFIG_MODULE_PROPERTIES.put("colored_fire", "persist-colors-on-unload", false);
3737
CONFIG_MODULE_PROPERTIES.put("combat", "disable-miss-penalty", false);
38+
CONFIG_MODULE_PROPERTIES.put("combat", "disable-block-miss-penalty", false);
3839
CONFIG_MODULE_PROPERTIES.put("combat", "allow-dig-and-use", false);
3940
CONFIG_MODULE_PROPERTIES.put("packet_enrichment", "player-attack.send-packet", false);
4041
CONFIG_MODULE_PROPERTIES.put("packet_enrichment", "player-chat-open.send-packet", false);

docs/developers/lightweight/protobuf/packet-util.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ static {
3535
// While using the Apollo plugin this would be equivalent to modifying the config.yml
3636
CONFIG_MODULE_PROPERTIES.put("colored_fire", "persist-colors-on-unload", Value.newBuilder().setBoolValue(false).build());
3737
CONFIG_MODULE_PROPERTIES.put("combat", "disable-miss-penalty", Value.newBuilder().setBoolValue(false).build());
38+
CONFIG_MODULE_PROPERTIES.put("combat", "disable-block-miss-penalty", Value.newBuilder().setBoolValue(false).build());
3839
CONFIG_MODULE_PROPERTIES.put("combat", "allow-dig-and-use", Value.newBuilder().setBoolValue(false).build());
3940
CONFIG_MODULE_PROPERTIES.put("packet_enrichment", "player-attack.send-packet", Value.newBuilder().setBoolValue(false).build());
4041
CONFIG_MODULE_PROPERTIES.put("packet_enrichment", "player-chat-open.send-packet", Value.newBuilder().setBoolValue(false).build());

docs/developers/modules/combat.mdx

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { Callout, Tab, Tabs } from 'nextra-theme-docs'
77
The combat module allows you to modify certain aspects of combat that are usually handled client-sided.
88

99
- Adds the ability to disable the miss penalty, on all versions 1.8 and above.
10+
- Adds the ability to disable the miss penalty when targeting a block, on all versions 1.8 and above.
1011
- Adds the ability to dig and use an item at the same time, like in 1.7, on all versions 1.8 and above.
1112

1213
### Sample Code
@@ -28,6 +29,14 @@ public void setDisableMissPenalty(boolean value) {
2829
}
2930
```
3031

32+
### Toggle Block Miss Penalty
33+
34+
```java
35+
public void setDisableBlockMissPenalty(boolean value) {
36+
this.combatModule.getOptions().set(CombatModule.DISABLE_BLOCK_MISS_PENALTY, value);
37+
}
38+
```
39+
3140
### Toggle Dig and Use
3241

3342
```java
@@ -56,6 +65,18 @@ public void setDisableMissPenalty(boolean value) {
5665
}
5766
```
5867

68+
### Toggle Block Miss Penalty
69+
70+
```java
71+
public void setDisableBlockMissPenalty(boolean value) {
72+
Map<String, Value> properties = new HashMap<>();
73+
properties.put("disable-block-miss-penalty", Value.newBuilder().setBoolValue(value).build());
74+
75+
ConfigurableSettings settings = ProtobufPacketUtil.createModuleMessage("combat", properties);
76+
ProtobufPacketUtil.broadcastPacket(settings);
77+
}
78+
```
79+
5980
### Toggle Dig and Use
6081

6182
```java
@@ -88,6 +109,18 @@ public void setDisableMissPenalty(boolean value) {
88109
}
89110
```
90111

112+
### Toggle Block Miss Penalty
113+
114+
```java
115+
public void setDisableBlockMissPenalty(boolean value) {
116+
Map<String, Object> properties = new HashMap<>();
117+
properties.put("disable-block-miss-penalty", value);
118+
119+
JsonObject message = JsonUtil.createEnableModuleObjectWithType("combat", properties);
120+
JsonPacketUtil.broadcastPacket(message);
121+
}
122+
```
123+
91124
### Toggle Dig and Use
92125

93126
```java
@@ -111,6 +144,11 @@ public void setAllowDigAndUse(boolean value) {
111144
- Values
112145
- Type: `Boolean`
113146
- Default: `false`
147+
- __`DISABLE_BLOCK_MISS_PENALTY`__
148+
- Whether the player gets a hit delay for a missed hit while targeting a block. Applies to all versions 1.8 and above. Enabling this option may cause compatibility issues with anti-cheats.
149+
- Values
150+
- Type: `Boolean`
151+
- Default: `false`
114152
- __`ALLOW_DIG_AND_USE`__
115153
- Whether the player can dig and use an item at the same time, like in 1.7. Applies to all versions 1.8 and above. Enabling this option may cause compatibility issues with anti-cheats.
116154
- Values

example/bukkit/json/src/main/java/com/lunarclient/apollo/example/json/util/JsonPacketUtil.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ public final class JsonPacketUtil {
5353
// While using the Apollo plugin this would be equivalent to modifying the config.yml
5454
CONFIG_MODULE_PROPERTIES.put("colored_fire", "persist-colors-on-unload", false);
5555
CONFIG_MODULE_PROPERTIES.put("combat", "disable-miss-penalty", false);
56+
CONFIG_MODULE_PROPERTIES.put("combat", "disable-block-miss-penalty", false);
5657
CONFIG_MODULE_PROPERTIES.put("combat", "allow-dig-and-use", false);
5758
CONFIG_MODULE_PROPERTIES.put("packet_enrichment", "player-attack.send-packet", false);
5859
CONFIG_MODULE_PROPERTIES.put("packet_enrichment", "player-chat-open.send-packet", false);

example/bukkit/proto/src/main/java/com/lunarclient/apollo/example/proto/util/ProtobufPacketUtil.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ public final class ProtobufPacketUtil {
5454
// While using the Apollo plugin this would be equivalent to modifying the config.yml
5555
CONFIG_MODULE_PROPERTIES.put("colored_fire", "persist-colors-on-unload", Value.newBuilder().setBoolValue(false).build());
5656
CONFIG_MODULE_PROPERTIES.put("combat", "disable-miss-penalty", Value.newBuilder().setBoolValue(false).build());
57+
CONFIG_MODULE_PROPERTIES.put("combat", "disable-block-miss-penalty", Value.newBuilder().setBoolValue(false).build());
5758
CONFIG_MODULE_PROPERTIES.put("combat", "allow-dig-and-use", Value.newBuilder().setBoolValue(false).build());
5859
CONFIG_MODULE_PROPERTIES.put("packet_enrichment", "player-attack.send-packet", Value.newBuilder().setBoolValue(false).build());
5960
CONFIG_MODULE_PROPERTIES.put("packet_enrichment", "player-chat-open.send-packet", Value.newBuilder().setBoolValue(false).build());

0 commit comments

Comments
 (0)