Compare commits

..

393 Commits

Author SHA1 Message Date
891eeff75a PocketMine 1.4.1 2015-03-17 18:01:58 +01:00
b4f62bf423 Fixed salling sand breaking on full BB partial blocks, closes #2770 2015-03-17 18:00:19 +01:00
7c76c1e3d7 Changed generator choosing logic, add proper preset if needed, fixes #2751 2015-03-17 18:00:19 +01:00
37bc1273ee Implemented double chest fix, closes #2744, fixes #2493 2015-03-17 18:00:19 +01:00
ffcdf49912 Allow plugins to cancel some kicks better, closes #2743 2015-03-17 18:00:18 +01:00
3e893ed0f7 Implemented hardcore banning, closes #2574 2015-03-17 18:00:18 +01:00
bfb7e8bb9e Merge pull request #2776 from PEMapModder/armor-fix
Implemented proportional armor modifier, applied armor in other damage types and consume armor when player is damaged
2015-03-17 17:57:28 +01:00
5067b96184 Merge pull request #2631 from 64FF00/master
TallGrass blocks should be only placed on grass blocks
2015-03-17 17:49:46 +01:00
cb2157ea80 Merge pull request #2614 from mmlmml1/master
Fixed for Iron bars and stonecutter
2015-03-17 17:36:01 +01:00
5b3e65345f Fixed a typo
`$source->isCancelled()` shouldn't be checked twice
2015-03-17 22:20:33 +08:00
8aa8ae5094 Implemented proportional armor modifier, applied armor in other damage types and consume armor when player is damaged 2015-03-17 20:04:59 +08:00
220d2b7bee Fixed NBT IntArray off-by-one reading 2015-03-15 16:40:44 +01:00
807107e581 Fixed constructors, default memory to -1, default async generator 2015-03-14 15:51:21 +01:00
9158cc4f19 Implemented Threaded ClassLoader, improves class loading while on different threads (no need to synchronize states) 2015-03-14 15:22:42 +01:00
2cd757d80a Fixed formatting of #2771 2015-03-13 09:26:45 +01:00
be20f61a93 Merge pull request #2771 from alejandroliu/ChunkCorruption
Fix some Chunk corruption due to Chunk overlap
2015-03-13 09:24:24 +01:00
59e9446fe5 Added another place where the same happens 2015-03-13 08:19:47 +01:00
4f47dac8ec Fix some Chunk corrumption due to Chunk overlap 2015-03-13 06:23:32 +01:00
b54c0835b7 Update RakLib 2015-03-12 18:40:12 +01:00
9ca3ad8971 Merge pull request #2767 from alejandroliu/blockskylight
Fixed some typos in Anvil
2015-03-10 09:57:48 +01:00
a644b46ec4 Fixed some typos 2015-03-09 23:57:53 +01:00
9d3f59fab6 Merge pull request #2750 from LDX-MCPE/patch-2
Fixed Dark Oak Fence's name
2015-03-09 11:10:17 +01:00
6309d4abf1 Fixed #2762 2015-03-08 15:53:01 +01:00
LDX
39291e4061 Fixed Dark Oak Fence's name 2015-03-02 16:14:31 -05:00
bb71a3c4a6 Added Entity->fastMove() for players and direct-controlled entities, improved speed checking 2015-02-22 21:16:05 +01:00
eb0525e892 Ignore spawn protection when no ops are set 2015-02-22 19:07:45 +01:00
f49db47b2e Added basic speed protection 2015-02-18 00:37:57 +01:00
3ff5e12302 Updated RakLib 2015-02-17 21:12:28 +01:00
99ad65ba44 Catch file saving exceptions 2015-02-15 20:01:47 +01:00
5f4f996efe Fixed #2599 2015-02-15 19:01:25 +01:00
21e0739845 Fixed #2598 2015-02-15 18:48:30 +01:00
3a157d0f02 Future workaround for #2626 2015-02-15 18:45:25 +01:00
8e56782138 Fixed #2619 BlockMetadataStore 2015-02-15 18:25:40 +01:00
116ede3679 Improved flight detection, added Entity->resetFallDistance(), closes #2632 2015-02-15 17:40:17 +01:00
7c0f5987d3 Fixed players getting kicked for flying when going through special blocks 2015-02-15 16:26:05 +01:00
547e152e40 Fixed #2615, closes #2634 invalid pull request 2015-02-15 15:12:33 +01:00
7905fbdd29 TallGrass blocks should be only placed on grass blocks 2015-02-12 19:33:44 +09:00
ae65701a23 Update IronBars.php 2015-02-05 20:11:08 +08:00
9134a69936 Merge pull request #2613 from 64FF00/master
OH-GAWD-WHY blame @PEMapModder
2015-02-05 12:57:44 +01:00
907fe8aff6 Fixed for wrong hardness and stonecutter 2015-02-05 19:05:00 +08:00
afa9acf22f OH-GAWD-WHY 2015-02-05 19:30:52 +09:00
9a5afff4ab Merge pull request #2612 from PEMapModder/patch-1
Added Location::__toString()
2015-02-05 11:06:52 +01:00
2f8c281a2e Added Location::__toString() 2015-02-05 18:00:25 +08:00
2096dace68 fixed for some bugs
Signed-off-by: mmlmml1 <mmlmml1@126.com>
2015-02-04 23:12:06 +08:00
8421985102 Merge pull request #2577 from Falkirks/master
Improve FallingSand behaviour
2015-01-28 08:48:01 +01:00
f63e859b3a Falling sand will become block when in contact with a Liquid
This replicates the behaviour of MCPE.
2015-01-27 17:09:31 -08:00
c56eb0b9df Merge pull request #2566 from sekjun9878/master
Fixed #2565
2015-01-26 19:01:22 +10:30
3f2e5bbef4 Fixed #2565 2015-01-26 18:59:56 +10:30
9886eb4768 Return on Level->getSafeSpawn() in case of invalid position 2015-01-25 10:23:04 +01:00
ea44eee5df Merge branch 'master' of github.com:PocketMine/PocketMine-MP 2015-01-24 10:35:24 +01:00
9173f930ca Fixed #2541 server not saving chunks on chunk unloading 2015-01-24 10:35:08 +01:00
80b6a8ebaf Merge pull request #2555 from Striker209MPE/patch-6
Removed useless spawned check...
2015-01-24 10:29:18 +01:00
7c64a33389 Fixed #2557 2015-01-21 14:48:31 +01:00
9fac896f28 Removed useless spawned check...
because it has already be done before
2015-01-20 16:29:29 +01:00
5bd76e955c Added rotation transformations to remaining packet 2015-01-16 01:43:40 +01:00
63f1a50be4 Added new predictive flight protection 2015-01-14 23:47:01 +01:00
24c6cca664 Updated RakLib, fixed help message not showing command, added documentation to Plugin->getResource() 2015-01-14 17:23:16 +01:00
9fac990b19 Throw exception when RakLib crashes 2015-01-13 18:44:15 +01:00
e8e7938490 Fixed PHPRC env. variable being set 2015-01-13 17:25:52 +01:00
f6c4a726b3 Bump Minecraft version to 0.10.5 2015-01-12 20:00:11 +01:00
8eec5e6b5e Allow placing Snow Layers on top of solid transparent blocks 2015-01-12 02:18:02 +01:00
bd7fa71d7f Updated RakLib 2015-01-11 20:33:17 +01:00
7d406066a7 Added outdated event static properties 2015-01-11 19:37:21 +01:00
3e9196d224 Changed max speed per tick from 100 to 10 blocks 2015-01-11 17:31:34 +01:00
f30986d187 Block saving chunks too big 2015-01-11 15:48:08 +01:00
f8c144be31 Fixed #2529 2015-01-11 15:06:16 +01:00
c61e4adcf1 Improved chunk ticking a bit more 2015-01-08 23:27:14 +01:00
5a55040ab9 Improved chunk ticking 2015-01-08 23:22:47 +01:00
83360187c9 Removed fence classes, added fence damage (¬¬ Mojang) 2015-01-08 17:51:29 +01:00
9d97a940a6 Merge pull request #2517 from PEMapModder/patch-1
Fixed /timings off
2015-01-07 14:42:17 +01:00
cd21c28d46 Fixed /timings off
When issuing `/timings off`, the message `Please enable timings by typing /timings on` is sent to the issuer. This commit fixes this issue.
2015-01-07 17:34:45 +08:00
37fd0372cc Added GarbageCollectionTask, workaround for weird PHP behaviour when using --disable-ansi 2015-01-06 19:45:41 +01:00
ed02026815 Improved file resource usage 2015-01-06 19:04:24 +01:00
042a143dd6 Unload unused regions after 5 minutes 2015-01-06 18:59:21 +01:00
4b73dbd9f8 Fixed Flat generator on existing chunks, region issues 2015-01-06 18:46:18 +01:00
d4e4430df0 Fixed Entities being placed in recreated chunks 2015-01-06 18:45:08 +01:00
469ef84733 Fixed issue where plugins schedule a Player update before log in 2015-01-06 00:25:40 +01:00
efe75f2836 Catch more coruption issues in Region-based worlds, fixed first chunk being generated on an invalid sector 2015-01-06 00:11:38 +01:00
53f2f21f2d Fixed #2511 2015-01-05 16:15:57 +01:00
9c28f0a5be Decrease async worker task amount after crashed task 2015-01-05 02:41:14 +01:00
5bf5014b60 Added Async Task crash warning 2015-01-05 00:16:47 +01:00
f37e79b611 Added Level->getChunks(), fixed some Doc Comments 2015-01-04 23:16:03 +01:00
7a0118820c Improved chunk saving times by not marking it as changed when Players are added/removed 2015-01-04 23:07:08 +01:00
c8b5c023cd Fixed visual typo in /ban-ip, closes #2503 2015-01-04 09:36:07 +01:00
f9dd929e04 Fixed phar check 2015-01-03 16:49:10 +01:00
87970726e4 Added PlayerCreationEvent->setBaseClass() 2015-01-03 16:46:00 +01:00
1daf9a96a3 Added PlayerCreationEvent->setBaseClass() 2015-01-03 16:45:43 +01:00
6c8b33fcc8 Fixed PlayerCreationEvent 2015-01-03 16:41:14 +01:00
438591bd75 API 1.11.0, fixed phar check 2015-01-03 16:38:36 +01:00
7ef8edccf4 Added PlayerCreationEvent 2015-01-03 16:38:00 +01:00
074c8b876d Cleaned up code 2015-01-03 16:07:49 +01:00
f9762c870a Cleaned up BanEntry creation 2015-01-03 15:47:03 +01:00
4039895d3c Fixed #2489 2015-01-03 03:43:41 +01:00
d207a5daea WTF, ghost objects and why does this fix it? (and btw, fixes #2488) 2015-01-03 03:38:25 +01:00
8e3667c95b Fixed messages and default settings 2015-01-03 02:56:46 +01:00
0da628deca Fixed some crashes related to crashing 2015-01-02 19:19:34 +01:00
04bdb13103 Improved move offset check 2015-01-02 19:14:18 +01:00
e8ad828498 Catch exceptions on level generation 2015-01-02 18:56:27 +01:00
f46473bbe8 Removed all @mkdir() calls 2015-01-02 18:52:45 +01:00
692045d714 Improved threading and resource usage, new defaults 2015-01-02 18:46:39 +01:00
47cbf56725 Version bump 2015-01-02 07:04:20 +01:00
3de14d8ba6 Preparing release 2015-01-02 01:37:33 +01:00
5fffabe05b Fixed players not calculating onGround correctly 2015-01-02 01:22:33 +01:00
3128ae9736 Improved exception handling and trace creation 2015-01-01 22:50:45 +01:00
7be4e2fa81 Merge pull request #2438 from PocketMine/new-version-format
New release version format
2014-12-31 17:53:12 +01:00
95b305ce87 Detect really big corrupted chunks, closes #2471 2014-12-31 12:40:11 +01:00
767800662c Added chunk check on Level 2014-12-30 15:54:12 +01:00
fe32e6f5d0 Merge branch 'master' into new-version-format 2014-12-29 12:43:15 +01:00
2cec0d9f36 Improved Simplex 2D noise 2014-12-28 03:51:08 +01:00
d800a21bd4 Higher chunk defaults 2014-12-28 02:58:17 +01:00
8d9fbec4ce Fixed memory leak issues on chunk generation under 32-bit hosts, fixed issue with generated chunks not having a provider. Closes #2419, fixes #2308, closes #2421 2014-12-28 02:22:13 +01:00
ab72c32769 Improved Normal generator speed 2014-12-28 02:12:48 +01:00
346626305c Corrected fence crafting recipes, closes #2457 2014-12-28 01:49:42 +01:00
fafbd500e1 Added typehints to HelpCommand 2014-12-28 01:49:10 +01:00
2db2e8cfc4 Block IP addresses on ban-ip 2014-12-26 13:56:35 +01:00
854479180f Move Query exceptions to debug level > 1 2014-12-26 13:47:15 +01:00
902ba81e02 Added automatic/manual RakLib IP address, block addresses when exceptions are thrown 2014-12-26 13:33:41 +01:00
1ac17abec0 Fixed #2446 2014-12-24 23:00:11 +01:00
714ea54121 Players won't take damage 60 ticks after spawning / respawning. 2014-12-24 20:44:22 +01:00
aa992684ba Possible workaround for some PHP bug 2014-12-24 00:55:23 +01:00
0c58de86b7 New version format 2014-12-23 14:02:35 +01:00
7ecac019a9 Bitmask block state 2014-12-23 13:58:30 +01:00
6cb88afe1a Improved block breaking time and event handling 2014-12-22 23:49:17 +01:00
a677bcb331 Increased transaction timeout, not needed anymore due to packet ordering 2014-12-22 23:38:47 +01:00
2f6007342c Fixed server.log created in two different places on path changed 2014-12-22 23:00:28 +01:00
b6c0eb8c96 Added optional parameter for multiple NBT read 2014-12-22 16:25:12 +01:00
afa8496767 Fixed possible memory leak when hiding players from each other 2014-12-21 20:03:39 +01:00
d7be2ce439 Added Chest recreation on imported levels 2014-12-21 14:29:18 +01:00
6dcb5da069 Added Double Plant block, fixes damage walking inside it. 2014-12-21 14:28:45 +01:00
3cf1692c96 Possible fix for #2424 2014-12-21 13:59:04 +01:00
d04af590d1 Updated RakLib
* Fixes issues with packets without messageIndex
* Workarounds possible CPU-hog DoS attack over ACK/NACK packets
2014-12-21 13:45:28 +01:00
d4c43215b1 Fixed typo about async chunk generation 2014-12-19 16:10:01 +01:00
a40918aabf LevelDB load/write fixes 2014-12-19 10:35:16 +01:00
20f9352714 Merge branch 'master' of github.com:PocketMine/PocketMine-MP 2014-12-19 01:07:13 +01:00
a605e90dfc Added experimental LevelDB support, fixed a few issues with NBT, spawning and Binary R/W 2014-12-19 00:28:50 +01:00
9fc250956f Merge pull request #2395 from PEMapModder/patch-6
Allow $base in knockback() to be dynamic and getters/setters in EntityDa...
2014-12-18 20:39:48 +09:00
db2dfc47a6 Update RakLib 2014-12-18 03:33:33 +01:00
408a537001 Added TesterPlugin submodule, updated RakLib to fix packet loop issues 2014-12-17 23:29:57 +01:00
922bfb33ac Updated .gitignore 2014-12-16 18:50:57 +01:00
8e47c93fbc Fixed some issues with chunks being generated on a loop 2014-12-16 02:57:44 +01:00
c175485cd8 Added World Generation timings 2014-12-15 17:52:07 +01:00
b6981cc31d Merge branch 'master' of github.com:PocketMine/PocketMine-MP 2014-12-15 01:05:55 +01:00
1f9cd6a99b Added default parameter to Config getters, implements and closes #2398 2014-12-15 01:05:32 +01:00
ded7ada7d7 Merge pull request #2399 from PEMapModder/patch-7
Update documentation of PluginBase::getCommand() for IDEs' auto completion
2014-12-15 00:52:43 +01:00
1b50879823 Snow layer recipe added: Fix for #2400 2014-12-13 17:10:17 +01:00
1bd9cbd4d3 Update documentation of PluginBase::getCommand() for IDEs' auto completion 2014-12-13 20:42:23 +08:00
96122d3be7 Allow $base in knockback() to be dynamic and getters/setters in EntityDamageByEntityEvent
This change is backwards-compatible.
2014-12-12 23:01:31 +08:00
71d602a4cf Faster chunk setting on provider 2014-12-12 15:51:31 +01:00
c81bbdaaa9 Possible fix for #2394 2014-12-12 12:05:36 +01:00
2752393c42 Fixed #2392 2014-12-12 12:05:15 +01:00
312e064b07 Updated RakLib, changed some Entity move AABB calls 2014-12-11 17:39:59 +01:00
94f91967f3 Updated RakLib: Implemented packet reordering, fixed packet recovery in both sides, errors are now debug level 2014-12-11 03:13:44 +01:00
fe900b417e Less calls! 2014-12-10 02:42:02 +01:00
4c30b6b8a1 Optimized Liquid spreading, optimized light updates, improved side block get/update, fixed raw set not cleaning Block cache (TNT explosions) 2014-12-10 00:37:04 +01:00
c41ac7b0a2 Updated PocketMine-SPL, added trait autoloading 2014-12-09 16:33:42 +01:00
b220bd2a45 Updated chunk indexes on generator 2014-12-09 15:14:11 +01:00
04ee94dc91 Fixed #2388 2014-12-09 15:05:36 +01:00
ea8f10efa4 Limited death animation to Living entities 2014-12-09 14:57:28 +01:00
04ecbd1a76 Level optimization, added new chunk/block hashes 2014-12-09 14:55:21 +01:00
ddfc9d9ce1 Fixed players not getting sound when they are harmed 2014-12-09 02:22:42 +01:00
a4735eaf76 Replaced some instanceof to null checks 2014-12-09 02:22:18 +01:00
306f492fc0 Added Player death animations, improved spawning behavior to correct invisible players, fixed players getting stuck when dead, closes #2304 2014-12-09 01:36:46 +01:00
5e5f8bf33d Better block creation on Level 2014-12-08 22:02:36 +01:00
3bb2f12cde Improved block reading
* Created global block states array
* Improved Level->getBlock() using block states
* Improved Level->getBlock() for 64-bit systems
* Added Level->getFullBlock()
* Added FullChunk->getFullBlock()
* Added Chunk->getFullBlock()
* Added ChunkSection->getFullBlock()
* Deprecated FullChunk->getBlock()
* Deprecated Chunk->getBlock()
* Deprecated ChunkSection->getBlock()
2014-12-08 20:54:47 +01:00
1041bb0e6a Do not quiet error messages when parsing config files 2014-12-07 23:21:47 +01:00
49e93cee80 Merge branch 'master' of github.com:PocketMine/PocketMine-MP 2014-12-07 22:05:58 +01:00
8b6681c56d FIxed some preprocessor includes 2014-12-07 22:05:45 +01:00
9e3d432b9e Faster Level provider chunk unloading 2014-12-07 21:51:57 +01:00
841a3d5ee6 Merge pull request #2381 from PocketMine/revert-2379-master
Revert "Fixed small possible error in permission"
2014-12-07 20:54:46 +01:00
a5294d5ec7 Revert "Fixed small possible error in permission" 2014-12-07 20:54:38 +01:00
5373e6be07 Merge pull request #2379 from sudoku173/master
Fixed small possible error in permission
2014-12-07 20:41:08 +01:00
075137bd3c Fixed small possible error in permission
Changed permission to "pocketmine.command.deop" from "pocketmine.command.op.take"
2014-12-07 11:38:44 -08:00
68da4b5b39 Collect unallocated chunks from the Level provider 2014-12-07 18:27:11 +01:00
e4557a2e8e Added HeightMap get/set methods on chunks, Level 2014-12-07 18:02:07 +01:00
964bf98ca6 Added Config->getNested(key) and Config->setNested(key, value) 2014-12-07 16:41:43 +01:00
747f7685e7 Fix formatting issues due to bad IDE settings 2014-12-07 16:30:04 +01:00
bb82e7be50 Handle a hotbar queue to allow using more than the first slot (won't save order due to the protocol) 2014-12-07 16:01:45 +01:00
7506f01302 Improved Item property handling 2014-12-07 15:51:00 +01:00
a98da3bab1 Renamed old getID() calls to getId() 2014-12-07 15:21:32 +01:00
f0d6128282 Use squared distance on movement handling 2014-12-07 15:18:14 +01:00
161e7ae7ec Fix CPU issue when starting without STDIN 2014-12-07 02:42:38 +01:00
6104c5b5a3 API 1.9.0, backwards-compatible 2014-12-07 02:24:45 +01:00
af82d616c1 Block creating and property handling rewrite, part2 2014-12-07 02:20:26 +01:00
a0d4bff385 Block creating and property handling rewrite, part1 2014-12-07 01:53:27 +01:00
79236c971c Possibly fix issues related to new lines on different operating systems and event listeners modifiers 2014-12-05 22:43:31 +01:00
20e63ae543 Force player setting their new position 2014-12-05 02:24:34 +01:00
add7879720 Implemented no damage ticks 2014-12-05 02:24:08 +01:00
1a064d38b1 Merge remote-tracking branch 'origin/master' 2014-12-04 00:04:18 +01:00
294e680d5d Added armor items and max stack size for them. 2014-12-04 00:04:09 +01:00
811970e58d Merge pull request #2352 from PEMapModder/patch-3
Added internal use warning for TaskHandler::cancel()
2014-12-01 12:07:30 +01:00
941961f5ef Added internal use warning for TaskHandler::cancel()
It is confusing for some developers to whether to use this function or `ServerScheduler::cancelTask($taskId)`. It is better to add warning in the documentation.
2014-12-01 16:25:37 +08:00
1963d8fde0 Change last X/Y/Z/Yaw/Pitch on teleport 2014-11-30 12:49:35 +01:00
e44ed4da3b Enabled batch block sending again 2014-11-29 12:58:31 +01:00
a72488d41e Updated player movement processing and event handling 2014-11-29 12:43:34 +01:00
3930f379cf Updated light filter values 2014-11-29 11:58:50 +01:00
66ba327e62 Improved light spread algorithm even more 2014-11-29 11:27:22 +01:00
329ca62465 Improved light spread algorithm 2014-11-28 19:54:25 +01:00
26e47ef694 Removed old revert flag from Player->processMovement() 2014-11-28 14:49:06 +01:00
61ea149ff0 API 1.8.0 2014-11-28 14:44:56 +01:00
b3c3f896a3 Implemented light population, added Level->getFullLight() 2014-11-28 14:44:27 +01:00
d139e5f342 Removed temporal pthreads workaround 2014-11-28 13:01:25 +01:00
3abf36ad07 Fixed invalid worlds property being set by users 2014-11-28 12:47:28 +01:00
0bc9a9bdab Fixed armor dropping twice 2014-11-27 23:19:46 +01:00
98340522d9 Fixed items getting added on the same empty slot 2014-11-27 20:49:18 +01:00
6d09754ea7 Improved Inventory->addItem(), fixed breaking containers duplicating the last slot, removed not necessary slot changes 2014-11-27 20:10:55 +01:00
a3b1d318cc Fixed ladder crafting recipe 2014-11-27 20:02:38 +01:00
f866efb622 Removed unused Block->isLiquid property 2014-11-27 17:26:43 +01:00
b1c4578726 Fixed #2340 2014-11-27 16:18:43 +01:00
f4181a6e36 Bump Minecraft: PE version 2014-11-27 14:37:44 +01:00
38089af098 Improved global entity motion encoding using per-player queues 2014-11-27 14:26:36 +01:00
cd135b39ad Improved player spawn item in hand sending 2014-11-27 13:59:32 +01:00
dd3207cbd8 Possible fix for #2267, #2314 2014-11-27 13:47:17 +01:00
a7abd5ff9d Catch exceptions when chunks are unloaded 2014-11-27 13:35:54 +01:00
a3e50f6337 Properly close inventory windows from Players 2014-11-27 13:32:07 +01:00
441a98e60a Removed old trigger_error() calls, closes #2335 2014-11-27 13:16:39 +01:00
4a90ac270f Improved exception handling and debugging 2014-11-22 13:52:36 +01:00
a906a2988b Bumped Minecraft: PE version string 2014-11-22 13:44:34 +01:00
545f68382c Increased Fence, Fence Gate and Stone Wall Y bounding box 2014-11-22 13:44:05 +01:00
8249cac592 Catch corrupted chunk data errors 2014-11-20 22:02:00 +01:00
7b7bbe9105 Regenerate corrupt player data if invalid data is found 2014-11-20 21:58:27 +01:00
05679c7872 Merge branch 'master' of github.com:PocketMine/PocketMine-MP 2014-11-20 21:46:14 +01:00
8eb80be691 Remove duplicated tiles from chunk table automatically 2014-11-20 21:45:52 +01:00
f55b0d0b45 Merge pull request #2295 from LukeDarling/patch-1
Fixed Server->getOps() capitalization
2014-11-19 13:10:03 +01:00
754e0dbb49 Protect permission removal against bad plugins 2014-11-18 18:43:30 +01:00
525c8db779 Improved chunk loading/unloading 2014-11-18 18:33:24 +01:00
c7f578f297 Possible fix for #2297 2014-11-18 13:57:03 +01:00
19c030281f Fixed #1969 2014-11-18 13:53:38 +01:00
ca9fe1b89a Improved and fixed command exception message, closes #2301 2014-11-18 13:46:00 +01:00
9fd6a695f6 Fixed permission-related memory leak 2014-11-18 13:42:24 +01:00
c07b0ff35b Fixed tile entities not being placed in the correct array 2014-11-15 11:49:09 +01:00
00be3f0dd3 Fixed Server->getOps() capitalization
I'm not 100% sure, but I believe this is how it's supposed to be.
2014-11-15 00:01:57 -05:00
6796fca2b6 Merge pull request #2294 from LukeDarling/patch-1
fixed version message color
2014-11-15 14:20:14 +10:30
5657cce3db fixed version message color 2014-11-14 15:52:38 -05:00
05ac256cc3 Fixed Acacia / Dark Oak logs crafting recipes 2014-11-14 15:58:31 +01:00
49977c5410 Bumped weakref version, fixes travis builds 2014-11-14 10:30:06 +01:00
ca40bb678c Merge pull request #2288 from sekjun9878/master
Get timezone directly. Fixes #2287.
2014-11-13 23:08:22 +10:30
2068cc9cdf Merge pull request #2243 from PEMapModder/patch-1
cmd files comment syntax should be like this.
2014-11-13 21:42:25 +10:30
ea4617cedd Get timezone directly. Fixes #2287. 2014-11-13 21:13:12 +10:30
1a5544f68c Fixed Chunk tile indexes 2014-11-08 15:00:18 +01:00
0128a7aeb2 API version 1.7.1 (fixes) 2014-11-07 09:45:30 +01:00
fd954ce708 Fixed PlayerInventory->setItem() with null items 2014-11-07 09:43:36 +01:00
d63a82de0a MCPE protocol 20 2014-11-06 19:08:32 +01:00
92143d523c Added SetDifficultyPacket 2014-11-06 19:07:24 +01:00
1818e64c8e Merge branch 'master' into 0.10 2014-11-06 18:56:47 +01:00
7e1095e28d Reenabled collision against entities on move 2014-11-06 12:57:17 +01:00
f1519e6d13 Improved Level->getTile() to a direct lookup instead of linear search 2014-11-06 12:34:33 +01:00
3b9a9bcd5d Use proper indexes on Living->getLineOfSight() when a max length is set 2014-11-06 12:23:45 +01:00
263bff01c8 Change RuntimeException to InvalidStateException on BlockIterator 2014-11-06 12:16:12 +01:00
987d647b76 Return proper BlockIterator index, throw more exceptions, improved blockQueue performance 2014-11-06 12:12:31 +01:00
522b75645c Merge branch 'master' into 0.10 2014-11-05 19:04:36 +01:00
9eed0a579c Fixed red sand smelting recipe 2014-11-05 17:41:12 +01:00
064976d32b Fixed ladder recipe 2014-11-05 17:38:23 +01:00
2abb577178 Fixed String -> Wool recipe 2014-11-05 17:36:44 +01:00
127855c220 Fixed Snow block recipe 2014-11-05 17:36:06 +01:00
93c7a3c170 Fixed bonemeal recipe, closes #2260 2014-11-05 17:32:28 +01:00
31903a764a Fixed unloaded chunks residing on memory and getting loaded again causing crash, fixed spawn chunks getting unloaded by players 2014-11-04 17:16:02 +01:00
79bc1d6c85 Fixed server not stopping after a special crash 2014-11-04 17:15:20 +01:00
cc7f12739d Added vertical and horizontal collision detection to Entities 2014-11-04 12:23:42 +01:00
32dae93ef9 Removed unused imports 2014-11-04 12:08:24 +01:00
8fd6582e74 Automatically set Entity / Tile entity save identifiers 2014-11-04 12:04:08 +01:00
a5369b3570 Fixed unloading chunks 2014-11-04 11:18:34 +01:00
abbd33210a Possible fix for #2245 2014-11-04 00:19:50 +01:00
6b6222c09c Allow passing a Player source as last parameter on Inventory->addItem() and Inventory->removeItem() 2014-11-04 00:16:25 +01:00
a8c997d88a ¬¬ 2014-11-03 12:54:46 +01:00
6993718a83 Added EntityDamageByChildEntityEvent 2014-11-03 12:03:37 +01:00
86afecec89 Improved inventory sending, send single slots instead of full inventory as much as possible 2014-11-03 11:48:10 +01:00
29d1fd1fc8 Fixed player viewer list including themselves 2014-11-03 11:29:01 +01:00
af4eb2ab1e Create server.log properly on non-existent directories 2014-11-02 16:15:15 +01:00
f7baf46a54 Fire PlayerInteractEvent on 0xff face 2014-11-02 16:12:51 +01:00
75c0d8324c Fixed some inventory events not firing on players 2014-11-02 13:26:58 +01:00
da4334f06b Revert Armor then Inventory instead of Inventory then Armor on failed transaction 2014-11-01 23:02:59 +01:00
413bd3c0df Use SplFixedArray for improved performance 2014-11-01 22:12:35 +01:00
1a0428654b Updated timings command, give direct link to results 2014-11-01 21:20:44 +01:00
2803a38fd1 Fixed random block updates not firing 2014-11-01 20:26:13 +01:00
95a5ca7889 Added command message to /time add 2014-11-01 20:12:55 +01:00
240f14c425 Fixed #2253 2014-11-01 19:40:15 +01:00
cb9b6ab1d1 Fixed server not using the correct provided path if it did not exist 2014-11-01 19:23:10 +01:00
8a87280566 Added /time start and /time stop 2014-11-01 17:45:11 +01:00
4d97827d44 Improved level switching for players 2014-11-01 17:39:09 +01:00
f8f1e0e9df Despawn entities correctly from clients as they move 2014-11-01 16:47:40 +01:00
bf596ebf05 Fixed Query-related crash 2014-11-01 16:20:40 +01:00
90777014b6 Fixed Stone crash 2014-11-01 16:17:47 +01:00
4a78ffd2dd Fixed FallingSand crash 2014-11-01 16:15:09 +01:00
7c361a52d2 Fixed #2252 2014-11-01 13:52:20 +01:00
13fc0df92c Fixed #2251 2014-11-01 12:40:45 +01:00
d5012f6fcf Fixed server not stopping after a fatal error 2014-11-01 03:07:47 +01:00
4569a73f3d Fixed Entity being set position after being closed 2014-10-31 23:10:29 +01:00
66acb5cdd7 Possible fix for crashing server not stopping 2014-10-31 23:10:12 +01:00
8601405a88 Fixed CPU leak 2014-10-31 21:07:00 +01:00
ae06681b60 Added packet exception handling, updated RakLib 2014-10-31 19:14:59 +01:00
01ffb14e39 Fixed #2204 2014-10-31 17:34:45 +01:00
ce989876af Improved freeing chunks 2014-10-31 16:39:32 +01:00
f8d6ebabf3 Removed some calls 2014-10-31 15:57:07 +01:00
094b600a0c Updated NBT/DataPacket reading 2014-10-31 01:02:31 +01:00
82cfe6ea9c Updated NBT/DataPacket reading 2014-10-31 00:32:50 +01:00
4fba6d7c86 Merge branch 'master' into 0.10 2014-10-30 23:20:59 +01:00
f72d7284b9 Added EncapsulatedPacket reuse on broadcast 2014-10-30 23:20:28 +01:00
8f0527832f Removed extra AxisAlignedBB generation on Door and Trapdoor 2014-10-30 22:15:19 +01:00
f66944368d Update RakLib 2014-10-30 22:06:23 +01:00
7ab3c57b00 Optimized networking code & AxisAlignedBB 2014-10-30 22:06:07 +01:00
673b867ee8 Fixed players not loading chunks when stuck on a unloaded chunk 2014-10-30 20:05:40 +01:00
2424c8a76c Update RakLib, possible fix for notifyACK 2014-10-30 19:44:05 +01:00
92eb5cb0b8 Added LE Triad methods 2014-10-30 17:56:58 +01:00
fd46c71120 Updated RakLib 2014-10-30 17:18:43 +01:00
6a4259bf24 Updated RakLib 2014-10-30 17:04:19 +01:00
9a65279c6a Added ifndef for packets Binary 2014-10-30 16:41:11 +01:00
09a01be709 Added ifndef for NBT Binary 2014-10-30 16:32:57 +01:00
57d1847c50 Updated to receive new optimizations 2014-10-30 16:02:48 +01:00
6e8e2a79dd Fixed Event name being null 2014-10-30 14:52:11 +01:00
d8f9def7f4 Added preprocessor optimizations 2014-10-30 07:58:53 +01:00
8cb9dd9a14 Fixed #2244 2014-10-29 22:58:40 +01:00
c4c374e3fa Added extra chunk sending timings 2014-10-29 21:52:27 +01:00
d57e37896d Improved Region / RakLib 2014-10-29 17:43:21 +01:00
022a978ffb Added InventoryPickupArrowEvent 2014-10-29 16:29:00 +01:00
00b282d40c Improved cache pool cleanup times 2014-10-29 16:13:47 +01:00
8a768cea33 EntityDamageEvent and children now only fire if the attack is possible, moved event trigger to Entity->attack() 2014-10-29 16:02:40 +01:00
289bc56b4b Blocks now save their bounding box, fixed entity block collision check 2014-10-29 15:43:23 +01:00
6f64af3066 Reuse even more objects! 2014-10-29 14:23:51 +01:00
72c09045d5 Fixed Zombie drops crash 2014-10-29 13:21:54 +01:00
5e55c3a8f0 Fixed Chest->unpair() 2014-10-29 13:21:14 +01:00
afaa2cf722 Fixed Double Chest behavior 2014-10-29 12:57:26 +01:00
50cfeaa393 Fixed Stonecutter recipe 2014-10-29 12:36:34 +01:00
dda8b03349 Fixed Bowl recipe 2014-10-29 12:12:54 +01:00
56e848488a Fixed Trapdoor recipe 2014-10-29 12:10:48 +01:00
7e4f862634 Fixed typo in OfflinePlayer 2014-10-29 11:42:29 +01:00
577a7a1c3d cmd files comment syntax should be like this. 2014-10-29 17:20:36 +08:00
78f8d0280d Removed unused imports 2014-10-29 01:14:09 +01:00
0680b98380 Remove chunks from advanced cache after setting 2014-10-29 01:07:30 +01:00
cbe0fe5e46 Added Entity->onGround setting when entities keep moving without checks 2014-10-29 00:41:13 +01:00
7eed92e8fb Use Player->forceMovement on MovePlayerPacket non-tick revert 2014-10-29 00:31:17 +01:00
f772391866 Fixed InventoryPickupItemEvent 2014-10-28 22:05:54 +01:00
8c4faa8622 Added extra Exceptions 2014-10-28 21:07:12 +01:00
b6f7ee20fc Added Error -> Exception handling 2014-10-28 20:43:36 +01:00
0fce83c671 Fixed #2189 2014-10-28 13:27:30 +01:00
8080643cc9 Fixed plugins crashing the server when teleporting players on an invalid event 2014-10-28 13:18:40 +01:00
5bf2174cad Fixed UseItemPacket being able to be sent before spawning 2014-10-28 13:16:20 +01:00
34ae760def New way to spawn entities/tiles using a global register table, allow overriding default entity/tile classes via classes 2014-10-28 13:09:27 +01:00
a5b85c549a Added Snowballs 2014-10-28 12:13:31 +01:00
b9f1812f61 Disallow further modification of Signs by its creator after load/unload 2014-10-28 11:05:32 +01:00
350cee3d41 Added Event allocation pool, updated SPL with Class::onClassLoaded() 2014-10-28 10:47:40 +01:00
144a871c07 Improved Vector3 and Block handling, less allocation on Positions 2014-10-28 10:03:10 +01:00
69492474e4 Improve #2238, do not crash when an invalid/corrupt RCON stop event happens 2014-10-28 02:09:36 +01:00
4299ebebcc Bump API version to 1.6.1 2014-10-28 00:55:07 +01:00
119b429ab8 RakLib update 2014-10-28 00:43:47 +01:00
8f1eb41ca5 RakLib update 2014-10-28 00:23:55 +01:00
ca92d2a0d3 Bumped API version to 1.7.0 2014-10-27 20:30:58 +01:00
db82f76c11 Improved network packets allocation 2014-10-27 20:30:33 +01:00
3f5b129cf5 Updated RakLib 2014-10-27 19:39:24 +01:00
f6aac8728b Mark chunk to be saved when removing invalid entities/tiles 2014-10-27 18:43:58 +01:00
809fc44813 Bump API version to 1.6.1 2014-10-27 16:07:00 +01:00
64f1ff066d Fixed /setworldspawn changing sender data 2014-10-27 15:57:26 +01:00
a5a3f4801a Fixed entities not getting ticks on movement 2014-10-27 15:53:14 +01:00
23d1532ff9 Merge branch 'master' of github.com:PocketMine/PocketMine-MP 2014-10-27 15:44:44 +01:00
ecbbcc2e8e Drop invalid entities / tile entities on chunk loading 2014-10-27 15:44:36 +01:00
7abf52e615 Implemented Vector3 List and AxisAlignedBB Pool to decrease object allocation 2014-10-27 15:39:20 +01:00
9e01e2ef49 Merge pull request #2235 from nno88551/patch-2
Update BaseInventory.php
2014-10-26 15:52:08 +01:00
df81b365e5 Update BaseInventory.php 2014-10-26 22:21:21 +09:00
db8ac0b9cb Merge pull request #2225 from PEMapModder/falling-sand
Update FallingBlock to new Anvil formats, possible fix for #2189
2014-10-25 17:58:47 +02:00
ee4f416d93 Fix FallingBlock.php 2014-10-25 18:15:47 +08:00
8feea721e3 Merge pull request #2223 from Falkirks/set-armour-fix
Fix various get and set armour in PlayerInventory
2014-10-25 12:13:28 +02:00
8e7077ff4b Update FallingBlock to new Anvil formats, possible fix for #2189
I don't have time to test yet, so I am not sure if it does fix it.
2014-10-25 12:26:57 +08:00
4f4a6e7446 Fixes get and set armour 2014-10-24 17:11:59 -07:00
1fc066fc37 Updated time steps from x2.5 to x1.25 2014-10-24 12:12:01 +02:00
b565844062 Merge branch 'master' into 0.10 2014-10-24 12:07:35 +02:00
be948f99cc Fixed #2207 Server crashing if players are closed before logging in 2014-10-24 12:06:55 +02:00
5cb428e5cc Updated build number 2014-10-23 17:23:59 +02:00
d2f4a14d66 Merge branch 'master' into 0.10 2014-10-23 17:21:24 +02:00
516bb37a50 Removed some direct type checks on Entity/Tile->closed 2014-10-21 19:28:29 +02:00
580ade9092 Possible fix for entities not closing correctly 2014-10-21 19:26:16 +02:00
8f7dfe0b71 Removed extra ; from if, fixes #2205 2014-10-21 18:37:29 +02:00
5310ba3ae6 Fixed crash when doing var_dump() of anything that contains the Server object 2014-10-20 13:06:53 +02:00
ef97efcd96 Added explosion death message 2014-10-20 13:00:03 +02:00
30c3718ea8 Improved Explosion item drop position 2014-10-20 12:58:05 +02:00
5437567e95 Merge branch 'master' into 0.10 2014-10-20 12:53:14 +02:00
e3e97a4205 Improved Player->onGround checking 2014-10-20 12:52:00 +02:00
fec387d2ec Fixed entities not being pushed out of blocks 2014-10-20 12:37:17 +02:00
481e2b08ee Removed debug call 2014-10-20 12:05:40 +02:00
15de0eece7 Improved inventory and window allocation, fixes #2200 2014-10-20 09:48:11 +02:00
2f8267aa1e Improved Level object deallocation 2014-10-19 20:45:03 +02:00
f2b573c32f Fixed Level->getMetadata() and similar, removed extra references 2014-10-19 19:51:36 +02:00
34946faf94 Remove errors from Utils::getRandomBytes() 2014-10-19 13:44:38 +02:00
3b47513439 Return result directly on Server->getOfflinePlayer() 2014-10-19 02:49:58 +02:00
7d9a98ec6b Updated UseItemPacket 2014-10-18 23:42:41 +02:00
92facc94b9 Added new fences and fence gates to fuel types 2014-10-18 18:02:39 +02:00
d3327f450c Added different Fence Gates, new Fence Gate crafting recipes 2014-10-18 17:56:18 +02:00
570cab9c66 Added different Fences, new Fence crafting recipes 2014-10-18 17:44:24 +02:00
582ba100b0 Bumped protocol version to 19 2014-10-18 17:01:36 +02:00
4c0daa462d Merge branch 'master' into 0.10 2014-10-18 16:54:03 +02:00
2e6366868d Merge branch 'master' of github.com:PocketMine/PocketMine-MP 2014-10-18 16:53:42 +02:00
245e9b4f18 Fixes inventory changes getting the wrong window, closes #2187 2014-10-18 16:53:06 +02:00
68e73d4e3a Merge pull request #2188 from aodzip/patch-1
Update Skeleton.php
2014-10-18 15:36:02 +02:00
684617d370 Update Skeleton.php
fixed a little wrong
2014-10-18 21:13:35 +08:00
a879104a6f Minecraft: PE version bump 2014-10-17 14:43:10 +02:00
404 changed files with 8865 additions and 4917 deletions

1
.gitignore vendored
View File

@ -2,6 +2,7 @@ players/*
worlds/* worlds/*
plugins/* plugins/*
bin/* bin/*
timings/*
*.log *.log
*.txt *.txt
*.phar *.phar

3
.gitmodules vendored
View File

@ -9,3 +9,6 @@
[submodule "src/spl"] [submodule "src/spl"]
path = src/spl path = src/spl
url = https://github.com/PocketMine/PocketMine-SPL.git url = https://github.com/PocketMine/PocketMine-SPL.git
[submodule "tests/TesterPlugin"]
path = tests/TesterPlugin
url = https://github.com/PocketMine/TesterPlugin.git

View File

@ -10,7 +10,7 @@ before_script:
- mkdir plugins - mkdir plugins
- wget -O plugins/DevTools.phar https://github.com/PocketMine/DevTools/releases/download/v1.9.0/DevTools_v1.9.0.phar - 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/pthreads-2.0.10
- pecl install channel://pecl.php.net/weakref-0.2.4 - pecl install channel://pecl.php.net/weakref-0.2.6
- echo | pecl install channel://pecl.php.net/yaml-1.1.1 - echo | pecl install channel://pecl.php.net/yaml-1.1.1
script: script:
@ -18,4 +18,4 @@ script:
notifications: notifications:
email: false email: false
#webhooks: http://n.tkte.ch/h/214/wsNvmG43-ncxUVRrFPwSM-r0 #webhooks: http://n.tkte.ch/h/214/wsNvmG43-ncxUVRrFPwSM-r0

View File

@ -42,7 +42,10 @@ class CrashDump{
$this->time = time(); $this->time = time();
$this->server = $server; $this->server = $server;
$this->path = $this->server->getDataPath() . "CrashDump_" . date("D_M_j-H.i.s-T_Y", $this->time) . ".log"; $this->path = $this->server->getDataPath() . "CrashDump_" . date("D_M_j-H.i.s-T_Y", $this->time) . ".log";
$this->fp = fopen($this->path, "wb"); $this->fp = @fopen($this->path, "wb");
if(!is_resource($this->fp)){
throw new \RuntimeException("Could not create Crash Dump");
}
$this->data["time"] = $this->time; $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($this->server->getName() . " Crash Dump " . date("D M j H:i:s T Y", $this->time));
$this->addLine(); $this->addLine();
@ -137,7 +140,7 @@ class CrashDump{
$error = $lastExceptionError; $error = $lastExceptionError;
}else{ }else{
$error = (array) error_get_last(); $error = (array) error_get_last();
$error["trace"] = getTrace(4); $error["trace"] = @getTrace(3);
$errorConversion = [ $errorConversion = [
E_ERROR => "E_ERROR", E_ERROR => "E_ERROR",
E_WARNING => "E_WARNING", E_WARNING => "E_WARNING",

File diff suppressed because it is too large Load Diff

View File

@ -65,16 +65,15 @@ namespace {
} }
namespace pocketmine { namespace pocketmine {
use LogLevel;
use pocketmine\utils\Binary; use pocketmine\utils\Binary;
use pocketmine\utils\MainLogger; use pocketmine\utils\MainLogger;
use pocketmine\utils\Utils; use pocketmine\utils\Utils;
use pocketmine\wizard\Installer; use pocketmine\wizard\Installer;
const VERSION = "Alpha_1.4dev"; const VERSION = "1.4.1";
const API_VERSION = "1.6.0"; const API_VERSION = "1.11.0";
const CODENAME = "絶好(Zekkou)ケーキ(Cake)"; const CODENAME = "絶好(Zekkou)ケーキ(Cake)";
const MINECRAFT_VERSION = "v0.9.5 alpha"; const MINECRAFT_VERSION = "v0.10.5 alpha";
/* /*
* Startup code. Do not look at it, it may harm you. * Startup code. Do not look at it, it may harm you.
@ -96,6 +95,7 @@ namespace pocketmine {
} }
if(!class_exists("ClassLoader", false)){ 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/ClassLoader.php");
require_once(\pocketmine\PATH . "src/spl/BaseClassLoader.php"); require_once(\pocketmine\PATH . "src/spl/BaseClassLoader.php");
require_once(\pocketmine\PATH . "src/pocketmine/CompatibleClassLoader.php"); require_once(\pocketmine\PATH . "src/pocketmine/CompatibleClassLoader.php");
@ -104,7 +104,6 @@ namespace pocketmine {
$autoloader = new CompatibleClassLoader(); $autoloader = new CompatibleClassLoader();
$autoloader->addPath(\pocketmine\PATH . "src"); $autoloader->addPath(\pocketmine\PATH . "src");
$autoloader->addPath(\pocketmine\PATH . "src" . DIRECTORY_SEPARATOR . "spl"); $autoloader->addPath(\pocketmine\PATH . "src" . DIRECTORY_SEPARATOR . "spl");
$autoloader->addPath(\pocketmine\PATH . "src" . DIRECTORY_SEPARATOR . "raklib");
$autoloader->register(true); $autoloader->register(true);
@ -117,16 +116,21 @@ namespace pocketmine {
ini_set("display_startup_errors", 1); ini_set("display_startup_errors", 1);
ini_set("default_charset", "utf-8"); ini_set("default_charset", "utf-8");
ini_set("memory_limit", "256M"); //Default ini_set("memory_limit", -1);
define("pocketmine\\START_TIME", microtime(true)); define("pocketmine\\START_TIME", microtime(true));
$opts = getopt("", ["enable-ansi", "disable-ansi", "data:", "plugins:", "no-wizard", "enable-profiler"]); $opts = getopt("", ["enable-ansi", "disable-ansi", "data:", "plugins:", "no-wizard", "enable-profiler"]);
define("pocketmine\\DATA", isset($opts["data"]) ? realpath($opts["data"]) . DIRECTORY_SEPARATOR : \getcwd() . DIRECTORY_SEPARATOR); define("pocketmine\\DATA", isset($opts["data"]) ? $opts["data"] . DIRECTORY_SEPARATOR : \getcwd() . DIRECTORY_SEPARATOR);
define("pocketmine\\PLUGIN_PATH", isset($opts["plugins"]) ? realpath($opts["plugins"]) . DIRECTORY_SEPARATOR : \getcwd() . DIRECTORY_SEPARATOR . "plugins" . 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"])); 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. //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"); date_default_timezone_set("UTC");
$logger = new MainLogger(\pocketmine\DATA . "server.log", \pocketmine\ANSI); $logger = new MainLogger(\pocketmine\DATA . "server.log", \pocketmine\ANSI);
@ -134,15 +138,15 @@ namespace pocketmine {
if(!ini_get("date.timezone")){ if(!ini_get("date.timezone")){
if(($timezone = detect_system_timezone()) and date_default_timezone_set($timezone)){ if(($timezone = detect_system_timezone()) and date_default_timezone_set($timezone)){
//Success! Timezone has already been set and validated in the if statement. //Success! Timezone has already been set and validated in the if statement.
//This here is just for redundancy just in case some stupid program wants to read timezone data from the ini. //This here is just for redundancy just in case some program wants to read timezone data from the ini.
ini_set("date.timezone", $timezone); ini_set("date.timezone", $timezone);
}else{ }else{
//If system timezone detection fails or timezone is an invalid value. //If system timezone detection fails or timezone is an invalid value.
if($response = Utils::getURL("http://ip-api.com/json") if($response = Utils::getURL("http://ip-api.com/json")
and $ip_geolocation_data = json_decode($response, true) and $ip_geolocation_data = json_decode($response, true)
and $ip_geolocation_data['status'] != 'fail' and $ip_geolocation_data['status'] != 'fail'
and date_default_timezone_set($ip_geolocation_data['timezone'])) and date_default_timezone_set($ip_geolocation_data['timezone'])
{ ){
//Again, for redundancy. //Again, for redundancy.
ini_set("date.timezone", $ip_geolocation_data['timezone']); ini_set("date.timezone", $ip_geolocation_data['timezone']);
}else{ }else{
@ -153,7 +157,8 @@ namespace pocketmine {
} }
}else{ }else{
/* /*
* This is here so that stupid idiots don't come to us complaining and fill up the issue tracker when they put an incorrect timezone abbreviation in php.ini apparently. * 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(); $default_timezone = date_default_timezone_get();
if(strpos($default_timezone, "/") === false){ if(strpos($default_timezone, "/") === false){
@ -166,17 +171,30 @@ namespace pocketmine {
function detect_system_timezone(){ function detect_system_timezone(){
switch(Utils::getOS()){ switch(Utils::getOS()){
case 'win': case 'win':
$regex = '/(?:Time Zone:\s*\()(UTC)(\+*\-*\d*\d*\:*\d*\d*)(?:\))/'; $regex = '/(UTC)(\+*\-*\d*\d*\:*\d*\d*)/';
exec("systeminfo", $output); /*
* 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)); $string = trim(implode("\n", $output));
//Detect the Time Zone string in systeminfo //Detect the Time Zone string
preg_match($regex, $string, $matches); preg_match($regex, $string, $matches);
if(!isset($matches[2])) if(!isset($matches[2])){
{
return false; return false;
} }
@ -234,6 +252,7 @@ namespace pocketmine {
/** /**
* @param string $offset In the format of +09:00, +02:00, -04:00 etc. * @param string $offset In the format of +09:00, +02:00, -04:00 etc.
*
* @return string * @return string
*/ */
function parse_offset($offset){ function parse_offset($offset){
@ -314,7 +333,7 @@ namespace pocketmine {
$args = $trace[$i]["params"]; $args = $trace[$i]["params"];
} }
foreach($args as $name => $value){ foreach($args as $name => $value){
$params .= (is_object($value) ? get_class($value) . " " . (method_exists($value, "__toString") ? $value->__toString() : "object") : gettype($value) . " " . @strval($value)) . ", "; $params .= (is_object($value) ? get_class($value) . " " . (method_exists($value, "__toString") ? $value->__toString() : "object") : gettype($value) . " " . (is_array($value) ? "Array()" : @strval($value))) . ", ";
} }
} }
$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) . ")"; $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) . ")";
@ -327,55 +346,7 @@ namespace pocketmine {
return rtrim(str_replace(["\\", ".php", "phar://", rtrim(str_replace(["\\", "phar://"], ["/", ""], \pocketmine\PATH), "/"), rtrim(str_replace(["\\", "phar://"], ["/", ""], \pocketmine\PLUGIN_PATH), "/")], ["/", "", "", "", ""], $path), "/"); return rtrim(str_replace(["\\", ".php", "phar://", rtrim(str_replace(["\\", "phar://"], ["/", ""], \pocketmine\PATH), "/"), rtrim(str_replace(["\\", "phar://"], ["/", ""], \pocketmine\PLUGIN_PATH), "/")], ["/", "", "", "", ""], $path), "/");
} }
function error_handler($errno, $errstr, $errfile, $errline, $context, $trace = null){ set_error_handler([\ExceptionHandler::class, "handler"], -1);
global $lastError;
if(error_reporting() === 0){ //@ error-con..trol
return false;
}
$errorConversion = [
E_ERROR => "E_ERROR",
E_WARNING => "E_WARNING",
E_PARSE => "E_PARSE",
E_NOTICE => "E_NOTICE",
E_CORE_ERROR => "E_CORE_ERROR",
E_CORE_WARNING => "E_CORE_WARNING",
E_COMPILE_ERROR => "E_COMPILE_ERROR",
E_COMPILE_WARNING => "E_COMPILE_WARNING",
E_USER_ERROR => "E_USER_ERROR",
E_USER_WARNING => "E_USER_WARNING",
E_USER_NOTICE => "E_USER_NOTICE",
E_STRICT => "E_STRICT",
E_RECOVERABLE_ERROR => "E_RECOVERABLE_ERROR",
E_DEPRECATED => "E_DEPRECATED",
E_USER_DEPRECATED => "E_USER_DEPRECATED",
];
$type = ($errno === E_ERROR or $errno === E_USER_ERROR) ? LogLevel::ERROR : (($errno === E_USER_WARNING or $errno === E_WARNING) ? LogLevel::WARNING : LogLevel::NOTICE);
$errno = isset($errorConversion[$errno]) ? $errorConversion[$errno] : $errno;
if(($pos = strpos($errstr, "\n")) !== false){
$errstr = substr($errstr, 0, $pos);
}
$logger = MainLogger::getLogger();
$oldFile = $errfile;
$errfile = cleanPath($errfile);
$logger->log($type, "An $errno error happened: \"$errstr\" in \"$errfile\" at line $errline");
foreach(($trace = getTrace($trace === null ? 3 : 0, $trace)) as $i => $line){
$logger->debug($line);
}
$lastError = [
"type" => $type,
"message" => $errstr,
"fullFile" => $oldFile,
"file" => $errfile,
"line" => $errline,
"trace" => $trace
];
return true;
}
set_error_handler("\\pocketmine\\error_handler", E_ALL);
$errors = 0; $errors = 0;
@ -398,8 +369,8 @@ namespace pocketmine {
if(substr_count($pthreads_version, ".") < 2){ if(substr_count($pthreads_version, ".") < 2){
$pthreads_version = "0.$pthreads_version"; $pthreads_version = "0.$pthreads_version";
} }
if(version_compare($pthreads_version, "2.0.8") < 0){ if(version_compare($pthreads_version, "2.0.9") < 0){
$logger->critical("pthreads >= 2.0.8 is required, while you have $pthreads_version."); $logger->critical("pthreads >= 2.0.9 is required, while you have $pthreads_version.");
++$errors; ++$errors;
} }
@ -463,7 +434,7 @@ namespace pocketmine {
new Installer(); new Installer();
} }
if(substr(__FILE__, 0, 7) !== "phar://"){ if(\Phar::running(true) === ""){
$logger->warning("Non-packaged PocketMine-MP installation detected, do not use on production."); $logger->warning("Non-packaged PocketMine-MP installation detected, do not use on production.");
} }

File diff suppressed because it is too large Load Diff

View File

@ -26,9 +26,13 @@ namespace pocketmine;
*/ */
abstract class Thread extends \Thread{ abstract class Thread extends \Thread{
public final function start($options = PTHREADS_INHERIT_ALL){ public function start($options = PTHREADS_INHERIT_ALL){
ThreadManager::getInstance()->add($this); ThreadManager::getInstance()->add($this);
return parent::start($options); if(!$this->isRunning() and !$this->isJoined() and !$this->isTerminated()){
return parent::start($options);
}
return false;
} }
} }

View File

@ -26,9 +26,13 @@ namespace pocketmine;
*/ */
abstract class Worker extends \Worker{ abstract class Worker extends \Worker{
public final function start($options = PTHREADS_INHERIT_ALL){ public function start($options = PTHREADS_INHERIT_ALL){
ThreadManager::getInstance()->add($this); ThreadManager::getInstance()->add($this);
return parent::start($options); if(!$this->isRunning() and !$this->isJoined() and !$this->isTerminated() and !$this->isShutdown()){
return parent::start($options);
}
return false;
} }
} }

View File

@ -24,8 +24,15 @@ namespace pocketmine\block;
use pocketmine\item\Item; use pocketmine\item\Item;
class AcaciaWoodStairs extends Stair{ class AcaciaWoodStairs extends Stair{
protected $id = self::ACACIA_WOOD_STAIRS;
public function __construct($meta = 0){ public function __construct($meta = 0){
parent::__construct(self::ACACIA_WOOD_STAIRS, $meta, "Acacia Wood Stairs"); $this->meta = $meta;
}
public function getName(){
return "Acacia Wood Stairs";
} }
public function getDrops(Item $item){ public function getDrops(Item $item){

View File

@ -21,29 +21,45 @@
namespace pocketmine\block; namespace pocketmine\block;
use pocketmine\item\Item;
/** /**
* Air block * Air block
*/ */
class Air extends Transparent{ class Air extends Transparent{
public $isActivable = false;
public $breakable = false;
public $isFlowable = true;
public $isTransparent = true;
public $isReplaceable = true;
public $isPlaceable = false;
public $hasPhysics = false;
public $isSolid = false;
public $isFullBlock = true;
protected $id = self::AIR; protected $id = self::AIR;
protected $meta = 0; protected $meta = 0;
protected $name = "Air";
protected $hardness = 0;
public function __construct(){ public function __construct(){
} }
public function getName(){
return "Air";
}
public function isBreakable(Item $item){
return false;
}
public function canBeFlowedInto(){
return true;
}
public function canBeReplaced(){
return true;
}
public function canBePlaced(){
return false;
}
public function isSolid(){
return false;
}
public function getBoundingBox(){ public function getBoundingBox(){
return null; return null;
} }

View File

@ -28,19 +28,27 @@ use pocketmine\network\protocol\ChatPacket;
use pocketmine\Player; use pocketmine\Player;
class Bed extends Transparent{ class Bed extends Transparent{
public function __construct($type = 0){
parent::__construct(self::BED_BLOCK, $type, "Bed Block"); protected $id = self::BED_BLOCK;
$this->isActivable = true;
$this->isFullBlock = false; public function __construct($meta = 0){
$this->hardness = 1; $this->meta = $meta;
} }
public function getBoundingBox(){ public function canBeActivated(){
if($this->boundingBox !== null){ return true;
return $this->boundingBox; }
}
return $this->boundingBox = new AxisAlignedBB( public function getHardness(){
return 1;
}
public function getName(){
return "Bed Block";
}
protected function recalculateBoundingBox(){
return new AxisAlignedBB(
$this->x, $this->x,
$this->y, $this->y,
$this->z, $this->z,
@ -57,7 +65,7 @@ class Bed extends Transparent{
$isNight = ($time >= Level::TIME_NIGHT and $time < Level::TIME_SUNRISE); $isNight = ($time >= Level::TIME_NIGHT and $time < Level::TIME_SUNRISE);
if($player instanceof Player and !$isNight){ if($player instanceof Player and !$isNight){
$pk = new ChatPacket; $pk = new ChatPacket();
$pk->message = "You can only sleep at night"; $pk->message = "You can only sleep at night";
$player->dataPacket($pk); $player->dataPacket($pk);
@ -71,17 +79,17 @@ class Bed extends Transparent{
if(($this->meta & 0x08) === 0x08){ //This is the Top part of bed if(($this->meta & 0x08) === 0x08){ //This is the Top part of bed
$b = $this; $b = $this;
}else{ //Bottom Part of Bed }else{ //Bottom Part of Bed
if($blockNorth->getID() === $this->id and ($blockNorth->meta & 0x08) === 0x08){ if($blockNorth->getId() === $this->id and ($blockNorth->meta & 0x08) === 0x08){
$b = $blockNorth; $b = $blockNorth;
}elseif($blockSouth->getID() === $this->id and ($blockSouth->meta & 0x08) === 0x08){ }elseif($blockSouth->getId() === $this->id and ($blockSouth->meta & 0x08) === 0x08){
$b = $blockSouth; $b = $blockSouth;
}elseif($blockEast->getID() === $this->id and ($blockEast->meta & 0x08) === 0x08){ }elseif($blockEast->getId() === $this->id and ($blockEast->meta & 0x08) === 0x08){
$b = $blockEast; $b = $blockEast;
}elseif($blockWest->getID() === $this->id and ($blockWest->meta & 0x08) === 0x08){ }elseif($blockWest->getId() === $this->id and ($blockWest->meta & 0x08) === 0x08){
$b = $blockWest; $b = $blockWest;
}else{ }else{
if($player instanceof Player){ if($player instanceof Player){
$pk = new ChatPacket; $pk = new ChatPacket();
$pk->message = "This bed is incomplete"; $pk->message = "This bed is incomplete";
$player->dataPacket($pk); $player->dataPacket($pk);
} }
@ -91,7 +99,7 @@ class Bed extends Transparent{
} }
if($player instanceof Player and $player->sleepOn($b) === false){ if($player instanceof Player and $player->sleepOn($b) === false){
$pk = new ChatPacket; $pk = new ChatPacket();
$pk->message = "This bed is occupied"; $pk->message = "This bed is occupied";
$player->dataPacket($pk); $player->dataPacket($pk);
} }
@ -101,7 +109,7 @@ class Bed extends Transparent{
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){ public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){
$down = $this->getSide(0); $down = $this->getSide(0);
if($down->isTransparent === false){ if($down->isTransparent() === false){
$faces = [ $faces = [
0 => 3, 0 => 3,
1 => 4, 1 => 4,
@ -111,7 +119,7 @@ class Bed extends Transparent{
$d = $player instanceof Player ? $player->getDirection() : 0; $d = $player instanceof Player ? $player->getDirection() : 0;
$next = $this->getSide($faces[(($d + 3) % 4)]); $next = $this->getSide($faces[(($d + 3) % 4)]);
$downNext = $this->getSide(0); $downNext = $this->getSide(0);
if($next->isReplaceable === true and $downNext->isTransparent === false){ if($next->canBeReplaced() === true and $downNext->isTransparent() === false){
$meta = (($d + 3) % 4) & 0x03; $meta = (($d + 3) % 4) & 0x03;
$this->getLevel()->setBlock($block, Block::get($this->id, $meta), true, true); $this->getLevel()->setBlock($block, Block::get($this->id, $meta), true, true);
$this->getLevel()->setBlock($next, Block::get($this->id, $meta | 0x08), true, true); $this->getLevel()->setBlock($next, Block::get($this->id, $meta | 0x08), true, true);
@ -130,23 +138,23 @@ class Bed extends Transparent{
$blockWest = $this->getSide(4); $blockWest = $this->getSide(4);
if(($this->meta & 0x08) === 0x08){ //This is the Top part of bed 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 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); $this->getLevel()->setBlock($blockNorth, new Air(), true, true);
}elseif($blockSouth->getID() === $this->id and $blockSouth->meta !== 0x08){ }elseif($blockSouth->getId() === $this->id and $blockSouth->meta !== 0x08){
$this->getLevel()->setBlock($blockSouth, new Air(), true, true); $this->getLevel()->setBlock($blockSouth, new Air(), true, true);
}elseif($blockEast->getID() === $this->id and $blockEast->meta !== 0x08){ }elseif($blockEast->getId() === $this->id and $blockEast->meta !== 0x08){
$this->getLevel()->setBlock($blockEast, new Air(), true, true); $this->getLevel()->setBlock($blockEast, new Air(), true, true);
}elseif($blockWest->getID() === $this->id and $blockWest->meta !== 0x08){ }elseif($blockWest->getId() === $this->id and $blockWest->meta !== 0x08){
$this->getLevel()->setBlock($blockWest, new Air(), true, true); $this->getLevel()->setBlock($blockWest, new Air(), true, true);
} }
}else{ //Bottom Part of Bed }else{ //Bottom Part of Bed
if($blockNorth->getID() === $this->id and ($blockNorth->meta & 0x08) === 0x08){ if($blockNorth->getId() === $this->id and ($blockNorth->meta & 0x08) === 0x08){
$this->getLevel()->setBlock($blockNorth, new Air(), true, true); $this->getLevel()->setBlock($blockNorth, new Air(), true, true);
}elseif($blockSouth->getID() === $this->id and ($blockSouth->meta & 0x08) === 0x08){ }elseif($blockSouth->getId() === $this->id and ($blockSouth->meta & 0x08) === 0x08){
$this->getLevel()->setBlock($blockSouth, new Air(), true, true); $this->getLevel()->setBlock($blockSouth, new Air(), true, true);
}elseif($blockEast->getID() === $this->id and ($blockEast->meta & 0x08) === 0x08){ }elseif($blockEast->getId() === $this->id and ($blockEast->meta & 0x08) === 0x08){
$this->getLevel()->setBlock($blockEast, new Air(), true, true); $this->getLevel()->setBlock($blockEast, new Air(), true, true);
}elseif($blockWest->getID() === $this->id and ($blockWest->meta & 0x08) === 0x08){ }elseif($blockWest->getId() === $this->id and ($blockWest->meta & 0x08) === 0x08){
$this->getLevel()->setBlock($blockWest, new Air(), true, true); $this->getLevel()->setBlock($blockWest, new Air(), true, true);
} }
} }

View File

@ -24,10 +24,19 @@ namespace pocketmine\block;
use pocketmine\item\Item; use pocketmine\item\Item;
class Bedrock extends Solid{ class Bedrock extends Solid{
protected $id = self::BEDROCK;
public function __construct(){ public function __construct(){
parent::__construct(self::BEDROCK, 0, "Bedrock");
$this->breakable = false; }
$this->hardness = 18000000;
public function getName(){
return "Bedrock";
}
public function getHardness(){
return 18000000;
} }
public function isBreakable(Item $item){ public function isBreakable(Item $item){

View File

@ -24,8 +24,15 @@ namespace pocketmine\block;
use pocketmine\item\Item; use pocketmine\item\Item;
class Beetroot extends Crops{ class Beetroot extends Crops{
protected $id = self::BEETROOT_BLOCK;
public function __construct($meta = 0){ public function __construct($meta = 0){
parent::__construct(self::BEETROOT_BLOCK, $meta, "Beetroot Block"); $this->meta = $meta;
}
public function getName(){
return "Beetroot Block";
} }
public function getDrops(Item $item){ public function getDrops(Item $item){

View File

@ -24,8 +24,15 @@ namespace pocketmine\block;
use pocketmine\item\Item; use pocketmine\item\Item;
class BirchWoodStairs extends Stair{ class BirchWoodStairs extends Stair{
protected $id = self::BIRCH_WOOD_STAIRS;
public function __construct($meta = 0){ public function __construct($meta = 0){
parent::__construct(self::BIRCH_WOOD_STAIRS, $meta, "Birch Wood Stairs"); $this->meta = $meta;
}
public function getName(){
return "Birch Wood Stairs";
} }
public function getDrops(Item $item){ public function getDrops(Item $item){

View File

@ -179,7 +179,7 @@ class Block extends Position implements Metadatable{
const NETHER_BRICKS_STAIRS = 114; const NETHER_BRICKS_STAIRS = 114;
const END_PORTAL = 120; const END_PORTAL_FRAME = 120;
const END_STONE = 121; const END_STONE = 121;
const SANDSTONE_STAIRS = 128; const SANDSTONE_STAIRS = 128;
@ -228,6 +228,14 @@ class Block extends Position implements Metadatable{
const HARDENED_CLAY = 172; const HARDENED_CLAY = 172;
const COAL_BLOCK = 173; const COAL_BLOCK = 173;
const DOUBLE_PLANT = 175;
const FENCE_GATE_SPRUCE = 183;
const FENCE_GATE_BIRCH = 184;
const FENCE_GATE_JUNGLE = 185;
const FENCE_GATE_DARK_OAK = 186;
const FENCE_GATE_ACACIA = 187;
const PODZOL = 243; const PODZOL = 243;
const BEETROOT_BLOCK = 244; const BEETROOT_BLOCK = 244;
const STONECUTTER = 245; const STONECUTTER = 245;
@ -354,7 +362,17 @@ class Block extends Position implements Metadatable{
[Item::WOODEN_DOOR, 0], [Item::WOODEN_DOOR, 0],
[Item::TRAPDOOR, 0], [Item::TRAPDOOR, 0],
[Item::FENCE, 0], [Item::FENCE, 0],
[Item::FENCE, 1],
[Item::FENCE, 2],
[Item::FENCE, 3],
[Item::FENCE, 4],
[Item::FENCE, 5],
[Item::FENCE_GATE, 0], [Item::FENCE_GATE, 0],
[Item::FENCE_GATE_BIRCH, 0],
[Item::FENCE_GATE_SPRUCE, 0],
[Item::FENCE_GATE_DARK_OAK, 0],
[Item::FENCE_GATE_JUNGLE, 0],
[Item::FENCE_GATE_ACACIA, 0],
[Item::IRON_BARS, 0], [Item::IRON_BARS, 0],
[Item::BED, 0], [Item::BED, 0],
[Item::BOOKSHELF, 0], [Item::BOOKSHELF, 0],
@ -505,170 +523,242 @@ class Block extends Position implements Metadatable{
]; ];
/** @var Block[] */ /** @var \SplFixedArray */
public static $list = []; public static $list = null;
/** @var \SplFixedArray */
public static $fullList = null;
/** @var \SplFixedArray */
public static $light = null;
/** @var \SplFixedArray */
public static $lightFilter = null;
/** @var \SplFixedArray */
public static $solid = null;
/** @var \SplFixedArray */
public static $hardness = null;
/** @var \SplFixedArray */
public static $transparent = null;
protected $id; protected $id;
protected $meta; protected $meta = 0;
protected $name = "Unknown";
protected $breakTime = 0.20; /** @var AxisAlignedBB */
protected $hardness = 10;
protected $boundingBox = null; protected $boundingBox = null;
public $hasEntityCollision = false;
public $isActivable = false; /**
public $breakable = true; * Backwards-compatibility with old way to define block properties
public $isFlowable = false; *
public $isSolid = true; * @deprecated
public $isTransparent = false; *
public $isReplaceable = false; * @param string $key
public $isPlaceable = true; *
public $hasPhysics = false; * @return mixed
public $isLiquid = false; */
public $isFullBlock = true; public function __get($key){
public $x = 0; static $map = [
public $y = 0; "hardness" => "getHardness",
public $z = 0; "lightLevel" => "getLightLevel",
public $frictionFactor = 0.6; "frictionFactor" => "getFrictionFactor",
"name" => "getName",
"isPlaceable" => "canBePlaced",
"isReplaceable" => "canBeReplaced",
"isTransparent" => "isTransparent",
"isSolid" => "isSolid",
"isFlowable" => "canBeFlowedInto",
"isActivable" => "canBeActivated",
"hasEntityCollision" => "hasEntityCollision"
];
return isset($map[$key]) ? $this->{$map[$key]}() : null;
}
public static function init(){ public static function init(){
if(count(self::$list) === 0){ if(self::$list === null){
self::$list = [ self::$list = new \SplFixedArray(256);
self::AIR => Air::class, self::$fullList = new \SplFixedArray(4096);
self::STONE => Stone::class, self::$light = new \SplFixedArray(256);
self::GRASS => Grass::class, self::$lightFilter = new \SplFixedArray(256);
self::DIRT => Dirt::class, self::$solid = new \SplFixedArray(256);
self::COBBLESTONE => Cobblestone::class, self::$hardness = new \SplFixedArray(256);
self::PLANKS => Planks::class, self::$transparent = new \SplFixedArray(256);
self::SAPLING => Sapling::class, self::$list[self::AIR] = Air::class;
self::BEDROCK => Bedrock::class, self::$list[self::STONE] = Stone::class;
self::WATER => Water::class, self::$list[self::GRASS] = Grass::class;
self::STILL_WATER => StillWater::class, self::$list[self::DIRT] = Dirt::class;
self::LAVA => Lava::class, self::$list[self::COBBLESTONE] = Cobblestone::class;
self::STILL_LAVA => StillLava::class, self::$list[self::PLANKS] = Planks::class;
self::SAND => Sand::class, self::$list[self::SAPLING] = Sapling::class;
self::GRAVEL => Gravel::class, self::$list[self::BEDROCK] = Bedrock::class;
self::GOLD_ORE => GoldOre::class, self::$list[self::WATER] = Water::class;
self::IRON_ORE => IronOre::class, self::$list[self::STILL_WATER] = StillWater::class;
self::COAL_ORE => CoalOre::class, self::$list[self::LAVA] = Lava::class;
self::WOOD => Wood::class, self::$list[self::STILL_LAVA] = StillLava::class;
self::LEAVES => Leaves::class, self::$list[self::SAND] = Sand::class;
self::SPONGE => Sponge::class, self::$list[self::GRAVEL] = Gravel::class;
self::GLASS => Glass::class, self::$list[self::GOLD_ORE] = GoldOre::class;
self::LAPIS_ORE => LapisOre::class, self::$list[self::IRON_ORE] = IronOre::class;
self::LAPIS_BLOCK => Lapis::class, self::$list[self::COAL_ORE] = CoalOre::class;
self::SANDSTONE => Sandstone::class, self::$list[self::WOOD] = Wood::class;
self::BED_BLOCK => Bed::class, self::$list[self::LEAVES] = Leaves::class;
self::COBWEB => Cobweb::class, self::$list[self::SPONGE] = Sponge::class;
self::TALL_GRASS => TallGrass::class, self::$list[self::GLASS] = Glass::class;
self::DEAD_BUSH => DeadBush::class, self::$list[self::LAPIS_ORE] = LapisOre::class;
self::WOOL => Wool::class, self::$list[self::LAPIS_BLOCK] = Lapis::class;
self::DANDELION => Dandelion::class, self::$list[self::SANDSTONE] = Sandstone::class;
self::POPPY => CyanFlower::class, self::$list[self::BED_BLOCK] = Bed::class;
self::BROWN_MUSHROOM => BrownMushroom::class, self::$list[self::COBWEB] = Cobweb::class;
self::RED_MUSHROOM => RedMushroom::class, self::$list[self::TALL_GRASS] = TallGrass::class;
self::GOLD_BLOCK => Gold::class, self::$list[self::DEAD_BUSH] = DeadBush::class;
self::IRON_BLOCK => Iron::class, self::$list[self::WOOL] = Wool::class;
self::DOUBLE_SLAB => DoubleSlab::class, self::$list[self::DANDELION] = Dandelion::class;
self::SLAB => Slab::class, self::$list[self::POPPY] = Poppy::class;
self::BRICKS_BLOCK => Bricks::class, self::$list[self::BROWN_MUSHROOM] = BrownMushroom::class;
self::TNT => TNT::class, self::$list[self::RED_MUSHROOM] = RedMushroom::class;
self::BOOKSHELF => Bookshelf::class, self::$list[self::GOLD_BLOCK] = Gold::class;
self::MOSS_STONE => MossStone::class, self::$list[self::IRON_BLOCK] = Iron::class;
self::OBSIDIAN => Obsidian::class, self::$list[self::DOUBLE_SLAB] = DoubleSlab::class;
self::TORCH => Torch::class, self::$list[self::SLAB] = Slab::class;
self::FIRE => Fire::class, self::$list[self::BRICKS_BLOCK] = Bricks::class;
self::MONSTER_SPAWNER => MonsterSpawner::class, self::$list[self::TNT] = TNT::class;
self::WOOD_STAIRS => WoodStairs::class, self::$list[self::BOOKSHELF] = Bookshelf::class;
self::CHEST => Chest::class, self::$list[self::MOSS_STONE] = MossStone::class;
self::$list[self::OBSIDIAN] = Obsidian::class;
self::$list[self::TORCH] = Torch::class;
self::$list[self::FIRE] = Fire::class;
self::$list[self::MONSTER_SPAWNER] = MonsterSpawner::class;
self::$list[self::WOOD_STAIRS] = WoodStairs::class;
self::$list[self::CHEST] = Chest::class;
self::DIAMOND_ORE => DiamondOre::class, self::$list[self::DIAMOND_ORE] = DiamondOre::class;
self::DIAMOND_BLOCK => Diamond::class, self::$list[self::DIAMOND_BLOCK] = Diamond::class;
self::WORKBENCH => Workbench::class, self::$list[self::WORKBENCH] = Workbench::class;
self::WHEAT_BLOCK => Wheat::class, self::$list[self::WHEAT_BLOCK] = Wheat::class;
self::FARMLAND => Farmland::class, self::$list[self::FARMLAND] = Farmland::class;
self::FURNACE => Furnace::class, self::$list[self::FURNACE] = Furnace::class;
self::BURNING_FURNACE => BurningFurnace::class, self::$list[self::BURNING_FURNACE] = BurningFurnace::class;
self::SIGN_POST => SignPost::class, self::$list[self::SIGN_POST] = SignPost::class;
self::WOOD_DOOR_BLOCK => WoodDoor::class, self::$list[self::WOOD_DOOR_BLOCK] = WoodDoor::class;
self::LADDER => Ladder::class, self::$list[self::LADDER] = Ladder::class;
self::COBBLESTONE_STAIRS => CobblestoneStairs::class, self::$list[self::COBBLESTONE_STAIRS] = CobblestoneStairs::class;
self::WALL_SIGN => WallSign::class, self::$list[self::WALL_SIGN] = WallSign::class;
self::IRON_DOOR_BLOCK => IronDoor::class, self::$list[self::IRON_DOOR_BLOCK] = IronDoor::class;
self::REDSTONE_ORE => RedstoneOre::class, self::$list[self::REDSTONE_ORE] = RedstoneOre::class;
self::GLOWING_REDSTONE_ORE => GlowingRedstoneOre::class, self::$list[self::GLOWING_REDSTONE_ORE] = GlowingRedstoneOre::class;
self::SNOW_LAYER => SnowLayer::class, self::$list[self::SNOW_LAYER] = SnowLayer::class;
self::ICE => Ice::class, self::$list[self::ICE] = Ice::class;
self::SNOW_BLOCK => Snow::class, self::$list[self::SNOW_BLOCK] = Snow::class;
self::CACTUS => Cactus::class, self::$list[self::CACTUS] = Cactus::class;
self::CLAY_BLOCK => Clay::class, self::$list[self::CLAY_BLOCK] = Clay::class;
self::SUGARCANE_BLOCK => Sugarcane::class, self::$list[self::SUGARCANE_BLOCK] = Sugarcane::class;
self::FENCE => Fence::class, self::$list[self::FENCE] = Fence::class;
self::PUMPKIN => Pumpkin::class, self::$list[self::PUMPKIN] = Pumpkin::class;
self::NETHERRACK => Netherrack::class, self::$list[self::NETHERRACK] = Netherrack::class;
self::SOUL_SAND => SoulSand::class, self::$list[self::SOUL_SAND] = SoulSand::class;
self::GLOWSTONE_BLOCK => Glowstone::class, self::$list[self::GLOWSTONE_BLOCK] = Glowstone::class;
self::LIT_PUMPKIN => LitPumpkin::class, self::$list[self::LIT_PUMPKIN] = LitPumpkin::class;
self::CAKE_BLOCK => Cake::class, self::$list[self::CAKE_BLOCK] = Cake::class;
self::TRAPDOOR => Trapdoor::class, self::$list[self::TRAPDOOR] = Trapdoor::class;
self::STONE_BRICKS => StoneBricks::class, self::$list[self::STONE_BRICKS] = StoneBricks::class;
self::IRON_BARS => IronBars::class, self::$list[self::IRON_BARS] = IronBars::class;
self::GLASS_PANE => GlassPane::class, self::$list[self::GLASS_PANE] = GlassPane::class;
self::MELON_BLOCK => Melon::class, self::$list[self::MELON_BLOCK] = Melon::class;
self::PUMPKIN_STEM => PumpkinStem::class, self::$list[self::PUMPKIN_STEM] = PumpkinStem::class;
self::MELON_STEM => MelonStem::class, self::$list[self::MELON_STEM] = MelonStem::class;
self::VINE => Vine::class, self::$list[self::VINE] = Vine::class;
self::FENCE_GATE => FenceGate::class, self::$list[self::FENCE_GATE] = FenceGate::class;
self::BRICK_STAIRS => BrickStairs::class, self::$list[self::BRICK_STAIRS] = BrickStairs::class;
self::STONE_BRICK_STAIRS => StoneBrickStairs::class, self::$list[self::STONE_BRICK_STAIRS] = StoneBrickStairs::class;
self::MYCELIUM => Mycelium::class, self::$list[self::MYCELIUM] = Mycelium::class;
self::NETHER_BRICKS => NetherBrick::class, self::$list[self::NETHER_BRICKS] = NetherBrick::class;
self::NETHER_BRICKS_STAIRS => NetherBrickStairs::class, self::$list[self::NETHER_BRICKS_STAIRS] = NetherBrickStairs::class;
self::END_PORTAL => EndPortal::class, self::$list[self::END_PORTAL_FRAME] = EndPortalFrame::class;
self::END_STONE => EndStone::class, self::$list[self::END_STONE] = EndStone::class;
self::SANDSTONE_STAIRS => SandstoneStairs::class, self::$list[self::SANDSTONE_STAIRS] = SandstoneStairs::class;
self::EMERALD_ORE => EmeraldOre::class, self::$list[self::EMERALD_ORE] = EmeraldOre::class;
self::EMERALD_BLOCK => Emerald::class, self::$list[self::EMERALD_BLOCK] = Emerald::class;
self::SPRUCE_WOOD_STAIRS => SpruceWoodStairs::class, self::$list[self::SPRUCE_WOOD_STAIRS] = SpruceWoodStairs::class;
self::BIRCH_WOOD_STAIRS => BirchWoodStairs::class, self::$list[self::BIRCH_WOOD_STAIRS] = BirchWoodStairs::class;
self::JUNGLE_WOOD_STAIRS => JungleWoodStairs::class, self::$list[self::JUNGLE_WOOD_STAIRS] = JungleWoodStairs::class;
self::STONE_WALL => StoneWall::class, self::$list[self::STONE_WALL] = StoneWall::class;
self::CARROT_BLOCK => Carrot::class, self::$list[self::CARROT_BLOCK] = Carrot::class;
self::POTATO_BLOCK => Potato::class, self::$list[self::POTATO_BLOCK] = Potato::class;
self::QUARTZ_BLOCK => Quartz::class, self::$list[self::QUARTZ_BLOCK] = Quartz::class;
self::QUARTZ_STAIRS => QuartzStairs::class, self::$list[self::QUARTZ_STAIRS] = QuartzStairs::class;
self::DOUBLE_WOOD_SLAB => DoubleWoodSlab::class, self::$list[self::DOUBLE_WOOD_SLAB] = DoubleWoodSlab::class;
self::WOOD_SLAB => WoodSlab::class, self::$list[self::WOOD_SLAB] = WoodSlab::class;
self::STAINED_CLAY => StainedClay::class, self::$list[self::STAINED_CLAY] = StainedClay::class;
self::LEAVES2 => Leaves2::class, self::$list[self::LEAVES2] = Leaves2::class;
self::WOOD2 => Wood2::class, self::$list[self::WOOD2] = Wood2::class;
self::ACACIA_WOOD_STAIRS => AcaciaWoodStairs::class, self::$list[self::ACACIA_WOOD_STAIRS] = AcaciaWoodStairs::class;
self::DARK_OAK_WOOD_STAIRS => DarkOakWoodStairs::class, self::$list[self::DARK_OAK_WOOD_STAIRS] = DarkOakWoodStairs::class;
self::HAY_BALE => HayBale::class, self::$list[self::HAY_BALE] = HayBale::class;
self::CARPET => Carpet::class, self::$list[self::CARPET] = Carpet::class;
self::HARDENED_CLAY => HardenedClay::class, self::$list[self::HARDENED_CLAY] = HardenedClay::class;
self::COAL_BLOCK => Coal::class, self::$list[self::COAL_BLOCK] = Coal::class;
self::PODZOL => Podzol::class, self::$list[self::DOUBLE_PLANT] = DoublePlant::class;
self::BEETROOT_BLOCK => Beetroot::class,
self::STONECUTTER => Stonecutter::class, self::$list[self::FENCE_GATE_SPRUCE] = FenceGateSpruce::class;
self::GLOWING_OBSIDIAN => GlowingObsidian::class, self::$list[self::FENCE_GATE_BIRCH] = FenceGateBirch::class;
self::NETHER_REACTOR => NetherReactor::class, self::$list[self::FENCE_GATE_JUNGLE] = FenceGateJungle::class;
]; self::$list[self::FENCE_GATE_DARK_OAK] = FenceGateDarkOak::class;
self::$list[self::FENCE_GATE_ACACIA] = FenceGateAcacia::class;
self::$list[self::PODZOL] = Podzol::class;
self::$list[self::BEETROOT_BLOCK] = Beetroot::class;
self::$list[self::STONECUTTER] = Stonecutter::class;
self::$list[self::GLOWING_OBSIDIAN] = GlowingObsidian::class;
self::$list[self::NETHER_REACTOR] = NetherReactor::class;
foreach(self::$list as $id => $class){
if($class !== null){
/** @var Block $block */
$block = new $class();
for($data = 0; $data < 16; ++$data){
self::$fullList[($id << 4) | $data] = new $class($data);
}
self::$solid[$id] = $block->isSolid();
self::$transparent[$id] = $block->isTransparent();
self::$hardness[$id] = $block->getHardness();
self::$light[$id] = $block->getLightLevel();
if($block->isSolid()){
if($block->isTransparent()){
if($block instanceof Liquid or $block instanceof Ice){
self::$lightFilter[$id] = 2;
}else{
self::$lightFilter[$id] = 1;
}
}else{
self::$lightFilter[$id] = 15;
}
}else{
self::$lightFilter[$id] = 1;
}
}else{
self::$lightFilter[$id] = 1;
for($data = 0; $data < 16; ++$data){
self::$fullList[($id << 4) | $data] = new Block($id, $data);
}
}
}
} }
} }
@ -680,14 +770,18 @@ class Block extends Position implements Metadatable{
* @return Block * @return Block
*/ */
public static function get($id, $meta = 0, Position $pos = null){ public static function get($id, $meta = 0, Position $pos = null){
if(isset(self::$list[$id])){ try{
$block = self::$list[$id]; $block = self::$list[$id];
$block = new $block($meta); if($block !== null){
}else{ $block = new $block($meta);
}else{
$block = new Block($id, $meta);
}
}catch(\RuntimeException $e){
$block = new Block($id, $meta); $block = new Block($id, $meta);
} }
if($pos instanceof Position){ if($pos !== null){
$block->x = $pos->x; $block->x = $pos->x;
$block->y = $pos->y; $block->y = $pos->y;
$block->z = $pos->z; $block->z = $pos->z;
@ -698,14 +792,12 @@ class Block extends Position implements Metadatable{
} }
/** /**
* @param int $id * @param int $id
* @param int $meta * @param int $meta
* @param string $name
*/ */
public function __construct($id, $meta = 0, $name = "Unknown"){ public function __construct($id, $meta = 0){
$this->id = (int) $id; $this->id = (int) $id;
$this->meta = (int) $meta; $this->meta = (int) $meta;
$this->name = $name;
} }
/** /**
@ -734,7 +826,7 @@ class Block extends Position implements Metadatable{
* @return bool * @return bool
*/ */
public function isBreakable(Item $item){ public function isBreakable(Item $item){
return $this->breakable; return true;
} }
/** /**
@ -768,27 +860,92 @@ class Block extends Position implements Metadatable{
* @return bool * @return bool
*/ */
public function onActivate(Item $item, Player $player = null){ public function onActivate(Item $item, Player $player = null){
return $this->isActivable; return false;
} }
/** /**
* @return int * @return int
*/ */
final public function getHardness(){ public function getHardness(){
return $this->hardness; return 10;
}
/**
* @return float
*/
public function getFrictionFactor(){
return 0.6;
}
/**
* @return int 0-15
*/
public function getLightLevel(){
return 0;
}
/**
* AKA: Block->isPlaceable
*
* @return bool
*/
public function canBePlaced(){
return true;
}
/**
* AKA: Block->canBeReplaced()
*
* @return bool
*/
public function canBeReplaced(){
return false;
}
/**
* @return bool
*/
public function isTransparent(){
return false;
}
public function isSolid(){
return true;
}
/**
* AKA: Block->isFlowable
*
* @return bool
*/
public function canBeFlowedInto(){
return false;
}
/**
* AKA: Block->isActivable
*
* @return bool
*/
public function canBeActivated(){
return false;
}
public function hasEntityCollision(){
return false;
} }
/** /**
* @return string * @return string
*/ */
final public function getName(){ public function getName(){
return $this->name; return "Unknown";
} }
/** /**
* @return int * @return int
*/ */
final public function getID(){ final public function getId(){
return $this->id; return $this->id;
} }
@ -807,7 +964,7 @@ class Block extends Position implements Metadatable{
* @param int $meta * @param int $meta
*/ */
final public function setDamage($meta){ final public function setDamage($meta){
$this->meta = $meta & 0x0F; $this->meta = $meta & 0x0f;
} }
/** /**
@ -848,7 +1005,7 @@ class Block extends Position implements Metadatable{
* @return float * @return float
*/ */
public function getBreakTime(Item $item){ public function getBreakTime(Item $item){
return $this->breakTime; return 0.20;
} }
/** /**
@ -860,19 +1017,18 @@ class Block extends Position implements Metadatable{
* @return Block * @return Block
*/ */
public function getSide($side, $step = 1){ public function getSide($side, $step = 1){
$v = parent::getSide($side, $step);
if($this->isValid()){ if($this->isValid()){
return $this->getLevel()->getBlock($v); return $this->getLevel()->getBlock(Vector3::getSide($side, $step));
} }
return Block::get(Item::AIR, 0, $v); return Block::get(Item::AIR, 0, Position::fromObject(Vector3::getSide($side, $step)));
} }
/** /**
* @return string * @return string
*/ */
final public function __toString(){ public function __toString(){
return "Block " . $this->name . " (" . $this->id . ":" . $this->meta . ")"; return "Block[" . $this->getName() . "] (" . $this->id . ":" . $this->meta . ")";
} }
/** /**
@ -883,7 +1039,7 @@ class Block extends Position implements Metadatable{
*/ */
public function collidesWithBB(AxisAlignedBB $bb, &$list = []){ public function collidesWithBB(AxisAlignedBB $bb, &$list = []){
$bb2 = $this->getBoundingBox(); $bb2 = $this->getBoundingBox();
if($bb2 !== null and $bb2->intersectsWith($bb)){ if($bb2 !== null and $bb->intersectsWith($bb2)){
$list[] = $bb2; $list[] = $bb2;
} }
} }
@ -899,11 +1055,17 @@ class Block extends Position implements Metadatable{
* @return AxisAlignedBB * @return AxisAlignedBB
*/ */
public function getBoundingBox(){ public function getBoundingBox(){
if($this->boundingBox !== null){ if($this->boundingBox === null){
return $this->boundingBox; $this->boundingBox = $this->recalculateBoundingBox();
} }
return $this->boundingBox;
}
return $this->boundingBox = new AxisAlignedBB( /**
* @return AxisAlignedBB
*/
protected function recalculateBoundingBox(){
return new AxisAlignedBB(
$this->x, $this->x,
$this->y, $this->y,
$this->z, $this->z,

View File

@ -23,9 +23,19 @@ namespace pocketmine\block;
class Bookshelf extends Solid{ class Bookshelf extends Solid{
protected $id = self::BOOKSHELF;
public function __construct(){ public function __construct(){
parent::__construct(self::BOOKSHELF, 0, "Bookshelf");
$this->hardness = 7.5; }
public function getName(){
return "Bookshelf";
}
public function getHardness(){
return 7.5;
} }
} }

View File

@ -23,8 +23,15 @@ namespace pocketmine\block;
class BrickStairs extends Stair{ class BrickStairs extends Stair{
protected $id = self::BRICK_STAIRS;
public function __construct($meta = 0){ public function __construct($meta = 0){
parent::__construct(self::BRICK_STAIRS, $meta, "Brick Stairs"); $this->meta = $meta;
}
public function getName(){
return "Brick Stairs";
} }
} }

View File

@ -24,9 +24,19 @@ namespace pocketmine\block;
use pocketmine\item\Item; use pocketmine\item\Item;
class Bricks extends Solid{ class Bricks extends Solid{
protected $id = self::BRICKS_BLOCK;
public function __construct(){ public function __construct(){
parent::__construct(self::BRICKS_BLOCK, 0, "Bricks");
$this->hardness = 30; }
public function getHardness(){
return 30;
}
public function getName(){
return "Bricks";
} }
public function getBreakTime(Item $item){ public function getBreakTime(Item $item){

View File

@ -26,14 +26,24 @@ use pocketmine\level\Level;
use pocketmine\Player; use pocketmine\Player;
class BrownMushroom extends Flowable{ class BrownMushroom extends Flowable{
public function __construct(){
parent::__construct(self::BROWN_MUSHROOM, 0, "Brown Mushroom"); protected $id = self::BROWN_MUSHROOM;
$this->hardness = 0;
public function __construct($meta = 0){
$this->meta = $meta;
}
public function getName(){
return "Brown Mushroom";
}
public function getLightLevel(){
return 1;
} }
public function onUpdate($type){ public function onUpdate($type){
if($type === Level::BLOCK_UPDATE_NORMAL){ if($type === Level::BLOCK_UPDATE_NORMAL){
if($this->getSide(0)->isTransparent === true){ if($this->getSide(0)->isTransparent() === true){
$this->getLevel()->useBreakOn($this); $this->getLevel()->useBreakOn($this);
return Level::BLOCK_UPDATE_NORMAL; return Level::BLOCK_UPDATE_NORMAL;
@ -45,7 +55,7 @@ class BrownMushroom extends Flowable{
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){ public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){
$down = $this->getSide(0); $down = $this->getSide(0);
if($down->isTransparent === false){ if($down->isTransparent() === false){
$this->getLevel()->setBlock($block, $this, true, true); $this->getLevel()->setBlock($block, $this, true, true);
return true; return true;

View File

@ -32,10 +32,27 @@ use pocketmine\tile\Furnace;
use pocketmine\tile\Tile; use pocketmine\tile\Tile;
class BurningFurnace extends Solid{ class BurningFurnace extends Solid{
protected $id = self::BURNING_FURNACE;
public function __construct($meta = 0){ public function __construct($meta = 0){
parent::__construct(self::BURNING_FURNACE, $meta, "Burning Furnace"); $this->meta = $meta;
$this->isActivable = true; }
$this->hardness = 17.5;
public function getName(){
return "Burning Furnace";
}
public function canBeActivated(){
return true;
}
public function getHardness(){
return 17.5;
}
public function getLightLevel(){
return 13;
} }
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){ public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){
@ -55,7 +72,7 @@ class BurningFurnace extends Solid{
new Int("z", $this->z) new Int("z", $this->z)
]); ]);
$nbt->Items->setTagType(NBT::TAG_Compound); $nbt->Items->setTagType(NBT::TAG_Compound);
new Furnace($this->getLevel()->getChunk($this->x >> 4, $this->z >> 4), $nbt); Tile::createTile("Furnace", $this->getLevel()->getChunk($this->x >> 4, $this->z >> 4), $nbt);
return true; return true;
} }
@ -81,7 +98,7 @@ class BurningFurnace extends Solid{
new Int("z", $this->z) new Int("z", $this->z)
]); ]);
$nbt->Items->setTagType(NBT::TAG_Compound); $nbt->Items->setTagType(NBT::TAG_Compound);
$furnace = new Furnace($this->getLevel()->getChunk($this->x >> 4, $this->z >> 4), $nbt); $furnace = Tile::createTile("Furnace", $this->getLevel()->getChunk($this->x >> 4, $this->z >> 4), $nbt);
} }
if(($player->getGamemode() & 0x01) === 0x01){ if(($player->getGamemode() & 0x01) === 0x01){

View File

@ -2,11 +2,11 @@
/* /*
* *
* ____ _ _ __ __ _ __ __ ____ * ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \ * | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) | * | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/ * | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_| * |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU Lesser General Public License as published by
@ -15,7 +15,7 @@
* *
* @author PocketMine Team * @author PocketMine Team
* @link http://www.pocketmine.net/ * @link http://www.pocketmine.net/
* *
* *
*/ */
@ -25,29 +25,38 @@ use pocketmine\entity\Entity;
use pocketmine\event\block\BlockGrowEvent; use pocketmine\event\block\BlockGrowEvent;
use pocketmine\event\entity\EntityDamageByBlockEvent; use pocketmine\event\entity\EntityDamageByBlockEvent;
use pocketmine\event\entity\EntityDamageEvent; use pocketmine\event\entity\EntityDamageEvent;
use pocketmine\inventory\InventoryHolder;
use pocketmine\inventory\PlayerInventory;
use pocketmine\item\Item; use pocketmine\item\Item;
use pocketmine\level\Level; use pocketmine\level\Level;
use pocketmine\math\AxisAlignedBB; use pocketmine\math\AxisAlignedBB;
use pocketmine\math\Vector3 as Vector3; use pocketmine\math\Vector3;
use pocketmine\Player; use pocketmine\Player;
use pocketmine\Server; use pocketmine\Server;
class Cactus extends Transparent{ class Cactus extends Transparent{
public $hasEntityCollision = true; protected $id = self::CACTUS;
public function __construct($meta = 0){ public function __construct($meta = 0){
parent::__construct(self::CACTUS, $meta, "Cactus"); $this->meta = $meta;
$this->isFullBlock = false;
$this->hardness = 2;
} }
public function getBoundingBox(){ public function getHardness(){
if($this->boundingBox !== null){ return 2;
return $this->boundingBox; }
}
return $this->boundingBox = new AxisAlignedBB( public function hasEntityCollision(){
return true;
}
public function getName(){
return "Cactus";
}
protected function recalculateBoundingBox(){
return new AxisAlignedBB(
$this->x + 0.0625, $this->x + 0.0625,
$this->y, $this->y,
$this->z + 0.0625, $this->z + 0.0625,
@ -58,32 +67,36 @@ class Cactus extends Transparent{
} }
public function onEntityCollide(Entity $entity){ public function onEntityCollide(Entity $entity){
$ev = new EntityDamageByBlockEvent($this, $entity, EntityDamageEvent::CAUSE_CONTACT, 1); $damage = [EntityDamageEvent::MODIFIER_BASE => 1];
Server::getInstance()->getPluginManager()->callEvent($ev); if($entity instanceof InventoryHolder){
if(!$ev->isCancelled()){ $inventory = $entity->getInventory();
$entity->attack($ev->getFinalDamage(), $ev); 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 onUpdate($type){ public function onUpdate($type){
if($type === Level::BLOCK_UPDATE_NORMAL){ if($type === Level::BLOCK_UPDATE_NORMAL){
$down = $this->getSide(0); $down = $this->getSide(0);
if($down->getID() !== self::SAND and $down->getID() !== self::CACTUS){ if($down->getId() !== self::SAND and $down->getId() !== self::CACTUS){
$this->getLevel()->useBreakOn($this); $this->getLevel()->useBreakOn($this);
}else{ }else{
for($side = 2; $side <= 5; ++$side){ for($side = 2; $side <= 5; ++$side){
$b = $this->getSide($side); $b = $this->getSide($side);
if(!$b->isFlowable){ if(!$b->canBeFlowedInto()){
$this->getLevel()->useBreakOn($this); $this->getLevel()->useBreakOn($this);
} }
} }
} }
}elseif($type === Level::BLOCK_UPDATE_RANDOM){ }elseif($type === Level::BLOCK_UPDATE_RANDOM){
if($this->getSide(0)->getID() !== self::CACTUS){ if($this->getSide(0)->getId() !== self::CACTUS){
if($this->meta == 0x0F){ if($this->meta == 0x0F){
for($y = 1; $y < 3; ++$y){ for($y = 1; $y < 3; ++$y){
$b = $this->getLevel()->getBlock(new Vector3($this->x, $this->y + $y, $this->z)); $b = $this->getLevel()->getBlock(new Vector3($this->x, $this->y + $y, $this->z));
if($b->getID() === self::AIR){ if($b->getId() === self::AIR){
Server::getInstance()->getPluginManager()->callEvent($ev = new BlockGrowEvent($b, new Cactus())); Server::getInstance()->getPluginManager()->callEvent($ev = new BlockGrowEvent($b, new Cactus()));
if(!$ev->isCancelled()){ if(!$ev->isCancelled()){
$this->getLevel()->setBlock($b, $ev->getNewState(), true); $this->getLevel()->setBlock($b, $ev->getNewState(), true);
@ -104,12 +117,12 @@ class Cactus extends Transparent{
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){ public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){
$down = $this->getSide(0); $down = $this->getSide(0);
if($down->getID() === self::SAND or $down->getID() === self::CACTUS){ if($down->getId() === self::SAND or $down->getId() === self::CACTUS){
$block0 = $this->getSide(2); $block0 = $this->getSide(2);
$block1 = $this->getSide(3); $block1 = $this->getSide(3);
$block2 = $this->getSide(4); $block2 = $this->getSide(4);
$block3 = $this->getSide(5); $block3 = $this->getSide(5);
if($block0->isTransparent === true and $block1->isTransparent === true and $block2->isTransparent === true and $block3->isTransparent === true){ if($block0->isTransparent() === true and $block1->isTransparent() === true and $block2->isTransparent() === true and $block3->isTransparent() === true){
$this->getLevel()->setBlock($this, $this, true); $this->getLevel()->setBlock($this, $this, true);
return true; return true;
@ -124,4 +137,4 @@ class Cactus extends Transparent{
[$this->id, 0, 1], [$this->id, 0, 1],
]; ];
} }
} }

View File

@ -29,22 +29,30 @@ use pocketmine\Player;
use pocketmine\Server; use pocketmine\Server;
class Cake extends Transparent{ class Cake extends Transparent{
protected $id = self::CAKE_BLOCK;
public function __construct($meta = 0){ public function __construct($meta = 0){
parent::__construct(self::CAKE_BLOCK, 0, "Cake Block"); $this->meta = $meta;
$this->isFullBlock = false;
$this->isActivable = true;
$this->meta = $meta & 0x07;
$this->hardness = 2.5;
} }
public function getBoundingBox(){ public function canBeActivated(){
if($this->boundingBox !== null){ return true;
return $this->boundingBox; }
}
public function getHardness(){
return 2.5;
}
public function getName(){
return "Cake Block";
}
protected function recalculateBoundingBox(){
$f = (1 + $this->getDamage() * 2) / 16; $f = (1 + $this->getDamage() * 2) / 16;
return $this->boundingBox = new AxisAlignedBB( return new AxisAlignedBB(
$this->x + $f, $this->x + $f,
$this->y, $this->y,
$this->z + 0.0625, $this->z + 0.0625,
@ -56,7 +64,7 @@ class Cake extends Transparent{
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){ public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){
$down = $this->getSide(0); $down = $this->getSide(0);
if($down->getID() !== self::AIR){ if($down->getId() !== self::AIR){
$this->getLevel()->setBlock($block, $this, true, true); $this->getLevel()->setBlock($block, $this, true, true);
return true; return true;
@ -67,7 +75,7 @@ class Cake extends Transparent{
public function onUpdate($type){ public function onUpdate($type){
if($type === Level::BLOCK_UPDATE_NORMAL){ if($type === Level::BLOCK_UPDATE_NORMAL){
if($this->getSide(0)->getID() === self::AIR){ //Replace with common break method if($this->getSide(0)->getId() === self::AIR){ //Replace with common break method
$this->getLevel()->setBlock($this, new Air(), true); $this->getLevel()->setBlock($this, new Air(), true);
return Level::BLOCK_UPDATE_NORMAL; return Level::BLOCK_UPDATE_NORMAL;

View File

@ -27,9 +27,19 @@ use pocketmine\math\AxisAlignedBB;
use pocketmine\Player; use pocketmine\Player;
class Carpet extends Flowable{ class Carpet extends Flowable{
protected $id = self::CARPET;
public function __construct($meta = 0){ public function __construct($meta = 0){
parent::__construct(self::CARPET, $meta, "Carpet"); $this->meta = $meta;
$names = [ }
public function isSolid(){
return true;
}
public function getName(){
static $names = [
0 => "White Carpet", 0 => "White Carpet",
1 => "Orange Carpet", 1 => "Orange Carpet",
2 => "Magenta Carpet", 2 => "Magenta Carpet",
@ -47,18 +57,12 @@ class Carpet extends Flowable{
14 => "Red Carpet", 14 => "Red Carpet",
15 => "Black Carpet", 15 => "Black Carpet",
]; ];
$this->name = $names[$this->meta]; return $names[$this->meta & 0x0f];
$this->hardness = 0;
$this->isFullBlock = false;
$this->isSolid = true;
} }
public function getBoundingBox(){ protected function recalculateBoundingBox(){
if($this->boundingBox !== null){
return $this->boundingBox;
}
return $this->boundingBox = new AxisAlignedBB( return new AxisAlignedBB(
$this->x, $this->x,
$this->y, $this->y,
$this->z, $this->z,
@ -70,7 +74,7 @@ class Carpet extends Flowable{
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){ public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){
$down = $this->getSide(0); $down = $this->getSide(0);
if($down->getID() !== self::AIR){ if($down->getId() !== self::AIR){
$this->getLevel()->setBlock($block, $this, true, true); $this->getLevel()->setBlock($block, $this, true, true);
return true; return true;
@ -81,7 +85,7 @@ class Carpet extends Flowable{
public function onUpdate($type){ public function onUpdate($type){
if($type === Level::BLOCK_UPDATE_NORMAL){ if($type === Level::BLOCK_UPDATE_NORMAL){
if($this->getSide(0)->getID() === self::AIR){ if($this->getSide(0)->getId() === self::AIR){
$this->getLevel()->useBreakOn($this); $this->getLevel()->useBreakOn($this);
return Level::BLOCK_UPDATE_NORMAL; return Level::BLOCK_UPDATE_NORMAL;

View File

@ -24,8 +24,15 @@ namespace pocketmine\block;
use pocketmine\item\Item; use pocketmine\item\Item;
class Carrot extends Crops{ class Carrot extends Crops{
protected $id = self::CARROT_BLOCK;
public function __construct($meta = 0){ public function __construct($meta = 0){
parent::__construct(self::CARROT_BLOCK, $meta, "Carrot Block"); $this->meta = $meta;
}
public function getName(){
return "Carrot Block";
} }
public function getDrops(Item $item){ public function getDrops(Item $item){

View File

@ -34,20 +34,26 @@ use pocketmine\tile\Tile;
class Chest extends Transparent{ class Chest extends Transparent{
const SLOTS = 27; protected $id = self::CHEST;
public function __construct($meta = 0){ public function __construct($meta = 0){
parent::__construct(self::CHEST, $meta, "Chest"); $this->meta = $meta;
$this->isActivable = true;
$this->hardness = 15;
} }
public function getBoundingBox(){ public function canBeActivated(){
if($this->boundingBox !== null){ return true;
return $this->boundingBox; }
}
return $this->boundingBox = new AxisAlignedBB( public function getHardness(){
return 15;
}
public function getName(){
return "Chest";
}
protected function recalculateBoundingBox(){
return new AxisAlignedBB(
$this->x + 0.0625, $this->x + 0.0625,
$this->y, $this->y,
$this->z + 0.0625, $this->z + 0.0625,
@ -65,7 +71,7 @@ class Chest extends Transparent{
3 => 3, 3 => 3,
]; ];
$chest = false; $chest = null;
$this->meta = $faces[$player instanceof Player ? $player->getDirection() : 0]; $this->meta = $faces[$player instanceof Player ? $player->getDirection() : 0];
for($side = 2; $side <= 5; ++$side){ for($side = 2; $side <= 5; ++$side){
@ -93,9 +99,9 @@ class Chest extends Transparent{
new Int("z", $this->z) new Int("z", $this->z)
]); ]);
$nbt->Items->setTagType(NBT::TAG_Compound); $nbt->Items->setTagType(NBT::TAG_Compound);
$tile = new TileChest($this->getLevel()->getChunk($this->x >> 4, $this->z >> 4), $nbt); $tile = Tile::createTile("Chest", $this->getLevel()->getChunk($this->x >> 4, $this->z >> 4), $nbt);
if($chest instanceof TileChest){ if($chest instanceof TileChest and $tile instanceof TileChest){
$chest->pairWith($tile); $chest->pairWith($tile);
$tile->pairWith($chest); $tile->pairWith($chest);
} }
@ -116,7 +122,7 @@ class Chest extends Transparent{
public function onActivate(Item $item, Player $player = null){ public function onActivate(Item $item, Player $player = null){
if($player instanceof Player){ if($player instanceof Player){
$top = $this->getSide(1); $top = $this->getSide(1);
if($top->isTransparent !== true){ if($top->isTransparent() !== true){
return true; return true;
} }
@ -133,11 +139,11 @@ class Chest extends Transparent{
new Int("z", $this->z) new Int("z", $this->z)
]); ]);
$nbt->Items->setTagType(NBT::TAG_Compound); $nbt->Items->setTagType(NBT::TAG_Compound);
$chest = new TileChest($this->getLevel()->getChunk($this->x >> 4, $this->z >> 4), $nbt); $chest = Tile::createTile("Chest", $this->getLevel()->getChunk($this->x >> 4, $this->z >> 4), $nbt);
} }
if(($player->gamemode & 0x01) === 0x01){ if($player->isCreative()){
return true; return true;
} }
$player->addWindow($chest->getInventory()); $player->addWindow($chest->getInventory());

View File

@ -24,9 +24,19 @@ namespace pocketmine\block;
use pocketmine\item\Item; use pocketmine\item\Item;
class Clay extends Solid{ class Clay extends Solid{
protected $id = self::CLAY_BLOCK;
public function __construct(){ public function __construct(){
parent::__construct(self::CLAY_BLOCK, 0, "Clay Block");
$this->hardness = 3; }
public function getHardness(){
return 3;
}
public function getName(){
return "Clay Block";
} }
public function getDrops(Item $item){ public function getDrops(Item $item){

View File

@ -24,9 +24,19 @@ namespace pocketmine\block;
use pocketmine\item\Item; use pocketmine\item\Item;
class Coal extends Solid{ class Coal extends Solid{
protected $id = self::COAL_BLOCK;
public function __construct(){ public function __construct(){
parent::__construct(self::COAL_BLOCK, 0, "Coal Block");
$this->hardness = 30; }
public function getHardness(){
return 30;
}
public function getName(){
return "Coal Block";
} }
public function getBreakTime(Item $item){ public function getBreakTime(Item $item){

View File

@ -24,9 +24,19 @@ namespace pocketmine\block;
use pocketmine\item\Item; use pocketmine\item\Item;
class CoalOre extends Solid{ class CoalOre extends Solid{
protected $id = self::COAL_ORE;
public function __construct(){ public function __construct(){
parent::__construct(self::COAL_ORE, 0, "Coal Ore");
$this->hardness = 15; }
public function getHardness(){
return 15;
}
public function getName(){
return "Coal Ore";
} }
public function getBreakTime(Item $item){ public function getBreakTime(Item $item){

View File

@ -24,9 +24,19 @@ namespace pocketmine\block;
use pocketmine\item\Item; use pocketmine\item\Item;
class Cobblestone extends Solid{ class Cobblestone extends Solid{
protected $id = self::COBBLESTONE;
public function __construct(){ public function __construct(){
parent::__construct(self::COBBLESTONE, 0, "Cobblestone");
$this->hardness = 30; }
public function getName(){
return "Cobblestone";
}
public function getHardness(){
return 30;
} }
public function getBreakTime(Item $item){ public function getBreakTime(Item $item){

View File

@ -23,8 +23,15 @@ namespace pocketmine\block;
class CobblestoneStairs extends Stair{ class CobblestoneStairs extends Stair{
protected $id = self::COBBLESTONE_STAIRS;
public function __construct($meta = 0){ public function __construct($meta = 0){
parent::__construct(self::COBBLESTONE_STAIRS, $meta, "Cobblestone Stairs"); $this->meta = $meta;
}
public function getName(){
return "Cobblestone Stairs";
} }
} }

View File

@ -26,20 +26,30 @@ use pocketmine\item\Item;
class Cobweb extends Flowable{ class Cobweb extends Flowable{
public $hasEntityCollision = true; protected $id = self::COBWEB;
public function __construct(){ public function __construct(){
parent::__construct(self::COBWEB, 0, "Cobweb");
$this->isSolid = true; }
$this->isFullBlock = false;
$this->hardness = 25; public function hasEntityCollision(){
return true;
}
public function getName(){
return "Cobweb";
}
public function getHardness(){
return 25;
} }
public function onEntityCollide(Entity $entity){ public function onEntityCollide(Entity $entity){
$entity->fallDistance = 0; $entity->resetFallDistance();
} }
public function getDrops(Item $item){ public function getDrops(Item $item){
//TODO: correct drops
return []; return [];
} }
} }

View File

@ -29,17 +29,13 @@ use pocketmine\Server;
abstract class Crops extends Flowable{ abstract class Crops extends Flowable{
public $isActivable = true; public function canBeActivated(){
public $hardness = 0; return true;
public function getBoundingBox(){
return null;
} }
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){ public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){
$down = $this->getSide(0); $down = $this->getSide(0);
if($down->getID() === self::FARMLAND){ if($down->getId() === self::FARMLAND){
$this->getLevel()->setBlock($block, $this, true, true); $this->getLevel()->setBlock($block, $this, true, true);
return true; return true;
@ -50,7 +46,7 @@ abstract class Crops extends Flowable{
public function onActivate(Item $item, Player $player = null){ public function onActivate(Item $item, Player $player = null){
if($item->getID() === Item::DYE and $item->getDamage() === 0x0F){ //Bonemeal if($item->getId() === Item::DYE and $item->getDamage() === 0x0F){ //Bonemeal
$block = clone $this; $block = clone $this;
$block->meta += mt_rand(2, 5); $block->meta += mt_rand(2, 5);
if($block->meta > 7){ if($block->meta > 7){
@ -73,7 +69,7 @@ abstract class Crops extends Flowable{
public function onUpdate($type){ public function onUpdate($type){
if($type === Level::BLOCK_UPDATE_NORMAL){ if($type === Level::BLOCK_UPDATE_NORMAL){
if($this->getSide(0)->isTransparent === true){ if($this->getSide(0)->isTransparent() === true){
$this->getLevel()->useBreakOn($this); $this->getLevel()->useBreakOn($this);
return Level::BLOCK_UPDATE_NORMAL; return Level::BLOCK_UPDATE_NORMAL;
} }

View File

@ -26,19 +26,21 @@ use pocketmine\level\Level;
use pocketmine\Player; use pocketmine\Player;
class Dandelion extends Flowable{ class Dandelion extends Flowable{
protected $id = self::DANDELION;
public function __construct(){ public function __construct(){
parent::__construct(self::DANDELION, 0, "Dandelion");
$this->hardness = 0;
} }
public function getBoundingBox(){ public function getName(){
return null; return "Dandelion";
} }
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){ public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){
$down = $this->getSide(0); $down = $this->getSide(0);
if($down->getID() === 2 or $down->getID() === 3 or $down->getID() === 60){ if($down->getId() === 2 or $down->getId() === 3 or $down->getId() === 60){
$this->getLevel()->setBlock($block, $this, true, true); $this->getLevel()->setBlock($block, $this, true, true);
return true; return true;
@ -49,7 +51,7 @@ class Dandelion extends Flowable{
public function onUpdate($type){ public function onUpdate($type){
if($type === Level::BLOCK_UPDATE_NORMAL){ if($type === Level::BLOCK_UPDATE_NORMAL){
if($this->getSide(0)->isTransparent === true){ if($this->getSide(0)->isTransparent() === true){
$this->getLevel()->useBreakOn($this); $this->getLevel()->useBreakOn($this);
return Level::BLOCK_UPDATE_NORMAL; return Level::BLOCK_UPDATE_NORMAL;

View File

@ -24,8 +24,15 @@ namespace pocketmine\block;
use pocketmine\item\Item; use pocketmine\item\Item;
class DarkOakWoodStairs extends Stair{ class DarkOakWoodStairs extends Stair{
protected $id = self::DARK_OAK_WOOD_STAIRS;
public function __construct($meta = 0){ public function __construct($meta = 0){
parent::__construct(self::DARK_OAK_WOOD_STAIRS, $meta, "Dark Oak Wood Stairs"); $this->meta = $meta;
}
public function getName(){
return "Dark Oak Wood Stairs";
} }
public function getDrops(Item $item){ public function getDrops(Item $item){

View File

@ -24,21 +24,22 @@ namespace pocketmine\block;
use pocketmine\level\Level; use pocketmine\level\Level;
class DeadBush extends Flowable{ class DeadBush extends Flowable{
public function __construct(){
parent::__construct(self::DEAD_BUSH, 0, "Dead Bush"); protected $id = self::DEAD_BUSH;
//$this->isReplaceable = true;
$this->hardness = 0; public function __construct($meta = 0){
$this->meta = $meta;
} }
public function getBoundingBox(){ public function getName(){
return null; return "Dead Bush";
} }
public function onUpdate($type){ public function onUpdate($type){
if($type === Level::BLOCK_UPDATE_NORMAL){ if($type === Level::BLOCK_UPDATE_NORMAL){
if($this->getSide(0)->isTransparent === true){ //Replace with common break method if($this->getSide(0)->isTransparent() === true){
$this->getLevel()->setBlock($this, new Air(), false, false, true); $this->getLevel()->useBreakOn($this);
return Level::BLOCK_UPDATE_NORMAL; return Level::BLOCK_UPDATE_NORMAL;
} }

View File

@ -24,9 +24,19 @@ namespace pocketmine\block;
use pocketmine\item\Item; use pocketmine\item\Item;
class Diamond extends Solid{ class Diamond extends Solid{
protected $id = self::DIAMOND_BLOCK;
public function __construct(){ public function __construct(){
parent::__construct(self::DIAMOND_BLOCK, 0, "Diamond Block");
$this->hardness = 30; }
public function getHardness(){
return 30;
}
public function getName(){
return "Diamond Block";
} }
public function getBreakTime(Item $item){ public function getBreakTime(Item $item){

View File

@ -24,9 +24,19 @@ namespace pocketmine\block;
use pocketmine\item\Item; use pocketmine\item\Item;
class DiamondOre extends Solid{ class DiamondOre extends Solid{
protected $id = self::DIAMOND_ORE;
public function __construct(){ public function __construct(){
parent::__construct(self::DIAMOND_ORE, 0, "Diamond Ore");
$this->hardness = 15; }
public function getHardness(){
return 15;
}
public function getName(){
return "Diamond Ore";
} }
public function getBreakTime(Item $item){ public function getBreakTime(Item $item){

View File

@ -26,16 +26,24 @@ use pocketmine\Player;
class Dirt extends Solid{ class Dirt extends Solid{
public $isActivable = true;
protected $hardness = 2.5;
protected $id = self::DIRT; protected $id = self::DIRT;
protected $meta = 0;
protected $name = "Dirt";
public function __construct(){ public function __construct(){
} }
public function canBeActivated(){
return true;
}
public function getHardness(){
return 2.5;
}
public function getName(){
return "Dirt";
}
public function onActivate(Item $item, Player $player = null){ public function onActivate(Item $item, Player $player = null){
if($item->isHoe()){ if($item->isHoe()){
$item->useOn($this); $item->useOn($this);

View File

@ -30,9 +30,13 @@ use pocketmine\Server;
abstract class Door extends Transparent{ abstract class Door extends Transparent{
public function __construct($id, $meta = 0, $name = "Unknown"){
parent::__construct($id, $meta, $name); public function canBeActivated(){
$this->isSolid = false; return true;
}
public function isSolid(){
return false;
} }
private function getFullDamage(){ private function getFullDamage(){
@ -52,10 +56,7 @@ abstract class Door extends Transparent{
return $first & 0x07 | ($flag ? 8 : 0) | ($flag1 ? 0x10 : 0); return $first & 0x07 | ($flag ? 8 : 0) | ($flag1 ? 0x10 : 0);
} }
public function getBoundingBox(){ protected function recalculateBoundingBox(){
if($this->boundingBox !== null){
return $this->boundingBox;
}
$f = 0.1875; $f = 0.1875;
$damage = $this->getFullDamage(); $damage = $this->getFullDamage();
@ -76,7 +77,7 @@ abstract class Door extends Transparent{
if($j === 0){ if($j === 0){
if($flag){ if($flag){
if(!$flag1){ if(!$flag1){
$bb = new AxisAlignedBB( $bb->setBounds(
$this->x, $this->x,
$this->y, $this->y,
$this->z, $this->z,
@ -85,7 +86,7 @@ abstract class Door extends Transparent{
$this->z + $f $this->z + $f
); );
}else{ }else{
$bb = new AxisAlignedBB( $bb->setBounds(
$this->x, $this->x,
$this->y, $this->y,
$this->z + 1 - $f, $this->z + 1 - $f,
@ -95,7 +96,7 @@ abstract class Door extends Transparent{
); );
} }
}else{ }else{
$bb = new AxisAlignedBB( $bb->setBounds(
$this->x, $this->x,
$this->y, $this->y,
$this->z, $this->z,
@ -107,7 +108,7 @@ abstract class Door extends Transparent{
}elseif($j === 1){ }elseif($j === 1){
if($flag){ if($flag){
if(!$flag1){ if(!$flag1){
$bb = new AxisAlignedBB( $bb->setBounds(
$this->x + 1 - $f, $this->x + 1 - $f,
$this->y, $this->y,
$this->z, $this->z,
@ -116,7 +117,7 @@ abstract class Door extends Transparent{
$this->z + 1 $this->z + 1
); );
}else{ }else{
$bb = new AxisAlignedBB( $bb->setBounds(
$this->x, $this->x,
$this->y, $this->y,
$this->z, $this->z,
@ -126,7 +127,7 @@ abstract class Door extends Transparent{
); );
} }
}else{ }else{
$bb = new AxisAlignedBB( $bb->setBounds(
$this->x, $this->x,
$this->y, $this->y,
$this->z, $this->z,
@ -138,7 +139,7 @@ abstract class Door extends Transparent{
}elseif($j === 2){ }elseif($j === 2){
if($flag){ if($flag){
if(!$flag1){ if(!$flag1){
$bb = new AxisAlignedBB( $bb->setBounds(
$this->x, $this->x,
$this->y, $this->y,
$this->z + 1 - $f, $this->z + 1 - $f,
@ -147,7 +148,7 @@ abstract class Door extends Transparent{
$this->z + 1 $this->z + 1
); );
}else{ }else{
$bb = new AxisAlignedBB( $bb->setBounds(
$this->x, $this->x,
$this->y, $this->y,
$this->z, $this->z,
@ -157,7 +158,7 @@ abstract class Door extends Transparent{
); );
} }
}else{ }else{
$bb = new AxisAlignedBB( $bb->setBounds(
$this->x + 1 - $f, $this->x + 1 - $f,
$this->y, $this->y,
$this->z, $this->z,
@ -169,7 +170,7 @@ abstract class Door extends Transparent{
}elseif($j === 3){ }elseif($j === 3){
if($flag){ if($flag){
if(!$flag1){ if(!$flag1){
$bb = new AxisAlignedBB( $bb->setBounds(
$this->x, $this->x,
$this->y, $this->y,
$this->z, $this->z,
@ -178,7 +179,7 @@ abstract class Door extends Transparent{
$this->z + 1 $this->z + 1
); );
}else{ }else{
$bb = new AxisAlignedBB( $bb->setBounds(
$this->x + 1 - $f, $this->x + 1 - $f,
$this->y, $this->y,
$this->z, $this->z,
@ -188,7 +189,7 @@ abstract class Door extends Transparent{
); );
} }
}else{ }else{
$bb = new AxisAlignedBB( $bb->setBounds(
$this->x, $this->x,
$this->y, $this->y,
$this->z + 1 - $f, $this->z + 1 - $f,
@ -199,12 +200,12 @@ abstract class Door extends Transparent{
} }
} }
return $this->boundingBox = $bb; return $bb;
} }
public function onUpdate($type){ public function onUpdate($type){
if($type === Level::BLOCK_UPDATE_NORMAL){ if($type === Level::BLOCK_UPDATE_NORMAL){
if($this->getSide(0)->getID() === self::AIR){ //Replace with common break method if($this->getSide(0)->getId() === self::AIR){ //Replace with common break method
$this->getLevel()->setBlock($this, new Air(), false); $this->getLevel()->setBlock($this, new Air(), false);
if($this->getSide(1) instanceof Door){ if($this->getSide(1) instanceof Door){
$this->getLevel()->setBlock($this->getSide(1), new Air(), false); $this->getLevel()->setBlock($this->getSide(1), new Air(), false);
@ -221,7 +222,7 @@ abstract class Door extends Transparent{
if($face === 1){ if($face === 1){
$blockUp = $this->getSide(1); $blockUp = $this->getSide(1);
$blockDown = $this->getSide(0); $blockDown = $this->getSide(0);
if($blockUp->isReplaceable === false or $blockDown->isTransparent === true){ if($blockUp->canBeReplaced() === false or $blockDown->isTransparent() === true){
return false; return false;
} }
$direction = $player instanceof Player ? $player->getDirection() : 0; $direction = $player instanceof Player ? $player->getDirection() : 0;
@ -234,7 +235,7 @@ abstract class Door extends Transparent{
$next = $this->getSide($face[(($direction + 2) % 4)]); $next = $this->getSide($face[(($direction + 2) % 4)]);
$next2 = $this->getSide($face[$direction]); $next2 = $this->getSide($face[$direction]);
$metaUp = 0x08; $metaUp = 0x08;
if($next->getID() === $this->id or ($next2->isTransparent === false and $next->isTransparent === true)){ //Door hinge if($next->getId() === $this->id or ($next2->isTransparent() === false and $next->isTransparent() === true)){ //Door hinge
$metaUp |= 0x01; $metaUp |= 0x01;
} }
@ -250,12 +251,12 @@ abstract class Door extends Transparent{
public function onBreak(Item $item){ public function onBreak(Item $item){
if(($this->meta & 0x08) === 0x08){ if(($this->meta & 0x08) === 0x08){
$down = $this->getSide(0); $down = $this->getSide(0);
if($down->getID() === $this->id){ if($down->getId() === $this->id){
$this->getLevel()->setBlock($down, new Air(), true); $this->getLevel()->setBlock($down, new Air(), true);
} }
}else{ }else{
$up = $this->getSide(1); $up = $this->getSide(1);
if($up->getID() === $this->id){ if($up->getId() === $this->id){
$this->getLevel()->setBlock($up, new Air(), true); $this->getLevel()->setBlock($up, new Air(), true);
} }
} }
@ -267,14 +268,14 @@ abstract class Door extends Transparent{
public function onActivate(Item $item, Player $player = null){ public function onActivate(Item $item, Player $player = null){
if(($this->meta & 0x08) === 0x08){ //Top if(($this->meta & 0x08) === 0x08){ //Top
$down = $this->getSide(0); $down = $this->getSide(0);
if($down->getID() === $this->id){ if($down->getId() === $this->id){
$meta = $down->getDamage() ^ 0x04; $meta = $down->getDamage() ^ 0x04;
$this->getLevel()->setBlock($down, Block::get($this->id, $meta), true); $this->getLevel()->setBlock($down, Block::get($this->id, $meta), true);
$players = $this->getLevel()->getUsingChunk($this->x >> 4, $this->z >> 4); $players = $this->getLevel()->getUsingChunk($this->x >> 4, $this->z >> 4);
if($player instanceof Player){ if($player instanceof Player){
unset($players[$player->getID()]); unset($players[$player->getId()]);
} }
$pk = new LevelEventPacket; $pk = new LevelEventPacket();
$pk->x = $this->x; $pk->x = $this->x;
$pk->y = $this->y; $pk->y = $this->y;
$pk->z = $this->z; $pk->z = $this->z;
@ -291,9 +292,9 @@ abstract class Door extends Transparent{
$this->getLevel()->setBlock($this, $this, true); $this->getLevel()->setBlock($this, $this, true);
$players = $this->getLevel()->getUsingChunk($this->x >> 4, $this->z >> 4); $players = $this->getLevel()->getUsingChunk($this->x >> 4, $this->z >> 4);
if($player instanceof Player){ if($player instanceof Player){
unset($players[$player->getID()]); unset($players[$player->getId()]);
} }
$pk = new LevelEventPacket; $pk = new LevelEventPacket();
$pk->x = $this->x; $pk->x = $this->x;
$pk->y = $this->y; $pk->y = $this->y;
$pk->z = $this->z; $pk->z = $this->z;

View File

@ -0,0 +1,70 @@
<?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;
use pocketmine\item\Item;
use pocketmine\level\Level;
class DoublePlant extends Flowable{
protected $id = self::DOUBLE_PLANT;
public function __construct($meta = 0){
$this->meta = $meta;
}
public function canBeReplaced(){
return true;
}
public function getName(){
static $names = [
0 => "Sunflower",
1 => "Lilac",
2 => "Double Tallgrass",
3 => "Large Fern",
4 => "Rose Bush",
5 => "Peony"
];
return $names[$this->meta & 0x07];
}
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 false;
}
public function getDrops(Item $item){
//TODO
return [];
}
}

View File

@ -24,9 +24,19 @@ namespace pocketmine\block;
use pocketmine\item\Item; use pocketmine\item\Item;
class DoubleSlab extends Solid{ class DoubleSlab extends Solid{
protected $id = self::DOUBLE_SLAB;
public function __construct($meta = 0){ public function __construct($meta = 0){
parent::__construct(self::DOUBLE_SLAB, $meta, "Double Slab"); $this->meta = $meta;
$names = [ }
public function getHardness(){
return 30;
}
public function getName(){
static $names = [
0 => "Stone", 0 => "Stone",
1 => "Sandstone", 1 => "Sandstone",
2 => "Wooden", 2 => "Wooden",
@ -36,8 +46,7 @@ class DoubleSlab extends Solid{
6 => "Quartz", 6 => "Quartz",
7 => "", 7 => "",
]; ];
$this->name = "Double " . $names[$this->meta & 0x07] . " Slab"; return "Double " . $names[$this->meta & 0x07] . " Slab";
$this->hardness = 30;
} }
public function getBreakTime(Item $item){ public function getBreakTime(Item $item){

View File

@ -24,18 +24,29 @@ namespace pocketmine\block;
use pocketmine\item\Item; use pocketmine\item\Item;
class DoubleWoodSlab extends Solid{ class DoubleWoodSlab extends Solid{
protected $id = self::DOUBLE_WOOD_SLAB;
public function __construct($meta = 0){ public function __construct($meta = 0){
parent::__construct(self::DOUBLE_WOOD_SLAB, $meta, "Double Wooden Slab"); $this->meta = $meta;
$names = [ }
public function getHardness(){
return 15;
}
public function getName(){
static $names = [
0 => "Oak", 0 => "Oak",
1 => "Spruce", 1 => "Spruce",
2 => "Birch", 2 => "Birch",
3 => "Jungle", 3 => "Jungle",
4 => "Acacia", 4 => "Acacia",
5 => "Dark Oak", 5 => "Dark Oak",
6 => "",
7 => ""
]; ];
$this->name = "Double " . $names[$this->meta & 0x07] . " Wooden Slab"; return "Double " . $names[$this->meta & 0x07] . " Wooden Slab";
$this->hardness = 15;
} }
public function getBreakTime(Item $item){ public function getBreakTime(Item $item){

View File

@ -24,9 +24,19 @@ namespace pocketmine\block;
use pocketmine\item\Item; use pocketmine\item\Item;
class Emerald extends Solid{ class Emerald extends Solid{
protected $id = self::EMERALD_BLOCK;
public function __construct(){ public function __construct(){
parent::__construct(self::EMERALD_BLOCK, 0, "Emerald Block");
$this->hardness = 30; }
public function getHardness(){
return 30;
}
public function getName(){
return "Emerald Block";
} }
public function getBreakTime(Item $item){ public function getBreakTime(Item $item){

View File

@ -24,9 +24,19 @@ namespace pocketmine\block;
use pocketmine\item\Item; use pocketmine\item\Item;
class EmeraldOre extends Solid{ class EmeraldOre extends Solid{
protected $id = self::EMERALD_ORE;
public function __construct(){ public function __construct(){
parent::__construct(self::EMERALD_ORE, 0, "Emerald Ore");
$this->hardness = 15; }
public function getName(){
return "Emerald Ore";
}
public function getHardness(){
return 15;
} }
public function getBreakTime(Item $item){ public function getBreakTime(Item $item){

View File

@ -21,20 +21,36 @@
namespace pocketmine\block; namespace pocketmine\block;
use pocketmine\item\Item;
use pocketmine\math\AxisAlignedBB; use pocketmine\math\AxisAlignedBB;
class EndPortal extends Solid{ class EndPortalFrame extends Solid{
protected $id = self::END_PORTAL_FRAME;
public function __construct($meta = 0){ public function __construct($meta = 0){
parent::__construct(self::END_PORTAL, $meta, "End Portal"); $this->meta = $meta;
$this->hardness = 18000000;
} }
public function getBoundingBox(){ public function getLightLevel(){
if($this->boundingBox !== null){ return 1;
return $this->boundingBox; }
}
return $this->boundingBox = new AxisAlignedBB( public function getName(){
return "End Portal Frame";
}
public function getHardness(){
return 18000000;
}
public function isBreakable(Item $item){
return false;
}
protected function recalculateBoundingBox(){
return new AxisAlignedBB(
$this->x, $this->x,
$this->y, $this->y,
$this->z, $this->z,

View File

@ -24,9 +24,19 @@ namespace pocketmine\block;
use pocketmine\item\Item; use pocketmine\item\Item;
class EndStone extends Solid{ class EndStone extends Solid{
protected $id = self::END_STONE;
public function __construct(){ public function __construct(){
parent::__construct(self::END_STONE, 0, "End Stone");
$this->hardness = 45; }
public function getName(){
return "End Stone";
}
public function getHardness(){
return 45;
} }
public function getBreakTime(Item $item){ public function getBreakTime(Item $item){

View File

@ -21,7 +21,7 @@
namespace pocketmine\block; namespace pocketmine\block;
use pocketmine\entity\FallingBlock; use pocketmine\entity\Entity;
use pocketmine\item\Item; use pocketmine\item\Item;
use pocketmine\level\Level; use pocketmine\level\Level;
use pocketmine\nbt\tag\Byte; use pocketmine\nbt\tag\Byte;
@ -29,12 +29,11 @@ use pocketmine\nbt\tag\Compound;
use pocketmine\nbt\tag\Double; use pocketmine\nbt\tag\Double;
use pocketmine\nbt\tag\Enum; use pocketmine\nbt\tag\Enum;
use pocketmine\nbt\tag\Float; use pocketmine\nbt\tag\Float;
use pocketmine\nbt\tag\Int;
use pocketmine\Player; use pocketmine\Player;
abstract class Fallable extends Solid{ abstract class Fallable extends Solid{
public $hasPhysics = true;
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){ public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){
$ret = $this->getLevel()->setBlock($this, $this, true, true); $ret = $this->getLevel()->setBlock($this, $this, true, true);
@ -42,10 +41,10 @@ abstract class Fallable extends Solid{
} }
public function onUpdate($type){ public function onUpdate($type){
if($this->hasPhysics === true and $type === Level::BLOCK_UPDATE_NORMAL){ if($type === Level::BLOCK_UPDATE_NORMAL){
$down = $this->getSide(0); $down = $this->getSide(0);
if($down->getID() === self::AIR or ($down instanceof Liquid)){ if($down->getId() === self::AIR or ($down instanceof Liquid)){
$fall = new FallingBlock($this->getLevel()->getChunk($this->x >> 4, $this->z >> 4), new Compound("", [ $fall = Entity::createEntity("FallingSand", $this->getLevel()->getChunk($this->x >> 4, $this->z >> 4), new Compound("", [
"Pos" => new Enum("Pos", [ "Pos" => new Enum("Pos", [
new Double("", $this->x + 0.5), new Double("", $this->x + 0.5),
new Double("", $this->y), new Double("", $this->y),
@ -60,13 +59,12 @@ abstract class Fallable extends Solid{
new Float("", 0), new Float("", 0),
new Float("", 0) new Float("", 0)
]), ]),
"Tile" => new Byte("Tile", $this->getID()) "TileID" => new Int("TileID", $this->getId()),
"Data" => new Byte("Data", $this->getDamage()),
])); ]));
$fall->spawnToAll(); $fall->spawnToAll();
} }
return false;
} }
} }
} }

View File

@ -25,17 +25,23 @@ use pocketmine\item\Item;
use pocketmine\math\AxisAlignedBB; use pocketmine\math\AxisAlignedBB;
class Farmland extends Solid{ class Farmland extends Solid{
protected $id = self::FARMLAND;
public function __construct($meta = 0){ public function __construct($meta = 0){
parent::__construct(self::FARMLAND, $meta, "Farmland"); $this->meta = $meta;
$this->hardness = 3;
} }
public function getBoundingBox(){ public function getName(){
if($this->boundingBox !== null){ return "Farmland";
return $this->boundingBox; }
}
return $this->boundingBox = new AxisAlignedBB( public function getHardness(){
return 3;
}
protected function recalculateBoundingBox(){
return new AxisAlignedBB(
$this->x, $this->x,
$this->y, $this->y,
$this->z, $this->z,

View File

@ -21,43 +21,59 @@
namespace pocketmine\block; namespace pocketmine\block;
use pocketmine\math\AxisAlignedBB; use pocketmine\math\AxisAlignedBB;
class Fence extends Transparent{ class Fence extends Transparent{
public function __construct(){
parent::__construct(self::FENCE, 0, "Fence"); protected $id = self::FENCE;
$this->isFullBlock = false;
$this->hardness = 15; public function __construct($meta = 0){
$this->meta = $meta;
} }
public function getBoundingBox(){ public function getHardness(){
if($this->boundingBox !== null){ return 15;
return $this->boundingBox; }
}
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)); $flag = $this->canConnect($this->getSide(2));
$flag1 = $this->canConnect($this->getSide(3)); $flag1 = $this->canConnect($this->getSide(3));
$flag2 = $this->canConnect($this->getSide(4)); $flag2 = $this->canConnect($this->getSide(4));
$flag3 = $this->canConnect($this->getSide(5)); $flag3 = $this->canConnect($this->getSide(5));
$f = $flag2 ? 0 : 0.375; $f = $flag2 ? 0 : 0.375;
$f1 = $flag3 ? 1 : 0.625; $f1 = $flag3 ? 1 : 0.625;
$f2 = $flag ? 0 : 0.375; $f2 = $flag ? 0 : 0.375;
$f3 = $flag1 ? 1 : 0.625; $f3 = $flag1 ? 1 : 0.625;
return $this->boundingBox = new AxisAlignedBB( return new AxisAlignedBB(
$this->x + $f, $this->x + $f,
$this->y, $this->y,
$this->z + $f2, $this->z + $f2,
$this->x + $f1, $this->x + $f1,
$this->y + 1, //TODO: check this, add extra bounding box $this->y + 1.5,
$this->z + $f3 $this->z + $f3
); );
} }
public function canConnect(Block $block){ public function canConnect(Block $block){
return ($block->getID() !== self::FENCE and $block->getID() !== self::FENCE_GATE) ? $block->isSolid : true; return (!($block instanceof Fence) and !($block instanceof FenceGate)) ? $block->isSolid() : true;
} }
} }

View File

@ -26,22 +26,27 @@ use pocketmine\math\AxisAlignedBB;
use pocketmine\Player; use pocketmine\Player;
class FenceGate extends Transparent{ class FenceGate extends Transparent{
protected $id = self::FENCE_GATE;
public function __construct($meta = 0){ public function __construct($meta = 0){
parent::__construct(self::FENCE_GATE, $meta, "Fence Gate"); $this->meta = $meta;
$this->isActivable = true; }
if(($this->meta & 0x04) === 0x04){
$this->isFullBlock = true; public function getName(){
}else{ return "Oak Fence Gate";
$this->isFullBlock = false; }
}
$this->hardness = 15; public function getHardness(){
return 15;
}
public function canBeActivated(){
return true;
} }
public function getBoundingBox(){ protected function recalculateBoundingBox(){
if($this->boundingBox !== null){
return $this->boundingBox;
}
if(($this->getDamage() & 0x04) > 0){ if(($this->getDamage() & 0x04) > 0){
return null; return null;
@ -49,21 +54,21 @@ class FenceGate extends Transparent{
$i = ($this->getDamage() & 0x03); $i = ($this->getDamage() & 0x03);
if($i === 2 and $i === 0){ if($i === 2 and $i === 0){
return $this->boundingBox = new AxisAlignedBB( return new AxisAlignedBB(
$this->x, $this->x,
$this->y, $this->y,
$this->z + 0.375, $this->z + 0.375,
$this->x + 1, $this->x + 1,
$this->y + 1, $this->y + 1.5,
$this->z + 0.625 $this->z + 0.625
); );
}else{ }else{
return $this->boundingBox = new AxisAlignedBB( return new AxisAlignedBB(
$this->x + 0.375, $this->x + 0.375,
$this->y, $this->y,
$this->z, $this->z,
$this->x + 0.625, $this->x + 0.625,
$this->y + 1, $this->y + 1.5,
$this->z + 1 $this->z + 1
); );
} }
@ -96,11 +101,6 @@ class FenceGate extends Transparent{
3 => 2, 3 => 2,
]; ];
$this->meta = ($faces[$player instanceof Player ? $player->getDirection() : 0] & 0x03) | ((~$this->meta) & 0x04); $this->meta = ($faces[$player instanceof Player ? $player->getDirection() : 0] & 0x03) | ((~$this->meta) & 0x04);
if(($this->meta & 0x04) === 0x04){
$this->isFullBlock = true;
}else{
$this->isFullBlock = false;
}
$this->getLevel()->setBlock($this, $this, true); $this->getLevel()->setBlock($this, $this, true);
return true; return true;

View File

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

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

View File

@ -0,0 +1,32 @@
<?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 FenceGateDarkOak extends FenceGate{
protected $id = self::FENCE_GATE_DARK_OAK;
public function getName(){
return "Dark Oak Fence Gate";
}
}

View File

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

View File

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

@ -2,11 +2,11 @@
/* /*
* *
* ____ _ _ __ __ _ __ __ ____ * ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \ * | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) | * | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/ * | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_| * |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU Lesser General Public License as published by
@ -15,7 +15,7 @@
* *
* @author PocketMine Team * @author PocketMine Team
* @link http://www.pocketmine.net/ * @link http://www.pocketmine.net/
* *
* *
*/ */
@ -25,32 +25,50 @@ use pocketmine\entity\Entity;
use pocketmine\event\entity\EntityCombustByBlockEvent; use pocketmine\event\entity\EntityCombustByBlockEvent;
use pocketmine\event\entity\EntityDamageByBlockEvent; use pocketmine\event\entity\EntityDamageByBlockEvent;
use pocketmine\event\entity\EntityDamageEvent; use pocketmine\event\entity\EntityDamageEvent;
use pocketmine\inventory\InventoryHolder;
use pocketmine\inventory\PlayerInventory;
use pocketmine\item\Item; use pocketmine\item\Item;
use pocketmine\level\Level; use pocketmine\level\Level;
use pocketmine\Server; use pocketmine\Server;
class Fire extends Flowable{ class Fire extends Flowable{
public $hasEntityCollision = true; protected $id = self::FIRE;
public function __construct($meta = 0){ public function __construct($meta = 0){
parent::__construct(self::FIRE, $meta, "Fire"); $this->meta = $meta;
$this->isReplaceable = true;
$this->breakable = false;
$this->isFullBlock = true;
$this->hardness = 0;
} }
public function getBoundingBox(){ public function hasEntityCollision(){
return null; return true;
}
public function getName(){
return "Fire Block";
}
public function getLightLevel(){
return 15;
}
public function isBreakable(Item $item){
return false;
}
public function canBeReplaced(){
return true;
} }
public function onEntityCollide(Entity $entity){ public function onEntityCollide(Entity $entity){
$ev = new EntityDamageByBlockEvent($this, $entity, EntityDamageEvent::CAUSE_FIRE, 1); $damage = [EntityDamageEvent::MODIFIER_BASE => 1];
Server::getInstance()->getPluginManager()->callEvent($ev); if($entity instanceof InventoryHolder){
if(!$ev->isCancelled()){ $inventory = $entity->getInventory();
$entity->attack($ev->getFinalDamage(), $ev); if($inventory instanceof PlayerInventory){
$damage[EntityDamageEvent::MODIFIER_ARMOR] = $inventory->getArmorPoints();
}
} }
$ev = new EntityDamageByBlockEvent($this, $entity, EntityDamageEvent::CAUSE_FIRE, $damage);
$entity->attack($ev->getFinalDamage(), $ev);
$ev = new EntityCombustByBlockEvent($this, $entity, 8); $ev = new EntityCombustByBlockEvent($this, $entity, 8);
Server::getInstance()->getPluginManager()->callEvent($ev); Server::getInstance()->getPluginManager()->callEvent($ev);
@ -67,7 +85,7 @@ class Fire extends Flowable{
if($type === Level::BLOCK_UPDATE_NORMAL){ if($type === Level::BLOCK_UPDATE_NORMAL){
for($s = 0; $s <= 5; ++$s){ for($s = 0; $s <= 5; ++$s){
$side = $this->getSide($s); $side = $this->getSide($s);
if($side->getID() !== self::AIR and !($side instanceof Liquid)){ if($side->getId() !== self::AIR and !($side instanceof Liquid)){
return false; return false;
} }
} }
@ -75,7 +93,7 @@ class Fire extends Flowable{
return Level::BLOCK_UPDATE_NORMAL; return Level::BLOCK_UPDATE_NORMAL;
}elseif($type === Level::BLOCK_UPDATE_RANDOM){ }elseif($type === Level::BLOCK_UPDATE_RANDOM){
if($this->getSide(0)->getID() !== self::NETHERRACK){ if($this->getSide(0)->getId() !== self::NETHERRACK){
$this->getLevel()->setBlock($this, new Air(), true); $this->getLevel()->setBlock($this, new Air(), true);
return Level::BLOCK_UPDATE_NORMAL; return Level::BLOCK_UPDATE_NORMAL;
@ -85,4 +103,4 @@ class Fire extends Flowable{
return false; return false;
} }
} }

View File

@ -24,8 +24,19 @@ namespace pocketmine\block;
abstract class Flowable extends Transparent{ abstract class Flowable extends Transparent{
public $isFlowable = true; public function canBeFlowedInto(){
public $isFullBlock = false; return true;
public $isSolid = false; }
public function isSolid(){
return false;
}
public function getBoundingBox(){
return null;
}
public function getHardness(){
return 0;
}
} }

View File

@ -23,10 +23,10 @@ namespace pocketmine\block;
class Furnace extends BurningFurnace{ class Furnace extends BurningFurnace{
public function __construct($meta = 0){
parent::__construct($meta); protected $id = self::FURNACE;
$this->id = self::FURNACE;
$this->name = "Furnace"; public function getName(){
$this->isActivable = true; return "Furnace";
} }
} }

View File

@ -24,9 +24,19 @@ namespace pocketmine\block;
use pocketmine\item\Item; use pocketmine\item\Item;
class Glass extends Transparent{ class Glass extends Transparent{
protected $id = self::GLASS;
public function __construct(){ public function __construct(){
parent::__construct(self::GLASS, 0, "Glass");
$this->hardness = 1.5; }
public function getName(){
return "Glass";
}
public function getHardness(){
return 1.5;
} }
public function getDrops(Item $item){ public function getDrops(Item $item){

View File

@ -22,9 +22,25 @@
namespace pocketmine\block; namespace pocketmine\block;
use pocketmine\item\Item;
class GlassPane extends Thin{ class GlassPane extends Thin{
protected $id = self::GLASS_PANE;
public function __construct(){ public function __construct(){
parent::__construct(self::GLASS_PANE, 0, "Glass Pane");
} }
public function getName(){
return "Glass Pane";
}
public function getHardness(){
return 1.5;
}
public function getDrops(Item $item){
return [];
}
} }

View File

@ -23,8 +23,19 @@ namespace pocketmine\block;
class GlowingObsidian extends Solid{ class GlowingObsidian extends Solid{
protected $id = self::GLOWING_OBSIDIAN;
public function __construct($meta = 0){ public function __construct($meta = 0){
parent::__construct(self::GLOWING_OBSIDIAN, $meta, "Glowing Obsidian"); $this->meta = $meta;
}
public function getName(){
return "Glowing Obsidian";
}
public function getLightLevel(){
return 12;
} }
} }

View File

@ -25,9 +25,23 @@ use pocketmine\item\Item;
use pocketmine\level\Level; use pocketmine\level\Level;
class GlowingRedstoneOre extends Solid{ class GlowingRedstoneOre extends Solid{
protected $id = self::GLOWING_REDSTONE_ORE;
public function __construct(){ public function __construct(){
parent::__construct(self::GLOWING_REDSTONE_ORE, 0, "Glowing Redstone Ore");
$this->hardness = 15; }
public function getHardness(){
return 15;
}
public function getName(){
return "Glowing Redstone Ore";
}
public function getLightLevel(){
return 9;
} }
public function onUpdate($type){ public function onUpdate($type){

View File

@ -24,9 +24,23 @@ namespace pocketmine\block;
use pocketmine\item\Item; use pocketmine\item\Item;
class Glowstone extends Transparent{ class Glowstone extends Transparent{
protected $id = self::GLOWSTONE_BLOCK;
public function __construct(){ public function __construct(){
parent::__construct(self::GLOWSTONE_BLOCK, 0, "Glowstone");
$this->hardness = 1.5; }
public function getName(){
return "Glowstone";
}
public function getHardness(){
return 1.5;
}
public function getLightLevel(){
return 15;
} }
public function getDrops(Item $item){ public function getDrops(Item $item){

View File

@ -24,9 +24,19 @@ namespace pocketmine\block;
use pocketmine\item\Item; use pocketmine\item\Item;
class Gold extends Solid{ class Gold extends Solid{
protected $id = self::GOLD_BLOCK;
public function __construct(){ public function __construct(){
parent::__construct(self::GOLD_BLOCK, 0, "Gold Block");
$this->hardness = 30; }
public function getName(){
return "Gold Block";
}
public function getHardness(){
return 30;
} }
public function getBreakTime(Item $item){ public function getBreakTime(Item $item){

View File

@ -24,9 +24,19 @@ namespace pocketmine\block;
use pocketmine\item\Item; use pocketmine\item\Item;
class GoldOre extends Solid{ class GoldOre extends Solid{
protected $id = self::GOLD_ORE;
public function __construct(){ public function __construct(){
parent::__construct(self::GOLD_ORE, 0, "Gold Ore");
$this->hardness = 15; }
public function getName(){
return "Gold Ore";
}
public function getHardness(){
return 15;
} }
public function getBreakTime(Item $item){ public function getBreakTime(Item $item){

View File

@ -25,23 +25,31 @@ use pocketmine\event\block\BlockSpreadEvent;
use pocketmine\item\Item; use pocketmine\item\Item;
use pocketmine\level\generator\object\TallGrass as TallGrassObject; use pocketmine\level\generator\object\TallGrass as TallGrassObject;
use pocketmine\level\Level; use pocketmine\level\Level;
use pocketmine\level\Position; use pocketmine\math\Vector3;
use pocketmine\Player; use pocketmine\Player;
use pocketmine\Server; use pocketmine\Server;
use pocketmine\utils\Random; use pocketmine\utils\Random;
class Grass extends Solid{ class Grass extends Solid{
public $isActivable = true;
protected $hardness = 3;
protected $id = self::GRASS; protected $id = self::GRASS;
protected $meta = 0;
protected $name = "Grass";
public function __construct(){ public function __construct(){
} }
public function canBeActivated(){
return true;
}
public function getName(){
return "Grass";
}
public function getHardness(){
return 3;
}
public function getDrops(Item $item){ public function getDrops(Item $item){
return [ return [
[Item::DIRT, 0, 1], [Item::DIRT, 0, 1],
@ -54,9 +62,8 @@ class Grass extends Solid{
$x = mt_rand($this->x - 1, $this->x + 1); $x = mt_rand($this->x - 1, $this->x + 1);
$y = mt_rand($this->y - 2, $this->y + 2); $y = mt_rand($this->y - 2, $this->y + 2);
$z = mt_rand($this->z - 1, $this->z + 1); $z = mt_rand($this->z - 1, $this->z + 1);
$block = $this->getLevel()->getBlockIdAt($x, $y, $z); $block = $this->getLevel()->getBlock(new Vector3($x, $y, $z));
if($block === Block::DIRT){ if($block->getId() === Block::DIRT){
$block = Block::get($block, $this->getLevel()->getBlockDataAt($x, $y, $z), new Position($x, $y, $z, $this->getLevel()));
if($block->getSide(1) instanceof Transparent){ if($block->getSide(1) instanceof Transparent){
Server::getInstance()->getPluginManager()->callEvent($ev = new BlockSpreadEvent($block, $this, new Grass())); Server::getInstance()->getPluginManager()->callEvent($ev = new BlockSpreadEvent($block, $this, new Grass()));
if(!$ev->isCancelled()){ if(!$ev->isCancelled()){
@ -68,7 +75,7 @@ class Grass extends Solid{
} }
public function onActivate(Item $item, Player $player = null){ public function onActivate(Item $item, Player $player = null){
if($item->getID() === Item::DYE and $item->getDamage() === 0x0F){ if($item->getId() === Item::DYE and $item->getDamage() === 0x0F){
$item->count--; $item->count--;
TallGrassObject::growGrass($this->getLevel(), $this, new Random(mt_rand()), 8, 2); TallGrassObject::growGrass($this->getLevel(), $this, new Random(mt_rand()), 8, 2);

View File

@ -24,9 +24,19 @@ namespace pocketmine\block;
use pocketmine\item\Item; use pocketmine\item\Item;
class Gravel extends Fallable{ class Gravel extends Fallable{
protected $id = self::GRAVEL;
public function __construct(){ public function __construct(){
parent::__construct(self::GRAVEL, 0, "Gravel");
$this->hardness = 3; }
public function getName(){
return "Gravel";
}
public function getHardness(){
return 3;
} }
public function getDrops(Item $item){ public function getDrops(Item $item){

View File

@ -24,9 +24,19 @@ namespace pocketmine\block;
use pocketmine\item\Item; use pocketmine\item\Item;
class HardenedClay extends Solid{ class HardenedClay extends Solid{
protected $id = self::HARDENED_CLAY;
public function __construct(){ public function __construct(){
parent::__construct(self::HARDENED_CLAY, 0, "Hardened Clay");
$this->hardness = 30; }
public function getName(){
return "Hardened Clay";
}
public function getHardness(){
return 30;
} }
public function getBreakTime(Item $item){ public function getBreakTime(Item $item){

View File

@ -25,9 +25,19 @@ use pocketmine\item\Item;
use pocketmine\Player; use pocketmine\Player;
class HayBale extends Solid{ class HayBale extends Solid{
protected $id = self::HAY_BALE;
public function __construct($meta = 0){ public function __construct($meta = 0){
parent::__construct(self::HAY_BALE, $meta, "Hay Bale"); $this->meta = $meta;
$this->hardness = 10; }
public function getName(){
return "Hay Bale";
}
public function getHardness(){
return 10;
} }
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){ public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){

View File

@ -24,9 +24,19 @@ namespace pocketmine\block;
use pocketmine\item\Item; use pocketmine\item\Item;
class Ice extends Transparent{ class Ice extends Transparent{
protected $id = self::ICE;
public function __construct(){ public function __construct(){
parent::__construct(self::ICE, 0, "Ice");
$this->hardness = 2.5; }
public function getName(){
return "Ice";
}
public function getHardness(){
return 2.5;
} }
public function onBreak(Item $item){ public function onBreak(Item $item){

View File

@ -24,9 +24,19 @@ namespace pocketmine\block;
use pocketmine\item\Item; use pocketmine\item\Item;
class Iron extends Solid{ class Iron extends Solid{
protected $id = self::IRON_BLOCK;
public function __construct(){ public function __construct(){
parent::__construct(self::IRON_BLOCK, 0, "Iron Block");
$this->hardness = 30; }
public function getName(){
return "Iron Block";
}
public function getHardness(){
return 30;
} }
public function getBreakTime(Item $item){ public function getBreakTime(Item $item){

View File

@ -21,10 +21,49 @@
namespace pocketmine\block; namespace pocketmine\block;
use pocketmine\item\Item;
class IronBars extends Thin{ class IronBars extends Thin{
protected $id = self::IRON_BARS;
public function __construct(){ public function __construct(){
parent::__construct(self::IRON_BARS, 0, "Iron Bars");
} }
} public function getName(){
return "Iron Bars";
}
public function getHardness(){
return 5;
}
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 5;
}
}
public function getDrops(Item $item){
if($item->isPickaxe() >= 1){
return [
[Item::IRON_BARS, 0, 1],
];
}else{
return [];
}
}
}

View File

@ -24,10 +24,19 @@ namespace pocketmine\block;
use pocketmine\item\Item; use pocketmine\item\Item;
class IronDoor extends Door{ class IronDoor extends Door{
protected $id = self::IRON_DOOR_BLOCK;
public function __construct($meta = 0){ public function __construct($meta = 0){
parent::__construct(self::IRON_DOOR_BLOCK, $meta, "Iron Door Block"); $this->meta = $meta;
//$this->isActivable = true; }
$this->hardness = 25;
public function getName(){
return "Iron Door Block";
}
public function getHardness(){
return 25;
} }
public function getBreakTime(Item $item){ public function getBreakTime(Item $item){

View File

@ -24,9 +24,19 @@ namespace pocketmine\block;
use pocketmine\item\Item; use pocketmine\item\Item;
class IronOre extends Solid{ class IronOre extends Solid{
protected $id = self::IRON_ORE;
public function __construct(){ public function __construct(){
parent::__construct(self::IRON_ORE, 0, "Iron Ore");
$this->hardness = 15; }
public function getName(){
return "Iron Ore";
}
public function getHardness(){
return 15;
} }
public function getBreakTime(Item $item){ public function getBreakTime(Item $item){

View File

@ -24,8 +24,15 @@ namespace pocketmine\block;
use pocketmine\item\Item; use pocketmine\item\Item;
class JungleWoodStairs extends Stair{ class JungleWoodStairs extends Stair{
protected $id = self::JUNGLE_WOOD_STAIRS;
public function __construct($meta = 0){ public function __construct($meta = 0){
parent::__construct(self::JUNGLE_WOOD_STAIRS, $meta, "Jungle Wood Stairs"); $this->meta = $meta;
}
public function getName(){
return "Jungle Wood Stairs";
} }
public function getDrops(Item $item){ public function getDrops(Item $item){

View File

@ -29,29 +29,39 @@ use pocketmine\Player;
class Ladder extends Transparent{ class Ladder extends Transparent{
public $hasEntityCollision = true; protected $id = self::LADDER;
public function __construct($meta = 0){ public function __construct($meta = 0){
parent::__construct(self::LADDER, $meta, "Ladder"); $this->meta = $meta;
$this->isSolid = false; }
$this->isFullBlock = false;
$this->hardness = 2; public function getName(){
return "Ladder";
}
public function hasEntityCollision(){
return true;
}
public function isSolid(){
return false;
}
public function getHardness(){
return 2;
} }
public function onEntityCollide(Entity $entity){ public function onEntityCollide(Entity $entity){
$entity->fallDistance = 0; $entity->resetFallDistance();
$entity->onGround = true; $entity->onGround = true;
} }
public function getBoundingBox(){ protected function recalculateBoundingBox(){
if($this->boundingBox !== null){
return $this->boundingBox;
}
$f = 0.125; $f = 0.125;
if($this->meta === 2){ if($this->meta === 2){
return $this->boundingBox = new AxisAlignedBB( return new AxisAlignedBB(
$this->x, $this->x,
$this->y, $this->y,
$this->z + 1 - $f, $this->z + 1 - $f,
@ -60,7 +70,7 @@ class Ladder extends Transparent{
$this->z + 1 $this->z + 1
); );
}elseif($this->meta === 3){ }elseif($this->meta === 3){
return $this->boundingBox = new AxisAlignedBB( return new AxisAlignedBB(
$this->x, $this->x,
$this->y, $this->y,
$this->z, $this->z,
@ -69,7 +79,7 @@ class Ladder extends Transparent{
$this->z + $f $this->z + $f
); );
}elseif($this->meta === 4){ }elseif($this->meta === 4){
return $this->boundingBox = new AxisAlignedBB( return new AxisAlignedBB(
$this->x + 1 - $f, $this->x + 1 - $f,
$this->y, $this->y,
$this->z, $this->z,
@ -78,7 +88,7 @@ class Ladder extends Transparent{
$this->z + 1 $this->z + 1
); );
}elseif($this->meta === 5){ }elseif($this->meta === 5){
return $this->boundingBox = new AxisAlignedBB( return new AxisAlignedBB(
$this->x, $this->x,
$this->y, $this->y,
$this->z, $this->z,
@ -93,7 +103,7 @@ class Ladder extends Transparent{
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){ public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){
if($target->isTransparent === false){ if($target->isTransparent() === false){
$faces = [ $faces = [
2 => 2, 2 => 2,
3 => 3, 3 => 3,
@ -113,7 +123,7 @@ class Ladder extends Transparent{
public function onUpdate($type){ public function onUpdate($type){
if($type === Level::BLOCK_UPDATE_NORMAL){ if($type === Level::BLOCK_UPDATE_NORMAL){
/*if($this->getSide(0)->getID() === self::AIR){ //Replace with common break method /*if($this->getSide(0)->getId() === self::AIR){ //Replace with common break method
Server::getInstance()->api->entity->drop($this, Item::get(LADDER, 0, 1)); Server::getInstance()->api->entity->drop($this, Item::get(LADDER, 0, 1));
$this->getLevel()->setBlock($this, new Air(), true, true, true); $this->getLevel()->setBlock($this, new Air(), true, true, true);
return Level::BLOCK_UPDATE_NORMAL; return Level::BLOCK_UPDATE_NORMAL;

View File

@ -24,9 +24,19 @@ namespace pocketmine\block;
use pocketmine\item\Item; use pocketmine\item\Item;
class Lapis extends Solid{ class Lapis extends Solid{
protected $id = self::LAPIS_BLOCK;
public function __construct(){ public function __construct(){
parent::__construct(self::LAPIS_BLOCK, 0, "Lapis Block");
$this->hardness = 15; }
public function getName(){
return "Lapis Block";
}
public function getHardness(){
return 15;
} }
public function getBreakTime(Item $item){ public function getBreakTime(Item $item){

View File

@ -24,9 +24,19 @@ namespace pocketmine\block;
use pocketmine\item\Item; use pocketmine\item\Item;
class LapisOre extends Solid{ class LapisOre extends Solid{
protected $id = self::LAPIS_ORE;
public function __construct(){ public function __construct(){
parent::__construct(self::LAPIS_ORE, 0, "Lapis Ore");
$this->hardness = 15; }
public function getHardness(){
return 15;
}
public function getName(){
return "Lapis Ore";
} }
public function getBreakTime(Item $item){ public function getBreakTime(Item $item){

View File

@ -2,11 +2,11 @@
/* /*
* *
* ____ _ _ __ __ _ __ __ ____ * ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \ * | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) | * | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/ * | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_| * |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU Lesser General Public License as published by
@ -15,7 +15,7 @@
* *
* @author PocketMine Team * @author PocketMine Team
* @link http://www.pocketmine.net/ * @link http://www.pocketmine.net/
* *
* *
*/ */
@ -25,30 +25,53 @@ use pocketmine\entity\Entity;
use pocketmine\event\entity\EntityCombustByBlockEvent; use pocketmine\event\entity\EntityCombustByBlockEvent;
use pocketmine\event\entity\EntityDamageByBlockEvent; use pocketmine\event\entity\EntityDamageByBlockEvent;
use pocketmine\event\entity\EntityDamageEvent; use pocketmine\event\entity\EntityDamageEvent;
use pocketmine\inventory\InventoryHolder;
use pocketmine\inventory\PlayerInventory;
use pocketmine\item\Item; use pocketmine\item\Item;
use pocketmine\Player; use pocketmine\Player;
use pocketmine\Server; use pocketmine\Server;
class Lava extends Liquid{ class Lava extends Liquid{
protected $id = self::LAVA;
public function __construct($meta = 0){ public function __construct($meta = 0){
parent::__construct(self::LAVA, $meta, "Lava"); $this->meta = $meta;
$this->hardness = 0; }
public function getLightLevel(){
return 15;
}
public function getName(){
return "Lava";
}
public function getHardness(){
return 0;
} }
public function onEntityCollide(Entity $entity){ public function onEntityCollide(Entity $entity){
$entity->fallDistance *= 0.5; $entity->fallDistance *= 0.5;
$ev = new EntityDamageByBlockEvent($this, $entity, EntityDamageEvent::CAUSE_LAVA, 4); $damage = [EntityDamageEvent::MODIFIER_BASE => 1];
Server::getInstance()->getPluginManager()->callEvent($ev); if($entity instanceof InventoryHolder){
if(!$ev->isCancelled()){ $inventory = $entity->getInventory();
$entity->attack($ev->getFinalDamage(), $ev); if($inventory instanceof PlayerInventory){
$damage[EntityDamageEvent::MODIFIER_ARMOR] = $inventory->getArmorPoints();
}
} }
$ev = new EntityDamageByBlockEvent($this, $entity, EntityDamageEvent::CAUSE_LAVA, $damage);
$entity->attack($ev->getFinalDamage(), $ev);
$ev = new EntityCombustByBlockEvent($this, $entity, 15); $ev = new EntityCombustByBlockEvent($this, $entity, 15);
Server::getInstance()->getPluginManager()->callEvent($ev); Server::getInstance()->getPluginManager()->callEvent($ev);
if(!$ev->isCancelled()){ if(!$ev->isCancelled()){
$entity->setOnFire($ev->getDuration()); $entity->setOnFire($ev->getDuration());
} }
if($entity instanceof Player){
$entity->onGround = true;
}
} }
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){ public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){

View File

@ -35,16 +35,24 @@ class Leaves extends Transparent{
const ACACIA = 0; const ACACIA = 0;
const DARK_OAK = 1; const DARK_OAK = 1;
protected $id = self::LEAVES;
public function __construct($meta = 0){ public function __construct($meta = 0){
parent::__construct(self::LEAVES, $meta, "Leaves"); $this->meta = $meta;
$names = [ }
public function getHardness(){
return 1;
}
public function getName(){
static $names = [
self::OAK => "Oak Leaves", self::OAK => "Oak Leaves",
self::SPRUCE => "Spruce Leaves", self::SPRUCE => "Spruce Leaves",
self::BIRCH => "Birch Leaves", self::BIRCH => "Birch Leaves",
self::JUNGLE => "Jungle Leaves", self::JUNGLE => "Jungle Leaves",
]; ];
$this->name = $names[$this->meta & 0x03]; return $names[$this->meta & 0x03];
$this->hardness = 1;
} }
private function findLog(Block $pos, array $visited, $distance, &$check, $fromSide = null){ private function findLog(Block $pos, array $visited, $distance, &$check, $fromSide = null){
@ -53,11 +61,11 @@ class Leaves extends Transparent{
if(isset($visited[$index])){ if(isset($visited[$index])){
return false; return false;
} }
if($pos->getID() === self::WOOD){ if($pos->getId() === self::WOOD){
return true; return true;
}elseif($pos->getID() === self::LEAVES and $distance < 3){ }elseif($pos->getId() === self::LEAVES and $distance < 3){
$visited[$index] = true; $visited[$index] = true;
$down = $pos->getSide(0)->getID(); $down = $pos->getSide(0)->getId();
if($down === Item::WOOD){ if($down === Item::WOOD){
return true; return true;
} }

View File

@ -29,14 +29,18 @@ use pocketmine\Server;
class Leaves2 extends Leaves{ class Leaves2 extends Leaves{
protected $id = self::LEAVES2;
public function __construct($meta = 0){ public function __construct($meta = 0){
Transparent::__construct(self::LEAVES, $meta, "Leaves"); $this->meta = $meta;
$names = [ }
public function getName(){
static $names = [
self::ACACIA => "Acacia Leaves", self::ACACIA => "Acacia Leaves",
self::DARK_OAK => "Dark Oak Leaves", self::DARK_OAK => "Dark Oak Leaves",
]; ];
$this->name = $names[$this->meta & 0x03]; return $names[$this->meta & 0x01];
$this->hardness = 1;
} }
private function findLog(Block $pos, array $visited, $distance, &$check, $fromSide = null){ private function findLog(Block $pos, array $visited, $distance, &$check, $fromSide = null){
@ -45,11 +49,11 @@ class Leaves2 extends Leaves{
if(isset($visited[$index])){ if(isset($visited[$index])){
return false; return false;
} }
if($pos->getID() === self::WOOD2){ if($pos->getId() === self::WOOD2){
return true; return true;
}elseif($pos->getID() === self::LEAVES2 and $distance < 3){ }elseif($pos->getId() === self::LEAVES2 and $distance < 3){
$visited[$index] = true; $visited[$index] = true;
$down = $pos->getSide(0)->getID(); $down = $pos->getSide(0)->getId();
if($down === Item::WOOD2){ if($down === Item::WOOD2){
return true; return true;
} }

View File

@ -28,13 +28,25 @@ use pocketmine\level\Level;
use pocketmine\math\Vector3; use pocketmine\math\Vector3;
abstract class Liquid extends Transparent{ abstract class Liquid extends Transparent{
public $hasEntityCollision = true;
public $isLiquid = true; /** @var Vector3 */
public $breakable = false; private $temporalVector = null;
public $isReplaceable = true;
public $isSolid = false; public function hasEntityCollision(){
public $isFullBlock = true; return true;
}
public function isBreakable(Item $item){
return false;
}
public function canBeReplaced(){
return true;
}
public function isSolid(){
return false;
}
public $adjacentSources = 0; public $adjacentSources = 0;
public $isOptimalFlowDirection = [0, 0, 0, 0]; public $isOptimalFlowDirection = [0, 0, 0, 0];
@ -54,7 +66,7 @@ abstract class Liquid extends Transparent{
$pos = $this->getLevel()->getBlock($pos); $pos = $this->getLevel()->getBlock($pos);
} }
if($pos->getID() !== $this->getID()){ if($pos->getId() !== $this->getId()){
return -1; return -1;
}else{ }else{
return $pos->getDamage(); return $pos->getDamage();
@ -66,7 +78,7 @@ abstract class Liquid extends Transparent{
$pos = $this->getLevel()->getBlock($pos); $pos = $this->getLevel()->getBlock($pos);
} }
if($pos->getID() !== $this->getID()){ if($pos->getId() !== $this->getId()){
return -1; return -1;
} }
@ -82,6 +94,10 @@ abstract class Liquid extends Transparent{
public function getFlowVector(){ public function getFlowVector(){
$vector = new Vector3(0, 0, 0); $vector = new Vector3(0, 0, 0);
if($this->temporalVector === null){
$this->temporalVector = new Vector3(0, 0, 0);
}
$decay = $this->getEffectiveFlowDecay($this); $decay = $this->getEffectiveFlowDecay($this);
for($j = 0; $j < 4; ++$j){ for($j = 0; $j < 4; ++$j){
@ -99,46 +115,50 @@ abstract class Liquid extends Transparent{
}elseif($j === 3){ }elseif($j === 3){
++$z; ++$z;
} }
$sideBlock = $this->getLevel()->getBlock(new Vector3($x, $y, $z)); $sideBlock = $this->getLevel()->getBlock($this->temporalVector->setComponents($x, $y, $z));
$blockDecay = $this->getEffectiveFlowDecay($sideBlock); $blockDecay = $this->getEffectiveFlowDecay($sideBlock);
if($blockDecay < 0){ if($blockDecay < 0){
if(!$sideBlock->isFlowable){ if(!$sideBlock->canBeFlowedInto()){
continue; continue;
} }
$blockDecay = $this->getEffectiveFlowDecay($sideBlock->getSide(0)); $blockDecay = $this->getEffectiveFlowDecay($this->getLevel()->getBlock($this->temporalVector->setComponents($x, $y - 1, $z)));
if($blockDecay >= 0){ if($blockDecay >= 0){
$realDecay = $blockDecay - ($decay - 8); $realDecay = $blockDecay - ($decay - 8);
$vector = $vector->add(($sideBlock->x - $this->x) * $realDecay, ($sideBlock->y - $this->y) * $realDecay, ($sideBlock->z - $this->z) * $realDecay); $vector->x += ($sideBlock->x - $this->x) * $realDecay;
$vector->y += ($sideBlock->y - $this->y) * $realDecay;
$vector->z += ($sideBlock->z - $this->z) * $realDecay;
} }
continue; continue;
}else{ }else{
$realDecay = $blockDecay - $decay; $realDecay = $blockDecay - $decay;
$vector = $vector->add(($sideBlock->x - $this->x) * $realDecay, ($sideBlock->y - $this->y) * $realDecay, ($sideBlock->z - $this->z) * $realDecay); $vector->x += ($sideBlock->x - $this->x) * $realDecay;
$vector->y += ($sideBlock->y - $this->y) * $realDecay;
$vector->z += ($sideBlock->z - $this->z) * $realDecay;
} }
} }
if($this->getDamage() >= 8){ if($this->getDamage() >= 8){
$falling = false; $falling = false;
if(!$this->getLevel()->getBlock($this->add(0, 0, -1))->isFlowable){ if(!$this->getLevel()->getBlock($this->temporalVector->setComponents($this->x, $this->y, $this->z - 1))->canBeFlowedInto()){
$falling = true; $falling = true;
}elseif(!$this->getLevel()->getBlock($this->add(0, 0, 1))->isFlowable){ }elseif(!$this->getLevel()->getBlock($this->temporalVector->setComponents($this->x, $this->y, $this->z + 1))->canBeFlowedInto()){
$falling = true; $falling = true;
}elseif(!$this->getLevel()->getBlock($this->add(-1, 0, 0))->isFlowable){ }elseif(!$this->getLevel()->getBlock($this->temporalVector->setComponents($this->x - 1, $this->y, $this->z))->canBeFlowedInto()){
$falling = true; $falling = true;
}elseif(!$this->getLevel()->getBlock($this->add(1, 0, 0))->isFlowable){ }elseif(!$this->getLevel()->getBlock($this->temporalVector->setComponents($this->x + 1, $this->y, $this->z))->canBeFlowedInto()){
$falling = true; $falling = true;
}elseif(!$this->getLevel()->getBlock($this->add(0, 1, -1))->isFlowable){ }elseif(!$this->getLevel()->getBlock($this->temporalVector->setComponents($this->x, $this->y + 1, $this->z - 1))->canBeFlowedInto()){
$falling = true; $falling = true;
}elseif(!$this->getLevel()->getBlock($this->add(0, 1, 1))->isFlowable){ }elseif(!$this->getLevel()->getBlock($this->temporalVector->setComponents($this->x, $this->y + 1, $this->z + 1))->canBeFlowedInto()){
$falling = true; $falling = true;
}elseif(!$this->getLevel()->getBlock($this->add(-1, 1, 0))->isFlowable){ }elseif(!$this->getLevel()->getBlock($this->temporalVector->setComponents($this->x - 1, $this->y + 1, $this->z))->canBeFlowedInto()){
$falling = true; $falling = true;
}elseif(!$this->getLevel()->getBlock($this->add(1, 1, 0))->isFlowable){ }elseif(!$this->getLevel()->getBlock($this->temporalVector->setComponents($this->x + 1, $this->y + 1, $this->z))->canBeFlowedInto()){
$falling = true; $falling = true;
} }
@ -172,6 +192,10 @@ abstract class Liquid extends Transparent{
$this->checkForHarden(); $this->checkForHarden();
$this->getLevel()->scheduleUpdate($this, $this->tickRate()); $this->getLevel()->scheduleUpdate($this, $this->tickRate());
}elseif($type === Level::BLOCK_UPDATE_SCHEDULED){ }elseif($type === Level::BLOCK_UPDATE_SCHEDULED){
if($this->temporalVector === null){
$this->temporalVector = new Vector3(0, 0, 0);
}
$decay = $this->getFlowDecay($this); $decay = $this->getFlowDecay($this);
$multiplier = $this instanceof Lava ? 2 : 1; $multiplier = $this instanceof Lava ? 2 : 1;
@ -180,10 +204,10 @@ abstract class Liquid extends Transparent{
if($decay > 0){ if($decay > 0){
$smallestFlowDecay = -100; $smallestFlowDecay = -100;
$this->adjacentSources = 0; $this->adjacentSources = 0;
$smallestFlowDecay = $this->getSmallestFlowDecay($this->getSide(4), $smallestFlowDecay); $smallestFlowDecay = $this->getSmallestFlowDecay($this->level->getBlock($this->temporalVector->setComponents($this->x, $this->y, $this->z - 1)), $smallestFlowDecay);
$smallestFlowDecay = $this->getSmallestFlowDecay($this->getSide(5), $smallestFlowDecay); $smallestFlowDecay = $this->getSmallestFlowDecay($this->level->getBlock($this->temporalVector->setComponents($this->x, $this->y, $this->z + 1)), $smallestFlowDecay);
$smallestFlowDecay = $this->getSmallestFlowDecay($this->getSide(2), $smallestFlowDecay); $smallestFlowDecay = $this->getSmallestFlowDecay($this->level->getBlock($this->temporalVector->setComponents($this->x - 1, $this->y, $this->z)), $smallestFlowDecay);
$smallestFlowDecay = $this->getSmallestFlowDecay($this->getSide(3), $smallestFlowDecay); $smallestFlowDecay = $this->getSmallestFlowDecay($this->level->getBlock($this->temporalVector->setComponents($this->x + 1, $this->y, $this->z)), $smallestFlowDecay);
$k = $smallestFlowDecay + $multiplier; $k = $smallestFlowDecay + $multiplier;
@ -191,7 +215,7 @@ abstract class Liquid extends Transparent{
$k = -1; $k = -1;
} }
if(($topFlowDecay = $this->getFlowDecay($this->getSide(1))) >= 0){ if(($topFlowDecay = $this->getFlowDecay($this->level->getBlock($this->level->getBlock($this->temporalVector->setComponents($this->x, $this->y + 1, $this->z))))) >= 0){
if($topFlowDecay >= 8){ if($topFlowDecay >= 8){
$k = $topFlowDecay; $k = $topFlowDecay;
}else{ }else{
@ -200,8 +224,8 @@ abstract class Liquid extends Transparent{
} }
if($this->adjacentSources >= 2 and $this instanceof Water){ if($this->adjacentSources >= 2 and $this instanceof Water){
$bottomBlock = $this->getSide(0); $bottomBlock = $this->level->getBlock($this->level->getBlock($this->temporalVector->setComponents($this->x, $this->y - 1, $this->z)));
if($bottomBlock->isSolid){ if($bottomBlock->isSolid()){
$k = 0; $k = 0;
}elseif($bottomBlock instanceof Water and $bottomBlock->getDamage() === 0){ }elseif($bottomBlock instanceof Water and $bottomBlock->getDamage() === 0){
$k = 0; $k = 0;
@ -216,7 +240,7 @@ abstract class Liquid extends Transparent{
if($k !== $decay){ if($k !== $decay){
$decay = $k; $decay = $k;
if($decay < 0){ if($decay < 0){
$this->getLevel()->setBlock($this, Block::get(Item::AIR), true); $this->getLevel()->setBlock($this, new Air(), true);
}else{ }else{
$this->getLevel()->setBlock($this, Block::get($this->id, $decay), true); $this->getLevel()->setBlock($this, Block::get($this->id, $decay), true);
$this->getLevel()->scheduleUpdate($this, $this->tickRate()); $this->getLevel()->scheduleUpdate($this, $this->tickRate());
@ -229,9 +253,9 @@ abstract class Liquid extends Transparent{
//$this->updateFlow(); //$this->updateFlow();
} }
$bottomBlock = $this->getSide(0); $bottomBlock = $this->level->getBlock($this->temporalVector->setComponents($this->x, $this->y - 1, $this->z));
if($bottomBlock->isFlowable or $bottomBlock instanceof Liquid){ if($bottomBlock->canBeFlowedInto() or $bottomBlock instanceof Liquid){
if($this instanceof Lava and $bottomBlock instanceof Water){ if($this instanceof Lava and $bottomBlock instanceof Water){
$this->getLevel()->setBlock($bottomBlock, Block::get(Item::STONE), true); $this->getLevel()->setBlock($bottomBlock, Block::get(Item::STONE), true);
return; return;
@ -244,7 +268,7 @@ abstract class Liquid extends Transparent{
$this->getLevel()->setBlock($bottomBlock, Block::get($this->id, $decay + 8), true); $this->getLevel()->setBlock($bottomBlock, Block::get($this->id, $decay + 8), true);
$this->getLevel()->scheduleUpdate($bottomBlock, $this->tickRate()); $this->getLevel()->scheduleUpdate($bottomBlock, $this->tickRate());
} }
}elseif($decay >= 0 and ($decay === 0 or !$bottomBlock->isFlowable)){ }elseif($decay >= 0 and ($decay === 0 or !$bottomBlock->canBeFlowedInto())){
$flags = $this->getOptimalFlowDirections(); $flags = $this->getOptimalFlowDirections();
$l = $decay + $multiplier; $l = $decay + $multiplier;
@ -259,19 +283,19 @@ abstract class Liquid extends Transparent{
} }
if($flags[0]){ if($flags[0]){
$this->flowIntoBlock($this->getSide(4), $l); $this->flowIntoBlock($this->level->getBlock($this->temporalVector->setComponents($this->x - 1, $this->y, $this->z)), $l);
} }
if($flags[1]){ if($flags[1]){
$this->flowIntoBlock($this->getSide(5), $l); $this->flowIntoBlock($this->level->getBlock($this->temporalVector->setComponents($this->x + 1, $this->y, $this->z)), $l);
} }
if($flags[2]){ if($flags[2]){
$this->flowIntoBlock($this->getSide(2), $l); $this->flowIntoBlock($this->level->getBlock($this->temporalVector->setComponents($this->x, $this->y, $this->z - 1)), $l);
} }
if($flags[3]){ if($flags[3]){
$this->flowIntoBlock($this->getSide(3), $l); $this->flowIntoBlock($this->level->getBlock($this->temporalVector->setComponents($this->x, $this->y, $this->z + 1)), $l);
} }
} }
@ -281,8 +305,8 @@ abstract class Liquid extends Transparent{
} }
private function flowIntoBlock(Block $block, $newFlowDecay){ private function flowIntoBlock(Block $block, $newFlowDecay){
if($block->isFlowable){ if($block->canBeFlowedInto()){
if($block->getID() > 0){ if($block->getId() > 0){
$this->getLevel()->useBreakOn($block); $this->getLevel()->useBreakOn($block);
} }
@ -314,13 +338,13 @@ abstract class Liquid extends Transparent{
}elseif($j === 3){ }elseif($j === 3){
++$z; ++$z;
} }
$blockSide = $this->getLevel()->getBlock(new Vector3($x, $y, $z)); $blockSide = $this->getLevel()->getBlock($this->temporalVector->setComponents($x, $y, $z));
if(!$blockSide->isFlowable and !($blockSide instanceof Liquid)){ if(!$blockSide->canBeFlowedInto() and !($blockSide instanceof Liquid)){
continue; continue;
}elseif($blockSide instanceof Liquid and $blockSide->getDamage() === 0){ }elseif($blockSide instanceof Liquid and $blockSide->getDamage() === 0){
continue; continue;
}elseif($blockSide->getSide(0)->isFlowable){ }elseif($this->getLevel()->getBlock($this->temporalVector->setComponents($x, $y - 1, $z))->canBeFlowedInto()){
return $accumulatedCost; return $accumulatedCost;
} }
@ -340,6 +364,10 @@ abstract class Liquid extends Transparent{
} }
private function getOptimalFlowDirections(){ private function getOptimalFlowDirections(){
if($this->temporalVector === null){
$this->temporalVector = new Vector3(0, 0, 0);
}
for($j = 0; $j < 4; ++$j){ for($j = 0; $j < 4; ++$j){
$this->flowCost[$j] = 1000; $this->flowCost[$j] = 1000;
@ -356,13 +384,13 @@ abstract class Liquid extends Transparent{
}elseif($j === 3){ }elseif($j === 3){
++$z; ++$z;
} }
$block = $this->getLevel()->getBlock(new Vector3($x, $y, $z)); $block = $this->getLevel()->getBlock($this->temporalVector->setComponents($x, $y, $z));
if(!$block->isFlowable and !($block instanceof Liquid)){ if(!$block->canBeFlowedInto() and !($block instanceof Liquid)){
continue; continue;
}elseif($block instanceof Liquid and $block->getDamage() === 0){ }elseif($block instanceof Liquid and $block->getDamage() === 0){
continue; continue;
}elseif($block->getSide(0)->isFlowable){ }elseif($this->getLevel()->getBlock($this->temporalVector->setComponents($x, $y - 1, $z))->canBeFlowedInto()){
$this->flowCost[$j] = 0; $this->flowCost[$j] = 0;
}else{ }else{
$this->flowCost[$j] = $this->calculateFlowCost($block, 1, $j); $this->flowCost[$j] = $this->calculateFlowCost($block, 1, $j);

View File

@ -25,9 +25,23 @@ use pocketmine\item\Item;
use pocketmine\Player; use pocketmine\Player;
class LitPumpkin extends Solid{ class LitPumpkin extends Solid{
public function __construct(){
parent::__construct(self::LIT_PUMPKIN, "Jack o'Lantern"); protected $id = self::LIT_PUMPKIN;
$this->hardness = 5;
public function getLightLevel(){
return 15;
}
public function getHardness(){
return 5;
}
public function getName(){
return "Jack o'Lantern";
}
public function __construct($meta = 0){
$this->meta = $meta;
} }
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){ public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){

View File

@ -24,9 +24,19 @@ namespace pocketmine\block;
use pocketmine\item\Item; use pocketmine\item\Item;
class Melon extends Transparent{ class Melon extends Transparent{
protected $id = self::MELON_BLOCK;
public function __construct(){ public function __construct(){
parent::__construct(self::MELON_BLOCK, 0, "Melon Block");
$this->hardness = 5; }
public function getName(){
return "Melon Block";
}
public function getHardness(){
return 5;
} }
public function getDrops(Item $item){ public function getDrops(Item $item){

View File

@ -27,13 +27,20 @@ use pocketmine\level\Level;
use pocketmine\Server; use pocketmine\Server;
class MelonStem extends Crops{ class MelonStem extends Crops{
protected $id = self::MELON_STEM;
public function getName(){
return "Melon Stem";
}
public function __construct($meta = 0){ public function __construct($meta = 0){
parent::__construct(self::MELON_STEM, $meta, "Melon Stem"); $this->meta = $meta;
} }
public function onUpdate($type){ public function onUpdate($type){
if($type === Level::BLOCK_UPDATE_NORMAL){ if($type === Level::BLOCK_UPDATE_NORMAL){
if($this->getSide(0)->isTransparent === true){ if($this->getSide(0)->isTransparent() === true){
$this->getLevel()->useBreakOn($this); $this->getLevel()->useBreakOn($this);
return Level::BLOCK_UPDATE_NORMAL; return Level::BLOCK_UPDATE_NORMAL;
} }
@ -51,13 +58,13 @@ class MelonStem extends Crops{
}else{ }else{
for($side = 2; $side <= 5; ++$side){ for($side = 2; $side <= 5; ++$side){
$b = $this->getSide($side); $b = $this->getSide($side);
if($b->getID() === self::MELON_BLOCK){ if($b->getId() === self::MELON_BLOCK){
return Level::BLOCK_UPDATE_RANDOM; return Level::BLOCK_UPDATE_RANDOM;
} }
} }
$side = $this->getSide(mt_rand(2, 5)); $side = $this->getSide(mt_rand(2, 5));
$d = $side->getSide(0); $d = $side->getSide(0);
if($side->getID() === self::AIR and ($d->getID() === self::FARMLAND or $d->getID() === self::GRASS or $d->getID() === self::DIRT)){ if($side->getId() === self::AIR and ($d->getId() === self::FARMLAND or $d->getId() === self::GRASS or $d->getId() === self::DIRT)){
Server::getInstance()->getPluginManager()->callEvent($ev = new BlockGrowEvent($side, new Melon())); Server::getInstance()->getPluginManager()->callEvent($ev = new BlockGrowEvent($side, new Melon()));
if(!$ev->isCancelled()){ if(!$ev->isCancelled()){
$this->getLevel()->setBlock($side, $ev->getNewState(), true); $this->getLevel()->setBlock($side, $ev->getNewState(), true);

View File

@ -24,29 +24,39 @@ namespace pocketmine\block;
use pocketmine\item\Item; use pocketmine\item\Item;
class MonsterSpawner extends Solid{ class MonsterSpawner extends Solid{
public function __construct(){
parent::__construct(self::MONSTER_SPAWNER, 0, "Monster Spawner"); protected $id = self::MONSTER_SPAWNER;
$this->hardness = 25;
public function __construct($meta = 0){
$this->meta = $meta;
} }
public function getBreakTime(Item $item){ public function getHardness(){
switch($item->isPickaxe()){ return 25;
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 getDrops(Item $item){ public function getName(){
return []; return "Monster Spawner";
} }
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 getDrops(Item $item){
return [];
}
} }

View File

@ -24,9 +24,19 @@ namespace pocketmine\block;
use pocketmine\item\Item; use pocketmine\item\Item;
class MossStone extends Solid{ class MossStone extends Solid{
protected $id = self::MOSS_STONE;
public function __construct($meta = 0){ public function __construct($meta = 0){
parent::__construct(self::MOSS_STONE, $meta, "Moss Stone"); $this->meta = $meta;
$this->hardness = 30; }
public function getName(){
return "Moss Stone";
}
public function getHardness(){
return 30;
} }
public function getBreakTime(Item $item){ public function getBreakTime(Item $item){

View File

@ -24,13 +24,23 @@ namespace pocketmine\block;
use pocketmine\event\block\BlockSpreadEvent; use pocketmine\event\block\BlockSpreadEvent;
use pocketmine\item\Item; use pocketmine\item\Item;
use pocketmine\level\Level; use pocketmine\level\Level;
use pocketmine\level\Position; use pocketmine\math\Vector3;
use pocketmine\Server; use pocketmine\Server;
class Mycelium extends Solid{ class Mycelium extends Solid{
protected $id = self::MYCELIUM;
public function __construct(){ public function __construct(){
parent::__construct(self::MYCELIUM, 0, "Mycelium");
$this->hardness = 2.5; }
public function getName(){
return "Mycelium";
}
public function getHardness(){
return 2.5;
} }
public function getDrops(Item $item){ public function getDrops(Item $item){
@ -45,9 +55,8 @@ class Mycelium extends Solid{
$x = mt_rand($this->x - 1, $this->x + 1); $x = mt_rand($this->x - 1, $this->x + 1);
$y = mt_rand($this->y - 2, $this->y + 2); $y = mt_rand($this->y - 2, $this->y + 2);
$z = mt_rand($this->z - 1, $this->z + 1); $z = mt_rand($this->z - 1, $this->z + 1);
$block = $this->getLevel()->getBlockIdAt($x, $y, $z); $block = $this->getLevel()->getBlock(new Vector3($x, $y, $z));
if($block === Block::DIRT){ if($block->getId() === Block::DIRT){
$block = Block::get($block, $this->getLevel()->getBlockDataAt($x, $y, $z), new Position($x, $y, $z, $this->getLevel()));
if($block->getSide(1) instanceof Transparent){ if($block->getSide(1) instanceof Transparent){
Server::getInstance()->getPluginManager()->callEvent($ev = new BlockSpreadEvent($block, $this, new Mycelium())); Server::getInstance()->getPluginManager()->callEvent($ev = new BlockSpreadEvent($block, $this, new Mycelium()));
if(!$ev->isCancelled()){ if(!$ev->isCancelled()){

View File

@ -24,9 +24,19 @@ namespace pocketmine\block;
use pocketmine\item\Item; use pocketmine\item\Item;
class NetherBrick extends Solid{ class NetherBrick extends Solid{
protected $id = self::NETHER_BRICKS;
public function __construct(){ public function __construct(){
parent::__construct(self::NETHER_BRICKS, 0, "Nether Bricks");
$this->hardness = 30; }
public function getName(){
return "Nether Bricks";
}
public function getHardness(){
return 30;
} }
public function getBreakTime(Item $item){ public function getBreakTime(Item $item){

View File

@ -23,8 +23,15 @@ namespace pocketmine\block;
class NetherBrickStairs extends Stair{ class NetherBrickStairs extends Stair{
protected $id = self::NETHER_BRICKS_STAIRS;
public function getName(){
return "Nether Bricks Stairs";
}
public function __construct($meta = 0){ public function __construct($meta = 0){
parent::__construct(self::NETHER_BRICKS_STAIRS, $meta, "Nether Bricks Stairs"); $this->meta = $meta;
} }
} }

View File

@ -23,9 +23,19 @@ namespace pocketmine\block;
class NetherReactor extends Solid{ class NetherReactor extends Solid{
protected $id = self::NETHER_REACTOR;
public function __construct($meta = 0){ public function __construct($meta = 0){
parent::__construct(self::NETHER_REACTOR, $meta, "Nether Reactor"); $this->meta = $meta;
$this->isActivable = true; }
public function getName(){
return "Nether Reactor";
}
public function canBeActivated(){
return true;
} }
} }

View File

@ -24,9 +24,19 @@ namespace pocketmine\block;
use pocketmine\item\Item; use pocketmine\item\Item;
class Netherrack extends Solid{ class Netherrack extends Solid{
protected $id = self::NETHERRACK;
public function __construct(){ public function __construct(){
parent::__construct(self::NETHERRACK, 0, "Netherrack");
$this->hardness = 2; }
public function getName(){
return "Netherrack";
}
public function getHardness(){
return 2;
} }
public function getBreakTime(Item $item){ public function getBreakTime(Item $item){

View File

@ -24,9 +24,19 @@ namespace pocketmine\block;
use pocketmine\item\Item; use pocketmine\item\Item;
class Obsidian extends Solid{ class Obsidian extends Solid{
protected $id = self::OBSIDIAN;
public function __construct(){ public function __construct(){
parent::__construct(self::OBSIDIAN, 0, "Obsidian");
$this->hardness = 6000; }
public function getName(){
return "Obsidian";
}
public function getHardness(){
return 6000;
} }
public function getBreakTime(Item $item){ public function getBreakTime(Item $item){

View File

@ -30,18 +30,28 @@ class Planks extends Solid{
const ACACIA = 4; const ACACIA = 4;
const DARK_OAK = 5; const DARK_OAK = 5;
protected $id = self::WOODEN_PLANKS;
public function __construct($meta = 0){ public function __construct($meta = 0){
parent::__construct(self::PLANKS, $meta, "Wood Planks"); $this->meta = $meta;
$names = [ }
public function getHardness(){
return 15;
}
public function getName(){
static $names = [
self::OAK => "Oak Wood Planks", self::OAK => "Oak Wood Planks",
self::SPRUCE => "Spruce Wood Planks", self::SPRUCE => "Spruce Wood Planks",
self::BIRCH => "Birch Wood Planks", self::BIRCH => "Birch Wood Planks",
self::JUNGLE => "Jungle Wood Planks", self::JUNGLE => "Jungle Wood Planks",
self::ACACIA => "Acacia Wood Planks", self::ACACIA => "Acacia Wood Planks",
self::DARK_OAK => "Jungle Wood Planks", self::DARK_OAK => "Jungle Wood Planks",
"",
""
]; ];
$this->name = $names[$this->meta & 0x07]; return $names[$this->meta & 0x07];
$this->hardness = 15;
} }
} }

View File

@ -22,8 +22,18 @@
namespace pocketmine\block; namespace pocketmine\block;
class Podzol extends Solid{ class Podzol extends Solid{
protected $id = self::PODZOL;
public function __construct(){ public function __construct(){
parent::__construct(self::PODZOL, 0, "Podzol");
$this->hardness = 2.5; }
public function getName(){
return "Podzol";
}
public function getHardness(){
return 2.5;
} }
} }

View File

@ -25,20 +25,22 @@ use pocketmine\item\Item;
use pocketmine\level\Level; use pocketmine\level\Level;
use pocketmine\Player; use pocketmine\Player;
class CyanFlower extends Flowable{ class Poppy extends Flowable{
public function __construct(){
parent::__construct(self::POPPY, 0, "Cyan Flower"); protected $id = self::POPPY;
$this->hardness = 0;
public function __construct($meta = 0){
$this->meta = $meta;
} }
public function getBoundingBox(){ public function getName(){
return null; return "Poppy";
} }
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){ public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){
$down = $this->getSide(0); $down = $this->getSide(0);
if($down->getID() === 2 or $down->getID() === 3 or $down->getID() === 60){ if($down->getId() === 2 or $down->getId() === 3 or $down->getId() === 60){
$this->getLevel()->setBlock($block, $this, true, true); $this->getLevel()->setBlock($block, $this, true, true);
return true; return true;
@ -49,7 +51,7 @@ class CyanFlower extends Flowable{
public function onUpdate($type){ public function onUpdate($type){
if($type === Level::BLOCK_UPDATE_NORMAL){ if($type === Level::BLOCK_UPDATE_NORMAL){
if($this->getSide(0)->isTransparent === true){ if($this->getSide(0)->isTransparent() === true){
$this->getLevel()->useBreakOn($this); $this->getLevel()->useBreakOn($this);
return Level::BLOCK_UPDATE_NORMAL; return Level::BLOCK_UPDATE_NORMAL;

View File

@ -24,8 +24,15 @@ namespace pocketmine\block;
use pocketmine\item\Item; use pocketmine\item\Item;
class Potato extends Crops{ class Potato extends Crops{
protected $id = self::POTATO_BLOCK;
public function __construct($meta = 0){ public function __construct($meta = 0){
parent::__construct(self::POTATO_BLOCK, $meta, "Potato Block"); $this->meta = $meta;
}
public function getName(){
return "Potato Block";
} }
public function getDrops(Item $item){ public function getDrops(Item $item){

View File

@ -25,9 +25,19 @@ use pocketmine\item\Item;
use pocketmine\Player; use pocketmine\Player;
class Pumpkin extends Solid{ class Pumpkin extends Solid{
protected $id = self::PUMPKIN;
public function __construct(){ public function __construct(){
parent::__construct(self::PUMPKIN, "Pumpkin");
$this->hardness = 5; }
public function getHardness(){
return 5;
}
public function getName(){
return "Pumpkin";
} }
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){ public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){

View File

@ -27,13 +27,20 @@ use pocketmine\level\Level;
use pocketmine\Server; use pocketmine\Server;
class PumpkinStem extends Crops{ class PumpkinStem extends Crops{
protected $id = self::PUMPKIN_STEM;
public function __construct($meta = 0){ public function __construct($meta = 0){
parent::__construct(self::PUMPKIN_STEM, $meta, "Pumpkin Stem"); $this->meta = $meta;
}
public function getName(){
return "Pumpkin Stem";
} }
public function onUpdate($type){ public function onUpdate($type){
if($type === Level::BLOCK_UPDATE_NORMAL){ if($type === Level::BLOCK_UPDATE_NORMAL){
if($this->getSide(0)->isTransparent === true){ if($this->getSide(0)->isTransparent() === true){
$this->getLevel()->useBreakOn($this); $this->getLevel()->useBreakOn($this);
return Level::BLOCK_UPDATE_NORMAL; return Level::BLOCK_UPDATE_NORMAL;
} }
@ -51,13 +58,13 @@ class PumpkinStem extends Crops{
}else{ }else{
for($side = 2; $side <= 5; ++$side){ for($side = 2; $side <= 5; ++$side){
$b = $this->getSide($side); $b = $this->getSide($side);
if($b->getID() === self::PUMPKIN){ if($b->getId() === self::PUMPKIN){
return Level::BLOCK_UPDATE_RANDOM; return Level::BLOCK_UPDATE_RANDOM;
} }
} }
$side = $this->getSide(mt_rand(2, 5)); $side = $this->getSide(mt_rand(2, 5));
$d = $side->getSide(0); $d = $side->getSide(0);
if($side->getID() === self::AIR and ($d->getID() === self::FARMLAND or $d->getID() === self::GRASS or $d->getID() === self::DIRT)){ if($side->getId() === self::AIR and ($d->getId() === self::FARMLAND or $d->getId() === self::GRASS or $d->getId() === self::DIRT)){
Server::getInstance()->getPluginManager()->callEvent($ev = new BlockGrowEvent($side, new Pumpkin())); Server::getInstance()->getPluginManager()->callEvent($ev = new BlockGrowEvent($side, new Pumpkin()));
if(!$ev->isCancelled()){ if(!$ev->isCancelled()){
$this->getLevel()->setBlock($side, $ev->getNewState(), true); $this->getLevel()->setBlock($side, $ev->getNewState(), true);

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