Commit Graph

494 Commits

Author SHA1 Message Date
Snowiiii
987aaad3e9 Fix: living entity kill
Also fix: https://github.com/Snowiiii/Pumpkin/issues/265
2024-11-13 23:05:33 +01:00
Commandcracker
060274bd48 Disallow illegal characters in chat (#258)
* Disallow illegal characters in chat
2024-11-13 21:01:43 +01:00
user622628252416
c2822f45f9 Add Command Suggestions and Tab Completion (#245)
* add prototype for /give command

* fix /give namespace

* fix accidentally replaced text

* replace block_registry with item_registry

* sync added items with client

* add command and command suggestion packets

* Add List command  (#238)

* List command

* Stop message on /stop

* add coverter for (mostly) correctly obtaining CCommands packet payload from CommandDispatcher

* fix proof of concept suggestions replacing entire command

* add client side command argument suggestions

* fix arg_position_2d and arg_position_3d not setting pos to block center when coordinate is an integer

* add optional server side command suggestions

* disable serverside suggestions for entity args

* remove pumpkin test client_side_arg_parsers

* use unsigned bytes for flags

* add missing command arg parsers

* fix entities parser flags

* add player permission level

* fix merge conflicts

---------

Co-authored-by: user622628252416 <nnew8715@gmail.com>
Co-authored-by: Victor <47831936+solvictor@users.noreply.github.com>
2024-11-12 20:49:31 +01:00
Commandcracker
8767e66777 Add icon to windows binary (#257)
* Add icon for windows binary

* Add comment to FileDescription

FileDescription is handled as the Program name by Windows!
2024-11-12 19:51:25 +01:00
Edvin Bryntesson
98e8bba936 Inventory cleanup (#256)
* add pumpkin error handling for commands

* cleanup clear command

* fix so that all Container implementations follow the same order as the trait

* cleanup give command

* remove unnecessary function

* remove unnecessary function

* fix give command

* fix clear command

* fixup item placement logic

* cleanup clear command a little
2024-11-12 19:24:52 +01:00
Edvin Bryntesson
8cde02e625 Add Shaped and Unshaped crafting support, as well as deserializing the entire recipe format (#165)
* add cleaner registry parsing

* start adding recipes

* add tags, and some crafting things

* Fix echest command

* add partly working crafting interface

* add generated assets

* fix container commands and clippy lints

* fix issues with resolving recursive item tags for crafting

* add flatten3x3 function

* add shapeless crafting

* add tests to and fix recipe flattening function

* refactor recipe system a bit

* add rayon to speed up initial loading of recipes

* almost working after rebase

* add deserialization for new crafting type "transmute"

* make crafting work again

* make shapeless recipes not require all permutations

* fixed visual bug with when taking out ingredients for crafting

* add support for new tags system
2024-11-12 12:57:14 +01:00
Victor
80bfee705c Clear command and details (#250)
* Clear command

* Version alias
2024-11-11 22:42:02 +01:00
Tiiita
4067f65ff9 Check collision before block place (#251)
* Add bounding box to entities)

* Try to update boundingbox when changin pos

* Remove unused imports

* Update / recalc boundingbox when changing pos

* Add collision when placing check

* Add todo: Check collision with every entity in pos

* Change BoundingBox::new() args

* Seperate bounding box width and height

* Change intersect fn name

* Clean up code
2024-11-10 23:28:14 +01:00
Snowiiii
2d24098e91 Fix: Wrong Flags numbers
Also fixes Sprinting broadcastig
2024-11-10 17:25:50 +01:00
Snowiiii
63979710b2 Better block air checking 2024-11-09 11:33:38 +01:00
Snowiiii
65cb0b52b4 Decrease Block count when Placed 2024-11-09 11:33:14 +01:00
Alexander Medvedev
2f6f11673b MPSC channel buffer fix (#246)
* Fix: Check is chunks Vec is not empty
2024-11-07 22:44:17 +01:00
user622628252416
16dabf1826 Add /give Command (#234)
* add prototype for /give command

* fix /give namespace

* fix accidentally replaced text

* remove dbg! statements

* replace block_registry with item_registry

* sync added items with client

* warn!(..) => log::warn!(..)

---------

Co-authored-by: user622628252416 <nnew8715@gmail.com>
2024-11-07 20:34:56 +01:00
Victor
41e71a857d Add List command (#238)
* List command

* Stop message on /stop
2024-11-07 16:32:27 +01:00
Snowiiii
0fb1ac5f5d Fix: build 2024-11-06 07:07:17 +01:00
Alvsch
d3f299d2f6 Add damage and re-spawning (#224)
* Added new packets

Added packets to pumpkin-protocol for damage and re-spawning.

* Made damage_type registry value accessible

* Added damage and fall damage

* fixed phasing bug

* fix issues caused by merge

* spawn player on ground

make the player spawn on the highest block instead of in the air.

* dont default player to flying

* mode last_pos to living_entity

* fix using entity instead of living_entity

* fixed fall damage not working properly when switching gamemodes
2024-11-05 23:38:26 +01:00
Snowiiii
17f1984699 Remove some ToPrimitive 2024-11-05 23:32:56 +01:00
we sell insurance
93c6da993f Implement Query protocol (#218)
* Add query options to config
Added packet data types
Correctly parse a handshake packet
Add tokio to pumpkin protocol for `AsyncReadExt` convenience functions

* Add repr(u8) so that PacketType is a byte

* Respond to handshake correctly

* Allow for proper decoding of status packets and properly handle errors in decoding

* Implement challange tokens and verify with token and address

* Encode Basic status packet
Switch to CString since its better to and null errors higher up the code

* Encode Full status packet

* Add forgotten fields to full status packet

* Correctly respond to query clients when requesting full status

* Return actual address and port of server
Respect config options
Remove uncessary debug derives

* Remove packet type as it is redundant/unnecssary

* Implement basic status request
Refactor code for better error handling

* Update README

* Show players correctly in full status packet

* Store all packets in structs instead of enums
Break up en/decoding for each packet
Reduce client tracking
Get rid of QueryClients struct
Stop storing of magic value and check during decoding
Added tests for all decoding and encoding
Fix all sugestions from @StripedMonkey
2024-11-05 20:07:31 +01:00
Snowiiii
1f8385e890 Add Serverbound Player Input 2024-11-04 22:02:14 +01:00
Snowiiii
f30da32848 Add Serverbound Client Tick End 2024-11-04 21:53:40 +01:00
Snowiiii
3c7106af0b Print raw Packet ID when not found
We now will use Raw Packet IDs instead of hex
2024-11-04 21:48:28 +01:00
user622628252416
87aa5ec493 Commands: Fix Bug, Refactor Arguments, Add /tp (#227)
* fix command dispatch, add/refactor arguments & add tp command

* implement teleport facing location/facing entity

* implement teleport facing location/facing entity

* implement arg_player/arg_entity and refactor commands accordingly

* implement ~ coordinate notation

* refactor arg_position_3d

* major command refactor

* add documentation

* add default names to more argument types

* add argument names to arg_bounded_nums

* change command argument api

---------

Co-authored-by: user622628252416 <nnew8715@gmail.com>
2024-11-03 23:15:49 +01:00
Snowiiii
8db277f63e Minior Changes 2024-11-03 22:36:00 +01:00
Snowiiii
1842e8e6b1 Parse Serverbound Packet IDs from JSON as well
Before only Clientbound Packet IDs where parsed from JSON, Now Serverbound Packet IDs are parsed from JSON as well. This makes porting to new minecraft version much easier
2024-11-03 12:25:10 +01:00
Snowiiii
8f90b29cfe Extractor: Parse and use screens.json 2024-11-03 11:25:15 +01:00
Snowiiii
9e7adec16b Parse Registries from JSON 2024-11-02 16:34:35 +01:00
Snowiiii
1b510eaa21 Fix: https://github.com/Snowiiii/Pumpkin/issues/222
Check if item is a block, Because Not every item can be placed
2024-11-01 16:18:01 +01:00
Snowiiii
460e9d3cae Add more informations about blocks
Also fixed light for transparent blocks
2024-11-01 11:01:25 +01:00
Snowiiii
21dd9c194c Split PacketError into 2 Structs
Much nicer now
2024-11-01 10:26:07 +01:00
Snowiiii
acf2fab100 Fix: Block still placed when empty slot 2024-10-31 18:35:03 +01:00
Snowiiii
3fb191fa37 Fix: deadlock when removing player 2024-10-31 17:47:01 +01:00
Snowiiii
14c8c7e362 Add more docs 2024-10-29 23:21:04 +01:00
Snowiiii
9f70b95b9b Split commands into their own Folder
Now its much nicer separate from the command base
2024-10-29 22:47:52 +01:00
Snowiiii
74c4662121 Fix: https://github.com/Snowiiii/Pumpkin/issues/195 2024-10-29 16:35:09 +01:00
suprohub
89640fe0c0 Command /say (#211)
* add say command
2024-10-29 11:07:53 +01:00
Snowiiii
e0dd8d6b61 Move Chunks things from Client to Player
Also made Chunk handling more robust
2024-10-28 22:48:17 +01:00
suprohub
ba6f50aae0 Super commit (#208) 2024-10-28 21:04:56 +01:00
Snowiiii
79d2f91deb Chunk: Use Air if block is not found
So currently we trough an error and don't load the entire chunk if a block is not found in the registry, Which is often the case when loading worlds from older or newer version than Currently supported. So now we will just not load the not founded blocks and load blocks which we found
2024-10-27 22:45:51 +01:00
lokka30
1c048a17cc Implement cross platform signal handling with tokio (#183)
* ctrlc: also handle `sigterm` and `sighup` via `termination` feature

This commit enables the `termination` feature in `ctrlc` so that
`sigterm` and `sighup` are also handled on UNIX systems. This in turn
improves Docker compatibility since containers now listen to the
`SIGTERM` signal it sends to containers when trying to stop the
container via `Ctrl-C` whilst attached.

* Replace `ctrlc` signal handling with `tokio`

This removes the `ctrlc` crate from the project, replacing (and upgrading) its functionality to also handle `sigterm` and `sighup`.

Sigterm handling is working on UNIX with this commit, I haven't tested Windows compatibility with `Ctrl-C` nor have I tested `sighup` or `sigint`.

Of course, compiles and runs on UNIX. Haven't tested Windows.

* fix: remove unused import; collapse if statement

* main: fix per-os signal handling

Will only compile Windows-specific/Unix-specific code when on their respective environments.

Handles signals in a separate tokio thread so it doesn't suspend the main thread.

Tested to work on UNIX (macOS) but not tested on Windows.

* main: cargo fmt

* main: fix setup_sighandler fn signature on windows

* main: attempt 2 at fixing windows sighandler

* main: enable ctrlc for all non-unix systems

Previously, ctrlc usage in tokio was only enabled on Windows systems
(since UNIX systems have their own signal handling in Pumpkin). Instead
of limiting ctrlc to just Windows, we can make it run on any non-UNIX
system since it should be platform independent anyhow.
2024-10-27 16:29:59 +01:00
lokka30
15d9920826 Implement max player limit (#194)
* Implement max player limit

* Removed unnecessary `return`.

* Moved server full check to start of `handle_login_start`

Also removed unnecessary debug log.

* Use  instead of  for max players; add disable logic

* Fix semicolon missing
2024-10-27 16:18:28 +01:00
lokka30
1a1a7e351c Add player join and quit messages. (#192)
* pumpkin: Add player join and quit messages.

This implementation will send a 'joined the game' and 'left the game'
message akin to the vanilla server when a player joins or disconnects
respectively.

One caveat with this implementation is that it only broadcasts the
join/quit messages to players in the same world, unlike the vanilla
server, which broadcasts it to all online players (regardless of their
world).

I discussed this with Alex who suggested to keep it as per-world
(seemingly for now?) - [Discord conversation](https://discord.com/channels/1268592337445978193/1268611318617866261/1299668206734147597).

Regardless, this implementation works perfectly on my end. (yes, it has been tested)

* pumpkin: added logs for join/quit

* Move disconnect message code to world from player

Compiles and runs, sends join and quit messages in console with no
errors.

* Move join message from server to world
2024-10-27 14:50:52 +01:00
Snowiiii
a6f3b3f748 Clientbound Packets: use ids from JSON 2024-10-27 14:18:18 +01:00
Alvsch
5507b2069f Added Worldborder (#202)
* Added packets

* Created worldborder struct

* Added worldborder command

* Improved worldborder command

Added messages to worldborder command
Removed all .unwrap()
Created consumer for command

* Fixed small issue

/worldborder add wasn't working properly
2024-10-27 13:11:08 +01:00
Snowiiii
b23b7421cf Revert "CChunkData optimizations (#193)"
This reverts commit a1b97730bd.

Due to Errors
```
thread 'tokio-runtime-worker' panicked at pumpkin-protocol/src/client/play/c_chunk_data.rs:84:25:
index out of bounds: the len is 4096 but the index is 25374
```
2024-10-27 12:29:53 +01:00
Alexander Medvedev
b17ade7b06 Add own Extractor (#201)
* Add custom extractor

* Add namespaces to blocks

* Fix: Errors
2024-10-27 12:21:55 +01:00
Alvsch
a1b97730bd CChunkData optimizations (#193)
* optimized CChunkData::write

* Added a profiling profile

* fix CI
2024-10-27 00:15:01 +02:00
lokka30
5a1c2451dd world docs: corrected to 'world', not 'server' (#191)
These functions access only the world itself's current players, and thus
the old documentation was incorrect saying that it accesses the server's
online players.
2024-10-26 12:25:03 +02:00
kralverde
29b3c8260b make consumers async (#187) 2024-10-25 23:10:38 +02:00
kralverde
c15232929f reduce client id to u16 (#172) 2024-10-25 22:37:11 +02:00
Snowiiii
a395e61c15 Fix: block place in creative 2024-10-25 18:40:10 +02:00