Compare commits

...

3412 Commits

Author SHA1 Message Date
6399dacba7 Release 3.9.8 2019-12-06 20:33:51 +00:00
4d13c48e5c UPnP: COM constructor never returns false anymore 2019-12-05 16:07:06 +00:00
9159e8f002 MainLogger: mark static logger field as nullable 2019-12-05 15:48:58 +00:00
f5aa461945 GlobalConstants: assume we are on 64-bit when declaring INT32_MASK
fixes a FP reported by phpstan level 4
2019-12-05 15:48:11 +00:00
16817ff301 Player: remove superfluous conditions for RESPAWN action handling
spawned is always true here because of the condition at the top of the function.
isOnline() is always true here because the handler won't even be called if it isn't.
2019-12-05 14:52:12 +00:00
18863b1098 Player: remove superfluous check from processMovement()
if we reached this branch, revert is always false because it is not modified between this branch and the parent one.
detected by phpstan level 4
2019-12-05 14:47:15 +00:00
7b1ae2a822 phpstan: green on level 3 2019-12-04 22:12:14 +00:00
8ecf5e02b9 bad fix for WritableBook phpstan warning
master has this shit so much better
2019-12-04 22:00:19 +00:00
39c607cbd5 Position: mark level field as nullable
allowing the level to be null is, to be honest, a big design flaw, but one that can't be fixed without BC breaks.
2019-12-04 21:31:35 +00:00
d867ffc60d MetadataStore: fix some doc comments 2019-12-04 21:14:09 +00:00
c57eb26fd5 phpstan-bugs: add some extra patterns for level 3 false positives 2019-12-04 19:50:15 +00:00
c35d91a104 phpstan: allow blanket ignoreErrors in src to reduce merge work for master 2019-12-04 19:42:18 +00:00
9fc260fb1a keep phpstan.neon.dist ignoreErrors sorted by file 2019-12-04 19:38:54 +00:00
73d0f799c2 Update to PHPStan 0.12.0 2019-12-04 10:29:49 +00:00
ecb2e6e3af PluginManager: remove useless information from softDepend debug
we don't report the parameter type anywhere else, and since PHP doesn't support overloading, we don't need to.
This fixes PHPStan 0.12 complaints about ReflectionNamedType. I figured this was the best solution instead of adding an extra few lines of code.
2019-12-04 10:17:25 +00:00
7b75b6928d AvailableCommandsPacket: fixed foreach docs
these probably aren't necessary at all to be honest.
2019-12-04 10:15:50 +00:00
753a8a6937 Event: remove useless @var $this annotations
we are not in a trait here, the scope is always Event.
2019-12-04 10:15:04 +00:00
bc76b1cafe Server: remove several redundant @var annotations (copy pasta)
these are all useless because it is implied by the parameter type anyway.
2019-12-04 10:14:15 +00:00
00e415fc79 move phpstan.neon to phpstan.neon.dist to allow phpstan.neon to be locally modified for development 2019-12-03 19:57:19 +00:00
dbbe1f2d5c Revert "Entity: remove redundant check from spawnTo()"
This reverts commit 3028832cd3.

When I created this commit, I made the flawed assumption that spawnTo()
would not be used by plugins. In addition, I was not aware that there
are some usages of spawnTo() in the core which do not check for chunk
usage, such as in Player->showPlayer().

This caused a collection of problems including memory leaks and crashes
due to disconnecting players not removing their references from viewed
entities.

The reverted commit may be the cause of #3178.
2019-12-03 10:41:13 +00:00
ce27c03774 PlayerChatEvent: fixed crash when non-CommandSender permissibles subscribe to broadcast permission
doing such a thing doesn't make any sense, but the system allows it, so it has to be accounted for.
2019-12-01 21:44:13 +00:00
c4a8781b5c Fixed doc type inconsistencies surrounding chat broadcast handling (several problems that are all related) 2019-12-01 21:40:11 +00:00
dbab8b5733 Level: fixed type doc of tickRateTime field 2019-12-01 21:21:42 +00:00
2b08bbc7b1 Server: fixed type doc comment of nextTick field 2019-12-01 21:18:20 +00:00
17037f5e9c Chunk: clean up nonsensical code in initChunk()
I have no idea why the extra check was there, or why the null assignment was used, because it doesn't make any sense.
2019-12-01 21:14:23 +00:00
fee3c17148 CraftingManager: fixed type doc of craftingDataCache field 2019-12-01 21:06:34 +00:00
25e6cb74b3 Squid: fixed type doc comment of swimDirection field 2019-12-01 21:06:03 +00:00
8d2e59222e Entity: fixed not calculating surrounding blocks on entity creation
it's unclear if this was actually causing any bugs, but if it was it would likely manifest in the form of, for example, not burning in lava.
2019-12-01 21:05:36 +00:00
cd778661c2 Entity: fixed type doc comment for blocksAround field 2019-12-01 21:03:57 +00:00
c2afc05e7c Entity: fix type doc comment for static knownEntities field 2019-12-01 21:03:29 +00:00
9be95bf263 Block: return [] instead of null in getMetadata() (return type is non-nullable) 2019-12-01 21:02:49 +00:00
4b65e1cbe1 Command: fix type doc comment for commandMap field 2019-12-01 21:01:57 +00:00
5caae37768 Server: fixed return type doc comment for getCommandAliases() 2019-12-01 21:00:49 +00:00
92e1811b06 DataPacket: fixed bad null assignment to buffer in clean()
this is never expected to be null, so implicitly relies on PHP magic behaviour to convert it to string when appended.
2019-12-01 20:36:56 +00:00
293c2710d0 PlayerCreationEvent: fixed doc comments for baseClass and playerClass fields 2019-12-01 20:19:59 +00:00
8a7017fd6b Enchantment: fixed doc comment for static enchantments field 2019-12-01 20:16:45 +00:00
15f8886958 phpstan: separate non-PM bugs from the main neon config
everything left in here is now a PM problem that needs to be looked into.
2019-12-01 20:12:41 +00:00
3226a9dc6a phpstan: ignore more optional-leveldb errors 2019-12-01 19:52:49 +00:00
1a1e3ff63b BaseInventory: fixed incorrect & redundant default value for slots field 2019-12-01 19:45:16 +00:00
ea413d0882 phpstan: analyze on level 2, close #3193 2019-12-01 19:32:03 +00:00
0890b5fc99 AsyncPool: assert() that the unstacked task is actually an AsyncTask
it's possible that it might not be if the workers were accessed directly, but that shouldn't be possible.
This also silences a PHPStan warning on level 2.
2019-12-01 19:28:05 +00:00
163ed225f2 NetworkBinaryStream: fixed crash when non-compound root tag is provided for itemstack 2019-12-01 18:41:02 +00:00
a4a6d3e094 PlayerCreationEvent: fixed illegal doc comment types 2019-12-01 18:08:25 +00:00
ecbf3e9722 GamemodeCommand: fix CommandSender assignment causing troubles for type inference on static analyzers
this would never crash, but in strongly typed code it would be a compile failure.
2019-12-01 09:33:12 +00:00
47a959dace block: fix some possible crashes when plugins overwrite tile classes in bad ways
phpstan was complaining on level 2, and it's not wrong to ...
2019-12-01 09:29:22 +00:00
3968f85c82 sync composer dependencies 2019-12-01 08:54:48 +00:00
6d109bfc6f CraftingDataPacket: fixed not retaining cleanRecipes during decode 2019-11-30 21:15:37 +00:00
42d8357821 AvailableCommandsPacket: fixed missing decoded overloads with 0 arguments
these should be listed even if they have 0 arguments
2019-11-30 11:58:29 +00:00
f2ac63d235 update build/php submodule to pmmp/php-build-scripts@8308571448 2019-11-29 11:54:42 +00:00
3e4366b30d readme: add XLM since Keybase made it so easy
... and also gave lots of keybase users free XLM. Well played, Keybase, you managed to make me adopt Stellar.
2019-11-20 10:51:07 +00:00
314ce1d012 build/make-release: push after 5 seconds instead of 10 2019-11-11 16:41:50 +00:00
8d2e3894ef DataPacket: fixed var_dump() not showing private & protected subclass properties 2019-11-11 15:41:08 +00:00
025cb73bf5 update travis pthreads 2019-11-09 17:34:04 +00:00
2a6ffb5aa9 updated build/php submodule 2019-11-09 17:33:25 +00:00
932418b951 fixing some PHPStan complaints about bootstrap
this isn't an ideal fix, but it'll do.
2019-11-07 18:22:37 +00:00
95812252d6 NetworkBinaryStream: fix a mistake in doc for putEntityRuntimeId() 2019-11-07 18:22:37 +00:00
cac3c356a5 Painting: fix dropping multiple items when multiple blockupdates occur in the same tick
test case: place sand on top of a line of signs, put a painting on the sand and break the supporting sign
fixes #2774 for stable
2019-11-06 14:29:43 -05:00
c5d3e9be76 phpstan: silence leveldb noise
maybe there's a better way to do this, but I don't know it yet.
2019-11-05 20:21:36 +00:00
714f4dc023 fortify CI with PHPStan 2019-11-05 19:42:37 +00:00
a86bcd5110 travis.sh: don't redownload phpunit if it already locally exists 2019-11-05 19:39:04 +00:00
7ffc477d76 introduced baseline PHPStan configuration 2019-11-05 11:16:49 +00:00
4cb0b319c0 load some non-class constants with composer
this makes PHPStan happy and also makes working with PM code externally less of a pain in the ass.
2019-11-05 11:16:22 +00:00
5edff79f5f 3.9.8 is next 2019-10-28 16:07:35 +00:00
0c91d568b4 Release 3.9.7 2019-10-28 16:07:35 +00:00
35fabc7765 updated DevTools submodule to 1.13.5 2019-10-28 16:03:26 +00:00
b5a98a993f lazy-init RuntimeBlockMapping 2019-10-27 20:58:43 +00:00
0840ba8067 PocketMine.php: reduce unnecessary pocketmine\NAME dependencies 2019-10-26 21:37:15 +01:00
274cf58ccf PocketMine.php: remove useless ini_set() (this is a PHP_INI_SYSTEM directive which can't be changed at runtime) 2019-10-25 21:38:47 +01:00
1bce5d0bc2 PocketMine.php: move BaseClassLoader creation to where it's actually used 2019-10-25 21:26:22 +01:00
0d5d5e21a8 CommandReader: define $w and $e to make PHPStan happy 2019-10-25 16:11:02 +01:00
a145e18c1e CrashDump: use fully qualified reference for GIT_COMMIT constant
this makes it easier to filter out PHPStan noise.
2019-10-25 16:08:37 +01:00
d1ca779c1a fix PHPStan @throws incompatible warning 2019-10-25 15:49:47 +01:00
abbb8bbf55 travis.sh: allow latest phpunit v7 now that we have XML
not ready to move to v8 yet because of BC breaks
2019-10-24 13:37:24 +01:00
86c7870427 update build/php submodule 2019-10-24 13:28:27 +01:00
48080b7f90 PocketMine.php: define INT32_MASK earlier
this is non-dependent on any of the PM crap.
2019-10-24 09:23:37 +01:00
b216fb8910 PocketMine.php: set INI entries as early as possible 2019-10-24 09:18:50 +01:00
d3171d6a8e backport a53f698d38: PocketMine.php: remove useless set_time_limit() call
this is hardcoded to zero in the PHP core anyway.
2019-10-24 09:14:18 +01:00
c063a4da29 backport 5c1f1f00cb: move assert.exception to PocketMine.php with the other stuff 2019-10-24 09:12:05 +01:00
cc79dfa64c backport 8b40a8f217: PocketMine.php: move INI entry setting to a separate function 2019-10-24 09:09:53 +01:00
d6b9950901 backport fdfbaf4e95: make startup performance warnings a little more coherent 2019-10-24 09:06:28 +01:00
1815fe5b46 backport 647f86a5b8: PocketMine.php: remove redundant ini_set()
this is overridden later on by MemoryManager.
2019-10-24 09:02:37 +01:00
3e993250d8 backport 0c31b8731f: PocketMine.php: use main logger to emit force-kill debug 2019-10-24 08:57:31 +01:00
1163ac1d7a backport 0c31b8731f: PocketMine.php: get rid of redundant LOCK_FILE_PATH constant 2019-10-24 08:55:28 +01:00
9a51ba697a PocketMine.php: move some mission-critical stuff earlier in boot sequence
fixes #3161
2019-10-24 08:50:13 +01:00
32ad9d0c1a Squid: fix spammy rotation in enclosed spaces
this bug was caused by 2f3c77c68a. It looks unrelated to the commit title, so it may have been committed by mistake.
2019-10-22 22:50:35 +01:00
3d840e969d 3.9.7 is next 2019-10-22 14:38:02 +01:00
d1b70bd400 Release 3.9.6 2019-10-22 14:38:02 +01:00
29f002b32c LightUpdate: fixed type doc for updateNodes field 2019-10-22 12:23:42 +01:00
da17ade575 AvailableCommandsPacket: fixed wrong parameter type doc for putEnum() 2019-10-22 12:23:01 +01:00
f0c36f3413 ClientCacheMissResponsePacket: fix broken type assert in create()
ouch! PhpStorm never saw these...
2019-10-22 11:57:10 +01:00
77d8f133f1 LevelChunkPacket: fixed broken type assert in withCache() 2019-10-22 11:54:37 +01:00
43ebb23085 Permission: remove dead code from loadPermission() 2019-10-22 10:42:22 +01:00
e198c8fa8b Task: mark taskHandler field as nullable 2019-10-22 10:26:49 +01:00
cc3285c8fe Chest: fixed type doc of doubleChestInventory field 2019-10-22 10:25:24 +01:00
305c63ba4d MainLogger: initialize shutdown field in the conventional manner
this avoids uninitialized uses
2019-10-22 10:21:17 +01:00
acaa0e33b0 update DevTools submodule to pmmp/PocketMine-DevTools@3fadb2c3f4 2019-10-22 10:16:44 +01:00
f63857deed update build/php submodule to pmmp/php-build-scripts@1b3fe3120c 2019-10-22 10:15:29 +01:00
eda3d9b5e4 sync composer dependencies 2019-10-22 10:13:47 +01:00
c3872619cd Block: mark boundingBox as nullable 2019-10-22 10:07:27 +01:00
39cc590829 Skin: accommodate JSON geometry containing comments, closes #3121 2019-10-21 22:26:48 +01:00
f347345bb3 Human::getInventory(): explicitly declare return type
the lack of this causes type inference bugs and documentation problems.
thanks PHPStan
2019-10-21 15:25:57 +01:00
bb05cfb36c Shears: fixed always-false hardness check
thanks PHPStan
2019-10-21 15:21:22 +01:00
7d5c3c9b46 backport 4364d2a94: AvailableCommandsPacket: Clean up internals
this is still disgusting, but it's a little more bearable now.
2019-10-21 14:51:36 +01:00
cff2d37add backport ec0558597b: CommandParameter: change byte1 field to "flags" (#3115) 2019-10-21 10:03:59 +01:00
447477c5fb RegionLoader: Write location table changes when deleting chunks 2019-10-20 20:54:46 +01:00
abdbb2bf0e backport 3f6660027: RegionLoader: Extract location table validation to separate function 2019-10-20 20:53:47 +01:00
783c13926f backport f2404804d: RegionLoader: clean up lastSector handling 2019-10-20 20:48:29 +01:00
45329ddf67 backport 07a9c35ee: RegionLoader: Use objects instead of arrays 2019-10-20 20:42:55 +01:00
20af789963 backport 3e58708130: Add some missing @throws annotations 2019-10-20 20:23:51 +01:00
93cb9390e0 RegionLoader: backport 62185d476b 2019-10-20 19:59:02 +01:00
0aed7f86f5 Updated BossEventPacket comments (#3155)
* Updated BossBar comments

* Fixed comments
2019-10-20 19:23:07 +01:00
bf44bd016d TransferServerCommand: add missing boilerplate permission check 2019-10-20 14:28:53 +01:00
04e4a36653 LevelDB: remove unnecessary \pocketmine\NAME dependency
this is non-obvious and makes it a pain the ass to use outside of PM.
2019-10-17 18:56:51 +01:00
7439e1971d Server: stop spamming crashdumps on unsupported / corrupted worlds
really we should look into making the server stop if any world fails to load, but flooding the place with crashdumps isn't the way to do it.
This is a simplified version of cf73c7f5c1
2019-10-17 11:27:00 +01:00
b961b4e003 SetupWizard: use constant for default gamemode 2019-10-16 11:48:25 +01:00
d9eac8fc0a Server: fixed default difficulty being EASY instead of NORMAL 2019-10-16 11:45:30 +01:00
aeeee5eb53 Added encode/decode for StructureTemplateDataExport(Request|Response)Packet (#3145) 2019-10-14 11:14:42 +01:00
13994055d9 SetupWizard: disable spawn protection by default
we can't change anything else wrt. this on a patch version, disabling it in the main core by default involves possible behavioural breaks
2019-10-09 11:26:58 +01:00
247875e3d5 Explosion: add documentation for explodeA() and explodeB()
these functions really ought to be renamed, or possibly redesigned entirely. However, that's no task for a patch version.

[ci skip]
2019-10-07 09:44:17 +01:00
ee60a7bc36 Item: add documentation for addCreativeItem(), removeCreativeItem() and clearCreativeItems()
[ci skip]
2019-10-07 09:37:59 +01:00
348c2a599b Internet: report PM version in user agent
this is useful for statistics
2019-10-04 10:59:32 +01:00
562b47a1e5 Player: guard against repeated resource pack sequence
this can happen because of the client being super broken in 1.12
close #3036
2019-10-03 11:20:44 +01:00
4e060bc13f EventPacket: Added some new constants (#3132) 2019-10-02 13:37:05 +01:00
2807f14fcd 3.9.6 is next 2019-10-01 15:02:34 +01:00
f0539f4898 Release 3.9.5 2019-10-01 15:02:33 +01:00
63d7e7b811 Fixed decoding form responses with double commas inside quotes (#3131)
closes #3113
2019-10-01 14:28:55 +01:00
4da06078ed Server: promote Patreon on startup 2019-10-01 14:22:07 +01:00
8a6381c3fa StupidJsonDecodeTest: add some extra test vectors 2019-10-01 13:25:20 +01:00
d0d61597c7 StupidJsonDecodeTest: use getClosure() instead of traditional mess
this is faster and requires less code.
2019-09-26 11:28:40 +01:00
7a2a4e2aa3 change some heading sizes [ci skip] 2019-09-25 12:59:04 +01:00
e41a2c0792 Link to StackOverflow in README (#3084) 2019-09-23 11:56:37 +01:00
11a6e04a28 EnderPearl: remove collision box hack (this isn't needed for MCPE anyway)
This was intended to address the problem that ender pearls would not stop on grass, saplings, and other similar objects. However, they don't stop on such objects in MCPE anyway, only PC.
2019-09-18 10:02:52 +01:00
70b1ac856d ZippedResourcePack: fix mishandling of wrong root JSON type (crashdump #2840512) 2019-09-17 11:01:33 +01:00
d724374d1a StupidJsonDecodeTest: add failing test case for #3113 2019-09-16 15:53:00 +01:00
a19143cae7 3.9.5 is next 2019-08-16 17:58:02 +01:00
1be6783c34 Release 3.9.4 2019-08-16 17:58:01 +01:00
092edc9d43 avoid breaking concrete powder 2019-08-16 17:41:50 +01:00
2ba8eac27f FallingBlock: fix endless falling on top of fences
this is a shitty fix, but I don't think there's a better way to do it on 3.x. This also fixes dropping on cactus.
close #2449, close #2895
2019-08-16 17:27:41 +01:00
25ff90b2c6 PluginManager: fix chained softdepend plugins load order
Test case:
- plugin2 depends on nonexistent plugin1
- plugin3 depends on plugin2

At random occasions, plugin3 would be loaded before plugin2, because plugin2 load would be deferred in the expectation of plugin1 being loaded. This would result in the assumption that plugin3's softdepend plugins would not be loaded, so they were ignored.
We fix this problem by removing missing plugins from softdepend if they were not present on a scan of the directory. This way, we don't ignore any unresolved deferred dependency resolutions.
2019-08-16 16:46:59 +01:00
b912ae78bc Merge branch 'stable' of https://github.com/pmmp/PocketMine-MP into stable 2019-08-14 18:21:24 +01:00
677d43028a add php-build-scripts as a submodule 2019-08-14 18:08:26 +01:00
7bfb55ec9a Fixed some errors in support.yml (#3095)
[ci skip]
2019-08-13 14:09:03 +01:00
2f61d42518 backport d23eeff832: FallingBlock: remove useless check 2019-08-11 19:38:12 +01:00
dbb669b156 Entity: add some deprecation warnings to despawnFrom() and despawnFromAll() 2019-08-11 19:34:57 +01:00
4d0e8741fe Added a deprecation notice to Entity->getBlocksAround() 2019-08-11 19:32:21 +01:00
53dc6e2050 fix TallGrass and Tree random/base amounts never being initialized, closes #2996 2019-08-11 19:06:20 +01:00
807b860cfe protocol: fixup data type changes, closes #3072 2019-08-11 19:02:16 +01:00
d756500928 Also updated Discord link in suppor template and README 2019-08-08 00:03:10 +08:00
7ef27a1a21 support.yml Discord link should point to #rules 2019-08-07 14:54:01 +08:00
6b4d8b91c6 fix crashdump plugin detection
some things which were copy pasting PM classes into plugins were causing incorrect detection here. The path cleaning guarantees that all plugin paths will start with "plugins/", so we can use that to check instead.
2019-07-30 18:58:31 +01:00
8f5eb7ef37 Level: fix memory leak on scheduled blockupdate in unloaded chunk 2019-07-30 15:37:24 +01:00
0ea9a08963 3.9.4 is next 2019-07-29 17:27:21 +01:00
18a1bfe4dd Release 3.9.3 2019-07-29 17:27:21 +01:00
2d3562c687 World: fixed scheduled updates causing chunk loading
this probably needs to be backported.
2019-07-29 17:21:54 +01:00
cb40484a2e AsyncTask: Remove a bunch of reference-management drivel from documentation of storeLocal()
this works (mostly) the same way regular properties do, so the usual rules are implied.
2019-07-27 14:52:53 +01:00
e75a08a5a3 AsyncPool: ensure TLS is always cleaned on task removal, closes #3059 2019-07-27 14:39:40 +01:00
95dfff727e Wrap PocketMine.php body inside a function
this isolates variables from the global scope and also prevents doxygen documenting these variables.
2019-07-26 19:47:03 +01:00
d55889d85f AsyncTask: fixing docs 2019-07-26 19:41:45 +01:00
99f65f19ac BulkCurlTask: point to the right place in docs 2019-07-26 19:18:09 +01:00
581eeee01d fix rogue @package doc making doxygen choke 2019-07-26 19:15:02 +01:00
17341d7406 Load Mathjax from https to prevent unsafe scripts error (#3058) 2019-07-26 18:49:02 +01:00
04c0cd142d 3.9.3 is next 2019-07-22 17:28:33 +01:00
7a747d6f93 Release 3.9.2 2019-07-22 17:28:33 +01:00
e93d034a4e fix bucket empty sound position, close #3051 2019-07-22 17:17:15 +01:00
5a08a10448 update dependency requirements 2019-07-22 17:15:18 +01:00
622f93df45 remove usages of deprecated {} string access, closes #3035 2019-07-22 16:39:33 +01:00
b788982d60 Item: fixed setCustomName() not removing display NBT tag with empty name (#3049) 2019-07-19 20:07:53 +01:00
26faf4a952 Player: fixed sendTranslation() passing parent parameters to translate parameters 2019-07-19 18:15:35 +01:00
670bf2b9d1 doxygen: sort more things, for our sanity (#3045) 2019-07-19 10:52:32 +01:00
f5491346ce doxygen: set HIDE_IN_BODY_DOCS = yes (#3044)
fixes #3043
2019-07-19 10:34:41 +01:00
73d3f9f7f7 Fix loadbefore sometimes not working (#3040)
loadbefore operates by injecting self into the target plugin's soft-dependencies. The problem is that these soft-dependency lists are overwritten if the target plugin's soft-dependencies are resolved after the loadbefore of the origin plugin.
2019-07-17 16:52:29 +01:00
d874be99a6 PrimedTNT: fix explosion position, close #3037 2019-07-16 13:55:31 +01:00
1767cbe80d Player: Lower moved-too-fast warning and illegal-move warning to debug
many users have complained that this spams their consoles and they can't turn it off.
2019-07-16 13:51:38 +01:00
64fbf5025a 3.9.2 is next 2019-07-14 19:10:29 +01:00
aaa01bb6f8 Release 3.9.1 2019-07-14 19:10:29 +01:00
50d71809e1 Entity: fixed onfire flag being set when setting fire ticks to zero, closes #3031 2019-07-14 19:03:06 +01:00
6839712394 added new PlayerActionPacket constant, silence debug noise every time a player clicks a block 2019-07-14 17:30:37 +01:00
9b5ae7ec75 regenerate LevelSoundEventPacket sound IDs 2019-07-14 17:28:29 +01:00
94eb64c2be 1.12: fix resource packs, closes #3023 2019-07-14 17:22:44 +01:00
3fae57508b update particle ids 2019-07-13 20:08:17 +01:00
a883c35fd0 clean up yesterday's mess 2019-07-13 18:15:14 +01:00
740398282f [ci skip] added some detail about packet changes in 3.9.0 release 2019-07-13 15:35:00 +01:00
9d14bc54d6 3.9.1 is next 2019-07-12 19:03:24 +01:00
bd69c66d03 Release 3.9.0 2019-07-12 19:03:23 +01:00
c58a1bf9b7 Protocol changes for 1.12.0.28 2019-07-12 19:00:15 +01:00
59c310b914 unfuck the make-release script 2019-07-12 18:59:54 +01:00
790fcc4ebb Release 3.8.7 2019-07-12 18:20:47 +01:00
5430f19e7a make-release: allow specifying a version number explicitly 2019-07-12 18:18:26 +01:00
1cf4cf8614 Fixed decoding entries in SetScorePacket
closes #3000
2019-07-09 15:49:24 +01:00
55cccff850 Player: fixed documentation of isValidUserName()
[ci skip]
2019-07-07 23:50:59 +01:00
03e70e68f4 Player: fixed documentation of getDisplayName()
[ci skip]
2019-07-07 23:49:11 +01:00
7c52b4c93d make-release: added a missing newline 2019-07-07 18:02:25 +01:00
3f31dbde57 3.8.7 is next 2019-07-07 17:49:37 +01:00
1bfd6f2a90 Release 3.8.6 2019-07-07 17:49:37 +01:00
c7a5b8b0b4 Fixed noDamageTicks not preventing damage when last damage cause is null
noDamageTicks should make the entity completely invulnerable while active.
2019-07-07 17:37:52 +01:00
11fc16617a Liquid: fix max cost calculation for flow direction search, closes #2995 2019-07-07 14:32:52 +01:00
77a4393c7b Fixed possible out-of-bounds access on corrupted playerdata when loading inventory contents 2019-07-06 19:39:07 +01:00
f714ed6e90 Generator: fixed incorrect negative seed parsing in convertSeed() 2019-07-05 19:20:21 +01:00
7fc45bc5c3 partial fix for #2986 2019-07-04 18:18:42 +01:00
ab4b1be363 add constants for boat action of AnimatePacket
closes #2991
2019-07-03 16:30:45 +01:00
3c7f68dc1e Fix Entity::isNameTagAlwaysVisible() was returning the wrong value (#2990)
* Fix Entity::isNameTagAlwaysVisible() was returning the wrong value

* "> 0" to "=== 1"
2019-07-02 10:44:41 +01:00
15fa1056b7 added make-release script 2019-06-25 18:03:48 +01:00
feac2df088 readme: point to /plugins on poggit
[ci skip]
2019-06-25 13:11:36 +01:00
4c2015fd0f Update README.md
[ci skip]
2019-06-25 10:48:11 +01:00
16482e6a95 Update README.md
[ci skip]
2019-06-25 10:46:44 +01:00
ae9115ad0d 3.8.6 is next 2019-06-24 14:55:38 +01:00
6b090d653c Release 3.8.5 2019-06-24 14:55:38 +01:00
012f015e7d [ci skip] update changelog md for 3.8.5 2019-06-24 14:25:47 +01:00
6925451f3f StartGamePacket: added rogue field
this was added after 1.11.0 without a protocol version bump.
2019-06-22 20:25:50 +01:00
46054803d5 [ci skip] tinkering with readme logo alignment 2019-06-19 14:04:30 +01:00
a9f99240b5 readme: even less noise [ci skip] 2019-06-19 13:57:20 +01:00
a16b44ea12 readme: reduce useless noise [ci skip] 2019-06-19 13:51:16 +01:00
cd48d8272c added changelog for 3.8.5 2019-06-16 17:17:21 +01:00
6d09460abc Merge branch 'changelogs' into stable 2019-06-16 17:12:57 +01:00
0ca07ad075 Fire QueryRegenerateEvent every 1 second instead of every 25, fixes #2670 2019-06-16 16:17:06 +01:00
60b183b0d9 backport a753c1342: Clean up Query cache handling, remove useless timeouts
the timeout was entirely useless, because:
- when shorter than 25.6 seconds (512 ticks) it would cause caches to be needlessly destroyed and regenerated
- when longer than 25.6 seconds, just made outdated caches persist for longer, even after the query info was regenerated.

This now uses a mark-dirty model to deal with caches, which means that plugin modifications to the query data will be reflected immediately, regardless of when they are made. Previously, modifying the result of Server->getQueryInformation() would have inconsistent results.
2019-06-16 16:08:27 +01:00
dbf4054b1f backport 209135492: UUID: add type docs 2019-06-16 14:44:13 +01:00
82e4ef6d48 backport d8c81c0a1: UUID: remove useless default values
these are overwritten by the constructor, so they have no use here.
2019-06-16 14:43:28 +01:00
d0d300a6f8 backport 342b48b75: VersionString: Use the correct bitwise operators 2019-06-16 14:21:02 +01:00
6161155660 CraftingManager: micro optimization: reuse closure for item deserialize & reduce indirection 2019-06-16 14:05:37 +01:00
2a5561fcd1 added more MultiRecipe UUIDs 2019-06-15 19:51:59 +01:00
5d531b56db travis.sh: lock down PHPUnit at 7.5.11
7.5.12 makes changes which assume libxml is present, which isn't the case with our PHP builds.
2019-06-14 16:58:56 +01:00
3568c7b1c7 Merge branch 'stable' of https://github.com/pmmp/PocketMine-MP into stable 2019-06-13 16:05:18 +01:00
862c844759 Write PID into lock file 2019-06-13 15:11:59 +01:00
42954c1d72 Server: document the crazy behaviour of some innocent looking functions 2019-06-12 10:14:29 +01:00
4c5f6eb1b7 Moved preprocessor submodule to build/ directory 2019-06-11 17:56:13 +01:00
02bc43b440 missed a bit 2019-06-11 16:48:24 +01:00
5832f42783 added changelogs as mdfiles 2019-06-11 16:44:05 +01:00
7c1f038f20 3.8.5 is next 2019-06-10 17:56:23 +01:00
a42f68d3cf Release 3.8.4 2019-06-10 17:55:50 +01:00
b6f3f6120b InventoryTransaction: Shuffle actions on execution to prevent plugins relying on the order
closes #2955
2019-06-10 17:24:16 +01:00
96d3f4f78b Updated documentation for transaction classes 2019-06-10 17:19:03 +01:00
6756203aec InventoryTransaction: Added a warning about ordering 2019-06-10 16:54:45 +01:00
adb78679c5 Added link to docker image 2019-06-09 18:47:04 +08:00
b60731607d Update travis.sh 2019-06-06 17:20:16 +01:00
0058bfcd23 Utils: Limit length of printed stack trace strings to 80 characters 2019-06-06 14:56:19 +01:00
9f31b479e1 Improve stack trace rendering, show array and string lengths 2019-06-06 14:53:50 +01:00
eb161f8e1c Use base64 instead of hex to display binary in some places
base64 takes less space than hex, which is beneficial for logging larger payloads.
2019-06-06 14:43:20 +01:00
80f8a27094 Fixed implicit dependency on MobArmorEquipmentPacket field ordering
the order of the slots is entirely dependent on Mojang whims, so we shouldn't let our internals rely on it.
2019-06-04 18:16:56 +01:00
341c480e13 ContainerSetDataPacket: added missing furnace property ID 2019-06-03 18:21:29 +01:00
971ad04299 Attribute: add more things
i got tired of commenting out exceptions in packets, so this is the quickest way to fix the problem.
2019-06-03 17:37:18 +01:00
025b72e2f2 Randomize the order of plugins retrieved from disk, fixes #2945 (#2948)
On most filesystems, plugins are loaded in lexical order because that's how the filesystem gives the files to us. This is a problem because it can hide bugs with dependency resolution on specific platforms with this behaviour, while inexplicably breaking on other platforms where the load order is different or undefined.

This change prevents plugins depending on any file yield order by randomizing the order in which plugin files are checked for loadability.
2019-05-31 17:11:20 +01:00
cf538afb84 LevelEventPacket: added two extra IDs 2019-05-31 15:31:03 +01:00
7ff91337ad 3.8.4 is next 2019-05-27 19:01:06 +01:00
63e5867727 Release 3.8.3 2019-05-27 18:59:56 +01:00
c38779f1fd Block: fixed use of full meta as variant in several cases
fixes #2940

now I need to go to the bathroom and wash this off my hands ... I'd forgotten how nasty this code is
2019-05-27 18:04:25 +01:00
14bae72dd5 Create FUNDING.yml 2019-05-27 14:14:09 +01:00
f35b43613d IronTrapdoor: fixed fuel time, closes #2914
this should be removed during branch merge.
2019-05-24 17:31:36 +01:00
3d0fa10437 Stonecutter: fix hardness, close #2915 2019-05-24 17:30:20 +01:00
76e5ea385b Skin: improved error checking
plugin devs should find this less of a pain in the ass now.
2019-05-17 17:40:27 +01:00
5a351d3caf Fix for Server::hasOfflinePlayerData (#2919) 2019-05-12 12:06:05 +01:00
bb93d4f8de TimeCommand: Fix commands.time.query message (#2917) 2019-05-12 09:21:39 +01:00
66818e178a DefaultPermissions: Fix typos in permission descriptions (#2918) 2019-05-12 09:20:45 +01:00
f782a478c4 Player: clarify resetTitles() documentation 2019-05-08 17:03:40 +01:00
c06b4830d1 Player: don't spawn entities on out-of-sync chunks on join, closes #2911 2019-05-08 15:36:54 +01:00
6d64ef8d74 Server: fixed crash reporting bug introduced by a6e5b6e158 2019-05-05 20:52:52 +01:00
c5498bb3fa Implement a locking variable to circumvent a infinite regression (#2901)
closes #2876
2019-05-03 14:46:51 +01:00
59334d652f 3.8.3 is next 2019-05-02 17:13:50 +01:00
5c81da9b1e Release 3.8.2 2019-05-02 17:13:21 +01:00
b08affc4c6 Updated preprocessor submodule 2019-05-02 17:11:40 +01:00
cb49f1e835 fixed air being breakable by creative players
closes #2851
2019-05-02 16:25:23 +01:00
f6a0f4aa82 Player: fixed immobile interference on PlayerJoinEvent
closes #2894

this should use a cleaner hack that doesn't affect plugins at all, but that's too much work for this one bug fix.
2019-05-02 16:20:28 +01:00
de09c8c082 Player: fix crash handling resource pack requests 2019-05-02 16:17:39 +01:00
0ac87989dc Update RakLib to 0.12.4 2019-05-02 16:08:03 +01:00
13ea984b12 Server: setup world things at a more appropriate time
closes #2859

this also fixes reported headaches attempting to override generators before world load.
2019-05-02 15:02:10 +01:00
3878f58847 Level: fixed crash when time overflows
this can be triggered by a plugin setting time to PHP_INT_MAX

fixes CA 2346977
2019-05-02 14:22:01 +01:00
d7a35a5302 Entity: fixed motion not being initialized when Motion NBT tag is missing
fixes CA 2355485
2019-05-02 14:00:28 +01:00
d850a84d0d Level: clean up and remove checkTime() 2019-04-26 14:15:41 +01:00
22d9260a3b remove unused import 2019-04-26 13:56:32 +01:00
3c90ed13b9 NoteBlock: added //TODO 2019-04-26 12:45:08 +01:00
396efbac7e Human: simplify setFood() 2019-04-26 12:40:15 +01:00
00644dd529 Fixed an edge-case in AvailableCommandsPacket decoding 2019-04-26 12:32:42 +01:00
c2c210e25a Fixed --enable-ansi and --disable-ansi not being respected on threads
this causes some breakage to the behaviour of Terminal, and for that reason this is going on 4.0.

Terminal::hasFormattingCodes() will no longer auto-detect whether colour codes are supported.
2019-04-26 12:30:24 +01:00
86c4e936cb Player now drops the contents of temporary inventories
these inventories are just glorified crafting tables.
2019-04-26 12:27:52 +01:00
3b103dcd62 Level: use isInWorld() where appropriate 2019-04-26 12:26:01 +01:00
48dfc5b232 Level: reduce complexity of populateChunk() 2019-04-26 12:18:00 +01:00
39360f127a Player: Don't use iusername in cases where it's useless
these calls all do strtolower() anyway, so having iusername here just makes it confusing.
2019-04-26 12:07:47 +01:00
25890e76e2 Player: replace redundant usage of Server->broadcast() 2019-04-26 12:04:56 +01:00
810bdeb965 Test one extra case for LevelProviderManager 2019-04-26 12:01:12 +01:00
b6b3dcc1aa Improve documentation of SourceInterface and AdvancedSourceInterface 2019-04-26 11:59:10 +01:00
e0818e7e52 reorganize and optimize start.sh (#2267) 2019-04-26 11:54:50 +01:00
d0c4463773 3.8.2 is next 2019-04-26 10:08:59 +01:00
7521160f53 Release 3.8.1 2019-04-26 10:08:22 +01:00
4f5190e3f8 Updated BedrockData submodule 2019-04-25 20:53:08 +01:00
3c941dd992 Move more stuff to BedrockData submodule 2019-04-25 18:23:31 +01:00
89f457b397 updated legacy ID table (thanks @MCMrARM) 2019-04-25 17:49:10 +01:00
2bdbb9794c New, more efficient blockstate table format
this reduces the file size by ~90%.
2019-04-25 17:28:22 +01:00
898009a91b Sync crafting data changes
this seems to fix #2881, at least the reproducing case that was given.
2019-04-25 16:22:12 +01:00
793f93afdb NetworkSession: sync with latest code generation changes 2019-04-25 14:49:20 +01:00
64506ea3ae PacketPool: add @throws 2019-04-25 14:48:55 +01:00
4a35516441 Reduce BatchPacket hacks
we can't get rid of these hacks entirely because BAcKWARdS ComPaTIbilitY, but this at least ensures that things over PID 127 won't burn the house down when 1.12 gets here. This also reduces conflicts with 4.0 line.
2019-04-25 14:48:36 +01:00
74b9922a28 3.8.1 is next 2019-04-24 20:00:58 +01:00
088fbf65b1 Release 3.8.0 2019-04-24 19:54:57 +01:00
fa70127241 1.11.0 protocol changes 2019-04-24 19:54:16 +01:00
fc76d04dcb StartGamePacket: allow specifying a custom runtimeID table
this is not the intended goal, but it's a happy side effect of making it easier to extract structured information from the client.
2019-04-24 18:40:29 +01:00
15ae323bcb doxygen: updated config file 2019-04-23 17:58:24 +01:00
353bae87a7 3.7.4 is next 2019-04-23 17:14:49 +01:00
dc7be3fd52 Release 3.7.3 2019-04-23 17:13:04 +01:00
f28a0740a0 Move version info to its own file for easier third party tooling 2019-04-23 16:07:25 +01:00
df990fb47a disable C preprocessing (this will just cause unwanted bugs) 2019-04-23 15:43:39 +01:00
98ca28d96e add a warning when chunkutils is missing 2019-04-21 17:36:38 +01:00
db896b9faf ok i'm done
i am obviously not in any fit state to be doing this today...
2019-04-21 14:22:54 +01:00
76c234e4e6 add some limits on batches 2019-04-21 14:16:38 +01:00
2ef3962028 sync RakLib dependency 2019-04-21 13:24:19 +01:00
1e5941c98c Level: Properly report world save timings
this wasn't including chunk unloading in the world save timings.
2019-04-18 19:39:23 +01:00
9ca7c0c883 3.7.3 is next 2019-04-15 18:45:53 +01:00
b4a8f8391b Release 3.7.2 2019-04-15 18:45:16 +01:00
142d750b9f TextFormat: clean() now removes private-use area Unicode characters
the console can't print these, and these are being abused to cause mass crashes in the wild.
2019-04-15 18:42:09 +01:00
948b0b4cbc Add an API change request template 2019-04-15 08:49:31 +01:00
d6b596a8ac moar issue templates 2019-04-15 08:49:16 +01:00
eab2d4d704 Add a Support issue template
maybe this will guide people who don't read into shooting themselves in the foot automatically >:)
2019-04-15 08:49:01 +01:00
8114551600 add a Crash issue template
valid crashdumps are usually self explanatory and include all required information like OS/version/etc, so there's no need to force reporters to rewrite a bunch of extra information that should already be in the crashdump.
2019-04-15 08:48:45 +01:00
8e1d1993c5 Update support.yml 2019-04-15 08:48:31 +01:00
82bf5f6193 Add Discord link to issue template 2019-04-15 08:48:16 +01:00
76a86e51f7 Remove legacy issue template 2019-04-15 08:47:58 +01:00
d1e803685a Update issue templates 2019-04-15 08:47:42 +01:00
0a884aa5fb Support bot: Be a little less rude 2019-04-15 08:47:32 +01:00
c410e676b3 Update ISSUE_TEMPLATE.md 2019-04-15 08:47:18 +01:00
8f1f5fde47 Security vulnerability reporting for dummies 2019-04-15 08:46:59 +01:00
0f268df2e0 Add community Discord to Discussion section 2019-04-14 22:57:13 +01:00
86108e7010 Added donation methods 2019-04-14 22:57:00 +01:00
5ea448ef36 Add ExamplePlugin to README 2019-04-14 22:56:49 +01:00
389e7767d1 Sign: apply a very stupid limit on text size
this is necessary because of the epidemic of server attacks going around lately.
2019-04-14 19:30:28 +01:00
4c268acc00 Fixed /whitelist on/off permissions, closes #2849 2019-04-14 17:58:53 +01:00
e34a4f6b98 Added server.lock into .gitignore
closes #2868
2019-04-13 14:26:47 +01:00
3925e598d6 Acquire exclusive lock on <datadir>/server.lock to avoid data corruption (#2858)
this fixes #2855.
2019-04-08 20:31:24 +01:00
383ec8a8e3 TextFormat: Fixed tokenize() not being Unicode-aware 2019-04-08 15:45:26 +01:00
95313e0a90 Updated some entity metadata properties 2019-04-08 14:42:33 +01:00
e9a87978a6 Fixed usages of commands.generic.permission
apparently this doesn't exist in the client anymore
2019-04-07 15:07:24 +01:00
612e9e162c Fixed worlds with unknown generators silently getting wrong generator, closes #2860 2019-04-06 15:17:36 +01:00
fdc3faadc9 Register two missing default permissions
this fixes the pocketmine.command node not having the expected effect in some cases.
2019-04-05 18:48:37 +01:00
9644e72acf Doxygen: added index page 2019-04-05 09:35:25 +01:00
2c678dcf0d Player: Fixed memory leak when PlayerLoginEvent is cancelled 2019-04-03 17:37:15 +01:00
7bd9a2b2e0 3.7.2 is next 2019-03-30 19:15:17 +00:00
5c26deb517 Release 3.7.1 2019-03-29 19:56:06 +00:00
8fcb44de7d Merge branch '3.6' into 3.7 2019-03-29 19:55:36 +00:00
bd2e7db3b9 Release 3.6.6 2019-03-29 19:49:30 +00:00
f4480c07ee Updated NBT dependency 2019-03-29 19:47:15 +00:00
c09e2301c8 Merge branch '3.6' into 3.7 2019-03-29 14:35:35 +00:00
8e9f787d33 Implement runtimeID table randomization, closes #2841 2019-03-29 14:35:06 +00:00
89833b3b68 Merge branch '3.6' into 3.7 2019-03-26 15:01:59 +00:00
a10a656a5d Network: add a README to mcpe namespace 2019-03-26 15:01:00 +00:00
2659ed8d91 AvailableCommandsPacket: Updated the argument type constants for 1.10. (#2824) 2019-03-22 15:07:15 +00:00
9c01ecbe7e Merge branch '3.6' into 3.7 2019-03-21 19:02:20 +00:00
6a55021779 Flat: Allow asterisk in preset layers
closes #2818
2019-03-21 18:59:50 +00:00
6ada261b04 3.7.1 is next 2019-03-20 19:39:36 +00:00
14a6779e08 Release 3.7.0 2019-03-20 19:17:41 +00:00
cce99b07af 1.10.0 updates 2019-03-20 19:17:41 +00:00
c3d80d711d Fixed autosave time report measurement not using correct unit (as per master) 2019-03-20 19:01:10 +00:00
1a8b33dafe AvailableCommandsPacket: Updated the ARG_TYPE constants
closes #2817
2019-03-18 08:58:07 +00:00
baa094a2d1 3.6.6 is next 2019-03-10 11:49:31 +00:00
f2ff510597 Release 3.6.5 2019-03-10 11:49:06 +00:00
562179bdd6 Backport 58cafc853f: s/level/world (strings only)
we should look at doing this for code too, but for now I'm not planning to break everyone's plugins.
2019-03-10 11:35:46 +00:00
5c12bee874 Backport other part of 2bffd5cc1c: Add timer measurements for autosave 2019-03-10 11:20:51 +00:00
99606bbe23 beware possible API break 2019-03-09 19:33:46 +00:00
a1d50de12e OOF 2019-03-09 19:31:13 +00:00
4252c5914b Backport 93cd00ae8f: Remove dead settings from pocketmine.yml 2019-03-09 19:21:39 +00:00
0659d2fbef Backport 6bd43a8215: Firehose auto-tick-rate anti-feature, closes #2665 2019-03-09 19:20:53 +00:00
10612acace Partial backport of 2bffd5cc1c to 3.6 2019-03-09 19:10:09 +00:00
1d810f8aeb Backport c3e66e0adc to 3.6 2019-03-09 19:09:05 +00:00
414104851a LevelDB: Mark chunks as changed when upgraded from an older chunk format 2019-03-09 19:02:34 +00:00
c0bed03a2a Update PlayerRespawnEvent.php (#2797)
removed obsolete comment
2019-03-05 16:28:58 +00:00
d25c84acff Fixed RegionLoader corrupting location table when too-large chunks are discovered
this was making the location table point to an offset that did not yet exist, which caused the region header consistency check to discard the region as corrupted the next time it was loaded.
2019-03-05 12:09:27 +00:00
55994e08db RegionLoader: make some error messages more detailed 2019-03-05 11:18:02 +00:00
6f5d4d6b80 RegionLoader: fixed handling of invalid chunk coordinates 2019-03-05 10:52:36 +00:00
df1ef7fe0c Improve RegionLoader tests 2019-03-05 10:51:44 +00:00
20a25a69df Force emission of output buffer contents on crash 2019-03-04 12:01:30 +00:00
faca610594 NetworkBinaryStream: remove dead field 2019-03-03 12:38:03 +00:00
91603dc2d6 3.6.5 is next 2019-03-03 11:50:10 +00:00
af90e18b18 Release 3.6.4 2019-03-03 11:49:07 +00:00
ab5b4d112b BaseInventory: fixed items with userdata stacking with items without userdata 2019-03-03 11:12:36 +00:00
a30b1fb6d5 Inventory: Add failing test case for itemstack NBT duplication 2019-03-03 11:11:33 +00:00
20b4723728 Player: fixed held slot being out of sync after dying, closes #2788
it appears this premature optimization dates back to the days when PlayerHotbarPacket was not useless.
2019-02-27 09:26:56 +00:00
d1ced0ffc6 Player: fixed XP not dropping on death 2019-02-27 09:22:52 +00:00
2164dbae67 Fixed reloaded arrows not despawning, closes #2781 2019-02-26 19:58:21 +00:00
6c92a2e88b Ladder: be more strict about resetting fall distance
closes #2790
2019-02-26 19:54:57 +00:00
97deadc59f PackedIce: fixed dropping without silk touch, closes #2789 2019-02-26 19:48:18 +00:00
0c3b136a8d Player: fixed removeWindow() sometimes removing GUI / crashing clients 2019-02-24 12:14:19 +00:00
79b7e08e60 Silence NetworkStackLatencyPacket spam from dev builds 2019-02-23 11:03:50 +00:00
2540dacdd7 PluginManager: fixed suffix split handling 2019-02-23 10:51:06 +00:00
f1078e3909 3.6.4 is next 2019-02-22 18:07:48 +00:00
2f43b054de Release 3.6.3 2019-02-22 18:07:00 +00:00
23b5d64535 Merge branch '3.5' into 3.6 2019-02-22 18:03:51 +00:00
9afa0e5483 Release 3.5.13 2019-02-22 17:56:44 +00:00
4eaea54b0e TaskScheduler: fixed wrong typehints
These methods never return null.
2019-02-22 17:47:28 +00:00
6b51bf4a80 Merge branch '3.5' into 3.6 2019-02-18 13:11:16 +00:00
cba8d86c4f Fixed Fire Aspect not working on TNT 2019-02-18 13:11:08 +00:00
2e834c8f5c Merge branch '3.5' into 3.6 2019-02-17 16:10:47 -05:00
f9873e9108 ItemFrame: fixed hardness 2019-02-17 16:10:21 -05:00
074baf7e1c Merge branch '3.5' into 3.6 2019-02-17 17:08:15 +00:00
2e0dd574e0 Set default health attribute value when changing max health, closes #2771 2019-02-17 17:06:32 +00:00
e16d8e31af Merge branch '3.5' into 3.6 2019-02-17 11:33:46 +00:00
3c93a57397 Entity: add a hack to prevent client-side movement when entity is not moving
this fixes #2227.
2019-02-17 11:33:34 +00:00
e2e927b328 3.6.3 is next 2019-02-14 17:17:18 +00:00
a8dab25201 Release 3.6.2 2019-02-14 17:15:19 +00:00
3de2b7969e Merge branch '3.5' into 3.6 2019-02-14 17:14:59 +00:00
8f486ea65d 3.5.13 is next 2019-02-14 17:14:34 +00:00
6b971b1761 Release 3.5.12 2019-02-14 16:55:44 +00:00
6f36fa504b TextFormat: make clean() less confusing, deduplicate some regex 2019-02-14 16:52:39 +00:00
8e73842a93 Player: work around 1.9 command casing crash bug, closes #2761 2019-02-14 16:17:17 +00:00
e71e18fc88 Merge branch '3.5' into 3.6 2019-02-14 16:02:30 +00:00
e1bacb5c6d Human: fixed hunger underflow when value is a fraction, closes #2761 2019-02-14 16:01:25 +00:00
44697e784a Sign: add validity checks on text encoding, scrub invalid UTF-8 on load
this works around a bug where corrupted text on preexisting signs can mess up the client. This also prevents corrupted text getting onto signs in the future by having them scrubbed and validated before applying them.
2019-02-14 15:16:51 +00:00
65529ff2ce Command: add @throws CommandException 2019-02-14 15:09:41 +00:00
c346c45d42 Use regex for command argument parsing, fixes #2266
moral of the story: don't abuse functions for things they weren't designed for... lol
2019-02-14 15:07:58 +00:00
c433fad0a7 another /u modifier 2019-02-14 13:50:56 +00:00
8fad5a6e30 TextFormat: use mb_scrub() in clean()
this redacts invalid characters to prevent them appearing in places that might break the client.
2019-02-13 20:01:36 +00:00
7a6f279825 TextFormat: fixed clean() not being unicode-aware 2019-02-13 17:06:44 +00:00
10b72c895d Merge branch '3.5' into 3.6 2019-02-13 14:53:00 +00:00
d520928888 Fixed startup time measurement, closes #2713, closes #2750 2019-02-13 14:50:52 +00:00
27767e7ddb Verify player name command input, closes #2729, closes #2749 2019-02-13 14:50:43 +00:00
243c12de7c EffectCommand: fix bounds check, closes #2055 2019-02-13 14:37:40 +00:00
372545e47e Merge branch '3.5' into 3.6 2019-02-12 16:56:53 +00:00
8913b48700 "Implement" info-update and reserved6 2019-02-12 16:56:12 +00:00
6ee4a0e090 Implement invisible bedrock to fix placement issues
I don't know why this wasn't done a long time ago, but here it is.
2019-02-12 16:41:23 +00:00
8bd8da4bc6 Merge branch '3.5' into 3.6 2019-02-10 17:15:48 +00:00
9ba4144a71 Server: remove useless gc_collect_cycles()
the server is shutting down at this point so who cares if there are cycles...
2019-02-10 17:15:41 +00:00
9da7c6af27 new metadata properties 2019-02-10 13:59:21 +00:00
109312284c 3.6.2 is next 2019-02-08 16:41:10 +00:00
51934614bc Release 3.6.1 2019-02-08 16:40:38 +00:00
9e89f65094 Fixed handling for some new blocks which slipped through the frontline 2019-02-08 16:38:17 +00:00
9562711b84 Updated BedrockData submodule to 1.9.0 2019-02-08 15:32:57 +00:00
30b49e0d22 Merge branch '3.5' into 3.6 2019-02-08 15:32:20 +00:00
a975868fc3 3.5.12 is next 2019-02-08 13:52:31 +00:00
b38b932845 Release 3.5.11 2019-02-08 13:52:09 +00:00
43cb19ebca Updated bedrockData submodule to 1.8.0 2019-02-08 13:51:41 +00:00
769cc91543 ItemFactory: fix crash when getting negative item IDs
these are now treated the same as any unknown item, and are now not possible to place.
2019-02-08 13:51:41 +00:00
278f37d3e0 3.6.1 is next 2019-02-07 22:07:31 +00:00
02a6ca84a9 Releass 3.6.0 2019-02-07 22:06:33 +00:00
b8703d5dff Protocol changes for 1.9.0 2019-02-07 21:56:42 +00:00
37c2d78731 3.5.11 is next 2019-02-07 20:47:05 +00:00
b7663e5815 Release 3.5.10 2019-02-07 20:46:27 +00:00
1d0ffa06f8 TallGrass: fixed placement on dirt, closes #2552 2019-02-07 16:55:25 +00:00
768cfe3953 Updated composer dependencies 2019-02-07 16:47:16 +00:00
2822465f33 Updated submodules 2019-02-07 16:20:45 +00:00
5da48f429f Fixed some remaining one-line field declarations, added type docs 2019-02-05 14:03:27 +00:00
dbd0d04549 fix wrong doc comments in Thread & Worker 2019-02-05 13:58:18 +00:00
0f92ec6d2a Level: Record a debug message when chunks are loaded without loaders 2019-02-03 16:24:10 +00:00
791b4d8ef3 SplashPotion: measure distance from eye height instead of base
this fixes effect durations being off (mostly), closes #2650
there are still some minor differences, but this is closer matching than the previous version.
2019-02-03 11:32:47 +00:00
0b7ff6f2e7 Level: properly mark some functions as @internal
this ensures these functions won't appear in the documentation.
2019-02-01 14:33:06 +00:00
af092b01e1 3.5.10 is next 2019-01-31 18:47:57 +00:00
d811217755 Release 3.5.9 2019-01-31 18:47:32 +00:00
d7f86f0240 Hack for client side regeneration (disable natural regeneration gamerule) (#2722) 2019-01-31 18:45:25 +00:00
5fe1d2e396 Level: fixed setChunk() bug introduced by eebd90ec42
Anyone who is using getChunkPlayers() should probably check that their code is actually doing what they think it's doing.
2019-01-31 18:28:42 +00:00
ddbb5363ef Block->getBreakTime() now throws InvalidArgumentException on items with bad efficiency values 2019-01-30 19:10:24 +00:00
d3704bfae4 3.5.9 is next 2019-01-30 12:49:46 +00:00
07f034d2da Release 3.5.8 2019-01-30 12:49:16 +00:00
331ae5498f Crash the generator when encountering invalid presets
this is a partial fix for #2717, but still not ideal because it'll spam whenever a chunk is attempted to be generated. However, fixing this properly requires potentially breaking API changes.
2019-01-30 12:29:04 +00:00
eebd90ec42 Level: fixed setChunk() leaking memory when not copying tiles/entities
closes #2719
2019-01-30 10:58:35 +00:00
8e47a40b4c Level: rename poorly-named parameter of setChunk()
this now has a mouthful of a name. I'd like to invert it, but I can't do that without silently breaking backwards compatibility, which is unacceptable.
2019-01-30 10:26:18 +00:00
0f9fdf6442 Fixed Cactus and Sugarcane growing through bad blocks
closes #2714
2019-01-29 17:32:48 +00:00
5364e4de68 Explosion: fix chest unpairing (root cause of #2701)
not ready to call this "fixed" yet because any chests that were already affected by the bug will still be affected. This change will prevent the creation of more broken chests like this.
2019-01-29 13:58:47 +00:00
1099e2044b SetupWizard: fixed user being able to avoid agreeing to license, closes #2703 2019-01-29 13:43:13 +00:00
80d48161d3 Crops: fixed consuming bonemeal on fully-grown crop, closes #2704 2019-01-29 13:41:02 +00:00
fbe8485696 Player: fixed falling causing starvation, closes #2708 2019-01-29 13:36:24 +00:00
a150f39b02 Fixed fall handling when flying, closes #2709 2019-01-29 13:28:43 +00:00
71d17c50d6 Fixed internal IP detection (#2711), closes #2702 2019-01-29 12:51:53 +00:00
3a18bdd6a0 Prevent block-picking unknown blocks 2019-01-28 17:45:48 +00:00
96857c65b6 Player: Fixed subscribing to broadcast permissions too early
Plugins would indirectly trigger permissible recalculation too early in the login sequence, which then caused their permissions to be recalculated and subscribing them to the broadcast permission far too early.
2019-01-27 15:08:08 +00:00
9826abd83e Stair: fixed crash if player is null 2019-01-26 16:59:03 +00:00
48c8c2a8c3 ItemFrame: address crashdump 2113950
thanks Mojang for designing this lovely system where so much undefined behaviour is able to take place :(
2019-01-26 16:58:25 +00:00
c83b7d9b69 Utils: fixed getNiceClosureName() not processing namespaced closures properly 2019-01-26 12:08:07 +00:00
c66dc7b273 Level: Optimize blockticking coordinate selection
generating 1 large bounded random costs the same as generating 4 small ones, so it makes more sense to do it like this instead.

Note that prior to 7.1 this code would not work due to it not handling 64-bit appropriately.
2019-01-25 19:43:16 +00:00
5bf7350ee5 Level: change some stupid var names 2019-01-25 17:10:44 +00:00
636cc1c199 Level: some mitigations for #2675
this reduces the performance impact by using smaller keys, which reduces the key distance for nearby blocks.
2019-01-25 13:17:33 +00:00
62b6405371 Use 2 space indents in YAML files
this is (mostly) a backport of #2593 to 3.5. Closes #2593.
2019-01-24 18:44:06 +00:00
9ecf23d3ee Fix some bugs in doxygen config 2019-01-24 11:26:48 +00:00
187f36fe38 ExperienceOrb: clean up some confusing code 2019-01-23 16:46:18 +00:00
dc89b48354 Human: Fixed XP drop amount to match vanilla
In vanilla it doesn't drop the exact number of points you collected. Rather, you lose a little for every level above 1 you had (1 level requires 7 points, later levels require +2 per level), and can recover at most 100 points. Hence, if you had 10 levels, you get back enough points to fill 5 levels and most of a 6th. 14-15 levels gets you the upper bound of about 7.5 levels.
2019-01-23 12:39:25 +00:00
e6d1c1dfbc Living: Get rid of delayed XP spawning, closes #2644
This is not identical to vanilla, but I don't care because it gets rid of edge cases and also makes it easier to integrate with EntityDeathEvent in the future.
2019-01-23 12:31:05 +00:00
5a8812b1dc 3.5.8 is next 2019-01-22 22:14:19 +00:00
4b8e4123af Release 3.5.7 2019-01-22 22:13:35 +00:00
45a4252c26 RCON: Explicitly specify connection backlog size, fixes #2685
I believe this is caused by a bug in the linux kernel, since it only impacts certain machines I tested (one, to be specific). Whatever the case, setting a max backlog size is prudent anyway, and fixes the problem.
2019-01-22 22:11:32 +00:00
feaaa925a7 Fixed a series of denial-of-service bugs in RCON
Packets with a too-short payload would either cause the RCON thread to hang until the client disconnected, or crash the RCON thread entirely.

commit 90bb1894d7f87645b806f5fc67d1b877bb963180
Author: Dylan K. Taylor <odigiman@gmail.com>
Date:   Tue Jan 22 18:15:46 2019 +0000

    fix some bugs in RCON
2019-01-22 22:05:15 +00:00
5221db1178 Updated BinaryUtils dependency 2019-01-22 17:22:11 +00:00
47321114eb login: allow 60 seconds clock drift on login JWT
can everyone please just use NTP already?
2019-01-20 15:51:29 +00:00
a27c9409f1 ExperienceOrb: fixed wrong condition 2019-01-20 12:30:24 +00:00
854f851525 ExperienceOrb: don't follow players in other worlds 2019-01-20 12:30:09 +00:00
9003b38be3 Fixed a wtf in Player->removeWindow() 2019-01-19 19:14:21 +00:00
a6a93f822f 3.5.7 is next 2019-01-19 17:48:16 +00:00
d4851a8f1f Release 3.5.6 2019-01-19 17:33:07 +00:00
480a513f30 Sign: fixed asserts on loading NBT, closes #2636 2019-01-19 16:42:22 +00:00
4fd3bee360 Entity: Address fireticks crashdumps
This will now throw an exception at the source instead of crashing when the entity is saved, which should put the blame on the correct plugin responsible for this.
This also includes magic method hacks to preserve backwards compatibility, since the fireTicks field is now protected.
2019-01-19 16:05:10 +00:00
41fd7545e3 RegionLoader: Account for unexpected EOF when reading chunks, closes #2676 2019-01-19 15:49:19 +00:00
82dddde159 Remove dead code in /time command handler 2019-01-19 15:15:04 +00:00
bc709efb77 Prevent stupidity with /enchant 2019-01-19 15:14:51 +00:00
cd98e6a23e Updated PreProcessor submodule 2019-01-19 13:57:17 +00:00
cb591a98f4 NetworkBinaryStream: Skip item NBT which is too large when encoded
Encoded tags larger than 32KB overflow the length field, so we can't send these over network. However, it's unreasonable to randomly throw this burden off onto users by crashing their servers, so the next best solution is to just not send the NBT. This is also not an ideal solution (books and the like with too-large tags won't work on the client side) but it's better than crashing the server or client due to a protocol bug. Mojang have confirmed this will be resolved by a future MCPE release, so we'll just work around this problem until then.
2019-01-16 21:50:43 +00:00
e9d1af0aee Fixed stack trace encoding bug in CrashDump
it was encoding the real (full) trace, instead of emitting the printable version.
2019-01-16 18:56:56 +00:00
0f545c410a Bow: Improve consistency with vanilla (JE at least), closes #2660
This change causes the existing test I did to now report ~55-60 blocks, which is much closer to parity with vanilla.
2019-01-15 14:42:41 +00:00
1c2ed0836f Sync composer dependencies 2019-01-15 10:26:33 +00:00
6cf30dc813 build 7.3 on travis 2019-01-11 23:54:44 +00:00
f7d9247d39 Server: Permit NULL value entries in pocketmine.yml worlds
this permits listing worlds to load as keys without values.
2019-01-10 19:30:37 +00:00
3380aa3ac2 Config: Assert only whitespace precedes .properties key, fixes #commented properties not being skipped 2019-01-07 12:25:05 +00:00
6a9cad8fb7 3.5.6 is next 2019-01-06 20:18:32 +00:00
c9e598cdb9 Release 3.5.5 2019-01-06 19:55:21 +00:00
a6e5b6e158 Log a debug message when not sending crash due to folder plugin 2019-01-06 19:52:20 +00:00
22a6b817d7 Distinguish between direct and indirect plugin crash involvement
If a plugin was involved in a crash, we can't safely blame it for the crash, since it might have innocently triggered a core bug. Furthermore, it's difficult to accurately detect plugin causing things like invalid argument crashes.
2019-01-06 18:07:29 +00:00
2cdf97b7b5 CrashDump: Scan full stack trace to determine plugin involvement 2019-01-06 18:07:29 +00:00
836cb67850 Server: don't abuse random_bytes() to generate integers 2019-01-06 17:22:31 +00:00
ab37df4484 Server: micro-optimization: avoid unnecessary array_shift()
it's much less expensive to just calculate the modulo of the current tick and 20, and overwrite past entries. The effect is the same. The only difference is that the arrays won't be ordered by time, but that doesn't matter anyway.
2019-01-06 01:08:56 +00:00
93969197f7 Enable status,gc,dumpmemory OOB
dumpmemory has been confined to console by default due to the hazards it poses to a running server.

closes #2528
2019-01-05 18:56:57 +00:00
946a1036f1 Drop warn-if-enabled for asserts
I don't know why this is optional when no other debug warnings are.
2019-01-05 18:49:15 +00:00
43410cdafb Server: warn on assertions !== -1, closes #2640 2019-01-05 18:47:29 +00:00
a99e15012c Backport no-ai hack to disable pre-spawn movement 2019-01-05 17:39:20 +00:00
b22a2ef914 Living: Despawn in endDeathAnimation()
this removes the necessity for the player to do this.
2019-01-05 12:46:11 +00:00
f7f7be896e Server: drop misleading config values 2019-01-05 11:12:09 +00:00
254281cd5e Ice: don't create water for creative players, fixes #2622 2019-01-05 09:26:35 +00:00
5dfceeea98 Fix typo in command.op.take permission description 2019-01-04 23:56:29 +00:00
4b9a142a5d Import global functions and constants for enhanced performance
This is better for performance because these then don't need to be reevaluated every time they are called.

When encountering an unqualified function or constant reference, PHP will first try to locate a symbol in the current namespace by that name, and then fall back to the global namespace.
This short-circuits the check, which has substantial performance effects in some cases - in particular, ord(), chr() and strlen() show ~1500x faster calls when they are fully qualified.

However, this doesn't mean that PM is getting a massive amount faster. In real world terms, this translates to about 10-15% performance improvement.
But before anyone gets excited, you should know that the CodeOptimizer in the PreProcessor repo has been applying fully-qualified symbol optimizations to Jenkins builds for years, which is one of the reasons why Jenkins builds have better performance than home-built or source installations.
We're choosing to do this for the sake of future SafePHP integration and also to be able to get rid of the buggy CodeOptimizer, so that phar and source are more consistent.
2019-01-04 20:43:15 +00:00
0bacf51729 Fix another swathe of number_format() truncation bugs 2019-01-04 19:39:51 +00:00
33f6b441d8 Fixed /gc truncating memory freed
wtf PHP?
2019-01-04 17:30:35 +00:00
11b59498d9 TakeItemEntityPacket: add missing decode, close #2633 2019-01-04 11:45:37 +00:00
d71a543d10 Fixed a bunch of things PHPStan finds unpalatable
close #2614, fix a bunch of docs bugs, fix sendCreativeContents() crash on Human holders, move some inline variable declarations
2019-01-04 00:23:09 +00:00
5e0c3333cf Player: catch more specific exceptions for transactions 2019-01-03 17:57:37 +00:00
0f941410f6 Use more appropriate exceptions in the protocol layer 2019-01-03 17:57:06 +00:00
504cc3bf8b AddEntityPacket: fix some bugs in legacy ID conversion handling 2019-01-03 17:00:16 +00:00
6bd1491b8b AsyncPool: Apply a cooldown to workers to cut down unnecessary GC lag spikes
Since 3.2 there have been some runtime performance issues related to garbage collection and dynamic AsyncWorker booting. This is partly because of GC being dumb about shutting down what it thinks are "unused" workers. A worker which has been idle for a single tick is considered the same as a worker which has been idle for hours. The result of this is that on active servers, workers would get shut down and then immediately restarted because of something like chunk sending. Since booting an async worker is frightfully expensive, this causes lag spikes, which is obviously bad.

This commit changes the GC mechanism to only shutdown workers which have not been used for the last 5 minutes.
2019-01-03 15:06:53 +00:00
658786f2f6 TitleCommand: fix off-by-one bug in "times" subcommand 2019-01-02 21:04:25 +00:00
d34f3f1af3 Add a terminal message for the crash strangler 2019-01-02 19:10:05 +00:00
8650c187f9 Entity: fixed mob head yaw 2019-01-02 15:04:56 +00:00
4b4820cf53 3.5.5 is next 2019-01-01 13:55:45 +00:00
d33acc4fd0 Release 3.5.4 2019-01-01 12:33:17 +00:00
f7de6eb59f Network: Deprecate some garbage
Deprecations on a patch version breaks release protocol, but I don't care at this point. Nobody should have been using this shit anyway.
2018-12-31 22:52:39 +00:00
75a0627bf2 Network: cut this catch-all bullshit out as well
If a network interface crashes, it should take out the whole server, not try to keep on ticking.
2018-12-31 22:40:13 +00:00
8752e363c9 EXCUSE ME, HOW DARE YOU NOT LOG NETWORK ERRORS?! 2018-12-31 22:33:56 +00:00
9ed1b5ca7f Event: More detailed errors for non-cancellable events 2018-12-31 21:29:22 +00:00
1cbb31f1db Player: Reintroduce permission checks for command hints
This was removed way back in 2016 because of an unidentified bug which caused permissible commands not to show up on the client. Back then, command parsing and validity checks were client-sided, and the client would simply not send the command at all if it didn't recognize it. Now, that problem is gone, so it doesn't matter as much if there are permission bugs which cause commands to be erroneously missing.
closes #2625
2018-12-31 19:35:59 +00:00
1393b4c4e2 Player: aDd a HacK foR CliEnt SidE rIghT cLicK SpaM BuG
this bug has existed for so long I forgot it was still here. People stopped pestering me to do something about it, and as a result I forgot to do anything about it.

This hack isn't perfect, but it filters out the worst of the noise. It has side effects for legitimate fast double-clicks, but I don't think anyone will be too bothered - just click more slowly.

This hack may also have negative side effects on poor connections where latency spikes are a problem, but there isn't really much that can be done about that.
2018-12-31 19:16:13 +00:00
2921c86b3c Torch: fixed crash on blockupdate with corrupted meta 2018-12-30 19:50:35 +00:00
9c3a929b65 3.5.4 is next 2018-12-30 19:04:47 +00:00
9abaa42cd7 Release 3.5.3 2018-12-30 18:44:16 +00:00
77b9feb3c0 Player: don't waste CPU time ordering chunks for non-moving players 2018-12-30 18:40:36 +00:00
e0e2e1775f Player: Fixed sluggish chunk updates when not moving
Always order chunks ASAP on chunk change, not just during the spawn sequence. This fixes the sluggishness observed in BlockSniper when doing async chunk modifications.
2018-12-30 17:32:38 +00:00
d2d65ce6cc Attribute: Fix exception messages, make them less useless 2018-12-30 13:44:30 +00:00
ff2e982f22 Updated BinaryUtils dependency 2018-12-30 12:44:08 +00:00
daf56e990b Get rid of some network-layer asserts
NEVER assert on user data. 🤦
2018-12-30 12:42:52 +00:00
3f5e83a322 Backport 23954c4cda to 3.5 branch 2018-12-29 16:39:56 +00:00
5ecc5ed7e0 Get rid of catch-all on chunk unload
god only knows what the fuck is going on in here that warrants this catch-all... so let's remove it and find out!
2018-12-29 16:37:59 +00:00
cd80ae00d4 Handle errors properly on chunk load
Only CorruptedChunkException and UnsupportedChunkFormatException are expected. Anything else should crash the server.
2018-12-29 16:37:10 +00:00
beb5d72299 RegionLoader: fix off-by-one bug with large chunks, closes #2615 2018-12-29 00:02:54 +00:00
0eef634aab Player: Give me ALLLLL your crashdumps
I suspect this is going to cause a firestorm, but once it does we'll be able to see what needs fixing.
2018-12-28 19:30:05 +00:00
0ea166a551 Prevent placement of unknown blocks, closes #2260
I don't know why I ever allowed this in the first place... stupid idea...
2018-12-28 13:03:34 +00:00
6417cff618 Fixed resource packs with comments in manifest
MOJANG, THERE'S NO SUCH THING AS COMMENTS IN STANDARD JSON
2018-12-27 15:50:51 +00:00
a71af952ba Sign: simplify network data reading, ensure text is always 4 lines, closes #2610 2018-12-26 22:57:42 +00:00
93dd05a03e Fixed ender chest sounds, closes #2611 2018-12-26 22:33:51 +00:00
98f903783c Chest: remove pairx and pairz on blockpick, fixes #2612 2018-12-26 22:26:17 +00:00
5d47ea4337 Merge branch 'release/3.4' into release/3.5 2018-12-23 14:04:13 +00:00
c242d6213a Rewrite documentation for PlayerPreLogin, PlayerLogin and PlayerJoin events
this is some of the most awful documentation I've ever seen. No documentation would have been better.
2018-12-23 14:03:19 +00:00
4ad1093fd7 3.5.3 is next 2018-12-22 17:36:29 +00:00
fc0782df02 Release 3.5.2 2018-12-22 17:29:31 +00:00
bfaa224f6b Merge branch 'release/3.4' into release/3.5 2018-12-22 17:29:11 +00:00
de88f0fce1 3.4.4 is next 2018-12-22 17:28:47 +00:00
9b078854c4 Release 3.4.3 2018-12-22 17:17:24 +00:00
42f8e061a5 Merge branch 'release/3.4' into release/3.5 2018-12-22 13:29:41 +00:00
1455c38dbe Utils: fixed crash in getCoreCount(), closes #2600
this should just default to 2 instead of shitting its pants.
2018-12-22 13:27:11 +00:00
75df6973df LevelDB: Account for 2D maps tag being missing
I don't know why this would be missing, but in some cases it is, as seen in the crash archive. Whatever the case, we shouldn't be shitting the bed because of this.
2018-12-22 13:13:14 +00:00
4763360e9e Update BinaryUtils dependency 2018-12-22 13:07:45 +00:00
0299191e64 Attribute: fit value when resetting to default, closes #2599 2018-12-22 11:44:36 +00:00
2664a1b4d8 Merge branch 'release/3.4' into release/3.5 2018-12-21 18:39:42 +00:00
4249c00c3e Level: Fixed generation/send race condition causing blocks to be missing on the client
this FINALLY fixes the remaining occurrences of half-trees.
2018-12-21 18:39:33 +00:00
517c4e5143 Merge branch 'release/3.4' into release/3.5 2018-12-21 17:26:32 +00:00
69c343bb9b Level: fix setChunk() deleting tiles when replacing a chunk with the same chunk
this can be desirable to trigger events related to chunks changing, such as chunk sending.
2018-12-21 17:24:08 +00:00
70df1579a8 Merge branch 'release/3.4' into release/3.5 2018-12-20 20:02:00 +00:00
ea9f9aa250 Update some non-critical protocol magic numbers 2018-12-20 19:59:42 +00:00
34a899e28b Clean up Utils error handling functions (internal) 2018-12-16 17:50:00 +00:00
b80868040e Utils: fixed getTrace() including itself in trace when no alt trace is given
it always seemed a little strange that crashdump trace would pop 4 frames when only 3 are written in the comment...
2018-12-16 17:15:16 +00:00
a7f1181335 Merge branch 'release/3.4' into release/3.5 2018-12-16 14:13:19 +00:00
bf8a8b386e Allow ~relative coordinates to work in /particle 2018-12-16 14:12:46 +00:00
4b518f2a58 Merge branch 'release/3.4' into release/3.5 2018-12-14 17:32:34 +00:00
60b1f0a6e9 Fixed burning TNT setting affected mobs on fire when exploding, closes #2561 2018-12-14 17:32:11 +00:00
5934399a0d 3.5.2 is next 2018-12-14 09:46:12 +00:00
b42132a7c3 Release 3.5.1 2018-12-14 09:45:47 +00:00
c05697f506 Merge branch 'release/3.4' into release/3.5 2018-12-14 09:39:21 +00:00
d4fe1b8ece 3.4.3 is next 2018-12-14 09:30:44 +00:00
9b2653fb6f Release 3.4.2 2018-12-14 09:30:14 +00:00
ed88684e71 Fixed invisible FloatingTextParticle crashing the server, closes #2560 2018-12-14 09:30:14 +00:00
cbb9c4f298 Entity: require scale > 0 in setScale(), fixes #2563 2018-12-14 09:30:14 +00:00
660d42e8d1 Backport usage of SetLocalPlayerAsInitializedPacket to 3.4 (#2558)
This fixes various problems, such as forms not working on PlayerJoinEvent.
2018-12-13 20:07:17 +00:00
dbeceb02f9 fixup 1.8 crafting, take 2 2018-12-13 10:54:15 +00:00
fd77dd0066 Revert "Fixed crafting grid transaction handling, close #2559"
This reverts commit dfeb62491a.
2018-12-13 10:38:04 +00:00
87ce87112b Merge branch 'release/3.4' into release/3.5 2018-12-13 09:56:21 +00:00
1d71f5edb3 DataPacket: more detail in error messages for undefined fields 2018-12-13 09:55:50 +00:00
0f620157e8 3.5.1 is next 2018-12-12 19:20:40 +00:00
2323601f98 Release 3.5.0 2018-12-12 19:03:07 +00:00
d34b94302f fixed lava fizz sound 2018-12-12 18:00:43 +00:00
ec4c61e113 fix extradata defaults for broadcastLevelSoundEvent
fixes TNT sounds not working, amongst other things
2018-12-12 17:42:52 +00:00
231e491bb9 Fixed black spawn eggs 2018-12-12 17:14:13 +00:00
69cdc6f13a Remove misleading default value for NetworkInventoryAction windowId 2018-12-12 16:08:47 +00:00
dfeb62491a Fixed crafting grid transaction handling, close #2559 2018-12-12 15:41:54 +00:00
178eedb536 Merge branch 'release/3.4' into release/3.5 2018-12-12 10:12:12 +00:00
4975da2aae NetworkInventoryAction: additional validity checks 2018-12-12 10:11:44 +00:00
5946ec8819 fix inventory bug, silence debug spam, shut the fuck up MCPE 2018-12-11 21:57:07 +00:00
abf0dee426 bump version 2018-12-11 21:07:56 +00:00
30f5a8fac6 Protocol changes for 1.8.0 release 2018-12-11 21:05:03 +00:00
f704061618 Tree: fixed being able to overwrite other trees
this was observable by planting a sapling underneath an existing tree and punching it with bone meal.

This change will also prevent trees generating too close together.
2018-12-09 19:26:48 +00:00
23dc6e09d8 Sync DevTools submodule 2018-12-09 15:34:06 +00:00
15b7fc978e 3.4.2 is next 2018-12-08 17:00:36 +00:00
bb396174ba Release 3.4.1 2018-12-08 17:00:07 +00:00
dcef3cba21 CrashDump: cleanup some version related stuff
this should have been done a long time ago, but we didn't want to cause compatibility problems with CA. Now it enforces version checks, this isn't a problem anymore.
2018-12-08 16:58:06 +00:00
5f8a9f8747 Add a new format_version field to crashdumps
this will be used in the future to allow CA to decide how to decode crashdumps and/or refuse crashdumps from incompatible versions.
2018-12-08 16:57:57 +00:00
84e41e6967 3.4.1 is next 2018-12-06 21:01:57 +00:00
5e0e0daf7d Release 3.4.0 2018-12-06 20:45:57 +00:00
a95694ed06 Add signature validation for some user-defined callbacks 2018-12-04 18:33:58 +00:00
762405d16a Add daverandom/callback-validator as a dependency 2018-12-04 17:14:37 +00:00
e3f46987f5 Liquid: Add events to allow controlling flow and fusion (#2547) 2018-12-04 13:14:22 +00:00
e4223bb7dc Level: Duct tape fix for crashy trees at the top of the world
this doesn't fix shit but it at least doesn't crash. Fixing this properly can't be effectively done any other way without backwards compatibility breaks. Fortunately it's not common practice to grow trees at the top of the world.
2018-12-03 18:30:27 +00:00
f091446ec7 Sync NBT dependency 2018-12-03 16:15:02 +00:00
b0f891081c Mark EXHAUSTION as non-syncable
this attribute is not visible on the client and is only used for controlling saturation depletion. It's extremely spammy and as such really shouldn't be sent over network. This has also been causing some minor client-side performance issues in survival.
2018-12-02 16:43:00 +00:00
acd7c9b336 Permission: Throw exception on unknown values in getByName()
Previously, writing wrong values into plugin.yml for permission defaults would cause the permission to be silently denied to everyone.
2018-12-01 15:56:44 +00:00
75482124f2 Merge branch 'release/3.3' into release/3.4 2018-12-01 10:09:46 +00:00
288599cbe7 3.3.5 is next 2018-12-01 10:00:59 +00:00
aa7206126a Release 3.3.4 2018-12-01 10:00:38 +00:00
1a6db1c7ce DataPacket: add missing field
this must have been missing for how many years now? thanks @shoghicp

this is why we don't do releases on friday night... in my defence my device had the beta installed...
2018-12-01 09:29:53 +00:00
f1c071ce7f Release 3.3.3 2018-11-30 19:41:36 +00:00
e2f46a4358 Remove unused import... 2018-11-30 19:40:35 +00:00
36c0c350a7 Merge branch 'release/3.3' into release/3.4 2018-11-30 18:37:28 +00:00
4c08a05fae Barf on trying to read/write nonexisting fields of packets
this should make it easier to debug problems when content of packets changes during protocol updates.
2018-11-30 18:36:28 +00:00
6295ef8a81 Add language option to server.properties (#2531)
This allows to save the language without rewriting pocketmine.yml. Since this is a "standard" config option (something that the user might want to directly modify) it's reasonable to put it in server.properties. pocketmine.yml is generally reserved for more advanced configuration options.
2018-11-30 13:25:04 +00:00
05dba61a69 Merge branch 'release/3.3' into release/3.4 2018-11-29 19:47:28 +00:00
b473ffdedc Remove async playerdata saving, closes #2515
this technically involves non-breaking API changes which should happen on a patch release, but I can't be bothered with the dust cleanup, so we'll just blow it away now. It doesn't hurt anyone anyway.
2018-11-29 19:47:15 +00:00
60dddcd12a Painting: clean up guard checks, remove unnecessary checks 2018-11-29 19:29:10 +00:00
c010ef45ed Merge branch 'release/3.3' into release/3.4 2018-11-29 18:46:00 +00:00
93c26a0b0c Living: Suspend effects ticking on death
This was the cause of a bug with regeneration which caused players taking fatal damage under regeneration not to die correctly. On the server side they would die and immediately regenerate some health, which would cause the next attribute sync to not report the health drop to zero, which made the client unaware that it was dead.

Perhaps attributes should be forcibly synced in some circumstances, but nonetheless regeneration shouldn't apply post-death.
2018-11-29 18:45:46 +00:00
08ec021f78 Merge branch 'release/3.3' into release/3.4 2018-11-26 14:02:32 +00:00
545ec9c881 Updated PreProcessor submodule 2018-11-26 14:02:23 +00:00
b0060caaf7 Config: don't catch-all in save() 2018-11-25 16:35:59 +00:00
c90d1faa81 Merge remote-tracking branch 'origin/release/3.3' into release/3.4 2018-11-25 14:35:45 +00:00
d5a1961e6b Force minimum uptime to be >= 120 seconds if a crash occurs (#2534)
This is an incremental improvement over 4a6841a5a4. This change works better because it also reduces disk spam of crashdumps.

This will now sleep if the server uptime was less than 120 seconds before crashing. If unattended, this will clamp down on automated crashdump spam. If attended, the user can simply press CTRL+C to abort the process and skip the delay.
2018-11-25 14:35:35 +00:00
449dda83fb Merge branch 'release/3.3' into release/3.4 2018-11-22 16:48:57 +00:00
6bc79149c3 SubChunk: Fixed $changed not getting set in setBlock() when only block data changed
it was comparing a string and an int. This now compares the integer values first.
2018-11-22 16:47:25 +00:00
cdf7e28251 shut up PhpStorm 2018-11-17 18:12:48 +00:00
a02f422d85 SubChunk: Fixed constant redefinition on worker threads when autoloading
this happens when workers inherit constants but not classes.
2018-11-17 16:29:53 +00:00
f8bfbc107d Reduce chunk memory usage by 20-60% by exploiting PHP copy-on-write behaviour (#2527)
This takes advantage of two key behaviours of PHP:
1. Assigning a string does not copy the string
2. Changing an offset in a string causes the string to be copied.

These two factors combined, along with the fact that blocklight and skylight arrays are usually all-zeros, allow us to produce a significant memory usage reduction of loaded chunks.
A freshly generated PM world with 3,332 chunks loaded drops from 310MB to 200MB memory usage with these changes applied.
2018-11-17 14:46:05 +00:00
554c029fbd Merge branch 'release/3.3' into release/3.4 2018-11-13 18:24:08 +00:00
e018311e73 Make start script errors a bit more noob-friendly 2018-11-13 18:23:54 +00:00
de50f02076 Merge branch 'release/3.3' into release/3.4 2018-11-12 22:07:22 +00:00
71d02e5870 Improve dev build error messages 2018-11-12 22:07:14 +00:00
46d9475568 Use Utils::getNiceClosureName() in PluginManager 2018-11-11 19:50:07 +00:00
788b278fc3 Utils: fixed handling of non-anonymous closure functions 2018-11-11 19:43:00 +00:00
2e4143f57e Merge branch 'release/3.3' into release/3.4 2018-11-11 12:38:53 +00:00
d312aef1ac 3.3.3 is next 2018-11-11 11:58:51 +00:00
200de3fe84 Release 3.3.2 2018-11-11 11:58:25 +00:00
f560a6efea Merge tag '3.2.7' into release/3.3 2018-11-11 11:24:23 +00:00
7ecd7fd13f Release 3.2.7 2018-11-11 11:23:20 +00:00
5284ad0346 Merge branch 'release/3.3' into release/3.4 2018-11-11 11:15:46 +00:00
b893645a81 Merge branch 'release/3.2' into release/3.3 2018-11-11 11:15:39 +00:00
b19b3134ad PluginManager: reduce unnecessary indentation 2018-11-11 11:15:27 +00:00
7cf36f460b Merge branch 'release/3.3' into release/3.4 2018-11-10 22:37:08 +00:00
243f86b0a0 Merge branch 'release/3.2' into release/3.3 2018-11-10 22:37:02 +00:00
9156cbc269 PluginManager: Make registerEvents() check order more logical
Prioritize validating that the function is actually a handler, before trying to parse its doc comment.
2018-11-10 22:36:46 +00:00
a5f776af2f Merge branch 'release/3.3' into release/3.4 2018-11-07 22:11:13 +00:00
43fe6a1934 Merge branch 'release/3.2' into release/3.3 2018-11-07 20:02:28 +00:00
342a74ffcb Level: Collect garbage from chunk internals in doChunkGarbageCollection() 2018-11-07 20:01:07 +00:00
3d2701e775 Merge branch 'release/3.3' into release/3.4 2018-11-04 23:32:56 +00:00
2183bf875c Merge remote-tracking branch 'origin/release/3.2' into release/3.3 2018-11-04 23:32:33 +00:00
8cc2a4ce5d Remove start script support for source-code installations (#2495)
This was suggested recently by @TheDeibo. We don't want users running source-code installations unless they are developers, and developers should know how to boot a source-code installation anyway.
2018-11-04 23:31:57 +00:00
e26af3fa1b TaskScheduler: don't catch unexpected exceptions
this means that errors in scheduled tasks which are uncaught will now cause a server crash.
2018-11-04 23:22:30 +00:00
1634dd62e3 Don't catch unexpected exceptions during command execution 2018-11-04 23:11:51 +00:00
755db3dac8 Added a ClosureTask implementation for easier task scheduling (#2497) 2018-11-04 22:55:40 +00:00
3dabf90b0e Merge branch 'release/3.3' into release/3.4 2018-11-04 22:38:58 +00:00
f61e14e341 Merge branch 'release/3.2' into release/3.3 2018-11-04 22:38:45 +00:00
7b24fbc8db Utils: fix a mistake in getNiceClassName() doc 2018-11-04 22:38:38 +00:00
0543c17849 Merge branch 'release/3.3' into release/3.4 2018-11-04 22:15:46 +00:00
c4f3426bae Merge branch 'release/3.2' into release/3.3 2018-11-04 22:15:21 +00:00
046c39b02e Remove some Throwable abuse in AsyncTasks 2018-11-04 22:15:06 +00:00
87b471ce0f AsyncPool: reverse e0d5c79848, don't catch unexpected exceptions thrown by onCompletion()
this should never throw an uncaught exception, and if it does it indicates broken code.
2018-11-04 22:09:30 +00:00
055ba6aa7c Merge branch 'release/3.3' into release/3.4 2018-11-04 11:57:35 +00:00
5c3eed40b3 Merge branch 'release/3.2' into release/3.3 2018-11-04 11:57:28 +00:00
3e5237b6e0 ItemEntity: remove useless instanceof 2018-11-04 11:57:22 +00:00
af1227f154 Merge branch 'release/3.3' into release/3.4 2018-11-03 19:43:54 +00:00
d9a867016c Merge branch 'release/3.2' into release/3.3 2018-11-03 19:43:45 +00:00
a50a863ab7 Chunk: be more intelligent about fast-serializing chunks
This reduces the amount of useless data that pthreads has to copy around.
2018-11-03 19:43:35 +00:00
9caf62778c AsyncTask: remove $serialize parameter from setResult()
Whether serialization is necessary can be determined automatically based on the type of variable.
2018-11-03 16:56:24 +00:00
d257d36e55 Merge branch 'release/3.3' into release/3.4 2018-11-03 15:14:27 +00:00
1b03168b88 Merge branch 'release/3.2' into release/3.3 2018-11-03 15:12:40 +00:00
6b9fee05d6 Fixed performance bug with chunk sending
this process of fast-serialization, fast-deserialize, network-serialize is an order of magnitude slower than just doing the network encode directly on the main thread, and also copies more useless data.

For the main thread, the figures were something like 3x more expensive, and then an extra 7x for deserialization on the worker thread. This is a ridiculously large overhead.
2018-11-03 15:12:30 +00:00
44d8a5528e Merge branch 'release/3.3' into release/3.4 2018-11-03 12:12:42 +00:00
45a18ffe1e Merge branch 'release/3.2' into release/3.3 2018-11-03 12:12:23 +00:00
f0182c9996 TaskHandler: remove incorrect internal warning
this is perfectly fine to use, and preferable to getting a cyclic ref to the scheduler. TaskScheduler->cancelTask() does pretty much the exact same thing, and the scheduler internals are designed to deal with this anyway.
2018-11-03 12:12:02 +00:00
265b61b3e6 Merge branch 'release/3.3' into release/3.4 2018-10-31 18:55:26 +00:00
2d88058710 Merge branch 'release/3.2' into release/3.3 2018-10-31 18:55:18 +00:00
ab48d85c35 Properly deal with anonymous tasks in timings 2018-10-31 18:51:30 +00:00
cf43f479df Server: cleanup setting up of console 2018-10-30 16:59:03 +00:00
c143834632 Merge branch 'release/3.3' into release/3.4 2018-10-30 15:43:06 +00:00
d9b7a28747 Merge branch 'release/3.2' into release/3.3 2018-10-30 15:42:52 +00:00
31ceafa111 Chest: keep inventory better in sync when paired
should fix #2502
2018-10-30 15:42:44 +00:00
a0eb6e23e5 Merge branch 'release/3.3' into release/3.4 2018-10-29 12:42:17 +00:00
694d7d4e20 Merge branch 'release/3.2' into release/3.3 2018-10-29 12:42:10 +00:00
2da2fdd6d4 Added a test for Item->equals() when both items have no NBT 2018-10-29 12:42:03 +00:00
0aa30295af Merge branch 'release/3.3' into release/3.4 2018-10-26 20:09:02 +01:00
c1c56f29bb Merge branch 'release/3.2' into release/3.3 2018-10-26 20:08:55 +01:00
9b820a0849 Guard against possible overflow bug in NetworkBinaryStream 2018-10-26 20:08:48 +01:00
c6a4bc4bf7 Merge branch 'release/3.3' into release/3.4 2018-10-25 19:36:44 +01:00
3128449033 3.3.2 is next 2018-10-25 19:36:20 +01:00
a60154e0b7 Release 3.3.1 2018-10-25 19:29:57 +01:00
4cbbf2e91c Merge branch 'release/3.2' into release/3.3 2018-10-25 19:29:34 +01:00
b0624aff9f 3.2.7 is next 2018-10-25 19:28:54 +01:00
c38e2c5ccb Release 3.2.6 2018-10-25 19:20:26 +01:00
02ef0bfbb4 Remove unnecessary quotes
these appear on the echoed message, which is undesirable.
2018-10-25 18:49:06 +01:00
a714612453 Merge branch 'release/3.3' into release/3.4 2018-10-25 18:42:09 +01:00
4835537886 Merge branch 'release/3.2' into release/3.3 2018-10-25 18:41:58 +01:00
4a6841a5a4 Added client side self rate-limiting for crashdump reporting
this should produce some reduction in spam at the source.

This could also be used to control the rate at which constantly-crashing servers restart to stop them spamming the disk as well, but the main concern here is eliminating crash archive involuntary DDoS by crashy servers.
2018-10-25 18:10:59 +01:00
f61e099828 Merge branch 'release/3.3' into release/3.4 2018-10-24 15:52:04 +01:00
925da62afa Merge branch 'release/3.2' into release/3.3 2018-10-24 15:49:09 +01:00
09985c5763 Fixed async light population producing garbage when generator isn't registered, closes #2488 2018-10-24 15:49:00 +01:00
447b9562bb Merge branch 'release/3.3' into release/3.4 2018-10-24 12:16:46 +01:00
d1ee9eb960 Merge branch 'release/3.2' into release/3.3 2018-10-24 12:00:55 +01:00
196cf8a68d Fixed missing MoveEntityDeltaPacket field 2018-10-24 12:00:25 +01:00
cac21c2caf SubChunk: implement branchless read/write for nibble arrays (#2489)
this was inspired by https://hub.spigotmc.org/stash/projects/SPIGOT/repos/spigot/browse/CraftBukkit-Patches/0121-Branchless-NibbleArray.patch
2018-10-22 17:46:14 +01:00
6dd2597934 Merge branch 'release/3.3' into release/3.4 2018-10-21 18:17:07 +01:00
5e68858ebf Merge branch 'release/3.2' into release/3.3 2018-10-21 18:16:59 +01:00
45c9caa38c Fixup some formatting issues 2018-10-21 18:15:25 +01:00
b35759cc25 Add /unban and /unban-ip as aliases of /pardon and /pardon-ip 2018-10-21 15:32:38 +01:00
2a40c0d82c Make use of isInLoadedTerrain() 2018-10-20 19:13:34 +01:00
8ac1b18b17 Level: add API method isInLoadedTerrain() 2018-10-20 19:09:53 +01:00
4aef9919dc Use newly added API method 2018-10-20 16:26:10 +01:00
43426a4c5c Level: Add API method getViewersForPosition()
This returns all players who have the given position within their view radius.
2018-10-20 16:25:56 +01:00
3028832cd3 Entity: remove redundant check from spawnTo()
this won't be reached if the player isn't using this chunk anyway.
2018-10-20 16:24:46 +01:00
9f8a2dc61a Make use of new API method getChunkAtPosition() 2018-10-20 15:58:29 +01:00
d9ebe6f321 Level: Added API method getChunkAtPosition()
This returns the chunk containing the given vector.
2018-10-20 15:54:13 +01:00
cb1eb1ee09 Level: Rename addGlobalPacket() to broadcastGlobalPacket()
this name makes the intention more clear and consistent with other functions.
2018-10-20 15:24:33 +01:00
d563b9e31b Level: Added API method broadcastPacketToViewers()
This supersedes addChunkPacket() in most cases, and has a more clear name. It broadcasts the given packet to every player who has the target position within their chunk load radius.
2018-10-20 15:14:41 +01:00
7c44eea625 Merge branch 'release/3.3' into release/3.4 2018-10-19 18:53:18 +01:00
d749f19c73 Merge branch 'release/3.2' into release/3.3 2018-10-19 18:53:12 +01:00
41fd03f329 LightUpdate: fixed double-updated nodes not getting light propagated appropriately
This can happen when a light source is removed and later encountering another light source to fill the gap. A higher light level may get set and then not propagated. This bug is difficult to explain, but fairly easy to reproduce.
2018-10-19 18:53:04 +01:00
646c8970b8 Merge branch 'release/3.3' into release/3.4 2018-10-19 15:56:01 +01:00
58067b2ad1 Merge branch 'release/3.2' into release/3.3 2018-10-19 15:55:53 +01:00
0c9946621c Level: Do not tick chunks which have unloaded adjacent chunks
Grass can cause issues here by requesting blocks randomly offset away from itself, which can cause silent chunk loading on chunk ticking. It also causes crashes if chunk autoloading is taken away, which is obviously undesired.

It was also noticed that player chunkloaders cause chunks to start getting ticked as soon as they load their first chunk, which is before the entity is visible to everyone else on the server. This is probably undesired behaviour.
2018-10-19 15:48:46 +01:00
f1cd6940f9 Merge branch 'release/3.3' into release/3.4 2018-10-16 22:56:46 +01:00
af5637e050 PlayerListEntry: remove dead fields 2018-10-16 22:56:21 +01:00
4221e274d6 Merge branch 'release/3.3' into release/3.4 2018-10-16 18:20:14 +01:00
a524b0e447 3.3.1 is next 2018-10-16 18:19:49 +01:00
88a5e92c20 Release 3.3.0 2018-10-16 17:47:35 +01:00
b876ae4ef8 Merge branch 'release/3.2' into release/3.3 2018-10-16 17:26:46 +01:00
1983964f9e 3.2.6 is next 2018-10-16 17:26:04 +01:00
c4c55a45c9 Release 3.2.5 2018-10-16 17:17:53 +01:00
c5cd813b76 bump PM version 2018-10-16 17:15:49 +01:00
bc2dff3f51 version numbers 2018-10-16 17:15:26 +01:00
839d5eab7b Protocol changes for 1.7
there's also some new cases in stats, but we don't care about those anyway.
2018-10-16 17:13:52 +01:00
cd506bb443 shuffle back to 3.4 to make space for new MCPE release 2018-10-16 17:11:46 +01:00
4c8ffce86f Merge branch 'release/3.2' into release/3.3 2018-10-16 16:46:39 +01:00
78923177f9 VersionString: use appropriate regex for number matching 2018-10-16 16:46:27 +01:00
df6bb2ea0e Merge branch 'release/3.2' into release/3.3 2018-10-16 09:51:19 +01:00
b7062e7bff CrashDump: don't try to report code that doesn't exist
this can happen when eval() is used, and then we get a big blank mess with nothing on it. eval() is a special case that should be handled separately, but for now this is just fixing a bug.
2018-10-16 09:50:59 +01:00
ba68192206 Fixed bad event handlers (whose errors get caught) breaking recursion protection for future event calls
This was observed in a recent crashdump where a plugin triggered a recursion error, but the stack trace did not contain any sign of a recursive event call. I conclude that this must have been caused by previous event handlers triggering errors 50 times in order to make the recursion detection break, because the recursion detection did not decrement the counter in cases where an exception was thrown.
2018-10-14 11:07:16 +01:00
6579930638 Revamp MetadataStore API (#2477)
This would be a lot less messy if we had generics, but no tango.
2018-10-12 12:16:21 +01:00
a0ab996b9f Merge branch 'release/3.2' into release/3.3 2018-10-12 09:31:48 +01:00
97980d4516 Update composer dependency versions 2018-10-12 09:31:19 +01:00
b261129788 Merge branch 'release/3.2' into release/3.3 2018-10-11 19:42:18 +01:00
d9220395d1 Dummy decode for ResourcePacksInfoPacket and ResourcePackStackPacket
while we can't deal with this information, it's needed for the sake of unit testing so we don't shit on every bit of incoming data of these packet types.
2018-10-11 19:42:00 +01:00
4f2f373a24 Merge branch 'release/3.2' into release/3.3 2018-10-10 13:41:51 +01:00
2858db430e Fixed AsyncTask publishProgress() race condition on task exit
It's possible for a progress update to be lost due to the task finishing before the main thread found the progress update.
2018-10-10 13:41:15 +01:00
de6d62aba2 Merge branch 'release/3.2' into release/3.3 2018-10-09 22:51:40 +01:00
32836cbfb8 Don't handle remaining packets in a batch when an earlier one triggered a disconnect 2018-10-09 22:50:02 +01:00
8316e00927 Player: Throw exception on failure to encode form JSON 2018-10-09 22:39:48 +01:00
6f694b0801 Merge branch 'release/3.2' into release/3.3 2018-10-07 19:45:26 +01:00
fd459cda54 3.2.5 is next 2018-10-07 19:45:06 +01:00
a66dd4a7d9 Release 3.2.4 2018-10-07 19:32:04 +01:00
3617eba4a3 Merge branch 'release/3.1' into release/3.2 2018-10-07 19:31:16 +01:00
e79cc98883 Release 3.1.8 2018-10-07 19:20:20 +01:00
a3552875cb Merge branch 'release/3.2' into release/3.3 2018-10-07 17:48:26 +01:00
d259b2c9ee Merge branch 'release/3.1' into release/3.2 2018-10-07 17:48:19 +01:00
10fa74b417 Make clear that Plugin->setEnabled() is @internal
Use of this by plugins will produce a lot of undefined behaviour, such as event handlers not being unregistered, scheduled tasks not being removed, and registered permissions causing memory leaks.
2018-10-07 17:48:11 +01:00
ab5aec6c30 Event: Remove unnecessary check from call() hot path
This check is completely unnecessary since handlers get unregistered when a plugin is disabled. Additionally, this is an extremely hot path and this change produces a modest 5% performance improvement to event calls.
2018-10-07 16:36:30 +01:00
0e508876d2 RakLibInterface: Disconnect players who trigger errors during handler
this is cleaner than leaving the player hanging for 5 seconds (which they'll often timeout from anyway). Banning the IP without kicking the player can often look like "lag" and end up getting brushed off as a performance issue.
2018-10-07 15:32:23 +01:00
50b89c30f8 Merge branch 'release/3.2' into release/3.3 2018-10-06 14:45:12 +01:00
17ceb27af4 Merge branch 'release/3.1' into release/3.2 2018-10-06 14:45:05 +01:00
adbd1c7bed RCON: remove redundant sleep
this dates back to the days where PM used to kill threads to stop them. Today we're more civilized and ask it to stop nicely, so this isn't necessary anymore.
2018-10-06 14:44:56 +01:00
495fdbd19f Move block and network namespaces away from PluginManager->callEvent()
the original step that wasn't supposed to cause conflicts, caused messy conflicts... so I might as well do this part too
2018-10-05 18:22:49 +01:00
620784e4e7 Merge branch 'release/3.2' into release/3.3 2018-10-05 17:44:03 +01:00
cf20e626e2 Merge branch 'release/3.1' into release/3.2 2018-10-05 17:43:54 +01:00
d75c830a7e Add -f parameter to lint.sh to allow it to not be useless in cygwin
find can conflict with windows' built in find command, which causes it to bug out when running tests.
2018-10-05 17:43:45 +01:00
1dd6591ac1 Migrate a bunch of PluginManager->callEvent() usages to Event->call
This has the triple bonus effect of a) making a lot of code easier to read, b) reducing Server::getInstance() usages, and c) removing a whole bunch of Server dependencies.

The network and block namespaces are untouched by this commit due to potential for merge conflicts. These should be dealt with separately on master.
2018-10-05 17:30:06 +01:00
6efef3bbc7 Move event calling functionality to Event->call() method
This is dependent on the changes made in b1e0f82cbf. This now makes it possible to call events without fetching a Server reference, allowing to eliminate a vast array of Server dependencies.
2018-10-05 16:55:37 +01:00
b1e0f82cbf PluginManager: Stop catching exceptions thrown by event handlers (#2472)
The basic principle here is "if you're not expecting it, don't catch it".

Event handlers are **never** supposed to throw exceptions. If they do throw exceptions, it's usually going to one of two things;
1. Broken code producing an error
2. Code triggering (and not catching) a runtime error

Both 1) and 2) boil down to defective code on the part of the event handler, and thus should not be caught by the caller, but instead allowed to crash the server and produce a crashdump.

It's also undesirable to catch unexpected errors here for a few other reasons
- It leaves the owner of the event handler in an unknown, potentially unstable state
- It allows broken code to cause event handlers to spam the logger in events that happen frequently (for example movement handlers)
- It allows the process to continue down a train of further undefined behaviour, which may lead to more errors or ultimately a crash, so it makes no sense to hold off the inevitable.

This has a few advantages that are not merely inverted disadvantages:
- Crash dumps will now be created and automatically submitted for defective event handlers, allowing quicker issue location, debugging and fixing in plugins without manual user interaction
- Event calling now isn't dependent on Server to work.
2018-10-05 16:46:10 +01:00
c065cfbeda Merge branch 'release/3.2' into release/3.3 2018-10-04 16:41:03 +01:00
722924a779 Merge branch 'release/3.1' into release/3.2 2018-10-04 16:40:55 +01:00
60e1b29462 RegionLoader: Remove incorrect size cap
This assumes that the region is properly garbage-collected and packed, but if the file contains uncollected garbage this may not be the case, resulting in a region larger than a gigabyte.
2018-10-04 16:40:45 +01:00
0171095036 Merge branch 'release/3.2' into release/3.3 2018-09-29 15:39:34 +01:00
5b511f6d06 Merge branch 'release/3.1' into release/3.2 2018-09-29 15:39:27 +01:00
426dee04a6 Potion: remove unnecessary exception throw in getPotionEffectsById()
this is only used by Potion and SplashPotion, and simply causes errors when trying to use potions with unknown IDs.
2018-09-29 15:39:20 +01:00
9d8898a4ed Server: added API method hasOfflinePlayerData() 2018-09-27 16:36:42 +01:00
3bb22f9778 Merge branch 'release/3.2' into release/3.3 2018-09-26 13:12:34 +01:00
bb1944ca40 Merge branch 'release/3.1' into release/3.2 2018-09-26 13:12:20 +01:00
d1a20ecb4a CommandReader: Require readline to be explicitly enabled on Windows
readline on Windows causes issues with console output corruption. Additionally, PM readline impl is extremely buggy and probably ought to be removed. However, have a hotfix for now.
2018-09-26 13:11:21 +01:00
16c636df83 Merge branch 'release/3.2' into release/3.3 2018-09-24 18:27:04 -04:00
f6a8ec83a1 Merge branch 'release/3.1' into release/3.2 2018-09-24 18:26:39 -04:00
28137efb53 Fixed server freezing when using chorus fruit from large Y coordinates 2018-09-24 18:26:20 -04:00
e597067a92 Merge branch 'release/3.3' of https://github.com/pmmp/pocketmine-mp into release/3.3 2018-09-23 16:43:36 +01:00
06f00020cd Merge branch 'release/3.2' into release/3.3 2018-09-23 16:35:20 +01:00
7b0836d399 Merge branch 'release/3.1' into release/3.2 2018-09-23 16:35:11 +01:00
cea146e335 Thin: use bounding box instead of collision boxes 2018-09-23 16:35:01 +01:00
5eeaeb6c3e Level: Bail on trying to unload a level during level tick (#2435) 2018-09-22 13:40:50 +01:00
2712287995 Merge branch 'release/3.2' into release/3.3 2018-09-20 19:02:39 +01:00
8db1ccc1ae Merge branch 'release/3.1' into release/3.2 2018-09-20 19:02:09 +01:00
5d56030afa Item: make nbtDeserialize() return AIR when reading an unknown PC item
This is scummy, but it's better than crashing the whole server just because a chest contained an unknown item.
2018-09-20 19:00:44 +01:00
6be5e75263 Merge branch 'release/3.2' into release/3.3 2018-09-20 17:04:55 +01:00
d9c251b613 Merge branch 'release/3.1' into release/3.2 2018-09-20 17:04:45 +01:00
8085b81f5c fix phars 2018-09-20 17:04:34 +01:00
6b44f99dfb Merge branch 'release/3.2' into release/3.3 2018-09-20 16:50:04 +01:00
33d3fff3c5 Merge branch 'release/3.1' into release/3.2 2018-09-20 16:49:57 +01:00
7c092b93b4 Fixed bug when placing blocks by clicking on redstone ore 2018-09-20 16:49:50 +01:00
aa05650994 Fixed block picking for mob heads 2018-09-20 13:11:45 +01:00
758d9b9784 Farmland: fixed block picking 2018-09-20 12:03:01 +01:00
24a6bf7365 PocketMine.php: Allow overriding autoloader path using --bootstrap
I've gotten tired of re-running composer every time I switch branches...
2018-09-20 12:01:39 +01:00
9a5d51fd3d Fixed block-picking cake giving the block instead of item 2018-09-20 11:31:48 +01:00
fa9ea6a7d7 Merge branch 'release/3.2' into release/3.3 2018-09-20 10:04:19 +01:00
6a7f39978b Merge branch 'release/3.1' into release/3.2 2018-09-20 10:03:47 +01:00
c52e1ea9f9 Fixed block picking double slabs giving the double slab block 2018-09-20 10:02:55 +01:00
5e94d20d79 Merge branch 'release/3.2' into release/3.3 2018-09-19 16:17:00 +01:00
a0bb747d6d Merge branch 'release/3.1' into release/3.2 2018-09-19 16:16:18 +01:00
4bc0d850b1 Added Block->getRuntimeId(), clean up some mess 2018-09-19 16:16:10 +01:00
ad9df6764d Merge branch 'release/3.2' into release/3.3 2018-09-18 12:32:07 +01:00
97583c8b04 Merge branch 'release/3.1' into release/3.2 2018-09-18 12:32:01 +01:00
107192c753 Bed: fixed block-pick giving wrong colour items 2018-09-18 12:31:53 +01:00
6309a242dc Merge branch 'release/3.2' into release/3.3 2018-09-18 12:22:26 +01:00
870f9abc20 Merge branch 'release/3.1' into release/3.2 2018-09-18 12:22:20 +01:00
0e2bbc44db Fixed drops and item picking of Brewing Stand 2018-09-18 12:22:12 +01:00
e58d015f14 Merge branch 'release/3.2' into release/3.3 2018-09-16 17:47:08 +01:00
d9768abe47 Merge branch 'release/3.1' into release/3.2 2018-09-16 17:47:01 +01:00
e9b84ecc8b Fixed incorrect break check for torch 2018-09-16 17:46:50 +01:00
0d65f9c4b8 Merge branch 'release/3.2' into release/3.3 2018-09-14 17:09:51 +01:00
c83d12790e Merge branch 'release/3.1' into release/3.2 2018-09-14 17:09:41 +01:00
5863d4c066 Fixed PermissibleBase->clearPermissions() not unsubscribing from permissions that aren't explicitly assigned
This came to light after observing cfb6856634 in a fresh light. I noticed that this fix should not have been necessary because clearPermissions() should have dealt with it. Unfortunately, permissions can be set without being set in PermissibleBase->permissions, so this misses things.
2018-09-14 17:06:32 +01:00
22077c1fdd Merge branch 'release/3.2' into release/3.3 2018-09-14 16:18:19 +01:00
7d54d18732 Merge branch 'release/3.1' into release/3.2 2018-09-14 16:18:12 +01:00
bfbc845efa Remove impossible uses of PlayerInteractEvent CLICK_AIR constants 2018-09-14 16:17:55 +01:00
f33c19e77a Merge branch 'release/3.2' into release/3.3 2018-09-14 11:06:24 +01:00
2ff4228fb7 Merge branch 'release/3.1' into release/3.2 2018-09-14 11:06:11 +01:00
06c4f31db7 Server: Account for later levels being unloaded by earlier levels' ticking function in checkTickUpdates()
should fix #2434

This happens when a plugin causes a level to be unloaded during an event fired on level tick.
2018-09-14 11:05:51 +01:00
09dea035d4 Level: Batch light updates at the end of the tick to amortize CPU cost (#2429)
this produces a 5x performance improvement for lighting updates during water flow, and 25% improvement for lava flow.
2018-09-12 10:33:28 +01:00
a9fc67663c Strip anti flight out of the core (#2428)
This may later be developed into a plugin if it is a desired feature, but having it in the core is unnecessary and a pain in the ass.
2018-09-12 10:06:57 +01:00
519659fd2b Merge branch 'release/3.2' into release/3.3 2018-09-11 19:48:23 +01:00
6c70e84fa2 Merge branch 'release/3.1' into release/3.2 2018-09-11 19:47:46 +01:00
7d0e631a75 RakLibInterface: fixed processing hook being registered too early
this would cause bugs if the interface was not added directly to the network.
2018-09-11 19:47:26 +01:00
5134c0cf5a Merge branch 'release/3.2' into release/3.3 2018-09-11 12:28:09 +01:00
65b751d080 3.2.4 is next 2018-09-11 12:27:45 +01:00
27effff403 Release 3.2.3 2018-09-11 12:19:56 +01:00
a940cc5b5e Merge branch 'release/3.1' into release/3.2 2018-09-11 12:19:32 +01:00
15e654131c 3.1.8 is next 2018-09-11 12:18:54 +01:00
6e6cda91ce Release 3.1.7 2018-09-11 11:45:17 +01:00
0aa63d269a Merge branch 'release/3.2' into release/3.3 2018-09-11 11:35:46 +01:00
53a76c0d14 Merge branch 'release/3.1' into release/3.2 2018-09-11 11:35:38 +01:00
69500fe183 LightUpdate: Remove garbage left over from dab73d8950 2018-09-11 11:35:31 +01:00
191f0038b8 LightUpdate: Allow a single position to be set more than once before executing
This is needed for batched lighting updates to work. It also reduces the overhead involved with simply preparing a lighting update and moves the pain to the execute() instead.
2018-09-11 11:33:57 +01:00
99d6aa92cb Implemented rail connectivity (#2414) 2018-09-10 19:32:11 +01:00
90d01f5ed2 Merge branch 'release/3.2' into release/3.3 2018-09-08 14:25:20 +01:00
5af4dd20df Merge branch 'release/3.1' into release/3.2 2018-09-08 14:25:11 +01:00
c7d58db7eb Cleanup Entity age handling, fixed arrows despawning too quickly after long flight 2018-09-08 14:23:06 +01:00
a3b78236eb Server: don't catch Throwable for level ticking
this usually causes the console to get spammed with errors. Additionally, in the case where doTick() throws any exception, it's usually because we're in a state we didn't want to be in, so we really should not carry on trying to keep ticking when something breaks here. Instead, this should generate a crashdump.
2018-09-08 14:13:28 +01:00
b70905b287 Merge branch 'release/3.2' into release/3.3 2018-09-06 19:31:05 +01:00
d8e27e6081 Bow: fix wrong arithmetic for Flame fire ticks, closes #2420 2018-09-06 19:30:55 +01:00
7a48c0b23d Merge branch 'release/3.2' into release/3.3 2018-09-06 19:15:41 +01:00
14a2ffa51b Merge branch 'release/3.1' into release/3.2 2018-09-06 18:43:28 +01:00
c447d51e3f Bucket: use ItemFactory instead of self-clone
in the future Item->setDamage() will be removed.
2018-09-06 18:42:09 +01:00
557fd34754 Make MainLogger independent of runtime-defined INI entries
Previously every thread using the logger had to inherit runtime-defined INI entries in order for the timezone to be set correctly. This removes that requirement.
2018-09-04 15:57:45 +01:00
32077d96b4 Merge branch 'release/3.2' into release/3.3 2018-09-04 11:56:58 +01:00
9f4722f537 3.2.3 is next 2018-09-04 11:56:27 +01:00
cb04f287eb Release 3.2.2 2018-09-04 11:51:28 +01:00
f649ef5195 Sync 3.2 and 3.1 branches 2018-09-04 11:51:05 +01:00
b615cad22d 3.1.7 is next 2018-09-04 11:50:05 +01:00
b93e219231 Release 3.1.6 2018-09-04 11:44:05 +01:00
a4a9309193 Updated NBT dependency for bug fix 2018-09-04 11:43:38 +01:00
e621cde8f1 Player: Tighten validity checks for addWindow() (#2419)
- Don't allow the same window ID to be used when another window is already using it
- Detect window ID collisions when selecting IDs for regular containers (should never happen, but anything is possible)
2018-09-01 15:25:46 +01:00
56ee957fda 3.2.2 is next 2018-08-31 19:03:58 +01:00
1193efd69e Release 3.2.1 2018-08-31 18:58:53 +01:00
2738e38aee Merge branch 'release/3.2' into release/3.3 2018-08-31 16:19:52 +01:00
f466fd5568 Updated runtime IDs table
apparently 1 (!) missing entry (for barrier) was causing client sided crashes unexplained. This is infuriating.
2018-08-31 16:19:42 +01:00
72d447276b Merge branch 'release/3.2' into release/3.3 2018-08-30 15:46:54 +01:00
d5a5209334 Merge branch 'release/3.1' into release/3.2 2018-08-30 15:46:46 +01:00
3a85e6cab9 Backport ce58294305 for 3.x line 2018-08-30 15:46:26 +01:00
d0aff2ecbd Bump version for 3.3 dev branch 2018-08-30 11:05:58 +01:00
bca493a682 3.2.1 is next 2018-08-30 11:04:47 +01:00
ba12dfafd6 Release 3.2.0 2018-08-29 16:28:35 +01:00
e09087de26 Fix version numbers 2018-08-29 16:27:01 +01:00
888dba704b Merge branch 'mcpe-1.6' into release/3.2 2018-08-29 16:23:53 +01:00
511249c562 Sync 3.2 and 3.1 branches 2018-08-29 16:23:28 +01:00
17f1bf5512 3.1.6 is next 2018-08-29 16:08:45 +01:00
5179bb1d30 Release 3.1.5 2018-08-29 15:57:58 +01:00
6bff840293 Sync 3.1 and 3.0 branches 2018-08-29 15:55:14 +01:00
08897c6941 Release 3.0.12 2018-08-29 15:47:28 +01:00
05d9bb45d0 Merge branch 'release/3.1' into release/3.2 2018-08-26 19:15:16 +01:00
dfe2aa9c67 Merge branch 'release/3.0' into release/3.1 2018-08-26 19:15:08 +01:00
4006be35d9 Update BinaryUtils dependency 2018-08-26 19:15:01 +01:00
e5cda34548 Merge branch 'release/3.1' into mcpe-1.6 2018-08-26 18:05:14 +01:00
032b20f659 Server: remove premature optimization of findEntity() 2018-08-25 18:37:18 +01:00
fe6d546190 Merge branch 'release/3.1' into release/3.2 2018-08-25 17:49:21 +01:00
c7af1cf785 Merge branch 'release/3.0' into release/3.1 2018-08-25 17:49:14 +01:00
22fcfffa53 PluginsCommand: remove useless private function 2018-08-25 16:09:51 +01:00
7dd53f2397 Replace unnecessary strlen > 0 calls with !== "" checks 2018-08-25 16:07:49 +01:00
298259b473 PluginsCommand: clean up garbage code 2018-08-25 16:05:25 +01:00
c123f2d10b SimpleCommandMap: clean up error reporting in registerServerAliases() 2018-08-25 15:43:23 +01:00
3e6f70ddf6 Merge branch 'release/3.1' into mcpe-1.6 2018-08-23 18:00:06 +01:00
bea634a9b7 Change air tank regeneration to match UA (#2396) 2018-08-22 19:10:53 +01:00
8daf3dc8b4 Merge branch 'release/3.1' into release/3.2 2018-08-22 15:41:52 +01:00
4cc7573a64 Merge branch 'release/3.0' into release/3.1 2018-08-22 15:40:43 +01:00
9d80802e53 Living: fixed some update conditions not being set 2018-08-22 15:40:32 +01:00
ec1e257e21 Entity: Fixed fire damage not taking effect in the void
this is an absurd bug that nobody would ever otherwise notice, but the problem is that the doOnFireTick() call isn't evaluated if hasUpdate is already true.
2018-08-22 15:36:31 +01:00
d419d4308f Add a couple of item constants, register Scute item
leaving out turtle helmet for now because of complications relating to the effect application - I REALLY don't want to tick armour if I can avoid it, due to the performance concerns.
2018-08-21 19:54:24 +01:00
9ca38ba868 Protocol changes for 1.6.0.8 + resource packs "fix" 2018-08-21 17:36:55 +01:00
424c50e1e9 Protocol changes for 1.6.0.5, minus Entity->Actor rename 2018-08-21 17:36:29 +01:00
566f3c6262 AvailableCommandsPacket: stricter decode and handling 2018-08-21 17:14:54 +01:00
0d05dcec08 AvailableCommandsPacket: deal with dynamic enums
somehow I missed this, thanks @NiclasOlofsson for pointing it out
2018-08-21 17:14:53 +01:00
986077e03c Protocol changes for 1.6.0.1 2018-08-21 17:14:53 +01:00
ddcb2f002a Tile: Be explicit about not calling Tile::createNBT() (#2388)
A common pitfall developers fall into with this function is that it has to be called from the scope of the tile class you're creating NBT for, but people commonly do Tile::createNBT() directly, which then results in cryptic "Tile is not registered" errors. This now throws a BadMethodCallException instead to be fully clear about this.

In the future this will be removed completely once NBT is no longer required to create a tile, but for now this is a confusing issue that should be dealt with.
2018-08-19 19:54:22 +01:00
c496480d2b Merge branch 'release/3.1' into release/3.2 2018-08-19 19:52:40 +01:00
6fce2b3349 Merge branch 'release/3.0' into release/3.1 2018-08-19 19:52:30 +01:00
64ed8adefc Cactus: fixed place/break logic mismatch causing item spewing 2018-08-19 19:52:07 +01:00
2eda8cfad3 Merge branch 'release/3.1' into release/3.2 2018-08-19 16:01:47 +01:00
91be5aba0c Merge branch 'release/3.0' into release/3.1 2018-08-19 16:00:25 +01:00
5df601c817 Add @see docs so PhpStorm can see dynamic constructor usages
PhpStorm can't see constructor usages when the class name is dynamic. This causes maintenance problems because cross-referencing constructors called like this doesn't show up dynamic calls.
2018-08-19 16:00:15 +01:00
21e7b5ea43 TesterPlugin: removed usage of deprecated ServerCommandEvent 2018-08-19 14:05:26 +01:00
8304675af7 Merge branch 'release/3.1' into release/3.2 2018-08-19 13:59:58 +01:00
1a47735d84 Merge branch 'release/3.0' into release/3.1 2018-08-19 13:59:34 +01:00
0cdf4d0c55 Spoon the TesterPlugin into the main repository
I am eating my own words this once, because having the tester plugin as a separate repository makes no sense - it is just added barriers to writing proper tests with no actual benefit. Since the tester plugin is specifically intended for CI, it doesn't make sense for it to be in its own module.
2018-08-19 13:58:13 +01:00
e6e28b74b5 Nuke the TesterPlugin submodule 2018-08-19 13:47:43 +01:00
ebffff0caa Added CommandEvent, deprecated (Remote)?ServerCommandEvent (#2376) 2018-08-19 12:59:16 +01:00
0dc4bd36e1 Form: change handleResponse() return type to void
this returning is counter intuitive and doesn't make any sense without the queuing mechanism. Instead it's simpler to just use Player->sendForm().
2018-08-19 11:44:59 +01:00
9d17c9a09d Merge branch 'release/3.1' into release/3.2 2018-08-19 11:22:58 +01:00
72f46b4631 Merge branch 'release/3.0' into release/3.1 2018-08-19 11:22:51 +01:00
3892f2f404 Config: Properly prevent keys getting transformed into bools
The original regex almost completely failed at its objective, because it a) only worked if there was no value for the key, and b) did not prevent all such occurrences getting transformed, while quoting patterns that would not get transformed anyway.
2018-08-19 11:22:36 +01:00
bfa415e108 Add unit tests for json decoding hack 2018-08-19 10:30:52 +01:00
b66095cb36 Added a hack for MC W10 JSON empty strings bug (#2383) 2018-08-19 10:10:40 +01:00
0336ae8229 Merge branch 'release/3.1' into release/3.2 2018-08-17 19:47:41 +01:00
4a1d67cb91 Merge branch 'release/3.0' into release/3.1 2018-08-17 19:47:34 +01:00
b4694092b7 Painting: fix motive not being saved 2018-08-17 19:47:26 +01:00
4b3e17e681 Sync 3.2 and 3.1 branches 2018-08-16 18:33:54 +01:00
d99ee515c6 3.1.5 is next 2018-08-16 18:33:27 +01:00
17f7dc34be Release 3.1.4 2018-08-16 18:26:49 +01:00
a63d66c048 Sync 3.1 and 3.0 branches 2018-08-16 18:26:26 +01:00
95f6995ae0 3.0.12 is next 2018-08-16 18:25:31 +01:00
4a24d7909e Release 3.0.11 2018-08-16 18:14:04 +01:00
5424644ca1 Merge branch 'release/3.1' into release/3.2 2018-08-16 15:52:19 +01:00
4e2387edc1 Merge branch 'release/3.0' into release/3.1 2018-08-16 15:52:12 +01:00
a5e38576ef ItemEntity: fixed using -1 for infinite pickup delay not working
closes #2382 (squash-merge)
2018-08-16 15:52:05 +01:00
aa7c4bc64d Merge branch 'release/3.1' into release/3.2 2018-08-15 13:48:46 +01:00
381151dedc Merge branch 'release/3.0' into release/3.1 2018-08-15 13:48:36 +01:00
a604e6835e CoalOre: fixed ignoring silk touch for XP drops, closes #2374 2018-08-15 13:48:29 +01:00
df8e10cad9 Forms API, part 1: add Player->sendForm() and Form interface
There's no implementation here yet, but that can come later. This lays the ground for allowing plugins to have an integrated method to send forms, as well as a solution to the ID conflict problem.

A built in implementation should not be a concretion and it should be able to be swapped for third party implementations. This enables the possiblity to do so.
2018-08-14 16:06:55 +01:00
d98a6e566c Merge branch 'release/3.1' into release/3.2 2018-08-14 15:03:30 +01:00
142a6d7678 Merge branch 'release/3.0' into release/3.1 2018-08-14 15:03:22 +01:00
b2ca364de0 SplashPotion: Don't apply effects to entities which are not alive
fixes #2372
2018-08-14 15:03:15 +01:00
ade2be9eee Merge branch 'release/3.1' into release/3.2 2018-08-13 13:22:40 +01:00
09ed40a921 Merge branch 'release/3.0' into release/3.1 2018-08-13 13:22:32 +01:00
565373cee6 OfflinePlayer: remove unnecessary getName() usages 2018-08-13 13:22:00 +01:00
c29723e3c4 OfflinePlayer: remove unnecessary strtolower() calls
closes #2371
2018-08-13 13:18:58 +01:00
39ed6a7cdf Merge branch 'release/3.1' into release/3.2 2018-08-11 19:59:53 +01:00
a8811ab2b3 Fixed 1.5.0 PlayerSkinPacket protocol change that somehow disappeared
I am 100% sure I committed this change, but it isn't in the merge...
2018-08-11 19:59:44 +01:00
bec5aaa54b Merge branch 'release/3.1' into release/3.2 2018-08-11 19:37:18 +01:00
974583a853 Merge branch 'release/3.0' into release/3.1 2018-08-11 19:37:10 +01:00
03f8fe62d4 Fixed structure of GuiDataPickItemPacket
this changed in 1.2.0.7 beta and I didn't spot it.
2018-08-11 19:36:53 +01:00
cf29ab1f17 Arrow: remove unused import 2018-08-07 19:06:40 +01:00
c5c5a53a13 Merge branch 'release/3.1' into release/3.2 2018-08-07 18:49:13 +01:00
699f35cc05 Merge branch 'release/3.0' into release/3.1 2018-08-07 18:49:06 +01:00
8fa196efc9 FallingBlock: fixed state not being saved 2018-08-07 18:48:52 +01:00
63a65680ac typo 2018-08-07 14:43:29 +01:00
47cd6fe105 EntityDamageEvent: Add API to customize Living entity attack cooldown time
closes #2310
2018-08-07 14:39:26 +01:00
f582b5a3db Merge branch 'release/3.1' into release/3.2 2018-08-07 14:32:38 +01:00
b1ab881b99 Merge branch 'release/3.0' into release/3.1 2018-08-07 14:32:28 +01:00
69c54e789a Clear the title bar when the server shutdown. 2018-08-07 14:31:39 +01:00
7f0fa2ac3d PluginBase: Do not fill defaults from resources/config.yml (#2316)
This fixes #2219.
2018-08-07 12:33:24 +01:00
max
f3b2bcfd13 Added Conduit Power effect 2018-08-06 21:30:15 +01:00
c947909c2e Updated language submodule 2018-08-06 20:52:53 +01:00
09dadc72bc Merge branch 'release/3.1' into release/3.2 2018-08-06 18:45:08 +01:00
e33d1279fa Merge branch 'release/3.0' into release/3.1 2018-08-06 18:45:01 +01:00
9e1fa453ad Level: Fixed leak of global packets when no players are online
If a global packet was broadcasted when no players were online, it would be held in memory indefinitely (until a player joined).
2018-08-06 18:44:53 +01:00
ca541032ae Move Player death message derivation to PlayerDeathEvent static method
This now no longer requires a Player to operate, only a player name.
2018-08-05 12:19:16 +01:00
bcf9915082 Merge branch 'release/3.1' into release/3.2 2018-08-05 11:33:11 +01:00
6a05edb4e9 Merge branch 'release/3.0' into release/3.1 2018-08-05 11:33:02 +01:00
70635d0870 DropItemAction: Consider invalid if the target item is null
it's not possible to drop a null item.
2018-08-05 11:32:50 +01:00
8d6dc4e188 Merge branch 'release/3.1' into release/3.2 2018-08-04 16:47:26 +01:00
46bd096f06 3.1.4 is next 2018-08-04 16:46:51 +01:00
51a8905fb3 Release 3.1.3 2018-08-04 16:41:16 +01:00
f954d7c3dc Bring 3.1 up to speed with 3.0 2018-08-04 16:40:40 +01:00
7ad0aa56b1 3.0.11 is next 2018-08-04 16:39:53 +01:00
1ff6f8846e disable dev flag 2018-08-04 16:30:23 +01:00
12d8d925c8 TimingsCommand: check for instances of InternetException only 2018-08-04 14:59:31 +01:00
f3f229ef7c Internet: only catch InternetExceptions - anything else is an unexpected fault condition 2018-08-04 14:51:26 +01:00
6614183c7f Merge branch 'release/3.1' into release/3.2 2018-08-03 20:07:52 +01:00
e6f53cc56b Merge branch 'release/3.0' into release/3.1 2018-08-03 20:07:46 +01:00
87f458f9bd AsyncPool: remove now-unnecessary isTerminated() call 2018-08-03 20:07:37 +01:00
5a7e575c3a AsyncPool: isCrashed() now returns true when a fatal error occurred
the fix for chunks earlier didn't fix...
2018-08-03 20:06:41 +01:00
7ebf3c7bf4 Merge branch 'release/3.1' into release/3.2 2018-08-03 18:50:22 +01:00
20b37d0208 Merge branch 'release/3.0' into release/3.1 2018-08-03 18:50:14 +01:00
d6d98183ea MainLogger: Log messages and exception traces in a synchronized block
this ensures that stack traces are emitted coherently without messages from other threads landing in the middle.
2018-08-03 18:50:06 +01:00
334caaaa34 Merge branch 'release/3.1' into release/3.2 2018-08-03 18:24:44 +01:00
89cf76363f Merge branch 'release/3.0' into release/3.1 2018-08-03 18:24:36 +01:00
9ff5c65fb6 Level: Make async chunk sending aware of faults
Previously any random error could occur during an AsyncTask preparing a chunk, and the Level would never know about it and thus never send the chunk.

I don't know how many invisible-chunk bug cases this fixes, but I expect it's quite a lot.
2018-08-03 18:23:32 +01:00
1532b0ef6d Level: Remove chunks from chunk send queue on unload
When a chunk request task crashes, these can get stuck and never get removed. This allows using /gc to collect the bad chunk in order to fix the bug.
2018-08-03 18:04:56 +01:00
6fcaef068f Merge branch 'release/3.1' into release/3.2 2018-08-02 14:43:51 +01:00
61accee682 Merge branch 'release/3.0' into release/3.1 2018-08-02 14:43:44 +01:00
9ece971a2b Server: remove useless check from exceptionHandler()
this cannot be null... @shoghicp y u litter the code with these useless checks ???
2018-08-02 14:41:28 +01:00
5546c88f88 Server: Fixed parse errors getting reported to CA
this changed to throwing errors as of PHP 7
2018-08-02 14:40:36 +01:00
c09ad9263b Empty merge of 3.1 into 3.2 2018-07-30 15:21:42 +01:00
4c4761d200 back to dev 2018-07-30 15:21:10 +01:00
5492495d38 disable dev flag 2018-07-30 15:10:12 +01:00
6bef07db7c Empty merge of 3.0 into 3.1 2018-07-30 15:09:53 +01:00
e8c7ae595d back to dev 2018-07-30 15:08:32 +01:00
0d9f40873f disable dev flag 2018-07-30 14:57:51 +01:00
4cc2f037a9 Merge branch 'release/3.1' into release/3.2 2018-07-30 14:54:10 +01:00
f7358cd7e1 Merge branch 'release/3.0' into release/3.1 2018-07-30 14:54:01 +01:00
a4aee98cba TimingsCommand: some code cleanup 2018-07-30 14:53:10 +01:00
a97c7d3132 Fix for timings 2018-07-30 14:42:16 +01:00
99045fe21a Entity: Implement setting score tag 2018-07-30 09:36:32 +01:00
bda271ca63 Merge branch 'release/3.1' into release/3.2 2018-07-27 11:47:36 +01:00
808d289610 Merge branch 'release/3.0' into release/3.1 2018-07-27 11:47:22 +01:00
4a1ed21e52 PluginManager: Fix patch level check to allow loading the plugin when the server's minor level is higher than the plugins declared minor level. 2018-07-27 11:46:24 +01:00
b3f2396ea5 UPnP: Make error message less useless 2018-07-26 16:00:35 +01:00
ab0510cb37 Merge branch 'release/3.1' into release/3.2 2018-07-26 14:40:33 +01:00
06c035bfe6 Merge branch 'release/3.0' into release/3.1 2018-07-26 14:40:24 +01:00
1b053c7928 Clean up pointless checks in Thread/Worker 2018-07-26 14:20:55 +01:00
c684f99cc4 Clean up Thread/Worker quit() 2018-07-26 14:17:01 +01:00
9a423be1db Internet: Throw more specific exceptions
RuntimeException is very generic and might be thrown for other reasons apart from web request failures.

This is backwards compatible because InternetException is a descendent of RuntimeException. Additionally, getURL() and postURL() have intentionally been left untouched for backwards compatibility's sake.
2018-07-26 12:34:14 +01:00
08be51dc23 Clear permissions on server reload 2018-07-26 10:40:28 +01:00
94352782d5 https://media.giphy.com/media/UAUtB4Oi9U4EM/giphy.gif 2018-07-26 10:31:57 +01:00
8fae79f85b Merge branch 'release/3.1' into release/3.2 2018-07-26 10:25:19 +01:00
8d47a222b4 Merge branch 'release/3.0' into release/3.1 2018-07-26 10:25:13 +01:00
695793795e PluginManager: Remove dead $pluginParentTimer left over from 9e4d88a852 2018-07-26 10:25:01 +01:00
9a2845640b Permissions management cleanup (#2332)
* Added a new PermissionManager, remove ridiculous cyclic dependencies of Permissions on Server

Aside from all the other ridiculous design problems with the permission system, the biggest problems are its API. This is, once again, a result of poor API design copied from Bukkit.

This pull request removes all permission-related functionality from `PluginManager` and moves it to the `pocketmine\permission\PermissionManager` class.

As can be observed from the removed code in the diff, the permissions system was previously entirely dependent on the Server, because it needed to get the PluginManager for registering permissions. This is utterly ridiculous. This refactor isolates _most_ permission-related functionality within the `permission` namespace.

As mentioned above, this stupid API is a direct result of copying from Bukkit. If you look at the API documentation for Bukkit for `PluginManager` you will see that the methods I'm deprecating here are also in there.

## Changes
- Added a new `PermissionManager` class. This can be accessed via its singleton `getInstance()` static method.
- Deprecated the following `PluginManager` methods - these will be removed no later than 4.0.0:
  - `getPermission()`
  - `addPermission()`
  - `removePermission()`
  - `getDefaultPermissions()`
  - `recalculatePermissionDefaults()`
  - `subscribeToPermission()`
  - `unsubscribeFromPermission()`
  - `getPermissionSubscriptions()`
  - `subscribeToDefaultPerms()`
  - `unsubscribeFromDefaultPerms()`
  - `getDefaultPermSubscriptions()`
  - `getPermissions()`
2018-07-26 10:21:41 +01:00
580f71d496 Permission: cosmetic reorg 2018-07-25 20:56:23 +01:00
24f11779f2 Level: don't try to unregister generators from non-live workers
this was causing garbage-collected workers to get restarted on shutdown if they previously had the generator registered for that level.
2018-07-25 18:52:17 +01:00
706c620d04 Move Internet-related functions from Utils into their own class (#2324)
- Added `Internet::getIP()`, `Internet::getURL()`, `Internet::postURL()`, and `Internet::simpleCurl()`.
- Deprecated the corresponding functions in `Utils`. Updating to the new functions is as simple as replacing `Utils` with `Internet`, since this doesn't break backwards compatibility.

The deprecations should be catered for by plugin developers. These deprecated redirects will be removed no later than 4.0.0.
2018-07-25 15:51:18 +01:00
951870e6ec Merge branch 'release/3.1' into release/3.2 2018-07-25 15:30:40 +01:00
9f425bbe2b Merge branch 'release/3.0' into release/3.1 2018-07-25 15:30:31 +01:00
a4965842d6 Remove $handlerList from PlayerExperienceChangeEvent 2018-07-25 15:30:01 +01:00
1405099768 Merge branch 'release/3.1' into release/3.2 2018-07-24 17:19:18 +01:00
d0339796b4 Added DATA_FLAG_SHOW_TRIDENT_ROPE 2018-07-24 17:19:06 +01:00
1464487945 Utils: remove unnecessary do...while(false) from getIP() 2018-07-24 16:33:03 +01:00
40c28f4d26 PluginManager: Automatically create data directories for plugins (#2284) 2018-07-21 15:57:37 +01:00
90bf94f8f7 Merge branch 'release/3.1' into release/3.2 2018-07-21 09:53:41 +01:00
5e13e2e777 Merge branch 'release/3.0' into release/3.1 2018-07-21 09:53:31 +01:00
1ef6f5d166 ZippedResourcePack: Make manifest parse errors less useless 2018-07-21 09:53:16 +01:00
eccc249009 KillCommand: clean up old shitcode 2018-07-20 19:44:41 +01:00
522ef042a7 yet another empty merge... this is tiresome 2018-07-20 12:21:49 +01:00
4be36914d6 back to dev 2018-07-20 12:21:15 +01:00
e3ef1ecb30 another empty merge 2018-07-20 12:20:54 +01:00
dbaf7287bc back to dev 2018-07-20 12:20:24 +01:00
3640062142 disable dev flag 2018-07-20 12:12:26 +01:00
9af70283fd Empty merge 2018-07-20 12:11:58 +01:00
b3b240e25b disable dev flag 2018-07-20 12:05:14 +01:00
76ee6bc298 Merge branch 'release/3.1' into release/3.2 2018-07-20 11:57:13 +01:00
b18872fbc6 Merge branch 'release/3.0' into release/3.1 2018-07-20 11:57:06 +01:00
2b30ef1671 Revert "Living: fix knockback condition, take 2"
This reverts commit 0081e30a89.

The logic introduced by this commit is correct in MC JAVA 1.9+. Unfortunately, nobody likes 1.9+ for combat.
Some testing in MCPE vanilla made it apparent that this logic isn't correct for MCPE. The old logic is correct for pre-1.9 knockback.
2018-07-20 11:55:10 +01:00
04f20c703c Merge branch 'release/3.1' into release/3.2 2018-07-20 11:30:39 +01:00
dd8499e202 Merge branch 'release/3.0' into release/3.1 2018-07-20 11:30:27 +01:00
124ebf69c5 PlayStatusPacket: default to current protocol if not specified 2018-07-20 11:29:40 +01:00
efe4b0cd3a Merge branch 'release/3.1' into release/3.2 2018-07-18 15:14:34 +01:00
4d1e56069d Merge branch 'release/3.0' into release/3.1 2018-07-18 15:14:27 +01:00
4274640845 Player: fixed on-ground state not being updated when walking horizontally
it's possible to walk off a tower while flying without moving vertically, and this code previously wouldn't detect that, leaving a gaping hole in the anti-cheat.
2018-07-18 15:14:18 +01:00
527d8e9374 Merge branch 'release/3.1' into release/3.2 2018-07-17 18:35:16 +01:00
c1c70a8a98 move up a version
pushing this back to 3.2 so that we can make space for MCPE 1.5 line as 3.1.
2018-07-17 18:34:55 +01:00
45d30d53cc back to dev 2018-07-17 18:33:36 +01:00
cfc8dfa369 disable dev flag 2018-07-17 18:21:02 +01:00
93a2f397c6 Merge branch 'mc-broken-ed-1.5' into release/3.1 2018-07-17 18:13:06 +01:00
62fc875cdc bump version 2018-07-17 18:12:49 +01:00
58b665985e back to dev 2018-07-17 18:09:24 +01:00
0f5c48e342 Disable dev flag for release 2018-07-17 16:59:00 +01:00
b7f15b6574 Merge branch 'release/3.0' into release/3.1 2018-07-17 16:56:57 +01:00
08ad5db05b Config: remove useless switch cases
CNF is the same type as PROPERTIES (it's an alias) so these cases are useless.
2018-07-17 16:56:47 +01:00
6ab2fa84da added some tests for ItemFactory::fromString() 2018-07-17 14:52:47 +01:00
b480c63060 Fixed ItemFactory::fromString() meta handling bug introduced by 71c3c34976 2018-07-17 14:46:08 +01:00
f6b54f5116 Server: don't create levels inside catch-all
Under normal circumstances, none of the boxed code will throw exceptions. Under exceptional circumstances, the caller should know about it. Usually the caller is the server. We don't want to catch unexpected exceptions because those should crash the server and generate a crashdump.
2018-07-17 12:18:46 +01:00
89bfc380e3 Merge branch 'release/3.0' into release/3.1 2018-07-17 12:14:33 +01:00
94e8623c75 Server: account for default provider being missing 2018-07-17 12:14:26 +01:00
40030e9800 added some LevelProviderManager tests 2018-07-17 12:02:08 +01:00
ad1cf38c21 LevelProviderManager: tighten up checks on registering 2018-07-17 12:02:08 +01:00
5d769147ca LevelProviderManager: make addProvider() throw InvalidArgumentException instead of LevelException
LevelException is not useful because it's too generic.
2018-07-17 12:02:08 +01:00
6f00a30ad7 Merge branch 'release/3.0' into release/3.1 2018-07-17 10:12:52 +01:00
b4bf6901e3 Server: remove useless try/catch around Query event firing
this doesn't raise any exceptions, and if it causes Errors to be thrown, those are defects that should be fixed. A catch-all is a bad thing.
2018-07-17 10:10:28 +01:00
921f7e8f6a Level: remove useless check from populateChunk()
this is already checked at the top of the function.
2018-07-16 17:36:36 +01:00
71c3c34976 ItemFactory: prepare for handling items with negative IDs 2018-07-16 13:24:12 +01:00
16c253d7a9 Item: allow negative IDs
this will be needed in the future for extended blocks support.
2018-07-16 12:46:16 +01:00
7efe767f1f Merge branch 'release/3.0' into release/3.1 2018-07-16 12:08:22 +01:00
710e1d014d Entity: fixed 0-length motion vectors being passed to move()
this was an interesting bug.

This was discovered by making a projectile's drag 0, making its gravity a factor of its throw force (such that force / gravity = integer value), and then throwing it directly up. At the apex, an error would occur due to trying to do a ray trace with a zero vector.

This also led me to realize that there's an edge case in the current movement system - if an entity's motion reaches 0, it will stop getting movement updates. This can be undesirable when things such as gravity cause motion to become zero when throwing a projectile directly upwards. This will need to be fixed separately.
2018-07-16 12:08:13 +01:00
2e18fe710c MemoryManager: Shut down idle workers during GC to reclaim memory
workers can be a major memory hog, especially if you have lots of them.
2018-07-14 18:07:37 +01:00
165aac1ba3 Merge branch 'release/3.0' into mc-broken-ed-1.5 2018-07-14 16:09:57 +01:00
878dd3b842 Merge branch 'release/3.0' into release/3.1 2018-07-14 16:06:02 +01:00
7fc22d3227 Entity: fixed setNameTagAlwaysVisible()
mojang >.<

this doesn't fix the problem of invisibility making nametags hidden though.
2018-07-14 16:05:46 +01:00
478a131aa5 Flat: separate logic of parsing preset and generating base chunk
now always generates the base chunk on init, because the generator won't be created unless there is generation to be done.
2018-07-14 11:51:49 +01:00
53068caf3c Level: Only register generators when attempting to actually generate chunks
This saves a ton of memory on servers which don't generate any chunks during their runtime (which is most servers).
2018-07-14 11:34:55 +01:00
fe7ad7a5b3 Merge branch 'release/3.0' into release/3.1 2018-07-14 10:39:28 +01:00
7bfe487ee5 ConcretePowder: fixed a missed usage of Block::get() 2018-07-14 10:35:05 +01:00
24f749a933 Merge branch 'release/3.0' into release/3.1 2018-07-13 12:36:10 +01:00
d8cf835f92 BlockFactory: better handling for dodgy IDs
I thought I'd already dealt with this, but it seems not.
2018-07-13 12:31:22 +01:00
65e44364e5 Added some debug for raw packets and Query handling 2018-07-13 10:07:11 +01:00
af80aefd45 Remove async config save (#2298)
As discussed in #2297:

Honestly I don't see a fit purpose for async saving at all. It should either always be synchronous or always asynchronous, and at the user's own option. However, this isn't currently possible because Config doesn't enable you to get the serialized content without writing it to disk.

Consider the following code:
```php
		for($i = 0, $size = $this->getServer()->getAsyncPool()->getSize(); $i < $size; ++$i){
			$this->getServer()->getAsyncPool()->submitTask(new class extends AsyncTask{
				public function onRun(){
					sleep(5);
				}
			});
		}
		$config = $this->getConfig();
		$config->set("steve", "hi");
		$config->save(true);
		$config->set("steve", "bye");
		$config->save(false);
```
Output:
```yml
---
steve: hi
...
```
Expected output:
```yml
---
steve: bye
...
```

Additionally, if your configs are causing you performance issues when you're saving, it's a clear sign that
a) you're saving too much
b) you're abusing configs and should consider using a database.

Configs should be used for _simple_ data which does not change much. Configuration is such that the _user_ is expected to be able to modify it. As such, it should never be an issue to save synchronously.

In the future, something like ReactPHP may be introduced to allow proper async saving. When this happens, async saving would always be sequential but non blocking. Using threads for this makes no sense.
2018-07-12 19:31:00 +01:00
1d5c741f28 PluginBase: Automatically save default config if it doesn't exist (#2285)
I wasn't sure whether this would be considered a bug fix or a feature. Nonetheless, it's a behavioural change, so it belongs in 3.1 if anywhere.

Prior to this, plugins would be required to call saveDefaultConfig() before calling getConfig() or anything else. Calling getConfig() without saveDefaultConfig() first would generate an empty configuration file. Instead, it now saves the default config before loading it.
2018-07-12 19:25:48 +01:00
3a373b880d Listener: Add documentation on functionality (#2292)
The Listener interface is one of the most magical parts of PocketMine-MP, and before this pull request it didn't have a single bit of documentation.
2018-07-12 19:24:46 +01:00
1b7cd156aa Merge branch 'release/3.0' into release/3.1 2018-07-12 18:04:19 +01:00
ebbbc581ca Player: clean up cursor inventory when closing main inventory 2018-07-12 17:52:22 +01:00
8aa8280a63 Level: Make spawn protection always active regardless of op count (#2290)
I don't care if this matches PC behaviour or not. bugs.mojang.com is full of bug reports about this. Just search for "minecraft spawn protection not working" and you'll see what I mean.

If you want to disable spawn protection, actually disable it. This behaviour is something that most users are not aware of and find astonishing when they discover it.

This behaviour was copied from Minecraft PC, and it's nearly as unexpected there as it is here.

This commit reverses the stupidity done in eb0525e892.
2018-07-12 17:25:05 +01:00
6a637d9099 update pthreads version for travis 2018-07-12 17:23:52 +01:00
7a164a8254 PluginManager: Allow @ignoreCancelled annotation on event handlers to not have parameters (#2294) 2018-07-12 17:12:14 +01:00
4a5ff32d2e hacks for NPC and floating text
I didn't think mojang could break this fucking game any worse
2018-07-11 19:45:48 +01:00
066c990301 Merge branch 'release/3.0' into release/3.1 2018-07-11 10:21:16 +01:00
06b80a9536 Level: Make getSafeSpawn() account for non-generated chunks
fixes #2295

There is still an issue in that the spawn point will not be offset if the chunk is not generated, but this is better than the spawn point being down at y=0. The other issue is a job for another time.
2018-07-11 10:17:59 +01:00
b5dcdea6d8 Protocol changes for 1.5.0 "release"
what a piece of shit this version is...
2018-07-11 10:00:15 +01:00
287ff8d7bf Merge branch 'release/3.0' into release/3.1 2018-07-11 09:15:19 +01:00
b3ffce9729 back to dev 2018-07-11 09:14:38 +01:00
ce9f18c6b4 disable dev flag 2018-07-10 17:38:40 +01:00
9610c55b19 PluginManager: Skip methods not declared by instanceof Listener when registering handlers (#2293)
This is quite an interesting bug. If you have
```php
class A{
    public function onMove(PlayerMoveEvent $event){} //shouldn't be a handler because this class isn't a Listener
}

class B extends A implements Listener{}
```
then
```php
registerEvents(new B, $plugin);
```

then `A::onMove()` will be registered as an event handler even though `A` is not an instanceof `Listener`.

This was observed by noting that plugins which do something like `extends PluginBase implements Listener` causes `registerEvents()` to try and register `PluginBase` methods as event handlers, which could lead to astonishing behaviour.


then A::onMove() will be registered as an event handler even though A is not an instanceof Listener.

This was observed by noting that plugins which do something like "extends PluginBase implements Listener" causes registerEvents() to try and register PluginBase methods as event handlers, which could lead to astonishing behaviour.
2018-07-10 16:59:33 +01:00
1087212d75 Merge branch 'release/3.0' into release/3.1 2018-07-10 12:48:02 +01:00
b01b477a2a Properly fixed newline issues when parsing doc comments
fixes #2110 properly

fixed @notHandler and such not being detected when CRLF is used
2018-07-10 12:46:20 +01:00
0c350f2f57 Add quitMessage parameter to Player::kick() 2018-07-09 18:40:30 +01:00
bfcef2ab6b Add setReason() method to PlayerKickEvent 2018-07-09 18:36:19 +01:00
2994d0f3ae Merge branch 'release/3.0' into release/3.1 2018-07-09 10:06:28 +01:00
2d454ae56f PluginManager: fixed bug in YML commands permission type checking 2018-07-08 16:19:46 +01:00
066c9d4fd4 PluginManager: simplify isPluginEnabled() 2018-07-08 16:16:39 +01:00
23829952c3 PermissibleBase: removed nonsensical code
it's not possible for this to be null, unless a child class doesn't call the constructor, and anything could break in that case anyway.
2018-07-08 13:04:51 +01:00
57cc0ebe75 Merge branch 'release/3.0' into release/3.1 2018-07-08 12:17:06 +01:00
7ee98ff139 Config: fixed whitespace between key and = being invalid
it tolerates whitespace everywhere except here already ^.^
2018-07-08 11:54:06 +01:00
f1cab91ac9 Config: fixed interpreting invalid keys as empty strings
these should just be ignored completely.
2018-07-08 11:50:17 +01:00
7554d9a370 Empty merge 2018-07-07 19:22:30 +01:00
e0bc9c5e96 back to dev 2018-07-07 19:20:55 +01:00
32574118ea Implemented Mending enchantment (#2257) 2018-07-06 13:28:33 +01:00
5a3135659b Merge branch 'release/3.0' into release/3.1 2018-07-06 13:12:13 +01:00
70caa00266 disable dev flag for release 2018-07-06 12:59:02 +01:00
ee7c838040 LoginPacket: barf on finding extraData multiple times
this fixes a potential exploit where clients could append JWTs signed with their own keys to the end of the chain containing fake XUID/UUID/username which would then overwrite the legitimate ones in earlier links.
This stems from the fact that the final link of the vanilla chain contains the client's own pubkey, so the client is able to append its own data to the end of the chain.
2018-07-06 12:54:43 +01:00
34e9e93210 PluginBase: fixed crashing on getConfig() when data dir doesn't exist
I considered making this instead save the default config instead of creating an empty config file, but that would be (albeit minor) a behavioural change which therefore belongs in 3.1.
2018-07-05 19:59:08 +01:00
b90d7d1839 Merge branch 'release/3.0' into release/3.1 2018-07-05 17:43:11 +01:00
5dbb0d177e Fixed double chest inventory desync issues, closes #2261 (#2279)
chest pairing really needs rewriting... this code really sucks
2018-07-05 17:42:30 +01:00
670b940837 PocketMine.php: clean up on platform dependency checks 2018-07-05 17:32:13 +01:00
6cad7be3ef Merge branch 'release/3.0' into release/3.1 2018-07-05 12:11:12 +01:00
28a72a93b4 Chunk: Use an SplFixedArray for heightmap
this goes on 3.1 because it changes the behaviour of chunk cloning, which might possibly break some plugins, and this isn't a bug fix.

This should see no change in behaviour other than a minor performance improvement and slight reduction in memory usage.
2018-07-05 11:58:20 +01:00
58f0ad3e3e Command: remove unnecessary getPermission() calls 2018-07-05 10:38:31 +01:00
0df3585c81 TellCommand: remove useless strtolower() and temp variable 2018-07-05 09:12:21 +01:00
697723b551 DoubleChestInventory: remove redundant clear() override
this calls setItem() which deals with the necessary logic anyway.
2018-07-04 20:06:42 +01:00
5926d80525 DoubleChestInventory: fixed wrong logic for setting items into the right-hand side 2018-07-04 20:04:40 +01:00
0f0d12bebc Merge branch 'release/3.0' into release/3.1 2018-07-02 16:58:15 +01:00
dfc11abf2d Level: fixed sendBlocks() documentation 2018-07-02 16:53:48 +01:00
17eef9f902 Level: stricten type checks on sendBlocks()
because people are morons
2018-07-02 16:53:00 +01:00
a57ec1b1ba Living: fixed death animation not being played when kill() is used
this fixes players having a random delayed despawn when using /kill on themselves
2018-06-29 16:49:40 +01:00
905259a4e1 Fixed not being able to place blocks inside dead players
closes #2265
2018-06-29 16:38:35 +01:00
b04319a4ab Merge branch 'release/3.0' into release/3.1 2018-06-29 12:30:52 +01:00
ca6930006c back to dev 2018-06-29 12:30:08 +01:00
33eeeb856e disable dev flag 2018-06-29 12:21:56 +01:00
0afbf6c547 Merge branch 'release/3.0' into release/3.1 2018-06-29 12:19:25 +01:00
c43ce5c8fa RCONInstance: apply stfu operator 2018-06-29 12:16:17 +01:00
57cfe9fd43 Level: fixed logic for sending changed blocks to players
If there is an empty list of blocks in the changedBlocks array for a chunk, that means that blocks changed the normal way and then were later set the direct way in the same tick. This means that no action needs to be taken on these chunks.
2018-06-29 11:10:31 +01:00
d8824e7ee1 Level: discard changed blocks on chunk replace
this could cause issues when plugins replace chunks when blocks in the chunk have been changed on the same tick.
2018-06-29 11:06:33 +01:00
3455d0f3b9 Level: cleaned up some nonsensical code in setChunk() 2018-06-29 10:58:31 +01:00
ec2cca04a7 Merge branch 'release/3.0' into release/3.1 2018-06-24 17:34:37 +01:00
6b2250cbce RCONInstance: terminate session on ECONNRESET errors 2018-06-24 17:32:51 +01:00
8dae497610 back to dev 2018-06-24 17:32:51 +01:00
cade15e2dd disable dev flag for release 2018-06-24 16:34:19 +01:00
272b76d24c fix Punch mess 2018-06-24 13:43:52 +01:00
8c672cb7c8 Implemented Sharpness, Fire Aspect and Knockback enchantments 2018-06-24 12:13:54 +01:00
4d9368f205 Merge branch 'release/3.0' into release/3.1 2018-06-24 12:07:45 +01:00
97c267c70c Implemented Punch enchantment 2018-06-23 17:40:01 +01:00
85a3c0e7dc Implemented Flame enchantment 2018-06-23 17:11:20 +01:00
d3e54db146 ExperienceOrb: stop tracking targets if they die while being tracked 2018-06-23 16:41:21 +01:00
0081e30a89 Living: fix knockback condition, take 2
onGround doesn't necessarily reflect 0 motion, because something else could change the motion prior to the onGround flag getting updated - for example 2 knockbacks in a row.
2018-06-23 14:30:26 +01:00
2f70a1eefb Implemented Thorns enchantment (#2258)
This implementation is rough and can probably be improved to make it extendable, but this works for now and can be improved later.
2018-06-23 13:36:58 +01:00
7ba6e92b6c Merge branch 'release/3.0' into release/3.1 2018-06-23 13:04:05 +01:00
76174f1920 Explosion: avoid leaving arrows stuck in nonexistent blocks 2018-06-23 13:03:46 +01:00
47c862bc38 Projectile: check for blockhit change on nearby blockupdate 2018-06-23 12:57:13 +01:00
860c20109b TNT can now be ignited by burning arrows 2018-06-23 12:54:21 +01:00
1c0b49343c Implemented Infinity enchantment (#2259) 2018-06-23 11:44:35 +01:00
814a949580 Implemented Power enchantment 2018-06-23 11:39:39 +01:00
b393f5f17e Projectile: ensure that damage multiplier gets saved and restored 2018-06-23 10:41:04 +01:00
f1970492c1 Projectile: added API to modify projectile base damage multiplier
This adds two new methods:
- Projectile->getBaseDamage()
- Projectile->setBaseDamage()
2018-06-23 10:38:58 +01:00
dd6b5902a6 EmeraldOre: fixed not dropping XP on break 2018-06-22 21:35:58 +01:00
87852f2fe1 EmeraldOre: remove excess indentation 2018-06-22 21:31:22 +01:00
056d24c67d Add MUTTON as an ID constant
fixes crashdump #518862 - Unable to resolve "minecraft:mutton" to a valid item

PC refers to these as just mutton, but PE calls them muttonraw
2018-06-22 19:39:18 +01:00
4c9ca53b32 Merge branch 'release/3.0' into release/3.1 2018-06-22 17:47:33 +01:00
484d34fe04 Living: Reset attack cooldown before applying post damage effects
this fixes things causing damage during post-damage calls coming back and being able to do even more damage
2018-06-22 17:47:11 +01:00
6c6630d845 Player: avoid doing some post-melee attack actions if attacking killed the attacker
This can happen when an attacker attacks a victim wearing thorns armour while having low health, which prior to this commit would cause the tool to be duplicated.
2018-06-22 17:17:40 +01:00
a5a236084f Living: don't applyPostDamageEffects() for dead mobs
this has already been seen to cause duplication bugs when thorns is used. Anything else that modifies inventory during applyPostDamageEffects() when the mob is possibly dead will also cause duplication issues.
2018-06-22 14:31:48 +01:00
390db976e5 Arrow: allow controlling pickup mode (like PC)
This allows controlling how arrows are picked up:
- by anything
- by only creative players
- by nothing

This adds new API methods to Arrow:
- getPickupMode()
- setPickupMode()

This adds new public constants to Arrow:
- PICKUP_NONE
- PICKUP_ANY
- PICKUP_CREATIVE
2018-06-22 13:40:32 +01:00
98ac534820 bump version 2018-06-22 13:22:11 +01:00
641a5a5e23 fixed damaged anvils dropping the wrong items
they changed this in 1.2.13 to use regular masks instead of bitshifts. The item was fixed, but not the block.
2018-06-22 09:57:39 +01:00
ebacb8525f SignPost: fixed possible field read on null 2018-06-22 09:12:48 +01:00
579ab5866b Versions again 2018-06-22 09:12:48 +01:00
56b04fa0bb disable dev flag 2018-06-21 12:55:36 +01:00
95787c2be9 TaskScheduler: fixed tasks not getting destroyed when all tasks in scheduler are cancelled before next heartbeat
they got removed from the tasks array, but not from the queue (for performance reasons). The queue gets cleaned up by the heartbeat, but it was checking if there were things in the main array, not in the queue.

There are a couple of other bugs with cancelling tasks that this doesn't fix that are rather more complicated to deal with.
2018-06-21 12:49:08 +01:00
7b7be9618c PluginBase: fixed plugin task timings showing "Unknown" for plugin name 2018-06-21 12:05:30 +01:00
4a8232d591 MemoryManager: Fixed parent private properties not being visible in memory dumps 2018-06-21 12:03:05 +01:00
40e5a1aacb versions again 2018-06-21 12:03:05 +01:00
dbda044229 bump version 2018-06-19 18:34:19 +01:00
d2a037de71 InventoryTransaction: Avoid crashing when trying to compact slot changes with invalid slot numbers
fixes #2250
2018-06-19 18:31:13 +01:00
03510333dc Disable dev flag for 3.0.0 release 2018-06-18 19:46:23 +01:00
064e9464bc Removed --enable-profiler CLI option
krakjoe's profiler hasn't been updated since 2013. I doubt it's going to get updated in the near future. These days we use xdebug, which is either always on or always off.
2018-06-18 12:27:51 +01:00
2d3ce9e8b0 Remove some fully qualified function calls
PhpStorm can't see these or understand how they are being called, which is very annoying for bug hunting. Additionally, we already have the CodeOptimizer for this.
2018-06-18 12:23:19 +01:00
49f80830a7 Clean up unused imports 2018-06-18 12:10:27 +01:00
80daaf09b2 SendUsageTask: fixed oops x2 (thanks PhpStorm)
looks like this file was somehow missed during the refactor.
2018-06-18 12:08:55 +01:00
30ad3a1705 RCONInstance: inherit runtime-defined INI entries 2018-06-18 10:32:17 +01:00
4e7d1a7947 fixed doxyfile 2018-06-17 19:59:45 +01:00
da6439e3f4 SendUsageTask: fixed oops 2018-06-17 16:13:05 +01:00
5f2d4c36c0 Updated Language submodule 2018-06-17 13:04:34 +01:00
1f9bed275a Merged server and API version 2018-06-17 12:54:18 +01:00
77f3ca4d47 PluginManager: make isCompatibleApi() a bit less sub optimal 2018-06-17 11:13:48 +01:00
d88368ceb6 BlockBreakEvent: rename inconsistently-named function 2018-06-16 19:17:13 +01:00
f77a829a52 LevelDB: remove redundant check
Assume that entities on a chunk are not closed... none of the other providers check this
2018-06-16 18:00:26 +01:00
f315aca4c3 Tile: make saveNBT() return a CompoundTag
I don't know why I made it take a parameter for this...
2018-06-16 17:59:41 +01:00
9f7f62e9e5 Don't use Config for builtin JSON resources
it doesn't make sense to use a config in these cases, and also it just hides problems when the files are missing.
2018-06-16 16:35:47 +01:00
cc97f76ec9 Added plugin_data folder to .gitignore (#2243) 2018-06-15 12:49:08 +01:00
3b0aad38cf PocketMine.php: Stop telling noobs to use an installer that doesn't exist 2018-06-15 09:57:08 +01:00
a9b7cd1699 VersionString: Always consider dev builds less than release builds 2018-06-14 13:12:18 +01:00
37b65aac91 AutoUpdater: Use update info for build number instead of trying to parse the version number
the version number might not include the build number, particularly for releases.
2018-06-13 18:19:17 +01:00
ad7787e13b PluginLoader: fixed access protocol, updated devtools 2018-06-13 17:22:29 +01:00
7b0ce16b12 Fixed buckets being able to delete any block 2018-06-13 17:05:51 +01:00
0ff6b7b572 PluginManager: Track enabled plugins in a separate array 2018-06-13 16:54:04 +01:00
763e20ba4e Server: prevent stupidity with settings.async-workers 2018-06-13 16:44:40 +01:00
4b99285fd6 PocketMine.php: remove unused function 2018-06-13 16:33:48 +01:00
03a55d5e9d PocketMine.php: fixed pthreads version 2018-06-13 16:27:02 +01:00
fe29b89fd1 Store plugin data in <data path>/plugin_data in new installations
This will preserve the old behaviour for existing installations.
2018-06-13 12:57:41 +01:00
b0780c4d1d VersionString: Always show the patch version 2018-06-13 12:17:11 +01:00
c835c97aba Fixed phar plugins not reading resources correctly 2018-06-13 12:07:27 +01:00
78eae28a3e Updated dependencies to release versions 2018-06-13 11:17:07 +01:00
31c187f366 Bed: fixed recursion when setting state to something it already is
fixes #2236
2018-06-13 04:16:52 -04:00
2e6afa54c2 [ci skip] typo 2018-06-12 21:20:00 +01:00
e36a6dc8cc Stop RakLib spamming the console when php.ini has a bad timezone 2018-06-12 21:18:33 +01:00
2e9e44ba05 Moved JSON blobs to submodule 2018-06-12 18:49:18 +01:00
c9ec6f0a63 Remove JSON vanilla blobs in preparation for move to submodule 2018-06-12 18:45:37 +01:00
60836ebec9 Updated resources json to use base64 instead of hex 2018-06-12 18:32:26 +01:00
3def3cd502 Item: use base64 instead of hex for json encoding NBT 2018-06-12 18:31:35 +01:00
b5da6b1591 Added a pocketmine.yml kill switch for development builds 2018-06-12 17:11:01 +01:00
8a9af7bf2f Update and sync extension dependencies 2018-06-12 16:27:52 +01:00
8cfd5604cf PocketMine.php: remove 1.3 legacy things 2018-06-12 14:35:11 +01:00
f51743765d Start console reader in a more sensible place 2018-06-12 11:26:34 +01:00
0b9ce8a0d4 Remove server codename
This has long been a waste of time and creativity, and that's only going to continue to be the case now that we're going to be properly versioning. New codenames every couple of months is not worth the bother.
2018-06-12 10:51:49 +01:00
c3c360f589 Bump API to 3.0.0
This may raise a few eyebrows.

Does this mean that all the things that were planned for API 3.0.0 are done?
Not at all. The plans laid out in December 2016 for API 3.0.0 were far too ambitious, and as a result the ALPHA series dragged out forever (18 months now). This is a break away from those plans, to bring development and release flow back to some sort of sanity.

Does this mean that my plugins will stop breaking all the time now?
No, it does not! Development isn't going to stop, although breaking changes will be confined only to major API releases. It's anticipated that the major API version will be bumped as nearly as often as the ALPHA version was during the last 18 months. The reason for this return to 3.0.0 is to allow us to fine-tune our release flow so that plugin developers can get advantage of newer, non-breaking API features without having to bump the API in a breaking way.

What are the criteria for the API versions now?
- Major: This will be bumped for breaking changes, changes which will break plugins. it's expected that we'll roll out new major versions regularly.
- Minor: This will be bumped when non-breaking feature additions are made, such that API 3.0.0 plugins would still load on 3.1.0. However, plugins requiring 3.1.0 will not run on 3.0.0.
- Patch: This will be bumped for bugfix updates. Plugins requiring 3.0.0 will work on 3.0.1, but not vice versa.

TL;DR: This insanity has gone on far too long.
2018-06-12 10:39:49 +01:00
5a55d434ab Nuke plugin loaders from orbit
This features a near-total rewrite of PluginLoaders and some code associated with them.

Highlights:
- PluginManager->registerInterface() does not return anything, and now accepts a PluginLoader instance instead of a string.
- PluginLoader itself is drastically simplified. getPluginFilters(), enablePlugin() and disablePlugin() are now removed. loadPlugin() responsibilities are now solely confined to doing whatever is necessary to make the plugin's classes visible by the server, and does not emit log messages or check for data directories.
- PluginBase->init() and PluginBase->isInitialized() have been removed.
- Plugin interface now declares a signature for the constructor which implementations must comply with.
- Plugin interface now declares setEnabled().
2018-06-12 10:23:49 +01:00
19d2d6b91c PluginManager: use null coalesce in getPermission() 2018-06-11 16:38:27 +01:00
ff2e99ecdc McRegion: nbtDeserialize() cannot return null 2018-06-11 15:05:38 +01:00
07a156f5c4 BaseLevelProvider: remove leftover from b54197904d 2018-06-11 14:32:42 +01:00
13fe8ee96d PluginDescription: fix precedence issue with ?? and cast
this would cause issues if the api field was null or not found.
2018-06-11 13:53:49 +01:00
eb0276d459 Apply nullable and void typehints to events namespace 2018-06-11 13:49:16 +01:00
cfb10360ff Furnace: remove trailing whitespace 2018-06-11 13:31:05 +01:00
05af87e1d4 Strip empty lines at the end of classes 2018-06-11 13:19:23 +01:00
b3ea9606c7 Server: fixed doc comment for shutdown() 2018-06-11 12:32:38 +01:00
a080a9b75c Player: remove redundant parameter from checkNearEntities() 2018-06-11 12:25:01 +01:00
137a05c418 Player: remove useless return value from orderChunks() 2018-06-11 12:22:46 +01:00
245f5c6bef Player: remove obsolete TODO 2018-06-11 12:20:11 +01:00
3be6665e3d AsyncWorker IDs now start from 0 instead of 1
this now matches their IDs in the AsyncWorker pool, as used by submitTask().
2018-06-11 11:58:24 +01:00
8704d378d4 PluginBase::getResources() returns associative array (#2193)
Now, it has string keys, which is the path of the resource file relative to the resources folder.
2018-06-11 11:06:54 +01:00
b9718f9e87 Remove redundant second parameters for BlockFactory::get() 2018-06-11 11:03:23 +01:00
1d1e6966a2 Biome: remove useless abstract class 2018-06-11 11:00:33 +01:00
610b7bd8b0 RiverBiome: don't generate grass underwater 2018-06-11 10:58:30 +01:00
17607b8116 AsyncPool: added some void typehints 2018-06-11 10:41:40 +01:00
4c98d9d3ad AsyncPool: add a type doc to $size 2018-06-11 10:40:01 +01:00
7d5b3079bc AsyncPool: more documentation 2018-06-11 10:38:51 +01:00
88d83e0fca AsyncPool: Lazy-start AsyncWorkers when they are needed only
This changes how the AsyncPool works so that it does not immediately always start all of the workers in the pool.
Instead, workers will be started only when an idle worker was not found.
This allows for significant memory footprint reductions while idle.

In effect the async-workers setting in pocketmine.yml now dictates a _maximum_ pool size, not a fixed pool size.
2018-06-11 10:23:46 +01:00
4b221c0601 OceanBiome: don't inherit from GrassyBiome, change ground cover to gravel 2018-06-11 09:58:48 +01:00
e867427f71 Leaves: remove useless $check parameter
this is only written to and never read from.
2018-06-10 17:20:34 +01:00
c4c6c58615 Added some missing typehints 2018-06-10 17:18:55 +01:00
89643ff9af MainLogger: Added getFormat() and setFormat()
this allows plugins to easily alter the output of the console logger.
2018-06-10 10:49:12 +01:00
9657d50aeb MainLogger: workaround --disable-ansi not being respected on other threads 2018-06-10 10:24:49 +01:00
3725bea3e5 AsyncPool: Slightly reduce worker memory usage with more conservative start options
this results in a memory footprint reduction of maybe 4MB for a total of 8 workers. Not much, but it's something.
2018-06-10 10:18:07 +01:00
f3a84b332b Updated RakLib and SPL dependencies, allow any 0.3.x SPL 2018-06-09 20:13:27 +01:00
f6481eab8f Implemented an InventoryEventProcessor, fixes #1986 (#2176)
* Implemented InventoryEventProcessor, fixes #1986
Event processors can now be registered and unregistered at will. Entity inventory/armor change events are now handled by event processors instead of the inventories themselves, which allows enabling/disabling the calling of these events at will.
This now avoids stupid things happening when initializing inventory contents, since the callers for those events are now registered _after_ the contents are initialized.
2018-06-09 17:37:10 +01:00
8e5aca70b4 Entity: Avoid using close() during initEntity()
this simply conceals bugs and will cause astonishing behaviour.
2018-06-09 17:06:15 +01:00
85136b7b4a Entity: Attach to level & chunk after initEntity() call, not before
this avoids leaving garbage entities attached to chunks when exceptions are thrown during initEntity().
2018-06-09 16:59:22 +01:00
47742d74c8 Player: Drop load queue on level switch
This ensures that the player doesn't request bad chunks if it was teleported from an invalid level.
2018-06-09 16:21:41 +01:00
ca54c8d78e Merge branch 'master' of https://github.com/pmmp/pocketmine-mp 2018-06-09 16:21:01 +01:00
601811f0f8 Player: Account for the possibility of Level being null in switchLevel()
the Entity base also accounts for this, and assuming that this is automatically valid is causing lots of crashes. I am not sure of the circumstances under which this is suddenly becoming null, but this shouldn't assume that the level is valid nonetheless.
2018-06-09 16:20:51 +01:00
aeb551b317 Remove double use of spl_object_hash (#2226) 2018-06-09 14:15:50 +01:00
37b445f210 Updated Math dependency 2018-06-09 13:05:25 +01:00
d04991feb6 Level: Avoid chunk sending bugs caused by duplicate chunks with wrong coordinates
If the same chunk is set into multiple different places in the world, the chunk's position is no longer able to be relied on, because it will have the position of the last place it was set. This results in chunks not getting sent correctly when the same chunk is set in multiple places.

This avoids the bug by using known valid coordinates (using chunk hashes) to establish the real coordinates, and also adds an assert to notify developers should they unintentionally set a duplicate chunk by mistake.
2018-06-09 11:25:45 +01:00
c327b3d2c4 AsyncPool: be less dependent on Server in the code
The goal is to remove the Server things from here completely.
2018-06-08 20:08:23 +01:00
af69418a55 PlainBiome: reduce maximum elevation 2018-06-08 13:04:45 +01:00
8cd311bcb4 GroundCover: don't replace liquid with can-be-flowed-into blocks
fixes snow layers generating underwater
2018-06-08 11:15:19 +01:00
78ec3937bf BiomeSelector: drastically simplified implementation and made more robust
- Doesn't need to be pre-populated with biomes prior to calculating the heatmap - now population of biomes is entirely dependent on the lookup function, improving consistency
- Uses an abstract class method for lookup instead of callback (use anonymous class instead)
- Faster because the heatmap is directly populated with biomes instead of biome IDs, removing an unnecessary lookup.
2018-06-08 10:19:08 +01:00
4e3e807741 Biome: Added UnknownBiome class to avoid astonishing behaviour on unknown biomes 2018-06-08 10:19:08 +01:00
8c6161a4f2 Biome: make biomes list use an SplFixedArray 2018-06-08 10:19:08 +01:00
c8a87b14d5 PopulationTask: actually fix locks not getting released in generation errors 2018-06-07 23:53:59 +01:00
8fca7cc68d Apply some typehints to generators 2018-06-07 20:22:35 +01:00
45f940681a Make Normal->pickBiome() private 2018-06-07 20:21:26 +01:00
e3c97d7d5e Flat: clean up more garbage 2018-06-07 20:18:04 +01:00
172abef2a7 Flat: clean up generation of base chunk 2018-06-07 20:11:29 +01:00
709abb02e6 Generator: remove more dead incomplete code
again, this can be added when and if it's actually implemented.
2018-06-07 19:54:51 +01:00
428ca29e4b Remove dead bedrockDepth fields from generator
yes, this is not implemented yet. fields for this can be added when proper bedrock generation is implemented. For now, it's just dead code.
2018-06-07 19:52:56 +01:00
f61ad20f6b Remove a whole bunch of dead copy-pasted code from Nether generator 2018-06-07 19:51:27 +01:00
3c9af5cd6d Generator: small reduction of code duplication 2018-06-07 19:49:51 +01:00
996935e9b2 Cleaned up level seed handling 2018-06-07 19:39:24 +01:00
3707a41b67 Server: small cleanup to seed handling 2018-06-07 18:25:44 +01:00
354b2dc5d1 and an extra note just in case 2018-06-07 15:20:51 +01:00
0c70b83d81 LevelProvider: workaround bug fixed in b54197904d for previously-affected worlds 2018-06-07 15:18:42 +01:00
083a1e1ff6 GeneratorManager: Make addGenerator() throw exceptions instead of returning false 2018-06-07 14:34:26 +01:00
17b58357fb GeneratorManager: add documentation for functions 2018-06-07 14:30:19 +01:00
96a4dbb7d8 GeneratorManager: add typehints 2018-06-07 14:24:01 +01:00
5eec683110 Generator: Moved generator registering things to a separate GeneratorManager class
this isolates the concerns of the Generator class, and also removes cyclic dependencies between the Generator class and its descendents.
2018-06-07 13:48:01 +01:00
0bca3cd481 Generator: Move static noise functions to Noise instance methods 2018-06-07 13:40:10 +01:00
b54197904d Fixed imported worlds getting PM classpaths written into their level.dat for generator
This will not fix existing worlds affected by this bug.
2018-06-07 13:20:50 +01:00
fb484087a8 Entity: Remove unnecessary scheduleUpdate() call from initEntity()
this is already done by the constructor
2018-06-07 12:53:59 +01:00
14914781fc Added exception throws when a closed tile or entity attempts to schedule itself for updating
I can't believe it took so long to find what was causing these stdClass bugs.
2018-06-07 12:37:26 +01:00
fdd5b7b9c9 Entity: Fixed despawn flagging not kicking in until scheduling updates on entities 2018-06-07 12:34:23 +01:00
c83c0eb935 Entity: Move responsibility of checking for despawn to Level
this ensures that flagging for despawn will always work as intended, including when onUpdate() is overridden.
2018-06-07 12:31:21 +01:00
b331f8e1c9 AsyncWorker: added removeFromThreadStore()
and use it instead of overwriting with null things, which still occupies memory
2018-06-07 10:12:50 +01:00
ee787974f2 AsyncWorker: Use statics for thread-local worker storage instead of globals 2018-06-07 09:59:32 +01:00
73e56c8a36 Utils: Make kill() use static MainLogger instead of global variable 2018-06-07 09:29:53 +01:00
5f7c884255 Reduce AsyncWorker default memory limit to 256MB
a worker shouldn't be using as much memory as the main server thread would, so 1024MB is extremely excessive.
2018-06-06 18:49:48 +01:00
2b5e6b790f BanList: rename poorly-named parameter 2018-06-06 18:18:06 +01:00
1a21041d00 AsyncPool: Parameterize worker memory limit instead of calling back into Server 2018-06-06 18:00:56 +01:00
7b17a83227 Level: fix chunk locks not getting released on generation errors 2018-06-06 11:42:29 +01:00
edd150971e CommandReader: Use statics for thread-local storage instead of globals 2018-06-06 10:06:52 +01:00
38f4afb17c Make sure that test failures kill the build 2018-06-05 19:49:22 +01:00
9d16863b1a Convert some TesterPlugin tests into PHPUnit tests, add PHPUnit configuration 2018-06-05 19:33:21 +01:00
41a179e6e1 BlockFactory: fix bug in light filters which could result in negative light levels (and therefore wraparounds) 2018-06-05 18:12:45 +01:00
3a31c531af Level: remove unused import 2018-06-05 13:04:24 +01:00
e081b7dffa PermissibleBase: fix typehints of calculateChildPermissions() 2018-06-05 11:14:36 +01:00
0233ae1eb6 Updated TesterPlugin submodule 2018-06-04 21:17:48 +01:00
dce8ed9dd1 Eliminate more hard dependencies on MainLogger 2018-06-04 16:52:03 +01:00
35eaf38ca1 MemoryManager: parameterize an abstract \Logger to remove dependency on MainLogger 2018-06-04 13:30:48 +01:00
1d71f0cf43 AsyncWorker: added getLogger() 2018-06-04 13:29:38 +01:00
9644766df3 Merge pull request #2213: Scheduler API refactor, plugins now have their own schedulers
- Removed `Server->getScheduler()`. All plugins now have their own scheduler which is accessible using `Plugin->getScheduler()`. Aside from being syntactically more concise and pleasant, this also allows much more effective management of tasks when plugins are disabled.
- Removed `PluginTask` class. Before this PR it was necessary for plugin tasks to descend from `PluginTask` to ensure that the server could clean them up correctly on plugin disable. This is no longer necessary, so the `PluginTask` class has been removed. Plugins may now utilize the `Task` class as a base if they like.
- Added `Server->getAsyncPool()`. Since the global scheduler does not exist any more, it does not manage the server's `AsyncPool` any more. Additionally, `ServerScheduler` was previously bloated by a lot of `AsyncTask` related methods, which are now not necessary because direct access to `AsyncPool` is granted instead.

- `ServerScheduler`:
  - `ServerScheduler` has been renamed to `TaskScheduler` since it is now a general-purpose task scheduler which is non-dependent on the user. This allows much greater flexibility and also makes it possible to unit-test.
  - All `AsyncTask`/`AsyncPool` related methods have been removed - the task scheduler does not manage the async pool anymore.
    - Calls to `Server->getScheduler()->scheduleAsyncTask()` should be replaced with `Server->getAsyncPool()->submitTask()`.
    - Calls to `Server->getScheduler()->scheduleAsyncTaskToWorker()` should be replaced with and `Server->getAsyncPool()->submitTaskToWorker()`.

## Backwards compatibility
This poses significant backwards compatibility breaks for any plugins utilizing Tasks or AsyncTasks. These breaks are described above, along with basic upgrade steps. The upgrade process is quite straightforward.

## Follow-up
A large part of the goal with this pull request is to modularize these parts of the code so that they can be reused and also unit-tested. I would like to remove the existing test set from TesterPlugin at some stage when the AsyncPool can operate without a Server.

Because of the above, I am considering making further backwards incompatible changes directly to `AsyncTask` to remove the `Server` parameters from `onCompletion()` and `onProgressUpdate()`. These shouldn't be too difficult to upgrade from and can be prepared for in advance.
2018-06-04 11:54:43 +01:00
857f6dd5df Chunk: Share EmptySubChunk instance with other chunks on the same thread 2018-06-04 11:44:18 +01:00
0d177d5219 Entity: Clear dirty properties at the end of the constructor
this prevents sending duplicate properties immediately after entity spawn (due to properties getting set in the constructor).
2018-06-04 11:18:42 +01:00
fe21f0e916 Spawnable: change visibility of addAdditionalSpawnData() 2018-06-03 19:58:48 +01:00
4c1d29cdf7 Tile: remove unnecessary removeTag() calls
these CompoundTags are now ephemeral, so it's not necessary to remove potential garbage from them anymore.
2018-06-03 18:31:23 +01:00
fa21cd96c5 Tiles no longer store their NBT at runtime
This is a significant breaking change for anything utilizing Tiles as they now do not store their NBT at runtime anymore.
This is another step in the process of ridding PocketMine-MP of runtime NBT.

It can be noticed that all tiles are now using class fields to store properties instead of NBT, which is much faster, uses less memory and is also more concise when written in code.

Highlights:
- Tile->namedtag has been removed.
- Tile->saveNBT() now accepts a CompoundTag() parameter. Typically it's expected that this will be fed a newly-created CompoundTag (this part may be improved in the future).
- New internal methods Tile->readSaveData() and Tile->writeSaveData() have been added. Instead of overriding __construct() and saveNBT() to load and save properties from NBT, you should now implement these methods instead.

This is not final and will see further changes before it's done.
2018-06-03 18:29:08 +01:00
a22e5616f6 Fixed tile and furnace custom names not being visible
This is caused by the Spawnable constructor calling spawnToAll() before the tile is fully initialized. I really really really hate constructors that _DO_ things by themselves.
2018-06-03 17:02:00 +01:00
b6317fa7ce Sign: remove non-standard broken bad solution for editing
this never really worked properly and is a bad idea anyway. This was the cause of many sign-going-blank bugs before it was broken (by me), and since it's broken it's now useless. I don't think there's any practical way to make this work properly, so I leave it up to plugins to decide whether or not they want to cancel sign editing in protected areas. PocketMine-MP built-in spawn protection will already block this by default anyway.
2018-06-03 16:45:26 +01:00
b1cb63ebd6 Tile: make ContainerTrait and NameableTrait non-dependent on context-retained NBT 2018-06-03 16:32:05 +01:00
7b7917939a Cleaned up Container lock handling 2018-06-03 13:42:04 +01:00
6aaaaefd2f Make tiles less dependent on runtime NBT, use properties instead
This will ultimately culminate in the complete removal of runtime NBT, so plugins should also follow these steps if they have custom data.
2018-06-03 12:50:16 +01:00
1bb0337420 Tile: Improved Nameable and NameableTrait to cut down code duplication 2018-06-02 15:17:32 +01:00
b6b0bbde18 Level: remove nonsensical code from generateChunkCallback()
it's impossible for this to be null when we just set it to a Chunk object. It's assigned directly to the chunk index.
2018-06-01 19:47:47 +01:00
5d07f66d86 Travis: Limit worker count to 4
By default it starts 30 workers on Travis because there are 32 logical cores available. This is ridiculously excessive and pollutes the log with debug spam.
2018-06-01 18:58:30 +01:00
ec28612a12 BlockFactory: partial revert of 515e4aabc4
it's necessary to register these to fill the static property arrays. Someday these won't be necessary I hope...
2018-06-01 17:08:58 +01:00
6047810113 Level: remove useless null checks for fastDeserialize() returns 2018-06-01 17:02:29 +01:00
d535fe20a3 BlockFactory: split up static ID mapping registration from other things
this is actually HUGELY WASTEFUL on memory. An average of 3 MB is wasted per AsyncWorker on this.
2018-06-01 10:28:53 +01:00
515e4aabc4 BlockFactory: minor reduction in memory usage
removing useless array and don't pre-populate with UnknownBlock objects
2018-06-01 10:15:20 +01:00
f27c6fcf70 ResourcePack: slightly better handling of bad configs 2018-05-31 18:30:21 +01:00
7864a315f6 ResourcePackManager: cleaned up pack loading error handling 2018-05-31 17:58:47 +01:00
02b4eeeb9b TaskScheduler: Remove repeating tasks which throw exceptions 2018-05-31 14:10:59 +01:00
6b4b4e4bb1 TaskScheduler: remove redundant else branch 2018-05-31 13:01:06 +01:00
f2b8d6879f TaskScheduler: remove leftover code that makes no sense
this is impossible now that we have typehints
2018-05-31 12:52:29 +01:00
60212cef2f TaskScheduler: adjust disabled scheduler exception 2018-05-31 12:38:36 +01:00
15270f8329 Fixed plugin schedulers crashing after disable/reenable 2018-05-31 12:34:22 +01:00
05ef13b23a Merge branch 'master' into scheduler-nuke
# Conflicts:
#	src/pocketmine/level/Level.php
2018-05-31 10:40:10 +01:00
1b4723d816 AsyncWorker: don't require an attachable logger 2018-05-31 10:34:42 +01:00
c493d0e6ac Level: Stop unnecessarily initializing the generator on the main thread
this is just slowing down startup times for no good reason.
2018-05-31 10:22:44 +01:00
b3043f9552 Task: remove obsolete doc comment
not anymore sunshine
2018-05-30 21:30:43 +01:00
18fdbc2834 TaskScheduler: fix typo in isReady() parameter 2018-05-30 16:45:37 +01:00
a8c766be88 Remove TaskHandler dependency on MainLogger
This instead allows the exception to be caught by the scheduler and reported using its logger.
2018-05-30 16:00:25 +01:00
e20be3eeba Move task timings responsibility from scheduler to handler 2018-05-30 15:38:39 +01:00
51f43fb375 Removed global ServerScheduler - plugins now get their own isolated schedulers
This change breaks pretty much all API pertaining to synchronous task scheduling.

Significant changes:
- Server->getScheduler() has been removed
- Plugin->getScheduler() has been added - every plugin now has its own scheduler
- Because schedulers are now per-plugin, it is now unnecessary for PluginTask to exist because stopping plugin tasks on plugin disable is as simple as destroying the plugin's scheduler. Therefore PluginTask has now been removed and it is expected for things to now use the base Task class instead.

For the most part, plugins will simply need to change Plugin->getServer()->getScheduler()->... to Plugin->getScheduler()->...
Another highlight is that plugin tasks now no longer have global IDs - they are unique to each scheduler.
2018-05-30 14:11:11 +01:00
132746aa3d ServerScheduler: Require a Logger instance as ctor param, now non-dependent on Server
yay for unit-testing and reusability!!!
2018-05-30 12:29:19 +01:00
d03f36ebee First look at splitting up AsyncPool and ServerScheduler
This commit contains quite a few breaking changes with respect to how AsyncTasks are handled. This is necessary to allow separation of the ServerScheduler and the AsyncPool, because in the future the ServerScheduler may be removed and instead there will be isolated per-plugin sync-task schedulers - but we cannot have every plugin with its own worker pool for memory usage reasons if nothing else.

The following things have changed:
- ServerScheduler: scheduleAsyncTask(), scheduleAsyncTaskToWorker(), getAsyncTaskPoolSize(), increaseAsyncTaskPoolSize() and similar methods have all been removed. Additionally the static \$WORKERS field has been removed.
- Server: added API method getAsyncPool(). This grants you direct access to the server's AsyncPool. Calls to getScheduler()->scheduleAsyncTask() and scheduleAsyncTaskToWorker() should be replaced with getAsyncPool()->submitTask() and submitTaskToWorker() respectively.
2018-05-30 12:20:10 +01:00
7fce48d38c AsyncPool: Unstack tasks from workers before entering the below loop 2018-05-30 11:17:16 +01:00
b7ca045c51 updated TesterPlugin submodule 2018-05-29 20:11:29 +01:00
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
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
0a50b8cb9b Removed imports left over from 4f8f334436 2018-05-29 11:42:12 +01:00
6d53350291 Level: Moved LightPopulationTask out of generator namespace 2018-05-29 11:20:27 +01:00
ad61d70eee Level: added getBiome()
this will be needed for weather impl, amongst other things.
2018-05-29 11:10:06 +01:00
353a1d69db Level: move getHeightMap() to be more consistent 2018-05-29 11:10:06 +01:00
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
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
ad15ab5b42 EnchantCommand: use Item->isNull() instead of maths on ID 2018-05-28 19:45:37 +01:00
b003295d01 Player: reduce duplicated code in PlayerActionPacket handler 2018-05-28 19:38:29 +01:00
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
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
0a9ed059d6 Level: fixed logic of getCollisionBlocks() to match getCollisionCubes() 2018-05-28 17:40:05 +01:00
74c0863905 Living: fixed preventing effect expiry using events, closes #2208 2018-05-28 17:14:18 +01:00
87ff1c0382 Player: don't catch Throwable on transaction creation failure 2018-05-28 17:00:59 +01:00
2eaba7c936 Timings: added timings for Player->checkNearEntities() 2018-05-28 16:27:03 +01:00
3ee6bfca2a Updated Math dependency 2018-05-28 14:04:17 +01:00
63ab27550a Level: Use bitshifts instead of division in some cases 2018-05-28 14:02:32 +01:00
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
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
982444949c Fixed typo in AsyncPool
asychronous -> asynchronous
2018-05-26 16:30:49 +01:00
8cf0fc63d8 Player: spawn at safe-spawn on level not found, instead of real spawn 2018-05-26 12:20:58 +01:00
c18ba38b74 Entity: avoid astonishing behaviour with motion vector modifications 2018-05-26 10:40:04 +01:00
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
8ccd13319c LevelSoundEventPacket: update constants
now with whitespace gaps generated because apparently some are missing... ugh!
2018-05-25 17:27:31 +01:00
c513d355cb Updated Snooze dependency 2018-05-25 13:52:12 +01:00
02b53785be Entity: added some new ID constants 2018-05-24 12:39:44 +01:00
9dd0ee7f05 Entity: replaced motion and lastMotion fields with vectors 2018-05-24 12:11:41 +01:00
595f1f58da Living: added knockback resistance attribute checks 2018-05-24 11:49:18 +01:00
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
263cd900a8 Enchantment: update item type flags 2018-05-23 17:39:52 +01:00
164ce76ff5 Enchantment: apply typehints to PHP 7.2 standards 2018-05-23 17:28:40 +01:00
fbf760bafe Enchantment: implemented Vanishing 2018-05-23 17:23:56 +01:00
2c1afe5f2c ItemFactory: generate some TODOs 2018-05-23 13:42:19 +01:00
b109b457dc Item: added some new constants 2018-05-23 13:35:15 +01:00
e12e2897bb Enchantment: Add new constants
these aren't registered yet because they aren't implemented.
2018-05-23 12:34:58 +01:00
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
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
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
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
c9ed517063 Merge branch 'release/alpha12' 2018-05-22 18:50:24 +01:00
28b0f5f86a UpdateBlockSyncedPacket: rename field 2018-05-22 18:49:41 +01:00
e87e2d4e52 UpdateBlockSyncedPacket: fix field visibility 2018-05-22 18:49:41 +01:00
86c27953ec NetworkBinaryStream: bail on unknown entity data types 2018-05-22 16:44:03 +01:00
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
c7ac5dfd4b Fixed the doc comment in Plugin::getResources()
It returns SplFileInfo[] not string[]
2018-05-21 17:24:12 +08:00
bd9b59f401 Contributing: be more clear about committing on GitHub 2018-05-21 09:59:56 +01:00
2f03f5f6d5 Fix a grammar error in Player (#2197) 2018-05-20 21:27:40 +01:00
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
adb9390b53 Entity: Rename isInsideOfWater() to isUnderwater() 2018-05-19 18:10:43 +01:00
6111ce7df1 Human: don't hardcode max food 2018-05-19 16:48:21 +01:00
1f73c08762 Human: fix possible bug with food ticking
it updates it but doesn't take note of the updated value, which could cause the code below to be erroneously triggered.
2018-05-19 16:47:04 +01:00
2900167ffa Human: removed redundant isSprinting() check from doFoodTick()
this is checked in setSprinting() anyway.
2018-05-19 16:33:13 +01:00
11cc9f19ad Human: replace hardcoded difficulty values with constants in doFoodTick() 2018-05-19 16:32:30 +01:00
807af2e6fb Human: change doFoodTick() visibility to protected 2018-05-19 16:30:41 +01:00
f2511983cf Level: use increment operation for updating time 2018-05-19 16:05:08 +01:00
bac649137b Level: fixed doc comment for getSafeSpawn() 2018-05-19 14:02:54 +01:00
71224f51d5 Level: cleaned up some nonsensical code in getSafeSpawn()
it's impossible for this function to return false because $spawn is guaranteed to be a Vector3 when it's checked in instanceof.
2018-05-19 13:18:20 +01:00
6c3fc4af46 Level: switch order of addEntity() and removeEntity()
now it's consistent with addTile() and removeTile()
2018-05-19 13:14:11 +01:00
75d13be38e EnderChestInventory: remove unused import 2018-05-19 11:37:22 +01:00
9bc860f7a8 LevelDB: fixup extra-data handling, don't delete it - just don't read it
we'll need this once multi-layer block storages are implemented.
2018-05-19 11:35:54 +01:00
66963fbf9a Nuke block extradata
this has been superseded by multi-layer blockstorages in 1.2.14+
2018-05-19 11:03:28 +01:00
172c6420c1 Server: add type documentation for fields
found a few bugs in the process too
2018-05-19 10:55:34 +01:00
e7fc9227bc Server: fixed bug in alwaysTickPlayers config 2018-05-19 10:53:31 +01:00
13cd0cdcfd Server: cast result of getProperty() for networkCompressionAsync 2018-05-19 10:52:09 +01:00
0bb5e88b5c Hinting up Entity API to PHP 7.2 standards 2018-05-19 10:46:47 +01:00
389990e0a8 Entity: remove useless functions
these may be TODOs but I have no idea why or where they need to be implemented, so until they do they are useless clutter.
2018-05-18 20:09:55 +01:00
067aad9546 PocketMine.php: Remove unused \pocketmine\ANSI constant
Terminal::hasFormattingCodes() should be used instead (this is also portable across threads even if constants aren't inherited by child threads, provided that the child thread has an autoloader available.
2018-05-18 18:51:18 +01:00
b1a7606e82 PocketMine.php: Take dependency versions for granted
Since this is managed by Composer now, it's expected that users should install dependencies appropriately when running from source code. We have a few more dependencies than just RakLib and SPL which are version-critical which are not checked here, and I don't have the taste for adding more version checks here.

A better way would be to automatically detect outdated Composer autoloader and warn that dependencies might need updating, but I'm not sure how to do that off the hop. Users should prefer using prebuilt phars anyway - only developers and/or people who know what they are doing should be running the server from source code.
2018-05-18 18:47:12 +01:00
febba6e3a6 Tile: call parent constructor instead of duping code 2018-05-18 16:49:14 +01:00
d8dc89e7c8 EnderChestInventory: Removed unnecessary owner parameter 2018-05-18 16:46:48 +01:00
b75413e3c4 CommandReader: Use stream_isatty() instead of posix_isatty() (new in 7.2) 2018-05-18 16:46:48 +01:00
f08537a1e0 BlockMetadataStore: fix case of import
found by PHPStan static analysis tool
2018-05-18 16:46:48 +01:00
6643fa5f09 README: it's not Pocket Edition anymore 2018-05-18 14:54:50 +01:00
210e108574 Level: add a null coalesce
meant to add this before push but wasn't thinking clearly...
2018-05-18 11:28:52 +01:00
813437e3ee Level: Avoid unnecessary use of getChunk()
this is completely pointless.
2018-05-18 11:27:53 +01:00
24295ce02f Level: Avoid creating useless throwaway objects in sensitive functions 2018-05-18 11:05:41 +01:00
29fd26627e Level: Change isInWorld signature to use ints instead of floats
this is only used in one place, where it's being given floats, and it's 10% faster to use int for this because it won't convert it.

It is also 25% faster to remove typehints and 60% faster to inline it. We really need a proper PHP preprocessor for inlining.
2018-05-18 11:01:13 +01:00
22b91aaa24 SubChunkIteratorManager: Added method invalidate() to allow destroying stale chunk refs conveniently
this could be necessary for reusable long-life iterators when chunks get replaced.
2018-05-18 09:52:27 +01:00
f757ba1851 Merge branch 'release/alpha12' 2018-05-17 19:27:26 -04:00
8c1c8f34cc Player: confine command data resending on permission recalculate to post-spawn only
this fixes crashes when PurePerms causes this to be recalculated on player login - the client doesn't like receiving this before StartGame and crashes.

Confining this to post-spawn should not cause any issues since any permission recalculation in login events will be reflected immediately afterwards when the initial command data is sent anyway.

This same bug popped up at 1.1... I don't know why it wasn't fixed properly back then.
2018-05-17 19:26:42 -04:00
c285295037 Merge branch 'release/alpha12' 2018-05-17 18:40:24 +01:00
2034caf71c Merge branch 'mcpe-1.4.0-alpha12' into release/alpha12 2018-05-17 18:38:58 +01:00
89ccac7a8c updated blockIDs table 2018-05-17 16:17:26 +01:00
f6e71d8296 Protocol changes for 1.4.0 release
this is nearly the same as 1.5.0.0, except the skin packet premium boolean has been dropped.

This isn't production ready yet because the blockID table needs updating (waiting on MrARM to fix his script for that).
2018-05-17 10:36:16 +01:00
b333a0e24c PlayStatusPacket: add new constant 2018-05-17 10:33:18 +01:00
8312ad709e InventoryTransaction: Removed creationTime
this is no longer necessary because transactions now always arrive in a single packet.
2018-05-16 12:14:29 +01:00
63fc04b3dd thanks for being useless PhpStorm 2018-05-13 11:56:32 +01:00
34b8557094 Moved parseDocComment from PluginManager to Utils 2018-05-13 11:24:04 +01:00
edaef588ab CommandReader: remove unnecessary setClassLoader() call
this is already handled in start() anyway.
2018-05-12 12:47:28 +01:00
889222e9c5 MainLogger: Use PTHREADS_INHERIT_NONE
this thread doesn't need to inherit anything because its sole purpose is to write log messages to file.
2018-05-12 12:39:13 +01:00
8239c67b1a Enchantment: split up primary and secondary flags
closes #1911
2018-05-12 11:20:27 +01:00
ed65e91a3c Tree: avoid astonishing behaviour with dark-oak and acacia saplings
ref #1973, these should simply not grow at all since they are not implemented yet.
2018-05-12 10:03:20 +01:00
619390c5b7 Sapling: Account for light level when trying to grow on random ticks 2018-05-11 09:53:03 +01:00
7e70569ba2 Player: Send all open inventories instead of hardcoded selection
Players have a few associated inventories which might need sending nowadays, such as main, armour, offhand (not implemented yet), cursor, crafting (if it ever worked). Under these conditions we should be sending all open windows.
2018-05-11 09:28:59 +01:00
083ac8a770 Clean up Tool garbage leftovers
these were intended to be removed long ago, but other things came up and durability handling still depended on them.
2018-05-11 09:23:51 +01:00
b21572774a Tool: cleanup durability handling, closes #379
long overdue... this isn't quite as extensible as the original api3/blocks system was, but this is primarily intended to replace Item->useOn(). If plugins want to use it it can be extended later on.
2018-05-10 19:48:51 +01:00
b8523cb304 Merge branch 'remove-weak-position' 2018-05-10 13:53:07 +01:00
6ceb9af749 .-. 2018-05-10 12:51:39 +01:00
bcd197d7bb AsyncWorker: fixed __construct() signature 2018-05-10 12:50:09 +01:00
3148f692c1 AsyncWorker: No need to register static logger - it's inherited by default with pthreads 3.1.7 2018-05-10 12:49:03 +01:00
d8d22efc3b Server: avoid abusing Throwable in a couple of places 2018-05-10 12:46:13 +01:00
7b3653f75d SetupWizard: remove dead constant 2018-05-10 12:39:15 +01:00
9c5f7128a4 RCON: lots of cleanup, now notification-based instead of poll-based
This now utilizes Snooze in order to have the server wake up to process RCON commands ondemand, similar to how the CommandReader thread operates. This is better for performance and response times.

This also makes a few other changes:
- RCON thread will now waste less CPU since it uses a blocking select() with timeout to read
- Following from that, IPC sockets are used to allow interrupting select() from the RCON thread.
- Multiple threads for RCON has been removed (this is entirely unnecessary, reading data from sockets is not CPU-intensive, and a single thread is easier to work with)
2018-05-10 12:33:05 +01:00
1e4a97f921 Server: remove dead code from forceShutdown() 2018-05-10 11:30:50 +01:00
4d743ade45 CrashDump: resource hygiene 2018-05-10 11:29:16 +01:00
78b5cc993b Server: fixed signatures and type-checks for logger
this might not be a MainLogger instance, but it definitely has to be an \AttachableThreadedLogger instance.
2018-05-10 10:49:41 +01:00
5e91c05424 Server::getIp() now returns 0.0.0.0 if the IP string is empty 2018-05-10 10:25:44 +01:00
e7c5d14af3 Fix DoubleSlab name (#2177) 2018-05-09 21:17:35 +01:00
126a97b405 ServerKiller: fixed start/stop race condition
in some cases the main thread was trying to signal the server killer to stop before it was even started due to limited resources available for scheduling.
2018-05-09 20:59:56 +01:00
753ed3801d update RakLib version 2018-05-09 20:18:36 +01:00
68ef4b210d Allow RakLibServer to inherit constants (PATH const is needed for exception logging)
this is very annoying and needs a better fix.
2018-05-09 20:08:25 +01:00
c3822b795c CommandReader: use PTHREADS_INHERIT_NONE
probably not necessary to register autoloader, but just in case...
2018-05-09 20:02:51 +01:00
be0e85dfae CommandReader: fix notifier race condition crash, don't start self in constructor
self-start is extremely annoying!
2018-05-09 20:01:16 +01:00
72690ea7f5 RakLibInterface: start RakLibServer with PTHREADS_INHERIT_NONE
this is now OK since the logger colours will be initialized on the fly.
2018-05-09 20:00:09 +01:00
c9bd60123b Scheduler: shutdown async pool properly instead of relying on ThreadManager 2018-05-09 19:49:12 +01:00
05f4262e81 MainLogger: moved format to private variable 2018-05-09 18:14:46 +01:00
dd11bcaf11 Fixed #1979: logger colours don't show on other threads when classes are not inherited 2018-05-09 18:07:12 +01:00
b96adda14d MainLogger: Colorize at point of echo, not beforehand
this removes the need for a hack I had to do with ClientConsole to translate ANSI colour codes back into MC colour codes.
2018-05-09 18:04:16 +01:00
5c66c615bf Living: fix possible crash in getTargetBlock()
ArrayOutOfBoundsException is not thrown by SPL anymore since the exception handler throwing it was removed by @shoghicp. Regardless, it seems cleaner to to check it properly.
2018-05-09 17:11:37 +01:00
2ff2a2de08 FormattedCommandAlias: use multiple catch clauses 2018-05-09 16:58:55 +01:00
78f8d54f89 Merge branch 'release/alpha12' 2018-05-09 16:53:41 +01:00
5b6762d0d5 Fixed lang submodule version 2018-05-09 14:53:22 +01:00
2a0a2134d1 Server: Implemented an signal/sleep interrupt mechanism for ticking (#2171)
This allows other threads to notify the main thread to wake it up while it's sleeping between ticks, allowing reduction of processing latency.

Currently only RakLib and the CommandReader threads utilize this, but it's planned to extend it to more things in the near future.

CommandReader is now event-driven instead of poll-based - the server will not poll the CommandReader thread for messages each tick anymore.

RakLib utilizes this mechanism to get packets processed without delays to lower latency.

This now adds an extra dependency - `pocketmine/snooze` library contains the meat of the code used for this. See the Snooze repository for details.
2018-05-09 14:18:13 +01:00
e70af362d0 RCONInstance: fixup bad continues 2018-05-07 13:55:23 +01:00
24aab8365e RCONInstance: remove redundant size ref param from readPacket() 2018-05-07 13:53:34 +01:00
0e5504ed3f RCONInstance: add docs to fields, make 'stop' private 2018-05-07 13:52:33 +01:00
83008440c0 RCONInstance: replace hardcoded status values with constants
I thought I'd seen the worst of PM, but I haven't.........
2018-05-07 13:44:59 +01:00
b14dfa9f7e RCONInstance: Remove pointless code that makes pthreads segfault
pthreads doesn't play well with resources, and this code upsets it. Also, this code is utterly pointless.

The whole of RCON needs burning to the ground...
2018-05-07 10:05:05 +01:00
197102ca3d Level: fixed blocks not dropping when not broken by player
closes #2172
2018-05-05 21:50:28 +01:00
f497e43db3 SourceInterface: removed redundant return value from process() 2018-05-05 15:30:46 +01:00
38c3f00ef7 avoid crashes when XUID is null 2018-05-05 13:33:13 +01:00
396056c636 Sign: Pad exploded blob to appropriate size
I'm not sure how it's possible to get one of these blobs with less newlines than expected, but whatever I guess
closes #2152
2018-05-04 23:29:32 +01:00
dd1dfefd83 ItemEntity: remove unnecessary damage types restrictions
Invalid damage types are all restricted by other means anyway. This fixes items not getting killed by fire (close #2143) and cacti.
2018-05-04 22:57:28 +01:00
68638f9779 Fixed translations
Apparently the translation type doesn't translate unless this flag is set now...
2018-05-04 22:14:02 +01:00
7565b786e7 Implemented @notHandler annotation for event handlers - skip registering any handlers with this annotation (#2164)
It is somewhat reasonable to have a function in an event handler which accepts an Event parameter, but is not a handler. For example, multiple event handlers can redirect to the same function to process an event, but this function may not want to receive called events.

There are other ways to get around this, such as making the event handler protected/private, or adding a dummy parameter, but this way is cleaner and more explicit.

Relevant old-repo PR: PocketMine/PocketMine-MP#2143
2018-05-04 21:36:58 +01:00
ae0c1c185f Fixed wrong doccomment for Permission::$children 2018-05-04 15:31:00 +08:00
723251e800 Fixed bug in commit hash detection when output ends with newline 2018-05-03 16:37:05 +01:00
295016cbc1 DisconnectPacket: fix decoding 2018-05-02 16:56:48 +01:00
8228774ad4 Remove extra data, this time without API breaks
this is necessary because the next MCPE release will probably be made before the next PM release.
2018-05-02 12:08:44 +01:00
2a54726905 Updated runtimeIDs table
from https://github.com/MCMrARM/minecraft-block-ids/blob/master/blocks_270.json
2018-05-02 12:03:29 +01:00
8b225fc4ef New entity metadata flags and properties 2018-05-02 12:03:29 +01:00
a014b44b69 New PlayerActionPacket constants
anyone know what these are for? something to do with riptide but I didn't manage to find out what...
2018-05-02 12:03:29 +01:00
c7544c1d25 AvailableCommandsPacket: update arg types 2018-05-02 12:03:29 +01:00
eb28622823 Protocol changes for 1.5.0.0
this feels so strange to type... can we ditch the versioning system already?
2018-05-02 12:03:29 +01:00
68494f1c0d CraftingDataPacket: decode chemistry recipes correctly 2018-05-02 12:03:29 +01:00
27ea0d360f updated block IDs table
minified, from https://github.com/MCMrARM/minecraft-block-ids/blob/master/blocks_260.json
2018-05-02 12:03:29 +01:00
d384df1f2e fixed some mistakes in the protocol 2018-05-02 12:03:29 +01:00
fe8102c062 Silence another stupid spam bug 2018-05-02 12:03:29 +01:00
8b15d85469 bump versions for 1.2.20.1 beta 2018-05-02 12:03:29 +01:00
a5ba716232 Updated block ID mappings for 1.2.14 (thanks again MrARM) 2018-05-02 12:03:29 +01:00
db432bb024 Found some things in new packets 2018-05-02 12:03:29 +01:00
91486a23a5 some changes for 1.2.14.2 beta 2018-05-02 12:03:29 +01:00
d80c471ae1 Typehints on missed sound and particle APIs 2018-05-02 11:44:18 +01:00
b4068dfd2f remove unused import 2018-05-02 10:44:05 +01:00
3095eb544d Item: removed isTool()
this should be replaced with `instanceof Tool`.
2018-05-01 20:05:53 +01:00
0247dff909 Fixed mis-uses of Item->isTool()
this has been wrongly used to indicate a durable item, but not just tools are durable items.
2018-05-01 20:05:02 +01:00
5368120f13 Level: remove redundant getAutoSave() condition in close()
this is already checked by save() anyway.
2018-05-01 18:47:08 +01:00
2e7db552dc Level: __construct() now accepts a LevelProvider object instead of string, string
This is made possible by the removal of LevelProvider dependence on their Levels, and furthers the goal of #2024.
2018-05-01 18:43:11 +01:00
53c35aaa1d Server: remove unused variable from generateLevel() 2018-05-01 18:26:03 +01:00
3293074cfc Implement @softDepend annotation for event handlers - skip registering if the event class is undefined (#2162)
This allows plugins to soft-depend on other plugins without separating their listeners into a dedicated class for listening to that plugin.

This can be utilized by adding a `@softDepend PluginName` to the event handler's annotations.
If the plugin providing the event does not exist or is not loaded, then the handler will silently not be registered.
If it does exist and the event is not found, the original behaviour applies and an exception will be thrown.

This change should be fully backwards compatible.
2018-05-01 14:33:24 +01:00
d8f4dde5f3 PlayerHotbarPacket: remove unused import 2018-05-01 14:09:17 +01:00
dfa6cd2b7e Biome: Moved biome classes from level\generator\* to level\biome 2018-05-01 14:07:46 +01:00
e03d2b23f7 Sign: add some typehints where it wasn't previously possible 2018-05-01 14:00:23 +01:00
96a2fd7482 Server: fixed wonky doc comment for broadcastTitle() 2018-05-01 12:30:06 +01:00
88c56bcdc8 Server: move formattingCodes check to initial assignment of doTitleTick 2018-05-01 12:21:41 +01:00
2731fc3d0f Server: remove redundant return value from tick() 2018-05-01 12:17:11 +01:00
a02f178f80 PocketMine.php: add git hash length check "just in case" 2018-04-29 18:07:40 +01:00
96d26a77a1 Explosion: set block damage to zero on destruction 2018-04-16 14:30:54 +01:00
554fe4d14d Updated dependencies, require 64-bit PHP in composer.json 2018-04-16 10:19:17 +01:00
532269a484 Implemented block break XP drops 2018-04-15 19:03:18 +01:00
1e2122d854 avoid crashing in forceShutdown() if properties wasn't initialized yet 2018-04-14 12:45:03 +01:00
c276ef2b7f Updated dependency versions 2018-04-13 20:09:18 +01:00
5138bdc4bd Updated DevTools submodule 2018-04-13 17:38:51 +01:00
a30a157d8c API bump to 3.0.0-ALPHA12
Yes, I am not happy about this either. new-versioning has issues, and there hasn't been enough development and testing on it.
I didn't want to delay release to cram in a half-baked new versioning system, and it's ended up delayed anyway and new-versioning is still half-baked.
we're overdue a new release, so here it is.
2018-04-13 13:31:15 +01:00
e565cdeea4 Tile: remove unnecessary createAdditionalNBT() things
these things are filled in by the tiles' constructors anyway.
2018-04-13 11:50:04 +01:00
556a465c05 Container tiles: remove unnecessary ListTag Items creation
the existence of this tag is checked for anyway.
2018-04-13 11:27:11 +01:00
280f2b7259 always loose imports... 2018-04-13 11:25:52 +01:00
933b0e8b41 Furnace: cleanup, stop abusing NBT, stop spamming packets 2018-04-13 11:22:47 +01:00
58279d4cfe NetworkBinaryStream: fixed not decoding items with negative IDs correctly
negative IDs are used for new block-items.
2018-04-11 13:01:41 +01:00
1e21066c1c Server: remove redundant == true from setConfigBool() 2018-04-10 12:22:21 +01:00
76854da7ba Command: remove dead field 2018-04-10 12:11:27 +01:00
46cbcb0c42 Fixed fire with no nearby flammable blocks burning for too long 2018-04-10 10:07:14 +01:00
af9b0b019d Added BlockBurnEvent 2018-04-10 10:04:11 +01:00
7db8845375 Fire has a 1/3 chance of aging on a random or scheduled tick 2018-04-10 09:59:54 +01:00
f47f593555 Level: Removed fire hack from destroyBlockInternal()
this was causing unexpected behaviour particularly on burning trees, whereby fire would be unconditionally extinguished if the block below it was removed.
2018-04-10 09:59:40 +01:00
691df5c11d FlintSteel: remove instanceof Solid check
This makes the behaviour match vanilla. This will now allow Fire block itself to handle deletion of itself when the area is not suitable (now that the logic is implemented in Fire for this).

This allows attempting to place in invalid conditions, which is as expected. This will produce the sound and flash as per vanilla, as the fire extinguishes itself.
2018-04-10 09:59:27 +01:00
9a1d3aec6b Flammable blocks adjacent to fire now burn away
There are some strange bugs with blockupdating causing invisible client-side-only fires that need to be investigated.
2018-04-10 09:59:10 +01:00
670a53ba3b Fire: fixed logic of extinguishing 2018-04-10 09:58:58 +01:00
f22ad14c67 Block: added isFlammable() 2018-04-10 09:58:35 +01:00
64540f36be Block: added burnsForever() 2018-04-10 09:58:21 +01:00
e66b1953de Block: added flame encouragement and flammability properties 2018-04-10 09:58:08 +01:00
aa6666872a BlockFactory: added a hack for weird air blocks with non-zero damage values
I don't know what causes this to occur, but they should never have non-zero damage values, so we discard the metadata.
2018-04-09 16:35:31 +01:00
646455f6e8 fixed painting particles, removed DestroyParticle
it didn't last long because they changed how this works... yuk
2018-04-09 16:26:15 +01:00
05a1e61e5b Painting: polyfill height and width 2018-04-09 16:20:46 +01:00
5f52e00213 Fixed plugin loaders trying to load plugins they aren't able to load
closes #2125

This is an API break for things implementing the PluginLoader interface.
2018-04-09 15:54:20 +01:00
476ac39988 update PHP version requirements in composer files 2018-04-09 15:50:55 +01:00
5f1ae1059e Move min required PHP version to 7.2.0 2018-04-09 15:37:56 +01:00
08d8adae5b fixup some ResourcePack TODOs 2018-04-07 13:09:44 +01:00
8d988af7db EntityLink: added type constants 2018-04-07 11:35:36 +01:00
db5890fddb Rename more unknown things in the protocol 2018-04-07 11:35:35 +01:00
5b532fdcf5 Clean up on AddHangingEntityPacket and AddPaintingPacket
AddPainting is a subclass of AddHangingEntity in vanilla.
2018-04-07 11:35:35 +01:00
e85fc54037 LevelSoundEventPacket: found unknown field
wtf mojang
2018-04-07 11:35:35 +01:00
7fb237938c EntityLink: rename unknown field
close #1465
2018-04-07 11:35:35 +01:00
9a5f9c8586 PlayerListPacket: fixup on platformChatId stuff 2018-04-07 11:35:35 +01:00
4b16be7e0b PlayerListEntry: remove leftover TODO 2018-04-07 11:35:35 +01:00
47faf5a994 Human: Add support for 128x128 skins in isValidSkin() (#2140) 2018-04-07 09:00:08 +01:00
3f31f6d310 TimeCommand: Use Level constant instead of hardcoded value 2018-04-05 15:41:59 +01:00
c06c1c7ce0 Human: Added a hack for nametags
Apparently NAMETAG metadata is useless in AddPlayerPacket now, so it has to be sent separately.
2018-04-05 11:56:44 +01:00
a889a0e517 Workaround for player hitbox bug on respawn
this happens when a player respawns before their death animation ends. I don't know why, but their bounding box height suddenly becomes zero. This solves the bug by simply resending the height and width properties to viewers on respawn.

Closes #2135.
2018-04-04 20:11:16 +01:00
9ed0d9d36f added some data properties 2018-04-04 19:40:12 +01:00
3134fa2744 Fixed FloatingTextParticle YET AGAIN
how many fucking ways can you break nametags Mojang???
2018-04-04 16:59:39 +01:00
2660448601 Crafting: Match recipe based only on transaction inputs/outputs
As of 1.2.13 release, the client now skips the crafting grid step when it crafts with right-click on the recipe book. This means that we can't validate crafting based on the crafting grid contents anymore. The only way to do it now is to use the inputs and outputs calculated by the transaction balance.
2018-04-04 12:48:17 +01:00
eb354916d4 CraftingTransaction: simplifiy repetition calculation handling 2018-04-04 12:18:24 +01:00
033b44df5a CraftingTransaction: Start from pre-computed iteration count for input matching
This will be faster to bail out on failures.
2018-04-04 12:15:46 +01:00
ef2dd1de92 Inventory: Use exceptions to report back why a transaction failed
Returning false all the time could mean any one of a range of things. Throwing exceptions is better in that it allows us to catch them and see what actually broke.
2018-04-04 12:11:24 +01:00
5b7b2dd0e2 Merge changes from ALPHA11 for 1.2.13 2018-04-04 11:31:39 +01:00
3a10df634b Protocol bump for release 2018-04-04 11:13:36 +01:00
f1aecc3a71 Updated block IDs json from release (thanks MrARM) 2018-04-04 11:09:12 +01:00
42d04a4418 Allow use of 128x128 skins for last beta build (#2123) 2018-04-04 11:03:51 +01:00
3fe4ebc301 Found more unknown things 2018-04-04 11:03:36 +01:00
d97abfaa7b Found some unknown things 2018-04-04 11:03:25 +01:00
526f05631e fix metadata properties for new beta
there are more things than this, but I don't have time to figure them all out.
2018-04-04 11:03:05 +01:00
ebaef89e06 bump 2018-04-04 11:02:19 +01:00
6ab0cff9d3 Bump for 1.2.13.10
doesn't appear that anything of interest has changed
2018-04-04 11:01:46 +01:00
ae31ce1d25 LevelSoundEventPacket: updated sounds constants 2018-04-04 11:01:29 +01:00
a1cf5dbd1e fix doc inconsistency 2018-04-04 11:01:14 +01:00
c86132028e BlockFactory: add new "dynamic" fake runtime IDs for unknown legacy ID/meta combinations
This is basically how blockstate discovery would actually work in the full-blown system. This maps blocks with unrecognized blockstates to static runtimeIDs not known to the client.

This means that all blocks which don't have corresponding runtimeIDs in the new system will translate to update! blocks instead.

Mojang do this differently: they try to a) match id+meta, if that fails b) match id+0, and if that fails, then replace with update! block runtime ID. I can't do that here because I need to be able to convert both ways. They only need to be able to convert from legacy -> new.
2018-04-04 11:00:58 +01:00
5ce55bd3b0 duct tape for block ID remapping 2018-04-04 11:00:39 +01:00
c81f178cdb fix skins on 1.2.13.5
this is not the full changeset and more things are needed!
2018-04-04 10:59:09 +01:00
fc795b80ae Protocol changes for 1.2.10 2018-04-04 10:58:49 +01:00
99134de6b6 Updated NBT dependency
this needs further changes (particularly to Furnace) to stop things abusing NBT for runtime data handling, otherwise performance is going to drop off a cliff.
2018-04-04 10:29:32 +01:00
1fc388d6de DataPropertyManager: fix an unnecessary FQN 2018-04-02 12:34:05 +01:00
eba1ca030c Fix variadic type docs ...again
PhpStorm changed its mind how it wants these documenting in 2018.1, and apparently the correct syntax follows the PHP code.
2018-04-02 12:33:24 +01:00
8ce0fab8cc Remove unused imports 2018-04-02 12:26:13 +01:00
5ed2d6022c GiveCommand: don't catch Throwables
this caused me to think a thyntax error in my code was a syntax error in the NBT I was trying to parse.
2018-04-01 12:17:17 +01:00
37d085f793 UPnP: error messages on failure to portforward instead of silently failing 2018-03-31 12:51:17 +01:00
69c54de460 UPnP: remove useless 'or false' 2018-03-31 12:42:11 +01:00
b9d3bd22a3 Player: fixed getLastPlayed() being useless
this should only be set on quit, not on join.
2018-03-31 10:44:59 +01:00
d4d57aa9ea Merge branch 'feature/xp-event' 2018-03-30 12:46:53 +01:00
4ce1f228e6 Player: removed checkBlockCollision() override 2018-03-30 12:23:00 +01:00
4b03dbebba Entity: use temporalVector in checkBlockCollision() instead of creating a new Vector3 2018-03-30 12:21:37 +01:00
1d5978df98 Fixed falling blocks getting moved by currents, closes #2080 2018-03-30 12:20:59 +01:00
5d32587cf7 DeadBush: match placement condition with break condition, fixes #2116 2018-03-30 11:54:57 +01:00
d53258c943 EffectCommand: restrict range of values for duration, fixes #2055 2018-03-30 11:51:20 +01:00
773f760fff VanillaCommand: added getBoundedInt() 2018-03-30 11:48:42 +01:00
c20b16a0fe Living: fixed damage resistance negating >100% of damage, closes #2052 2018-03-30 11:31:43 +01:00
b151cb26a5 Fix deprecated event message (#2127) 2018-03-30 11:09:24 +01:00
49622cc2a5 NetworkBinaryStream: simplify read of canPlaceOn and canDestroy lists 2018-03-30 11:07:29 +01:00
56328f66a7 InventoryAction: remove useless creationTime field 2018-03-29 12:20:13 +01:00
f41a731493 DropItemAction: don't require a source item in constructor 2018-03-29 12:18:19 +01:00
ec332e3e60 Fill null UUIDs in CraftingDataPacket, remove all UUID things from CraftingRecipe
This allows deleting lots of code, and additionally provides a huge reduction in the compressed size of CraftingDataPacket. Since we don't care about these UUIDs (they are only used in CraftingEventPacket, which is broken and unused in PM) we fill them with zeros instead.
2018-03-29 12:05:23 +01:00
a1090623a2 CraftingRecipe: added methods to allow recipes to derive outputs from inputs
this will be needed for special recipes like shulker-box and banner recipes.
2018-03-29 12:05:22 +01:00
8572e9e560 Crafting: nuke
This commit brings in a much-needed rewrite of crafting transaction handling.

The following classes have been removed:
- CraftingTransferMaterialAction
- CraftingTakeResultAction

The following classes have significant changes:
- CraftingTransaction
	- All API methods have been removed and are now handled in CraftItemEvent
- CraftItemEvent
	- added the following:
		- getInputs()
		- getOutputs()
		- getRepetitions() (tells how many times a recipe was crafted in this event)
- Recipe interface:
	- Removed getResult() (individual recipes may handle this differently)
- CraftingRecipe interface
	- removed the following:
		- matchItems()
		- getExtraResults()
		- getAllResults()
	- added the following
		- getResults()
		- getIngredientList() : Item[], which must return a 1D array of items that should be consumed (wildcards accepted).
		- matchesCraftingGrid(CraftingGrid)
- ShapedRecipe
	- constructor now accepts string[], Item[], Item[]
- ShapelessRecipe
	- constructor now accepts Item[], Item[]
2018-03-29 12:05:22 +01:00
bc836aaec1 Make CraftingManager::sort() more cool with spaceship operators 😎 2018-03-29 11:45:12 +01:00
145a4fad0f CraftingManager: Make sort() static
this doesn't need access to $this
2018-03-29 11:45:06 +01:00
08c48d8145 CraftingRecipe: removed requiresCraftingTable()
the requirement for a crafting table is determined by the number of ingredients can fit on the grid (shapeless) or the max height and width (shaped). It's impossible to craft a big recipe with a small crafting table simply because you're not able to put the required resources into the grid.
2018-03-29 11:43:31 +01:00
81ecb56095 ShapedRecipe: fixed bug in constructor 2018-03-29 11:32:39 +01:00
a6d7365a28 Moved CraftingManager init to its own function
this allows the crafting manager to be re-initialized on the fly without recreating it.
2018-03-29 11:32:22 +01:00
1f4f8ab3f0 Inventory: Removed BigCraftingGrid, allow arbitrary size parameter
This is more flexible and requires less classes.
2018-03-29 11:24:28 +01:00
1420cd1fa5 InventoryTransaction: Added a more robust action flattening mechanism
This now handles the case where there are multiple options which could be taken, and opts for the first result which successfully ties all the actions together. Previously it would be entirely down to chance (ordering) whether the actions would get ordered successfully.
2018-03-29 11:23:52 +01:00
30a83544a0 don't break double chests 2018-03-27 10:23:18 +01:00
7e20385bdb BaseInventory: improved performance of getContents()
this old code is extremely inefficient. This showed up distinctly in my crafting bruteforce benchmarks, where I discovered that getContents() accounted for the vast majority of the time taken to match shaped recipes.
2018-03-27 10:13:55 +01:00
c7e803372c Inventory: added API method isSlotEmpty() 2018-03-26 09:24:00 +01:00
cf3638ad8d BaseInventory: fixed doc comment for slots field 2018-03-26 09:22:38 +01:00
0dd8fd2651 CraftingTransaction: fixed ingredient map trimming (again)
closes #2118
2018-03-25 13:46:39 +01:00
c0c684b12e Removed the need for paintings to check for destruction on schedule
Since we have a mechanism for triggering things on entities anyway, make use of it to do more than just forcing movement updates.
2018-03-25 13:15:10 +01:00
924334a776 Painting: fixed performance bug, close #2117 2018-03-25 13:06:02 +01:00
be7c27f60d Player: explicitly load chunk for player to spawn, fixes #2115
this is an ugly fix, but it'll do for now...
2018-03-25 12:45:51 +01:00
2b37b4a659 Player: close session in interface right at the top
I don't know why this would be anywhere _but_ here...
2018-03-24 13:00:44 +00:00
a4c50d3204 Remove unused imports 2018-03-24 11:59:15 +00:00
eb9f60f41c Entity: some minor cleanup to constructor 2018-03-24 11:52:23 +00:00
071aa44d29 Player: fixed facepalm 2018-03-24 11:05:03 +00:00
25089f5e70 Player: use setPosition() when jumping to off position 2018-03-24 10:58:31 +00:00
22dd8faf1d Player: don't jump to bad position when reverting movement 2018-03-24 10:57:59 +00:00
7354a55af8 Player: use vector methods for calculating diff on move 2018-03-24 10:50:09 +00:00
611f5d684b Player: removed redundant isFirst check for movement
Since the addition of resetLastMovements(), this code is useless.

Additionally, it doesn't make sense to ignore the first movement, because the first movement still _moves the player_ from point A to point B.
2018-03-24 10:40:30 +00:00
9a099d3f5d Player: remove a couple of useless lines from respawn()
teleport() handles these already.
2018-03-24 10:34:30 +00:00
5eb1ee3416 Position: use setLevel() in constructor to validate level 2018-03-24 10:02:10 +00:00
e4b6a18404 Player: removed redundant proxy function 2018-03-23 19:56:35 +00:00
364d278714 Player: removed useless condition for chunk ordering
This just causes it to attempt to spam chunk orders prior to the player spawning. It won't succeed, because the render distance is zero.

The other time this could occur is when teleporting into an unloaded chunk, but it's not necessary to continually spam chunk orders in that case, especially since chunk orders are done on teleport anyway.
2018-03-23 19:48:33 +00:00
c464d39401 Player: Order chunks immediately on receiving chunk radius request 2018-03-23 19:44:03 +00:00
a185b78486 Player: fixed logic of move-into-bad-chunk checks
particularly the hack with chunk switching was causing unexpected behaviour wrt. invisible players.
2018-03-23 19:34:45 +00:00
c19cf22ac5 Fixed #2110 2018-03-21 21:52:55 +08:00
d2fb32c28a PluginManager: added event call recursion limit, closes #2109
This prevents unexplained segfaults on accidental event call recursion by limiting the max depth of event call stack to 50. If another event attempts to be called, an exception will be thrown.
2018-03-21 10:40:08 +00:00
49fbbea7bf Implemented event handler inheritance, allow registering handlers for any valid event (#1792)
* Event handlers always handle subclass events. public static $handlerList no longer required.
* Removed $handlerList declarations
* HandlerList cleanup: Removed HandlerList->handlers and related bake methods
* Removed obsolete Event->getHandlers()
* EventPriority: Added fromString()
* PluginManager: throw exceptions on registering handlers with invalid priorities

This allows specifying a handler of `EntityDamageEvent` which will handle any instanceof it (as per current behaviour), AND also now allows specifying a handler specifically for `EntityDamageByEntityEvent`, which only handles `EntityDamageEvent`.

This was not previously possible due to limitations in the way handlers were registered.

Abstract events may not be handled unless they declare the `@allowHandle` PhpDoc tag.
2018-03-20 17:05:09 +00:00
1648fff916 Replaced Position->getLevel() null checks with isValid() 2018-03-20 11:10:36 +00:00
8d645b714f Position: Destroy references to Level in isValid() 2018-03-20 10:55:24 +00:00
403e996d2f Level: Removed WeakPosition
This is a bad fix for an issue found in one specific use-case. This is redundant because the only places this is used are places where it's guaranteed to be valid, or places where it is checked to be valid anyway.

The Level leak originally noted that led to the creation of this class is something I consider to be a non-issue, because all the heavy things will be cleaned up anyway.
2018-03-20 10:49:23 +00:00
73e09392b6 Timings: Clean up some terrible code, move namespaces 2018-03-19 19:05:51 +00:00
209e28dfe5 Level: Removed MovingObjectPosition 2018-03-19 16:58:45 +00:00
ac5a91b67e Cleaned up bool comparison mess 2018-03-19 14:10:55 +00:00
24c5d7557e Updated PreProcessor submodule 2018-03-19 12:44:54 +00:00
3d89bf5693 Updated PocketMine Math dependency 2018-03-18 18:08:24 +00:00
e48ec9fb71 Ore: replaced a sub-optimal multiply()->divide() on Vector2 2018-03-18 18:06:04 +00:00
95606b6e04 Generator: fixed a couple of hardcoded block IDs 2018-03-18 18:03:23 +00:00
c243daabe1 DumpMemoryCommand: removed token annoyance, use date/time to identify memory dumps by default 2018-03-18 12:17:31 +00:00
357674cb54 DumpMemoryCommand: move memory dumps to their own folder
this is for ease of ignoring in IDEs.
2018-03-18 12:06:15 +00:00
9d5eeb328e Player: cleanup how login verification is handled
Players are now only considered authenticated if they have an XUID AND have a keychain with a Mojang signature in it somewhere.
2018-03-17 18:44:26 +00:00
b2ee6b2ca5 Player: consolidate and add type docs for fields 2018-03-17 17:42:01 +00:00
2860e9e8ee Player: remove clientSecret (useless) 2018-03-17 16:44:34 +00:00
e82073834f Player: protect some fields 2018-03-17 16:43:34 +00:00
7fcc538a75 Level: clone Block object passed to setBlock() if set successfully
closes #2042
2018-03-17 16:35:10 +00:00
7f6b8ad7c2 Moved \pocketmine\math to a separate library 2018-03-17 12:45:55 +00:00
313b224bec Updated Composer dependency names and repo URLs 2018-03-17 12:19:14 +00:00
d12b1d3e07 Updated RakLib dependency 2018-03-17 11:27:56 +00:00
eeeef8df51 Fixed concrete powder not falling 2018-03-16 16:43:47 +00:00
9c786089f8 Level: don't create objects which aren't going to be used 2018-03-16 13:00:16 +00:00
e3cae7364f Level: don't send empty block update batches 2018-03-16 12:58:46 +00:00
d542bbc736 Level: Fixed race condition between direct and batched block updating
This happened when a block was set into the world with a direct update, when an entry for that block was already present in the changedBlocks map. This fixes the bug by removing the entry from the changedBlocks map to avoid sending outdated block updates in batches.
2018-03-16 11:44:57 +00:00
e88541b269 TeleportCommand: add /teleport alias 2018-03-16 10:49:57 +00:00
fdad965db8 Player: if command has aliases, add command name as alias if not found
closes #2106

For some strange reason, using aliases overwrites the original command name instead of coexisting with it. This is rather astonishing behaviour, and probably a bug in the client. However, this workaround is the same thing vanilla does (see /tp in vanilla).
2018-03-16 10:41:00 +00:00
dd844f7ad3 Position: call parent constructor 2018-03-15 10:29:21 +00:00
596c8a7b4f Tile: Removed cyclic dependence on Chunks
Chunks were used by tiles for a couple of things:
- 1. for coordinates - which can be gotten using bitshifts
- 2. setChanged() - which is unnecessary as seen in the previous commit

Removing this circular dependency was actually remarkably easy to do.
2018-03-15 10:21:42 +00:00
9c598d1345 Spawnable: don't mark chunk as changed onChanged()
this is unnecessary because a chunk is considered "changed" if it has tiles on it anyway.
2018-03-15 09:48:28 +00:00
a2af838b1d Level: fixed autosave not kicking in when entities are updated in a chunk (e.g. moving, dying, spawning) 2018-03-15 09:46:04 +00:00
bf97eab98f Block: remove redundant local variable from collidesWithBB() 2018-03-15 09:38:14 +00:00
a9a55e9558 GlowingRedstoneOre: fixed infinite recursion and crash on block update
closes #2104

The inheritance of GlowingRedstoneOre from RedstoneOre maybe should be reconsidered. They only share properties in reality.
2018-03-15 09:24:48 +00:00
95fb1d1602 AxisAlignedBB: added epsilon for floating-point comparison (#2101)
This fixes bugs where, for example, one cannot place a block below oneself at y=7.0.
2018-03-14 16:52:05 +00:00
fa644edef3 Entity: removed redundant return values for move() 2018-03-14 13:39:23 +00:00
ddc9dca8b4 Player: fixed being able to eat cake in creative
closes #2070
2018-03-13 18:32:08 +00:00
86eee429bb Block: Split onUpdate() into several functions, removed Level::BLOCK_UPDATE_* constants
This allows the removal of lots of ugly code, and also exposes lots of similarities with how this update type was handled. This can be further improved in the future to more generically handle cases.

I realized in the process of changing this, that it might actually be simpler to treat to treat scheduled updates and neighbour updates as one and the same. They use the same mechanism for being saved on chunks (TileTicks),
and doing that would make updating only require one queue instead of two.

RedstoneOre: use onActivate() to trigger glowing
this is not technically correct behaviour, but this preserves the current behaviour.
2018-03-13 17:29:46 +00:00
4f20a504e3 Level: remove dead function
this is handled by a queue now instead of ondemand, to avoid recursion bugs.
2018-03-13 11:46:23 +00:00
6a1f8640f6 Cactus: fix bugs in local block updating 2018-03-13 11:40:45 +00:00
8a0414f306 Server: Changed logic of isLevelGenerated() to prevent astonishing behaviour
Previously to this, a level would be considered "not generated" if no level providers registered as valid for that directory. This caused astonishing behaviour when the user's world has, for example, a mixture of .mca and .mcr region files - the world would instead get _re-generated_ according to the default level format, which might or might not load the existing regions depending on the format used for generation. This behaviour is utterly absurd.

This changes the behaviour of the generated check to check for a non-empty directory in the given path. Non-empty directories without recognized world files in them are now considered to have an unknown format.
2018-03-12 10:24:59 +00:00
d478661961 Minor cleanup to LevelDB constructor 2018-03-11 18:15:20 +00:00
b8064aa45c LevelDB: fixed more usages of CompoundTag ArrayAccess API 2018-03-11 17:55:35 +00:00
00f596c4f8 Level: typehint hashing methods 2018-03-11 16:42:57 +00:00
3f7b14bf59 Level: Remove dead generator leftovers
This is all handled by the population mechanism now. Nothing uses these things anymore since years.
2018-03-11 13:56:41 +00:00
ba0a256834 SplashPotion: fix max stack size 2018-03-11 13:43:45 +00:00
f2f8c235e7 Explosion: add exception throws for bad arguments 2018-03-11 13:06:29 +00:00
69b3bb183d Explosion: typehints and docs 2018-03-11 13:02:46 +00:00
cd35bd6872 git diff-tree --check $(git hash-object -t tree /dev/null) HEAD 2018-03-11 10:31:25 +00:00
d09a43cfef Added PlayerExperienceChangeEvent 2018-03-10 20:04:36 +00:00
40b995a435 Level: Fixed botch-job PR #2089
@zKoz210 Do not contribute to this repository again without first testing your changes.
2018-03-10 19:08:30 +00:00
590826b9bd Player: Disallow modifying NBT of tiles inside spawn protection 2018-03-10 18:19:17 +00:00
a5e87484d9 Player: removed superfluous null-check from setMotion()
this is already checked by broadcastMotion().
2018-03-10 17:08:00 +00:00
8a86e0825b Entity: Moved PrimedTNT and FallingSand to object\PrimedTNT and object\FallingBlock 2018-03-10 16:25:07 +00:00
b39bbffdc5 Entity: Moved and renamed entity\Item to entity\object\ItemEntity 2018-03-10 12:36:46 +00:00
bd3d2451bc Level: Added getRandomTickedBlocks() function (#2089) 2018-03-10 11:32:01 +00:00
606407933e ProjectileItem: fixed error when projectile entity is null 2018-03-10 10:59:22 +00:00
ad09e8c8d0 Implemented Bottle o' Enchanting 2018-03-10 10:53:03 +00:00
486edf0e55 Projectile: remove redundant parent onHit() calls 2018-03-10 10:31:24 +00:00
2ee01eb195 Projectile: fix stupidity with collided block IDs 2018-03-09 21:50:27 +00:00
9098502199 Item: added some foods, cleaned up Fish abomination
@PEMapModder GET A CLIENT ALREADY
2018-03-09 19:54:42 +00:00
b130374e46 EnderPearl: fixed max stack size 2018-03-09 19:19:21 +00:00
31106bc227 ItemFactory: Register Dragon's Breath item
this is only used for brewing, it doesn't need anything special.
2018-03-09 19:13:30 +00:00
cc1a3d695f Implemented basic Ender Pearls
this doesn't have full functionality yet (like spawning endermites) because some things aren't implemented yet.
2018-03-09 19:05:14 +00:00
8020780fc5 LevelEventPacket: added enderman teleport particle cloud constant 2018-03-09 17:20:35 +00:00
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
3827892e48 ArmorInventory: fixed debug spam when sending contents to the player itself 2018-03-09 13:23:51 +00:00
e06b78b0ee Implemented armor durability 2018-03-09 13:21:05 +00:00
74cff89df3 Instant Damage splash potions now deal knockback 2018-03-09 12:52:09 +00:00
a9957c3db3 Water bottles extinguish fires when hitting a block 2018-03-09 12:25:34 +00:00
2e9bf7e93b Implemented Splash Potions 2018-03-09 12:25:02 +00:00
dbcc69c2de LevelEventPacket: added useless constant 2018-03-09 11:35:08 +00:00
cdd3fe81e1 Projectile: allow using negative damage amounts to remove damage effects 2018-03-09 11:35:08 +00:00
a8a3eb3866 Added particles for snowballs and eggs 2018-03-09 11:35:07 +00:00
83a3c6f614 Arrow: added shake effect and strike sound 2018-03-09 11:35:07 +00:00
8cc6a32a04 Rewritten Projectile movement handling, added ProjectileHitBlockEvent and ProjectileHitEntityEvent, fixed a swathe of arrow-related bugs
I usually avoid mega-commits, but one thing led to another.
2018-03-09 11:35:07 +00:00
c1a2144f60 Particle: added some new constants 2018-03-09 10:42:59 +00:00
b2491a5874 CraftingTransaction: clean up some logic 2018-03-08 20:44:52 +00:00
2e125168c3 CraftingTransaction: Fixed ingredient map trimming
I really don't know why I made this so complicated to start with. This works much better and is much easier to read.

Fixes #2083.
2018-03-08 19:51:06 +00:00
5059a92b91 Fixed bow and throwable sounds 2018-03-08 13:20:26 +00:00
ea5db98d12 Player: fixed draining hunger when teleporting
this was caused by abe5d94d5b 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
1f77c074e9 Level: Unload chunks prior to save() to avoid saving chunks twice on shutdown
save() calls saveChunks() which saves any chunks found to be modified. But chunk unloading does this anyway, so it's better to unload first and then trigger the save mechanism, to avoid saving chunks twice.
2018-03-07 19:47:54 +00:00
73a5788774 Door: remove unused local variable 2018-03-07 18:53:38 +00:00
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
c7f8796136 Implemented Paintings (#2073)
This supports vanilla placement of paintings, with overlap and collision checking.
Paintings are removed when a block is placed inside them or if any of their supporting blocks are removed.

As per vanilla, a random painting is chosen from the largest subset that will fit into the given space.
2018-03-07 09:03:30 +00:00
c5336776a5 Update ISSUE_TEMPLATE.md 2018-03-05 09:24:28 +00:00
b623c4aba1 Remove accidentally committed file 2018-03-04 15:17:14 +00:00
49a39fc7bd Split DestroyBlockParticle into two classes
this level-event is not only used for blocks, it's also used for paintings.
2018-03-04 13:11:38 +00:00
2e4519cb36 ExperienceOrb: fixed behaviour when placing blocks on top of them 2018-03-04 12:47:09 +00:00
2ff3b12376 Cleaned up projectile "collide" checks 2018-03-04 12:19:41 +00:00
9e4bccd8c0 updated Language submodule 2018-03-03 19:59:13 +00:00
1c5180b720 McRegion: don't assign regions to the index until all exception handling is done
it appears that errors are occurring in the exception handler when handling corrupted regions, leaving regions in the provider index with incomplete location tables. This causes strange-looking errors later down the line.

This moves the region assignment to the end of the condition to avoid leaving incomplete/corrupted regions in the location table when errors occur.
2018-03-02 18:30:45 +00:00
fa6d44ea9e Move Attribute and Effect init calls to Entity::init()
since entities are dependent on these, they should be here.
2018-03-02 10:05:50 +00:00
9d018e8d9e Level: cleaned up chunk loading error handling, close #2056
This now removes logging from the level providers (for the most part) and replaces it with exception throws and catches. The implementation using the providers should catch these exceptions if they are thrown.
2018-03-01 12:30:12 +00:00
ae2e1fdd5a McRegion: Make nbtDeserialize() and nbtSerialize() protected
Not really sure why these are still exposed publicly.
2018-03-01 10:42:27 +00:00
97bfcf6e71 Create support.yml 2018-03-01 10:28:32 +00:00
5457c7a202 Updated PocketMine-Language submodule 2018-03-01 09:53:14 +00:00
ee28296d60 Server: fixed authentication messages
why did I do this...
2018-03-01 09:32:04 +00:00
06af742bef wtf 2018-03-01 09:30:50 +00:00
6bdf5e15c0 Fixed a couple of mistakes in generateLevel() docs 2018-03-01 09:23:50 +00:00
d4eba3f4b1 Moved some things out of Server to appropriate init() functions 2018-03-01 09:18:40 +00:00
5a89e80873 Server: added getPlayerByUUID() and getPlayerByRawUUID()
closes #2047

Since the player list already indexes players by UUID, it's simple to just use that for fetching the player.

A possible future improvement could be to allow fetching an _offline_ player by UUID, but no capability to do that is yet available.
2018-03-01 09:09:34 +00:00
28e601bbb9 Tile: added handling for PC 1.11 save IDs 2018-02-28 19:58:18 +00:00
7e9f1324a7 Entity: fixed tiny sub optimal code in registerEntity() 2018-02-28 19:30:30 +00:00
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
533d139385 Server: Move removePlayer() to somewhere more sensible 2018-02-28 18:28:36 +00:00
6a94c8183c NetworkBinaryStream: Add clarification on array structure for gamerules
we need objects for this really
2018-02-28 18:10:47 +00:00
629a254639 Server: stop reporting exceptions as "notice" in crashdumps 2018-02-28 10:57:25 +00:00
732b931556 BatchPacket: use PacketPool::getPacket() instead of getPacketById()
this is what getPacket() is for.
2018-02-27 21:43:40 +00:00
2dd1878d57 Entity: remove dead field isPlayer 2018-02-27 17:01:28 +00:00
3104a312b2 ConsoleCommandSender: Remove useless function isPlayer()
This function is not declared in any useful places (like the CommandSender interface) and it is not present in Player (!!!). Additionally, an is-player check is better done with an instanceof so that type safety is enforced and IDEs can give auto-complete.

This is a BC break, but this is such a pointless function that it's probably not even worth mentioning.
2018-02-27 16:43:40 +00:00
d6d47feda9 Query: Send responses to the source interface only, instead of all the things
who the fuck wrote this shitty code?
2018-02-27 13:23:01 +00:00
0ba1b58ee0 always takes 2 commits to do one simple thing...
I really love Golang being so strict on this.
2018-02-27 12:34:28 +00:00
ab2df8b11b Removed Server->addRecipe()
This method is pointless extra bloat in Server. Use CraftingManager->registerRecipe() instead.
2018-02-27 12:33:32 +00:00
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
f0535df96d Remove deprecated things 2018-02-27 11:59:16 +00:00
f903dbfe00 Server: Removed identifiers array
This is completely unnecessary and adds extra complexity for no good reason. Maybe it was used historically, but nowadays it is only used to identify players to send async-prepared batch packets to.

There are two alternative ways to do that:
1. use spl_object_hash() as the targets array in CompressBatchedTask
2. use ServerScheduler's object storage to retain references to the Player[] array.

I've opted for the second method.

Removing these identifiers allows great code simplification in removePlayer() and removes the need for those old stupid hacks.

This also includes a backwards-compatibility break by removing the $identifier parameter of Server->addPlayer().
2018-02-27 11:43:02 +00:00
e0d5c79848 Scheduler: Catch exceptions thrown from AsyncTask->onCompletion() 2018-02-27 11:33:16 +00:00
e024f381c9 Living: fixed cycle between armor inventory and holder not getting cleaned up on close
this was getting collected by the cycle GC, but it should have been dealt with properly like other inventories.
2018-02-27 11:08:09 +00:00
2a09aaf456 start.ps1: use -NoProfile for starting child
The child powershell is a workaround for an unidentified bug which causes colours to get messed up after using git in the same console window. However, loading profiles on the child is a major slowdown when starting the server, and for no good reason.
2018-02-27 09:54:29 +00:00
0ad8ea6e92 Remove unused imports 2018-02-24 19:01:09 +00:00
bd47852ca4 Allow Command::getPermissionMessage() to return null (#2057) 2018-02-24 18:15:27 +00:00
2b036b1a5c Added API method Living::hasEffects() (#2054) 2018-02-24 13:48:15 +00:00
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
abe5d94d5b Entity: fixed teleport() not updating movement to players
cc @CortexPE
2018-02-24 12:22:03 +00:00
da5febc34a fix crash report 127835 2018-02-24 11:46:36 +00:00
3de5e132a2 CrashDump: fixed broken argv reporting 2018-02-22 22:05:35 +00:00
37e8c8d324 BanEntry: work around stupid bug in ext/date
https://bugs.php.net/bug.php?id=75992

When plugins do time-limited bans and users enter stupid time values, a shitty bug in ext/date gets triggered, but only when reading the ban entries from disk. DateTime->format() is able to produce formatted strings which have more than 4 digits in the year, which are then considered invalid. This works around it by trying to parse a formatted version on the fly to ensure that it is valid.

This also cleans up and improves ban list loading and handling.
2018-02-22 14:48:53 +00:00
aa11dbb928 Player: Add warnings for messing with movement checks 2018-02-20 13:50:30 +00:00
e7adaef2d2 Level: fix syncChunkLoad timer not getting stopped when no chunk is returned 2018-02-20 10:39:41 +00:00
6bf9ae0a18 Expose plugin.yml contents to plugins (#2043)
This allows plugins and libraries to rely on values in plugin.yml without parsing it again
2018-02-19 22:16:45 +00:00
e7b2dc87d6 Most pointless optimization ever (ServerKiller) 2018-02-19 12:20:31 +00:00
d7a02793fa PocketMine.php: update comment 2018-02-19 12:02:27 +00:00
6a996611f8 Move functions from PocketMine.php to Utils
This cleans a lot of mess out of the bootstrap file, and also has the added bonus that threads which do not inherit functions can now get access to them by autoloading Utils.
2018-02-19 11:56:22 +00:00
ad8d67137e Implemented critical hits (#1929) 2018-02-19 10:14:32 +00:00
cbbed6a6c1 Updated RakLib dependency 2018-02-19 10:01:56 +00:00
99ef3e6576 RakLibInterface: don't self-unregister from Network on crash
This is already done by the Network itself.
2018-02-18 11:52:55 +00:00
eeaf75ac85 Server: add typehint to addPlayer() 2018-02-17 19:54:56 +00:00
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
f27b62027c McRegion: fix some missed ArrayAccess usages of CompoundTag 2018-02-17 14:58:04 +00:00
093cb5b39e Updated PocketMine-NBT dependency 2018-02-17 14:29:20 +00:00
3f41628bf3 Merge branch 'legacy/alpha11' 2018-02-17 10:59:19 +00:00
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
08daf655e5 RakLibInterface: Remove useless function 2018-02-16 17:57:43 +00:00
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
ecd830463c PlayerNetworkSessionAdapter: Remove dead TODO 2018-02-16 11:49:28 +00:00
ffe89f5e1b fixed Anvils item/block different logic handling, close #1910 2018-02-16 11:07:50 +00:00
88a05845c2 Item: Removed protected block field, items should now override getBlock() 2018-02-16 11:06:29 +00:00
2cabdca3f7 ItemFactory: Allow block-items to be overridden
Currently an ItemBlock is created for every Block requested, but this will need to change in the future (for Anvils because they have stupid bitshifts on the meta instead of a nice bitmask). This allows registering items in the ItemFactory with IDs lower than 256 and having them recognized.
2018-02-16 11:03:04 +00:00
be1ddb9f5b Item: Added API method getVanillaName()
This allows retrieving the name of an item without the custom name being plastered over the top. This will also allow weird things to have special functions for their names.
2018-02-16 10:57:02 +00:00
7fc3eeab00 Level: Remove redundant null checks for Item->getBlock()
this is typehinted to return Block, so these checks are pointless.
2018-02-16 10:45:54 +00:00
9395dbf9fa Player: added missing spawn protection check for frame item removal
fixes #2025
2018-02-16 10:35:16 +00:00
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
3b632c2870 ItemFactory::fromString(): throw an exception on failure to parse meta value 2018-02-16 09:45:38 +00:00
7dd834bca0 Fixed API patch version being useless
Plugins will now be able to require a specific minimum patch version, in case they depend on bug fixes or whatever.
2018-02-15 21:45:46 +00:00
2b6e135c83 Switch to PSR-4 based autoloader
Since we don't use the PEAR-style namespacing convention, there's no reason to use PSR-0 autoloader.
We don't quite follow PSR-4 conventions because there is still a pocketmine subdirectory, but changing this might pollute the git history, so I'm wary of changing it.
2018-02-15 21:01:26 +00:00
c26e3aa9fa GiveCommand: Make invalid player checking logic less confusing
some code in this namespace is just total WTF...
2018-02-15 18:19:41 +00:00
aeba15c5c6 GiveCommand: don't crash when an invalid item is specified 2018-02-15 18:18:09 +00:00
4c583ec8ab ItemFactory: Throw exception on failure to parse string as an item in fromString()
closes #1487
2018-02-15 17:56:55 +00:00
af2435f199 Removed redundant checks from ItemFactory::init() and BlockFactory::init()
These are never called accidentally, or at least it's highly unlikely to do so. It might be reasonable to throw exceptions for this, but for the meantime they are redundant - extra indentation for no good reason.

This also removes the $force parameter from BlockFactory::init().
2018-02-15 17:42:03 +00:00
456987e212 ItemFactory: Don't initialize creative items in init()
Wanting initialized item factory does not require initializing the creative inventory. This is often useless and unwanted extra baggage (when this is used on threads for example).
2018-02-15 17:09:38 +00:00
8e6ec04abc Item: Replace a usage of hardcoded resource path with \pocketmine\RESOURCE_PATH 2018-02-15 12:24:57 +00:00
42a7b7fa36 More NBT updates
This library is going to be completely different before I'm done here >.>
2018-02-15 12:11:36 +00:00
ce4e0bf69c Tile: fixed copying of custom block data 2018-02-15 11:47:12 +00:00
dc84484c2b ContainerTrait: Add PhpDoc for ListTag iteration 2018-02-15 11:45:13 +00:00
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
4e9e285e37 Vector2: Fixed getFloorX() and getFloorY() logical flaws
(int) typecast does not round down, it truncates!!!!!!!! :yodaangry:
2018-02-15 10:24:35 +00:00
3962d32ffe Chunk: Remove obsolete checks for entity/tile coordinate mismatches
This code is no longer necessary, because entities are constructed with a Level instead of a Chunk since API 3.0.0-ALPHA4. This means that they will not get allocated in the wrong chunk at runtime after having been saved on the wrong chunk by something else (such as an older version of PM). They will instead be allocated in a chunk selected by bitshifting their coordinates.

This is necessary to be able to fix #1789 without causing entities affected by the infamous bitshift-on-floats bugs to inexplicably vanish.
2018-02-14 18:58:52 +00:00
a84aba5517 Replaced some bad usages of Vector3 get*() with their respective getFloor*() 2018-02-14 18:45:10 +00:00
0b82d5c8d4 Math: Fix typo in Matrix->subtract() name 2018-02-14 18:22:37 +00:00
3aef4c5a09 Merge branch 'legacy/alpha11' 2018-02-14 09:13:00 +00:00
6307952ae9 Server: bail on trying to send empty batch (issue #2020) 2018-02-14 09:12:52 +00:00
cacd0f5d8f Level: fixed global packet mechanism spamming empty batch packets every tick
This also spammed to nobody when the level is empty.

Closes #2020.
2018-02-14 09:12:07 +00:00
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 4a4900e5e7.

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
9abfd54cc1 Updated with ListTag changes from PocketMine-NBT 2018-02-13 16:50:49 +00:00
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
8a4f6eb6c2 ArmorInventory: fixed slots not updating when set
closes #2014
2018-02-13 11:33:54 +00:00
6e7a693355 Tests: Make lint.sh a little more useful 2018-02-12 11:34:51 +00:00
b7bd8dc7f1 Human: fixed NPC skin crash after ByteArray change 2018-02-12 09:56:02 +00:00
b445825467 TextFormat: Moved toANSI() to Terminal, close #1995
This also removes a cyclic dependency between TextFormat and Terminal, meaning that TextFormat is now standalone without any external dependencies.

This is also an API break. Beware all ye who wander here, master = bleeding-edge!
2018-02-11 19:11:51 +00:00
98d6aea7fe Server: rename getResourcePackManager()
casual BC break, ain't nobody got time for deprecations!

closes #1797
2018-02-11 17:17:56 +00:00
b75d121c7e Human: remove obsolete TODO 2018-02-11 17:08:59 +00:00
88bbb03f12 Human: store cape & geometry data in NBT 2018-02-11 17:08:01 +00:00
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
7ec886faa2 Updated PocketMine-NBT dependency with string corruption fix
This fix doesn't fix existing data, but it will prevent the bug happening in the future by capping the length of strings to 32767 bytes, and throwing an exception if too long.
2018-02-11 16:36:50 +00:00
610e62e2cd Timings: don't return the paste we just sent in the response 2018-02-11 11:56:16 +00:00
906442136b Merge branch 'legacy/alpha11' 2018-02-11 09:56:10 +00:00
3600542d78 Timings: fixed pastes not working after ubuntu pastebin update 2018-02-11 09:55:52 +00:00
3b36d46a8f Living: don't reset attack time on regaining health
fixes #2004 and related bugs
2018-02-10 20:53:39 +00:00
63fa6a36a9 Merge branch 'pr/1982' 2018-02-08 12:09:29 +00:00
e0ed877494 Protocol changes for 1.2.10 release
Looks like they reverted near enough everything they did in the beta.
2018-02-08 11:19:04 +00:00
bab2daf711 Protocol changes for 1.2.10 release
Looks like they reverted near enough everything they did in the beta.
2018-02-08 11:18:46 +00:00
5858025d90 Updated PocketMine-NBT dependency to fix CompoundTag bugs 2018-02-07 19:49:52 +00:00
dbac2abafb TextFormat: make colour matching regex less absurd 2018-02-07 11:31:49 +00:00
266d1cb935 Updated Composer dependencies 2018-02-07 10:22:31 +00:00
ffbb44673f Enchantment: fix mistake in Protection translation key 2018-02-07 10:15:31 +00:00
a84a8ecc14 Fixed 32-bit accident
gud fuckup
2018-02-06 21:39:15 +00:00
687886e70b PermissibleBase: remove useless destructor 2018-02-06 21:10:42 +00:00
bad323f5cc PocketMine.php: move stuff out of do{}while(false) that doesn't need to be in there 2018-02-06 19:13:57 +00:00
ca9f700fb0 PocketMine.php: refactor timezone handling into its own class
This removes lots of bloat from PocketMine.php, and this is also important for reusability across threads.
2018-02-06 19:09:24 +00:00
c51cc6b2fe Drop support for Zephir entirely
This extension hasn't been maintained in 4 years and it doesn't make sense to update it to PHP 7, since :shoghi: just dumped a blob of PHP into zephir. It's not worth the hassle of updating.

I prefer to modularise and then C-ify modules, so that they can be reused on their own.
2018-02-06 18:40:36 +00:00
03c66f0f86 PocketMine.php: clean up dependencies checking 2018-02-06 18:38:09 +00:00
610b041631 PocketMine.php: remove unused import 2018-02-06 18:25:59 +00:00
75289b1498 kill(): fix bug when running with POSIX extension but without pcntl
SIGKILL constant is defined by pcntl, not by posix. If pcntl is not compiled then bugs can occur when trying to kill() the server (such as during a crash).
2018-02-06 17:55:18 +00:00
4eea54780a start.cmd: pause on exit with error code in CMD
Closing the command window immediately when an error occurs is particularly unhelpful. This keeps the command window open so that the user can see what went wrong.

[ci skip]
2018-02-06 17:49:12 +00:00
e860d32b3a Merge branch 'text-container-move' 2018-02-06 13:13:19 +00:00
c4486d9ad7 Tile: Cleaned up utterly pointless overcomplicated code for inventories 2018-02-06 13:01:54 +00:00
8222b16d9a LevelDB: fixed leftover usage of the old CompoundTag API 2018-02-06 11:16:14 +00:00
dcb53b1cbb RCON: Use PTHREADS_INHERIT_NONE - these threads don't need baggage from upstairs 2018-02-05 17:27:00 +00:00
a52a2f6d26 RCON: register autoloader on RCON threads
fixes #1993
Interesting that this bug was never noticed before. Maybe because of the class getting loaded by PocketMine.php previously.
2018-02-04 22:24:19 +00:00
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
bf3f5532ac Server: duct tape for very early startup crashes
Exceptions occurring early in the start sequence (before BaseLang is initialized) will result in the server hanging and not killing process as expected. This works around that issue.
2018-02-04 19:53:11 +00:00
07bf1c9e22 Bump API version for release 2018-02-04 18:06:02 +00:00
b659a3d39f Server: more shutdown debug 2018-02-04 10:14:35 +00:00
68b30108be CrashDump: fix mis-reporting Composer dependency exceptions as plugin crashes
this is still not foolproof but whatever.
2018-02-03 19:27:59 +00:00
f223fb2876 Use realpath() to determine correct file path case for DATA and PLUGIN_PATH
fixes issues where cleanPath() doesn't remove these paths from crash traces
2018-02-03 19:21:13 +00:00
8bb785b7af Update pthreads for Travis 2018-02-03 14:17:42 +00:00
806a2005d7 added missing dependency check for OpenSSL
this is managed by Composer now so I didn't think to check it.
2018-02-03 01:03:59 +00:00
c794ced0ad fix dependencies order 2018-02-03 01:03:08 +00:00
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
1c12be6bf2 README: Remove IRC
these channels have been dead for years.
2018-02-02 09:31:13 +00:00
a1d9b8486e README: Be more clear about "getting latest phar"
We don't want people to be using latest development builds, but that's the first thing people see when visiting Jenkins. We want them using releases instead.
2018-02-02 09:28:22 +00:00
9397356ce4 Server: fix crash when specifying settings.async-workers on the command-line 2018-02-01 17:58:49 +00:00
e56e363dcc DataPacket: rename split-screen bytes 2018-01-31 12:07:26 +00:00
18b287c3ea AsyncTask: Remove cleanObject() and calls to it
This is no longer needed. Doing worker GC (via collect()) frees the allocated memory anyway, so this function is now redundant.
2018-01-30 16:45:49 +00:00
9014eb72e9 TeleportCommand: Fixed the bug fix again
This all comes from a shitty bugfix by @PEMapModder. Should be applied globally really, but it wasn't - and not properly tested either :P
2018-01-30 15:08:11 +00:00
82948726ed Beware threads/workers might not inherit \pocketmine\PATH
if the inherit flags don't include PTHREADS_INHERIT_CONSTANTS, this code would fail. Store the Composer autoloader path in advance instead.
2018-01-30 14:50:19 +00:00
c601816586 Terminal::hasFormattingCodes() workaround for STDOUT not being defined
#1979

This isn't a full solution because formatting codes are still not applied correctly if the calling thread doesn't inherit classes.
2018-01-30 10:54:04 +00:00
54f7a88fbb Added getXuid() 2018-01-30 01:25:27 +03:00
d2d1df0447 MainLogger: Remove redundant condition
these are always ThreadedLoggerAttachments anyway, this code doesn't make sense.
2018-01-29 12:24:00 +00:00
f9b1afe4cf Fixed race condition causing exception log messages to sometimes not get written to disk when kill() is used
Synchronize with the logger thread when logging an exception or killing. This forces the main thread to wait for disk write to complete when logging exceptions or killing the process.
2018-01-29 12:04:23 +00:00
033cb8bd63 oops, wrong namespace 2018-01-28 13:08:11 +00:00
0ed9fcb641 Restrict VerifyLoginTask exception handling to known exceptions
everything else should produce a nice big stack trace for debugging purposes, because everything else is probably bugs

This fixes random exception error messages getting relayed to the client when a user does stupid things like editing the source code without knowing what they are doing.
2018-01-28 13:07:09 +00:00
efac23d4af Updated to new RakLib version 2018-01-27 19:10:55 +00:00
48dc1c38f7 Generator: fixed misuse of InvalidArgumentCountException 2018-01-27 12:46:09 +00:00
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
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
3e35bc38e2 Inventory: Fixed crash when breaking right half of a double chest while open 2018-01-27 10:57:04 +00:00
de0741f727 Item: remove unused imports 2018-01-26 17:12:00 -05:00
6fd4b9f1e2 Entity: Cater for old data with CustomNameVisible as a StringTag
This was a bug in older versions, fixed by 890f72dbf2. 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
6c8a1a5b80 Item: Remove redundant Level parameter from onActivate()
there are three other sources this could be gotten from, an arbitrary level doesn't make sense.
2018-01-25 10:15:36 +00:00
3842ee15cf Item: Removed now-obsolete Cake class
>> As of 1.2, cake has a max stack size of 64, making this class redundant as its only purpose was to declare a stack size of 1.
2018-01-25 10:09:09 +00:00
6c71b443e8 Fixed armor not dropping (#1962) 2018-01-24 20:01:32 +00:00
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 1d4bafb6ff.
2018-01-24 19:21:32 +00:00
26d4169fea EntityShootBowEvent: Remove unnecessary kill() 2018-01-24 19:17:08 +00:00
7d88a8b315 Player: Remove useless assignments from constructor 2018-01-24 18:22:23 +00:00
41592a04b7 InventoryTransactionPacket: Update some field names 2018-01-24 13:50:30 +00:00
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
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
0658c0851b Entity: Remove some unused properties 2018-01-24 11:37:01 +00:00
0df2064802 Implement armor damage protection enchantments (#1839) 2018-01-24 10:13:24 +00:00
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
0bf5ab76fb Remove WeakRef leftovers 2018-01-23 19:04:37 +00:00
8e1394bf53 MemoryManager: Use get_declared_classes() to build lists of static properties
This makes memory dumping independent from the autoloader implementation, and fixes #1958.
2018-01-23 18:23:53 +00:00
6ddbdc9dc1 Fixed worker memory dump crash
$GLOBALS does not exist at all on threads :(
2018-01-23 17:21:24 +00:00
2a8be527d7 Remove redundant paths from BaseClassLoader
Everything under src is now handled by the Composer autoloader, and SPL doesn't exist anymore (it's a Composer library now).
2018-01-23 17:03:04 +00:00
aca1422fca Updated pthreads version for Travis 2018-01-23 16:49:32 +00:00
b0d0932ed9 DoubleChestInventory: Fixed items getting rearranged in single chests when creating a double chest
I fixed this elsewhere more than 18 months ago, why is this still here?
2018-01-23 15:50:13 +00:00
fd5557861b Changed how login verification is handled, add more useful error messages
closes #1955
2018-01-28 14:13:59 +00:00
1de7c5b114 Inventory: Added includeEmpty parameter to getContents() 2018-01-22 22:33:57 +00:00
2fb580db26 Inventory: Removed need for Inventory to have an InventoryHolder
Inventory holders are now freed from BaseInventory. They are now declared by subclasses by convention, but are not required in most cases.

Ideally, this would be followed by the removal of the need for inventories to know their holders at all. They should just be simple containers of items.

This fixes #1560 by removing FakeBlockMenu.
2018-01-22 19:44:52 +00:00
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
69ddaacc28 Inventory: Add a $send parameter to clearAll() 2018-01-22 18:39:39 +00:00
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
4943ff9dfc Not sure how this got missed :< 2018-01-21 19:36:42 +00:00
e36b38939c Lever: fix placement 2018-01-21 17:53:41 +00:00
ecb3f9aeac Level: Allow broadcastLevelEvent() to accept a null position to broadcast to everyone in the Level 2018-01-21 17:41:00 +00:00
f0696f77ef Level: Added global packet broadcast mechanism 2018-01-21 17:40:31 +00:00
6813838754 EntityDamageEvent: Remove redundant TODO
Armor does absorb lightning damage by default.
2018-01-21 17:40:03 +00:00
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
a4f5cab12d Entity: Added getDataPropertyManager() 2018-01-20 20:07:11 +00:00
29e06e30b2 Fix projectiles throwing errors on launching, fix #1942 (#1943)
* Fix Projectile::setOwningEntity() on null error
2018-01-20 18:07:53 +00:00
3939e2d9dd NetworkBinaryStream: add some typehints 2018-01-20 11:05:41 +00:00
2579438b84 NetworkBinaryStream: Use nullable typehint for putVector3Nullable() instead of default value
the parameter is not optional
2018-01-20 11:01:16 +00:00
95d42b9907 Network: Remove legacy Vector3 primitive encode/decode methods 2018-01-20 10:58:39 +00:00
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
8f928915d9 Merge PR #1936: Vector3:: setComponents() documentation fix
Vector3::setComponents() and override changes/removal
2018-01-19 08:12:44 +00:00
3af8cf48b2 Removed setComponents() override in Position 2018-01-18 19:03:53 -05:00
21c03670b6 PhpDoc fix for my sanity 2018-01-18 18:04:54 -05:00
0c868b16b6 Network: Added config to pocketmine.yml to allow changing max MTU size
This might be useful for people with older routers where the connection MTU is actually lower than the router allows.
2018-01-18 18:15:14 +00:00
1e67360048 SpawnEgg: Remove redundant isSurvival() check 2018-01-18 17:04:25 +00:00
3520dafd29 Entity: Make fall distance explicit float to shut a PhpStorm bug up 2018-01-18 16:52:17 +00:00
857b63ba8f Entity: Added recalculateBoundingBox() 2018-01-18 16:35:38 +00:00
9551e5b8e5 Durable: Allow subclasses to override behaviour when the item breaks 2018-01-18 14:37:22 +00:00
c7f15a556d Durable: Don't allow damage to exceed max damage 2018-01-18 14:34:50 +00:00
efca9f0450 Item: Moved getMaxDurability() to Durable class only, and make it abstract
It's only now used in the Durable class, so it does not make sense to keep it in Item anymore. This is a leftover from the days where Durable did not exist.
2018-01-18 14:16:30 +00:00
d728154e87 Level: Fixed entities getting deleted when switching levels
So this came from a bugfix (795d6c8ddf) which fixed a memory leak related to entities getting kill()ed on chunk unload.
HOWEVER, me2016 did NOT realize that this code is actually entirely pointless and causes unexpected behaviour.

removeEntity() is used in 2 places in the core code:
1. in Entity->close() (so close() doesn't need to be called again, obviously)
2. in Entity->switchLevel() (which then causes the entirely unexpected behaviour of close()ing the entity on level change.

Conclusion: This code is pointless. This fixes the bugfix.
2018-01-17 11:30:59 +00:00
2e1a167bed Arrow class: No need to import Item class with other name (#1932) 2018-01-17 10:59:50 +00:00
6f6e3aaa21 Fixed projectiles collding with spectator players
closes #1857
2018-01-17 10:57:04 +00:00
9c65a2b890 Furnace: Fixed lit furnaces dropping the wrong item
closes #1915
2018-01-17 10:24:01 +00:00
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
7a5e5773b7 Updated RakLib dependency 2018-01-16 20:01:41 +00:00
f1b0a4f1de Not sure why we are still blaming @shoghicp for this :< 2018-01-15 11:17:01 +00:00
751345c736 Updated BinaryUtils dependency 2018-01-14 18:56:31 +00:00
e850f34d76 Fix TNT block not setting fuse NBT correctly (#1917) 2018-01-14 18:10:57 +00:00
8d7c65585c Enchantment: Implement Silk Touch (#1912) 2018-01-14 13:37:27 +00:00
96f6362117 Fixed glowing redstone ore giving itself when block-picked 2018-01-14 13:35:41 +00:00
66c768d453 PR template: Make clear that "tested" is not acceptable test information
[ci skip]
2018-01-14 11:44:29 +00:00
6fe7763db9 Contributing: require details of tests done
[ci skip]
2018-01-14 11:37:51 +00:00
fda97decaa Contributing: batch commit of changes
very hypocritical of me, I know...

[ci skip]
2018-01-14 11:35:04 +00:00
b3f44562e9 Contributing: updated example
[ci skip]
2018-01-14 11:04:46 +00:00
51350be190 CONTRIBUTING.md: fixed indentation
[ci skip]
2018-01-14 10:42:53 +00:00
7f4b5d282e Fixed plugin name validation
Invalid characters in plugin names are no longer stripped. They always result in a load error.

The behaviour of replacing spaces with underscores is not changed.
2018-01-14 18:28:19 +08:00
94feecd44b Enchantment: Implemented Unbreaking 2018-01-13 19:34:45 +00:00
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
fe4b5498e6 Level: Fixed 2D block cache not getting counted correctly
Fixes #1903
Closes #1906, which, while a pretty solution, is very inefficient (see PR discussion). This is an optimization of microscopic proportions, but the point still stands.
2018-01-12 11:02:43 +00:00
98b36fd73e Enchantment: Implemented Efficiency
This is only needed server-side for block-break animation times.
2018-01-11 20:13:57 +00:00
07c7048433 Enchantment: Converted item type bitflags to hex 2018-01-11 20:09:42 +00:00
f09cf92197 Enchantment: Updated item type flags 2018-01-11 20:08:50 +00:00
98eba11da5 Human: Use Item->getEnchantmentLevel() for Respiration check 2018-01-11 18:32:46 +00:00
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
b04cee12ea Item: Added API method getEnchantmentLevel() 2018-01-11 18:22:29 +00:00
c4966404bb Moved NBT to Composer library 2018-01-11 14:18:09 +00:00
579c508761 Move Binary and BinaryStream to Composer library 2018-01-11 13:19:59 +00:00
43959bccb1 Change Composer package vendor name to pocketmine instead of pmmp, update dependencies 2018-01-11 13:16:27 +00:00
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
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
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
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
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
a0683dbb0f Chunk: Remove useless code in fastDeserialize() 2018-01-08 21:38:30 +00:00
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
4d2549b50a PlayerInventory: Fixed $send parameter not working for setting armour slots 2018-01-06 16:24:41 +00:00
1fb3274f37 Server: Make start() private
This should not be exposed to plugin use.
2018-01-06 15:04:58 +00:00
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
266a253c03 Remove dead imports 2018-01-05 19:48:04 +00:00
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
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
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
418d099a2e Merge PR #1561: Implement XP 2018-01-05 12:53:48 +00:00
9d2eb5e911 Human: Added some void typehints 2018-01-05 12:30:03 +00:00
b6c1124d50 Move XP drop amount to Human instead of Player 2018-01-05 12:09:24 +00:00
03fda936a8 Added XP level-up sounds and refactored XP gain sound handling 2018-01-05 11:58:54 +00:00
684fd46d09 Entity: Throw exception when trying to get save ID of non registered entity 2018-01-04 21:05:17 +00:00
90fc649441 Fixed bad PhpDoc leftovers from NBT streams refactor 2018-01-04 20:32:06 +00:00
0410df77aa Drop experience on death 2018-01-04 19:33:37 +00:00
0f30467f62 Added Level->dropExperience() and API for splitting XP into orb sizes 2018-01-04 19:32:54 +00:00
a84910f04c Implemented XP orbs 2018-01-04 19:28:19 +00:00
3ee225caec Human: Refactored XP API methods 2018-01-04 19:15:26 +00:00
f963dbd10d Level: Added getNearestEntity()
This may be used for AI in the future.
2018-01-04 19:10:43 +00:00
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
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
3ca162f23f Revert "Player: Remove obsolete maxDiff parameter from canInteract()"
This reverts commit a5c3fbdd7a.
2018-01-04 15:33:23 +00:00
5f48433c95 Bucket: Added sounds for bucket fill/empty 2018-01-03 14:27:41 +00:00
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
db52501462 Bucket: Fixed stack size handling for empty buckets
GOD this code is horrible
close #1472
2018-01-03 14:12:04 +00:00
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
1bdb68b7da EnderChest: Remove dead onBreak() code (follow-up to previous commit) 2018-01-03 12:10:36 +00:00
6ce728169e Chest: Remove redundant unpairing code from onBreak()
This is already done in the Level.
2018-01-03 12:08:35 +00:00
06a3c7c478 Entity: Write attributes in AddEntityPacket 2018-01-03 11:30:22 +00:00
70982c145b Level: Clarified documentation for loadChunk() and changed misleading parameter name 2018-01-02 18:08:43 +00:00
417f2d8998 Level: Clarified documentation on getChunk() 2018-01-02 18:05:30 +00:00
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
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
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
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
9a956692de Fixed wasteful throwaway objects used for spawn positions 2018-01-02 12:21:11 +00:00
d30a6b60b7 .gitignore: Ignore crashdumps directory
How did this never become a problem before?!
2018-01-02 12:09:31 +00:00
41873bb115 Merge PR #1864: LevelProviders refactor 2018-01-02 11:47:11 +00:00
8064152777 LevelProvider: Add documentation for doGarbageCollection() and close() 2018-01-02 11:39:51 +00:00
872df446bd Level: Remove redundant duplicate condition in unloadChunk() 2018-01-02 11:16:20 +00:00
376a615634 thanks for the warning PhpStorm... not 2018-01-02 11:14:01 +00:00
c16c9efdf3 Chunk: Rename unload() to onUnload()
this more accurately describes what the function does.
2018-01-02 10:50:22 +00:00
c3cc6f9880 Chunk: Clean up unnecessary checks in unload() 2018-01-02 10:48:01 +00:00
1e139743b8 Level: Do level provider GC every 5 minutes from level tick
this should solve #1183, pending further testing.
2018-01-02 10:23:57 +00:00
bde0ba1100 Level: Set chunk coordinates in setChunk()
The level provider used to do this in LevelProvider->setChunk(), but it does not anymore.
2018-01-01 13:13:47 +00:00
50f273c041 Vector2: Fixed ceil() and floor() totally broken logic
"So if I Vector2->ceil()->ceil() my vector2 magically gets incrementing values..." @Sandertv 2018
2018-01-01 12:57:34 +00:00
db095f9705 Updated PreProcessor submodule 2018-01-01 12:54:18 +00:00
f580f27ec7 LevelProvider: Updated documentation 2018-01-01 11:59:22 +00:00
a46029c0f6 LevelProvider: Nuked the complicated mess out of level providers
Level providers are now cut back to just an interface to a world's data. They don't keep their own chunk registries or any stupid shit like that because the Level already does that.

This furthers the goal of being able to move level I/O off the main thread, and also drastically decreases the complication of implementing level providers.
2018-01-01 11:21:46 +00:00
1a615591e2 LevelProvider: Remove cyclic dependency between Level and LevelProvider
This will now allow LevelProviders to be constructed on threads.
2018-01-01 10:50:13 +00:00
d19683b7dd LevelProvider: Remove some dead methods 2017-12-31 18:35:23 +00:00
f17b3b2a3b LevelProvider: Refactor providers to drop lots of duplicated code 2017-12-31 18:35:23 +00:00
a0a2ea01bc LevelDB: Check for LEVELDB_ZLIB_RAW_COMPRESSION when checking for the extension's presence
We always want to validate that the leveldb provided supports the world format.
2017-12-31 17:49:02 +00:00
5132ab6cd9 LevelDB: Remove redundant folder creation in generate()
This is pointless because the call below - which is _also_ recursively creating directories - will create this directory anyway.
2017-12-31 17:46:07 +00:00
256bdf2581 McRegion: Use MainLogger::getLogger()
another one bites the dust
2017-12-31 16:06:08 +00:00
8a3f8b4706 LevelProvider: Remove redundant method requestChunkTask()
This removes one more dependency that LevelProvider has on Level.
2017-12-31 16:05:58 +00:00
7264ce43ae McRegion: Added method pathToRegion() 2017-12-31 14:25:17 +00:00
66e475cbb8 Region: Remove RegionLoader/McRegion cyclic dependency 2017-12-30 19:59:35 +00:00
1e896efff9 McRegion: Added an assert 2017-12-30 19:49:44 +00:00
4db7a7e57f Region: Change chunk offset calculation in regions to use bitmasks
I don't know why it wasn't done like this to start with. However this has not been tested yet, so this goes on a different branch for now to test.
2017-12-30 19:41:58 +00:00
54b23968e7 McRegion: Refactor some ambiguous variable names 2017-12-30 18:59:01 +00:00
bcb080e2b9 Level: Make sleepTicks private, don't write directly 2017-12-30 18:41:13 +00:00
e5c58f9b04 Player: Add typehint for maxDistance parameter of canInteract()
Not sure why this was missing :<
2017-12-30 17:43:12 +00:00
af7aef70db Implemented TextFormat::colorize() (#1837)
Implemented TextFormat::colorize()
See 4c46087ffc for the initial discussion
2017-12-30 16:51:04 +00:00
3ea72a0bf9 Merge PR #1775: NBT streams refactor 2017-12-30 15:53:47 +00:00
be02fbb352 NBT: Add typehints to PHP 7.2 standards 2017-12-30 15:07:50 +00:00
a67f7e3930 Add header includes and preprocessor checks 2017-12-30 14:56:29 +00:00
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
63edcb8934 Updated PreProcessor submodule 2017-12-30 14:15:33 +00:00
e7a012d69a Player: Remove dead imports 2017-12-30 12:42:42 +00:00
99c55ac889 Plugin: Fixed return type documentation for getResource() 2017-12-30 12:40:50 +00:00
f14adf5827 Updated RakLib dependency 2017-12-28 12:51:16 +00:00
c64b9ad63a MovingObjectPosition: Use asVector3() instead of creating a new vector the hard way 2017-12-26 15:37:00 +00:00
dda71b06ae AxisAlignedBB: Use elseif in calculate*Offset()
It's impossible for both of these conditions to be met in the same call.
2017-12-26 14:31:42 +00:00
3c4dca7fdb ZippedResourcePack: Handle json decoding errors correctly
Previously this would crash if it failed to decode the JSON (https://forums.pmmp.io/threads/texture-pack-shows-errors-not-working.4880/)
2017-12-25 19:01:02 +00:00
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
1edf69892a Fixed chorus fruit teleporting players into the void in superflat worlds 2017-12-24 16:27:58 +00:00
f10c2a2df2 FlowerPot: Fix drops retaining damage
close #1844
2017-12-23 17:54:22 +00:00
3bbdc5ab5b Implemented chorus fruit 2017-12-23 15:11:48 +00:00
082e3404c3 Potion: Implement potion effects 2017-12-23 15:07:39 +00:00
547833ae23 Effect: Add constants with vanilla names where missing 2017-12-23 14:48:56 +00:00
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
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
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
6332814a04 Effect: Minor cleanup on Instant Health/Damage effect amplification 2017-12-23 11:23:29 +00:00
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
36f3accf4b Effect: Don't allow cancellation of expired effect removal, close #1770 2017-12-23 10:55:25 +00:00
8d08840ea4 Effect: Better fix for duration bug seen in 3614711a02 2017-12-23 10:45:59 +00:00
7f0d0c9d63 Revert "fixed negative effect durations when level tick rate is > 1"
This reverts commit 3614711a02.
2017-12-23 10:44:21 +00:00
bf55f03a3e Merge pull request #1842 from pmmp/issues/983-interact-fix
Fix direction checking for player interactions, close #983
2017-12-23 09:42:39 +00:00
a5c3fbdd7a Player: Remove obsolete maxDiff parameter from canInteract() 2017-12-22 20:38:39 +00:00
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
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
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
8bf275cb8b Player: Execute PlayerPreLoginEvent before banlist/whitelist checks, close #1831 (#1833) 2017-12-22 11:19:56 +00:00
1896576a24 ResourcePackManager: Remove Server constructor dependency 2017-12-22 11:11:58 +00:00
8f811c29d7 ResourcePackManager: Remove redundant config property
This was only used in the constructor, there's no need to store it.
2017-12-22 11:05:47 +00:00
3a4f79629c ResourcePackManager: Add API method getPath() 2017-12-22 11:04:15 +00:00
375243860e Potion: Restrict item stack size to 1 2017-12-21 15:02:56 +00:00
a842a5319f Enchantment: Create constant name once, and reuse it
this is more readable and more maintainable.
2017-12-21 13:11:31 +00:00
c2b0f6af22 Enchantment: Simplify getEnchantment() with null coalesce
This is made possible by 0e538ee51d.
2017-12-21 13:02:24 +00:00
6490d99ac2 Enchantment: Added a TODO (calculating XP min/max level cost bounds) 2017-12-21 12:55:55 +00:00
e0b063ac85 Enchantment: Added max level property 2017-12-21 12:49:34 +00:00
12ac2f4ac7 Enchantment: Fixed rarity constant values to match vanilla
Rarity is used for "weighting" enchantments on enchantment tables and such. Therefore higher numbers mean the enchantment is more common. This changes the rarity values to match vanilla.
2017-12-21 12:48:35 +00:00
cc1951c7ba Enchantment: Remove activation type stuff
This isn't and won't be used anywhere.
2017-12-21 12:48:14 +00:00
0e538ee51d Enchantment: Split up enchantment type data and enchantment instance data (#1825)
* Enchantment: Split enchantment type data from instance data
This commit splits enchantments into (effectively) enchantment TYPES vs enchantment INSTANCES.

When applying an enchantment to an item, it only needs to know 2 things:
1. the enchantment ID (identifier) which is used to identify the TYPE
2. the enchantment LEVEL which is used to modify the enchantment's power IN THIS INSTANCE.

Therefore, the LEVEL is not an immutable property. However, all other properties of the currently-named "Enchantment" class are immutable type properties.
Currently, when applying an enchantment to an item, a copy of the enchantment object is created from the registry, and returned. This copies all of the properties contained by the type, which is obviously sub optimal.
2017-12-21 12:40:33 +00:00
1b4b832c8c Added a getEntry() to BanList (#1830) 2017-12-21 10:08:56 +00:00
4f8e4f0522 Add EOF newlines where missing (bulk) (#1836)
This should solve issues with people making GitHub PRs and having the web editor messing things up. GitHub Web Editor sucks :(
2017-12-20 11:56:36 +00:00
0ee78d2416 Update DevTools submodule, fix build 2017-12-17 15:01:05 +00:00
4c46087ffc TextFormat: Added EOL constant (for MCPE)
MCPE always uses LF for line endings. PHP_EOL might be LF, CRLF, or CR depending on the platform, so it should not be used for (for example) sending messages to players containing newlines.
2017-12-17 14:58:37 +00:00
bb3e72ea4b StringTag: Fixed bad error message for bad value type 2017-12-17 12:30:18 +00:00
914e4c9a72 Enchantment: Fix formatting issue 2017-12-16 13:04:25 +00:00
9fd7312629 EnchantCommand: Fix vanilla translation
This parameter isn't required server side, but it doesn't matter anyway.
2017-12-16 10:34:38 +00:00
24387d1efe Enchantment: Add some PhpDoc for fields 2017-12-16 10:01:42 +00:00
3853938ef3 Level: Manage block cache appropriately when loading/unloading/replacing chunks, close #1813 (#1823)
This changes the block cache to be a 2-dimensional hashmap of [chunkHash][blockHash]. This is needed to more effectively dispose of chunk-specific block caches when chunks are modified.

This now destroys the cache for specific chunk indexes in the following circumstances:
- When a chunk is unloaded (the cache isn't needed anymore)
- When a chunk is set into the world (for example, from the generator)
- When a chunk is loaded (probably unnecessary)

This resolves the ghost blocks bug many have been complaining about.
2017-12-16 09:49:48 +00:00
4ec8416f9a Level: Fix minor code duplication in setChunk() 2017-12-15 16:47:59 +00:00
8aff793a4f Fix drops for leaves, close #1821
Seems that leaves are another special case - they technically speaking accept any tool to break, but only drop when shears are used. They don't REQUIRE shears because if they did the break time would be longer for non-shears tools.
2017-12-15 10:14:24 +00:00
d93ded9047 merge 1.2.7 "changes" 2017-12-14 18:59:11 +00:00
fbd04b0fe7 Bump to 1.2.7 2017-12-14 18:56:32 +00:00
953f45c50f Altered armour handling, now works for damage other than PvP 2017-12-14 12:37:28 +00:00
1822abc862 Living: Apply absorption after effect damage reduction is checked 2017-12-14 12:03:12 +00:00
92e966686e Refactor Living->attack() into several methods 2017-12-14 11:39:05 +00:00
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
532600ab67 Player: Remove another redundant attack check
This is checked in Player->attack() anyway.
2017-12-14 11:03:13 +00:00
78f8fe602c Player: Remove redundant PvP check
This is already checked in a block lower down.
2017-12-14 10:59:17 +00:00
e75fbd7fb4 Changed Effect colours to use Color objects instead of arrays (#1814) 2017-12-14 10:21:07 +00:00
06f605879a Effect: Save and restore ambiency properly 2017-12-14 10:10:26 +00:00
4c7038f941 Effect: Added proper documentation on "ambiency" 2017-12-14 09:57:20 +00:00
4bd4d42b82 Fixed raw porkchop being inedible 2017-12-14 09:09:47 +00:00
f5ebfc3418 Effect: Added Fatal Poison effect
This is identical to normal Poison, except that it kills the victim. Parrots receive this effect when they are fed cookies.
2017-12-13 18:59:49 +00:00
4ae278686c Player: Hack anti-fly to ignore levitation 2017-12-13 18:50:56 +00:00
740786c99e PillarRotationHelper: Drop redundant commit 2017-12-13 18:39:16 +00:00
6abf880e44 Block: Drop unnecessary parameters for ItemFactory::get() 2017-12-13 18:37:04 +00:00
853411fa4f Merge pull request #1795 from pmmp/tools-refactor
Tools refactor
2017-12-13 18:04:12 +00:00
6e30d23254 Added missing properties for several blocks 2017-12-13 16:28:21 +00:00
717b36a983 Cleaned up non-trivial getDrops() stuff 2017-12-13 14:47:50 +00:00
90eed14cd6 Fixed cobweb drops 2017-12-13 14:46:58 +00:00
4452e6ac93 Merge branch 'master' into tools-refactor 2017-12-13 12:58:50 +00:00
66562f24fb Made Leaves drops more generic, fix dark oak leaves not dropping apples 2017-12-13 12:57:58 +00:00
56f1a6ba37 Block: Migrated all trivial drops code to getDropsForCompatibleTool()
getDrops() should now be overridden only for special cases. There are some non-trivial overrides left that are going to need some extra work to clean up.
2017-12-13 12:49:58 +00:00
8c47a338df Block: Remove unused imports 2017-12-13 12:44:21 +00:00
7c6535283e SnowLayer: Fixed tool requirement 2017-12-13 12:39:29 +00:00
c669819bbb Fixed stained/hardened clay being harvestable without a pickaxe, close #1803 2017-12-13 12:01:46 +00:00
50f3231629 Fixed being able to mine double stone slabs without a pickaxe 2017-12-13 11:34:41 +00:00
015cde2169 Merge branch 'master' into tools-refactor 2017-12-13 11:26:24 +00:00
dc064dfa2e Level: Fixed some unnecessary double uses of Level::blockHash() 2017-12-13 11:25:36 +00:00
131a6a4d19 Cache fix related to #1813: Don't cache blocks for chunks that don't exist 2017-12-13 10:47:12 +00:00
67a576722c Fixed item frames placed on invalid blocks, close #1804 2017-12-13 09:46:18 +00:00
b9b50dd5dc Added Block->getDropsForCompatibleTool(), removed lots of boilerplate code from subclasses
The function name is a little long-winded, but that can always be refactored later if needed. This provides a way for blocks requiring specific tools to override drops with non-standard stuff without needing to worry about what tool type was used.

It's also possible that passing the Item used here is actually entirely redundant, but again that can be fixed later.
2017-12-12 20:02:50 +00:00
da3640357c Rename Block->canBeBrokenWith() to isCompatibleWithTool() and add documentation
This name better describes it. "can be broken with" implies that items which this returns false for cannot destroy the block at all, which is incorrect. What this actually returns is whether the item is the best tool to use to break the block.
2017-12-12 19:51:31 +00:00
0004e7429f Added some documentation on harvest level properties 2017-12-12 16:55:00 +00:00
e2e6b7516a Removed WoodenTool classes
These were only needed for their fuel properties, which are the same for all tools of the wooden tier anyway.
2017-12-12 13:55:38 +00:00
b903161a5d Refactored tool efficiency handling
This fixes lots of bugs with things like wool, cobwebs, swords.
2017-12-12 13:55:36 +00:00
99fe63b2a3 Added harvest level properties to applicable blocks
this fixes block-breaking animations with wrong tools, and also finally resolves the long-standing hierarchy problem in Stair.
2017-12-12 13:54:17 +00:00
dbc180315e Declare tool harvest level as a property 2017-12-12 13:54:16 +00:00
45983acc0d Fixed too-fast break times with wrong tool types 2017-12-12 13:54:16 +00:00
a02af1053f Remove redundant overrides from WoodenTools 2017-12-12 13:54:16 +00:00
7de88b9040 Tool tier efficiency should still apply if the block can't be harvested
If you use an iron pickaxe on obsidian, it still mines faster because the tool types are compatible, even though the tool is not high enough.
2017-12-12 13:54:06 +00:00
58327d0514 Change block tool types to bitflags
This allows specification of multiple tool types for a block, such as cobwebs.
2017-12-12 13:51:33 +00:00
db31d13f96 Added Item->getBlockToolType() 2017-12-12 13:45:52 +00:00
55d0684565 Move block-breaking tool-type constants to a BlockToolType interface 2017-12-12 13:45:52 +00:00
7e3cd24444 Added TieredTool->getTier() 2017-12-12 13:45:51 +00:00
2088a43c56 Refactored tool hierarchy 2017-12-12 13:45:51 +00:00
3beccc47cd SlotChangeAction: Remove superfluous >= 0 inventorySlot check
This is done by slotExists() anyway.
2017-12-12 10:36:53 +00:00
dfc2d1dfe6 Stop hardcoding src/pocketmine/resources everywhere 2017-12-11 19:52:49 +00:00
1f1531810d Added \pocketmine\RESOURCE_PATH and Server->getResourcePath() 2017-12-11 19:52:20 +00:00
a5fc77749f Added -file (-f) option to start.ps1
This allows specifying a PocketMine-MP PHP file to execute (phar or source) to use to run the server, like start.sh. If not specified, auto-detection is used.
2017-12-11 19:40:02 +00:00
98cb7f2e10 Removed redundant filePath from Server constructor
This parameter is hardcoded to \pocketmine\PATH in PocketMine.php. Additionally, it does not make sense for the server source path to not be the server source path. \pocketmine\PATH is accessible from the Server context, therefore it should be used and does not need to be stored.
2017-12-11 19:25:06 +00:00
e58db75396 Level: Remove redundant null checks from useBreakOn()
These checks are not needed as of 3eae7a1875.
2017-12-11 16:31:43 +00:00
a94c669730 Fixed sword efficiency on anything that's not cobwebs 2017-12-11 12:57:18 +00:00
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
44e06f6a32 Player: Stop abusing getItemInHand() when we already have it stored 2017-12-10 17:08:56 +00:00
2e62c084a4 Oops! composer.lock wasn't up to date 2017-12-10 12:34:01 +00:00
a3622dfa9d Updated PocketMine-SPL dependency 2017-12-10 12:26:48 +00:00
7c8a29151c MemoryManager: Remove unused field (leftover from 59d9d6a7df) 2017-12-10 12:12:43 +00:00
8a90d159fe Cleanup unused imports 2017-12-10 12:09:46 +00:00
bf4076766e Living: Fixed passing FloatTag to setHealth() when HealF tag is present, close #1784 2017-12-09 20:31:14 +00:00
49dbd8b2c8 Living: Remove superfluous fire resistance check from dealFireDamage()
This is already checked in Living->attack(). It's preferable to allow it to be cancelled there since plugins can then un-cancel EntityDamageEvent to bypass the effect.
2017-12-07 17:32:50 +00:00
502dd14c67 Entity: Remove excess whitespace in doOnFireTick() 2017-12-07 17:28:37 +00:00
74239eec69 Living: Remove nonsensical >0 condition on boolean
Maybe this once returned integers, but it doesn't anymore.
2017-12-07 16:49:16 +00:00
3c936e1be8 Entity: removed dead maxFireTicks property 2017-12-07 16:37:32 +00:00
16fd37a039 Entity: Add getter & setter for fireTicks 2017-12-07 16:37:01 +00:00
1ce961f688 Merge branch 'command-reader-fix' 2017-12-07 13:55:48 +00:00
d80f711d18 CommandReader: Removed redundant else branch 2017-12-07 13:50:24 +00:00
ebd3d207e4 Fixed server not accepting commands after pressing ctrl+D (non-readline) 2017-12-07 13:42:34 +00:00
31f0437c96 fix readline crash when user presses ctrl+D 2017-12-07 13:41:58 +00:00
b06ca6eb0b Rename Living->callDeathEvent() to Living->onDeath() 2017-12-07 12:26:49 +00:00
67a09a9b16 Bump versions for 1.2.6
No changes. Mojang sucks.
2017-12-06 18:12:45 +00:00
51cec525ee Added methods for calculating sun angle and sky light level reduction by day time
Use real sky light level in Level->getFullLightAt()

close #1471
2017-12-06 12:40:52 +00:00
a5f4dda918 Added documentation for Level->addChunkPacket()
this method is confusingly named
2017-12-06 11:15:17 +00:00
e2d66ac96d Use Player->isBanned() instead of repeating code 2017-12-06 10:38:02 +00:00
d03fdd5f72 Liquids refactor, bug fixes and performance improvements (#1753)
* Added Liquid->getLiquidLevelDecreasePerBlock()

* Fixed lava turning into cobblestone when flowing over water

* Cache liquid flow vectors for faster entity movement

* Removed a condition that made lava impossible to get rid of
In the PC code, the equivalent code makes the delay between scheduled ticks 4 times longer. Here, it just breaks the code. I don't know what the 4x stuff is about, but this code does not produce the expected behaviour and lava works fine regardless.

* Fixed strange behaviour with liquids trying to flow into other liquids
Liquids should consider other liquids as a path of least resistance. However, they should not actually flow into them. This fixes a variety of CPU leak issues with falling water in large water bodies such as oceans.
This also fixes the plus-shape effect that liquid is supposed to produce when a source is placed above ground.

* Removed a bad optimization making liquids flowing down slopes behave undesirably

* Optimize performance of slope searching by limiting recursion depth based on previous path lengths
If we already found a step down on a previous run after 2 blocks, it doesn't make sense to continue allowing checking 4 blocks because the results will just be ignored. This allows limiting the number of recursion steps, which significantly improves the performance when flowing down slopes.
However, this will still be just as bad for performance on flat terrain as it was to start with.

* Make some Liquid methods only accept Blocks as parameters
these are only ever passed blocks anyway, doesn't make sense to allow vectors.

* Moved some things to local variables
these are each only used in one function, so it doesn't make sense for them to be class members.

* Fixed water flow down slopes going everywhere, but degraded performance again

* Lava should only search 2 blocks for a slope

* Stop wasting CPU calculating optimal flow directions for liquids with too-high decay
It calculates the flow directions and THEN doesn't use them when it
realizes the flow decay is too high. This is completely pointless.

* Use a less hacky method to handle lava flowing into water

* Doubled flow performance on flat terrain
Since calculateFlowCost() usually ends up visiting the same blocks about 6 times when on flat terrain, it makes sense to cache some stuff for when blocks get revisited so expensive dumb checks don't need to keep on being done. On my machine this produces a 50-60% performance improvement when flowing on flat terrain.

* Fixed missing return values in Liquid->onUpdate()
these return values aren't used anywhere, but we should be consistent

* Don't allow flowing back in the same direction we just came from
This reduces the recursions by about 30%, providing about the same percentage performance improvement.

* Remove Liquid's temporalVector (it's not used anymore)
primitive types for the win!

* Move liquid collide to its own method

* add sound for lava/water mix
2017-12-04 10:09:35 +00:00
990a48d858 Better error message when a level is unloaded during its level tick
Plugins may cause this issue unexpectedly by unloading levels directly during events such as EntityDamageEvent. This adds a better error message to allow developers to understand what is going on and create appropriate workarounds.
2017-12-04 10:01:55 +00:00
af68125872 Make Level->getName() less volatile
this resolves problems with crashes when getName() is called on an unloaded level. This obviously doesn't solve the root cause of the issue (level being accessed after unload) but since many things use the level name without checking if it's unloaded first, it's a bad idea for it to be volatile.

This resolves the server crash issue noted in #1527, where an exception is raised due to level unload during a tick, which subsequently causes a crash when trying to log the exception.
2017-12-04 09:57:53 +00:00
5a0afa9f88 Fixed broken logic in EntityEffectEvents, close #1767 (#1768) 2017-12-03 16:14:20 +00:00
c301788864 API bump 2017-12-02 17:22:05 +00:00
472bf1a1ef Kill off the JSON garbage in commands
kill it with fire!
2017-12-02 16:33:19 +00:00
1a4b653d07 Color: Fixed a confusing inconsistency in documentation 2017-12-02 16:17:27 +00:00
d9f0546cb3 Added Color::mix() 2017-12-02 16:17:12 +00:00
92a1f45175 Make Living::addEffect() return bool (#1755) 2017-12-01 16:56:37 +00:00
0afe20c382 Remove redundant overridden meta property from Air 2017-11-30 11:10:07 +00:00
e94db980d7 Fixed not being able to wear armour 2017-11-29 19:51:38 +00:00
2cb81b5f8d NetworkInventoryAction: Allow returning null to ignore weird transactions
Revert "Return null on unmatched inventory action and log details"

This reverts commit fd7fb10223.
2017-11-29 12:44:41 +00:00
78cf875080 Quick-fix for crafting with big crafting grid after cancelling PlayerInteractEvent on a crafting table
this is not an ideal solution, but it works. Crafting is messy and is going to need more refactoring. Fixes #1480
2017-11-28 19:23:26 +00:00
878f1bffb9 CraftingTransaction: Don't hardcode crafting grid sizes 2017-11-28 17:29:53 +00:00
98ac6fc7be Check inventory slot is in range in SlotChangeAction 2017-11-28 16:56:02 +00:00
88318d740a Use standard subchunk iterator code in Explosion
this causes a slight performance loss (<10%), but in a sane language this would be inlined anyway
2017-11-28 11:20:22 +00:00
d3e5733ea0 Significantly improved light population performance using subchunk
direct accessing

These changes produce upwards of 2x better performance (YMMV, also
depends on the circumstances).
2017-11-28 11:20:22 +00:00
4703715063 Added a SubChunkIteratorManager class for faster subchunk handling 2017-11-28 11:20:14 +00:00
523a7f0999 Fix a very rare light propagation bug
This could occur when light sources were placed near each other and one of them is removed, the other's light would not be propagated far enough because the node wasn't queued for updating although it was marked as if it was.
2017-11-27 19:43:56 +00:00
256527c953 Chunk: Fixed possible bug with Chunk->setBlockData()
to be honest this would probably never affect anything, but let's be consistent.
2017-11-27 19:26:20 +00:00
b93691a177 Chunk: Remove redundant assignment 2017-11-27 18:58:08 +00:00
48c5db4296 Chunk: Add some PhpDoc 2017-11-27 17:51:42 +00:00
c564655f9b Chunk: Remove unnecessary default values
these are assigned in the constructor anyway.
2017-11-27 17:49:08 +00:00
49301b0d74 Chunk: Use an SplFixedArray for subchunks 2017-11-27 17:46:48 +00:00
8bc733514b LevelDB: Fixed nonsensical array access in iterator loop 2017-11-27 17:21:26 +00:00
c1a6711514 Fix for explosions modifying the wrong subchunks under some circumstances 2017-11-27 17:11:52 +00:00
f477cfa1bf Fixed a mistake in AvailableCommandsPacket 2017-11-25 11:15:20 +00:00
1f5f67e087 Liquid: Removed a bad hack-fix, fixed mobs not moving when water flows around them
this breaks more than it appears to fix, and I can't reproduce any CPU
leaks when block updates are enabled, so I'm going to assume this is OK.
2017-11-24 17:23:12 +00:00
74967eed87 Liquid: Stop abusing getLevel() in performance-sensitive situations
Most of these methods are called from onUpdate(). It's unreasonable to
assume that the level might be null during a tick (unless a plugin
messes with a block update event or something, but that's undefined
behaviour anyway). Using getLevel() simply wastes processing time by
constantly checking if the level is closed.
2017-11-24 16:58:03 +00:00
b88ffa3bdf Fixed a mistake in Block->getSide() documentation
side() -> getSide()
2017-11-24 15:09:55 +00:00
79fd9b1c96 added RottenFlesh item 2017-11-24 10:46:55 +00:00
ed195e1167 phpdoc 2017-11-23 17:27:41 +00:00
667a54fd00 Store world height in the Level for faster access
this might look like a micro optimization, but it shows up big-time on profiler snapshots.
2017-11-23 17:24:37 +00:00
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
0badaeb8f4 bump max dead ticks to 25 so death smoke cloud works properly
I wish this wasn't client sided... it's a pain to get it synced properly.
2017-11-22 19:55:25 +00:00
c5ac6a7606 Remove redundant count() for effects ticking 2017-11-22 19:44:22 +00:00
e9951b1b1f Remove redundant condition for setBreathing() 2017-11-22 19:43:09 +00:00
47f94eebd1 Use maxDeadTicks instead of hardcoded 20 2017-11-22 18:58:58 +00:00
e9e22db1e7 Cleaned up death animation handling, removed dead ticking from non-Living entities 2017-11-22 17:17:47 +00:00
75e469c380 Fixed bad parameter names due to old code additions in Block->place() 2017-11-22 14:26:55 +00:00
686e1c4470 Implement ender chest (#1462) 2017-11-22 14:25:21 +00:00
8d59843020 Order tile constants alphabetically 2017-11-22 14:00:41 +00:00
580b30b768 update versions 2017-11-22 13:51:40 +00:00
589ca45825 Updated RakLib dependency (again) 2017-11-22 09:43:33 +00:00
88ad43971a constant visibility 2017-11-21 16:50:27 +00:00
1fd9994056 Merge branch 'master' into mcpe-1.2.5 2017-11-21 16:48:18 +00:00
808227d9a9 Hack for player spawning issue (ref. #1539) 2017-11-21 15:20:56 +00:00
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
3f854127ca Updated RakLib depdendency 2017-11-21 14:36:23 +00:00
9da19b5f15 Added API methods for getting & setting armour dye colours 2017-11-21 14:10:33 +00:00
78d24b9183 Take 2: Fixed resource pack matching for uppercased UUIDs
fixed the wrong damned bug...
2017-11-21 11:29:12 +00:00
46afb7caf1 Fixed resource pack matching for uppercased UUIDs 2017-11-21 11:25:21 +00:00
0ee452773d Fixed missing getValue() implementation on CompoundTag 2017-11-21 10:52:00 +00:00
a39c9e8c8e add ResourcePack->getPath(), close #1559 2017-11-20 13:24:30 +00:00
32714d4564 Don't write server.properties to disk unless it's been modified at runtime 2017-11-20 10:04:39 +00:00
feade9d982 Added a flag to Config to allow detecting if it has been modified since it was last saved 2017-11-20 10:04:11 +00:00
373f085436 Fixed a usage of get(true) 2017-11-20 09:50:52 +00:00
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
a8ad956b29 Fixed keepMovement logic 2017-11-19 19:28:04 +00:00
00a9ae6c95 make use of getSavableEntities() in Level->unloadChunk()
why couldn't I have thought of this before I changed this the first time >.>
2017-11-19 18:08:42 +00:00
a9df383346 generalized conditions for saving entities with chunks 2017-11-19 18:06:38 +00:00
19dc22d6b3 Chunk save: skip entities which won't be saved anyway
don't just hardcode this to players
2017-11-19 17:57:54 +00:00
2fd61163bf cleanup some chunks leftovers from 1.0 2017-11-19 17:52:36 +00:00
5640bcb0b8 add some new leveldb keys 2017-11-19 17:43:54 +00:00
ea3c7383fb Added support for handling MCPE 1.2 leveldb worlds
requires php-leveldb version >=0.2.1 and the latest version of
pmmp/leveldb-mcpe
2017-11-19 17:31:09 +00:00
7e496afdd1 Fixed issues with LevelDB worlds silently getting overwritten with the default format when LevelDB extension is not loaded
Always register the level provider (to allow detecting the world format) but throw exceptions if anything tries to use it without the extension being loaded.
2017-11-19 17:28:16 +00:00
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
c75e62b38c Fix /gamemode output again 2017-11-19 15:28:34 +00:00
3a80ec4db8 Add bed too far message 2017-11-19 10:22:04 +00:00
8abad33048 Change TextFormat::WHITE to RESET in Server.php 2017-11-19 10:22:04 +00:00
a91a4489d4 Updated PocketMine-Language submodule 2017-11-19 10:21:06 +00:00
96348e0e44 Fix setMaxAirSupplyTicks() (#1555) 2017-11-19 01:40:46 +00:00
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
dc553142c9 Remove redundant if/else in Player->checkGroundState() 2017-11-18 15:59:51 +00:00
81fe00a0a5 Slightly simplify Player->kick() 2017-11-18 15:56:58 +00:00
6facd8b50f Provide a way for plugins such as Specter to bypass chain verification 2017-11-18 12:44:18 +00:00
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
eaba105614 Durable: use new CompoundTag API 2017-11-18 11:13:35 +00:00
12bbc764ec Fixed Level->getSafeSpawn() looking for blocks in chunk 0,0 2017-11-17 20:45:29 +00:00
bee3c4f5cd Cleaned up error messages for submodules (they are Composer dependencies now) 2017-11-17 19:56:05 +00:00
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
5178373d8a fixed overoptimized code in getSafeSpawn(), close #1248 2017-11-17 13:58:03 +00:00
28188e5ef4 remove redundant count() for updateTiles 2017-11-17 13:47:54 +00:00
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
adabfe78df no-op for PlayerAction START_SLEEPING
this is pretty pointless tbh
2017-11-17 13:30:25 +00:00
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
ffa9a91a95 Remove dead craftingType field from Player 2017-11-17 12:57:49 +00:00
78bb951942 Remove redundant survival check for exhaustion 2017-11-17 12:55:48 +00:00
7508524b7b Arrange login sequence code in a bit more chronological order 2017-11-17 12:47:57 +00:00
db4a8be240 Remove duplicated duplicated player code in Player 2017-11-17 12:39:12 +00:00
3fe9963c84 remove redundant arguments for Entity methods 2017-11-17 12:19:36 +00:00
db8a835a64 add a default value for Entity->setCanClimb() 2017-11-17 12:19:04 +00:00
460d540dbc Further cleanup on ListTag and CompoundTag usage 2017-11-17 11:43:32 +00:00
665130561e Further cleanup on NBT dynamic field access
not sure how I missed so many of these... there are probably lots more besides :(
2017-11-17 11:19:36 +00:00
48a7627b96 add constants for NBT tag names in WritableBook 2017-11-17 10:48:48 +00:00
235fc4cd2f remove redundant null coalesce 2017-11-17 10:45:14 +00:00
e0654b85ba get rid of dynamic field assignments
nearly there now... eventually
2017-11-17 10:43:51 +00:00
19315dfd06 Some cleanup on WritableBook code, get rid of some CompoundTag magic 2017-11-17 10:43:51 +00:00
f3ee605cd3 ignore doxygen files 2017-11-16 16:37:30 +00:00
976d5583cc Remove ItemFrame drops hack 2017-11-16 15:13:22 +00:00
6adc813a7f Fixed disable-block-ticking pocketmine.yml config not working 2017-11-16 14:45:00 +00:00
769f3f75cd added public doxygen configuration 2017-11-16 10:38:39 +00:00
432d90bddd quickfixes for command messages
these will have to be fixed properly at a later date
2017-11-16 08:56:01 +00:00
3a16985d45 Cleaned up item & arrow pickup code 2017-11-15 12:14:42 +00:00
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
2794df34ab Basic implementation of banners, including API to modify them with ease. (#1331)
Banner crafting is NOT implemented yet.
2017-11-15 11:10:46 +00:00
73cd195e76 Merge branch 'master' into mcpe-1.2.5 2017-11-14 20:06:00 +00:00
0d2b171c2c Remove RakLib and SPL submodules, start using Composer 2017-11-14 19:37:58 +00:00
aa399a1109 migrate to new CompoundTag API (#1515) 2017-11-10 15:38:21 +00:00
d4494687d1 Fixed collision blocks not being recalculated after teleporting, close #1531 2017-11-09 15:11:42 +00:00
6fe45a69c8 Updated RakLib submodule 2017-11-09 14:44:38 +00:00
784ecef805 Remove unnecessary count() 2017-11-08 19:44:10 +00:00
41f363d0c1 Added encode for AvailableCommandsPacket, bring back command lists (no arguments yet) 2017-11-08 11:52:06 +00:00
827ee5ff33 more constants in Tile 2017-11-08 10:49:15 +00:00
a4e955c0a4 Merge branch 'master' into mcpe-1.2.5 2017-11-07 15:27:14 +00:00
733e61f815 add return typehints for Item fluent methods
to prevent issues like a2d4baf8b9 happening again >.>
2017-11-07 09:54:08 +00:00
0621d5c8ea Fixed JSON NBT parsing lists in /give 2017-11-07 09:50:59 +00:00
a2d4baf8b9 Fixed ItemBlock->setDamage() not returning a value 2017-11-07 09:44:34 +00:00
23bc97e098 Updated PocketMine-DevTools submodule 2017-11-07 09:36:58 +00:00
14e6e3694d Updated RakLib submodule 2017-11-07 09:35:00 +00:00
0e64c3dad8 fixed misusing isAlive(), close #1523 2017-11-07 09:32:38 +00:00
99f06c6c18 Fixed player hit animations 2017-11-06 14:41:48 +00:00
3ca9e6ae98 Merge branch 'master' into mcpe-1.2.5 2017-11-06 14:35:10 +00:00
fd0b07a0aa Added API to allow getting player latency 2017-11-06 14:33:27 +00:00
6ece799998 Updated RakLib submodule 2017-11-06 09:09:20 +00:00
a9c75a882a Updated PocketMine-SPL submodule 2017-11-05 20:51:26 +00:00
4437b67178 added some EntityEventPacket constants 2017-11-05 12:41:39 +00:00
34d2047ac3 A better error message for Server::getInstance() access on other threads 2017-11-05 18:40:47 +08:00
20d2ef9d38 Fixed players respawning in the wrong world
add() returns a Vector3 instance, not a Position instance... argh
2017-11-04 22:04:33 +00:00
eab7b93483 Fixed misuse of kill() and close() when deleting entities (#1490) 2017-11-04 19:30:48 +00:00
e84ab8fec2 Disable stats reporting by default on new installs
since we don't have a stats server at the moment, this simply causes long delays on server stop while the server instance attempts to communicate with stats.pocketmine.net.
2017-11-04 18:41:18 +00:00
a66a757f56 Cleaned up EntityEventPacket handling 2017-11-04 18:31:35 +00:00
ddb7fd12f2 removed obsolete EntityEvent broadcast 2017-11-04 18:28:29 +00:00
6ccb494f8d added API to get player language code
sadly this isn't particularly useful without something like the intl
extension to translate the language codes to ISO-632-1 codes like the
ones PocketMine-MP uses. However, this will do for now.
2017-11-04 15:50:00 +00:00
2ec7763bd6 Cosmetically improve UUID::equals() (#1517) 2017-11-04 10:45:05 +00:00
d663887f9c Merge branch 'master' into mcpe-1.2.5 2017-11-03 16:43:34 -04:00
6ebe3bfbea use Player->sendDataPacket() with immediate parameter 2017-11-03 19:00:08 +00:00
4533df17cf make username validation on login less stupid
why are we checking if the username is valid AFTER we already tried to set it? it might not even be a string
2017-11-03 18:49:28 +00:00
8ae663425f try...catch attempt to decode connection request in incompatible logins
to allow protocol version hacking without it being so damn inconvenient
2017-11-03 18:46:40 +00:00
e95b1d4b00 look for item IDs in ItemIds instead of Item
Item is likely to be more polluted by other constants which aren't item IDs.
2017-11-03 12:42:51 +00:00
8ad02c9a4e Remove redundant condition from ItemFactory
it's unrealistic to have a numeric constant name, so this condition is pointless.
2017-11-03 12:41:24 +00:00
754e088ee8 Change visibility of Block->boundingBox 2017-11-03 12:19:51 +00:00
451f5d0cd7 Fixed block-pick on crops giving the crop block itself 2017-11-03 12:17:38 +00:00
42ed03fd02 Merge branch 'left-click-spawn-prot' 2017-11-03 11:59:26 +00:00
b51ec9e606 rough work for CommandOutputPacket, no idea if it works 2017-11-01 20:12:13 +00:00
8d07f833fc updated CommandRequestPacket 2017-11-01 20:11:31 +00:00
372b97ba8f Revert "Patch %0 client translation exploit"
this bug was (FINALLY) fixed in 1.2.5.15

This reverts commit 378c3d7994.
2017-11-01 16:17:17 +00:00
dea2942062 bump to 141 2017-11-01 16:14:12 +00:00
3614711a02 fixed negative effect durations when level tick rate is > 1
thank you @Sandertv
2017-11-01 09:09:17 +00:00
dcdea6a1f4 Merge branch 'master' into mcpe-1.2.5 2017-10-31 21:52:16 +00:00
b7cd8dbfa9 Fixed CraftingManager->cloneItemMap() being utterly useless 2017-10-31 19:01:03 +00:00
1486b5aa71 make more properties in CraftingManager protected 2017-10-31 18:49:49 +00:00
f8e6438efe updated some NBT for tiles 2017-10-31 18:22:06 +00:00
caf9eaa2da rename field in EntityPickRequestPacket 2017-10-31 12:25:20 +00:00
6db5596b00 Added Jukebox window type ID 2017-10-30 18:37:42 +00:00
4ed1a39638 Updated DevTools submodule 2017-10-30 17:06:33 +00:00
a770e681dc Implemented Config->removeNested() (#1499) 2017-10-30 16:32:48 +00:00
a342a61037 nuke nestedCache when config is modified 2017-10-30 16:27:47 +00:00
91c256f1a9 Added Level->getTileAt() 2017-10-30 13:36:42 +00:00
93443992be Fixed chests not getting updated properly on pair/unpair, close #1514
it wasn't clearing spawn compound caches or chunk caches
2017-10-30 11:50:02 +00:00
ea09cc06c7 added UUID constants for MultiRecipe 2017-10-30 11:18:56 +00:00
67af4d3b65 Cleaned up PMAnvil implementation 2017-10-29 19:13:58 +00:00
4a78bfaa18 stop messing with my doc comments PhpStorm 2017-10-29 18:02:33 +00:00
bb6b100443 extended CompoundTag API to allow force-writes and returning defaults on bad tag types 2017-10-29 18:01:33 +00:00
8aca373194 added some docs to shut PhpStorm up 2017-10-29 13:02:19 +00:00
7e490ccdf2 broadcast player skin to all online players by default
otherwise we could end up with undesirable bugs like players having the wrong skin when travelling from another part of the world... the skin has to be sent to everyone to update the player list
2017-10-29 12:19:47 +00:00
991d321928 improved geometry debloating, also apply on skin changes 2017-10-29 12:14:16 +00:00
600d80331a Accept null for targets in Human->sendSkin()
For humans, it'll send to all viewers. For players, it'll send to all viewers, and the player itself.
2017-10-29 11:18:34 +00:00
f79e4237df Cache a compressed CraftingDataPacket to reduce workload on player join
this saves only a couple of ms per player join, but still worth it.
2017-10-29 09:57:55 +00:00
6ce9e79cd5 fix some minor documentation issues in Binary 2017-10-28 18:40:05 +01:00
e88aa385a3 make use of new pack() codes for longs 2017-10-28 14:04:41 +01:00
5303a710ac Updated RakLib submodule 2017-10-28 10:26:34 +01:00
dd085b35cc Merge branch 'master' into mcpe-1.2.5 2017-10-27 21:24:30 +01:00
6ff1088a57 fix chest AABB 2017-10-27 19:16:06 +01:00
d1db27016e s/facePos/clickVector/
clickVector better describes this
2017-10-27 19:05:26 +01:00
c55bc2d7e9 added use-item click vector to PlayerInteractEvent
now go and make some touchscreens with maps!
2017-10-27 19:00:17 +01:00
747477dfcf Changed potentially misleading parameter name in CompoundTag->getTagValue() 2017-10-27 11:04:03 +01:00
48fefae920 Added cache for tile spawn compounds
avoids expensive repetetive NBT writes on chunk sends when the tile hasn't been changed
2017-10-27 10:23:48 +01:00
52d0ad8a61 be yet more tolerant for on-ground checks on players 2017-10-26 23:23:11 +01:00
bddd7e0eee Fixed no fall damage when falling 3-4 blocks, close #891 2017-10-26 23:23:08 +01:00
883898682f Merge remote-tracking branch 'origin/master' into mcpe-1.2.5 2017-10-26 15:34:56 -04:00
daf457213d Updated RakLib submodule 2017-10-26 16:35:33 +01:00
bd2cb85861 changed type of EntityLink unknown field and added a constructor 2017-10-25 18:50:07 +01:00
1d651046c9 Compute time in milliseconds once and use it for both firstPlayed and lastPlayed
fixes issues where lastPlayed can be a tiny fraction of time into the future of firstPlayed when players join for the first time
2017-10-25 17:12:17 +01:00
1dea25d123 Fixed wrong translation key used for level generation errors 2017-10-25 16:42:49 +01:00
b6264d188e Change Server->getConfigBoolean() to getConfigBool()
to be consistent, deprecated the original
2017-10-25 16:30:39 +01:00
2635c85873 beware users putting garbage in pocketmine.yml 2017-10-25 12:54:53 +01:00
3b85e558ce Fixed bad documentation on Level->checkSpawnProtection() 2017-10-24 18:56:38 +01:00
d48880e31b Remove redundant assert 2017-10-24 17:40:22 +01:00
93d60a9beb Updated DevTools submodule 2017-10-24 16:23:04 +01:00
a82efc44aa wtf 2017-10-24 13:29:28 +01:00
6daa0135d5 Cancel PlayerInteractEvent automatically on left-click block when spawn protection is triggered 2017-10-24 13:11:19 +01:00
08092f17e0 Merge branch 'master' into mcpe-1.2.5 2017-10-24 10:24:37 +01:00
716c1f29b4 Fixed slabs again 2017-10-24 10:23:07 +01:00
0072af95cb Bump version to 1.2.5.12 and protocol changes 2017-10-23 20:04:47 +01:00
0df3b00de4 Fixed incompatible protocol message showing an empty pair of brackets when protocol is null
this happens if an exception occurs while or before trying to read the protocol version
2017-10-23 19:44:19 +01:00
13e5718463 Using BlockFactory instead of Block 2017-10-23 18:50:37 +01:00
270e0c076c Fixed items not removed when put in the lava 2017-10-23 18:50:37 +01:00
3765511317 rename WritableBook->swapPage() to swapPages() 2017-10-23 17:55:01 +01:00
8daa8deae9 Added Living->lookAt() 2017-10-23 17:29:20 +01:00
e055ce9526 Use translation for flight kick message (#1489) 2017-10-23 13:18:57 +01:00
3ed8855894 fix drop chance of rotten flesh 2017-10-23 12:35:57 +01:00
f25255e46c fix zombie drops 2017-10-23 12:24:34 +01:00
7db8345424 Added rough support for reading entity saves with multiple save IDs (for PC 1.11 compatibility)
this will still always save using the legacy format to remain compatible with PC < 1.11.

TODO: entirely separate entity NBT format from entity implementation for proper multi-format compatibility
2017-10-22 10:16:24 +01:00
bc7ba3b3c1 Found field of ShowProfilePacket 2017-10-21 14:53:49 +01:00
1dd2203ee5 Fixed burning mobs not getting onfire data flag set when read from disk
they'd just flash red and take damage for no apparent reason
2017-10-21 12:36:30 +01:00
554096953b Abuse property visibility to micro optimize CompoundTags
this produced a little less than 10% performance improvement under xdebug, and while the real-time benefit is negligible, it's harmless to have.
2017-10-20 20:07:54 +01:00
55a1731da3 Remove redundant asserting function in Binary
If this was an inline assert, it would be harmless. Since it's in a function, it contributes to a 20% performance loss when using these functions on a large scale regardless of whether assertions are enabled or not.
Additionally, there's no need to assert that we have enough bytes since unpack() will raise warnings if there isn't, which will trigger exceptions, and for readByte(), an undefined offset notice will be raised, which will also trigger an exception.

TL;DR: This is simply wasting CPU time for no good reason.
2017-10-20 19:23:04 +01:00
ba3fe20227 Fixed missing variant bitmask for Leaves, close #1478 2017-10-20 18:37:46 +01:00
7b04049bb7 Throw exceptions when trying to add closed entities or tiles to levels 2017-10-20 18:22:28 +01:00
30211bee82 Fixed excessive idle CPU usage for chunk ticking
"excessive" = 5%, after changes = 1.6% - YMMV, but that's my machine.
2017-10-20 15:54:22 +01:00
e318dc12a5 missed target 2017-10-20 15:36:59 +01:00
967ce99b03 Made incompatible PHP version messages more useful 2017-10-20 15:35:43 +01:00
9bdda54aec Fixed PocketMine.php compatibility with < PHP7 2017-10-20 15:34:03 +01:00
18e4e5364f Fixed getBlock() performance degradation caused by 781de3efab, added Level->getBlockAt() to avoid creating vectors everywhere 2017-10-20 13:22:49 +01:00
98cfd0b398 fix entity rotation changes not getting broadcast until the entity moves 2017-10-20 10:13:19 +01:00
a245615531 fixed non-living entities lingering for a second after being kill()ed
only living entities should have death animation time
2017-10-19 20:51:50 +01:00
0a19a2611a Re-organise some Entity methods 2017-10-19 19:03:11 +01:00
50be26958a Added a helper function Entity->createBaseNBT() to cut down on boilerplate code 2017-10-19 17:36:51 +01:00
67c6fca0ed Relocate a couple of Entity API methods and add some documentation 2017-10-19 17:05:27 +01:00
d99e9513b0 Remove some redundant constructor overrides 2017-10-19 16:42:14 +01:00
5a353012de Clean up some unused imports 2017-10-19 16:39:34 +01:00
087badcb48 Remove deprecated effects methods from Entity 2017-10-19 16:35:44 +01:00
d9769360fe Remove redundant code from Entity->entityBaseTick()
this will never be called because onUpdate() checks this and returns.
2017-10-19 16:32:45 +01:00
9fb93985d6 Cleaned up Entity->spawnTo() 2017-10-19 16:13:09 +01:00
2b22d5d8cc Added EntityIds interface with constants 2017-10-19 15:43:55 +01:00
2db13bd114 added throwable eggs and refactor some projectile logic
close #1473
2017-10-19 14:12:50 +01:00
11cc20972f extended death animation time 2017-10-19 13:39:51 +01:00
4821e7386d fixed entities despawning too soon when killed 2017-10-19 13:39:10 +01:00
584810780a Moved projectile-related classes to their own namespace 2017-10-19 12:27:44 +01:00
55de75b914 Let blast resistance be computed from hardness for flowable blocks
fixes several flowable blocks apparently not having any resistance to explosions
2017-10-19 11:50:21 +01:00
2a1a17aa7a Refactored button code, fix placement rotation 2017-10-19 11:36:30 +01:00
90165cf99d Implemented farmland hydration
TODO: make crops take notice of this
2017-10-19 11:23:54 +01:00
a4ca3f1d1c Updated PocketMine-Language submodule 2017-10-18 21:08:39 +01:00
f783789e5a fixed escape code unescaping in language files, close #1474 2017-10-18 20:43:35 +01:00
43be64baed Register some more items
the item-blocks will allow their blocks to be placed, but they still won't work until the blocks themselves are added.
2017-10-18 19:52:19 +01:00
5c92c8a9d3 added red sandstone and red sandstone stairs 2017-10-18 19:42:12 +01:00
d2dc49cd9c Refactor Slab logic away from WoodenSlab, added StoneSlab2 and its double 2017-10-18 19:27:54 +01:00
f148c366f9 Use Block->getVariant() more, get rid of hardcoded bitmasks 2017-10-18 17:46:24 +01:00
91d84aaff4 Fixed a direct Block construction that PhpStorm somehow couldn't see 2017-10-18 17:03:55 +01:00
6b78ba8c25 replace some hardcoded values with Vec3 constants 2017-10-18 17:03:18 +01:00
b9de2e8b4b Use bit operations for rotations instead of hardcoded values 2017-10-18 16:47:37 +01:00
15764543b4 Use PillarRotationHelper for hay bales 2017-10-18 16:41:43 +01:00
2c34648c3d fixed second half of double chest items getting deleted, close #1477 2017-10-18 12:29:57 +01:00
3e3157cbe1 fix tick diff debug spam when entities are spawned 2017-10-17 17:38:43 +01:00
07abd61f73 Added a FIXME for Entity->move() 2017-10-17 17:14:45 +01:00
a456b7cfca Disable movement anti-cheat by default
shit's useless and an annoyance.
2017-10-17 16:45:18 +01:00
ece37d1e19 Added more methods to PlayerIllegalMoveEvent 2017-10-17 16:14:41 +01:00
cccaade00c make Player#unloadChunk() method protected 2017-10-17 14:22:57 +01:00
7f0a961526 "Creator" tag on signs may not exist 2017-10-17 13:35:31 +01:00
68ac4f538f Added ContainerTrait, reduce copy-pasted code in Tile 2017-10-16 20:01:17 +01:00
f14b7cbf78 Renamed BlockEventPacket fields 2017-10-16 19:55:42 +01:00
f4ff5d81ea Added missing parent calls for saveNBT() in Chest and Furnace 2017-10-16 18:56:48 +01:00
28a840d161 Make use of CompoundTag->hasTag() 2017-10-16 18:32:08 +01:00
292e462ea0 Remove nullable return types on CompoundTag getters
this doesn't make sense because there are default value parameters for this
2017-10-16 18:22:45 +01:00
c8379efbce Added expectedClass parameter to hasTag() to allow type-checking 2017-10-16 17:26:12 +01:00
1b5746fd97 Use NamedTag::class for default expectedClass in CompoundTag->getTag() 2017-10-16 17:22:38 +01:00
4a0ac01697 Fix PhpStorm derp
wtf?
2017-10-16 17:02:00 +01:00
9bcb41fb21 Refactor misleading parameter names in CompoundTag
these are NBT tag classes, not the NBT tag type. The tag type is an integer which describes the tag on disk.
2017-10-16 17:00:57 +01:00
20b86bdea8 Cleaned up tile NBT handling, use new CompoundTag API methods 2017-10-16 16:48:24 +01:00
0b1a9ba062 Added more typehints to Tile namespace 2017-10-16 16:14:44 +01:00
45b003ac2e Removed unnecessary return from Sign 2017-10-16 16:10:33 +01:00
769a50faa5 Refactor confusing parameter names for Item->onActivate()
next: refactor the function itself
2017-10-16 13:30:36 +01:00
af85659c63 Remove redundant property from Tile 2017-10-16 12:35:32 +01:00
95fa1824c8 Use a trait for nameable tiles instead of repeating code 2017-10-16 12:32:10 +01:00
251d5d7946 Fixed some hardcoded values in Tree 2017-10-16 12:30:46 +01:00
3b5eb45ff5 More usages of Item->isNull() 2017-10-16 12:29:39 +01:00
fd847f02ad Added BaseInventory->dropContents() 2017-10-16 12:18:06 +01:00
18d3a97466 Anvil result slot is not a real inventory slot
like the crafting grid result slot, this doesn't actually exist, it's
just somewhere you get the result item from.
2017-10-16 12:00:43 +01:00
04668d534d Oops, these fields need to be filled 2017-10-16 11:50:34 +01:00
092cc2750f Added entity unique ID for Entity containers
minecart with chest for example
2017-10-16 11:49:34 +01:00
68809d992b Added BaseInventory->removeAllViewers() 2017-10-16 11:15:03 +01:00
1641183674 added some typehints to Item 2017-10-16 10:29:44 +01:00
72531209bf Added some constants for frequently-accessed item NBT tags 2017-10-16 10:24:32 +01:00
8c6ab3e634 Some cleanup to item NBT handling 2017-10-16 10:15:41 +01:00
97e2d64592 "Fixed" shift-clicking recipe book, close #1401
this is not an optimal solution because you'll still only get 1 crafting
event when the user actually crafted a lot of items, so this isn't very
nice for plugins to work with. However, for gameplay purposes it works,
so it'll do for now.
2017-10-15 18:08:32 +01:00
a547e2cca8 Fixed sub-optimal code in WritableBook 2017-10-15 10:14:02 +01:00
cdebb62c35 added typecast for forceLanguage property read 2017-10-14 23:26:00 +01:00
2e73fd7f8c Add missing setValue() override to LongTag
why did this take two commits ;-;
2017-10-14 22:24:17 +01:00
51906daad0 Add typehints and PhpDoc to NBT API 2017-10-14 22:07:25 +01:00
ce67bc620a add Travis Test data directory to gitignore 2017-10-14 22:06:07 +01:00
bcefc3a54b Flag expectedType as nullable 2017-10-14 20:45:37 +01:00
f5378ab604 Fixed assertion failure when using getTag() without specifying an expected type 2017-10-14 20:45:32 +01:00
dab7cfde1c Added new API methods in CompoundTag to allow developers to stay sane (#1469)
Added getters and setters to CompoundTag with type safety
we need generics so badly here it hurts

This is fully backwards compatible, however the following API methods have been added to the `CompoundTag` class:

- getTag(string $name, string $expectedType = null) : ?NamedTag
- getListTag(string $name) : ?ListTag
- getCompoundTag(string $name) : ?CompoundTag
- setTag(NamedTag $tag) : void
- removeTag(string ...$names) : void
- hasTag(string $name) : bool

- getTagValue(string $name, string $expectedType, $default = null)
- getByte(string $name, ?int $default = null) : ?int
- getShort(string $name, ?int $default = null) : ?int
- getInt(string $name, ?int $default = null) : ?int
- getLong(string $name, ?int $default = null) : ?int
- getFloat(string $name, ?float $default = null) : ?float
- getDouble(string $name, ?float $default = null) : ?float
- getByteArray(string $name, ?string $default = null) : ?string
- getString(string $name, ?string $default = null) : ?string
- getIntArray(string $name, ?array $default = null) : ?array

- setTagValue(string $name, string $tagType, $value) : void
- setByte(string $name, int $value) : void
- setShort(string $name, int $value) : void
- setInt(string $name, int $value) : void
- setLong(string $name, int $value) : void
- setFloat(string $name, float $value) : void
- setDouble(string $name, float $value) : void
- setByteArray(string $name, string $value) : void
- setString(string $name, string $value) : void
- setIntArray(string $name, array $value) : void
2017-10-14 18:36:02 +01:00
6e1318b522 Push minimum requirement to PHP 7.2.0RC3
there are needed ZTS bugfixes included in RC3. I didn't move this earlier because Travis didn't have an RC3 build.
2017-10-14 14:26:21 +01:00
cd8006e242 Use constructor parameter for ListTags instead of setTagType() and removed some unnecessary type setting 2017-10-14 13:49:24 +01:00
f5abed95ec added missing type doc to ListTag 2017-10-14 12:48:38 +01:00
489b9fc29b Added missing getter override for LongTag
adds a return typehint
2017-10-14 11:34:41 +01:00
b524b841c5 Reduced duplicated code in AxisAlignedBB->calculateIntercept() 2017-10-14 11:01:00 +01:00
41f292d995 BlockUpdateEvent doesn't allow changing the target block anyway 2017-10-14 10:10:19 +01:00
fd8a562e02 Fixed collision bugs caused by not clearing pre-computed outdated AABBs for blocks
take fences as an example: say you have fence1 and fence2 next to each other, like this:
|==|
and they are joined together
then delete the fence on the right
the left fence will then look like this
|
but the server would still think its collision boxes were like this:
|=
so you wouldn't be able to shoot arrows through that space.

This commit clears pre-computed bounding boxes when a block is set using Level->setBlock() (in case the block was previously already set and has pre-calculated outdated AABB). However, because of weird blocks like fences, glass and walls, they must also be cleared on neighbour block update (since connection state isn't shown in the block data).
2017-10-14 10:07:17 +01:00
cc553a157d Clean up BlockEventPacket handling for Chests and fix wrong data for chest open 2017-10-13 20:07:33 +01:00
a6d1cc27ec Fix for explosions not removing tiles, close #1450 (#1463) 2017-10-13 13:57:50 +01:00
d8c90be5b8 Make on-ground checking less fussy 2017-10-13 13:19:20 +01:00
060426ff12 Add ability to unregister a command completely, close #1229 (#1464) 2017-10-13 11:55:36 +01:00
eeea4fa06a Added some new blocks 2017-10-13 11:51:38 +01:00
401e33dd85 fix anvil bounding box 2017-10-13 11:18:19 +01:00
2893aac3ac ... 2017-10-13 11:06:10 +01:00
c5c74c1898 fixing glass & bars collision detection
so much duplicated code, it would be nice if Fence could inherit from Thin, but that causes too many issues with block connections.
2017-10-13 11:04:51 +01:00
423bea4b57 Fixed a couple of blocks incorrectly descending from Solid 2017-10-13 10:37:48 +01:00
e3567faa94 Anvils aren't non-solid, they are transparent
solid and transparent are not mutually exclusive!
2017-10-13 10:22:22 +01:00
4b5040dcc7 Blocks extending Thin ARE solid 2017-10-13 09:52:08 +01:00
21c79b0645 Use up to 2 AABBs for fence collision checks instead of 5
overlapping cuboids do fine
2017-10-13 09:40:29 +01:00
7b5df10b6a Reset position properly when reverting movement 2017-10-12 20:33:26 +01:00
c4fe9ad32d Remove pointless API method from PlayerMoveEvent 2017-10-12 19:59:32 +01:00
60b62a4890 fixed wall collision detection
walls have to be weird...
2017-10-12 19:36:06 +01:00
061a9444cc implemented multi AABB collision checks for fences and walls
fixes anti-cheat getting triggered when falling down between a square of fences
fixes not being able to shoot arrows between a square of fences
2017-10-12 18:33:26 +01:00
3eb73ab468 Abstracted Fence code away from wooden fences 2017-10-12 17:04:49 +01:00
15d6fd86e2 Added basic support for blocks with multiple AABBs, fixed stairs (#1303) 2017-10-12 16:29:24 +01:00
0c092a7ceb reduced size of arrow bounding box
as per MCPE addon data
2017-10-12 16:21:23 +01:00
b9501ef415 Remove unnecessary duplicated ray-trace code from Block
this isn't actually used anywhere, but "backwards compatibility"
2017-10-12 13:40:12 +01:00
5afe4fdb5b Use Vector3 constants instead of hardcoded integers 2017-10-12 13:32:17 +01:00
cc7ed7a28f Added some documentation to AxisAlignedBB 2017-10-12 12:22:13 +01:00
7e9b89e48a Make Entity->checkObstruction() less confusing 2017-10-12 11:59:02 +01:00
63fccd4682 farmland and grass path should die when a solid block is above them 2017-10-12 11:11:33 +01:00
35e7aca88f refactor some more stupid variable names 2017-10-12 10:45:22 +01:00
9413f155ce implement updating properly for multi-face vines 2017-10-12 10:21:08 +01:00
6569fdbe04 Refactor some variable names in Vine 2017-10-11 20:12:12 +01:00
d8b1757ebc added some nullable and void typehints to Block API 2017-10-11 18:45:40 +01:00
8f0ee84277 Cleaned up Ladder AABB calculation code 2017-10-11 18:25:16 +01:00
b7a9e10d49 Some cleanup to how tiles are created 2017-10-11 18:08:08 +01:00
be2d134994 Added API to allow flagging an entity not to be saved to disk when its chunk is saved (#1452) 2017-10-11 16:09:08 +01:00
7b1bfc0520 fix some typos in pocketmine.yml 2017-10-11 13:42:32 +01:00
59d9d6a7df Fixed logic for low memory chunk radius override 2017-10-11 13:40:13 +01:00
8d095dff6c Given some MemoryManager fields less confusing names 2017-10-11 13:27:33 +01:00
4981931c4a Remove reliability hacks for RakLib
bug was fixed in 691a7be66b
2017-10-11 10:59:27 +01:00
5dafabbec2 Updated RakLib submodule 2017-10-11 10:59:27 +01:00
2a5d954c67 fixed yaw/headyaw field order
I wish they'd stop changing this shit... this is the third or fourth time now?
2017-10-10 22:45:30 +01:00
287f08cbd1 Changed confusing MovePlayerPacket field name to be consistent with other packets 2017-10-10 21:56:17 +01:00
76469e1d5f Remove useless properties from pocketmine.yml
these have been here for years but have never been of any use, they just confuse new users.
2017-10-10 00:01:05 +01:00
c4c83e23ca Revert RakLib to 1830bb7
disconnect & transfer issues... no idea why
2017-10-09 20:30:44 +01:00
eccc7bf7b3 Moved EntityLink to its own type 2017-10-09 19:15:53 +01:00
78ca2f2e58 fix heads rotating 45 degrees when placed facing north 2017-10-09 18:12:56 +01:00
cef9c4621c added som PhpDoc to Tile 2017-10-09 17:27:34 +01:00
151681bd80 Remove some dead properties from Tile 2017-10-09 17:25:10 +01:00
327907988b Fixed a typo in Sign->setText() docs 2017-10-09 16:56:25 +01:00
97dbf61236 Remove some no-longer-needed item classes 2017-10-09 12:31:57 +01:00
2be8b576ef Changed constructor of ItemBlock to allow handling blocks with different item IDs, added more doors 2017-10-09 11:58:58 +01:00
6dbdefafdd Add the long-awaited Enchantment::registerEnchantment() API method
api3/blocks users: I am sorry I kept you waiting so long
2017-10-09 11:40:53 +01:00
9598b8cee4 Use API methods instead of directly setting properties 2017-10-09 11:38:52 +01:00
246c6daef6 how irritating 2017-10-09 11:30:11 +01:00
2601e35990 Cleaned up and added API for entity air supply, fixed oxygen being used in creative/spectator
this commit also includes respiration checks because it's cherry-picked
from api3/blocks, but respiration won't work until it's registered.
2017-10-09 11:28:40 +01:00
bdfd9c95dd Minor cleanup to attack handler 2017-10-09 11:02:00 +01:00
cd44551d64 Cleaned up checks for handling inventory transactions 2017-10-09 10:57:28 +01:00
cebb4b35f6 Fixed beds not getting deleted properly in survival
the anti-instabreak kicked in twice... damned anti-cheat... luckily the player is not needed for this part
2017-10-09 10:49:30 +01:00
7267f1a520 Fixed some usages of Item constants for Blocks
only cosmetic change
2017-10-09 10:37:19 +01:00
66a3354b31 Fixed not respawning adjacent tiles correctly when cancelling block break events 2017-10-09 10:30:48 +01:00
ac7384a2b4 Re-organise some Player methods
- group spawn-related methods
- group achievement-related methods
- move isSleeping()
- group name-related methods
- move Player->sendAllInventories()
- move Player->jump()
2017-10-09 10:25:33 +01:00
748beaaaa7 Changed a couple of very misleading default values
why on earth did I do this
2017-10-09 09:55:18 +01:00
58788b4bc7 Removed some unnecessary stuff PhpStorm complained about 2017-10-09 09:46:21 +01:00
ae76ac82c8 Removed unnecessary delegate packet handlers
let's keep all the TODOs in one place
2017-10-09 09:44:22 +01:00
e4000f8f03 Reorganise some packet methods in Player 2017-10-09 09:35:31 +01:00
ebcce43131 Don't hold player references for hiddenPlayers
they aren't needed, and this is just one more thing that could go wrong in Player->close() that could lead to leaks.
2017-10-09 09:20:44 +01:00
119913da30 Modified misleading comment (#1455)
The plugin isn't supposed to extend PluginTask, the task is
2017-10-09 07:52:40 +01:00
1a88f59b23 Moved some stuff from join to login
this is how it should be
2017-10-08 19:38:03 +01:00
fdfe70b9f2 Removed entity metadata setting from LoginPacket handler
why the f was this here
2017-10-08 19:10:49 +01:00
3bda1473e7 Removed outdated documentation for Player->getClientId() 2017-10-08 18:47:13 +01:00
29cd071108 Added some documentation on player UUIDs 2017-10-08 18:40:27 +01:00
1810088acf Use Player->isCreative() 2017-10-08 18:17:12 +01:00
51e4a62e7b Use setUsingItem() instead of directly setting data flags 2017-10-08 18:03:19 +01:00
aa91183504 Added Durable class, fixed some tools not breaking correctly, removed some boilerplate code 2017-10-08 15:54:31 +01:00
ae5aa31e7b Add Item->setNamedTagEntry() and Item->removeNamedTagEntry() 2017-10-08 15:06:30 +01:00
7239dbbb1a Merge remote-tracking branch 'origin/pr/1453' 2017-10-08 14:20:02 +01:00
3738ab1f8a Fixed villager professions being useless 2017-10-08 14:14:42 +01:00
8fafef2f7f Added tagType parameter to ListTag constructor, remove some boilerplate code 2017-10-08 13:28:01 +01:00
5b9515b20f Peaceful difficulty allows PvP 2017-10-08 13:57:25 +02:00
69e29236aa Remove some redundant code for checking existence of creative items
getCreativeItemIndex() does basically the same thing anyway
2017-10-08 12:50:53 +01:00
e8453b7872 Item->getNamedTag() now always returns a CompoundTag object, removed lots of boilerplate code
This change resulted from many complaints and ugly boilerplate code because getNamedTag() is only ever used when you want to read from the tag or modify it. If you have code that depends on this returning null, you should use hasCompoundTag() instead.
2017-10-08 12:41:57 +01:00
00bf190e54 Make Item->getNamedTag() a bit less ugly 2017-10-08 12:17:18 +01:00
81dee2f9fc Adding writable and written books. (#1397)
* Adding writable and written books.
* Added a PlayerEditBookEvent.
* Changed BookEditPacket field names.
2017-10-08 11:49:57 +01:00
f6875705a1 Found fields of PhotoTransferPacket
now if we could only get portfolios...
2017-10-08 11:25:27 +01:00
d294d5a91b Clarified location table doc for RegionLoader 2017-10-06 09:40:46 +01:00
a7e9aa4bc1 Fixed falling sand replacing wrong blocks when moved slightly by currents 2017-10-05 17:38:32 -04:00
628ff9449e Fixed respawn fall damage when dying while falling from causes other than fall damage
tl;dr: fall distance didn't get reset
2017-10-05 16:47:50 -04:00
7f5fe137d1 Added some type docs to RegionLoader 2017-10-05 18:47:32 +01:00
18448cbcb8 Fixed several bugs with statistics updating and resetting
- fixed ridiculous network stats when title ticker or console colours are disabled (shoghicp, what fit of madness led you to think this was a good idea)
- fixed network stats reporting kb/16ticks instead of kb/s
- fixed TPS reporting getting reset after 16 ticks instead of 20
- title ticker and MOTD is now updated every 20 ticks instead of 16
2017-10-05 16:48:50 +01:00
b0104099fe Add a couple of comments to pocketmine.yml to clarify settings usage 2017-10-04 14:44:52 +01:00
68195c64ce Remove dead COMPRESSION_LEVEL property from Level 2017-10-04 14:26:04 +01:00
27aa51bac4 Added some type docs to Level 2017-10-04 14:25:06 +01:00
eac1d76e8b Fixed Level->stopTime not being set 2017-10-04 14:08:23 +01:00
a8c6e14d02 Chunk cache is now non-optional, close #1448 2017-10-04 13:50:32 +01:00
bf68a6a9fc Fixed canUseChunkCache() logic (#1446)
Fix setting disable chunk cache on low memory being useless, fix chunk cache not working if low memory cache clear is enabled
2017-10-03 20:27:53 +01:00
4dfd171af0 Add flint-steel light sound, close #1434 2017-10-03 19:39:01 +01:00
fc9c264e77 Resend blocks around targeted blocks when interactions & block-break are cancelled, fixes #906
this solution is dumber but more effective (also solves the beds & doors placement problem)
2017-10-03 19:28:01 +01:00
04ba41c58c Remove redundant properties from recipes.json
- we don't use the UUIDs, and they change every time, this just pollutes the diffs and makes my contribs ridiculous
- we don't need the height/width of shaped recipes because the generated shape tells us what it is
2017-10-03 17:30:26 +01:00
736cc927ff Enable chunk caching by default
the footprint of compressed chunk batches is so small now that it doesn't make sense to disable it out of the box. The performance gains from caching chunks are more than worth it.
As of 1.2, the average footprint of these caches is usually ~2% or less of the size of the actual chunk itself. Moving around a lot will frequently cause the same chunks to get sent several times as it passes in and out of your render distance, and the chunk isn't even changing in that time, so the chunk is getting needlessly re-serialized over and over again. So even if your world is not static (for example a creative server) chunk caching will still offer benefits, and the memory expense is so small it's a no-brainer.
2017-10-03 13:16:30 +01:00
4be7885ee4 Remove redundant assignment in Level constructor 2017-10-03 12:57:30 +01:00
7dc5dc3a9f Restrict item meta values to max signed short value, closes #1101 2017-10-03 12:35:08 +01:00
f7ee78233b Item IDs should always be unsigned, treat them with appropriate measures (fixes #1376) 2017-10-03 12:28:50 +01:00
88807e8b22 Fixed Binary::unsignShort() being non-static 2017-10-03 12:21:09 +01:00
5a6812357b imports 2017-10-03 11:34:41 +01:00
ca401ec3f5 Force-close the crafting window only when doing crafting transactions
otherwise the client will crash when using right-click on the recipe book
2017-10-03 11:33:09 +01:00
9bbebaa071 Force-close the inventory window when crafting fails to avoid desync issues
mojang, why does this have to be hard work
2017-10-03 11:04:21 +01:00
76117e7fa0 Get XUID from LoginPacket after authentication, add Player->getXuid() 2017-10-02 18:51:51 +01:00
088a44ea3a Fixed bug reading pubkey from LoginPacket
this isn't part of extraData
2017-10-02 18:05:50 +01:00
b54f256fea Added a hack to cut down on excess skin geometry bloat
there are further ways this can be debloated, but non-pretty-printing it cuts the size down by ~70-80%.
2017-10-01 16:50:16 +01:00
c09d782503 Fix #145, take 2 (slab placement in half gaps doesn't work) (#1411) 2017-10-01 16:19:59 +01:00
b3b3ee7c56 Use transparent skin on FloatingTextParticle 2017-10-01 14:10:47 +01:00
ab5bbaa7bd Remove redundant property from Player 2017-10-01 12:19:11 +01:00
afa37bd2aa check range of valid compression values
zero is not allowed because it's pointless, just raise your compression threshold if you want zero compression.

Chunks will always be compressed regardless of threshold because they are huge. It doesn't make sense to allow uncompressed chunks when even compression level 1 will reduce their size 50x. The point of the last two (reverted) commits was to prevent compression level zero being used on chunks. Probably obvious that I was up late and not thinking very clearly.

Revert "Reduced chunk compression level to 7"

This reverts commit 49ac2555ce.

Revert "Always use best compression for chunks"

This reverts commit 42dd9d6abd.
2017-10-01 11:06:14 +01:00
49ac2555ce Reduced chunk compression level to 7
According to benchmarks 8 and 9 are simply orders of magnitude slower while not saving enough bytes to make it worth the performance loss. 7 is a good balance.
2017-10-01 09:20:14 +01:00
edd0189d59 Some improvements to issue template 2017-09-30 21:19:38 +01:00
b76b9d53fe Fixed drops for DeadBush 2017-09-30 21:04:39 +01:00
42dd9d6abd Always use best compression for chunks 2017-09-30 20:30:24 +01:00
9cd7f39c03 Fixed typo on ProjectileItem class (#1431) 2017-09-30 16:17:22 +01:00
f6e30d4225 s/online-mode/xbox-auth/
lots of servers are currently running in insecure mode without realizing because of old Genisys shit configs?!
2017-09-30 12:19:24 +01:00
27798c69ee fix collision detection not detecting fence & fence-gate, fixed nether-brick fence gate AABB, close #1299 2017-09-29 15:27:14 +01:00
a33be643c4 Fixed falling blocks not falling when placed above fire, close #1425
yes, hardcoding this is not a nice solution - PC also does this, want to fight?
2017-09-29 14:53:23 +01:00
a06ff3d96b Revert "Fixed falling blocks glitching when spawned"
This reverts commit 827ee5d4f9.

can't ever seem to get falling blocks right... should I blame mojang?
2017-09-29 14:22:03 +01:00
e6cecabf3f New skin API, add support for custom capes & custom geometry (#1416)
* Added support for changing skins ingame, custom capes & geometry
* Use PlayerSkinPacket for setting Human skin instead of PlayerList hack
2017-09-29 14:09:00 +01:00
c273a46537 Ditch crafting transaction if we get normal inventory action with incomplete crafting transaction 2017-09-28 20:07:07 +01:00
c448f4a3b5 Added handling for reflected ShapedRecipe crafting, close #1415 2017-09-28 18:45:22 +01:00
86b76bfcab Fixed trying to get pubkey that doesn't exist in VerifyLoginTask
bug was exposed by previous commit
2017-09-28 18:14:53 +01:00
7ba193dc2e Set ErrorException handler on AsyncWorkers 2017-09-28 18:01:31 +01:00
f565791e41 World loading: Actually use the data in each item instead of getProperty() 2017-09-28 16:38:10 +01:00
bc0434913e Fixed crash when a numeric world seed is set in pocketmine.yml 2017-09-28 16:35:19 +01:00
9bc8d8db79 Revert "Add buffering for non-immediate priority packets to reduce compression overhead"
This reverts commit 2162675b64.

This broke Human skins... it seems MCPE doesn't like you adding and
removing a player from the list in the same batch.
2017-09-28 14:29:17 +01:00
d0bf0ff083 Imports cleanup 2017-09-28 10:51:05 +01:00
7dc1fc54b1 Oops, didn't mean to commit this 2017-09-27 20:34:37 +01:00
bae42dc0d9 Fixed incorrect field names in PlayerSkinPacket 2017-09-27 17:55:04 +01:00
ab809f8a2b Updated RakLib submodule 2017-09-27 15:53:43 +01:00
2162675b64 Add buffering for non-immediate priority packets to reduce compression overhead 2017-09-27 14:06:42 +01:00
8f63117dac Use try...finally in Player->sendDataPacket() so we don't forget to stop timings 2017-09-27 13:52:25 +01:00
1c9b4f3e21 Fixed ItemBlocks retaining Level references after being placed, close #1395 2017-09-27 12:04:56 +01:00
48d2d7e422 Remove unused import from FoodSource 2017-09-27 12:01:55 +01:00
52bd042bde BaseInventory: Don't keep calling getSize() over and over and over again 2017-09-27 11:24:21 +01:00
4b63a22f8c More use of Item->isNull() 2017-09-27 11:05:40 +01:00
c47f1f572c Added API method Item->pop() 2017-09-27 10:56:04 +01:00
7a77bb0402 Login verification: guilty until proven innocent
assume it's invalid until we've verified everything
2017-09-27 10:29:01 +01:00
90cb018de2 Re-organise some Block code 2017-09-26 19:39:05 +01:00
992c4ce6a0 Added API method Block->getVariant() 2017-09-26 19:35:04 +01:00
78af87a572 ConcretePowder: add tool type 2017-09-26 19:00:53 +01:00
c79a5509f6 Implemented concrete powder
this is a little buggy with water updating due to a hack for liquids to fix a CPU leak (210bdc2436), but everything works fine when a block nearby gets updated.
2017-09-26 18:56:43 +01:00
827ee5d4f9 Fixed falling blocks glitching when spawned
this now (finally) works flawlessly
2017-09-26 18:33:34 +01:00
f5b0cbb337 Generated some TODOs for BlockFactory & ItemFactory 2017-09-26 16:15:35 +01:00
18777a9041 Remove useless EntityEventPacket
vanilla doesn't send this, and it doesn't do anything if we _do_ send it.
2017-09-26 12:50:36 +01:00
13d50aff62 don't break bows, stupid 2017-09-26 12:20:40 +01:00
5b191327bc Fixed players' arms staying stuck up after eating something 2017-09-26 12:14:10 +01:00
8811188e71 Split FoodSource up into two interfaces 2017-09-26 11:48:47 +01:00
38fad4b963 Implement difficulty per-world (#878)
* Moved Server::getDifficultyFromString() to Level
* Added ability to set difficulty in worlds section of pocketmine.yml for generation
2017-09-26 11:16:51 +01:00
e64076ec81 Disconnect 1.1 clients properly (HACK!) 2017-09-26 10:01:32 +01:00
ccbdb77618 Cleaned up LoginPacket handling, don't nuke the buffer 2017-09-26 09:49:35 +01:00
91c6086ae1 Updated PocketMine-Language submodule 2017-09-26 09:35:43 +01:00
85ec7d9732 Change default MOTD
"Minecraft: PE Server" is no longer accurate, "Minecraft: Bedrock
Edition Server" is too wordy, and "Minecraft: BE Server" just sounds
weird.

and I'm not calling it simply a "Minecraft Server"
2017-09-25 23:43:09 +01:00
10f597cd64 Stop hardcoding "PocketMine-MP" everywhere 2017-09-25 18:17:35 +01:00
6e5759b1d1 Made incompatible client disconnect messages more informative 2017-09-25 14:30:11 +01:00
03d3e595d6 Implement JWT signature verification and Xbox Live checks, close #315
This can be enabled or disabled using the "online-mode" directive in
server.properties.

NOTE: For safety reasons it is enabled by default, since many naive server owners currently believe that authentication is not needed because "the client is forced to sign-in".
Newsflash for readers: the forced authentication is easily bypassed using a LAN proxy.

Un-authenticated LAN connections will still work fine if the online mode is disabled.

Added the following API methods:
- Server->getOnlineMode() : bool
- Server->requiresAuthentication() : bool
- Player->isAuthenticated() : bool

JWT verification is rather expensive, so it is done in an AsyncTask. Make sure you don't hog your worker threads.
2017-09-25 12:30:58 +01:00
8ca59d12e9 Updated PocketMine-Language submodule 2017-09-25 11:36:39 +01:00
89e4defa29 use null coalesce in Server->getLevel() 2017-09-25 09:51:21 +01:00
f5534a9ab0 Server: add some typehints 2017-09-25 09:49:19 +01:00
28bce8d48c Fixed plugins causing crashes by using Level->unload() and add a warning
yes, we don't want you to use this, but it still shouldn't crash if it can be prevented...
2017-09-25 09:46:19 +01:00
3c02a6a8ed Fixed eating sounds 2017-09-24 21:18:08 +01:00
6b0ac8adb8 Don't overwrite the input map with reindexed stuff
we might need this again?
2017-09-24 19:17:00 +01:00
38ec5da260 Refactored API compatibility checking code into its own method (#1394)
Refactored API compatibility checking code into its own method so plugins can use it
this change was inspired by https://github.com/poggit/devirion/blob/master/src/poggit/virion/devirion/DEVirion.php#L140-L172
2017-09-24 15:00:08 +01:00
240cc3043a Rewritten crafting, fixed #45 2017-09-24 14:14:24 +01:00
043ae487de Fixed some inconsistent uses of new ShortTag vs setValue() in Furnace 2017-09-24 10:34:25 +01:00
f12701e582 Fixed possible undefined NBT in Furnace, close #1398 2017-09-24 10:29:36 +01:00
6e961ae897 Addition of Coarse Dirt (#1396) 2017-09-23 22:25:03 +01:00
e1d10f595a AdventureSettingsPacket: removed leftover TODO comment 2017-09-23 16:51:58 +01:00
178dd1b981 Fixed block picking, added PlayerBlockPickEvent 2017-09-23 14:42:28 +01:00
826ec90856 Revert "Workaround for some plugins crashing clients during PlayerLoginEvent"
This reverts commit 087a994393.
2017-09-23 13:23:19 +01:00
0523f26613 Send forced movement when getting bad movements after teleport, fixes AlwaysSpawn-type plugins
it's mostly harmless to send it here anyway
2017-09-23 12:49:46 +01:00
5190d9c1e2 Fixed possible issue with JWT decoding
this is url-encoded, these characters should be replaced before base64_decode()ing. Not sure how this didn't get noticed before now.
2017-09-22 19:52:08 +01:00
c8fd0eaf8b Removed autogenerated stub TODO from BoneBlock 2017-09-21 19:50:03 +01:00
53ef9b653a Added some getters to FloatingTextParticle 2017-09-21 19:10:30 +01:00
030cc4afb0 FloatingTextParticle: import cleanup & typehints 2017-09-21 19:09:33 +01:00
9bd7f771d3 "Fixed" FloatingTextParticle yet again
- nametag visibility flags don't work properly, only players show them all the time
- invisibility overrides nametag visibility
- scale 0 triggers asserts on debug builds

..... how hard is it to NOT break these simple things each update Mojang?

closes #1205
2017-09-21 19:04:45 +01:00
10f6a0eef0 FloatingTextParticle: fixed incorrect parameter type doc 2017-09-21 18:31:12 +01:00
d0a96f35da ./ hack is back (/help is client-side >_<) 2017-09-21 17:51:39 +01:00
65e908a403 Move Travis Test server files into a separate directory
this is for convenience locally running Travis Test so my existing data doesn't interfere
2017-09-21 17:16:27 +01:00
d7091f4460 Fixed not being able to disable stats reporting using command line options 2017-09-21 17:14:44 +01:00
c6670b2e74 Fixed Nether Wart's name 2017-09-21 16:56:41 +01:00
194278d986 Updated TesterPlugin submodule 2017-09-21 16:56:27 +01:00
0e2e9aab2e Fixed crash when block classes override the constructor but don't specify a fallback name 2017-09-21 16:43:33 +01:00
1b5fed983b Revert "Fixed slab placement, close #145", reopen #145, close #1314
This reverts commit f2ff0198cc.
2017-09-21 14:41:18 +01:00
5aba87b250 Added brown and red mushroom blocks 2017-09-21 14:07:51 +01:00
f01ce8e994 null and void typehints 2017-09-21 12:54:04 +01:00
d89b8cf12e Clean up SlotChangeAction inventory handling 2017-09-21 12:44:03 +01:00
6aa9b081e9 Cleanup unused imports 2017-09-21 12:26:41 +01:00
dbed80386a Removed redundant interface 2017-09-21 12:22:47 +01:00
cefad0444c Merge branch 'master' into mcpe-1.2 2017-09-21 10:32:35 +01:00
ee052f91d4 Fixed some air items with count 1 instead of 0 2017-09-21 10:30:14 +01:00
ef6250967f Use Item->isNull() more 2017-09-21 10:29:29 +01:00
61cfdac6a1 Fixed a mistake in entity attack handler 2017-09-21 10:18:52 +01:00
fd7fb10223 Return null on unmatched inventory action and log details 2017-09-20 18:38:14 +01:00
6897cb4774 Moved inventory action magic slot constants where they belong 2017-09-20 18:27:29 +01:00
8e7ad532f1 Updated RakLib submodule 2017-09-20 18:16:41 +01:00
9e8366725a Bump for 1.2.0.81 2017-09-20 17:30:27 +01:00
b14ecc18c4 Remove unused imports 2017-09-20 12:24:44 +01:00
55720d9f0a Added InventoryAction->onPreExecute(), fixed PlayerDropItemEvent deleting items 2017-09-20 12:19:42 +01:00
0262465a26 Fixed dupe cake glitch
this is what happens when you try to be clever when not properly awake
2017-09-20 11:19:15 +01:00
7996a7b08c Testing handling multiple result items for ShapedRecipes
this doesn't work yet, I wanted to see how glitchy it is with cakes. The answer is: very glitchy.
2017-09-20 11:14:09 +01:00
4a1fc1bdf7 don't try to send contents during inventory construction 2017-09-20 10:18:24 +01:00
85b2b2ae2e Don't send tile inventory slots during the constructor
This is completely pointless and a waste of time.
2017-09-20 10:15:28 +01:00
38e11aae5e Some cleanup to how EntityInventoryChangeEvents are handled 2017-09-20 10:13:05 +01:00
f0755d1659 Fixed handling of recipes that require a crafting table 2017-09-20 09:43:49 +01:00
fd33a65e3b Small cleanup of recipe UUID handling (furnace recipes don't need UUIDs) 2017-09-20 09:34:00 +01:00
7baadf9dad Throw updated pthreads at Travis 2017-09-19 20:49:41 +01:00
ca23864e4c CraftingManager: use null coalesce for matching furnace recipes 2017-09-19 20:03:21 +01:00
8728547a11 Remove unused imports 2017-09-19 19:58:53 +01:00
90fb3c5e12 Moved getNetworkType() to ContainerInventory since it's not used anywhere else 2017-09-19 19:57:22 +01:00
1fb6d12a6b Add getInventory() to Container interface where it's actually useful 2017-09-19 19:26:41 +01:00
1323d89139 Remove redundant duplicated code for sendContents() and sendSlot() 2017-09-19 19:07:12 +01:00
136ab1dba1 Inventory->getItem(): Removed useless clones
this already returns a copy of the item anyway... wtf?
2017-09-19 18:49:08 +01:00
8cae20e818 Removed hotbar slot linking (works like PC now) 2017-09-19 18:36:57 +01:00
ff2b3bfa2a SimpleCommandMap: remove some dupe and arrange commands alphabetically 2017-09-18 18:43:06 +01:00
361b262d3a Merge branch 'master' into mcpe-1.2 2017-09-18 10:29:38 +01:00
1fd7f441b4 Travis: use older version of pthreads
master is broken - https://github.com/krakjoe/pthreads/issues/757
2017-09-18 10:20:15 +01:00
3f56d6ddc8 RakLibInterface: removed useless needACK condition 2017-09-18 09:42:25 +01:00
1e4cbb0dd9 RakLibInterface: move array initialization to default value
doesn't make sense to do this in the ctor when all the others are normal
2017-09-18 09:34:00 +01:00
a99eee9def Removed redundant assignment 2017-09-17 20:01:11 +01:00
bdee746e46 Automatically enable ANSI colours on Windows versions that support it
Note that stream_isatty() and sapi_windows_vt100_support() are ONLY defined on PHP 7.2, and the latter is only available on Windows.
2017-09-17 19:57:20 +01:00
642c7733cd Cleaned up ShapedRecipe handling, ShapedRecipe API changes
use shapes from json instead of just generating maps
fix a ton of bugs
2017-09-17 11:45:16 +01:00
c8199e14ad Removed redundant duplicate method call 2017-09-16 23:09:14 +01:00
0f37bc35ba Always evacuate the crafting grid on close, no matter whether it's big or not
otherwise items will get deleted and people will cry
2017-09-16 21:58:10 +01:00
8dc3d019f6 Return handled on fake window close 2017-09-16 21:55:25 +01:00
bd64172750 Added API method Item->equalsExact() and removed some boilerplate code 2017-09-15 16:48:46 +01:00
0e51820dfb Merge remote-tracking branch 'origin/master' into mcpe-1.2 2017-09-15 15:54:30 +01:00
30d2318bb7 Merge pull request #1383 from pmmp/quoted-command-args
Quoted command args & allow playernames with spaces
2017-09-15 14:04:48 +01:00
63634d7e7d Added compaction and sorting for repeated slot changes in a single transaction
Now items should be able to move around the crafting grid correctly.
2017-09-15 13:32:17 +01:00
d941bf8e74 Add vanilla-style crafting grid item evacuation server-side when closing the window in case something goes wrong 2017-09-15 13:22:53 +01:00
8c9d9626ab Merge branch 'new-pack-codes' 2017-09-14 19:53:07 +01:00
6b34c47c96 Merge branch 'master' into mcpe-1.2 2017-09-14 18:16:45 +01:00
77241e14ce Bumped to ALPHA8 to account for AsyncTask API changes 2017-09-14 17:49:12 +01:00
15b08c1417 Added capability to dump AsyncWorkers' memory (#1379)
This now actually works with PHP 7.2 + latest pthreads, before it was too unstable.
2017-09-14 16:45:48 +01:00
4d1daecd91 oops! 2017-09-14 11:01:47 +01:00
53e5db5142 Updated PreProcessor submodule 2017-09-14 10:58:46 +01:00
ad72fe6232 Make use of awesome new pack() codes for floats 2017-09-14 10:41:53 +01:00
8b33f711d0 Allow spaces in player names 2017-09-14 10:15:35 +01:00
319735db3a Add support for quoting command arguments
Un-escape quotes in inputted strings
2017-09-14 10:15:30 +01:00
c283d87494 Some minor cleanup of PocketMine.php 2017-09-13 19:14:31 +01:00
be27e03126 Some minor AutoUpdater cleanup, stop hardcoding everything 2017-09-13 18:51:06 +01:00
c1c290cd39 Beware matching items that aren't actually correct
This would only ever happen if we received the actions in the wrong order, but that wouldn't surprise me.
2017-09-13 11:37:10 +01:00
5267c571e9 add handling for -100 fake source type (evacuate crafting table contents) 2017-09-13 11:15:31 +01:00
0fac3b9a9d Added encode for InventoryTransactionPacket and refactor some stuff 2017-09-13 11:14:04 +01:00
23a38400e2 Added CraftingGrid and BigCraftingGrid, WIP stuff for crafting
moving whole stacks in & out of the crafting grid works now, splitting stacks is fucked up because the transaction system can't handle the same slot changing multiple times in one transaction
2017-09-12 19:34:06 +01:00
297172d111 Send creative inventory for all gamemodes, fixed recipe book 2017-09-12 14:40:16 +01:00
825d4f9702 Location cleanup (#1380)
There's no sense rewriting code that the parent constructor already implements.
2017-09-12 12:18:35 +01:00
1d31958ce6 Updated preprocessor submodule 2017-09-12 09:12:38 +01:00
130a60f2b2 Fixed ItemFactory::isRegistered() returns false for blocks 2017-09-11 18:23:26 +01:00
07268e4b37 Added API methods to determine if a block or item is already registered 2017-09-11 16:22:55 +01:00
441efc4ae2 Merge branch 'master' into mcpe-1.2 2017-09-11 14:40:25 +01:00
88bd7713c5 Fix preprocessor 2017-09-11 09:42:31 +01:00
aaa3b6e59a Added explicit AsyncTask->storeLocal(), removed AsyncTask->__construct() object storage (#1322)
Far too often I see people using IDEs which generate the constructors for them and then accidentally unintentionally store things in the object store. This parent constructor behaviour is unexpected. If a developer wants to store something, they should now do so explicitly by calling storeLocal().
2017-09-10 20:31:28 +01:00
25adac8859 Added support for Composer (#323) 2017-09-10 19:23:34 +01:00
8d0b881762 fixed command arg types 2017-09-10 13:56:34 +01:00
16cb75ef38 Merge branch 'master' into mcpe-1.2 2017-09-09 21:58:30 +01:00
3b9689674d Merge remote-tracking branch 'origin/php/7.0' 2017-09-09 21:57:44 +01:00
7f5d8cc900 Always log stack traces regardless of whether log-debug is enabled 2017-09-09 19:27:26 +01:00
8761256246 Be more clear about WHY not to use source installs in production 2017-09-09 19:21:32 +01:00
8c363cb571 Added capability to specify arguments to PocketMine.php when running start.ps1
Example: .\start.ps1 --disable-ansi --debug.level=2
2017-09-09 18:44:18 +01:00
10b765e17a Merge branch 'php/7.0' into mcpe-1.2 2017-09-09 18:08:47 +01:00
0eb866bf25 Updated AvailableCommandsPacket 2017-09-09 14:23:19 +01:00
c46caa38e1 merge 2017-09-09 11:33:00 +01:00
17d949f476 Fixed SPL being reported as incompatible when it's actually not found 2017-09-09 11:25:59 +01:00
c569f55933 Fixed can't find sources when PocketMine.php is run from anywhere other than the repository root 2017-09-09 11:22:56 +01:00
01d8d216ca Yet another merge commit 2017-09-09 00:53:03 +01:00
f1ccee505b Submodule update (this is getting annoying) 2017-09-09 00:51:20 +01:00
a61adb5991 Merge branch 'php/7.0' 2017-09-08 21:40:25 +01:00
cae1a3bb4b Updated DevTools submodule 2017-09-08 21:38:14 +01:00
6681bd250a Merge branch 'php/7.0' 2017-09-08 20:37:09 +01:00
38293913ee Updated DevTools submodule 2017-09-08 20:36:32 +01:00
8493ce8a35 Merge branch 'php/7.0' 2017-09-07 20:07:16 +01:00
9b7868238c Improved Travis Test, capture error output from console, test phar 2017-09-07 20:03:58 +01:00
953c1ef4ec Fixed formatting issues in Travis test script 2017-09-07 20:03:54 +01:00
021a9a4820 Merge branch 'php/7.0' 2017-09-07 19:33:01 +01:00
5b7565664c Removed WeakRef from Travis CI 2017-09-07 19:32:04 +01:00
ebdfbe6bb9 Removed flight controls hack for spectator mode
THEY FINALLY FIXED IT
2017-09-07 19:06:36 +01:00
85ff236461 Fixed formatting issues in Travis test script 2017-09-07 17:27:07 +01:00
d7422d9283 Updated for 1.2.0.31 beta 2017-09-07 10:50:53 +01:00
fcb3c4820e Merge branch 'php/7.0' into mcpe-1.2 2017-09-07 10:42:20 +01:00
c72ef605b9 Fixed server crash when a garbage timezone value is set in php.ini, fallback to auto-detection 2017-09-07 10:40:32 +01:00
e274f1b7f8 Merge branch 'php/7.0' 2017-09-06 17:54:50 +01:00
69514c5763 Submodule update: Fixes little-endian longs being written in the wrong order, closes #1358 2017-09-06 17:54:38 +01:00
2c6205e3f3 Added new events for network interface handling, close #1232 (#1250)
Added 
- NetworkInterfaceRegisterEvent (cancellable)
- NetworkInterfaceUnregisterEvent
- NetworkInterfaceCrashEvent
2017-09-06 11:22:10 +01:00
12c154badf Merge branch 'php/7.0' 2017-09-05 20:06:02 +01:00
2215543e39 Fixed not being able to remove logger attachments, closes #1141 2017-09-05 20:04:19 +01:00
b310959fd1 Added --php parameter to start.ps1 2017-09-05 19:57:38 +01:00
c9ee206fe6 Merge branch 'php/7.0' 2017-09-04 19:42:03 +01:00
d065e76a41 Fixed plugins with unknown dependencies saying they have circular dependencies, close #356 (#1342) 2017-09-04 19:41:21 +01:00
6877ac35eb Merge branch 'php/7.0' 2017-09-04 10:01:47 +01:00
f0c1ea7dd7 Fixed string seeds in pocketmine.yml crash the server, close #1355 2017-09-04 10:01:21 +01:00
6aaef1660a Added dependency checks for BC Math 2017-09-04 08:08:04 +01:00
78d49f8e66 Merge branch 'php/7.0' into mcpe-1.2 2017-09-03 15:02:41 +01:00
de6ebc5791 Merge branch 'php/7.0' 2017-09-03 15:00:29 +01:00
815c697767 Fixed sticks being useless as furnace fuel 2017-09-03 14:59:04 +01:00
231617b9d0 fuel time should be ticks here, not seconds 2017-09-03 14:27:17 +01:00
90cb3c010f Added some new items (the basic ones) 2017-09-03 14:24:21 +01:00
2398e2450a Allow building inside spectators
This check is pretty ugly, it'll need cleaning up later. For now, this will suffice.
2017-09-03 13:47:44 +01:00
bb9299070d Fixed several Cake bugs
fixed cake flat-out doesn't work
fixed last slice of cake vanishing (NOOOOO)
fixed EntityEatBlockEvent not getting called
made AABB calculation less confusing
2017-09-03 13:09:53 +01:00
58bf5d6679 Use null coalesce in EntityDamageEvent 2017-09-03 12:48:57 +01:00
cb7911ee9c Improved Absorption, now only applies to living entities, now controllable by plugins 2017-09-03 12:37:34 +01:00
aa9fd1b4f9 Remove redundant gamemode checks
The caller will check the player's gamemode, so there is no use for these checks.
2017-09-03 12:22:37 +01:00
7483f22e8b Fixed a PhpStorm inspection 2017-09-03 12:10:56 +01:00
89f5567476 Use Entity->getDirectionVector() more 2017-09-03 12:08:40 +01:00
4df261b75a Made some variable names in Bucket less confusing 2017-09-03 12:00:24 +01:00
41780fd195 Made entity collision checks for block placement more logical and less wasteful
We don't care how many entities collide, only that a non-zero number collided.
2017-09-03 11:50:15 +01:00
0b83c61494 Fixed cyclic reference with chest tiles and DoubleChestInventory 2017-09-03 11:24:34 +01:00
1d338bfdf9 Fixed uncaught exceptions during Task->onCancel() causing all kinds of nasty behaviour
including crashing the server on shutdown, preventing self-cancellation, and causing memory leaks
2017-09-02 19:28:51 +01:00
2cff5a500c Merge branch 'php/7.0' 2017-09-02 19:05:27 +01:00
f077ba4748 Merge branch 'php/7.0' into mcpe-1.2 2017-09-02 19:05:18 +01:00
2f614c5dc2 don't break the preprocessor 2017-09-02 19:04:10 +01:00
dcf34b7188 Merge branch 'php/7.0' 2017-09-02 18:57:49 +01:00
ca84532640 Merge branch 'php/7.0' into mcpe-1.2 2017-09-02 18:57:39 +01:00
4d8d57ca5e Fixed LongTags in tile NBT 2017-09-02 18:57:23 +01:00
75e32b11b7 Merge branch 'php/7.0' into mcpe-1.2 2017-09-02 18:29:53 +01:00
9f44b2ed75 fixing ClientboundMapItemDataPacket 2017-09-02 18:22:53 +01:00
62aba15f9e Updated RakLib submodule 2017-09-02 16:52:55 +01:00
1c02c747ca Merge branch 'php/7.0' 2017-09-02 13:13:54 +01:00
22d8626e23 Fixed sign bug introduced in #1204 rebase, close #1346 2017-09-02 13:12:55 +01:00
b071ce9c5a Refactored projectile handling, added Item->onClickAir() 2017-09-02 11:57:26 +01:00
a6c0f1512c Send the hotbar instead of contents when resetting hotbar
This used to be fine before 1.2, but now hotbar is handled separately.
2017-09-02 11:07:14 +01:00
604d8ecf9a Protocol changes for 1.2.0.25 2017-09-02 11:05:49 +01:00
5d75d3d5b6 Merge branch 'php/7.0' into mcpe-1.2 2017-09-01 23:10:58 +01:00
8b13b520e0 Merge branch 'php/7.0' 2017-09-01 20:22:25 +01:00
2603f5cc63 Fixed RakLib crashing when exceptions are thrown in packet handlers after the player was closed
This occurred if the player happened to be closed during the packet being handled, and then an uncaught exception bubbled up to the RakLibInterface. This resulted in a crash due to trying to get the address of a player who no longer had a network session, in order to block their IP address.
2017-09-01 20:22:02 +01:00
00e4fff259 Fixed Item fromString() crash on PHP 7.2 2017-09-01 20:05:04 +01:00
a06c934f4d Merge branch 'php/7.0' 2017-09-01 19:37:27 +01:00
14ea76ecd7 Fixed PlayerBucketEmptyEvent never called, close #1339 2017-09-01 19:36:57 +01:00
c81b76cbf6 Make plugin load errors more descriptive 2017-09-01 18:52:55 +01:00
517609dc2e Cleaned up plugin property reading 2017-09-01 18:36:31 +01:00
506118e28f Fixed exception thrown when plugins specify API version like 3.0 instead of 3.0.0
This could only be seen in a build with a non-suffixed API version, for example 3.0.0. When attempting to load plugins which specify API like 3.0 the server would raise errors.
2017-09-01 18:13:07 +01:00
6e8631347d Added capability to specify compatible protocol versions in plugin.yml (#1247)
Protocol-dependent plugins may specify the `mcpe-protocol` attribute in plugin.yml to disallow plugin loading when the protocol changes.
2017-09-01 17:57:40 +01:00
5335ed9394 Merge branch 'php/7.0' 2017-09-01 16:57:51 +01:00
138d85307b Fixed double chests being openable when the other half has a solid block above it, close #1165 2017-09-01 16:50:55 +01:00
226175f961 setText now nullable instead of overwriting with empty lines (#1204) 2017-09-01 08:34:40 +01:00
297cfcf168 Check for existence of ChunkUtils extension 2017-08-31 21:42:24 +01:00
9ea39ea3d7 Stop clearing chunk cache after 768 batched packets are cached. (#1320) 2017-08-31 21:14:18 +01:00
16aeb0ac85 Update .travis.yml 2017-08-31 21:12:45 +01:00
8caabd3267 Check for existence of ChunkUtils extension 2017-08-31 21:04:36 +01:00
ddfe828445 Require PHP 7.2, bump PocketMine-MP version to 1.7dev 2017-08-31 20:27:05 +01:00
67ad2d25b9 Added FireImmune data flag 2017-08-30 18:36:36 +01:00
b9c4a65307 Don't save players with chunks!
I can't believe I didn't notice this
2017-08-30 16:55:17 +01:00
23752548fe Address several LevelDB related crashdumps in the crash archive 2017-08-30 15:42:31 +01:00
190f4dd6ab New entity metadata flags 2017-08-30 14:13:24 +01:00
120cf56a47 Misc return typehints 2017-08-30 12:59:26 +01:00
21f09d5fdb Cleaned up Effect handling and replacement 2017-08-30 12:53:41 +01:00
bde6d7db8d Remove redundant duplicate implements 2017-08-30 12:21:09 +01:00
adc6b03d4c Typehinted up Entity API and some cleanup 2017-08-30 12:17:56 +01:00
fd52022065 Refactor of health int -> float and fixed armor being useless when
computed damage reduction is less than 1
2017-08-30 11:03:07 +01:00
ea5bd0348a Fixed liquid flow attempting to set negative block damage values
This should only execute if the current liquid block is actually still existent. When decay is negative, it means the water block doesn't exist anymore.
2017-08-29 14:22:12 +01:00
c3cf82ab26 Updated RakLib submodule 2017-08-29 11:05:25 +01:00
6abef6b22d Made block and item factory lists private to stop people doing stupid things with them 2017-08-29 10:53:01 +01:00
9902d29734 ServerScheduler::scheduleAsyncTask() returns the worker used (#1312) 2017-08-29 10:29:24 +01:00
7475aa3a18 Do not allow use of PHP 7.1 due to not compatible 2017-08-28 23:42:22 +01:00
6d6283b7f3 Fixed Player->sendPosition() not working correctly 2017-08-28 20:07:04 +01:00
a3d21de559 Cleaned up network inventory action reading and core action creation 2017-08-28 20:04:35 +01:00
6a717d8050 Fixed PlaySoundPacket
thanks @undrfined
2017-08-28 18:32:56 +01:00
ece0692229 Fixed UUID corruption in recipe data
this is important for MultiRecipes to work correctly (yes I know we don't use these yet!)
2017-08-28 18:04:11 +01:00
b5d2402c9b Merge branch 'master' into mcpe-1.2 2017-08-28 18:02:09 +01:00
37b050f864 Return an UnknownBlock if the BlockFactory hasn't been initialized yet 2017-08-28 17:07:39 +01:00
d07b5ba1e1 Added missing return to Bow, fixed #1329 2017-08-27 20:40:30 +01:00
697ea55fb7 Another typehint 2017-08-27 20:01:38 +01:00
8b3fad8a7b Removed redundant condition 2017-08-27 19:44:40 +01:00
f2402f2122 Strict-compare these to strings since they cannot return anything but 2017-08-27 19:32:57 +01:00
b548c4fdbe Use null coalesce in BanList->addBan() 2017-08-27 19:29:04 +01:00
a982344b96 Cleaned up Level->addSound() and Level->addParticle() 2017-08-27 19:09:05 +01:00
0b2b9126a2 Improved tile spawning
There's no need to recreate the spawn packet for every single player, or re-serialize the NBT.
2017-08-27 18:40:18 +01:00
f4f2323518 Fixed entityBaseTick not being timed for Players 2017-08-27 18:29:54 +01:00
badd669b3d Removed use of literal ints for block ID checks in Dandelion 2017-08-27 16:16:37 +01:00
c7fd3eb725 Merge branch 'master' into mcpe-1.2 2017-08-27 16:09:23 +01:00
a5f5502380 Moved bow functionality out of Player 2017-08-26 19:04:04 +01:00
6d5620606e Block->place() parameter refactor to make things clearer 2017-08-26 14:41:49 +01:00
20f34fba53 Missed another dupe 2017-08-26 14:34:21 +01:00
61968cca28 Cleaned up duplicated spawn protection code and refactor some variable names 2017-08-26 14:25:34 +01:00
13187e1749 Removed damage-table mess and added API methods Item->getAttackPoints() and Item->getDefensePoints() 2017-08-26 12:59:03 +01:00
7c212d3d53 Fix formatting issue in AsyncPool 2017-08-25 19:15:57 +01:00
9e142655ea Removed redundant count parameter from item constructors, added some documentation and tightened safety checks
the count parameter is useless since Item ctor should now only be used for constructing item _types_, not actual items. All item creations for inventories etc, should go through the ItemFactory.
2017-08-25 19:06:23 +01:00
1fec16f167 Fix Block::get() regression introduced in 02f42eba 2017-08-25 18:15:53 +01:00
4ab286a142 Generated some Item TODOs 2017-08-25 14:35:50 +01:00
44dd7c2222 Removed some redundant item classes 2017-08-25 14:07:50 +01:00
97911aa9cf Fix undetected collision of nether brick block and nether brick item 2017-08-25 13:36:36 +01:00
7ff143c793 Some minor tool cleanup 2017-08-25 13:19:21 +01:00
cd7724d94a Added concrete 2017-08-25 13:13:11 +01:00
76e213ae73 Cleaned up shared rotation code, fixed quartz pillar rotation, added bone blocks 2017-08-25 13:06:16 +01:00
8ce833bf74 Stripped redundant trailing commas 2017-08-25 12:41:49 +01:00
ba27fff853 Fix formatting derp 2017-08-25 11:53:41 +01:00
80f2519d7d Fixed obsidian hardness, no more destroying obsidian with TNT 2017-08-25 11:52:46 +01:00
ebda6ec19b Cleaned up random-block-ticking registration 2017-08-25 11:47:38 +01:00
6553c82320 Fix random block ticking losing randomness on third iteration
More expensive to do it this way, but this should be foolproof. The old method ran short by 4 or 5 bits, causing the Y coordinate of the third loop to be always < 8 and the Z coordinate to always be 0.
2017-08-24 22:14:07 +01:00
1b0ed0f1b8 Use metadata for git hashes 2017-08-24 20:01:19 +01:00
5433a3f964 Merge branch 'master' into mcpe-1.2 2017-08-24 19:26:52 +01:00
3ee8f2b182 Require RakLib version 0.8.1 2017-08-24 19:26:30 +01:00
238b3ca4c1 Fixed UUID variant corruption in UUID->toString(), close #1286
This class may encapsulate any type of UUID, not just RFC 4122. Additionally, an RFC 4122 UUID may have this set as 8, 9, A or B.
2017-08-24 12:51:46 +01:00
2c3d7c49f9 Updated creative inventory data with new item json serialization (more compact) 2017-08-24 12:17:17 +01:00
76acb1da7b New crafting recipe data format, more readable & more compact 2017-08-24 12:05:35 +01:00
17518195d1 Be more smart about json-serializing items
Don't include nbt_hex if we don't have a NBT tag
Don't include damage unless it's non-zero
Don't include count unless it's non-1
2017-08-24 12:02:03 +01:00
2443a57234 Merge branch 'master' into mcpe-1.2 2017-08-24 11:57:41 +01:00
90edb8ebe7 Make decoding accessible 2017-08-24 10:45:30 +01:00
55e32424a0 Ability to get a player's quit reason from PlayerQuitEvent (#1308) 2017-08-23 19:26:24 +01:00
d6266d19b6 Added correct friction factor for ice & packed-ice 2017-08-23 18:38:09 +01:00
95752ef542 Merge branch 'master' into mcpe-1.2 2017-08-23 13:20:35 +01:00
84c8ac03fb Fixed #1179
This solution isn't ideal, but it works...
2017-08-23 13:19:34 +01:00
da4c9cf404 Fixed inventory cyclic references causing players to not get garbage-collected 2017-08-23 13:13:15 +01:00
0f2ca99c67 Merge remote-tracking branch 'origin/pr/1310' 2017-08-23 10:44:33 +01:00
a7674c52e6 Micro optimization to movement update checking
No need to keep abs()ing this, because next time we have a movement update, motion < 0.00001 will be flattened to zero anyway.
2017-08-23 10:42:23 +01:00
a52fa93998 Remove Entity->length 2017-08-23 02:21:33 -04:00
770616d4ab Merge branch 'master' into mcpe-1.2 2017-08-22 20:48:32 +01:00
d1852834de Revert "Added capability to dump AsyncWorker memory"
This reverts commit eb4594348b.

This is far too unstable with more than one worker thread.
2017-08-22 20:46:20 +01:00
eb4594348b Added capability to dump AsyncWorker memory 2017-08-22 19:57:00 +01:00
5a3ce42f74 Updated RakLib submodule (again) 2017-08-22 19:55:47 +01:00
0712979908 Fixed blastResistance array not being initialized 2017-08-22 19:45:53 +01:00
ae715cf2f2 Updated RakLib submodule 2017-08-22 17:54:45 +01:00
3a5fc78c53 Fixed players getting kicked for flying when standing still when blocks near them get updated, fixed item movement being too slippery 2017-08-22 17:47:48 +01:00
445a67954d Merge changes from master 2017-08-22 14:13:31 +01:00
50580f4408 Added server ID proper to ping response, fixes #1208, closes #1306 2017-08-22 12:39:33 +01:00
4250e99e3a Updated for 1.2.0.22 2017-08-22 11:35:56 +01:00
8229410e27 typo/OCD 2017-08-22 10:48:13 +01:00
938af60733 Update ISSUE_TEMPLATE.md 2017-08-22 10:46:20 +01:00
8a35b9da29 Added some documentation 2017-08-22 10:28:43 +01:00
c32b75fa18 Further (major!) performance enhancements to entity ticking 2017-08-21 20:28:56 +01:00
b8ade18888 Fixed double plants and beds sometimes dropping in creative 2017-08-21 19:25:04 +01:00
592ce3c9e9 Adding some missed commands typehints and documentation 2017-08-21 19:02:30 +01:00
876659cc73 Item factory refactor and added capability to register custom items 2017-08-21 17:49:26 +01:00
604d11a8fd import cleanup and fixed an inspection 2017-08-21 17:39:02 +01:00
d2ace6bdd2 added some typedocs
shut up PhpStorm
2017-08-21 17:17:47 +01:00
672b7610a9 Maybe I should stop using PhpStorm EAPs 2017-08-21 13:51:58 +01:00
456ddd3fb3 Removed obsolete parameters from Entity->attack() and Entity->heal() 2017-08-21 13:25:11 +01:00
b62597fe63 Fixed some minor issues in Player events API 2017-08-21 13:05:32 +01:00
9e54980ded Fixed some usages of Block::get() 2017-08-21 12:58:35 +01:00
121777375e Rewired eating 2017-08-21 12:52:20 +01:00
93e149e91c Rewiring release-item action to fix bows 2017-08-20 22:14:31 +01:00
1f70a7830e Branch merge 2017-08-20 21:07:19 +01:00
2f3c77c68a Fixed entity move performance issue and a ton of entity movement bugs
- fixed zombies and villagers movement not updating
- fixed dropped items "movement" lagging the living **** out of the server when not actually moving
- fixed arrows not falling when the supporting block is removed
- fixed knockback
- fixed zombies + villagers being un-attackable after hitting them

... the list goes on
2017-08-20 20:31:09 +01:00
02f42eba48 Move block registration to its own class 2017-08-20 18:05:01 +01:00
9451dd361e Fixed some issues in MovingObjectPosition 2017-08-20 17:12:25 +01:00
da83b879c0 Major performance improvement to explosions
These changes produce about 3x performance improvements. Some numbers
from my machine (i7-7700k @ 4.5GHz) with TNT:
- before changes: 35ms
- after changes: 11ms

in powersave mode (0.9GHz):
- before changes: 170ms
- after changes: 60ms
2017-08-20 16:12:30 +01:00
d1fd6aef44 add type doc 2017-08-20 14:04:02 +01:00
cd02f1e4be Minor performance improvement to explosions
This improves calculation time by 20-25% per explosion on flat terrain.
2017-08-20 13:28:31 +01:00
eeedcf7332 Refactor Block->getResistance() -> Block->getBlastResistance() and added some documentation 2017-08-20 13:25:43 +01:00
216fc6fe31 Fixed incorrect comment 2017-08-20 12:17:44 +01:00
17053389b0 Added memory limits for AsyncWorkers 2017-08-20 12:15:48 +01:00
8475c63426 Remove redundant brackets from WoodenSlab 2017-08-20 11:02:34 +01:00
f2ff0198cc Fixed slab placement, close #145 2017-08-20 10:52:07 +01:00
c394aea803 Replaced more literal ints with Vector3 constants 2017-08-20 10:43:48 +01:00
e1d894057c Changed face position floating-point params to Vector3s 2017-08-20 10:23:34 +01:00
5b3bed8b06 Don't check entity movement or in-air ticks if player dies due to movement, close #1226
Not an ideal solution but it'll do.
2017-08-20 09:49:02 +01:00
159b2e3d5e Merge branch 'master' into mcpe-1.2 2017-08-19 21:42:33 +01:00
bed68a012d Don't bother doing null checks for block copy
This will never be null if the block factory was initialized correctly. This will also cause a crash if bugs like e88053faf4 occur again in the future instead of silently causing unexpected behaviour.
2017-08-19 21:29:24 +01:00
e0307411da Cleaned up PlayerList handling 2017-08-19 19:36:15 +01:00
e88053faf4 ... 2017-08-19 18:25:08 +01:00
e51106e64c Fixed bad overrides of getBoundingBox() 2017-08-19 17:16:22 +01:00
0e24596aed Changed block construction calls to Block::get() 2017-08-19 13:46:17 +01:00
276fccf4bb Typehinted block events API 2017-08-19 11:25:32 +01:00
64f2e7587d Some cleanup and added missing strict types declare for EndRod 2017-08-19 11:11:49 +01:00
bedfca8698 Fix some type errors on custom ExplodePacket use (#1297) 2017-08-19 08:16:10 +01:00
4a3f01703e Removed redundant override method 2017-08-18 19:52:23 +01:00
41c6cb6f97 Added Block->getVariantBitmask(0 to cut down on getDrops() boilerplate, fixed several blocks incorrectly retaining meta when broken 2017-08-18 19:49:28 +01:00
384a4b3a09 Who put this here? 2017-08-18 18:59:34 +01:00
e5e76d4c93 Merge branch 'master' into mcpe-1.2 2017-08-18 18:39:39 +01:00
a7ad26426f Add stained glass and stained glass pane (#1298) 2017-08-18 18:30:03 +01:00
2688228a6f Don't dump subchunk raw data 2017-08-18 16:57:07 +01:00
e15eefc58f ... 2017-08-18 13:58:33 +01:00
f73d3d086e Added some new blocks, fixed collisions not being detected when standing on top of a full block 2017-08-18 13:58:05 +01:00
41f5cba971 Added End Rods, close #940 2017-08-18 13:05:39 +01:00
8853452feb Updated for 1.2.0.18 2017-08-18 12:36:04 +01:00
d8f0dd6db8 Changed Block->getDrops() to return Item[] 2017-08-18 11:21:33 +01:00
09c53552c1 Merge branch 'master' into mcpe-1.2 2017-08-18 08:29:40 +01:00
c8ed2406d7 Fix bad setChunk() documentation 2017-08-17 21:03:07 +01:00
a4ec2b7f2c Removed copy-pasted code from Player 2017-08-17 19:50:17 +01:00
1f6d325328 Added API for assigning permanent windows, fixed teleportation breaking inventory 2017-08-17 19:43:59 +01:00
f35ca147bb Merge branch 'master' into mcpe-1.2 2017-08-17 18:38:30 +01:00
9efd350e78 Return unhandled on desktop crafting instead of hitting errors 2017-08-17 18:34:21 +01:00
be4f48a119 Updating submodules 2017-08-17 18:26:06 +01:00
b6fb2bca13 forgot to add this to the merge 2017-08-17 17:27:49 +01:00
4f1302adf2 Merge branch 'master' into mcpe-1.2 2017-08-17 17:14:16 +01:00
83f29e5639 Fixed tests failing since 83af4dcd 2017-08-17 17:02:13 +01:00
e825ebd8fa Added some wrapper methods to make data flags less of a pain in the ass to work with 2017-08-17 16:52:17 +01:00
83af4dcd59 Block API typehints 2017-08-17 13:50:19 +01:00
f6c31680f6 Fixed unknown blocks dropping themselves 2017-08-17 13:25:11 +01:00
6320a63ca5 Use standard format for color hex, some minor name alteration 2017-08-17 13:08:18 +01:00
9e02f3c4e3 Fixed redstone lamp light levels and hardness 2017-08-17 11:47:10 +01:00
2cd05bf5b5 Removed redundant Block constructor overrides 2017-08-17 11:42:26 +01:00
5b4035253b Casting cleanup and removed some 32-bit string-int leftovers 2017-08-17 11:24:49 +01:00
77376d3e33 No idea how this happened 2017-08-17 11:15:42 +01:00
56e45a031b Fixed missing returns for Player->switchLevel() 2017-08-17 11:15:22 +01:00
21a1e0eb6b Player API typehints 2017-08-17 11:08:54 +01:00
670a9fe44f Fix some crashy issues when incompatible players get disconnected 2017-08-17 10:29:12 +01:00
6efa4343b1 Cleaned up fuel duration handling, fixed some fuel items not working in furnaces 2017-08-17 10:22:47 +01:00
dc3f13cd30 Cleanup from previous commit 2017-08-17 09:42:00 +01:00
b4c4005009 Some condition simplifications suggested by static analysis 2017-08-16 20:06:48 +01:00
eebc52e00b Added API method Entity->isClosed() and made Entity->closed protected 2017-08-16 19:30:23 +01:00
20aa519f3a Added capability to remove owners/target entities 2017-08-16 19:14:15 +01:00
741394dab1 Typehinted up entity API
Did you guys think ALPHA7 changes were done?!
Sone stuff still needs some work, most notably data-properties can't be typed yet because they are just mushed into a couple of methods.
2017-08-16 19:04:30 +01:00
ea414ea72d Fixed MetadataStore 2017-08-16 17:09:03 +01:00
696c67f541 Missed a couple 2017-08-16 14:43:18 +01:00
021dbd65d7 Cleaned up some copy-pasted code for coloured blocks names 2017-08-16 14:38:41 +01:00
8510be062c Nether Reactor block is back
This should never have been removed, it exists as an unobtainable block in vanilla which drops iron and diamond.
2017-08-16 14:17:14 +01:00
7b142d4742 Generated some TODO comments for blocks 2017-08-16 13:25:36 +01:00
643e10037c Merge branch 'master' into mcpe-1.2 2017-08-16 13:19:37 +01:00
0257432afc Fixed a typo in BlockIds 2017-08-16 13:17:22 +01:00
4950157f1d How did this escape notice? 2017-08-16 13:08:30 +01:00
c4d8c28338 Some inspection fixes 2017-08-16 13:07:33 +01:00
eda2473e78 New LevelEventPacket constants 2017-08-16 12:53:53 +01:00
4b65fef957 Fixed LevelEvent broadcasting 2017-08-16 12:53:32 +01:00
fbe2567e58 Merge branch 'master' into mcpe-1.2 2017-08-16 12:31:12 +01:00
9a0b3a6e22 Updated RakLib submodule 2017-08-16 12:28:44 +01:00
5fc50aeda5 Found an unknown field in StartGamePacket 2017-08-16 10:10:42 +01:00
ebb71fc6c5 Typehints and docs for MemoryManager 2017-08-15 19:48:19 +01:00
ae3a8a5493 Added capability to unblock addresses without a restart 2017-08-14 14:12:06 +01:00
9be1b929a5 Added PhpDoc for packet field types and changed float x,y,z to Vector3 2017-08-13 20:02:07 +01:00
6480f7a989 Found an unknown field in TextPacket and added some docs 2017-08-13 18:20:06 +01:00
1576a79644 more packets 2017-08-13 17:43:33 +01:00
02cbf800d0 Added encode/decode for ModalFormResponsePacket 2017-08-12 19:33:16 +01:00
5a4fbc6f5a Handle exception for crafting and resend inventories 2017-08-12 19:11:57 +01:00
83fcec3e94 Don't add actions to the transaction if a crash occurred when getting the source inventory 2017-08-12 14:29:12 +01:00
5d436a06ec Added a method to get player cursor inventory 2017-08-12 14:10:47 +01:00
8958b3c51c Many many changes related to inventory transactions, fixed item dropping, fixed creative menu 2017-08-11 19:57:30 +01:00
c1ff7bbef4 Added creative-inventory magic slot numbers and renamed some constants 2017-08-11 12:31:11 +01:00
74ee94b385 Duct tape for inventory transactions, removed ContainerSetSlotPacket 2017-08-10 20:05:15 +01:00
5208ad885c Added crafting use-ingredient fake transaction source 2017-08-10 18:42:14 +01:00
0c798222a4 ... blame PhpStorm EAP 2017-08-10 18:04:44 +01:00
e8bd0c3e09 add typehints to Metadatable interface and implementations, fix missing return for Block->hasMetadata() reported in #1285 2017-08-10 18:02:01 +01:00
51be88c698 Fixed AdventureSettings not working 2017-08-10 13:01:20 +01:00
0dc8362536 Added custom player permission level 2017-08-10 11:34:34 +01:00
9bae4d8ef6 updates for 1.2.0.11 2017-08-10 11:15:23 +01:00
bb4808c23e attacking entities working
just moved some code :P
2017-08-10 10:49:14 +01:00
3025f76cd0 Fix a couple of Sign bugs 2017-08-10 08:57:57 +01:00
1e539c4e3b fix some 1.2 translation issues, close pmmp/PocketMine-Language#19 2017-08-09 21:40:20 +01:00
590003d7c1 Fixed PlayerListPacket 2017-08-09 19:51:39 +01:00
72d40860f3 Remove useless else branch and and return unhandled for unmatched window IDs 2017-08-09 19:05:00 +01:00
d3d1e32309 Removed teleport zero-offsets (not needed in 1.2) 2017-08-09 17:01:56 +01:00
36d47a33f3 Fixed crash on player death 2017-08-09 13:34:25 +01:00
260179197b Use SplFixedArrays in inventory, added more typehints and cleaned up some duplicated code 2017-08-09 13:12:07 +01:00
82fd3b540e Fixed a mistake in Block->isBreakable() doc 2017-08-08 22:15:44 +01:00
75644b5df2 s/windowid/windowId 2017-08-08 12:37:26 +01:00
3ad1b1ba7f Added some ContainerSetDataPacket constants 2017-08-08 12:19:11 +01:00
b4c2305c7f Minor cleanup of Human->initEntity() 2017-08-08 10:44:11 +01:00
1d0f0a2999 Merge branch 'master' into mcpe-1.2 2017-08-08 10:23:19 +01:00
8ca37b3813 Fixed a bug in multiline chat handling 2017-08-07 19:41:08 +01:00
2ba601b6e9 Fixed signs 2017-08-07 19:40:45 +01:00
06083d6dc4 s/Item/Block 2017-08-07 16:26:27 +01:00
2d8395f70e Absorption should be a float. Fixed #1071 2017-08-07 16:09:10 +01:00
6b5c0af161 Separation of effect handling from Entity, fixes #886 2017-08-07 16:03:54 +01:00
c84218c55b Remove overloaded parameter from GeneratorUnregisterTask construction
PhpStorm, pls tell me why you only found this _now_ and not back in January when I started using PhpStorm...
2017-08-07 15:46:57 +01:00
6b7a382625 import cleanup and missing strict types declare 2017-08-07 15:42:46 +01:00
54b6a5710e Fixed entityBaseTickTimer doesn't cover child overrides 2017-08-07 14:21:06 +01:00
7958fffa07 Move some code around to fix block placing, breaking, and throwing snowballs 2017-08-07 12:28:07 +01:00
98e0a2ecba Removed InventoryType, added new inventory API methods 2017-08-07 11:31:36 +01:00
44f1dedbf8 Give creative players carte blanche
Close #879, close #431

This will be solved properly in 1.2 when creative transactions are
actually trackable. For now... HACK!
2017-08-06 21:16:08 +01:00
899e318a88 Merge branch 'master' into mcpe-1.2 2017-08-06 18:46:56 +01:00
23eb8600ab Added methods for endian-flipping 2017-08-06 18:46:03 +01:00
989505c42c Updated crafting & creative data from 1.2.0.7 2017-08-06 17:21:52 +01:00
d9da9accbc Fix packet buffers when encoding twice 2017-08-06 17:21:52 +01:00
711d62b5eb Updated block & item IDs from 1.2.0.7
Note to self: these may need updating again later in the beta.
2017-08-06 17:21:52 +01:00
49506659e0 More constants 2017-08-06 17:21:51 +01:00
7886918140 Cleaned up some bad code in DataPacket, added encode/decodeHeader and made encode/decodePayload protected 2017-08-06 17:21:51 +01:00
8a151dc373 Fixed PlayerSkinPacket for 1.2.0.7 2017-08-06 17:21:51 +01:00
58a12fdfa3 Updated for 1.2.0.7 2017-08-06 17:21:51 +01:00
50dffeb6a1 Day 3, part 1 2017-08-06 17:21:51 +01:00
63d2b341b9 Day 2 2017-08-06 17:21:51 +01:00
77cd8e7799 More broken mess to spawn 1.2 2017-08-06 17:21:51 +01:00
10ff2948ac Fixed double wooden slab name inconsistency 2017-08-06 17:15:35 +01:00
0d0df3390a Added glazed terracotta 2017-08-06 17:10:06 +01:00
e4a5cb6021 Changed NBT representation in JSON to hex, fix encoding problems with UTF-8 2017-08-06 14:50:18 +01:00
71e354cf1d Added chest open/close sounds and cleanup duplicated code 2017-08-06 12:48:46 +01:00
7d3fca83f0 Tile NBT usage enhancements (#1259)
* Do not create new NBT objects on Tile::getSpawnCompound()

* PocketMine's string formatting

* Remove more useless array indices and create lesser new NBT objects.

* Remove unused imports and type-hint Sign::setText() params

* Do not mess with Sign::setText() params due to #1204

* Fix formatting

* Make getSpawnCompound() final and add abstract addAdditionalSpawnData()

* Make the same changes for Bed tile

* Fix a missing "->" and remove some unneeded int casting.
2017-08-06 12:35:37 +01:00
3fdbcee10f Add some typehints and documentation to MainLogger 2017-08-06 11:43:42 +01:00
4e9af1ac45 Fixed several extremely stupid bugs in MainLogger
- Fixed log writes being blocking (these were executed on a thread, but IN A SYNCHRONIZED BLOCK - what the fuck shoghi?!)
- Fixed log file being open for reading as well as writing
- The logger will now be buffered for 25ms before writing to disk, as it should have been to begin with.
- Moved the log resource to a local variable (it's unsafe to try to access resources from different threads, this takes away the ability to do so)
- Fixed line endings to use PHP_EOL instead of hardcoded LF, fix viewing logs in Notepadi
2017-08-06 10:56:39 +01:00
475066c9f5 Removed minor code duplication in MainLogger 2017-08-06 08:55:46 +01:00
d5f6966ce3 Fixed server freeze due to bad light filter values 2017-08-05 23:22:33 +01:00
0ad4a59d5a Added test for light filter levels (must always be >= 1) 2017-08-05 23:03:13 +01:00
5f6dc25c9f Fixed EnchantCommand being retarded, close #1012 2017-08-05 21:27:57 +01:00
3b7fc21839 Enchantment API changes, understandable constant names 2017-08-05 21:27:57 +01:00
ecba80fd63 Fixed some trailing whitespace
$ shopt -s globstar
 $ sed -i 's/[ \t]*$//' src/pocketmine/*/**.php

:P
2017-08-05 21:07:21 +01:00
fb59b57bdf Improve item enchantment API and fix some bugs (#512) 2017-08-05 20:50:28 +01:00
2b4e303f52 Fix client-side translation for gamemode change 2017-08-05 12:05:35 +01:00
2103c981a9 Replaced literal ints with Vector3 constants for Block->getSide() calls 2017-08-04 13:33:23 +01:00
3188f1c053 Removed redundant override 2017-08-04 13:23:46 +01:00
fdf71841e1 Added missing strict type declares 2017-08-04 13:17:59 +01:00
11fae493a5 Added Nether Wart 2017-08-04 13:17:53 +01:00
3135fe3c69 Added API method Block->getItemId(), cleaned up excess wooden stairs and fence-gate classes, added more wooden door types 2017-08-04 13:02:24 +01:00
561d8e7a39 Regenerated block/item id lists and refactored some names for consistency with MCPE 2017-08-04 12:17:24 +01:00
3048a3b39b Added precision and mode arguments to Vector3::round() (#1256)
If the precision is positive (i.e. there are numbers after the decimal point), the results should be floating-point numbers rather than integers, hence the additional check.

Even if the precision is negative or zero, the $mode parameter may still be useful.
2017-08-04 09:56:42 +01:00
63c12440dc Fixed items ordering 2017-08-03 17:48:56 +01:00
b912b9173c Changed how blocks are registered, add API to allow registering custom blocks 2017-08-03 16:46:48 +01:00
ca3cf3e067 Fixed ordering of blocks list and duplicated RedstoneTorch registration 2017-08-03 15:27:46 +01:00
8a02dbb15a fix crash when var_dumping packets 2017-08-03 08:47:10 +01:00
f0b4a33e2e www.pocketmine.net -> update.pmmp.io (#1263) 2017-07-31 22:44:02 +01:00
306bf7be5f Moved dimension id constants to their own interface (PHP needs enums) 2017-07-31 16:38:01 +01:00
0b47324fe3 Add some constants to AnimatePacket 2017-07-31 16:03:45 +01:00
17be06a56d Rough implementation of double plants, fixes #882 2017-07-31 08:14:01 +01:00
caff686827 Fixed grass growth and death, close #436
way too fast to grow back though :S
2017-07-31 08:00:03 +01:00
210bdc2436 Fixed liquid CPU leaks and some flow issues
Liquid still needs a total rewrite, but at least it won't constantly waste CPU anymore.
2017-07-31 07:24:22 +01:00
acaa0d2740 Translate command usage messages server-side, close #236 2017-07-30 21:14:40 +01:00
ffefcd4473 Fixed 'moved too fast' when respawning 2017-07-30 20:59:42 +01:00
8957dbf08e Use occupied bitflag and added distance check for beds
must be < 2 blocks from either half of the bed
2017-07-30 20:02:48 +01:00
2d626d1d90 Improved Beds, fixed bed tiles not getting removed for other halves
relates to #880
2017-07-30 19:57:10 +01:00
253db40a11 Fixed bed placement with head over a transparent block 2017-07-30 19:50:47 +01:00
8a3b31077e Fixed some items not keeping meta when constructed, close #968 2017-07-30 19:46:24 +01:00
1f4e6535bb Added Bed tile and support for coloured beds 2017-07-30 19:34:06 +01:00
6ae24c5c19 Removed unnecessary methods Block->canBeActivated() and Item->canBeActivated() (needless extra confusion) 2017-07-30 18:14:43 +01:00
036663e0b5 Made rails less weird
Not up to the task of implementing rail connectivity today, some other time
2017-07-30 18:02:24 +01:00
344500785c Fixed wrong drops for Bookshelf 2017-07-30 17:58:34 +01:00
a95d173989 Fixed a couple of repeated Level->getBlock() calls in Liquid 2017-07-30 17:57:40 +01:00
e72d8cf8f5 Remove a couple of obsolete TODO comments 2017-07-30 17:43:14 +01:00
c0e0730923 Fixed PE armor screen glitching when equipping armor items 2017-07-30 17:41:44 +01:00
b6fe231bc1 Added melting for ice and snow layers 2017-07-30 17:27:28 +01:00
3bd94c9da7 Heads do not drop when the supporting block is removed
https://github.com/PocketMine/PocketMine-MP/pull/4087 didn't get reviewed properly, or at all 🤦
2017-07-30 17:26:55 +01:00
2e5e016b87 Remove redundant TODO from CraftingTable 2017-07-30 17:26:06 +01:00
822c048af0 Fixed wrong docs in Block 2017-07-30 17:24:59 +01:00
6e4b8ba677 Removed some useless code 2017-07-30 17:24:33 +01:00
a5a8732800 Removed redundant overriden method from Furnace 2017-07-30 17:24:02 +01:00
21887b283f Removed some copy-pasted code, fix leaves2 drops 2017-07-30 17:22:28 +01:00
3e141afe48 Exposed LoginPacket chain data to allow plugins to access this data 2017-07-29 14:27:16 +01:00
aa6eef26e9 Fixed #1255 2017-07-28 14:23:27 +01:00
87c16dab23 Don't allocate subs that aren't going to be modified 2017-07-28 11:26:15 +01:00
c1542d853f Improved flat world initial chunk generation speed by ~50% 2017-07-27 21:57:28 +01:00
8274f5b3cc More hack-fixes for #1220
Player and network really need to get divorced, and fast.
2017-07-27 11:25:40 +01:00
e8be8550a0 Fixed possible issues with tick counters being inaccurate when the server lags 2017-07-27 10:58:34 +01:00
b3dada4cb9 Fix wrong documentation in ServerEvent 2017-07-26 21:24:19 +01:00
ed5f69f170 Fixed documentation and expiration date nullability in BanEntry, close #1242 2017-07-26 19:37:08 +01:00
7d777510c5 Use the Crash Archive for crashdump submission instead of pasting them into an issue 2017-07-25 10:12:02 +01:00
6ff92f2adf Fix player timeouts crashing the server 2017-07-24 21:12:05 +01:00
f32e880542 Fixed really dumb copy bug breaking crafting 2017-07-22 12:04:52 +01:00
6cacb368ce Add PlayerJumpEvent (#1223) 2017-07-22 11:18:53 +01:00
6fa59230db Added documentation for Thread->registerClassLoader() and Worker->registerClassLoader() 2017-07-22 10:55:00 +01:00
1a7f567a70 Return the dropped item entity in Level->dropItem() (#1222) 2017-07-20 12:27:58 +01:00
42fb1d1fef Improve usability of Sign API (#1202)
* Improve usability of Sign API

* PHP

* Throw exceptions if out of range

* Fix phpdocs

* Formatting, additional checks in the SignChangeEvent.

* Blame php storm

* require line count to always be 4

* Adjust exception message
2017-07-19 15:22:04 +01:00
cca9cf2c86 Workaround for plugin versions being read as strings from plugin.yml
Config is a real pain in the ass to work with... need to split it up so this can be handled properly
2017-07-16 11:31:21 +01:00
7c00982fff Fixed furnaces crashing the server
Beware ListTag indices being strings! Should be impossible, but the NBT library is poorly designed.
2017-07-15 21:53:43 +01:00
3150c50cac Typehinted AxisAlignedBB 2017-07-15 18:43:10 +01:00
57e7c3d91f Missed one 2017-07-15 13:30:02 +01:00
3e8825f826 Fix bad documentation in Block 2017-07-15 12:48:41 +01:00
ab3b50f062 Stop it PhpStorm, you're making me look bad 2017-07-15 12:15:15 +01:00
dbb92096e4 More typehints, documentation fixes and static analysis cleanup 2017-07-15 12:12:06 +01:00
24bdf330d5 Merge branch 'moar-typehints' 2017-07-15 09:43:43 +01:00
b28128f835 Submodule updates 2017-07-15 09:43:33 +01:00
fb5587350d Solved issue of builds hanging when TesterPlugin fails to load (for example incompatible API version) 2017-07-14 16:48:42 +01:00
e6a2b0f270 Fix inaccurate documentation for ServerCommandEvent 2017-07-14 16:28:47 +01:00
bb230c5812 Shut up PhpStorm 2017-07-14 14:13:04 +01:00
6de8415c79 Merge network refactors 2017-07-14 13:04:02 +01:00
2018ad6376 Merge master 2017-07-14 12:12:35 +01:00
b5790d19bf Cleaned up MainLogger registration and declared a typehint
Remove null hint from MainLogger::getLogger() so static analysis doesn't complain everywhere
just make sure you register the logger before trying to use MainLogger::getLogger() on a different thread!
2017-07-14 11:39:04 +01:00
9390866a13 Fix derp 2017-07-14 11:00:59 +01:00
c3b8be3f60 and more typehints 2017-07-14 10:56:51 +01:00
b9355387da fix some inspections related to crafting recipes 2017-07-14 08:53:37 +01:00
7f99d9019a API bump and submodule updates 2017-07-14 08:52:27 +01:00
8bb0c53797 More typehints for Command stuff 2017-07-14 08:52:27 +01:00
46a2e6cbf8 Some breaking changes for plugins >:D 2017-07-14 08:52:27 +01:00
8fc1501e89 Moar typehints 2017-07-14 08:52:27 +01:00
6a191b5069 Remove useless condition 2017-07-13 19:59:01 +01:00
08b8debd78 Added a FIXME for generator 2017-07-13 19:53:48 +01:00
2a7b736f18 Heap of bugfixes, cleanup and PHP 7 upgrades 2017-07-13 19:18:56 +01:00
c2a7c2c6cd Remove duplicate Quartz class (cc @PEMapModder)
how did nobody ever notice this...
2017-07-13 16:48:25 +01:00
4d874e7e78 static analysis 2017-07-13 16:45:24 +01:00
23866359c9 Fix some PSR-2 violations 2017-07-13 16:14:28 +01:00
3a214b7ce6 Cleaned up isEncoded mess 2017-07-13 12:21:26 +01:00
6341d3a0dc don't break the preprocessor 2017-07-13 12:09:03 +01:00
72d1948f30 Improved batch handling 2017-07-13 12:04:47 +01:00
a7f5ee2f3e Added capability to get/set screen height in lines for each CommandSender to alter page sizes of command output such as /help (#1144) 2017-07-13 10:57:10 +01:00
6b773dc04d Make resource-pack error messages a little clearer 2017-07-13 10:55:42 +01:00
6af87b7b30 Fixed clearCustomBlockData(), close #1118 2017-07-13 10:44:49 +01:00
5283975f20 Move inventory ID constants to their own interface
ContainerSetContentPacket will be removed in 1.2, and these aren't specific to ContainerSetContentPacket anyway.
2017-07-12 20:04:36 +01:00
a5c6c8b973 Added some fields to new packets
gave up on EventPacket because it's a mess, and StructureBlockUpdate is a job all by itself
2017-07-12 19:31:20 +01:00
caa229a25f Fix wrong generator name returned for Nether->getName() (#1194) 2017-07-12 18:10:54 +01:00
4731bf0a16 Fix autogenerated version numbers (didn't mean to commit this)
I'm working with a beta version >_>
2017-07-12 16:36:04 +01:00
30df0c2418 Refactor a bunch of network-related things for easier auto-generation of protocol stuff 2017-07-12 16:32:39 +01:00
e485999218 Just cut the adapter loose instead of needing extra fields for this 2017-07-12 12:28:54 +01:00
650afe2d94 Added PlayerNetworkSessionAdapter to allow abstraction of NetworkSession base 2017-07-12 12:28:54 +01:00
fa58736360 Remove derpy little try/catch for RakLib dependency check (not necessary anymore) 2017-07-11 20:00:16 +01:00
c33972aa67 Update submodule 2017-07-11 19:53:50 +01:00
6bcc8cea8e Fixed BossEventPacket breaks, now shut up and go away 2017-07-11 15:32:46 +01:00
f2467d3dbc Workaround for grass-path/farmland anti-flight issue, close #1170 2017-07-11 10:37:01 +01:00
be7e97e0bb Fixed server ping responses showing up in the wrong entries on the client
Seems it doesn't like negative numbers
2017-07-11 09:28:50 +01:00
767f0dcbf6 Fixed not being able to connect to Jenkins builds 2017-07-11 08:10:40 +01:00
c9fdb66c78 Made flat-world generation faster and less stupid
No need to set blocks which are obviously already going to be air >_>
2017-07-10 18:14:13 +01:00
8a28dfa64d Don't send crashdumps if git hash is invalid 2017-07-10 08:50:11 +01:00
c6a6571c07 Revert bad optimization due to broken logic
Revert "Small optimization to light propagation"

This reverts commit 6d7b76f356.
2017-07-09 12:45:11 +01:00
6d7b76f356 Small optimization to light propagation 2017-07-09 12:21:07 +01:00
8cca8e1256 Fixed a bug in light removal 2017-07-09 12:19:38 +01:00
30c5487f94 Drastically improved performance of basic chunk sky-light population
back 2 commits: 53ms per chunk
back 1 commit: 27ms per chunk
this commit: 3ms per chunk

(on my machine, of course)
2017-07-08 17:13:22 +01:00
728851594b Improved performance of basic chunk sky-light population
No need to recalculate this 256 times
2017-07-08 13:37:45 +01:00
2726f2a011 Solved packet encode/decode boilerplate code issue
Something as simple as forgetting the reset() when encoding would cause lots of problems which could go unnoticed. This should be fully backwards-compatible but needs more tests.
2017-07-07 13:59:09 +01:00
1a5e3b2ad0 Fixed outdated movement problem, fixed #1171 2017-07-06 10:40:03 +01:00
1493cde07f Added pause-game LevelEvent constant 2017-07-05 17:51:53 +01:00
6cd4d2c5a2 Added typehints and PhpDoc for events API
excluded blocks and entities events API to avoid merge conflicts
2017-07-05 16:42:06 +01:00
6504fdabab Fixed squid not updating and added some debug 2017-07-05 11:42:24 +01:00
394f420059 Fixed chunks not loading when respawning and some minor spawn sequence cleanup (#1153)
* Fixed chunks not loading when respawning and some minor spawn sequence cleanup

* This causes too much unexpected behaviour to be useful

Revert "Make use of Mojang's pitch hack, close #821"

This reverts commit c2dfef700f.

* Removed delayed-teleport system and cleaned up movement reset for dead players

* Fixed health resetting to max when quitting and rejoining
2017-07-05 10:31:16 +01:00
b8a30309bb Improve checks for Position::equals() and Location::equals() (#929)
* Add files via upload

* Position::$level can be null.

* Use getLevel() in place of $level

because of WeakPosition.
2017-07-04 20:25:25 +01:00
1a6517ea4e Added timings for console title ticking
As stupid as this seems, this can actually cost a significant amount of tick time due to reading from disk and/or executing commands.
2017-07-04 17:05:53 +01:00
9c9095060f Register MainLogger on AsyncWorkers to make MainLogger::getLogger() usable in AsyncTasks
Threaded static properties aren't thread-local anymore in pthreads 3.1.7dev
2017-07-04 16:50:17 +01:00
97f6a32557 Changed usage message displaying to exceptions to reduce boilerplate code
Someday this won't need to be done by commands themselves, it'll be done by the parser.
2017-07-04 13:45:00 +01:00
409fc282d2 Cleaned up ping response and added missing fields (#1114) 2017-07-04 11:17:47 +01:00
d474f73665 Move base offset to Human from Player
fixes jojoe77777/Slapper#58
2017-07-03 19:58:07 +01:00
c2dfef700f Make use of Mojang's pitch hack, close #821 2017-07-03 13:35:27 +01:00
dca7efa03c Fixed crash when /teleporting with yaw/pitch 2017-07-03 13:26:38 +01:00
b4a149cce8 Fix some issues with entities in leveldb worlds 2017-07-02 13:37:30 +01:00
2a67507997 Require php-leveldb version 0.2.0 or greater 2017-07-02 12:52:22 +01:00
70bd9afd37 Updated leveldb implementation to support MCPE 1.1 worlds 2017-06-30 09:11:26 +01:00
56dfa7d000 Added some debug for ChunkRequestTask 2017-06-29 11:31:28 +01:00
390df00966 Remove useless condition 2017-06-29 10:38:24 +01:00
82fd0e8d47 Added debug for view distance setting 2017-06-29 09:46:02 +01:00
6259f42d81 Fixed trace parameter list showing boolean instead of being empty for function calls with no parameters 2017-06-28 10:33:07 +01:00
08d4d7fe0e Fix /banlist and /whitelist list when no players are in the lists, close #1146 2017-06-28 10:28:43 +01:00
ae612b913e Fixed config type detection, fixed configs being saved empty
Fixes LegendOfMCPE/EssentialsPE#354

When the config file didn't exist, no type detection was performed. This resulted in the case statement for Config->save() falling through and not writing anything to the file.
2017-06-27 16:44:05 +01:00
adbc298909 Fixed item CompoundTags keeping the tag name after NBT serialize/deserialize, close #1145 2017-06-27 15:58:00 +01:00
d92a6240d8 Moved spawn check to sendChunk() instead of sendNextChunk(), fix #828
doesn't make sense to put it anywhere else regardless...
2017-06-27 13:36:26 +01:00
4a7c40edd5 ExplodePacket records have a signed Y coordinate -_- 2017-06-26 23:09:20 +01:00
1dd8fc008b Fixed players taking forever to spawn when generating a new world 2017-06-26 18:37:20 +01:00
ec079b68a6 Fixed missing packet registrations 2017-06-25 17:36:12 +01:00
ecfcf49984 Added basic encode/decode for gamerules data and added GameRulesChangedPacket
needed it for tests

Squashed:

oops

PhpStorm you asshole
2017-06-25 15:43:08 +01:00
f7aad8e2fe Use CRLF for PowerShell scripts 2017-06-25 14:15:34 +01:00
a73c6f1861 Fixed some unnecessary FQNs in docs 2017-06-25 12:43:04 +01:00
a365c831a8 Fixed some doc problems 2017-06-25 12:07:28 +01:00
c0377fc63a more typehints, removed more 32-bit leftovers 2017-06-25 11:40:12 +01:00
22d148a59d Fixed TAG_Short being read as unsigned 2017-06-24 11:22:32 +01:00
a1ce535d02 Remove the old plugin repo from README since it is dead/outdated 2017-06-23 23:21:34 +01:00
993af0fa30 Added build-denied action constant
don't need this, but good to have for completion's sake
2017-06-23 16:58:28 +01:00
b83c135c3f Made Item::setLore() fluent (#1120) 2017-06-23 08:39:56 +01:00
8bf1cc9e48 PHP version should be the very first thing to be checked 2017-06-23 01:52:53 +01:00
c70690a600 Fixed cleanPath() not working when the current working dir case doesn't match the actual path case 2017-06-22 19:49:27 +01:00
4b4f2af9e3 Fixed some very unusual crashdumps reporting non-fatal errors when plugins use die() or exit() 2017-06-22 19:08:33 +01:00
9047c2c1ef Updated DevTools submodule with /makeserver fix 2017-06-22 17:16:59 +01:00
89ca2ac2d5 Found an unknown field in ChangeDimensionPacket
No idea what this is actually used for though. It's set when a client dies in a different dimension and respawns in the overworld.
2017-06-22 15:52:29 +01:00
6a2a74a457 Improved git hash handling, add dirty git detection and disable automatic reporting for dirty builds 2017-06-22 13:35:04 +01:00
7ba807fd42 Update submodules 2017-06-22 09:41:07 +01:00
19410754c6 API bump 2017-06-22 09:34:04 +01:00
8cd31c2dc4 Fixed crashes starting RCON 2017-06-21 18:15:57 +01:00
c09a5ab301 Revert botched fix that broke teleports
Revert "Do chunk orders and sending during onUpdate() when we know the player has been constructed"

This reverts commit 080b35bf53.
2017-06-21 17:51:16 +01:00
a0ef15b15e New CrashArchive is up 2017-06-21 14:25:54 +01:00
03826d9cbc Fixed player spawnpoints glitching and not saving 2017-06-21 12:17:26 +01:00
080b35bf53 Do chunk orders and sending during onUpdate() when we know the player has been constructed 2017-06-21 11:54:05 +01:00
e9c46da7f0 Fixed glitching on respawn due to player 1.62 position offset 2017-06-21 11:27:50 +01:00
0f79b19fdc Removed masks for Y coordinates, fixed bugs related to out-of-bounds coordinates, fixed #914 (#915) 2017-06-21 10:55:38 +01:00
69ae37d191 Added no PvP flag for spectator mode, fixes nodamage sound in spectator 2017-06-21 09:42:26 +01:00
86742fcf30 Workaround for flight controls fail on teleport (TODO: fix this properly) 2017-06-20 20:10:20 +01:00
a4b8dd43e6 Removed useless confusing array indices in CompoundTag constructors (#1116) 2017-06-20 12:11:24 +01:00
e11f1e94e9 Cleaned up SubChunk implementation 2017-06-19 15:40:31 +01:00
938452bfe9 Clarified guidelines on useless issues 2017-06-19 13:43:10 +01:00
a724395148 Added exception handling to Player->close(), mitigates #1060 and #1101 2017-06-19 13:37:38 +01:00
bc10edfdd3 Removed incorrect use of \pocketmine\ANSI constant for debug logging in MainLogger constructor 2017-06-18 16:50:34 +01:00
f7d07ca155 Updated DevTools submodule 2017-06-18 11:46:31 +01:00
be7b057fa5 Improved metadata sending and made it less spammy
Add changed properties to a list to send in a group on tick in a single packet
2017-06-17 20:00:45 +01:00
8637e0224f Check protocol version before anything else 2017-06-17 19:30:37 +01:00
8919d4a372 Some refactoring to allow for light updates to be executed asynchronously 2017-06-17 17:38:47 +01:00
0cf3914f5d Player base offset doesn't change with scale, close #943, close #945 2017-06-17 12:59:41 +01:00
e9a638d84a Set a default value 0 for tick counter (#1108) 2017-06-17 12:42:42 +01:00
e3b3f60c66 Fixed item stack count and effect amplifier overflows, close #1072 2017-06-17 12:22:38 +01:00
1bae973502 Fix server crashing while crashing when trying to decode an invalid response from the crash-archive post 2017-06-17 10:31:20 +01:00
e0f8a02bb8 Catch and log all crashes occurring while creating crashdumps 2017-06-17 10:25:34 +01:00
846be84324 Fixed all file headers 2017-06-16 16:18:16 +01:00
8ef24423d1 This should never be null 2017-06-16 15:48:08 +01:00
8fc38c36f9 Fixed some derp Vector3 aliases 2017-06-16 13:48:53 +01:00
eb05f2ecde Added UpdateNotifyEvent 2017-06-15 11:16:13 +01:00
478e954b3f Updated preprocessor submodule 2017-06-15 11:04:52 +01:00
313fdb9e87 Added INT32_MIN and INT32_MAX constants and an exception throw for out-of-range effect amplifiers 2017-06-14 19:38:39 +01:00
1bf18ba8d2 Fixed messed-up header in ItemFrame 2017-06-14 18:46:35 +01:00
5011198a4e Cleaned up SetupWizard and fixed crash when pressing CTRL+C during setup 2017-06-13 17:38:19 +01:00
e96fa8b682 TODO: REVERT - Added a hack for InteractPacket spam issue 2017-06-12 19:50:31 +01:00
bf3868c078 Missed one 2017-06-12 09:33:48 +01:00
3167817e34 Fixed crash when memory hard limit is disabled, close #1074 2017-06-12 09:32:31 +01:00
433b8369f5 Point updater to new host update.pmmp.io 2017-06-11 19:15:35 +01:00
0612244b5e Fixed warn-ops config being useless 2017-06-11 19:07:41 +01:00
487233a101 Improved AutoUpdater error handling and made it more robust 2017-06-11 18:41:18 +01:00
4341fb8347 AddEntityPacket's attributes encoding is still non-standard -_-
I thought they fixed this...
2017-06-11 18:09:58 +01:00
789df942b6 Don't try to order packets sent with immediate priority, fixes #1026 2017-06-11 13:04:43 +01:00
9e99252817 Improved ListCommand and fixed crash when no players are online
I <3 closures
2017-06-11 10:56:16 +01:00
75cc2d6914 Cleaned up Utils::getIP(), resolved strict-type issues, close #1062 2017-06-11 10:25:48 +01:00
61b857a81c Fixed ExplodePacket
fixed-float my ass!
2017-06-10 19:54:04 +01:00
2024e9ecdf Fixed extremely stupid zero-length bug in BinaryStream
pls don't kill me 😢
2017-06-10 18:33:54 +01:00
4765242397 Drop support for 32 bit systems/PHP (#984)
* Cutting out 32-bit and minor improvements to bootstrap

* Byeeeeee

* Removing legacy code

* added note to the issue template
as suggested by @xxFlare
2017-06-10 16:11:28 +01:00
3687b149b9 Fix a couple of bugs exposed by php 7.2.0alpha1 2017-06-10 14:51:28 +01:00
1aae9e03b6 Fixed reference parameter fail in UpdateCheckTask, close #1048
not sure _why_ this doesn't work... maybe something to do with the old property being a member of a threaded object?
2017-06-09 19:51:18 +01:00
c43ab12a9a Fix spawnForced not specified in SetSpawnPositionPacket, close #1046 (#1047)
* Fix #1046

* Change spawnForced to false
2017-06-09 18:12:57 +01:00
cd66f58526 Restrict XpSeed to the bounds of an int32, close #1040 2017-06-09 16:05:28 +01:00
7870a8672e Remove useless duplicate check 2017-06-09 16:02:30 +01:00
eac756470a Fixed trying to save health as a ShortTag, close #1039 2017-06-09 09:11:02 +01:00
a302b4988f Fixed bad values assigned to LongTags
PhpStorm you bitch... why didn't you tell me these were a problem?!
2017-06-08 19:28:29 +01:00
2193adf844 Removed auto-generated stub comments 2017-06-08 19:22:52 +01:00
890f72dbf2 Type-hinted NBT tag constructors, made getValue() and setValue() more strict, fix dozens of assorted related bugs 2017-06-08 19:17:52 +01:00
595e1ab52f Added Plugins section to the issue template (#1034)
* Added Plugins section to the issue template

* break it down a little
2017-06-08 18:26:53 +01:00
4a7abb7033 Fix flat worlds crashing when generating 2017-06-08 13:47:13 +01:00
d358e13868 Strict type all the things and fix lots of assorted bugs exposed by strict types (#993)
Strict type all the things
2017-06-08 11:21:51 +01:00
1f630e57f2 Fixed vine block update crashes, close #1032
The meta->side array was the wrong way round (keys & values inverted).
2017-06-08 09:32:38 +01:00
cc1d1b0f45 Fix type error in Furnace due to useless floor(), close #1031 2017-06-08 09:12:58 +01:00
78c09267e5 Typehinted things in BinaryStream, sorted some methods and related bugfixes 2017-06-07 13:53:10 +01:00
c445db421f Fixed stupid bug in resource pack chunk counting, close #1028 2017-06-07 13:29:13 +01:00
e18a3ac933 Fixed UUID-related issues 2017-06-07 13:11:03 +01:00
75863e2a44 OCD commit 2017-06-07 12:54:12 +01:00
5aea9220c9 Fixed chat and some TextContainer documentation issues 2017-06-07 12:54:12 +01:00
bd7205dd64 PhpStorm doesn't understand variable class names :( 2017-06-07 12:54:12 +01:00
82a63ed18e Added an assert to shut PhpStorm up 2017-06-07 12:54:12 +01:00
cf07af8b55 Fix some strict type violations reported by PhpStorm (strict types <3) 2017-06-07 12:54:12 +01:00
b775e8c88a Fix Achievement bug (thanks strict types <3)
as if nobody ever noticed this... LMAO
2017-06-07 12:54:12 +01:00
51091fe87b Fix player data saving 2017-06-07 12:54:12 +01:00
7c14ffbcfa More type fixes 2017-06-07 12:54:12 +01:00
db93827650 Fix world saving 2017-06-07 12:54:12 +01:00
c2186041d6 Fix TranslationContainer issue 2017-06-07 12:53:16 +01:00
481114281e Server starts! 2017-06-07 12:53:16 +01:00
51b0673b4b Bite the bullet and enable strict types on everything 2017-06-07 12:53:16 +01:00
606b9b687d Fix level ticking errors (these methods return floats >_<) 2017-06-07 12:53:15 +01:00
45618c7cfe Enable strict types for Server and add a bunch of type-hints 2017-06-07 12:53:15 +01:00
3f03d9e683 Fixed DevTools getting disabled when a plugin throws an exception during load (#1025) 2017-06-07 11:12:47 +01:00
f0d12a0b30 Implemented asVector3(), asPosition() and asLocation()
Squash merge, closes #973
2017-06-07 16:40:45 +08:00
9cc27b2719 Force sync 'compression' under the batch threshold
Since we aren't actually compressing these anyway, only writing a checksum, sending these asynchronously causes strange bugs due to race conditions.
2017-06-06 11:40:41 +01:00
87e54d7a3a Send block updates in batches 2017-06-06 11:40:30 +01:00
29e88d8592 Send area broadcasted packets in batches
- I don't know why it wasn't done like this to start with
- This provides a significant lightening of workload for large servers with lots of players in the same area because packets are only compressed once instead of for each player.
- Improves client-sided performance receiving these in batches instead of being spammed with many individual packets.
2017-06-05 23:39:16 +01:00
c6e800cf42 Use compression level 0 when batch size is below threshold
This isn't free, because of the adler32 checksum... but it's much lighter on performance for small packets.
2017-06-05 22:05:46 +01:00
b7b7bcee4f Fixed some weak comparisons 2017-06-05 21:07:35 +01:00
6ea0eb47ec Fixed PlayerInventory in_array recursion issue, close #1008
This is INTENDED BEHAVIOUR for comparing objects?????
2017-06-05 20:51:12 +01:00
b9a87ed147 New fields for InventoryActionPacket
TODO: use this packet
2017-06-05 20:04:20 +01:00
742f593758 Added a new constant to ContainerSetContentPacket 2017-06-05 19:15:30 +01:00
1e9ff44890 New field for MobEquipmentPacket
If anyone wants to play with the off-hand, the window ID is 0x77 ;)
2017-06-05 19:10:00 +01:00
55c4e35407 Added a new PlayerActionPacket constant
thanks @jojoe77777
2017-06-05 18:37:53 +01:00
e83ffd5afe Fixed players don't see teleport movement, close #921 2017-06-05 16:47:12 +01:00
54453d0b0a Refactored entity IDs in packets for consistency and to clarify on types 2017-06-05 15:41:27 +01:00
51d510aa4f Who set these stupid values... fixed #1011 2017-06-05 14:22:45 +01:00
4cd97a7c7a Fixed UpdateAttributesPacket not being registered for reading 2017-06-05 14:14:50 +01:00
d586ad03ec Update submodules 2017-06-05 10:15:03 +01:00
61d354a4ea Block constructor mass-replace to fix #963 and related issues 2017-06-05 10:02:27 +01:00
6f126ad239 Fix outdated preprocessor rules for varints, close #1003 2017-06-04 23:27:39 +01:00
efea39e0a4 Change buffer unread assertion to debug
I lost count of how many times I changed this now... what happened to the other times?
2017-06-04 19:19:50 +01:00
d4bb078566 Fixed some formatting issues in Player 2017-06-04 18:32:45 +01:00
6686bd4442 Quick fix for melons and pumpkins, close #965 2017-06-04 16:57:51 +01:00
2b02fcfe2c fixed #992 2017-06-04 16:54:35 +01:00
138fb88431 More default packet fields 2017-06-04 14:53:31 +01:00
26577d9d5b fixed a doc warning 2017-06-04 14:37:06 +01:00
2f4943ac90 Fixed some doc issues 2017-06-04 14:27:30 +01:00
eda7965f86 Fixed wrong types in ParticleCommand 2017-06-04 14:22:12 +01:00
4666560731 Removed some tags that don't exist in vanilla McRegion chunks 2017-06-04 13:04:06 +01:00
b01ad01eff Merge branch 'spammy-backtrace' 2017-06-03 22:04:31 +01:00
4ba3a3af3d fix FloatingTextParticle 2017-06-03 20:51:48 +01:00
5baf59ca56 fix #990 2017-06-03 20:25:24 +01:00
902957cb53 more defaults for optional fields, close #985 2017-06-03 17:41:40 +01:00
3463bea932 add defaults to MobEffectPacket
these fields may be unspecified if we are only removing effects
2017-06-03 15:21:24 +01:00
105917a534 Fixed type issues writing longs and var-longs on 32-bit 2017-06-03 12:04:08 +01:00
b83082f224 Fixed missing field in ContainerSetContentPacket, close #980 2017-06-03 11:59:19 +01:00
840a3883b1 Fixed type of empty ListTags and removed some undefined behaviour (#974)
* Fixed fallback type of empty ListTags, close #972

* Less undefined behaviour
2017-06-03 11:18:00 +01:00
ad4659365a Use default amplifier 0 instead of implicit null
(how did nobody ever notice this?!)
2017-06-03 11:06:22 +01:00
8d858e3e6d Removed __toString() from backtrace, fixes ludicrous amounts of spam when something crashes involving EncapsulatedPackets or NBT 2017-06-03 10:36:04 +01:00
22ba017965 Binary strict types (#969)
* Some Binary cleanup, type-hints and strict types
yes, I know this is very crashy... that's good, because it highlights unexpected behaviour

* added some default values
2017-06-03 09:39:45 +01:00
8bb0e8d398 Fixed a mistake in DropItemPacket encode 2017-06-02 17:52:10 +01:00
087a994393 Workaround for some plugins crashing clients during PlayerLoginEvent 2017-06-02 17:06:01 +01:00
e4e4ef5f2a Fixed preprocessor issues with signed bytes and floats, close #967 2017-06-02 12:50:48 +01:00
3ac51e1095 TAG_Byte should always be signed (#962) 2017-06-02 11:30:44 +01:00
2db6ea6b18 Updated creative inventory data
some items will show wrong damage values due to a bug in meta handling on master
2017-06-02 11:00:36 +01:00
b6ae92e1a7 Updated crafting data and item serialization for 1.1, fixed #963 2017-06-02 10:36:14 +01:00
31e2c1d26c fix stupid bug in PlayerInventory 2017-06-01 20:19:17 +01:00
846e3b6f1e New fields for StartGamePacket 2017-06-01 19:48:06 +01:00
0e525ac1c3 Autogenerated data for 1.1.0.55 2017-06-01 19:24:17 +01:00
8382970d56 Merge branch 'master' into mcpe-1.1 2017-05-30 16:09:46 +01:00
db3cd1829c Made Binary::readVarInt/VarLong methods less useless 2017-05-30 14:19:34 +01:00
caced595d2 Fixed server crash on startup on 32-bit with memory limit set >= 4096MB 2017-05-30 14:15:40 +01:00
86f3b257a7 Remove unneeded foreach loop in Human::getDrops() (#941)
* Remove unneeded foreach loop in Human::getDrops()

* Use array_values() for backwards compatibility.
2017-05-30 13:27:47 +01:00
1ed5de1d3b Merge branch 'nbt-cleanup' 2017-05-30 12:26:17 +01:00
63358a8065 Merge branch 'master' into mcpe-1.1 2017-05-30 09:45:20 +01:00
f6ff03fc31 Added support for MCPACK resource packs 2017-05-30 09:43:28 +01:00
0ad16c1919 Added PlayerDataSaveEvent, resolved #487 (#920)
* Added PlayerDataSaveEvent, resolved #487

* Added getPlayer() to PlayerDataSaveEvent
may return an IPlayer

* Fixed quit messages
This TranslationContainer vs. string mess... >_<
2017-05-29 18:50:45 +01:00
38b8f14758 Fixed wrong reported slot in PlayerItemHeldEvent, fixed assert failures due to negative slot numbers in the hotbar
fixes some issues reported in #525
2017-05-29 16:33:48 +01:00
8779259734 Stop spawning entities to players twice
This will be done when the chunk is sent to the player anyway.
2017-05-29 15:57:05 +01:00
2f306c3a38 Fix crash when new players join due to attempting to send negative inventory slot 2017-05-29 15:30:11 +01:00
57379b93ce Fixed a mistake in metadata decoder 2017-05-27 14:18:40 +01:00
954271b90f Found unknown fields for SetSpawnPositionPacket 2017-05-27 13:13:19 +01:00
645d744e05 Added a check for Phar extension 2017-05-26 21:39:43 +01:00
4c764072b2 Check the entity is actually inside a block before trying to shove it out, fix #271 2017-05-26 17:15:25 +01:00
3446f68c74 Workaround for PowerShell escape code issue after using git in the same window
I don't have any idea why the bug happens. Starting the server in a child PowerShell process resolves the issue.
2017-05-26 13:46:34 +01:00
ca6826898b Added API method Server->broadcastTitle() (#932) 2017-05-25 14:05:41 +01:00
76ab3d4288 This worked fine locally... 2017-05-24 14:50:33 +01:00
b6c1139b27 Fixed lint scan ignoring PHP_BINARY argument 2017-05-24 14:25:48 +01:00
af06d78725 Merge changes from master 2017-05-24 09:54:11 +01:00
8cc1003956 Fixed FloatingTextParticle 2017-05-24 07:37:11 +01:00
92281da514 Fix wrong comment in FallingSand
This is actually a bug in MCPE
2017-05-23 20:02:23 +01:00
5c8297f4a1 Fixed some logic issues with falling blocks, fix #897 #899 #935 2017-05-23 19:48:49 +01:00
23ed3334c2 added creative mode check for block picking 2017-05-23 16:26:29 +01:00
674394c4f5 Fixed undefined offset when retrieving something from the thread store that doesn't exist (#919) 2017-05-22 13:53:57 +08:00
4e381ab033 Added DATA_COLOR alias 2017-05-21 14:40:49 +01:00
c5527db424 Be more clear about ProtocolInfo being automatically generated and add notice to not bother submitting PRs for changing version numbers (#931) 2017-05-21 13:58:01 +01:00
aecff7c782 Revert "Improved handling of incompatible protocols"
This reverts commit 576702ffa9.

This crippled plugins which use data fromm LoginPacket :S
2017-05-21 13:27:27 +01:00
0207b22110 Fixed Mojang world converters barfing on PocketMine-MP generated McRegion worlds
blame @shoghicp
2017-05-21 12:44:42 +01:00
a77c1ce13c remove leftover 2017-05-20 12:24:10 +01:00
afd90adb1c Refactored JSON-parsing NBT utilities into their own class 2017-05-20 12:24:10 +01:00
2e480b5ea1 Fixed broken logic for recursive counts of ListTag 2017-05-20 12:24:10 +01:00
d4cc7d13cd Fixed setValue() being useless for CompoundTags and ListTags 2017-05-20 12:24:10 +01:00
f6c0ba9846 Cleaned up some duplicated code in NBT parser 2017-05-20 12:24:01 +01:00
f3c38700f5 Removed options for disabling assertion exceptions 2017-05-20 12:24:00 +01:00
77b1b565a4 Stop silently blocking people 2017-05-19 12:11:40 +01:00
36c95660e6 Fixed some logic issues with async compression 2017-05-19 11:30:23 +01:00
905d3f1610 Only save batch buffer when compressing chunks
faster due to not needing to serialize, and reduces memory footprint of caching
2017-05-18 19:46:20 +01:00
0f174f7605 Fixed ServerKiller always killing on shutdown on single-core machines, close #170 2017-05-18 15:58:09 +01:00
60f5c7ccef Async chunk compression and serialization is now non-optional 2017-05-18 12:19:27 +01:00
85c1535c75 Merge branch 'master' into mcpe-1.1 2017-05-18 11:29:52 +01:00
568e2760f1 Collect workers when cancelling all tasks 2017-05-17 19:30:50 +01:00
fe8cb8cd86 Server->batchPackets() now only accepts DataPacket objects, fixed players receiving double PlayerListPackets with their own data 2017-05-17 17:15:42 +01:00
15b47fcb2f Merge branch 'master' into mcpe-1.1 2017-05-17 15:52:01 +01:00
00e6d6a6b1 Fixed AsyncTask memory leak (#922)
* Added PocketMine-TesterPlugin submodule with regression test
2017-05-17 15:43:44 +01:00
8887a92d4b Removed useless break statements 2017-05-16 21:20:22 +01:00
a9afad10bc BinaryStream no longer extends stdClass, fixed a couple of minor bugs
Seems :shoghi: used stdClass to silence IDEs, which before ALPHA5 would complain about myriad undefined fields due to lack of type checking (switch based on packet id 🤦)
2017-05-15 19:28:39 +01:00
b41fef0276 Fixed some field types 2017-05-15 16:38:02 +01:00
fe3b5bac51 New fields for PlaySoundPacket and StopSoundPacket 2017-05-15 16:19:08 +01:00
0a4d62b405 Added encode and decode methods for more packets 2017-05-15 15:56:59 +01:00
0935855def Fix issue with colored message on some languages (#910) 2017-05-15 10:07:01 +01:00
c7c7a40899 Added "extensions" attribute in plugin.yml with version checking (#903)
* Added "extensions" attribute in plugin.yml with version checking

* Renamed getExtensions() to getRequiredExtensions()

As per recommendation from @dktapps
2017-05-15 10:04:26 +01:00
162a08b8cb Removed options for disabling assertion exceptions 2017-05-14 20:48:58 +01:00
b9ad0b99a5 Merge master into mcpe-1.1 2017-05-14 16:42:42 +01:00
576702ffa9 Improved handling of incompatible protocols
Allow plugins to hack around incompatible protocol numbers 🙈
2017-05-14 16:15:15 +01:00
dbb8e8ad0a Improved checks for event registration 2017-05-14 12:07:15 +01:00
4a9acf564c Silence PlayerFallPacket unhandled spam
we're not using this packet
2017-05-13 19:26:57 +01:00
69f64dd802 BossEventPacket
lots of stuff doesn't work (not implemented in MCPE, bug, or are we doing something wrong???)
2017-05-13 17:33:56 +01:00
11169b0777 add ifndef for BatchPacket 2017-05-13 14:57:48 +01:00
71af694cc1 Use getBool() more 2017-05-10 11:30:24 +01:00
c51c8ae700 Standardised attributes encoding 2017-05-10 10:48:53 +01:00
713f3facf9 Fixed stupid bug with Arrows 2017-05-09 21:09:34 +01:00
df577bddc2 Updated LevelSoundEventPacket constants (again) 2017-05-09 14:02:51 +01:00
046f17c9e2 Merge branch 'master' into mcpe-1.1 2017-05-08 17:43:09 +01:00
50f7d04044 Import cleanup 2017-05-07 16:55:10 +01:00
4ccd955647 Fixed possible memory leak with projectiles, use owner/target metadata 2017-05-07 16:50:32 +01:00
c383c7b0dd Found an unknown field in LevelSoundEventPacket 2017-05-05 18:34:52 +01:00
adbb53929e Fixed scaling issues with height and width on the client, close #819
Seems these metadata fields are actually the _base_ height/width. Setting the scale will cause the client to calculate bounding boxes with the scale already taken into account. This caused the scale to be applied twice on the client.
2017-05-05 16:51:15 +01:00
8a7259aa73 Merge #826: use getEffectLevel() instead of getAmplifier() + 1
Closes #412
2017-05-05 19:01:04 +08:00
76ceddf266 Reduced deltas for player movement, significantly smoother player movement and rotation (#883)
Send movement to viewers if the player moved more than 0.01 blocks in a tick or rotated more than 1 degree in any direction.
2017-05-05 11:23:06 +01:00
11f35d28c2 Call PlayerInteractEventm when receiving ItemFrameDropItemPacket to allow plugins to prevent item frame item removal (#887) 2017-05-05 11:18:58 +01:00
c4f461f65d Fixed fall damage in 1 block of water, close #470 2017-05-05 10:41:44 +01:00
702c129a97 Added basic support back for block-crack animations when breaking blocks
TODO: improve this to take stuff like swimming, ladders, enchanted tools into account, fix wrong tool break time calculations for bad tools (pmmp/PocketMine-MP#211)
2017-05-05 09:40:55 +01:00
56306f6636 Merge branch 'master' into mcpe-1.1 2017-05-04 21:15:49 +01:00
18f1376c65 Added handling for punch-block player action, added block punch particles 2017-05-04 21:11:47 +01:00
49eb0eb050 Fixed falling sand glitching on landing, minor logic improvements 2017-05-04 17:48:39 +01:00
13fd8b681e Added some sounds, fixed DestroyBlockParticle wrong particles for blocks with different meta values 2017-05-04 16:50:13 +01:00
40f2d7fcdc Updated LevelSoundEventPacket sound constants 2017-05-04 16:00:49 +01:00
c537cea87e Resolved issues with incorrect item and TNT position offsets, close #848 2017-05-04 13:52:10 +01:00
eaef2bd169 Fixed some inspections 2017-05-04 12:19:50 +01:00
966e4bf8a1 Added name field to crashdump data 2017-05-02 19:37:35 +01:00
f889bf9cf5 Fixed player list self-duplication 2017-05-02 12:28:27 +01:00
6d90f91be0 Fixed crashes while crashing related to plugins 2017-04-30 16:22:50 +01:00
0a52e210db Fixed crash when crashing while generating a crashdump due to crashing 2017-04-30 16:01:08 +01:00
971703a618 Dump object counts when dumping memory 2017-04-29 19:12:46 +01:00
de359a2bce Fixed a microscopic Command TimingsHandler memory leak
This reduces memory usage of an idling server by about 20kb. Definitely worth the time.
2017-04-29 18:03:45 +01:00
1266f8f1aa Fixed static properties not being dumped if an instance of the class was not referenced by Server 2017-04-29 12:25:00 +01:00
a22306d418 Fixed static property refcount bug 2017-04-28 18:43:36 +01:00
b542277eca Disable memory limit before performing a mem dump
Fix memory dumps not completing due to exhausting available memory
2017-04-28 16:53:05 +01:00
edf1fbb6e6 Removed a couple of useless null checks from PermissibleBase 2017-04-27 18:00:20 +01:00
653b6b55a9 Added title command and API for resetting title duration 2017-04-27 16:38:51 +01:00
7f09a2a26e Added Announcement type to TextPacket 2017-04-27 16:10:42 +01:00
7aeb3129ac Merge conflict resolution 2017-04-27 14:27:29 +01:00
dc71eb5246 Protocol updates for 1.1.0.9 2017-04-27 11:24:49 +01:00
bf9b8722c9 Cleaned up batching checks 2017-04-26 22:02:45 +01:00
4d897b824b Added more metadata properties, fixed some wrong values, fixed too many oxygen bubbles 2017-04-26 19:48:31 +01:00
caf4937222 Fixed arrow flight and spawning bugs, fixed critical trail, close #420 2017-04-26 18:55:48 +01:00
2f87dfdcb0 Merge branch 'master' into mcpe-1.1 2017-04-25 18:05:32 +01:00
ffcada88f3 New data flags 2017-04-25 16:27:29 +01:00
946d7e2bb1 Merge changes from master 2017-04-25 12:32:10 +01:00
7a2ed232cc Merge branch 'api3/network' into api3/network-mcpe-1.1 2017-04-24 13:56:19 +01:00
1be4bd67e4 Fixed assert failure when player join in un-generated areas of the world 2017-04-24 10:32:50 +01:00
fcff6961a8 Bump for 1.1.0.8 and removed LoginPacket zlib hack 2017-04-22 11:10:13 +01:00
db4027cdb2 New fields for MovePlayer and MoveEntity packets 2017-04-22 00:58:18 +01:00
e22bb213af Oops 2017-04-22 00:47:01 +01:00
179210aa27 Merge branch 'api3/network' into api3/network-mcpe-1.1 2017-04-21 22:50:14 +01:00
be631ad6f7 Fixed disconnects properly 2017-04-21 20:31:47 +01:00
3f1790bcb8 Found some missing data flags and proper fix for ladders 2017-04-20 19:42:00 +01:00
a0ba8f0098 Added some new metadata, fixed others, fixed TNT (again) 2017-04-20 17:52:24 +01:00
feb538900b Added a couple of entity metadata properties 2017-04-20 16:05:46 +01:00
5ce860c2f5 Updated AnimatePacket with extra float handling 2017-04-20 15:39:12 +01:00
6c5ca9b256 Protocol updates for 1.1.0.5 2017-04-20 13:54:55 +01:00
17e4f45e97 Fixed kicking players not working properly 2017-04-18 19:41:09 +01:00
6828ce66b6 Fixed farmland appearing black on clients (farmland is transparent in PE) 2017-04-18 19:40:54 +01:00
b7b7a93e4e Merge branch 'api3/network' into api3/network-mcpe-1.1 2017-04-18 14:52:06 +01:00
a34573643f Fixed transparent blocks filtering direct sky light 2017-04-18 14:14:19 +01:00
dab73d8950 Implemented sky light generation-time population and updating, obsolete and close #160 2017-04-18 13:05:01 +01:00
5e6a0e7ba0 More metadata changes, fixed TNT 2017-04-16 22:03:52 +01:00
c5eccc8e1c Minor improvements to Batch encoding 2017-04-15 19:40:06 +01:00
b55929b382 Merge branch 'api3/network' into api3/network-mcpe-1.1 2017-04-15 10:30:02 +01:00
d7378fe6f4 Some new metadata properties 2017-04-14 19:56:23 +01:00
66924729ff Fixed climbing blocks such as ladders and vines
Seems we can now climb ANY block if the climbing flag is true, and nothing if false. This commit adds local block checks to see if a climbable block exists at the entity's feet and if so, sets the flag.
2017-04-14 19:02:53 +01:00
f12a6eed29 Fixed vine block placement 2017-04-14 18:25:50 +01:00
a327a74ece Protocol changes for 1.1.0.3, fixed red sky, fixed crashes 2017-04-14 15:17:56 +01:00
f3ab45e7d5 Merged in 1.0.6 changes, added autogenerated data for 1.1.0.3 (doesn't work yet) and deliberately made the same merge error as Mojang 2017-04-14 13:00:43 +01:00
cdf6d200ef More protocol changes for 1.1, fixed resource packs 2017-04-14 12:48:50 +01:00
894beed59b Removed time stopping fields from SetTimePacket and fixed #526
TODO: rules
2017-04-11 20:13:37 +01:00
022f33b256 Fixed encoding of StartGamePacket, fixed world name not showing up in settings screen 2017-04-03 16:04:15 +01:00
90f1efc667 Found use of extra bytes in Item serialization
No idea why these are separate from the NBT data, but this is what they do.
2017-04-02 19:29:14 +01:00
f7e959d602 Fixed inventory crash, fixed crafting 2017-04-02 10:58:39 +01:00
9c25ec3afd Some protocol changes for 1.1.0.0 2017-04-01 19:20:30 +01:00
e47c7ea55f A bunch of really dirty hacks to get 1.1.0.0 working
Mojang: once again, what the hell have you done.
2017-04-01 19:18:15 +01:00
1144 changed files with 59309 additions and 54900 deletions

View File

@ -4,3 +4,7 @@ root = yes
[*]
indent_size = 4
indent_style = tab
[*.yml]
indent_size = 2
indent_style = space

1
.gitattributes vendored
View File

@ -6,6 +6,7 @@
*.properties text eol=lf
*.bat text eol=crlf
*.cmd text eol=crlf
*.ps1 text eol=crlf
# Custom for Visual Studio
*.cs diff=csharp

8
.github/FUNDING.yml vendored Normal file
View File

@ -0,0 +1,8 @@
# These are supported funding model platforms
github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
patreon: pocketminemp
open_collective: # Replace with a single Open Collective username
ko_fi: # Replace with a single Ko-fi username
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
custom: https://github.com/pmmp/PocketMine-MP#donate

View File

@ -1,30 +0,0 @@
### Issue description
<!--- use our forum https://forums.pmmp.io for questions -->
<!--- Any issues requesting updates to new versions of MCPE will be treated as spam. We do not need issues to tell us that there is a new version available. -->
<!---
Write a short description about the issue
If you are reporting a regression or unexpected behaviour, please include the below information:
Expected result: What were you expecting to happen?
Actual result: What actually happened?
-->
### Steps to reproduce the issue
<!--- help us find the problem by adding steps to reproduce the issue -->
1. ...
2. ...
### OS and versions
<!--- use the 'version' command in PocketMine-MP
NOTE: LATEST is not a valid version.
PocketMine version should include Jenkins build number and/or git commit hash.
ALSO NOTE: NO support whatsoever will be provided for forks or spoons of PocketMine. Issues relating to non-official distributions will be closed as spam. Please send such issues to whoever is responsible for the fork or spoon you are using.
-->
* PocketMine-MP:
* PHP:
* Server OS:
* Game version: PE/Win10 (delete as appropriate)
### Crashdump, backtrace or other files
<!--- please use gist or anything else and add links here -->
* ...

View File

@ -0,0 +1,19 @@
---
name: API change request
about: Suggest a change, addition or removal to the plugin API
title: ''
labels: ''
assignees: ''
---
<!--- tell us what you want -->
## Description
<!--- explain why you want this and why it's a good idea -->
## Justification
<!--- (optional) describe alternative methods you've explored to achieve your goal -->
## Alternative methods

36
.github/ISSUE_TEMPLATE/bug_report.md vendored Normal file
View File

@ -0,0 +1,36 @@
---
name: Bug report
about: Unexpected non-crash behaviour (except missing gameplay features)
title: ''
labels: ''
assignees: ''
---
### Issue description
- Expected result: What were you expecting to happen?
- Actual result: What actually happened?
### Steps to reproduce the issue
1. ...
2. ...
### OS and versions
<!-- try the `version` command | LATEST IS NOT A VALID VERSION -->
* PocketMine-MP:
* PHP:
* Server OS:
* Game version: PE/Win10 (delete as appropriate)
### Plugins
<!--- use the `plugins` command and paste the output below -->
- If you remove all plugins, does the issue still occur?
- If the issue is **not** reproducible without plugins:
- Have you asked for help on our forums before creating an issue?
- Can you provide sample, *minimal* reproducing code for the issue? If so, paste it in the bottom section
### Crashdump, backtrace or other files
<!--- Submit crashdumps at https://crash.pmmp.io and paste a link -->
<!--- Use gist or anything else to add other files and add links here -->

15
.github/ISSUE_TEMPLATE/crash.md vendored Normal file
View File

@ -0,0 +1,15 @@
---
name: Crash
about: Report a crash in PocketMine-MP (not plugins)
title: Server crashed
labels: ''
assignees: ''
---
<!--- submit crashdump files to https://crash.pmmp.io -->
<!--- or, copy the data between ===BEGIN CRASH DUMP=== and ===END CRASH DUMP and paste it on a site like https://pastebin.com -->
Link to crashdump:
<!--- write additional information about the crash to help us find the problem -->
### Additional comments (optional)

View File

@ -0,0 +1,14 @@
---
name: Help & support
about: We don't accept support requests here. Try the links on the README.
title: ''
labels: Support request
assignees: ''
---
We don't accept support requests on the issue tracker. Please try the following links instead:
Documentation: http://pmmp.rtfd.io
Forums: https://forums.pmmp.io
Discord: https://discord.gg/bmSAZBG

View File

@ -0,0 +1,12 @@
---
name: Security/DoS vulnerability
about: 'Bug or exploit that can be used to attack servers (hint: don''t report it
on a public issue tracker)'
title: ''
labels: 'Auto: Spam'
assignees: ''
---
Please DO NOT report security vulnerabilities here.
Instead, send an email to team@pmmp.io or contact a developer directly, IN PRIVATE.

View File

@ -33,4 +33,8 @@ Requires translations:
-->
## Tests
<!-- Attach scripts or actions to test this pull request, as well as the result -->
<!--
Details should be provided of tests done. Simply saying "tested" or equivalent is not acceptable.
Attach scripts or actions to test this pull request, as well as the result
-->

16
.github/support.yml vendored Normal file
View File

@ -0,0 +1,16 @@
# Configuration for support-requests - https://github.com/dessant/support-requests
# Label used to mark issues as support requests
supportLabel: "Support request"
# Comment to post on issues marked as support requests. Add a link
# to a support page, or set to `false` to disable
supportComment: >
Thanks, but this issue tracker is not intended for support requests. Please read the guidelines on [submitting an issue](https://github.com/pmmp/PocketMine-MP/blob/master/CONTRIBUTING.md#creating-an-issue).
[Docs](https://pmmp.rtfd.io) | [Discord](https://discord.gg/bmSAZBG) | [Forums](https://forums.pmmp.io)
# Whether to close issues marked as support requests
close: true
# Whether to lock issues marked as support requests
lock: false

17
.gitignore vendored
View File

@ -1,15 +1,19 @@
players/*
worlds/*
plugin_data/*
plugins/*
bin/*
bin*/*
timings/*
crashdumps/*
*.log
*.txt
*.phar
server.properties
/pocketmine.yml
memoryDump_*/*
memory_dumps/*
resource_packs/
server.lock
/phpstan.neon
# Common IDEs
.idea/
@ -28,3 +32,12 @@ Desktop.ini
# Sphinx-doc
/docs/build/
!/docs/requirements.txt
# Composer
vendor/*
# Travis files
test_data/*
# Doxygen
Documentation/*

15
.gitmodules vendored
View File

@ -1,16 +1,15 @@
[submodule "src/raklib"]
path = src/raklib
url = https://github.com/pmmp/RakLib.git
branch = master
[submodule "src/spl"]
path = src/spl
url = https://github.com/pmmp/PocketMine-SPL.git
[submodule "src/pocketmine/lang/locale"]
path = src/pocketmine/lang/locale
url = https://github.com/pmmp/PocketMine-Language.git
[submodule "tests/preprocessor"]
path = tests/preprocessor
path = build/preprocessor
url = https://github.com/pmmp/preprocessor.git
[submodule "tests/plugins/PocketMine-DevTools"]
path = tests/plugins/PocketMine-DevTools
url = https://github.com/pmmp/PocketMine-DevTools.git
[submodule "src/pocketmine/resources/vanilla"]
path = src/pocketmine/resources/vanilla
url = https://github.com/pmmp/BedrockData.git
[submodule "build/php"]
path = build/php
url = https://github.com/pmmp/php-build-scripts.git

View File

@ -1,15 +1,25 @@
language: php
php:
- 7.0
- 7.2
- 7.3
before_script:
- pecl install channel://pecl.php.net/pthreads-3.1.6
- pecl install channel://pecl.php.net/weakref-0.3.3
- echo | pecl install channel://pecl.php.net/yaml-2.0.0
# - pecl install channel://pecl.php.net/pthreads-3.1.6
- echo | pecl install channel://pecl.php.net/yaml-2.0.4
- git clone https://github.com/pmmp/pthreads.git
- cd pthreads
- git checkout 1b7da492b944146fa9680f6399bd9c6c6c6095e0
- phpize
- ./configure
- make
- make install
- cd ..
- echo "extension=pthreads.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini
- composer install
script:
- ./tests/travis.sh
- ./tests/travis.sh -t4
notifications:
email: false

View File

@ -5,56 +5,48 @@
## Creating an Issue
- If you are reporting a bug:
- **make sure that you are using the latest supported version** before opening an issue.
- **test it on a clean test server, WITHOUT PLUGINS**, to see if the issue still occurs. If not then it may be a plugin issue. Please also indicate the result of such tests.
- [Search the issue tracker](https://github.com/pmmp/PocketMine-MP/issues?utf8=%E2%9C%93&q=is%3Aissue) to check if anyone has already reported it, to avoid needlessly creating duplicate issues. Make sure you also check closed issues, as an issue you think is valid may already have been resolved.
- If your issue is related to a plugin, **do not report here, contact the plugin's original author** instead.
- **make sure that you are using the latest supported version** before opening an issue.
- **test it on a clean test server, WITHOUT PLUGINS**, to see if the issue still occurs. If not then it may be a plugin issue. Please also indicate the result of such tests.
- **[Search the issue tracker](https://github.com/pmmp/PocketMine-MP/issues?utf8=%E2%9C%93&q=is%3Aissue)** to check if anyone has already reported it, to avoid needlessly creating duplicate issues. Make sure you also check closed issues, as an issue you think is valid may already have been resolved.
- **Do not report plugin issues here.** If your issue is related to a plugin, contact the plugin's original author instead.
- **Support requests are not bugs.** Issues such as "How do I do this" are not bugs and will be closed. If you need help, please see [here](README.md#discussion) and do not misuse our issue tracker.
- **No generic titles** such as "Question", "Help", "Crash Report" etc. A good issue report provides a quick summary in the title. If you just got a crash report but you don't understand it, please look for a line starting with `Message`. It summarizes the bug.
- Information must be provided in the issue body, not in the title. No tags like `[BUG]` are allowed in the title, including `[SOLVED]` for solved issues.
- Similarly, no generic issue reports. For bugs, it is the issue author's responsibility to provide us an issue that is **trackable, debuggable, reproducible, reported professionally and is an actual bug**. If you do not provide us with a summary or instructions on how to reproduce the issue, it will be treated as spam and will therefore be closed.
<br>In simple words, if your issue does not appear to be a bug or a feature request, or if the issue cannot be properly confirmed to be valid, the issue will be closed until further information is provided.
- **Provide information in the issue body, not in the title.** No tags like `[BUG]` are allowed in the title, including `[SOLVED]` for solved issues.
- **No generic issue reports.** For bugs, it is the issue author's responsibility to provide us an issue that is **trackable, debuggable, reproducible, reported professionally and is an actual bug**.
<br>Valid issue reports must include instructions how to reproduce the issue or a crashdump/backtrace (unless the cause of the issue is obvious).
<br>**If you do not provide us with a summary or instructions on how to reproduce the issue, it will be treated as spam and will therefore be closed.**
<br>In simple words, if the issue cannot be properly confirmed to be valid or lacks required information, the issue will be closed until further information is provided.
- To express appreciation, objection, confusion or other supported reactions on pull requests, issues or comments on them, use GitHub [reactions](https://github.com/blog/2119-add-reactions-to-pull-requests-issues-and-comments) rather than posting an individual comment with an emoji only. This helps keeping the issue/pull request conversation clean and readable.
- If your issue is related to the PocketMine-MP website, forums, etc., please [talk to a human directly](README.md#discussion).
## Contributing Code
- To contribute code to the repository, [fork it on GitHub](https://github.com/pmmp/PocketMine-MP/fork), create a branch on your fork, and make your changes on your fork. You can then make a [pull request](https://github.com/pmmp/PocketMine-MP/pull/new) to the project to compare your branch to ours and propose your changes to our repository. We use the Pull Request system to allow members of the team to review changes before they are merged.
## Contributing
To contribute to the repository, [fork it on GitHub](https://github.com/pmmp/PocketMine-MP/fork), create a branch on your fork, and make your changes on your fork. You can then make a [pull request](https://github.com/pmmp/PocketMine-MP/pull/new) to the project to compare your branch to ours and propose your changes to our repository. We use the Pull Request system to allow members of the team to review changes before they are merged.
- By proposing a pull request to the project, you agree to your code being distributed within PocketMine-MP under the [LGPL license](LICENSE).
### Licensing
By proposing a pull request to the project, you agree to your code being distributed within PocketMine-MP under the [LGPL license](LICENSE).
- At PocketMine, **we enforce a very high standard for contributions**. This is because PocketMine-MP and its related projects are used very widely in production. While this might seem like we are being mean at times, **our priority is what is best for PocketMine-MP itself**. We try to ensure that our project's codebase is as clean as possible and ensure that only top-quality material makes it through to PocketMine-MP itself. **If a contribution does not live up to our standards, changes may be requested or the pull request may be closed.**
- **Your pull request will be checked and discussed in due time.** Since the team is scattered all around the world, your PR may not receive any attention for some time.
- **Avoid using GitHub Web Editor**. The web editor lacks most useful GIT features and **should only be used for very minor changes**. It is immediately clear if the web editor has been used, and if so the PR is more likely to be rejected. If you want to make serious contributions, **please learn how to use [GIT version control](https://git-scm.com/)**.
- **Do not copy-paste code**. There are potential license issues implicit with copy-pasting, and copy-paste usually indicates a lack of understanding of the actual code. Copy-pasted code is obvious a mile off and **any PR like this is likely to be closed**. If you want to use somebody else's code from a Git repository, **use [GIT's cherry-pick feature](https://git-scm.com/docs/git-cherry-pick)** to cherry-pick the commit. **Cherry-picking is the politer way to copy somebody's changes** and retains all the original accreditation, so there is no need for copy-pasted commits with descriptions like `Some code, thanks @exampleperson`.
- In addition to the above, **make sure you can explain your changes**. If you can't provide a good explanation of changes, your PR may be rejected.
### Contribution standards
- **We enforce a very high standard for contributions**. This is because PocketMine-MP and its related projects are used very widely in production. While this might seem like we are being mean at times, **our priority is what is best for PocketMine-MP itself**.
We try to ensure that our project's codebase is as clean as possible and ensure that only top-quality material makes it through to PocketMine-MP itself.
- **If a contribution does not meet our standards, changes may be requested or the pull request may be closed.**
### Pull requests
- **Create a new branch for each pull request.** Do not create a pull request with commits that exist in another pull request.
- **Code should use the same style as in PocketMine-MP.** See [below](#code-syntax) for an example.
- **The code must be clear** and written in English, comments included.
- **Use descriptive commit titles.** You can see an example [here](http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html).
- **Try to stick to one change per commit.** This ensures that if you create a PR with several changes, we can decide which ones we wish to include and which ones not to include.
- **It is inadvisable to create pull requests with large commits** unless this has been discussed with the team beforehand. Large pull requests are difficult to review, and such pull requests may end up being closed. The only exception is when all features in the pull request are related to each other, and share the same core changes.
- **Do not include multiple unrelated changes in one commit.** An atomic style for commits is preferred - this means that changes included in a commit should be part of a single distinct change set. See [this link](https://www.freshconsulting.com/atomic-commits/) for more information on atomic commits. See the [documentation on `git add`](https://git-scm.com/docs/git-add) for information on how to isolate local changes for committing.
- **Your pull request will be checked and discussed in due time.** Since the team is scattered all around the world, your PR may not receive any attention for some time.
- **It is inadvisable to create large pull requests with lots of changes** unless this has been discussed with the team beforehand. Large pull requests are difficult to review, and such pull requests may end up being closed. The only exception is when all features in the pull request are related to each other, and share the same core changes.
- **You may be asked to rebase your pull request** if the branch becomes outdated and/or if possibly conflicting changes are made to the target branch. To see how to do this, read [this page](https://github.com/edx/edx-platform/wiki/How-to-Rebase-a-Pull-Request).
- **Details should be provided of tests done.** Simply saying "Tested" or equivalent is not acceptable.
### Code contributions
- **Avoid committing changes directly on GitHub. This includes use of the web editor, and also uploading files.** The web editor lacks most useful GIT features and **should only be used for very minor changes**. It is immediately clear if the web editor has been used, and if so the PR is more likely to be rejected. If you want to make serious contributions, **please learn how to use [GIT version control](https://git-scm.com/)**.
- **Do not copy-paste code**. There are potential license issues implicit with copy-pasting, and copy-paste usually indicates a lack of understanding of the actual code. Copy-pasted code is obvious a mile off and **any PR like this is likely to be closed**. If you want to use somebody else's code from a Git repository, **use [GIT's cherry-pick feature](https://git-scm.com/docs/git-cherry-pick)** to cherry-pick the commit. **Cherry-picking is the politer way to copy somebody's changes** and retains all the original accreditation, so there is no need for copy-pasted commits with descriptions like `Some code, thanks @exampleperson`.
- **Make sure you can explain your changes**. If you can't provide a good explanation of changes, your PR may be rejected.
- **Code should use the same style as in PocketMine-MP.** See [below](#code-syntax) for an example.
- **The code must be clear** and written in English, comments included.
**Thanks for contributing to PocketMine-MP!**
@ -76,17 +68,18 @@ It is mainly [PSR-2](https://github.com/php-fig/fig-standards/blob/master/accept
- Strings SHOULD use the double quote `"` except when the single quote is required.
- All code SHOULD have parameter and type declarations where possible.
- Strict types SHOULD be enabled on new files where it is sensible to do so.
- All constant declarations SHOULD be preceded by a visibility modifier.
```php
<?php
declare(strict_types = 1);
declare(strict_types=1);
namespace pocketmine\example;
class ExampleClass{
const EXAMPLE_CLASS_CONSTANT = 1;
public const EXAMPLE_CLASS_CONSTANT = 1;
public $examplePublicVariable = "defaultValue";
private $examplePrivateVariable;
@ -97,7 +90,7 @@ class ExampleClass{
* @param string $firstArgument the first argument
* @param string|null $secondArgument default null
*/
public function __construct(string $firstArgument, &$secondArgument = null){
public function __construct(string $firstArgument, ?string &$secondArgument = null){
if($firstArgument === "exampleValue"){ //Remember to use === instead of == when possible
//do things
}elseif($firstArgument === "otherValue"){
@ -117,7 +110,6 @@ class ExampleClass{
public function doStuff(string $stuff) : string{
return $stuff;
}
}
```
@ -131,4 +123,4 @@ class ExampleClass{
* After voting has been closed, no further votes will be counted.
* An RFC will be rejected if less than 50% + 1 (simple majority) has voted Yes.
* If the RFC is approved, Team Members have the final word on its implementation or rejection.
* RFCs with complex voting options will specify the vote percentage or other details.
* RFCs with complex voting options will specify the vote percentage or other details.

View File

@ -1,55 +1,34 @@
# [![PocketMine-MP](http://cdn.pocketmine.net/img/PocketMine-MP-h.png)](https://pmmp.io)
__A highly customisable, open source server software for Minecraft: Pocket Edition written in PHP__
<p align="center">
<a href="https://pmmp.io"><img src="http://cdn.pocketmine.net/img/PocketMine-MP-h.png"></img></a><br>
<b>A highly customisable, open source server software for Minecraft: Bedrock Edition written in PHP</b>
</p>
[![Build Status](https://travis-ci.org/pmmp/PocketMine-MP.svg?branch=master)](https://travis-ci.org/pmmp/PocketMine-MP)
### Setup, help & support, FAQs
Head over to the [documentation site](http://pmmp.readthedocs.org/).
If you don't find what you're looking for there, [talk to a human](#discussion). Please do not use our issue tracker for support requests.
## Getting started
- [Documentation](http://pmmp.readthedocs.org/)
- [Installation instructions](https://pmmp.readthedocs.io/en/rtfd/installation.html)
- [Docker image](https://hub.docker.com/r/pmmp/pocketmine-mp)
- [Plugin repository](https://poggit.pmmp.io/plugins)
### Discussion
## Discussion/Help
- [Forums](https://forums.pmmp.io/)
- [#pmmp + #pocketmine channel IRC](http://webchat.freenode.net/?channels=pmmp,pocketmine)
- [Community Discord](https://discord.gg/bmSAZBG)
- [StackOverflow](https://stackoverflow.com/tags/pocketmine)
### Plugins
There are a very wide range of already-written plugins available which you can use to customise your server. Check out [the old plugin repository](http://plugins.pocketmine.net/) and [Poggit](https://poggit.pmmp.io), or just search GitHub.
### For developers
## For developers
* [Latest API documentation](https://jenkins.pmmp.io/job/PocketMine-MP-doc/doxygen/) - Doxygen documentation generated from development
* [DevTools](https://github.com/pmmp/PocketMine-DevTools/) - A development tools plugin for creating plugins.
* [DevTools](https://github.com/pmmp/PocketMine-DevTools/) - Development tools plugin for creating plugins
* [ExamplePlugin](https://github.com/pmmp/ExamplePlugin/) - Example plugin demonstrating some basic API features
* [Contributing Guidelines](CONTRIBUTING.md)
### Can I contribute?
Yes you can! Contributions are welcomed provided that they comply with our [Contributing Guidelines](CONTRIBUTING.md). Please ensure you read the relevant sections of the guidelines carefully before making a Pull Request or opening an Issue.
### Where can I get the latest .phar?
Head over to our [official Jenkins server](https://jenkins.pmmp.io/)
## Third-party Libraries/Protocols Used
* __[PHP Sockets](http://php.net/manual/en/book.sockets.php)__
* __[PHP mbstring](http://php.net/manual/en/book.mbstring.php)__
* __[PHP BCMath](http://php.net/manual/en/book.bc.php)__
* __[PHP pthreads](http://pthreads.org/)__ by _[krakjoe](https://github.com/krakjoe)_: Threading for PHP - Share Nothing, Do Everything.
* __[PHP YAML](https://code.google.com/p/php-yaml/)__ by _Bryan Davis_: The Yaml PHP Extension provides a wrapper to the LibYAML library.
* __[LibYAML](http://pyyaml.org/wiki/LibYAML)__ by _Kirill Simonov_: A YAML 1.1 parser and emitter written in C.
* __[cURL](http://curl.haxx.se/)__: cURL is a command line tool for transferring data with URL syntax
* __[Zlib](http://www.zlib.net/)__: A Massively Spiffy Yet Delicately Unobtrusive Compression Library
* __[Source RCON Protocol](https://developer.valvesoftware.com/wiki/Source_RCON_Protocol)__
* __[UT3 Query Protocol](http://wiki.unrealadmin.org/UT3_query_protocol)__
## Donate
- Bitcoin Cash (BCH): `qq3r46hn6ljnhnqnfwxt5pg3g447eq9jhvw5ddfear`
- Bitcoin (BTC): `171u8K9e4FtU6j3e5sqNoxKUgEw9qWQdRV`
- Stellar Lumens (XLM): `GAAC5WZ33HCTE3BFJFZJXONMEIBNHFLBXM2HJVAZHXXPYA3HP5XPPS7T`
- [Patreon](https://www.patreon.com/pocketminemp)
## Licensing information
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
This project is licensed under LGPL-3.0. Please see the [LICENSE](/LICENSE) file for details.
pmmp/PocketMine are not affiliated with Mojang. All brands and trademarks belong to their respective owners. PocketMine-MP is not a Mojang-approved software, nor is it associated with Mojang.

81
build/make-release.php Normal file
View File

@ -0,0 +1,81 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\build_script;
use pocketmine\utils\VersionString;
use function dirname;
use function fgets;
use function file_get_contents;
use function file_put_contents;
use function preg_quote;
use function preg_replace;
use function sleep;
use function sprintf;
use function system;
use const pocketmine\BASE_VERSION;
use const STDIN;
require_once dirname(__DIR__) . '/src/pocketmine/VersionInfo.php';
require_once dirname(__DIR__) . '/vendor/autoload.php';
if(isset($argv[1])){
$currentVer = new VersionString($argv[1]);
}else{
$currentVer = new VersionString(BASE_VERSION);
}
$nextVer = new VersionString(sprintf(
"%u.%u.%u",
$currentVer->getMajor(),
$currentVer->getMinor(),
$currentVer->getPatch() + 1
));
function replaceVersion(string $versionInfoPath, string $newVersion, bool $isDev) : void{
$versionInfo = file_get_contents($versionInfoPath);
$versionInfo = preg_replace(
$pattern = '/^const BASE_VERSION = "(\d+)\.(\d+)\.(\d+)(?:-(.*))?";$/m',
'const BASE_VERSION = "' . $newVersion . '";',
$versionInfo
);
$versionInfo = preg_replace(
'/^const IS_DEVELOPMENT_BUILD = (?:true|false);$/m',
'const IS_DEVELOPMENT_BUILD = ' . ($isDev ? 'true' : 'false'). ';',
$versionInfo
);
file_put_contents($versionInfoPath, $versionInfo);
}
$versionInfoPath = dirname(__DIR__) . '/src/pocketmine/VersionInfo.php';
replaceVersion($versionInfoPath, $currentVer->getBaseVersion(), false);
echo "please add appropriate notes to the changelog and press enter...";
fgets(STDIN);
system('git add "' . dirname(__DIR__) . '/changelogs"');
system('git commit -m "Release ' . $currentVer->getBaseVersion() . '" --include "' . $versionInfoPath . '"');
system('git tag ' . $currentVer->getBaseVersion());
replaceVersion($versionInfoPath, $nextVer->getBaseVersion(), true);
system('git add "' . $versionInfoPath . '"');
system('git commit -m "' . $nextVer->getBaseVersion() . ' is next" --include "' . $versionInfoPath . '"');
echo "pushing changes in 5 seconds\n";
sleep(5);
system('git push origin HEAD ' . $currentVer->getBaseVersion());

1
build/php Submodule

Submodule build/php added at 8308571448

1
build/preprocessor Submodule

Submodule build/preprocessor added at b01f50c50e

182
changelogs/1.3.md Normal file
View File

@ -0,0 +1,182 @@
# 1.3.3
- Minecraft: Pocket Edition alpha 0.7.2 compatible!
- Unicode support
- Fixed /difficulty command
- Fixed a few flying kicks
- Fixed async. operations thread
- Added whitelist enabled property to Query
# 1.3.4
**This is a compatibility update for Minecraft: Pocket Edition v0.7.3 alpha.**
Double chests do not work yet, we will fix more bugs and add them when MCPE 0.7.4 is released. There were too many bugs in 0.7.3 to test double chests properly.
#### Including in this release:
- Fixed armor crash
- Fixed ghost armor
- Fixed packets being received after player disconnection
- Fixed player count bug
- Added compatibility with encrypted login
- Fixed flying check on fences
- Fixed players connecting with empty usernames
- Fixed several crashes related to Items
- Added temporal water flowing. Really buggy
- Automatic recovery of index-corrupted maps
- Fixed hotbar reset when changing armor
- Fixed some hotbar reset bugs on block placement
- Added basic tool durability and breaking
- Chests now have opening/closing animation.
- Fixed /difficulty
- In-game player list is now handled correctly
- Player entities are saved in all worlds to remove join/leave spam
- Quartz slabs
# 1.3.5
#### Including in this release:
- Fixed block durability (blocks being replaced)
- Added armor replacing (changing the armor while you have other)
- Added proper Player object cleanups as a fix to a memory leak
# 1.3.7
**This update is compatible with Minecraft: Pocket Edition v0.7.4 alpha.** Older versions won't work.
In Minecraft: PE 0.7.4 you can add External servers directly. [How to add servers](https://github.com/PocketMine/PocketMine-MP/wiki/How-to-add-servers)
![](http://i.imgur.com/ltBJgmUl.png)
### Changelog
- **Updated for 0.7.4 alpha**
- **New API version 10**
- Adds Tile methods
- Changes message events to use new Minecraft protocol
- Added Level::getSafeSpawn()
- Linux now uses PHP 5.5.3
- Removed water updating
- Fixes for Player teleporting
- Removed invalid Cookie and fish items
- Fixed Stone brick and quartz slab recipes
- Shears now are used to drop leaves
- Fixed a crash on Windows XP
- Cake is removed when the bottom block is broken
- Added new NBT parser/writer
- Fixed chests and furnaces drops when broken.
- Fixed signs not spawning on world load
- Fixed actions not being deleted (memory leak)
- Chests now are spawned correctly
- Double chests
- Added random x,z offset to item drops
# 1.3.8
This release consists of a few bugfixes and several features added. It is compatible with MCPE 0.7.4 and 0.7.5
**Changelog:**
- No API changes
- Fixed x,y,z indexes when opening a Furnace
- Fixed invalid fix for CPU usage limiter on idle
- Fixed cross-compiling
- Fixed some Stonecutter recipes
- Fixed a few items stack sizes
- Fixed TimeAPI bugs
- Forces position on teleport, blocks fast teleport mods
- Fixed some blocks havin a send lag on place/break
- Fixed Sign Posts not deleting the Tile data when broken by update
- Fixed Ice converting to Water on creative mode
- Added beds
- Added scheduled teleport on spawn to fix spawning underground
- Added date to console logs
# 1.3.9
This release is compatible with MCPE 0.7.4 and 0.7.5.
**Changelog:**
- Fixed server crash related to beds
- Player movement is less laggy
- Added new text formatting system for future updates
- New Terminal Emulator for Windows
- More colors! Less warnings!
# 1.3.10
**Changelog:**
- Added door sounds
- Fixed bed sleeping position offset
- Added explosions
- Flint & Steel on Creative Mode (replaces Eggs)
- Changed the Sword and Hoe to the diamond tier on the Creative inventory
- Fixed colors on MacOS
- Water flow
- Fixed Windows console input not being accepted when using special keys
- Added a way to disable console colors
- Updated PHP to 5.5.6, pthreads to 0.0.55, and cURL
- Armor drops
- Fixed plugin issues
- Fixed some block drops
- Fixed a crash when @all is used in console, and only usable for OPs
- Fixed some issues regarding teleporting
- deop no longer op the player again
# 1.3.11
And here it comes the stable release for **MCPE v0.8.1 alpha**. We decided to remove the improved networking that was delaying this release, but you should see it in the next one. Minecarts couldn't be added for the same reason as mobs, but we will try to implement "fake" minecarts that behave correctly inside rails, but not outside of them.
Starting with this release, all PocketMine-MP versions will be given a codename. This one received the codename 「甘いビートルート」_(Amai Beetroot)_.
**Changelog:**
- Fixed existing Packets of Death
- Fixed lots of bugs related to crafting
- Fixed block placement bugs
- Redstone ore drops redstone dust
- Sideway logs
- Sponges
- Added new wooden planks & stairs
- Added iron bars, cobblestone walls and pumpkins
- Added carpets, hay bales and coal blocks
- Added potatoes, carrots and beetroots
- Additional tall grass drops
- Achievements
- Added multiple orders for _/gamemode_ command
- Chat plugins can work with each other #975
- Fixed internal world chunks bug
- Private messages are now hidden on console except when the console is the target/origin
- PHP plugins are now loaded with include()
- Fixed plugin paths
- Added source SHA1 sum to crash reports
- Added Level::startTime() and Level::stopTime()
- Fixed server not being able to start on several OS when offline
- More small fixes and small additions
For more information, check the [complete changelog](https://github.com/PocketMine/PocketMine-MP/compare/Alpha_1.3.10...Alpha_1.3.11).
# 1.3.12
Before starting to rewrite even more parts of the code, we are releasing the last version of the Alpha_1.3.x Amai Beetroot「甘いビートルート」. Next one will be Alpha_1.4 with more rewrite!
We have included the new Event API that will be used on the next release, but now it is only used to hook on packets.
**API Changelog:**
- **Full network rewrite.** Plugins can work with packets easily now.
- **New Event API,** only implemented for packets right now.
- Added player.block.place.bypass and player.block.break.bypass
- Level included in data for event item.drop
- Added Utils::getUniqueID()
- **Added default support in PHP binaries for MySQLi**
- Removed Spyc
- Call Plugin::__destruct() on PluginAPI::__destruct()
- Added more OS detection on Utils::getOS()
**Changelog:**
- New set-up wizard in multiple languages. Help translate it to more languages on http://translate.pocketmine.net/
- Updated pthreads and PHP binaries
- New font for MinTTY console on Windows
- Send partial hotbar history
- Fixed Tile saving indexes
- Fixed a few teleport bugs
- Improved crash dumps
- Increased apple health restore
- Fixed players being invincible after death
- Fixed Level::unloadChunk() not using saveEnabled
- Show player name on bad username kick
- Fixed item duplication on void #1100
- OPs can bypass the player limit
- Fixed item replacing on furnace #1114
- Fixed multiple small bugs #1058 #1032 #854 #823 #1135 #1150 #1172 #1173 #486 #466 #483
- Fixed PHP compilation on 64-bit linux #519 #861 #940 #505 #590 #761 #129
- Included OPCache to optimize opcodes
If you are on Linux, you can use `wget -q -O - http://cdn.pocketmine.net/installer.sh | bash -s - -v Alpha_1.3.12` to update. If you are on a MacOS, use `curl -sL http://cdn.pocketmine.net/installer.sh | bash -s - -v Alpha_1.3.12`

1278
changelogs/1.4.md Normal file

File diff suppressed because it is too large Load Diff

72
changelogs/1.6.md Normal file
View File

@ -0,0 +1,72 @@
# 1.6.1dev-87
**For Minecraft PE 0.16.0.5 alpha**
**THIS IS A PRE RELEASE. Do not use it in production unless you are sure you know what you are doing.**
Only changes since the 1.6dev tag will be documented here. Changes between 1.4.1 and 1.6dev are far too extensive to document effectively.
## Core
- New RNG, based on XorShift128 from the php-random library. This fixes issue with repeating terrain on 32-bit systems. _Note however that new generation into existing worlds will not be seamless._
- Block and Item IDs have been moved to interfaces for better consistency
- Better method for synchronisation of client/server time (less packet spam)
- Utils::getRandomBytes() has been deprecated in favour of php7's random_bytes() function.
- `<player>.dat` saving/reading can now be disabled in `pocketmine.yml` (set `player.save-player-data` to `false`)
## Gameplay/game features
- Added Flower Pots
- Containers can now be opened in creative
- Trapdoors can now be placed without a supporting block
## API
This release has API changes, bumping the version to 2.1.0.
### Entity metadata (0.16)
Many changes have been made to entity metadata. Many true/false data properties are now entity status flags, such as NoAI, NametagVisible and various others. Entity status flags can be set using:
`$entity->setDataFlag(Entity::DATA_FLAGS, Entity::INSERT_DATA_FLAG_NAME, true/false);`
**Breaking** changes are detailed here. Additions are not documented. https://gist.github.com/dktapps/76b291b7a861762b54f7a8b834389883
**NOTE: It's strongly recommended to use provided API methods where possible instead of tampering with metadata directly.**
### AsyncTask API additions
- Main thread local storage: Developers can pass any data including objects to the constructor of AsyncTask such that the data can be retrieved after the AsyncTask completes using the new `AsyncTask::fetchLocal()` method, or use the `AsyncTask::peekLocal()` method to get the data without removing it.
- Progress updates: Developers can use the new `AsyncTask::publishProgress() method and override`AsyncTask::onProgressUpdated()` to handle AsyncTask progress information in the main thread.
Refer to #1 and #100 for details.
### WeakPosition
WeakPosition was added in 1.6.1 to fix bugs with unloading levels which have player spawn points set in them. This type of position holds a level ID instead of a direct reference. Use this when your position may outlive the level it is in.
### Removal of Item/NBT circular dependency
Refer to #121 for details.
### Other
- Added Player->sendWhisper() (#73).
- Removed LargeExplodeParticle due to incorrect name - use HugeExplodeParticle. Added HugeExplodeSeedParticle and BlockForceFieldParticle (7314aaf7f7bdae582f674c085c7ae879985bf847)
## Fixes
- Fixed the infamous hotbar spaz bug
- Creative/spectator inventory now sends correctly
- Fixed spectator flight controls
- Fixed issues with items going past the end of the regular inventory
- Fixed furnace client crashes
- Fixed inventory windows for anvils and enchanting tables
- Fixed kicked for walking on lily pads (#blameshoghicp)
- Fixed a nasty entity-related memory leak on chunk unload
- Fixed sleeping players floating above beds and teleportation of sleeping players.
- Fixed a bug in Level::updateAround() where only one block would update
- Fixed some slab placement issues (#31)
- Fixed crash loading 1.11 worlds (#32)
- Fixed broken `--disable-readline` command-line option (#34)
- Fixed world unload crash when players have spawnpoints set in that world (#24)
- Fixed start.sh detection of system PHP binaries (#66)
- Fixed anvil rotation when placed and variant drops (d696049a0ad5e3b878a8f902e4ef75f19ec8cecc)
- /timings command is now more verbose about paste errors (#95)
- Fixed server crash at shutdown when RCON is enabled (#101)
- Fixed server name is always "Minecraft: PE Server" when running setup wizard (92bd1a755d4b171b687538db83893b9bd9c70420)
- Fixed CraftItemEvent->getInput() does not return used items (7eb9530346e953d1555623ff871086f85447b6c6)
- Fixed useless ServerKiller (#122)

1155
changelogs/3.0-alpha.md Normal file

File diff suppressed because it is too large Load Diff

264
changelogs/3.0.md Normal file
View File

@ -0,0 +1,264 @@
**For Minecraft: Bedrock Edition 1.4.0**
Plugin scheduler rewrite, RCON rewrite, performance improvements, improved idle memory usage
**While this release is nominally not an alpha, it is still not feature complete and does not include all gameplay features. Please do not create issues for missing gameplay features.**
This build has breaking API changes.
This release is the first to use the new merged versioning system. The PocketMine-MP version and the API version are now one and the same.
Please use our issue tracker to report bugs.
# 3.0.0
## Core
### General
- This release introduces a new dependency library called `Snooze`, which PocketMine-MP utilizes for managing notifications between threads. This library is currently utilized by command reading, RCON and RakLib, allowing faster response times to commands, reduced network latency, and better performance due to lack of need for polling.
- Fixed race condition causing `ServerKiller` to sometimes kill the server for no reason on shutdown.
### Dependency libraries
Requires the following libraries:
- [`pocketmine/raklib` `^0.12.0`](https://github.com/pmmp/RakLib/releases/0.12.0)
- [`pocketmine/spl` `^0.3.0`](https://github.com/pmmp/SPL/releases/0.3.0)
- [`pocketmine/binaryutils` `^0.1.0`](https://github.com/pmmp/BinaryUtils/releases/0.1.0)
- [`pocketmine/nbt` `^0.2.0`](https://github.com/pmmp/NBT/releases/0.2.0)
- [`pocketmine/math` `^0.2.0`](https://github.com/pmmp/Math/releases/0.2.0)
- [`pocketmine/snooze` `^0.1.0`](https://github.com/pmmp/Snooze/releases/0.1.0)
These libraries may individually have changes which are not recorded here. See their independent repository releases for their changelogs.
### Async pooling
- Async workers are now started dynamically when they are needed only, instead of being started immediately on startup. This allows reducing idle memory usage.
- AsyncPool now appropriately shuts down the workers when instructed to, instead of leaving it up to the ThreadManager to clean it up. This eliminates debug messages of shutting down async workers on server shutdown.
- Default maximum async worker memory limit has been lowered from 1024MB to 256MB.
- Async workers are now started using the options `PTHREADS_INHERIT_CONSTANTS | PTHREADS_INHERIT_INI`, which reduces idle memory wastage and works around some bugs in pthreads.
### Entities
- Fixed entities not being despawned when flagged, if they weren't scheduled for an update.
### Levels
- Seed handling is now always consistent between `pocketmine.yml` and `server.properties`.
- Fixed generation bugs in imported LevelDB worlds where the classpath was saved into level.dat.
- Generators for levels are no longer created on the main thread, reducing memory usage.
### Plugins
- Plugin data is now stored under `<data dir>/plugin_data` by default on new installations, instead of in `<plugins dir>`. This behaviour does not affect existing installations by default - if you want to enable it, set `plugins.legacy-data-dir` to `false` in `pocketmine.yml`.
### RCON
RCON has been almost completely rewritten in this release.
- Now event-driven (using Snooze) instead of poll-based, improving performance.
- Fixed segmentation fault when stopping the server with RCON enabled.
## API
**WARNING: Dependency library API changes are not listed here. See their individual release notes for changes (linked above in the Core section).**
### API versioning changes for plugins
The way that the API versioning is done has changed. Now the API version is synonymous with the PocketMine-MP version.
Plugin compatibility is determined by the following:
- Take the base version, and strip any metadata (everything after the `+` sign, for example `3.0.0+dev.1191` becomes `3.0.0`).
- Assert that:
- The major versions is the same
- The server's minor version is greater than or equal to the plugin's
- The server's patch version is greater than or equal to the plugin's
Currently there is no support for locking version by metadata, although this could be implemented if it is a wanted feature.
### General
- `Server->getCodename()` and `\pocketmine\CODENAME` have been removed.
- Added API method `Server->getTickSleeper()`, which returns a `\pocketmine\snooze\SleeperHandler` instance.
- `Server->getIp()` now returns `0.0.0.0` if not set.
### Block
- Added `Block->getXpDropForTool()`.
### Entity
- Calling `scheduleUpdate()` on an `Entity` after it has been `close()`d will now cause an exception to be thrown.
- `Entity->motionX`, `Entity->motionY` `Entity->motionZ` have been removed in favour of an `Entity->motion` `Vector3` field. This also applies for the `lastMotion` fields.
- `Entity->isInsideOfWater()` has been renamed to `isUnderwater()`.
### Events
- Added support for `@softDepend` annotation on event handlers, which allows the event handler to not be registered if the dependency plugin is not loaded.
- Added support for `@notHandler` annotation for `Listener` methods to indicate that such methods are not event handlers.
- Typehints have been applied to the events API to PHP 7.2 standards.
- Fixed preventing effect expiry using `EntityEffectRemoveEvent` not being reflected on the client.
- `EntityDamageEvent` API has significant changes. 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 parameter is now mandatory
- `getDamage()` renamed to `getModifier()`, and type parameter is now mandatory
- `getOriginalDamage()` renamed to `getOriginalModifier()`, and type parameter is now mandatory
- Removed `MODIFIER_BASE` constant
- Constructors now accept: `float baseDamage`, `float[] modifiers` instead of just `float[] modifiers`
- Added `BlockBreakEvent->getXpDropAmount()` and `BlockBreakEvent->setXpDropAmount()`.
### Inventory
- `InventoryTransaction->getCreationTime()` has been removed.
- `EntityInventoryChangeEvent` and `EntityArmorChangeEvent` are no longer fired during entity inventory intialization.
### Item
- Methods `isPickaxe()`, `isAxe()`, `isSword()`, `isShovel()`, `isHoe()`, `isShears()` have been removed. These should be replaced with `instanceof` checks for the relevant classes.
- Removed `Item->useOn()`. This has been superseded by new methods used for handling durability changes.
- Added hooks `Item->onDestroyBlock()` and `Item->onAttackEntity()`. These are called when a player uses the item to destroy a block or attack an entity respectively. This is used in the core code for updating durability.
- `Item->pop()` now accepts an optional count parameter.
- `Enchantment` now has separated primary items (which can be enchanted directly) and secondary items (which can be enchanted on an anvil). The constructor of `Enchantment` has been updated to reflect this.
- Removed `Enchantment->getSlot()` and `Enchantment->hasSlot()`.
- Added `Enchantment->getPrimaryItemFlags()`, `Enchantment->hasPrimaryItemFlag()`, `Enchantment->getSecondaryItemFlags()` and `Enchantment->hasSecondaryItemFlag()`
### Level
- `Biome` classes have been moved to `pocketmine\level\biome` namespace. This is in preparation for future work on Levels which requires biome information (such as weather conditions).
- `WeakPosition` has been removed.
- Added `Level->getBiome()`.
- `Level->getSafeSpawn()` now always returns a `Position` instance.
- `Level->getBlockExtraData()` and `Level->setBlockExtraData()` have been removed (as well as their associated `Chunk` methods).
- `ChunkManager->isInWorld()` now accepts integers instead of floats.
- Added `SubChunkIteratorManager->invalidate()`.
#### Generator
- `BiomeSelector` has been refactored to make it simpler and more robust.
- Generator-management methods `registerDefaultGenerators()`, `addGenerator()`, `getGeneratorList()`, `getGenerator()`, and `getGeneratorName()` have been moved from `Generator` to a new `GeneratorManager` class.
- Static noise functions in the `Generator` base class have been moved to `Noise` instance methods.
- Added static method `Generator::convertSeed()`, which converts an int or string into a numeric seed for generation.
### Network
- `SourceInterface->process()` no longer returns a value.
### Plugin
- `PluginBase->getResources()` now returns an associative array where the index is the path to the resource relative to the plugin's `resources` directory.
- `PluginLoader`s have been almost completely rewritten to make them simpler and more robust.
- `PluginManager->registerInterface()` does not return anything, and now accepts a `PluginLoader` instance instead of a `string`.
- `PluginLoader`:
- `getPluginFilters()`, `enablePlugin()` and `disablePlugin()` are removed.
- `loadPlugin()` responsibilities are now solely confined to doing whatever is necessary to make the plugin's classes visible by the server, and does not emit log messages or check for data directories.
- Added method `getAccessProtocol()` which determines what prefix to apply to the plugin path to access the files inside it (for example `phar://`).
- `PluginBase->init()` and `PluginBase->isInitialized()` have been removed.
- `Plugin` interface now declares a signature for the constructor which implementations must comply with.
- `Plugin` interface now declares `setEnabled()`.
- It is now possible to create a custom `Plugin` implementation without requiring a custom `PluginLoader`.
### Scheduler
This release features major changes to how plugin task scheduling works.
- Removed `Server->getScheduler()`. All plugins now have their own scheduler which is accessible using `Plugin->getScheduler()`. Aside from being syntactically more concise and pleasant, this also allows much more effective management of tasks when plugins are disabled.
- Removed `PluginTask` class, because it's now unnecessary. Previously it was required to allow the server to delete tasks associated with a plugin when the plugin was disabled. With plugin-owned schedulers, this is no longer a requirement. Plugins may now utilize the `Task` class as a base if they like.
- Added `Server->getAsyncPool()`. Since the global scheduler does not exist any more, it does not manage the server's `AsyncPool` any more. Additionally, `ServerScheduler` was previously bloated by a lot of `AsyncTask` related methods, which are now not necessary because direct access to `AsyncPool` is granted instead.
- `ServerScheduler`:
- `ServerScheduler` has been renamed to `TaskScheduler` since it is now a general-purpose task scheduler which is non-dependent on the user. This allows much greater flexibility and also makes it possible to unit-test.
- All `AsyncTask`/`AsyncPool` related methods have been removed - the task scheduler does not manage the async pool anymore.
- Calls to `Server->getScheduler()->scheduleAsyncTask()` should be replaced with `Server->getAsyncPool()->submitTask()`.
- Calls to `Server->getScheduler()->scheduleAsyncTaskToWorker()` should be replaced with and `Server->getAsyncPool()->submitTaskToWorker()`.
### Tile
- Calling `scheduleUpdate()` on a `Tile` after it has been `close()`d will now cause an exception to be thrown.
- Tile NBT is now ephemeral and is not retained after creating the tile.
- `Tile->namedtag` has been removed.
- `Tile->saveNBT()` now returns a new `CompoundTag` containing saved data.
- Added new protected methods `Tile->readSaveData()` and `Tile->writeSaveData()`. These should be overridden to add or read tile-specific data, instead of overriding `saveNBT()` and `__construct()`.
### Utils
- Added `MainLogger->getFormat()` and `MainLogger->setFormat()` to allow manipulating console output format.
## Gameplay
### General
- Fixed a range of block collision issues stemming from off-by-one errors when fetching areas.
### Blocks
- Fixed a crash which occurred when leaving a bed which was broken and replaced during sleep.
- Fixed dark oak and acacia saplings growing into oak trees - now they will not grow at all (they need to be implemented).
- Saplings now take light level into account when trying to grow.
- Ores and other blocks now drop experience when broken with an appropriate tool.
### Entities
- Fixed dropped items not being correctly destroyed by fire, cacti and other damage sources.
### Generation
- Grass no longer generates as the top layer of ground cover in river biomes.
- Ocean biomes now use gravel instead of grass+dirt for ground cover.
- Reduced maximum elevation of plains biomes to make them less bumpy.
- Snow layers and other can-be-flowed-into blocks no longer generate underwater.
### Items
- Buckets are no longer able to delete any block by replacing it with water.
- Dried Kelp, Bleach, Nautilus Shell and Heart of the Sea items are registered (although crafting recipes for these are not yet available).
- Implemented `Vanishing` enchantment.
- Implemented Totems.
### World
- Fixed explosions sometimes leaving behind air blocks with non-zero damage values.
# 3.0.1
- Fixed error when players move things around in the crafting grid after plugins cancel `PlayerInteractEvent` on crafting tables.
# 3.0.2
- Fixed memory dumps not showing private properties of parent classes.
- Fixed a memory leak when cancelling all tasks in the `TaskScheduler`.
- Fixed scheduled task timings showing `Unknown` as the plugin name.
# 3.0.3
- Fixed possible crash in Sign when placed by a plugin.
- Fixed slightly-damaged and very-damaged anvils dropping incorrect items.
- `Living->applyPostDamageEffects()` is no longer called if the mob died from an attack.
- Cooldown for mob attack is now reset prior to applying post-damage effects.
- Added constant `ItemIds::MUTTON` to resolve crashes using PC worlds.
- Fixed emerald ore not dropping XP when broken with a valid tool.
- Fixed mobs getting crazy vertical knockback if attacked while airborne.
- Fixed XP orbs continuing to follow dead players.
# 3.0.4
- Fixed RCON spamming the console when a client does not disconnect correctly.
- Fixed dropping chunk cache unnecessarily when no blocks need to be updated on a chunk.
- Fixed outdated block updates getting sent on chunks replaced using `setBlock()`.
# 3.0.5
- Fixed not being able to place blocks where a player died and has not yet respawned (#2265).
- Fixed mob death animation not being played when `Entity->kill()` is called directly or `/kill` is used.
- Fixed viewers of different halves of double chests not seeing changes made by viewers who opened the other half (#2261).
- Fixed bugs setting items into wrong indexes when double chest halves have differently sized inventories.
- Fixed `getConfig()` crashing when called when the plugin's data directory doesn't exist.
- Fixed a possible exploit with keychain signing for XBL login.
# 3.0.6
- Fixed invalid keys in `.properties` config files being considered as invalid strings.
- Fixed whitespace between key and value `key = value` being invalid in `.properties` config files.
- Fixed a bug in exception message when an invalid permission type is written for a command in plugin.yml.
- Properly fixed newline issues when parsing event handler annotations - `@notHandler` will now work as expected when CRLF line endings are used.
- Fixed `PluginManager->registerEvents()` registering functions as event handlers declared by parent classes which are not `Listener` instances (#2293).
# 3.0.7
- Fixed setting spawn points in un-generated chunks causing the player to fall out of the world.
- Fixed spawn protection deactivating when there are no ops set (this was an unwanted/unexpected feature, so it's considered a bug).
- Fixed cursor items not getting dropped when closing the inventory or dying.
- Fixed more issues with blocks with invalid metadata appearing as update! blocks.
- `Entity->setNameTagAlwaysVisible()` now works (although nametags will still not be shown if the entity is invisible, due to a behavioural change in Minecraft PE).
- Fixed errors passing zero motions to projectiles in some cases.
# 3.0.8
- Fixed player on-ground state not updating when moving horizontally. This allowed fly hacks with the built in anti-cheat, and also affected some third party anti-cheat plugins due to the effect on `inAirTicks`.
- Fixed knockback. PC 1.9-style knockback was mistakenly introduced in 3.0.3. This has now been reverted back to the old 1.8-style behaviour.
# 3.0.9
- Cleaned up odd behaviour of `/kill` due to old broken code.
- Fixed patch level check for plugin APIs not allowing lesser patch versions on greater minor versions.
- Fixed `/timings paste`. This now reports directly to the timings host instead of using Ubuntu Pastebin.
- Minor code cleanups in various places.
- Zip resource packs will now give slightly less useless errors - errors for broken manifest have been separated from those with fields missing, and now reports why decoding failed if it failed.
# 3.0.10
- Syntax error crashdumps will no longer be reported to the crash archive.
- Chunk sending is now fault-tolerant. Before this release, any error on a worker during async chunk sending (such as memory errors caused by pthreads) would cause that chunk to never get sent, resulting in invisible and missing chunks. Levels will now attempt to retry chunk prepare when a task crashes, which should fix most invisible chunk bugs.
- `MainLogger` now logs exception stack traces in a synchronized block to ensure that they are coherent when log messages are emitted from multiple threads at once.
- `AsyncTask->isCrashed()` now returns `true` if a fatal error occurred during the task execution.
# 3.0.11
- `DropItemAction` will now consider itself invalid if attempting to drop a null item.
- Fixed leaking globally broadcasted Level packets when no players are on the server.
- Fixed title bar not being cleared on server stop on some terminals.
- Fixed `FallingBlock` saving corrupted data.
- Fixed the structure of `GuiDataPickItemPacket`.
- Cleaned up some code in `OfflinePlayer`.
- Splash potions no longer apply effects to dead (but not yet respawned) players.
- Coal ore no longer drops XP when mined with a silk touch tool.
- Item entities now cannot be picked up when a negative pickup delay is used.
# 3.0.12
- `Config` keys which are considered bools by YAML 1.1 will no longer be transformed into 1 or 0.
- Fixed painting motives not getting saved.
- Fixed cacti spewing items when placed in some invalid locations.
- Fixed entity fire damage not applying in the void.
- Fixed entities not getting updated appropriately in some conditions.

68
changelogs/3.1.md Normal file
View File

@ -0,0 +1,68 @@
**For Minecraft: Bedrock Edition 1.5.0**
### Note
Plugins compatible with any previous 3.x.y version will also run on this build and do not need API bumps. Plugin developers should **only** update their required API to this version if you need the changes in this build.
**This build contains changes to the **protocol** which are not covered by the API version. To lock your plugin to a specific protocol version, declare the `mcpe-protocol` attribute in your `plugin.yml`.
# 3.1.0
- Support for Minecraft: Bedrock Edition version 1.5.0
# 3.1.1
- Fixed player on-ground state not updating when moving horizontally. This allowed fly hacks with the built in anti-cheat, and also affected some third party anti-cheat plugins due to the effect on `inAirTicks`.
- Fixed knockback. PC 1.9-style knockback was mistakenly introduced in 3.0.3. This has now been reverted back to the old 1.8-style behaviour.
# 3.1.2
- Cleaned up odd behaviour of `/kill` due to old broken code.
- Fixed patch level check for plugin APIs not allowing lesser patch versions on greater minor versions.
- Fixed `/timings paste`. This now reports directly to the timings host instead of using Ubuntu Pastebin.
- Minor code cleanups in various places.
- Zip resource packs will now give slightly less useless errors - errors for broken manifest have been separated from those with fields missing, and now reports why decoding failed if it failed.
- Added constant `Entity::DATA_FLAG_SHOW_TRIDENT_ROPE`.
# 3.1.3
- Syntax error crashdumps will no longer be reported to the crash archive.
- Chunk sending is now fault-tolerant. Before this release, any error on a worker during async chunk sending (such as memory errors caused by pthreads) would cause that chunk to never get sent, resulting in invisible and missing chunks. Levels will now attempt to retry chunk prepare when a task crashes, which should fix most invisible chunk bugs.
- `MainLogger` now logs exception stack traces in a synchronized block to ensure that they are coherent when log messages are emitted from multiple threads at once.
- `AsyncTask->isCrashed()` now returns `true` if a fatal error occurred during the task execution.
# 3.1.4
- `DropItemAction` will now consider itself invalid if attempting to drop a null item.
- Fixed leaking globally broadcasted Level packets when no players are on the server.
- Fixed title bar not being cleared on server stop on some terminals.
- Fixed `FallingBlock` saving corrupted data.
- Fixed the structure of `GuiDataPickItemPacket`.
- Cleaned up some code in `OfflinePlayer`.
- Splash potions no longer apply effects to dead (but not yet respawned) players.
- Coal ore no longer drops XP when mined with a silk touch tool.
- Item entities now cannot be picked up when a negative pickup delay is used.
- Fixed extra byte at the end of `PlayerSkinPacket` not being read (1.5 protocol change that somehow got lost).
# 3.1.5
- `Config` keys which are considered bools by YAML 1.1 will no longer be transformed into 1 or 0.
- Fixed painting motives not getting saved.
- Fixed cacti spewing items when placed in some invalid locations.
- Fixed entity fire damage not applying in the void.
- Fixed entities not getting updated appropriately in some conditions.
# 3.1.6
- Fixed players disconnected during login verification getting leaked and not destroyed correctly.
- Updated NBT dependency to 0.2.1 to receive bug fixes (see https://github.com/pmmp/NBT/releases/tag/0.2.1).
# 3.1.7
- Errors thrown during level tick will now crash the server instead of spamming the console.
- Fixed arrows despawning too soon after hitting the ground.
- Fixed projectiles despawning before colliding if they were airborne for > 60 seconds.
# 3.1.8
- Fixed levels unloaded during an earlier level's tick on the same tick causing a crash.
- PermissibleBase->clearPermissions() now properly unsubscribes from all permissions.
- Fixed incorrect break check for standing torch.
- Fixed drops for brewing stand.
- Fixed block picking brewing stand, bed, double slab, cake, farmland, and mob heads giving the wrong items.
- Fixed blocks not placing correctly when clicking on redstone ore.
- Fixed unknown PC items in tile inventories crashing the server - now they'll be quietly removed instead.
- Fixed server freezing when eating chorus fruit from high altitude.
- `readline` is now disabled by default on Windows and must be explicitly enabled with `--enable-readline` due to thread-safety issues.
- Fixed server crash when trying to use non-implemented splash potions.
- Removed incorrect maximum region file size cap which may have caused some worlds to be incorrectly detected as corrupted.

121
changelogs/3.2.md Normal file
View File

@ -0,0 +1,121 @@
**For Minecraft: Bedrock Edition 1.6.0**
This is a minor feature release, including support for Minecraft Bedrock 1.6.0, some new minor gameplay features and some API deprecations and additions.
### Note
Plugins compatible with any previous 3.x.y version will also run on this build and do not need API bumps.
However, some API features have been deprecated in this version. Plugin developers do not need to do anything about these deprecations immediately, however they may raise harmless warnings if used.
Features marked **`@deprecated`** are **recommended** not to be used, but will continue to work for any future 3.x.y versions. They will be removed in the next major release (4.0).
# 3.2.0
### Core
- `Level` generators are now registered only when needed instead of as soon as a worker starts. This drastically reduces memory consumption on servers with lots of workers.
- Async workers are now garbage-collected along with everything else on the default schedule. Idle workers with 0 queued tasks will be shutdown and removed from the pool to reduce memory usage.
- UPnP error messages are now more informative of troubleshooting steps.
- Errors are no longer caught in cases where they are unrecoverable.
### API
#### Entity
- Arrow pickup mode can now be controlled via `Arrow->setPickupMode()`. This accepts one of three `Arrow` constants: `PICKUP_NONE`, `PICKUP_ANY`, `PICKUP_CREATIVE`.
- Added new API methods `Projectile->getBaseDamage()` and `Projectile->setBaseDamage()`.
- Added new API methods `Entity->getScoreTag()` and `Entity->setScoreTag()`.
#### Events
- The `Listener` interface has now received in-depth documentation about its behaviour and uses. See the top of the `Listener` class to read it.
- It is now possible to declare `@ignoreCancelled` on an event handler without specifying `true` or `false`. If no value is found, `true` will be assumed.
- `ServerCommandEvent` and `RemoteServerCommandEvent` are now **`@deprecated`** and their usage discouraged. A new generic `CommandEvent` has been introduced in its place, which allows capturing commands from any type of command sender. This was done in response to difficulties of code duplication when wanting to intercept commands from both console and players.
- `EntityDamageEvent`
- Added `MODIFIER_WEAPON_ENCHANTMENTS` constant for attack damage bonuses due to enchantments like Sharpness.
- Added new API methods `getAttackCooldown()` and `setAttackCooldown()` to allow controlling Living entities attack cooldown times (default 10 ticks).
- `PlayerDeathEvent`: Added new static method `deriveMessage()`.
- `PlayerKickEvent`: Added new method `setReason()`.
#### Forms
- Added a new `pocketmine\form\Form` interface. Implementing this interface permits custom form implementations to make use of `Player->sendForm()`, eliminating the need to handle packets directly and also solving the form ID collision problem.
#### Items
- `Item` and `ItemFactory` now support negative item IDs (needed for future extended blocks support).
- Updated `ItemIds` interface with new constants.
#### Permission
- Added a new `PermissionManager` class which encapsulates all of the permission-management functionality originally bloating `PluginManager`. The API is identical to that of `PluginManager`'s permission API. All methods moved to `PermissionManager` have **`@deprecated`** redirects remaining behind in `PluginManager`, which will be removed in the next major release (4.0).
#### Plugin
- `PluginBase->getConfig()` will now automatically save the default config if it does not already exist.
- Plugin data directories will now be automatically created on plugin load, eliminating the need for boilerplate `@mkdir($this->getDataFolder())` calls at the top of every plugin.
#### Tile
- `Tile::createNBT()` will now throw a `BadMethodCallException` when called directly.
#### Utils
- `Utils::getURL()`, `Utils::postURL()`, `Utils::simpleCurl()` and `Utils::getIP()` have been moved to a new `pocketmine\utils\Internet` class. The original methods are **`@deprecated`** and will be removed for the next major version (4.0).
- Removed the ability for `Config` to be asynchronously saved. This was discussed for removal because of various problems that it causes. It was deemed not worth fixing since `Config` saving should not be significant enough to cause problems anyway. See #2298 for details.
#### Server
- Deprecated `level` parameter of `findEntity()`. This parameter was premature optimization. Code using it will continue to work as before.
### Gameplay
#### General
- Air bubbles are now regenerated at the same speed as vanilla UpdateAquatic, instead of instantly when leaving water.
- Implemented Conduit Power effect.
#### Enchantments
- Implemented the following enchantments: Thorns, Sharpness, Knockback, Fire Aspect, Power, Punch, Flame, Infinity, Mending.
#### Items
- Added the following new items: `Scute`
# 3.2.1
- Fixed `VerifyLoginTask` completion bug when players get disconnected prior to the task completing.
- Fixed client crash issue due to outdated runtime ID mappings.
# 3.2.2
- Updated NBT dependency to 0.2.1 to receive bug fixes (see https://github.com/pmmp/NBT/releases/tag/0.2.1).
# 3.2.3
- Errors thrown during level tick will now crash the server instead of spamming the console.
- Fixed arrows despawning too soon after hitting the ground.
- Fixed projectiles despawning before colliding if they were airborne for > 60 seconds.
- Fixed crash related to Flame enchantment when the player shooting the arrow was on fire.
# 3.2.4
- Fixed levels unloaded during an earlier level's tick on the same tick causing a crash.
- PermissibleBase->clearPermissions() now properly unsubscribes from all permissions.
- Fixed incorrect break check for standing torch.
- Fixed drops for brewing stand.
- Fixed block picking brewing stand, bed, double slab, cake, farmland, and mob heads giving the wrong items.
- Fixed blocks not placing correctly when clicking on redstone ore.
- Fixed unknown PC items in tile inventories crashing the server - now they'll be quietly removed instead.
- Fixed server freezing when eating chorus fruit from high altitude.
- `readline` is now disabled by default on Windows and must be explicitly enabled with `--enable-readline` due to thread-safety issues.
- Fixed server crash when trying to use non-implemented splash potions.
- Removed incorrect maximum region file size cap which may have caused some worlds to be incorrectly detected as corrupted.
# 3.2.5
- `Player->sendForm()` now throws a proper exception when failing to JSON-encode `Form` objects given to it.
- Fixed crash when handling later packets in a batch when an earlier packet triggered termination of the player's connection.
- Fixed a race condition causing progress updates in `AsyncTasks` to be lost when published near completion.
- Fixed bad decoding for some packets with unsupported structures.
- Crash dumps no longer report 20 empty lines when an error occurs in `eval()`'d code.
- `pocketmine/nbt` dependency updated to `0.2.2` to fix bugs (see NBT repo for changelog).
# 3.2.6
- Chunk ticking no longer occurs in chunks which have an adjacent unloaded chunks, fixing things like grass ticking triggering unintentional chunk loading.
- Fixed some lighting propagation issues where step count is the same but light level is different.
- Fixed full-chunk light repopulation producing broken lighting when the generator hasn't been registered on a worker.
- Fixed a missing field in `MoveEntityDeltaPacket`.
- Added client-sided rate limiting for crashdump reporting to mitigate involuntary DDoS of the crash archive.
- Fixed a bug in `start.cmd` where quotes would appear around the "couldn't find installation" message.
# 3.2.7
- Added a network-layer check for item NBT size to avoid unexplained client-sided crashes due to length overflow.
- Fixed some desync bugs with double chests when one half of a double chest is unloaded.
- Anonymous class timings will now have a cleaned path for the identifier relative to the plugins directory.
- Anonymous class timings now render correctly on timings.pmmp.io.
- Fixed empty garbage subchunks not getting removed from long-life chunks.
- `start.ps1`, `start.sh` and `start.cmd` no longer recognize source-code installations. Since source-code installations should only be used by developers who know what they are doing anyway, this was considered unwise to keep.
- Fixed a bug/oversight in network chunk preparation that caused chunk prepare to be 4x slower than necessary.
- `Chunk->fastSerialize()` now doesn't serialize useless data (data is omitted based on chunk flags). This significantly reduces the amount of useless data getting copied for generation, population and light calculation.
- `TaskHandler->cancel()` was incorrectly marked as `@internal` in 2014. This has been fixed. Plugin developers should in fact prefer `TaskHandler->cancel()` since it does not require a task to have a circular dependency on its own executor.

44
changelogs/3.3.md Normal file
View File

@ -0,0 +1,44 @@
**For Minecraft: Bedrock Edition 1.7.0**
### Note
Plugins compatible with any previous 3.x.y version will also run on these releases and do not need API bumps. Plugin developers should **only** update their required API to this version if you need the bug fixes in this build.
# 3.3.0
- Compatibility with Minecraft: Bedrock Edition 1.7.0
- Removed compatibility with 1.6.0
- `Player->sendForm()` now throws a proper exception when failing to JSON-encode `Form` objects given to it.
- Fixed crash when handling later packets in a batch when an earlier packet triggered termination of the player's connection.
- Fixed a race condition causing progress updates in `AsyncTasks` to be lost when published near completion.
- Fixed bad decoding for some packets with unsupported structures.
- Crash dumps no longer report 20 empty lines when an error occurs in `eval()`'d code.
- `pocketmine/nbt` dependency updated to `0.2.2` to fix bugs (see NBT repo for changelog).
# 3.3.1
- Chunk ticking no longer occurs in chunks which have an adjacent unloaded chunks, fixing things like grass ticking triggering unintentional chunk loading.
- Fixed some lighting propagation issues where step count is the same but light level is different.
- Fixed full-chunk light repopulation producing broken lighting when the generator hasn't been registered on a worker.
- Fixed a missing field in `MoveEntityDeltaPacket`.
- Added client-sided rate limiting for crashdump reporting to mitigate involuntary DDoS of the crash archive.
- Fixed a bug in `start.cmd` where quotes would appear around the "couldn't find installation" message.
# 3.3.2
- Added a network-layer check for item NBT size to avoid unexplained client-sided crashes due to length overflow.
- Fixed some desync bugs with double chests when one half of a double chest is unloaded.
- Anonymous class timings will now have a cleaned path for the identifier relative to the plugins directory.
- Anonymous class timings now render correctly on timings.pmmp.io.
- Fixed empty garbage subchunks not getting removed from long-life chunks.
- `start.ps1`, `start.sh` and `start.cmd` no longer recognize source-code installations. Since source-code installations should only be used by developers who know what they are doing anyway, this was considered unwise to keep.
- Fixed a bug/oversight in network chunk preparation that caused chunk prepare to be 4x slower than necessary.
- `Chunk->fastSerialize()` now doesn't serialize useless data (data is omitted based on chunk flags). This significantly reduces the amount of useless data getting copied for generation, population and light calculation.
- `TaskHandler->cancel()` was incorrectly marked as `@internal` in 2014. This has been fixed. Plugin developers should in fact prefer `TaskHandler->cancel()` since it does not require a task to have a circular dependency on its own executor.
# 3.3.3
- Development build error messages are now more user friendly.
- Fixed meta-only changes not getting saved correctly in `SubChunk->setBlock()`.
- Server will now sleep for up to 120 seconds on a crash if the uptime was less than 120 seconds. This delay is intended to reduce crash archive spam and can be skipped by the user if attended by pressing CTRL+C.
- Fixed preprocessed builds sometimes having `new ` calls treated as function calls.
- Fixed a rare corruption case where player data could be written incorrectly due to a race condition.
- `DataPacket` will now throw errors when attempting to read/write nonexisting fields to make it easier to debug protocol change errors.
# 3.3.4
- Fixed an undefined `DataPacket` field making the previous release unusable.

97
changelogs/3.4.md Normal file
View File

@ -0,0 +1,97 @@
**For Minecraft: Bedrock Edition 1.7.0**
This is a cumulative minor release featuring performance improvements, memory usage improvements, some new minor gameplay features, some API deprecations and additions, and significant changes to error handling.
### Note
Plugins compatible with any previous 3.x.y version will also run on these releases and do not need API bumps.
However, some API features have been deprecated in this version. Plugin developers do not need to do anything about these deprecations immediately, however they may raise harmless warnings if used.
Features marked **`@deprecated`** are **recommended** not to be used, but will continue to work for any future 3.x.y versions. They will be removed in the next major release (4.0).
# 3.4.0
## Core changes
### Performance & memory improvements
- Entity `EXHAUSTION` attribute is no longer synced to the client, which reduces network traffic for survival players and reduces client-sided lag.
- A redundant call was removed from an `Event` call hot path which improves event calling performance by ~15% per event handler executed.
- Light updates are now batched together and executed on the end of each tick. The effects of this are noticeable when setting a large number of blocks in a close area - significant performance improvements should be noticeable for world editors (the ones that didn't disable light updates) and liquid flow is now significantly less expensive.
- Internal enhancements have been made to subchunk light array interfacing to reduce branching and improve access performance.
- Memory usage of most chunks has dropped by ~30-40% due to some improvements to internal storage of unlit subchunks. In real terms this translates to ~30% memory usage reduction for a freshly generated world.
### Error handling
The most notable core change in this release revolves around error handling. Internals have been cleaned up substantially to improve the server behaviour under occurrence of unexpected behaviour. The goal of this is to improve consistency and quality while reducing undefined runtime behaviour.
The following changes have been made:
- Throwing **unexpected** `Throwable`s in the following cases will now cause a server crash (except on network (this will be changed in the future)):
- Event handlers
- `Task->onRun()` on a scheduler
- `AsyncTask->onCompletion()`
- `Command->execute()` and `CommandExecutor->onCommand()`
- Unexpected `Throwable`s thrown during packet handling will now cause the target player to be disconnected with an `Internal server error` message.
### Other changes
- Anti-flight has been removed, along with the `allow-flight` directive in `server.properties`.
- Server language is now controlled by the `language` directive in `server.properties`.
- Added `unban` and `unban-ip` as aliases of `pardon` and `pardon-ip` commands respectively.
## API changes
### Block
- `BlockSpreadEvent` is now fired when lava or water tries to flow into a block.
- `BlockFormEvent` is now fired when lava and water collide to form cobblestone, obsidian or stone.
### Event
- Added new method `Event->call()`. This should be used instead of `PluginManager->callEvent()` in plugins only supporting 3.4+.
- `PluginManager->callEvent()` has been `@deprecated`.
### Level
- Attempting to unload a level during its tick will now throw an `InvalidStateException`.
- Added the following new methods:
- `Level->broadcastPacketToViewers()`
- `Level->getViewersForPosition()`
- `Level->broadcastGlobalPacket()`
- `Level->getChunkAtPosition()`
- `Level->isInLoadedTerrain()`
- `Level->addGlobalPacket()` has been `@deprecated`.
- `LightUpdate` now allows calling `setAndUpdateLight()` for the same position multiple times (needed for light update batching).
### Permission
- `Permission::getByName()` now throws an exception on invalid values instead of silently returning `DEFAULT_FALSE`. This may cause new errors to appear if your plugins had broken permission defaults in `plugin.yml`.
### Player
- `addWindow()` now has stricter validity checks and will now throw exceptions in the following cases: No window IDs left to use, and when a forced window ID collides with an existing window.
- The public `$speed` field has been removed (this was only used by anti-cheat which has now been removed).
### Scheduler
- `AsyncTask->setResult()` has had the `$serialize` parameter removed - now it will automatically serialize (or not) as appropriate.
- Added a new `ClosureTask` which allows concisely scheduling closure execution on a `TaskScheduler`.
- `TaskScheduler->__construct()` `$logger` parameter has been `@deprecated` and will be removed in a future major version.
### Server
- Added new method `Server->hasOfflinePlayerData(string $name) : bool`.
- `Server->getAllowFlight()` has been `@deprecated`.
### Utils
- `Config->save()` will no longer catch unexpected exceptions thrown while encoding data.
## Gameplay changes
### Blocks
- Rail connectivity has been implemented for normal, powered, detector and activator rails (but there are currently no minecarts).
# 3.4.1
- Updated crashdump format to be compatible with newest CA. This version or newer is required if you want to be able to submit crashdumps to crash.pmmp.io.
# 3.4.2
- `DataPacket` errors when writing to undefined fields are now more clear.
- Fixed trees being able to overwrite the log parts of other trees.
- Fixed `Player->sendForm()` not working during `PlayerJoinEvent`.
- `Entity->setScale()` now explicitly requires a scale larger than 0.
- Adding invisible `FloatingTextParticle` to a level no longer causes an error.
# 3.4.3
- Fixed burning TNT setting hurt entities on fire when exploding.
- `~` relative coordinates now work in the `/particle` command.
- Various boring fixes to error stack trace reporting.
- `Level->setChunk()` no longer deletes tiles and entities when replacing a chunk with itself.
- Fixed a generator race condition causing rare appearances of half-trees on the client in freshly generated terrain.
- `Attribute->resetToDefault()` now fits the default per the min/max bounds, fixing crashes when the bounds are changed to exclude the default.
- Fixed a crash with LevelDB worlds when the `TAG_2D_MAPS` tag is missing.
- Fixed `Utils::getCoreCount()` crashing on some Debian variants.

149
changelogs/3.5.md Normal file
View File

@ -0,0 +1,149 @@
**For Minecraft: Bedrock Edition 1.8.0**
### Note
Plugins compatible with any previous 3.x.y version will also run on these releases and do not need API bumps. Plugin developers should **only** update their required API to this version if you need the changes in this build.
# 3.5.0
- Compatibility with Minecraft: Bedrock Edition 1.8.0
- Removed compatibility with 1.7.0
# 3.5.1
- Fixed internal server errors when attempting to craft.
- `DataPacket` errors when writing to undefined fields are now more clear.
- Fixed trees being able to overwrite the log parts of other trees.
- Fixed `Player->sendForm()` not working during `PlayerJoinEvent`.
- `Entity->setScale()` now explicitly requires a scale larger than 0.
- Adding invisible `FloatingTextParticle` to a level no longer causes an error.
# 3.5.2
- Updated some misc protocol magic numbers.
- Fixed burning TNT setting hurt entities on fire when exploding.
- `~` relative coordinates now work in the `/particle` command.
- Various boring fixes to error stack trace reporting.
- `Level->setChunk()` no longer deletes tiles and entities when replacing a chunk with itself.
- Fixed a generator race condition causing rare appearances of half-trees on the client in freshly generated terrain.
- `Attribute->resetToDefault()` now fits the default per the min/max bounds, fixing crashes when the bounds are changed to exclude the default.
- Fixed a crash with LevelDB worlds when the `TAG_2D_MAPS` tag is missing.
- Fixed `Utils::getCoreCount()` crashing on some Debian variants.
# 3.5.3
- Rewritten documentation of `PlayerPreLoginEvent`, `PlayerLoginEvent` and `PlayerJoinEvent`. They are now much more detailed and no longer misleading.
- Chest items block-picked from double chests will no longer place chests that crash the server when opened.
- Ender chests now make the correct sounds when opening and closing.
- Fixed Sign errors when a buggy or malicious client sent broken NBT with the wrong tags or wrong number of lines.
- Resource packs with comments in the manifest will now load correctly. (MOJANG!!!)
- Placement of unknown blocks is now disallowed. This solves a range of problems with invalid blocks in the world, such as #2260 .
- Errors thrown during `PlayerQuitEvent` or other `Player->close()` errors will now crash the server instead of causing cryptic bugs later on.
- Fixed large chunks (>= 1044476 bytes) becoming corrupted when saved in Region-based worlds - now an exception is thrown instead.
- Reduced the range of exceptions caught during chunk loading. Now, only chunk corruption errors are caught, and anything else will produce a crash.
- Removed catch-all block on chunk saving. Unexpected errors thrown during chunk save will now create a crash.
- Fixed some asserts in packet decode methods.
- `Attribute` now throws exceptions with more informative messages on errors.
- Properly handled some remaining `Uninitialized string offset` bugs when decoding packets.
- Fixed chunk updates taking several seconds to show up on the client. This bug was most apparent during generation and some world editing tools using asynchronous tasks.
- Fixed CPU waste ordering chunks for non-moving players.
# 3.5.4
### Fixes
- Fixed server crash when a block update occurs on a torch with corrupted metadata.
- Added a hack to mitigate client-side right-click spam bug. This mostly eliminates spam of `PlayerInteractEvent` on right-click.
- Players will no longer see commands they don't have permission to use in client-sided hints when typing a `/` in the chat window.
- `Event->isCancelled()` and `Event->setCancelled()` now throw more informative errors.
- Errors thrown during a network interface processing will now _actually_ crash the server.
### API changes
- Deprecated `NetworkInterfaceCrashEvent`. Nobody should have been using this anyway.
- Deprecated `Network->processInterface()`
- Deprecated `SourceInterface->emergencyShutdown()`
# 3.5.5
- Mobs no longer spawn with their heads facing a different direction to their bodies.
- Added a console message when the crash strangler sleeps to stop crash spam.
- Fixed crash in `/title` command `times` subcommand when not enough arguments were passed.
- AsyncWorkers will now not be shut down on GC unless they have not been used for the last 5 minutes. This reduces lag spikes on garbage collection.
- Fixed some unhandled error cases in `AddEntityPacket` encoding.
- Fixed `LogicException` descendents being thrown from some packet decoding methods when encountering bad userdata.
- Player network inventory transaction processing now catches more specific errors.
- Fixed missing decode for `TakeItemEntityPacket`.
- Fixed `/gc` and `/status` truncating memory statistics - now they report to 0.01 precision.
- Global functions and constants are now imported to improve performance.
- Fixed a typo in `pocketmine.command.op.take` description.
- Ice no longer creates water when a creative player breaks it.
- `spawn-mobs` and `spawn-animals` no longer appear in generated `server.properties` on a newly-installed server.
- Added a hack to disable pre-spawn client-sided movement.
- Assertions enabled warning now always shows when `zend.assertions` is not `-1`. The config option to disable this warning has been removed.
- `/status`,`/dumpmemory` and `/gc` are now enabled by default. The `debug.commands` config option has been removed.
- Crash dumps are now more thorough at catching plugin-related crashes.
# 3.5.6
- Fixed `#`-commenting properties in `.properties` files not working.
- `pocketmine.yml` now permits writing `worldname:` with no generation settings in the `worlds` section to force a world to be loaded.
- Fixed Bow force being too low - now it's consistent with Minecraft Java (but not with Bedrock due to a vanilla bug).
- Fixed `recursion detected` bug when encoding crashdumps in some cases.
- Items with too-large NBT tags on network will now have their tags ignored when sending over network, instead of crashing the server. This is a workaround for a protocol bug which will be addressed in a future Minecraft release.
- `/enchant` no longer crashes the server when out-of-bounds enchantment levels are used.
- Fixed some crashes loading Region-based worlds when encountering unexpected EOF.
- `Entity->fireTicks` is now protected (but accessible by magic method for BC purposes) and will now throw an exception when written to if the value is > 32767 or < 0.
- Fixed Signs asserting on corrupted world data with more than 4 lines of text per sign.
# 3.5.7
- Fixed several bugs in RCON packet receive that would allow an attacker to block or crash the RCON thread, denying service to other legitimate RCON clients.
- Fixed RCON connections not working (timing out with no response) on some platforms.
- Logins are now permitted to have up to 60 seconds clock drift on the `nbf` and `exp` timestamps in the login JWT.
- Fixed XP orbs following players who switched to a location spatially nearby in a different world.
- `Player->removeWindow()` now throws `InvalidArgumentException` instead of `BadMethodCallException` when trying to non-forcefully remove a fixed window ID.
# 3.5.8
- Fixed player XP not dropping if a player was fast enough to respawn.
- Player XP drop amount now matches vanilla (7x level points, incurs some loss of points for higher levels)
- Fixed Doxygen configuration including test sources.
- Improved performance of block-cache accesses.
- Improved performance of random block-ticking.
- Closure tasks will now show the correctly formatted name on timings.
- Fixed a crash when a local update happens next to an `ItemFrame` with invalid metadata.
- Fixed player being subscribed to broadcast permissions too early when permissions are modified before spawn.
- Block-picking is now disallowed on unknown blocks.
- Internal IP detection now works correctly on all platforms.
- Fixed UPnP portforwarding not working correctly when multiple network adapters are installed.
- Starting or stopping flight now resets fall distance and in-air ticks.
- Fixed falling causing starvation.
- Fixed crops consuming bone meal when fully grown.
- Users are no longer able to avoid agreeing to the license by restarting the server.
- Explosions no longer create broken double chests which crash the server. Existing chests affected by this bug will continue to crash. This will be addressed in a future release.
- Cactus and sugarcane no longer grow through non-air blocks.
- Fixed a memory leak in `setChunk()` when the `unload` parameter is true.
- Generator will now crash if preset is invalid, instead of producing unexpected results.
# 3.5.9
- Fixed a `setChunk()` bug introduced by 3.5.8.
- Applied a hack to disable client-sided automatic regeneration.
- `Level->getChunkPlayers()` is now deprecated.
# 3.5.10
- Some internal `Level` functions are now correctly marked `@internal`.
- Fixed splash potion distance being measured from player feet instead of eye height.
- Fixed tall grass being unplaceable on dirt.
- A debug message is now recorded when a chunk is loaded with no associated loaders.
- Composer dependencies have been updated to fix bugs in some dependencies.
# 3.5.11
- Fixed crashing when items with negative IDs are found in the inventory (caused by downgrading from dev builds).
- Updated creative inventory and crafting recipes.
# 3.5.12
- Fixed crash when too-large values are given to `/effect` for duration.
- `/op` and other commands no longer crash when an invalid player name is given.
- Startup time no longer includes the time spent in the setup wizard.
- `TextFormat::clean()` is now UTF-8 aware, and will scrub any invalid UTF-8 characters from the given string.
- Fixed `TextFormat::clean()` not fully removing ANSI escape codes in some cases.
- Fixed Korean command arguments failing to parse.
- `Sign->setText()` and `Sign->setLine()` now enforce that the given text must be UTF-8 text, or an exception will be thrown.
- Sign text is now processed by `mb_scrub()` immediately after loading to remove invalid UTF-8 characters that could crash the client.
- `Human->exhaust()` no longer underflows when the hunger attribute has a fractional value.
# 3.5.13
- Added a hack to disable client sided AI for non-moving entities. This fixes items floating in water despite it not being implemented server-side yet.
- Fixed max health not working as expected on respawn if changed by plugins.
- Fixed Item Frame hardness (0.25 instead of 0).
- Fire Aspect tools will now light TNT when right-clicked with.
- Fixed incorrect nullable typehints on `TaskScheduler` return values.

65
changelogs/3.6.md Normal file
View File

@ -0,0 +1,65 @@
**For Minecraft: Bedrock Edition 1.9.0**
### Note
Plugins compatible with any previous 3.x.y version will also run on these releases and do not need API bumps. Plugin developers should **only** update their required API to this version if you need the changes in this build.
This changelog **does not account for protocol changes**. If your plugin uses the protocol, you're not shielded by API change constraints.
# 3.6.0
- Compatibility with Minecraft: Bedrock Edition 1.9.0
- Removed compatibility with 1.8.0
- `Item->getCompoundTag()` is now `@deprecated`.
- `Item->setCompoundTag()` now accepts NULL as a possible value.
- `ItemFactory::fromString()` now accepts NULL for the `tags` parameter.
# 3.6.1
- Fixed crashing when items with negative IDs are found in the inventory (caused by downgrading from dev builds).
- Updated creative inventory and crafting recipes.
- Fixed handling for some new blocks which magically appeared without appropriate implementations (extra meta values).
# 3.6.2
- Fixed client-sided crash when upper-case letters appear in command names.
- Fixed crash when too-large values are given to `/effect` for duration.
- `/op` and other commands no longer crash when an invalid player name is given.
- Startup time no longer includes the time spent in the setup wizard.
- `TextFormat::clean()` is now UTF-8 aware, and will scrub any invalid UTF-8 characters from the given string.
- Fixed `TextFormat::clean()` not fully removing ANSI escape codes in some cases.
- Fixed Korean command arguments failing to parse.
- `Sign->setText()` and `Sign->setLine()` now enforce that the given text must be UTF-8 text, or an exception will be thrown.
- Sign text is now processed by `mb_scrub()` immediately after loading to remove invalid UTF-8 characters that could crash the client.
- `Human->exhaust()` no longer underflows when the hunger attribute has a fractional value.
# 3.6.3
- Added a hack to disable client sided AI for non-moving entities. This fixes items floating in water despite it not being implemented server-side yet.
- Fixed max health not working as expected on respawn if changed by plugins.
- Fixed Item Frame hardness (0.25 instead of 0).
- Fire Aspect tools will now light TNT when right-clicked with.
- Fixed incorrect nullable typehints on `TaskScheduler` return values.
# 3.6.4
- `NetworkStackLatencyPacket` unhandled debug has been silenced.
- Fixed `Player->removeWindow()` removing GUI or crashing clients when removing a window which was not added.
- Fixed packed ice dropping itself when mined without a silk touch pickaxe.
- Fixed players not taking fall damage when falling off the side of a ladder when their AABB was intersecting with the ladder's full block area.
- Fixed arrows reloaded from disk never despawning.
- Fixed player XP not dropping on death.
- Fixed player's held slot being out of sync when respawning.
- Fixed items with different NBT being considered stackable in some cases by `BaseInventory->canAddItem()`.
# 3.6.5
- Fixed stdout silence on crash if a crash occurs when PHP output buffering is enabled.
- Fixed `RegionLoader` considering a range of invalid chunk coordinates as valid.
- Fixed `RegionLoader` causing region header corruption when an oversized chunk was discovered. This was causing entire regions to be discarded next time they were freshly loaded.
- Fixed performance issue loading old LevelDB worlds (from before MCPE 1.0) due to unmodified chunks being converted every time they were loaded.
- Added new debug messages when a world takes too long (longer than 50ms) to complete a tick.
- Debug messages are now logged when autosave kicks in (with time measurements), which helps debugging unexplained lag spikes.
- Level "auto tick rate" anti-feature and its associated `pocketmine.yml` settings have been removed (see #2665). The settings will persist in old configurations, but will be ignored by this version and future versions.
- The `/save-all` command now outputs custom (non-vanilla) messages informing the user how long it took to complete autosaving.
- The word `level` has been replaced with `world` (where appropriate) throughout language strings and general user interface messages.
# 3.6.6
- Fixed protocol argument types for commands.
- Autosave debug message will now report in milliseconds when the time taken is less than 1 second.
- Flatworld presets now allow `*` as a multiplier symbol (fixes PC compatibility).
- Network runtimeIDs for blocks are now randomized to prevent things (like plugins) relying on them.
- Updated NBT dependency to 0.2.7 for some bug fixes.

33
changelogs/3.7.md Normal file
View File

@ -0,0 +1,33 @@
**For Minecraft: Bedrock Edition 1.10.0**
### Note
Plugins compatible with any previous 3.x.y version will also run on these releases and do not need API bumps. Plugin developers should **only** update their required API to this version if you need the changes in this build.
This changelog **does not account for protocol changes**. If your plugin uses the protocol, you're not shielded by API change constraints.
# 3.7.0
- Compatibility with Minecraft: Bedrock Edition 1.10.0
- Removed compatibility with 1.9.0
# 3.7.1
- Fixed protocol argument types for commands.
- Autosave debug message will now report in milliseconds when the time taken is less than 1 second.
- Flatworld presets now allow `*` as a multiplier symbol (fixes PC compatibility).
- Network runtimeIDs for blocks are now randomized to prevent things (like plugins) relying on them.
- Updated NBT dependency to 0.2.7 for some bug fixes.
# 3.7.2
- Fixed a memory leak when `PlayerLoginEvent` is cancelled.
- Fixed permissions `pocketmine.command.ban.list`, `pocketmine.command.difficulty`, `pocketmine.command.whitelist.enable` and `pocketmine.command.whitelist.disable` always being granted to operators.
- Fixed some commands outputting `commands.generic.permission` instead of the proper message when running commands that the sender doesn't have permission to use.
- Worlds with unknown generator types will now refuse to load instead of getting incorrect terrain generation ruining them.
- `TextFormat::tokenize()` no longer corrupts Unicode sequences.
- `TextFormat::clean()` now removes non-printable Unicode code points in the private-use area.
- Running two servers in the same data directory is no longer allowed and will gracefully halt instead of corrupting your data.
- Sign text length is now soft-capped at 1000 characters.
# 3.7.3
- World save timings now include saves that are triggered by chunk unloading.
- Fixed several network denial-of-service bugs.
- A warning is now emitted when the `ChunkUtils` extension is not loaded.
- Moved version constants to a separate `VersionInfo` file for easier parsing and handling.

69
changelogs/3.8.md Normal file
View File

@ -0,0 +1,69 @@
**For Minecraft: Bedrock Edition 1.11.0**
### Note
Plugins compatible with any previous 3.x.y version will also run on these releases and do not need API bumps. Plugin developers should **only** update their required API to this version if you need the changes in this build.
This changelog **does not account for protocol changes**. If your plugin uses the protocol, you're not shielded by API change constraints.
# 3.8.0
- Compatibility with Minecraft: Bedrock Edition 1.11.0
- Removed compatibility with 1.10.0
# 3.8.1
- Fixed furnace smelting recipes not working.
- Reduced legacy hacks dealing with `BatchPacket` to fix possible ID collisions.
- Reduced release phar size by minifying JSON data blobs.
- Moved some MCPE-specific JSON blobs to submodule.
# 3.8.2
- Fixed --enable-ansi and --disable-ansi not being respected on threads.
- Fixed a crash that could occur when decoding `AvailableCommandsPacket`.
- Fixed a crash when loading worlds with entities with missing `Motion` NBT tag.
- Fixed a crash when world time overflows signed int64 max.
- Fixed world generators and providers being registered too late (this was causing plugin issues).
- Updated RakLib version to get a security fix.
- Fixed errors when custom clients fill the wrong information in `ResourcePackClientResponsePacket`.
- Fixed `setImmobile()` getting overridden directly after `PlayerJoinEvent`.
- Fixed air being breakable by creative players.
- Fixed performance loss caused by bugs in the preprocessor.
# 3.8.3
- Fixed infinite recursion when using `Entity->close()` during `EntityDespawnEvent`.
- Fixed crash reports caused by folder plugins being reported to the crash archive.
- Fixed spawning entities on unloaded chunks during spawn sequence (possible client crash cause).
- Fixed `/time query` output message.
- Fixed `Server->hasOfflinePlayerData()` being case-sensitive.
- Improved error messages for skin validation in some places.
- Fixed classic stonecutter hardness.
- Fixed iron trapdoors being considered a valid furnace fuel.
- Fixed apple dropping from leaves happening less frequently than intended.
- Fixed tall plants like sunflower being replaceable by the top half.
# 3.8.4
- Plugin load order is now randomised to remove the ability to implicitly depend on filesystem-specific ordering.
- Packet logging in debug messages now uses base64 instead of hex (uses less space).
- Array and string size are now shown in error stack trace logs.
- Stack traces now render a maximum of 80 characters when making string parameters printable.
- Improved documentation for some transaction classes.
- Action order in inventory transactions is now randomised to prevent dependencies on any accidental or client-dependent ordering. Since the transaction system is specifically designed to avoid depending on order, this does not affect any core functionality.
# 3.8.5
- Moved preprocessor to build/ directory.
- Added documentation for `Server->getPlayer()`, `Server->getPlayerExact()` and `Server->matchPlayer()`.
- `server.lock` now contains the PID of the currently-running server.
- PID of server is now reported in the error message when attempting to run two servers from the same data directory at once.
- Fixed sluggish playercount updating on MOTD.
- Added new MultiRecipe UUIDs.
- Added an extra field to `StartGamePacket` to resolve minor incompatibility issues on different 1.11.x patch versions.
# 3.8.6
- Fixed `Entity->isNameTagAlwaysVisible()` not working.
- Log messages are now cleaned of invalid UTF-8 sequences before emitting them.
- Fixed negative integers being considered as strings for world seeds.
- Fixed out-of-bounds access on invalid inventory data in player data saves.
- Fixed crash when custom liquids have flow decays which aren't factors of 4.
- Fixed `Entity->noDamageTicks` not working when the entity had no previous damage cause.
# 3.8.7
- Improved documentation of `Player->getDisplayName()` and `Player::isValidUserName()`.
- Fixed a bug in `SetScorePacket` decoding causing the entry list to always be empty.

129
changelogs/3.9.md Normal file
View File

@ -0,0 +1,129 @@
**For Minecraft: Bedrock Edition 1.12.0**
### Note about API versions
Plugins which don't touch the protocol and compatible with any previous 3.x.y version will also run on these releases and do not need API bumps.
Plugin developers should **only** update their required API to this version if you need the changes in this build.
**WARNING: If your plugin uses the protocol, you're not shielded by API change constraints.** You should consider using the `mcpe-protocol` directive in `plugin.yml` as a constraint if you do.
# 3.9.0
- Added support for Minecraft: Bedrock Edition 1.12.0
- Removed compatibility with 1.11.0
## Protocol
- The following classes in the `\pocketmine\network\mcpe\protocol` namespace have been renamed:
- `AddEntityPacket` -> `AddActorPacket`
- `AddItemEntityPacket` -> `AddItemActorPacket`
- `AvailableEntityIdentifiersPacket` -> `AvailableActorIdentifiersPacket`
- `BlockEntityDataPacket` -> `BlockActorDataPacket`
- `EntityEventPacket` -> `ActorEventPacket`
- `EntityFallPacket` -> `ActorFallPacket`
- `EntityPickRequestPacket` -> `ActorPickRequestPacket`
- `MoveEntityAbsolutePacket` -> `MoveActorAbsolutePacket`
- `MoveEntityDeltaPacket` -> `MoveActorDeltaPacket`
- `RemoveEntityPacket` -> `RemoveActorPacket`
- `SetEntityDataPacket` -> `SetActorDataPacket`
- `SetEntityLinkPacket` -> `SetActorLinkPacket`
- `SetEntityMotionPacket` -> `SetActorMotionPacket`
- `TakeItemEntityPacket` -> `TakeItemActorPacket`
- The following classes in the `\pocketmine\network\mcpe\protocol` namespace have been removed:
- `FullChunkDataPacket`
- The following classes in the `\pocketmine\network\mcpe\protocol` namespace have been added:
- `AddEntityPacket` (not to be confused with the old one)
- `ClientCacheBlobStatusPacket`
- `ClientCacheMissResponsePacket`
- `ClientCacheStatusPacket`
- `LevelChunkPacket`
- `RemoveEntityPacket` (not to be confused with the old one)
- `StructureTemplateDataExportRequestPacket`
- `StructureTemplateDataExportResponsePacket`
# 3.9.1
- Fixed resource packs not working on 1.12 clients.
- Fixed some particles displaying incorrectly (some still don't render at all).
- Fixed `Entity->setFireTicks()` with a value of `0` setting the on-fire flag.
- Silenced a debug message which appeared every time a player right-clicked a block.
- Updated constants for `LevelSoundEventPacket`.
# 3.9.2
- Logger warnings for illegal player movements have been lowered to debug.
- TNT explosions now start from the center instead of the base. This fixes unexpected results when TNT is lit on top of obsidian.
- Fixed the `loadbefore` directive in `plugin.yml` sometimes being ignored.
- Fixed `Item->setCustomName()` with an empty string leaving behind an empty tag.
- Fixed incorrect positioning of bucket empty sound.
- Fixed some incorrect tag parsing in `/give` involving quoted numbers.
# 3.9.3
- Fixed a memory leak on async task removal in error conditions.
- Fixed scheduled block updates (for example liquid) triggering chunk reloading. This could cause a significant performance issue in some conditions.
- Fixed some minor cosmetic issues in documentation.
# 3.9.4
- Fixed a memory leak when scheduled updates were pending on a chunk being unloaded.
- Fixed plugin detection in crashdumps. Previously `src/pocketmine` anywhere in the path would cause the error to be considered a core crash, regardless of the preceding path.
- Fixed entity metadata types for 1.12. The SLOT type was removed and a COMPOUND_TAG type added. This change involves changes to internal API which may break plugins. **See the warning at the top of this changelog about API versioning.**
- Fixed random and base populator amounts of trees and tallgrass never being initialized. This bug had no obvious effect, but may have become a problem in future PHP versions.
- The following internal methods have been marked as `@deprecated` and documentation warnings added:
- `Entity->getBlocksAround()`
- `Entity->despawnFrom()`
- `Entity->despawnFromAll()`
- Fixed plugin `softdepend` not influencing load order when a soft-depended plugin had an unresolved soft dependency of its own.
- Fixed endless falling of sand on top of fences.
# 3.9.5
- Fixed some issues with multiple consecutive commas inside quotes in form responses.
- Fixed server crash when the manifest json does not contain a json object in a resource pack.
- Ender pearls no longer collide with blocks that do not have any collision boxes.
# 3.9.6
- Updated Composer dependencies to their latest versions.
- Prevent clients repeating the resource pack sequence. This fixes error spam with bugged 1.12 clients.
- `Internet::simpleCurl()` now includes the PocketMine-MP version in the user-agent string.
- Spawn protection is now disabled by default in the setup wizard.
- Default difficulty is now NORMAL(2) instead of EASY(1).
- Fixed crashing on corrupted world manifest and unsupported world formats.
- Fixed `/transferserver` being usable without appropriate permissions.
- `RegionLoader->removeChunk()` now writes the region header as appropriate.
- Fixed performance issue when loading large regions (bug in header validation).
- Fixed skin geometry being removed when the JSON contained comments.
- Added new constants to `EventPacket`.
- Added encode/decode for `StructureTemplateDataExportRequestPacket` and `StructureTemplateDataExportResponsePacket`.
- Fixed broken type asserts in `LevelChunkPacket::withCache()` and `ClientCacheMissResponsePacket::create()`.
- `types\CommandParameter` field `byte1` has been renamed to `flags`.
- Cleaned up public interface of `AvailableCommandsPacket`, removing fields which exposed details of the encoding scheme.
- Improved documentation for the following API methods:
- `pocketmine\item\Item`:
- `addCreativeItem()`
- `removeCreativeItem()`
- `clearCreativeItems()`
- `pocketmine\level\Explosion`:
- `explodeA()`
- `explodeB()`
- Fixed various cosmetic documentation inconsistencies in the core and dependencies.
# 3.9.7
- Fixed a crash that could occur during timezone detection.
- Squid no longer spin around constantly in enclosed spaces. Their performance impact is reduced.
- Cleaned up the bootstrap file.
# 3.9.8
- Added [PHPStan](https://github.com/phpstan/phpstan) configuration. PHPStan is now used on CI for automated QA, which should improve stability and quality going forward.
- The following constants are now autoloaded when loading the Composer autoloader:
- `pocketmine\NAME`
- `pocketmine\BASE_VERSION`
- `pocketmine\IS_DEVELOPMENT_BUILD`
- `pocketmine\BUILD_NUMBER`
- `INT32_MIN`
- `INT32_MAX`
- `INT32_MASK`
- Fixed memory leaks and crashes caused by plugin use of `Player->showPlayer()` and `Entity->spawnTo()`.
- Fixed crashes that could occur when tile classes were overridden with classes incompatible with the originals.
- Fixed improper handling of non-Compound root NBT tags on network itemstack decoding.
- Fixed paintings dropping multiple items when destroyed by block updates.
- Fixed `var_dump()` not showing private and protected properties of `DataPacket` subclasses.
- Fixed overloads with zero arguments being missing when decoding `AvailableCommandsPacket`.
- `CraftingDataPacket` now retains the `cleanRecipes` field when decoding.
- Fixed `Block->getMetadata()` returning null (non-iterable).
- `PlayerChatEvent` documentation has been updated to specify that `CommandSender` recipients are accepted. This behaviour was already present in previous versions, but incorrectly documented.
- Fixed various issues with PHPDoc comments reported by PHPStan.
- Fixed various minor code nits reported by PHPStan.

76
composer.json Normal file
View File

@ -0,0 +1,76 @@
{
"name": "pocketmine/pocketmine-mp",
"description": "A server software for Minecraft: Pocket Edition written in PHP",
"type": "project",
"homepage": "https://pmmp.io",
"license": "LGPL-3.0",
"require": {
"php": ">=7.2.0",
"php-64bit": "*",
"ext-bcmath": "*",
"ext-curl": "*",
"ext-ctype": "*",
"ext-date": "*",
"ext-hash": "*",
"ext-json": "*",
"ext-mbstring": "*",
"ext-openssl": "*",
"ext-pcre": "*",
"ext-phar": "*",
"ext-pthreads": "~3.2.0",
"ext-reflection": "*",
"ext-sockets": "*",
"ext-spl": "*",
"ext-yaml": ">=2.0.0",
"ext-zip": "*",
"ext-zlib": ">=1.2.11",
"pocketmine/raklib": "^0.12.5",
"pocketmine/spl": "^0.3.0",
"pocketmine/binaryutils": "^0.1.9",
"pocketmine/nbt": "^0.2.10",
"pocketmine/math": "^0.2.0",
"pocketmine/snooze": "^0.1.0",
"daverandom/callback-validator": "dev-master",
"adhocore/json-comment": "^0.0.7"
},
"autoload": {
"psr-4": {
"": ["src"]
},
"files": [
"src/pocketmine/GlobalConstants.php",
"src/pocketmine/VersionInfo.php"
]
},
"autoload-dev": {
"psr-4": {
"pocketmine\\": "tests/phpunit/"
}
},
"repositories": [
{
"type": "vcs",
"url": "https://github.com/pmmp/RakLib"
},
{
"type": "vcs",
"url": "https://github.com/pmmp/SPL"
},
{
"type": "vcs",
"url": "https://github.com/pmmp/BinaryUtils"
},
{
"type": "vcs",
"url": "https://github.com/pmmp/NBT"
},
{
"type": "vcs",
"url": "https://github.com/pmmp/Math"
},
{
"type": "vcs",
"url": "https://github.com/pmmp/Snooze"
}
]
}

338
composer.lock generated Normal file
View File

@ -0,0 +1,338 @@
{
"_readme": [
"This file locks the dependencies of your project to a known state",
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "377d9e0ab5f1a9a4ef9b664706d26f5b",
"packages": [
{
"name": "adhocore/json-comment",
"version": "v0.0.7",
"source": {
"type": "git",
"url": "https://github.com/adhocore/php-json-comment.git",
"reference": "135356c7e7336ef59924f1d921c770045f937a76"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/adhocore/php-json-comment/zipball/135356c7e7336ef59924f1d921c770045f937a76",
"reference": "135356c7e7336ef59924f1d921c770045f937a76",
"shasum": ""
},
"require": {
"php": ">=5.4"
},
"require-dev": {
"phpunit/phpunit": "^4.8 || ^5.7 || ^6.5"
},
"type": "library",
"autoload": {
"psr-4": {
"Ahc\\Json\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Jitendra Adhikari",
"email": "jiten.adhikary@gmail.com"
}
],
"description": "Lightweight JSON comment stripper library for PHP",
"keywords": [
"comment",
"json",
"strip-comment"
],
"time": "2018-08-01T12:27:26+00:00"
},
{
"name": "daverandom/callback-validator",
"version": "dev-master",
"source": {
"type": "git",
"url": "https://github.com/DaveRandom/CallbackValidator.git",
"reference": "d87a08cddbc6099816ed01e50ce25cdfc43b542f"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/DaveRandom/CallbackValidator/zipball/d87a08cddbc6099816ed01e50ce25cdfc43b542f",
"reference": "d87a08cddbc6099816ed01e50ce25cdfc43b542f",
"shasum": ""
},
"require": {
"ext-reflection": "*",
"php": ">=7.0"
},
"require-dev": {
"phpunit/phpunit": "^6.0"
},
"type": "library",
"autoload": {
"psr-4": {
"DaveRandom\\CallbackValidator\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Chris Wright",
"email": "cw@daverandom.com"
}
],
"description": "Tools for validating callback signatures",
"time": "2017-04-03T15:22:41+00:00"
},
{
"name": "pocketmine/binaryutils",
"version": "0.1.10",
"source": {
"type": "git",
"url": "https://github.com/pmmp/BinaryUtils.git",
"reference": "435f2ee265bce75ef1aa9563f9b60ff36d705e80"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/pmmp/BinaryUtils/zipball/435f2ee265bce75ef1aa9563f9b60ff36d705e80",
"reference": "435f2ee265bce75ef1aa9563f9b60ff36d705e80",
"shasum": ""
},
"require": {
"php": ">=7.2",
"php-64bit": "*"
},
"type": "library",
"autoload": {
"psr-4": {
"pocketmine\\utils\\": "src/"
}
},
"license": [
"LGPL-3.0"
],
"description": "Classes and methods for conveniently handling binary data",
"support": {
"source": "https://github.com/pmmp/BinaryUtils/tree/0.1.10",
"issues": "https://github.com/pmmp/BinaryUtils/issues"
},
"time": "2019-10-21T14:40:32+00:00"
},
{
"name": "pocketmine/math",
"version": "0.2.3",
"source": {
"type": "git",
"url": "https://github.com/pmmp/Math.git",
"reference": "68be8a79fd0169043ef514797c304517cb8a6071"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/pmmp/Math/zipball/68be8a79fd0169043ef514797c304517cb8a6071",
"reference": "68be8a79fd0169043ef514797c304517cb8a6071",
"shasum": ""
},
"require": {
"php": ">=7.2.0",
"php-64bit": "*"
},
"type": "library",
"autoload": {
"psr-4": {
"pocketmine\\math\\": "src/"
}
},
"license": [
"LGPL-3.0"
],
"description": "PHP library containing math related code used in PocketMine-MP",
"support": {
"source": "https://github.com/pmmp/Math/tree/0.2.3",
"issues": "https://github.com/pmmp/Math/issues"
},
"time": "2019-10-21T14:35:10+00:00"
},
{
"name": "pocketmine/nbt",
"version": "0.2.12",
"source": {
"type": "git",
"url": "https://github.com/pmmp/NBT.git",
"reference": "b5777265329753b74dd40bb105eedabeefb98724"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/pmmp/NBT/zipball/b5777265329753b74dd40bb105eedabeefb98724",
"reference": "b5777265329753b74dd40bb105eedabeefb98724",
"shasum": ""
},
"require": {
"ext-zlib": "*",
"php": ">=7.2.0",
"php-64bit": "*",
"pocketmine/binaryutils": "^0.1.9"
},
"type": "library",
"autoload": {
"psr-4": {
"pocketmine\\nbt\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"pocketmine\\nbt\\": "tests/phpunit/"
}
},
"license": [
"LGPL-3.0"
],
"description": "PHP library for working with Named Binary Tags",
"support": {
"source": "https://github.com/pmmp/NBT/tree/0.2",
"issues": "https://github.com/pmmp/NBT/issues"
},
"time": "2019-12-01T08:20:26+00:00"
},
{
"name": "pocketmine/raklib",
"version": "0.12.5",
"source": {
"type": "git",
"url": "https://github.com/pmmp/RakLib.git",
"reference": "874db2d3c24117db2221c1e4550380478aeea852"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/pmmp/RakLib/zipball/874db2d3c24117db2221c1e4550380478aeea852",
"reference": "874db2d3c24117db2221c1e4550380478aeea852",
"shasum": ""
},
"require": {
"ext-bcmath": "*",
"ext-pthreads": "~3.2.0",
"ext-sockets": "*",
"php": ">=7.2.0",
"php-64bit": "*",
"php-ipv6": "*",
"pocketmine/binaryutils": "^0.1.9",
"pocketmine/snooze": "^0.1.0",
"pocketmine/spl": "^0.3.0"
},
"type": "library",
"autoload": {
"psr-4": {
"raklib\\": "src/"
}
},
"license": [
"GPL-3.0"
],
"description": "A RakNet server implementation written in PHP",
"support": {
"source": "https://github.com/pmmp/RakLib/tree/0.12",
"issues": "https://github.com/pmmp/RakLib/issues"
},
"time": "2019-07-22T14:38:20+00:00"
},
{
"name": "pocketmine/snooze",
"version": "0.1.1",
"source": {
"type": "git",
"url": "https://github.com/pmmp/Snooze.git",
"reference": "b7bd231bdb75e69300cac89ccd515fc731c38c40"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/pmmp/Snooze/zipball/b7bd231bdb75e69300cac89ccd515fc731c38c40",
"reference": "b7bd231bdb75e69300cac89ccd515fc731c38c40",
"shasum": ""
},
"require": {
"ext-pthreads": ">=3.1.7dev",
"php-64bit": ">=7.2.0"
},
"type": "library",
"autoload": {
"psr-4": {
"pocketmine\\snooze\\": "src/"
}
},
"license": [
"LGPL-3.0"
],
"description": "Thread notification management library for code using the pthreads extension",
"support": {
"source": "https://github.com/pmmp/Snooze/tree/0.1.1",
"issues": "https://github.com/pmmp/Snooze/issues"
},
"time": "2019-01-04T15:54:45+00:00"
},
{
"name": "pocketmine/spl",
"version": "0.3.3",
"source": {
"type": "git",
"url": "https://github.com/pmmp/SPL.git",
"reference": "94d4df142fe837ba836e9348dd00209e4bdcc307"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/pmmp/SPL/zipball/94d4df142fe837ba836e9348dd00209e4bdcc307",
"reference": "94d4df142fe837ba836e9348dd00209e4bdcc307",
"shasum": ""
},
"type": "library",
"autoload": {
"classmap": [
"./"
]
},
"license": [
"LGPL-3.0"
],
"description": "Standard library files required by PocketMine-MP and related projects",
"support": {
"source": "https://github.com/pmmp/SPL/tree/0.3.3",
"issues": "https://github.com/pmmp/SPL/issues"
},
"time": "2019-10-28T11:41:20+00:00"
}
],
"packages-dev": [],
"aliases": [],
"minimum-stability": "stable",
"stability-flags": {
"daverandom/callback-validator": 20
},
"prefer-stable": false,
"prefer-lowest": false,
"platform": {
"php": ">=7.2.0",
"php-64bit": "*",
"ext-bcmath": "*",
"ext-curl": "*",
"ext-ctype": "*",
"ext-date": "*",
"ext-hash": "*",
"ext-json": "*",
"ext-mbstring": "*",
"ext-openssl": "*",
"ext-pcre": "*",
"ext-phar": "*",
"ext-pthreads": "~3.2.0",
"ext-reflection": "*",
"ext-sockets": "*",
"ext-spl": "*",
"ext-yaml": ">=2.0.0",
"ext-zip": "*",
"ext-zlib": ">=1.2.11"
},
"platform-dev": []
}

2529
doxygen/doxygen.conf Normal file

File diff suppressed because it is too large Load Diff

10
doxygen/index.md Normal file
View File

@ -0,0 +1,10 @@
## PocketMine-MP API Documentation
This site contains auto-generated API documentation for PocketMine-MP (and dependencies which are not outsourced). Documentation here is regenerated for every release.
This site can be accessed via https://apidoc.pmmp.io.
### Additional developer resources
- [DevTools](https://github.com/pmmp/PocketMine-DevTools/) - Development tools plugin for creating plugins
- [ExamplePlugin](https://github.com/pmmp/ExamplePlugin/) - Example plugin demonstrating some basic API features
- [DeveloperDocs](https://github.com/pmmp/DeveloperDocs/) - Reference, guides and specifications for the PocketMine-MP API

124
phpstan.neon.dist Normal file
View File

@ -0,0 +1,124 @@
includes:
- tests/phpstan/configs/gc-hacks.neon
- tests/phpstan/configs/optional-com-dotnet.neon
- tests/phpstan/configs/optional-leveldb.neon
- tests/phpstan/configs/phpstan-bugs.neon
- tests/phpstan/configs/pthreads-bugs.neon
parameters:
level: 3
autoload_files:
- tests/phpstan/bootstrap.php
- src/pocketmine/PocketMine.php
paths:
- src
reportUnmatchedIgnoredErrors: false #no other way to silence platform-specific non-warnings
ignoreErrors:
-
message: "#^Cannot instantiate interface pocketmine\\\\level\\\\format\\\\io\\\\LevelProvider\\.$#"
count: 1
path: src/pocketmine/Server.php
-
message: "#^Call to an undefined method pocketmine\\\\command\\\\CommandSender\\:\\:teleport\\(\\)\\.$#"
count: 1
path: src/pocketmine/command/defaults/TeleportCommand.php
# comment: "not actually possible, but high cost to fix warning"
-
message: "#^Array \\(array\\<string\\>\\) does not accept pocketmine\\\\entity\\\\Entity\\.$#"
count: 2
path: src/pocketmine/entity/Entity.php
-
message: "#^Invalid array key type pocketmine\\\\entity\\\\Entity\\.$#"
count: 1
path: src/pocketmine/entity/Entity.php
-
message: "#^Method pocketmine\\\\event\\\\entity\\\\EntityDeathEvent\\:\\:getEntity\\(\\) should return pocketmine\\\\entity\\\\Living but returns pocketmine\\\\entity\\\\Entity\\.$#"
count: 1
path: src/pocketmine/event/entity/EntityDeathEvent.php
-
message: "#^Method pocketmine\\\\event\\\\entity\\\\EntityShootBowEvent\\:\\:getEntity\\(\\) should return pocketmine\\\\entity\\\\Living but returns pocketmine\\\\entity\\\\Entity\\.$#"
count: 1
path: src/pocketmine/event/entity/EntityShootBowEvent.php
-
message: "#^Property pocketmine\\\\event\\\\entity\\\\EntityShootBowEvent\\:\\:\\$projectile \\(pocketmine\\\\entity\\\\projectile\\\\Projectile\\) does not accept pocketmine\\\\entity\\\\Entity\\.$#"
count: 1
path: src/pocketmine/event/entity/EntityShootBowEvent.php
-
message: "#^Method pocketmine\\\\event\\\\entity\\\\ItemDespawnEvent\\:\\:getEntity\\(\\) should return pocketmine\\\\entity\\\\object\\\\ItemEntity but returns pocketmine\\\\entity\\\\Entity\\.$#"
count: 1
path: src/pocketmine/event/entity/ItemDespawnEvent.php
-
message: "#^Method pocketmine\\\\event\\\\entity\\\\ItemSpawnEvent\\:\\:getEntity\\(\\) should return pocketmine\\\\entity\\\\object\\\\ItemEntity but returns pocketmine\\\\entity\\\\Entity\\.$#"
count: 1
path: src/pocketmine/event/entity/ItemSpawnEvent.php
-
message: "#^Method pocketmine\\\\event\\\\entity\\\\ProjectileHitEvent\\:\\:getEntity\\(\\) should return pocketmine\\\\entity\\\\projectile\\\\Projectile but returns pocketmine\\\\entity\\\\Entity\\.$#"
count: 1
path: src/pocketmine/event/entity/ProjectileHitEvent.php
-
message: "#^Method pocketmine\\\\event\\\\entity\\\\ProjectileLaunchEvent\\:\\:getEntity\\(\\) should return pocketmine\\\\entity\\\\projectile\\\\Projectile but returns pocketmine\\\\entity\\\\Entity\\.$#"
count: 1
path: src/pocketmine/event/entity/ProjectileLaunchEvent.php
-
message: "#^Constructor of class pocketmine\\\\level\\\\generator\\\\hell\\\\Nether has an unused parameter \\$options\\.$#"
count: 1
path: src/pocketmine/level/generator/hell/Nether.php
-
message: "#^Constructor of class pocketmine\\\\level\\\\generator\\\\normal\\\\Normal has an unused parameter \\$options\\.$#"
count: 1
path: src/pocketmine/level/generator/normal/Normal.php
-
message: "#^Used constant pocketmine\\\\RESOURCE_PATH not found\\.$#"
count: 1
path: src/pocketmine/network/mcpe/protocol/StartGamePacket.php
-
message: "#^Constructor of class pocketmine\\\\scheduler\\\\TaskScheduler has an unused parameter \\$logger\\.$#"
count: 1
path: src/pocketmine/scheduler/TaskScheduler.php
-
message: "#^Constant pocketmine\\\\COMPOSER_AUTOLOADER_PATH not found\\.$#"
path: src
-
message: "#^Constant pocketmine\\\\DATA not found\\.$#"
path: src
-
message: "#^Constant pocketmine\\\\GIT_COMMIT not found\\.$#"
path: src
-
message: "#^Constant pocketmine\\\\PATH not found\\.$#"
path: src
-
message: "#^Constant pocketmine\\\\PLUGIN_PATH not found\\.$#"
path: src
-
message: "#^Constant pocketmine\\\\RESOURCE_PATH not found\\.$#"
path: src
-
message: "#^Constant pocketmine\\\\START_TIME not found\\.$#"
path: src
-
message: "#^Constant pocketmine\\\\VERSION not found\\.$#"
path: src

View File

@ -19,9 +19,11 @@
*
*/
declare(strict_types=1);
namespace pocketmine;
use pocketmine\event\TranslationContainer;
use pocketmine\lang\TranslationContainer;
use pocketmine\utils\TextFormat;
/**
@ -39,76 +41,82 @@ abstract class Achievement{
"mineWood" => [
"name" => "Getting Wood",
"requires" => [ //"openInventory",
],
]
],
"buildWorkBench" => [
"name" => "Benchmarking",
"requires" => [
"mineWood",
],
"mineWood"
]
],
"buildPickaxe" => [
"name" => "Time to Mine!",
"requires" => [
"buildWorkBench",
],
"buildWorkBench"
]
],
"buildFurnace" => [
"name" => "Hot Topic",
"requires" => [
"buildPickaxe",
],
"buildPickaxe"
]
],
"acquireIron" => [
"name" => "Acquire hardware",
"requires" => [
"buildFurnace",
],
"buildFurnace"
]
],
"buildHoe" => [
"name" => "Time to Farm!",
"requires" => [
"buildWorkBench",
],
"buildWorkBench"
]
],
"makeBread" => [
"name" => "Bake Bread",
"requires" => [
"buildHoe",
],
"buildHoe"
]
],
"bakeCake" => [
"name" => "The Lie",
"requires" => [
"buildHoe",
],
"buildHoe"
]
],
"buildBetterPickaxe" => [
"name" => "Getting an Upgrade",
"requires" => [
"buildPickaxe",
],
"buildPickaxe"
]
],
"buildSword" => [
"name" => "Time to Strike!",
"requires" => [
"buildWorkBench",
],
"buildWorkBench"
]
],
"diamonds" => [
"name" => "DIAMONDS!",
"requires" => [
"acquireIron",
],
],
"acquireIron"
]
]
];
public static function broadcast(Player $player, $achievementId){
/**
* @param Player $player
* @param string $achievementId
*
* @return bool
*/
public static function broadcast(Player $player, string $achievementId) : bool{
if(isset(Achievement::$list[$achievementId])){
$translation = new TranslationContainer("chat.type.achievement", [$player->getDisplayName(), TextFormat::GREEN . Achievement::$list[$achievementId]["name"]]);
if(Server::getInstance()->getConfigString("announce-player-achievements", true) === true){
$translation = new TranslationContainer("chat.type.achievement", [$player->getDisplayName(), TextFormat::GREEN . Achievement::$list[$achievementId]["name"] . TextFormat::RESET]);
if(Server::getInstance()->getConfigBool("announce-player-achievements", true)){
Server::getInstance()->broadcastMessage($translation);
}else{
$player->sendMessage($translation);
@ -120,11 +128,18 @@ abstract class Achievement{
return false;
}
public static function add($achievementId, $achievementName, array $requires = []){
/**
* @param string $achievementId
* @param string $achievementName
* @param array $requires
*
* @return bool
*/
public static function add(string $achievementId, string $achievementName, array $requires = []) : bool{
if(!isset(Achievement::$list[$achievementId])){
Achievement::$list[$achievementId] = [
"name" => $achievementName,
"requires" => $requires,
"requires" => $requires
];
return true;
@ -132,6 +147,4 @@ abstract class Achievement{
return false;
}
}

View File

@ -19,9 +19,11 @@
*
*/
declare(strict_types=1);
namespace pocketmine;
abstract class Collectable extends \Threaded implements \Collectable{
abstract class Collectable extends \Threaded{
private $isGarbage = false;

View File

@ -19,23 +19,89 @@
*
*/
declare(strict_types=1);
namespace pocketmine;
use pocketmine\network\mcpe\protocol\ProtocolInfo;
use pocketmine\plugin\PluginBase;
use pocketmine\plugin\PluginLoadOrder;
use pocketmine\plugin\PluginManager;
use pocketmine\utils\Utils;
use pocketmine\utils\VersionString;
use raklib\RakLib;
use function base64_encode;
use function date;
use function error_get_last;
use function fclose;
use function file;
use function file_exists;
use function file_get_contents;
use function fopen;
use function fwrite;
use function get_loaded_extensions;
use function implode;
use function is_dir;
use function is_resource;
use function json_encode;
use function json_last_error_msg;
use function max;
use function mkdir;
use function ob_end_clean;
use function ob_get_contents;
use function ob_start;
use function php_uname;
use function phpinfo;
use function phpversion;
use function preg_replace;
use function str_split;
use function strpos;
use function substr;
use function time;
use function zend_version;
use function zlib_encode;
use const E_COMPILE_ERROR;
use const E_COMPILE_WARNING;
use const E_CORE_ERROR;
use const E_CORE_WARNING;
use const E_DEPRECATED;
use const E_ERROR;
use const E_NOTICE;
use const E_PARSE;
use const E_RECOVERABLE_ERROR;
use const E_STRICT;
use const E_USER_DEPRECATED;
use const E_USER_ERROR;
use const E_USER_NOTICE;
use const E_USER_WARNING;
use const E_WARNING;
use const FILE_IGNORE_NEW_LINES;
use const JSON_UNESCAPED_SLASHES;
use const PHP_EOL;
use const PHP_OS;
class CrashDump{
/**
* Crashdump data format version, used by the crash archive to decide how to decode the crashdump
* This should be incremented when backwards incompatible changes are introduced, such as fields being removed or
* having their content changed, version format changing, etc.
* It is not necessary to increase this when adding new fields.
*/
private const FORMAT_VERSION = 2;
private const PLUGIN_INVOLVEMENT_NONE = "none";
private const PLUGIN_INVOLVEMENT_DIRECT = "direct";
private const PLUGIN_INVOLVEMENT_INDIRECT = "indirect";
/** @var Server */
private $server;
private $fp;
private $time;
private $data = [];
private $encodedData = null;
/** @var string */
private $encodedData = "";
/** @var string */
private $path;
public function __construct(Server $server){
@ -49,6 +115,7 @@ class CrashDump{
if(!is_resource($this->fp)){
throw new \RuntimeException("Could not create Crash Dump");
}
$this->data["format_version"] = self::FORMAT_VERSION;
$this->data["time"] = $this->time;
$this->addLine($this->server->getName() . " Crash Dump " . date("D M j H:i:s T Y", $this->time));
$this->addLine();
@ -59,9 +126,11 @@ class CrashDump{
$this->extraData();
$this->encodeData();
fclose($this->fp);
}
public function getPath(){
public function getPath() : string{
return $this->path;
}
@ -69,7 +138,7 @@ class CrashDump{
return $this->encodedData;
}
public function getData(){
public function getData() : array{
return $this->data;
}
@ -78,7 +147,11 @@ class CrashDump{
$this->addLine("----------------------REPORT THE DATA BELOW THIS LINE-----------------------");
$this->addLine();
$this->addLine("===BEGIN CRASH DUMP===");
$this->encodedData = zlib_encode(json_encode($this->data, JSON_UNESCAPED_SLASHES), ZLIB_ENCODING_DEFLATE, 9);
$json = json_encode($this->data, JSON_UNESCAPED_SLASHES);
if($json === false){
throw new \RuntimeException("Failed to encode crashdump JSON: " . json_last_error_msg());
}
$this->encodedData = zlib_encode($json, ZLIB_ENCODING_DEFLATE, 9);
foreach(str_split(base64_encode($this->encodedData), 76) as $line){
$this->addLine($line);
}
@ -86,7 +159,7 @@ class CrashDump{
}
private function pluginsData(){
if(class_exists("pocketmine\\plugin\\PluginManager", false)){
if($this->server->getPluginManager() instanceof PluginManager){
$this->addLine();
$this->addLine("Loaded plugins:");
$this->data["plugins"] = [];
@ -110,10 +183,10 @@ class CrashDump{
}
private function extraData(){
global $arguments;
global $argv;
if($this->server->getProperty("auto-report.send-settings", true) !== false){
$this->data["parameters"] = (array) $arguments;
$this->data["parameters"] = (array) $argv;
$this->data["server.properties"] = @file_get_contents($this->server->getDataPath() . "server.properties");
$this->data["server.properties"] = preg_replace("#^rcon\\.password=(.*)$#m", "rcon.password=******", $this->data["server.properties"]);
$this->data["pocketmine.yml"] = @file_get_contents($this->server->getDataPath() . "pocketmine.yml");
@ -143,7 +216,7 @@ class CrashDump{
$error = $lastExceptionError;
}else{
$error = (array) error_get_last();
$error["trace"] = getTrace(4); //Skipping CrashDump->baseCrash, CrashDump->construct, Server->crashDump
$error["trace"] = Utils::currentTrace(3); //Skipping CrashDump->baseCrash, CrashDump->construct, Server->crashDump
$errorConversion = [
E_ERROR => "E_ERROR",
E_WARNING => "E_WARNING",
@ -159,10 +232,10 @@ class CrashDump{
E_STRICT => "E_STRICT",
E_RECOVERABLE_ERROR => "E_RECOVERABLE_ERROR",
E_DEPRECATED => "E_DEPRECATED",
E_USER_DEPRECATED => "E_USER_DEPRECATED",
E_USER_DEPRECATED => "E_USER_DEPRECATED"
];
$error["fullFile"] = $error["file"];
$error["file"] = cleanPath($error["file"]);
$error["file"] = Utils::cleanPath($error["file"]);
$error["type"] = $errorConversion[$error["type"]] ?? $error["type"];
if(($pos = strpos($error["message"], "\n")) !== false){
$error["message"] = substr($error["message"], 0, $pos);
@ -170,6 +243,9 @@ class CrashDump{
}
if(isset($lastError)){
if(isset($lastError["trace"])){
$lastError["trace"] = Utils::printableTrace($lastError["trace"]);
}
$this->data["lastError"] = $lastError;
}
@ -181,53 +257,74 @@ class CrashDump{
$this->addLine("Line: " . $error["line"]);
$this->addLine("Type: " . $error["type"]);
if(strpos($error["file"], "src/pocketmine/") === false and strpos($error["file"], "src/raklib/") === false and file_exists($error["fullFile"])){
$this->addLine();
$this->addLine("THIS CRASH WAS CAUSED BY A PLUGIN");
$this->data["plugin"] = true;
$reflection = new \ReflectionClass(PluginBase::class);
$file = $reflection->getProperty("file");
$file->setAccessible(true);
foreach($this->server->getPluginManager()->getPlugins() as $plugin){
$filePath = \pocketmine\cleanPath($file->getValue($plugin));
if(strpos($error["file"], $filePath) === 0){
$this->data["plugin"] = $plugin->getName();
$this->addLine("BAD PLUGIN: " . $plugin->getDescription()->getFullName());
$this->data["plugin_involvement"] = self::PLUGIN_INVOLVEMENT_NONE;
if(!$this->determinePluginFromFile($error["fullFile"], true)){ //fatal errors won't leave any stack trace
foreach($error["trace"] as $frame){
if(!isset($frame["file"])){
continue; //PHP core
}
if($this->determinePluginFromFile($frame["file"], false)){
break;
}
}
}else{
$this->data["plugin"] = false;
}
$this->addLine();
$this->addLine("Code:");
$this->data["code"] = [];
if($this->server->getProperty("auto-report.send-code", true) !== false){
if($this->server->getProperty("auto-report.send-code", true) !== false and file_exists($error["fullFile"])){
$file = @file($error["fullFile"], FILE_IGNORE_NEW_LINES);
for($l = max(0, $error["line"] - 10); $l < $error["line"] + 10; ++$l){
$this->addLine("[" . ($l + 1) . "] " . @$file[$l]);
$this->data["code"][$l + 1] = @$file[$l];
for($l = max(0, $error["line"] - 10); $l < $error["line"] + 10 and isset($file[$l]); ++$l){
$this->addLine("[" . ($l + 1) . "] " . $file[$l]);
$this->data["code"][$l + 1] = $file[$l];
}
}
$this->addLine();
$this->addLine("Backtrace:");
foreach(($this->data["trace"] = $error["trace"]) as $line){
foreach(($this->data["trace"] = Utils::printableTrace($error["trace"])) as $line){
$this->addLine($line);
}
$this->addLine();
}
private function determinePluginFromFile(string $filePath, bool $crashFrame) : bool{
$frameCleanPath = Utils::cleanPath($filePath); //this will be empty in phar stub
if(strpos($frameCleanPath, "plugins") === 0 and file_exists($filePath)){
$this->addLine();
if($crashFrame){
$this->addLine("THIS CRASH WAS CAUSED BY A PLUGIN");
$this->data["plugin_involvement"] = self::PLUGIN_INVOLVEMENT_DIRECT;
}else{
$this->addLine("A PLUGIN WAS INVOLVED IN THIS CRASH");
$this->data["plugin_involvement"] = self::PLUGIN_INVOLVEMENT_INDIRECT;
}
$reflection = new \ReflectionClass(PluginBase::class);
$file = $reflection->getProperty("file");
$file->setAccessible(true);
foreach($this->server->getPluginManager()->getPlugins() as $plugin){
$filePath = Utils::cleanPath($file->getValue($plugin));
if(strpos($frameCleanPath, $filePath) === 0){
$this->data["plugin"] = $plugin->getName();
$this->addLine("BAD PLUGIN: " . $plugin->getDescription()->getFullName());
break;
}
}
return true;
}
return false;
}
private function generalData(){
$version = new VersionString();
$version = new VersionString(\pocketmine\BASE_VERSION, \pocketmine\IS_DEVELOPMENT_BUILD, \pocketmine\BUILD_NUMBER);
$this->data["general"] = [];
$this->data["general"]["version"] = $version->get(false);
$this->data["general"]["build"] = $version->getBuild();
$this->data["general"]["name"] = $this->server->getName();
$this->data["general"]["base_version"] = \pocketmine\BASE_VERSION;
$this->data["general"]["build"] = \pocketmine\BUILD_NUMBER;
$this->data["general"]["is_dev"] = \pocketmine\IS_DEVELOPMENT_BUILD;
$this->data["general"]["protocol"] = ProtocolInfo::CURRENT_PROTOCOL;
$this->data["general"]["api"] = \pocketmine\API_VERSION;
$this->data["general"]["git"] = \pocketmine\GIT_COMMIT;
$this->data["general"]["raklib"] = RakLib::VERSION;
$this->data["general"]["uname"] = php_uname("a");
@ -235,8 +332,8 @@ class CrashDump{
$this->data["general"]["zend"] = zend_version();
$this->data["general"]["php_os"] = PHP_OS;
$this->data["general"]["os"] = Utils::getOS();
$this->addLine("PocketMine-MP version: " . $version->get(false) . " #" . $version->getBuild() . " [Protocol " . ProtocolInfo::CURRENT_PROTOCOL . "; API " . API_VERSION . "]");
$this->addLine("Git commit: " . GIT_COMMIT);
$this->addLine($this->server->getName() . " version: " . $version->getFullVersion(true) . " [Protocol " . ProtocolInfo::CURRENT_PROTOCOL . "]");
$this->addLine("Git commit: " . \pocketmine\GIT_COMMIT);
$this->addLine("uname -a: " . php_uname("a"));
$this->addLine("PHP Version: " . phpversion());
$this->addLine("Zend version: " . zend_version());
@ -250,5 +347,4 @@ class CrashDump{
public function add($str){
fwrite($this->fp, $str);
}
}
}

View File

@ -19,10 +19,12 @@
*
*/
namespace pocketmine\item;
class BlazePowder extends Item{
public function __construct($meta = 0, $count = 1){
parent::__construct(self::BLAZE_POWDER, $meta, $count, "Blaze Powder");
}
// composer autoload doesn't use require_once and also pthreads can inherit things
if(defined('pocketmine\_GLOBAL_CONSTANTS_INCLUDED')){
return;
}
define('pocketmine\_GLOBAL_CONSTANTS_INCLUDED', true);
const INT32_MIN = -0x80000000;
const INT32_MAX = 0x7fffffff;
const INT32_MASK = 0xffffffff;

View File

@ -19,6 +19,8 @@
*
*/
declare(strict_types=1);
namespace pocketmine;
use pocketmine\permission\ServerOperator;
@ -28,32 +30,32 @@ interface IPlayer extends ServerOperator{
/**
* @return bool
*/
public function isOnline();
public function isOnline() : bool;
/**
* @return string
*/
public function getName();
public function getName() : string;
/**
* @return bool
*/
public function isBanned();
public function isBanned() : bool;
/**
* @param bool $banned
*/
public function setBanned($banned);
public function setBanned(bool $banned);
/**
* @return bool
*/
public function isWhitelisted();
public function isWhitelisted() : bool;
/**
* @param bool $value
*/
public function setWhitelisted($value);
public function setWhitelisted(bool $value);
/**
* @return Player|null
@ -61,18 +63,18 @@ interface IPlayer extends ServerOperator{
public function getPlayer();
/**
* @return int|double
* @return int|null
*/
public function getFirstPlayed();
/**
* @return int|double
* @return int|null
*/
public function getLastPlayed();
/**
* @return mixed
* @return bool
*/
public function hasPlayedBefore();
public function hasPlayedBefore() : bool;
}

View File

@ -19,40 +19,95 @@
*
*/
declare(strict_types=1);
namespace pocketmine;
use pocketmine\event\server\LowMemoryEvent;
use pocketmine\event\Timings;
use pocketmine\scheduler\DumpWorkerMemoryTask;
use pocketmine\scheduler\GarbageCollectionTask;
use pocketmine\timings\Timings;
use pocketmine\utils\Utils;
use function arsort;
use function count;
use function fclose;
use function file_exists;
use function file_put_contents;
use function fopen;
use function fwrite;
use function gc_collect_cycles;
use function gc_disable;
use function gc_enable;
use function get_class;
use function get_declared_classes;
use function implode;
use function ini_get;
use function ini_set;
use function is_array;
use function is_object;
use function is_resource;
use function is_string;
use function json_encode;
use function min;
use function mkdir;
use function preg_match;
use function print_r;
use function round;
use function spl_object_hash;
use function sprintf;
use function strlen;
use function strtoupper;
use function substr;
use const JSON_PRETTY_PRINT;
use const JSON_UNESCAPED_SLASHES;
use const SORT_NUMERIC;
class MemoryManager{
/** @var Server */
private $server;
/** @var int */
private $memoryLimit;
/** @var int */
private $globalMemoryLimit;
/** @var int */
private $checkRate;
/** @var int */
private $checkTicker = 0;
/** @var bool */
private $lowMemory = false;
/** @var bool */
private $continuousTrigger = true;
/** @var int */
private $continuousTriggerRate;
/** @var int */
private $continuousTriggerCount = 0;
/** @var int */
private $continuousTriggerTicker = 0;
/** @var int */
private $garbageCollectionPeriod;
/** @var int */
private $garbageCollectionTicker = 0;
/** @var bool */
private $garbageCollectionTrigger;
/** @var bool */
private $garbageCollectionAsync;
private $chunkRadiusOverride;
private $chunkCollect;
private $chunkTrigger;
/** @var int */
private $lowMemChunkRadiusOverride;
/** @var bool */
private $lowMemChunkGC;
private $chunkCache;
private $cacheTrigger;
/** @var bool */
private $lowMemDisableChunkCache;
/** @var bool */
private $lowMemClearWorldCache;
/** @var bool */
private $dumpWorkers = true;
public function __construct(Server $server){
$this->server = $server;
@ -90,7 +145,7 @@ class MemoryManager{
$hardLimit = ((int) $this->server->getProperty("memory.main-hard-limit", $defaultMemory));
if($hardLimit <= 0){
ini_set("memory_limit", -1);
ini_set("memory_limit", '-1');
}else{
ini_set("memory_limit", $hardLimit . "M");
}
@ -104,22 +159,28 @@ class MemoryManager{
$this->garbageCollectionTrigger = (bool) $this->server->getProperty("memory.garbage-collection.low-memory-trigger", true);
$this->garbageCollectionAsync = (bool) $this->server->getProperty("memory.garbage-collection.collect-async-worker", true);
$this->chunkRadiusOverride = (int) $this->server->getProperty("memory.max-chunks.chunk-radius", 4);
$this->chunkCollect = (bool) $this->server->getProperty("memory.max-chunks.trigger-chunk-collect", true);
$this->chunkTrigger = (bool) $this->server->getProperty("memory.max-chunks.low-memory-trigger", true);
$this->lowMemChunkRadiusOverride = (int) $this->server->getProperty("memory.max-chunks.chunk-radius", 4);
$this->lowMemChunkGC = (bool) $this->server->getProperty("memory.max-chunks.trigger-chunk-collect", true);
$this->chunkCache = (bool) $this->server->getProperty("memory.world-caches.disable-chunk-cache", true);
$this->cacheTrigger = (bool) $this->server->getProperty("memory.world-caches.low-memory-trigger", true);
$this->lowMemDisableChunkCache = (bool) $this->server->getProperty("memory.world-caches.disable-chunk-cache", true);
$this->lowMemClearWorldCache = (bool) $this->server->getProperty("memory.world-caches.low-memory-trigger", true);
$this->dumpWorkers = (bool) $this->server->getProperty("memory.memory-dump.dump-async-worker", true);
gc_enable();
}
public function isLowMemory(){
/**
* @return bool
*/
public function isLowMemory() : bool{
return $this->lowMemory;
}
public function canUseChunkCache(){
return !($this->lowMemory and $this->chunkTrigger);
/**
* @return bool
*/
public function canUseChunkCache() : bool{
return !$this->lowMemory or !$this->lowMemDisableChunkCache;
}
/**
@ -130,26 +191,34 @@ class MemoryManager{
* @return int
*/
public function getViewDistance(int $distance) : int{
return $this->lowMemory ? min($this->chunkRadiusOverride, $distance) : $distance;
return ($this->lowMemory and $this->lowMemChunkRadiusOverride > 0) ? (int) min($this->lowMemChunkRadiusOverride, $distance) : $distance;
}
public function trigger($memory, $limit, $global = false, $triggerCount = 0){
/**
* Triggers garbage collection and cache cleanup to try and free memory.
*
* @param int $memory
* @param int $limit
* @param bool $global
* @param int $triggerCount
*/
public function trigger(int $memory, int $limit, bool $global = false, int $triggerCount = 0){
$this->server->getLogger()->debug(sprintf("[Memory Manager] %sLow memory triggered, limit %gMB, using %gMB",
$global ? "Global " : "", round(($limit / 1024) / 1024, 2), round(($memory / 1024) / 1024, 2)));
if($this->cacheTrigger){
if($this->lowMemClearWorldCache){
foreach($this->server->getLevels() as $level){
$level->clearCache(true);
}
}
if($this->chunkTrigger and $this->chunkCollect){
if($this->lowMemChunkGC){
foreach($this->server->getLevels() as $level){
$level->doChunkGarbageCollection();
}
}
$ev = new LowMemoryEvent($memory, $limit, $global, $triggerCount);
$this->server->getPluginManager()->callEvent($ev);
$ev->call();
$cycles = 0;
if($this->garbageCollectionTrigger){
@ -159,6 +228,9 @@ class MemoryManager{
$this->server->getLogger()->debug(sprintf("[Memory Manager] Freed %gMB, $cycles cycles", round(($ev->getMemoryFreed() / 1024) / 1024, 2)));
}
/**
* Called every tick to update the memory manager state.
*/
public function check(){
Timings::$memoryManagerTimer->startTiming();
@ -196,13 +268,19 @@ class MemoryManager{
Timings::$memoryManagerTimer->stopTiming();
}
public function triggerGarbageCollector(){
/**
* @return int
*/
public function triggerGarbageCollector() : int{
Timings::$garbageCollectorTimer->startTiming();
if($this->garbageCollectionAsync){
$size = $this->server->getScheduler()->getAsyncTaskPoolSize();
for($i = 0; $i < $size; ++$i){
$this->server->getScheduler()->scheduleAsyncTaskToWorker(new GarbageCollectionTask(), $i);
$pool = $this->server->getAsyncPool();
if(($w = $pool->shutdownUnusedWorkers()) > 0){
$this->server->getLogger()->debug("Shut down $w idle async pool workers");
}
foreach($pool->getRunningWorkers() as $i){
$pool->submitTaskToWorker(new GarbageCollectionTask(), $i);
}
}
@ -213,26 +291,112 @@ class MemoryManager{
return $cycles;
}
public function dumpServerMemory($outputFolder, $maxNesting, $maxStringSize){
/**
* Dumps the server memory into the specified output folder.
*
* @param string $outputFolder
* @param int $maxNesting
* @param int $maxStringSize
*/
public function dumpServerMemory(string $outputFolder, int $maxNesting, int $maxStringSize){
$this->server->getLogger()->notice("[Dump] After the memory dump is done, the server might crash");
self::dumpMemory($this->server, $outputFolder, $maxNesting, $maxStringSize, $this->server->getLogger());
if($this->dumpWorkers){
$pool = $this->server->getAsyncPool();
foreach($pool->getRunningWorkers() as $i){
$pool->submitTaskToWorker(new DumpWorkerMemoryTask($outputFolder, $maxNesting, $maxStringSize), $i);
}
}
}
/**
* Static memory dumper accessible from any thread.
*
* @param mixed $startingObject
* @param string $outputFolder
* @param int $maxNesting
* @param int $maxStringSize
* @param \Logger $logger
*
* @throws \ReflectionException
*/
public static function dumpMemory($startingObject, string $outputFolder, int $maxNesting, int $maxStringSize, \Logger $logger){
$hardLimit = ini_get('memory_limit');
ini_set('memory_limit', '-1');
gc_disable();
if(!file_exists($outputFolder)){
mkdir($outputFolder, 0777, true);
}
$this->server->getLogger()->notice("[Dump] After the memory dump is done, the server might crash");
$obData = fopen($outputFolder . "/objects.js", "wb+");
$staticProperties = [];
$data = [];
$objects = [];
$refCounts = [];
$this->continueDump($this->server, $data, $objects, $refCounts, 0, $maxNesting, $maxStringSize);
$instanceCounts = [];
$staticProperties = [];
$staticCount = 0;
foreach(get_declared_classes() as $className){
$reflection = new \ReflectionClass($className);
$staticProperties[$className] = [];
foreach($reflection->getProperties() as $property){
if(!$property->isStatic() or $property->getDeclaringClass()->getName() !== $className){
continue;
}
if(!$property->isPublic()){
$property->setAccessible(true);
}
$staticCount++;
self::continueDump($property->getValue(), $staticProperties[$className][$property->getName()], $objects, $refCounts, 0, $maxNesting, $maxStringSize);
}
if(count($staticProperties[$className]) === 0){
unset($staticProperties[$className]);
}
}
file_put_contents($outputFolder . "/staticProperties.js", json_encode($staticProperties, JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT));
$logger->info("[Dump] Wrote $staticCount static properties");
if(isset($GLOBALS)){ //This might be null if we're on a different thread
$globalVariables = [];
$globalCount = 0;
$ignoredGlobals = [
'GLOBALS' => true,
'_SERVER' => true,
'_REQUEST' => true,
'_POST' => true,
'_GET' => true,
'_FILES' => true,
'_ENV' => true,
'_COOKIE' => true,
'_SESSION' => true
];
foreach($GLOBALS as $varName => $value){
if(isset($ignoredGlobals[$varName])){
continue;
}
$globalCount++;
self::continueDump($value, $globalVariables[$varName], $objects, $refCounts, 0, $maxNesting, $maxStringSize);
}
file_put_contents($outputFolder . "/globalVariables.js", json_encode($globalVariables, JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT));
$logger->info("[Dump] Wrote $globalCount global variables");
}
self::continueDump($startingObject, $data, $objects, $refCounts, 0, $maxNesting, $maxStringSize);
do{
$continue = false;
@ -243,6 +407,11 @@ class MemoryManager{
$continue = true;
$className = get_class($object);
if(!isset($instanceCounts[$className])){
$instanceCounts[$className] = 1;
}else{
$instanceCounts[$className]++;
}
$objects[$hash] = true;
@ -261,49 +430,56 @@ class MemoryManager{
$info["implements"] = implode(", ", $reflection->getInterfaceNames());
}
foreach($reflection->getProperties() as $property){
if($property->isStatic()){
continue;
}
if(!$property->isPublic()){
$property->setAccessible(true);
}
$this->continueDump($property->getValue($object), $info["properties"][$property->getName()], $objects, $refCounts, 0, $maxNesting, $maxStringSize);
}
fwrite($obData, "$hash@$className: " . json_encode($info, JSON_UNESCAPED_SLASHES) . "\n");
if(!isset($objects["staticProperties"][$className])){
$staticProperties[$className] = [];
for($original = $reflection; $reflection !== false; $reflection = $reflection->getParentClass()){
foreach($reflection->getProperties() as $property){
if(!$property->isStatic() or $property->getDeclaringClass()->getName() !== $className){
if($property->isStatic()){
continue;
}
$name = $property->getName();
if($reflection !== $original and !$property->isPublic()){
$name = $reflection->getName() . ":" . $name;
}
if(!$property->isPublic()){
$property->setAccessible(true);
}
$this->continueDump($property->getValue($object), $staticProperties[$className][$property->getName()], $objects, $refCounts, 0, $maxNesting, $maxStringSize);
self::continueDump($property->getValue($object), $info["properties"][$name], $objects, $refCounts, 0, $maxNesting, $maxStringSize);
}
}
fwrite($obData, "$hash@$className: " . json_encode($info, JSON_UNESCAPED_SLASHES) . "\n");
}
echo "[Dump] Wrote " . count($objects) . " objects\n";
}while($continue);
$logger->info("[Dump] Wrote " . count($objects) . " objects");
fclose($obData);
file_put_contents($outputFolder . "/staticProperties.js", json_encode($staticProperties, JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT));
file_put_contents($outputFolder . "/serverEntry.js", json_encode($data, JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT));
file_put_contents($outputFolder . "/referenceCounts.js", json_encode($refCounts, JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT));
echo "[Dump] Finished!\n";
arsort($instanceCounts, SORT_NUMERIC);
file_put_contents($outputFolder . "/instanceCounts.js", json_encode($instanceCounts, JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT));
$logger->info("[Dump] Finished!");
ini_set('memory_limit', $hardLimit);
gc_enable();
}
private function continueDump($from, &$data, &$objects, &$refCounts, $recursion, $maxNesting, $maxStringSize){
/**
* @param mixed $from
* @param mixed &$data
* @param object[] &$objects
* @param int[] &$refCounts
* @param int $recursion
* @param int $maxNesting
* @param int $maxStringSize
*/
private static function continueDump($from, &$data, array &$objects, array &$refCounts, int $recursion, int $maxNesting, int $maxStringSize){
if($maxNesting <= 0){
$data = "(error) NESTING LIMIT REACHED";
return;
@ -327,10 +503,10 @@ class MemoryManager{
}
$data = [];
foreach($from as $key => $value){
$this->continueDump($value, $data[$key], $objects, $refCounts, $recursion + 1, $maxNesting, $maxStringSize);
self::continueDump($value, $data[$key], $objects, $refCounts, $recursion + 1, $maxNesting, $maxStringSize);
}
}elseif(is_string($from)){
$data = "(string) len(". strlen($from) .") " . substr(Utils::printable($from), 0, $maxStringSize);
$data = "(string) len(" . strlen($from) . ") " . substr(Utils::printable($from), 0, $maxStringSize);
}elseif(is_resource($from)){
$data = "(resource) " . print_r($from, true);
}else{

View File

@ -19,6 +19,8 @@
*
*/
declare(strict_types=1);
namespace pocketmine;
use pocketmine\metadata\Metadatable;
@ -28,29 +30,30 @@ use pocketmine\plugin\Plugin;
class OfflinePlayer implements IPlayer, Metadatable{
/** @var string */
private $name;
/** @var Server */
private $server;
private $namedtag;
/** @var CompoundTag|null */
private $namedtag = null;
/**
* @param Server $server
* @param string $name
*/
public function __construct(Server $server, $name){
public function __construct(Server $server, string $name){
$this->server = $server;
$this->name = $name;
if(file_exists($this->server->getDataPath() . "players/" . strtolower($this->getName()) . ".dat")){
if($this->server->hasOfflinePlayerData($this->name)){
$this->namedtag = $this->server->getOfflinePlayerData($this->name);
}else{
$this->namedtag = null;
}
}
public function isOnline(){
public function isOnline() : bool{
return $this->getPlayer() !== null;
}
public function getName(){
public function getName() : string{
return $this->name;
}
@ -58,77 +61,75 @@ class OfflinePlayer implements IPlayer, Metadatable{
return $this->server;
}
public function isOp(){
return $this->server->isOp(strtolower($this->getName()));
public function isOp() : bool{
return $this->server->isOp($this->name);
}
public function setOp($value){
public function setOp(bool $value){
if($value === $this->isOp()){
return;
}
if($value === true){
$this->server->addOp(strtolower($this->getName()));
if($value){
$this->server->addOp($this->name);
}else{
$this->server->removeOp(strtolower($this->getName()));
$this->server->removeOp($this->name);
}
}
public function isBanned(){
return $this->server->getNameBans()->isBanned(strtolower($this->getName()));
public function isBanned() : bool{
return $this->server->getNameBans()->isBanned($this->name);
}
public function setBanned($value){
if($value === true){
$this->server->getNameBans()->addBan($this->getName(), null, null, null);
public function setBanned(bool $value){
if($value){
$this->server->getNameBans()->addBan($this->name, null, null, null);
}else{
$this->server->getNameBans()->remove($this->getName());
$this->server->getNameBans()->remove($this->name);
}
}
public function isWhitelisted(){
return $this->server->isWhitelisted(strtolower($this->getName()));
public function isWhitelisted() : bool{
return $this->server->isWhitelisted($this->name);
}
public function setWhitelisted($value){
if($value === true){
$this->server->addWhitelist(strtolower($this->getName()));
public function setWhitelisted(bool $value){
if($value){
$this->server->addWhitelist($this->name);
}else{
$this->server->removeWhitelist(strtolower($this->getName()));
$this->server->removeWhitelist($this->name);
}
}
public function getPlayer(){
return $this->server->getPlayerExact($this->getName());
return $this->server->getPlayerExact($this->name);
}
public function getFirstPlayed(){
return $this->namedtag instanceof CompoundTag ? $this->namedtag["firstPlayed"] : null;
return $this->namedtag instanceof CompoundTag ? $this->namedtag->getLong("firstPlayed", 0, true) : null;
}
public function getLastPlayed(){
return $this->namedtag instanceof CompoundTag ? $this->namedtag["lastPlayed"] : null;
return $this->namedtag instanceof CompoundTag ? $this->namedtag->getLong("lastPlayed", 0, true) : null;
}
public function hasPlayedBefore(){
public function hasPlayedBefore() : bool{
return $this->namedtag instanceof CompoundTag;
}
public function setMetadata($metadataKey, MetadataValue $metadataValue){
$this->server->getPlayerMetadata()->setMetadata($this, $metadataKey, $metadataValue);
public function setMetadata(string $metadataKey, MetadataValue $newMetadataValue){
$this->server->getPlayerMetadata()->setMetadata($this, $metadataKey, $newMetadataValue);
}
public function getMetadata($metadataKey){
public function getMetadata(string $metadataKey){
return $this->server->getPlayerMetadata()->getMetadata($this, $metadataKey);
}
public function hasMetadata($metadataKey){
public function hasMetadata(string $metadataKey) : bool{
return $this->server->getPlayerMetadata()->hasMetadata($this, $metadataKey);
}
public function removeMetadata($metadataKey, Plugin $plugin){
$this->server->getPlayerMetadata()->removeMetadata($this, $metadataKey, $plugin);
public function removeMetadata(string $metadataKey, Plugin $owningPlugin){
$this->server->getPlayerMetadata()->removeMetadata($this, $metadataKey, $owningPlugin);
}
}

File diff suppressed because it is too large Load Diff

View File

@ -19,507 +19,279 @@
*
*/
namespace {
function safe_var_dump(){
static $cnt = 0;
foreach(func_get_args() as $var){
switch(true){
case is_array($var):
echo str_repeat(" ", $cnt) . "array(" . count($var) . ") {" . PHP_EOL;
foreach($var as $key => $value){
echo str_repeat(" ", $cnt + 1) . "[" . (is_int($key) ? $key : '"' . $key . '"') . "]=>" . PHP_EOL;
++$cnt;
safe_var_dump($value);
--$cnt;
}
echo str_repeat(" ", $cnt) . "}" . PHP_EOL;
break;
case is_int($var):
echo str_repeat(" ", $cnt) . "int(" . $var . ")" . PHP_EOL;
break;
case is_float($var):
echo str_repeat(" ", $cnt) . "float(" . $var . ")" . PHP_EOL;
break;
case is_bool($var):
echo str_repeat(" ", $cnt) . "bool(" . ($var === true ? "true" : "false") . ")" . PHP_EOL;
break;
case is_string($var):
echo str_repeat(" ", $cnt) . "string(" . strlen($var) . ") \"$var\"" . PHP_EOL;
break;
case is_resource($var):
echo str_repeat(" ", $cnt) . "resource() of type (" . get_resource_type($var) . ")" . PHP_EOL;
break;
case is_object($var):
echo str_repeat(" ", $cnt) . "object(" . get_class($var) . ")" . PHP_EOL;
break;
case is_null($var):
echo str_repeat(" ", $cnt) . "NULL" . PHP_EOL;
break;
}
}
}
function dummy(){
}
}
declare(strict_types=1);
namespace pocketmine {
use pocketmine\utils\Binary;
use pocketmine\utils\MainLogger;
use pocketmine\utils\ServerKiller;
use pocketmine\utils\Terminal;
use pocketmine\utils\Timezone;
use pocketmine\utils\Utils;
use pocketmine\utils\VersionString;
use pocketmine\wizard\SetupWizard;
use raklib\RakLib;
const VERSION = "1.6.2dev";
const API_VERSION = "3.0.0-ALPHA5";
const CODENAME = "Unleashed";
require_once __DIR__ . '/VersionInfo.php';
const MIN_PHP_VERSION = "7.2.0";
function critical_error($message){
echo "[ERROR] $message" . PHP_EOL;
}
/*
* Startup code. Do not look at it, it may harm you.
* Most of them are hacks to fix date-related bugs, or basic functions used after this
* This is the only non-class based file on this project.
* Enjoy it as much as I did writing it. I don't want to do it again.
*/
if(\Phar::running(true) !== ""){
@define('pocketmine\PATH', \Phar::running(true) . "/");
}else{
@define('pocketmine\PATH', \getcwd() . DIRECTORY_SEPARATOR);
}
if(version_compare("7.0", PHP_VERSION) > 0){
echo "[CRITICAL] You must use PHP >= 7.0" . PHP_EOL;
echo "[CRITICAL] Please use the installer provided on the homepage." . PHP_EOL;
exit(1);
}
if(!extension_loaded("pthreads")){
echo "[CRITICAL] Unable to find the pthreads extension." . PHP_EOL;
echo "[CRITICAL] Please use the installer provided on the homepage." . PHP_EOL;
exit(1);
}
if(!class_exists("ClassLoader", false)){
if(!is_file(\pocketmine\PATH . "src/spl/ClassLoader.php")){
echo "[CRITICAL] Unable to find the PocketMine-SPL library." . PHP_EOL;
echo "[CRITICAL] Please use provided builds or clone the repository recursively." . PHP_EOL;
exit(1);
}
require_once(\pocketmine\PATH . "src/spl/ClassLoader.php");
require_once(\pocketmine\PATH . "src/spl/BaseClassLoader.php");
}
$autoloader = new \BaseClassLoader();
$autoloader->addPath(\pocketmine\PATH . "src");
$autoloader->addPath(\pocketmine\PATH . "src" . DIRECTORY_SEPARATOR . "spl");
$autoloader->register(true);
try{
if(!class_exists(RakLib::class)){
throw new \Exception;
}
}catch(\Exception $e){
echo "[CRITICAL] Unable to find the RakLib library." . PHP_EOL;
exit(1);
}
set_time_limit(0); //Who set it to 30 seconds?!?!
error_reporting(-1);
ini_set("allow_url_fopen", 1);
ini_set("display_errors", 1);
ini_set("display_startup_errors", 1);
ini_set("default_charset", "utf-8");
ini_set("memory_limit", -1);
define('pocketmine\START_TIME', microtime(true));
$opts = getopt("", ["data:", "plugins:", "no-wizard", "enable-profiler"]);
define('pocketmine\DATA', isset($opts["data"]) ? $opts["data"] . DIRECTORY_SEPARATOR : \getcwd() . DIRECTORY_SEPARATOR);
define('pocketmine\PLUGIN_PATH', isset($opts["plugins"]) ? $opts["plugins"] . DIRECTORY_SEPARATOR : \getcwd() . DIRECTORY_SEPARATOR . "plugins" . DIRECTORY_SEPARATOR);
Terminal::init();
define('pocketmine\ANSI', Terminal::hasFormattingCodes());
if(!file_exists(\pocketmine\DATA)){
mkdir(\pocketmine\DATA, 0777, true);
}
//Logger has a dependency on timezone, so we'll set it to UTC until we can get the actual timezone.
date_default_timezone_set("UTC");
$logger = new MainLogger(\pocketmine\DATA . "server.log", \pocketmine\ANSI);
if(!ini_get("date.timezone")){
if(($timezone = detect_system_timezone()) and date_default_timezone_set($timezone)){
//Success! Timezone has already been set and validated in the if statement.
//This here is just for redundancy just in case some program wants to read timezone data from the ini.
ini_set("date.timezone", $timezone);
}else{
//If system timezone detection fails or timezone is an invalid value.
if($response = Utils::getURL("http://ip-api.com/json")
and $ip_geolocation_data = json_decode($response, true)
and $ip_geolocation_data['status'] !== 'fail'
and date_default_timezone_set($ip_geolocation_data['timezone'])
){
//Again, for redundancy.
ini_set("date.timezone", $ip_geolocation_data['timezone']);
}else{
ini_set("date.timezone", "UTC");
date_default_timezone_set("UTC");
$logger->warning("Timezone could not be automatically determined. An incorrect timezone will result in incorrect timestamps on console logs. It has been set to \"UTC\" by default. You can change it on the php.ini file.");
}
}
}else{
/*
* This is here so that people don't come to us complaining and fill up the issue tracker when they put
* an incorrect timezone abbreviation in php.ini apparently.
*/
$timezone = ini_get("date.timezone");
if(strpos($timezone, "/") === false){
$default_timezone = timezone_name_from_abbr($timezone);
ini_set("date.timezone", $default_timezone);
date_default_timezone_set($default_timezone);
}else{
date_default_timezone_set($timezone);
}
}
function detect_system_timezone(){
switch(Utils::getOS()){
case 'win':
$regex = '/(UTC)(\+*\-*\d*\d*\:*\d*\d*)/';
/*
* wmic timezone get Caption
* Get the timezone offset
*
* Sample Output var_dump
* array(3) {
* [0] =>
* string(7) "Caption"
* [1] =>
* string(20) "(UTC+09:30) Adelaide"
* [2] =>
* string(0) ""
* }
*/
exec("wmic timezone get Caption", $output);
$string = trim(implode("\n", $output));
//Detect the Time Zone string
preg_match($regex, $string, $matches);
if(!isset($matches[2])){
return false;
}
$offset = $matches[2];
if($offset == ""){
return "UTC";
}
return parse_offset($offset);
break;
case 'linux':
// Ubuntu / Debian.
if(file_exists('/etc/timezone')){
$data = file_get_contents('/etc/timezone');
if($data){
return trim($data);
}
}
// RHEL / CentOS
if(file_exists('/etc/sysconfig/clock')){
$data = parse_ini_file('/etc/sysconfig/clock');
if(!empty($data['ZONE'])){
return trim($data['ZONE']);
}
}
//Portable method for incompatible linux distributions.
$offset = trim(exec('date +%:z'));
if($offset == "+00:00"){
return "UTC";
}
return parse_offset($offset);
break;
case 'mac':
if(is_link('/etc/localtime')){
$filename = readlink('/etc/localtime');
if(strpos($filename, '/usr/share/zoneinfo/') === 0){
$timezone = substr($filename, 20);
return trim($timezone);
}
}
return false;
break;
default:
return false;
break;
}
}
/**
* @param string $offset In the format of +09:00, +02:00, -04:00 etc.
*
* @return string
* @return string[]
*/
function parse_offset($offset){
//Make signed offsets unsigned for date_parse
if(strpos($offset, '-') !== false){
$negative_offset = true;
$offset = str_replace('-', '', $offset);
}else{
if(strpos($offset, '+') !== false){
$negative_offset = false;
$offset = str_replace('+', '', $offset);
}else{
return false;
}
}
$parsed = date_parse($offset);
$offset = $parsed['hour'] * 3600 + $parsed['minute'] * 60 + $parsed['second'];
//After date_parse is done, put the sign back
if($negative_offset == true){
$offset = -abs($offset);
}
//And then, look the offset up.
//timezone_name_from_abbr is not used because it returns false on some(most) offsets because it's mapping function is weird.
//That's been a bug in PHP since 2008!
foreach(timezone_abbreviations_list() as $zones){
foreach($zones as $timezone){
if($timezone['offset'] == $offset){
return $timezone['timezone_id'];
}
}
}
return false;
}
if(isset($opts["enable-profiler"])){
if(function_exists("profiler_enable")){
\profiler_enable();
$logger->notice("Execution is being profiled");
}else{
$logger->notice("No profiler found. Please install https://github.com/krakjoe/profiler");
}
}
function kill($pid){
switch(Utils::getOS()){
case "win":
exec("taskkill.exe /F /PID " . ((int) $pid) . " > NUL");
break;
case "mac":
case "linux":
default:
if(function_exists("posix_kill")){
posix_kill($pid, SIGKILL);
}else{
exec("kill -9 " . ((int) $pid) . " > /dev/null 2>&1");
}
}
}
/**
* @param object $value
* @param bool $includeCurrent
*
* @return int
*/
function getReferenceCount($value, $includeCurrent = true){
ob_start();
debug_zval_dump($value);
$ret = explode("\n", ob_get_contents());
ob_end_clean();
if(count($ret) >= 1 and preg_match('/^.* refcount\\(([0-9]+)\\)\\{$/', trim($ret[0]), $m) > 0){
return ((int) $m[1]) - ($includeCurrent ? 3 : 4); //$value + zval call + extra call
}
return -1;
}
function getTrace($start = 0, $trace = null){
if($trace === null){
if(function_exists("xdebug_get_function_stack")){
$trace = array_reverse(xdebug_get_function_stack());
}else{
$e = new \Exception();
$trace = $e->getTrace();
}
function check_platform_dependencies(){
if(version_compare(MIN_PHP_VERSION, PHP_VERSION) > 0){
//If PHP version isn't high enough, anything below might break, so don't bother checking it.
return [
"PHP >= " . MIN_PHP_VERSION . " is required, but you have PHP " . PHP_VERSION . "."
];
}
$messages = [];
$j = 0;
for($i = (int) $start; isset($trace[$i]); ++$i, ++$j){
$params = "";
if(isset($trace[$i]["args"]) or isset($trace[$i]["params"])){
if(isset($trace[$i]["args"])){
$args = $trace[$i]["args"];
}else{
$args = $trace[$i]["params"];
}
foreach($args as $name => $value){
$params .= (is_object($value) ? get_class($value) . " " . (method_exists($value, "__toString") ? $value->__toString() : "object") : gettype($value) . " " . (is_array($value) ? "Array()" : Utils::printable(@strval($value)))) . ", ";
}
if(PHP_INT_SIZE < 8){
$messages[] = "32-bit systems/PHP are no longer supported. Please upgrade to a 64-bit system, or use a 64-bit PHP binary if this is a 64-bit system.";
}
if(php_sapi_name() !== "cli"){
$messages[] = "Only PHP CLI is supported.";
}
$extensions = [
"bcmath" => "BC Math",
"curl" => "cURL",
"ctype" => "ctype",
"date" => "Date",
"hash" => "Hash",
"json" => "JSON",
"mbstring" => "Multibyte String",
"openssl" => "OpenSSL",
"pcre" => "PCRE",
"phar" => "Phar",
"pthreads" => "pthreads",
"reflection" => "Reflection",
"sockets" => "Sockets",
"spl" => "SPL",
"yaml" => "YAML",
"zip" => "Zip",
"zlib" => "Zlib"
];
foreach($extensions as $ext => $name){
if(!extension_loaded($ext)){
$messages[] = "Unable to find the $name ($ext) extension.";
}
$messages[] = "#$j " . (isset($trace[$i]["file"]) ? cleanPath($trace[$i]["file"]) : "") . "(" . (isset($trace[$i]["line"]) ? $trace[$i]["line"] : "") . "): " . (isset($trace[$i]["class"]) ? $trace[$i]["class"] . (($trace[$i]["type"] === "dynamic" or $trace[$i]["type"] === "->") ? "->" : "::") : "") . $trace[$i]["function"] . "(" . Utils::printable(substr($params, 0, -2)) . ")";
}
if(extension_loaded("pthreads")){
$pthreads_version = phpversion("pthreads");
if(substr_count($pthreads_version, ".") < 2){
$pthreads_version = "0.$pthreads_version";
}
if(version_compare($pthreads_version, "3.2.0") < 0){
$messages[] = "pthreads >= 3.2.0 is required, while you have $pthreads_version.";
}
}
if(extension_loaded("leveldb")){
$leveldb_version = phpversion("leveldb");
if(version_compare($leveldb_version, "0.2.1") < 0){
$messages[] = "php-leveldb >= 0.2.1 is required, while you have $leveldb_version.";
}
}
if(extension_loaded("pocketmine")){
$messages[] = "The native PocketMine extension is no longer supported.";
}
return $messages;
}
function cleanPath($path){
return rtrim(str_replace(["\\", ".php", "phar://", rtrim(str_replace(["\\", "phar://"], ["/", ""], \pocketmine\PATH), "/"), rtrim(str_replace(["\\", "phar://"], ["/", ""], \pocketmine\PLUGIN_PATH), "/")], ["/", "", "", "", ""], $path), "/");
}
$errors = 0;
if(php_sapi_name() !== "cli"){
$logger->critical("You must run PocketMine-MP using the CLI.");
++$errors;
}
$pthreads_version = phpversion("pthreads");
if(substr_count($pthreads_version, ".") < 2){
$pthreads_version = "0.$pthreads_version";
}
if(version_compare($pthreads_version, "3.1.5") < 0){
$logger->critical("pthreads >= 3.1.5 is required, while you have $pthreads_version.");
++$errors;
}
if(extension_loaded("pocketmine")){
if(version_compare(phpversion("pocketmine"), "0.0.1") < 0){
$logger->critical("You have the native PocketMine extension, but your version is lower than 0.0.1.");
++$errors;
}elseif(version_compare(phpversion("pocketmine"), "0.0.4") > 0){
$logger->critical("You have the native PocketMine extension, but your version is higher than 0.0.4.");
++$errors;
function emit_performance_warnings(\Logger $logger){
if(extension_loaded("xdebug")){
$logger->warning("Xdebug extension is enabled. This has a major impact on performance.");
}
if(!extension_loaded("pocketmine_chunkutils")){
$logger->warning("ChunkUtils extension is missing. Anvil-format worlds will experience degraded performance.");
}
if(((int) ini_get('zend.assertions')) !== -1){
$logger->warning("Debugging assertions are enabled. This may degrade performance. To disable them, set `zend.assertions = -1` in php.ini.");
}
if(\Phar::running(true) === ""){
$logger->warning("Non-packaged installation detected. This will degrade autoloading speed and make startup times longer.");
}
}
if(extension_loaded("xdebug")){
$logger->warning("
You are running PocketMine with xdebug enabled. This has a major impact on performance.
");
function set_ini_entries(){
ini_set("allow_url_fopen", '1');
ini_set("display_errors", '1');
ini_set("display_startup_errors", '1');
ini_set("default_charset", "utf-8");
ini_set('assert.exception', '1');
}
$extensions = [
"curl" => "cURL",
"json" => "JSON",
"mbstring" => "Multibyte String",
"yaml" => "YAML",
"sockets" => "Sockets",
"zip" => "Zip",
"zlib" => "Zlib"
];
foreach($extensions as $ext => $name){
if(!extension_loaded($ext)){
$logger->critical("Unable to find the $name ($ext) extension.");
++$errors;
function server(){
if(!empty($messages = check_platform_dependencies())){
echo PHP_EOL;
$binary = version_compare(PHP_VERSION, "5.4") >= 0 ? PHP_BINARY : "unknown";
critical_error("Selected PHP binary ($binary) does not satisfy some requirements.");
foreach($messages as $m){
echo " - $m" . PHP_EOL;
}
critical_error("Please recompile PHP with the needed configuration, or refer to the installation instructions at http://pmmp.rtfd.io/en/rtfd/installation.html.");
echo PHP_EOL;
exit(1);
}
}
unset($messages);
if($errors > 0){
$logger->critical("Please use the installer provided on the homepage, or recompile PHP again.");
$logger->shutdown();
$logger->join();
exit(1); //Exit with error
}
error_reporting(-1);
set_ini_entries();
if(PHP_INT_SIZE < 8){
$logger->warning("Running PocketMine-MP with 32-bit systems/PHP is deprecated. Support for 32-bit may be dropped in the future.");
}
if(\Phar::running(true) !== ""){
define('pocketmine\PATH', \Phar::running(true) . "/");
}else{
define('pocketmine\PATH', dirname(__FILE__, 3) . DIRECTORY_SEPARATOR);
}
$gitHash = str_repeat("00", 20);
if(file_exists(\pocketmine\PATH . ".git/HEAD")){ //Found Git information!
$ref = trim(file_get_contents(\pocketmine\PATH . ".git/HEAD"));
if(preg_match('/^[0-9a-f]{40}$/i', $ref)){
$gitHash = strtolower($ref);
}elseif(substr($ref, 0, 5) === "ref: "){
$refFile = \pocketmine\PATH . ".git/" . substr($ref, 5);
if(is_file($refFile)){
$gitHash = strtolower(trim(file_get_contents($refFile)));
$opts = getopt("", ["bootstrap:"]);
if(isset($opts["bootstrap"])){
$bootstrap = realpath($opts["bootstrap"]) ?: $opts["bootstrap"];
}else{
$bootstrap = \pocketmine\PATH . 'vendor/autoload.php';
}
define('pocketmine\COMPOSER_AUTOLOADER_PATH', $bootstrap);
if(\pocketmine\COMPOSER_AUTOLOADER_PATH !== false and is_file(\pocketmine\COMPOSER_AUTOLOADER_PATH)){
require_once(\pocketmine\COMPOSER_AUTOLOADER_PATH);
}else{
critical_error("Composer autoloader not found at " . $bootstrap);
critical_error("Please install/update Composer dependencies or use provided builds.");
exit(1);
}
set_error_handler([Utils::class, 'errorExceptionHandler']);
$version = new VersionString(\pocketmine\BASE_VERSION, \pocketmine\IS_DEVELOPMENT_BUILD, \pocketmine\BUILD_NUMBER);
define('pocketmine\VERSION', $version->getFullVersion(true));
$gitHash = str_repeat("00", 20);
if(\Phar::running(true) === ""){
if(Utils::execute("git rev-parse HEAD", $out) === 0 and $out !== false and strlen($out = trim($out)) === 40){
$gitHash = trim($out);
if(Utils::execute("git diff --quiet") === 1 or Utils::execute("git diff --cached --quiet") === 1){ //Locally-modified
$gitHash .= "-dirty";
}
}
}else{
$phar = new \Phar(\Phar::running(false));
$meta = $phar->getMetadata();
if(isset($meta["git"])){
$gitHash = $meta["git"];
}
}
}
define('pocketmine\GIT_COMMIT', $gitHash);
define('pocketmine\GIT_COMMIT', $gitHash);
define('pocketmine\RESOURCE_PATH', \pocketmine\PATH . 'src' . DIRECTORY_SEPARATOR . 'pocketmine' . DIRECTORY_SEPARATOR . 'resources' . DIRECTORY_SEPARATOR);
@define("ENDIANNESS", (pack("d", 1) === "\77\360\0\0\0\0\0\0" ? Binary::BIG_ENDIAN : Binary::LITTLE_ENDIAN));
@define("INT32_MASK", is_int(0xffffffff) ? 0xffffffff : -1);
@ini_set("opcache.mmap_base", bin2hex(random_bytes(8))); //Fix OPCache address errors
$opts = getopt("", ["data:", "plugins:", "no-wizard", "enable-ansi", "disable-ansi"]);
define('pocketmine\DATA', isset($opts["data"]) ? $opts["data"] . DIRECTORY_SEPARATOR : realpath(getcwd()) . DIRECTORY_SEPARATOR);
define('pocketmine\PLUGIN_PATH', isset($opts["plugins"]) ? $opts["plugins"] . DIRECTORY_SEPARATOR : realpath(getcwd()) . DIRECTORY_SEPARATOR . "plugins" . DIRECTORY_SEPARATOR);
if(!file_exists(\pocketmine\DATA . "server.properties") and !isset($opts["no-wizard"])){
$installer = new SetupWizard();
if(!$installer->run()){
$logger->shutdown();
$logger->join();
exit(-1);
if(!file_exists(\pocketmine\DATA)){
mkdir(\pocketmine\DATA, 0777, true);
}
}
if(\Phar::running(true) === ""){
$logger->warning("Non-packaged PocketMine-MP installation detected, do not use on production.");
}
ThreadManager::init();
new Server($autoloader, $logger, \pocketmine\PATH, \pocketmine\DATA, \pocketmine\PLUGIN_PATH);
$logger->info("Stopping other threads");
$killer = new ServerKiller(8);
$killer->start();
$erroredThreads = 0;
foreach(ThreadManager::getInstance()->getAll() as $id => $thread){
$logger->debug("Stopping " . $thread->getThreadName() . " thread");
try{
$thread->quit();
$logger->debug($thread->getThreadName() . " thread stopped successfully.");
}catch(\ThreadException $e){
++$erroredThreads;
$logger->debug("Could not stop " . $thread->getThreadName() . " thread: " . $e->getMessage());
define('pocketmine\LOCK_FILE', fopen(\pocketmine\DATA . 'server.lock', "a+b"));
if(!flock(\pocketmine\LOCK_FILE, LOCK_EX | LOCK_NB)){
//wait for a shared lock to avoid race conditions if two servers started at the same time - this makes sure the
//other server wrote its PID and released exclusive lock before we get our lock
flock(\pocketmine\LOCK_FILE, LOCK_SH);
$pid = stream_get_contents(\pocketmine\LOCK_FILE);
critical_error("Another " . \pocketmine\NAME . " instance (PID $pid) is already using this folder (" . realpath(\pocketmine\DATA) . ").");
critical_error("Please stop the other server first before running a new one.");
exit(1);
}
}
ftruncate(\pocketmine\LOCK_FILE, 0);
fwrite(\pocketmine\LOCK_FILE, (string) getmypid());
fflush(\pocketmine\LOCK_FILE);
flock(\pocketmine\LOCK_FILE, LOCK_SH); //prevent acquiring an exclusive lock from another process, but allow reading
$logger->shutdown();
$logger->join();
//Logger has a dependency on timezone
$tzError = Timezone::init();
echo Terminal::$FORMAT_RESET . PHP_EOL;
if($erroredThreads > 0){
if(\pocketmine\DEBUG > 1){
echo "Some threads could not be stopped, performing a force-kill" . PHP_EOL . PHP_EOL;
if(isset($opts["enable-ansi"])){
Terminal::init(true);
}elseif(isset($opts["disable-ansi"])){
Terminal::init(false);
}else{
Terminal::init();
}
kill(getmypid());
}else{
exit(0);
$logger = new MainLogger(\pocketmine\DATA . "server.log");
$logger->registerStatic();
foreach($tzError as $e){
$logger->warning($e);
}
unset($tzError);
emit_performance_warnings($logger);
$exitCode = 0;
do{
if(!file_exists(\pocketmine\DATA . "server.properties") and !isset($opts["no-wizard"])){
$installer = new SetupWizard();
if(!$installer->run()){
$exitCode = -1;
break;
}
}
//TODO: move this to a Server field
define('pocketmine\START_TIME', microtime(true));
ThreadManager::init();
/*
* We now use the Composer autoloader, but this autoloader is still for loading plugins.
*/
$autoloader = new \BaseClassLoader();
$autoloader->register(false);
new Server($autoloader, $logger, \pocketmine\DATA, \pocketmine\PLUGIN_PATH);
$logger->info("Stopping other threads");
$killer = new ServerKiller(8);
$killer->start(PTHREADS_INHERIT_NONE);
usleep(10000); //Fixes ServerKiller not being able to start on single-core machines
if(ThreadManager::getInstance()->stopAll() > 0){
$logger->debug("Some threads could not be stopped, performing a force-kill");
Utils::kill(getmypid());
}
}while(false);
$logger->shutdown();
$logger->join();
echo Terminal::$FORMAT_RESET . PHP_EOL;
exit($exitCode);
}
if(!defined('pocketmine\_PHPSTAN_ANALYSIS')){
\pocketmine\server();
}
}

File diff suppressed because it is too large Load Diff

View File

@ -19,6 +19,8 @@
*
*/
declare(strict_types=1);
namespace pocketmine;
/**
@ -26,8 +28,11 @@ namespace pocketmine;
*/
abstract class Thread extends \Thread{
/** @var \ClassLoader */
/** @var \ClassLoader|null */
protected $classLoader;
/** @var string|null */
protected $composerAutoloaderPath;
protected $isKilled = false;
public function getClassLoader(){
@ -35,33 +40,37 @@ abstract class Thread extends \Thread{
}
public function setClassLoader(\ClassLoader $loader = null){
$this->composerAutoloaderPath = \pocketmine\COMPOSER_AUTOLOADER_PATH;
if($loader === null){
$loader = Server::getInstance()->getLoader();
}
$this->classLoader = $loader;
}
/**
* Registers the class loader for this thread.
*
* WARNING: This method MUST be called from any descendent threads' run() method to make autoloading usable.
* If you do not do this, you will not be able to use new classes that were not loaded when the thread was started
* (unless you are using a custom autoloader).
*/
public function registerClassLoader(){
if(!interface_exists("ClassLoader", false)){
require(\pocketmine\PATH . "src/spl/ClassLoader.php");
require(\pocketmine\PATH . "src/spl/BaseClassLoader.php");
if($this->composerAutoloaderPath !== null){
require $this->composerAutoloaderPath;
}
if($this->classLoader !== null){
$this->classLoader->register(true);
$this->classLoader->register(false);
}
}
public function start(int $options = PTHREADS_INHERIT_ALL){
public function start(?int $options = \PTHREADS_INHERIT_ALL){
ThreadManager::getInstance()->add($this);
if(!$this->isRunning() and !$this->isJoined() and !$this->isTerminated()){
if($this->getClassLoader() === null){
$this->setClassLoader();
}
return parent::start($options);
if($this->getClassLoader() === null){
$this->setClassLoader();
}
return false;
return parent::start($options);
}
/**
@ -70,18 +79,15 @@ abstract class Thread extends \Thread{
public function quit(){
$this->isKilled = true;
$this->notify();
if(!$this->isJoined()){
if(!$this->isTerminated()){
$this->join();
}
$this->notify();
$this->join();
}
ThreadManager::getInstance()->remove($this);
}
public function getThreadName(){
public function getThreadName() : string{
return (new \ReflectionClass($this))->getShortName();
}
}

View File

@ -19,8 +19,13 @@
*
*/
declare(strict_types=1);
namespace pocketmine;
use pocketmine\utils\MainLogger;
use function spl_object_hash;
class ThreadManager extends \Volatile{
/** @var ThreadManager */
@ -58,7 +63,7 @@ class ThreadManager extends \Volatile{
/**
* @return Worker[]|Thread[]
*/
public function getAll(){
public function getAll() : array{
$array = [];
foreach($this as $key => $thread){
$array[$key] = $thread;
@ -66,4 +71,23 @@ class ThreadManager extends \Volatile{
return $array;
}
}
public function stopAll() : int{
$logger = MainLogger::getLogger();
$erroredThreads = 0;
foreach($this->getAll() as $thread){
$logger->debug("Stopping " . $thread->getThreadName() . " thread");
try{
$thread->quit();
$logger->debug($thread->getThreadName() . " thread stopped successfully.");
}catch(\ThreadException $e){
++$erroredThreads;
$logger->debug("Could not stop " . $thread->getThreadName() . " thread: " . $e->getMessage());
}
}
return $erroredThreads;
}
}

View File

@ -0,0 +1,35 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
namespace pocketmine;
// composer autoload doesn't use require_once and also pthreads can inherit things
// TODO: drop this file and use a final class with constants
if(defined('pocketmine\_VERSION_INFO_INCLUDED')){
return;
}
const _VERSION_INFO_INCLUDED = true;
const NAME = "PocketMine-MP";
const BASE_VERSION = "3.9.8";
const IS_DEVELOPMENT_BUILD = false;
const BUILD_NUMBER = 0;

View File

@ -19,6 +19,8 @@
*
*/
declare(strict_types=1);
namespace pocketmine;
/**
@ -26,8 +28,10 @@ namespace pocketmine;
*/
abstract class Worker extends \Worker{
/** @var \ClassLoader */
/** @var \ClassLoader|null */
protected $classLoader;
/** @var string|null */
protected $composerAutoloaderPath;
protected $isKilled = false;
@ -36,33 +40,37 @@ abstract class Worker extends \Worker{
}
public function setClassLoader(\ClassLoader $loader = null){
$this->composerAutoloaderPath = \pocketmine\COMPOSER_AUTOLOADER_PATH;
if($loader === null){
$loader = Server::getInstance()->getLoader();
}
$this->classLoader = $loader;
}
/**
* Registers the class loader for this thread.
*
* WARNING: This method MUST be called from any descendent threads' run() method to make autoloading usable.
* If you do not do this, you will not be able to use new classes that were not loaded when the thread was started
* (unless you are using a custom autoloader).
*/
public function registerClassLoader(){
if(!interface_exists("ClassLoader", false)){
require(\pocketmine\PATH . "src/spl/ClassLoader.php");
require(\pocketmine\PATH . "src/spl/BaseClassLoader.php");
if($this->composerAutoloaderPath !== null){
require $this->composerAutoloaderPath;
}
if($this->classLoader !== null){
$this->classLoader->register(true);
$this->classLoader->register(false);
}
}
public function start(int $options = PTHREADS_INHERIT_ALL){
public function start(?int $options = \PTHREADS_INHERIT_ALL){
ThreadManager::getInstance()->add($this);
if(!$this->isRunning() and !$this->isJoined() and !$this->isTerminated()){
if($this->getClassLoader() === null){
$this->setClassLoader();
}
return parent::start($options);
if($this->getClassLoader() === null){
$this->setClassLoader();
}
return false;
return parent::start($options);
}
/**
@ -71,22 +79,16 @@ abstract class Worker extends \Worker{
public function quit(){
$this->isKilled = true;
$this->notify();
if($this->isRunning()){
$this->shutdown();
while($this->unstack() !== null);
$this->notify();
$this->unstack();
}elseif(!$this->isJoined()){
if(!$this->isTerminated()){
$this->join();
}
$this->shutdown();
}
ThreadManager::getInstance()->remove($this);
}
public function getThreadName(){
public function getThreadName() : string{
return (new \ReflectionClass($this))->getShortName();
}
}

View File

@ -19,17 +19,17 @@
*
*/
declare(strict_types=1);
namespace pocketmine\block;
class ActivatorRail extends Rail{
class ActivatorRail extends RedstoneRail{
protected $id = self::ACTIVATOR_RAIL;
public function __construct($meta = 0){
$this->meta = $meta;
}
public function getName(){
public function getName() : string{
return "Activator Rail";
}
//TODO
}

View File

@ -19,9 +19,12 @@
*
*/
declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\item\Item;
use pocketmine\math\AxisAlignedBB;
/**
@ -30,50 +33,52 @@ use pocketmine\item\Item;
class Air extends Transparent{
protected $id = self::AIR;
protected $meta = 0;
public function __construct(){
public function __construct(int $meta = 0){
$this->meta = $meta;
}
public function getName(){
public function getName() : string{
return "Air";
}
public function canPassThrough(){
public function canPassThrough() : bool{
return true;
}
public function isBreakable(Item $item){
public function isBreakable(Item $item) : bool{
return false;
}
public function canBeFlowedInto(){
public function canBeFlowedInto() : bool{
return true;
}
public function canBeReplaced(){
public function canBeReplaced() : bool{
return true;
}
public function canBePlaced(){
public function canBePlaced() : bool{
return false;
}
public function isSolid(){
public function isSolid() : bool{
return false;
}
public function getBoundingBox(){
public function getBoundingBox() : ?AxisAlignedBB{
return null;
}
public function getHardness(){
public function getCollisionBoxes() : array{
return [];
}
public function getHardness() : float{
return -1;
}
public function getResistance(){
public function getBlastResistance() : float{
return 0;
}
}
}

View File

@ -19,55 +19,87 @@
*
*/
declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\inventory\AnvilInventory;
use pocketmine\item\Item;
use pocketmine\item\Tool;
use pocketmine\item\TieredTool;
use pocketmine\math\AxisAlignedBB;
use pocketmine\math\Vector3;
use pocketmine\Player;
class Anvil extends Fallable{
const TYPE_NORMAL = 0;
const TYPE_SLIGHTLY_DAMAGED = 4;
const TYPE_VERY_DAMAGED = 8;
public const TYPE_NORMAL = 0;
public const TYPE_SLIGHTLY_DAMAGED = 4;
public const TYPE_VERY_DAMAGED = 8;
protected $id = self::ANVIL;
public function isSolid(){
return false;
}
public function __construct($meta = 0){
public function __construct(int $meta = 0){
$this->meta = $meta;
}
public function canBeActivated(){
public function isTransparent() : bool{
return true;
}
public function getHardness(){
public function getHardness() : float{
return 5;
}
public function getResistance(){
public function getBlastResistance() : float{
return 6000;
}
public function getName(){
public function getVariantBitmask() : int{
return 0x0c;
}
public function getName() : string{
static $names = [
self::TYPE_NORMAL => "Anvil",
self::TYPE_SLIGHTLY_DAMAGED => "Slightly Damaged Anvil",
self::TYPE_VERY_DAMAGED => "Very Damaged Anvil"
];
return $names[$this->meta & 0x0c] ?? "Anvil";
return $names[$this->getVariant()] ?? "Anvil";
}
public function getToolType(){
return Tool::TYPE_PICKAXE;
public function getToolType() : int{
return BlockToolType::TYPE_PICKAXE;
}
public function onActivate(Item $item, Player $player = null){
public function getToolHarvestLevel() : int{
return TieredTool::TIER_WOODEN;
}
public function recalculateBoundingBox() : ?AxisAlignedBB{
$inset = 0.125;
if($this->meta & 0x01){ //east/west
return new AxisAlignedBB(
$this->x,
$this->y,
$this->z + $inset,
$this->x + 1,
$this->y + 1,
$this->z + 1 - $inset
);
}else{
return new AxisAlignedBB(
$this->x + $inset,
$this->y,
$this->z,
$this->x + 1 - $inset,
$this->y + 1,
$this->z + 1
);
}
}
public function onActivate(Item $item, Player $player = null) : bool{
if($player instanceof Player){
$player->addWindow(new AnvilInventory($this));
}
@ -75,19 +107,9 @@ class Anvil extends Fallable{
return true;
}
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){
public function place(Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, Player $player = null) : bool{
$direction = ($player !== null ? $player->getDirection() : 0) & 0x03;
$this->meta = ($this->meta & 0x0c) | $direction;
$this->getLevel()->setBlock($block, $this, true, true);
$this->meta = $this->getVariant() | $direction;
return $this->getLevel()->setBlock($blockReplace, $this, true, true);
}
public function getDrops(Item $item){
if($item->isPickaxe() >= Tool::TIER_WOODEN){
return [
[$this->id, $this->meta & 0x0c, 1],
];
}else{
return [];
}
}
}
}

View File

@ -0,0 +1,273 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\item\Item;
use pocketmine\math\Vector3;
use pocketmine\Player;
use function array_map;
use function array_reverse;
use function array_search;
use function array_shift;
use function count;
use function implode;
use function in_array;
abstract class BaseRail extends Flowable{
public const STRAIGHT_NORTH_SOUTH = 0;
public const STRAIGHT_EAST_WEST = 1;
public const ASCENDING_EAST = 2;
public const ASCENDING_WEST = 3;
public const ASCENDING_NORTH = 4;
public const ASCENDING_SOUTH = 5;
private const ASCENDING_SIDES = [
self::ASCENDING_NORTH => Vector3::SIDE_NORTH,
self::ASCENDING_EAST => Vector3::SIDE_EAST,
self::ASCENDING_SOUTH => Vector3::SIDE_SOUTH,
self::ASCENDING_WEST => Vector3::SIDE_WEST
];
protected const FLAG_ASCEND = 1 << 24; //used to indicate direction-up
protected const CONNECTIONS = [
//straights
self::STRAIGHT_NORTH_SOUTH => [
Vector3::SIDE_NORTH,
Vector3::SIDE_SOUTH
],
self::STRAIGHT_EAST_WEST => [
Vector3::SIDE_EAST,
Vector3::SIDE_WEST
],
//ascending
self::ASCENDING_EAST => [
Vector3::SIDE_WEST,
Vector3::SIDE_EAST | self::FLAG_ASCEND
],
self::ASCENDING_WEST => [
Vector3::SIDE_EAST,
Vector3::SIDE_WEST | self::FLAG_ASCEND
],
self::ASCENDING_NORTH => [
Vector3::SIDE_SOUTH,
Vector3::SIDE_NORTH | self::FLAG_ASCEND
],
self::ASCENDING_SOUTH => [
Vector3::SIDE_NORTH,
Vector3::SIDE_SOUTH | self::FLAG_ASCEND
]
];
public function __construct(int $meta = 0){
$this->meta = $meta;
}
public function getHardness() : float{
return 0.7;
}
public function place(Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, Player $player = null) : bool{
if(!$blockReplace->getSide(Vector3::SIDE_DOWN)->isTransparent() and $this->getLevel()->setBlock($blockReplace, $this, true, true)){
$this->tryReconnect();
return true;
}
return false;
}
protected static function searchState(array $connections, array $lookup) : int{
$meta = array_search($connections, $lookup, true);
if($meta === false){
$meta = array_search(array_reverse($connections), $lookup, true);
}
if($meta === false){
throw new \InvalidArgumentException("No meta value matches connections " . implode(", ", array_map('\dechex', $connections)));
}
return $meta;
}
/**
* Returns a meta value for the rail with the given connections.
*
* @param array $connections
*
* @return int
*
* @throws \InvalidArgumentException if no state matches the given connections
*/
protected function getMetaForState(array $connections) : int{
return self::searchState($connections, self::CONNECTIONS);
}
/**
* Returns the connection directions of this rail (depending on the current block state)
*
* @return int[]
*/
abstract protected function getConnectionsForState() : array;
/**
* Returns all the directions this rail is already connected in.
*
* @return int[]
*/
private function getConnectedDirections() : array{
/** @var int[] $connections */
$connections = [];
/** @var int $connection */
foreach($this->getConnectionsForState() as $connection){
$other = $this->getSide($connection & ~self::FLAG_ASCEND);
$otherConnection = Vector3::getOppositeSide($connection & ~self::FLAG_ASCEND);
if(($connection & self::FLAG_ASCEND) !== 0){
$other = $other->getSide(Vector3::SIDE_UP);
}elseif(!($other instanceof BaseRail)){ //check for rail sloping up to meet this one
$other = $other->getSide(Vector3::SIDE_DOWN);
$otherConnection |= self::FLAG_ASCEND;
}
if(
$other instanceof BaseRail and
in_array($otherConnection, $other->getConnectionsForState(), true)
){
$connections[] = $connection;
}
}
return $connections;
}
private function getPossibleConnectionDirections(array $constraints) : array{
switch(count($constraints)){
case 0:
//No constraints, can connect in any direction
$possible = [
Vector3::SIDE_NORTH => true,
Vector3::SIDE_SOUTH => true,
Vector3::SIDE_WEST => true,
Vector3::SIDE_EAST => true
];
foreach($possible as $p => $_){
$possible[$p | self::FLAG_ASCEND] = true;
}
return $possible;
case 1:
return $this->getPossibleConnectionDirectionsOneConstraint(array_shift($constraints));
case 2:
return [];
default:
throw new \InvalidArgumentException("Expected at most 2 constraints, got " . count($constraints));
}
}
protected function getPossibleConnectionDirectionsOneConstraint(int $constraint) : array{
$opposite = Vector3::getOppositeSide($constraint & ~self::FLAG_ASCEND);
$possible = [$opposite => true];
if(($constraint & self::FLAG_ASCEND) === 0){
//We can slope the other way if this connection isn't already a slope
$possible[$opposite | self::FLAG_ASCEND] = true;
}
return $possible;
}
private function tryReconnect() : void{
$thisConnections = $this->getConnectedDirections();
$changed = false;
do{
$possible = $this->getPossibleConnectionDirections($thisConnections);
$continue = false;
foreach($possible as $thisSide => $_){
$otherSide = Vector3::getOppositeSide($thisSide & ~self::FLAG_ASCEND);
$other = $this->getSide($thisSide & ~self::FLAG_ASCEND);
if(($thisSide & self::FLAG_ASCEND) !== 0){
$other = $other->getSide(Vector3::SIDE_UP);
}elseif(!($other instanceof BaseRail)){ //check if other rails can slope up to meet this one
$other = $other->getSide(Vector3::SIDE_DOWN);
$otherSide |= self::FLAG_ASCEND;
}
if(!($other instanceof BaseRail) or count($otherConnections = $other->getConnectedDirections()) >= 2){
//we can only connect to a rail that has less than 2 connections
continue;
}
$otherPossible = $other->getPossibleConnectionDirections($otherConnections);
if(isset($otherPossible[$otherSide])){
$otherConnections[] = $otherSide;
$other->updateState($otherConnections);
$changed = true;
$thisConnections[] = $thisSide;
$continue = count($thisConnections) < 2;
break; //force recomputing possible directions, since this connection could invalidate others
}
}
}while($continue);
if($changed){
$this->updateState($thisConnections);
}
}
private function updateState(array $connections) : void{
if(count($connections) === 1){
$connections[] = Vector3::getOppositeSide($connections[0] & ~self::FLAG_ASCEND);
}elseif(count($connections) !== 2){
throw new \InvalidArgumentException("Expected exactly 2 connections, got " . count($connections));
}
$this->meta = $this->getMetaForState($connections);
$this->level->setBlock($this, $this, false, false); //avoid recursion
}
public function onNearbyBlockChange() : void{
if($this->getSide(Vector3::SIDE_DOWN)->isTransparent() or (
isset(self::ASCENDING_SIDES[$this->meta & 0x07]) and
$this->getSide(self::ASCENDING_SIDES[$this->meta & 0x07])->isTransparent()
)){
$this->getLevel()->useBreakOn($this);
}
}
public function getVariantBitmask() : int{
return 0;
}
}

View File

@ -19,36 +19,42 @@
*
*/
declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\event\TranslationContainer;
use pocketmine\item\Item;
use pocketmine\item\ItemFactory;
use pocketmine\lang\TranslationContainer;
use pocketmine\level\Level;
use pocketmine\math\AxisAlignedBB;
use pocketmine\math\Vector3;
use pocketmine\Player;
use pocketmine\tile\Bed as TileBed;
use pocketmine\tile\Tile;
use pocketmine\utils\TextFormat;
class Bed extends Transparent{
public const BITFLAG_OCCUPIED = 0x04;
public const BITFLAG_HEAD = 0x08;
protected $id = self::BED_BLOCK;
public function __construct($meta = 0){
protected $itemId = Item::BED;
public function __construct(int $meta = 0){
$this->meta = $meta;
}
public function canBeActivated(){
return true;
}
public function getHardness(){
public function getHardness() : float{
return 0.2;
}
public function getName(){
public function getName() : string{
return "Bed Block";
}
protected function recalculateBoundingBox(){
protected function recalculateBoundingBox() : ?AxisAlignedBB{
return new AxisAlignedBB(
$this->x,
$this->y,
@ -59,64 +65,123 @@ class Bed extends Transparent{
);
}
public function onActivate(Item $item, Player $player = null){
public function isHeadPart() : bool{
return ($this->meta & self::BITFLAG_HEAD) !== 0;
}
$time = $this->getLevel()->getTime() % Level::TIME_FULL;
/**
* @return bool
*/
public function isOccupied() : bool{
return ($this->meta & self::BITFLAG_OCCUPIED) !== 0;
}
$isNight = ($time >= Level::TIME_NIGHT and $time < Level::TIME_SUNRISE);
if($player instanceof Player and !$isNight){
$player->sendMessage(new TranslationContainer(TextFormat::GRAY . "%tile.bed.noSleep"));
return true;
public function setOccupied(bool $occupied = true){
if($occupied){
$this->meta |= self::BITFLAG_OCCUPIED;
}else{
$this->meta &= ~self::BITFLAG_OCCUPIED;
}
$blockNorth = $this->getSide(2); //Gets the blocks around them
$blockSouth = $this->getSide(3);
$blockEast = $this->getSide(5);
$blockWest = $this->getSide(4);
if(($this->meta & 0x08) === 0x08){ //This is the Top part of bed
$b = $this;
}else{ //Bottom Part of Bed
if($blockNorth->getId() === $this->id and ($blockNorth->meta & 0x08) === 0x08){
$b = $blockNorth;
}elseif($blockSouth->getId() === $this->id and ($blockSouth->meta & 0x08) === 0x08){
$b = $blockSouth;
}elseif($blockEast->getId() === $this->id and ($blockEast->meta & 0x08) === 0x08){
$b = $blockEast;
}elseif($blockWest->getId() === $this->id and ($blockWest->meta & 0x08) === 0x08){
$b = $blockWest;
}else{
if($player instanceof Player){
$player->sendMessage(TextFormat::GRAY . "This bed is incomplete");
}
$this->getLevel()->setBlock($this, $this, false, false);
if(($other = $this->getOtherHalf()) !== null and $other->isOccupied() !== $occupied){
$other->setOccupied($occupied);
}
}
/**
* @param int $meta
* @param bool $isHead
*
* @return int
*/
public static function getOtherHalfSide(int $meta, bool $isHead = false) : int{
$rotation = $meta & 0x03;
$side = -1;
switch($rotation){
case 0x00: //South
$side = Vector3::SIDE_SOUTH;
break;
case 0x01: //West
$side = Vector3::SIDE_WEST;
break;
case 0x02: //North
$side = Vector3::SIDE_NORTH;
break;
case 0x03: //East
$side = Vector3::SIDE_EAST;
break;
}
if($isHead){
$side = Vector3::getOppositeSide($side);
}
return $side;
}
/**
* @return Bed|null
*/
public function getOtherHalf() : ?Bed{
$other = $this->getSide(self::getOtherHalfSide($this->meta, $this->isHeadPart()));
if($other instanceof Bed and $other->getId() === $this->getId() and $other->isHeadPart() !== $this->isHeadPart() and (($other->getDamage() & 0x03) === ($this->getDamage() & 0x03))){
return $other;
}
return null;
}
public function onActivate(Item $item, Player $player = null) : bool{
if($player !== null){
$other = $this->getOtherHalf();
if($other === null){
$player->sendMessage(TextFormat::GRAY . "This bed is incomplete");
return true;
}elseif($player->distanceSquared($this) > 4 and $player->distanceSquared($other) > 4){
$player->sendMessage(new TranslationContainer(TextFormat::GRAY . "%tile.bed.tooFar"));
return true;
}
$time = $this->getLevel()->getTime() % Level::TIME_FULL;
$isNight = ($time >= Level::TIME_NIGHT and $time < Level::TIME_SUNRISE);
if(!$isNight){
$player->sendMessage(new TranslationContainer(TextFormat::GRAY . "%tile.bed.noSleep"));
return true;
}
}
if($player instanceof Player and $player->sleepOn($b) === false){
$player->sendMessage(new TranslationContainer(TextFormat::GRAY . "%tile.bed.occupied"));
$b = ($this->isHeadPart() ? $this : $other);
if($b->isOccupied()){
$player->sendMessage(new TranslationContainer(TextFormat::GRAY . "%tile.bed.occupied"));
return true;
}
$player->sleepOn($b);
}
return true;
}
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){
$down = $this->getSide(0);
if($down->isTransparent() === false){
$faces = [
0 => 3,
1 => 4,
2 => 2,
3 => 5,
];
$d = $player instanceof Player ? $player->getDirection() : 0;
$next = $this->getSide($faces[(($d + 3) % 4)]);
$downNext = $this->getSide(0);
if($next->canBeReplaced() === true and $downNext->isTransparent() === false){
$meta = (($d + 3) % 4) & 0x03;
$this->getLevel()->setBlock($block, Block::get($this->id, $meta), true, true);
$this->getLevel()->setBlock($next, Block::get($this->id, $meta | 0x08), true, true);
public function place(Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, Player $player = null) : bool{
$down = $this->getSide(Vector3::SIDE_DOWN);
if(!$down->isTransparent()){
$meta = (($player instanceof Player ? $player->getDirection() : 0) - 1) & 0x03;
$next = $this->getSide(self::getOtherHalfSide($meta));
if($next->canBeReplaced() and !$next->getSide(Vector3::SIDE_DOWN)->isTransparent()){
$this->getLevel()->setBlock($blockReplace, BlockFactory::get($this->id, $meta), true, true);
$this->getLevel()->setBlock($next, BlockFactory::get($this->id, $meta | self::BITFLAG_HEAD), true, true);
Tile::createTile(Tile::BED, $this->getLevel(), TileBed::createNBT($this, $face, $item, $player));
Tile::createTile(Tile::BED, $this->getLevel(), TileBed::createNBT($next, $face, $item, $player));
return true;
}
@ -125,42 +190,36 @@ class Bed extends Transparent{
return false;
}
public function onBreak(Item $item){
$blockNorth = $this->getSide(2); //Gets the blocks around them
$blockSouth = $this->getSide(3);
$blockEast = $this->getSide(5);
$blockWest = $this->getSide(4);
if(($this->meta & 0x08) === 0x08){ //This is the Top part of bed
if($blockNorth->getId() === $this->id and $blockNorth->meta !== 0x08){ //Checks if the block ID and meta are right
$this->getLevel()->setBlock($blockNorth, new Air(), true, true);
}elseif($blockSouth->getId() === $this->id and $blockSouth->meta !== 0x08){
$this->getLevel()->setBlock($blockSouth, new Air(), true, true);
}elseif($blockEast->getId() === $this->id and $blockEast->meta !== 0x08){
$this->getLevel()->setBlock($blockEast, new Air(), true, true);
}elseif($blockWest->getId() === $this->id and $blockWest->meta !== 0x08){
$this->getLevel()->setBlock($blockWest, new Air(), true, true);
}
}else{ //Bottom Part of Bed
if($blockNorth->getId() === $this->id and ($blockNorth->meta & 0x08) === 0x08){
$this->getLevel()->setBlock($blockNorth, new Air(), true, true);
}elseif($blockSouth->getId() === $this->id and ($blockSouth->meta & 0x08) === 0x08){
$this->getLevel()->setBlock($blockSouth, new Air(), true, true);
}elseif($blockEast->getId() === $this->id and ($blockEast->meta & 0x08) === 0x08){
$this->getLevel()->setBlock($blockEast, new Air(), true, true);
}elseif($blockWest->getId() === $this->id and ($blockWest->meta & 0x08) === 0x08){
$this->getLevel()->setBlock($blockWest, new Air(), true, true);
}
public function getDropsForCompatibleTool(Item $item) : array{
if($this->isHeadPart()){
return [$this->getItem()];
}
$this->getLevel()->setBlock($this, new Air(), true, true);
return true;
return [];
}
public function getDrops(Item $item){
return [
[Item::BED, 0, 1],
];
public function getPickedItem() : Item{
return $this->getItem();
}
private function getItem() : Item{
$tile = $this->getLevel()->getTile($this);
if($tile instanceof TileBed){
return ItemFactory::get($this->getItemId(), $tile->getColor());
}
return ItemFactory::get($this->getItemId(), 14); //Red
}
public function isAffectedBySilkTouch() : bool{
return false;
}
public function getAffectedBlocks() : array{
if(($other = $this->getOtherHalf()) !== null){
return [$this, $other];
}
return parent::getAffectedBlocks();
}
}

View File

@ -19,6 +19,8 @@
*
*/
declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\item\Item;
@ -27,24 +29,23 @@ class Bedrock extends Solid{
protected $id = self::BEDROCK;
public function __construct(){
public function __construct(int $meta = 0){
$this->meta = $meta;
}
public function getName(){
public function getName() : string{
return "Bedrock";
}
public function getHardness(){
public function getHardness() : float{
return -1;
}
public function getResistance(){
public function getBlastResistance() : float{
return 18000000;
}
public function isBreakable(Item $item){
public function isBreakable(Item $item) : bool{
return false;
}
}
}

View File

@ -19,31 +19,40 @@
*
*/
declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\item\Item;
use pocketmine\item\ItemFactory;
use function mt_rand;
class Beetroot extends Crops{
protected $id = self::BEETROOT_BLOCK;
public function __construct($meta = 0){
public function __construct(int $meta = 0){
$this->meta = $meta;
}
public function getName(){
public function getName() : string{
return "Beetroot Block";
}
public function getDrops(Item $item){
$drops = [];
public function getDropsForCompatibleTool(Item $item) : array{
if($this->meta >= 0x07){
$drops[] = [Item::BEETROOT, 0, 1];
$drops[] = [Item::BEETROOT_SEEDS, 0, mt_rand(0, 3)];
}else{
$drops[] = [Item::BEETROOT_SEEDS, 0, 1];
return [
ItemFactory::get(Item::BEETROOT),
ItemFactory::get(Item::BEETROOT_SEEDS, 0, mt_rand(0, 3))
];
}
return $drops;
return [
ItemFactory::get(Item::BEETROOT_SEEDS)
];
}
}
public function getPickedItem() : Item{
return ItemFactory::get(Item::BEETROOT_SEEDS);
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,443 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\item\Item;
use pocketmine\level\Position;
use pocketmine\network\mcpe\protocol\types\RuntimeBlockMapping;
use function min;
/**
* Manages block registration and instance creation
*/
class BlockFactory{
/** @var \SplFixedArray<Block> */
private static $fullList = null;
/** @var \SplFixedArray<bool> */
public static $solid = null;
/** @var \SplFixedArray<bool> */
public static $transparent = null;
/** @var \SplFixedArray<float> */
public static $hardness = null;
/** @var \SplFixedArray<int> */
public static $light = null;
/** @var \SplFixedArray<int> */
public static $lightFilter = null;
/** @var \SplFixedArray<bool> */
public static $diffusesSkyLight = null;
/** @var \SplFixedArray<float> */
public static $blastResistance = null;
/**
* Initializes the block factory. By default this is called only once on server start, however you may wish to use
* this if you need to reset the block factory back to its original defaults for whatever reason.
*/
public static function init() : void{
self::$fullList = new \SplFixedArray(4096);
self::$light = new \SplFixedArray(256);
self::$lightFilter = new \SplFixedArray(256);
self::$solid = new \SplFixedArray(256);
self::$hardness = new \SplFixedArray(256);
self::$transparent = new \SplFixedArray(256);
self::$diffusesSkyLight = new \SplFixedArray(256);
self::$blastResistance = new \SplFixedArray(256);
self::registerBlock(new Air());
self::registerBlock(new Stone());
self::registerBlock(new Grass());
self::registerBlock(new Dirt());
self::registerBlock(new Cobblestone());
self::registerBlock(new Planks());
self::registerBlock(new Sapling());
self::registerBlock(new Bedrock());
self::registerBlock(new Water());
self::registerBlock(new StillWater());
self::registerBlock(new Lava());
self::registerBlock(new StillLava());
self::registerBlock(new Sand());
self::registerBlock(new Gravel());
self::registerBlock(new GoldOre());
self::registerBlock(new IronOre());
self::registerBlock(new CoalOre());
self::registerBlock(new Wood());
self::registerBlock(new Leaves());
self::registerBlock(new Sponge());
self::registerBlock(new Glass());
self::registerBlock(new LapisOre());
self::registerBlock(new Lapis());
//TODO: DISPENSER
self::registerBlock(new Sandstone());
self::registerBlock(new NoteBlock());
self::registerBlock(new Bed());
self::registerBlock(new PoweredRail());
self::registerBlock(new DetectorRail());
//TODO: STICKY_PISTON
self::registerBlock(new Cobweb());
self::registerBlock(new TallGrass());
self::registerBlock(new DeadBush());
//TODO: PISTON
//TODO: PISTONARMCOLLISION
self::registerBlock(new Wool());
self::registerBlock(new Dandelion());
self::registerBlock(new Flower());
self::registerBlock(new BrownMushroom());
self::registerBlock(new RedMushroom());
self::registerBlock(new Gold());
self::registerBlock(new Iron());
self::registerBlock(new DoubleStoneSlab());
self::registerBlock(new StoneSlab());
self::registerBlock(new Bricks());
self::registerBlock(new TNT());
self::registerBlock(new Bookshelf());
self::registerBlock(new MossyCobblestone());
self::registerBlock(new Obsidian());
self::registerBlock(new Torch());
self::registerBlock(new Fire());
self::registerBlock(new MonsterSpawner());
self::registerBlock(new WoodenStairs(Block::OAK_STAIRS, 0, "Oak Stairs"));
self::registerBlock(new Chest());
//TODO: REDSTONE_WIRE
self::registerBlock(new DiamondOre());
self::registerBlock(new Diamond());
self::registerBlock(new CraftingTable());
self::registerBlock(new Wheat());
self::registerBlock(new Farmland());
self::registerBlock(new Furnace());
self::registerBlock(new BurningFurnace());
self::registerBlock(new SignPost());
self::registerBlock(new WoodenDoor(Block::OAK_DOOR_BLOCK, 0, "Oak Door", Item::OAK_DOOR));
self::registerBlock(new Ladder());
self::registerBlock(new Rail());
self::registerBlock(new CobblestoneStairs());
self::registerBlock(new WallSign());
self::registerBlock(new Lever());
self::registerBlock(new StonePressurePlate());
self::registerBlock(new IronDoor());
self::registerBlock(new WoodenPressurePlate());
self::registerBlock(new RedstoneOre());
self::registerBlock(new GlowingRedstoneOre());
self::registerBlock(new RedstoneTorchUnlit());
self::registerBlock(new RedstoneTorch());
self::registerBlock(new StoneButton());
self::registerBlock(new SnowLayer());
self::registerBlock(new Ice());
self::registerBlock(new Snow());
self::registerBlock(new Cactus());
self::registerBlock(new Clay());
self::registerBlock(new Sugarcane());
//TODO: JUKEBOX
self::registerBlock(new WoodenFence());
self::registerBlock(new Pumpkin());
self::registerBlock(new Netherrack());
self::registerBlock(new SoulSand());
self::registerBlock(new Glowstone());
//TODO: PORTAL
self::registerBlock(new LitPumpkin());
self::registerBlock(new Cake());
//TODO: REPEATER_BLOCK
//TODO: POWERED_REPEATER
self::registerBlock(new InvisibleBedrock());
self::registerBlock(new Trapdoor());
//TODO: MONSTER_EGG
self::registerBlock(new StoneBricks());
self::registerBlock(new BrownMushroomBlock());
self::registerBlock(new RedMushroomBlock());
self::registerBlock(new IronBars());
self::registerBlock(new GlassPane());
self::registerBlock(new Melon());
self::registerBlock(new PumpkinStem());
self::registerBlock(new MelonStem());
self::registerBlock(new Vine());
self::registerBlock(new FenceGate(Block::OAK_FENCE_GATE, 0, "Oak Fence Gate"));
self::registerBlock(new BrickStairs());
self::registerBlock(new StoneBrickStairs());
self::registerBlock(new Mycelium());
self::registerBlock(new WaterLily());
self::registerBlock(new NetherBrick(Block::NETHER_BRICK_BLOCK, 0, "Nether Bricks"));
self::registerBlock(new NetherBrickFence());
self::registerBlock(new NetherBrickStairs());
self::registerBlock(new NetherWartPlant());
self::registerBlock(new EnchantingTable());
self::registerBlock(new BrewingStand());
//TODO: CAULDRON_BLOCK
//TODO: END_PORTAL
self::registerBlock(new EndPortalFrame());
self::registerBlock(new EndStone());
//TODO: DRAGON_EGG
self::registerBlock(new RedstoneLamp());
self::registerBlock(new LitRedstoneLamp());
//TODO: DROPPER
self::registerBlock(new ActivatorRail());
self::registerBlock(new CocoaBlock());
self::registerBlock(new SandstoneStairs());
self::registerBlock(new EmeraldOre());
self::registerBlock(new EnderChest());
self::registerBlock(new TripwireHook());
self::registerBlock(new Tripwire());
self::registerBlock(new Emerald());
self::registerBlock(new WoodenStairs(Block::SPRUCE_STAIRS, 0, "Spruce Stairs"));
self::registerBlock(new WoodenStairs(Block::BIRCH_STAIRS, 0, "Birch Stairs"));
self::registerBlock(new WoodenStairs(Block::JUNGLE_STAIRS, 0, "Jungle Stairs"));
//TODO: COMMAND_BLOCK
//TODO: BEACON
self::registerBlock(new CobblestoneWall());
self::registerBlock(new FlowerPot());
self::registerBlock(new Carrot());
self::registerBlock(new Potato());
self::registerBlock(new WoodenButton());
self::registerBlock(new Skull());
self::registerBlock(new Anvil());
self::registerBlock(new TrappedChest());
self::registerBlock(new WeightedPressurePlateLight());
self::registerBlock(new WeightedPressurePlateHeavy());
//TODO: COMPARATOR_BLOCK
//TODO: POWERED_COMPARATOR
self::registerBlock(new DaylightSensor());
self::registerBlock(new Redstone());
self::registerBlock(new NetherQuartzOre());
//TODO: HOPPER_BLOCK
self::registerBlock(new Quartz());
self::registerBlock(new QuartzStairs());
self::registerBlock(new DoubleWoodenSlab());
self::registerBlock(new WoodenSlab());
self::registerBlock(new StainedClay());
self::registerBlock(new StainedGlassPane());
self::registerBlock(new Leaves2());
self::registerBlock(new Wood2());
self::registerBlock(new WoodenStairs(Block::ACACIA_STAIRS, 0, "Acacia Stairs"));
self::registerBlock(new WoodenStairs(Block::DARK_OAK_STAIRS, 0, "Dark Oak Stairs"));
//TODO: SLIME
self::registerBlock(new IronTrapdoor());
self::registerBlock(new Prismarine());
self::registerBlock(new SeaLantern());
self::registerBlock(new HayBale());
self::registerBlock(new Carpet());
self::registerBlock(new HardenedClay());
self::registerBlock(new Coal());
self::registerBlock(new PackedIce());
self::registerBlock(new DoublePlant());
self::registerBlock(new StandingBanner());
self::registerBlock(new WallBanner());
//TODO: DAYLIGHT_DETECTOR_INVERTED
self::registerBlock(new RedSandstone());
self::registerBlock(new RedSandstoneStairs());
self::registerBlock(new DoubleStoneSlab2());
self::registerBlock(new StoneSlab2());
self::registerBlock(new FenceGate(Block::SPRUCE_FENCE_GATE, 0, "Spruce Fence Gate"));
self::registerBlock(new FenceGate(Block::BIRCH_FENCE_GATE, 0, "Birch Fence Gate"));
self::registerBlock(new FenceGate(Block::JUNGLE_FENCE_GATE, 0, "Jungle Fence Gate"));
self::registerBlock(new FenceGate(Block::DARK_OAK_FENCE_GATE, 0, "Dark Oak Fence Gate"));
self::registerBlock(new FenceGate(Block::ACACIA_FENCE_GATE, 0, "Acacia Fence Gate"));
//TODO: REPEATING_COMMAND_BLOCK
//TODO: CHAIN_COMMAND_BLOCK
self::registerBlock(new WoodenDoor(Block::SPRUCE_DOOR_BLOCK, 0, "Spruce Door", Item::SPRUCE_DOOR));
self::registerBlock(new WoodenDoor(Block::BIRCH_DOOR_BLOCK, 0, "Birch Door", Item::BIRCH_DOOR));
self::registerBlock(new WoodenDoor(Block::JUNGLE_DOOR_BLOCK, 0, "Jungle Door", Item::JUNGLE_DOOR));
self::registerBlock(new WoodenDoor(Block::ACACIA_DOOR_BLOCK, 0, "Acacia Door", Item::ACACIA_DOOR));
self::registerBlock(new WoodenDoor(Block::DARK_OAK_DOOR_BLOCK, 0, "Dark Oak Door", Item::DARK_OAK_DOOR));
self::registerBlock(new GrassPath());
self::registerBlock(new ItemFrame());
//TODO: CHORUS_FLOWER
self::registerBlock(new Purpur());
self::registerBlock(new PurpurStairs());
//TODO: UNDYED_SHULKER_BOX
self::registerBlock(new EndStoneBricks());
//TODO: FROSTED_ICE
self::registerBlock(new EndRod());
//TODO: END_GATEWAY
self::registerBlock(new Magma());
self::registerBlock(new NetherWartBlock());
self::registerBlock(new NetherBrick(Block::RED_NETHER_BRICK, 0, "Red Nether Bricks"));
self::registerBlock(new BoneBlock());
//TODO: SHULKER_BOX
self::registerBlock(new GlazedTerracotta(Block::PURPLE_GLAZED_TERRACOTTA, 0, "Purple Glazed Terracotta"));
self::registerBlock(new GlazedTerracotta(Block::WHITE_GLAZED_TERRACOTTA, 0, "White Glazed Terracotta"));
self::registerBlock(new GlazedTerracotta(Block::ORANGE_GLAZED_TERRACOTTA, 0, "Orange Glazed Terracotta"));
self::registerBlock(new GlazedTerracotta(Block::MAGENTA_GLAZED_TERRACOTTA, 0, "Magenta Glazed Terracotta"));
self::registerBlock(new GlazedTerracotta(Block::LIGHT_BLUE_GLAZED_TERRACOTTA, 0, "Light Blue Glazed Terracotta"));
self::registerBlock(new GlazedTerracotta(Block::YELLOW_GLAZED_TERRACOTTA, 0, "Yellow Glazed Terracotta"));
self::registerBlock(new GlazedTerracotta(Block::LIME_GLAZED_TERRACOTTA, 0, "Lime Glazed Terracotta"));
self::registerBlock(new GlazedTerracotta(Block::PINK_GLAZED_TERRACOTTA, 0, "Pink Glazed Terracotta"));
self::registerBlock(new GlazedTerracotta(Block::GRAY_GLAZED_TERRACOTTA, 0, "Grey Glazed Terracotta"));
self::registerBlock(new GlazedTerracotta(Block::SILVER_GLAZED_TERRACOTTA, 0, "Light Grey Glazed Terracotta"));
self::registerBlock(new GlazedTerracotta(Block::CYAN_GLAZED_TERRACOTTA, 0, "Cyan Glazed Terracotta"));
self::registerBlock(new GlazedTerracotta(Block::BLUE_GLAZED_TERRACOTTA, 0, "Blue Glazed Terracotta"));
self::registerBlock(new GlazedTerracotta(Block::BROWN_GLAZED_TERRACOTTA, 0, "Brown Glazed Terracotta"));
self::registerBlock(new GlazedTerracotta(Block::GREEN_GLAZED_TERRACOTTA, 0, "Green Glazed Terracotta"));
self::registerBlock(new GlazedTerracotta(Block::RED_GLAZED_TERRACOTTA, 0, "Red Glazed Terracotta"));
self::registerBlock(new GlazedTerracotta(Block::BLACK_GLAZED_TERRACOTTA, 0, "Black Glazed Terracotta"));
self::registerBlock(new Concrete());
self::registerBlock(new ConcretePowder());
//TODO: CHORUS_PLANT
self::registerBlock(new StainedGlass());
self::registerBlock(new Podzol());
self::registerBlock(new Beetroot());
self::registerBlock(new Stonecutter());
self::registerBlock(new GlowingObsidian());
self::registerBlock(new NetherReactor());
self::registerBlock(new InfoUpdate(Block::INFO_UPDATE, 0, "update!"));
self::registerBlock(new InfoUpdate(Block::INFO_UPDATE2, 0, "ate!upd"));
//TODO: MOVINGBLOCK
//TODO: OBSERVER
//TODO: STRUCTURE_BLOCK
self::registerBlock(new Reserved6(Block::RESERVED6, 0, "reserved6"));
for($id = 0, $size = self::$fullList->getSize() >> 4; $id < $size; ++$id){
if(self::$fullList[$id << 4] === null){
self::registerBlock(new UnknownBlock($id));
}
}
}
public static function isInit() : bool{
return self::$fullList !== null;
}
/**
* Registers a block type into the index. Plugins may use this method to register new block types or override
* existing ones.
*
* NOTE: If you are registering a new block type, you will need to add it to the creative inventory yourself - it
* will not automatically appear there.
*
* @param Block $block
* @param bool $override Whether to override existing registrations
*
* @throws \RuntimeException if something attempted to override an already-registered block without specifying the
* $override parameter.
*/
public static function registerBlock(Block $block, bool $override = false) : void{
$id = $block->getId();
if(!$override and self::isRegistered($id)){
throw new \RuntimeException("Trying to overwrite an already registered block");
}
for($meta = 0; $meta < 16; ++$meta){
$variant = clone $block;
$variant->setDamage($meta);
self::$fullList[($id << 4) | $meta] = $variant;
}
self::$solid[$id] = $block->isSolid();
self::$transparent[$id] = $block->isTransparent();
self::$hardness[$id] = $block->getHardness();
self::$light[$id] = $block->getLightLevel();
self::$lightFilter[$id] = min(15, $block->getLightFilter() + 1); //opacity plus 1 standard light filter
self::$diffusesSkyLight[$id] = $block->diffusesSkyLight();
self::$blastResistance[$id] = $block->getBlastResistance();
}
/**
* Returns a new Block instance with the specified ID, meta and position.
*
* @param int $id
* @param int $meta
* @param Position $pos
*
* @return Block
*/
public static function get(int $id, int $meta = 0, Position $pos = null) : Block{
if($meta < 0 or $meta > 0xf){
throw new \InvalidArgumentException("Block meta value $meta is out of bounds");
}
try{
if(self::$fullList !== null){
$block = clone self::$fullList[($id << 4) | $meta];
}else{
$block = new UnknownBlock($id, $meta);
}
}catch(\RuntimeException $e){
throw new \InvalidArgumentException("Block ID $id is out of bounds");
}
if($pos !== null){
$block->x = $pos->getFloorX();
$block->y = $pos->getFloorY();
$block->z = $pos->getFloorZ();
$block->level = $pos->level;
}
return $block;
}
/**
* @internal
* @return \SplFixedArray
*/
public static function getBlockStatesArray() : \SplFixedArray{
return self::$fullList;
}
/**
* Returns whether a specified block ID is already registered in the block factory.
*
* @param int $id
*
* @return bool
*/
public static function isRegistered(int $id) : bool{
$b = self::$fullList[$id << 4];
return $b !== null and !($b instanceof UnknownBlock);
}
/**
* @internal
* @deprecated
*
* @param int $id
* @param int $meta
*
* @return int
*/
public static function toStaticRuntimeId(int $id, int $meta = 0) : int{
return RuntimeBlockMapping::toStaticRuntimeId($id, $meta);
}
/**
* @deprecated
* @internal
*
* @param int $runtimeId
*
* @return int[] [id, meta]
*/
public static function fromStaticRuntimeId(int $runtimeId) : array{
return RuntimeBlockMapping::fromStaticRuntimeId($runtimeId);
}
}

View File

@ -19,214 +19,261 @@
*
*/
declare(strict_types=1);
namespace pocketmine\block;
interface BlockIds{
const AIR = 0;
const STONE = 1;
const GRASS = 2;
const DIRT = 3;
const COBBLESTONE = 4, COBBLE = 4;
const PLANK = 5, PLANKS = 5, WOODEN_PLANK = 5, WOODEN_PLANKS = 5;
const SAPLING = 6, SAPLINGS = 6;
const BEDROCK = 7;
const WATER = 8;
const STILL_WATER = 9;
const LAVA = 10;
const STILL_LAVA = 11;
const SAND = 12;
const GRAVEL = 13;
const GOLD_ORE = 14;
const IRON_ORE = 15;
const COAL_ORE = 16;
const LOG = 17, WOOD = 17, TRUNK = 17;
const LEAVES = 18;
const SPONGE = 19;
const GLASS = 20;
const LAPIS_ORE = 21;
const LAPIS_BLOCK = 22;
const DISPENSER = 23;
const SANDSTONE = 24;
const NOTE_BLOCK = 25, NOTEBLOCK = 25;
const BED_BLOCK = 26;
const POWERED_RAIL = 27;
const DETECTOR_RAIL = 28;
const STICKY_PISTON = 29;
const COBWEB = 30;
const TALL_GRASS = 31;
const BUSH = 32, DEAD_BUSH = 32;
const PISTON = 33;
const PISTON_HEAD = 34;
const WOOL = 35;
public const AIR = 0;
public const STONE = 1;
public const GRASS = 2;
public const DIRT = 3;
public const COBBLESTONE = 4;
public const PLANKS = 5, WOODEN_PLANKS = 5;
public const SAPLING = 6;
public const BEDROCK = 7;
public const FLOWING_WATER = 8;
public const STILL_WATER = 9, WATER = 9;
public const FLOWING_LAVA = 10;
public const LAVA = 11, STILL_LAVA = 11;
public const SAND = 12;
public const GRAVEL = 13;
public const GOLD_ORE = 14;
public const IRON_ORE = 15;
public const COAL_ORE = 16;
public const LOG = 17, WOOD = 17;
public const LEAVES = 18;
public const SPONGE = 19;
public const GLASS = 20;
public const LAPIS_ORE = 21;
public const LAPIS_BLOCK = 22;
public const DISPENSER = 23;
public const SANDSTONE = 24;
public const NOTEBLOCK = 25, NOTE_BLOCK = 25;
public const BED_BLOCK = 26;
public const GOLDEN_RAIL = 27, POWERED_RAIL = 27;
public const DETECTOR_RAIL = 28;
public const STICKY_PISTON = 29;
public const COBWEB = 30, WEB = 30;
public const TALLGRASS = 31, TALL_GRASS = 31;
public const DEADBUSH = 32, DEAD_BUSH = 32;
public const PISTON = 33;
public const PISTONARMCOLLISION = 34, PISTON_ARM_COLLISION = 34;
public const WOOL = 35;
const DANDELION = 37;
const POPPY = 38, ROSE = 38, RED_FLOWER = 38;
const BROWN_MUSHROOM = 39;
const RED_MUSHROOM = 40;
const GOLD_BLOCK = 41;
const IRON_BLOCK = 42;
const DOUBLE_SLAB = 43, DOUBLE_SLABS = 43;
const SLAB = 44, SLABS = 44, STONE_SLAB = 44;
const BRICKS = 45, BRICKS_BLOCK = 45;
const TNT = 46;
const BOOKSHELF = 47;
const MOSS_STONE = 48, MOSSY_STONE = 48;
const OBSIDIAN = 49;
const TORCH = 50;
const FIRE = 51;
const MONSTER_SPAWNER = 52;
const WOOD_STAIRS = 53, WOODEN_STAIRS = 53, OAK_WOOD_STAIRS = 53, OAK_WOODEN_STAIRS = 53;
const CHEST = 54;
const REDSTONE_WIRE = 55;
const DIAMOND_ORE = 56;
const DIAMOND_BLOCK = 57;
const CRAFTING_TABLE = 58, WORKBENCH = 58;
const WHEAT_BLOCK = 59;
const FARMLAND = 60;
const FURNACE = 61;
const BURNING_FURNACE = 62, LIT_FURNACE = 62;
const SIGN_POST = 63;
const DOOR_BLOCK = 64, WOODEN_DOOR_BLOCK = 64, WOOD_DOOR_BLOCK = 64;
const LADDER = 65;
const RAIL = 66;
const COBBLESTONE_STAIRS = 67, COBBLE_STAIRS = 67;
const WALL_SIGN = 68;
const LEVER = 69;
const STONE_PRESSURE_PLATE = 70;
const IRON_DOOR_BLOCK = 71;
const WOODEN_PRESSURE_PLATE = 72;
const REDSTONE_ORE = 73;
const GLOWING_REDSTONE_ORE = 74, LIT_REDSTONE_ORE = 74;
const UNLIT_REDSTONE_TORCH = 75;
const REDSTONE_TORCH = 76, LIT_REDSTONE_TORCH = 76;
const STONE_BUTTON = 77;
const SNOW = 78, SNOW_LAYER = 78;
const ICE = 79;
const SNOW_BLOCK = 80;
const CACTUS = 81;
const CLAY_BLOCK = 82;
const REEDS = 83, SUGARCANE_BLOCK = 83;
public const DANDELION = 37, YELLOW_FLOWER = 37;
public const POPPY = 38, RED_FLOWER = 38;
public const BROWN_MUSHROOM = 39;
public const RED_MUSHROOM = 40;
public const GOLD_BLOCK = 41;
public const IRON_BLOCK = 42;
public const DOUBLE_STONE_SLAB = 43;
public const STONE_SLAB = 44;
public const BRICK_BLOCK = 45;
public const TNT = 46;
public const BOOKSHELF = 47;
public const MOSSY_COBBLESTONE = 48, MOSS_STONE = 48;
public const OBSIDIAN = 49;
public const TORCH = 50;
public const FIRE = 51;
public const MOB_SPAWNER = 52, MONSTER_SPAWNER = 52;
public const OAK_STAIRS = 53, WOODEN_STAIRS = 53;
public const CHEST = 54;
public const REDSTONE_WIRE = 55;
public const DIAMOND_ORE = 56;
public const DIAMOND_BLOCK = 57;
public const CRAFTING_TABLE = 58, WORKBENCH = 58;
public const WHEAT_BLOCK = 59;
public const FARMLAND = 60;
public const FURNACE = 61;
public const BURNING_FURNACE = 62, LIT_FURNACE = 62;
public const SIGN_POST = 63, STANDING_SIGN = 63;
public const OAK_DOOR_BLOCK = 64, WOODEN_DOOR_BLOCK = 64;
public const LADDER = 65;
public const RAIL = 66;
public const COBBLESTONE_STAIRS = 67, STONE_STAIRS = 67;
public const WALL_SIGN = 68;
public const LEVER = 69;
public const STONE_PRESSURE_PLATE = 70;
public const IRON_DOOR_BLOCK = 71;
public const WOODEN_PRESSURE_PLATE = 72;
public const REDSTONE_ORE = 73;
public const GLOWING_REDSTONE_ORE = 74, LIT_REDSTONE_ORE = 74;
public const UNLIT_REDSTONE_TORCH = 75;
public const LIT_REDSTONE_TORCH = 76, REDSTONE_TORCH = 76;
public const STONE_BUTTON = 77;
public const SNOW_LAYER = 78;
public const ICE = 79;
public const SNOW = 80, SNOW_BLOCK = 80;
public const CACTUS = 81;
public const CLAY_BLOCK = 82;
public const REEDS_BLOCK = 83, SUGARCANE_BLOCK = 83;
public const JUKEBOX = 84;
public const FENCE = 85;
public const PUMPKIN = 86;
public const NETHERRACK = 87;
public const SOUL_SAND = 88;
public const GLOWSTONE = 89;
public const PORTAL = 90;
public const JACK_O_LANTERN = 91, LIT_PUMPKIN = 91;
public const CAKE_BLOCK = 92;
public const REPEATER_BLOCK = 93, UNPOWERED_REPEATER = 93;
public const POWERED_REPEATER = 94;
public const INVISIBLEBEDROCK = 95, INVISIBLE_BEDROCK = 95;
public const TRAPDOOR = 96, WOODEN_TRAPDOOR = 96;
public const MONSTER_EGG = 97;
public const STONEBRICK = 98, STONE_BRICK = 98, STONE_BRICKS = 98;
public const BROWN_MUSHROOM_BLOCK = 99;
public const RED_MUSHROOM_BLOCK = 100;
public const IRON_BARS = 101;
public const GLASS_PANE = 102;
public const MELON_BLOCK = 103;
public const PUMPKIN_STEM = 104;
public const MELON_STEM = 105;
public const VINE = 106, VINES = 106;
public const FENCE_GATE = 107, OAK_FENCE_GATE = 107;
public const BRICK_STAIRS = 108;
public const STONE_BRICK_STAIRS = 109;
public const MYCELIUM = 110;
public const LILY_PAD = 111, WATERLILY = 111, WATER_LILY = 111;
public const NETHER_BRICK_BLOCK = 112;
public const NETHER_BRICK_FENCE = 113;
public const NETHER_BRICK_STAIRS = 114;
public const NETHER_WART_PLANT = 115;
public const ENCHANTING_TABLE = 116, ENCHANTMENT_TABLE = 116;
public const BREWING_STAND_BLOCK = 117;
public const CAULDRON_BLOCK = 118;
public const END_PORTAL = 119;
public const END_PORTAL_FRAME = 120;
public const END_STONE = 121;
public const DRAGON_EGG = 122;
public const REDSTONE_LAMP = 123;
public const LIT_REDSTONE_LAMP = 124;
public const DROPPER = 125;
public const ACTIVATOR_RAIL = 126;
public const COCOA = 127, COCOA_BLOCK = 127;
public const SANDSTONE_STAIRS = 128;
public const EMERALD_ORE = 129;
public const ENDER_CHEST = 130;
public const TRIPWIRE_HOOK = 131;
public const TRIPWIRE = 132, TRIP_WIRE = 132;
public const EMERALD_BLOCK = 133;
public const SPRUCE_STAIRS = 134;
public const BIRCH_STAIRS = 135;
public const JUNGLE_STAIRS = 136;
public const COMMAND_BLOCK = 137;
public const BEACON = 138;
public const COBBLESTONE_WALL = 139, STONE_WALL = 139;
public const FLOWER_POT_BLOCK = 140;
public const CARROTS = 141, CARROT_BLOCK = 141;
public const POTATOES = 142, POTATO_BLOCK = 142;
public const WOODEN_BUTTON = 143;
public const MOB_HEAD_BLOCK = 144, SKULL_BLOCK = 144;
public const ANVIL = 145;
public const TRAPPED_CHEST = 146;
public const LIGHT_WEIGHTED_PRESSURE_PLATE = 147;
public const HEAVY_WEIGHTED_PRESSURE_PLATE = 148;
public const COMPARATOR_BLOCK = 149, UNPOWERED_COMPARATOR = 149;
public const POWERED_COMPARATOR = 150;
public const DAYLIGHT_DETECTOR = 151, DAYLIGHT_SENSOR = 151;
public const REDSTONE_BLOCK = 152;
public const NETHER_QUARTZ_ORE = 153, QUARTZ_ORE = 153;
public const HOPPER_BLOCK = 154;
public const QUARTZ_BLOCK = 155;
public const QUARTZ_STAIRS = 156;
public const DOUBLE_WOODEN_SLAB = 157;
public const WOODEN_SLAB = 158;
public const STAINED_CLAY = 159, STAINED_HARDENED_CLAY = 159, TERRACOTTA = 159;
public const STAINED_GLASS_PANE = 160;
public const LEAVES2 = 161;
public const LOG2 = 162, WOOD2 = 162;
public const ACACIA_STAIRS = 163;
public const DARK_OAK_STAIRS = 164;
public const SLIME = 165, SLIME_BLOCK = 165;
const FENCE = 85;
const PUMPKIN = 86;
const NETHERRACK = 87;
const SOUL_SAND = 88;
const GLOWSTONE = 89, GLOWSTONE_BLOCK = 89;
const PORTAL_BLOCK = 90, PORTAL = 90;
const JACK_O_LANTERN = 91, LIT_PUMPKIN = 91;
const CAKE_BLOCK = 92;
const REPEATER_BLOCK = 93, UNPOWERED_REPEATER_BLOCK = 93;
const POWERED_REPEATER_BLOCK = 94;
const INVISIBLE_BEDROCK = 95;
const TRAPDOOR = 96, WOODEN_TRAPDOOR = 96;
const MONSTER_EGG_BLOCK = 97;
const STONE_BRICKS = 98, STONE_BRICK = 98;
const BROWN_MUSHROOM_BLOCK = 99;
const RED_MUSHROOM_BLOCK = 100;
const IRON_BARS = 101, IRON_BAR = 101;
const GLASS_PANE = 102, GLASS_PANEL = 102;
const MELON_BLOCK = 103;
const PUMPKIN_STEM = 104;
const MELON_STEM = 105;
const VINES = 106, VINE = 106;
const FENCE_GATE = 107, OAK_FENCE_GATE = 107;
const BRICK_STAIRS = 108;
const STONE_BRICK_STAIRS = 109;
const MYCELIUM = 110;
const LILY_PAD = 111, WATER_LILY = 111;
const NETHER_BRICKS = 112, NETHER_BRICK_BLOCK = 112;
const NETHER_BRICK_FENCE = 113;
const NETHER_BRICK_STAIRS = 114, NETHER_BRICKS_STAIRS = 114;
const NETHER_WART_BLOCK = 115;
const ENCHANTING_TABLE = 116, ENCHANT_TABLE = 116, ENCHANTMENT_TABLE = 116;
const BREWING_STAND_BLOCK = 117;
const CAULDRON_BLOCK = 118;
public const IRON_TRAPDOOR = 167;
public const PRISMARINE = 168;
public const SEALANTERN = 169, SEA_LANTERN = 169;
public const HAY_BALE = 170, HAY_BLOCK = 170;
public const CARPET = 171;
public const HARDENED_CLAY = 172;
public const COAL_BLOCK = 173;
public const PACKED_ICE = 174;
public const DOUBLE_PLANT = 175;
public const STANDING_BANNER = 176;
public const WALL_BANNER = 177;
public const DAYLIGHT_DETECTOR_INVERTED = 178, DAYLIGHT_SENSOR_INVERTED = 178;
public const RED_SANDSTONE = 179;
public const RED_SANDSTONE_STAIRS = 180;
public const DOUBLE_STONE_SLAB2 = 181;
public const STONE_SLAB2 = 182;
public const SPRUCE_FENCE_GATE = 183;
public const BIRCH_FENCE_GATE = 184;
public const JUNGLE_FENCE_GATE = 185;
public const DARK_OAK_FENCE_GATE = 186;
public const ACACIA_FENCE_GATE = 187;
public const REPEATING_COMMAND_BLOCK = 188;
public const CHAIN_COMMAND_BLOCK = 189;
const END_PORTAL_FRAME = 120, END_PORTAL = 120;
const END_STONE = 121;
public const SPRUCE_DOOR_BLOCK = 193;
public const BIRCH_DOOR_BLOCK = 194;
public const JUNGLE_DOOR_BLOCK = 195;
public const ACACIA_DOOR_BLOCK = 196;
public const DARK_OAK_DOOR_BLOCK = 197;
public const GRASS_PATH = 198;
public const FRAME_BLOCK = 199, ITEM_FRAME_BLOCK = 199;
public const CHORUS_FLOWER = 200;
public const PURPUR_BLOCK = 201;
const REDSTONE_LAMP = 123, INACTIVE_REDSTONE_LAMP = 123;
const LIT_REDSTONE_LAMP = 124, ACTIVE_REDSTONE_LAMP = 124;
const DROPPER = 125;
const ACTIVATOR_RAIL = 126;
const COCOA_BLOCK = 127, COCOA_PODS = 127;
const SANDSTONE_STAIRS = 128;
const EMERALD_ORE = 129;
public const PURPUR_STAIRS = 203;
const TRIPWIRE_HOOK = 131;
const TRIPWIRE = 132;
const EMERALD_BLOCK = 133;
const SPRUCE_WOOD_STAIRS = 134, SPRUCE_WOODEN_STAIRS = 134;
const BIRCH_WOOD_STAIRS = 135, BIRCH_WOODEN_STAIRS = 135;
const JUNGLE_WOOD_STAIRS = 136, JUNGLE_WOODEN_STAIRS = 136;
public const UNDYED_SHULKER_BOX = 205;
public const END_BRICKS = 206;
public const FROSTED_ICE = 207;
public const END_ROD = 208;
public const END_GATEWAY = 209;
const BEACON = 138;
const COBBLESTONE_WALL = 139, COBBLE_WALL = 139, STONE_WALL = 139;
const FLOWER_POT_BLOCK = 140;
const CARROT_BLOCK = 141;
const POTATO_BLOCK = 142;
const WOODEN_BUTTON = 143;
const MOB_HEAD_BLOCK = 144, SKULL_BLOCK = 144;
const ANVIL = 145;
const TRAPPED_CHEST = 146;
const WEIGHTED_PRESSURE_PLATE_LIGHT = 147, LIGHT_WEIGHTED_PRESSURE_PLATE = 147, GOLD_PRESSURE_PLATE = 147;
const WEIGHTED_PRESSURE_PLATE_HEAVY = 148, HEAVY_WEIGHTED_PRESSURE_PLATE = 148, IRON_PRESSURE_PLATE = 148;
const COMPARATOR_BLOCK = 149, UNPOWERED_COMPARATOR_BLOCK = 149;
const POWERED_COMPARATOR_BLOCK = 150;
const DAYLIGHT_SENSOR = 151;
const REDSTONE_BLOCK = 152;
const NETHER_QUARTZ_ORE = 153;
const HOPPER_BLOCK = 154;
const QUARTZ_BLOCK = 155;
const QUARTZ_STAIRS = 156;
const DOUBLE_WOOD_SLAB = 157, DOUBLE_WOODEN_SLAB = 157, DOUBLE_WOOD_SLABS = 157, DOUBLE_WOODEN_SLABS = 157;
const WOOD_SLAB = 158, WOODEN_SLAB = 158, WOOD_SLABS = 158, WOODEN_SLABS = 158;
const STAINED_CLAY = 159, STAINED_HARDENED_CLAY = 159;
public const MAGMA = 213;
public const NETHER_WART_BLOCK = 214;
public const RED_NETHER_BRICK = 215;
public const BONE_BLOCK = 216;
const LEAVES2 = 161;
const WOOD2 = 162, TRUNK2 = 162, LOG2 = 162;
const ACACIA_WOOD_STAIRS = 163, ACACIA_WOODEN_STAIRS = 163;
const DARK_OAK_WOOD_STAIRS = 164, DARK_OAK_WOODEN_STAIRS = 164;
const SLIME_BLOCK = 165;
public const SHULKER_BOX = 218;
public const PURPLE_GLAZED_TERRACOTTA = 219;
public const WHITE_GLAZED_TERRACOTTA = 220;
public const ORANGE_GLAZED_TERRACOTTA = 221;
public const MAGENTA_GLAZED_TERRACOTTA = 222;
public const LIGHT_BLUE_GLAZED_TERRACOTTA = 223;
public const YELLOW_GLAZED_TERRACOTTA = 224;
public const LIME_GLAZED_TERRACOTTA = 225;
public const PINK_GLAZED_TERRACOTTA = 226;
public const GRAY_GLAZED_TERRACOTTA = 227;
public const SILVER_GLAZED_TERRACOTTA = 228;
public const CYAN_GLAZED_TERRACOTTA = 229;
const IRON_TRAPDOOR = 167;
const PRISMARINE = 168;
const SEA_LANTERN = 169;
const HAY_BALE = 170;
const CARPET = 171;
const HARDENED_CLAY = 172;
const COAL_BLOCK = 173;
const PACKED_ICE = 174;
const DOUBLE_PLANT = 175;
public const BLUE_GLAZED_TERRACOTTA = 231;
public const BROWN_GLAZED_TERRACOTTA = 232;
public const GREEN_GLAZED_TERRACOTTA = 233;
public const RED_GLAZED_TERRACOTTA = 234;
public const BLACK_GLAZED_TERRACOTTA = 235;
public const CONCRETE = 236;
public const CONCRETEPOWDER = 237, CONCRETE_POWDER = 237;
const INVERTED_DAYLIGHT_SENSOR = 178, DAYLIGHT_SENSOR_INVERTED = 178;
const RED_SANDSTONE = 179;
const RED_SANDSTONE_STAIRS = 180;
const DOUBLE_RED_SANDSTONE_SLAB = 181;
const RED_SANDSTONE_SLAB = 182;
const SPRUCE_FENCE_GATE = 183, FENCE_GATE_SPRUCE = 183;
const BIRCH_FENCE_GATE = 184, FENCE_GATE_BIRCH = 184;
const JUNGLE_FENCE_GATE = 185, FENCE_GATE_JUNGLE = 185;
const DARK_OAK_FENCE_GATE = 186, FENCE_GATE_DARK_OAK = 186;
const ACACIA_FENCE_GATE = 187, FENCE_GATE_ACACIA = 187;
public const CHORUS_PLANT = 240;
public const STAINED_GLASS = 241;
const SPRUCE_DOOR_BLOCK = 193;
const BIRCH_DOOR_BLOCK = 194;
const JUNGLE_DOOR_BLOCK = 195;
const ACACIA_DOOR_BLOCK = 196;
const DARK_OAK_DOOR_BLOCK = 197;
const GRASS_PATH = 198;
const ITEM_FRAME_BLOCK = 199;
public const PODZOL = 243;
public const BEETROOT_BLOCK = 244;
public const STONECUTTER = 245;
public const GLOWINGOBSIDIAN = 246, GLOWING_OBSIDIAN = 246;
public const NETHERREACTOR = 247, NETHER_REACTOR = 247;
public const INFO_UPDATE = 248;
public const INFO_UPDATE2 = 249;
public const MOVINGBLOCK = 250, MOVING_BLOCK = 250;
public const OBSERVER = 251;
public const STRUCTURE_BLOCK = 252;
public const RESERVED6 = 255;
const PODZOL = 243;
const BEETROOT_BLOCK = 244;
const STONECUTTER = 245;
const GLOWING_OBSIDIAN = 246;
const NETHER_REACTOR = 247;
const UPDATE_BLOCK = 248;
const ATEUPD_BLOCK = 249;
const BLOCK_MOVED_BY_PISTON = 250;
const OBSERVER = 251;
const INFO_RESERVED6 = 255;
}

View File

@ -0,0 +1,39 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\block;
/**
* Types of tools that can be used to break blocks
* Blocks may allow multiple tool types by combining these bitflags
*/
interface BlockToolType{
public const TYPE_NONE = 0;
public const TYPE_SWORD = 1 << 0;
public const TYPE_SHOVEL = 1 << 1;
public const TYPE_PICKAXE = 1 << 2;
public const TYPE_AXE = 1 << 3;
public const TYPE_SHEARS = 1 << 4;
}

View File

@ -0,0 +1,64 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\block\utils\PillarRotationHelper;
use pocketmine\item\Item;
use pocketmine\item\TieredTool;
use pocketmine\math\Vector3;
use pocketmine\Player;
class BoneBlock extends Solid{
protected $id = Block::BONE_BLOCK;
public function __construct(int $meta = 0){
$this->meta = $meta;
}
public function getName() : string{
return "Bone Block";
}
public function getHardness() : float{
return 2;
}
public function getToolType() : int{
return BlockToolType::TYPE_PICKAXE;
}
public function getToolHarvestLevel() : int{
return TieredTool::TIER_WOODEN;
}
public function place(Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, Player $player = null) : bool{
$this->meta = PillarRotationHelper::getMetaFromFace($this->meta, $face);
return $this->getLevel()->setBlock($blockReplace, $this, true, true);
}
public function getVariantBitmask() : int{
return 0x03;
}
}

View File

@ -19,28 +19,48 @@
*
*/
declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\item\Tool;
use pocketmine\item\Item;
use pocketmine\item\ItemFactory;
class Bookshelf extends Solid{
protected $id = self::BOOKSHELF;
public function __construct(){
public function __construct(int $meta = 0){
$this->meta = $meta;
}
public function getName(){
public function getName() : string{
return "Bookshelf";
}
public function getHardness(){
public function getHardness() : float{
return 1.5;
}
public function getToolType(){
return Tool::TYPE_AXE;
public function getToolType() : int{
return BlockToolType::TYPE_AXE;
}
}
public function getDropsForCompatibleTool(Item $item) : array{
return [
ItemFactory::get(Item::BOOK, 0, 3)
];
}
public function getFuelTime() : int{
return 300;
}
public function getFlameEncouragement() : int{
return 30;
}
public function getFlammability() : int{
return 20;
}
}

View File

@ -19,27 +19,42 @@
*
*/
declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\item\Tool;
use pocketmine\item\Item;
use pocketmine\item\TieredTool;
class BrewingStand extends Transparent{
protected $id = self::BREWING_STAND_BLOCK;
public function __construct(){
protected $itemId = Item::BREWING_STAND;
public function __construct(int $meta = 0){
$this->meta = $meta;
}
public function getName(){
public function getName() : string{
return "Brewing Stand";
}
public function getHardness(){
public function getHardness() : float{
return 0.5;
}
public function getToolType(){
return Tool::TYPE_PICKAXE;
public function getToolType() : int{
return BlockToolType::TYPE_PICKAXE;
}
}
public function getToolHarvestLevel() : int{
return TieredTool::TIER_WOODEN;
}
public function getVariantBitmask() : int{
return 0;
}
//TODO
}

View File

@ -19,32 +19,37 @@
*
*/
declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\item\Tool;
use pocketmine\item\TieredTool;
class BrickStairs extends Stair{
protected $id = self::BRICK_STAIRS;
public function __construct($meta = 0){
public function __construct(int $meta = 0){
$this->meta = $meta;
}
public function getHardness(){
public function getHardness() : float{
return 2;
}
public function getResistance(){
public function getBlastResistance() : float{
return 30;
}
public function getToolType(){
return Tool::TYPE_PICKAXE;
public function getToolType() : int{
return BlockToolType::TYPE_PICKAXE;
}
public function getName(){
public function getToolHarvestLevel() : int{
return TieredTool::TIER_WOODEN;
}
public function getName() : string{
return "Brick Stairs";
}
}
}

View File

@ -19,42 +19,37 @@
*
*/
declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\item\Item;
use pocketmine\item\Tool;
use pocketmine\item\TieredTool;
class Bricks extends Solid{
protected $id = self::BRICKS_BLOCK;
public function __construct(){
protected $id = self::BRICK_BLOCK;
public function __construct(int $meta = 0){
$this->meta = $meta;
}
public function getHardness(){
public function getHardness() : float{
return 2;
}
public function getResistance(){
public function getBlastResistance() : float{
return 30;
}
public function getToolType(){
return Tool::TYPE_PICKAXE;
public function getToolType() : int{
return BlockToolType::TYPE_PICKAXE;
}
public function getName(){
public function getToolHarvestLevel() : int{
return TieredTool::TIER_WOODEN;
}
public function getName() : string{
return "Bricks";
}
public function getDrops(Item $item){
if($item->isPickaxe() >= Tool::TIER_WOODEN){
return [
[Item::BRICKS_BLOCK, 0, 1],
];
}else{
return [];
}
}
}
}

View File

@ -19,53 +19,19 @@
*
*/
declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\item\Item;
use pocketmine\level\Level;
use pocketmine\Player;
class BrownMushroom extends Flowable{
class BrownMushroom extends RedMushroom{
protected $id = self::BROWN_MUSHROOM;
public function __construct($meta = 0){
$this->meta = $meta;
}
public function getName(){
public function getName() : string{
return "Brown Mushroom";
}
public function getLightLevel(){
public function getLightLevel() : int{
return 1;
}
public function onUpdate($type){
if($type === Level::BLOCK_UPDATE_NORMAL){
if($this->getSide(0)->isTransparent() === true){
$this->getLevel()->useBreakOn($this);
return Level::BLOCK_UPDATE_NORMAL;
}
}
return false;
}
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){
$down = $this->getSide(0);
if($down->isTransparent() === false){
$this->getLevel()->setBlock($block, $this, true, true);
return true;
}
return false;
}
public function getBoundingBox(){
return null;
}
}
}

View File

@ -0,0 +1,42 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\item\Item;
use function mt_rand;
class BrownMushroomBlock extends RedMushroomBlock{
protected $id = Block::BROWN_MUSHROOM_BLOCK;
public function getName() : string{
return "Brown Mushroom Block";
}
public function getDropsForCompatibleTool(Item $item) : array{
return [
Item::get(Item::BROWN_MUSHROOM, 0, mt_rand(0, 2))
];
}
}

View File

@ -19,15 +19,13 @@
*
*/
declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\item\Item;
use pocketmine\item\Tool;
use pocketmine\nbt\NBT;
use pocketmine\nbt\tag\CompoundTag;
use pocketmine\nbt\tag\IntTag;
use pocketmine\nbt\tag\ListTag;
use pocketmine\nbt\tag\StringTag;
use pocketmine\item\TieredTool;
use pocketmine\math\Vector3;
use pocketmine\Player;
use pocketmine\tile\Furnace as TileFurnace;
use pocketmine\tile\Tile;
@ -36,102 +34,68 @@ class BurningFurnace extends Solid{
protected $id = self::BURNING_FURNACE;
public function __construct($meta = 0){
protected $itemId = self::FURNACE;
public function __construct(int $meta = 0){
$this->meta = $meta;
}
public function getName(){
public function getName() : string{
return "Burning Furnace";
}
public function canBeActivated(){
return true;
}
public function getHardness(){
public function getHardness() : float{
return 3.5;
}
public function getToolType(){
return Tool::TYPE_PICKAXE;
public function getToolType() : int{
return BlockToolType::TYPE_PICKAXE;
}
public function getLightLevel(){
public function getToolHarvestLevel() : int{
return TieredTool::TIER_WOODEN;
}
public function getLightLevel() : int{
return 13;
}
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){
public function place(Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, Player $player = null) : bool{
$faces = [
0 => 4,
1 => 2,
2 => 5,
3 => 3,
3 => 3
];
$this->meta = $faces[$player instanceof Player ? $player->getDirection() : 0];
$this->getLevel()->setBlock($block, $this, true, true);
$nbt = new CompoundTag("", [
new ListTag("Items", []),
new StringTag("id", Tile::FURNACE),
new IntTag("x", $this->x),
new IntTag("y", $this->y),
new IntTag("z", $this->z)
]);
$nbt->Items->setTagType(NBT::TAG_Compound);
$this->getLevel()->setBlock($blockReplace, $this, true, true);
if($item->hasCustomName()){
$nbt->CustomName = new StringTag("CustomName", $item->getCustomName());
}
if($item->hasCustomBlockData()){
foreach($item->getCustomBlockData() as $key => $v){
$nbt->{$key} = $v;
}
}
Tile::createTile("Furnace", $this->getLevel(), $nbt);
Tile::createTile(Tile::FURNACE, $this->getLevel(), TileFurnace::createNBT($this, $face, $item, $player));
return true;
}
public function onBreak(Item $item){
$this->getLevel()->setBlock($this, new Air(), true, true);
return true;
}
public function onActivate(Item $item, Player $player = null){
public function onActivate(Item $item, Player $player = null) : bool{
if($player instanceof Player){
$furnace = $this->getLevel()->getTile($this);
if(!($furnace instanceof TileFurnace)){
$nbt = new CompoundTag("", [
new ListTag("Items", []),
new StringTag("id", Tile::FURNACE),
new IntTag("x", $this->x),
new IntTag("y", $this->y),
new IntTag("z", $this->z)
]);
$nbt->Items->setTagType(NBT::TAG_Compound);
$furnace = Tile::createTile("Furnace", $this->getLevel(), $nbt);
}
if(isset($furnace->namedtag->Lock) and $furnace->namedtag->Lock instanceof StringTag){
if($furnace->namedtag->Lock->getValue() !== $item->getCustomName()){
$furnace = Tile::createTile(Tile::FURNACE, $this->getLevel(), TileFurnace::createNBT($this));
if(!($furnace instanceof TileFurnace)){
return true;
}
}
if(!$furnace->canOpenWith($item->getCustomName())){
return true;
}
$player->addWindow($furnace->getInventory());
}
return true;
}
public function getDrops(Item $item){
$drops = [];
if($item->isPickaxe() >= Tool::TIER_WOODEN){
$drops[] = [Item::FURNACE, 0, 1];
}
return $drops;
public function getVariantBitmask() : int{
return 0;
}
}
}

View File

@ -0,0 +1,51 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\item\Item;
use pocketmine\math\Vector3;
use pocketmine\Player;
abstract class Button extends Flowable{
public function __construct(int $meta = 0){
$this->meta = $meta;
}
public function getVariantBitmask() : int{
return 0;
}
public function place(Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, Player $player = null) : bool{
//TODO: check valid target block
$this->meta = $face;
return $this->level->setBlock($this, $this, true, true);
}
public function onActivate(Item $item, Player $player = null) : bool{
//TODO
return true;
}
}

View File

@ -19,6 +19,8 @@
*
*/
declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\entity\Entity;
@ -26,33 +28,31 @@ use pocketmine\event\block\BlockGrowEvent;
use pocketmine\event\entity\EntityDamageByBlockEvent;
use pocketmine\event\entity\EntityDamageEvent;
use pocketmine\item\Item;
use pocketmine\level\Level;
use pocketmine\math\AxisAlignedBB;
use pocketmine\math\Vector3;
use pocketmine\Player;
use pocketmine\Server;
class Cactus extends Transparent{
protected $id = self::CACTUS;
public function __construct($meta = 0){
public function __construct(int $meta = 0){
$this->meta = $meta;
}
public function getHardness(){
public function getHardness() : float{
return 0.4;
}
public function hasEntityCollision(){
public function hasEntityCollision() : bool{
return true;
}
public function getName(){
public function getName() : string{
return "Cactus";
}
protected function recalculateBoundingBox(){
protected function recalculateBoundingBox() : ?AxisAlignedBB{
return new AxisAlignedBB(
$this->x + 0.0625,
@ -64,56 +64,63 @@ class Cactus extends Transparent{
);
}
public function onEntityCollide(Entity $entity){
public function onEntityCollide(Entity $entity) : void{
$ev = new EntityDamageByBlockEvent($this, $entity, EntityDamageEvent::CAUSE_CONTACT, 1);
$entity->attack($ev->getFinalDamage(), $ev);
$entity->attack($ev);
}
public function onUpdate($type){
if($type === Level::BLOCK_UPDATE_NORMAL){
$down = $this->getSide(0);
if($down->getId() !== self::SAND and $down->getId() !== self::CACTUS){
$this->getLevel()->useBreakOn($this);
}else{
for($side = 2; $side <= 5; ++$side){
$b = $this->getSide($side);
if(!$b->canBeFlowedInto()){
$this->getLevel()->useBreakOn($this);
}
}
}
}elseif($type === Level::BLOCK_UPDATE_RANDOM){
if($this->getSide(0)->getId() !== self::CACTUS){
if($this->meta == 0x0F){
for($y = 1; $y < 3; ++$y){
$b = $this->getLevel()->getBlock(new Vector3($this->x, $this->y + $y, $this->z));
if($b->getId() === self::AIR){
Server::getInstance()->getPluginManager()->callEvent($ev = new BlockGrowEvent($b, new Cactus()));
if(!$ev->isCancelled()){
$this->getLevel()->setBlock($b, $ev->getNewState(), true);
}
}
}
$this->meta = 0;
$this->getLevel()->setBlock($this, $this);
}else{
++$this->meta;
$this->getLevel()->setBlock($this, $this);
public function onNearbyBlockChange() : void{
$down = $this->getSide(Vector3::SIDE_DOWN);
if($down->getId() !== self::SAND and $down->getId() !== self::CACTUS){
$this->getLevel()->useBreakOn($this);
}else{
for($side = 2; $side <= 5; ++$side){
$b = $this->getSide($side);
if($b->isSolid()){
$this->getLevel()->useBreakOn($this);
break;
}
}
}
return false;
}
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){
$down = $this->getSide(0);
public function ticksRandomly() : bool{
return true;
}
public function onRandomTick() : void{
if($this->getSide(Vector3::SIDE_DOWN)->getId() !== self::CACTUS){
if($this->meta === 0x0f){
for($y = 1; $y < 3; ++$y){
$b = $this->getLevel()->getBlockAt($this->x, $this->y + $y, $this->z);
if($b->getId() === self::AIR){
$ev = new BlockGrowEvent($b, BlockFactory::get(Block::CACTUS));
$ev->call();
if($ev->isCancelled()){
break;
}
$this->getLevel()->setBlock($b, $ev->getNewState(), true);
}else{
break;
}
}
$this->meta = 0;
$this->getLevel()->setBlock($this, $this);
}else{
++$this->meta;
$this->getLevel()->setBlock($this, $this);
}
}
}
public function place(Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, Player $player = null) : bool{
$down = $this->getSide(Vector3::SIDE_DOWN);
if($down->getId() === self::SAND or $down->getId() === self::CACTUS){
$block0 = $this->getSide(2);
$block1 = $this->getSide(3);
$block2 = $this->getSide(4);
$block3 = $this->getSide(5);
if($block0->isTransparent() === true and $block1->isTransparent() === true and $block2->isTransparent() === true and $block3->isTransparent() === true){
$block0 = $this->getSide(Vector3::SIDE_NORTH);
$block1 = $this->getSide(Vector3::SIDE_SOUTH);
$block2 = $this->getSide(Vector3::SIDE_WEST);
$block3 = $this->getSide(Vector3::SIDE_EAST);
if(!$block0->isSolid() and !$block1->isSolid() and !$block2->isSolid() and !$block3->isSolid()){
$this->getLevel()->setBlock($this, $this, true);
return true;
@ -123,9 +130,7 @@ class Cactus extends Transparent{
return false;
}
public function getDrops(Item $item){
return [
[$this->id, 0, 1],
];
public function getVariantBitmask() : int{
return 0;
}
}
}

View File

@ -19,42 +19,42 @@
*
*/
declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\entity\Effect;
use pocketmine\event\entity\EntityEatBlockEvent;
use pocketmine\entity\EffectInstance;
use pocketmine\entity\Living;
use pocketmine\item\FoodSource;
use pocketmine\item\Item;
use pocketmine\level\Level;
use pocketmine\math\AxisAlignedBB;
use pocketmine\math\Vector3;
use pocketmine\Player;
class Cake extends Transparent implements FoodSource{
protected $id = self::CAKE_BLOCK;
public function __construct($meta = 0){
protected $itemId = Item::CAKE;
public function __construct(int $meta = 0){
$this->meta = $meta;
}
public function canBeActivated(){
return true;
}
public function getHardness(){
public function getHardness() : float{
return 0.5;
}
public function getName(){
return "Cake Block";
public function getName() : string{
return "Cake";
}
protected function recalculateBoundingBox(){
protected function recalculateBoundingBox() : ?AxisAlignedBB{
$f = (1 + $this->getDamage() * 2) / 16;
$f = $this->getDamage() * 0.125; //1 slice width
return new AxisAlignedBB(
$this->x + $f,
$this->x + 0.0625 + $f,
$this->y,
$this->z + 0.0625,
$this->x + 1 - 0.0625,
@ -63,10 +63,10 @@ class Cake extends Transparent implements FoodSource{
);
}
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){
$down = $this->getSide(0);
public function place(Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, Player $player = null) : bool{
$down = $this->getSide(Vector3::SIDE_DOWN);
if($down->getId() !== self::AIR){
$this->getLevel()->setBlock($block, $this, true, true);
$this->getLevel()->setBlock($blockReplace, $this, true, true);
return true;
}
@ -74,30 +74,24 @@ class Cake extends Transparent implements FoodSource{
return false;
}
public function onUpdate($type){
if($type === Level::BLOCK_UPDATE_NORMAL){
if($this->getSide(0)->getId() === self::AIR){ //Replace with common break method
$this->getLevel()->setBlock($this, new Air(), true);
return Level::BLOCK_UPDATE_NORMAL;
}
public function onNearbyBlockChange() : void{
if($this->getSide(Vector3::SIDE_DOWN)->getId() === self::AIR){ //Replace with common break method
$this->getLevel()->setBlock($this, BlockFactory::get(Block::AIR), true);
}
return false;
}
public function getDrops(Item $item){
public function getDropsForCompatibleTool(Item $item) : array{
return [];
}
public function onActivate(Item $item, Player $player = null){
if($player instanceof Player and $player->getHealth() < $player->getMaxHealth()){
$ev = new EntityEatBlockEvent($player, $this);
public function isAffectedBySilkTouch() : bool{
return false;
}
if(!$ev->isCancelled()){
$this->getLevel()->setBlock($this, $ev->getResidue());
return true;
}
public function onActivate(Item $item, Player $player = null) : bool{
if($player !== null){
$player->consumeObject($this);
return true;
}
return false;
@ -111,19 +105,30 @@ class Cake extends Transparent implements FoodSource{
return 0.4;
}
public function requiresHunger() : bool{
return true;
}
/**
* @return Block
*/
public function getResidue(){
$clone = clone $this;
$clone->meta++;
if($clone->meta >= 0x06){
$clone = new Air();
if($clone->meta > 0x06){
$clone = BlockFactory::get(Block::AIR);
}
return $clone;
}
/**
* @return Effect[]
* @return EffectInstance[]
*/
public function getAdditionalEffects() : array{
return [];
}
public function onConsume(Living $consumer) : void{
$this->level->setBlock($this, $this->getResidue());
}
}

View File

@ -19,52 +19,37 @@
*
*/
declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\block\utils\ColorBlockMetaHelper;
use pocketmine\item\Item;
use pocketmine\level\Level;
use pocketmine\math\AxisAlignedBB;
use pocketmine\math\Vector3;
use pocketmine\Player;
class Carpet extends Flowable{
protected $id = self::CARPET;
public function __construct($meta = 0){
public function __construct(int $meta = 0){
$this->meta = $meta;
}
public function getHardness(){
public function getHardness() : float{
return 0.1;
}
public function isSolid(){
public function isSolid() : bool{
return true;
}
public function getName(){
static $names = [
0 => "White Carpet",
1 => "Orange Carpet",
2 => "Magenta Carpet",
3 => "Light Blue Carpet",
4 => "Yellow Carpet",
5 => "Lime Carpet",
6 => "Pink Carpet",
7 => "Gray Carpet",
8 => "Light Gray Carpet",
9 => "Cyan Carpet",
10 => "Purple Carpet",
11 => "Blue Carpet",
12 => "Brown Carpet",
13 => "Green Carpet",
14 => "Red Carpet",
15 => "Black Carpet",
];
return $names[$this->meta & 0x0f];
public function getName() : string{
return ColorBlockMetaHelper::getColorFromMeta($this->getVariant()) . " Carpet";
}
protected function recalculateBoundingBox(){
protected function recalculateBoundingBox() : ?AxisAlignedBB{
return new AxisAlignedBB(
$this->x,
@ -76,10 +61,10 @@ class Carpet extends Flowable{
);
}
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){
$down = $this->getSide(0);
public function place(Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, Player $player = null) : bool{
$down = $this->getSide(Vector3::SIDE_DOWN);
if($down->getId() !== self::AIR){
$this->getLevel()->setBlock($block, $this, true, true);
$this->getLevel()->setBlock($blockReplace, $this, true, true);
return true;
}
@ -87,16 +72,17 @@ class Carpet extends Flowable{
return false;
}
public function onUpdate($type){
if($type === Level::BLOCK_UPDATE_NORMAL){
if($this->getSide(0)->getId() === self::AIR){
$this->getLevel()->useBreakOn($this);
return Level::BLOCK_UPDATE_NORMAL;
}
public function onNearbyBlockChange() : void{
if($this->getSide(Vector3::SIDE_DOWN)->getId() === self::AIR){
$this->getLevel()->useBreakOn($this);
}
return false;
}
}
public function getFlameEncouragement() : int{
return 30;
}
public function getFlammability() : int{
return 20;
}
}

View File

@ -19,30 +19,33 @@
*
*/
declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\item\Item;
use pocketmine\item\ItemFactory;
use function mt_rand;
class Carrot extends Crops{
protected $id = self::CARROT_BLOCK;
public function __construct($meta = 0){
public function __construct(int $meta = 0){
$this->meta = $meta;
}
public function getName(){
public function getName() : string{
return "Carrot Block";
}
public function getDrops(Item $item){
$drops = [];
if($this->meta >= 0x07){
$drops[] = [Item::CARROT, 0, mt_rand(1, 4)];
}else{
$drops[] = [Item::CARROT, 0, 1];
}
return $drops;
public function getDropsForCompatibleTool(Item $item) : array{
return [
ItemFactory::get(Item::CARROT, 0, $this->meta >= 0x07 ? mt_rand(1, 4) : 1)
];
}
}
public function getPickedItem() : Item{
return ItemFactory::get(Item::CARROT);
}
}

View File

@ -19,16 +19,13 @@
*
*/
declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\item\Item;
use pocketmine\item\Tool;
use pocketmine\math\AxisAlignedBB;
use pocketmine\nbt\NBT;
use pocketmine\nbt\tag\CompoundTag;
use pocketmine\nbt\tag\IntTag;
use pocketmine\nbt\tag\ListTag;
use pocketmine\nbt\tag\StringTag;
use pocketmine\math\Vector3;
use pocketmine\Player;
use pocketmine\tile\Chest as TileChest;
use pocketmine\tile\Tile;
@ -37,43 +34,40 @@ class Chest extends Transparent{
protected $id = self::CHEST;
public function __construct($meta = 0){
public function __construct(int $meta = 0){
$this->meta = $meta;
}
public function canBeActivated(){
return true;
}
public function getHardness(){
public function getHardness() : float{
return 2.5;
}
public function getName(){
public function getName() : string{
return "Chest";
}
public function getToolType(){
return Tool::TYPE_AXE;
public function getToolType() : int{
return BlockToolType::TYPE_AXE;
}
protected function recalculateBoundingBox(){
protected function recalculateBoundingBox() : ?AxisAlignedBB{
//these are slightly bigger than in PC
return new AxisAlignedBB(
$this->x + 0.0625,
$this->x + 0.025,
$this->y,
$this->z + 0.0625,
$this->x + 0.9375,
$this->y + 0.9475,
$this->z + 0.9375
$this->z + 0.025,
$this->x + 0.975,
$this->y + 0.95,
$this->z + 0.975
);
}
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){
public function place(Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, Player $player = null) : bool{
$faces = [
0 => 4,
1 => 2,
2 => 5,
3 => 3,
3 => 3
];
$chest = null;
@ -95,27 +89,8 @@ class Chest extends Transparent{
}
}
$this->getLevel()->setBlock($block, $this, true, true);
$nbt = new CompoundTag("", [
new ListTag("Items", []),
new StringTag("id", Tile::CHEST),
new IntTag("x", $this->x),
new IntTag("y", $this->y),
new IntTag("z", $this->z)
]);
$nbt->Items->setTagType(NBT::TAG_Compound);
if($item->hasCustomName()){
$nbt->CustomName = new StringTag("CustomName", $item->getCustomName());
}
if($item->hasCustomBlockData()){
foreach($item->getCustomBlockData() as $key => $v){
$nbt->{$key} = $v;
}
}
$tile = Tile::createTile("Chest", $this->getLevel(), $nbt);
$this->getLevel()->setBlock($blockReplace, $this, true, true);
$tile = Tile::createTile(Tile::CHEST, $this->getLevel(), TileChest::createNBT($this, $face, $item, $player));
if($chest instanceof TileChest and $tile instanceof TileChest){
$chest->pairWith($tile);
@ -125,54 +100,39 @@ class Chest extends Transparent{
return true;
}
public function onBreak(Item $item){
$t = $this->getLevel()->getTile($this);
if($t instanceof TileChest){
$t->unpair();
}
$this->getLevel()->setBlock($this, new Air(), true, true);
return true;
}
public function onActivate(Item $item, Player $player = null){
public function onActivate(Item $item, Player $player = null) : bool{
if($player instanceof Player){
$top = $this->getSide(1);
if($top->isTransparent() !== true){
return true;
}
$t = $this->getLevel()->getTile($this);
$chest = null;
if($t instanceof TileChest){
$chest = $t;
}else{
$nbt = new CompoundTag("", [
new ListTag("Items", []),
new StringTag("id", Tile::CHEST),
new IntTag("x", $this->x),
new IntTag("y", $this->y),
new IntTag("z", $this->z)
]);
$nbt->Items->setTagType(NBT::TAG_Compound);
$chest = Tile::createTile("Chest", $this->getLevel(), $nbt);
}
if(isset($chest->namedtag->Lock) and $chest->namedtag->Lock instanceof StringTag){
if($chest->namedtag->Lock->getValue() !== $item->getCustomName()){
$chest = Tile::createTile(Tile::CHEST, $this->getLevel(), TileChest::createNBT($this));
if(!($chest instanceof TileChest)){
return true;
}
}
if(
!$this->getSide(Vector3::SIDE_UP)->isTransparent() or
($chest->isPaired() and !$chest->getPair()->getBlock()->getSide(Vector3::SIDE_UP)->isTransparent()) or
!$chest->canOpenWith($item->getCustomName())
){
return true;
}
$player->addWindow($chest->getInventory());
}
return true;
}
public function getDrops(Item $item){
return [
[$this->id, 0, 1],
];
public function getVariantBitmask() : int{
return 0;
}
}
public function getFuelTime() : int{
return 300;
}
}

View File

@ -19,34 +19,36 @@
*
*/
declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\item\Item;
use pocketmine\item\Tool;
use pocketmine\item\ItemFactory;
class Clay extends Solid{
protected $id = self::CLAY_BLOCK;
public function __construct(){
public function __construct(int $meta = 0){
$this->meta = $meta;
}
public function getHardness(){
public function getHardness() : float{
return 0.6;
}
public function getToolType(){
return Tool::TYPE_SHOVEL;
public function getToolType() : int{
return BlockToolType::TYPE_SHOVEL;
}
public function getName(){
public function getName() : string{
return "Clay Block";
}
public function getDrops(Item $item){
public function getDropsForCompatibleTool(Item $item) : array{
return [
[Item::CLAY, 0, 4],
ItemFactory::get(Item::CLAY_BALL, 0, 4)
];
}
}
}

View File

@ -19,38 +19,45 @@
*
*/
declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\item\Item;
use pocketmine\item\Tool;
use pocketmine\item\TieredTool;
class Coal extends Solid{
protected $id = self::COAL_BLOCK;
public function __construct(){
public function __construct(int $meta = 0){
$this->meta = $meta;
}
public function getHardness(){
public function getHardness() : float{
return 5;
}
public function getToolType(){
return Tool::TYPE_PICKAXE;
public function getToolType() : int{
return BlockToolType::TYPE_PICKAXE;
}
public function getName(){
public function getToolHarvestLevel() : int{
return TieredTool::TIER_WOODEN;
}
public function getName() : string{
return "Coal Block";
}
public function getDrops(Item $item){
if($item->isPickaxe() >= Tool::TIER_WOODEN){
return [
[Item::COAL_BLOCK, 0, 1],
];
}else{
return [];
}
public function getFuelTime() : int{
return 16000;
}
}
public function getFlameEncouragement() : int{
return 5;
}
public function getFlammability() : int{
return 5;
}
}

View File

@ -19,39 +19,46 @@
*
*/
declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\item\Item;
use pocketmine\item\Tool;
use pocketmine\item\ItemFactory;
use pocketmine\item\TieredTool;
use function mt_rand;
class CoalOre extends Solid{
protected $id = self::COAL_ORE;
public function __construct(){
public function __construct(int $meta = 0){
$this->meta = $meta;
}
public function getHardness(){
public function getHardness() : float{
return 3;
}
public function getToolType(){
return Tool::TYPE_PICKAXE;
public function getToolType() : int{
return BlockToolType::TYPE_PICKAXE;
}
public function getName(){
public function getToolHarvestLevel() : int{
return TieredTool::TIER_WOODEN;
}
public function getName() : string{
return "Coal Ore";
}
public function getDrops(Item $item){
if($item->isPickaxe() >= Tool::TIER_WOODEN){
return [
[Item::COAL, 0, 1],
];
}else{
return [];
}
public function getDropsForCompatibleTool(Item $item) : array{
return [
ItemFactory::get(Item::COAL)
];
}
}
protected function getXpDropAmount() : int{
return mt_rand(0, 2);
}
}

View File

@ -19,38 +19,33 @@
*
*/
declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\item\Item;
use pocketmine\item\Tool;
use pocketmine\item\TieredTool;
class Cobblestone extends Solid{
protected $id = self::COBBLESTONE;
public function __construct(){
public function __construct(int $meta = 0){
$this->meta = $meta;
}
public function getToolType(){
return Tool::TYPE_PICKAXE;
public function getToolType() : int{
return BlockToolType::TYPE_PICKAXE;
}
public function getName(){
public function getToolHarvestLevel() : int{
return TieredTool::TIER_WOODEN;
}
public function getName() : string{
return "Cobblestone";
}
public function getHardness(){
public function getHardness() : float{
return 2;
}
public function getDrops(Item $item){
if($item->isPickaxe() >= Tool::TIER_WOODEN){
return [
[Item::COBBLESTONE, 0, 1],
];
}else{
return [];
}
}
}
}

View File

@ -19,28 +19,33 @@
*
*/
declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\item\Tool;
use pocketmine\item\TieredTool;
class CobblestoneStairs extends Stair{
protected $id = self::COBBLESTONE_STAIRS;
public function __construct($meta = 0){
public function __construct(int $meta = 0){
$this->meta = $meta;
}
public function getHardness(){
public function getHardness() : float{
return 2;
}
public function getToolType(){
return Tool::TYPE_PICKAXE;
public function getToolType() : int{
return BlockToolType::TYPE_PICKAXE;
}
public function getName(){
public function getToolHarvestLevel() : int{
return TieredTool::TIER_WOODEN;
}
public function getName() : string{
return "Cobblestone Stairs";
}
}
}

View File

@ -0,0 +1,117 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\item\TieredTool;
use pocketmine\math\AxisAlignedBB;
use pocketmine\math\Vector3;
class CobblestoneWall extends Transparent{
public const NONE_MOSSY_WALL = 0;
public const MOSSY_WALL = 1;
public const GRANITE_WALL = 2;
public const DIORITE_WALL = 3;
public const ANDESITE_WALL = 4;
public const SANDSTONE_WALL = 5;
public const BRICK_WALL = 6;
public const STONE_BRICK_WALL = 7;
public const MOSSY_STONE_BRICK_WALL = 8;
public const NETHER_BRICK_WALL = 9;
public const END_STONE_BRICK_WALL = 10;
public const PRISMARINE_WALL = 11;
public const RED_SANDSTONE_WALL = 12;
public const RED_NETHER_BRICK_WALL = 13;
protected $id = self::COBBLESTONE_WALL;
public function __construct(int $meta = 0){
$this->meta = $meta;
}
public function getToolType() : int{
return BlockToolType::TYPE_PICKAXE;
}
public function getToolHarvestLevel() : int{
return TieredTool::TIER_WOODEN;
}
public function getHardness() : float{
return 2;
}
public function getName() : string{
static $names = [
self::NONE_MOSSY_WALL => "Cobblestone",
self::MOSSY_WALL => "Mossy Cobblestone",
self::GRANITE_WALL => "Granite",
self::DIORITE_WALL => "Diorite",
self::ANDESITE_WALL => "Andesite",
self::SANDSTONE_WALL => "Sandstone",
self::BRICK_WALL => "Brick",
self::STONE_BRICK_WALL => "Stone Brick",
self::MOSSY_STONE_BRICK_WALL => "Mossy Stone Brick",
self::NETHER_BRICK_WALL => "Nether Brick",
self::END_STONE_BRICK_WALL => "End Stone Brick",
self::PRISMARINE_WALL => "Prismarine",
self::RED_SANDSTONE_WALL => "Red Sandstone",
self::RED_NETHER_BRICK_WALL => "Red Nether Brick"
];
return ($names[$this->getVariant()] ?? "Unknown") . " Wall";
}
protected function recalculateBoundingBox() : ?AxisAlignedBB{
//walls don't have any special collision boxes like fences do
$north = $this->canConnect($this->getSide(Vector3::SIDE_NORTH));
$south = $this->canConnect($this->getSide(Vector3::SIDE_SOUTH));
$west = $this->canConnect($this->getSide(Vector3::SIDE_WEST));
$east = $this->canConnect($this->getSide(Vector3::SIDE_EAST));
$inset = 0.25;
if(
$this->getSide(Vector3::SIDE_UP)->getId() === Block::AIR and //if there is a block on top, it stays as a post
(
($north and $south and !$west and !$east) or
(!$north and !$south and $west and $east)
)
){
//If connected to two sides on the same axis but not any others, AND there is not a block on top, there is no post and the wall is thinner
$inset = 0.3125;
}
return new AxisAlignedBB(
$this->x + ($west ? 0 : $inset),
$this->y,
$this->z + ($north ? 0 : $inset),
$this->x + 1 - ($east ? 0 : $inset),
$this->y + 1.5,
$this->z + 1 - ($south ? 0 : $inset)
);
}
public function canConnect(Block $block){
return $block instanceof static or $block instanceof FenceGate or ($block->isSolid() and !$block->isTransparent());
}
}

View File

@ -19,42 +19,53 @@
*
*/
declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\entity\Entity;
use pocketmine\item\Item;
use pocketmine\item\Tool;
use pocketmine\item\ItemFactory;
class Cobweb extends Flowable{
protected $id = self::COBWEB;
public function __construct(){
public function __construct(int $meta = 0){
$this->meta = $meta;
}
public function hasEntityCollision(){
public function hasEntityCollision() : bool{
return true;
}
public function getName(){
public function getName() : string{
return "Cobweb";
}
public function getHardness(){
public function getHardness() : float{
return 4;
}
public function getToolType(){
return Tool::TYPE_SWORD;
public function getToolType() : int{
return BlockToolType::TYPE_SWORD | BlockToolType::TYPE_SHEARS;
}
public function onEntityCollide(Entity $entity){
public function getToolHarvestLevel() : int{
return 1;
}
public function onEntityCollide(Entity $entity) : void{
$entity->resetFallDistance();
}
public function getDrops(Item $item){
//TODO: correct drops
return [];
public function getDropsForCompatibleTool(Item $item) : array{
return [
ItemFactory::get(Item::STRING)
];
}
}
public function diffusesSkyLight() : bool{
return true;
}
}

View File

@ -19,17 +19,33 @@
*
*/
declare(strict_types=1);
namespace pocketmine\block;
class CocoaBlock extends Solid{
class CocoaBlock extends Transparent{
protected $id = self::COCOA_BLOCK;
public function __construct($meta = 0){
public function __construct(int $meta = 0){
$this->meta = $meta;
}
public function getName(){
public function getName() : string{
return "Cocoa Block";
}
public function getHardness() : float{
return 0.2;
}
public function getToolType() : int{
return BlockToolType::TYPE_AXE;
}
//TODO
public function isAffectedBySilkTouch() : bool{
return false;
}
}

View File

@ -0,0 +1,52 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\block\utils\ColorBlockMetaHelper;
use pocketmine\item\TieredTool;
class Concrete extends Solid{
protected $id = Block::CONCRETE;
public function __construct(int $meta = 0){
$this->meta = $meta;
}
public function getName() : string{
return ColorBlockMetaHelper::getColorFromMeta($this->getVariant()) . " Concrete";
}
public function getHardness() : float{
return 1.8;
}
public function getToolType() : int{
return BlockToolType::TYPE_PICKAXE;
}
public function getToolHarvestLevel() : int{
return TieredTool::TIER_WOODEN;
}
}

View File

@ -0,0 +1,75 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\block\utils\ColorBlockMetaHelper;
class ConcretePowder extends Fallable{
protected $id = self::CONCRETE_POWDER;
public function __construct(int $meta = 0){
$this->meta = $meta;
}
public function getName() : string{
return ColorBlockMetaHelper::getColorFromMeta($this->getVariant()) . " Concrete Powder";
}
public function getHardness() : float{
return 0.5;
}
public function getToolType() : int{
return BlockToolType::TYPE_SHOVEL;
}
public function onNearbyBlockChange() : void{
if(($block = $this->checkAdjacentWater()) !== null){
$this->level->setBlock($this, $block);
}else{
parent::onNearbyBlockChange();
}
}
/**
* @return null|Block
*/
public function tickFalling() : ?Block{
return $this->checkAdjacentWater();
}
/**
* @return null|Block
*/
private function checkAdjacentWater() : ?Block{
for($i = 1; $i < 6; ++$i){ //Do not check underneath
if($this->getSide($i) instanceof Water){
return BlockFactory::get(Block::CONCRETE, $this->meta);
}
}
return null;
}
}

View File

@ -19,48 +19,43 @@
*
*/
declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\inventory\CraftingGrid;
use pocketmine\item\Item;
use pocketmine\item\Tool;
use pocketmine\Player;
//TODO: check orientation
class Workbench extends Solid{
class CraftingTable extends Solid{
protected $id = self::WORKBENCH;
protected $id = self::CRAFTING_TABLE;
public function __construct($meta = 0){
public function __construct(int $meta = 0){
$this->meta = $meta;
}
public function canBeActivated(){
return true;
}
public function getHardness(){
public function getHardness() : float{
return 2.5;
}
public function getName(){
public function getName() : string{
return "Crafting Table";
}
public function getToolType(){
return Tool::TYPE_AXE;
public function getToolType() : int{
return BlockToolType::TYPE_AXE;
}
public function onActivate(Item $item, Player $player = null){
public function onActivate(Item $item, Player $player = null) : bool{
if($player instanceof Player){
$player->craftingType = 1;
$player->setCraftingGrid(new CraftingGrid($player, CraftingGrid::SIZE_BIG));
}
return true;
}
public function getDrops(Item $item){
return [
[$this->id, 0, 1],
];
public function getFuelTime() : int{
return 300;
}
}
}

View File

@ -19,24 +19,21 @@
*
*/
declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\event\block\BlockGrowEvent;
use pocketmine\item\Item;
use pocketmine\level\Level;
use pocketmine\math\Vector3;
use pocketmine\Player;
use pocketmine\Server;
use function mt_rand;
abstract class Crops extends Flowable{
public function canBeActivated(){
return true;
}
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){
$down = $this->getSide(0);
if($down->getId() === self::FARMLAND){
$this->getLevel()->setBlock($block, $this, true, true);
public function place(Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, Player $player = null) : bool{
if($blockReplace->getSide(Vector3::SIDE_DOWN)->getId() === Block::FARMLAND){
$this->getLevel()->setBlock($blockReplace, $this, true, true);
return true;
}
@ -45,16 +42,16 @@ abstract class Crops extends Flowable{
}
public function onActivate(Item $item, Player $player = null){
if($item->getId() === Item::DYE and $item->getDamage() === 0x0F){ //Bonemeal
public function onActivate(Item $item, Player $player = null) : bool{
if($this->meta < 7 and $item->getId() === Item::DYE and $item->getDamage() === 0x0F){ //Bonemeal
$block = clone $this;
$block->meta += mt_rand(2, 5);
if($block->meta > 7){
$block->meta = 7;
}
Server::getInstance()->getPluginManager()->callEvent($ev = new BlockGrowEvent($this, $block));
$ev = new BlockGrowEvent($this, $block);
$ev->call();
if(!$ev->isCancelled()){
$this->getLevel()->setBlock($this, $ev->getNewState(), true, true);
}
@ -67,30 +64,31 @@ abstract class Crops extends Flowable{
return false;
}
public function onUpdate($type){
if($type === Level::BLOCK_UPDATE_NORMAL){
if($this->getSide(0)->isTransparent() === true){
$this->getLevel()->useBreakOn($this);
return Level::BLOCK_UPDATE_NORMAL;
}
}elseif($type === Level::BLOCK_UPDATE_RANDOM){
if(mt_rand(0, 2) == 1){
if($this->meta < 0x07){
$block = clone $this;
++$block->meta;
Server::getInstance()->getPluginManager()->callEvent($ev = new BlockGrowEvent($this, $block));
public function onNearbyBlockChange() : void{
if($this->getSide(Vector3::SIDE_DOWN)->getId() !== Block::FARMLAND){
$this->getLevel()->useBreakOn($this);
}
}
if(!$ev->isCancelled()){
$this->getLevel()->setBlock($this, $ev->getNewState(), true, true);
}else{
return Level::BLOCK_UPDATE_RANDOM;
}
public function ticksRandomly() : bool{
return true;
}
public function onRandomTick() : void{
if(mt_rand(0, 2) === 1){
if($this->meta < 0x07){
$block = clone $this;
++$block->meta;
$ev = new BlockGrowEvent($this, $block);
$ev->call();
if(!$ev->isCancelled()){
$this->getLevel()->setBlock($this, $ev->getNewState(), true, true);
}
}else{
return Level::BLOCK_UPDATE_RANDOM;
}
}
}
public function isAffectedBySilkTouch() : bool{
return false;
}
}
}

View File

@ -19,29 +19,31 @@
*
*/
declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\item\Item;
use pocketmine\level\Level;
use pocketmine\math\Vector3;
use pocketmine\Player;
class Dandelion extends Flowable{
protected $id = self::DANDELION;
public function __construct(){
public function __construct(int $meta = 0){
$this->meta = $meta;
}
public function getName(){
public function getName() : string{
return "Dandelion";
}
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){
$down = $this->getSide(0);
if($down->getId() === 2 or $down->getId() === 3 or $down->getId() === 60){
$this->getLevel()->setBlock($block, $this, true, true);
public function place(Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, Player $player = null) : bool{
$down = $this->getSide(Vector3::SIDE_DOWN);
if($down->getId() === Block::GRASS or $down->getId() === Block::DIRT or $down->getId() === Block::FARMLAND){
$this->getLevel()->setBlock($blockReplace, $this, true, true);
return true;
}
@ -49,15 +51,17 @@ class Dandelion extends Flowable{
return false;
}
public function onUpdate($type){
if($type === Level::BLOCK_UPDATE_NORMAL){
if($this->getSide(0)->isTransparent() === true){
$this->getLevel()->useBreakOn($this);
return Level::BLOCK_UPDATE_NORMAL;
}
public function onNearbyBlockChange() : void{
if($this->getSide(Vector3::SIDE_DOWN)->isTransparent()){
$this->getLevel()->useBreakOn($this);
}
return false;
}
}
public function getFlameEncouragement() : int{
return 60;
}
public function getFlammability() : int{
return 100;
}
}

View File

@ -1,31 +0,0 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
namespace pocketmine\block;
class DarkOakWoodStairs extends WoodStairs{
protected $id = self::DARK_OAK_WOOD_STAIRS;
public function getName(){
return "Dark Oak Wood Stairs";
}
}

View File

@ -19,21 +19,33 @@
*
*/
declare(strict_types=1);
namespace pocketmine\block;
class DaylightSensor extends Transparent{
protected $id = self::DAYLIGHT_SENSOR;
public function __construct($meta = 0){
public function __construct(int $meta = 0){
$this->meta = $meta;
}
public function getName(){
public function getName() : string{
return "Daylight Sensor";
}
public function getHardness(){
public function getHardness() : float{
return 0.2;
}
public function getFuelTime() : int{
return 300;
}
public function getToolType() : int{
return BlockToolType::TYPE_AXE;
}
//TODO
}

View File

@ -19,33 +19,65 @@
*
*/
declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\level\Level;
use pocketmine\item\Item;
use pocketmine\item\ItemFactory;
use pocketmine\math\Vector3;
use pocketmine\Player;
use function mt_rand;
class DeadBush extends Flowable{
protected $id = self::DEAD_BUSH;
public function __construct($meta = 0){
public function __construct(int $meta = 0){
$this->meta = $meta;
}
public function getName(){
public function getName() : string{
return "Dead Bush";
}
public function onUpdate($type){
if($type === Level::BLOCK_UPDATE_NORMAL){
if($this->getSide(0)->isTransparent() === true){
$this->getLevel()->useBreakOn($this);
return Level::BLOCK_UPDATE_NORMAL;
}
public function place(Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, Player $player = null) : bool{
if(!$this->getSide(Vector3::SIDE_DOWN)->isTransparent()){
return parent::place($item, $blockReplace, $blockClicked, $face, $clickVector, $player);
}
return false;
}
}
public function onNearbyBlockChange() : void{
if($this->getSide(Vector3::SIDE_DOWN)->isTransparent()){
$this->getLevel()->useBreakOn($this);
}
}
public function getToolType() : int{
return BlockToolType::TYPE_SHEARS;
}
public function getToolHarvestLevel() : int{
return 1;
}
public function getDrops(Item $item) : array{
if(!$this->isCompatibleWithTool($item)){
return [
ItemFactory::get(Item::STICK, 0, mt_rand(0, 2))
];
}
return parent::getDrops($item);
}
public function getFlameEncouragement() : int{
return 60;
}
public function getFlammability() : int{
return 100;
}
}

View File

@ -19,17 +19,17 @@
*
*/
declare(strict_types=1);
namespace pocketmine\block;
class DetectorRail extends Rail{
class DetectorRail extends RedstoneRail{
protected $id = self::DETECTOR_RAIL;
public function __construct($meta = 0){
$this->meta = $meta;
}
public function getName(){
public function getName() : string{
return "Detector Rail";
}
//TODO
}

View File

@ -19,38 +19,33 @@
*
*/
declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\item\Item;
use pocketmine\item\Tool;
use pocketmine\item\TieredTool;
class Diamond extends Solid{
protected $id = self::DIAMOND_BLOCK;
public function __construct(){
public function __construct(int $meta = 0){
$this->meta = $meta;
}
public function getHardness(){
public function getHardness() : float{
return 5;
}
public function getName(){
public function getName() : string{
return "Diamond Block";
}
public function getToolType(){
return Tool::TYPE_PICKAXE;
public function getToolType() : int{
return BlockToolType::TYPE_PICKAXE;
}
public function getDrops(Item $item){
if($item->isPickaxe() >= Tool::TIER_IRON){
return [
[Item::DIAMOND_BLOCK, 0, 1],
];
}else{
return [];
}
public function getToolHarvestLevel() : int{
return TieredTool::TIER_IRON;
}
}
}

View File

@ -19,38 +19,46 @@
*
*/
declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\item\Item;
use pocketmine\item\Tool;
use pocketmine\item\ItemFactory;
use pocketmine\item\TieredTool;
use function mt_rand;
class DiamondOre extends Solid{
protected $id = self::DIAMOND_ORE;
public function __construct(){
public function __construct(int $meta = 0){
$this->meta = $meta;
}
public function getHardness(){
public function getHardness() : float{
return 3;
}
public function getName(){
public function getName() : string{
return "Diamond Ore";
}
public function getToolType(){
return Tool::TYPE_PICKAXE;
public function getToolType() : int{
return BlockToolType::TYPE_PICKAXE;
}
public function getDrops(Item $item){
if($item->isPickaxe() >= Tool::TIER_IRON){
return [
[Item::DIAMOND, 0, 1],
];
}else{
return [];
}
public function getToolHarvestLevel() : int{
return TieredTool::TIER_IRON;
}
}
public function getDropsForCompatibleTool(Item $item) : array{
return [
ItemFactory::get(Item::DIAMOND)
];
}
protected function getXpDropAmount() : int{
return mt_rand(3, 7);
}
}

View File

@ -19,44 +19,49 @@
*
*/
declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\item\Hoe;
use pocketmine\item\Item;
use pocketmine\item\Tool;
use pocketmine\Player;
class Dirt extends Solid{
protected $id = self::DIRT;
public function __construct(){
public function __construct(int $meta = 0){
$this->meta = $meta;
}
public function canBeActivated(){
return true;
}
public function getHardness(){
public function getHardness() : float{
return 0.5;
}
public function getToolType(){
return Tool::TYPE_SHOVEL;
public function getToolType() : int{
return BlockToolType::TYPE_SHOVEL;
}
public function getName(){
public function getName() : string{
if($this->meta === 1){
return "Coarse Dirt";
}
return "Dirt";
}
public function onActivate(Item $item, Player $player = null){
if($item->isHoe()){
$item->useOn($this);
$this->getLevel()->setBlock($this, Block::get(Item::FARMLAND, 0), true);
public function onActivate(Item $item, Player $player = null) : bool{
if($item instanceof Hoe){
$item->applyDamage(1);
if($this->meta === 1){
$this->getLevel()->setBlock($this, BlockFactory::get(Block::DIRT), true);
}else{
$this->getLevel()->setBlock($this, BlockFactory::get(Block::FARMLAND), true);
}
return true;
}
return false;
}
}
}

View File

@ -19,10 +19,11 @@
*
*/
declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\item\Item;
use pocketmine\level\Level;
use pocketmine\level\sound\DoorSound;
use pocketmine\math\AxisAlignedBB;
use pocketmine\math\Vector3;
@ -31,11 +32,7 @@ use pocketmine\Player;
abstract class Door extends Transparent{
public function canBeActivated(){
return true;
}
public function isSolid(){
public function isSolid() : bool{
return false;
}
@ -56,7 +53,7 @@ abstract class Door extends Transparent{
return $down & 0x07 | ($isUp ? 8 : 0) | ($isRight ? 0x10 : 0);
}
protected function recalculateBoundingBox(){
protected function recalculateBoundingBox() : ?AxisAlignedBB{
$f = 0.1875;
$damage = $this->getFullDamage();
@ -203,79 +200,51 @@ abstract class Door extends Transparent{
return $bb;
}
public function onUpdate($type){
if($type === Level::BLOCK_UPDATE_NORMAL){
if($this->getSide(0)->getId() === self::AIR){ //Replace with common break method
$this->getLevel()->setBlock($this, new Air(), false);
if($this->getSide(1) instanceof Door){
$this->getLevel()->setBlock($this->getSide(1), new Air(), false);
}
return Level::BLOCK_UPDATE_NORMAL;
public function onNearbyBlockChange() : void{
if($this->getSide(Vector3::SIDE_DOWN)->getId() === self::AIR){ //Replace with common break method
$this->getLevel()->setBlock($this, BlockFactory::get(Block::AIR), false);
if($this->getSide(Vector3::SIDE_UP) instanceof Door){
$this->getLevel()->setBlock($this->getSide(Vector3::SIDE_UP), BlockFactory::get(Block::AIR), false);
}
}
return false;
}
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){
if($face === 1){
$blockUp = $this->getSide(1);
$blockDown = $this->getSide(0);
if($blockUp->canBeReplaced() === false or $blockDown->isTransparent() === true){
public function place(Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, Player $player = null) : bool{
if($face === Vector3::SIDE_UP){
$blockUp = $this->getSide(Vector3::SIDE_UP);
$blockDown = $this->getSide(Vector3::SIDE_DOWN);
if(!$blockUp->canBeReplaced() or $blockDown->isTransparent()){
return false;
}
$direction = $player instanceof Player ? $player->getDirection() : 0;
$face = [
$faces = [
0 => 3,
1 => 4,
2 => 2,
3 => 5,
3 => 5
];
$next = $this->getSide($face[(($direction + 2) % 4)]);
$next2 = $this->getSide($face[$direction]);
$next = $this->getSide($faces[($direction + 2) % 4]);
$next2 = $this->getSide($faces[$direction]);
$metaUp = 0x08;
if($next->getId() === $this->getId() or ($next2->isTransparent() === false and $next->isTransparent() === true)){ //Door hinge
if($next->getId() === $this->getId() or (!$next2->isTransparent() and $next->isTransparent())){ //Door hinge
$metaUp |= 0x01;
}
$this->setDamage($player->getDirection() & 0x03);
$this->getLevel()->setBlock($block, $this, true, true); //Bottom
$this->getLevel()->setBlock($blockUp, $b = Block::get($this->getId(), $metaUp), true); //Top
$this->getLevel()->setBlock($blockReplace, $this, true, true); //Bottom
$this->getLevel()->setBlock($blockUp, BlockFactory::get($this->getId(), $metaUp), true); //Top
return true;
}
return false;
}
public function onBreak(Item $item){
if(($this->getDamage() & 0x08) === 0x08){
$down = $this->getSide(0);
if($down->getId() === $this->getId()){
$this->getLevel()->setBlock($down, new Air(), true);
}
}else{
$up = $this->getSide(1);
if($up->getId() === $this->getId()){
$this->getLevel()->setBlock($up, new Air(), true);
}
}
$this->getLevel()->setBlock($this, new Air(), true);
return true;
}
public function onActivate(Item $item, Player $player = null){
public function onActivate(Item $item, Player $player = null) : bool{
if(($this->getDamage() & 0x08) === 0x08){ //Top
$down = $this->getSide(0);
$down = $this->getSide(Vector3::SIDE_DOWN);
if($down->getId() === $this->getId()){
$meta = $down->getDamage() ^ 0x04;
$this->getLevel()->setBlock($down, Block::get($this->getId(), $meta), true);
$players = $this->getLevel()->getChunkPlayers($this->x >> 4, $this->z >> 4);
if($player instanceof Player){
unset($players[$player->getLoaderId()]);
}
$this->level->setBlock($down, BlockFactory::get($this->getId(), $meta), true);
$this->level->addSound(new DoorSound($this));
return true;
}
@ -283,14 +252,42 @@ abstract class Door extends Transparent{
return false;
}else{
$this->meta ^= 0x04;
$this->getLevel()->setBlock($this, $this, true);
$players = $this->getLevel()->getChunkPlayers($this->x >> 4, $this->z >> 4);
if($player instanceof Player){
unset($players[$player->getLoaderId()]);
}
$this->level->setBlock($this, $this, true);
$this->level->addSound(new DoorSound($this));
}
return true;
}
}
public function getVariantBitmask() : int{
return 0;
}
public function getDropsForCompatibleTool(Item $item) : array{
if(($this->meta & 0x08) === 0){ //bottom half only
return parent::getDropsForCompatibleTool($item);
}
return [];
}
public function isAffectedBySilkTouch() : bool{
return false;
}
public function getAffectedBlocks() : array{
if(($this->getDamage() & 0x08) === 0x08){
$down = $this->getSide(Vector3::SIDE_DOWN);
if($down->getId() === $this->getId()){
return [$this, $down];
}
}else{
$up = $this->getSide(Vector3::SIDE_UP);
if($up->getId() === $this->getId()){
return [$this, $up];
}
}
return parent::getAffectedBlocks();
}
}

View File

@ -19,24 +19,30 @@
*
*/
declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\item\Item;
use pocketmine\level\Level;
use pocketmine\item\ItemFactory;
use pocketmine\math\Vector3;
use pocketmine\Player;
use function mt_rand;
class DoublePlant extends Flowable{
public const BITFLAG_TOP = 0x08;
protected $id = self::DOUBLE_PLANT;
public function __construct($meta = 0){
public function __construct(int $meta = 0){
$this->meta = $meta;
}
public function canBeReplaced(){
return true;
public function canBeReplaced() : bool{
return $this->getVariant() === 2 or $this->getVariant() === 3; //grass or fern
}
public function getName(){
public function getName() : string{
static $names = [
0 => "Sunflower",
1 => "Lilac",
@ -45,26 +51,78 @@ class DoublePlant extends Flowable{
4 => "Rose Bush",
5 => "Peony"
];
return $names[$this->meta & 0x07];
return $names[$this->getVariant()] ?? "";
}
public function place(Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, Player $player = null) : bool{
$id = $blockReplace->getSide(Vector3::SIDE_DOWN)->getId();
if(($id === Block::GRASS or $id === Block::DIRT) and $blockReplace->getSide(Vector3::SIDE_UP)->canBeReplaced()){
$this->getLevel()->setBlock($blockReplace, $this, false, false);
$this->getLevel()->setBlock($blockReplace->getSide(Vector3::SIDE_UP), BlockFactory::get($this->id, $this->meta | self::BITFLAG_TOP), false, false);
public function onUpdate($type){
if($type === Level::BLOCK_UPDATE_NORMAL){
if($this->getSide(0)->isTransparent() === true){ //Replace with common break method
$this->getLevel()->setBlock($this, new Air(), true, true);
return Level::BLOCK_UPDATE_NORMAL;
}
return true;
}
return false;
}
public function getDrops(Item $item){
//TODO
/**
* Returns whether this double-plant has a corresponding other half.
* @return bool
*/
public function isValidHalfPlant() : bool{
if($this->meta & self::BITFLAG_TOP){
$other = $this->getSide(Vector3::SIDE_DOWN);
}else{
$other = $this->getSide(Vector3::SIDE_UP);
}
return (
$other->getId() === $this->getId() and
$other->getVariant() === $this->getVariant() and
($other->getDamage() & self::BITFLAG_TOP) !== ($this->getDamage() & self::BITFLAG_TOP)
);
}
public function onNearbyBlockChange() : void{
if(!$this->isValidHalfPlant() or (($this->meta & self::BITFLAG_TOP) === 0 and $this->getSide(Vector3::SIDE_DOWN)->isTransparent())){
$this->getLevel()->useBreakOn($this);
}
}
public function getVariantBitmask() : int{
return 0x07;
}
public function getToolType() : int{
return ($this->getVariant() === 2 or $this->getVariant() === 3) ? BlockToolType::TYPE_SHEARS : BlockToolType::TYPE_NONE;
}
public function getToolHarvestLevel() : int{
return ($this->getVariant() === 2 or $this->getVariant() === 3) ? 1 : 0; //only grass or fern require shears
}
public function getDrops(Item $item) : array{
if($this->meta & self::BITFLAG_TOP){
if($this->isCompatibleWithTool($item)){
return parent::getDrops($item);
}
if(mt_rand(0, 24) === 0){
return [
ItemFactory::get(Item::SEEDS)
];
}
}
return [];
}
}
public function getAffectedBlocks() : array{
if($this->isValidHalfPlant()){
return [$this, $this->getSide(($this->meta & self::BITFLAG_TOP) !== 0 ? Vector3::SIDE_DOWN : Vector3::SIDE_UP)];
}
return parent::getAffectedBlocks();
}
}

View File

@ -19,49 +19,36 @@
*
*/
declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\item\Item;
use pocketmine\item\Tool;
use pocketmine\item\ItemFactory;
class DoubleSlab extends Solid{
abstract class DoubleSlab extends Solid{
protected $id = self::DOUBLE_SLAB;
public function __construct($meta = 0){
public function __construct(int $meta = 0){
$this->meta = $meta;
}
public function getHardness(){
return 2;
abstract public function getSlabId() : int;
public function getName() : string{
return "Double " . BlockFactory::get($this->getSlabId(), $this->getVariant())->getName();
}
public function getToolType(){
return Tool::TYPE_PICKAXE;
}
public function getName(){
static $names = [
0 => "Stone",
1 => "Sandstone",
2 => "Wooden",
3 => "Cobblestone",
4 => "Brick",
5 => "Stone Brick",
6 => "Quartz",
7 => "Nether Brick",
public function getDropsForCompatibleTool(Item $item) : array{
return [
ItemFactory::get($this->getSlabId(), $this->getVariant(), 2)
];
return "Double " . $names[$this->meta & 0x07] . " Slab";
}
public function getDrops(Item $item){
if($item->isPickaxe() >= Tool::TIER_WOODEN){
return [
[Item::SLAB, $this->meta & 0x07, 2],
];
}else{
return [];
}
public function isAffectedBySilkTouch() : bool{
return false;
}
}
public function getPickedItem() : Item{
return ItemFactory::get($this->getSlabId(), $this->getVariant());
}
}

Some files were not shown because too many files have changed in this diff Show More