1
0
Fork 0
Commit Graph

659 Commits

Author SHA1 Message Date
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
Tiger Wang 21068011c6 Remove SetProperty(...cPlayer)
Enchantment table, anvil windows are already opened one per-player.
2020-10-03 16:54:14 +01:00
12xx12 f8de67aace Added end portal and enchanting table block entities 2020-09-20 01:40:20 +01:00
Tiger Wang e2e78abdb7 Style, no need to tag struct with s 2020-09-18 16:41:06 +01:00
Tiger Wang 608e7a9950 Remove unused ServerPort argument 2020-09-18 16:41:06 +01:00
Tiger Wang 7f372b12cb Add State enum to protocol 2020-09-18 16:41:06 +01:00
Tiger Wang bf253caab5 Remove unused ServerPort member 2020-09-18 16:41:06 +01:00
Tiger Wang acc399ffb3 Cleanup Protocol classes
* Visibility, static, ordering changes
2020-09-18 16:41:06 +01:00
Tiger Wang 93adbdce9a
Use tracing for explosions (#4845)
* TNT: Implement tracing algorithm

+ Add intensity tracing
* Fix iterating over all players to SendExplosion, even those not in range

* Implemented TNT entity interaction

* Fixed misaligned destruction tracing

* Finalise TNT algorithm

- Remove BlockArea and just use chunks

Using SetBlock makes it so that we can update everything properly, and does appear to be faster.

* BlockInfo learns about explosion attentuation

* Rename Explodinator parameters

* TNT: pull block destruction into common function

Co-authored-by: Alexander Harkness <me@bearbin.net>
2020-09-12 18:57:44 +00:00
Tiger Wang 07ffd9f6f3 Unused/duplicate function cleanup
* FaceIntToBlockFace in 1.8/1.9 protocol merged
- Removed undefined permissions stuff in Player header
2020-08-29 16:47:40 +01:00
Tiger Wang ecd8f0c0de 1.13+: Send length-prefixed server Brand string
Ref: 5176c22656
2020-08-28 21:08:06 +01:00
Tiger Wang a473e8ba52 ChunkDataSerializer: don't repeatedly mallocate
+ Store an instance of the class, the way it seems it is meant to be used.
2020-08-21 18:22:04 +01:00
Tiger Wang 440523b022 CompressPacket: reserve CompressedSize, not the uncompressed size
+ Assign the length data to a_CompressedData to overwrite it, mirroring the behaviour of cByteBuffer::ReadAll
2020-08-21 18:17:45 +01:00
Tiger Wang 8cca3db61b Consolidate various Chunk serialisers under one roof
* Merge most into WriteSectionDataSeamless
2020-08-21 00:53:10 +01:00
Tiger Wang 82d251b71b Made cProtocol::Version, EntityMetadata enums less verbose 2020-08-21 00:53:09 +01:00
Tiger Wang 9a9079d3da Remove complex templated SendBlockChange
If we're sending enough blocks to have virtual calls be an issue, we should resend the chunk instead.
2020-08-21 00:53:09 +01:00
12xx12 70ab8d2f96
Adding block entity transmission to 1.13 (#4829)
+ Adding block entity transmission to 1.13
+ Added HandlePacketSetBeaconEffect

Co-authored-by: 12xx12 <12xx12100@gmail.com>
2020-08-19 20:46:03 +01:00
Tiger Wang dbc81c3548 Add statistics palette for 1.15 & 1.16 2020-08-19 20:45:27 +01:00
12xx12 7d0813ce8c Add Statistics and Achievements for newer Network standards 2020-08-19 20:45:27 +01:00
Alexander Harkness b45d8bfc1e
Revert "Hotpatch optional for macOSX builds on buildserver"
This reverts commit 5e3f51f5ff.
2020-08-06 12:36:41 +01:00
12xx12 5176c22656
imprementing plugin message to send server brand (#4786)
* fixed issue #4773


Co-authored-by: 12xx12 <12xx12100@gmail.com>
2020-08-05 18:55:19 +00:00
Tiger Wang c0d1cffe0b Delete unreferenced variable 2020-08-05 08:35:37 +01:00
Tiger Wang 25906a3b87 Adjust incorrect palette inclusions 2020-08-05 08:35:37 +01:00
Alexander Harkness 5e3f51f5ff
Hotpatch optional for macOSX builds on buildserver 2020-08-04 23:01:39 +01:00
Tiger Wang 99856df686 Add WakeUp/AddBlock distinction
* WakeUp is for singular changes (block breaking for example). The simulator should check blocks around the position and discover other affected blocks as it sees fit
* AddBlock is for when you know a whole area is to be updated; chunk loading, or area wakeups for example
+ Prepares for correct handling of destroyed blocks after removal of SolidBlockHandler in the redstone simulator
2020-08-02 15:52:06 +01:00
Tiger Wang fb3d3dac1e Correct Serialise393/477 version annotations 2020-07-28 00:08:57 +01:00
Tiger Wang 99f8c44342 1.14 connection support 2020-07-26 18:55:16 +01:00
Tiger Wang de06ae7add Fix incorrect big flower translation
* Upgrade palette had incorrect values for upper half of large flowers
2020-07-26 01:23:01 +01:00
Tiger Wang 07f3f7ec30 Remove some unused inclusions 2020-07-20 09:28:02 +01:00
Tiger Wang 2f30e98dae Remove GetProtocolVersion unneeded comments 2020-07-19 23:11:02 +01:00
Tiger Wang 3dae696b41 Remove ProtocolPalettes 2020-07-19 21:20:27 +01:00
Tiger Wang 5dd51e87e5 Inherit constructors, remove duplication 2020-07-19 20:49:29 +01:00
Tiger Wang e2f15776c7 Remove Waterlogged value from registry
(apparently they're going to remove it, we don't want such a large breaking change)

* Also alpha sort ids, parameters
2020-07-19 20:27:26 +01:00
Tiger Wang f4fe137ab5 Use 1.13.1 block palette 2020-07-19 17:02:14 +01:00
Tiger Wang 00f8c3a225 Implement "caching" in ChunkDataSerializer
+ When sending a chunk to multiple clients, group them by protocol version and send the same data
2020-07-19 16:29:49 +01:00
Tiger Wang bedddfffbc Reduce duplication in CompressPacket
- Remove line 1742 that wrote data which was then immediately cleared
* Store the compress/no compress threshold in a constant
- Remove adding a noncompressed header in SendPacket, CompressPacket handles everything now
2020-07-19 16:21:05 +01:00
Tiger Wang c99ddbc376 1.13.1, 1.13.2 connection support 2020-07-19 00:43:33 +01:00
Tiger Wang 1b9b587734 Add 1.13.1 to 1.15.2 mappings 2020-07-19 00:43:33 +01:00
Tiger Wang bc1b70dcde Use cMultiVersionProtocol's buffer 2020-07-18 19:23:10 +01:00
Tiger Wang 5141d05ba6 Delete duplicated status request handlers
Here we go again...
2020-07-18 19:23:10 +01:00
Tiger Wang 7425305154 1.13 items support
+ Add 1.16 block and item definitions
2020-07-18 19:23:10 +01:00
Mat eb0f640fa0
Initial work on 1.13 entity metadata (#4539)
* Initial work on 1.13 entity metadata

* Largely complete metadata

Co-authored-by: Tiger Wang <ziwei.tiger@outlook.com>
2020-07-17 19:33:02 +01:00
Tiger Wang ff2c246de2
cProtocolRecognizer goes on a diet (#4770)
- Removed inheritance from cProtocol
2020-07-17 18:46:50 +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
Tiger Wang f49f90906c Reduced packet spam when entities idle
* Try not to send look packets when nothing's changed.
2020-07-06 20:56:05 +01:00
Tiger Wang e205d4109b Made grass spreader prettier 2020-07-06 20:56:05 +01:00
Peter Bell ce1d6a7ebd Protocol: Avoid crashing on invalid sign text 2020-05-29 13:46:11 +01:00
Tiger Wang 9e8598fb1c
Upgrade to C++17 [CMake] (#4717)
* Make our CMake slightly less insane
2020-05-16 20:59:10 +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
Mattes D bdb8830b9c Fixed various MSVC warnings. 2020-05-06 12:53:37 +01:00
Tiger Wang eb3ca16921 Fix one definition rule violations 2020-05-04 13:29:56 +01: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
Tiger Wang 0b9b7bc1a8 Unify entity spawn packet sending 2020-04-30 23:04:56 +01:00
Tiger Wang afd377a941 Unify 1.8 and 1.9
- Deleted ridiculous amount of duplicated code
2020-04-22 17:26:31 +01:00
Tiger Wang 246acb19f9 Delet SpawnObject params
* Fix #4679

awkward...
2020-04-19 23:29:52 +01:00
Mattes D 9ee47e5999 Using Super. 2020-04-16 20:07:48 +00:00
Mat d4f3d674d1
Use correct value for zombie villager in 1.13 2020-04-10 05:17:46 +03:00
Alexander Harkness 4b3043f627
Fix compilation, for real this time.
I should go to sleep now...
2020-04-10 01:01:07 +01:00
Bond-009 8438def87e
Add Zombie Villagers 2020-04-10 00:50:45 +01:00
Mat 6a21bf979c
Initial resource pack support (#4622) 2020-04-07 21:23:54 +00:00
Mat 3eaab73540
Potion changes (#4601)
* Correct protocol translation for potions

* Update brewing recipes
2020-04-04 14:16:36 +00:00
Mat 60bcc06f43
Implement wither skeletons (#4563) 2020-04-04 13:44:17 +02:00
Mat 4c6f95f49a
Quick fix to make spawn eggs work (#4611) 2020-04-03 21:56:48 +03:00
Mattes D 01b8ed5295
Pulled the BlockID and BlockInfo headers from Globals.h. (#4591)
The BlockID.h file was removed from Globals.h and renamed to BlockType.h (main change)
The BlockInfo.h file was removed from Globals.h (main change)
The ENUM_BLOCK_ID and ENUM_ITEM_ID enum names were replaced with ENUM_BLOCK_TYPE and ENUM_ITEM_TYPE (cosmetics)
The various enums, such as eDimension, eDamageType and eExplosionSource were moved from BlockType.h to Defines.h, together with the helper functions for converting between them and strings (StringToDimension et al.) (minor)
Many inline functions were moved from headers to their respective cpp files, so that BlockType.h could be included only into the cpp file, rather than the header.
That broke our tests a bit, since they pick bits and pieces out of the main code and provide stubs for the rest; they had to be re-stubbed and re-verified.
eMonsterType values are no longer tied to E_ITEM_SPAWN_EGG_META_* values
2020-04-03 08:57:01 +02:00
Mat 31ace87d28
Add protocol mob ID remapping (#4538) 2020-03-29 17:54:37 +02:00
Alexander Harkness aa9a16b0c6
Fix build on Clang 2020-03-28 18:27:38 +00:00
Mat fce548139b
Inventory changes (#4561)
Co-Authored-By: peterbell10 <peterbell10@live.co.uk>
2020-03-28 13:52:40 +00:00
mathiascode bff7319622 Enable functional packets in 1.13 2020-03-23 18:02:32 +02:00
Mat cff9f7571b
Use LastSentPos for mob spawn packet in 1.11+ (#4490) 2020-03-05 12:58:46 +02:00
mathiascode 3d699c0dc4 Remove 1.13 from supported protocol list 2020-02-24 09:33:59 +01:00
Mattes D 4aef80b47e Added temporary block type mapping for 1.13+ protocols. 2020-01-07 06:53:17 +01:00
Mattes D 583fd0a387 ProtocolRecognizer: Updated to unique_ptr. 2020-01-07 06:53:17 +01:00
Mattes D 7453a9fbe1 Moved ProtocolBlockTypePalette functionality into BlockTypePalette. 2019-12-28 22:43:35 +01:00
Bond-009 eda2fc42d9 Fix clang8.0 build (#4399)
The protocol 13.0 PR broke clang 8.0 builds.
2019-09-24 20:38:54 +01:00
E14 d1c95742dd Add ProtocolBlockTypePalette (#4391) 2019-09-22 22:57:54 +02:00
Mattes D c7132a3091 Protocol 1.9: Alpha-sort, add useful debugging code. 2019-09-16 15:37:54 +02:00
Tiger Wang 77731f80fb Initial support for 1.13 clients
+ Can look at *shape* of world
+ Can look at *shape* of inventory
2019-09-16 15:37:54 +02:00
Mattes D 3bc0f07fea Fixed warnings in ChunkDataSerializer. 2019-09-10 09:45:28 +02:00
Mattes D 2c804dd34a Protocol: Use logical outgoing packet types. 2019-09-10 09:45:28 +02:00
Bond-009 e0ca4d8399 Fix building with clang 8.0 (#4346) 2019-08-11 10:39:43 +01:00
DaPorkchop_ 8b4d37771f Fix player skin sending through BungeeCord (#4328)
This fixes sending of player skins through BungeeCord by actually parsing the JSON instead of setting the player properties as a string.
2019-04-22 18:54:22 +01:00
peterbell10 ee84197014
Force all headers other than "Globals.h" to be included with relative paths (#4269)
Closes #4236

CMake now creates a header file in the build directory under the path "include/Globals.h" which just includes "src/Globals.h" with an absolute path. Then instead of adding "src/" to the include directories, it adds "include/".

#include "Globals.h" still works by including the build generated file and any other src-relative path will not work.
2018-08-29 01:51:25 +01:00
Alexander Harkness c4f43cd8ec
Store and pass entity effect duration as an int not a short. (#4293)
Fixes #4292.
2018-08-26 15:52:39 +01:00
peterbell10 950aeffff8
CheckBasicStyle: Check number of empty lines between functions (#4267)
Add check for number of empty lines between functions and fix the corresponding failures
2018-07-26 22:24:36 +01:00
changyong guo 7b0db672d1 Keep players in gmNotSet (#4248)
This allows players game mode to update to the default after portal to another world.
Fixes #4207
2018-07-23 00:35:32 +01:00
changyong guo 3e802932a6 recover hotbar selected slot after reconnect (#4249)
1. implement protocol message SendHeldItemChange
2. add save / load inventory equipped item slot in JSON
3. send held item slot message after player connect to server

Fixes #4189
2018-07-22 23:23:33 +01:00
peterbell10 7b431bed51
cIsThread: Reset m_ShouldTerminate after the thread has stopped (#4258)
This allows threads to be restarted after stopping.

Fixes #4257
2018-07-22 22:35:58 +01:00
peterbell10 a4dbb5c582
Prefer static_cast to reinterpret_cast (#4223)
* Change reinterpret_cast -> static_cast wherever possible
* Remove more unnecessary `const_cast`s.

reinterpret_casts should be avoided for the same reason as c-style casts - they don't do any type-checking. reinterpret_cast was mainly being used for down-casting in inheritance hierarchies but static_cast works just as well while also making sure that there is actually an inheritance relationship there.
2018-05-02 08:50:36 +01:00
peterbell10 d3c1c626f5
Deal with covered switches consistently (#4161)
* Fixes a number of "<function>: not all control paths return a value" warnings on MSVC.

* Introduces the UNREACHABLE global macro and uses it instead of conditionally compiled switch defaults.

* Move cNBTParseErrorCategory from FastNBT.h into FastNBT.cpp to prevent bad calls to message()
2018-02-04 23:07:12 +00:00
9caihezi 4242431407 Rewrite cClientHandle::HandleRightClick (#4089)
* Add hand parameter to distinguish main hand/off hand.
* Add a new function cClientHandle::HandleUseItem to separate the functionality of using an item without a target block. This matches the protocol with client version >= 1.9
* Always actively update the status of a block if the placement fails (by out of reach or rejected by plugin).
* Do not call plugin callback CallHookPlayerRightClick(-1, 255, -1, -1, 0, 0, 0) when using item.
   The CallHookPlayerUsingItem will still be called.
   Now at most one of CallHookPlayerRightClick, CallHookPlayerUsingBlock,
   CallHookPlayerUsingItem and CallHookPlayerEating will be called based on
   the type of action (not including the used version of callbacks).
* Do not count using item as BlockInteractionsRate check (Using item takes time).
* Now we can open chests(etc.) when sneaking as long as the player's hand is empty.
   This is what vanilla server does.
2018-01-08 13:37:10 +00:00
peterbell10 757231cc6e
Add the fmt library (#4065)
* Replaces AppendVPrintf with fmt::sprintf
* fmt::ArgList now used as a type safe alternative to varargs.
* Removed SIZE_T_FMT compatibility macros. fmt::sprintf is fully portable and supports %zu.
* Adds FLOG functions to log with fmt's native formatting style.
2018-01-03 17:41:16 +00:00
peterbell10 533c95d9e2 Protocol: Fix potion metadata parsing (#4116) 2017-12-26 18:51:38 +00:00
Fabian 0dd172b80f Store Health as a float (#4073)
* Fix #4024

* Fix clang error

* Add comment

* Fix behaviour

* Save Health as float

* Changed m_Health to float

* Remove redundant static_cast

* Fix casts
2017-11-22 13:47:52 +00:00
peterbell10 0bacda3269 Implement horse inventory (#4053)
* Implement horse inventory

* Fix sign conversions

* Add API doc for ItemCategory::IsHorseArmor

* Improve HandleOpenHorseInventory comment and style fixes.
2017-10-21 17:56:09 +01:00
Bond-009 05e7be7f73 Fixed FreeBSD build (#4061) 2017-10-16 18:39:53 +01:00
peterbell10 e883aa828c Add support for release 1.12.2 (#4041) 2017-09-21 14:12:43 +01:00
Lukas Pioch c5f590d460 Removed UTF-8 BOM (#4033) 2017-09-19 10:34:08 +02:00
peterbell10 307e7aaff5 Fix switch warnings (#4013)
* Fix switch warnings
  * Fix a variety of -Wswitch and -Wswitch-enum warnings
  * Remove unneeded -Wno-error flags

* Reorganise some eMonsterType switches
  * Alpha sort eMonsterType cases in WriteMobMetadata
    and in cNBTChunkSerializer::AddMonsterEntity
  * List all mob types in protocol 1.12 and NBTChunkSerializer

* cStructGenTrees::GetNumTrees: remove switch default

* cWSSAnvil::LoadOldMinecartFromNBT: Log unhandled minecart type
2017-09-14 09:48:57 +01:00
Lane Kolbly 028a35ef0d Added assert to cProtocolRecognizer::GetPacketId. (#4001) 2017-09-04 16:58:38 +01:00