Skip to content

Botings/counter-detection

 
 

Repository files navigation

Counter Detector (1.8.9 Forge)

Core logic for a Counter Detector with a cannon whitelist, TNT threat vector detection, explosion box rendering, and a Cannoning config UI.

How to use

  1. Install

    • Put counterdetector-1.0.0.jar from build/libs/ into your Minecraft mods folder (1.8.9 Forge).
  2. Cannon whitelist

    • In-game, stand at one corner of your cannon area and run /cannon pos1.
    • Stand at the opposite corner and run /cannon pos2.
    • TNT (and other entities) inside this box are treated as “your” cannon and ignored by the threat logic.
  3. Config screen

    • Press C (or your keybind) to open the Cannoning config.
    • Explosion Boxes – toggle cyan boxes at enemy explosion positions (visible through walls); size from Box Size slider.
    • Counter Detector – toggle threat-direction logic; when active the card has a green border.
    • Box Size – slider linked to renderBox in real time.
  4. In play

    • TNT inside the whitelist: ignored.
    • Enemy TNT (outside): direction West/East (by tnt.posX vs player.posX) or North/South; cyan explosion boxes (S2APacketExplosion precision when available).
  5. Detection range (server limit)

    • The mod can only “see” TNT that the server has sent to your client. In vanilla this is the entity tracking range: about 48 blocks horizontal (X/Z) and about 96–100 blocks vertical (Y). Beyond that, TNT is not in loadedEntityList, so we cannot detect it. This cannot be fixed by the mod alone. To detect from further:
    • Sound packets do not extend range: vanilla only sends TNT-primed sound within 16 blocks, and explosion within 64 (volume-based).
    • To detect from further: Singleplayer – increase simulation/view distance. Multiplayer – ask the server owner to increase entity tracking range, if supported.

Features

  1. Coordinate Whitelist (/cannon – client command only)

    • Registered with ClientCommandHandler; never sent to the server.
    • myCannonMin and myCannonMax store the box; /cannon pos1 and /cannon pos2 set them at your feet.
    • isEnemyTNT(EntityTNTPrimed) returns true if the TNT is outside the box (enemy); isInsideCannon(Entity) for the box test.
  2. Threat vector (TNT)

    • In client tick, TNT outside the whitelist is classified by motion:
    • West/East: |motionX| >= |motionZ|, then West if tnt.posX < player.posX, else East.
    • North/South: |motionZ| > |motionX|, then North if tnt.posZ < player.posZ, else South.
  3. Explosion box rendering

    • ExplosionBoxRenderer.renderBox(double x, double y, double z, float size) draws a box at the given position.
    • Uses GlStateManager.disableDepth() so the box is visible through walls.
    • Explosion positions are recorded from TNT fuse (fallback) or from the explosion packet (see below).
  4. Exact blast coordinates (S27PacketExplosion)

    • For precise positions, hook the explosion packet (e.g. with Mixin) and call:
      ExplosionPacketCapture.onExplosionPacket(x, y, z)
    • In 1.8.9 the packet is S27PacketExplosion; read the double x, y, z (or a, b, c in obf).
  5. Cannoning UI

    • Press C (configurable) to open the Cannoning config.
    • Explosion Boxes and Counter Detector are toggles (square cards).
    • Box Size slider updates the size passed to renderBox(...).

Build

  • Setup: gradlew setupDecompWorkspace
  • Run client: gradlew runClient
  • Build JAR: gradlew build (output in build/libs/)

OneConfig / Crystal Grid

The in-mod Cannoning screen is standalone. To integrate with OneConfig’s Cannoning category and use Explosion Boxes / Counter Detector as icon-cards with a Box Size slider, add the OneConfig dependency and register a config that:

  • Uses the Cannoning category (or equivalent).
  • Exposes Explosion Boxes and Counter Detector as cards/pages.
  • Exposes a float slider that calls CounterDetectorConfig.setBoxSize(value).

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • Java 100.0%