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,31 @@
# fastcrystal: Fast Crystal
An end crystal you hit, and a charged respawn anchor you set off, are gone on your screen at once,
not a ping later, so the next one can go in its place sooner. Prediction only
([ADR 0073](../../docs/adr/0073-combat-prediction-not-automation.md)): your click sends the one
packet it always did, nothing is clicked for you, and one the server keeps comes back. Off by
default.
| Setting | Kind | Default |
| --- | --- | --- |
| Crystals | On/off | On |
| Anchors | On/off: anchors outside the Nether (where they explode) | On |
The module holds `Game.predictBreaks`; the client's `ModuleBreaks` acts on it:
| Hook | What |
| --- | --- |
| `MultiPlayerGameMode.attack`, after the attack packet | Takes the crystal away, unless the hit does no damage or the crystal is invulnerable |
| `ClientPacketListener.handleRemoveEntities` | The server removed it: nothing to put back |
| `RespawnAnchorBlock.useWithoutItem`, client side | Sets the anchor to air in the game's block prediction; the server's acknowledgement restores it if it stays |
A crystal the server hasn't removed after twice the ping plus 0.3 s (0.6 to 3 s) comes back.
The Rust build's mod ([`rust/mods/fastcrystal`](../../rust/mods/fastcrystal/)) does the same on
Horizon's prediction hooks: `object_attacked` takes the crystal off (`native_take_crystal`), `tick`
puts back one the server kept (`native_return_crystal`), and `block_used` shows the anchor as air
under the use's sequence (`native_predict_air`).
```sh
./gradlew :features:fastcrystal:check
```
@@ -0,0 +1,16 @@
plugins {
`java-library`
}
// Fast Crystal: crystals and anchors gone on this client as soon as the player breaks them.
// A feature module: it sees the module framework and nothing else.
dependencies {
api(project(":framework"))
testImplementation(testFixtures(project(":framework")))
testImplementation(platform(libs.junit.bom))
testImplementation(libs.junit.jupiter)
testImplementation(libs.assertj)
testImplementation(libs.archunit)
testRuntimeOnly(libs.junit.launcher)
}
@@ -0,0 +1,50 @@
package incari.features.fastcrystal;
import incari.framework.Category;
import incari.framework.Module;
import incari.framework.setting.BooleanSetting;
/**
* Fast Crystal: an end crystal the player hits, and a charged respawn anchor they set off, go from
* this client at once instead of a round trip later, so the next one can go in its place without
* waiting out the ping. Prediction only (as the game predicts a broken block): the player's own
* click still sends the one packet it always did, nothing is clicked for them, and one the server
* keeps comes back. The choice is handed to the game once per change; the client checks it on a
* hit or a use.
*/
public final class FastCrystal extends Module {
final BooleanSetting crystals = settings()
.bool("crystals", "Crystals", true)
.describedAs("A crystal you hit is gone at once, so the next can go in its place.");
final BooleanSetting anchors = settings()
.bool("anchors", "Anchors", true)
.describedAs("A charged anchor you set off is gone at once, outside the Nether.");
/** Fast Crystal, off until the player turns it on. */
public FastCrystal() {
super(
"fastcrystal",
"Fast Crystal",
"Crystals and anchors go as you break them, not a ping later.",
Category.COMBAT);
crystals.onChange(this::changed);
anchors.onChange(this::changed);
}
private void changed() {
if (isEnabled()) {
system().game().predictBreaks(crystals.get(), anchors.get());
}
}
@Override
protected void onEnable() {
system().game().predictBreaks(crystals.get(), anchors.get());
}
@Override
protected void onDisable() {
system().game().predictBreaks(false, false);
}
}
@@ -0,0 +1,5 @@
/** Fast Crystal: end crystals and respawn anchors gone on this client as soon as the player breaks them. */
@NullMarked
package incari.features.fastcrystal;
import org.jspecify.annotations.NullMarked;
@@ -0,0 +1,24 @@
package incari.features.fastcrystal;
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.fastcrystal", 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.fastcrystal..");
}
@@ -0,0 +1,51 @@
package incari.features.fastcrystal;
import static org.assertj.core.api.Assertions.assertThat;
import incari.framework.testing.TestGame;
import org.junit.jupiter.api.Test;
class FastCrystalTest {
private final FastCrystal module = new FastCrystal();
private final TestGame game = new TestGame(module);
@Test
void offUntilTurnedOnAndOffAgainAfter() {
assertThat(module.isEnabled()).isFalse();
assertThat(game.predictCrystals).isFalse();
assertThat(game.predictAnchors).isFalse();
module.setEnabled(true);
assertThat(game.predictCrystals).isTrue();
assertThat(game.predictAnchors).isTrue();
module.setEnabled(false);
assertThat(game.predictCrystals).isFalse();
assertThat(game.predictAnchors).isFalse();
}
@Test
void eachKindCanBeLeftToTheGame() {
module.setEnabled(true);
module.anchors.set(false);
assertThat(game.predictCrystals).isTrue();
assertThat(game.predictAnchors).isFalse();
module.crystals.set(false);
module.anchors.set(true);
assertThat(game.predictCrystals).isFalse();
assertThat(game.predictAnchors).isTrue();
}
@Test
void aSettingChangedWhileOffWaitsForTheModule() {
module.anchors.set(false);
assertThat(game.predictAnchors).isFalse();
assertThat(game.predictCrystals).isFalse();
module.setEnabled(true);
assertThat(game.predictCrystals).isTrue();
assertThat(game.predictAnchors).isFalse();
}
}