7727 Commits

Author SHA1 Message Date
Dylan K. Taylor
81957d133d AsyncTask: Rewrite how thread-local storage works, now non-dependent on Server or ServerScheduler
this implementation was god-awful bad and it was entirely avoidable to make it this complicated.

This utilizes the fact that pthreads treats static properties as thread-local. AsyncTask local storage now utilizes a \SplObjectStorage stored in an AsyncTask private static field.
2018-05-29 19:41:00 +01:00
Dylan K. Taylor
299e4c8a85 ServerScheduler: remove nonsensical condition in addTask()
now that return type declarations exist, it's not possible for this to return a non-Plugin instance.
2018-05-29 18:17:49 +01:00
Dylan K. Taylor
0a50b8cb9b Removed imports left over from 4f8f334436c69336d1bc2811717983544eda41e8 2018-05-29 11:42:12 +01:00
Dylan K. Taylor
6d53350291 Level: Moved LightPopulationTask out of generator namespace 2018-05-29 11:20:27 +01:00
Dylan K. Taylor
ad61d70eee Level: added getBiome()
this will be needed for weather impl, amongst other things.
2018-05-29 11:10:06 +01:00
Dylan K. Taylor
353a1d69db Level: move getHeightMap() to be more consistent 2018-05-29 11:10:06 +01:00
Dylan K. Taylor
1d8b77f16e
README: remove unnecessary and outdated section
Code dependencies can be seen in the code and in the composer.json file. Besides, there are additional third-party libraries used by PocketMine-MP now which are not listed in this section, and I don't plan to maintain it...
2018-05-29 10:42:59 +01:00
Dylan K. Taylor
e3d2fa10a5 Item: added count parameter to pop()
this allows popping an arbitrary number of items from the stack, instead of just 1.
2018-05-29 10:21:04 +01:00
Dylan K. Taylor
ad15ab5b42 EnchantCommand: use Item->isNull() instead of maths on ID 2018-05-28 19:45:37 +01:00
Dylan K. Taylor
b003295d01 Player: reduce duplicated code in PlayerActionPacket handler 2018-05-28 19:38:29 +01:00
Dylan K. Taylor
4f8f334436 Replaced usages of Math::floorFloat() with (int) floor() and Math::ceilFloat() with (int) ceil()
Once upon a time, these userland functions were faster than calling builtins, but not anymore. According to my test the Math functions are twice slower in PHP 7.2 with typehints and 50% slower without typehints.

Inlining is slightly faster than using builtins, but the difference is very small - not worth making the code look any more ugly than it does already.
2018-05-28 18:54:35 +01:00
Dylan K. Taylor
71fdd59c4c Level: fine-tuned getCollisionCubes() a little bit
since we're getting the BBs anyway, what's the point in delegating this job to the block?
2018-05-28 17:41:12 +01:00
Dylan K. Taylor
0a9ed059d6 Level: fixed logic of getCollisionBlocks() to match getCollisionCubes() 2018-05-28 17:40:05 +01:00
Dylan K. Taylor
74c0863905 Living: fixed preventing effect expiry using events, closes #2208 2018-05-28 17:14:18 +01:00
Dylan K. Taylor
87ff1c0382 Player: don't catch Throwable on transaction creation failure 2018-05-28 17:00:59 +01:00
Dylan K. Taylor
2eaba7c936 Timings: added timings for Player->checkNearEntities() 2018-05-28 16:27:03 +01:00
Dylan K. Taylor
3ee6bfca2a Updated Math dependency 2018-05-28 14:04:17 +01:00
Dylan K. Taylor
63ab27550a Level: Use bitshifts instead of division in some cases 2018-05-28 14:02:32 +01:00
Dylan K. Taylor
d612988882 Level: fixed more off-by-one errors
these are the same crap as the previous commit, but with whole chunks instead of blocks.
2018-05-28 14:00:00 +01:00
Dylan K. Taylor
c9a0c381b1 Level: fixed logical errors in getCollisionBlocks() and getCollisionCubes()
This is the same bug that Entity->getBlocksAround() had, except this actually checks for BB intersections. What this means is that as a result of the bug, one extra layer of blocks is unnecessarily checked on the max sides of the BB.

For example:
Assume you have a BB with maxY -5.5
You're definitely colliding with block -6 (because you're inside it) and you want to check an extra block in case you hit something weird like a fence.
So you want to check _at most_ up to block -5 (inclusive).

Following this maths:
-5.5 + 1 = -4.5
ceil(-4.5) = -4

This causes us to check block -4 unnecessarily. This may be a performance waste - depending on the BB size it could be proportionally a lot of blocks getting unnecessarily checked. This has not been benchmarked.
2018-05-28 12:37:17 +01:00
Dylan K. Taylor
982444949c Fixed typo in AsyncPool
asychronous -> asynchronous
2018-05-26 16:30:49 +01:00
Dylan K. Taylor
8cf0fc63d8 Player: spawn at safe-spawn on level not found, instead of real spawn 2018-05-26 12:20:58 +01:00
Dylan K. Taylor
c18ba38b74 Entity: avoid astonishing behaviour with motion vector modifications 2018-05-26 10:40:04 +01:00
Dylan K. Taylor
3a1df1d99e LevelSoundEventPacket: added STOP_RECORD constant
this isn't actually a sound and as such doesn't have a stringy ID, so the script didn't see it.
2018-05-25 17:56:05 +01:00
Dylan K. Taylor
8ccd13319c LevelSoundEventPacket: update constants
now with whitespace gaps generated because apparently some are missing... ugh!
2018-05-25 17:27:31 +01:00
Dylan K. Taylor
c513d355cb Updated Snooze dependency 2018-05-25 13:52:12 +01:00
Dylan K. Taylor
02b53785be Entity: added some new ID constants 2018-05-24 12:39:44 +01:00
Dylan K. Taylor
9dd0ee7f05 Entity: replaced motion and lastMotion fields with vectors 2018-05-24 12:11:41 +01:00
Dylan K. Taylor
595f1f58da Living: added knockback resistance attribute checks 2018-05-24 11:49:18 +01:00
Dylan K. Taylor
509e8c5f6d ItemFactory: register some easy items
these are items that do nothing and/or are only used for crafting. As such they are simple to add.

Others will be added later on, but others require extra work and/or reverse engineering which I don't have time for now.
2018-05-23 19:48:30 +01:00
Dylan K. Taylor
263cd900a8 Enchantment: update item type flags 2018-05-23 17:39:52 +01:00
Dylan K. Taylor
164ce76ff5 Enchantment: apply typehints to PHP 7.2 standards 2018-05-23 17:28:40 +01:00
Dylan K. Taylor
fbf760bafe Enchantment: implemented Vanishing 2018-05-23 17:23:56 +01:00
Dylan K. Taylor
2c1afe5f2c ItemFactory: generate some TODOs 2018-05-23 13:42:19 +01:00
Dylan K. Taylor
b109b457dc Item: added some new constants 2018-05-23 13:35:15 +01:00
Dylan K. Taylor
e12e2897bb Enchantment: Add new constants
these aren't registered yet because they aren't implemented.
2018-05-23 12:34:58 +01:00
Dylan K. Taylor
8f41384923 Item: remove workaround for anvils
they removed this in the 1.2.13 release. now the metadata matches the block.
2018-05-23 11:43:55 +01:00
Dylan K. Taylor
acf29711c2 Implemented Totems, close #2198
Totem usage can be detected using the MODIFIER_TOTEM constant of EntityDamageEvent.

This does not currently support using the totem in the offhand because offhand is not implemented yet.
2018-05-23 10:06:35 +01:00
Dylan K. Taylor
1c4dd4f280 Player: broadcast entity event to self as well when sending to all viewers
this fixes several bugs with entity events and removes the need for a hit animation hack.
2018-05-23 09:28:46 +01:00
Dylan K. Taylor
faa88a55e4 EntityDamageEvent: break API
The general purpose of this is to split up base damage from modifiers.

- Added methods getBaseDamage(), setBaseDamage(), getOriginalBaseDamage(), getModifiers(), getOriginalModifiers()
- setDamage() renamed to setModifier() and type is now mandatory
- getDamage() renamed to getModifier() and type is now mandatory
- getOriginalDamage() renamed to getOriginalModifier() and type is now mandatory
- Removed MODIFIER_BASE constant
- Constructors now accept: float baseDamage, float[] modifiers instead of just float[] modifiers
2018-05-22 19:05:25 +01:00
Dylan K. Taylor
c9ed517063 Merge branch 'release/alpha12' 2018-05-22 18:50:24 +01:00
Dylan K. Taylor
28b0f5f86a UpdateBlockSyncedPacket: rename field 2018-05-22 18:49:41 +01:00
Dylan K. Taylor
e87e2d4e52 UpdateBlockSyncedPacket: fix field visibility 2018-05-22 18:49:41 +01:00
Dylan K. Taylor
86c27953ec NetworkBinaryStream: bail on unknown entity data types 2018-05-22 16:44:03 +01:00
SOFe
5552704922
PluginBase->getResources() should only return files
Directories should not be returned. Previously it even returns resources\.. according to my test on Windows.
2018-05-21 17:25:57 +08:00
SOFe
c7ac5dfd4b
Fixed the doc comment in Plugin::getResources()
It returns SplFileInfo[] not string[]
2018-05-21 17:24:12 +08:00
Dylan K. Taylor
bd9b59f401 Contributing: be more clear about committing on GitHub 2018-05-21 09:59:56 +01:00
SalmonDE
2f03f5f6d5 Fix a grammar error in Player (#2197) 2018-05-20 21:27:40 +01:00
Dylan K. Taylor
f4a26ddfd9 update Composer dependencies to get Snooze asserts
warning: there are bugs in this code! this will crash and burn without warning!!!!!
2018-05-20 12:57:23 +01:00
Dylan K. Taylor
adb9390b53 Entity: Rename isInsideOfWater() to isUnderwater() 2018-05-19 18:10:43 +01:00