1
0
Commit Graph

496 Commits

Author SHA1 Message Date
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
4fbf04413d
Make offline UUIDs consistent with vanilla. (#4178)
Fixes #4177

This is a breaking change to existing Cuberite permissions settings.
2018-07-20 00:30:09 +01:00
changyong guo
2d3013d1d3 Support swap item between main hand and offhand by press key "F" (#4241)
Hi,

I found cuberite don't support to press key "F" to swap items on main hand and offhand, so I implemented this feature.

Best regards
Changyong
2018-06-24 10:24:10 +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
mathiascode
02d75c5336 Removed unnecessary disconnect (#4200) 2018-04-27 08:59:03 +02:00
mathiascode
f4a1ebd880 Properly destroy player (#4199) 2018-04-03 14:39:39 +01:00
mathiascode
a879778968 Broadcast playerlist removal in every world (#4201) 2018-04-02 18:39:54 +01:00
peterbell10
95108c134d
cClientHandle: Always call HOOK_PLAYER_RIGHT_CLICK (#4149)
Reverts the reduction in cases where the hook was called, a change which broke plugins.
2018-01-25 08:10:16 +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
Bond-009
5badb9bcca cChunkInterface GetBlock, GetBlockMeta, GetBlockTypeMeta use vectors (#4050) 2017-11-20 11:13:11 +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
10c5c1227e BroadcastBlockBreakAnimation and BroadcastBlockEntity use vectors (#4038) 2017-09-25 18:17:45 +02:00
Lane Kolbly
30c8470a52 Changed BroadcastSoundEffect, SendSoundEffect, and CastThunderbolt parameters to vectors (#3959)
* Made BroadcastSoundEffect take vector parameters.

* Added docs for new vectored methods

* Removed old code

* Fixed lua warnings

* Made old BroadcastSoundEffect not an override.

* m_Block to m_BlockPos, used Vector3d constructor where prettier.

* a_Block to a_BlockPos

* Changed thunderbolt a_Block to a_BlockPos
2017-09-19 15:12:54 +01:00
Lukas Pioch
c5f590d460 Removed UTF-8 BOM (#4033) 2017-09-19 10:34:08 +02:00
peterbell10
e225b7f826 Replace ItemCallbacks with lambdas (#3993) 2017-09-11 23:20:49 +02:00
Alexander Harkness
c334824199 Shutdown connection when disconnect packet sent (#3999) 2017-09-08 09:36:23 +02:00
LogicParrot
49c443896d Revert "Replace ItemCallbacks with lambdas (#3948)"
This reverts commit 496c337cdf.
2017-09-02 08:50:23 +01:00
Alexander Harkness
7f2c0ef0d6 OnLogin now kicks players properly (#3980) 2017-09-01 15:49:35 +02:00
peterbell10
496c337cdf Replace ItemCallbacks with lambdas (#3948) 2017-09-01 13:04:50 +02: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
peterbell10
f4f2fc7c3d Add cUUID class (#3871) 2017-08-25 13:43:18 +01:00
Pablo Beltrán
b18f6637b6 Fully implemented leashes (#3798) 2017-08-21 10:46:41 +02:00
Tiger Wang
0e10464ac5 Merge pull request #3921 from lkolbly/removeAssert
- Removed incorrect assert in SendRespawn
2017-08-18 11:36:01 +01:00
Lane Kolbly
9cc48ac2a3 Removed incorrect assert in cClientHandle::SendRespawn. 2017-08-11 11:00:21 -05:00
Tiger Wang
4ef47aed62 Changed entity ownership model to use smart pointers 2017-08-07 19:24:16 +01:00
Lukas Pioch
4691bc5a29 Removed double includes (#3885) 2017-08-02 19:57:20 +01:00
peterbell10
0d0323608d cBlockHandler: take player by ref 2017-08-01 08:21:20 +02:00
peterbell10
8eb5672920 cWorld::SendBlockTo take player by ref 2017-08-01 08:21:20 +02: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
Mattes D
f6bab71d05 Fixed memory leak in cClientHandle. (#3794) 2017-06-26 09:11:30 +02:00
Mattes D
9c08b4524c Fix assert when clicking blocks at the top of the world. 2017-06-09 13:44:06 +02:00
Heiko Hund
a0341d561a Add rank prefix and suffix to player name in chat (#3730)
Fixes issue #1721
2017-05-27 02:15:56 +01:00
Pablo Beltrán
84bdba345d Off-hand/shield slot functional, save and load slot, bow + arrow functional (#3725)
Fixes #3714.
2017-05-24 08:09:58 +02:00
mathiascode
8cf48f7682 Allow enabling/disabling of block change limit 2017-05-19 19:51:03 +02:00
Mattes D
6b0c795655 Fixed ClientHandle:GetProtocolVersion returning wrong number. 2017-01-28 10:31:04 +01:00
Mattes D
0e3b3be766 Initial support for the 1.11 protocol. 2016-12-16 00:07:22 +01:00
Mattes D
2aecc7d701 Fixed race conditions in cClientHandle's State. 2016-11-19 23:24:01 +01:00
mohe2015
32b38fb264 Anticheat fastbreak (#3411)
Added block hardness checks when breaking blocks.
2016-11-06 19:30:19 +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
Moritz Borcherding
b268db4caa Use cChunkDef::Height for Y coord comparison where applicable. 2016-09-27 14:32:20 +02:00
Mattes D
e169043a84 Fixed cCompositeChat's constructor LuaAPI bindings.
The tolua-generated constructor would return an extra string value.
2016-09-25 12:42:05 +02:00
LogicParrot
5625598afa Improve cPlayer::DoMoveToWorld (#3113) 2016-09-03 10:39:52 +03:00
LogicParrot
c088f7ff0a Proper respawn packets on dimension travel 2016-08-29 11:16:06 +03:00
LogicParrot
d5b3fbcadb Fixed SendUnloadChunk bug (#3353) 2016-08-28 12:42:34 +03:00
ElNounch
40b929c02e Fix breaking ice in survival not giving a water's source (#3356)
Fix #3355
2016-08-28 08:18:32 +03:00
Mattes D
d1dee3c909 Fixed RasPi builds of unit tests.
On RasPi with gcc 4.8.2, the asserts wouldn't compile when tests were enabled.
Enforced the assumption that ASSERT code is generated only in Debug builds.
2016-08-04 20:47:53 +02:00
Alexander Harkness
a2a9341c24 Tab completion across worlds (#3270)
Fixes #2563.
2016-07-21 13:00:30 +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
00e7b65d87 Fixed some logout crashes 2016-04-24 19:09:44 +03:00
LogicParrot
3283a9613c ClientHandle destruction thread safety 2016-04-23 10:22:48 +03:00
LogicParrot
9b60ee6e43 Auto clean bad world linkages 2016-04-19 12:06:52 +03:00
LogicParrot
bb0e885589 Minor improvements to player freeze 2016-04-05 21:47:49 +03:00
LogicParrot
a431b45641 Improved player freeze code 2016-04-05 14:20:50 +03:00
LogicParrot
dd0ce3287f Players never fall through unloaded chunks or end up inside solids on teleport 2016-03-31 21:35:43 +03:00
LogicParrot
83459d0d89 Proper entity destruction in non-ticking chunks 2016-02-19 07:05:22 +02:00
Lukas Pioch
dc4ea39755 Don't remove water after ice block has been destroyed 2016-02-18 08:16:34 +01:00
LogicParrot
6e269de274 Prevent player from falling when block breaking is denied 2016-02-08 14:10:51 +02:00
Mathias
89f3dec7ac Updated old forum links 2016-01-31 02:25:03 +02:00
LogicParrot
439b3304f4 Improved tamed wolf pack cooperation and projectile reactions 2016-01-22 21:16:27 +02:00
LogicParrot
8c12227687 Fix crash when tamed wolf is hit by arrows 2016-01-16 16:37:37 +02:00
bibo38
41aa7cf123 Limited the username length to 16 characters.
This fixes a client crash, because Minecraft requires that a username is not longer than 16 characters.
See also: http://minecraft.gamepedia.com/The_Player#Name
Fixes #2545
2016-01-13 09:55:48 +01:00
LogicParrot
359e772dee Tamed wolf assists owner (attack / defence) 2016-01-12 11:47:59 +02:00
Tiger Wang
5b62c4c314 Reorganised the redstone simulator
-> Many thanks to @worktycho for the idea, and @Haxi52 for the implementation plan!
* Uses classes and inheritance now
* Speed should be improved
2015-12-18 13:17:38 +00:00
Gargaj
f9008a4860 allow use failures to propagate from the entity/block to the player 2015-12-13 13:27:38 +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
Tiger Wang
9de3a3f938 Examined a fix for #2588 2015-11-02 22:07:48 +00:00
Mattes D
da92286da9 Fixed a crash when sending messages too early after connection. 2015-10-21 20:59:48 +02:00
tycho
d8c860ae58 Improved the data structure for storing loaded chunks
Should significantly increase the performance of deciding which chunks to stream
2015-10-05 16:20:07 +01:00
Lukas Pioch
e56aa4032d Maked it compileable for clang-3.7 2015-09-25 17:09:19 +02:00
tycho
fd7b87741a Refactored cProtocol Chat handling 2015-09-21 12:32:56 +01:00
Tiger Wang
de2cce9b79 Fixed food drain bugs 2015-08-20 16:26:42 +01:00
Matti Hänninen
b20294604c Fix old style casts and implicit conversions 2015-08-12 16:51:38 +03:00
Samuel Barney
804805d35a Silenced and fixed many warning messages across multiple files. 2015-07-29 09:49:30 -06:00
Tiger Wang
8656e149c8 Improved maps 2015-07-14 21:46:30 +01:00
Mattes D
bebd4de144 Fixed warnings generated by 64-bit MSVC. 2015-07-07 11:50:06 +02:00
Tiger Wang
dd4b415051 Reinstate "Chunk queue collapsing"
This reinstates commit f36acb6835
     and reverts commit adfbc42c02.
2015-06-10 15:16:05 +01:00
worktycho
adfbc42c02 Revert "Chunk queue collapsing" 2015-06-07 20:45:47 +01:00
tycho
9ebbe969c8 Made the list of chunks to stream an unordered_set
This should increase performance of chunk streaming
2015-06-05 22:31:22 +01:00
jan64
d37e0eb72b Added system and above action bar chat messages 2015-06-02 19:59:46 +02:00
Tiger Wang
291370e367 Fix Destroy() calling behaviour
* Fixes Core/#142
2015-05-30 00:23:34 +01:00
b33duck
022348645e Fix for the way connecting clients receive player lists and broadcast chat 2015-05-28 19:43:16 -07:00
Tiger Wang
20b7152572 Potential crash fixes
* Potentially addresses my comment in #1969
* Probably fixes #2145
2015-05-28 13:03:28 +01:00
tycho
31b95afd79 Fixed ClientHandle not getting properly removed from the world
when socket is closed whilst the client is being added to the world
Fixes #1969
2015-05-26 10:34:14 +01:00
Mattes D
c3c30a78e1 Merge pull request #1848 from scottwillmoore/ImplementTitleCommand
Implement backend for /title command
2015-05-26 08:46:16 +02:00
Mattes D
2cdc2a16e4 Fixed chat message manipulation by plugins.
Plugins, in their OnChat hook, can change the chat message sent by a player.
2015-05-13 18:45:29 +02:00
Mattes D
c13b1931ff More style checking.
Spaces around some operators are checked.
2015-05-09 12:58:54 +02:00
tycho
448df85e56 Added support for additional data in the ParticleEffect Packet
Also started refactoring how broadcasts are handled
2015-05-07 03:47:46 +01:00
Mattes D
fd497b8269 ClientHandle: Fixed re-sending refused right-clicks.
The coords weren't checked against Y boundary and -1 coords weren't sent.
This fixes mc-server/Gallery#45.
2015-04-19 17:33:58 +02:00
Mattes D
de8e5ea8e4 Placing a fluid from bucket calls plugin hooks.
Ref.: #1857.
2015-04-14 10:49:01 +02:00
Scott Moore
8c144207dc Implement backend for /title command 2015-04-13 16:22:51 +10:00
Mattes D
e5a7a730ed Merge pull request #1826 from mc-server/UnifyPacketizer
Unify packetizer
2015-03-24 13:09:41 +01:00
Mattes D
c3c29577a5 Fixed signedness warnings in Protocol. 2015-03-21 16:11:57 +01:00
Mattes D
3923e3e37a Fixed signedness issues in protocols. 2015-03-21 15:40:56 +01:00
Mattes D
b1d4b3bb96 Unified cByteBuffer types.
cByteBuffer now reads and writes any of the [U]Int<N> types.
2015-03-21 13:00:20 +01:00
Tommy Santerre
3f6d823aa4 Correct world height validations.
Unify the way we test block above the current one (Height - 1 instead of a_RelY + 1).
Allow generation of world of flat height = 255
2015-03-19 20:32:17 -04:00
Mattes D
65d2ef32e9 Merge pull request #1734 from mc-server/pistons
Handle client 'leave bed' request
2015-03-14 22:44:04 +01:00