Archive incari-client (client, 26.3, clean)

This commit is contained in:
2026-11-28 00:54:38 -06:00
parent 7a6174687f
commit 12838e838c
2383 changed files with 280266 additions and 0 deletions
@@ -0,0 +1,79 @@
package incari.features.hitboxes;
import incari.framework.Category;
import incari.framework.Module;
import incari.framework.game.Hitboxes;
import incari.framework.setting.BooleanSetting;
import incari.framework.setting.ChoiceSetting;
import incari.framework.setting.ColorSetting;
import incari.framework.setting.FloatSetting;
import incari.framework.setting.IntSetting;
import incari.framework.setting.Setting;
/**
* Hitboxes: the box each entity is hit by, in the player's color and width, the one under the
* crosshair in another if they like; with the eye-height line and look arrow F3+B shows. The style
* is handed to the game once per change, not per tick: the client draws it every frame.
*/
public final class HitboxesModule extends Module {
final ColorSetting color = settings().color("color", "Color", 0xFFFFFF).describedAs("The boxes' color.");
final IntSetting opacity = settings()
.integer("opacity", "Opacity", 10, 100, 100)
.formattedAs(value -> value + "%")
.describedAs("How solid the boxes are.");
final FloatSetting width =
settings().decimal("width", "Width", 1, 6, 0.5F, 2).describedAs("How thick the lines are, in pixels.");
final BooleanSetting targetColored = settings()
.bool("target-colored", "Target color", true)
.describedAs("Colors the box your crosshair is on differently.");
final ColorSetting targetColor = settings()
.color("target-color", "Target's color", 0xFF5555)
.describedAs("The color of the box your crosshair is on.")
.visibleWhen(targetColored::get);
final ChoiceSetting<Hitboxes.Show> show = settings()
.choice("show", "Show", Hitboxes.Show.values(), Hitboxes.Show.LIVING, Hitboxes.Show::label)
.describedAs("Which entities get a box.");
final BooleanSetting eyeLine =
settings().bool("eye-line", "Eye height", true).describedAs("A red line where each one's eyes are.");
final BooleanSetting lookLine =
settings().bool("look-line", "Look direction", true).describedAs("A blue arrow the way each one looks.");
final BooleanSetting own =
settings().bool("own", "Your own", false).describedAs("Your own box too, in third person.");
/** Hitboxes, off until the player turns it on. */
public HitboxesModule() {
super("hitboxes", "Hitboxes", "Shows the box each player or mob is hit by.", Category.COMBAT);
for (Setting<?> setting : settings()) {
setting.onChange(this::changed);
}
}
private void changed() {
if (isEnabled()) {
system().game().overrideHitboxes(style());
}
}
@Override
protected void onEnable() {
system().game().overrideHitboxes(style());
}
@Override
protected void onDisable() {
system().game().overrideHitboxes(null);
}
/** What the settings say, as the game takes it. */
Hitboxes style() {
int argb = withOpacity(color.get(), opacity.get());
int target = targetColored.get() ? withOpacity(targetColor.get(), opacity.get()) : argb;
return new Hitboxes(argb, target, width.get(), show.get(), eyeLine.get(), lookLine.get(), own.get());
}
/** {@code rgb} at {@code percent} opacity. */
static int withOpacity(int rgb, int percent) {
return Math.round(percent * 255 / 100.0F) << 24 | (rgb & 0xFFFFFF);
}
}
@@ -0,0 +1,5 @@
/** Hitboxes: the box each entity is hit by, drawn in the world in the player's color and width. */
@NullMarked
package incari.features.hitboxes;
import org.jspecify.annotations.NullMarked;
@@ -0,0 +1,20 @@
package incari.features.hitboxes;
import static com.tngtech.archunit.lang.syntax.ArchRuleDefinition.classes;
import com.tngtech.archunit.core.importer.ImportOption;
import com.tngtech.archunit.junit.AnalyzeClasses;
import com.tngtech.archunit.junit.ArchTest;
import com.tngtech.archunit.lang.ArchRule;
/** A feature sees the module framework and the JDK's basics: no game, platform or other feature. */
@AnalyzeClasses(packages = "incari.features.hitboxes", importOptions = ImportOption.DoNotIncludeTests.class)
class BoundaryTest {
@ArchTest
static final ArchRule onlyTheFramework = classes()
.should()
.onlyDependOnClassesThat()
.resideInAnyPackage(
"java.lang..", "java.util..", "org.jspecify..", "incari.framework..", "incari.features.hitboxes..");
}
@@ -0,0 +1,49 @@
package incari.features.hitboxes;
import static org.assertj.core.api.Assertions.assertThat;
import incari.framework.game.Hitboxes;
import incari.framework.testing.TestGame;
import org.junit.jupiter.api.Test;
class HitboxesModuleTest {
private final HitboxesModule module = new HitboxesModule();
private final TestGame game = new TestGame(module);
@Test
void drawsTheBoxesWhileOnAndNoneAfter() {
assertThat(game.hitboxes).isNull();
module.setEnabled(true);
assertThat(game.hitboxes)
.isEqualTo(new Hitboxes(0xFFFFFFFF, 0xFFFF5555, 2, Hitboxes.Show.LIVING, true, true, false));
module.setEnabled(false);
assertThat(game.hitboxes).isNull();
}
@Test
void aChangedSettingReachesTheGameAtOnceButOnlyWhileOn() {
module.setEnabled(true);
module.color.set(0x00FF00);
module.opacity.set(50);
module.show.set(Hitboxes.Show.PLAYERS);
assertThat(game.hitboxes).isNotNull();
assertThat(game.hitboxes.color()).isEqualTo(0x8000FF00);
assertThat(game.hitboxes.show()).isEqualTo(Hitboxes.Show.PLAYERS);
module.targetColored.set(false);
assertThat(game.hitboxes.targetColor()).isEqualTo(game.hitboxes.color());
module.setEnabled(false);
module.width.set(4);
assertThat(game.hitboxes).isNull();
}
@Test
void opacityScalesTheAlpha() {
assertThat(HitboxesModule.withOpacity(0xFF123456, 100)).isEqualTo(0xFF123456);
assertThat(HitboxesModule.withOpacity(0x123456, 10) >>> 24).isEqualTo(26);
}
}