Compare commits

...

4250 Commits

Author SHA1 Message Date
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
84ec944b6b Use short class names for unhandled packet logging, added some documentation 2017-04-27 12:16:24 +01:00
6ef132e468 Updated PocketMine-Language submodule 2017-04-27 11:50:17 +01:00
dc71eb5246 Protocol updates for 1.1.0.9 2017-04-27 11:24:49 +01:00
2a59977440 Added various checks for region file validity (#393)
Check size, check header size, check location table offsets point to valid locations, check for shared offsets, prevent issues with corrupted or junk data
2017-04-27 09:14:02 +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
716efe2549 Fixed a stupid mistake in AddEntityPacket 2017-04-25 18:04:41 +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
5a9b5db103 Better cURL API, use async in timings (#834)
* Improved cURL functions
* Created BulkCurlTask
* Use asynchronous cURL posting in /timings paste

Closes #509
2017-04-25 11:52:18 +01:00
beed94dfb9 Update DevTools submodule 2017-04-25 11:41:55 +01:00
c6229b1e52 Merge network current changes - checkpointing
This is stable enough for everyone to be using it in production, and we're about 200 commits up from the previous tag. This branch contains hundreds of bug fixes, regardless of other changes which are not yet finished.
2017-04-25 11:00:51 +01:00
7a2ed232cc Merge branch 'api3/network' into api3/network-mcpe-1.1 2017-04-24 13:56:19 +01:00
d682fdfdf0 Food and exhaustion should not apply in creative, close #860 2017-04-24 13:31:05 +01:00
0e7f364a41 Fixed chunk object memory leak when chunks are changed, close #419
If a player quit the server in the 1-second between a chunk changing and a fresh chunk-order requesting a resend of that chunk, the player wouldn't know they were using that chunk and did not unregister themselves, causing the subject chunks to always remain loaded.
2017-04-24 11:55:33 +01:00
1be4bd67e4 Fixed assert failure when player join in un-generated areas of the world 2017-04-24 10:32:50 +01:00
559504225a Throw an exception before calling base entity constructor if skin is not set or invalid, close #835 (#855) 2017-04-24 09:50:55 +01:00
8ddf781a51 Oops, a typo 2017-04-22 20:24:24 +08:00
7cafaf2844 This line in README is a bit ambiguous
It sounded like "Poggit" was an adverbial clause to specify the name of "the old plugin repository".
2017-04-22 20:22:55 +08: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
6ece57e23e Merge changes from master 2017-04-21 22:48:18 +01:00
be631ad6f7 Fixed disconnects properly 2017-04-21 20:31:47 +01:00
2204942338 Fixed the half-done hunger implementation, fixed lots of bugs related to hunger
- Fixed starvation doesn't deal any damage at all (Human->getFood() returns a float, not an int, === 0 won't work so great)
- Added exhaustion for sprinting, walking, jumping and sprint-jumping as per MCPE (these use MCPE values, and yes MCPE does walking exhaustion!)
- Fixed attributes don't get reset after player death
- Added food and hunger regeneration in peaceful difficulty
- Added API methods Living->jump() (motion isn't updated yet, so this won't actually do much if plugins try to use it) and Living->getJumpVelocity()

TODO: implement exhaustion for swimming
2017-04-21 19:48:25 +01:00
00a226921c Fixed server crash when taking damage after being killed when having Health Boost effect 2017-04-21 18:52:04 +01:00
e7406ba096 Fixed squid health attribute errors 2017-04-21 14:42:19 +01:00
a356e36340 Autogenerated data for 1.0.7.0
Did they actually _change_ anything or just trying to keep it on par with the game version? >_<
2017-04-21 13:22:36 +01:00
547a09c8d4 Fix "Creating default object from empty value" (#858)
while setting lore to items.
2017-04-20 20:39:09 +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
de95046c11 Reduce header sizes on PR template
Stop getting in my face
2017-04-20 10:43:10 +01:00
9e2b26de23 Remove redundant null check in PluginCommand (#853) 2017-04-19 17:59:01 +01:00
b867cf4c91 Fix a potential newline issue in PULL_REQUEST_TEMPLATE.md 2017-04-19 11:50:49 +08:00
d3f4b185f3 Fixed typo in PULL_REQUEST_TEMPLATE.md 2017-04-19 11:49:46 +08:00
86de0bddd9 World should only be completely immutable if we're in spectator mode
Fixes being unable to break any blocks at all in adventure mode
2017-04-18 20:01:51 +01:00
207056fb9d Fixed adventure mode being useless 2017-04-18 19:51:42 +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
930945db18 Create PULL_REQUEST_TEMPLATE.md (#845)
Adapted from the PHP RFC template
2017-04-18 16:33:37 +01:00
b7b7a93e4e Merge branch 'api3/network' into api3/network-mcpe-1.1 2017-04-18 14:52:06 +01:00
d2efcee115 Fixed tiles and entities being closed when replacing chunks, should fix #490 2017-04-18 14:47:42 +01:00
eefa8abaf2 Throw exceptions if something attempts to add a closed Tile or Entity to a chunk 2017-04-18 14:45:33 +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
8a775e0c45 Fix PopSound giving failed click sound. (#829) 2017-04-15 10:02:00 +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
f2159c5948 Fixed unlit furnaces glowing in the dark, close #508
Whether Furnace extending BurningFurnace actually makes logical sense is a different question, but that cna be resolved any other time.
2017-04-14 15:30:37 +01:00
4ab8233fe0 Fixed shooting bow while sprinting, close #827 2017-04-14 15:27:32 +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
40775f5d86 Fixed issues with subtitles not working correctly, close #823 (#825) 2017-04-14 10:42:23 +01:00
319763dd93 Fix #823
Thanks to @SuperMaXAleX
2017-04-13 22:32:53 +03:00
a455e25665 Merge remote-tracking branch 'jacknoordhuis/patch-2' 2017-04-13 13:28:06 +00:00
1c7773c5f1 Visibility keyword before final or abstract keyword. (#814) 2017-04-13 20:58:53 +08:00
7c66af5994 "Fixed" resource packs
TODO: new fields
2017-04-12 11:54:47 +01:00
cb7264e0e5 Hexdump unhandled packets 2017-04-12 11:20:58 +01:00
f7e1939ae8 Changed some handling of unknown packet content 2017-04-12 11:16:50 +01:00
172d7339f9 Autogenerated data for 1.0.6.52 2017-04-12 11:11:37 +01:00
894beed59b Removed time stopping fields from SetTimePacket and fixed #526
TODO: rules
2017-04-11 20:13:37 +01:00
c01e0354bd Address #816
Removes redundant compression argument from NBT::readCompressed() and
NBT:: readNetworkCompressed()
2017-04-12 00:42:27 +10:00
e312c697fd Merge master into api3/network 2017-04-10 21:21:29 +01:00
80292c6c7a Actually use iusername instead of repeatedly lowercasing player names (#811)
#blameshoghi
2017-04-10 21:15:38 +01:00
dda47ee566 Fix typo in explosion (#700) 2017-04-10 09:17:34 +01:00
5863d001bd Merge pull request #524 from pmmp/issues/516
Allow custom JSON pretty print options
2017-04-09 16:15:35 +08:00
6b72bbc234 Allow custom JSON pretty print options
Resolves #516
Closes #517
2017-04-06 15:05:39 +08:00
1c2895eb12 Fixed absorption application logic, close #518 2017-04-05 21:16:40 +01:00
fd982afce6 Removed misleading outdated documentation (#519) 2017-04-05 20:31:56 +01:00
022f33b256 Fixed encoding of StartGamePacket, fixed world name not showing up in settings screen 2017-04-03 16:04:15 +01:00
f1510428d0 Fixed double gc_enable call (#492) 2017-04-03 09:40:48 +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
630f0fab7f Fixed block update recursion issues (#464)
* Schedule all neighbour block updates to execute at the end of the tick, fixed recursion crash, close #251

* doTickPending timings now include neighbour block update times, refactored some var names
2017-04-01 20:18:56 +01:00
202bac28fc Merge master into api3/network 2017-04-01 19:37:15 +01:00
874afc2fd2 fixed players need to move to pick up dropped items, close #498 2017-04-01 19:33:16 +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
f75cc93160 HOW did nobody notice this?! 2017-04-01 14:08:02 +01:00
b24d516eda Send TransferPacket with immediate priority, should fix #497 2017-04-01 10:40:05 +01:00
845b124f89 Stop autosaving players who haven't joined yet, close #494 2017-03-31 20:33:15 +01:00
16972bf9a5 Fix issues with writing negative numbers as non-zigzag varints, close #493 2017-03-31 18:59:40 +01:00
87a52a4f35 Fixed yet another crash when level-settings.always-tick-players is set to true 2017-03-31 16:09:40 +01:00
7f838a8c36 Fixed crashes due to adding players 'online' far too early, fixed some Player save logic 2017-03-31 13:45:28 +01:00
b5f473a3df Throw an exception when attempting to tick closed Levels 2017-03-31 13:14:05 +01:00
40a6f4dee9 Elevated level close check to exception level
As an assertion, this will crash on save if the level is already closed due to the provider being null.
2017-03-30 19:41:42 +01:00
69ac80518c some improvements to the horrendous mess that is the handling of joining and quitting, fixed some crashes, probably caused some other crashes
I can't fix this completely because it's just too much of a fucking mess. NEED to separate network stuff from Player.
2017-03-30 19:33:47 +01:00
45e5b6b04c Do not subscribe to broadcast permissions until the player spawns
This is unnecessary since the player won't see any messages sent before they spawn anyway. This was also causing an occasional client-sided crash due to TextPackets being sent to players at bad times during the login sequence.
2017-03-30 16:29:18 +01:00
cb059ea713 fix some PhpStorm inspections 2017-03-30 12:10:59 +01:00
afb2e0c51f fixed setting entity scale doesn't resize bounding box, close #484 2017-03-30 09:34:52 +01:00
cd477163cd New Timings v1 host is up 2017-03-30 09:15:01 +01:00
6b747f9272 Added basic API for working with titles 2017-03-29 20:02:16 +01:00
868602a559 Add __clone to CompoundTag and ListTag, fixed issues with items sharing the same NBT tag objects 2017-03-29 13:58:36 +01:00
bc1c75a15a Throw exceptions when failing to deserialize item NBT data, fixed weird crashes when an invalid NBT tag is set on an item 2017-03-29 13:39:43 +01:00
1c3d89cfef Fixed lighting issues with subchunks containing no blocks
A subchunk with no blocks is not necessarily empty.
2017-03-29 11:34:43 +01:00
c84ec90398 Set forceMovement to null when player is closed (#472)
Cater for the very very very slim chance that a player could quit while teleporting, be leaked and then have their level unloaded and leak their level.
2017-03-29 09:20:31 +01:00
3e76c3a6dd Added handling for tile picking, added API for setting item lore
worked almost out of the box (some W10 equipment bugs though)
2017-03-28 18:47:51 +01:00
52f2596dc5 Merge branch 'master' into api3/network 2017-03-28 12:27:40 +01:00
2079e2fd88 Fixed entity visibility Player object memory leak, close #416 2017-03-28 12:26:02 +01:00
217f66e180 Removed redundant method override leftover from 0.15 2017-03-28 12:25:54 +01:00
07f32765ba Merge branch 'api3/network_mcpe-1.0.5' into api3/network 2017-03-26 18:52:30 +01:00
788bd6fc20 Fixed resource packs/login sequence fail, added basic safety restrictions for packet sending before clients are logged in
close #452
2017-03-26 14:42:23 +01:00
01440fb659 Fixed players receiving double SetEntityMotionPackets for themselves 2017-03-26 13:40:39 +01:00
dda8c6cc8f Removed a condition that's been useless almost since the beginning of PocketMine
This condition has been useless since before NBT was introduced to PocketMine.
If there was a use for it, it should have been placed BEFORE anything attempted to read from the NBT.

However, Server now handles bad data automatically now, so Server->getOfflinePlayerData() will never _not_ return a CompoundTag. Hence I've added a CompoundTag type-hint.
2017-03-26 13:20:46 +01:00
1da870b298 Measure block break times in ticks instead of floating-point real-time 2017-03-26 10:36:19 +01:00
7a36d80384 Fixed broken block-break timer logic causing creative players to be unable to remove fire after breaking blocks
This also causes some annoying issues with instabreak (false positives). Shoghi dude, this did _not_ fix those issues, only hid them and replaced them with different ones.
2017-03-26 10:36:19 +01:00
bb79684480 Merge branch 'api3/network' into api3/network_mcpe-1.0.5 2017-03-25 21:31:48 +00:00
4245274aec Merge branch 'master' into api3/network 2017-03-25 21:26:46 +00:00
b9dfc7551a Added Permission to bypass spawn protection, close #440 (#451) 2017-03-25 20:34:42 +00:00
839a2ce07e Merge branch 'patch-4' of https://github.com/SOF3/PocketMine-MP-Original 2017-03-25 16:58:46 +00:00
34f833fa79 Do not save empty inventory slots 2017-03-25 12:02:09 +00:00
c9cf3d5aa4 Throw an exception when something attempts to serialize Server (#459) 2017-03-25 10:33:05 +00:00
5332887a0a Fixed command name case sensitivity issue noted in #462 2017-03-25 10:26:06 +00:00
5926bab323 Block light bug fixes (#454)
* Fixed an age-old light calculation bug causing solid blocks to filter their own light, fixed #375, probably fixed #288
Light spread reduction should be done based on the _target's_ light filter level, not the source.

* Revert "Fix Glowing Obsidian lighting"
This hack is no longer necessary.
This reverts commit 35c33ba980.

* Fixed wrong light levels for torch and redstone torch

* Take adjacent light levels and opacity changes into account, block light will now spread when an obstruction is removed, close #455

* Added timings for Level->setBlock() and lighting updates
2017-03-24 17:56:26 +00:00
0750b3ab59 Added pocketmine.yml option to disable the title ticker (#447)
This gets really spammy on some consoles when you stick it in the background, but I don't want to lose colour for the sake of that.
2017-03-24 16:03:10 +00:00
96801be3d3 Fixed #453 multiple refs to the same cached NBT object tree 2017-03-23 11:40:49 +00:00
2fb92c1c62 Fixed wrong constant value for EntityEventPacket::RESPAWN 2017-03-22 16:10:42 +00:00
c040579e09 Fixed a mistake in spaced command handling
Nothing drastic, just a self-defeating line of code.
2017-03-21 15:11:48 +00:00
9a35b4fbc8 Removed redundant TODO comment 2017-03-21 14:03:53 +00:00
940b20c191 Implemented Absorption effect
This is a little buggy due to a client-sided bug. https://bugs.mojang.com/browse/MCPE-20520
TODO: add attribute save/restore
2017-03-21 13:23:57 +00:00
c21768df26 Updated Effect constants, removed incorrect/misleading SWIFTNESS constant
So what? I'd rather crash plugins than have them suddenly behave strangely because SWIFTNESS is now an alias for SPEED instead of HASTE.
2017-03-21 11:49:18 +00:00
2d927db264 Implemented Instant Health and Instant Damage effects 2017-03-21 11:38:08 +00:00
a5a51fb9c5 Merge branch 'master' into api3/network_mcpe-1.0.5 2017-03-21 10:47:41 +00:00
47f7af6739 Fixed usage reporting cannot be disabled 2017-03-20 21:26:20 +00:00
b7a3230f73 Fixed botched effect override condition for equivalent amplifiers 2017-03-20 18:56:54 +00:00
6a03f8d434 Fixed server creating resource packs directory inside itself when running from a phar
Once again, epic facepalm @dktapps
2017-03-20 13:28:45 +00:00
06f2a9c674 Fix client-side death bug (#438) 2017-03-20 12:21:58 +00:00
0e64d4bbc2 Given Player->iusername a use, added Player->getLowerCaseName()
Micro optimizations by not repeatedly lowercasing names when searching
2017-03-20 12:21:02 +00:00
284c18d401 Added debug for mismatched item equipment
tool damage packets sent in the wrong order?
This could be bad for performance since the entire inventory is resent every time this issue crops up.
2017-03-20 10:58:43 +00:00
6ba4a8fe5c Moved batch packet handling into BatchPacket->handle(), fixed data packet receive timings to include MCPE packet decode time 2017-03-20 10:26:53 +00:00
4638ccbb68 Remove this workaround (client bug fixed in 1.0.5 beta) 2017-03-19 21:58:12 +00:00
36cda5de61 Merge branch 'api3/network' into api3/network_mcpe-1.0.5 2017-03-19 21:54:14 +00:00
9c350dbe47 Fixed DataPacketReceiveEvent, fixed packet receive timings, gave Player->handleDataPacket() a new use 2017-03-19 21:50:09 +00:00
2673e4de7f More anti-leak measures for double chest inventory issues 2017-03-19 11:25:56 +00:00
be449b6106 Removed useless condition from RemoveBlockPacket handler 2017-03-19 10:32:54 +00:00
4c61ad9f2d Stop skipping stack frames (#425) 2017-03-19 10:24:33 +00:00
66fbfdd47b Fixed hunger not saving, resolves 1 of #435 (#439) 2017-03-18 21:58:02 +00:00
8a28021b44 Use hash_file instead of OpenSSL for resource pack hashing
Epic facepalm. I totally forgot this function existed. >_<
2017-03-18 21:47:04 +00:00
ab1150382a Merge branch 'api3/network' into api3/network_mcpe-1.0.5 2017-03-18 16:30:06 +00:00
8114ceaf68 Merge branch 'master' into api3/network 2017-03-18 16:29:38 +00:00
0d37d0d896 Added some documentation to resource packs namespace 2017-03-18 16:07:03 +00:00
cc0b4d888e Use a resource for reading resource packs from disk 2017-03-18 15:49:48 +00:00
116cba9fae Added expected and actual result questions to issue template 2017-03-18 15:32:58 +00:00
51a20470f6 Switch back to the old chunk-packet method since MoveEntityPacket and SetEntityMotionPacket no longer have lists 2017-03-18 15:03:41 +00:00
6e1abe7b15 Fixed some formatting issues in FlowerPot 2017-03-18 14:24:23 +00:00
cbb003bf29 Guard against leaked closed tiles leaking chunks and NBT trees
Once again, this does not fix the actual issue, only reduces the impact of it.
2017-03-18 11:50:05 +00:00
fa5e66478c Auto update checks are now asynchronous, improves startup time (#433) 2017-03-17 14:43:12 +00:00
bcbb5de5bb Added reference parameters for errors for Utils::getURL() and Utils::postURL(), close #332 (#357) 2017-03-16 19:15:31 +00:00
548df21645 Small docs fix (#432) 2017-03-16 18:19:30 +00:00
b7b73aab23 Fixed username regex failing, close #427 2017-03-15 19:22:43 +00:00
a8650a241c Removed @deprecated warning from PlayerInventory->setHotbarSlotIndex()
Core uses it, it's just that plugins shouldn't.
2017-03-14 17:37:29 +00:00
d26713ab59 Use assoc instead of object for command data, fix data modifications affecting all commands
how did I do manage to do somthing this stupid -_- smh what an idiot
Lucky permission is a root node, or the whole commands system would've been compromised. Epic fail.
2017-03-14 11:39:59 +00:00
3138e02acb Added support for commands with spaces in their names (#422) 2017-03-13 20:55:06 +00:00
d264a04db4 Added detection for recursive server aliases (#424)
* Added detection for recursive server aliases, close #423

* Oops
2017-03-13 20:43:34 +00:00
3c709b1d3e Return false on unhandled/unknown resource pack client response status 2017-03-13 15:52:00 +00:00
c344caaf78 Refactor InventoryNetworkIds as WindowTypes 2017-03-13 11:39:54 +00:00
9e341f74d8 Added new window types and found some UpdateTradePacket fields 2017-03-13 11:27:44 +00:00
e7dbda922a Rename some CommandBlockUpdatePacket fields 2017-03-13 10:44:40 +00:00
92193fd27b Use entity IDs in EntityDamageBy*EntityEvents, fixed memory leaks related to PvP/PvE/PvM (#418) 2017-03-13 10:30:31 +00:00
bb85308b01 Fix undefined variable 2017-03-13 09:46:39 +00:00
565335f29e Revert "TODO: REVERT - Added a workaround for client text duplication"
This reverts commit 52748fcf64.
2017-03-12 16:18:30 -04:00
78278a0b93 Fixed a mistake in old effect handling 2017-03-12 20:15:21 +00:00
955dc38be4 Fixed botch-job implementation of Health Boost, will now actually work and not crash the server 2017-03-12 20:06:39 +00:00
f58ee2028e Moved effects stuff to json 2017-03-12 19:52:57 +00:00
083d1e9ef8 Deprecated Item->deepEquals(), added automatic deep checking in equals(), added some documentation for Item API methods 2017-03-12 14:46:34 +00:00
90abc28c29 Merge branch 'api3/network' into api3/network_mcpe-1.0.5 2017-03-12 12:30:56 +00:00
6c5dbd7359 Merge branch 'master' into api3/network 2017-03-12 12:22:11 +00:00
4f27bce5b3 Destroy NBT references when closing entities, alleviates memory issues on leaked Player objects
This does NOT FIX THE ACTUAL ISSUES, only eliminates some of the symptoms.
2017-03-12 10:53:27 +00:00
6f1b12b021 Added new 1.0.5 packets 2017-03-11 19:58:32 +00:00
a71747347f Updated Doxygen documentation link 2017-03-11 16:51:20 +00:00
004880548c Autogenerated data for 1.0.5.0 2017-03-11 12:13:55 +00:00
91a92b4e57 Use a pre-created resource packs config with comments to explain how to use it 2017-03-11 11:40:58 +00:00
ed765a2c9b Added debug messages for resource requests with invalid pack IDs 2017-03-11 11:19:14 +00:00
e1fb4a44e9 Updated PocketMine-Language submodule 2017-03-11 11:03:14 +00:00
2cb98c48c2 Improved dependency checking 2017-03-10 21:51:05 +00:00
d41bdfc31c Added resource packs support 2017-03-10 21:10:46 +00:00
c925845173 Added forceSend for attribute value setting, fixed slowness >= 7 removed client-side when sprinting 2017-03-09 21:33:55 +00:00
7fb3c7343f Fit attribute value to range when applying slowness, close #410
According to http://minecraft.gamepedia.com/Status_effect#Slowness, anything higher than slowness 7 will cause the player to be unable to move. Therefore this value should be clamped to a minimum of 0, not crash.
2017-03-09 21:01:10 +00:00
132e04fdbb Hotbar/inventory bugfixes (#399)
- Fixed most issues with item equipment in creative
- Added save and restore of currently-held item
- Reset hotbar on death, added API method PlayerInventory->resetHotbar()
- Creative players now have more leeway to get items, alleviates issues with item equipment in desktop GUI
- Fixed creative players wearing armour
- Found unknown field in ContainerSetSlotPacket
- Removed outdated/redundant constants
- Use a case statement in ContainerSetSlotPacket handler, added handling for 0x7a hotbar slot link update
2017-03-09 20:31:55 +00:00
1f2b584400 Merge branch 'master' into api3/network 2017-03-09 18:31:10 +00:00
d31e92bbe7 Remove beta tag, bump client version to 1.0.4.11 2017-03-09 18:30:51 +00:00
08cd944e5d Merge branch 'master' into api3/network 2017-03-09 18:12:37 +00:00
dbb579aa73 Updated LevelSoundEvent constants 2017-03-09 17:55:26 +00:00
bc0598c0f1 Autogenerated data for 1.0.4.1 2017-03-09 17:55:26 +00:00
f87b745771 New entity metadata and found some UpdateTradePacket fields 2017-03-09 17:55:26 +00:00
8d43faf16e Added Inventory network IDs interface 2017-03-09 17:55:26 +00:00
f00e7ccb54 Forgot preprocessor header include 2017-03-09 17:55:26 +00:00
7b5e5832cb Added UpdateTradePacket 2017-03-09 17:55:25 +00:00
dd6abff712 Autogenerated data for 1.0.4.0 2017-03-09 17:55:25 +00:00
7e1bdd474a Revert multi-world hack (client issue fixed in 1.0.4.0), close #260
This reverts commit 162b993e65.
2017-03-09 17:55:25 +00:00
e31333edd4 Update ISSUE_TEMPLATE.md 2017-03-09 16:35:12 +00:00
c052ee5847 Set alpha value to 0xff, fixed potion bubbles, close #407
TODO: implement transparency
2017-03-09 12:26:24 +00:00
f8c2eb8c3a Fixed signed VarInt encoding on 64-bit systems
Numbers represented as hex or binary with the 32nd bit set, for example 0xffffffff, were not considered as signed on 64-bit.
2017-03-09 12:23:24 +00:00
94d78ca554 Added missing returns 2017-03-08 20:38:11 +00:00
c7fdbea0f0 Merge branch 'master' into api3/network 2017-03-08 20:35:41 +00:00
a19996a7cf Added deprecation warning for 32-bit 2017-03-08 20:29:25 +00:00
9311b4f248 Remove unneeded comments 2017-03-08 20:29:24 +00:00
295d9bc80b Cleaned up muddled varint/varlong mess, added separate methods for entity unique and runtime ids, moved some MCPE-protocol-specific methods out of BinaryStream 2017-03-08 20:29:24 +00:00
3a044f0154 Added methods for VarLong, limited Binary::readVarInt() to 5-byte numbers 2017-03-08 20:29:23 +00:00
adb7df212c Let the parent caller catch this so we get encapsulated packet hexdumps 2017-03-08 20:29:22 +00:00
9e92a350e3 ClientboundMapItemDataPacket 2017-03-08 20:29:15 +00:00
005c2419e9 Fixed batched packets being encoded twice 2017-03-08 20:29:14 +00:00
d823ff18d8 Bump API version to 3.0.0-ALPHA5 (not finalized) 2017-03-08 20:29:14 +00:00
9b47aed0ab Added MapInfoRequestPacket 2017-03-08 20:29:13 +00:00
55598ba703 Moaaaar resource packets 2017-03-08 20:29:13 +00:00
425686755b Added basic resource-pack response handling, fixed sounds, broadcast sounds received from client
There are still a lot of sounds which do not work, these are supposed to be sent by the server and will be fixed at a later date.
2017-03-08 20:29:04 +00:00
6676029319 Improved some handlers, added detection for no-clip 2017-03-08 20:29:03 +00:00
e008a3cd5e Added handling for unknown packets 2017-03-08 20:29:03 +00:00
5aed0fb0d5 Remove redundant TODO comment 2017-03-08 20:29:02 +00:00
d0faf3df91 Added S2C and C2S handshake packet classes and stub handlers
TODO: implement encryption

Add boilerplate reset() for C2S packet encode

This crap really needs fixing
2017-03-08 20:28:52 +00:00
564b50ea33 Added API methods for validating usernames and skins 2017-03-08 20:28:41 +00:00
ea0f291cb5 Added class method DataPacket->canBeBatched() 2017-03-08 20:28:40 +00:00
56990eb28b MCPE protocol gets its own namespace 2017-03-08 20:28:39 +00:00
477cb77002 Exploded Player->handleDataPacket() into 70+ methods 2017-03-08 20:28:20 +00:00
93896977d0 Add default 2017-03-07 10:18:58 +00:00
554816b8b6 Added configuration option to pocketmine.yml to allow changing timings host, added new host mcpetimings.com 2017-03-07 09:24:32 +00:00
fc5fa01442 Removed type-hint silently breaking use of CompoundTags in Item::get() 2017-03-06 19:45:49 +00:00
f204422432 Fixed precedence issue 2017-03-06 11:40:28 +00:00
d6d3184e37 Fixed players can't join if spawn-radius is higher than the player's view distance
TODO: use this properly instead of calculating a count
2017-03-06 11:37:39 +00:00
c569fd86b1 Simplified Vector3::getOppositeSide() (#377)
* Simplified Vector3::getOppositeSide()

* Throw exception on bad input values

* @throws doc
2017-03-05 19:30:12 +08:00
e33eb0ddb6 Fixed missing permission registration in in #355 (#396) 2017-03-05 10:03:59 +00:00
0a8bd72e11 New Jenkins server is up
This reverts commit 68998bac48.
2017-03-04 22:35:38 +00:00
4ee8d14584 Added API for transferring players to other servers (#355)
* Added API method `Player->transfer()` and PlayerTransferEvent
2017-03-04 18:22:31 +00:00
663cb514e2 Fixed missing Cake recipe
TODO: add support for multiple crafting recipe result items
2017-03-04 15:03:53 +00:00
15f098074a Fixed batched packets being encoded twice 2017-03-03 17:33:30 +00:00
8bf3b6bbea Added ShowCreditsPacket 2017-03-02 11:04:51 +00:00
eb13cec5d0 Added new packets 2017-03-02 11:04:51 +00:00
0cd1e82c52 Fixed encode/decode of ResourcePacksInfoPacket and ResourcePackClientResponsePacket 2017-03-02 11:04:50 +00:00
1ee689e759 Fixed mess of entity ID 0 for players, fixed emeralds 2017-03-02 11:04:00 +00:00
d25c8d93ca Revert "Better time ticking and sync (#2)"
didn't consider modded clients, how naive 🤦

This reverts commit e9f2bf0085.
2017-03-02 10:53:40 +00:00
4fbc5738e3 Re-implemented chunk sending (#304)
Re-implement chunk sending, send chunks inside a radius instead of below a count

This sends chunks in concentric squares around players. When the radius is hit, it will pad out the radius until a full circle of chunks is loaded around the player.
TODO: implement radius-per-tick, send chunks in concentric circles, use radius for player spawning.

To set your server chunk radius, change `view-distance` in server.properties. Values are intended to be the same as MCPE render distance values. With matching client and server render distances the chunks should reach the horizon.

NOTE: You may notice significantly increased memory usage per player when increasing these values to something respectable. This is normal and expected.
A player with render distance 14 for example will cause loading of 600+ chunks. A player cannot however exceed the render distance limit set in server.properties - the server will simply not send any more chunks.

Render distance of 8 chunks is approximately 200 chunks. This is roughly equivalent to the original default max-chunks of 192 in pocketmine.yml, but sent in a circle instead of a square.

Wait for client to request a chunk radius before ordering chunks

Use 8 for default maximum radius (roughly matches old setting of 192)

Calculate spawn chunk count from chunk-sending.spawn-radius
2017-03-02 10:30:30 +00:00
d588222e84 Added an exception throw for accessing permissions of closed players 2017-02-28 10:49:09 +00:00
c3fb2e9f23 Fixed broadcasting quit messages to quitting player, fixed accessing permission of closed players on quit 2017-02-28 10:43:11 +00:00
cfb6856634 Fixed Player object memory leak when players with admin channel permissions are closed 2017-02-25 15:39:36 +00:00
11e0387e19 Show an error if no language files found during setup, mitigates #380 2017-02-25 11:21:32 +00:00
dc7b5b14d5 Fixed wrong encoding of ResourcePacksInfoPacket 2017-02-24 12:38:02 +00:00
5eab956da6 Add block-break check for spectator mode, fixes players in spectator able to break blocks when adventure settings are not set correctly 2017-02-23 19:39:08 +00:00
ad88ca09bd Fixed cannot remove block metadata 2017-02-23 15:18:42 +00:00
f98a964cdc Fixed and silenced some inspections 2017-02-23 15:17:28 +00:00
99995579d7 Added WorldBuilder flag to AdventureSettingsPacket 2017-02-23 12:20:36 +00:00
4ae18526d1 Fix fence gates opening in opposite direction to expected
This still occasionally occurs due to a bug that seems to exist with
entity rotation calculations. May happen at 45° 135° 225° and 315°
2017-02-22 09:46:54 +00:00
282095513a Throw exception when attempting to save a non-generated chunk (#367) 2017-02-21 19:24:16 +00:00
c21197ef17 Removed entanglement between chunks and providers. WARNING: BREAKING API CHANGES.
- All entity and tile constructors now require a \pocketmine\level\Level instead of a \pocketmine\level\format\Chunk.
- Chunk->getProvider() and Chunk->setProvider() have been removed.
- Chunk::__construct() has had the $provider parameter removed.
- Chunk->unload() has had the unused $save parameter removed.
- ChunkEvents now take a Level parameter instead of going through the Chunk

API bump to 3.0.0-ALPHA4
2017-02-21 17:08:45 +00:00
0a8826b21f Fixed anti-fly triggered when walking on unknown blocks 2017-02-21 13:43:00 +00:00
dac6c49bce More php7 mess (EndTag Stone, EndTag Portal Frame) 2017-02-21 12:32:50 +00:00
9f7dc32650 Fix some php7 update DoubleTag leftovers 2017-02-21 12:27:27 +00:00
9195375af4 Don't allow these blocks to be washed out, we're only inheriting properties 2017-02-21 11:51:36 +00:00
c6cf3458de Added UnknownBlock class, fixed not-yet-added blocks in imported worlds killing people, close #181 2017-02-21 11:46:44 +00:00
e2cdd9eddc Fixed missing hardness on unimplemented blocks causing gameplay issues 2017-02-21 11:33:06 +00:00
f933107af0 Fix some non-properly-implemented blocks killing people and bad inheritances 2017-02-21 11:17:33 +00:00
408f63f8fa Accuracy again -_- 2017-02-20 19:46:10 +00:00
68998bac48 Update README.md 2017-02-20 16:21:29 +00:00
2ff565afe5 Fix heightmap crashes at the corner of chunks
Stupid unpack() return array indices start at 1, not 0 >_<
2017-02-20 10:28:50 +00:00
20c7e51077 Allow 0.01 of a block diff
Fixes loss of precision when handling player movements causing some position issues.
2017-02-19 17:35:23 +00:00
89216c3bd4 Use parse_ini_file instead of home-grown solution (#366)
* Use parse_ini_file instead of home-grown solution

* Updated PocketMine-Language submodule
2017-02-19 15:53:22 +00:00
834dc343b0 Updated ItemFrameDropItemPacket for >=1.0.3, fix decode errors
Sorry, this DOES NOT FIX creative, blame Mojang. https://bugs.mojang.com/browse/MCPE-20070
2017-02-18 15:09:44 +00:00
91907485b4 Fixed prismarine bad meta crashes 2017-02-18 10:42:25 +00:00
ee523eb5cc Reverted botched fix for #284, close #362
Revert "fixed player data not saving"

This reverts commit b3beb9f71d.

Revert "Call PlayerQuitEvent after unloading chunks, removed some weird code, fixed crash when unloading player level on quit, close #284"

This reverts commit 14a0ff5caa.
2017-02-16 21:04:39 +00:00
f2f51a88e5 Updated PocketMine-Language submodule (again) 2017-02-15 17:55:55 +00:00
abffe1297d Fixed crashes closing entities with unloaded levels 2017-02-15 17:51:41 +00:00
f8b9a13440 Updated PocketMine-Language submodule 2017-02-15 16:06:02 +00:00
5c281c6435 Merged #103 2017-02-15 14:58:41 +00:00
1908ed5812 Fix for incorrect gamemode messages, close #83 (#86)
Shows the correct message ingame but not in the console.
PocketMine doesn't handle the translation for gamemode changes, MCPE
does. No idea why but it requires the second and third parameter....

commands.gamemode.success.other=Set %2$s's game mode to %3$s
commands.gamemode.success.self=Set own game mode to %3$s

To solve the problem we have to change the language files and let
PocketMine-MP translate it.
2017-02-15 14:48:11 +00:00
2d5567d9dd Removed InstallerLang mess, language improvements, updated PocketMine-Language submodule 2017-02-15 14:44:12 +00:00
b3beb9f71d fixed player data not saving 2017-02-14 13:40:58 +00:00
14a0ff5caa Call PlayerQuitEvent after unloading chunks, removed some weird code, fixed crash when unloading player level on quit, close #284 2017-02-14 12:44:31 +00:00
119e458ac8 Removed SQLite3 dependency (no longer used by PocketMine-MP core)
BEFORE anyone yells at me about plugins, having the core demand every extension that a plugin could possibly need is very much sub-optimal. An API for plugin-required extensions will be added in the future.
2017-02-14 11:04:20 +00:00
01a07a0b09 Removed years-old leftovers from old PocketMine 2017-02-13 14:41:30 +00:00
903534572d Shut some inspections up 2017-02-13 14:27:17 +00:00
8a3c30ee7e Moved entity metadata methods out of Binary 2017-02-13 14:05:16 +00:00
91fd99d76a Fixed DestroyBlockParticle 2017-02-12 16:01:23 +00:00
27f2aec160 Fixed wrong docs for Plugin->getPluginFilters() 2017-02-12 12:52:02 +00:00
8f9c52507a Some PhpStorm cleanup 2017-02-12 12:36:02 +00:00
5a12f40074 Only Region file formats are allowed as parameters for RegionLoaders 2017-02-12 12:18:25 +00:00
b89a17ffe2 Added missing attributes encoding to AddEntityPacket 2017-02-12 10:35:35 +00:00
6dc6e32656 Added some very useless functions for easier size changing of entities. (#348) 2017-02-11 21:24:38 +00:00
d430ad50be Fixed wrong temperature and temperature -> rainfall (#347) 2017-02-11 20:15:22 +00:00
06de85fd33 Revert "Fix entities missing in imported leveldb worlds", fixed entities missing after restart in anything OTHER than LevelDB
🤦 I should test this stuff more

This reverts commit ffadc34691.
2017-02-11 19:22:59 +00:00
ffadc34691 Fix entities missing in imported leveldb worlds 2017-02-11 11:15:15 +00:00
f5e39ea9ad Merge branch 'mcpe-1.0.3.0' 2017-02-09 16:36:47 +00:00
595fffc432 Fix chunks not being updated client-side when Level->setChunk() is called (#328)
Fixes half-trees, probably fixes #265
2017-02-09 11:10:25 +00:00
c4d0fdb436 Added clientData field so plugins can access extra data 2017-02-08 21:25:02 +00:00
2a4fb93a92 Updated RakLib, use reliability constants instead of literal values 2017-02-07 11:34:25 +00:00
50bf671c28 Update .travis.yml 2017-02-06 19:32:34 +00:00
4a2b83ab47 Use xargs multi-process to improve lint scanning speed in tests 2017-02-06 18:57:21 +00:00
f332d3647c Fixed lint scan scanning some files twice 2017-02-06 17:21:18 +00:00
0c35c16727 Fix some doc comments 2017-02-06 14:50:05 +00:00
7c8586684e Fixed resource not closed after memory dump (#324) 2017-02-04 18:31:00 +00:00
6999388dd1 Updated DevTools submodule 2017-02-04 13:53:56 +00:00
662652f745 Update SPL submodule 2017-02-03 15:58:35 +00:00
987d492c1c Removed CompatibleClassLoader (not needed anymore) 2017-02-03 12:14:18 +00:00
80920a1673 Remove shutdown after memory dump. (#310) 2017-02-03 10:42:42 +00:00
613226c661 Fix sea lantern lighting doesn't save (#316) 2017-02-02 09:09:54 +00:00
06dd410340 Merge branch 'master' into mcpe-1.0.3.0 2017-02-01 18:15:08 +00:00
cf83143bbd Silence unread buffer assertion on incompatible protocol 2017-02-01 18:13:50 +00:00
28baae8154 Fix RakLib crashing without logging any useful crash information 2017-02-01 17:59:13 +00:00
7701555005 added default port 19132 2017-02-01 15:23:16 +00:00
38937fc4cc Added TransferPacket
TYSM MOJANG
2017-02-01 12:59:01 +00:00
bf6e8db941 Autogenerated data for 1.0.3.0 2017-02-01 10:11:55 +00:00
06c399fa05 Get MainLogger directly, in case translations are needed without a running server 2017-01-31 17:21:21 +00:00
82cf38d46c Installer: No need for force-kills 2017-01-31 12:05:56 +00:00
eb1ec2df05 Removed deprecated network constants 2017-01-31 11:49:55 +00:00
17102058ca Unknown in PlayerFallPacket is fallDistance 2017-01-28 22:03:28 +00:00
f881cea8e0 Remove some unused properties from Player 2017-01-28 17:53:52 +00:00
8beefabbbc Remove useless unset() from 2014 2017-01-28 16:14:37 +00:00
4cca3b866a Enchanted Golden Apples give the eater Absorption 4 (#305) 2017-01-28 12:49:04 +00:00
0535acf211 Update some LevelEvents 2017-01-27 18:21:11 +00:00
478a62e17b Merge branch 'master' into mcpe-1.0 2017-01-27 16:58:53 +00:00
9661d845bb Fix some command stupidity
This is why NOT to write code at 11PM when one is shattered.
2017-01-27 16:57:07 +00:00
69d6d24a38 Removed use of stfu operator 2017-01-27 10:53:49 +00:00
713ee753e4 Fixed wrong git commit hash parsing, fixes #295, closes #297 (#299) 2017-01-27 10:49:54 +00:00
740a8ad436 Lock player position for delayed teleport, and add related assertions 2017-01-26 11:13:35 +00:00
ccef0455ab Fixed CPU/mem leak when teleporting with movement checks disabled, close #231 2017-01-25 19:45:47 +00:00
755f4d232f Merge branch 'master' into mcpe-1.0 2017-01-25 17:37:54 +00:00
09a6776674 Fixed a bug in CrashDump
@xxFlare really?
2017-01-25 17:36:40 +00:00
661f17b6e0 Anti-cheat fixes, settings and API (#287)
* Added options to disable movement checks and anti-instabreak and API methods to control this
* Fixed anti-flight false positives
* Fix flight toggle kick cannot be disabled
* Added PlayerIllegalMoveEvent
2017-01-25 09:40:48 +00:00
77456702e9 Remove some old protocol leftovers 2017-01-24 12:08:25 +00:00
75a38699e2 Fix metadata block coords (signed Y coordinate), close #286 2017-01-23 13:13:29 +00:00
9c36e0cd1c Added crafting data packet cache, reduces on-join lag spikes, close #248 (#269) 2017-01-23 11:03:46 +00:00
21f5be27b6 Added options and API to enable/disable random ticking for specific block IDs 2017-01-23 10:59:27 +00:00
4dd0a13511 Updated DevTools submodule 2017-01-22 16:09:20 +00:00
904c52bb0f Merge branch 'master' into mcpe-1.0 2017-01-22 16:08:34 +00:00
3ab9722a9f Add DevTools as submodule, build DevTools for Travis Test 2017-01-22 16:02:22 +00:00
08ed2cd353 Merge branch 'master' into mcpe-1.0 2017-01-22 11:36:22 +00:00
06f0534d65 Fixed wrong encoding of NBT strings, fixed invisible signs issues 2017-01-22 11:24:55 +00:00
b22232730e Fixed eating golden apple with full hunger, fixed wrong implementation of enchanted golden apple, close #276 2017-01-21 18:25:32 +00:00
50b9034e16 Merge master into mcpe-1.0 2017-01-21 13:43:41 +00:00
8bf8e2e22f Moved crashdumps to their own folder (#275) 2017-01-20 10:52:35 +00:00
52748fcf64 TODO: REVERT - Added a workaround for client text duplication 2017-01-20 10:24:52 +00:00
19572b8c51 Remove multiline separation (unnecessary) 2017-01-20 10:24:52 +00:00
496061ba54 Travis: Build DevTools on the spot 2017-01-20 10:12:16 +00:00
2488d6e957 Updated preprocessor submodule 2017-01-20 10:00:20 +00:00
8ea03524ff Fixed most movement-check false-positives (finally!)
Removed ySize hack, fixes ladders, fixed original autojump and dropdown issues. These were due to a tiny, tiny tiny margin for error when decoding network floats (usually less than 0.000001, but enough to cause issues. Added Binary floating-point decode accuracy option to combat this. Network Vector3s are now rounded to 4 decimal places.
2017-01-20 10:00:20 +00:00
e4aa3d72fe Check for unloaded chunks, fix triple chest bug, fix Chest object leak, close #256
Revert "Fixed double chest tile memory leak on shutdown, close #256 (#261)"

This reverts commit 9869aaa46a.
2017-01-19 15:34:51 +00:00
26fc21d56c API version suffix is now non case sensitive 2017-01-19 10:57:32 +00:00
e4c889ae16 Check if the array contents are already the same, massive performance improvement for Anvil in a lot of cases 2017-01-18 20:04:19 +00:00
7de7593b89 Improved nibble array re-ordering in most cases by checking for common values 2017-01-18 19:51:43 +00:00
162b993e65 Added a hack for multiworld. This is not always reliable! (#263) 2017-01-17 10:28:48 +00:00
cb187be1a1 Remove derp comment 2017-01-16 16:30:52 +00:00
ab943a0462 Fix crashes 2017-01-16 14:50:32 +00:00
2290c33143 Add type-hints to Item::get() (these parameters cannot be null anymore) 2017-01-16 14:08:43 +00:00
9869aaa46a Fixed double chest tile memory leak on shutdown, close #256 (#261) 2017-01-15 19:41:15 +00:00
bcf049a660 Remove obsolete methods from Chunk 2017-01-15 18:03:40 +00:00
0114cb8399 Better vanilla layers support (no meta, MCPE doesn't support it) 2017-01-15 17:26:21 +00:00
b72218ac5b Fixed flat world terrain generation by MCPE 2017-01-15 17:26:21 +00:00
6b9c2b961b Fix invalid timestamp causing W10 Edition to crash, fixes one bug in #254 2017-01-15 17:26:20 +00:00
8ba0b49022 Initial working R/W of 0.16 + 1.0 worlds, highly unstable 2017-01-15 17:26:20 +00:00
74c9ed04a0 LevelDB is loaded? Tell me about it 2017-01-15 17:17:57 +00:00
b28e38ab26 Move some exceptions out of utils into their relevant namespaces, move some Chunk methods to ChunkUtils for I/O, refactor "colour" -> "color" 2017-01-15 11:31:12 +00:00
4577f3ee22 Added config to warn if assertions are enabled and to disable exception throws 2017-01-15 00:38:30 +00:00
3b82a5fddf Fix loop counter and add delay between restarts 2017-01-14 15:28:40 +00:00
2d3b8845fd Add a message for movement reverting 2017-01-14 10:19:53 +00:00
9004417456 Fixed file headers (#255) 2017-01-13 16:57:05 +00:00
946d301bc7 Fix lighting population, fix lighting issues when read by vanilla Minecraft 2017-01-13 11:33:55 +00:00
39c3b16e49 Micro optimization (#252) 2017-01-12 15:38:30 +00:00
3daa2723bf Bump to 7 entries per page (matches MCPE) 2017-01-12 09:42:07 +00:00
085d1a1359 Remove deprecated Utils::getRandomBytes() 2017-01-11 11:53:54 +00:00
3bbf2c245a Shut PhpStorm up 2017-01-11 10:11:13 +00:00
8f797442b3 Merge branch 'master' into mcpe-1.0 2017-01-10 10:55:05 +00:00
57f3f9b4ed Fix setting custom name erases CompoundTag, fixes #244 ...
... even though this bug was introduced AFTER said issue was reported.
Nice work @Muqsit
2017-01-10 08:58:31 +00:00
058468104a Fix setting item custom name does not update inventory
If a NamedTag was already present, it was modifying the object directly
WITHOUT serializing the tag back to raw NBT for sending. This commit
fixes that by always serializing the tag on change.
2017-01-10 00:38:23 +00:00
b566c4e609 Fix Normal generator logic fail 2017-01-09 22:27:35 +00:00
0428894cc6 Merge branch 'master' into mcpe-1.0 2017-01-09 16:04:11 +00:00
41d36e4e7a Fix .gitignore
Ignore the whole folder, stop deleting my damn PhpStorm files
2017-01-09 15:57:38 +00:00
4bf8f00b0f Use MODE_RESET for forceMovement, fixes most teleportation issues 2017-01-09 15:41:05 +00:00
6e87a48100 Revert "Fix a really annoying movement bug on player join", close #231
This reverts commit b16f7e4dd5.
2017-01-09 15:32:10 +00:00
441961b199 Fix players regenerating health from food while dead, fixes issue 2 in #23 2017-01-09 14:10:34 +00:00
92b85e0f15 Fix players regenerating health from food while dead, fixes issue 2 in #23 2017-01-09 14:10:05 +00:00
6fbb9b6083 Check for closed target Levels in Position (#241)
More foolproof
2017-01-09 13:18:28 +00:00
67940ad6ab Added PowerShell start script with loop capability, mainly useful for Win10 users (#240) 2017-01-09 13:16:46 +00:00
0a3fd8737a This is not needed anymore 2017-01-09 11:00:39 +00:00
8902992473 Fix McRegion read corruption errors, close #232
According to the wiki, McRegion heightmap should be ByteArray, not
IntArray. This caused issues with converted worlds with pretty much
every conversion tool. Blame @shoghicp.

IntArray McRegion heightmaps will now be converted to
ByteArray on save.
2017-01-08 21:16:57 +00:00
2e865a3af9 Fix doc comment fail 2017-01-08 19:35:28 +00:00
ed13f7f8e7 Add guideline to test bugs on a clean test server without plugins before reporting 2017-01-08 10:38:53 +00:00
02ddcef24e Fix calls to undefined method Human->getServer() (#234)
* Fixes sendHeldItem to stop crashes when executing.

* Fix server calling for food consuming.
2017-01-07 13:01:26 +00:00
3c9db45cf8 Fix tiles with async chunk sending, TODO: remove this 2017-01-07 10:52:39 +00:00
16e7eaaaa4 Merge branch 'master' into mcpe-1.0 2017-01-07 10:32:47 +00:00
4ace4b9542 Fixed CommandReader hanging on shutdown, close #25 (#171)
Use stream_select to poll stdin status before reading
Add detection for FIFO pipes, rewrite half of the CommandReader (again)
Add timeout for CommandReader to prevent hang in Windows custom consoles (unknown reason)
2017-01-07 10:28:03 +00:00
86dc8c48b9 Fix player burn time in creative 2017-01-06 20:01:21 +00:00
aaf549a469 Docs for Chunk 2017-01-06 17:57:00 +00:00
ad0553fbf8 Bump to API 3.0.0-ALPHA2 - READ DESCRIPTION!
Refactored level\format\generic\GenericChunk -> level\format\Chunk.
Re-added support for async chunk sending
Refactored most Level IO into new namespaces for more organisation
Removed LevelDB loader completely (will be re-added at a later date)
2017-01-06 17:13:45 +00:00
d8908676ac Refactor GenericChunk::fastSerialize() to be non-static, fix some unbelievable bugs, clean up some leftovers 2017-01-05 17:04:02 +00:00
598e7aac8f More PhpStorm inspections, import cleanup 2017-01-04 14:55:11 +00:00
07f18d8f6c Merge branch 'master' into mcpe-1.0 2017-01-04 11:34:39 +00:00
1cb96d24ce Some fixes, thanks PhpStorm 2017-01-04 11:29:24 +00:00
40600be4c1 Better README and contribution guidelines 2017-01-03 22:26:43 +00:00
096836faaa Moved Entity initialization into Entity class 2017-01-03 22:24:41 +00:00
b68df2da5c Remove unused files in preparation for rewrite 2017-01-03 22:24:41 +00:00
e2dc1a3bc6 Some consistency would be nice... fixed inconsistency between block light and sky light, always use Mojang order 2017-01-03 22:24:40 +00:00
8a29e77f5e Add missing byte, fix network sending issues, partly fixes #227 2017-01-03 22:24:40 +00:00
0bd7ea211d Refactored Server::broadcastPacket() to be non-static
Why the hell was this static at all? Seriously Shoghi?
2017-01-03 22:24:40 +00:00
55791e0819 Fix doc formatting from FullChunk -> Chunk mass-replace 2017-01-03 22:24:28 +00:00
69369c8998 Fix dropped items not saving due to missing CompoundTag name, close #223
The NBT library is really badly designed.
2017-01-03 22:24:27 +00:00
c36fc8c027 MobHeads are stackable to 64 2017-01-01 21:54:12 +00:00
7e15c6638a Fix dropped items not saving due to missing CompoundTag name, close #223
The NBT library is really badly designed.
2017-01-01 21:34:07 +00:00
88e36eda59 Stop wasting CPU calling functions 2017-01-01 15:50:13 +00:00
40d1394e3c Reuse empty chunk objects, stop creating new ones 2017-01-01 14:13:06 +00:00
69061ba4ad Removed the need for subchunks to know their Y coordinates 2017-01-01 14:12:58 +00:00
e85d6d134e Fix mob head crashes and drops, fix #221 2017-01-01 01:57:39 +00:00
0e10a149ef Refactor Level::chunkBlockHash() (makes no sense to put it here) 2017-01-01 01:10:10 +00:00
736ec6edac Auto-generated crafting and creative inventory data for 1.0.0.16, do not modify by hand 2016-12-31 16:33:53 +00:00
25b9581254 Make sure tag exists, prevent issues with bad world conversion
Addresses @legoboy0215's comments on #212
2016-12-31 10:24:21 +00:00
b263d81baf Explicit checks for missing tags, fix issues with converted worlds, close #212 2016-12-30 11:18:38 +00:00
0c3780de40 Re-added basic chunk skylight population for GenericChunk (#183) 2016-12-29 11:45:23 +00:00
850afed2c6 Merge branch 'master' into mcpe-1.0 2016-12-29 11:36:14 +00:00
efc6d429f6 Add some 0.16 blocks and items (#210) 2016-12-29 11:35:10 +00:00
b082bec150 Fix instabreak anti-cheat false positive on obsidian broken (#209) 2016-12-28 23:07:57 +00:00
2e1f572356 Fix netherrack and remove redundant override from NetherBrickFence 2016-12-28 23:07:57 +00:00
18ebc64ea0 Rename LevelSoundEventPacket field and add defaults 2016-12-28 23:07:56 +00:00
4f4bdea104 Fix trailing slashes in MOTD breaks server list, close #153 (#154)
Fixes #4083
2016-12-28 23:07:56 +00:00
c556ec84a2 MemoryManager: Fix sprint too less arguments if $from contains %x (#199) 2016-12-28 23:07:55 +00:00
a3a07ca847 Fix instabreak anti-cheat false positive on obsidian broken (#209) 2016-12-28 22:44:42 +00:00
227e1c42ea Fix netherrack and remove redundant override from NetherBrickFence 2016-12-28 22:30:03 +00:00
cb55cefa44 Fix trailing slashes in MOTD breaks server list, close #153 (#154)
Fixes #4083
2016-12-27 21:36:44 +00:00
10c8632417 Fixed effect amplifier overflow crash, close #147 (#191) 2016-12-27 21:30:54 +00:00
942b35ee4c Some metadata flags 2016-12-26 16:59:52 +00:00
440d66bd59 Runtime conversion would be far too slow, remove this redundant option 2016-12-23 20:48:56 +00:00
747aae94ec Refactor PMCustomAnvil -> PMAnvil 2016-12-23 20:38:31 +00:00
6d2a57f83a Prevent attempting to calculate lighting changes below y = 0 (#201) 2016-12-23 20:16:28 +00:00
a63020d6e5 Small performance improvement to nibble array re-ordering
thanks @Intyre
2016-12-23 20:07:55 +00:00
e2bbb76900 Use PMCustomAnvil as the default format for new worlds
mcregion is now "deprecated" due to its lack of suitability (fullchunk style, and no support for 256-high worlds)
2016-12-23 18:15:10 +00:00
f180167955 Add PMCustomAnvil format
Exactly the same as Anvil, but with XZY data ordering. Significantly more performant than Anvil due to no re-ordering necessary.
2016-12-23 18:15:09 +00:00
1eaf7c5431 Workaround for glob() fail, fix worlds not loading properly on some systems, close #197 2016-12-23 18:14:56 +00:00
3672d60bf4 More foolproof region file extension check 2016-12-23 12:40:04 +00:00
7e1557dc94 MemoryManager: Fix sprint too less arguments if $from contains %x (#199) 2016-12-23 12:20:55 +00:00
3848f6f39c Remove Anvil/McRegion circular dependency, more scalable region validity checks 2016-12-23 12:13:32 +00:00
00158d4805 Refactor namespace of Anvil/McRegion 2016-12-23 11:52:55 +00:00
3dcfa7b3ce Fix 32-bit crash and incorrect use of IntTag for Time 2016-12-22 21:03:18 +00:00
acd141e5aa Enable strict types on SubChunk and EmptySubChunk 2016-12-22 18:48:43 +00:00
8ee3723588 Removed Anvil RegionLoader, made mcregion RegionLoader usable for anything 2016-12-22 18:25:18 +00:00
29c27993ad Some mcregion/anvil improvements, add type-hints and enable strict-types 2016-12-22 16:57:03 +00:00
8bdfe0d297 Report CPU and tick usage accurately using averages (#195) 2016-12-22 14:11:46 +00:00
669af6f7b3 Fix a mistake in ItemFrame
thanks @awzaw
2016-12-22 13:47:33 +00:00
f4065dd411 Type-hints, strict-types, doc comments and rearrangement for LevelProviders 2016-12-22 13:16:25 +00:00
a99d7f93d9 Remove redundant return values
why am I still up at 6AM
2016-12-22 06:24:38 +00:00
363b24c663 Fix height limits on subchunks, fixed #196
facepalm
2016-12-22 04:46:28 +00:00
9e938baea0 Merge branch 'master' into mcpe-1.0 2016-12-21 20:27:49 +00:00
fb0c8c2c97 Merge branch 'item-fixes' into mcpe-1.0 2016-12-21 17:15:19 +00:00
772abc609d Fix ItemFrame crash 2016-12-21 17:11:03 +00:00
5feff79875 Fix deepEquals() crash when tag check is specified and only one item has a tag (#188) 2016-12-21 15:25:50 +00:00
7190f6a4ca Fix bow cannot be shot after jumping or sneaking, fix #190 2016-12-21 15:23:03 +00:00
6a066cdf31 Fix deepEquals() crash when tag check is specified and only one item has a tag (#188) 2016-12-21 15:00:00 +00:00
77b3cd71a3 Fixed cannot use items with custom NBT in regular crafting recipe, close #135 2016-12-21 14:55:13 +00:00
5443b10257 Use -1 for anydamage and empty string for null NBT, closes #146 2016-12-21 14:45:34 +00:00
300a3d5ccd Fix default hotbar mapping for W10 2016-12-20 21:19:25 +00:00
17a418f133 fix travis 2016-12-20 16:12:13 +00:00
e2b143a7cf Merge branch 'master' into mcpe-1.0 2016-12-20 13:03:49 +00:00
a1c3ca18ce Fix FlowerPot bugs 2016-12-20 13:01:28 +00:00
8c772fe671 Working item frames 2016-12-20 13:01:28 +00:00
c4d4277a6c Better BlockEntityDataPacket handling 2016-12-20 13:01:27 +00:00
2987c7a80c Remove unnecessary duplication 2016-12-20 12:59:27 +00:00
4063bc4ffb Relocated Server->registerTiles() to Tile::init() 2016-12-20 12:59:27 +00:00
90957cd908 Some tile improvements and added ItemFrame tile 2016-12-20 12:59:26 +00:00
50d59619a6 Remove unnecessary @throws 2016-12-20 12:25:46 +00:00
8db4b7116c Silence this error
Apply STFU operator
2016-12-20 11:08:46 +00:00
4b21e35d6e Fix head rotation issues, thank @jojoe77777 2016-12-20 09:38:47 +00:00
76a1165c0e Fix can't teleport over 128 2016-12-20 09:38:46 +00:00
35fbf78a77 Major API bump due to backwards-incompatible changes (not complete yet) 2016-12-19 21:50:13 +00:00
b86185519a Merge branch 'api-version-suffix' into mcpe-1.0 2016-12-19 21:49:22 +00:00
3433a931c1 Fix load order (no tolerance for mismatches with suffixes) 2016-12-19 19:30:11 +00:00
d9eb767420 Merge branch 'master' into mcpe-1.0 2016-12-19 18:38:13 +00:00
71704228a9 Added support for API alpha/beta/whatever suffixes 2016-12-19 18:08:45 +00:00
a122ea9e75 Merge pull request #161 from pmmp/deprecate-version-constants
Deprecate Minecraft game version constants in the `pocketmine` root namespace
2016-12-19 21:21:38 +08:00
a8694dcbf7 Relocated MINECRAFT_VERSION and MINECRAFT_VERSION_NETWORK to ProtocolInfo and deprecated the originals 2016-12-19 13:16:29 +00:00
1ec83420c8 Show debug messages in Travis test 2016-12-19 02:55:23 +08:00
bb7263beac Fixed script plugins not using first doccomment only 2016-12-17 23:56:43 +08:00
d84f990574 Fix Windows console unresponsive after a few hours, close #104 (#106) 2016-12-17 10:31:10 +00:00
61e8828f94 Fix ladder drops when supporting block is removed 2016-12-16 21:26:54 +00:00
aa8a13c4a3 Fix a bunch of block update bugs due to ancient code 2016-12-16 17:08:38 +00:00
0380c78926 Remove redundant override in Fallable 2016-12-16 16:33:31 +00:00
2930cf80b4 Merge branch 'master' into mcpe-1.0 2016-12-16 10:29:58 +00:00
5ce6c6227f Fix a couple of particle constants
Thanks @thebigsmilexd for information
2016-12-15 23:05:26 +00:00
5dca11dafb Increase ladder bounding box to 3/16, fix kicked for flying when sneaking on ladders (#168) 2016-12-15 16:18:49 +00:00
252d1988dc Merge pull request #166 from pmmp/0.16-isp
0.16 isp (PhpStorm inspections)
2016-12-15 18:45:05 +08:00
bd722bb85f fix misplaced doc 2016-12-15 09:22:51 +00:00
e1253db37c Some more minor changes for autocompletion in IDEs 2016-12-14 21:49:36 +00:00
175dd0efa6 PhpStorm inspections
Fixed some minor bugs and dropped some obsolete code

pocketmine\level\generator namespace is ignored in this commit
2016-12-14 21:49:35 +00:00
146f5a567f Add cases for some unhandled Player Actions and add unknown field to ContainerSetSlotPacket 2016-12-13 11:43:37 +00:00
e790573f2e Fix NBT "getArray()" (#163) 2016-12-12 16:03:05 +00:00
6ea45c5c4a Formatting and doc comments, overall useless commit 2016-12-12 14:25:42 +00:00
544d99f161 Added ability to force literal gamemode checks for Player->isSurvival(), Player->isCreative() and Player->isAdventure() (#155) 2016-12-12 10:07:34 +00:00
42b78cfba2 Some new particle IDs 2016-12-10 15:25:12 +00:00
99e8bcf26b Auto-generated sound constants from 1.0.0.2 2016-12-10 15:10:14 +00:00
6224f0cdf6 Protocol bump for 1.0.0.2 2016-12-10 12:22:28 +00:00
5e6d452678 Fix TNT flashing, add explosion particles and add DATA_FUSE_LENGTH entity data constant 2016-12-09 17:20:07 +00:00
ae6e0773ef Do not perform scheduled updates on still lava/water (#134) 2016-12-09 16:13:39 +00:00
cc9736314e Protocol update for 1.0.0.1
Added PlayerFallPacket
2016-12-08 12:34:31 +00:00
adabd7ef65 Merge branch 'master' into mcpe-1.0 2016-12-06 12:04:42 +00:00
5d16ecc003 Entity Effect Events (#141)
Add EntityEffectEvent class that the EntityEffectAddEvent and
EntityEffectRemoveEvent classes extend. Add event calls to Effect class.
2016-12-06 11:59:49 +00:00
288bf0fe6c Use folder name for saves instead of display name (#150) 2016-12-06 11:58:25 +00:00
e92052c2ab Fix blockhash fail (this would have returned excessive Y coordinates including the bits for X!) 2016-12-05 16:31:47 +00:00
25560a52b0 Remove unused Level field 2016-12-05 16:26:45 +00:00
d625a20934 Remove mess 2016-12-05 10:22:57 +00:00
a0cda3b45a Fixed extra data encoding 2016-12-04 17:46:56 +00:00
d74486a64a Fixed tile spawns 2016-12-04 15:12:45 +00:00
aafe0c4f69 Remove biome colours and fix biome id arrays 2016-12-04 15:12:23 +00:00
4674d34469 Update start.cmd 2016-12-04 14:16:15 +00:00
43b3b41039 Clean up unused files
Clean up unused files
2016-12-04 21:29:33 +08:00
d37afde0dc Disable Travis emails 2016-12-04 10:49:00 +00:00
fecbdc5ff2 Clean up unused files 2016-12-04 10:42:30 +00:00
4d121f7d84 Fix some entity metadata 2016-12-03 22:12:52 +00:00
6a8976c534 New PlayerActionPacket constants 2016-12-03 22:12:52 +00:00
74e31fe712 Fix ./command detection by old plugins (#138)
* Fix ./command detection by old plugins

* plugins might change it 🤦
2016-12-03 20:05:00 +00:00
28c3a882f8 Add new field to UseItemPacket 2016-12-02 18:43:35 +00:00
ebd2830770 Remove nonexistent NBT tags and fix movement issues in PC worlds 2016-12-02 18:06:36 +00:00
2e540300d8 Remove Twitter Link (#136)
Do you guys still have access to the Twitter account? I just noticed that it never got updated. If you still want to use it though, by all means keep this link in here :)
2016-12-02 13:26:32 +00:00
fb74d93e00 Protocol changes for 1.0.0.0 2016-12-02 13:20:52 +00:00
6696b7ed52 Clean up .travis.yml 2016-12-02 12:21:06 +00:00
35b3259053 Fix explosions over 128 do not damage blocks 2016-12-02 00:01:38 +00:00
577dbbce1f Support 256-block build height and fixed world saving 2016-12-01 23:45:12 +00:00
ce289cbe25 Merge branch 'master' into 0.17-chunks 2016-12-01 17:50:12 +00:00
756760a2f0 Fixed clicking on fire to extinguish it (#132) 2016-11-30 15:27:14 +00:00
d6629d6843 More ?? (#131)
* More ??

* fix undefined variable
2016-11-30 10:07:37 +00:00
43a36dba40 Fix op players automatically switching to creative/survival when set to spectator/adventure
Disable GUI gamemode switching, treat it as a cheat.
2016-11-30 09:22:45 +00:00
5025b4aba1 More nibble array re-ordering optimisation 2016-11-29 14:46:49 +00:00
dd01407dd4 Optimized byte re-ordering 2016-11-29 14:46:49 +00:00
d70be232d8 More tweaks 2016-11-29 14:46:48 +00:00
ecabe945e6 Changes for more performance, fixed some crashes and hacked out dodgy light population 2016-11-29 14:46:48 +00:00
2b46794ca2 Optimised nibble array re-ordering (halved loop count) 2016-11-29 14:46:08 +00:00
0be8fa4157 Optimized byte and nibble array re-ordering 2016-11-29 14:44:46 +00:00
b1ce19856f Fix adventure settings not updated for GUI gamemode changes 2016-11-28 11:25:29 +00:00
252afde06f Bump version numbers
Getting as bad as Mojang :O
2016-11-27 21:58:00 +00:00
039d6a488a Fix lighting *facepalm*
http://rmsnews.com/wp-content/uploads/2015/06/clavier-avec-uniquement-ctrl-c-et-ctrl-v.jpg
2016-11-27 21:57:59 +00:00
15f7cfb4f7 Add missing return value, fix blocks vanishing when placed 2016-11-27 21:57:59 +00:00
4c49db6036 New generic in-memory chunk format, fixed 0.17.0.1 chunk loading
Terrible performance, needs profiling. TODO: fix this.
2016-11-27 21:57:59 +00:00
60260a294b Remove chunk order fields 2016-11-27 21:57:59 +00:00
18c0567944 Autogenerated data for 0.17.0.1 (not functional yet) 2016-11-27 21:57:59 +00:00
367fa41161 Remove GUI remnants from start.cmd 2016-11-27 19:29:47 +00:00
439f418b0d Remove debug output 2016-11-27 16:00:54 +00:00
fa5624f87e Check rotation changes. Fix #124, fix #128 2016-11-27 15:58:37 +00:00
c79077cbed Fix MobHead bounding box and properties 2016-11-27 15:50:02 +00:00
995d0847f9 Fix tile derp 2016-11-27 13:06:11 +00:00
aa713c4e4a Added ability to specify tag name for serializing 2016-11-27 12:17:11 +00:00
3b3abab3ad Fix W10 throws away held item on inventory close
This issue will however still crop up if there are actual items in the crafting grid instead of air.
2016-11-27 12:01:09 +00:00
5f5f71cfbe Fix fail due to merge commit 2016-11-26 16:14:29 +00:00
363431dac2 Updated preprocessor submodule 2016-11-26 16:09:43 +00:00
1b543b2c16 Improved varint write performance (#126) 2016-11-26 15:07:27 +00:00
763ef7f937 Removed outdated GUI submodule (#125) 2016-11-25 13:46:41 +00:00
e51a2725de Remove circular dependency between Item and NBT modules (#121) 2016-11-25 10:17:50 +00:00
a0111d04ee Log exception with backtrace 2016-11-24 21:20:10 +00:00
958473b333 update PHP-YAML to 2.0.0 for Travis 2016-11-24 12:04:52 +00:00
744f5a8384 Fix ServerKiller and make it less useless (#122) 2016-11-24 08:47:28 +00:00
fe348b0a9d Speed up region file creation by only using ftruncate(). (#116)
* Speed up region file creation by only using ftruncate().

The old method was extremely slow (~200ms to create a single region file), but the new one is much faster (in the order of ~15ms). (Numbers were measured on a Linode 2048)

* Replace manual array fill with array_fill().

* Spaces -> tabs.

* Update RegionLoader.php
2016-11-23 21:23:38 +00:00
8d842732e0 Ignore MovePlayerPacket if position is the same 2016-11-22 16:55:40 +00:00
bee342691d Remove NetherBrickFenceGate derp 2016-11-22 15:47:20 +00:00
36623d8a5b Update links to .io 2016-11-21 17:55:14 +00:00
7eb9530346 Fix CraftItemEvent not return inputs 2016-11-21 17:43:04 +00:00
bd85d53a0b Removed unsafe use of potential non-Player-object parameter 2016-11-20 20:03:56 +08:00
ac37af3a46 Added types and changed to sendWhisper 2016-11-20 20:03:56 +08:00
208884422d Added whisper 2016-11-20 20:03:56 +08:00
da23568546 Disallow scheduling the same AsyncTask instance more than once 2016-11-20 01:12:38 +08:00
f0f6d85809 Merge branch 'asynctask-progress' 2016-11-19 23:17:26 +08:00
92bd1a755d Fix Installer server name bug (server name uses MOTD now 2016-11-18 11:41:25 +00:00
3ee43c5a17 Fix some varints 2016-11-17 18:28:39 +00:00
8ced6547f2 Fixed #109 2016-11-17 01:25:01 +08:00
d29e96407e Update another link
[ci skip]
2016-11-15 13:31:14 +00:00
8214e50bcc HTTPS [ci skip] 2016-11-14 14:25:17 +00:00
802bc21c53 Change forums link
[ci skip]
2016-11-14 10:04:04 +00:00
25b51b4dfd Update ISSUE_TEMPLATE.md 2016-11-14 09:32:29 +00:00
794ff643a7 Add new forum link (#102) 2016-11-13 16:33:52 +00:00
37ae760417 Fixed crashes after scheduleAsyncTaskToWorker() calls 2016-11-13 18:32:11 +08:00
ab4d6b1e36 Clarified that AsyncTask should not run for a long time 2016-11-13 18:14:41 +08:00
383df298a6 fix crash at server stop when RCON is enable (#101) 2016-11-13 10:11:15 +00:00
7314aaf7f7 Particles for 0.16
Added BlockForceFieldParticle, removed LargeExplodeParticle and added HugeExplodeSeedParticle
2016-11-12 21:05:01 +00:00
75fa2f1132 Fixed array progress crashing
Forgot to serialize them. They would be converted to Volatile, which is Threaded. Threaded objects still crash with progressUpdates.
2016-11-12 18:57:52 +08:00
d5881dbe83 Disallow Threaded objects to be passed as progress parameter 2016-11-12 18:33:25 +08:00
8404ce88bd Fixed pthreads crashes with progressUpdates 2016-11-12 18:30:55 +08:00
7861822a0f Fixed garbage AsyncTasks cannot be accessed 2016-11-12 17:47:07 +08:00
e6485c4734 Added AsyncTask progress update API 2016-11-12 17:31:59 +08:00
bd5bbbea10 Missed one
TODO: fix this properly
2016-11-10 13:28:27 +00:00
0ac04b52ff Merge pull request #95 from pmmp/timings-verbose
Make /timings command more verbose about errors
2016-11-10 08:48:09 +00:00
2d37d361a7 Make /timings command more verbose about errors 2016-11-09 22:09:16 +00:00
d696049a0a Fix anvil rotation and variant drops 2016-11-09 20:28:59 +00:00
1d876e30c8 Clean up some EnchantmentList mess 2016-11-09 14:20:25 +00:00
ea7313779e Update crafting recipes 2016-11-09 14:20:24 +00:00
5a8008367f Updated creative inventory json with better NBT encode/decode, fixes enchanted books issues 2016-11-09 14:20:24 +00:00
911529a6cc Added jsonSerialize() to Item and fixed some crafting data decode issues 2016-11-09 14:20:24 +00:00
bee6c546dc Added decode for CraftingDataPacket and shell for MultiRecipe 2016-11-09 14:20:23 +00:00
e3c900e071 Merge pull request #70 from pmmp/24-level-leak
Fixed bugs related to #24 such as getName() on null. Close #24
2016-11-09 10:51:15 +00:00
e50311f1ea Fix wrong SPL submodule branch 2016-11-07 16:52:29 +00:00
0bdb8a46f7 Update submodules 2016-11-07 16:49:01 +00:00
074583d104 Builtin thread-local object storage for AsyncTask (#1)
* Added AsyncTask::fetchLocal()
2016-11-06 22:02:53 +08:00
3b7377370c Critical error upon missing submodules (#77)
* Critical error upon missing SPL

* Added checks for RakLib and PocketMine-Language

* It actually throws ClassNotFoundException, not simply returns false :(

Should I blame :shoghi:?
2016-11-06 11:46:39 +08:00
1ac74fe5bc Temporary fix for commands, remove permission filter 2016-11-05 19:02:08 +00:00
c494af618c Clean up some old code 2016-11-04 21:46:14 +00:00
557257baed Fix wrong SetHealthPacket decode 2016-11-04 16:29:51 +00:00
75cc99a003 Fix client crash on join. TODO: new recipe type 4 (no longer enchantment entry) 2016-11-04 12:57:11 +00:00
7dc839fbe8 Merge pull request #75 from pmmp/fix-op-perm-calc
Fix double permission recalculation on op status change, fixes double…
2016-11-04 10:13:52 +00:00
d3fb8c46f5 Fix double permission recalculation on op status change, fixes double sending of AvailableCommandsPacket 2016-11-03 18:05:12 +00:00
fffa5488fd Fix command resending when permissibles are recalculated 2016-11-03 17:35:20 +00:00
e60364d7c9 Corrected encode/decode of TextPacket parameters 2016-11-03 15:55:08 +00:00
cf222324d6 Fix high load when teleporting and some teleportation weirdness 2016-11-02 14:18:47 +00:00
d3c62988b0 Add unknown field to ResourcePackInfoEntry 2016-11-02 13:41:59 +00:00
b34d438ed9 Fix AddPlayerPacket field ordering 2016-11-02 09:38:31 +00:00
f50c63a0c2 update docs link 2016-10-31 18:07:30 +00:00
d1f59632c2 Merge pull request #67 from KnownUnown/system_php
Fixed detection of system PHP binaries
2016-10-31 17:45:49 +00:00
03003ffa50 Improved invalid spawnpoint checking 2016-10-31 14:05:50 +00:00
7a1cdf88e8 Fixed bugs related to #24 such as getName() on null 2016-10-31 13:50:18 +00:00
4856dbd1c6 Add PreProcessor as submodule, and fixed for 0.16. Close #69 2016-10-31 13:24:57 +00:00
16d07e1f3d Remove redundant return value for setImmobile() 2016-10-30 17:07:06 +00:00
daed82612c fixed system PHP detection 2016-10-30 12:07:01 -05:00
16d72c7f86 Remove redundant type-hint causing crashes 2016-10-30 17:03:29 +00:00
ce5fa0e836 Fix FallingSand metadata 2016-10-30 15:54:02 +00:00
dc07fc42b4 Merge pull request #42 from pmmp/0.16
Update to 0.16 (1.6.1dev, API 2.1.0)
2016-10-30 11:27:10 +00:00
fdf3c0c1c7 Change Unknown Command message colour to Gold to highlight client command issues 2016-10-30 10:20:17 +00:00
656ec60805 Fix plugin metadata crashes 2016-10-29 17:56:34 +01:00
293af3d55d Add levelId to StartGamePacket (previously unknown) 2016-10-29 14:46:51 +01:00
0ce25f8b29 Fix #59 (FloatingTextParticle undefined ) 2016-10-29 09:59:34 +01:00
06f8390b30 Fix furnaces and wrong smelting data recipe encoding 2016-10-28 21:46:20 +01:00
55ad6c6b95 Fix wrong comment 2016-10-28 13:31:47 +01:00
46af92f781 Fix dataless crafting and furnace recipes 2016-10-28 12:17:11 +01:00
2765e87677 Add slashes (my bad -_-) 2016-10-28 10:01:57 +01:00
5df916099d Fire PlayerCommandPreProcessEvent for CommandStepPacket 2016-10-27 22:08:27 +01:00
137972098f Fixes for AnimatePacket and added TextPacket::TYPE_WHISPER constant 2016-10-27 14:05:49 +01:00
3d2f9f0e74 Better InteractPacket handling and added ACTION_MOUSEOVER constant 2016-10-27 13:15:53 +01:00
9d16f145dd Creative inventory update with unknown item filter 2016-10-27 12:13:27 +01:00
ae1501884b More metadata and some cleanup 2016-10-27 10:55:06 +01:00
5234327b3f Improved action check for InteractPacket (#55)
Fixes issues with 0.16 combat, where the server thinks the player is attacking an entity they're looking at
2016-10-27 10:55:05 +01:00
689a052bda Update game permissions when op status changes 2016-10-27 10:55:05 +01:00
813bb98850 Add some permission constants to AdventureSettings 2016-10-27 10:55:05 +01:00
d9e6676176 Fix wrong flag names 2016-10-27 10:55:05 +01:00
bfc77a772a New entity data flags
@Intyre, you are beyond awesome
2016-10-27 10:55:05 +01:00
6bcb3aeb26 Add new values for potion colour and ambient. TODO: bubble transparency. 2016-10-27 10:55:05 +01:00
0f8a6481c6 Fix snowball throw direction
Blame Mojang, TODO: Revert this once the bug is fixed
2016-10-27 10:55:05 +01:00
db3e801478 Fixed snowballs 2016-10-27 10:55:05 +01:00
0f261b7baa Fixed player flags (now can sleep!) 2016-10-27 10:55:05 +01:00
6c1dd81130 Remove type-hints, fix some crashes 2016-10-27 10:55:05 +01:00
eed8c37eab Addresses issues noted by @SOF3 2016-10-27 10:55:05 +01:00
6e0cebbe38 Add missing import 2016-10-27 10:55:04 +01:00
902dd4258b Bump version to 0.16.0.5 and protocol to 91 2016-10-27 10:55:04 +01:00
ce72f634b0 Update some old code 2016-10-27 10:55:04 +01:00
2dfca14714 Add varint length checks (10 bytes, currently no proper varlong support) 2016-10-27 10:55:04 +01:00
2ffbb452bb Fix a bunch of metadata bugs, fixed air ticking and added some new API methods 2016-10-27 10:55:04 +01:00
468b3e8d44 Flags now work on mobs, but not on players
This commit no doubt breaks something, somewhere
2016-10-27 10:55:04 +01:00
035084a5ac Remove useless override 2016-10-27 10:55:04 +01:00
869721a8ee Add more unknowns 2016-10-27 10:55:04 +01:00
787f6594b2 More new data properties 2016-10-27 10:55:04 +01:00
867ec6b509 Fix leads, crashes 2016-10-27 10:55:03 +01:00
b6e1a21566 Add new metadata type vector3f and correct metadata encoding. Result = client crash. TODO: new data values and flags. 2016-10-27 10:55:03 +01:00
694c9b151f Move default data to json 2016-10-27 10:55:03 +01:00
ed69303b4a Add permission checks back in 2016-10-27 10:55:03 +01:00
192fba9c88 Resend command data when op status changes 2016-10-27 10:55:03 +01:00
018897062c Initial working slash commands on 0.16. TODO: new API 2016-10-27 10:55:03 +01:00
b198f287db Add AvailableCommands and CommandStep packet shells 2016-10-27 10:55:03 +01:00
750462aa75 Fix large signed varint/negative number CPU leak 2016-10-27 10:55:03 +01:00
b1df4728d3 BatchPacket payload checks, fix crashes when older versions try to join 2016-10-27 10:55:03 +01:00
5eb2459355 Fix player list duplicates 2016-10-27 10:55:02 +01:00
1120dff492 Fix player lists and skins 2016-10-27 10:55:02 +01:00
bd1b18d9af Fix issues on 64-bit systems -_- (hate php) 2016-10-27 10:55:02 +01:00
01d465b038 Add decode for LevelSoundEventPacket
TODO: find new fields, find out when client sends this
2016-10-27 10:55:02 +01:00
d6fcc59a49 Support changing gamemode in GUI and fixed spectator flight controls 2016-10-27 10:55:02 +01:00
a45e232829 Fix wrong SetDifficultyPacket decode 2016-10-27 10:55:02 +01:00
9497dff3ee Add decode for ResourcePackClientResponse (fields unknown) 2016-10-27 10:55:02 +01:00
df88e9272e Fix DisconnectionScreen, add getBool() and putBool() methods, update some packets 2016-10-27 10:55:02 +01:00
ec328a8160 >_> 2016-10-27 10:55:02 +01:00
7cd7a7fbf6 Spawn working on new build. TODO: Resource packs. 2016-10-27 10:55:02 +01:00
9a12aa689e New StartGamePacket fields for 0.15.90.8 2016-10-27 10:55:02 +01:00
39ffc28f2a Auto-generated data for 0.15.90.8 (not functionalyet) 2016-10-27 10:55:01 +01:00
9242f89221 Add PlayerToggleFlightEvent 2016-10-27 10:55:01 +01:00
e35ed7f04a New fields for LevelSoundEventPacket (previously unknown) 2016-10-27 10:55:01 +01:00
08f11412a4 AdventureSettings fixes and added isFlying properties and methods 2016-10-27 10:55:01 +01:00
2bb50792c3 Fast commands hack for old plugins. 2016-10-27 10:55:01 +01:00
85c50731f8 Fixed crafting (cannot test enchanting) 2016-10-27 10:55:01 +01:00
ff40c0a070 NBT updates and tile spawns fixed 2016-10-27 10:55:01 +01:00
8f9574dec5 Fixed FOV and attributes 2016-10-27 10:55:01 +01:00
86ed0f1397 Updated existing packets and added new ones 2016-10-27 10:55:01 +01:00
affed33066 Add length check assertions 2016-10-27 10:55:00 +01:00
9cde63a327 Base inventory fixes 2016-10-27 10:55:00 +01:00
401de97719 Fixed chunk loading and movement 2016-10-27 10:55:00 +01:00
dd0c5efb56 Initial spawn on 0.16 2016-10-27 10:55:00 +01:00
bb9ab525b6 Fix quadruple-quote key parser bug 2016-10-26 22:18:06 +01:00
8053066ac0 Remove useless statement (#50)
* Remove useless statement

* Delete instead of commenting.
2016-10-23 17:03:51 +01:00
88d14e9923 Remove redundant ifndefs 2016-10-23 15:14:59 +01:00
702ab53e69 Moved the default mcr/mca worlds' spawn in the center of the r.0.0.mc* region file (#28)
The default mcr/mca spawn was not centered in the 0,0 region causing the generation of not needed regions walking just a bit
2016-10-21 13:50:30 +01:00
0163555d3e Add warning for xdebug on server startup 2016-10-21 13:44:38 +01:00
1c41667b9b Remove useless submodule (unused) (#39) 2016-10-20 20:22:44 +01:00
c2299b521f change homepage link 2016-10-20 11:43:32 +01:00
3692ddab1d Remove duplicate call to gc_collect_cycles
This is already done in forceShutdown(), and if it is not then the
process will have committed suicide and this will never be called
anyway. Either way, it's useless.
2016-10-19 22:08:44 +01:00
3ddfb97921 Support PC item save format with string ID, close #32 (#33)
* Fixed #32

* StringTag check, throw exception for other types

* Short, not int

* Fix misleading exception message
2016-10-19 09:41:59 +01:00
e7e476b65e Wooden and Stone slabs both placable 2016-10-18 18:19:58 +02:00
f3f853056a This messed up movement
Revert "Removed unneeded vars - fixed logical condition (#29)"

This reverts commit ef7a843fa3.
2016-10-18 17:10:06 +01:00
bcc641a25a Fix for slab placing, close #31 2016-10-18 17:37:40 +02:00
ebcc16d283 Fix --disable-readline command-line option does not work, close #34 (#35)
* Fix --disable-readline command-line option does not work, close #34

* add parentheses
2016-10-18 14:33:38 +01:00
4bc2275fc3 Merge branch 'ci' 2016-10-18 13:57:13 +01:00
ef7a843fa3 Removed unneeded vars - fixed logical condition (#29) 2016-10-18 12:52:18 +01:00
10698c892e Remove old script, add disable-readline option 2016-10-18 12:45:56 +01:00
43842691fe Merge branch 'new-labels' 2016-10-18 12:03:27 +01:00
8637a04e2b New label scheme 2016-10-18 12:03:11 +01:00
d53810c6bc Fix banlist crash when | is entered in any /ban arguments 2016-10-17 18:29:33 +01:00
f3e35bb94a Update some links 2016-10-17 14:41:59 +01:00
707847b46e Shell-based CI with lint scans 2016-10-17 12:59:20 +01:00
e81c738010 Update ISSUE_TEMPLATE.md 2016-10-17 12:14:16 +01:00
8f3b95164a Fix preprocessor issues
Blame @SOF3
2016-10-16 19:47:32 +01:00
19601f998a New Jenkins server 2016-10-16 19:04:18 +01:00
2fba1073dd Fix wrong comment 2016-10-12 13:24:00 +01:00
6b06e407c6 Delete .mailmap 2016-10-10 14:38:17 +01:00
0b270342b1 Update .mailmap 2016-10-10 14:33:30 +01:00
23e4ca64e4 Remove dupe load() causing reload debug spam
This call is completely redundant.
2016-10-10 14:10:37 +01:00
36207debe0 Update RakLib submodule
Fix DoS with empty packets does not trigger blocking
2016-10-08 13:41:50 +01:00
de28ddabdb Update RakLib submodule 2016-10-08 11:25:53 +01:00
c328d7359c Labels do not have restricted length
WhataTerribleFailure
@sekjun9878 why did you add that?
2016-10-08 18:11:09 +08:00
5e72850a62 Merge branch 'pmmp-cntrb' of https://github.com/pmmp/PocketMine-MP 2016-10-08 18:05:58 +08:00
a9cbe4f63e Updated CONTRIBUTING.md to adapt into pmmp org
Updated CONTRIBUTING.md to adapt into pmmp org
2016-10-07 18:52:53 +08:00
beabc5a85c Merge pull request #14 from pmmp/disable-player-dat
Added options to disable saving <player>.dat
2016-10-07 18:47:01 +08:00
2a07638af3 Do not show playerNotFound notice if player data should not be saved 2016-10-07 17:52:25 +08:00
d6fd9259cf Added options to disable saving player.dat 2016-10-07 10:25:26 +01:00
16c09e3610 Merge branch '0.15.10'
Skin models again
2016-10-06 09:46:59 +01:00
b78dd70f72 Bump version to 0.15.10.0 and protocol version to 84
Changes unknown
2016-10-05 15:29:27 +01:00
92784054cd Creative inventory fixes 2016-10-05 10:07:00 +01:00
98ea674d20 Ouch 2016-10-04 18:48:07 +01:00
4b869c8615 Merge branch 'master' of https://github.com/pmmp/PocketMine-MP 2016-10-03 23:29:39 +08:00
ec79477b3e gitignore memory dumps 2016-10-03 23:24:34 +08:00
58ff381557 PhpStorm automated formatting (#11)
* PhpStorm reformatting

* Tuned PhpStorm reformatting

* Improved ItemIds and BlockIds formatting

* Tuned more PhpStorm reformatting

* Improved string concatenation
2016-10-03 19:05:48 +08:00
2b6d058760 Fixed kicked for flying when walking on lily pads (#7)
Add an optional extended description…
2016-10-03 09:17:50 +01:00
535e1a0eb4 Merge branch 'master' of https://github.com/pmmp/PocketMine-MP 2016-10-03 01:59:22 +08:00
4133f98b23 Updated a few tabs, updated SPL submodule 2016-10-03 01:59:06 +08:00
d7a78ee00f Merge pull request #10 from SOF3/master
Fixed some lines indented with 4 spaces rather than tabs
2016-10-03 01:05:23 +08:00
e913b16804 Fixed some lines indented with 4 spaces rather than tabs 2016-10-03 00:58:34 +08:00
6fc435da0e Imports rearrangement 2016-10-03 00:43:46 +08:00
84e15b6b1a Remove derp brackets (#8) 2016-10-02 17:22:19 +01:00
e9f2bf0085 Better time ticking and sync (#2)
* Remove unnecessary SetTimePacket spam

This is handled automatically client-side, as long as it is calculated correctly server side there is no issue (unless the server hits a spot of bad lag)

* Better client/server time sync when lagging
2016-10-02 12:54:27 +01:00
5f26c21b9f Remove unused RemovePlayerPacket 2016-10-01 21:39:05 +01:00
ee4854d07c Typo fix (#5) 2016-10-01 17:07:00 +01:00
9a379734ba Use \pocketmine\Thread::getThreadName() instead (#6) 2016-10-01 17:03:24 +01:00
a7366324e5 Fixed RawChicken::getAdditionalEffects return values (#4)
* Fixed RawChicken::getAdditionalEffects returns void

* Update RawChicken.php
2016-10-01 16:35:20 +01:00
39f731aa06 Remove use of deprecated Utils::getRandomBytes(16) (#3)
Whichever guy did that, somehow this one just got missed out?
2016-10-01 16:08:59 +01:00
7c41aa66f1 Update submodules 2016-10-01 15:49:25 +01:00
98d129f1f4 Fix bad copy-paste job, blame @shoghicp 2016-10-01 14:54:50 +01:00
99622c5ce7 Fix wrong network IDs for inventories, fix anvil/enchanting table windows 2016-10-01 14:48:42 +01:00
ad64a074cb Fix furnace NBT assertion errors and inventory not working 2016-10-01 14:14:55 +01:00
23f3097390 Travis: Build all branches 2016-10-01 13:44:31 +01:00
abf004de7d Change Travis links 2016-10-01 11:37:52 +01:00
ff4b7612a6 Update submodules 2016-09-30 20:25:17 +01:00
2d95bdc10f Remove derp semicolon (#11)
* Update Furnace.php

* fix formatting
2016-09-30 19:20:03 +01:00
50c5c1de92 Bump version to 0.15.9 and protocol to 83
Seems the only thing that changed was the cape skin models, which would not be rendered correctly by older clients.
2016-09-30 19:20:01 +01:00
e2e31d345d Allow vanilla trapdoor placement 2016-09-30 19:20:00 +01:00
7145e16bce Fix getHandler() returns null on tasks (#3) 2016-09-30 19:19:59 +01:00
5485b63e6e Added ChangeDimensionPacket 2016-09-30 19:19:58 +01:00
f2f70480ee Fixed precedence problem (#1)
as mentioned in 4cb76f369a (commitcomment-19068812)
2016-09-30 19:19:57 +01:00
900c4adb66 Create sign tile like it should be. 2016-09-30 19:19:56 +01:00
5f8dc5829c Better inheritance for wooden stairs 2016-09-30 19:19:55 +01:00
e962f7fb0a Fixed bug in updateAround where only one block is updated 2016-09-30 19:19:54 +01:00
a3e3a5f631 RNG: XorShift128 adapted from php-random library
Fixes world generation problems on 32-bit systems
2016-09-30 19:19:53 +01:00
b156480550 Fix redstone ore glowing immediately when placed
Do not update the block when placed
2016-09-30 19:19:52 +01:00
7b8548b2b1 Added Flower Pots 2016-09-30 19:19:51 +01:00
fbe17344fb Fix plugin crashes when attempting to get metadata of offline players 2016-09-30 19:19:50 +01:00
e143fb80da create .editorconfig to improve code displaying on github 2016-09-30 19:19:49 +01:00
795d6c8ddf Fix entity-related memory leak on chunk unload 2016-09-30 19:19:48 +01:00
6bd028f8b3 Fix Wood2 crashes 2016-09-30 19:19:47 +01:00
35c33ba980 Fix Glowing Obsidian lighting 2016-09-30 19:19:46 +01:00
895790f46c Fix signs going blank
Sign text is not limited to 16 characters anymore, but to the width of
the sign. Server: Stop being such a control freak
2016-09-30 19:19:45 +01:00
378c3d7994 Patch %0 client translation exploit 2016-09-30 19:19:44 +01:00
9808f874c8 Remove Stonecutter remnants 2016-09-30 19:19:43 +01:00
4198c445b0 Fixed Furnace crash 2016-09-28 13:59:53 +01:00
42e8120961 Remove creative container open checks (lines up with 0.14) 2016-09-28 13:59:53 +01:00
2a4f85107d Less duplication, more consistency 2016-09-28 13:59:53 +01:00
97f6b80969 Fix players levitating in beds and teleportation of sleeping players 2016-09-28 13:59:52 +01:00
a6f8379c40 Fix time bugs 2016-09-28 13:59:52 +01:00
bf4b96e144 Block: Fix fence gate rotation when opened or closed. TODO: fix gate opening direction 2016-09-28 13:59:52 +01:00
4f26e5598c Network: Fix crashes caused by AddEntityPacket 2016-09-28 13:59:52 +01:00
e00176b677 Closes #4181 @ PM
https://github.com/PocketMine/PocketMine-MP/issues/4181
2016-09-28 13:59:51 +01:00
f32d588b9b Inventory: Creative Inventory update 2016-09-28 13:59:51 +01:00
f14a8e46be Inventory: Fix creative/spectator inventory sending 2016-09-28 13:59:46 +01:00
5851e7fe55 Network: Do not attempt to decode further for non-accepted protocols
Prevents 0.16 players crashing 0.15 servers
2016-09-06 11:54:52 +01:00
Tux
8e9a078ff9 Use built-in random_bytes functionality 2016-09-06 11:47:58 +01:00
b16f7e4dd5 Fix a really annoying movement bug on player join 2016-09-06 11:42:30 +01:00
15b9578245 Fix reach distance bugs 2016-09-06 11:33:27 +01:00
765bd5ced7 Inventory: Fix hotbar spaz 2016-09-06 11:23:49 +01:00
df4c3ec4a6 Bump version and protocol to 0.15.4 2016-09-06 11:12:18 +01:00
d6e343c2cf Premature optimization again 2016-08-24 17:15:22 +08:00
6fb41c5c7f UpdateBlockPacket fixed and changed skinName to skinId 2016-06-22 01:09:48 +02:00
df8e1e8702 Spawn unleashed, movement fixed and some Player DataProperty cleanup 2016-06-22 00:08:52 +02:00
ef8227a074 Bump version to 0.15.0.0 and protocol changes 2016-06-15 23:59:35 +02:00
80d6f8dfb3 Updated submodule 2016-06-07 10:41:57 -04:00
e2d079a7df Bump version to 0.14.3.0 and protocol changes 2016-05-20 00:21:44 +02:00
ee9ba9f1a0 Merge branch 'mob-heads' 2016-05-18 10:10:10 -05:00
292a212827 Merge branch master 2016-05-18 10:07:57 -05:00
ac482621a1 Bump version to 0.14.2.0 and protocol changes 2016-04-28 01:50:54 +02:00
754ff9b4c4 Fixes #3223 2016-04-04 17:59:23 +08:00
aade3fe390 Closes #3432 2016-03-28 02:42:08 +08:00
8441169365 Fixed warning messages when parsing @notscript files 2016-03-28 02:27:03 +08:00
e51c6b4b42 Merge branch 'notscript' 2016-03-28 01:26:29 +08:00
73f24786cd Fixed @notscript without trailing spaces not detected 2016-03-28 01:26:15 +08:00
13d1089d30 Fixed PluginManager:: type doc 2016-03-23 23:57:02 +08:00
eb3c1f95b0 Updated .gitignore to stage src/pocketmine/resources/pocketmine.yml 2016-03-23 23:56:29 +08:00
012d46dfd8 Added Mob Heads
Fixed duplicated items in JSON file
2016-03-22 22:25:36 -06:00
2fb3b41b8d Added the @notscript tag in potential script plugins
Then we can have .php files in the plugins folder that contain /** but are not script plugins
2016-03-23 02:32:11 +08:00
085ff56362 Clearer Config::__construct() documentation. 2016-03-21 14:41:49 +08:00
23da42f8a4 Merge pull request #4068 from PocketMine/PEMapModder-patch-2
Promotes the use of reactions
2016-03-18 23:35:36 +08:00
f82c59bdc4 Fixes #3991, closes #4011 2016-03-15 22:52:49 +08:00
3f801ff6f4 Promotes the use of reactions 2016-03-13 23:40:30 +08:00
6ba0abf587 Update README.md
Mentions that mbstring is used (already used in Player.php)
2016-03-11 01:16:07 +08:00
0b06a4f703 Fixed #3692; fixed "arrows should not catch fire in fire blocks" 2016-03-10 17:45:06 +08:00
8a0c2b7c4a Fixed time 2016-03-09 19:13:20 +08:00
8e909f05ca Fixed setSaturation() working incorrectly 2016-03-09 19:13:06 +08:00
27b7260c0a Merge branch 'master' of https://github.com/PocketMine/PocketMine-MP 2016-03-09 18:03:50 +08:00
dd22e4963f Fixed #4051 2016-03-09 18:02:35 +08:00
54254ffc88 Merge pull request #2955 from TruDan/master
Add DATA_SIZE to Slime!
2016-03-08 23:05:39 +08:00
9a3929d8ad Merge pull request #3724 from thebigsmileXD/patch-2
Fixed commit #3595
2016-03-07 18:58:01 +08:00
913a1fdce4 Fixed #3463 2016-03-07 18:56:24 +08:00
6e41e6837f Fixed #3266 2016-03-07 18:50:26 +08:00
df7eaa7242 Closes #3548 2016-03-07 18:48:27 +08:00
08e6caad88 Fixed #3563 2016-03-07 18:38:42 +08:00
fc08759199 Merge pull request #3978 from PEMapModder/attr
Implemented attributes
2016-03-07 18:15:15 +08:00
09ce8fab82 Fixed speed and slowness potions 2016-03-07 18:12:54 +08:00
781de3efab Addresses #4024 2016-03-06 23:13:33 +08:00
95abec1886 Merge pull request #4009 from Falkirks/patch-1
Update ISSUE_TEMPLATE.md
2016-03-02 01:31:47 +08:00
5e1f38bdb3 Update ISSUE_TEMPLATE.md 2016-03-01 08:42:46 -08:00
de10dfa737 Added issue template 2016-02-29 00:06:20 +01:00
a43db5ca25 fixed #4006 2016-02-28 22:54:56 +01:00
ccadb5f2bb Merge pull request #3526 from PEMapModder/patch-9
Fixed getNested() using cache desynchroinized from set()
2016-02-28 23:10:12 +08:00
218eed1e7a Merge pull request #3959 from dongjoon-hyun/show_travis_build_status
Show Travis-CI Build Status on README.md.
2016-02-28 10:29:29 +08:00
d39f3059dd Show Travis-CI Build Status on README.md.
For Github visitors, many projects shows its project build status in README.md.
It would be nice if PocketMine-MP shows Travis-CI build status, too.
Here is the sample layout in this PR branch.

https://github.com/dongjoon-hyun/PocketMine-MP/tree/show_travis_build_status

Signed-off-by: Dongjoon Hyun <dongjoon@apache.org>
2016-02-27 18:05:56 -08:00
2c1ef0ada3 Updated raklib module 2016-02-28 00:14:25 +01:00
e11b76318c fixing chunk sending 2016-02-27 16:35:38 +01:00
b766b969e2 Merge pull request #3387 from PEMapModder/patch-6
Allow saving resources with parent directory being recursively created
2016-02-27 20:52:03 +08:00
d6c9bcbabb Merge pull request #3993 from dongjoon-hyun/fix_travis_test
Fix Travis Test.
2016-02-27 19:40:53 +08:00
f00b52f04d Fix Travis Test. 2016-02-24 19:10:07 -08:00
Dan
35f0f36524 Update Grass.php
@PEMapModder is that all correct now?
2016-02-24 12:06:28 +01:00
e9eaf69a41 Removed redundant debug code 2016-02-23 22:33:53 +08:00
f34f54664f Merge branch 'master' of https://github.com/PocketMine/PocketMine-MP 2016-02-23 21:13:29 +08:00
7ba7eaf303 Fixed wrong InteractPacket constants
Thanks @thebigsmileXD
2016-02-23 21:05:59 +08:00
16c36d5a50 Updated TesterPlugin submodule 2016-02-23 13:36:03 +01:00
ad70e23659 Updated travis 2016-02-23 13:08:57 +01:00
ccb60ff81e update loop die 2016-02-23 18:25:04 +08:00
eb00dee8a6 removed int return from getSeed 2016-02-22 13:03:27 +01:00
068ad5e924 Added ACTION_JUMP
Thanks @thebigsmileXD
2016-02-22 19:41:30 +08:00
ed9888a2cb Fixed #3963, closes #3979, added hash for non-numeric seeds 2016-02-22 19:40:40 +08:00
41a847567c RandomSeed should be a TAG_Long 2016-02-22 18:42:49 +08:00
d59fd42fc6 Fixed EntityEatItemEvent::setResidue() declaration 2016-02-22 18:34:11 +08:00
86ec7ed771 Fixed player not dying 2016-02-22 18:24:51 +08:00
1574a823d4 Fixed #3864 2016-02-22 16:29:41 +08:00
17c73e9764 Fixed #3690 2016-02-22 16:26:35 +08:00
6945256e30 Resolved #3684 2016-02-22 16:05:45 +08:00
56644fed9d Fixed #3961 2016-02-22 15:42:44 +08:00
e2f7d657e8 Fixed trapdoors 2016-02-22 15:32:07 +08:00
83f29fd871 Fixed a crash 2016-02-22 15:06:45 +08:00
a2641f923d Merge branch master 2016-02-22 14:32:48 +08:00
36028679d8 Merge pull request #3956 from redcrab2016/redcrab2016-patch-1
PR: Bug Fix - Crash if player is spawn to Y coord. >0 & <1
2016-02-22 14:15:11 +08:00
542781c2b1 Merge branch 'php7-0.14-64ff00-01' of https://github.com/PurePlugins/PocketMine-MP 2016-02-22 01:11:55 -05:00
3640e13f17 Added some assertions for level seed 2016-02-21 22:46:44 -05:00
f98f180bbd fix for #3972 2016-02-21 22:21:50 +01:00
a6cd526e60 PHP7 to master 2016-02-21 12:47:30 +01:00
9acbd85b25 Bump version to 0.14.0.0 2016-02-19 13:39:42 +01:00
ffa835d730 Fixed #3557 2016-02-19 18:50:38 +08:00
80250aa78e Resolved 1️⃣ in #3961 2016-02-19 18:33:21 +08:00
675583293f Crash if player spawn back to Y coord. >0 & <1
The issue come from  line 2664 : $v = $spawn->floor()  
If $spawn->y is in ]0..1[ then $v->y == 0
Then getBlockId : line 2670 use  'y' as -1 => Crash boom
2016-02-18 10:54:54 +01:00
fc42fc534b Merge pull request #3952 from dongjoon-hyun/add_docs_for_throws
Add @throws docs.
2016-02-18 16:45:54 +08:00
302fb9e65e Add @throws docs.
Signed-off-by: Dongjoon Hyun <dongjoon@apache.org>
2016-02-17 14:22:47 -08:00
fe2957c315 Fixed imports 2016-02-18 01:43:42 +08:00
21c2e2d429 Closes #3832 2016-02-18 00:08:44 +08:00
3a184ddf97 Merge pull request #3915 from legoboy0215/patch-3 2016-02-18 00:05:10 +08:00
92ee4b3c73 Merge pull request #3876 from PEMapModder/patch-12
Add return value for PluginBase::saveDefaultConfig()
2016-02-17 20:33:15 +08:00
420007cef8 Merge remote-tracking branch 'origin/php7-0.14' into attr 2016-02-17 19:58:48 +08:00
5459576833 Added hunger and experience saving 2016-02-17 19:56:19 +08:00
05530bedc6 Bump to 0.14.0.7, new packets and fixes 2016-02-16 00:43:59 +01:00
1b4880a22f Merge branch 'patch-1' of https://github.com/Pub4Game/PocketMine-MP 2016-02-14 21:36:12 +08:00
a75c713d34 Merge pull request #3665 from zhsj/fix-start-sh
fix test php binary in start.sh
2016-02-14 21:30:02 +08:00
ef0f74bbd8 Merge pull request #3564 from PEMapModder/patch-11
Added additional information to Plugin::getDataFolder()
2016-02-14 16:09:45 +08:00
03c19aefbf Merge branch 'master' of https://github.com/PocketMine/PocketMine-MP 2016-02-12 14:09:39 +08:00
3b51d2c217 Resolved #3937 2016-02-12 14:08:59 +08:00
e79976bdac Added events 2016-02-11 22:07:04 +08:00
8807617480 Fixed attriutes not sending 2016-02-11 18:45:58 +08:00
cfca0a8726 Fixed TallGrass::getDrops() 2016-02-11 16:51:27 +08:00
28967ca495 Fixed eating 2016-02-11 15:42:07 +08:00
52e8781d36 Implemented hunger-related regen and damage 2016-02-11 01:53:51 +08:00
329a525ea1 Implemented food and hunger 2016-02-10 22:49:48 +08:00
d538a254ee Resolves #3918 2016-02-09 18:25:16 +08:00
074d7ed95c Resolve CompressBatchedTask-related crashes 2016-02-07 23:36:16 +09:00
1b6e8c14f0 Bump protocol version for 0.13.2 2016-02-06 22:01:26 +01:00
1082e32fd7 Fixed ShapedRecipe constructor 2016-02-07 01:02:40 +08:00
d5d2f46db2 Added "getter" for in air ticks. 2016-02-01 07:25:40 +08:00
e5937926cd Fix typo on ContainerSetSlotPacket
hotboar -> hotbar ![](http://i.imgur.com/n97uQb9.png)
2016-01-30 14:03:28 +01:00
e597314331 Read creative menu items from json 2016-01-28 04:39:30 +01:00
8a0bd85656 Item and Block, some wont work yet 2016-01-28 04:37:09 +01:00
b7d8956f23 Use ingredient damage to check inventory items on crafting event 2016-01-26 23:43:54 +01:00
bc3dca4736 Support for 0.14.0.1 2016-01-26 22:01:35 +01:00
d5f3c19054 Fix crafting not taking item from inventory 2016-01-25 23:10:18 +01:00
c7c78b1159 Read recipes from json 2016-01-25 20:40:26 +01:00
e2a400dd6b Fix for command alias arguments 2016-01-25 18:47:20 +01:00
99855773d7 Fix for command alias arguments 2016-01-24 18:33:34 +01:00
a2734f6dc0 Merged master into php7 to support 0.13.1 2016-01-22 17:36:45 +01:00
b66ce90c94 Add return value for PluginBase::saveDefaultConfig() 2016-01-16 11:39:11 +08:00
73b97c9490 fix sound error 2015-12-29 19:11:39 +03:00
ee0d4aa124 Merge pull request #3810 from markkrueg/markkrueg-patch-1
Fix Stair.php : add "use pocketmine\item\Tool;"
2015-12-28 17:42:26 +01:00
0b42ead2ab Update Stair.php to add use pocketmine\item\Tool;
Without this >= Tool::TIER_WOODEN does not work; so stone stairs do not give drops when broken. They also revert to not being broken on next connection.
2015-12-27 12:44:56 -08:00
78525e1f74 Seperated kick/ban messages 2015-12-22 21:26:26 +01:00
fb87165cd5 Merge branch 'PEMapModder-patch-12' 2015-12-20 00:41:03 +01:00
9f481fbdbe Merge branch 'patch-12' of https://github.com/PEMapModder/PocketMine-MP into PEMapModder-patch-12 2015-12-20 00:40:52 +01:00
7125148756 Merge branch 'MagicDroidX-patch-6' 2015-12-20 00:39:32 +01:00
9ca8c06f82 Merge branch 'patch-6' of https://github.com/MagicDroidX/PocketMine-MP into MagicDroidX-patch-6 2015-12-20 00:39:19 +01:00
32a0b61c2d Merge branch 'PEMapModder-patch-14' 2015-12-20 00:37:28 +01:00
15d6bf663d Merge branch 'patch-14' of https://github.com/PEMapModder/PocketMine-MP into PEMapModder-patch-14 2015-12-20 00:37:07 +01:00
d67fb9a721 Merge branch 'TrinityDevelopers-patch-1' 2015-12-20 00:32:07 +01:00
9ff58f6ab3 Merge branch 'patch-1' of https://github.com/TrinityDevelopers/PocketMine-MP into TrinityDevelopers-patch-1 2015-12-20 00:31:52 +01:00
b83964e527 Merge branch 'PEMapModder-patch-19' 2015-12-20 00:31:04 +01:00
c3e756a712 Merge branch 'patch-19' of https://github.com/PEMapModder/PocketMine-MP into PEMapModder-patch-19 2015-12-20 00:30:53 +01:00
55ce453e17 Merge branch 'Creeperface01-patch-11' 2015-12-20 00:30:15 +01:00
e4ab7a08ec Merge branch 'patch-11' of https://github.com/Creeperface01/PocketMine-MP into Creeperface01-patch-11 2015-12-20 00:28:50 +01:00
c1a484ee5c fixed #3702 and fix for setting timezone from php.ini 2015-12-19 23:58:05 +01:00
261ce1ba8b Merge branch 'mcpe-0.13' 2015-12-19 11:38:05 +01:00
90c3e66e6b Updated for .13.1. skinName replaces isSlim, API bump 2015-12-16 14:37:46 +01:00
7954754d4c Update Cake.php 2015-12-04 16:00:02 +01:00
2ddc4455c5 Added some blocks and items 2015-11-29 01:46:35 +01:00
c803dd8e69 skins fixed and added SetPlayerGameTypePacket 2015-11-26 00:47:58 +01:00
2e5490fb5b Merge pull request #3743 from hmy2001/patch-3
From TileEntityDataPacket in BlockEntityDataPacket
2015-11-25 17:05:16 +01:00
4f12533ad3 Update ChestInventory.php 2015-11-25 21:08:28 +09:00
8edebed11c Update DoubleChestInventory.php 2015-11-25 21:08:04 +09:00
963f7ee077 Update Spawnable.php 2015-11-25 21:00:03 +09:00
734736492a Added some creative items and removed nether reactor 2015-11-23 21:56:38 +01:00
58709293cf Fixed crafting 2015-11-23 21:04:23 +01:00
2ea81710ad Bump protocol and fixed packets for 0.13.0 2015-11-23 21:01:02 +01:00
Dan
f35db4a183 Fixed commit #3595
See https://github.com/PocketMine/PocketMine-MP/pull/3595
2015-11-20 13:01:28 +01:00
815411968b Silence the ifconfig not found message 2015-11-20 00:34:29 +08:00
cbed8d40ff Fix a mispelled "new" call 2015-11-05 17:11:42 -06:00
680d40d070 fix test php binary in start.sh 2015-11-01 20:47:41 +08:00
ea8ba995ac Update Player.php 2015-10-31 21:18:06 +08:00
6ae0f3c8d8 Cleaner (and maybe faster) INI parsing 2015-10-31 20:31:24 +08:00
4d5da41cd0 Fix autoSave in PlayerQuitEvent 2015-10-31 13:22:45 +08:00
f9d7e204c8 Block update on WallSign fix 2015-10-11 01:32:33 +02:00
94b79ac28a Tool tier added to getDrops 2015-10-11 00:52:44 +02:00
958c3589c9 Fix for #3569 NetherBrickFence 2015-10-10 23:40:59 +02:00
8ce02d8687 Hunger effect is not implemented 2015-10-10 23:30:42 +02:00
09b4d4dc7a Fixes for derps found with PHPStorm code inspector 2015-10-10 23:10:24 +02:00
813acc54dc Fixed translation for banlist command usage 2015-10-10 23:06:28 +02:00
c4fb469b4e Fixed recursive call 2015-10-10 05:26:01 +02:00
04fc062b2a Merge pull request #3568 from MagicDroidX/patch-3
Fixed recursive call
2015-10-08 07:40:58 +10:30
4e59d85cca Fixed recursive call 2015-10-07 17:04:27 +08:00
ae9a3dbd81 Added additional information to Plugin::getDataFolder() 2015-10-06 20:32:33 +08:00
84be56fefb edited TODO.md 2015-10-02 00:49:56 +02:00
19b2e1b4af sorted items in init() 2015-10-01 20:05:31 +02:00
cc8eca3084 Fixed string class conflict 2015-10-02 01:52:10 +08:00
6013213159 More items 2015-10-01 08:23:05 +02:00
a7413dac92 Merge branch with fixes for recipes 2015-09-30 18:14:51 +02:00
34df516d94 new branch to fix all issues with items and blocks 2015-09-30 18:09:09 +02:00
85dc136631 Crafting recipes, and packet fix 2015-09-29 00:45:57 +02:00
72e9765ec8 Merge branch 'Stonecutter-Recipes' of git://github.com/willowmaster66/PocketMine-MP into recipes-0.12-fix
Testing pull request.
2015-09-29 00:40:23 +02:00
cf3d8f449e Added some asserts 2015-09-27 19:48:42 +02:00
eaef40618b Send default reliable and ordered packets on RakNet 2015-09-27 19:48:31 +02:00
f560d07c97 Merge remote-tracking branch 'origin/mcpe-0.12' into php7 2015-09-27 14:31:28 +02:00
606948ef8e Fixed return value of Level::getTickRateTime() 2015-09-27 14:31:15 +02:00
46760abafc Require pthreads 3.0.7 2015-09-27 14:30:50 +02:00
a7e5e33db8 Merge pull request #3507 from alejandroliu/crafting-event
Added Player to CraftItemEvent
2015-09-27 14:05:38 +02:00
ddc140af5e Updated to new pthreads version, updated RakLib 2015-09-27 13:37:27 +02:00
a3ad5783b7 Fixed getNested() using cache desynchroinized from set() 2015-09-26 12:21:43 +08:00
cbef0e25a1 Merge pull request #3454 from Yosshi999/master
Fixed DoorSound won't be played
2015-09-25 10:01:15 +02:00
6273875a22 Added Player to CraftItemEvent 2015-09-19 23:08:57 +02:00
0b9ef5b856 Update of the stonecutter recipes
Added the shaped recipes and removed the shapeless ones.
2015-09-18 22:18:14 +02:00
a3bce67d35 Updating blocks and items
Added new blocks/items and added constants to existing blocks/items for
clearer recipe making.
2015-09-18 22:17:24 +02:00
cd6afb2020 Merge remote-tracking branch 'PocketMine/mcpe-0.12' into Stonecutter-Recipes 2015-09-18 22:14:34 +02:00
0bcf639a98 Changed how exceptions work and are logged, throw proper exceptions on tasks 2015-09-18 12:03:24 +02:00
472fcfa4c7 Removed ThreadedFactory 2015-09-18 11:18:41 +02:00
8768b7fdbd Merge remote-tracking branch 'origin/mcpe-0.12' into php7 2015-09-17 12:25:05 +02:00
86c1198648 Merge pull request #3495 from 0929hitoshi/mcpe-0.12
Changing the return value of getName
2015-09-17 09:47:30 +02:00
9665dfd63e Changing the return value of getName 2015-09-16 01:21:07 +09:00
ed559fdf98 Fixed not sending UUIDs properly 2015-09-15 12:23:15 +02:00
24f8de2cc3 Bad hack, TODO REMOVE, workarounds client bug by sending inventory contents specifically for creative players <-- this commit is full of sadness 2015-09-14 20:25:57 +02:00
885fc07e5c Merge pull request #3481 from LouisBHirst/patch-getOnlinePlayers
getOnlinePlayers() only returns the players already connected
2015-09-13 21:01:51 +02:00
3892d5d74f Removed call to detach 2015-09-13 17:56:21 +02:00
c7b915639d getOnlinePlayers() only returns the players already connected 2015-09-13 11:43:51 -04:00
21c3d03000 Removed sleep from ServerKiller 2015-09-13 17:38:55 +02:00
2d1b2050dc Merge remote-tracking branch 'origin/mcpe-0.12' into php7 2015-09-12 17:10:45 +02:00
3ffdb8e552 Removed @deprecated classes, methods and properties, added some type hints 2015-09-12 17:10:11 +02:00
79aa7583ec Merge pull request #3471 from PEMapModder/patch-7
Update Player.php
2015-09-12 15:16:10 +02:00
0d6f13cb4f Update Player.php 2015-09-12 20:53:35 +08:00
29a5012c02 Merge remote-tracking branch 'origin/mcpe-0.12' into php7 2015-09-12 01:03:09 +02:00
a1a1327415 Removed signed parameter in BinaryStream->getShort() in favor of getSignedShort() 2015-09-12 00:57:09 +02:00
16ff2d99b0 Merge remote-tracking branch 'origin/master' into mcpe-0.12 2015-09-11 17:34:11 +02:00
cb222601fd Haters gonna hate, also fix misleading interface default parameter 2015-09-11 16:50:57 +02:00
922e9d93d5 Moved exception handler to a big try catch 2015-09-11 09:09:45 +02:00
e137ac4c56 Base PHP7 work to make it "run" - READ NEXT LINES!
All plugins will need to bump the API if they want to use this.
NOTE THAT THIS IS NOT THE FINAL API 2.0.0 AND THAT THERE WILL BE MORE CHANGES.
To start updating, you might also want to read https://secure.php.net/manual/en/migration70.php and specifically https://secure.php.net/manual/en/migration70.incompatible.php

To compile PHP7 with some of the required dependencies, use https://gist.github.com/shoghicp/166ab26ce5cc7a390f45
ONLY LINUX IS TESTED, DO NOT ASK FOR OTHER PLATFORMS!

----- THIS VERSION IS NOT SUPPORTED -----

This version WILL crash randomly in unexpected places due to PHP7, pthreads, PocketMine or cosmic rays.

Handle with care, and store under direct sunlight for the best performance.
2015-09-10 21:29:29 +02:00
9501d03552 FIxed a bug No sound for TrapDoor
missing "use pocketmine\level\sound\DoorSound;"
2015-09-06 22:59:02 +09:00
ccca3ec0bf FIxed a bug No sound for FenceGate
missing "use pocketmine\level\sound\DoorSound;"
2015-09-06 22:55:56 +09:00
8f24306d65 Merge remote-tracking branch 'origin/master' into mcpe-0.12 2015-09-05 18:22:28 +02:00
59a775f82c Merge pull request #3448 from willowmaster66/willowmaster66-patch-4
First item in the hotbar is not loaded correctly
2015-09-05 18:19:45 +02:00
5baa87e9fe First item in the hotbar is not loaded correctly
When you logon the first hotbar item contains the first item of the inventory, but it should contain the previously selected item.
2015-09-04 23:40:19 +02:00
bdf5c46793 Merge branch 'master' into mcpe-0.12 2015-08-31 17:51:07 +02:00
4bd14e7424 Revert commit that removed useful parameter for plugins that made backwards-incompatible changes
Revert "@PEMapModder Removed redundant parameters for Living::knockBack. Closes #3427."

This reverts commit 9adcc19154.
2015-08-31 17:48:52 +02:00
a18826473b Added enderman teleport sound 2015-08-31 17:48:28 +02:00
9adcc19154 @PEMapModder Removed redundant parameters for Living::knockBack. Closes #3427. 2015-08-31 22:05:49 +09:30
66b86c3685 Merge pull request #3423 from willowmaster66/willowmaster66-patch-1
Block cache not cleared with a call to clearcache
2015-08-31 21:43:03 +09:30
7d18b92ea1 Merge pull request #3426 from PEMapModder/patch-7
Remove unused parameter in Level::requestChunk
2015-08-30 02:56:26 +09:30
0348d181d4 Remove unused parameter in Level::requestChunk 2015-08-29 18:03:40 +08:00
0b9b1738b3 Block cache not cleared with a call to clearcache
While trying to figure out Github and looking for a different bug I found this small bug in the code. The ClearCache function on Level.php did not correctly clear the blockcache.
2015-08-27 10:44:44 +02:00
244cef3b00 . <-- descriptive commit ftw! 2015-08-23 00:25:30 +02:00
b47cebb1d5 PHP7 changes 2015-08-23 00:25:30 +02:00
7f8b39a63c Renamed NBT tags to have Tag in the name 2015-08-23 00:25:29 +02:00
34dc6ea0d6 NOTE! THIS SHOULD BE REVERTED LATER! Removed WeakRef dependency 2015-08-23 00:25:29 +02:00
d7d05c20a9 Bumped to API 2.0.0 2015-08-23 00:25:29 +02:00
91bda131be Merge pull request #3395 from luca28pet/patch-1
Spelling fix
2015-08-22 23:37:23 +02:00
1a9ec65983 Spelling fix 2015-08-22 15:58:45 +02:00
4e0fc6d1de Allow saving resources with parent directory being recursively created 2015-08-18 10:20:04 +08:00
fabb632286 More changes! 2015-08-13 18:02:10 +02:00
99df6f8edc Updated language 2015-08-13 09:17:43 +02:00
6e2ea63ce1 Merge remote-tracking branch 'origin/master' into mcpe-0.12 2015-08-12 15:00:04 +02:00
31ef7721b1 Removed network channels, bumped protocol 2015-08-12 14:59:48 +02:00
f1cc8ddde4 Merge pull request #3372 from SuperMarcus/patch-2
Fix wrong id passed to constructer in CookedFish.php
2015-08-11 19:57:33 +02:00
25b9946d9e Fix wrong id passed to constructer in CookedFish.php 2015-08-11 23:06:40 +08:00
5a626405e3 Merge pull request #3368 from thebigsmileXD/patch-2
Added sound for opening/closing (FenceGates)
2015-08-11 12:58:34 +02:00
311d8d94dd Added sound for opening/closing (FenceGates)
Added DoorSound on opening/closing FenceGates depending on #3367 @0929hitoshi 's Idea
2015-08-11 12:48:41 +02:00
7d0810a5af Merge pull request #3367 from thebigsmileXD/patch-1
Added opening/closing sound
2015-08-11 12:27:18 +02:00
a5efd0bdf8 Added opening sound 2015-08-11 11:52:08 +02:00
ff232a9f04 Merge pull request #3332 from PEMapModder/dec
Disallow registration of events without handlerList, fixes #3330
2015-08-11 16:12:59 +09:30
8889e687c9 Changed TextPacket 2015-08-10 23:40:14 +02:00
0f993f8beb setDisplayName skin fix 2015-08-10 16:33:27 +02:00
d5c2702908 Update PluginManager.php 2015-08-10 22:14:11 +08:00
62848b914d Fixed String values on NBT parsing 2015-08-10 15:09:23 +02:00
0ce343d8ca Fixed escaping values in NBT parser 2015-08-09 13:52:15 +02:00
534b988a1c Added basic Nether generator 2015-08-09 00:38:23 +02:00
a9ead5567b Improved NBT json parsing, attribute base 2015-08-08 22:39:43 +02:00
f5429ef585 Merge remote-tracking branch 'origin/master' into mcpe-0.12 2015-08-08 16:50:37 +02:00
d729961bde Merge pull request #3331 from PEMapModder/patch-5
Fixes #3330
2015-08-09 00:12:35 +09:30
f093a6498d Added base enchantment adding utilities, /enchant command 2015-08-08 16:03:04 +02:00
4dd0469792 Base enchantment class 2015-08-08 14:53:03 +02:00
fe196c6404 Added display of names on death 2015-08-08 13:35:57 +02:00
fdf10b60dc Added PlayerToggleSneakEVent and PlayerToggleSprintEvent 2015-08-08 13:10:59 +02:00
d4163ea01c Added sneaking, sprinting 2015-08-08 13:02:59 +02:00
b3efb733a2 Improved block breaking timing, added faster block breaking with swords 2015-08-08 00:33:52 +02:00
fcba9596d6 Added CanDestroy and Lock tag 2015-08-07 22:20:01 +02:00
01d93d6e10 Added CanPlaceOn tag 2015-08-07 22:13:52 +02:00
1fa467eb58 Proper recipe ingredient matching, fixed crafting type resetting 2015-08-07 22:00:35 +02:00
3e2cce3c2c use cleanup 2015-08-07 21:26:24 +02:00
d026e2ecf0 Implemented new crafting mechanism 2015-08-07 21:26:12 +02:00
696edfd31f Added custom block data (example, chests), better deep checking of same NBT 2015-08-07 17:24:35 +02:00
e9c981b586 Updated lang 2015-08-07 16:28:49 +02:00
75b7b03857 Added support for more NBT data, renaming inventories, fixed tags not being saved, added support for tags in /give 2015-08-07 16:28:27 +02:00
d1bfb304cb Added some extra tile entities, fake enchanting table 2015-08-07 12:07:39 +02:00
cba9ff393c Fixed properties for NBT, fixed dropping items removing extra data set 2015-08-06 21:51:39 +02:00
02cb9d69a9 Save items properly on several places, added NBT::getItemHelper() and NBT::putItemHelper() 2015-08-06 21:44:00 +02:00
554bfb4855 Added methods for adding custom names directly to items 2015-08-06 21:09:37 +02:00
091d0b3ff9 Added compound tag checking for Item->equals() 2015-08-06 20:25:22 +02:00
a65109ff34 Oh well that fixes block placing 2015-08-06 17:47:17 +02:00
8a3c5ab6a1 Removed DropItemPacket field 2015-08-06 16:26:38 +02:00
2cec6812a8 Added extra data printing for Items, non-automatic bytearray on NBT 2015-08-06 14:51:41 +02:00
d0bfc826ea Updated protocol details, anvil menu creation 2015-08-06 11:51:41 +02:00
2e0ef645fa Fixed several issues with spawning/despawning Players/Humans, close #3345, close #3342 2015-08-05 13:40:11 +02:00
09720a2d90 Properly implemented Shaped recipes on Network and manager, no crafting! 2015-08-04 21:59:54 +02:00
9456e20770 Added support for extra data, improved BinaryStream 2015-08-04 18:29:13 +02:00
7fd053fb09 More changes! Alsp added Anvil block and BinaryStream 2015-08-03 18:04:13 +02:00
522932d7c0 Added new sounds, events, particles 2015-08-03 12:42:47 +02:00
2b2a1b18e7 Updated RakLib protocol 2015-08-03 10:54:24 +02:00
1b812d373c Updated protocol packet ids 2015-08-03 10:53:23 +02:00
5621ab0c49 Updated some packets for 0.12, UUIDs, other stuff! 2015-08-02 01:22:36 +02:00
4258e22c02 Made some changes for 0.12 2015-08-01 19:14:44 +02:00
ff16f2ef05 Disallow registration of events without handlerList 2015-07-29 21:47:39 -04:00
9bbaf5d00d Possible workaround with #3330
Filters away non-public event handlers
2015-07-30 09:21:35 +08:00
0380e9009a Added block break tool type, fixed falling sand, fixed duplicated jungle leaves 2015-07-27 20:31:55 +02:00
866fde5351 Improved speed of some int arrays, fixed block metadata 2015-07-27 20:31:55 +02:00
9f953fa675 Fixed #3232 2015-07-27 20:31:55 +02:00
4d95c65d95 Changed TIER_IRON to TIER_STONE 2015-07-27 20:31:55 +02:00
26c9eed82e Added all block hardness 2015-07-27 20:31:55 +02:00
f3c46b12c5 Block breaking part 1 2015-07-27 20:31:55 +02:00
b14d14d3d5 Merge pull request #3305 from SuperMarcus/patch-1
Fix wrong size increasing code.
2015-07-24 09:19:55 +02:00
60ab35774a Fix wrong size increasing code. 2015-07-24 15:14:17 +08:00
2df901b064 Merge pull request #3274 from SopaXorzTaker/patch-1
Update Utils.php #2
2015-07-17 06:44:15 +09:30
0c09361c46 Added main-hard-limit memory property similar to old memory-limit, use less memory on startup (RakLib) 2015-07-11 13:16:39 +02:00
1ebf2476df Merge pull request #3245 from alejandroliu/lastPlayed-fix
Fixes lastPlayed
2015-07-03 08:33:42 +02:00
fe85b5026d Fixes lastPlayed 2015-07-02 00:54:20 +02:00
bfd3fb6636 Merge pull request #3199 from alejandroliu/tile-fix-teleport-glitch-new
Teleport glitch fix
2015-06-20 09:48:08 +02:00
0723112207 Once again... 2015-06-19 21:06:15 +02:00
be9f5521e1 Fixed undefined index on async worker crash 2015-06-19 18:36:08 +02:00
6063738e69 Fixed setting inventory index after new entity id 0 for players 2015-06-19 17:14:09 +02:00
ef738ef299 Fixed effect entity id 2015-06-19 15:34:33 +02:00
5796784442 Stop calculating permissions on closed Players 2015-06-19 14:52:08 +02:00
a1cc60d472 Fixed eye height 2015-06-19 14:49:41 +02:00
f7ec1de0fd Players now have entity id 0 2015-06-19 14:40:05 +02:00
b856e5e909 Fixed #3093 2015-06-19 13:42:20 +02:00
f7e6246dc2 Destroy cycles that reference player for faster collection 2015-06-19 13:31:29 +02:00
b166628940 Added ability to dump memory 2015-06-19 13:01:49 +02:00
4e76c30788 Update Utils.php
Correct a typo
2015-06-17 08:39:18 +03:00
33e312c7d0 Added extra memory reportings (heap, stack), stop tasks faster, added extra timeouts fro ServerKiller 2015-06-13 15:37:02 +02:00
2ac27bd382 Improved safe spawn calculation, fixes #3094 2015-06-13 14:43:14 +02:00
f490ff8074 Added mossy stone brick recipe, added chiseled stone brick recipe, added cracked stone brick furnace recipe, fixed crafting stone bricks, fixed crafting stone brick slabs, closes #3161, fixes #3160 2015-06-13 13:45:05 +02:00
eeef81e2b1 Fixed #3154 2015-06-10 10:10:07 +02:00
4a8ca96aaa Skip getting bigger bounding boxes on higher tick rates 2015-06-09 18:24:17 +02:00
eef33d64e6 Fixed new players having air ticks to 0 instead of 300 2015-06-09 15:26:28 +02:00
7cf5df7e46 New console output formatting 2015-06-09 14:40:40 +02:00
ac2bcf7e30 Made /list output similar to PC output 2015-06-09 12:21:00 +02:00
ec226105e4 Added support for overriding properties over the command line 2015-06-09 11:23:57 +02:00
2a1a09a923 Create chunks in case of dropping items outside of world boundaries 2015-06-09 09:45:40 +02:00
20911930cf Fixed bad permission nodes on /kill, closes #3139 2015-06-09 09:45:10 +02:00
2eaa12005e Changed knockback process 2015-06-08 15:52:57 +02:00
fdcddcc04b Fix entity unloading after teleporting, closes #3136 2015-06-08 15:02:00 +02:00
4fd5e9ba7d Improved RakNet encapsulated packet encoding 2015-06-08 12:45:52 +02:00
7b17bf416e Fixed Arrows not hitting entities, added new movement system 2015-06-07 21:08:46 +02:00
d0f743a99e Fixed /time add message, chunk tick reset default 2015-06-07 20:15:30 +02:00
cbb1c55a06 Improved biome generation, get grass color from gradient interpolation, improved performance of generation, try to recreate grass colors from imported chunks, closes #2845, closes #1792 2015-06-07 15:17:02 +02:00
d881dbf1a2 Only spawn break particles when needed 2015-06-07 12:33:53 +02:00
383fcba8e1 Fixed skins issue 2015-06-07 12:17:27 +02:00
e5f28e0f7a Throw exception on invalid parameters on Inventory addItem() and removeItem() 2015-06-07 12:05:10 +02:00
cf3f32fdae Added Script plugin loader 2015-06-06 23:09:54 +02:00
c4bdbc5443 Report players as EntityPlayer all the time 2015-06-06 23:09:43 +02:00
62a8f58bb0 Improved block and chunk cache, fixed PlayerQuitEvent player save 2015-06-06 20:28:37 +02:00
f21ed39c1c Improved timing reports 2015-06-06 19:07:12 +02:00
b358a2e474 Fixed underscores >.< 2015-06-06 18:12:39 +02:00
21c6eeef11 Fixed A-Z range 2015-06-06 17:57:07 +02:00
96f67bdadf Added auto save to PlayerQuitEvent 2015-06-06 17:56:36 +02:00
6ee61cce7b Faster player login 2015-06-06 17:38:32 +02:00
7f6704f761 Chunk ticking depends on chunk loaders, fixes #3118 2015-06-06 17:38:10 +02:00
9e4d88a852 New extended packet timings 2015-06-06 16:58:49 +02:00
5682026eae Fixed state corruption for auto saving 2015-06-06 15:53:28 +02:00
2a805dc0ed Limited chat and sign length using UTF-8 2015-06-05 17:08:24 +02:00
bdb9b1865b Added exception when unloading the default level without switching it first, #3112 2015-06-05 16:48:27 +02:00
1e03c5b795 Workaround for players getting stuck on far chunks 2015-06-05 16:48:27 +02:00
ec82434ef4 Added charcoal for torches, improved recipe matching for wildcards, closes #3108 2015-06-05 16:48:27 +02:00
7bafa217c8 Fixed some saving 2015-06-05 16:46:53 +02:00
fe55023761 Better Terminal detection 2015-06-05 14:07:32 +02:00
ac4194eb3f Added lily pad, checked some bounding boxes 2015-06-05 13:58:59 +02:00
6e69e15dfd Moved network check out of level, added server killer for long stops 2015-06-05 11:46:33 +02:00
a53b041984 Improved region save and saving of chunks before population 2015-06-05 02:27:37 +02:00
d542dfc2ce Split player into more methods, added extra timings 2015-06-05 00:19:45 +02:00
188f4d7778 Clear chunk cache on tile change 2015-06-04 17:36:12 +02:00
71490f60f2 Fixed other invisibility issues 2015-06-04 16:51:48 +02:00
05dbf7b47f Fixed some corrupted states, probably fixed most invisible players cases 2015-06-04 15:46:57 +02:00
14ff537e71 Improved damage sources for projectiles, falling blocks, TNT, and items 2015-05-31 14:19:47 +02:00
9e14435dbb Moved network ids to constants, improved some entity methods, more performance 2015-05-30 23:59:24 +02:00
32680843fa Added multisize loading 2015-05-30 19:38:57 +02:00
9768bf4f8a Added BlockBreakEvent::getDrops() and BlockBreakEvent::setDrops(Item[] $drops) 2015-05-30 18:26:47 +02:00
7c806c7920 Added missing brace 2015-05-30 17:29:38 +02:00
b61c54c9cb Send motion to players on downwards movement 2015-05-30 17:16:12 +02:00
a349f6d4dd Merge pull request #3083 from PEMapModder/patch-5
Added Location::fromObject(Vector3, Level, yaw, pitch)
2015-05-30 17:11:40 +02:00
9541c9751b Merge pull request #3087 from PEMapModder/patch-6
Block break optimization
2015-05-30 17:09:36 +02:00
3c0efe9af2 Block break optimization 2015-05-30 22:20:05 +08:00
24c1e6880d Added Location::fromObject(Vector3, Level, yaw, pitch) 2015-05-30 12:46:40 +08:00
74917923b6 Improved checks, area collision checks, etc 2015-05-29 15:13:19 +02:00
f20d5b2c69 Fixed MainLogger 2015-05-29 11:38:18 +02:00
eaa42f8449 Workaround for bad calls to teleport, closes #3074 2015-05-29 10:17:27 +02:00
1e2038fac5 Faster respawn when needed 2015-05-29 10:04:56 +02:00
c8abbf4f2f Added Snowballs to the creative inventory 2015-05-29 10:04:31 +02:00
009a3b657f Merge pull request #3076 from xpyctum/patch-1
Torches didn't craft
2015-05-29 08:27:24 +02:00
5b57fe6967 Update CraftingManager.php
Torch can't crafting
2015-05-29 10:30:20 +05:00
f133154919 New chunk ordering algorithm 2015-05-29 00:35:40 +02:00
8d4decc548 Fixed bad vector initialization 2015-05-28 23:58:29 +02:00
3bb037204e light population is now optional via pocketmine.yml 2015-05-28 23:39:09 +02:00
c578898aa4 Moved light population to an async task when needed, improved empty chunks 2015-05-28 23:34:07 +02:00
0f5f71e612 Forgot to check chunks after moving 2015-05-28 22:55:09 +02:00
75cab3dfc3 Improved updates after first tick 2015-05-28 22:43:39 +02:00
03f178379e Fixed items getting corrupted pickup delay, not being able to be killed by other damage sources 2015-05-28 22:17:12 +02:00
ce59703dd0 Merge pull request #3072 from alejandroliu/Kill-entity-bug
Fixes bug #3071
2015-05-28 17:34:38 +02:00
a77d82ac81 Changed how creator tag works on signs 2015-05-28 16:44:31 +02:00
1833da01fe oops 2015-05-28 15:16:09 +02:00
c97e1fdce0 Made Player::close() final, fixes several plugin issues that crashed the server 2015-05-28 15:03:45 +02:00
0e9bff6f4e Fixed armor not being sent correctly to current player, fixes #3073 2015-05-28 14:28:23 +02:00
3dd4fe706c Changed Vector3 floor() and ceil() 2015-05-28 14:20:50 +02:00
9a2170d296 protocol 27, added player spawn events after death from new protocol, added EntityEvent constants 2015-05-28 14:19:00 +02:00
8a41512194 Fixes bug #3071 2015-05-28 00:44:16 +02:00
51062940c5 Implemented QueryRegenerateEvent as base for other interfaces 2015-05-26 01:17:34 +02:00
66435d4f6a Workaround client-sede issue, remove this when fixed 2015-05-24 10:16:43 +02:00
c4d63326be Fixed fix for flowers, removed corrupted flower state, added proper identifiers that do not collide, added remaining IDs everywhere for consistency, removed magic number for constants, closes #3058 2015-05-23 22:49:06 +02:00
f91a3a2666 Fixed invalid fix for block updates that corrupted state 2015-05-23 22:47:46 +02:00
d429992f5b Fix Fallable not dropping after explosion, Fixes #2735, Fixes #2806.
Signed-off-by: Michael Yoo <michael@yoo.id.au>
2015-05-23 22:36:23 +09:30
76c27fc18b Use broadcast permission to broadcast tips and popups 2015-05-23 22:05:48 +09:30
a0f8bc15dc Fix small whitespace issues, make broadcasts return count() as specified in PHPDoc 2015-05-23 22:05:48 +09:30
adc5aa11ac Added Server->broadcastTip() and Server->broadcastPopup()
Signed-off-by: Michael Yoo <michael@yoo.id.au>
2015-05-23 22:05:48 +09:30
388f5c2c91 Added flowers compatible with MCPE 0.11.
Signed-off-by: Michael Yoo <michael@yoo.id.au>
2015-05-23 21:57:59 +09:30
f64caf6c96 Use best method to create identifier on linux 2015-05-23 14:10:42 +02:00
b2b4cf788c Fixed possible channel order issue with chunks and start game packet 2015-05-23 13:38:50 +02:00
d7be531868 Limit amount of messages per tick per player to 2 2015-05-23 12:09:26 +02:00
5ad4f44dce Fixes sending newlines on messages to impersonate chat messages 2015-05-23 12:03:47 +02:00
7201372b0d oops 2015-05-23 12:02:20 +02:00
744ea6af8f Fixed #3023 2015-05-23 11:47:07 +02:00
1da0a48edb Fixed #3055 2015-05-23 11:37:48 +02:00
be6b0656a0 Do async saving only when needed 2015-05-23 10:54:15 +02:00
4f7aac50d3 build 13 2015-05-22 16:46:23 +02:00
149234f125 Added asynchronous file writing 2015-05-22 16:32:08 +02:00
cfe5ca91b2 Updated endpoint 2015-05-21 16:31:42 +02:00
46f20d36b3 Improved unique id generation for server 2015-05-21 12:59:33 +02:00
cde2d39029 New statistics system 2015-05-21 11:41:11 +02:00
36ddbf286d Build 12, added SILENT flag to entities, closes #3052 2015-05-21 11:40:51 +02:00
8d4abe2f39 Improved world loading, added chunk queue delay, closes #3046 2015-05-20 11:05:35 +02:00
32722856ea Updated FloatingTextParticle to use less heavy method 2015-05-19 21:59:23 +02:00
7753b1d8be Fixed items (and other entities) vibrating, bad offsets in tile calculation 2015-05-19 21:29:30 +02:00
92a2be024a Improved saving of modified properties 2015-05-19 20:49:47 +02:00
66f28f6dc4 Fixes #3042 2015-05-19 17:48:35 +02:00
1122a3c511 More undefined variables D: 2015-05-19 16:02:59 +02:00
0c6d8b9815 Fixed loader counter on Level, closes #1147 2015-05-19 14:49:18 +02:00
70a7c4c552 Added nametag saving 2015-05-18 19:04:37 +02:00
840690d801 Replaced old deprecated calls 2015-05-18 15:52:31 +02:00
f3a53be117 Moved Human->setNameTag() to Entity 2015-05-18 15:29:31 +02:00
ea7c0cb357 Removed debug code 2015-05-18 14:00:21 +02:00
85c43ba011 Allow setting nametag for any kind of entity 2015-05-18 13:08:06 +02:00
fbbe02a3bc Fixed some issues related to new indexes 2015-05-16 22:36:55 +02:00
fb05636694 Fixed Item vibration 2015-05-16 21:38:10 +02:00
63a5269313 Added settings.profile-report-trigger to only extract timings on a given tps rate 2015-05-16 16:02:32 +02:00
7705d8c52f Updated translations 2015-05-16 15:49:08 +02:00
419abdaad6 Proper chunk unloading in case of generation/loading without players 2015-05-16 15:43:34 +02:00
d6ebff412c Added ChunkLoader interface 2015-05-16 15:28:31 +02:00
7a34417e67 Kill player below -16 as now the bottom of the world can be rendered, send player count 2015-05-15 16:51:20 +02:00
76e6ccebd5 Proper recipe matching from network, bumped protocol, build 11, fixed entities not being killed on void (closes #3021), fixes achievement acquireIron not being possible (fixes #2600) 2015-05-15 13:59:29 +02:00
e61db8ad06 Added login timeout for players that do not complete the login process in time 2015-05-14 14:52:39 +02:00
b1edfd7631 Improved Falling blocks physics, entity kill, chunk unserialize, fixed flat generator color, fixed nbt tags __toString(), fixed explosion offsets, fixed increased player interaction range in creative 2015-05-13 12:18:59 +02:00
f3bdef7513 Fixed Anvil chunks not having NBT set 2015-05-12 16:52:11 +02:00
9791071262 Added Player->teleportImmediate() for tp force 2015-05-12 00:21:02 +02:00
aa38a4885f Fixed some issues with world generation and not creating chunks, closes #3008 2015-05-11 23:53:01 +02:00
de0f653027 build 10, improved levelDB constants 2015-05-11 20:31:28 +02:00
13906b32b8 Check connection status on batch, check sleep when players leave a level 2015-05-10 14:58:07 +02:00
925b0c1b07 Fixed empty chunks on generation, closes #2998 2015-05-10 13:18:39 +02:00
db409851e9 World generation is timed by type and chunks can be created on the fly 2015-05-09 19:03:41 +02:00
ab18b7833f Fixed light population happening before population 2015-05-09 16:37:34 +02:00
1a1b8830a4 Added MemoryManager object watcher for object leak debugging, improved SPL Thread/Worker stopping, fixed some possible weak references crashing unexpectedly 2015-05-09 16:11:12 +02:00
7e539ec85a Fixed invalid check 2015-05-08 15:38:51 +02:00
563f6f8e4f Interaction checks happen using the plane and not 3d space 2015-05-07 15:38:22 +02:00
82b0dbfe8e Improved /status, added world information 2015-05-06 19:11:47 +02:00
a4769248fb Set nextTick on start 2015-05-06 19:11:47 +02:00
fb03df3d06 Calculate skylight on chunk population 2015-05-06 16:57:49 +02:00
44b5c23ee1 Fixed dead entities and Item picking, improved timing reports 2015-05-06 16:21:35 +02:00
bff51322af Merge pull request #2986 from 64FF00/master
Fixed /tell command not displaying the sender's name correctly (aka "I'm Bored x3")
2015-05-05 14:27:49 +02:00
cc58d96071 Fixed /tell command not displaying the sender's name correctly 2015-05-05 19:59:12 +09:00
001915fcd6 beta build 9 2015-05-04 17:58:29 +02:00
cd607b0cec Oops distance 2015-05-04 17:57:03 +02:00
5ec4b3f46f "Fixed" #2982 2015-05-04 17:53:48 +02:00
d9a9808844 Added interaction and 3rd person cheat protection 2015-05-04 17:52:55 +02:00
f718d06a7d Updated RakLib, tick inside thread instead of depending on main thread 2015-05-03 23:40:36 +02:00
563f7404fe Time less than target fix 2015-05-03 23:20:40 +02:00
0ddf396b08 Use time_sleep_until() instead of usleep(), improved thread kill 2015-05-03 23:17:39 +02:00
d830386786 Changed default async compression 2015-05-03 22:14:57 +02:00
49f34ec524 Send spawn position after respawn on death, fixes #2976 2015-05-03 21:46:46 +02:00
9ec609d025 Improved Player flight detection after setMotion(), other method improvement 2015-05-03 13:42:54 +02:00
0ead3ec781 Changed round/floor to floor on BlockIterator 2015-05-02 17:38:45 +02:00
fdf395721e Improvements on player move updates 2015-05-01 15:09:37 +02:00
211e1ae121 Fixed slots on creative 2015-04-30 17:51:04 +02:00
923be2fffc Improved slot selection on creative mode, closes #2960 2015-04-30 12:53:03 +02:00
fb257c16f1 Set entities on fire if hit by an entity on fire 2015-04-30 11:40:22 +02:00
b33706d427 Merge pull request #2959 from LDX-MCPE/patch-1
fixed typo
2015-04-30 08:34:57 +02:00
LDX
6bcb319fb5 fixed typo 2015-04-29 23:12:22 -04:00
d4b2e3d1b7 Improved heightmap generation 2015-04-29 23:19:27 +02:00
7754aa71a3 Fixed end of regex on Config 2015-04-29 21:09:35 +02:00
978aa2ba0f Protocol changes 2015-04-29 17:04:34 +02:00
f74f5cfde7 Add DATA_SIZE to Slime! 2015-04-29 15:55:11 +01:00
c2b3f7cd7f Noclip in spectator mode, changed chunk format 2015-04-29 12:29:59 +02:00
3872a21474 Allow setting the flying status for any given player 2015-04-29 11:31:04 +02:00
11e2d23b83 Improved LoginPacket and BatchPacket handling 2015-04-29 10:55:29 +02:00
2cd78d4ae3 Merge pull request #2951 from EnderBrine101/patch-1
No longer needed :P
2015-04-28 18:52:21 +02:00
08f09cc3c8 No longer needed :P 2015-04-28 17:34:38 +01:00
1b13a4c1ec Protocol 25 2015-04-28 16:56:59 +02:00
71587db2be Merge branch 'master' of github.com:PocketMine/PocketMine-MP 2015-04-28 14:49:52 +02:00
8caf04ade5 build 8, allow setting selected hotbar slot, auto_jump setting 2015-04-28 14:20:35 +02:00
488fbc27fe Fixed issue reading/writing YAML 2015-04-27 21:26:50 +02:00
84d1f4596b Improved Anvil live conversion speed 2015-04-27 14:43:33 +02:00
6fc7ee2775 Fixed some bad defaults, improved spawning 2015-04-27 14:43:33 +02:00
ef00103fec Merge pull request #2944 from alejandroliu/generator-list
Added a getGeneratorList
2015-04-27 09:53:50 +02:00
bdf069ebe1 Added a getGeneratorList 2015-04-27 01:18:04 +02:00
5942cafa53 Send in the correct channel 2015-04-26 23:11:07 +02:00
fbdbac06cc New delayed teleporting system 2015-04-26 23:04:24 +02:00
fba12f2a13 Be sure that AsyncTask finish executing, fixes #2931 2015-04-25 17:52:57 +02:00
7ad98d4659 Deprecated CallbackTask, moved sleep checking to level 2015-04-25 17:28:30 +02:00
1d8c29add7 Fixed Block Iterator and getLineOfSight() 2015-04-24 18:10:45 +02:00
d4cae729c3 Added AsyncTasks timings 2015-04-24 17:21:39 +02:00
529f9b148b Save/reload skin on Human based entities 2015-04-24 17:05:00 +02:00
20842636f9 Added timings to chunk sending 2015-04-24 16:59:46 +02:00
7b699d9afd Improved fall damage while on jump boost, new protocol update, build 7, allow for live inventory resizing 2015-04-24 16:43:59 +02:00
ba635b8858 Fixed particles being emmited on non-player block breaks 2015-04-23 17:02:37 +02:00
04f3cc4905 Measure highest TPS load and lowest TPS between measurements 2015-04-23 15:34:42 +02:00
4a1e122605 Move UUID generation before PreLogin 2015-04-23 12:07:34 +02:00
a0739a7b03 Added more level tick options, force player ticks, base tick rate for levels 2015-04-23 11:34:01 +02:00
f73bd02198 Allow to tick players partially 2015-04-23 11:19:27 +02:00
ec7db3be4f build 6! 2015-04-22 17:08:59 +02:00
2ea8835b12 Removed possible crash on RakLibInterface 2015-04-22 15:45:04 +02:00
0aebcb9f81 Correctly load Anvil worlds 2015-04-22 12:07:27 +02:00
1578fc3ddb Improved world generation manager, UUIDs (some work for future usage) 2015-04-21 19:54:16 +02:00
514ce0fb04 Fixed colors not being shown on windows :s 2015-04-20 17:55:49 +02:00
f6e88ec055 Protect against null chunk on entity 2015-04-20 17:29:58 +02:00
15b4cd8fb3 Improved format constants, fixed cake eating when max health is > 20 2015-04-20 17:25:58 +02:00
f88aed1208 Fixed NBT parsing on false properties 2015-04-20 13:57:16 +02:00
6ed63edd89 Removed some remaining references, removed duplicated code on Anvil 2015-04-19 16:49:15 +02:00
897774f848 Increased manuall garbage collection rate 2015-04-19 16:16:05 +02:00
bf4a8398c4 Moved chunk garbage collector to memory manager 2015-04-19 16:14:54 +02:00
05385acb36 Added Memory Manager timings 2015-04-19 16:01:46 +02:00
094234dc0f Updated references and submodules 2015-04-19 15:37:18 +02:00
c2f72ea9ac Updated languages 2015-04-19 11:50:30 +02:00
e3c48b22cb Anvil fixes, improved memory settings 2015-04-19 11:45:43 +02:00
5860bdcc4d Improved network 2015-04-18 22:38:57 +02:00
1b84340e3f Improved manager 2015-04-18 22:35:00 +02:00
61828baa8f Improved manager 2015-04-18 22:33:50 +02:00
11ecaaa87f fixed oops in RakLib 2015-04-18 21:04:07 +02:00
b2c25eaf36 Added MemoryManager, new memory properties, improved performance, updated RakLib, fixed misc. bugs 2015-04-18 20:13:52 +02:00
ddc152ae0a Merge pull request #2903 from PEMapModder/patch-4
Added paramter types for some Config.php functions
2015-04-17 18:15:12 +02:00
08a612954e Added creative mode block list API 2015-04-17 18:01:10 +02:00
5b10ccf431 0.11.0 build 5, removed chat format workaround, improved gamemode switch, send allowed creative blocks (TBI as API) 2015-04-17 17:10:25 +02:00
2add19a4c8 Added paramter types for some Config.php functions 2015-04-17 16:32:40 +08:00
7ee21f6254 Try to clean chunks on other threads 2015-04-15 22:14:51 +02:00
f79476f530 Fixed health setting 2015-04-15 22:00:01 +02:00
4fbafe7c2f HACK: added workaround for MCPE eating characters, enable settings.force-language 2015-04-15 21:14:24 +02:00
d6186fa7c6 Moved Player->setGamemode() message to /gamemode command 2015-04-15 20:49:38 +02:00
88797d4c6c Enabled GC on AsyncWorker 2015-04-15 20:47:34 +02:00
fc2e4ddc63 Fixed long trunk generation 2015-04-15 20:47:18 +02:00
7f28deefcb Better BatchPacket decoding and LoginPacket handling 2015-04-15 19:30:49 +02:00
81fe98d4cc Added Milk bucket to creative inventory 2015-04-15 17:19:05 +02:00
dfec44645b Added milk drinking 2015-04-15 16:45:03 +02:00
1ef6328635 Allow negative potion effects 2015-04-15 16:37:13 +02:00
c0782caab9 Added alternate name for Swiftness 2015-04-15 16:15:17 +02:00
298b973604 Fixed a crash when saving chunks 2015-04-15 15:54:27 +02:00
5ca4f5416c More protocol updates 2015-04-15 15:53:11 +02:00
c36c0dfa66 Fixed health boost addition 2015-04-15 13:04:53 +02:00
64c366bdb5 Protocol 22 2015-04-15 12:38:52 +02:00
68ea9b067f Added health boost potion effect, added Player->sendTip(), MCPE 0.11.0 build 4 2015-04-15 12:33:16 +02:00
79adbdeafe Fixed trees not generating trunk 2015-04-15 11:04:00 +02:00
e09ebb0623 Oops! 2015-04-14 21:12:57 +02:00
91388c6b86 Added chunk-sending.cache-chunks property (old advanced-cache), improved chunk unload saving times 2015-04-14 20:57:09 +02:00
42eda170b5 Oops, forgot to do it correctly! 2015-04-14 20:39:37 +02:00
6ee3a7b8d7 Updated languages 2015-04-14 18:28:57 +02:00
18f6e1805f MCPE 0.11.0 build 3 2015-04-14 18:25:05 +02:00
0b176b3fe0 Implemented Channeled packet sending 2015-04-14 18:24:40 +02:00
bb945446b7 Merge branch 'master' of github.com:PocketMine/PocketMine-MP 2015-04-14 14:04:26 +02:00
1d1766a876 Removed format characters correctly :) 2015-04-14 14:04:10 +02:00
bd560ab3b1 Spawning mechanics change 2015-04-14 01:04:17 +02:00
547aa2ae31 Removed formatting on signs, allow OPs to use colored chat (or people with disabled remove format) 2015-04-13 16:45:20 +02:00
a993f15387 Added tick ms to level warning, call correct method on Anvil 2015-04-13 16:34:42 +02:00
1865622b89 Added settings.force-language property to force server language on clients 2015-04-13 12:02:40 +02:00
31387ff0be Added localized invalid name message 2015-04-13 11:36:15 +02:00
928660d59a Updated languages 2015-04-13 00:25:39 +02:00
5e2a21fc26 Added level-settings.auto-tick-rate property, added Level tick rate 2015-04-12 14:13:36 +02:00
410f6ba618 Fixed some potion effect names 2015-04-12 12:46:06 +02:00
05a9ad57bd Fixed BaseLang->get() 2015-04-12 12:41:38 +02:00
ba226d03c3 Added more translations 2015-04-12 12:27:55 +02:00
674a486654 Fixed #2863 2015-04-12 12:19:28 +02:00
e9963b603d Fixed #2864, closes #2864 2015-04-12 12:17:53 +02:00
e2bae92df8 Updated language files and command descriptions 2015-04-12 00:59:12 +02:00
8d468a1efb Format fix 2015-04-11 21:59:55 +02:00
ddeea2942c Updated RakLib, improved packet reading 2015-04-11 21:41:05 +02:00
a65c300a0a Fixed moving from different chunks, lots of issues fixed (all kind of strange things) 2015-04-11 21:39:51 +02:00
363e0e3b13 Revert slot change harder 2015-04-11 18:50:27 +02:00
6504047292 New translations, fixed multiplayer.player.leave 2015-04-11 18:19:28 +02:00
87a779afaf Enforced max distance checks 2015-04-11 18:07:12 +02:00
6b1b6711bd Send extra id on Add/Remove player 2015-04-11 18:00:25 +02:00
f71cf1c749 Added Fallback formatting codes to Windows/Android 2015-04-11 17:27:20 +02:00
3685d967a8 Fixed crash on /ban 2015-04-11 17:09:01 +02:00
d1006de421 Added fallback to BaseLang, better use by plugins 2015-04-11 16:15:45 +02:00
3cf42b558c Fixed language selection 2015-04-11 15:37:44 +02:00
5a0d1affcc Base translations moved to submodule! 2015-04-11 15:31:22 +02:00
414549659a Fixed crash on already dead players, closes #2856 2015-04-11 15:13:27 +02:00
3b6e10b759 More langs :D 2015-04-11 14:59:15 +02:00
c2138aa30c More language files 2015-04-11 12:56:38 +02:00
de052a79de Localized kick messages 2015-04-11 02:31:34 +02:00
c29ae333a2 Translate format text 2015-04-11 02:15:46 +02:00
0c041ebca3 Added base translation system 2015-04-11 01:32:08 +02:00
3224cd7dc5 Added Grass Path block, fixed redstone blocks not being able to be placed 2015-04-10 19:05:10 +02:00
3f60f7c0fb Merge pull request #2847 from matcracker/patch-3
Added Iron Shovel
2015-04-10 16:52:01 +02:00
c786ace355 Skin methods 2015-04-10 16:47:18 +02:00
60ac8f91ba Fixed pre-login disconnect messages 2015-04-10 15:26:32 +02:00
5720cb2be7 Added Iron Shovel
I think to have add Iron Shovel in creative inventory.
2015-04-10 15:06:02 +02:00
c32a7467bb Fixed wrong shift due to compiler change 2015-04-10 15:05:15 +02:00
0626d27003 Moved skin checks after protocol checks 2015-04-10 10:23:28 +02:00
2ae095a15a Fixed disable-ansi not working 2015-04-10 10:16:57 +02:00
5d102c2ede Fixed backwards compatibility issue on PlayerInteractyEvent 2015-04-10 10:16:03 +02:00
a7b1c6e086 Merge pull request #2844 from Falkirks/patch-1
Fix #2843
2015-04-10 08:48:22 +02:00
d855bbba0b Fix #2843 2015-04-09 20:59:42 -07:00
73d1d131e1 Added skin checks to Player and Human 2015-04-09 20:58:38 +02:00
0aa9586a52 Packet crashes fixed :D 2015-04-09 20:44:04 +02:00
205f6d50c1 Fixed PlayerActionPacket encode 2015-04-09 20:00:39 +02:00
ac6e2f9bf7 Fixed packet issues 2015-04-09 19:55:19 +02:00
1ddd58fd3b Fixed a few issues 2015-04-09 18:50:34 +02:00
66b58e36a1 Updated Code Guidelines 2015-04-09 18:24:29 +02:00
86184a230e Merge branch 'mcpe-0.11' 2015-04-09 18:18:10 +02:00
b4a0afc2c8 Getting ready, protocol changes! 2015-04-09 17:42:06 +02:00
f2e2cec024 Removed entity mask 2015-04-09 14:23:37 +02:00
0117e8dfae New codename, MCPE version, bumped split packet limit 2015-04-09 12:30:07 +02:00
69f841a00c Added Squids with basic AI 2015-04-09 00:12:50 +02:00
02ba9ffc16 Improved entity movement ySize offset 2015-04-08 22:09:06 +02:00
71657a2a4e Improved effects, threading changes 2015-04-08 17:31:06 +02:00
76767294bf Fish items, block of redstone! 2015-04-08 15:34:50 +02:00
3cae81c01b Added Nausea effect 2015-04-08 13:40:48 +02:00
141c0a297e Skins, protocol changes, handle split packets 2015-04-08 13:00:15 +02:00
45c6694ef9 Merge pull request #2827 from PEMapModder/patch-3
Removed useless code in Entity::getDirectionVector()
2015-04-07 10:11:09 +02:00
9b09b7ddd1 Removed useless code in Entity::getDirectionVector() 2015-04-03 15:15:35 +08:00
c9adc336ee Fixed items doing crazy things 2015-03-29 18:10:02 +02:00
d5ba2a72a5 Added strength, weakness, resistance effects, fixed entity area 2015-03-29 14:49:47 +02:00
9f6b5992e3 Merge pull request #2813 from Gamecrafter/patch-1
Really small fix
2015-03-29 20:32:11 +10:30
e51858ae17 Update ReloadCommand.php 2015-03-28 11:58:32 -07:00
c2baaf435d Merge branch 'master' into mcpe-0.11 2015-03-28 19:14:02 +01:00
c422b83abf Merge pull request #2812 from alejandroliu/patch-1
Added missing LEATHER_BOOTs to Item::$list
2015-03-28 18:08:08 +01:00
e0a6d0feab Critical arrows, fixed arrow interception calculation 2015-03-28 17:54:10 +01:00
0a85ad0d1f Improved trees, improved inventory transactions, improved snowball/bow usage 2015-03-28 16:59:15 +01:00
91315645cd Added missing LEATHER_BOOTs to Item::$list
For some reason the leather boots are missing.
2015-03-28 07:25:42 +01:00
47de616ac5 Fixed commands, added level automatic tick delay, improved biome gradient 2015-03-28 01:26:06 +01:00
e0522d8b1a Fixed data on generation, biome gradient 2015-03-27 12:42:59 +01:00
08f2b7f291 Moved chunk population to async tasks, and no more cut trees! 2015-03-27 01:57:08 +01:00
72c4c01542 Yay generation uses async tasks 2015-03-26 18:21:39 +01:00
668ddeeb13 Removed outdated Cache 2015-03-26 11:55:51 +01:00
286c1ee880 Added chunk spawn threshold for players 2015-03-26 11:28:44 +01:00
ed2ba70a29 Merge remote-tracking branch 'origin/master' into mcpe-0.11 2015-03-26 01:32:44 +01:00
962c28aaca BatchPacket, compress any packet depending on the size, really fast threaded chunk sending 2015-03-26 00:06:46 +01:00
7d1313c63d >= <= on move 2015-03-25 20:00:55 +01:00
d19631226f Improved Entity attack()/heal() event firing 2015-03-25 11:11:02 +01:00
6836e4fe58 Merge pull request #2800 from alejandroliu/patch-1
Corrected MINECART constant definition on Item.php
2015-03-25 11:03:39 +01:00
4a79c65544 Corrected MINECART constant definition on Item.php
MINECART was defined as 329, where it should be 328.
2015-03-24 23:47:33 +01:00
d1760d9bb8 Synchronize hotbar slots, removed RotateHeadPacket, improved MoveEntityPacket, FullChunkDataPacket 2015-03-24 16:26:46 +01:00
355ddc469c Merge pull request #2788 from alejandroliu/patch-1
Clone initial chunk in Flat.php
2015-03-24 10:23:35 +01:00
4e934654ef More awesomeness, No AI flag! 2015-03-23 14:44:04 +01:00
38f3dda13b Oops! 2015-03-23 11:15:03 +01:00
c68cd2c496 Cloned the initial empty chunk 2015-03-23 10:28:29 +01:00
a6b8170d9c Improved biomes 2015-03-23 08:02:18 +01:00
9da26fdb88 World generation with biomes! 2015-03-22 22:57:40 +01:00
1666602652 Improved memory output, logging, removed locks 2015-03-22 03:20:48 +01:00
d2bf92c3ed New batched UpdateBlockPacket, added Level->sendBlocks() 2015-03-22 02:44:39 +01:00
93a50d08e7 Merge branch 'master' into mcpe-0.11 2015-03-22 02:20:32 +01:00
1f977f68c0 Merge pull request #2794 from sekjun9878/master
Utils\Config preserves document type between reloads. Fixes #2777
2015-03-21 15:03:05 +01:00
91a26c15dd Utils\Config preserves document type between reloads. Fixes #2777 2015-03-21 21:35:57 +10:30
add380c7ed A few fixes! 2015-03-21 00:45:29 +01:00
652987110a Added popup notices! 2015-03-20 17:56:07 +01:00
58253be0a0 Implemented swiftness, added invisible status to FloatingTextParticle 2015-03-20 17:19:06 +01:00
b42424eb22 Sounds! 2015-03-20 16:42:50 +01:00
1d1a8a316e Take-2: Delay "parsePreset" until we have to really generate a block 2015-03-20 08:13:55 +01:00
a2b3e48b45 Added /particle command 2015-03-20 03:37:58 +01:00
ebc8928c21 Implemented effect colors 2015-03-20 02:31:54 +01:00
62ba36b474 New TextPacket, second part! 2015-03-19 20:27:51 +01:00
2c59983672 New TextPacket, first part 2015-03-19 18:48:03 +01:00
8ae9cd4eaf Clone initial chunk in Flat.php
The Flat generator destroys Chunk at 0,0.

What happens is that it request the level to read Chunk at 0,0.  It then uses that chunk to create the template chunk.  However this obliterates whatever was in Chunk at 0,0.

Added a line to "clone" this chunk, so when parsePreset generates the template chunk, all this goes to a copy rather than the original file chunk 0,0.
2015-03-19 15:41:26 +01:00
275a1e3f60 Water breathing potion 2015-03-19 10:14:35 +01:00
6735234bf4 Protocol update 2015-03-19 10:12:09 +01:00
d66a2d7105 Merge branch 'master' into mcpe-0.11 2015-03-19 09:18:39 +01:00
c882df7465 Fixed destroyblock particle duplicating on clients 2015-03-19 08:30:07 +01:00
f21e457dc0 Fixed particle constructor 2015-03-18 21:49:01 +01:00
6bf30c133a Merge pull request #2785 from PocketMine/revert-2776-armor-fix
Revert "Implemented proportional armor modifier, applied armor in other ...
2015-03-18 17:26:53 +01:00
d34499e67b Revert "Implemented proportional armor modifier, applied armor in other damage types and consume armor when player is damaged" 2015-03-18 17:26:06 +01:00
c2a3298a7e Particles. 2015-03-18 16:34:19 +01:00
b31604a536 Fixed data sending, more particles 2015-03-18 12:11:44 +01:00
c00370cfbf Added experimental particles 2015-03-18 08:51:38 +01:00
7c0bd45d1d Merge pull request #2779 from alejandroliu/patch-1
Fixed a silly typo in Server.php line 1142.
2015-03-18 14:04:36 +10:30
5f2254cc42 Fixed a silly typo in Server.php line 1142.
Fixed a silly typo in Server.php line 1142.  Yes, the "t" is next to the "y" on my keyboard too!
2015-03-17 23:48:23 +01:00
8169803bb4 Updated Water/Lava to use new methods 2015-03-17 21:22:51 +01:00
5a35e7b058 Removed damage reduction by armor for lava 2015-03-17 21:10:54 +01:00
1b25cd6ffa Merge branch 'master' into mcpe-0.11 2015-03-17 19:12:03 +01:00
6af87814e3 Added 64-bit entity data field 2015-03-17 16:26:02 +01:00
b5b46bfd7e Improved thread count 2015-03-17 00:47:43 +01:00
2ae80031f0 New implementation of sending/setting/getting entity data, added effect saving 2015-03-17 00:01:54 +01:00
85c5714cbf API 1.12.0, 1.5dev 2015-03-16 21:39:32 +01:00
bc31df37d0 Added invisibility potion, metadata sending for invisibility/nametags 2015-03-16 19:05:31 +01:00
29ca349b3d Less protocol madness 2015-03-16 12:13:52 +01:00
4ec584d800 Added real memory and thread usage 2015-03-16 11:56:00 +01:00
4383e272eb Added Effects base, /effect and methods 2015-03-15 23:15:54 +01:00
f9361aa931 Use new colors in terminal 2015-03-15 18:32:36 +01:00
d5601b0c9f Generator works! 2015-03-15 16:40:18 +01:00
5bfc747622 Fixed NBT IntArray off-by-one reading 2015-03-15 16:39:53 +01:00
b0f8c14640 Added Terminal class, Improved normal generator speed 2015-03-15 00:15:24 +01:00
328cd585c0 Merge branch 'biome-generation' into mcpe-0.11 2015-03-14 15:52:38 +01:00
94c2ec8498 Fixed constructors, default memory to -1, default async generator 2015-03-14 15:50:33 +01:00
11c13cd666 Implemented Threaded ClassLoader, improves class loading while on different threads (no need to synchronize states) 2015-03-14 15:22:13 +01:00
284958a21e Merge branch 'mcpe-0.11' of bitbucket.org:pocketmine/pocketmine-mp into mcpe-0.11 2015-03-14 02:39:12 +01:00
91e8bdbd37 Fixed size on MobSpawnParticle 2015-03-13 16:21:33 +01:00
9e0b9a6e5b Added right and left click interaction events 2015-03-13 14:39:37 +01:00
e48a3e5713 Added some types of Particles, Block break particles 2015-03-13 14:24:19 +01:00
1ce7cc64a6 Use ContainerSetSlotPacket instead of ContainerSetContentsPacket 2015-03-13 10:25:48 +01:00
7f9aad6840 Removed player foreach on Entity 2015-03-13 09:27:09 +01:00
3af784012c Fixed packets 2015-03-13 09:27:09 +01:00
a6c19734ce Fixed picking up items, entity IDs on packets 2015-03-13 09:27:09 +01:00
8ddd701d76 Renamed LoginStatusPacket to PlayStatusPacket, added spawn status, new colors 2015-03-13 09:27:09 +01:00
15ee0c37c6 Fixed Entity->setMotion() for Players 2015-03-13 09:27:09 +01:00
fc128affc5 Removed chat wrapping, deprecated TextWrapper 2015-03-13 09:27:09 +01:00
218fd999b0 More packets changed, unique IDs D: 2015-03-13 09:27:09 +01:00
eeeaac04e9 Updated packet order, removed player entity id as 0 2015-03-13 09:27:09 +01:00
8679ad5b86 Added colors, Disconnect Packet, protocol 21 2015-03-13 09:27:09 +01:00
1e00ff9e4a Update RakLib 2015-03-12 18:37:22 +01:00
1ac7f9f061 Removed player foreach on Entity 2015-03-12 15:58:10 +01:00
5b3ce2da9d Fixed packets 2015-03-12 15:38:17 +01:00
00942d3a2b Fixed picking up items, entity IDs on packets 2015-03-12 12:02:37 +01:00
4b442a9d7c Renamed LoginStatusPacket to PlayStatusPacket, added spawn status, new colors 2015-03-12 11:43:50 +01:00
44dfb59409 Fixed Entity->setMotion() for Players 2015-03-12 11:43:50 +01:00
696ba08a81 Removed chat wrapping, deprecated TextWrapper 2015-03-12 11:43:50 +01:00
d80b8524fb More packets changed, unique IDs D: 2015-03-12 11:43:50 +01:00
2175d7922a Updated packet order, removed player entity id as 0 2015-03-12 11:43:50 +01:00
5fcb0d6aa5 Added colors, Disconnect Packet, protocol 21 2015-03-12 11:43:50 +01:00
a893174473 Second biome generator iteration 2015-01-08 01:05:23 +01:00
a76be6cf38 First biome based generator iteration 2015-01-07 04:07:11 +01:00
1157 changed files with 71927 additions and 35353 deletions

6
.editorconfig Normal file
View File

@ -0,0 +1,6 @@
# http://editorconfig.org/
root = yes
[*]
indent_size = 4
indent_style = tab

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

48
.github/ISSUE_TEMPLATE.md vendored Normal file
View File

@ -0,0 +1,48 @@
### Issue description
<!---
THIS ISSUE TRACKER IS FOR BUG REPORTING, NOT FOR HELP & SUPPORT. If you need help, use the links below.
- http://pmmp.readthedocs.io/en/rtfd/ - Documentation
- https://forums.pmmp.io - PMMP Forums
Any issues requesting updates to new versions of MCPE will be treated as spam.
Please do not create issues for missing/un-implemented gameplay features - they will be closed.
-->
<!--- 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-MP version should include Jenkins build number and/or git commit hash.
NO support whatsoever will be provided for third-party modified variants of PocketMine-MP. Issues relating to third-party modifications will be closed as spam.
Note that 32-bit platforms are no longer supported by PocketMine-MP and issues concerning 32-bit platforms will be closed.
-->
* PocketMine-MP: <!-- LATEST IS NOT A VALID VERSION -->
* PHP:
* Server OS:
* Game version: PE/Win10 (delete as appropriate)
### Plugins
- Test on a clean server without plugins: is the issue reproducible without any plugins loaded?
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
- Paste your list of plugins here (use the 'plugins' command in PocketMine-MP)
### Crashdump, backtrace or other files
- Do not paste crashdumps into an issue - please use our Crash Archive at https://crash.pmmp.io for submitting crash reports to not spam the issue tracker. Add links to your reports in the Crash Archive here.
- Please use gist or anything else to add other files and add links here
* ...

40
.github/PULL_REQUEST_TEMPLATE.md vendored Normal file
View File

@ -0,0 +1,40 @@
## Introduction
<!-- Explain existing problems or why this pull request is necessary -->
### Relevant issues
<!-- List relevant issues here -->
<!--
* Fixes #1
* Fixes #2
-->
## Changes
### API changes
<!-- Any additions to the API that should be documented in release notes? -->
### Behavioural changes
<!-- Any change in how the server behaves, or its performance? -->
## Backwards compatibility
<!-- Any possible backwards incompatible changes? How are they solved, or how can they be solved? -->
## Follow-up
<!-- Suggest any actions to be done before/after merging this pull request -->
<!--
Requires translations:
| Name | Value in eng.ini |
| :--: | :---: |
| `foo.bar` | `Foo bar` |
-->
## Tests
<!--
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
-->

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

@ -0,0 +1,12 @@
# 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: >
This issue tracker is not a support forum. Please use the [forums](https://forums.pmmp.io) for support.
# Whether to close issues marked as support requests
close: true
# Whether to lock issues marked as support requests
lock: false

19
.gitignore vendored
View File

@ -1,16 +1,20 @@
players/*
worlds/*
plugin_data/*
plugins/*
bin/*
bin*/*
timings/*
crashdumps/*
*.log
*.txt
*.phar
server.properties
pocketmine.yml
/pocketmine.yml
memory_dumps/*
resource_packs/
# Common IDEs
.idea/*
.idea/
nbproject/*
# Windows image file caches
@ -26,3 +30,12 @@ Desktop.ini
# Sphinx-doc
/docs/build/
!/docs/requirements.txt
# Composer
vendor/*
# Travis files
test_data/*
# Doxygen
Documentation/*

26
.gitmodules vendored
View File

@ -1,14 +1,12 @@
[submodule "src/pocketmine/gui"]
path = src/pocketmine/gui
url = https://github.com/PocketMine/PocketMine-MP-GUI.git
branch = master
[submodule "src/raklib"]
path = src/raklib
url = https://github.com/PocketMine/RakLib.git
branch = master
[submodule "src/spl"]
path = src/spl
url = https://github.com/PocketMine/PocketMine-SPL.git
[submodule "tests/TesterPlugin"]
path = tests/TesterPlugin
url = https://github.com/PocketMine/TesterPlugin.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
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

View File

@ -1,5 +0,0 @@
Shoghi Cervantes <shoghicp@gmail.com>
Shoghi Cervantes <shoghicp@gmail.com> Shoghi Cervantes <shoghicp@pocketmine.net>
Brandon V <brandon15811@gmail.com>
Michael Yoo <sekjun9878@gmail.com> Michael Yoo <michael@yoo.id.au>
Michael Yoo <sekjun9878@gmail.com> Michael Yoo <sekjun9878@sekjun9878.info>

View File

@ -1,21 +1,24 @@
language: php
php:
- 5.6
branches:
- master
- 7.2
before_script:
- mkdir plugins
- wget -O plugins/DevTools.phar https://github.com/PocketMine/DevTools/releases/download/v1.9.0/DevTools_v1.9.0.phar
- pecl install channel://pecl.php.net/pthreads-2.0.10
- pecl install channel://pecl.php.net/weakref-0.2.6
- echo | pecl install channel://pecl.php.net/yaml-1.1.1
# - pecl install channel://pecl.php.net/pthreads-3.1.6
- echo | pecl install channel://pecl.php.net/yaml-2.0.2
- git clone https://github.com/pmmp/pthreads.git
- cd pthreads
- git checkout c8cfacda84f21032d6014b53e72bf345ac901dac
- phpize
- ./configure
- make
- make install
- cd ..
- echo "extension=pthreads.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini
- composer install
script:
- php tests/TravisTest.php
- ./tests/travis.sh -t4
notifications:
email: false
#webhooks: http://n.tkte.ch/h/214/wsNvmG43-ncxUVRrFPwSM-r0

View File

@ -2,63 +2,100 @@
# PocketMine-MP Contribution Guidelines
You must follow these guidelines if you wish to contribute to the PocketMine-MP code base, or participate in issue tracking.
## I have a question
* For questions, please refer to the _#pocketmine_ or _#mcpedevs_ IRC channel on Freenode. There is a [WebIRC](http://webchat.freenode.net?channels=pocketmine,mcpedevs&uio=d4) if you want.
* You can ask directly to _[@PocketMine](https://twitter.com/PocketMine)_ in Twitter, but don't expect an immediate reply.
* You may use our [Forum](http://forums.pocketmine.net) to ask questions.
* We do not accept questions or support requests in our issue tracker.
## Creating an Issue
- First, use the [Issue Search](https://github.com/PocketMine/PocketMine-MP/search?ref=cmdform&type=Issues) to check if anyone has reported it.
- If your issue is related to a plugin, you must contact their original author instead of reporting it here.
- If your issue is related to a PocketMine official plugin, or our Android application, you must create an issue on that specific repository.
- **Support requests are not bugs.** Issues such as "How do I do this" are not bugs and are closed as soon as a collaborator spots it. They are referred to our Forum to seek assistance.
- **No generic titles** such as "Question", "Help", "Crash Report" etc. If an issue has a generic title they will either be closed on the spot, or a collaborator will edit it to describe the actual symptom.
- Information must be provided in the issue body, not in the title. No tags are allowed in the title, and do not change the title if the issue has been solved.
- Similarly, no generic issue reports. It is the issue submitter'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 is a support request until the actual bug has been found and therefore the issue is closed.
- 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.
- **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.
- **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
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.
### Licensing
By proposing a pull request to the project, you agree to your code being distributed within PocketMine-MP under the [LGPL license](LICENSE).
### 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.
- **Use descriptive commit titles.** You can see an example [here](http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html).
- **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.
## Contributing Code
* Use the [Pull Request](https://github.com/PocketMine/PocketMine-MP/pull/new) system, your request will be checked and discussed.
* __Create a single branch for that pull request__
* Code using the syntax as in PocketMine-MP. See below for an example.
* The code must be clear and written in English, comments included.
* Use descriptive commit titles
* __No merge commits are allowed, or multiple features per pull request__
**Thanks for contributing to PocketMine-MP!**
### Code Syntax
It is mainly [PSR-2](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-1-basic-coding-standard.md) with a few exceptions.
* Opening braces MUST go on the same line, and MUST NOT have spaces before.
* `else if` MUST be written as `elseif`. _(It is in PSR-2, but using a SHOULD)_
* Control structure keywords or opening braces MUST NOT have one space after them.
* Code MUST use tabs for indenting.
* Long arrays MAY be split across multiple lines, where each subsequent line is indented once.
* Files MUST use only the `<?php` tag.
* Files MUST NOT have an ending `?>` tag.
* Code MUST use namespaces.
* Strings SHOULD use the double quote `"` except when the single quote is required.
* Argument lists MAY NOT be split across multiple lines, except long arrays.
- Opening braces MUST go on the same line, and MUST NOT have spaces before.
- `else if` MUST be written as `elseif`. _(It is in PSR-2, but using a SHOULD)_
- Control structure keywords or opening braces MUST NOT have one space before or after them.
- Code MUST use tabs for indenting.
- Long arrays MAY be split across multiple lines, where each subsequent line is indented once.
- Files MUST use only the `<?php` tag.
- Files MUST NOT have an ending `?>` tag.
- Code MUST use namespaces.
- 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
<?php
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;
public function __construct($firstArgument, &$secondArgument = null){
if($firstArgument === "exampleValue"){ //Remember to use === instead == when possible
/**
* Creates an instance of ExampleClass
*
* @param string $firstArgument the first argument
* @param string|null $secondArgument default null
*/
public function __construct(string $firstArgument, ?string &$secondArgument = null){
if($firstArgument === "exampleValue"){ //Remember to use === instead of == when possible
//do things
}elseif($firstArgument === "otherValue"){
$secondArgument = function(){
return [
$this->examplePrivateVariable = [
0 => "value1",
1 => "value2",
2 => "value3",
@ -66,13 +103,17 @@ class ExampleClass{
4 => "value5",
5 => "value6",
];
}
};
}
}
public function doStuff(string $stuff) : string{
return $stuff;
}
}
```
<!-- TODO: RFC and voting on the forums instead -->
### RFC and Voting
* These are big Pull Requests or contributions that change important behavior.
* RFCs will be tagged with the *PR: RFC* label
@ -83,58 +124,3 @@ class ExampleClass{
* 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.
## Bug Tracking for Collaborators
### Labels
To provide a concise bug tracking environment, prevent the issue tracker from over flowing and to keep support requests out of the bug tracker, PocketMine-MP uses a label scheme a bit different from the default GitHub Issues labels.
PocketMine-MP uses GitHub Issues Labels. There are a total of 12 labels.
Note: For future reference, labels must not be longer than 15 letters.
#### Categories
Category labels are prefixed by `C:`. Multiple category labels may be applied to a single issue(but try to keep this to a minimum and do not overuse category labels).
- C: Core - This label is applied when the bug results in a fatal crash, or is related to neither Gameplay nor Plugin API.
- C: Gameplay - This label is applied when the bug effects the gameplay.
- C: API - This label is applied when the bug effects the Plugin API.
#### Pull Requests
Pull Requests are prefixed by `PR:`. Only one label may be applied for a Pull Request.
- PR: Bug Fix - This label is applied when the Pull Request fixes a bug.
- PR: Contribution - This label is applied when the Pull Request contributes code to PocketMine-MP such as a new feature or an improvement.
- PR: RFC - Request for Comments
#### Status
Status labels show the status of the issue. Multiple status labels may be applied.
- Reproduced - This label is applied when the bug has been reproduced, or multiple people are reporting the same issue and symptoms in which case it is automatically assumed that the bug has been reproduced in different environments.
- Debugged - This label is applied when the cause of the bug has been found.
- Priority - This label is applied when the bug is easy to fix, or if the scale of the bug is global.
- Won't Fix - This label is applied if the bug has been decided not be fixed for some reason. e.g. when the bug benefits gameplay. *This label may only be applied to a closed issue.*
#### Miscellaneous
Miscellaneous labels are labels that show status not related to debugging that bug. The To-Do label and the Mojang label may not be applied to a single issue at the same time.
- To-Do - This label is applied when the issue is not a bug, but a feature request or a list of features to be implemented that count towards a milestone.
- Mojang - This label is applied when the issue is suspected of being caused by the Minecraft: Pocket Edition client, but has not been confirmed.
- Invalid - This label is applied when the issue is reporting a false bug that works as intended, a support request, etc. *This label may only be applied to a closed issue.*
### Closing Issues
To keep the bug tracker clear of non-related issues and to prevent it from overflowing, **issues must be closed as soon as possible** (This may sound unethical, but it is MUCH better than having the BUG TRACKER filled with SUPPORT REQUESTS and "I NEED HELP").
If an issue does not conform to the "Creating an Issue" guidelines above, the issue should be closed.
### Milestones
PocketMine-MP uses GitHub Milestones to set a goal for a new release. A milestone is set on the following occasions.
- A new Beta release
- A new Stable release
A milestone must use the following format:
```
Alpha_<version_number> [release_title][release_version]
```
For example:
```
Alpha_1.4 beta2
```

View File

@ -1,5 +1,33 @@
# ![PocketMine-MP](http://cdn.pocketmine.net/img/PocketMine-MP-h.png)
# [![PocketMine-MP](http://cdn.pocketmine.net/img/PocketMine-MP-h.png)](https://pmmp.io)
__A highly customisable, open source server software for Minecraft: Bedrock Edition written in PHP__
[![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.
### Discussion
- [Forums](https://forums.pmmp.io/)
### Plugins
There are a very wide range of already-written plugins available which you can use to customise your server. Check out [Poggit](https://poggit.pmmp.io), or just search GitHub.
### 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.
### 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?
- Latest release builds can be found in our [GitHub releases](https://github.com/pmmp/PocketMine-MP/releases).
- Latest bleeding-edge development builds (and other builds in the build job channels) can be found on our [Jenkins server](https://jenkins.pmmp.io/).
**Note: Please avoid development builds unless there is no other alternative for what you need.** Development builds are subject to changes at any time without notice, and it is likely that your server or plugins might break without warning.
## 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
@ -14,42 +42,4 @@
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/>.
__PocketMine-MP is a free, open-source software that creates Minecraft: Pocket Edition servers and allows extending its functionalities__
### [Homepage](http://www.pocketmine.net/)
### [Forums](http://forums.pocketmine.net/)
### [Documentation](http://pocketmine-mp.readthedocs.org/)
### [Plugin Repository](http://plugins.pocketmine.net/)
<!--## [FAQ: Frequently Asked Questions](https://github.com/PocketMine/PocketMine-MP/wiki/Frequently-Asked-Questions)-->
### [Official Jenkins server](http://jenkins.pocketmine.net/)
### API Documentation
* [Official Doxygen-generated documentation](http://docs.pocketmine.net/)
* [Latest Doxygen generated from development](http://jenkins.pocketmine.net/job/PocketMine-MP-doc/doxygen/)
### [Twitter @PocketMine](https://twitter.com/PocketMine)
### IRC Chat #pocketmine (or #mcpedevs) @ irc.freenode.net
[#pocketmine + #mcpedevs channel WebIRC](http://webchat.freenode.net/?channels=pocketmine,mcpedevs)
### Want to contribute?
* Check the [Contributing Guidelines](CONTRIBUTING.md)
## Third-party Libraries/Protocols Used
* __[PHP Sockets](http://php.net/manual/en/book.sockets.php)__
* __[PHP SQLite3](http://php.net/manual/en/book.sqlite3.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)__
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.

71
composer.json Normal file
View File

@ -0,0 +1,71 @@
{
"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.1.7dev",
"ext-reflection": "*",
"ext-sockets": "*",
"ext-spl": "*",
"ext-yaml": ">=2.0.0",
"ext-zip": "*",
"ext-zlib": ">=1.2.11",
"pocketmine/raklib": "^0.12.0",
"pocketmine/spl": "^0.3.0",
"pocketmine/binaryutils": "^0.1.0",
"pocketmine/nbt": "^0.2.1",
"pocketmine/math": "^0.2.0",
"pocketmine/snooze": "^0.1.0",
"daverandom/callback-validator": "dev-master"
},
"autoload": {
"psr-4": {
"": ["src"]
}
},
"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"
}
]
}

297
composer.lock generated Normal file
View File

@ -0,0 +1,297 @@
{
"_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": "2d120a3dd7d68958809c3662d1cb7c99",
"packages": [
{
"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.1",
"source": {
"type": "git",
"url": "https://github.com/pmmp/BinaryUtils.git",
"reference": "54efeb978be0ff9335022729fe63c1e2077bf1be"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/pmmp/BinaryUtils/zipball/54efeb978be0ff9335022729fe63c1e2077bf1be",
"reference": "54efeb978be0ff9335022729fe63c1e2077bf1be",
"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/master",
"issues": "https://github.com/pmmp/BinaryUtils/issues"
},
"time": "2018-08-26T18:11:05+00:00"
},
{
"name": "pocketmine/math",
"version": "0.2.1",
"source": {
"type": "git",
"url": "https://github.com/pmmp/Math.git",
"reference": "ee299f5c9c444ca526c9c691b920f321458cf0b6"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/pmmp/Math/zipball/ee299f5c9c444ca526c9c691b920f321458cf0b6",
"reference": "ee299f5c9c444ca526c9c691b920f321458cf0b6",
"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.1",
"issues": "https://github.com/pmmp/Math/issues"
},
"time": "2018-08-15T15:43:27+00:00"
},
{
"name": "pocketmine/nbt",
"version": "0.2.3",
"source": {
"type": "git",
"url": "https://github.com/pmmp/NBT.git",
"reference": "291bf5cc2a94500eada1edbda51d15bed25a1e1c"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/pmmp/NBT/zipball/291bf5cc2a94500eada1edbda51d15bed25a1e1c",
"reference": "291bf5cc2a94500eada1edbda51d15bed25a1e1c",
"shasum": ""
},
"require": {
"ext-zlib": "*",
"php": ">=7.2.0",
"php-64bit": "*",
"pocketmine/binaryutils": "^0.1.0"
},
"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.3",
"issues": "https://github.com/pmmp/NBT/issues"
},
"time": "2018-12-03T16:08:28+00:00"
},
{
"name": "pocketmine/raklib",
"version": "0.12.0",
"source": {
"type": "git",
"url": "https://github.com/pmmp/RakLib.git",
"reference": "922da28efd828e2af6c19db1676ea9b6a267071c"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/pmmp/RakLib/zipball/922da28efd828e2af6c19db1676ea9b6a267071c",
"reference": "922da28efd828e2af6c19db1676ea9b6a267071c",
"shasum": ""
},
"require": {
"ext-bcmath": "*",
"ext-pthreads": ">=3.1.7dev",
"ext-sockets": "*",
"php": ">=7.2.0",
"php-64bit": "*",
"php-ipv6": "*",
"pocketmine/binaryutils": "^0.1.0",
"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.0",
"issues": "https://github.com/pmmp/RakLib/issues"
},
"time": "2018-06-13T10:06:14+00:00"
},
{
"name": "pocketmine/snooze",
"version": "0.1.0",
"source": {
"type": "git",
"url": "https://github.com/pmmp/Snooze.git",
"reference": "3cc9d0164230889acb08e22cc126133809e9d346"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/pmmp/Snooze/zipball/3cc9d0164230889acb08e22cc126133809e9d346",
"reference": "3cc9d0164230889acb08e22cc126133809e9d346",
"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.0",
"issues": "https://github.com/pmmp/Snooze/issues"
},
"time": "2018-06-13T09:36:11+00:00"
},
{
"name": "pocketmine/spl",
"version": "0.3.2",
"source": {
"type": "git",
"url": "https://github.com/pmmp/SPL.git",
"reference": "7fd53857cd000491ba69e8db865792a024dd2c49"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/pmmp/SPL/zipball/7fd53857cd000491ba69e8db865792a024dd2c49",
"reference": "7fd53857cd000491ba69e8db865792a024dd2c49",
"shasum": ""
},
"type": "library",
"autoload": {
"exclude-from-classmap": [
"stubs"
],
"classmap": [
"./"
]
},
"license": [
"LGPL-3.0"
],
"description": "Standard library files required by PocketMine-MP and related projects",
"support": {
"source": "https://github.com/pmmp/SPL/tree/master"
},
"time": "2018-08-12T15:17:39+00:00"
}
],
"packages-dev": [],
"aliases": [],
"minimum-stability": "stable",
"stability-flags": {
"ext-pthreads": 20,
"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.1.7dev",
"ext-reflection": "*",
"ext-sockets": "*",
"ext-spl": "*",
"ext-yaml": ">=2.0.0",
"ext-zip": "*",
"ext-zlib": ">=1.2.11"
},
"platform-dev": []
}

2321
doxygen.conf Normal file

File diff suppressed because it is too large Load Diff

View File

@ -2,11 +2,11 @@
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* 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
@ -14,13 +14,16 @@
* (at your option) any later version.
*
* @author PocketMine Team
*
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine;
use pocketmine\lang\TranslationContainer;
use pocketmine\utils\TextFormat;
/**
@ -38,78 +41,85 @@ 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])){
if(Server::getInstance()->getConfigString("announce-player-achievements", true) === true){
Server::getInstance()->broadcastMessage($player->getDisplayName() . " has just earned the achievement " . TextFormat::GREEN . Achievement::$list[$achievementId]["name"]);
$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("You have just earned the achievement " . TextFormat::GREEN . Achievement::$list[$achievementId]["name"]);
$player->sendMessage($translation);
}
return true;
@ -118,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;
@ -130,6 +147,4 @@ abstract class Achievement{
return false;
}
}

View File

@ -0,0 +1,37 @@
<?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;
abstract class Collectable extends \Threaded{
private $isGarbage = false;
public function isGarbage() : bool{
return $this->isGarbage;
}
public function setGarbage(){
$this->isGarbage = true;
}
}

View File

@ -14,38 +14,55 @@
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine;
use pocketmine\network\protocol\Info;
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;
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 = 1;
/** @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){
$this->time = time();
$this->server = $server;
$this->path = $this->server->getDataPath() . "CrashDump_" . date("D_M_j-H.i.s-T_Y", $this->time) . ".log";
if(!is_dir($this->server->getDataPath() . "crashdumps")){
mkdir($this->server->getDataPath() . "crashdumps");
}
$this->path = $this->server->getDataPath() . "crashdumps/" . date("D_M_j-H.i.s-T_Y", $this->time) . ".log";
$this->fp = @fopen($this->path, "wb");
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();
@ -56,9 +73,11 @@ class CrashDump{
$this->extraData();
$this->encodeData();
fclose($this->fp);
}
public function getPath(){
public function getPath() : string{
return $this->path;
}
@ -66,7 +85,7 @@ class CrashDump{
return $this->encodedData;
}
public function getData(){
public function getData() : array{
return $this->data;
}
@ -83,7 +102,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"] = [];
@ -107,10 +126,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");
@ -140,7 +159,7 @@ class CrashDump{
$error = $lastExceptionError;
}else{
$error = (array) error_get_last();
$error["trace"] = @getTrace(3);
$error["trace"] = Utils::getTrace(4); //Skipping CrashDump->baseCrash, CrashDump->construct, Server->crashDump
$errorConversion = [
E_ERROR => "E_ERROR",
E_WARNING => "E_WARNING",
@ -156,11 +175,11 @@ 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["type"] = isset($errorConversion[$error["type"]]) ? $errorConversion[$error["type"]] : $error["type"];
$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);
}
@ -178,7 +197,7 @@ 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"])){
if(strpos($error["file"], "src/pocketmine/") === false and strpos($error["file"], "vendor/pocketmine/") === false and file_exists($error["fullFile"])){
$this->addLine();
$this->addLine("THIS CRASH WAS CAUSED BY A PLUGIN");
$this->data["plugin"] = true;
@ -187,7 +206,7 @@ class CrashDump{
$file = $reflection->getProperty("file");
$file->setAccessible(true);
foreach($this->server->getPluginManager()->getPlugins() as $plugin){
$filePath = \pocketmine\cleanPath($file->getValue($plugin));
$filePath = Utils::cleanPath($file->getValue($plugin));
if(strpos($error["file"], $filePath) === 0){
$this->data["plugin"] = $plugin->getName();
$this->addLine("BAD PLUGIN: " . $plugin->getDescription()->getFullName());
@ -202,11 +221,11 @@ class CrashDump{
$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];
}
}
@ -219,12 +238,13 @@ class CrashDump{
}
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"]["protocol"] = Info::CURRENT_PROTOCOL;
$this->data["general"]["api"] = \pocketmine\API_VERSION;
$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"]["git"] = \pocketmine\GIT_COMMIT;
$this->data["general"]["raklib"] = RakLib::VERSION;
$this->data["general"]["uname"] = php_uname("a");
@ -232,7 +252,7 @@ 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 " . Info::CURRENT_PROTOCOL . "; API " . API_VERSION . "]");
$this->addLine($this->server->getName() . " version: " . $version->getFullVersion(true) . " [Protocol " . ProtocolInfo::CURRENT_PROTOCOL . "]");
$this->addLine("Git commit: " . GIT_COMMIT);
$this->addLine("uname -a: " . php_uname("a"));
$this->addLine("PHP Version: " . phpversion());
@ -247,5 +267,4 @@ class CrashDump{
public function add($str){
fwrite($this->fp, $str);
}
}
}

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

@ -0,0 +1,483 @@
<?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;
use pocketmine\event\server\LowMemoryEvent;
use pocketmine\scheduler\DumpWorkerMemoryTask;
use pocketmine\scheduler\GarbageCollectionTask;
use pocketmine\timings\Timings;
use pocketmine\utils\Utils;
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;
/** @var int */
private $lowMemChunkRadiusOverride;
/** @var bool */
private $lowMemChunkGC;
/** @var bool */
private $lowMemDisableChunkCache;
/** @var bool */
private $lowMemClearWorldCache;
/** @var bool */
private $dumpWorkers = true;
public function __construct(Server $server){
$this->server = $server;
$this->init();
}
private function init(){
$this->memoryLimit = ((int) $this->server->getProperty("memory.main-limit", 0)) * 1024 * 1024;
$defaultMemory = 1024;
if(preg_match("/([0-9]+)([KMGkmg])/", $this->server->getConfigString("memory-limit", ""), $matches) > 0){
$m = (int) $matches[1];
if($m <= 0){
$defaultMemory = 0;
}else{
switch(strtoupper($matches[2])){
case "K":
$defaultMemory = $m / 1024;
break;
case "M":
$defaultMemory = $m;
break;
case "G":
$defaultMemory = $m * 1024;
break;
default:
$defaultMemory = $m;
break;
}
}
}
$hardLimit = ((int) $this->server->getProperty("memory.main-hard-limit", $defaultMemory));
if($hardLimit <= 0){
ini_set("memory_limit", '-1');
}else{
ini_set("memory_limit", $hardLimit . "M");
}
$this->globalMemoryLimit = ((int) $this->server->getProperty("memory.global-limit", 0)) * 1024 * 1024;
$this->checkRate = (int) $this->server->getProperty("memory.check-rate", 20);
$this->continuousTrigger = (bool) $this->server->getProperty("memory.continuous-trigger", true);
$this->continuousTriggerRate = (int) $this->server->getProperty("memory.continuous-trigger-rate", 30);
$this->garbageCollectionPeriod = (int) $this->server->getProperty("memory.garbage-collection.period", 36000);
$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->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->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();
}
/**
* @return bool
*/
public function isLowMemory() : bool{
return $this->lowMemory;
}
/**
* @return bool
*/
public function canUseChunkCache() : bool{
return !$this->lowMemory or !$this->lowMemDisableChunkCache;
}
/**
* Returns the allowed chunk radius based on the current memory usage.
*
* @param int $distance
*
* @return int
*/
public function getViewDistance(int $distance) : int{
return ($this->lowMemory and $this->lowMemChunkRadiusOverride > 0) ? (int) min($this->lowMemChunkRadiusOverride, $distance) : $distance;
}
/**
* 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->lowMemClearWorldCache){
foreach($this->server->getLevels() as $level){
$level->clearCache(true);
}
}
if($this->lowMemChunkGC){
foreach($this->server->getLevels() as $level){
$level->doChunkGarbageCollection();
}
}
$ev = new LowMemoryEvent($memory, $limit, $global, $triggerCount);
$ev->call();
$cycles = 0;
if($this->garbageCollectionTrigger){
$cycles = $this->triggerGarbageCollector();
}
$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();
if(($this->memoryLimit > 0 or $this->globalMemoryLimit > 0) and ++$this->checkTicker >= $this->checkRate){
$this->checkTicker = 0;
$memory = Utils::getMemoryUsage(true);
$trigger = false;
if($this->memoryLimit > 0 and $memory[0] > $this->memoryLimit){
$trigger = 0;
}elseif($this->globalMemoryLimit > 0 and $memory[1] > $this->globalMemoryLimit){
$trigger = 1;
}
if($trigger !== false){
if($this->lowMemory and $this->continuousTrigger){
if(++$this->continuousTriggerTicker >= $this->continuousTriggerRate){
$this->continuousTriggerTicker = 0;
$this->trigger($memory[$trigger], $this->memoryLimit, $trigger > 0, ++$this->continuousTriggerCount);
}
}else{
$this->lowMemory = true;
$this->continuousTriggerCount = 0;
$this->trigger($memory[$trigger], $this->memoryLimit, $trigger > 0);
}
}else{
$this->lowMemory = false;
}
}
if($this->garbageCollectionPeriod > 0 and ++$this->garbageCollectionTicker >= $this->garbageCollectionPeriod){
$this->garbageCollectionTicker = 0;
$this->triggerGarbageCollector();
}
Timings::$memoryManagerTimer->stopTiming();
}
/**
* @return int
*/
public function triggerGarbageCollector() : int{
Timings::$garbageCollectorTimer->startTiming();
if($this->garbageCollectionAsync){
$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);
}
}
$cycles = gc_collect_cycles();
Timings::$garbageCollectorTimer->stopTiming();
return $cycles;
}
/**
* 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);
}
$obData = fopen($outputFolder . "/objects.js", "wb+");
$data = [];
$objects = [];
$refCounts = [];
$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;
foreach($objects as $hash => $object){
if(!is_object($object)){
continue;
}
$continue = true;
$className = get_class($object);
if(!isset($instanceCounts[$className])){
$instanceCounts[$className] = 1;
}else{
$instanceCounts[$className]++;
}
$objects[$hash] = true;
$reflection = new \ReflectionObject($object);
$info = [
"information" => "$hash@$className",
"properties" => []
];
if($reflection->getParentClass()){
$info["parent"] = $reflection->getParentClass()->getName();
}
if(count($reflection->getInterfaceNames()) > 0){
$info["implements"] = implode(", ", $reflection->getInterfaceNames());
}
for($original = $reflection; $reflection !== false; $reflection = $reflection->getParentClass()){
foreach($reflection->getProperties() as $property){
if($property->isStatic()){
continue;
}
$name = $property->getName();
if($reflection !== $original and !$property->isPublic()){
$name = $reflection->getName() . ":" . $name;
}
if(!$property->isPublic()){
$property->setAccessible(true);
}
self::continueDump($property->getValue($object), $info["properties"][$name], $objects, $refCounts, 0, $maxNesting, $maxStringSize);
}
}
fwrite($obData, "$hash@$className: " . json_encode($info, JSON_UNESCAPED_SLASHES) . "\n");
}
}while($continue);
$logger->info("[Dump] Wrote " . count($objects) . " objects");
fclose($obData);
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));
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();
}
/**
* @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;
}
--$maxNesting;
if(is_object($from)){
if(!isset($objects[$hash = spl_object_hash($from)])){
$objects[$hash] = $from;
$refCounts[$hash] = 0;
}
++$refCounts[$hash];
$data = "(object) $hash@" . get_class($from);
}elseif(is_array($from)){
if($recursion >= 5){
$data = "(error) ARRAY RECURSION LIMIT REACHED";
return;
}
$data = [];
foreach($from as $key => $value){
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);
}elseif(is_resource($from)){
$data = "(resource) " . print_r($from, true);
}else{
$data = $from;
}
}
}

View File

@ -19,38 +19,41 @@
*
*/
declare(strict_types=1);
namespace pocketmine;
use pocketmine\metadata\Metadatable;
use pocketmine\metadata\MetadataValue;
use pocketmine\nbt\tag\Compound;
use pocketmine\nbt\tag\CompoundTag;
use pocketmine\plugin\Plugin;
class OfflinePlayer implements IPlayer{
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{
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 Compound ? $this->namedtag["firstPlayed"] : null;
return $this->namedtag instanceof CompoundTag ? $this->namedtag->getLong("firstPlayed", 0, true) : null;
}
public function getLastPlayed(){
return $this->namedtag instanceof Compound ? $this->namedtag["lastPlayed"] : null;
return $this->namedtag instanceof CompoundTag ? $this->namedtag->getLong("lastPlayed", 0, true) : null;
}
public function hasPlayedBefore(){
return $this->namedtag instanceof Compound;
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

@ -2,11 +2,11 @@
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* 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
@ -15,459 +15,257 @@
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*
*/
declare(strict_types=1);
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_integer($key) ? $key : '"' . $key . '"') . "]=>" . PHP_EOL;
++$cnt;
safe_var_dump($value);
--$cnt;
}
echo str_repeat(" ", $cnt) . "}" . PHP_EOL;
break;
case is_integer($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(){
}
const INT32_MIN = -0x80000000;
const INT32_MAX = 0x7fffffff;
}
namespace pocketmine {
use pocketmine\utils\Binary;
use pocketmine\utils\MainLogger;
use pocketmine\utils\Utils;
use pocketmine\wizard\Installer;
const VERSION = "1.4.1";
const API_VERSION = "1.11.0";
const CODENAME = "絶好(Zekkou)ケーキ(Cake)";
const MINECRAFT_VERSION = "v0.10.5 alpha";
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;
const NAME = "PocketMine-MP";
const BASE_VERSION = "3.4.1";
const IS_DEVELOPMENT_BUILD = false;
const BUILD_NUMBER = 0;
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(!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)){
require_once(\pocketmine\PATH . "src/spl/ThreadedFactory.php");
require_once(\pocketmine\PATH . "src/spl/ClassLoader.php");
require_once(\pocketmine\PATH . "src/spl/BaseClassLoader.php");
require_once(\pocketmine\PATH . "src/pocketmine/CompatibleClassLoader.php");
}
$autoloader = new CompatibleClassLoader();
$autoloader->addPath(\pocketmine\PATH . "src");
$autoloader->addPath(\pocketmine\PATH . "src" . DIRECTORY_SEPARATOR . "spl");
$autoloader->register(true);
set_time_limit(0); //Who set it to 30 seconds?!?!
gc_enable();
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("", ["enable-ansi", "disable-ansi", "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);
define("pocketmine\\ANSI", (Utils::getOS() !== "win" or isset($opts["enable-ansi"])) and !isset($opts["disable-ansi"]));
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.
*/
$default_timezone = date_default_timezone_get();
if(strpos($default_timezone, "/") === false){
$default_timezone = timezone_name_from_abbr($default_timezone);
ini_set("date.timezone", $default_timezone);
date_default_timezone_set($default_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:
exec("kill -9 " . ((int) $pid) . " > /dev/null 2>&1");
}
}
function getTrace($start = 1, $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 [
\pocketmine\NAME . " requires PHP >= " . MIN_PHP_VERSION . ", 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()" : @strval($value))) . ", ";
}
if(PHP_INT_SIZE < 8){
$messages[] = "Running " . \pocketmine\NAME . " with 32-bit systems/PHP is 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[] = "You must run " . \pocketmine\NAME . " using the CLI.";
}
$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"] . "(" . 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.1.7dev") < 0){
$messages[] = "pthreads >= 3.1.7dev 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), "/");
}
set_error_handler([\ExceptionHandler::class, "handler"], -1);
$errors = 0;
if(version_compare("5.6.0", PHP_VERSION) > 0){
$logger->critical("You must use PHP >= 5.6");
++$errors;
}
if(php_sapi_name() !== "cli"){
$logger->critical("You must run PocketMine-MP using the CLI.");
++$errors;
}
if(!extension_loaded("sockets")){
$logger->critical("Unable to find the Socket extension.");
++$errors;
}
$pthreads_version = phpversion("pthreads");
if(substr_count($pthreads_version, ".") < 2){
$pthreads_version = "0.$pthreads_version";
}
if(version_compare($pthreads_version, "2.0.9") < 0){
$logger->critical("pthreads >= 2.0.9 is required, while you have $pthreads_version.");
++$errors;
}
if(!extension_loaded("uopz")){
//$logger->notice("Couldn't find the uopz extension. Some functions may be limited");
}
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;
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);
error_reporting(-1);
if(\Phar::running(true) !== ""){
define('pocketmine\PATH', \Phar::running(true) . "/");
}else{
define('pocketmine\PATH', dirname(__FILE__, 3) . DIRECTORY_SEPARATOR);
}
if(!extension_loaded("Weakref") and !extension_loaded("weakref")){
$logger->critical("Unable to find the Weakref extension.");
++$errors;
$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);
}
if(!extension_loaded("curl")){
$logger->critical("Unable to find the cURL extension.");
++$errors;
set_error_handler([Utils::class, 'errorExceptionHandler']);
/*
* We now use the Composer autoloader, but this autoloader is still for loading plugins.
*/
$autoloader = new \BaseClassLoader();
$autoloader->register(false);
set_time_limit(0); //Who set it to 30 seconds?!?!
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));
define('pocketmine\RESOURCE_PATH', \pocketmine\PATH . 'src' . DIRECTORY_SEPARATOR . 'pocketmine' . DIRECTORY_SEPARATOR . 'resources' . DIRECTORY_SEPARATOR);
$opts = getopt("", ["data:", "plugins:", "no-wizard"]);
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)){
mkdir(\pocketmine\DATA, 0777, true);
}
if(!extension_loaded("sqlite3")){
$logger->critical("Unable to find the SQLite3 extension.");
++$errors;
//Logger has a dependency on timezone
$tzError = Timezone::init();
$logger = new MainLogger(\pocketmine\DATA . "server.log");
$logger->registerStatic();
foreach($tzError as $e){
$logger->warning($e);
}
unset($tzError);
if(!extension_loaded("yaml")){
$logger->critical("Unable to find the YAML extension.");
++$errors;
}
if(!extension_loaded("zlib")){
$logger->critical("Unable to find the Zlib extension.");
++$errors;
}
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
}
if(file_exists(\pocketmine\PATH . ".git/refs/heads/master")){ //Found Git information!
define("pocketmine\\GIT_COMMIT", strtolower(trim(file_get_contents(\pocketmine\PATH . ".git/refs/heads/master"))));
}else{ //Unknown :(
define("pocketmine\\GIT_COMMIT", str_repeat("00", 20));
}
@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(Utils::getRandomBytes(8, false))); //Fix OPCache address errors
if(!file_exists(\pocketmine\DATA . "server.properties") and !isset($opts["no-wizard"])){
new Installer();
if(extension_loaded("xdebug")){
$logger->warning(PHP_EOL . PHP_EOL . PHP_EOL . "\tYou are running " . \pocketmine\NAME . " with xdebug enabled. This has a major impact on performance." . PHP_EOL . PHP_EOL);
}
if(\Phar::running(true) === ""){
$logger->warning("Non-packaged PocketMine-MP installation detected, do not use on production.");
$logger->warning("Non-packaged " . \pocketmine\NAME . " installation detected. Consider using a phar in production for better performance.");
}
ThreadManager::init();
$server = new Server($autoloader, $logger, \pocketmine\PATH, \pocketmine\DATA, \pocketmine\PLUGIN_PATH);
$version = new VersionString(\pocketmine\BASE_VERSION, \pocketmine\IS_DEVELOPMENT_BUILD, \pocketmine\BUILD_NUMBER);
define('pocketmine\VERSION', $version->getFullVersion(true));
$logger->info("Stopping other threads");
$gitHash = str_repeat("00", 20);
foreach(ThreadManager::getInstance()->getAll() as $id => $thread){
if($thread->isRunning()){
$logger->debug("Stopping " . (new \ReflectionClass($thread))->getShortName() . " thread");
if($thread instanceof Thread){
$thread->kill();
sleep(1);
if($thread->isRunning()){
$thread->detach();
}
}elseif($thread instanceof Worker){
$thread->kill();
sleep(1);
if($thread->isRunning()){
$thread->detach();
}
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";
}
}elseif(!$thread->isJoined()){
$logger->debug("Joining " . (new \ReflectionClass($thread))->getShortName() . " thread");
$thread->join();
}
}else{
$phar = new \Phar(\Phar::running(false));
$meta = $phar->getMetadata();
if(isset($meta["git"])){
$gitHash = $meta["git"];
}
}
define('pocketmine\GIT_COMMIT', $gitHash);
@define("INT32_MASK", is_int(0xffffffff) ? 0xffffffff : -1);
@ini_set("opcache.mmap_base", bin2hex(random_bytes(8))); //Fix OPCache address errors
$exitCode = 0;
do{
if(!file_exists(\pocketmine\DATA . "server.properties") and !isset($opts["no-wizard"])){
$installer = new SetupWizard();
if(!$installer->run()){
$exitCode = -1;
break;
}
}
ThreadManager::init();
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){
if(\pocketmine\DEBUG > 1){
echo "Some threads could not be stopped, performing a force-kill" . PHP_EOL . PHP_EOL;
}
Utils::kill(getmypid());
}
}while(false);
$logger->shutdown();
$logger->join();
exit(0);
echo Terminal::$FORMAT_RESET . PHP_EOL;
exit($exitCode);
}

File diff suppressed because it is too large Load Diff

View File

@ -19,6 +19,8 @@
*
*/
declare(strict_types=1);
namespace pocketmine;
/**
@ -26,13 +28,66 @@ namespace pocketmine;
*/
abstract class Thread extends \Thread{
public function start($options = PTHREADS_INHERIT_ALL){
/** @var \ClassLoader */
protected $classLoader;
/** @var string|null */
protected $composerAutoloaderPath;
protected $isKilled = false;
public function getClassLoader(){
return $this->classLoader;
}
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($this->composerAutoloaderPath !== null){
require $this->composerAutoloaderPath;
}
if($this->classLoader !== null){
$this->classLoader->register(false);
}
}
public function start(?int $options = \PTHREADS_INHERIT_ALL){
ThreadManager::getInstance()->add($this);
if(!$this->isRunning() and !$this->isJoined() and !$this->isTerminated()){
return parent::start($options);
if($this->getClassLoader() === null){
$this->setClassLoader();
}
return parent::start($options);
}
/**
* Stops the thread using the best way possible. Try to stop it yourself before calling this.
*/
public function quit(){
$this->isKilled = true;
if(!$this->isJoined()){
$this->notify();
$this->join();
}
return false;
ThreadManager::getInstance()->remove($this);
}
}
public function getThreadName() : string{
return (new \ReflectionClass($this))->getShortName();
}
}

View File

@ -19,9 +19,13 @@
*
*/
declare(strict_types=1);
namespace pocketmine;
class ThreadManager extends \Threaded{
use pocketmine\utils\MainLogger;
class ThreadManager extends \Volatile{
/** @var ThreadManager */
private static $instance = null;
@ -58,7 +62,7 @@ class ThreadManager extends \Threaded{
/**
* @return Worker[]|Thread[]
*/
public function getAll(){
public function getAll() : array{
$array = [];
foreach($this as $key => $thread){
$array[$key] = $thread;
@ -66,4 +70,23 @@ class ThreadManager extends \Threaded{
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

@ -19,6 +19,8 @@
*
*/
declare(strict_types=1);
namespace pocketmine;
/**
@ -26,13 +28,67 @@ namespace pocketmine;
*/
abstract class Worker extends \Worker{
public function start($options = PTHREADS_INHERIT_ALL){
/** @var \ClassLoader */
protected $classLoader;
/** @var string|null */
protected $composerAutoloaderPath;
protected $isKilled = false;
public function getClassLoader(){
return $this->classLoader;
}
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($this->composerAutoloaderPath !== null){
require $this->composerAutoloaderPath;
}
if($this->classLoader !== null){
$this->classLoader->register(false);
}
}
public function start(?int $options = \PTHREADS_INHERIT_ALL){
ThreadManager::getInstance()->add($this);
if(!$this->isRunning() and !$this->isJoined() and !$this->isTerminated() and !$this->isShutdown()){
return parent::start($options);
if($this->getClassLoader() === null){
$this->setClassLoader();
}
return parent::start($options);
}
/**
* Stops the thread using the best way possible. Try to stop it yourself before calling this.
*/
public function quit(){
$this->isKilled = true;
if($this->isRunning()){
while($this->unstack() !== null);
$this->notify();
$this->shutdown();
}
return false;
ThreadManager::getInstance()->remove($this);
}
}
public function getThreadName() : string{
return (new \ReflectionClass($this))->getShortName();
}
}

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/
*
*
*/
declare(strict_types=1);
namespace pocketmine\block;
class ActivatorRail extends RedstoneRail{
protected $id = self::ACTIVATOR_RAIL;
public function getName() : string{
return "Activator Rail";
}
//TODO
}

View File

@ -2,11 +2,11 @@
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* 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
@ -15,13 +15,16 @@
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*
*/
declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\item\Item;
use pocketmine\math\AxisAlignedBB;
/**
@ -30,38 +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 isBreakable(Item $item){
return false;
}
public function canBeFlowedInto(){
public function canPassThrough() : bool{
return true;
}
public function canBeReplaced(){
public function isBreakable(Item $item) : bool{
return false;
}
public function canBeFlowedInto() : bool{
return true;
}
public function canBePlaced(){
public function canBeReplaced() : bool{
return true;
}
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 getCollisionBoxes() : array{
return [];
}
public function getHardness() : float{
return -1;
}
public function getBlastResistance() : float{
return 0;
}
}

View File

@ -0,0 +1,115 @@
<?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\inventory\AnvilInventory;
use pocketmine\item\Item;
use pocketmine\item\TieredTool;
use pocketmine\math\AxisAlignedBB;
use pocketmine\math\Vector3;
use pocketmine\Player;
class Anvil extends Fallable{
public const TYPE_NORMAL = 0;
public const TYPE_SLIGHTLY_DAMAGED = 4;
public const TYPE_VERY_DAMAGED = 8;
protected $id = self::ANVIL;
public function __construct(int $meta = 0){
$this->meta = $meta;
}
public function isTransparent() : bool{
return true;
}
public function getHardness() : float{
return 5;
}
public function getBlastResistance() : float{
return 6000;
}
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->getVariant()] ?? "Anvil";
}
public function getToolType() : int{
return BlockToolType::TYPE_PICKAXE;
}
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));
}
return true;
}
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->getVariant() | $direction;
return $this->getLevel()->setBlock($blockReplace, $this, true, true);
}
}

View File

@ -0,0 +1,266 @@
<?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 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

@ -2,11 +2,11 @@
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* 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
@ -15,39 +15,46 @@
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*
*/
declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\item\Item;
use pocketmine\item\ItemFactory;
use pocketmine\lang\TranslationContainer;
use pocketmine\level\Level;
use pocketmine\math\AxisAlignedBB;
use pocketmine\network\protocol\ChatPacket;
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() : float{
return 0.2;
}
public function getHardness(){
return 1;
}
public function getName(){
public function getName() : string{
return "Bed Block";
}
protected function recalculateBoundingBox(){
protected function recalculateBoundingBox() : ?AxisAlignedBB{
return new AxisAlignedBB(
$this->x,
$this->y,
@ -58,71 +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){
$pk = new ChatPacket();
$pk->message = "You can only sleep at night";
$player->dataPacket($pk);
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){
$pk = new ChatPacket();
$pk->message = "This bed is incomplete";
$player->dataPacket($pk);
}
$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){
$pk = new ChatPacket();
$pk->message = "This bed is occupied";
$player->dataPacket($pk);
$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;
}
@ -131,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

@ -2,11 +2,11 @@
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* 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
@ -15,10 +15,12 @@
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*
*/
declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\item\Item;
@ -27,20 +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 getBlastResistance() : float{
return 18000000;
}
public function isBreakable(Item $item){
public function isBreakable(Item $item) : bool{
return false;
}
}
}

View File

@ -2,11 +2,11 @@
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* 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
@ -15,35 +15,43 @@
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*
*/
declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\item\Item;
use pocketmine\item\ItemFactory;
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,468 @@
<?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;
/**
* 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;
/** @var int[] */
public static $staticRuntimeIdMap = [];
/** @var int[] */
public static $legacyIdMap = [];
/** @var int */
private static $lastRuntimeId = 0;
/**
* 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
//TODO: 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());
//TODO: INFO_UPDATE
//TODO: INFO_UPDATE2
//TODO: MOVINGBLOCK
//TODO: OBSERVER
//TODO: STRUCTURE_BLOCK
//TODO: 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);
}
public static function registerStaticRuntimeIdMappings() : void{
/** @var mixed[] $runtimeIdMap */
$runtimeIdMap = json_decode(file_get_contents(\pocketmine\RESOURCE_PATH . "runtimeid_table.json"), true);
foreach($runtimeIdMap as $k => $obj){
self::registerMapping($k, $obj["id"], $obj["data"]);
}
}
/**
* @internal
*
* @param int $id
* @param int $meta
*
* @return int
*/
public static function toStaticRuntimeId(int $id, int $meta = 0) : int{
/*
* try id+meta first
* if not found, try id+0 (strip meta)
* if still not found, return update! block
*/
return self::$staticRuntimeIdMap[($id << 4) | $meta] ?? self::$staticRuntimeIdMap[$id << 4] ?? self::$staticRuntimeIdMap[BlockIds::INFO_UPDATE << 4];
}
/**
* @internal
*
* @param int $runtimeId
*
* @return int[] [id, meta]
*/
public static function fromStaticRuntimeId(int $runtimeId) : array{
$v = self::$legacyIdMap[$runtimeId];
return [$v >> 4, $v & 0xf];
}
private static function registerMapping(int $staticRuntimeId, int $legacyId, int $legacyMeta) : void{
self::$staticRuntimeIdMap[($legacyId << 4) | $legacyMeta] = $staticRuntimeId;
self::$legacyIdMap[$staticRuntimeId] = ($legacyId << 4) | $legacyMeta;
self::$lastRuntimeId = max(self::$lastRuntimeId, $staticRuntimeId);
}
}

View File

@ -0,0 +1,279 @@
<?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;
interface BlockIds{
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;
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;
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;
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;
public const PURPUR_STAIRS = 203;
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;
public const MAGMA = 213;
public const NETHER_WART_BLOCK = 214;
public const RED_NETHER_BRICK = 215;
public const BONE_BLOCK = 216;
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;
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;
public const CHORUS_PLANT = 240;
public const STAINED_GLASS = 241;
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;
}

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

@ -2,11 +2,11 @@
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* 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
@ -15,27 +15,52 @@
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*
*/
declare(strict_types=1);
namespace pocketmine\block;
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(){
return 7.5;
public function getHardness() : float{
return 1.5;
}
}
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

@ -0,0 +1,60 @@
<?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\item\TieredTool;
class BrewingStand extends Transparent{
protected $id = self::BREWING_STAND_BLOCK;
protected $itemId = Item::BREWING_STAND;
public function __construct(int $meta = 0){
$this->meta = $meta;
}
public function getName() : string{
return "Brewing Stand";
}
public function getHardness() : float{
return 0.5;
}
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

@ -2,11 +2,11 @@
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* 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
@ -15,23 +15,41 @@
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*
*/
declare(strict_types=1);
namespace pocketmine\block;
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 getName(){
return "Brick Stairs";
public function getHardness() : float{
return 2;
}
}
public function getBlastResistance() : float{
return 30;
}
public function getToolType() : int{
return BlockToolType::TYPE_PICKAXE;
}
public function getToolHarvestLevel() : int{
return TieredTool::TIER_WOODEN;
}
public function getName() : string{
return "Brick Stairs";
}
}

View File

@ -2,11 +2,11 @@
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* 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
@ -15,54 +15,41 @@
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*
*/
declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\item\Item;
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 getBlastResistance() : float{
return 30;
}
public function getName(){
public function getToolType() : int{
return BlockToolType::TYPE_PICKAXE;
}
public function getToolHarvestLevel() : int{
return TieredTool::TIER_WOODEN;
}
public function getName() : string{
return "Bricks";
}
public function getBreakTime(Item $item){
switch($item->isPickaxe()){
case 5:
return 0.4;
case 4:
return 0.5;
case 3:
return 0.75;
case 2:
return 0.25;
case 1:
return 1.5;
default:
return 10;
}
}
public function getDrops(Item $item){
if($item->isPickaxe() >= 1){
return [
[Item::BRICKS_BLOCK, 0, 1],
];
}else{
return [];
}
}
}
}

View File

@ -2,11 +2,11 @@
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* 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
@ -15,57 +15,23 @@
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*
*/
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

@ -2,11 +2,11 @@
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* 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
@ -15,29 +15,27 @@
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*
*/
declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\item\Item;
class DarkOakWoodStairs extends Stair{
class BrownMushroomBlock extends RedMushroomBlock{
protected $id = self::DARK_OAK_WOOD_STAIRS;
protected $id = Block::BROWN_MUSHROOM_BLOCK;
public function __construct($meta = 0){
$this->meta = $meta;
public function getName() : string{
return "Brown Mushroom Block";
}
public function getName(){
return "Dark Oak Wood Stairs";
}
public function getDrops(Item $item){
public function getDropsForCompatibleTool(Item $item) : array{
return [
[$this->id, 0, 1],
Item::get(Item::BROWN_MUSHROOM, 0, mt_rand(0, 2))
];
}
}
}

View File

@ -2,11 +2,11 @@
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* 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
@ -15,93 +15,74 @@
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*
*/
declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\item\Item;
use pocketmine\nbt\NBT;
use pocketmine\nbt\tag\Compound;
use pocketmine\nbt\tag\Enum;
use pocketmine\nbt\tag\Int;
use pocketmine\nbt\tag\String;
use pocketmine\item\TieredTool;
use pocketmine\math\Vector3;
use pocketmine\Player;
use pocketmine\tile\Furnace;
use pocketmine\tile\Furnace as TileFurnace;
use pocketmine\tile\Tile;
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() : float{
return 3.5;
}
public function getHardness(){
return 17.5;
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 Compound(false, [
new Enum("Items", []),
new String("id", Tile::FURNACE),
new Int("x", $this->x),
new Int("y", $this->y),
new Int("z", $this->z)
]);
$nbt->Items->setTagType(NBT::TAG_Compound);
Tile::createTile("Furnace", $this->getLevel()->getChunk($this->x >> 4, $this->z >> 4), $nbt);
$this->getLevel()->setBlock($blockReplace, $this, true, true);
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){
$t = $this->getLevel()->getTile($this);
$furnace = false;
if($t instanceof Furnace){
$furnace = $t;
}else{
$nbt = new Compound(false, [
new Enum("Items", []),
new String("id", Tile::FURNACE),
new Int("x", $this->x),
new Int("y", $this->y),
new Int("z", $this->z)
]);
$nbt->Items->setTagType(NBT::TAG_Compound);
$furnace = Tile::createTile("Furnace", $this->getLevel()->getChunk($this->x >> 4, $this->z >> 4), $nbt);
$furnace = $this->getLevel()->getTile($this);
if(!($furnace instanceof TileFurnace)){
$furnace = Tile::createTile(Tile::FURNACE, $this->getLevel(), TileFurnace::createNBT($this));
}
if(($player->getGamemode() & 0x01) === 0x01){
if(!$furnace->canOpenWith($item->getCustomName())){
return true;
}
@ -111,29 +92,7 @@ class BurningFurnace extends Solid{
return true;
}
public function getBreakTime(Item $item){
switch($item->isPickaxe()){
case 5:
return 0.7;
case 4:
return 0.9;
case 3:
return 1.35;
case 2:
return 0.45;
case 1:
return 2.65;
default:
return 17.5;
}
public function getVariantBitmask() : int{
return 0;
}
public function getDrops(Item $item){
$drops = [];
if($item->isPickaxe() >= 1){
$drops[] = [Item::FURNACE, 0, 1];
}
return $drops;
}
}
}

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,110 +19,105 @@
*
*/
declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\entity\Entity;
use pocketmine\event\block\BlockGrowEvent;
use pocketmine\event\entity\EntityDamageByBlockEvent;
use pocketmine\event\entity\EntityDamageEvent;
use pocketmine\inventory\InventoryHolder;
use pocketmine\inventory\PlayerInventory;
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(){
return 2;
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,
$this->y,
$this->y + 0.0625,
$this->z + 0.0625,
$this->x + 0.9375,
$this->y + 1,
$this->y + 0.9375,
$this->z + 0.9375
);
}
public function onEntityCollide(Entity $entity){
$damage = [EntityDamageEvent::MODIFIER_BASE => 1];
if($entity instanceof InventoryHolder){
$inventory = $entity->getInventory();
if($inventory instanceof PlayerInventory){
$damage[EntityDamageEvent::MODIFIER_ARMOR] = $inventory->getArmorPoints();
}
}
$ev = new EntityDamageByBlockEvent($this, $entity, EntityDamageEvent::CAUSE_CONTACT, $damage);
$entity->attack($ev->getFinalDamage(), $ev);
public function onEntityCollide(Entity $entity) : void{
$ev = new EntityDamageByBlockEvent($this, $entity, EntityDamageEvent::CAUSE_CONTACT, 1);
$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);
}
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;
}
}
}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);
}
}
}
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()){
$this->getLevel()->setBlock($b, $ev->getNewState(), true);
}
}
$this->meta = 0;
$this->getLevel()->setBlock($this, $this);
}else{
++$this->meta;
$this->getLevel()->setBlock($this, $this);
}
$this->meta = 0;
$this->getLevel()->setBlock($this, $this);
}else{
++$this->meta;
$this->getLevel()->setBlock($this, $this);
}
}
return false;
}
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::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;
@ -132,9 +127,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

@ -2,11 +2,11 @@
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* 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
@ -15,45 +15,46 @@
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*
*/
declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\event\entity\EntityRegainHealthEvent;
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;
use pocketmine\Server;
class Cake extends Transparent{
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() : float{
return 0.5;
}
public function getHardness(){
return 2.5;
public function getName() : string{
return "Cake";
}
public function getName(){
return "Cake Block";
}
protected function recalculateBoundingBox() : ?AxisAlignedBB{
protected function recalculateBoundingBox(){
$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,
@ -62,10 +63,10 @@ class Cake extends Transparent{
);
}
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;
}
@ -73,39 +74,61 @@ class Cake extends Transparent{
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() < 20){
++$this->meta;
Server::getInstance()->getPluginManager()->callEvent($ev = new EntityRegainHealthEvent($player, 3, EntityRegainHealthEvent::CAUSE_EATING));
if(!$ev->isCancelled()){
$player->heal($ev->getAmount(), $ev);
}
if($this->meta >= 0x06){
$this->getLevel()->setBlock($this, new Air(), true);
}else{
$this->getLevel()->setBlock($this, $this, true);
}
public function isAffectedBySilkTouch() : bool{
return false;
}
public function onActivate(Item $item, Player $player = null) : bool{
if($player !== null){
$player->consumeObject($this);
return true;
}
return false;
}
}
public function getFoodRestore() : int{
return 2;
}
public function getSaturationRestore() : float{
return 0.4;
}
public function requiresHunger() : bool{
return true;
}
/**
* @return Block
*/
public function getResidue(){
$clone = clone $this;
$clone->meta++;
if($clone->meta > 0x06){
$clone = BlockFactory::get(Block::AIR);
}
return $clone;
}
/**
* @return EffectInstance[]
*/
public function getAdditionalEffects() : array{
return [];
}
public function onConsume(Living $consumer) : void{
$this->level->setBlock($this, $this->getResidue());
}
}

View File

@ -2,11 +2,11 @@
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* 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
@ -15,52 +15,41 @@
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*
*/
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 isSolid(){
public function getHardness() : float{
return 0.1;
}
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->meta) . " Carpet";
}
protected function recalculateBoundingBox(){
protected function recalculateBoundingBox() : ?AxisAlignedBB{
return new AxisAlignedBB(
$this->x,
@ -72,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;
}
@ -83,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

@ -2,11 +2,11 @@
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* 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
@ -15,34 +15,36 @@
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*
*/
declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\item\Item;
use pocketmine\item\ItemFactory;
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

@ -2,11 +2,11 @@
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* 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
@ -15,19 +15,17 @@
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*
*/
declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\item\Item;
use pocketmine\math\AxisAlignedBB;
use pocketmine\nbt\NBT;
use pocketmine\nbt\tag\Compound;
use pocketmine\nbt\tag\Enum;
use pocketmine\nbt\tag\Int;
use pocketmine\nbt\tag\String;
use pocketmine\math\Vector3;
use pocketmine\Player;
use pocketmine\tile\Chest as TileChest;
use pocketmine\tile\Tile;
@ -36,39 +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() : float{
return 2.5;
}
public function getHardness(){
return 15;
}
public function getName(){
public function getName() : string{
return "Chest";
}
protected function recalculateBoundingBox(){
public function getToolType() : int{
return BlockToolType::TYPE_AXE;
}
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;
@ -81,7 +80,7 @@ class Chest extends Transparent{
continue;
}
$c = $this->getSide($side);
if($c instanceof Chest and $c->getDamage() === $this->meta){
if($c->getId() === $this->id and $c->getDamage() === $this->meta){
$tile = $this->getLevel()->getTile($c);
if($tile instanceof TileChest and !$tile->isPaired()){
$chest = $tile;
@ -90,16 +89,8 @@ class Chest extends Transparent{
}
}
$this->getLevel()->setBlock($block, $this, true, true);
$nbt = new Compound(false, [
new Enum("Items", []),
new String("id", Tile::CHEST),
new Int("x", $this->x),
new Int("y", $this->y),
new Int("z", $this->z)
]);
$nbt->Items->setTagType(NBT::TAG_Compound);
$tile = Tile::createTile("Chest", $this->getLevel()->getChunk($this->x >> 4, $this->z >> 4), $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);
@ -109,52 +100,36 @@ 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 Compound(false, [
new Enum("Items", []),
new String("id", Tile::CHEST),
new Int("x", $this->x),
new Int("y", $this->y),
new Int("z", $this->z)
]);
$nbt->Items->setTagType(NBT::TAG_Compound);
$chest = Tile::createTile("Chest", $this->getLevel()->getChunk($this->x >> 4, $this->z >> 4), $nbt);
$chest = Tile::createTile(Tile::CHEST, $this->getLevel(), TileChest::createNBT($this));
}
if($player->isCreative()){
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

@ -2,11 +2,11 @@
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* 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
@ -15,33 +15,40 @@
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*
*/
declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\item\Item;
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(){
return 3;
public function getHardness() : float{
return 0.6;
}
public function getName(){
public function getToolType() : int{
return BlockToolType::TYPE_SHOVEL;
}
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

@ -2,11 +2,11 @@
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* 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
@ -15,54 +15,49 @@
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*
*/
declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\item\Item;
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(){
return 30;
public function getHardness() : float{
return 5;
}
public function getName(){
public function getToolType() : int{
return BlockToolType::TYPE_PICKAXE;
}
public function getToolHarvestLevel() : int{
return TieredTool::TIER_WOODEN;
}
public function getName() : string{
return "Coal Block";
}
public function getBreakTime(Item $item){
switch($item->isPickaxe()){
case 5:
return 0.95;
case 4:
return 1.25;
case 3:
return 1.9;
case 2:
return 0.65;
case 1:
return 3.75;
default:
return 25;
}
public function getFuelTime() : int{
return 16000;
}
public function getDrops(Item $item){
if($item->isPickaxe() >= 1){
return [
[Item::COAL_BLOCK, 0, 1],
];
}else{
return [];
}
public function getFlameEncouragement() : int{
return 5;
}
}
public function getFlammability() : int{
return 5;
}
}

View File

@ -2,11 +2,11 @@
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* 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
@ -15,55 +15,49 @@
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*
*/
declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\item\Item;
use pocketmine\item\ItemFactory;
use pocketmine\item\TieredTool;
class CoalOre extends Solid{
protected $id = self::COAL_ORE;
public function __construct(){
public function __construct(int $meta = 0){
$this->meta = $meta;
}
public function getHardness(){
return 15;
public function getHardness() : float{
return 3;
}
public function getName(){
public function getToolType() : int{
return BlockToolType::TYPE_PICKAXE;
}
public function getToolHarvestLevel() : int{
return TieredTool::TIER_WOODEN;
}
public function getName() : string{
return "Coal Ore";
}
public function getBreakTime(Item $item){
switch($item->isPickaxe()){
case 5:
return 0.6;
case 4:
return 0.75;
case 3:
return 1.15;
case 2:
return 0.4;
case 1:
return 2.25;
default:
return 15;
}
public function getDropsForCompatibleTool(Item $item) : array{
return [
ItemFactory::get(Item::COAL)
];
}
public function getDrops(Item $item){
if($item->isPickaxe() >= 1){
return [
[Item::COAL, 0, 1],
];
}else{
return [];
}
protected function getXpDropAmount() : int{
return mt_rand(0, 2);
}
}
}

View File

@ -2,11 +2,11 @@
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* 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
@ -15,54 +15,37 @@
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*
*/
declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\item\Item;
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 getName(){
public function getToolType() : int{
return BlockToolType::TYPE_PICKAXE;
}
public function getToolHarvestLevel() : int{
return TieredTool::TIER_WOODEN;
}
public function getName() : string{
return "Cobblestone";
}
public function getHardness(){
return 30;
public function getHardness() : float{
return 2;
}
public function getBreakTime(Item $item){
switch($item->isPickaxe()){
case 5:
return 0.4;
case 4:
return 0.5;
case 3:
return 0.75;
case 2:
return 0.25;
case 1:
return 1.5;
default:
return 10;
}
}
public function getDrops(Item $item){
if($item->isPickaxe() >= 1){
return [
[Item::COBBLESTONE, 0, 1],
];
}else{
return [];
}
}
}
}

View File

@ -2,11 +2,11 @@
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* 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
@ -15,23 +15,37 @@
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*
*/
declare(strict_types=1);
namespace pocketmine\block;
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 getName(){
return "Cobblestone Stairs";
public function getHardness() : float{
return 2;
}
}
public function getToolType() : int{
return BlockToolType::TYPE_PICKAXE;
}
public function getToolHarvestLevel() : int{
return TieredTool::TIER_WOODEN;
}
public function getName() : string{
return "Cobblestone Stairs";
}
}

View File

@ -0,0 +1,93 @@
<?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;
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{
if($this->meta === 0x01){
return "Mossy Cobblestone Wall";
}
return "Cobblestone 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

@ -2,11 +2,11 @@
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* 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
@ -15,41 +15,57 @@
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*
*/
declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\entity\Entity;
use pocketmine\item\Item;
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(){
return 25;
public function getHardness() : float{
return 4;
}
public function onEntityCollide(Entity $entity){
public function getToolType() : int{
return BlockToolType::TYPE_SWORD | BlockToolType::TYPE_SHEARS;
}
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

@ -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;
class CocoaBlock extends Transparent{
protected $id = self::COCOA_BLOCK;
public function __construct(int $meta = 0){
$this->meta = $meta;
}
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->meta) . " 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->meta) . " 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

@ -2,11 +2,11 @@
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* 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
@ -15,47 +15,47 @@
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*
*/
declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\inventory\CraftingGrid;
use pocketmine\item\Item;
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() : float{
return 2.5;
}
public function getHardness(){
return 15;
}
public function getName(){
public function getName() : string{
return "Crafting Table";
}
public function onActivate(Item $item, Player $player = null){
public function getToolType() : int{
return BlockToolType::TYPE_AXE;
}
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

@ -2,11 +2,11 @@
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* 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
@ -15,28 +15,24 @@
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*
*/
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;
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,7 +41,7 @@ abstract class Crops extends Flowable{
}
public function onActivate(Item $item, Player $player = null){
public function onActivate(Item $item, Player $player = null) : bool{
if($item->getId() === Item::DYE and $item->getDamage() === 0x0F){ //Bonemeal
$block = clone $this;
$block->meta += mt_rand(2, 5);
@ -53,8 +49,8 @@ abstract class Crops extends Flowable{
$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 +63,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

@ -2,11 +2,11 @@
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* 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
@ -15,33 +15,35 @@
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*
*/
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

@ -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;
class DaylightSensor extends Transparent{
protected $id = self::DAYLIGHT_SENSOR;
public function __construct(int $meta = 0){
$this->meta = $meta;
}
public function getName() : string{
return "Daylight Sensor";
}
public function getHardness() : float{
return 0.2;
}
public function getFuelTime() : int{
return 300;
}
public function getToolType() : int{
return BlockToolType::TYPE_AXE;
}
//TODO
}

View File

@ -2,11 +2,11 @@
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* 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
@ -15,37 +15,68 @@
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*
*/
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;
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

@ -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/
*
*
*/
declare(strict_types=1);
namespace pocketmine\block;
class DetectorRail extends RedstoneRail{
protected $id = self::DETECTOR_RAIL;
public function getName() : string{
return "Detector Rail";
}
//TODO
}

View File

@ -2,11 +2,11 @@
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* 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
@ -15,48 +15,37 @@
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*
*/
declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\item\Item;
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(){
return 30;
public function getHardness() : float{
return 5;
}
public function getName(){
public function getName() : string{
return "Diamond Block";
}
public function getBreakTime(Item $item){
switch($item->isPickaxe()){
case 5:
return 0.95;
case 4:
return 1.25;
default:
return 25;
}
public function getToolType() : int{
return BlockToolType::TYPE_PICKAXE;
}
public function getDrops(Item $item){
if($item->isPickaxe() >= 4){
return [
[Item::DIAMOND_BLOCK, 0, 1],
];
}else{
return [];
}
public function getToolHarvestLevel() : int{
return TieredTool::TIER_IRON;
}
}
}

View File

@ -2,11 +2,11 @@
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* 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
@ -15,48 +15,49 @@
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*
*/
declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\item\Item;
use pocketmine\item\ItemFactory;
use pocketmine\item\TieredTool;
class DiamondOre extends Solid{
protected $id = self::DIAMOND_ORE;
public function __construct(){
public function __construct(int $meta = 0){
$this->meta = $meta;
}
public function getHardness(){
return 15;
public function getHardness() : float{
return 3;
}
public function getName(){
public function getName() : string{
return "Diamond Ore";
}
public function getBreakTime(Item $item){
switch($item->isPickaxe()){
case 5:
return 0.6;
case 4:
return 0.75;
default:
return 15;
}
public function getToolType() : int{
return BlockToolType::TYPE_PICKAXE;
}
public function getDrops(Item $item){
if($item->isPickaxe() >= 4){
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

@ -2,11 +2,11 @@
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* 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
@ -15,12 +15,15 @@
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*
*/
declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\item\Hoe;
use pocketmine\item\Item;
use pocketmine\Player;
@ -28,30 +31,37 @@ 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() : float{
return 0.5;
}
public function getHardness(){
return 2.5;
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

@ -2,11 +2,11 @@
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* 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
@ -15,48 +15,45 @@
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*
*/
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\network\protocol\LevelEventPacket;
use pocketmine\math\Vector3;
use pocketmine\Player;
use pocketmine\Server;
abstract class Door extends Transparent{
public function canBeActivated(){
return true;
}
public function isSolid(){
public function isSolid() : bool{
return false;
}
private function getFullDamage(){
$damage = $this->getDamage();
$flag = ($damage & 0x08) > 0;
$isUp = ($damage & 0x08) > 0;
if($flag){
$first = $this->getSide(0)->getDamage();
$second = $damage;
if($isUp){
$down = $this->getSide(Vector3::SIDE_DOWN)->getDamage();
$up = $damage;
}else{
$first = $damage;
$second = $this->getSide(1)->getDamage();
$down = $damage;
$up = $this->getSide(Vector3::SIDE_UP)->getDamage();
}
$flag1 = ($second & 0x01) > 0;
$isRight = ($up & 0x01) > 0;
return $first & 0x07 | ($flag ? 8 : 0) | ($flag1 ? 0x10 : 0);
return $down & 0x07 | ($isUp ? 8 : 0) | ($isRight ? 0x10 : 0);
}
protected function recalculateBoundingBox(){
protected function recalculateBoundingBox() : ?AxisAlignedBB{
$f = 0.1875;
$damage = $this->getFullDamage();
@ -71,12 +68,12 @@ abstract class Door extends Transparent{
);
$j = $damage & 0x03;
$flag = (($damage & 0x04) > 0);
$flag1 = (($damage & 0x10) > 0);
$isOpen = (($damage & 0x04) > 0);
$isRight = (($damage & 0x10) > 0);
if($j === 0){
if($flag){
if(!$flag1){
if($isOpen){
if(!$isRight){
$bb->setBounds(
$this->x,
$this->y,
@ -106,8 +103,8 @@ abstract class Door extends Transparent{
);
}
}elseif($j === 1){
if($flag){
if(!$flag1){
if($isOpen){
if(!$isRight){
$bb->setBounds(
$this->x + 1 - $f,
$this->y,
@ -137,8 +134,8 @@ abstract class Door extends Transparent{
);
}
}elseif($j === 2){
if($flag){
if(!$flag1){
if($isOpen){
if(!$isRight){
$bb->setBounds(
$this->x,
$this->y,
@ -168,8 +165,8 @@ abstract class Door extends Transparent{
);
}
}elseif($j === 3){
if($flag){
if(!$flag1){
if($isOpen){
if(!$isRight){
$bb->setBounds(
$this->x,
$this->y,
@ -203,106 +200,94 @@ 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->id 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->meta = $player->getDirection() & 0x03;
$this->getLevel()->setBlock($block, $this, true, true); //Bottom
$this->getLevel()->setBlock($blockUp, $b = Block::get($this->id, $metaUp), true); //Top
$this->setDamage($player->getDirection() & 0x03);
$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->meta & 0x08) === 0x08){
$down = $this->getSide(0);
if($down->getId() === $this->id){
$this->getLevel()->setBlock($down, new Air(), true);
}
}else{
$up = $this->getSide(1);
if($up->getId() === $this->id){
$this->getLevel()->setBlock($up, new Air(), true);
}
}
$this->getLevel()->setBlock($this, new Air(), true);
return true;
}
public function onActivate(Item $item, Player $player = null){
if(($this->meta & 0x08) === 0x08){ //Top
$down = $this->getSide(0);
if($down->getId() === $this->id){
public function onActivate(Item $item, Player $player = null) : bool{
if(($this->getDamage() & 0x08) === 0x08){ //Top
$down = $this->getSide(Vector3::SIDE_DOWN);
if($down->getId() === $this->getId()){
$meta = $down->getDamage() ^ 0x04;
$this->getLevel()->setBlock($down, Block::get($this->id, $meta), true);
$players = $this->getLevel()->getUsingChunk($this->x >> 4, $this->z >> 4);
if($player instanceof Player){
unset($players[$player->getId()]);
}
$pk = new LevelEventPacket();
$pk->x = $this->x;
$pk->y = $this->y;
$pk->z = $this->z;
$pk->evid = 1003;
$pk->data = 0;
Server::broadcastPacket($players, $pk);
$this->level->setBlock($down, BlockFactory::get($this->getId(), $meta), true);
$this->level->addSound(new DoorSound($this));
return true;
}
return false;
}else{
$this->meta ^= 0x04;
$this->getLevel()->setBlock($this, $this, true);
$players = $this->getLevel()->getUsingChunk($this->x >> 4, $this->z >> 4);
if($player instanceof Player){
unset($players[$player->getId()]);
}
$pk = new LevelEventPacket();
$pk->x = $this->x;
$pk->y = $this->y;
$pk->z = $this->z;
$pk->evid = 1003;
$pk->data = 0;
Server::broadcastPacket($players, $pk);
$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

@ -2,11 +2,11 @@
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* 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
@ -15,28 +15,33 @@
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*
*/
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;
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->meta === 2 or $this->meta === 3; //grass or fern
}
public function getName(){
public function getName() : string{
static $names = [
0 => "Sunflower",
1 => "Lilac",
@ -45,26 +50,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(), false, false, 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->meta === 2 or $this->meta === 3) ? BlockToolType::TYPE_SHEARS : BlockToolType::TYPE_NONE;
}
public function getToolHarvestLevel() : int{
return ($this->meta === 2 or $this->meta === 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

@ -2,11 +2,11 @@
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* 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
@ -15,65 +15,40 @@
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*
*/
declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\item\Item;
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 30;
abstract public function getSlabId() : int;
public function getName() : string{
return "Double " . BlockFactory::get($this->getSlabId(), $this->getVariant())->getName();
}
public function getName(){
static $names = [
0 => "Stone",
1 => "Sandstone",
2 => "Wooden",
3 => "Cobblestone",
4 => "Brick",
5 => "Stone Brick",
6 => "Quartz",
7 => "",
public function getDropsForCompatibleTool(Item $item) : array{
return [
ItemFactory::get($this->getSlabId(), $this->getVariant(), 2)
];
return "Double " . $names[$this->meta & 0x07] . " Slab";
}
public function getBreakTime(Item $item){
switch($item->isPickaxe()){
case 5:
return 0.4;
case 4:
return 0.5;
case 3:
return 0.75;
case 2:
return 0.25;
case 1:
return 1.5;
default:
return 10;
}
public function isAffectedBySilkTouch() : bool{
return false;
}
public function getDrops(Item $item){
if($item->isPickaxe() >= 1){
return [
[Item::SLAB, $this->meta & 0x07, 2],
];
}else{
return [];
}
public function getPickedItem() : Item{
return ItemFactory::get($this->getSlabId(), $this->getVariant());
}
}
}

View File

@ -0,0 +1,47 @@
<?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;
class DoubleStoneSlab extends DoubleSlab{
protected $id = self::DOUBLE_STONE_SLAB;
public function getSlabId() : int{
return self::STONE_SLAB;
}
public function getHardness() : float{
return 2;
}
public function getToolType() : int{
return BlockToolType::TYPE_PICKAXE;
}
public function getToolHarvestLevel() : int{
return TieredTool::TIER_WOODEN;
}
}

View File

@ -0,0 +1,33 @@
<?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;
class DoubleStoneSlab2 extends DoubleStoneSlab{
protected $id = self::DOUBLE_STONE_SLAB2;
public function getSlabId() : int{
return self::STONE_SLAB2;
}
}

View File

@ -0,0 +1,49 @@
<?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;
class DoubleWoodenSlab extends DoubleSlab{
protected $id = self::DOUBLE_WOODEN_SLAB;
public function getSlabId() : int{
return self::WOODEN_SLAB;
}
public function getHardness() : float{
return 2;
}
public function getToolType() : int{
return BlockToolType::TYPE_AXE;
}
public function getFlameEncouragement() : int{
return 5;
}
public function getFlammability() : int{
return 20;
}
}

View File

@ -2,11 +2,11 @@
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* 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
@ -15,48 +15,37 @@
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*
*/
declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\item\Item;
use pocketmine\item\TieredTool;
class Emerald extends Solid{
protected $id = self::EMERALD_BLOCK;
public function __construct(){
public function __construct(int $meta = 0){
$this->meta = $meta;
}
public function getHardness(){
return 30;
public function getHardness() : float{
return 5;
}
public function getName(){
public function getToolType() : int{
return BlockToolType::TYPE_PICKAXE;
}
public function getToolHarvestLevel() : int{
return TieredTool::TIER_IRON;
}
public function getName() : string{
return "Emerald Block";
}
public function getBreakTime(Item $item){
switch($item->isPickaxe()){
case 5:
return 0.95;
case 4:
return 1.25;
default:
return 25;
}
}
public function getDrops(Item $item){
if($item->isPickaxe() >= 4){
return [
[Item::EMERALD_BLOCK, 0, 1],
];
}else{
return [];
}
}
}
}

View File

@ -2,11 +2,11 @@
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* 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
@ -15,48 +15,49 @@
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*
*/
declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\item\Item;
use pocketmine\item\ItemFactory;
use pocketmine\item\TieredTool;
class EmeraldOre extends Solid{
protected $id = self::EMERALD_ORE;
public function __construct(){
public function __construct(int $meta = 0){
$this->meta = $meta;
}
public function getName(){
public function getName() : string{
return "Emerald Ore";
}
public function getHardness(){
return 15;
public function getToolType() : int{
return BlockToolType::TYPE_PICKAXE;
}
public function getBreakTime(Item $item){
switch($item->isPickaxe()){
case 5:
return 0.6;
case 4:
return 0.75;
default:
return 15;
}
public function getToolHarvestLevel() : int{
return TieredTool::TIER_IRON;
}
public function getDrops(Item $item){
if($item->isPickaxe() >= 4){
return [
[Item::EMERALD, 0, 1],
];
}else{
return [];
}
public function getHardness() : float{
return 3;
}
}
public function getDropsForCompatibleTool(Item $item) : array{
return [
ItemFactory::get(Item::EMERALD)
];
}
protected function getXpDropAmount() : int{
return mt_rand(3, 7);
}
}

View File

@ -0,0 +1,79 @@
<?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\inventory\EnchantInventory;
use pocketmine\item\Item;
use pocketmine\item\TieredTool;
use pocketmine\math\Vector3;
use pocketmine\Player;
use pocketmine\tile\EnchantTable as TileEnchantTable;
use pocketmine\tile\Tile;
class EnchantingTable extends Transparent{
protected $id = self::ENCHANTING_TABLE;
public function __construct(int $meta = 0){
$this->meta = $meta;
}
public function place(Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, Player $player = null) : bool{
$this->getLevel()->setBlock($blockReplace, $this, true, true);
Tile::createTile(Tile::ENCHANT_TABLE, $this->getLevel(), TileEnchantTable::createNBT($this, $face, $item, $player));
return true;
}
public function getHardness() : float{
return 5;
}
public function getBlastResistance() : float{
return 6000;
}
public function getName() : string{
return "Enchanting Table";
}
public function getToolType() : int{
return BlockToolType::TYPE_PICKAXE;
}
public function getToolHarvestLevel() : int{
return TieredTool::TIER_WOODEN;
}
public function onActivate(Item $item, Player $player = null) : bool{
if($player instanceof Player){
//TODO lock
$player->addWindow(new EnchantInventory($this));
}
return true;
}
}

View File

@ -2,11 +2,11 @@
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* 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
@ -15,10 +15,12 @@
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*
*/
declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\item\Item;
@ -28,27 +30,31 @@ class EndPortalFrame extends Solid{
protected $id = self::END_PORTAL_FRAME;
public function __construct($meta = 0){
public function __construct(int $meta = 0){
$this->meta = $meta;
}
public function getLightLevel(){
public function getLightLevel() : int{
return 1;
}
public function getName(){
public function getName() : string{
return "End Portal Frame";
}
public function getHardness(){
public function getHardness() : float{
return -1;
}
public function getBlastResistance() : float{
return 18000000;
}
public function isBreakable(Item $item){
public function isBreakable(Item $item) : bool{
return false;
}
protected function recalculateBoundingBox(){
protected function recalculateBoundingBox() : ?AxisAlignedBB{
return new AxisAlignedBB(
$this->x,
@ -59,4 +65,4 @@ class EndPortalFrame extends Solid{
$this->z + 1
);
}
}
}

View File

@ -0,0 +1,104 @@
<?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\AxisAlignedBB;
use pocketmine\math\Vector3;
use pocketmine\Player;
class EndRod extends Flowable{
protected $id = Block::END_ROD;
public function __construct(int $meta = 0){
$this->meta = $meta;
}
public function getName() : string{
return "End Rod";
}
public function place(Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, Player $player = null) : bool{
if($face === Vector3::SIDE_UP or $face === Vector3::SIDE_DOWN){
$this->meta = $face;
}else{
$this->meta = $face ^ 0x01;
}
if($blockClicked instanceof EndRod and $blockClicked->getDamage() === $this->meta){
$this->meta ^= 0x01;
}
return $this->level->setBlock($blockReplace, $this, true, true);
}
public function isSolid() : bool{
return true;
}
public function getLightLevel() : int{
return 14;
}
protected function recalculateBoundingBox() : ?AxisAlignedBB{
$m = $this->meta & ~0x01;
$width = 0.375;
switch($m){
case 0x00: //up/down
return new AxisAlignedBB(
$this->x + $width,
$this->y,
$this->z + $width,
$this->x + 1 - $width,
$this->y + 1,
$this->z + 1 - $width
);
case 0x02: //north/south
return new AxisAlignedBB(
$this->x,
$this->y + $width,
$this->z + $width,
$this->x + 1,
$this->y + 1 - $width,
$this->z + 1 - $width
);
case 0x04: //east/west
return new AxisAlignedBB(
$this->x + $width,
$this->y + $width,
$this->z,
$this->x + 1 - $width,
$this->y + 1 - $width,
$this->z + 1
);
}
return null;
}
public function getVariantBitmask() : int{
return 0;
}
}

View File

@ -2,11 +2,11 @@
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* 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
@ -15,44 +15,37 @@
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*
*/
declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\item\Item;
use pocketmine\item\TieredTool;
class EndStone extends Solid{
protected $id = self::END_STONE;
public function __construct(){
public function __construct(int $meta = 0){
$this->meta = $meta;
}
public function getName(){
public function getName() : string{
return "End Stone";
}
public function getHardness(){
return 45;
public function getToolType() : int{
return BlockToolType::TYPE_PICKAXE;
}
public function getBreakTime(Item $item){
switch($item->isPickaxe()){
case 5:
return 0.6;
case 4:
return 0.75;
case 3:
return 1.15;
case 2:
return 0.4;
case 1:
return 2.25;
default:
return 15;
}
public function getToolHarvestLevel() : int{
return TieredTool::TIER_WOODEN;
}
}
public function getHardness() : float{
return 3;
}
}

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\TieredTool;
class EndStoneBricks extends Solid{
protected $id = self::END_BRICKS;
public function __construct(int $meta = 0){
$this->meta = $meta;
}
public function getName() : string{
return "End Stone Bricks";
}
public function getHardness() : float{
return 0.8;
}
public function getToolType() : int{
return BlockToolType::TYPE_PICKAXE;
}
public function getToolHarvestLevel() : int{
return TieredTool::TIER_WOODEN;
}
}

View File

@ -0,0 +1,109 @@
<?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\item\ItemFactory;
use pocketmine\item\TieredTool;
use pocketmine\math\Vector3;
use pocketmine\Player;
use pocketmine\tile\EnderChest as TileEnderChest;
use pocketmine\tile\Tile;
class EnderChest extends Chest{
protected $id = self::ENDER_CHEST;
public function getHardness() : float{
return 22.5;
}
public function getBlastResistance() : float{
return 3000;
}
public function getLightLevel() : int{
return 7;
}
public function getName() : string{
return "Ender Chest";
}
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{
$faces = [
0 => 4,
1 => 2,
2 => 5,
3 => 3
];
$this->meta = $faces[$player instanceof Player ? $player->getDirection() : 0];
$this->getLevel()->setBlock($blockReplace, $this, true, true);
Tile::createTile(Tile::ENDER_CHEST, $this->getLevel(), TileEnderChest::createNBT($this, $face, $item, $player));
return true;
}
public function onActivate(Item $item, Player $player = null) : bool{
if($player instanceof Player){
$t = $this->getLevel()->getTile($this);
$enderChest = null;
if($t instanceof TileEnderChest){
$enderChest = $t;
}else{
$enderChest = Tile::createTile(Tile::ENDER_CHEST, $this->getLevel(), TileEnderChest::createNBT($this));
}
if(!$this->getSide(Vector3::SIDE_UP)->isTransparent()){
return true;
}
$player->getEnderChestInventory()->setHolderPosition($enderChest);
$player->addWindow($player->getEnderChestInventory());
}
return true;
}
public function getDropsForCompatibleTool(Item $item) : array{
return [
ItemFactory::get(Item::OBSIDIAN, 0, 8)
];
}
public function getFuelTime() : int{
return 0;
}
}

View File

@ -2,11 +2,11 @@
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* 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
@ -15,56 +15,40 @@
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*
*/
declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\entity\Entity;
use pocketmine\item\Item;
use pocketmine\level\Level;
use pocketmine\nbt\tag\Byte;
use pocketmine\nbt\tag\Compound;
use pocketmine\nbt\tag\Double;
use pocketmine\nbt\tag\Enum;
use pocketmine\nbt\tag\Float;
use pocketmine\nbt\tag\Int;
use pocketmine\Player;
use pocketmine\math\Vector3;
abstract class Fallable extends Solid{
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){
$ret = $this->getLevel()->setBlock($this, $this, true, true);
public function onNearbyBlockChange() : void{
$down = $this->getSide(Vector3::SIDE_DOWN);
if($down->getId() === self::AIR or $down instanceof Liquid or $down instanceof Fire){
$this->level->setBlock($this, BlockFactory::get(Block::AIR), true);
return $ret;
}
$nbt = Entity::createBaseNBT($this->add(0.5, 0, 0.5));
$nbt->setInt("TileID", $this->getId());
$nbt->setByte("Data", $this->getDamage());
public function onUpdate($type){
if($type === Level::BLOCK_UPDATE_NORMAL){
$down = $this->getSide(0);
if($down->getId() === self::AIR or ($down instanceof Liquid)){
$fall = Entity::createEntity("FallingSand", $this->getLevel()->getChunk($this->x >> 4, $this->z >> 4), new Compound("", [
"Pos" => new Enum("Pos", [
new Double("", $this->x + 0.5),
new Double("", $this->y),
new Double("", $this->z + 0.5)
]),
"Motion" => new Enum("Motion", [
new Double("", 0),
new Double("", 0),
new Double("", 0)
]),
"Rotation" => new Enum("Rotation", [
new Float("", 0),
new Float("", 0)
]),
"TileID" => new Int("TileID", $this->getId()),
"Data" => new Byte("Data", $this->getDamage()),
]));
$fall = Entity::createEntity("FallingSand", $this->getLevel(), $nbt);
if($fall !== null){
$fall->spawnToAll();
}
}
}
}
/**
* @return null|Block
*/
public function tickFalling() : ?Block{
return null;
}
}

View File

@ -2,11 +2,11 @@
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* 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
@ -15,45 +15,104 @@
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*
*/
declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\item\Item;
use pocketmine\item\ItemFactory;
use pocketmine\math\AxisAlignedBB;
use pocketmine\math\Vector3;
class Farmland extends Solid{
class Farmland extends Transparent{
protected $id = self::FARMLAND;
public function __construct($meta = 0){
public function __construct(int $meta = 0){
$this->meta = $meta;
}
public function getName(){
public function getName() : string{
return "Farmland";
}
public function getHardness(){
return 3;
public function getHardness() : float{
return 0.6;
}
protected function recalculateBoundingBox(){
public function getToolType() : int{
return BlockToolType::TYPE_SHOVEL;
}
protected function recalculateBoundingBox() : ?AxisAlignedBB{
return new AxisAlignedBB(
$this->x,
$this->y,
$this->z,
$this->x + 1,
$this->y + 0.9375,
$this->y + 1, //TODO: this should be 0.9375, but MCPE currently treats them as a full block (https://bugs.mojang.com/browse/MCPE-12109)
$this->z + 1
);
}
public function getDrops(Item $item){
public function onNearbyBlockChange() : void{
if($this->getSide(Vector3::SIDE_UP)->isSolid()){
$this->level->setBlock($this, BlockFactory::get(Block::DIRT), true);
}
}
public function ticksRandomly() : bool{
return true;
}
public function onRandomTick() : void{
if(!$this->canHydrate()){
if($this->meta > 0){
$this->meta--;
$this->level->setBlock($this, $this, false, false);
}else{
$this->level->setBlock($this, BlockFactory::get(Block::DIRT), false, true);
}
}elseif($this->meta < 7){
$this->meta = 7;
$this->level->setBlock($this, $this, false, false);
}
}
protected function canHydrate() : bool{
//TODO: check rain
$start = $this->add(-4, 0, -4);
$end = $this->add(4, 1, 4);
for($y = $start->y; $y <= $end->y; ++$y){
for($z = $start->z; $z <= $end->z; ++$z){
for($x = $start->x; $x <= $end->x; ++$x){
$id = $this->level->getBlockIdAt($x, $y, $z);
if($id === Block::STILL_WATER or $id === Block::FLOWING_WATER){
return true;
}
}
}
}
return false;
}
public function getDropsForCompatibleTool(Item $item) : array{
return [
[Item::DIRT, 0, 1],
ItemFactory::get(Item::DIRT)
];
}
}
public function isAffectedBySilkTouch() : bool{
return false;
}
public function getPickedItem() : Item{
return ItemFactory::get(Item::DIRT);
}
}

View File

@ -2,11 +2,11 @@
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* 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
@ -15,65 +15,94 @@
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*
*/
declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\math\AxisAlignedBB;
use pocketmine\math\Vector3;
class Fence extends Transparent{
abstract class Fence extends Transparent{
protected $id = self::FENCE;
public function __construct($meta = 0){
public function __construct(int $meta = 0){
$this->meta = $meta;
}
public function getHardness(){
return 15;
public function getThickness() : float{
return 0.25;
}
public function getName(){
static $names = [
0 => "Oak Fence",
1 => "Spruce Fence",
2 => "Birch Fence",
3 => "Jungle Fence",
4 => "Acacia Fence",
5 => "Dark Oak Fence",
"",
""
];
return $names[$this->meta & 0x07];
}
protected function recalculateBoundingBox(){
$flag = $this->canConnect($this->getSide(2));
$flag1 = $this->canConnect($this->getSide(3));
$flag2 = $this->canConnect($this->getSide(4));
$flag3 = $this->canConnect($this->getSide(5));
$f = $flag2 ? 0 : 0.375;
$f1 = $flag3 ? 1 : 0.625;
$f2 = $flag ? 0 : 0.375;
$f3 = $flag1 ? 1 : 0.625;
protected function recalculateBoundingBox() : ?AxisAlignedBB{
$width = 0.5 - $this->getThickness() / 2;
return new AxisAlignedBB(
$this->x + $f,
$this->x + ($this->canConnect($this->getSide(Vector3::SIDE_WEST)) ? 0 : $width),
$this->y,
$this->z + $f2,
$this->x + $f1,
$this->z + ($this->canConnect($this->getSide(Vector3::SIDE_NORTH)) ? 0 : $width),
$this->x + 1 - ($this->canConnect($this->getSide(Vector3::SIDE_EAST)) ? 0 : $width),
$this->y + 1.5,
$this->z + $f3
$this->z + 1 - ($this->canConnect($this->getSide(Vector3::SIDE_SOUTH)) ? 0 : $width)
);
}
public function canConnect(Block $block){
return (!($block instanceof Fence) and !($block instanceof FenceGate)) ? $block->isSolid() : true;
protected function recalculateCollisionBoxes() : array{
$inset = 0.5 - $this->getThickness() / 2;
/** @var AxisAlignedBB[] $bbs */
$bbs = [];
$connectWest = $this->canConnect($this->getSide(Vector3::SIDE_WEST));
$connectEast = $this->canConnect($this->getSide(Vector3::SIDE_EAST));
if($connectWest or $connectEast){
//X axis (west/east)
$bbs[] = new AxisAlignedBB(
$this->x + ($connectWest ? 0 : $inset),
$this->y,
$this->z + $inset,
$this->x + 1 - ($connectEast ? 0 : $inset),
$this->y + 1.5,
$this->z + 1 - $inset
);
}
$connectNorth = $this->canConnect($this->getSide(Vector3::SIDE_NORTH));
$connectSouth = $this->canConnect($this->getSide(Vector3::SIDE_SOUTH));
if($connectNorth or $connectSouth){
//Z axis (north/south)
$bbs[] = new AxisAlignedBB(
$this->x + $inset,
$this->y,
$this->z + ($connectNorth ? 0 : $inset),
$this->x + 1 - $inset,
$this->y + 1.5,
$this->z + 1 - ($connectSouth ? 0 : $inset)
);
}
if(empty($bbs)){
//centre post AABB (only needed if not connected on any axis - other BBs overlapping will do this if any connections are made)
return [
new AxisAlignedBB(
$this->x + $inset,
$this->y,
$this->z + $inset,
$this->x + 1 - $inset,
$this->y + 1.5,
$this->z + 1 - $inset
)
];
}
return $bbs;
}
public function canConnect(Block $block){
return $block instanceof static or $block instanceof FenceGate or ($block->isSolid() and !$block->isTransparent());
}
}

View File

@ -2,11 +2,11 @@
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* 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
@ -15,45 +15,39 @@
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*
*/
declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\item\Item;
use pocketmine\level\sound\DoorSound;
use pocketmine\math\AxisAlignedBB;
use pocketmine\math\Vector3;
use pocketmine\Player;
class FenceGate extends Transparent{
protected $id = self::FENCE_GATE;
public function __construct($meta = 0){
$this->meta = $meta;
public function getHardness() : float{
return 2;
}
public function getName(){
return "Oak Fence Gate";
}
public function getHardness(){
return 15;
}
public function canBeActivated(){
return true;
public function getToolType() : int{
return BlockToolType::TYPE_AXE;
}
protected function recalculateBoundingBox(){
protected function recalculateBoundingBox() : ?AxisAlignedBB{
if(($this->getDamage() & 0x04) > 0){
return null;
}
$i = ($this->getDamage() & 0x03);
if($i === 2 and $i === 0){
if($i === 2 or $i === 0){
return new AxisAlignedBB(
$this->x,
$this->y,
@ -74,35 +68,38 @@ class FenceGate extends Transparent{
}
}
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){
$faces = [
0 => 3,
1 => 0,
2 => 1,
3 => 2,
];
$this->meta = $faces[$player instanceof Player ? $player->getDirection() : 0] & 0x03;
$this->getLevel()->setBlock($block, $this, true, true);
public function place(Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, Player $player = null) : bool{
$this->meta = ($player instanceof Player ? ($player->getDirection() - 1) & 0x03 : 0);
$this->getLevel()->setBlock($blockReplace, $this, true, true);
return true;
}
public function getDrops(Item $item){
return [
[$this->id, 0, 1],
];
public function getVariantBitmask() : int{
return 0;
}
public function onActivate(Item $item, Player $player = null){
$faces = [
0 => 3,
1 => 0,
2 => 1,
3 => 2,
];
$this->meta = ($faces[$player instanceof Player ? $player->getDirection() : 0] & 0x03) | ((~$this->meta) & 0x04);
public function onActivate(Item $item, Player $player = null) : bool{
$this->meta = (($this->meta ^ 0x04) & ~0x02);
if($player !== null){
$this->meta |= (($player->getDirection() - 1) & 0x02);
}
$this->getLevel()->setBlock($this, $this, true);
$this->level->addSound(new DoorSound($this));
return true;
}
}
public function getFuelTime() : int{
return 300;
}
public function getFlameEncouragement() : int{
return 5;
}
public function getFlammability() : int{
return 20;
}
}

View File

@ -1,32 +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 FenceGateAcacia extends FenceGate{
protected $id = self::FENCE_GATE_ACACIA;
public function getName(){
return "Acacia Fence Gate";
}
}

View File

@ -1,32 +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 FenceGateSpruce extends FenceGate{
protected $id = self::FENCE_GATE_SPRUCE;
public function getName(){
return "Spruce Fence Gate";
}
}

View File

@ -19,88 +19,150 @@
*
*/
declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\entity\Entity;
use pocketmine\entity\projectile\Arrow;
use pocketmine\event\block\BlockBurnEvent;
use pocketmine\event\entity\EntityCombustByBlockEvent;
use pocketmine\event\entity\EntityDamageByBlockEvent;
use pocketmine\event\entity\EntityDamageEvent;
use pocketmine\inventory\InventoryHolder;
use pocketmine\inventory\PlayerInventory;
use pocketmine\item\Item;
use pocketmine\level\Level;
use pocketmine\Server;
use pocketmine\math\Vector3;
class Fire extends Flowable{
protected $id = self::FIRE;
public function __construct($meta = 0){
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 "Fire Block";
}
public function getLightLevel(){
public function getLightLevel() : int{
return 15;
}
public function isBreakable(Item $item){
public function isBreakable(Item $item) : bool{
return false;
}
public function canBeReplaced(){
public function canBeReplaced() : bool{
return true;
}
public function onEntityCollide(Entity $entity){
$damage = [EntityDamageEvent::MODIFIER_BASE => 1];
if($entity instanceof InventoryHolder){
$inventory = $entity->getInventory();
if($inventory instanceof PlayerInventory){
$damage[EntityDamageEvent::MODIFIER_ARMOR] = $inventory->getArmorPoints();
}
}
$ev = new EntityDamageByBlockEvent($this, $entity, EntityDamageEvent::CAUSE_FIRE, $damage);
$entity->attack($ev->getFinalDamage(), $ev);
public function onEntityCollide(Entity $entity) : void{
$ev = new EntityDamageByBlockEvent($this, $entity, EntityDamageEvent::CAUSE_FIRE, 1);
$entity->attack($ev);
$ev = new EntityCombustByBlockEvent($this, $entity, 8);
Server::getInstance()->getPluginManager()->callEvent($ev);
if($entity instanceof Arrow){
$ev->setCancelled();
}
$ev->call();
if(!$ev->isCancelled()){
$entity->setOnFire($ev->getDuration());
}
}
public function getDrops(Item $item){
public function getDropsForCompatibleTool(Item $item) : array{
return [];
}
public function onUpdate($type){
if($type === Level::BLOCK_UPDATE_NORMAL){
for($s = 0; $s <= 5; ++$s){
$side = $this->getSide($s);
if($side->getId() !== self::AIR and !($side instanceof Liquid)){
return false;
public function onNearbyBlockChange() : void{
if(!$this->getSide(Vector3::SIDE_DOWN)->isSolid() and !$this->hasAdjacentFlammableBlocks()){
$this->getLevel()->setBlock($this, BlockFactory::get(Block::AIR), true);
}else{
$this->level->scheduleDelayedBlockUpdate($this, mt_rand(30, 40));
}
}
public function ticksRandomly() : bool{
return true;
}
public function onRandomTick() : void{
$down = $this->getSide(Vector3::SIDE_DOWN);
$result = null;
if($this->meta < 15 and mt_rand(0, 2) === 0){
$this->meta++;
$result = $this;
}
$canSpread = true;
if(!$down->burnsForever()){
//TODO: check rain
if($this->meta === 15){
if(!$down->isFlammable() and mt_rand(0, 3) === 3){ //1/4 chance to extinguish
$canSpread = false;
$result = BlockFactory::get(Block::AIR);
}
}elseif(!$this->hasAdjacentFlammableBlocks()){
$canSpread = false;
if(!$down->isSolid() or $this->meta > 3){ //fire older than 3, or without a solid block below
$result = BlockFactory::get(Block::AIR);
}
}
$this->getLevel()->setBlock($this, new Air(), true);
}
return Level::BLOCK_UPDATE_NORMAL;
}elseif($type === Level::BLOCK_UPDATE_RANDOM){
if($this->getSide(0)->getId() !== self::NETHERRACK){
$this->getLevel()->setBlock($this, new Air(), true);
if($result !== null){
$this->level->setBlock($this, $result);
}
return Level::BLOCK_UPDATE_NORMAL;
$this->level->scheduleDelayedBlockUpdate($this, mt_rand(30, 40));
if($canSpread){
//TODO: raise upper bound for chance in humid biomes
foreach($this->getHorizontalSides() as $side){
$this->burnBlock($side, 300);
}
//vanilla uses a 250 upper bound here, but I don't think they intended to increase the chance of incineration
$this->burnBlock($this->getSide(Vector3::SIDE_UP), 350);
$this->burnBlock($this->getSide(Vector3::SIDE_DOWN), 350);
//TODO: fire spread
}
}
public function onScheduledUpdate() : void{
$this->onRandomTick();
}
private function hasAdjacentFlammableBlocks() : bool{
for($i = 0; $i <= 5; ++$i){
if($this->getSide($i)->isFlammable()){
return true;
}
}
return false;
}
private function burnBlock(Block $block, int $chanceBound) : void{
if(mt_rand(0, $chanceBound) < $block->getFlammability()){
$ev = new BlockBurnEvent($block, $this);
$ev->call();
if(!$ev->isCancelled()){
$block->onIncinerate();
if(mt_rand(0, $this->meta + 9) < 5){ //TODO: check rain
$this->level->setBlock($block, BlockFactory::get(Block::FIRE, min(15, $this->meta + (mt_rand(0, 4) >> 2))));
}else{
$this->level->setBlock($block, BlockFactory::get(Block::AIR));
}
}
}
}
}

View File

@ -2,11 +2,11 @@
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* 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
@ -15,28 +15,31 @@
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*
*/
declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\math\AxisAlignedBB;
abstract class Flowable extends Transparent{
public function canBeFlowedInto(){
public function canBeFlowedInto() : bool{
return true;
}
public function isSolid(){
public function getHardness() : float{
return 0;
}
public function isSolid() : bool{
return false;
}
public function getBoundingBox(){
protected function recalculateBoundingBox() : ?AxisAlignedBB{
return null;
}
public function getHardness(){
return 0;
}
}
}

View File

@ -0,0 +1,86 @@
<?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;
class Flower extends Flowable{
public const TYPE_POPPY = 0;
public const TYPE_BLUE_ORCHID = 1;
public const TYPE_ALLIUM = 2;
public const TYPE_AZURE_BLUET = 3;
public const TYPE_RED_TULIP = 4;
public const TYPE_ORANGE_TULIP = 5;
public const TYPE_WHITE_TULIP = 6;
public const TYPE_PINK_TULIP = 7;
public const TYPE_OXEYE_DAISY = 8;
protected $id = self::RED_FLOWER;
public function __construct(int $meta = 0){
$this->meta = $meta;
}
public function getName() : string{
static $names = [
self::TYPE_POPPY => "Poppy",
self::TYPE_BLUE_ORCHID => "Blue Orchid",
self::TYPE_ALLIUM => "Allium",
self::TYPE_AZURE_BLUET => "Azure Bluet",
self::TYPE_RED_TULIP => "Red Tulip",
self::TYPE_ORANGE_TULIP => "Orange Tulip",
self::TYPE_WHITE_TULIP => "White Tulip",
self::TYPE_PINK_TULIP => "Pink Tulip",
self::TYPE_OXEYE_DAISY => "Oxeye Daisy"
];
return $names[$this->meta] ?? "Unknown";
}
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);
return true;
}
return false;
}
public function onNearbyBlockChange() : void{
if($this->getSide(Vector3::SIDE_DOWN)->isTransparent()){
$this->getLevel()->useBreakOn($this);
}
}
public function getFlameEncouragement() : int{
return 60;
}
public function getFlammability() : int{
return 100;
}
}

View File

@ -0,0 +1,113 @@
<?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\AxisAlignedBB;
use pocketmine\math\Vector3;
use pocketmine\Player;
use pocketmine\tile\FlowerPot as TileFlowerPot;
use pocketmine\tile\Tile;
class FlowerPot extends Flowable{
public const STATE_EMPTY = 0;
public const STATE_FULL = 1;
protected $id = self::FLOWER_POT_BLOCK;
protected $itemId = Item::FLOWER_POT;
public function __construct(int $meta = 0){
$this->meta = $meta;
}
public function getName() : string{
return "Flower Pot";
}
protected function recalculateBoundingBox() : ?AxisAlignedBB{
return new AxisAlignedBB(
$this->x + 0.3125,
$this->y,
$this->z + 0.3125,
$this->x + 0.6875,
$this->y + 0.375,
$this->z + 0.6875
);
}
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 false;
}
$this->getLevel()->setBlock($blockReplace, $this, true, true);
Tile::createTile(Tile::FLOWER_POT, $this->getLevel(), TileFlowerPot::createNBT($this, $face, $item, $player));
return true;
}
public function onNearbyBlockChange() : void{
if($this->getSide(Vector3::SIDE_DOWN)->isTransparent()){
$this->getLevel()->useBreakOn($this);
}
}
public function onActivate(Item $item, Player $player = null) : bool{
$pot = $this->getLevel()->getTile($this);
if(!($pot instanceof TileFlowerPot)){
return false;
}
if(!$pot->canAddItem($item)){
return true;
}
$this->setDamage(self::STATE_FULL); //specific damage value is unnecessary, it just needs to be non-zero to show an item.
$this->getLevel()->setBlock($this, $this, true, false);
$pot->setItem($item->pop());
return true;
}
public function getVariantBitmask() : int{
return 0;
}
public function getDropsForCompatibleTool(Item $item) : array{
$items = parent::getDropsForCompatibleTool($item);
$tile = $this->getLevel()->getTile($this);
if($tile instanceof TileFlowerPot){
$item = $tile->getItem();
if($item->getId() !== Item::AIR){
$items[] = $item;
}
}
return $items;
}
public function isAffectedBySilkTouch() : bool{
return false;
}
}

View File

@ -2,11 +2,11 @@
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* 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
@ -15,10 +15,12 @@
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*
*/
declare(strict_types=1);
namespace pocketmine\block;
@ -26,7 +28,11 @@ class Furnace extends BurningFurnace{
protected $id = self::FURNACE;
public function getName(){
public function getName() : string{
return "Furnace";
}
}
public function getLightLevel() : int{
return 0;
}
}

View File

@ -2,11 +2,11 @@
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* 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
@ -15,10 +15,12 @@
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*
*/
declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\item\Item;
@ -27,19 +29,19 @@ class Glass extends Transparent{
protected $id = self::GLASS;
public function __construct(){
public function __construct(int $meta = 0){
$this->meta = $meta;
}
public function getName(){
public function getName() : string{
return "Glass";
}
public function getHardness(){
return 1.5;
public function getHardness() : float{
return 0.3;
}
public function getDrops(Item $item){
public function getDropsForCompatibleTool(Item $item) : array{
return [];
}
}
}

View File

@ -2,11 +2,11 @@
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* 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
@ -15,12 +15,13 @@
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*
*/
namespace pocketmine\block;
declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\item\Item;
@ -28,19 +29,19 @@ class GlassPane extends Thin{
protected $id = self::GLASS_PANE;
public function __construct(){
public function __construct(int $meta = 0){
$this->meta = $meta;
}
public function getName(){
public function getName() : string{
return "Glass Pane";
}
public function getHardness(){
return 1.5;
public function getHardness() : float{
return 0.3;
}
public function getDrops(Item $item){
public function getDropsForCompatibleTool(Item $item) : array{
return [];
}
}
}

View File

@ -0,0 +1,63 @@
<?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\item\TieredTool;
use pocketmine\math\Vector3;
use pocketmine\Player;
class GlazedTerracotta extends Solid{
public function getHardness() : float{
return 1.4;
}
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{
if($player !== null){
$faces = [
0 => 4,
1 => 3,
2 => 5,
3 => 2
];
$this->meta = $faces[(~($player->getDirection() - 1)) & 0x03];
}
return $this->getLevel()->setBlock($blockReplace, $this, true, true);
}
public function getVariantBitmask() : int{
return 0;
}
}

View File

@ -2,11 +2,11 @@
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* 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
@ -15,27 +15,46 @@
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*
*/
declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\item\TieredTool;
class GlowingObsidian extends Solid{
protected $id = self::GLOWING_OBSIDIAN;
public function __construct($meta = 0){
public function __construct(int $meta = 0){
$this->meta = $meta;
}
public function getName(){
public function getName() : string{
return "Glowing Obsidian";
}
public function getLightLevel(){
public function getLightLevel() : int{
return 12;
}
}
public function getHardness() : float{
return 10;
}
public function getBlastResistance() : float{
return 50;
}
public function getToolType() : int{
return BlockToolType::TYPE_PICKAXE;
}
public function getToolHarvestLevel() : int{
return TieredTool::TIER_DIAMOND;
}
}

View File

@ -2,11 +2,11 @@
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* 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
@ -15,65 +15,44 @@
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*
*/
declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\item\Item;
use pocketmine\level\Level;
use pocketmine\Player;
class GlowingRedstoneOre extends Solid{
class GlowingRedstoneOre extends RedstoneOre{
protected $id = self::GLOWING_REDSTONE_ORE;
public function __construct(){
protected $itemId = self::REDSTONE_ORE;
}
public function getHardness(){
return 15;
}
public function getName(){
public function getName() : string{
return "Glowing Redstone Ore";
}
public function getLightLevel(){
public function getLightLevel() : int{
return 9;
}
public function onUpdate($type){
if($type === Level::BLOCK_UPDATE_SCHEDULED or $type === Level::BLOCK_UPDATE_RANDOM){
$this->getLevel()->setBlock($this, Block::get(Item::REDSTONE_ORE, $this->meta), false, false, true);
return Level::BLOCK_UPDATE_WEAK;
}
public function onActivate(Item $item, Player $player = null) : bool{
return false;
}
public function onNearbyBlockChange() : void{
public function getBreakTime(Item $item){
switch($item->isPickaxe()){
case 5:
return 0.6;
case 4:
return 0.75;
default:
return 15;
}
}
public function getDrops(Item $item){
if($item->isPickaxe() >= 4){
return [
[Item::REDSTONE_DUST, 0, mt_rand(4, 5)],
];
}else{
return [];
}
public function ticksRandomly() : bool{
return true;
}
}
public function onRandomTick() : void{
$this->getLevel()->setBlock($this, BlockFactory::get(Block::REDSTONE_ORE, $this->meta), false, false);
}
}

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