7033 Commits

Author SHA1 Message Date
Dylan K. Taylor
a6c1e02847 Enchantment: Register Respiration enchantment
First working enchantment on master. Hooray for 3 years late.

This works out of the box (the code checking for this enchantment already exists in Human->doAirSupplyTick()).
2018-01-11 18:32:22 +00:00
Dylan K. Taylor
b04cee12ea Item: Added API method getEnchantmentLevel() 2018-01-11 18:22:29 +00:00
Dylan K. Taylor
c4966404bb Moved NBT to Composer library 2018-01-11 14:18:09 +00:00
Dylan K. Taylor
579c508761 Move Binary and BinaryStream to Composer library 2018-01-11 13:19:59 +00:00
Dylan K. Taylor
43959bccb1 Change Composer package vendor name to pocketmine instead of pmmp, update dependencies 2018-01-11 13:16:27 +00:00
Dylan K. Taylor
e6bd12dc2f Consolidated MCPE network binary handling methods into one class, remove protocol-specific methods from BinaryStream
Remove MCPE-network specific stuff from BinaryStream, added NetworkBinaryStream
This removes dependencies of BinaryStream on core code, while providing some consolidation of network handling code.
2018-01-11 12:28:56 +00:00
Dylan K. Taylor
7daca754b1 BinaryStream: Fixed wrong header being included
This is currently harmless, except for adding a redundant extra use
statement. However harmless it is though, it is still incorrect.
2018-01-11 12:26:50 +00:00
Dylan K. Taylor
cb90e30bcf Entity: Fixed intersecting with blocks they aren't actually intersecting with...
at the expense of magma no longer working (which will need to be done better anyway).

This:
- reverts the +0.01 outset which hugely exacerbated the lava bug (fixes #1892)
- adds a 0.001 inset (PC-style) which prevents entities incorrectly intersecting with diagonally adjacent blocks at far-ish coordinates (lava at x=4000, z=4000 is a good way to test this).

PR #1880 does also solve this issue, but again at the expense of magma. Since the bugfix does not require a big bounding-box handling refactor, it has been separated out.
2018-01-11 11:10:36 +00:00
Dylan K. Taylor
71d11c73f0
Math: Kill BlockIterator, added a VoxelRayTrace class with level-independent generator functions (#1885)
This is a rather larger commit than I'm happy with, but oh well.

This kills off the enormously overcomplicated BlockIterator and replaces it with a VoxelRayTrace class containing ray tracing generator functions. These functions are independent of any Level. They yield Vector3 objects with current ray trace positions to allow implementations to handle the intercepted blocks in their own ways.

Living->getLineOfSight() now uses VoxelRayTrace instead of BlockIterator.
2018-01-10 20:14:36 +00:00
Dylan K. Taylor
24116ba846 Remove old pthreads v2 workarounds
This used to cause problems in earlier versions of pthreads if PTHREADS_INHERIT_CLASSES was not used. This is no longer a problem in pthreads v3, because pthreads v3 copies passed threaded object classes under the hood, so there is no need to manually include them anymore.

Additionally, the files in these paths don't exist anymore.
2018-01-10 10:59:58 +00:00
Dylan K. Taylor
a0683dbb0f Chunk: Remove useless code in fastDeserialize() 2018-01-08 21:38:30 +00:00
Dylan K. Taylor
b6811b643c .gitignore: Ignore all directories starting with bin
This might cause problems later on, but it's unlikely. Right now however, I am tired of my various PHP version directories showing up in git untracked files.
2018-01-08 11:17:29 +00:00
Dylan K. Taylor
4d2549b50a PlayerInventory: Fixed $send parameter not working for setting armour slots 2018-01-06 16:24:41 +00:00
Dylan K. Taylor
1fb3274f37 Server: Make start() private
This should not be exposed to plugin use.
2018-01-06 15:04:58 +00:00
Dylan K. Taylor
6772a69c55 Server: Prevent construction of more than one server instance at a time
I have no idea when one might choose to do this, but it could cause extremely undesirable effects, so it should be prevented.
2018-01-06 14:58:51 +00:00
Dylan K. Taylor
266a253c03 Remove dead imports 2018-01-05 19:48: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
8fbd0e58f0 Level: Fixed possible crash with changed blocks handling
Since chunks are unloaded before changed blocks are processed, there is a small chance that a block might get changed in a chunk, and then get unloaded due to not being in use, before the updates are broadcasted.
This is unlikely to ever happen since chunks usually don't get unloaded unless they don't have loaders anyway, but it could happen (?) if a chunk is forcefully unloaded.
2018-01-05 13:46:21 +00:00
Dylan K. Taylor
418d099a2e
Merge PR #1561: Implement XP 2018-01-05 12:53:48 +00:00
Dylan K. Taylor
9d2eb5e911 Human: Added some void typehints 2018-01-05 12:30:03 +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
03fda936a8 Added XP level-up sounds and refactored XP gain sound handling 2018-01-05 11:58:54 +00:00
Dylan K. Taylor
684fd46d09 Entity: Throw exception when trying to get save ID of non registered entity 2018-01-04 21:05:17 +00:00
Dylan K. Taylor
90fc649441 Fixed bad PhpDoc leftovers from NBT streams refactor 2018-01-04 20:32:06 +00:00
Dylan K. Taylor
0410df77aa Drop experience on death 2018-01-04 19:33:37 +00:00
Dylan K. Taylor
0f30467f62 Added Level->dropExperience() and API for splitting XP into orb sizes 2018-01-04 19:32:54 +00:00
Dylan K. Taylor
a84910f04c Implemented XP orbs 2018-01-04 19:28:19 +00:00
Dylan K. Taylor
3ee225caec Human: Refactored XP API methods 2018-01-04 19:15:26 +00:00
Dylan K. Taylor
f963dbd10d Level: Added getNearestEntity()
This may be used for AI in the future.
2018-01-04 19:10:43 +00:00
Dylan K. Taylor
debfbf0d93 Math: Added solveQuadratic()
will be used in future for XP. This is extracted from the experience work branch.
2018-01-04 15:58:54 +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
5f48433c95 Bucket: Added sounds for bucket fill/empty 2018-01-03 14:27:41 +00:00
Dylan K. Taylor
33352638a9 Bucket: Fixed appearing empty when picking up still liquids
Buckets already affected by this bug will still appear empty until used. After that they'll work fine.
2018-01-03 14:22:53 +00:00
Dylan K. Taylor
db52501462 Bucket: Fixed stack size handling for empty buckets
GOD this code is horrible
close #1472
2018-01-03 14:12:04 +00:00
Dylan K. Taylor
3a0cbd1cd4 Block: Cleaned up double-block break handling, close #1862, close #1525
This now removes the need for recursing around for structures comprised of multiple blocks. Instead, override getAffectedBlocks() to return all blocks that need to be deleted when the current block is deleted, and make sure that only one half of the block drops something. When a player breaks one of the blocks, all the blocks affected by that block will also be destroyed, creating particles and sounds where appropriate.

This fixes creative drops for double plants and beds.
2018-01-03 13:01:05 +00:00
Dylan K. Taylor
1bdb68b7da EnderChest: Remove dead onBreak() code (follow-up to previous commit) 2018-01-03 12:10:36 +00:00
Dylan K. Taylor
6ce728169e Chest: Remove redundant unpairing code from onBreak()
This is already done in the Level.
2018-01-03 12:08:35 +00:00
Dylan K. Taylor
06a3c7c478 Entity: Write attributes in AddEntityPacket 2018-01-03 11:30:22 +00:00
Dylan K. Taylor
70982c145b Level: Clarified documentation for loadChunk() and changed misleading parameter name 2018-01-02 18:08:43 +00:00
Dylan K. Taylor
417f2d8998 Level: Clarified documentation on getChunk() 2018-01-02 18:05:30 +00:00
Dylan K. Taylor
7339c4ac2f Player: Fixed not being able to interact with blocks in adventure mode, close #1848
This allows other undesired behaviour like flint&steel, buckets to work in adventure mode when they shouldn't, but that's a bug for another time.
2018-01-02 16:26:59 +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
c747c7d025 Throw exceptions when entities/tiles are created on chunks that don't exist
These assertions don't make sense. Since the chunk field is used below in both cases, the chunk should **never** be null no matter what.
2018-01-02 13:12:54 +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
9a956692de Fixed wasteful throwaway objects used for spawn positions 2018-01-02 12:21:11 +00:00
Dylan K. Taylor
d30a6b60b7 .gitignore: Ignore crashdumps directory
How did this never become a problem before?!
2018-01-02 12:09:31 +00:00
Dylan K. Taylor
41873bb115
Merge PR #1864: LevelProviders refactor 2018-01-02 11:47:11 +00:00
Dylan K. Taylor
8064152777 LevelProvider: Add documentation for doGarbageCollection() and close() 2018-01-02 11:39:51 +00:00