Commit Graph

65 Commits

Author SHA1 Message Date
Alexander Medvedev
e1117ce4a6 chore: nicer event firing 2026-08-03 21:16:07 +02:00
PigTurtle
7bfc6a6737 refactor(data) BlockId and BlockStateId wrapper types (#2328)
* refactor: less manual BlockMetadata impls

* refactor: added BlockId type

BlockId is a wrapper for u16: it is valid for any u16 that is the id of a Block.
- Changed the Block.id field type to BlockId
- added named BlockId constants
- BlockMetadata::ids() now returns Box<[BlockId]>
- adjusted pumpkin-macros to use BlockId constants
- fixed some methods that were comparing blockstate ids or item ids (u16) against block ids (previously u16)

TODO: check if unsafe blocks can be removed; The compiler might understand that BlockId is always a valid index into mappings::TYPE_FROM_RAW_ID

* refactor: added BlockStateId type

A BlockStateId is a safe wrapper around the numerical index of a BlockState in pumpkin-data. They help avoiding validity checks (outside of IO and, currently, plugins), and make it easier for other contributors to reason about what they're comparing; BlockStateIds, BlockIds or Item ids (still u16).
pumpkin-data::BlockStateId replaces RawBlockState and BlockStateId from pumpkin-world.

- added the BlockStateId wrapper type
- made (almost; plugins) every function interacting with block states or block state ids use the wrapper type
- changed codegen logic to create/work with BlockStateIds
- made ChunkPalette parsing check BlockStateId validity (pumpkin-world::chunk::format::ChunkSectionBlockStates)

TODO: check if unsafe blocks can be removed; The compiler might understand that BlockStateId is always a valid index into mappings::BLOCK_ID_FROM_STATE_ID and mappings::STATE_FROM_STATE_ID

* refactor: imports
changed every use pumpkin_world::BlockStateId to pumpkin_data::BlockStateId

* refactor: Block- & BlockStateId

finishing touches;
- rebased on latest mater
- ensure there are no bound checks on Block(State)Id conversions, making them extremely cheap
  - this required unsafe std::hint::assert_unchecked annotations because the compiler is (occasionally) stupid
  - on debug builds the bound checks still exist because of ub_checks (see rust unstable book for the feature of the same name)
- added Safety notes to hopefully prevent anyone from enabling the creation of invalid Block(State)Ids in the future

- fixed a benchmark
2026-07-01 18:05:05 +02:00
Alexander Medvedev
2fcc9bcf4a chore: enforce some more clippy lints
pumpkin contributors will love me :cap:
2026-05-20 22:27:54 +02:00
Alexander Medvedev
966fbec3d3 feat(plugin-api): add java/bedrock abstraction 2026-05-16 09:56:18 +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
Illyrius
fadccf9208 docs: pumpkin-macros v2 (#1720)
* init

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

* fmt

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

---------

Signed-off-by: illyrius666 <28700752+illyrius666@users.noreply.github.com>
2026-03-03 19:46:27 +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
Illyrius
8015b73882 typo: docs/pumpkin-macros (#1451)
* updated documentations and applied a minor fix to resource_pack.rs config (suggested and autofixed by rustrover).

* fmt

Signed-off-by: Illyrius <fitimq@live.nl>

* init

Signed-off-by: Illyrius <fitimq@live.nl>

* fix unnecessary spaces
2026-02-08 14:12:53 +01:00
Alexander Medvedev
fb13004b47 fix: apply clippy lints to workspace
also add contributors to /pumpkin command

Co-Authored-By: Fyor <90567841+fyordev@users.noreply.github.com>
Co-Authored-By: MartV0 <34748938+martv0@users.noreply.github.com>
Co-Authored-By: FabseGP <fabsegp@fabseman.space>
2026-01-28 00:52:47 +01:00
とぴ。(おーけ
45aa815d68 chore: move static instances into Server struct (#1362)
* vanilla data container

* banned_ip_list

* banned_player_list

* operator_config

* whitelist_config

* permission_manager

* permission_registry

* plugin_manager
2026-01-26 14:47:33 +01:00
Alexander Medvedev
186ad2edea feat: 1.21.7-1.21.11 support
Its works, but block state ids are currently not mapped, meaning that when using the current default world gen the client mostly will disconnect due to a not found block state id, vanilla version compatible worlds should work
2026-01-25 23:08:28 +01:00
Alexander Medvedev
5bfa6528da chore: changed block registration
only require block ids, should make bin size smaller and let the compiler better optimize, should also be faster performance wise
2026-01-23 23:32:17 +01:00
Alexander Medvedev
3829850607 removed some clones
fix: https://github.com/Pumpkin-MC/Pumpkin/issues/1226
2025-12-07 22:43:26 +01:00
vyPal
6cac55e0f0 Repurpose Event trait as generic Payload trait (#1116)
* Repurpose Event trait as generic Payload trait

* Fix clippy

---------

Co-authored-by: Alexander Medvedev <lilalexmed@proton.me>
2025-08-27 18:00:55 +02:00
Alexander Medvedev
7e3a1c0972 Fix rust 1.89 warns 2025-08-11 20:45:55 +02:00
Alexander Medvedev
fd8d89a219 Fix https://github.com/Pumpkin-MC/Pumpkin/issues/1075 2025-07-29 12:19:05 +02:00
vyPal
f463b5bc81 allow Custom Plugin APIs (#1080)
* Wrap Context in Arc

* Add support for plugin to expose custom APIs

* Add functionality to allow plugins to load in parallel

* Remove PluginManager from RwLock
2025-07-27 17:34:41 +02:00
teknostom
ee361f35cb Add macro for expanding tags to PumpkinBlock (#1071)
* add macro for expanding tags

* fmt

* Remove log
2025-07-26 19:56:17 +02:00
unschlagbar
2e2236bf3b Bedrock player joining (#1063)
Co-authored-by: unschlagbar <adrian@kuhlmann@gmx.de>
Co-authored-by: Alexander Medvedev <lilalexmed@proton.me>
Co-authored-by: unschlagbar <adrian@kuhlmann@gmx.de>
2025-07-26 17:31:00 +02:00
Alexander Medvedev
e0c91b3edc Initial Bedrock support
You can't join the World, But the base is ready
2025-06-29 00:33:44 +02:00
Alexander Medvedev
8ebc9ee494 Refactor block default state 2025-06-22 21:28:14 +02:00
Clicks
39359e35ff Improve errors from proc macros (#900)
* proc_macro_error2

* cargo fmt
2025-06-17 14:50:24 +02:00
vyPal
88dac44913 Small changes to plugin API (#841)
* Change method/module visibility to be accessible from plugin API

* Allow plugins to register custom plugin loaders with the PluginManager

* Unload all plugins when shutting down server

* Fix formatting
2025-06-07 12:36:16 +02:00
unschlagbar
b997687e8b implement Door placement & pumpkin_data changes (#713)
* fix: view distance goes no above 16

* fix: cargo fmt

* removed the floating point conversation

* fixed spelling

* renamed the test for the capacity estimation

* edit: replaced division with bitshifting

* added more ()

* extendet test and fixed missing chunks when the view distance is very low

* added commentar

* fixed door placement & fence connection

* fix linting

* fmt

* fix clippy

* removed useless borrow

* fix all clippy warnings

* bro i changed so much

* added const to fn

* Update block_state.rs

* added bunch of things

* fix

* lol

* fmt

* fix: player is able to place where it stands

* fix: spelling

* upd2

* upd 4

* remove Option types from blockstate

* resolve conflicts

* Update player.rs

* fix

* fmt

* remove uninit

* fix

* resolved conflicts

* fmt

* remove dupe code

---------

Co-authored-by: unschlagbar <adrian@kuhlmann@gmx.de>
2025-04-26 10:27:37 -10:00
Alexander Medvedev
7611427f92 rework block registration
this should now take less memory and enabled better compiler optimizations, also the piston facing got fixed
2025-04-14 11:39:58 +02:00
4lve
0dd176e8e2 add Block Entities (#737)
* Start implemetnign block entities

* fix

* Move block entites

* bruh wtf

* fix

* Add seralizers for compund

* don't panic on unknown block enity types

* Move block entites to pumpkin-world

* begin implementation

* Chunk packet works

* fix signs

* fix clippy

* merge

* Fix signs

* merge

* fix

* merge

* fix

* remove println

* move folder

---------

Co-authored-by: Alexander Medvedev <lilalexmed@proton.me>
2025-04-13 16:22:12 +02:00
Alexander Medvedev
aedb29f3fc Only store state id in RawBlockState
This theoretically cuts the internal memory usage of chunk data in half since we no longer save the block id
2025-04-12 12:57:09 +02:00
kralverde
b9d9bacf8c Abstract networking to streamline code and avoid creating a new buffer for (de)compression. (#607) 2025-03-20 06:23:25 -10:00
Epix
93510eecd5 Grammar fixes, terminology change (#633)
* Major grammar sweep

* Remove extra backtick

* Use more specific terminology for chunk data storage

* Forgor to cargofmt

* Fix typo "thier"

* Fix typo "clousures"

* Try new terminology

* Forgor to cargofmt

* Use "Subchunks" instead of "Heterogeneous" for ChunkBlocks variant

* Fix variable name

* Forgor to change comment
2025-03-16 10:40:17 +01:00
4lve
eb27cfa16a Generate Blocks and Properties Revamp (#613)
* Add block builder

* Implement loot tables

* chaos snapshot

* LFG

* add oak fence

* lever facing

* Add trait for CardinalDirection

* fix clippy

* fix clippy

* reimplement partial state of loottable

* Implement neighbor block updates

* add oak door

* Fix crash on invalid state

* Fixes

* Add fences

* Add doors

* Refactor how we handle block properties when implemented in many places

* Remove old loot_table, moved to block generation

* Better Block Properties

* Add fence gates

* Update block_grouper and add logs

* Build tags instead and make it easier to define variants of blocks

* Save block states

* Allow nether fences to connect with fence gates

* Move away from hardcoded property names

* Clean up property remaps

* start refactor of blocks

* refactor block compile build

* refactor name map for property groups

* Make it so fences can't connect to the air part of a fence gate

* Use extractor instead of hard coded property names

* to_value and from_value should be stripped of "L" prefix

* Prefix isn't used anymore

* use hashes to verify uniqueness

* Don't declare IntProvider twice and fix typo

* remove some comments that don't apply anymore

* Move loot table so it's shared

* Futureproof Loot Tables

* Implement BlockStateProperty condition for LootTables

* Move experience to pumpkin_utils

* Add is_liquid

---------

Co-authored-by: kralverde <github@email.kralverde.dev>
2025-03-10 18:06:44 +01:00
Alexander Medvedev
e055dd740c Check if player can destroy block using an tool
Prevents players to destroy blocks when holding a sword or trident in creative
2025-03-04 19:45:39 +01:00
kralverde
d518732a76 Fix dupe, double click, and shift click (re-PR) (#591)
* Fix dupe, doubble click and shift click

* Fix inventory desync

* Fix clippy

* refactor magic numbers

* fix clippy

* refactor item logic

* fix inventory

* prefer main inventory over offhand

* Set slot stack to None if empty

* fix container deadlock

* fix linter

* fix lint pt 2

---------

Co-authored-by: 4lve <72332750+4lve@users.noreply.github.com>
Co-authored-by: Alexander Medvedev <lilalexmed@proton.me>
2025-03-01 08:09:14 -10:00
Alexander Medvedev
26b69eae33 Minior packet changes 2025-02-23 13:35:22 +01:00
Alexander Medvedev
1fb2be46d4 Update to Rust edition 2024 2025-02-20 18:42:20 +01:00
MrMelther
daa67c2dfa Reworking block properties (#529)
* Added 11 blocks properties

Added the following properties:
Axis
Open
Age
Attachment
Signal Fire
6 connection directions

* Clippy my beloved 💕

* Reworked block properties

Changed block properties to make them more extensible and easier to handle.

* Little too much of Clippy

* Lever works!!! 🎉

Made the lever work, implementing modifiers to the “on_place” per block, plus the “on_interact” function to handle the state when interacting with a block that has it.

* Kinda implemented bool as value

* A little bit of Clippy :)
2025-02-09 18:45:18 +01:00
Alexander Medvedev
8592d095f3 Parse Items at Compile time 2025-02-08 19:23:59 +01:00
Kris
237b335a17 Add Support for Sign's (#490)
* Updated revised areas

* Removed enum added macro to search for block entity id

* Added sign update for all clients & clean up

* updated update_sign

* Updated code

* typo fix and format

* Finish and correct merge

* Remove hardcoded block entity value

* Move to own nbt crate

---------

Co-authored-by: whiteout314 <almagro.carlos@proton.me>
2025-02-03 12:45:15 +01:00
Alexander Medvedev
1729f58a6f Make Snowballs and Eggs work 2025-02-01 21:17:37 +01:00
suprohub
186e846858 Plugin event rewrite (#513)
* simplify all

* fmt

* Consider using derive macro

* Add new events

* Add events call

* minor fixes

* minor fixes

* fix

* optimize code

* big changes

* fix skill issue

* fix

* Consider not specify patch version

* make logger shared

* i want test one thing

* Add one useful function

* add little amouth of docs

* use config instead

* revert changes

* fmt

---------

Co-authored-by: Alexander Medvedev <lilalexmed@proton.me>
2025-02-01 18:14:28 +01:00
Alexander Medvedev
466d4380cf Some Refactors 2025-02-01 17:53:41 +01:00
suprohub
49c697b431 Plugin api events rewrite (#510)
* simplify all

* fmt
2025-01-28 20:30:34 +01:00
Alexander Medvedev
45a591b27b parse Sounds into enum at compile time 2025-01-10 14:47:34 +01:00
Alexander Medvedev
c711d1511c parse Particle into enum at compile time 2025-01-10 14:39:25 +01:00
Alexander Medvedev
1208e67f36 parse screen into enum at compile time 2025-01-10 14:31:43 +01:00
Alexander Medvedev
03e81a1436 transfer packet id parsing to build time
This also allows now to create custom packets with a custom packet id which is not in the packets.json
2025-01-10 13:42:39 +01:00
Alvsch
a04b23f633 Added compile time BlockState (#347)
* added block_state! macro

* Update block_state! macro
2024-12-07 13:10:37 +01:00
Nico Göbel
b82a4e130b Add: Interactive blocks (#333)
* WIP interactive blocks

* Added jukebox and crafting table

* Making feature more dynamic allowing every block action to be registered here

* Renamed interactive_block_manager to block_manager

* Simplifying register functions

* Added on placed

* Fix master merge

* Added pumpkin_block macro

* Removed junk

* Added the option to block placing in on_use_with_item

* Fixed inventory lock

* Adding on_broken and implementing it for the jukebox

* Fixed merge
2024-12-07 13:00:03 +01:00
Snowiiii
796341be05 Extractor: minimize everything
- blocks.json 8.3MB -> 4.1MB
- items.json 988KB -> 548KB
- packets.json 6.9kb -> 4.2kb
- particles.json 3.5kb -> 1.6kb
- recipies.json 376kb -> 264kb
- screens.json 731b -> 315b
- sounds.json 72.2kb -> 42.2kb
- synced_registeries.json 143.3kb -> 87.6kb
- tags.json 335.4kb -> 165.8kb
2024-11-27 00:12:11 +01:00
Alvsch
4348b56fbe Fix packet side in extractor (#294)
* fix packet side
2024-11-17 19:51:46 +01:00
Snowiiii
711e16528a Simplify Screens, Sounds and Particles Extractor
Particles: 6.6KB -> 3.5KB
Screens: 1.4KB -> 732B
Sounds: 118KB -> 72.2KB
2024-11-14 19:00:38 +01:00