911 Commits

Author SHA1 Message Date
Dylan K. Taylor
3f41628bf3 Merge branch 'legacy/alpha11' 2018-02-17 10:59:19 +00:00
Dylan K. Taylor
a3fa8adf4a Fixed XP orbs trying to track players after teleport
closes #2028

@mal0ne-23, you are today's MVP.
2018-02-17 10:58:54 +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
9abfd54cc1 Updated with ListTag changes from PocketMine-NBT 2018-02-13 16:50:49 +00:00
Dylan K. Taylor
4a85311c5f Living: Remove redundant isAlive() check from kill()
This just causes unexpected bugs, and hides actual bugs.
2018-02-13 12:47:33 +00:00
Dylan K. Taylor
b7bd8dc7f1 Human: fixed NPC skin crash after ByteArray change 2018-02-12 09:56:02 +00:00
Dylan K. Taylor
b75d121c7e Human: remove obsolete TODO 2018-02-11 17:08:59 +00:00
Dylan K. Taylor
88bbb03f12 Human: store cape & geometry data in NBT 2018-02-11 17:08:01 +00:00
Dylan K. Taylor
9478bc281f Human: Save skin data as TAG_ByteArray instead of TAG_String
TAG_String has a UTF-8 payload, which makes it more expensive to work with. Also, skins can contain bytes which are not valid UTF-8 characters and will therefore be treated as corrupted by external tools.
Additionally a TAG_String can only hold 32767 bytes, which might become a problem in the future.

A TAG_ByteArray can hold up to 2GB of data, and there is no character encoding restrictions on it.
2018-02-11 16:50:00 +00:00
Dylan K. Taylor
3b36d46a8f Living: don't reset attack time on regaining health
fixes #2004 and related bugs
2018-02-10 20:53:39 +00:00
Dylan K. Taylor
6fd4b9f1e2 Entity: Cater for old data with CustomNameVisible as a StringTag
This was a bug in older versions, fixed by 890f72dbf23a77f294169b79590770470041adc4. However since ALPHA10 this has been moved to the new, strict-ified CompoundTag API, which shits its pants when it encounters a tag of the wrong type.

Closes jojoe77777/Slapper#119
2018-01-26 20:01:04 +00:00
Muqsit
6c71b443e8 Fixed armor not dropping (#1962) 2018-01-24 20:01:32 +00:00
Dylan K. Taylor
4a4900e5e7 Revert bad duct-tape fix that broke lots of other things
Revert "Fixed players getting full health on rejoin after quitting on death"

This reverts commit 1d4bafb6ff3e768dc8fed0de414779ddc5e4ddb0.
2018-01-24 19:21:32 +00:00
Dylan K. Taylor
1d4bafb6ff Fixed players getting full health on rejoin after quitting on death
This makes #1567 less exploitable. Now, players who attempt to exploit this bug will get stuck - they won't be able to move or do anything. Not ideal, because they won't be able to respawn either - but it's better than nothing.
2018-01-24 12:27:10 +00:00
Dylan K. Taylor
0658c0851b Entity: Remove some unused properties 2018-01-24 11:37:01 +00:00
Dylan K. Taylor
0df2064802
Implement armor damage protection enchantments (#1839) 2018-01-24 10:13:24 +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
4943ff9dfc Not sure how this got missed :< 2018-01-21 19:36:42 +00:00
Dylan K. Taylor
65fe19ca71 Entity: Fixed logic error in getBlocksAround() which caused yet another firebug
Try setting a fire at z = -204, then stand on the edge between -205 and -206.

The coordinates that a BB's corners are encapsulated in are always the floor()ed coordinates

If you stand at -205.0, your BB min is -205.3 and your BB max is -204.7, which then incorrectly tells you that the BB intersects with block -204
because ceil(-204.7) == -204
when you actually are only intersecting with -205 and -206
this is as bad as using (int) to floor integers :kms:
2018-01-21 15:43:03 +00:00
Dylan K. Taylor
a4f5cab12d Entity: Added getDataPropertyManager() 2018-01-20 20:07:11 +00:00
Muqsit
29e06e30b2 Fix projectiles throwing errors on launching, fix #1942 (#1943)
* Fix Projectile::setOwningEntity() on null error
2018-01-20 18:07:53 +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
3520dafd29 Entity: Make fall distance explicit float to shut a PhpStorm bug up 2018-01-18 16:52:17 +00:00
Dylan K. Taylor
857b63ba8f Entity: Added recalculateBoundingBox() 2018-01-18 16:35:38 +00:00
Encritary
2e1a167bed Arrow class: No need to import Item class with other name (#1932) 2018-01-17 10:59:50 +00:00
Dylan K. Taylor
6f6e3aaa21 Fixed projectiles collding with spectator players
closes #1857
2018-01-17 10:57:04 +00:00
Muqsit
beb5bf6dda Add API methods: Entity::isInvisible(), Entity::setInvisible() (#1930)
* Make use of the API function in Effect class
2018-01-17 09:56:59 +00:00
Dylan K. Taylor
45b02d92d4 Math: Added RayTraceResult, removed dependence on MovingObjectPosition
MOP doesn't make any sense anyway.

RayTraceResult is a container which represents the point at which a line hits a bounding box. No dependence on blocks or entities is wanted or needed.
MovingObjectPosition has API changes to allow it to wrap RayTraceResult, but nothing uses MOP anymore anyway.

This would allow modularisation of the pocketmine\\math namespace.
2018-01-12 14:28:41 +00:00
Dylan K. Taylor
98eba11da5 Human: Use Item->getEnchantmentLevel() for Respiration check 2018-01-11 18:32:46 +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
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
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
06a3c7c478 Entity: Write attributes in AddEntityPacket 2018-01-03 11:30:22 +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
547833ae23 Effect: Add constants with vanilla names where missing 2017-12-23 14:48:56 +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
329fe7d844 Effect: Implement Saturation effect
I thought I did this months ago, but apparently not. Whatever, it's here now.
2017-12-23 11:35:01 +00:00
Dylan K. Taylor
b7aaf54a6f Effect: Fixed mistake in bitshifting with effect level in instant effects
This should be the amplifier, otherwise the effect will have double-effect on level 1.
2017-12-23 11:32:58 +00:00
Dylan K. Taylor
6332814a04 Effect: Minor cleanup on Instant Health/Damage effect amplification 2017-12-23 11:23:29 +00:00
Dylan K. Taylor
9d4818d360 Effect: Hunger is supposed to apply every tick
This fixes oddities in the behaviour noticeable with higher effect levels.
2017-12-23 11:15:23 +00:00