Commit Graph

47 Commits

Author SHA1 Message Date
Alexander Medvedev
fdf8ff5fd8 chore: Remove Integer0ToX 2026-04-29 14:57:11 +02:00
SomeYellowGuy
513477d1cf fix(codec): replace codec and map codec structs with Encode and Decode traits and their field versions (#2051)
* removed codecs in favor of the `Encode` and `Decode` traits and their derivatives

* placed more exports in the `pumpkin-codecs` lib

* split primitives into their own folder and added some tests

* added `Either` support and added a simple test for it

* fixed linting for tests
2026-04-21 16:38:25 +02:00
Alexander Medvedev
31a5687937 chore(performance): flat compiled surface rules, no recursion at runtime
Decreased the surface function from taking 18% to 7%
2026-04-20 22:31:32 +02:00
Alexander Medvedev
d048c33870 chore: prepare 1.20.5 2026-04-18 21:01:44 +02:00
Alexander Medvedev
32c5530d6c feat: implement remaining tree types 2026-04-16 22:30:43 +02:00
Alexander Medvedev
e9423dcb9c chore: add encoder fuzzing
ofc nothing more :wink
2026-04-16 20:32:19 +02:00
RB007
ead5cae611 feat: (small) end island feature (#2023)
* feat: end island feature

* chore: remove duplicate chorus_plant entry + other updates
2026-04-14 20:11:27 +02:00
RB007
1d70ec5fa7 feat: chorus blocks and feature (#2021) 2026-04-14 09:04:46 +02:00
RB007
b8c7067d21 feat: iceburg feature (#1890)
Signed-off-by: RB007 <36972202+RoosterBooster007@users.noreply.github.com>
2026-04-10 11:16:21 +02:00
RB007
57e9c57244 feat: ice spike feature (#1887) 2026-04-10 09:14:05 +02:00
RB007
39a2677f87 feat: snow and ice feature (#1886)
* feat: snow and ice feature

* fix: update configured_feature.rs

---------

Signed-off-by: Alexander Medvedev <lilalexmed@proton.me>
Co-authored-by: Alexander Medvedev <lilalexmed@proton.me>
2026-04-09 22:22:08 +02:00
Alexander Medvedev
1d7c72ba5b fix: water swimming bug 2026-04-09 22:18:21 +02:00
RB007
7c3b41ba32 feat: forest rock feature (#1885)
* feat: forest rock feature

* chore: migrate feature to use BlockState
2026-04-09 20:32:12 +02:00
RB007
eb57afe52c feat: basalt pillar feature (#1884) 2026-04-09 08:18:55 +02:00
BitForge
4916c05997 fix(entity): consolidate hurt sound parity for slime and shared dispatch families (#1935)
* fix(entity): derive hurt sound parity from generated mapping

Keep slime hurt sounds in runtime because they depend on entity size.\n\nMove enderman and undead-family hurt sound mappings into generated data so living.rs dispatches through a shared lookup instead of owning a hardcoded table.

* refactor(entity): derive hurt sound lookup from entities data

The Extractor companion now emits hurt_sound through entities.json. Keep Pumpkin's hurt_sound_for_entity_type helper narrow and generated while moving its source of truth to entity data.

Slime remains a runtime special case because its hurt sound depends on size rather than static entity metadata.

* refactor(entity): fold hurt sound helper into entity codegen

Move hurt-sound helper generation into the existing entity codegen path.

Remove the standalone helper builder and generated file now that hurt_sound is sourced from entities.json. Runtime dispatch stays unchanged and slime remains a runtime size-based exception.

* refactor(entity): inline hurt sound into EntityType

Remove the standalone entity_hurt_sound feature and helper path.

Hurt sounds now live directly on generated EntityType values, while runtime behavior stays the same and slime remains the size-based runtime exception.
2026-04-08 19:33:45 +02:00
Alexander Medvedev
878116ceff fix: https://github.com/Pumpkin-MC/Pumpkin/issues/1976 2026-04-08 11:01:29 +02:00
Alexander Medvedev
1e196cfe34 fix: arrows not damage non living entities 2026-04-07 14:04:41 +02:00
RB007
7760292c2e feat: basalt columns feature (#1882)
* feat: basalt cols 🪨

* chore: revert block.rs
2026-04-07 11:35:32 +02:00
Alexander Medvedev
eb8931f5f3 fix: < 26 item ids 2026-04-06 17:52:31 +02:00
Alexander Medvedev
82ce8e9633 chore: chunk gen just got a bit faster 2026-04-06 13:07:53 +02:00
Alexander Medvedev
0656aec158 fix: some bugs 2026-04-03 18:35:34 +02:00
Alexander Medvedev
4848ca52cc chore: finish 26.1 chunk generation port 2026-04-02 17:12:10 +02:00
Alexander Medvedev
ed15c00307 chore: surface rules: parse some block/states directly 2026-04-01 23:21:52 +02:00
RB007
3986682b34 feat: add disk features to worldgen (#1879)
* feat: add disk features to worldgen

* fix: get surface features to compile

---------

Signed-off-by: RB007 <36972202+RoosterBooster007@users.noreply.github.com>
2026-03-31 10:41:03 +02:00
Alexander Medvedev
a111cf3f20 fix: < 26.1 Support 2026-03-31 09:44:08 +02:00
RB007
3c43f9715e fix: end portal crash and island setup (#1945)
* fix: use noise_sampler

* fix: end portal teleportation and generation

* feature: dragon fight start (improved main end island)
2026-03-31 09:21:11 +02:00
Alexander Medvedev
0635b048b5 Port to 26.1 2026-03-30 16:43:15 +02:00
HairlessVillager
974bdd98a6 chore: add license to Cargo.toml files (#1927) 2026-03-28 15:47:15 +01:00
Grooble
c6bf417773 fix: make some gamerules take effect, feat: ItemModel data components (#1849)
* feat: add ItemModel data component

* fix: advance_time gamerule now stops sun moving clientside

* fix(mob spawning): respect gamerules & difficulty

* feat(ItemModel): read from nbt

* feat: add Consumable data component, doesn't support consume effects yet

* feat(DataComponents): add Consumable consume effects & add Equippable

* fix: SoundEvent deserialization

* fix: duplicate import

* fix: rebase issues

* fix: SoundEvent deserialization

* fix: format and spelling
2026-03-24 08:56:49 +01:00
RB007
655e69fc66 feat: vegetation patch features (#1708)
* feat: vegetation features

* refactor: surface_direction helpers

* fix: several issues

* refactor: add with_waterlogged helper to Block/BlockState

* refactor: small changes and added helpful comments
2026-03-20 09:43:28 +01:00
RB007
b1e25f0db9 feat: potion use and brewing (#1670)
* feat: potions and brewing

* fix: splash water puts out fire

* fix: saving

* fix: brew sound

* chore: fixes, formatting, and clippy
2026-03-19 17:40:09 +01:00
RB007
76e62cd739 feat: glowstone feature (#1878) 2026-03-18 08:10:52 +01:00
Illyrius
5dda697c15 docs: docs/pumpkin-codegen (#1826)
* added docs

* some small corrections

* woopsie

* revert back lock changes

Signed-off-by: Illyrius <28700752+illyrius666@users.noreply.github.com>

---------

Signed-off-by: Illyrius <28700752+illyrius666@users.noreply.github.com>
Co-authored-by: Illyrius <FitimQ@live.nl>
2026-03-15 20:48:50 +01:00
Andrei Șugubete
a0ff7f46dc feat: Durability Overhaul (#1848)
* feat: broadcast EntityStatus when equipment breaks

Pumpkin did not play any sound or show break particles when a tool or
piece of armour reached zero durability. Vanilla sends a per-slot
EntityStatus packet (47-52, 65, 68) that every nearby client uses to
play the break sound and spawn break particles textured with the item
that just broke.

Changes
-------

player.rs – new damage_item_in_slot(slot, amount) method:
- Generalises the old damage_held_item to cover all EquipmentSlots:
  MainHand, OffHand, Head, Chest, Legs, Feet.
- Resolves the correct PlayerInventory slot index per slot (36-39 for
  armour, 40 for off-hand) consistent with build_equipment_slots().
- Sends the EntityStatus break packet BEFORE clearing the slot so
  clients can use the item texture for break particles.
- Bypasses sync_hand_slot (which only broadcast for hand slots) and
  instead calls enqueue_slot_set_packet + send_equipment_changes
  directly, ensuring armour equipment changes also propagate.
- damage_held_item is kept as a thin convenience wrapper.

apply_mending_from_xp – DRY refactor:
- Replaces three separate candidate-gathering blocks (main hand, off
  hand, armour loop) with a single unified slot_pairs list iterated
  once. Behaviour is identical.

living.rs – damage_armor_items:
- When a player takes hit damage, armour durability is reduced through
  LivingEntity::damage_armor_items, a separate code path from the
  player item-damage methods. This path now also broadcasts the
  EntityStatus break packet when an armour piece's durability hits zero.

entity/mod.rs – shared helper:
- Add equipment_break_status(slot) -> EntityStatus as a #[must_use]
  pub const fn. Eliminates the duplicated slot→status match that would
  otherwise exist in both call sites (player.rs and living.rs).

Tests (16 new)
--------------
- entity::tests::equipment_break_status_maps_all_slots – asserts every
  EquipmentSlot variant (including Body and Saddle) maps to its
  expected EntityStatus break variant.
- item::tests (15 tests) – first unit tests for ItemStack durability
  logic, covering damage_item_with_context (zero/negative amount,
  non-damageable item, unbreakable item, accumulation, stack break at
  max damage, over-damage) and repair_item (zero/negative amount,
  undamaged item, partial repair, cap at current damage, full repair
  clears the Damage component patch entry) and set_damage (negative
  value clamps to zero).

* refactor: use table-driven cases in damage_increases_damage_value test

* chore: make clippy happy

* refactor: the rest of damage and repair tests to use table-driven cases

* feat: broadcast EntityStatus when equipment breaks

- Implement strict packet ordering (EntityStatus before slot sync)
- Add break broadcast in play.rs use_on_block for all tools
- Generalize damage_item_in_slot to support all equipped slots
- Trim PR comments to 1-2 professional lines
- Convert equipment_break_status test to table-driven format
- Ensure vanilla parity per decompiled 1.21.11 EntityEvent mappings

* feat(item): durability overhaul — DamageResult, armor/weapon parity, elytra fix

pumpkin-world
- Add DamageResult enum (Untouched/Damaged/Broken) replacing bool return on
  damage_item_with_context and damage_item
- Elytra clamped at max_damage-1; never deleted from inventory
- Stacked item break correctly returns Broken regardless of remaining count
- Add is_axe/is_pickaxe/is_shovel/is_hoe tag-based predicates to ItemStack
- 21 new unit tests covering all cases (elytra, stacks, Unbreaking, categories)

pumpkin
- Armor damage type filter: bypasses_armor_durability() driven by the
  vanilla minecraft:bypasses_armor data tag (1.21.11); id-based u8 lookup
- Elytra worn in armor slot skipped from hit damage
- Thorns: extra +2 durability cost + 1-4 magic retaliation damage
- Weapon 2-durability cost: axes/pickaxes/shovels/hoes in combat
- Fix armor slot Unbreaking formula (is_armor_slot() gate)
- Fix stacked-item break broadcast (Broken not is_empty())
- Extract combat_weapon_durability_cost as sync fn; reuse existing lock
- 5 forward-compatible TODO one-liners for shield/trident/crossbow/fishing rod/brush

* fix(item): resolve vanilla parity issues in durability and combat tracking

- Move armor durability calculation to pre-absorption damage
- Fix Thorns damage range to uniform float [1.0, 5.0) and correct execution order
- Attribute Thorns damage to victim for correct combat tracking
- Refactor `damage_item` to auto-infer armor via `#minecraft:enchantable/armor`
- Decouple Elytra clamping from generic item damage loop into dedicated methods
- Add TODOs for DAMAGE_RESISTANT, post-attack effects, and data-driven bypasses

Also reformatted long comments to be concise and techincal

* chore: trigger CI rerun

* fix: shears no longer take durability damage when attacking mobs (refactor + codegen to standardize)

Replace hardcoded item-category checks in combat_weapon_durability_cost
with a data-driven lookup of the minecraft:weapon component.

- Add item_damage_per_attack field to WeaponImpl with DataComponentImpl
- Wire WeaponComponent deserialization into pumpkin-codegen item builder
- Regenerate item data so weapon durability values come from items.json
- Items without the Weapon component (e.g. shears) return 0 cost

* chore: retrigger CI

* refactor: Remove Thorns retaliation and trigger mechanics

- Remove Thorns enchantment trigger check and probability
- Remove Thorns extra +2 durability cost on armor
- Remove Thorns retaliation damage to attacker (1-5 magic damage)
- Remove Thorns combat attribution via damage_with_context
- Remove related imports and TODO comments
- Keep source parameter for future compatibility

* fix: glaring issues

- Fix WeaponImpl::read_data to actually read item_damage_per_attack from NBT
  instead of hardcoding 1; custom weapons now load correctly
- Remove unused _source parameter from damage_armor_items signature
- Move is_axe/is_pickaxe/is_shovel/is_hoe behind #[cfg(test)] since they're
  test-only helpers, keeping public API clean

* fix: elytra unbreaking and Pre-absorption Armor Test
Also a comment for clarity

* refactor: remove elytra scope creep: damage handling and related tests

* adjustment: tighten unbreaking test, update comments to be correct

* fix: clamp negative NBT, widen Unbreaking test, document elytra and shield-disable TODOs

* refactor: armor bypass logic: use bitmask, hoist lookups, optimize durability loop

* feat: Remove hardcoded Elytra armor check; use EquippableImpl::damage_on_hurt for data-driven durability logic.

* fix: add bitmask compile-time assert, clarify NBT clamping, document damage_on_hurt logic, rename slot_result, add #[must_use] to damage_item, and fix all unused result warnings.

* fix: clarify stacked item break edge, strengthen bitmask asserts, document NBT error handling, add TODOs for tool break handling and loop short-circuit, remove dead code and trident stub, note TOCTOU, and document test determinism. All tests passing.

* fix: Various

CRITICAL ITEMS:
  * bypasses_armor_durability correctness: Verified by existing test suite
    (validates all 19 bypass types return true, 12 physical types return false).
  * TOCTOU race in attack(): Enhanced documentation with 3 specific mitigation
    options and justification for single-player safety.
  * must_use suppressions: Removed #[must_use] from damage_item; added TODO to
    restore once all DamageResult::Broken handlers implement proper semantics.

SIGNIFICANT ITEMS:
  * DamageResult::Broken semantics: Updated doc comment to clarify that breaking
    always broadcasts correctly—whether consuming a single item or decrementing
    a stack. Callers need not split the enum.
  * Stacked item multi-break behavior: Verified matches vanilla (one break per
    call, never chains). Updated comment to document this as correct behavior,
    not a regression.
  * should_apply_durability_damage_with visibility: Made private to prevent
    incorrect unbreaking formula usage outside durability context.
  * Elytra exemption caching optimization: Added PERF comment noting O(1)
    component lookup is already efficient (max 4/hit). Deferred to dedicated
    caching architecture pass.

MINOR ITEMS:
  * Unbreaking test windows: Tightened from (500–1500) to (865–1135) for ±5σ
    confidence—catches actual formula regressions while remaining statistically
    sound. Updated both tool and armor tests.
  * WeaponImpl NBT error handling: Documented conservative fallback behavior
    (clamp negatives, default missing keys). Added TODO for tracing::warn! at
    higher-level call site.
  * default_item_damage naming: Renamed return_1u32 for consistency and clarity
    in weapon damage context.
  * WeaponImpl Hash collision prevention: Added struct-level NOTE reminding
    developers to update get_hash() if fields are added. Deferred until
    multi-field scenario (currently impossible with one field).

* fix: Resolve duplicate `return_1f32` and restore `#[must_use]` on `damage_item`

- Removed duplicate `return_1f32` function in `pumpkin-codegen/src/item.rs` to fix a compile blocker.
- Restored `#[must_use]` attribute on `damage_item` in `pumpkin-world/src/item/mod.rs` to enforce proper handling of `DamageResult`.
2026-03-15 14:17:18 +01:00
Alexander Medvedev
744664cb2f chore: parse DoublePerlinNoiseParameters at compile time 2026-03-10 20:55:49 +01:00
Illyrius
823914ec1c feat: wasm-api/player/get_name (#1840)
* init

Signed-off-by: illyrius666 <28700752+illyrius666@users.noreply.github.com>

* fix fn order to match trait

Signed-off-by: illyrius666 <28700752+illyrius666@users.noreply.github.com>

* feat: add DowncastResourceExt impl for player

---------

Signed-off-by: illyrius666 <28700752+illyrius666@users.noreply.github.com>
Co-authored-by: Bjorn Beishline <75190918+BjornTheProgrammer@users.noreply.github.com>
2026-03-10 04:47:46 -07:00
RB007
e312c4cbd9 feat: underwater magma feature (#1747) 2026-03-07 09:31:55 +01:00
Alexander Medvedev
7248f942e7 fix: latest rust clippy lints 2026-03-05 21:34:47 +01:00
RB007
fbe13bbacd feat: geodes (#1697)
Signed-off-by: Alexander Medvedev <lilalexmed@proton.me>
Co-authored-by: Alexander Medvedev <lilalexmed@proton.me>
2026-03-05 14:32:27 +01:00
RB007
0f51346142 feat: monster room feature (#1748)
* feat: monster room feature

* fix: roof
2026-03-02 10:19:34 +01:00
とぴ。(おーけ
44989c86f4 feat: More compatible Java Edition versions (>=1.21) (#1435)
* 1.21.9

* 771: 1.21.6

* 770: 1.21.5

* 769: 1.21.4

* better impl

* missing data

* 768: 1.21.2

* added >=1.21.2 mapping

* impl abstract remapper.

* added entity_id remap

* fix commands packet (<1.21.6)

* fix 1.21.4 level_chunk_with_light

* fix reading packet

* fix sneak <=1.21.6

* Merge branch 'master' into protocol

* fixed `level_chunk_with_light` packet (<=1.21.4)

* 767: 1.21

* fixed `login_finished` packet (<=1.21.1)

* fixed `login` packet (<=1.21.1)

* fixed `player_position` packet (<=1.21.1)

* fixed `set_held_slot` packet (<=1.21.1)

* fixed `set_time` packet (<=1.21.1)

---------

Signed-off-by: とぴ。(おーけ <support@topi-banana.com>
Co-authored-by: Alexander Medvedev <lilalexmed@proton.me>
2026-02-23 12:06:37 +01:00
RB007
2996487160 refactor: parse placed and configured features at compile time (#1680)
* refactor: parse placed and configured features at compile time

* fix: remove serde_json from pumpkin-world

* fix: lib.rs imports

* 🥀

* refactor: stripped serde from features and moved generated code to pumpkin-data

* Remove: include_json_static

---------

Co-authored-by: Alexander Medvedev <lilalexmed@proton.me>
2026-02-22 11:55:08 +01:00
RB007
0ed3c8d9df fix: send proper dimension/timeline tag data (#1684) 2026-02-21 14:29:20 +01:00
RB007
b3fc910579 fix: lava and fire behavior (#1509)
* fix: item burning (except netherite), proper lava damage, and eliminate ghost lava

* fix: soul fire damage

* fix: fire spreading behavior

* chore: clippy and formatting

* fix: add on_entity_step for magma block damage

* chore: clippy and formatting

* fix: remove item.rs edit and hardcode is_fire_immune for now

* fix: compare biome ids and restore a fn name

* fix: god mode gamerule hack

* feat: DamageResistantImpl

* refactor: remove campfire damage fixes

* refactor: shared fire collision fn

* fix: typos

* fix: i did now 💀

* fix: gamerule and fire resistance now prevent magma block damage

* fix: fire_damage gamerule only for players

* fix: better on_entity_step detection (block edges)

* fix: on_entity_step now fires with bool flag (for detection under non-solid blocks)

* fix: rip

* fix: infiniburn tags and damage

* fix: send_pos_rot

* fix: restore adjust_movement_for_collisions logic and fmt

---------

Signed-off-by: RB007 <36972202+RoosterBooster007@users.noreply.github.com>
2026-02-17 22:49:58 +00:00
Richard Marshall
6e1bea72b7 fix: resolve multiple fluid flow bugs (#1561)
* fix: resolve multiple fluid flow bugs

- Fix from_state_id overlapping ranges so WATER/LAVA source blocks are
  correctly identified instead of always returning FLOWING variants
- Fix is_source always being false (was checking level==0 instead of is_still)
- Fix waterlogged blocks getting garbage fluid properties
- Fix lava receive_neighbor_fluids checking above instead of below
- Remove incorrect falling-to-non-falling quiescence guard in apply_spread
- Fix flow_to_sides TOCTOU by passing props from caller
- Add matches_type/same_fluid_type/to_flowing helpers for fluid type matching

* fix: check all 6 directions in lava receive_neighbor_fluids

Vanilla checks all directions (including Up) for water interaction.

* fix: clippy overlapping arm and redundant closure lints
2026-02-16 13:10:06 +00:00
Rorical
b22e66768a fix: preserve protocol ordering for sound event IDs (#1533)
* fix: preserve protocol ordering for sound event IDs in codegen

The Sound enum variants were sorted alphabetically, causing every
sound ID sent via the protocol to mismatch the client's expected
registration order. Only sort the LOOKUP table for binary search;
keep enum variants in the original sounds.json order.

Closes #1532

* chore: regenerate sound.rs with protocol-correct ordering
2026-02-12 00:04:24 +00:00
Alexander Medvedev
f60a77c5d9 chore: decrease compile time
Instead of parsing pumpkin-data for everyone who compiles lets have it as static files, pumpkin-codegen is a standalone parser now
2026-02-09 15:52:46 +01:00