From 4309c700d2c9ccca17b6be0eb75bcccfa2128d39 Mon Sep 17 00:00:00 2001 From: Paula Date: Fri, 2 Oct 2026 11:33:32 -0300 Subject: [PATCH] Remove useless effects for now --- docs/modding/entities/players.md | 6 ++---- server/game/entity/effects.ts | 28 ++-------------------------- server/game/entity/entity.ts | 1 - server/game/entity/living_entity.ts | 17 ++--------------- tests/entity_test.ts | 8 +------- 5 files changed, 7 insertions(+), 53 deletions(-) diff --git a/docs/modding/entities/players.md b/docs/modding/entities/players.md index 2b62367..7197f7c 100644 --- a/docs/modding/entities/players.md +++ b/docs/modding/entities/players.md @@ -103,10 +103,8 @@ sends players their `attack_speed` whenever it changes so the bar matches. ## Status Effects -Players have Minecraft's status effects: `bworld:speed`, `bworld:slowness`, `bworld:strength`, `bworld:weakness`, -`bworld:jump_boost`, `bworld:health_boost`, `bworld:regeneration`, `bworld:poison`, `bworld:wither`, -`bworld:instant_health`, `bworld:instant_damage`, `bworld:resistance`, `bworld:fire_resistance`, -`bworld:water_breathing`, `bworld:slow_falling` and `bworld:glowing`. +Players have some of Minecraft's status effects: `bworld:speed`, `bworld:slowness`, `bworld:regeneration`, +`bworld:poison`, `bworld:instant_health`, `bworld:resistance` and `bworld:water_breathing`. ```ts player.add_effect("bworld:regeneration", 100, { amplifier: 1 }); // regeneration II for 5 seconds diff --git a/server/game/entity/effects.ts b/server/game/entity/effects.ts index f113133..9c9c8ff 100644 --- a/server/game/entity/effects.ts +++ b/server/game/entity/effects.ts @@ -21,7 +21,7 @@ export interface EffectType { on_removed?(entity: LivingEntity, amplifier: number): void; } -// every n ticks, n halving with each level: minecraft's regeneration, poison and wither +// every n ticks, n halving with each level: minecraft's regeneration and poison const every = (ticks: number) => (duration: number, amplifier: number) => { const interval = ticks >> amplifier; return interval > 0 ? duration % interval === 0 : true; @@ -38,19 +38,6 @@ export const EFFECTS = { slowness: effect("slowness", false, { modifiers: [{ attribute: ATTRIBUTES.movement_speed, amount: -0.15, operation: "add_multiplied_total" }], }), - strength: effect("strength", true, { - modifiers: [{ attribute: ATTRIBUTES.attack_damage, amount: 3, operation: "add_value" }], - }), - weakness: effect("weakness", false, { - modifiers: [{ attribute: ATTRIBUTES.attack_damage, amount: -4, operation: "add_value" }], - }), - jump_boost: effect("jump_boost", true, { - modifiers: [{ attribute: ATTRIBUTES.safe_fall_distance, amount: 1, operation: "add_value" }], - }), - health_boost: effect("health_boost", true, { - modifiers: [{ attribute: ATTRIBUTES.max_health, amount: 4, operation: "add_value" }], - on_removed: (entity) => entity.health = Math.min(entity.health, entity.max_health), - }), regeneration: effect("regeneration", true, { should_tick: every(50), on_tick: (entity) => { @@ -64,24 +51,13 @@ export const EFFECTS = { if (entity.health > 1) entity.hurt(1, DAMAGE.magic); }, }), - wither: effect("wither", false, { - should_tick: every(40), - on_tick: (entity) => void entity.hurt(1, DAMAGE.wither), - }), instant_health: effect("instant_health", true, { instant: true, apply_instant: (entity, amplifier) => entity.heal(Math.max(4 << amplifier, 0)), }), - instant_damage: effect("instant_damage", false, { - instant: true, - apply_instant: (entity, amplifier) => void entity.hurt(Math.max(6 << amplifier, 0), DAMAGE.magic), - }), - // these do their thing where it happens: LivingEntity's damage, air and travel, and synced data + // these do their thing where it happens: LivingEntity's damage and air resistance: effect("resistance", true), - fire_resistance: effect("fire_resistance", true), water_breathing: effect("water_breathing", true), - slow_falling: effect("slow_falling", true), - glowing: effect("glowing", false), } satisfies Record; const registry = new Map(Object.values(EFFECTS).map((type) => [type.id, type])); diff --git a/server/game/entity/entity.ts b/server/game/entity/entity.ts index 5a26275..1af0f76 100644 --- a/server/game/entity/entity.ts +++ b/server/game/entity/entity.ts @@ -50,7 +50,6 @@ export const DAMAGE = { on_fire: { cause: "on_fire", fire: true, type: "arcane" }, void: { cause: "void", bypasses_invulnerability: true, type: "absolute" }, magic: { cause: "magic", type: "arcane" }, - wither: { cause: "wither", type: "arcane" }, } satisfies Record; // what entities can see and do in the world, the entity manager is one diff --git a/server/game/entity/living_entity.ts b/server/game/entity/living_entity.ts index af7d28b..3eace3a 100644 --- a/server/game/entity/living_entity.ts +++ b/server/game/entity/living_entity.ts @@ -28,8 +28,6 @@ const SWIM_UP = 0.04; // a jump can't start more often than this while jump is held const JUMP_DELAY = 10; const KNOCKBACK = 0.4; -// gravity while slow falling, blocks per tick per tick -const SLOW_FALL_GRAVITY = 0.01; export interface SavedLivingEntity extends SavedEntity { health?: number; @@ -206,20 +204,14 @@ export abstract class LivingEntity extends Entity { server_ai_step() {} jump_from_ground() { - const boost = this.get_effect(EFFECTS.jump_boost); - const power = this.attribute(ATTRIBUTES.jump_strength) + (boost ? 0.1 * (boost.amplifier + 1) : 0); - this.vy = Math.max(power * TICKS_PER_SECOND, this.vy); + this.vy = Math.max(this.attribute(ATTRIBUTES.jump_strength) * TICKS_PER_SECOND, this.vy); } // minecraft's LivingEntity.travel: speeds up towards where forward and strafe point, grip depending on whether it's // on the ground, in the air or in water, then moves travel() { this.step_height = this.attribute(ATTRIBUTES.step_height); - let gravity = this.attribute(ATTRIBUTES.gravity); - if (this.vy <= 0 && this.has_effect(EFFECTS.slow_falling)) { - gravity = Math.min(gravity, SLOW_FALL_GRAVITY); - this.fall_distance = 0; - } + const gravity = this.attribute(ATTRIBUTES.gravity); if (this.in_water) { this.gravity = -gravity / 16 * TICKS_PER_SECOND ** 2; @@ -272,10 +264,6 @@ export abstract class LivingEntity extends Entity { // health - override is_invulnerable_to(source: DamageSource) { - return super.is_invulnerable_to(source) || (source.fire === true && this.has_effect(EFFECTS.fire_resistance)); - } - // like minecraft's LivingEntity.hurt. returns whether it was hurt override hurt(amount: number, source: DamageSource): boolean { if (this.is_invulnerable_to(source) || this.dead || !(amount > 0)) { @@ -499,7 +487,6 @@ export abstract class LivingEntity extends Entity { override synced_data(): EntityData { const data = super.synced_data(); - if (this.has_effect(EFFECTS.glowing)) data.glowing = true; if (this.equipment.size) { data.equipment = Object.fromEntries( [...this.equipment].map(([slot, stack]) => [slot, stack.to_synced_data()]), diff --git a/tests/entity_test.ts b/tests/entity_test.ts index 897cc50..7b16ec2 100644 --- a/tests/entity_test.ts +++ b/tests/entity_test.ts @@ -88,7 +88,7 @@ Deno.test("a stronger, shorter effect hides a weaker one, which takes over when assertEquals(mob.attribute(ATTRIBUTES.movement_speed), base_speed); }); -Deno.test("effects: regeneration heals, poison never kills, health boost goes away with its health", async () => { +Deno.test("effects: regeneration heals and poison never kills", async () => { const { spawn } = await floor_game(); const mob = spawn(0.5, 100, 0.5); @@ -104,12 +104,6 @@ Deno.test("effects: regeneration heals, poison never kills, health boost goes aw mob.add_effect(new EffectInstance(EFFECTS.instant_health, 1)); assertEquals(mob.health, 9); - - mob.add_effect(new EffectInstance(EFFECTS.health_boost, 20)); - assertEquals(mob.max_health, 14); - mob.health = 14; - mob.remove_effect(EFFECTS.health_boost); - assertEquals([mob.max_health, mob.health], [10, 10]); }); Deno.test("hurting: a weaker hit right after does nothing, a harder one only the difference", async () => {