1
0
Commit Graph

590 Commits

Author SHA1 Message Date
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
Lane Kolbly
aebfbfb8c8 GetPacketID for protocol packet IDs (#3977)
* Added GetPacketId method to protocol, implemented for all protocols.

* Moved GetPacketID methods into a single file, alpha-sorted.

* Fixed 1.12.1 HandlePacket switch statement.

* Added SendLogin to the GetPacketId framework.

* Added SpawnObject to GetPacketId framework.

* Added missing sendEntityEquipment packet ID update for 1.12.1

* Added LeashEntity packet ID change to 1.12.1

* Alphabetized packet enum, added SpawnGlobalEntity to GetPacketId framework

* Fixed clang errors

* Indented cases, expanded comment for GetPacketId

* Changed dyslexic comment.
2017-09-02 17:46:57 +01:00
Lane Kolbly
5d64451f74 Protocol Spawn Position Should Use LastSentPosition (#3929)
+ Added GetLastSentPos

* Fixed spawn position bug in 1.8.
2017-08-30 15:01:33 +01:00
peterbell10
84941bcc9f Update mbedtls to 2.5.1 (#3964)
* Renaming changes:
  * macro prefix "POLARSSL" -> "MBEDTLS"
  * functions now prefixed with "mbedtls_"
  * rename PolarSSL++ -> mbedTLS++
  * rename polarssl submodule

* Use mbedtls' AES-CFB8 implementation.

* Add cSslConfig to wrap mbedtls_ssl_config

* Update cTCPLink and cBlockingSslClientSocket to use cSslConfig

* Use cSslConfig in cHTTPServer

* Use cSslConfig for cMojangAPI::SecureRequest

* CI Fixes

* Set -fomit-frame-pointer on the right target
2017-08-30 15:00:06 +01:00
satoshinm
6bc5031517 Implement Forge protocol handshake support (#3869) 2017-08-27 23:10:20 +02:00
mathiascode
3ebcf0fd5c Leashes work in 1.12.1 2017-08-26 20:56:10 +02:00
mathiascode
4b84288801 Don't assert when placing beds in older versions (#3916) 2017-08-25 14:52:32 +02:00
peterbell10
f4f2fc7c3d Add cUUID class (#3871) 2017-08-25 13:43:18 +01:00
mathiascode
02775e52c4 Minor changes (#3909) 2017-08-24 11:19:40 +02:00
peterbell10
096cdac80d Implement protocol level chunk sparsing (#3864) 2017-08-21 17:56:53 +01:00
Pablo Beltrán
b18f6637b6 Fully implemented leashes (#3798) 2017-08-21 10:46:41 +02:00
peterbell10
b8dda388e0 Represent cItem::m_Lore as an AStringVector (#3882)
* Replace cItem::m_Lore with AStringVector

* Reword deprecation warning

* Fix lua bindings
2017-08-18 11:29:54 +01:00
Bond-009
238f5bb338 Add support for 1.12.1 (#3908) 2017-08-17 16:25:53 +02:00
Lukas Pioch
743a50014a Replaced includes with forward declarations 2017-08-13 12:31:10 +01:00
Lukas Pioch
07f25253a2 Removed unneeded includes (#3902) 2017-08-06 20:57:44 +01:00
peterbell10
759618b035 Remove double includes part 2 (#3890) 2017-08-03 15:34:19 +02:00
Lukas Pioch
0397535fa7 Removed unused forward declarations (#3888) 2017-08-03 15:10:29 +02:00
Lane Kolbly
dc49092ae5 Handle Teleport Confirmation Packet (#3884)
+ Added code to drop incoming client position packets until the most recent teleport was confirmed.
2017-08-02 15:46:29 +01:00
peterbell10
8fbb9dbf53 cParsedNBT: Improved error reporting (#3876)
* cParsedNBT: Improved error reporting

* Fix typos
2017-07-30 17:55:19 +01:00
Tiger Wang
eb4432bb62 Tentative fix for player-limit race condition (#3862)
* Attempts to fix #2257

Derived from d233e9843148313c71fbaba96ccff660e47b07b1

* Changed player count type to int

* Clarified certain actions
2017-07-28 17:54:40 +01:00
peterbell10
e0a44fb3bc Handle incomplete packets in cProtocolRecognizer 2017-07-26 11:04:08 +01:00
peterbell10
a56cfd1f42 Remove smart pointer macros 2017-07-21 14:41:51 +01:00
peterbell10
41d016cf5b Handle middle mouse drag (#3847) 2017-07-13 15:43:48 +02:00
Bond-009
6a19841121 Added basic ocelot behavior (#3829) 2017-07-12 12:42:02 +02:00
Lukas Pioch
e38a2a1e8c Send player message when clicking on advancements or green book. (#3845) 2017-07-12 10:11:29 +02:00
Lukas Pioch
885d828712 Added bed entity (#3823)
* Added bed entity

* Export cBedEntity to lua
* Set color of bed through item damage value
* Added bed entity to APIDoc
* NBT: Added loading and saving
* Crafting recipes for the colored beds
2017-07-07 09:31:45 +02:00
Pablo Beltrán
7606448b05 Fixes double right click on entities till off-hand actions gets implemented (#3821) 2017-07-03 09:37:38 +02:00
Mattes D
e4b60b6a26 Protocol: Do not assume anything about unknown packets. (#3647) 2017-06-16 14:03:13 +02:00
mathiascode
7fa5725f3b Added missing 1.12 packet changes 2017-06-14 21:57:59 +02:00
Mattes D
d61d6b5b96 Protocol 1.12: Fixed missing override specifier 2017-06-14 15:27:05 +02:00
Lukas Pioch
5a228fbc16 Added support for protocol 1.12 (#3757) 2017-06-14 11:22:51 +02:00
Lukas Pioch
4e0ae63ec2 Added WriteBlockEntity to 1.10 and 1.11 and fixed mob spawner 2017-06-09 12:16:44 +02:00
Lukas Pioch
73a3c4e3be Exported boat
- NBT: Added saving / loading of material
- Added the material in the item handler of the boat
- Drop the correct boat if destroyed
- APIDoc: Added desc and functions
2017-05-24 19:02:18 +02:00
Lukas Pioch
fc49ace897 Spawn eggs works again 2017-05-22 18:10:12 +02:00
Lukas Pioch
e35ac1bfb9 Clang 5.0 fixes
- Added override keyword
- Removed inherited member variables
2017-05-21 12:19:06 +02:00
mathiascode
b02886a901 Use FastWriter instead of StyledWriter 2017-05-16 21:17:33 +02:00
peterbell10
f0a16e6d28 VarInt metadata written correctly for boats (#3709)
* Varint metadata written correctly for boats
2017-05-15 18:04:53 +02:00
Pokechu22
19094e7aa6 Add 1.11 entity metadata (#3601) 2017-03-03 10:59:17 +01:00
mathiascode
65ee749013 Corrected particles (#3577)
Fixes wrong IDs causing particles to become unknown to the server.
2017-02-26 01:31:08 +01:00
mathiascode
c89b20695d Add 1.11.1/1.11.2 protocol (#3575) 2017-02-21 16:11:28 +01:00
mathiascode
4311f4a658 Added some blocks and items (#3503) 2017-02-14 11:13:55 +01:00
Mattes D
6b0c795655 Fixed ClientHandle:GetProtocolVersion returning wrong number. 2017-01-28 10:31:04 +01:00
Pokechu22
9c2a0bb7b9 Track skin part and main hand preferences (#3498) 2017-01-03 21:19:29 +01:00
Mattes D
0e3b3be766 Initial support for the 1.11 protocol. 2016-12-16 00:07:22 +01:00
Mattes D
0bffa29358 Removed ClientHandle.h dependencies from common headers. 2016-11-18 20:00:04 +01:00
Lukas Pioch
b088123d18 Added SendMessageRaw for sending json string. 2016-10-21 11:17:39 +02:00
bibo38
cb640ffea4 Spectators added (#2852) 2016-10-12 14:38:45 +02:00
bibo38
015ab00e12 Enclosed Clang pragmas with ifdef's (#3373)
Fixes a warning in MSVC
2016-09-06 23:00:28 +02:00
bibo38
61078e8402 Added support for the Minecraft 1.10 protocol(#210) (#3348)
* Added support for the Minecraft 1.10 protocol(#210)

* Fixed the Clang compilation errors

* Fixed wrong sound pitch value and fixed SendPlayerSpawn Metadata value.

* Prefixed each enum item with the appropriate class name.
2016-09-02 20:22:06 +03:00
LogicParrot
c088f7ff0a Proper respawn packets on dimension travel 2016-08-29 11:16:06 +03:00
Mattes D
d2e8643607 Fixed type-casting-related warnings. 2016-08-24 22:26:53 +02:00
ElNounch
d75bbdd03d Fixing string literal catching word letter as hexa-digit
Was sending "\x08C""uberite" as plugin identifier, aka a String of lenght (Varint 0x8c 0x75 ->) 14988 characters but only 7 provided
Now sending "\x08""Cuberite" as plugin identifier, aka a String of lenght (Varint 0x08 ->) 8 characters, with 8 provided
Fix BungeeCord compatibility
2016-08-17 07:37:48 +00:00
Mathias
e7b4d7a776 Dropped 1.7 support (#3253) 2016-07-21 09:47:42 +02:00
Mattes D
8eaa8613da CMake: Remove needless minimum version specifications. 2016-07-18 22:11:42 +02:00
beeduck
db65e11d57 Fixes for boat entities (#3265)
protocol for vehicles now properly handled, protocol for boat paddles now properly handled, boats can no longer spawn underwater, boats now properly float, boat metadata now properly broadcasted.
2016-07-18 22:10:00 +02:00
Pokechu22
a4f327118b 1.9 / 1.9.2 / 1.9.3 / 1.9.4 protocol support (#3135)
* Semistable update to 15w31a

I'm going through snapshots in a sequential order since it should make things easier, and since protocol version history is written.

* Update to 15w34b protocol

Also, fix an issue with the Entity Equipment packet from the past version.  Clients are able to connect and do stuff!

* Partially update to 15w35e

Chunk data doesn't work, but the client joins.  I'm waiting to do chunk data because chunk data has an incomplete format until 15w36d.

* Add '/blk' debug command

This command lets one see what block they are looking at, and makes figuring out what's supposed to be where in a highly broken chunk possible.

* Fix CRLF normalization in CheckBasicStyle.lua

Normally, this doesn't cause an issue, but when running from cygwin, it detects the CR as whitespace and creates thousands of violations for every single line.  Lua, when run on windows, will normalize automatically, but when run via cygwin, it won't.

The bug was simply that gsub was returning a replaced version, but not changing the parameter, so the replaced version was ignored.

* Update to 15w40b

This includes chunk serialization.  Fully functional chunk serialization for 1.9.

I'm not completely happy with the chunk serialization as-is (correct use of palettes would be great), but cuberite also doesn't skip sending empty chunks so this performance optimization should probably come later.  The creation of a full buffer is suboptimal, but it's the easiest way to implement this code.

* Write long-by-long rather than creating a buffer

This is a bit faster and should be equivalent.  However, the code still doesn't look too good.

* Update to 15w41a protocol

This includes the new set passengers packet, which works off of the ridden entity, not the rider.  That means, among other things, that information about the previously ridden vehicle is needed when detaching.  So a new method with that info was added.

* Update to 15w45a

* 15w51b protocol

* Update to 1.9.0 protocol

Closes #3067.  There are still a few things that need to be worked out (picking up items, effects, particles, and most importantly inventory), but in general this should work.  I'll make a few more changes tomorrow to get the rest of the protocol set up, along with 1.9.1/1.9.2 (which did make a few changes).  Chunks, however, _are_ working, along with most other parts of the game (placing/breaking blocks).

* Fix item pickup packet not working

That was a silly mistake, but at least it was an easy one.

* 1.9.2 protocol support

* Fix version info found in server list ping

Thus, the client reports that it can connect rather than saying that the server is out of date.  This required creating separate classes for 1.9.1 and 1.9.2, unfortunately.

* Fix build errors generated by clang

These didn't happen in MSVC.

* Add protocol19x.cpp and protocol19x.h to CMakeLists

* Ignore warnings in protocol19x that are ignored in protocol18x

* Document BLOCK_FACE and DIG_STATUS constants

* Fix BLOCK_FACE links and add separate section for DIG_STATUS

* Fix bat animation and object spawning

The causes of both of these are explained in #3135, but the gist is that both were typos.

* Implement Use Item packet

This means that buckets, bows, fishing rods, and several other similar items now work when not looking at a block.

* Handle DIG_STATUS_SWAP_ITEM_IN_HAND

* Add support for spawn eggs and potions

The items are transformed from the 1.9 version to the 1.8 version when reading and transformed back when sending.

* Remove spammy potion debug logging

* Fix wolf collar color metadata

The wrong type was being used, causing several clientside issues (including the screen going black).

* Fix 1.9 chunk sending in the nether

The nether and the end don't send skylight.

* Fix clang build errors

* Fix water bottles becoming mundane potions

This happened because the can become splash potion bit got set incorrectly.  Water bottles and mundane potions are only differentiated by the fact that water bottles have a metadata of 0, so setting that bit made it a mundane potion.

Also add missing break statements to the read item NBT switch, which would otherwise break items with custom names and also cause incorrect "Unimplemented NBT data when parsing!" logging.

* Copy Protocol18x as Protocol19x

Aditionally, method and class names have been swapped to clean up other diffs.  This commit is only added to make the following diffs more readable; it doesn't make any other changes (beyond class names).

* Make thrown potions use the correct appearence

This was caused by potions now using metadata.

* Add missing api doc for cSplashPotionEntity::GetItem

* Fix compile error in SplashPotionEntity.cpp

* Fix fix of cSplashPotionEntity API doc

* Temporarilly disable fall damage particles

These were causing issues in 1.9 due to the changed effect ID.

* Properly send a kick packet when connecting with an invalid version

This means that the client no longer waits on the server screen with no indication whatsoever.  However, right now the server list ping isn't implemented for unknown versions, so it'll only load "Old" on the ping.

I also added a GetVarIntSize method to cByteBuffer.  This helps clean up part of the code here (and I think it could clean up other parts), but it may make sense for it to be moved elsewhere (or declared in a different way).

* Handle server list pings from unrecognized versions

This isn't the cleanest way of writing it (it feels odd to use ProtocolRecognizer to send packets, and the addition of m_InPingForUnrecognizedVersion feels like the wrong technique), but it works and I can't think of a better way (apart from creating a full separate protocol class to handle only the ping... which would be worse).

* Use cPacketizer for the disconnect packet

This also should fix clang build errors.

* Add 1.9.3 / 1.9.4 support

* Fix incorrect indentation in APIDesc
2016-05-14 20:12:42 +01:00
LogicParrot
ca6ef58b1e Bulk clearing of whitespace 2016-02-05 23:50:18 +02:00
bibo38
657b0ed007 Changed the format of the MobHead data to allow MobHeads working on MInecraft 1.8
The NBT format now carries the texture data and transmit it to the client.
See: http://minecraft.gamepedia.com/Head#Block_entity
Related to #2674
2016-01-11 17:55:32 +01:00
bibo38
a45315ee74 Fixed not working packet decompression
A compressed packed contains always the uncompressed size, but in the code this size was threatened as the compressed data size. This created a failure, when the client compressed a packet.
See: http://wiki.vg/Protocol#With_compression
Fixes #2841
Fixes #2467
2016-01-10 15:16:29 +01:00
Mattes D
491dbda7d3 Fixed Clang warnings. 2016-01-06 16:20:12 +01:00
Mattes D
80e1eb37dd Renamed leftover strings to Cuberite / Server, as needed.
Also upgraded the user setting file for MSVC to 2013.
2016-01-01 21:05:09 +01:00
Mattes D
0054104017 Fixed problems in cBlockingSslClientSocket. 2015-12-30 13:00:02 +01:00
worktycho
76cd723867 Added GeoTrust Root Certificate 2015-12-22 16:08:02 +00:00
Alexander Harkness
8b851d5048 Added HTTPS links wherever they are supported. 2015-12-19 14:30:32 +00:00
Lukas Pioch
d620dcdd08 Moved variables into scope, removed unused variables and fixed variables 2015-12-17 10:48:36 +01:00
Gargaj
68ff0edfde allow horse control (still quite buggy) 2015-12-15 21:14:27 +01:00
Gargaj
4ae3b64b07 implement breeding 2015-11-29 20:14:28 +01:00
Gargaj
1fb89a5409 fix escaped characters in signs (fixes #1736, fixes #2170) 2015-11-24 19:51:39 +01:00
Dave Tucker
83870f9fc0 Add enum for Sound and Particle Effects
Fixes #2603

Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
2015-11-24 13:21:40 +00:00
Julian Laubstein
48f84cc3e9 changed mob age from char to int 2015-11-16 14:13:44 +01:00