Archive incari-client (client, 26.3, clean)
This commit is contained in:
+50
@@ -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);
|
||||
}
|
||||
}
|
||||
+5
@@ -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;
|
||||
+24
@@ -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..");
|
||||
}
|
||||
+51
@@ -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();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user