1
0
Fork 0
Commit Graph

433 Commits

Author SHA1 Message Date
Tiger Wang 34bf5c0d9d Rename files to match code 2021-05-04 16:11:56 +01:00
nshah25 8be1dd54bb
Add player statistics to API (#5193)
* Fixed issue #5166

Co-authored-by: 12xx12 <44411062+12xx12@users.noreply.github.com>
Co-authored-by: Tiger Wang <ziwei.tiger@outlook.com>
2021-05-03 21:07:09 +01:00
Tiger Wang 3001e23e8c Thrown potions/enderpearls: cleanup 2021-04-12 22:35:07 +01:00
Tiger Wang 951e6c76a7 cPlayer: move some constants out of header 2021-04-12 22:35:07 +01:00
Tiger Wang a999c5d845 More cProtocol cleanup
* Alpha sort functions
* Simplify hand handling
* Fix left handed mode client-side display
2021-04-12 22:35:07 +01:00
Tiger Wang 63ded9f6b4 Add animations for shield/item block & break 2021-04-12 22:35:07 +01:00
Tiger Wang 2fc86476ae Improve bed handling robustness
+ Boot the player out if the bed was destroyed
2021-04-12 22:35:07 +01:00
Tiger Wang 66c211c33a Unify multiprotocol entity animations 2021-04-12 22:35:07 +01:00
Tiger Wang 6e80f7544d Update entity sizes 2021-04-12 22:35:07 +01:00
Tiger Wang 1394fc8eb5 Streamline player abilities handling
* Update player list gamemode on world change
* Fix invisibility for spectators, use entity metadata
* Populate m_World for cPlayers on load
- Remove SendPlayerMaxSpeed, a duplicate of SendEntityProperties
2021-04-12 22:35:07 +01:00
Tiger Wang 4cd49d7eca Fix sending incorrect date values on world change
Yak shave: make more things use cTickTime. Fix a couple of incorrect modulo-on-millisecond-value by making them use WorldTickAge.
2021-04-12 22:35:07 +01:00
Nate b2eddbed84
Teleport off of mount when throwing enderpearl (#5179)
* Teleport off of mount when throwing enderpearl

* Simplify returning boolean

* Oops forgot a semicolon

* Fix code conventions in Player.h
2021-04-08 12:17:24 +02:00
Damián Imrich 071b7be3d4
Basic elytra flight (#5124)
* Basic elytra flight

Co-authored-by: 12xx12 <44411062+12xx12@users.noreply.github.com>
Co-authored-by: Tiger Wang <ziwei.tiger@outlook.com>
2021-04-03 18:45:20 +01:00
Tiger Wang 8a30a4a7b8 Player data loading cleanup
* Kick player if data were corrupt to avoid making it worse
2021-03-29 23:36:15 +01:00
Tiger Wang abcc14076c Call ProcessProtocolOut at opportune times 2021-03-28 21:20:13 +01:00
Tiger Wang 90369deb5a
Change TimeOfDay to WorldDate (#5160)
* Change TimeOfDay to WorldDate

* Do not wrap at 20 minutes, continue incrementing
* Fixes #4737
* Fixes #5159
2021-03-20 20:58:19 +00:00
Tiger Wang 55ba39ca0e Don't send ping updates one packet at a time
* Use the batch update feature of the packet.
* Lengthen interval between time and ping update packets (ref. http://github.com/cuberite/cuberite/issues/4082#issuecomment-348675321).
2021-03-19 11:23:30 +00:00
Tiger Wang 45591cbe7b
Properly deprecate more XYZ parameter'd functions (#5147)
* Fixes #5144
2021-03-15 02:28:18 +00:00
NiLSPACE c729d7abde
Fixed some death messages showing up even when they are disabled. (#5153) 2021-03-11 21:26:35 +00:00
Tiger Wang be2bf999c2 Fix #5118 2021-02-07 22:36:15 +00:00
Tiger Wang 054a89dd9e Clarify cClientHandle, cPlayer ownership semantics
+ A cPlayer, once created, has a strong pointer to the cClientHandle. The player ticks the clienthandle. If he finds the handle destroyed, he destroys himself in turn. Nothing else can kill the player.
* The client handle has a pointer to the player. Once a player is created, the client handle never outlasts the player, nor does it manage the player's lifetime. The pointer is always safe to use after FinishAuthenticate, which is also the point where cProtocol is put into the Game state that allows player manipulation.
+ Entities are once again never lost by constructing a chunk when they try to move into one that doesn't exist.
* Fixed a forgotten Super invocation in cPlayer::OnRemoveFromWorld.
* Fix SaveToDisk usage in destructor by only saving things cPlayer owns, instead of accessing cWorld.
2021-01-12 12:34:34 +00:00
Tiger Wang 16aeb84cd3
Fix potential destruction crashes (#5095)
* Fix potential destruction crashes

* Fix destructors accessing destroyted objects
* Fix cPlayer not destroying windows (Destroyed never called)
* Tentatively fixes #4608, fixes #3236, fixes #3262
- Remove cEntity::Destroyed() and replace with cEntity::OnRemoveFromWorld()

* Add missing call to OnRemoveFromWorld
2021-01-02 13:50:34 +00:00
Aiden Neill 3d044d2dde
Added magma block contact damage (#5055)
* Added magma block contact damage
* Fireproof entities do not take damage from magma
* Fire resistance prevents magma damage
* No magma damage when hovering over magma block
2020-11-25 17:56:55 +00:00
Tiger Wang 645fea4237
Players are no longer kicked when clicking on bedrock (#5023)
* Players are no longer kicked when clicking on bedrock
* Fixes #5022
2020-11-06 14:58:47 +00:00
12xx12 c07ea7b9ab
added const correctness on some functions in cPlayer (#4999)
Co-authored-by: 12xx12 <12xx12100@gmail.com>
2020-10-15 20:18:32 +02:00
peterbell10 a9031b6bae
Fix cmake not adding Werror on clang, and _lots_ of warnings (#4963)
* Fix cmake not adding Werror on clang, and _lots_ of warnings

* WIP: Build fixes

* Cannot make intermediate blockhandler instance

* Tiger's changes

* Fix BitIndex check

* Handle invalid NextState values in cMultiVersionProtocol

Co-authored-by: Tiger Wang <ziwei.tiger@outlook.com>
2020-10-05 10:27:14 +00:00
KingCol13 cd1b507745
Fix instant mining of blocks not being recognised, tweak anti-cheat (#4938)
* Tried to fix a small issue...

Ended up rewriting a bunch of god awful, opaque code with no source
and no sense. Who names a function GetPlayerRelativeBlockHardness???
It's gone now. We're safe again.

* Testing anti-cheat.

* Tidy up debug logging.

* Remove empty member declaration.

* Rewrite GetDigSpeed slightly for better readability.

* GetMiningProgressPerTick now returns 1 when instantly mined. Fixed hasily written typo.

* Comment style and typo fixes.
2020-10-02 20:57:17 +00:00
KingCol13 8947147c25
Enchanting table shows detail on hover. Enchanting is deterministic. (#4937)
* Use lapis for enchanting, subtract correct number of levels, ClientHandle now selects from pregenerated list.

Co-authored-by: Tiger Wang <ziwei.tiger@outlook.com>
2020-10-01 22:33:32 +01:00
12xx12 a0dd311d02
Added dtEnvitonment to player damage text (#4925)
+ Added dtEnvironment to string conversion
+ Added dtEnvironment to player damage strings
2020-09-22 12:38:55 +01:00
Tiger Wang 68cced73af
BlockHandler initialisation is a constant expression (#4891)
* BlockHandler initialisation is a constant expression

If we can't make it all namespaces, this is the next best I guess.

+ Tag handlers constexpr, const as needed
+ Inherit constructors
* Privatise handler functions

* More constexpr

Co-authored-by: Alexander Harkness <me@bearbin.net>
2020-09-20 13:50:52 +00:00
12xx12 c2f8ceb554
Add more statistic tracking (#4837)
+ Added possible 1.8 stats
+ Added stat tracking for 1.8.2
+ Added stat tracking for 1.9
+ Added the breed cow achievement

Co-authored-by: 12xx12 <12xx12100@gmail.com>
2020-09-05 16:13:44 +01:00
Tiger Wang e23dcffaff Make StatSerializer a namespace 2020-08-21 00:53:10 +01:00
12xx12 7d0813ce8c Add Statistics and Achievements for newer Network standards 2020-08-19 20:45:27 +01:00
Tiger Wang 6bdd130aab OnBroken/OnPlaced are for entity actions
* Call OnPlaced/OnBroken in PlaceBlock/DigBlock
- Remove unused Placing/Breaking handlers
* Have the blockhandler's Check handle neighbour updating, instead of QueueTickBlockNeighbors
2020-08-04 18:15:18 +01:00
Tiger Wang 3f712ca9cf Precompile unordered_map/set
+ Add inclusions to Globals.h
* Sort Globals.h
- Remove sys/stat.h from Globals.h
2020-07-19 19:58:53 +01:00
Tobias Wilken 36eab1b323
Introduce recipe book functionality (#4493)
* Introduce recipe book functionality

The recipe book helps especially new players. Missing it gives the
impression that cuberite is not as advanced as it is.

The handling of the recipe book uses the following functions:

- Unlock Recipes
(https://wiki.vg/index.php?title=Protocol&oldid=14204#Unlock_Recipes) to
make recipes available and show the notification for new recipes.
Initialization is done on player login for known ones, the update is done
when new items are discovered.
- Craft Recipe Request
(https://wiki.vg/index.php?title=Protocol&oldid=14204#Craft_Recipe_Request)
when the user selects a recipe from the recipe book to fill the slots.

Known recipes are initialized on player login via `Unlock Recipes` with
`Action` 0.
As soon as a new recipe is discovered this is added via `Unlock Recipes`
with `Action` 1.

To be able to know and recognize new recipes the player class is
extended with `KnownItems` and `KnownRecipes`. As soon as a player
touches an item this is compared to the list of `KnownItems`, if the
item is unknown the recipes are checked for this item and the other
ingredients are checked with the list of `KnownItems`. If a full match
is discovered the recipe is unlocked with the client and stored in the
`KnownRecipes`.

To unlock recipes the recipe ID is sent to the client. A mapping file
(for protocol 1.12.2) translated the minecraft recipe names to ids. The
crafting.txt is extended with and minecraft recipe names is possible.

Limitations:
Only a single recipe is added to the crafting area. Multiple clicks or
shift click does not increase the number of builds.

Co-authored-by: peterbell10 <peterbell10@live.co.uk>

* Address first issues mentioned by @peterbell10

- Some linting
- Extract loading of recipe specific protocol mapping into a function
- Build `RecipeNameMap` only once
- Use `std::optional`
- Extract `LoadRecipe` from `Window`

* Start to implement new suggestions

* Update with suggestions from @peterbell10

* Some minor cleanup

* Update protocol packet IDs
* Remove unused include
* Include header in cmake
* Change a vector to integer counter

* Change dromedaryCase method names to PascalCase

* Address suggestions from @madmaxoft

* Read Protocol subdirectories to load recipe books

To load all recipebooks iterate over the `Protocol` subdirectories
to find mapping files.

Co-authored-by: peterbell10 <peterbell10@live.co.uk>
2020-07-14 17:56:42 +01:00
peterbell10 13144a08e4
Enable some more clang-tidy linter checks (#4738)
* Avoid inefficient AString -> c_str() -> AString round trip

* Avoid redundant string init expressions

* Avoid unnecessary return, continue, etc.

* Add .clang-format to help with clang-tidy fix-its

* Avoid unnecessary passing by value

* Avoid unnecessary local copying

* Avoid copying in range-for loops

* Avoid over-complicated boolean expressions

* Some violations missed by my local clang-tidy

* Allow unnecessary continue statements

* Add brackets

* Another expression missed locally

* Move BindingsProcessor call into clang-tidy.sh and add space

* Fix pushd not found error

* Different grouping of CheckBlockInteractionRate
2020-05-14 22:15:35 +00:00
peterbell10 e6634ed26c
Update submodules (#4727)
Closes #4708

This updates jsoncpp, mbedtls, TCLAP and SQLiteCpp to their latest stable release. A few additional changes were needed:

* jsoncpp deprecated Reader, FastWriter and StyledWriter which I've replaced
  with some helper functions in JsonUtils.cpp

* SQLiteCpp changed how it builds with external sqlite libraries, now expecting
  them to be installed. The simplest path was to remove sqlite from cuberite's
  submodule and just use SQLiteCpp's internal version.
2020-05-09 15:51:15 +01:00
Mat c710f6a4ea
Remove old Android leftovers (#4722) 2020-05-07 22:14:00 +03:00
Tiger Wang 07ca095740
Improve entity position updates (#4701)
* Make puking pickups fly nicer

* Improve entity position updates

* Move determination of whether a delta is too big for a packet into the protocol handlers
+ Less jittery movement
+ Generalise CollectEntity to take any entity
2020-05-04 08:10:47 +00:00
Alexander Harkness 994036a3b8
Add cEntity::GetBoundingBox, and use where appropriate. (#4711)
* Add cEntity::GetBoundingBox, and use where appropriate.
2020-05-03 21:04:33 +01:00
Tiger Wang 50893667db MoveToWorld must always be provided a world 2020-04-18 19:51:30 +01:00
Mattes D 9ee47e5999 Using Super. 2020-04-16 20:07:48 +00:00
Alexander Harkness cdc452916e
Replace buckets to the selected hotbar slot, rather than the first available. (#4580)
* Replace buckets to the selected hotbar slot, rather than the first available.

Replicates vanilla behaviour, as well as being more logical.

* Refactor cInventory::AddItem. Behaviour is now documented

* Add new cInventory::ReplaceOneEquippedItem and ::SetEquippedItem methods

* Return empty potion to the same slot after drinking

* Replace buckets correctly in other situations, not simply water and lava

Uses the new ReplaceOneEquippedItem method

* Correct collecting water from source block with bottle

* Add cPlayer::ReplaceOneEquippedItemTossRest method

* Handle stacked filled buckets (in theory)

Use new cPlayer::ReplaceOneEquippedItemTossRest method
2020-04-02 12:42:15 +00:00
peterbell10 59e38d1a46
Fix explosion knockback issues and tweak knockback strength (#4590) 2020-04-02 09:29:42 +02:00
Mat 5eb1ba3bcc
Lua API for spectating entities (#4518) 2020-03-30 21:35:37 +02:00
Mat 782619e3f8
Send respawn packet by default (#4540) 2020-03-24 14:54:12 +00:00
Alexander Harkness 0a68994f48 Manual merge of #4498.
Credit to @MeMuXin

Closes #4498
2020-03-23 12:18:12 +00:00
Mat 49dd645aa6
Don't remove items twice (#4524)
* Don't remove items twice
2020-03-22 12:17:04 +02:00
Mat 0e07e231a2
Improvements to knockback (#4504)
* Improvements to knockback
* SetSpeed for explosions
* Improve code consistency
2020-03-19 17:13:41 +00:00