Curios and artifacts !

This commit is contained in:
2026-09-30 15:22:32 -03:00
parent 342b45d593
commit 3af5f6e54b
45 changed files with 729 additions and 43 deletions
+10
View File
@@ -66,6 +66,8 @@ export class ServerPlayer extends LivingEntity {
knockback_ticks: number | undefined;
// when the last move came, to tell walking from sprinting
last_move_tick = 0;
// ticks since they last attacked or changed their held item, like minecraft's attackStrengthTicker
attack_strength_ticker = 0;
crafting = new Container(CRAFTING_SIZE);
cursor: Cursor = { item: undefined };
selected_slot = 0;
@@ -94,6 +96,7 @@ export class ServerPlayer extends LivingEntity {
...super.default_attributes(),
// a fist does half a heart, like minecraft
[ATTRIBUTES.attack_damage, 1],
[ATTRIBUTES.attack_speed],
[ATTRIBUTES.physical_shielding],
[ATTRIBUTES.arcane_shielding],
];
@@ -113,6 +116,7 @@ export class ServerPlayer extends LivingEntity {
// knocked back it moves them like a mob that isn't walking anywhere, landing hands them back to their client
override tick() {
this.base_tick();
this.attack_strength_ticker += 1;
if (!this.dead) {
this.tick_effects();
}
@@ -155,6 +159,12 @@ export class ServerPlayer extends LivingEntity {
this.level.on_death(this, source);
}
// like minecraft's getAttackStrengthScale: 0 right after attacking, filling up to 1 over 20 / attack_speed ticks
attack_strength(): number {
const delay = 20 / this.attribute(ATTRIBUTES.attack_speed);
return Math.min(1, Math.max(0, (this.attack_strength_ticker + 0.5) / delay));
}
get held_item(): ItemStack | undefined {
return this.inventory.get_item(this.selected_slot);
}