Skip to content

Latest commit

 

History

History
156 lines (114 loc) · 4.57 KB

File metadata and controls

156 lines (114 loc) · 4.57 KB

import { Callout, Tab, Tabs } from 'nextra-theme-docs'

Combat Module

Overview

The combat module allows you to modify certain aspects of combat that are usually handled client-sided.

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

Sample Code

Explore each integration by cycling through each tab, to find the best fit for your requirements and needs.

<Tabs items={['Apollo API', 'apollo-protos library', 'Manual JSON Object Construction']}>

**Apollo API examples.** See [General](/apollo/developers/general) for common patterns and helpers.

Toggle Miss Penalty

public void setDisableMissPenalty(boolean value) {
    this.combatModule.getOptions().set(CombatModule.DISABLE_MISS_PENALTY, value);
}

Toggle Block Miss Penalty

public void setDisableBlockMissPenalty(boolean value) {
    this.combatModule.getOptions().set(CombatModule.DISABLE_BLOCK_MISS_PENALTY, value);
}

Toggle Dig and Use

public void setAllowDigAndUse(boolean value) {
    this.combatModule.getOptions().set(CombatModule.ALLOW_DIG_AND_USE, value);
}
**Lightweight Protobuf examples.** See [Lightweight Protobuf](/apollo/developers/lightweight/protobuf) for setup.

Toggle Miss Penalty

public void setDisableMissPenalty(boolean value) {
    Map<String, Value> properties = new HashMap<>();
    properties.put("disable-miss-penalty", Value.newBuilder().setBoolValue(value).build());

    ConfigurableSettings settings = ProtobufPacketUtil.createModuleMessage("combat", properties);
    ProtobufPacketUtil.broadcastPacket(settings);
}

Toggle Block Miss Penalty

public void setDisableBlockMissPenalty(boolean value) {
    Map<String, Value> properties = new HashMap<>();
    properties.put("disable-block-miss-penalty", Value.newBuilder().setBoolValue(value).build());

    ConfigurableSettings settings = ProtobufPacketUtil.createModuleMessage("combat", properties);
    ProtobufPacketUtil.broadcastPacket(settings);
}

Toggle Dig and Use

public void setAllowDigAndUse(boolean value) {
    Map<String, Value> properties = new HashMap<>();
    properties.put("allow-dig-and-use", Value.newBuilder().setBoolValue(value).build());

    ConfigurableSettings settings = ProtobufPacketUtil.createModuleMessage("combat", properties);
    ProtobufPacketUtil.broadcastPacket(settings);
}
**Lightweight JSON examples.** See [Lightweight JSON](/apollo/developers/lightweight/json) for setup.

Toggle Miss Penalty

public void setDisableMissPenalty(boolean value) {
    Map<String, Object> properties = new HashMap<>();
    properties.put("disable-miss-penalty", value);

    JsonObject message = JsonUtil.createEnableModuleObjectWithType("combat", properties);
    JsonPacketUtil.broadcastPacket(message);
}

Toggle Block Miss Penalty

public void setDisableBlockMissPenalty(boolean value) {
    Map<String, Object> properties = new HashMap<>();
    properties.put("disable-block-miss-penalty", value);

    JsonObject message = JsonUtil.createEnableModuleObjectWithType("combat", properties);
    JsonPacketUtil.broadcastPacket(message);
}

Toggle Dig and Use

public void setAllowDigAndUse(boolean value) {
    Map<String, Object> properties = new HashMap<>();
    properties.put("allow-dig-and-use", value);

    JsonObject message = JsonUtil.createEnableModuleObjectWithType("combat", properties);
    JsonPacketUtil.broadcastPacket(message);
}

Available options

  • DISABLE_MISS_PENALTY
    • Whether the player gets a hit delay for a missed hit. Enabling this option may cause compatibility issues with anti-cheats.
    • Values
      • Type: Boolean
      • Default: false
  • DISABLE_BLOCK_MISS_PENALTY
    • 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.
    • Values
      • Type: Boolean
      • Default: false
  • ALLOW_DIG_AND_USE
    • 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.
    • Values
      • Type: Boolean
      • Default: false