1077 Commits

Author SHA1 Message Date
Dylan K. Taylor
ddc9dca8b4 Player: fixed being able to eat cake in creative
closes #2070
2018-03-13 18:32:08 +00:00
Dylan K. Taylor
590826b9bd Player: Disallow modifying NBT of tiles inside spawn protection 2018-03-10 18:19:17 +00:00
Dylan K. Taylor
a5e87484d9 Player: removed superfluous null-check from setMotion()
this is already checked by broadcastMotion().
2018-03-10 17:08:00 +00:00
Dylan K. Taylor
b39bbffdc5 Entity: Moved and renamed entity\Item to entity\object\ItemEntity 2018-03-10 12:36:46 +00:00
Dylan K. Taylor
2f266a5922 Player: added a server-side forced cooldown mechanism
This is necessary because the stupid client constantly spams right-click actions if you carry on trying to eat/throw/whatever the item when cooldown is in effect. Therefore ender pearls would be fired like machine guns without these checks server side.
2018-03-09 14:45:01 +00:00
Dylan K. Taylor
ea5db98d12 Player: fixed draining hunger when teleporting
this was caused by abe5d94d5b42ecc436fadfcf4786128bcb550ea4 because player's lastBlah wasn't getting updated anymore.

Player movement handling really needs cleaning up, but for now this fixes the issue.
2018-03-08 12:18:22 +00:00
Dylan K. Taylor
dc3bf8546e Refactored effects handling, split up concerns of effect types and instances
Removed json insanity for effects

Split up effect types and effect instances

Saturation is an instant effect
2018-03-07 12:42:31 +00:00
Dylan K. Taylor
973d5dc251 Small de-spaghettification of login handling
no need for these to be split up, it just makes the player login code flow look confusing.
2018-02-28 18:48:08 +00:00
Dylan K. Taylor
eb01dcaf60 Player: don't save data to disk on login
this is pointless, and it will get saved on disk on quit anyway.
2018-02-27 12:26:30 +00:00
Dylan K. Taylor
f0535df96d Remove deprecated things 2018-02-27 11:59:16 +00:00
Dylan K. Taylor
e5ec8fa603 Entity: Use MoveEntityPacket teleport flag for teleporting
fixes entities getting movement interpolation between origin and destination
2018-02-24 12:25:25 +00:00
Dylan K. Taylor
aa11dbb928 Player: Add warnings for messing with movement checks 2018-02-20 13:50:30 +00:00
Encritary
ad8d67137e Implemented critical hits (#1929) 2018-02-19 10:14:32 +00:00
Dylan K. Taylor
6954bfac4b Removed RakNet client ID parameters from Player
This is not used anywhere anymore and null is always filled for this, so it's pointless.

Also, this is an API break.
2018-02-17 19:51:04 +00:00
Dylan K. Taylor
093cb5b39e Updated PocketMine-NBT dependency 2018-02-17 14:29:20 +00:00
Dylan K. Taylor
61fc090cf2 Player: don't debloat skin geometry twice
This is already done in setSkin(), which is called below.
2018-02-16 14:27:16 +00:00
Dylan K. Taylor
9395dbf9fa Player: added missing spawn protection check for frame item removal
fixes #2025
2018-02-16 10:35:16 +00:00
Dylan K. Taylor
a7396d7ae9 Player: Cancel interaction on frames in spectator mode before calling the event, not after
This convention is used throughout the code to allow plugin developers to alter the behaviour of the event. In this case, it would instead produce unexpected behaviour when the event is not cancelled by a plugin.
2018-02-16 10:29:46 +00:00
Dylan K. Taylor
e7e4645c0b Fixed a wide range of bugs with floating-point coordinates getting incorrectly int-casted
This causes lots of bugs in negative coordinates.

This fixes #1789 after world load & save.
2018-02-15 10:27:42 +00:00
Dylan K. Taylor
f66928c345
Player: patch exploits relating to quitting on death (#2017)
* Revert "Revert bad duct-tape fix that broke lots of other things"
This reverts commit 4a4900e5e7ea1fd7b897b025b4b666fd2050f80a.

Player: Perform respawn actions when joining while dead
This fixes exploits related to #1567 by calling respawn logic on join when the player has zero health.
This is a shitty fix and doesn't solve the actual issues described in #1567, but it's a simple solution for the exploits related to it.
2018-02-13 21:23:31 +00:00
Dylan K. Taylor
98d6aea7fe Server: rename getResourcePackManager()
casual BC break, ain't nobody got time for deprecations!

closes #1797
2018-02-11 17:17:56 +00:00
Dylan K. Taylor
63fa6a36a9 Merge branch 'pr/1982' 2018-02-08 12:09:29 +00:00
Dylan K. Taylor
906d7eb176 Lang: Move TranslationContainer and TextContainer to \pocketmine\lang namespace
why the hell were they ever put in \pocketmine\event in the first place??

This change was suggested many months ago but I forgot all about it.
2018-02-04 20:03:30 +00:00
Dylan K. Taylor
f993358c5f fixed extremely stupid bug with player spawns
This was causing new players to inexplicably spawn in the wrong place when joining a world for the first time which had a different level name than folder name. With LevelDB worlds, this caused them to spawn wayyyy up at y=32767 for no good reason.
2018-02-02 16:00:28 +00:00
Oreo Oreo
54f7a88fbb Added getXuid() 2018-01-30 01:25:27 +03:00
Dylan K. Taylor
ffb3e2b47a Player: Fixed logical nonsense in removeWindow()
The only time this is set anyway is obviously if the ID is non-null.
2018-01-27 11:02:03 +00:00
Dylan K. Taylor
ef816c0a52 Player: Fixed window ID of closing inventory always being -1
reported by @Muqsit, thank you sir
2018-01-27 11:00:08 +00:00
Muqsit
6c71b443e8 Fixed armor not dropping (#1962) 2018-01-24 20:01:32 +00:00
Dylan K. Taylor
7d88a8b315 Player: Remove useless assignments from constructor 2018-01-24 18:22:23 +00:00
Dylan K. Taylor
28996f561f Player: Added a hack for knockback being messed up
This needs to be updated server side and isn't because of the way player movement is currently handled. Fixing this properly will require a lot more work than this.
2018-01-24 11:56:32 +00:00
Dylan K. Taylor
6543d96910
Inventory: Split up armor and player inventory (#1957)
* Inventory: Split up PlayerInventory and armour handling
* Fixed other players don't see armour changes. This bug also exists on master.
2018-01-23 20:01:26 +00:00
Dylan K. Taylor
fd5557861b Changed how login verification is handled, add more useful error messages
closes #1955
2018-01-28 14:13:59 +00:00
Dylan K. Taylor
e5ca22a9a6 Player: Simplified implementation of windows => window ID map
it is not necessary to reference the actual objects here. Doing so makes the implementation more confusing. Hashes are sufficient.
2018-01-22 18:58:19 +00:00
Dylan K. Taylor
897a31e608 Player: Moved logic of setUsingItem()
plugins might be using this method, or the item may have been dropped involuntarily due to server-side logic. Therefore it should be handled when the transaction is received and not when the item is dropped into the world.
2018-01-22 18:36:48 +00:00
Dylan K. Taylor
2eb6e075ae
Refactored entity metadata handling into its own class, with type-safe methods (#1876)
This includes several other changes, including:
- SLOT data properties now accept items directly
- POS data properties now accept floored Vector3s (in future this will be block positions) or null for 0,0,0
- VECTOR3F data properties now accept Vector3s or null for 0,0,0
2018-01-20 10:52:14 +00:00
Dylan K. Taylor
6f6e3aaa21 Fixed projectiles collding with spectator players
closes #1857
2018-01-17 10:57:04 +00:00
Dylan K. Taylor
c62e1abf2f Kill the instabreak anti-cheat
This is annoying and it requires that the server must match this precisely to not cause bugs. Additionally, this code shits its pants when the client hits a spot of network lag.

This can be implemented easily as a plugin. There is no reason whatsoever for this to be in the core.
2018-01-05 19:43:51 +00:00
Dylan K. Taylor
55f405f5c2 Player: Extend acceptable block-break distance by 1
Survival reach distance is 6, but that's only a measure of how far the player must reach to hit any part of the target block. Measured from the centre, this again provides a possible corner reach which is too far away from the centre of the block by sqrt(3) / 2 blocks.

Simple fix - allow an extra block's distance.
2018-01-05 19:36:02 +00:00
Dylan K. Taylor
b6c1124d50 Move XP drop amount to Human instead of Player 2018-01-05 12:09:24 +00:00
Dylan K. Taylor
0410df77aa Drop experience on death 2018-01-04 19:33:37 +00:00
Dylan K. Taylor
5c37d298a6 Player: Changed canInteract() default max diff to sqrt(3) / 2
This is needed because players can break blocks that are outside of their field of view. A player can be inside a block and be able to break that block, while looking up, which places its centre (which is where the interact check is done from) actually behind the player's field of view. This causes anti-cheat to be triggered and makes it impossible to break blocks one is inside.

This commit changes the max negative diff to be half of the distance between a block's centre and its corners (M_SQRT_3 / 2).
2018-01-04 15:46:49 +00:00
Dylan K. Taylor
3ca162f23f Revert "Player: Remove obsolete maxDiff parameter from canInteract()"
This reverts commit a5c3fbdd7a648d4a774e167570d2fc0165c66a80.
2018-01-04 15:33:23 +00:00
Dylan K. Taylor
43a0ede9d2 Player: Fix floating-point errors when float Vector3s are given to sleepOn()
In the future this will change to block positions and the Vector3 issue will cease to be an issue.

Closes #1871
2018-01-02 16:09:58 +00:00
Dylan K. Taylor
c9e2e8980f Fixed some places entities/players use their chunk without checking if it is valid
This may be invalid in some cases, such as:
- chunk is not loaded
- entity is not fully constructed
- entity is a Player who has not yet completed the login sequence.
2018-01-02 12:57:04 +00:00
Dylan K. Taylor
bcb080e2b9 Level: Make sleepTicks private, don't write directly 2017-12-30 18:41:13 +00:00
Dylan K. Taylor
e5c58f9b04 Player: Add typehint for maxDistance parameter of canInteract()
Not sure why this was missing :<
2017-12-30 17:43:12 +00:00
Dylan K. Taylor
965c19375f NBT: Split up concerns of endianness and varint NBT into their own classes, separate stream handling from NBT class
The remaining methods, constants and fields in the NBT class now pertain to generic NBT functionality (except for the matchList()/matchTree() methods, but that's a job for another time). All NBT I/O specific logic has now been moved to NBTStream and its descendents.
2017-12-30 14:55:45 +00:00
Dylan K. Taylor
e7a012d69a Player: Remove dead imports 2017-12-30 12:42:42 +00:00
Dylan K. Taylor
ddbc5cf960 Player: Use fmod() instead of modulo operator for yaw/pitch
the modulo (%) operator only operates on integers. If it's used on floats, they are silently casted to ints, which results in loss of accuracy. Fractions of a degree might not seem important, but for ray-tracing purposes a fraction of a degree can make the difference between hit and miss.
2017-12-24 19:48:43 +00:00
Dylan K. Taylor
6e1df36188
Consumables refactor (#1796)
* Removed broken EntityEatEvents - these don't fit the pattern since they only apply to Human entities anyway. PlayerItemConsumeEvent and PlayerInteractEvent can be used for cancellation purposes, and plugins can do custom stuff without mess.

* Restrict item consuming to Living entities only

* Added FoodSource->requiresHunger()

* Only items implementing the Consumable interface can now be consumed.

* The effects from consuming items are now generic-ized by way of the Living->consume() function. This is overridden in Human to allow applying food and hunger.

* Fixed the hardcoded mess for buckets
2017-12-23 13:03:41 +00:00