1034 Commits

Author SHA1 Message Date
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
Dylan K. Taylor
a5c3fbdd7a Player: Remove obsolete maxDiff parameter from canInteract() 2017-12-22 20:38:39 +00:00
Dylan K. Taylor
a8bf2191b9 Player: Do direction checks for interaction in 3D instead of 2D
This fixes #983, but I haven't yet tested if this will prevent cheating in an actual hacker scenario. Needs more tests.

Additionally, this should remove the need for the negative threshold - if the diff is less than 0, the player is almost definitely cheating.
2017-12-22 20:06:59 +00:00
Dylan K. Taylor
0688a86f57 Player: Fixed interaction checks preventing placing blocks when stood on the corner of one when using crosshairs
This issue can be seen on W10 Edition. Stand on the corner of a block and turn so that the majority of the target block is behind you. Then look down and try to mine it.
2017-12-22 19:58:33 +00:00
Dylan K. Taylor
2e11e448dd Player: Dump crafting grid on death, not on respawn
This fixes players managing to retain items by getting killed while they have something in the crafting grid.
2017-12-22 11:34:33 +00:00
Oreo Oreoniv
8bf275cb8b Player: Execute PlayerPreLoginEvent before banlist/whitelist checks, close #1831 (#1833) 2017-12-22 11:19:56 +00:00
Dylan K. Taylor
953f45c50f Altered armour handling, now works for damage other than PvP 2017-12-14 12:37:28 +00:00
Dylan K. Taylor
92e966686e Refactor Living->attack() into several methods 2017-12-14 11:39:05 +00:00
Dylan K. Taylor
3f50f88e2c Player: Cleaned up how hurt animations are handled
Override Living->doHitAnimation() instead to ensure that the animation always gets sent to the player.
2017-12-14 11:34:09 +00:00
Dylan K. Taylor
532600ab67 Player: Remove another redundant attack check
This is checked in Player->attack() anyway.
2017-12-14 11:03:13 +00:00
Dylan K. Taylor
78f8fe602c Player: Remove redundant PvP check
This is already checked in a block lower down.
2017-12-14 10:59:17 +00:00
Dylan K. Taylor
4ae278686c Player: Hack anti-fly to ignore levitation 2017-12-13 18:50:56 +00:00
Dylan K. Taylor
45ee115b67 Player: Fixed bad effects killing creative players
Players aren't supposed to take magic damage in creative... I don't know who added this, but it's wrong.
2017-12-10 20:50:50 +00:00
Dylan K. Taylor
44e06f6a32 Player: Stop abusing getItemInHand() when we already have it stored 2017-12-10 17:08:56 +00:00
Dylan K. Taylor
8a90d159fe Cleanup unused imports 2017-12-10 12:09:46 +00:00
Dylan K. Taylor
b06ca6eb0b Rename Living->callDeathEvent() to Living->onDeath() 2017-12-07 12:26:49 +00:00
Dylan K. Taylor
e2d66ac96d Use Player->isBanned() instead of repeating code 2017-12-06 10:38:02 +00:00
Dylan K. Taylor
2cb81b5f8d NetworkInventoryAction: Allow returning null to ignore weird transactions
Revert "Return null on unmatched inventory action and log details"

This reverts commit fd7fb10223f7373919701008970e7e87abc2654e.
2017-11-29 12:44:41 +00:00
Dylan K. Taylor
b22b493abb Fixed Player->onDeathUpdate() not being called
I did not realize this was going to be a problem... argh! stupid messy player impl D:
2017-11-23 14:23:57 +00:00
Dylan K. Taylor
e9e22db1e7 Cleaned up death animation handling, removed dead ticking from non-Living entities 2017-11-22 17:17:47 +00:00
Dylan K. Taylor
1fd9994056 Merge branch 'master' into mcpe-1.2.5 2017-11-21 16:48:18 +00:00
Dylan K. Taylor
808227d9a9 Hack for player spawning issue (ref. #1539) 2017-11-21 15:20:56 +00:00
Dylan K. Taylor
74b074753f Bulk addition of constant visibilities
thanks PhpStorm inspections plugin for annoying the shit out of me until
I did this.
2017-11-21 14:44:10 +00:00
Dylan K. Taylor
d2416d335e Use keepMovement in spectator and when movement anti-cheat is disabled
this makes it much less expensive for players to move around when anti-cheat is disabled. And let's be honest... who uses this shit anyway
2017-11-19 19:31:03 +00:00
Dylan K. Taylor
3bc3a0bb49 Remove redundant inventory resend on gamemode change
inventory isn't modified, so there is no need to resend it
2017-11-19 15:34:29 +00:00
Dylan K. Taylor
dd8a772d43 Removed handler for PlayerHotbarPacket
this thing is useless now, and the equipment stuff can be done with MobEquipmentPacket anyway.
2017-11-18 16:03:18 +00:00
Dylan K. Taylor
dc553142c9 Remove redundant if/else in Player->checkGroundState() 2017-11-18 15:59:51 +00:00
Dylan K. Taylor
81fe00a0a5 Slightly simplify Player->kick() 2017-11-18 15:56:58 +00:00
Dylan K. Taylor
6facd8b50f Provide a way for plugins such as Specter to bypass chain verification 2017-11-18 12:44:18 +00:00
Dylan K. Taylor
e709e3c653 Allow skin geometry name field to be missing
it's not needed, and plugins doing this might want to skip it
2017-11-18 12:32:31 +00:00
Dylan K. Taylor
bda40edebe Fixed default level spawning bug reported on forums
https://forums.pmmp.io/threads/pocketmine-mp-version-1-7dev-399-error-listtag-members-must-be-namedtags-got-integer-in-given.4561
2017-11-17 16:59:57 +00:00
Dylan K. Taylor
7c2dccd2a6 Replace Player->joined with Player->spawned, remove redundant field
spawned serves basically the same purpose as joined does.
2017-11-17 13:44:37 +00:00
Dylan K. Taylor
adabfe78df no-op for PlayerAction START_SLEEPING
this is pretty pointless tbh
2017-11-17 13:30:25 +00:00
Dylan K. Taylor
0fdceb6736 Remove useless sendNextChunk() condition
if the load queue is empty, it makes no difference whether we're spawned or not.
2017-11-17 13:24:31 +00:00
Dylan K. Taylor
ffa9a91a95 Remove dead craftingType field from Player 2017-11-17 12:57:49 +00:00
Dylan K. Taylor
78bb951942 Remove redundant survival check for exhaustion 2017-11-17 12:55:48 +00:00
Dylan K. Taylor
7508524b7b Arrange login sequence code in a bit more chronological order 2017-11-17 12:47:57 +00:00
Dylan K. Taylor
db4a8be240 Remove duplicated duplicated player code in Player 2017-11-17 12:39:12 +00:00
Dylan K. Taylor
3fe9963c84 remove redundant arguments for Entity methods 2017-11-17 12:19:36 +00:00
Dylan K. Taylor
460d540dbc Further cleanup on ListTag and CompoundTag usage 2017-11-17 11:43:32 +00:00
Dylan K. Taylor
3a16985d45 Cleaned up item & arrow pickup code 2017-11-15 12:14:42 +00:00
Oreo Oreoniv
bbbed22467 Save player data after PlayerQuitEvent (#1544), close #1543, close #1482
This reverses a bad solution for #1482 for level unloading on PlayerQuitEvent which caused more widespread issues with plugins doing other, more common things on player quit which directly affected the save data.
2017-11-15 11:16:02 +00:00
Dylan K. Taylor
73cd195e76 Merge branch 'master' into mcpe-1.2.5 2017-11-14 20:06:00 +00:00
Dylan K. Taylor
aa399a1109
migrate to new CompoundTag API (#1515) 2017-11-10 15:38:21 +00:00