Archive incari-client (client, 26.3, clean)
This commit is contained in:
+42
@@ -0,0 +1,42 @@
|
||||
package incari.features.shortitems;
|
||||
|
||||
import incari.framework.Category;
|
||||
import incari.framework.Module;
|
||||
import incari.framework.event.Events;
|
||||
import incari.framework.event.HeldItem;
|
||||
import incari.framework.setting.BooleanSetting;
|
||||
import incari.framework.setting.IntSetting;
|
||||
|
||||
/**
|
||||
* Short Items: whatever is held in first person, in either hand, is drawn smaller, toward the
|
||||
* hand, as 1.8 PvP packs drew swords, so it hides less of the view. Only the drawing changes:
|
||||
* reach and hits are the game's.
|
||||
*
|
||||
* <p>Was Short Swords, for swords only: the ids stay {@code shortswords}'s, so a profile keeps it.
|
||||
*/
|
||||
public final class ShortItems extends Module {
|
||||
|
||||
final IntSetting size = settings()
|
||||
.integer("size", "Size", 40, 100, 70)
|
||||
.formattedAs(percent -> percent + "%")
|
||||
.describedAs("How big held items are drawn, against the game's size.");
|
||||
final BooleanSetting whileUsing = settings()
|
||||
.bool("while-blocking", "Also while in use", true)
|
||||
.describedAs("Off: an item in use (blocking, eating, drawing a bow) is drawn at the game's size.");
|
||||
|
||||
/** Short Items, off until the player turns it on. */
|
||||
public ShortItems() {
|
||||
super(
|
||||
"shortswords",
|
||||
"Short Items",
|
||||
"Draws the items in your hands smaller, so they hide less.",
|
||||
Category.VISUAL);
|
||||
on(Events.HELD_ITEM, this::onHeldItem);
|
||||
}
|
||||
|
||||
private void onHeldItem(HeldItem item) {
|
||||
if (whileUsing.get() || !item.using()) {
|
||||
item.setScale(size.get() / 100.0F);
|
||||
}
|
||||
}
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
/** Short Items (ADR 0062): held items drawn smaller in first person. */
|
||||
@NullMarked
|
||||
package incari.features.shortitems;
|
||||
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
package incari.features.shortitems;
|
||||
|
||||
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.shortitems", 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.shortitems..");
|
||||
}
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
package incari.features.shortitems;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import incari.framework.testing.TestGame;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
class ShortItemsTest {
|
||||
|
||||
private final ShortItems module = new ShortItems();
|
||||
private final TestGame game = new TestGame(module);
|
||||
|
||||
@Test
|
||||
void shrinksEveryItemInEitherHand() {
|
||||
module.setEnabled(true);
|
||||
assertThat(game.heldSword(true, false).scale()).isEqualTo(0.7F);
|
||||
assertThat(game.heldItem(true, false, false).scale()).isEqualTo(0.7F);
|
||||
assertThat(game.heldItem(false, false, false).scale()).isEqualTo(0.7F);
|
||||
assertThat(game.heldItem(false, true, false).scale()).isEqualTo(0.7F);
|
||||
}
|
||||
|
||||
@Test
|
||||
void followsTheSizeAndCanLeaveAnItemInUseAlone() {
|
||||
module.setEnabled(true);
|
||||
module.size.set(50);
|
||||
assertThat(game.heldItem(false, false, false).scale()).isEqualTo(0.5F);
|
||||
module.whileUsing.set(false);
|
||||
assertThat(game.heldSword(true, true).scale()).isEqualTo(1);
|
||||
assertThat(game.heldItem(true, false, true).scale()).isEqualTo(1);
|
||||
assertThat(game.heldItem(true, false, false).scale()).isEqualTo(0.5F);
|
||||
}
|
||||
|
||||
@Test
|
||||
void keepsShortSwordsIdSoProfilesKeepIt() {
|
||||
assertThat(module.id()).isEqualTo("shortswords");
|
||||
}
|
||||
|
||||
@Test
|
||||
void offLeavesItemsAsTheGameDrawsThem() {
|
||||
assertThat(game.heldSword(true, false).scale()).isEqualTo(1);
|
||||
assertThat(game.heldItem(true, false, false).scale()).isEqualTo(1);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user