Compare commits

...

232 Commits

Author SHA1 Message Date
763ef7f937 Removed outdated GUI submodule (#125) 2016-11-25 13:46:41 +00:00
e51a2725de Remove circular dependency between Item and NBT modules (#121) 2016-11-25 10:17:50 +00:00
a0111d04ee Log exception with backtrace 2016-11-24 21:20:10 +00:00
958473b333 update PHP-YAML to 2.0.0 for Travis 2016-11-24 12:04:52 +00:00
744f5a8384 Fix ServerKiller and make it less useless (#122) 2016-11-24 08:47:28 +00:00
fe348b0a9d Speed up region file creation by only using ftruncate(). (#116)
* Speed up region file creation by only using ftruncate().

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

* Replace manual array fill with array_fill().

* Spaces -> tabs.

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

* Added checks for RakLib and PocketMine-Language

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

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

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

* StringTag check, throw exception for other types

* Short, not int

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

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

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

* Tuned PhpStorm reformatting

* Improved ItemIds and BlockIds formatting

* Tuned more PhpStorm reformatting

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

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

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

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

* fix formatting
2016-09-30 19:20:03 +01:00
50c5c1de92 Bump version to 0.15.9 and protocol to 83
Seems the only thing that changed was the cape skin models, which would not be rendered correctly by older clients.
2016-09-30 19:20:01 +01:00
e2e31d345d Allow vanilla trapdoor placement 2016-09-30 19:20:00 +01:00
7145e16bce Fix getHandler() returns null on tasks (#3) 2016-09-30 19:19:59 +01:00
5485b63e6e Added ChangeDimensionPacket 2016-09-30 19:19:58 +01:00
f2f70480ee Fixed precedence problem (#1)
as mentioned in 4cb76f369a (commitcomment-19068812)
2016-09-30 19:19:57 +01:00
900c4adb66 Create sign tile like it should be. 2016-09-30 19:19:56 +01:00
5f8dc5829c Better inheritance for wooden stairs 2016-09-30 19:19:55 +01:00
e962f7fb0a Fixed bug in updateAround where only one block is updated 2016-09-30 19:19:54 +01:00
a3e3a5f631 RNG: XorShift128 adapted from php-random library
Fixes world generation problems on 32-bit systems
2016-09-30 19:19:53 +01:00
b156480550 Fix redstone ore glowing immediately when placed
Do not update the block when placed
2016-09-30 19:19:52 +01:00
7b8548b2b1 Added Flower Pots 2016-09-30 19:19:51 +01:00
fbe17344fb Fix plugin crashes when attempting to get metadata of offline players 2016-09-30 19:19:50 +01:00
e143fb80da create .editorconfig to improve code displaying on github 2016-09-30 19:19:49 +01:00
795d6c8ddf Fix entity-related memory leak on chunk unload 2016-09-30 19:19:48 +01:00
6bd028f8b3 Fix Wood2 crashes 2016-09-30 19:19:47 +01:00
35c33ba980 Fix Glowing Obsidian lighting 2016-09-30 19:19:46 +01:00
895790f46c Fix signs going blank
Sign text is not limited to 16 characters anymore, but to the width of
the sign. Server: Stop being such a control freak
2016-09-30 19:19:45 +01:00
378c3d7994 Patch %0 client translation exploit 2016-09-30 19:19:44 +01:00
9808f874c8 Remove Stonecutter remnants 2016-09-30 19:19:43 +01:00
4198c445b0 Fixed Furnace crash 2016-09-28 13:59:53 +01:00
42e8120961 Remove creative container open checks (lines up with 0.14) 2016-09-28 13:59:53 +01:00
2a4f85107d Less duplication, more consistency 2016-09-28 13:59:53 +01:00
97f6b80969 Fix players levitating in beds and teleportation of sleeping players 2016-09-28 13:59:52 +01:00
a6f8379c40 Fix time bugs 2016-09-28 13:59:52 +01:00
bf4b96e144 Block: Fix fence gate rotation when opened or closed. TODO: fix gate opening direction 2016-09-28 13:59:52 +01:00
4f26e5598c Network: Fix crashes caused by AddEntityPacket 2016-09-28 13:59:52 +01:00
e00176b677 Closes #4181 @ PM
https://github.com/PocketMine/PocketMine-MP/issues/4181
2016-09-28 13:59:51 +01:00
f32d588b9b Inventory: Creative Inventory update 2016-09-28 13:59:51 +01:00
f14a8e46be Inventory: Fix creative/spectator inventory sending 2016-09-28 13:59:46 +01:00
5851e7fe55 Network: Do not attempt to decode further for non-accepted protocols
Prevents 0.16 players crashing 0.15 servers
2016-09-06 11:54:52 +01:00
Tux
8e9a078ff9 Use built-in random_bytes functionality 2016-09-06 11:47:58 +01:00
b16f7e4dd5 Fix a really annoying movement bug on player join 2016-09-06 11:42:30 +01:00
15b9578245 Fix reach distance bugs 2016-09-06 11:33:27 +01:00
765bd5ced7 Inventory: Fix hotbar spaz 2016-09-06 11:23:49 +01:00
df4c3ec4a6 Bump version and protocol to 0.15.4 2016-09-06 11:12:18 +01:00
327 changed files with 23116 additions and 3111 deletions

6
.editorconfig Normal file
View File

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

View File

@ -1,5 +1,5 @@
### Issue description
<!--- use our forum https://forums.pocketmine.net for questions -->
<!--- use our forum https://forums.pmmp.io for questions -->
Write a short description about the issue
### Steps to reproduce the issue
@ -8,10 +8,15 @@ Write a short description about the issue
2. ...
### OS and versions
<!--- use the 'version' command in PocketMine-MP -->
<!--- use the 'version' command in PocketMine-MP
NOTE: LATEST is not a valid version.
PocketMine version should include Jenkins build number and/or git commit hash.
ALSO NOTE: NO support whatsoever will be provided for forks or spoons of PocketMine. Issues relating to non-official distributions will be closed as spam. Please send such issues to whoever is responsible for the fork or spoon you are using.
-->
* PocketMine-MP:
* PHP:
* OS:
* Server OS:
* Game version: PE/Win10 (delete as appropriate)
### Crashdump, backtrace or other files
<!--- please use gist or anything else and add links here -->

1
.gitignore vendored
View File

@ -8,6 +8,7 @@ timings/*
*.phar
server.properties
/pocketmine.yml
memoryDump_*/*
# Common IDEs
.idea/*

16
.gitmodules vendored
View File

@ -1,17 +1,13 @@
[submodule "src/pocketmine/gui"]
path = src/pocketmine/gui
url = https://github.com/PocketMine/PocketMine-MP-GUI.git
branch = master
[submodule "src/raklib"]
path = src/raklib
url = https://github.com/PocketMine/RakLib.git
url = https://github.com/pmmp/RakLib.git
branch = master
[submodule "src/spl"]
path = src/spl
url = https://github.com/PocketMine/PocketMine-SPL.git
[submodule "tests/TesterPlugin"]
path = tests/TesterPlugin
url = https://github.com/PocketMine/TesterPlugin.git
url = https://github.com/pmmp/PocketMine-SPL.git
[submodule "src/pocketmine/lang/locale"]
path = src/pocketmine/lang/locale
url = https://github.com/PocketMine/PocketMine-Language.git
url = https://github.com/pmmp/PocketMine-Language.git
[submodule "tests/preprocessor"]
path = tests/preprocessor
url = https://github.com/pmmp/preprocessor.git

View File

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

View File

@ -3,18 +3,15 @@ language: php
php:
- 7.0
branches:
- master
before_script:
- mkdir plugins
- wget -O plugins/DevTools.phar https://github.com/PocketMine/DevTools/releases/download/v1.11.0/DevTools_v1.11.0.phar
- pecl install channel://pecl.php.net/pthreads-3.1.6
- pecl install channel://pecl.php.net/weakref-0.3.2
- echo | pecl install channel://pecl.php.net/yaml-2.0.0RC7
- echo | pecl install channel://pecl.php.net/yaml-2.0.0
script:
- php tests/TravisTest.php
- ./tests/lint.sh && ./tests/run.sh
notifications:
email: false

View File

@ -5,34 +5,39 @@
You must follow these guidelines if you wish to contribute to the PocketMine-MP code base, or participate in issue tracking.
## I have a question
* For questions, please refer to the _#pocketmine_ or _#mcpedevs_ IRC channel on Freenode. There is a [WebIRC](http://webchat.freenode.net?channels=pocketmine,mcpedevs&uio=d4) if you want.
* For questions, please refer to the _#pmmp_ or _#pocketmine_ IRC channel on Freenode. There is a [WebIRC](http://webchat.freenode.net?channels=pmmp,pocketmine&uio=d4) if you do not want to install an IRC client.
* You can ask directly to _[@PocketMine](https://twitter.com/PocketMine)_ in Twitter, but don't expect an immediate reply.
* You may use our [Forum](http://forums.pocketmine.net) to ask questions.
* You may use our [Forum](https://forums.pmmp.io) to ask questions.
* We do not accept questions or support requests in our issue tracker.
## Creating an Issue
- First, use the [Issue Search](https://github.com/PocketMine/PocketMine-MP/search?ref=cmdform&type=Issues) to check if anyone has reported it.
- If your issue is related to a plugin, you must contact their original author instead of reporting it here.
- If your issue is related to a PocketMine official plugin, or our Android application, you must create an issue on that specific repository.
- **Support requests are not bugs.** Issues such as "How do I do this" are not bugs and are closed as soon as a collaborator spots it. They are referred to our Forum to seek assistance.
- **No generic titles** such as "Question", "Help", "Crash Report" etc. If an issue has a generic title they will either be closed on the spot, or a collaborator will edit it to describe the actual symptom.
- Information must be provided in the issue body, not in the title. No tags are allowed in the title, and do not change the title if the issue has been solved.
- Similarly, no generic issue reports. It is the issue submitter's responsibility to provide us an issue that is **trackable, debuggable, reproducible, reported professionally and is an actual bug**. If you do not provide us with a summary or instructions on how to reproduce the issue, it is a support request until the actual bug has been found and therefore the issue is closed.
- To express appreciation, objection, confusion or other supported reactions on pull requests, issues or comments on them, use GitHub [reactions](https://github.com/blog/2119-add-reactions-to-pull-requests-issues-and-comments) rather than posting an individual comment with an emoji only. This helps keeping the issue/pull rqeuest conversation clean and readable.
* First, use the [Issue Search](https://github.com/pmmp/PocketMine-MP/search?ref=cmdform&type=Issues) to check if anyone has reported it. Check also closed issues, as an issue you think is valid may actually be invalid.
* If an issue has been _fixed_ and closed, create another issue.
* If your issue is related to a plugin, do **not** report here. Contact the plugin's original author instead.
* **Support requests are not bugs.** Issues such as "How do I do this" are not bugs and are closed as soon as a collaborator spots it. They are referred to our Forum to seek assistance. Please refer to the section [I have a quesetion](#i-have-a-question) instead.
* **No generic titles** such as "Question", "Help", "Crash Report" etc.
* If you just got a crash report but you don't understand it, please look for a line starting with `Message`. It summarizes the bug.
* Information must be provided in the issue body, not in the title. No tags like `[BUG]` are allowed in the title, including `[SOLVED]` for solved issues.
* Similarly, no generic issue reports. For bugs, it is the issue author's responsibility to provide us an issue that is **trackable, debuggable, reproducible, reported professionally and is an actual bug**. If you do not provide us with a summary or instructions on how to reproduce the issue, it is a support request until the actual bug has been found and therefore the issue is closed.
* In simple words, if your issue does not appear to be a bug or a feature request, or if the issue cannot be properly confirmed to be valid, the issue will be closed until further information is provided.
* To express appreciation, objection, confusion or other supported reactions on pull requests, issues or comments on them, use GitHub [reactions](https://github.com/blog/2119-add-reactions-to-pull-requests-issues-and-comments) rather than posting an individual comment with an emoji only. This helps keeping the issue/pull rqeuest conversation clean and readable.
* If your issue is related to the Pocketmine-MP website, forums, etc., please [talk to a human directly](#i-have-a-question).
## Contributing Code
* Use the [Pull Request](https://github.com/PocketMine/PocketMine-MP/pull/new) system, your request will be checked and discussed.
* __Create a single branch for that pull request__
* Code using the syntax as in PocketMine-MP. See below for an example.
* Use the [Pull Request](https://github.com/pmmp/PocketMine-MP/pull/new) system, your request will be checked and discussed.
* Create each pull request on a new branch. Do not create a pull request on commits that exist in another pull request.
* Code should use the same syntax as in PocketMine-MP. See below for an example.
* The code must be clear and written in English, comments included.
* Use descriptive commit titles
* __No merge commits are allowed, or multiple features per pull request__
* **Keep each pull request only contain one feature**. The only exception is when all features in the pull request are related to each other, and share the same core changes.
* **Do not create pull requests that only bump the MCPE version**. If it is ready to be updated, the team will update the values directly. Do not change the MCPE version or protocol version in a pull request, unless you have updated the protocol (all packets) entirely.
**Thanks for contributing to PocketMine-MP!**
### Code Syntax
It is mainly [PSR-2](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-1-basic-coding-standard.md) with a few exceptions.
* Opening braces MUST go on the same line, and MUST NOT have spaces before.
* `else if` MUST be written as `elseif`. _(It is in PSR-2, but using a SHOULD)_
* Control structure keywords or opening braces MUST NOT have one space before or after them.
@ -53,12 +58,17 @@ class ExampleClass{
public $examplePublicVariable = "defaultValue";
private $examplePrivateVariable;
/**
* Creates an instance of ExampleClass
* @param string $firstArgument the first argument
* @param string|null $secondArgument default null
*/
public function __construct($firstArgument, &$secondArgument = null){
if($firstArgument === "exampleValue"){ //Remember to use === instead == when possible
//do things
}elseif($firstArgument === "otherValue"){
$secondArgument = function(){
return [
$this->examplePrivateVariable = [
0 => "value1",
1 => "value2",
2 => "value3",
@ -73,6 +83,7 @@ class ExampleClass{
}
```
<!-- TODO: RFC and voting on the forums instead -->
### RFC and Voting
* These are big Pull Requests or contributions that change important behavior.
* RFCs will be tagged with the *PR: RFC* label
@ -90,51 +101,71 @@ class ExampleClass{
### Labels
To provide a concise bug tracking environment, prevent the issue tracker from over flowing and to keep support requests out of the bug tracker, PocketMine-MP uses a label scheme a bit different from the default GitHub Issues labels.
PocketMine-MP uses GitHub Issues Labels. There are a total of 12 labels.
Note: For future reference, labels must not be longer than 15 letters.
Labels are used to identify the type and status of issues and pull requests.
#### Categories
Category labels are prefixed by `C:`. Multiple category labels may be applied to a single issue(but try to keep this to a minimum and do not overuse category labels).
- C: Core - This label is applied when the bug results in a fatal crash, or is related to neither Gameplay nor Plugin API.
- C: Gameplay - This label is applied when the bug effects the gameplay.
- C: API - This label is applied when the bug effects the Plugin API.
Multiple category labels may be applied to a single issue (but try to keep this to a minimum and do not overuse category labels).
These labels may be applied to issues with bugs related to these, or pull requests that alter the behaviour of these or fix an issue with the same label applied.
- `Category: Core` - Related to PocketMine-MP's core functionality, but not gameplay or API.
- `Category: Gameplay` - Related to gameplay.
- `Category: API` - Related to plugin API.
- `Category: Client` - Related to client functionality or behaviour. This label may be applied to issues reporting client-related bugs, or PRs related to the client such as a protocol update. There are several sub-labels to account for the differences between supported clients.
- `all`: Related to all versions of the client.
- `W10`: Related only to Windows 10 Edition Beta.
- `PE`: Related only to the Pocket Edition
- `beta`: Related only to a beta version of the game.
- `other`: Related only to an uncommon PE-compatible version of the client, such as VR Edition.
- `Category: PHP` - Applied to issues caused by the PHP interpreter or its extensions.
- `Category: Other` - Applied to issues which cannot be categorized with any of the above labels.
#### Pull Requests
Pull Requests are prefixed by `PR:`. Only one label may be applied for a Pull Request.
- PR: Bug Fix - This label is applied when the Pull Request fixes a bug.
- PR: Contribution - This label is applied when the Pull Request contributes code to PocketMine-MP such as a new feature or an improvement.
- PR: RFC - Request for Comments
Pull Request labels are prefixed by `PR:`. Only one label may be applied for a Pull Request.
- `PR: Bug Fix` - The Pull Request fixes a bug.
- `PR: Contribution` - The Pull Request contributes new features or improvements, but does not fix a bug, nor controversial enough to be an RFC.
- `PR: RFC` - Request for Comments. Refer to [RFC and Voting](#rfc-and-voting).
#### Status
Status labels show the status of the issue. Multiple status labels may be applied.
- Reproduced - This label is applied when the bug has been reproduced, or multiple people are reporting the same issue and symptoms in which case it is automatically assumed that the bug has been reproduced in different environments.
- Debugged - This label is applied when the cause of the bug has been found.
- Priority - This label is applied when the bug is easy to fix, or if the scale of the bug is global.
- Won't Fix - This label is applied if the bug has been decided not be fixed for some reason. e.g. when the bug benefits gameplay. *This label may only be applied to a closed issue.*
*Issues*
- `Status: Unconfirmed` - reported issues that have yet to be reproduced by a developer successfully.
- `Status: Reproduced` - a bug that has been reproduced by a developer, or that multiple people are reporting the same issue and symptoms in which case it is automatically assumed that the bug has been reproduced in different environments.
- `Status: Debugged` - the cause of the bug has been found, but has not yet been fixed.
- `Status: Resolved` - applied to *valid* issues which have been fixed. *This label may only be applied to a closed issue.*
*Pull requests*
- `Status: Insufficiently tested` - applied for pull requests that have not undergone tests strict enough.
#### Resolution
Resolution labels show the resolution of an issue or pull request. These labels may only be applied to closed issues.
- `Resolution: Invalid` - Applied to support request issues or issues not related to PocketMine.
- `Resolution: Duplicate` - Applied to issues reporting the same problems as another issue.
- `Resolution: Fixed` - Applied to an issue reporting a bug which has been fixed.
- `Resolution: Works As Intended` - Applied to issues reporting false bugs which work the way they are intended to.
- `Resolution: Won't Fix` - Applied to issues reporting bugs which will not be fixed, for example if the bug is beneficial.
- `Resolution: Obsolete` - Applied to pull requests which are rendered unnecessary by other changes, such as another, similar pull request being merged.
#### Miscellaneous
Miscellaneous labels are labels that show status not related to debugging that bug. The To-Do label and the Mojang label may not be applied to a single issue at the same time.
- To-Do - This label is applied when the issue is not a bug, but a feature request or a list of features to be implemented that count towards a milestone.
- Mojang - This label is applied when the issue is suspected of being caused by the Minecraft: Pocket Edition client, but has not been confirmed.
- Invalid - This label is applied when the issue is reporting a false bug that works as intended, a support request, etc. *This label may only be applied to a closed issue.*
- `Enhancement` - Applied to issues with viable feature requests or TODO lists.
- `High priority` - Applied to issues or PRs related to critical bugs.
### Closing Issues
To keep the bug tracker clear of non-related issues and to prevent it from overflowing, **issues must be closed as soon as possible** (This may sound unethical, but it is MUCH better than having the BUG TRACKER filled with SUPPORT REQUESTS and "I NEED HELP").
If an issue does not conform to the "Creating an Issue" guidelines above, the issue should be closed.
<!--
### Milestones
PocketMine-MP uses GitHub Milestones to set a goal for a new release. A milestone is set on the following occasions.
- A new Beta release
- A new Stable release
- A new Beta release
- A new Stable release
A milestone must use the following format:
```
Alpha_<version_number> [release_title][release_version]
<version_number> [release_title][release_version]
```
For example:
```
Alpha_1.4 beta2
1.6.1b1
```
-->

View File

@ -1,5 +1,5 @@
# ![PocketMine-MP](http://cdn.pocketmine.net/img/PocketMine-MP-h.png)
[![Build Status](https://travis-ci.org/PocketMine/PocketMine-MP.svg?branch=master)](https://travis-ci.org/PocketMine/PocketMine-MP)
[![Build Status](https://travis-ci.org/pmmp/PocketMine-MP.svg?branch=master)](https://travis-ci.org/pmmp/PocketMine-MP)
This program is free software: you can redistribute it and/or modify
@ -18,26 +18,26 @@
__PocketMine-MP is a free, open-source software that creates Minecraft: Pocket Edition servers and allows extending its functionalities__
### [Homepage](http://www.pocketmine.net/)
### [Homepage](https://pmmp.io/)
### [Forums](http://forums.pocketmine.net/)
### [Forums](https://forums.pmmp.io/)
### [Documentation](http://pocketmine-mp.readthedocs.org/)
### [Documentation](http://pmmp.readthedocs.org/)
### [Plugin Repository](http://plugins.pocketmine.net/)
<!--## [FAQ: Frequently Asked Questions](https://github.com/PocketMine/PocketMine-MP/wiki/Frequently-Asked-Questions)-->
### [Official Jenkins server](http://jenkins.pocketmine.net/)
### [Official Jenkins server](https://jenkins.pmmp.io/)
### API Documentation
* [Official Doxygen-generated documentation](http://docs.pocketmine.net/)
* [Latest Doxygen generated from development](http://jenkins.pocketmine.net/job/PocketMine-MP-doc/doxygen/)
* [Latest Doxygen generated from development](https://jenkins.pmmp.io/job/PocketMine-MP%20Docs/doxygen/)
### [Twitter @PocketMine](https://twitter.com/PocketMine)
### IRC Chat #pocketmine (or #mcpedevs) @ irc.freenode.net
[#pocketmine + #mcpedevs channel WebIRC](http://webchat.freenode.net/?channels=pocketmine,mcpedevs)
### IRC Chat #pmmp (or #pocketmine) @ irc.freenode.net
[#pmmp + #pocketmine channel WebIRC](http://webchat.freenode.net/?channels=pmmp,pocketmine)
### Want to contribute?
* Check the [Contributing Guidelines](CONTRIBUTING.md)

View File

@ -23,13 +23,13 @@ namespace pocketmine;
abstract class Collectable extends \Threaded implements \Collectable{
private $isGarbage = false;
public function isGarbage() : bool{
return $this->isGarbage;
}
private $isGarbage = false;
public function setGarbage(){
$this->isGarbage = true;
}
public function isGarbage() : bool{
return $this->isGarbage;
}
public function setGarbage(){
$this->isGarbage = true;
}
}

View File

@ -26,7 +26,6 @@ use pocketmine\event\Timings;
use pocketmine\scheduler\GarbageCollectionTask;
use pocketmine\utils\Utils;
class MemoryManager{
/** @var Server */
@ -128,8 +127,8 @@ class MemoryManager{
}
public function trigger($memory, $limit, $global = false, $triggerCount = 0){
$this->server->getLogger()->debug("[Memory Manager] ".($global ? "Global " : "") ."Low memory triggered, limit ". round(($limit / 1024) / 1024, 2)."MB, using ". round(($memory / 1024) / 1024, 2)."MB");
$this->server->getLogger()->debug(sprintf("[Memory Manager] %sLow memory triggered, limit %gMB, using %gMB",
$global ? "Global " : "", round(($limit / 1024) / 1024, 2), round(($memory / 1024) / 1024, 2)));
if($this->cacheTrigger){
foreach($this->server->getLevels() as $level){
$level->clearCache(true);
@ -150,7 +149,7 @@ class MemoryManager{
$cycles = $this->triggerGarbageCollector();
}
$this->server->getLogger()->debug("[Memory Manager] Freed " . round(($ev->getMemoryFreed() / 1024) / 1024, 2)."MB, $cycles cycles");
$this->server->getLogger()->debug(sprintf("[Memory Manager] Freed %gMB, $cycles cycles", round(($ev->getMemoryFreed() / 1024) / 1024, 2)));
}
public function check(){
@ -266,7 +265,7 @@ class MemoryManager{
$this->continueDump($property->getValue($object), $info["properties"][$property->getName()], $objects, $refCounts, 0, $maxNesting, $maxStringSize);
}
fwrite($obData, "$hash@$className: ". json_encode($info, JSON_UNESCAPED_SLASHES) . "\n");
fwrite($obData, "$hash@$className: " . json_encode($info, JSON_UNESCAPED_SLASHES) . "\n");
if(!isset($objects["staticProperties"][$className])){
$staticProperties[$className] = [];
@ -324,7 +323,7 @@ class MemoryManager{
$this->continueDump($value, $data[$key], $objects, $refCounts, $recursion + 1, $maxNesting, $maxStringSize);
}
}elseif(is_string($from)){
$data = "(string) len(".strlen($from).") " . substr(Utils::printable($from), 0, $maxStringSize);
$data = sprintf("(string) len(%d) " . substr(Utils::printable($from), 0, $maxStringSize), strlen($from));
}elseif(is_resource($from)){
$data = "(resource) " . print_r($from, true);
}else{

View File

@ -21,12 +21,12 @@
namespace pocketmine;
use pocketmine\metadata\Metadatable;
use pocketmine\metadata\MetadataValue;
use pocketmine\nbt\tag\CompoundTag;
use pocketmine\plugin\Plugin;
class OfflinePlayer implements IPlayer{
class OfflinePlayer implements IPlayer, Metadatable{
private $name;
private $server;

File diff suppressed because it is too large Load Diff

View File

@ -71,12 +71,13 @@ namespace pocketmine {
use pocketmine\utils\Terminal;
use pocketmine\utils\Utils;
use pocketmine\wizard\Installer;
use raklib\RakLib;
const VERSION = "1.6dev";
const API_VERSION = "2.0.0";
const VERSION = "1.6.1dev";
const API_VERSION = "2.1.0";
const CODENAME = "Unleashed";
const MINECRAFT_VERSION = "v0.15.0.0 alpha";
const MINECRAFT_VERSION_NETWORK = "0.15.0.0";
const MINECRAFT_VERSION = "v0.16.0.5 alpha";
const MINECRAFT_VERSION_NETWORK = "0.16.0.5";
/*
* Startup code. Do not look at it, it may harm you.
@ -104,6 +105,11 @@ namespace pocketmine {
}
if(!class_exists("ClassLoader", false)){
if(!is_file(\pocketmine\PATH . "src/spl/ClassLoader.php")){
echo "[CRITICAL] Unable to find the PocketMine-SPL library." . PHP_EOL;
echo "[CRITICAL] Please use provided builds or clone the repository recursively." . PHP_EOL;
exit(1);
}
require_once(\pocketmine\PATH . "src/spl/ClassLoader.php");
require_once(\pocketmine\PATH . "src/spl/BaseClassLoader.php");
require_once(\pocketmine\PATH . "src/pocketmine/CompatibleClassLoader.php");
@ -114,6 +120,14 @@ namespace pocketmine {
$autoloader->addPath(\pocketmine\PATH . "src" . DIRECTORY_SEPARATOR . "spl");
$autoloader->register(true);
try{
if(!class_exists(RakLib::class)){
throw new \Exception;
}
}catch(\Exception $e){
echo "[CRITICAL] Unable to find the RakLib library." . PHP_EOL;
exit(1);
}
set_time_limit(0); //Who set it to 30 seconds?!?!
@ -154,7 +168,7 @@ namespace pocketmine {
//If system timezone detection fails or timezone is an invalid value.
if($response = Utils::getURL("http://ip-api.com/json")
and $ip_geolocation_data = json_decode($response, true)
and $ip_geolocation_data['status'] != 'fail'
and $ip_geolocation_data['status'] !== 'fail'
and date_default_timezone_set($ip_geolocation_data['timezone'])
){
//Again, for redundancy.
@ -175,7 +189,7 @@ namespace pocketmine {
$default_timezone = timezone_name_from_abbr($timezone);
ini_set("date.timezone", $default_timezone);
date_default_timezone_set($default_timezone);
} else {
}else{
date_default_timezone_set($timezone);
}
}
@ -323,7 +337,7 @@ namespace pocketmine {
if(function_exists("posix_kill")){
posix_kill($pid, SIGKILL);
}else{
exec("kill -9 " . ((int)$pid) . " > /dev/null 2>&1");
exec("kill -9 " . ((int) $pid) . " > /dev/null 2>&1");
}
}
}
@ -401,10 +415,6 @@ namespace pocketmine {
++$errors;
}
if(!extension_loaded("uopz")){
//$logger->notice("Couldn't find the uopz extension. Some functions may be limited");
}
if(extension_loaded("pocketmine")){
if(version_compare(phpversion("pocketmine"), "0.0.1") < 0){
$logger->critical("You have the native PocketMine extension, but your version is lower than 0.0.1.");
@ -415,6 +425,15 @@ namespace pocketmine {
}
}
if(extension_loaded("xdebug")){
$logger->warning("
You are running PocketMine with xdebug enabled. This has a major impact on performance.
");
}
if(!extension_loaded("curl")){
$logger->critical("Unable to find the cURL extension.");
++$errors;
@ -450,7 +469,7 @@ namespace pocketmine {
@define("ENDIANNESS", (pack("d", 1) === "\77\360\0\0\0\0\0\0" ? Binary::BIG_ENDIAN : Binary::LITTLE_ENDIAN));
@define("INT32_MASK", is_int(0xffffffff) ? 0xffffffff : -1);
@ini_set("opcache.mmap_base", bin2hex(Utils::getRandomBytes(8, false))); //Fix OPCache address errors
@ini_set("opcache.mmap_base", bin2hex(random_bytes(8))); //Fix OPCache address errors
if(!file_exists(\pocketmine\DATA . "server.properties") and !isset($opts["no-wizard"])){
new Installer();
@ -465,14 +484,14 @@ namespace pocketmine {
$logger->info("Stopping other threads");
foreach(ThreadManager::getInstance()->getAll() as $id => $thread){
$logger->debug("Stopping " . (new \ReflectionClass($thread))->getShortName() . " thread");
$thread->quit();
}
$killer = new ServerKiller(8);
$killer->start();
foreach(ThreadManager::getInstance()->getAll() as $id => $thread){
$logger->debug("Stopping " . $thread->getThreadName() . " thread");
$thread->quit();
}
$logger->shutdown();
$logger->join();

View File

@ -104,6 +104,7 @@ use pocketmine\scheduler\SendUsageTask;
use pocketmine\scheduler\ServerScheduler;
use pocketmine\tile\Chest;
use pocketmine\tile\EnchantTable;
use pocketmine\tile\FlowerPot;
use pocketmine\tile\Furnace;
use pocketmine\tile\Sign;
use pocketmine\tile\Skull;
@ -667,6 +668,10 @@ class Server{
$this->craftingManager->registerRecipe($recipe);
}
public function shouldSavePlayerData() : bool{
return (bool) $this->getProperty("player.save-player-data", true);
}
/**
* @param string $name
*
@ -691,18 +696,20 @@ class Server{
public function getOfflinePlayerData($name){
$name = strtolower($name);
$path = $this->getDataPath() . "players/";
if(file_exists($path . "$name.dat")){
try{
$nbt = new NBT(NBT::BIG_ENDIAN);
$nbt->readCompressed(file_get_contents($path . "$name.dat"));
if($this->shouldSavePlayerData()){
if(file_exists($path . "$name.dat")){
try{
$nbt = new NBT(NBT::BIG_ENDIAN);
$nbt->readCompressed(file_get_contents($path . "$name.dat"));
return $nbt->getData();
}catch(\Throwable $e){ //zlib decode error / corrupt data
rename($path . "$name.dat", $path . "$name.dat.bak");
$this->logger->notice($this->getLanguage()->translateString("pocketmine.data.playerCorrupted", [$name]));
return $nbt->getData();
}catch(\Throwable $e){ //zlib decode error / corrupt data
rename($path . "$name.dat", $path . "$name.dat.bak");
$this->logger->notice($this->getLanguage()->translateString("pocketmine.data.playerCorrupted", [$name]));
}
}else{
$this->logger->notice($this->getLanguage()->translateString("pocketmine.data.playerNotFound", [$name]));
}
}else{
$this->logger->notice($this->getLanguage()->translateString("pocketmine.data.playerNotFound", [$name]));
}
$spawn = $this->getDefaultLevel()->getSafeSpawn();
$nbt = new CompoundTag("", [
@ -743,56 +750,6 @@ class Server{
$nbt->Motion->setTagType(NBT::TAG_Double);
$nbt->Rotation->setTagType(NBT::TAG_Float);
if(file_exists($path . "$name.yml")){ //Importing old PocketMine-MP files
$data = new Config($path . "$name.yml", Config::YAML, []);
$nbt["playerGameType"] = (int) $data->get("gamemode");
$nbt["Level"] = $data->get("position")["level"];
$nbt["Pos"][0] = $data->get("position")["x"];
$nbt["Pos"][1] = $data->get("position")["y"];
$nbt["Pos"][2] = $data->get("position")["z"];
$nbt["SpawnLevel"] = $data->get("spawn")["level"];
$nbt["SpawnX"] = (int) $data->get("spawn")["x"];
$nbt["SpawnY"] = (int) $data->get("spawn")["y"];
$nbt["SpawnZ"] = (int) $data->get("spawn")["z"];
$this->logger->notice($this->getLanguage()->translateString("pocketmine.data.playerOld", [$name]));
foreach($data->get("inventory") as $slot => $item){
if(count($item) === 3){
$nbt->Inventory[$slot + 9] = new CompoundTag("", [
new ShortTag("id", $item[0]),
new ShortTag("Damage", $item[1]),
new ByteTag("Count", $item[2]),
new ByteTag("Slot", $slot + 9),
new ByteTag("TrueSlot", $slot + 9)
]);
}
}
foreach($data->get("hotbar") as $slot => $itemSlot){
if(isset($nbt->Inventory[$itemSlot + 9])){
$item = $nbt->Inventory[$itemSlot + 9];
$nbt->Inventory[$slot] = new CompoundTag("", [
new ShortTag("id", $item["id"]),
new ShortTag("Damage", $item["Damage"]),
new ByteTag("Count", $item["Count"]),
new ByteTag("Slot", $slot),
new ByteTag("TrueSlot", $item["TrueSlot"])
]);
}
}
foreach($data->get("armor") as $slot => $item){
if(count($item) === 2){
$nbt->Inventory[$slot + 100] = new CompoundTag("", [
new ShortTag("id", $item[0]),
new ShortTag("Damage", $item[1]),
new ByteTag("Count", 1),
new ByteTag("Slot", $slot + 100)
]);
}
}
foreach($data->get("achievements") as $achievement => $status){
$nbt->Achievements[$achievement] = new ByteTag($achievement, $status == true ? 1 : 0);
}
unlink($path . "$name.yml");
}
$this->saveOfflinePlayerData($name, $nbt);
return $nbt;
@ -800,23 +757,25 @@ class Server{
}
/**
* @param string $name
* @param string $name
* @param CompoundTag $nbtTag
* @param bool $async
* @param bool $async
*/
public function saveOfflinePlayerData($name, CompoundTag $nbtTag, $async = false){
$nbt = new NBT(NBT::BIG_ENDIAN);
try{
$nbt->setData($nbtTag);
if($this->shouldSavePlayerData()){
$nbt = new NBT(NBT::BIG_ENDIAN);
try{
$nbt->setData($nbtTag);
if($async){
$this->getScheduler()->scheduleAsyncTask(new FileWriteTask($this->getDataPath() . "players/" . strtolower($name) . ".dat", $nbt->writeCompressed()));
}else{
file_put_contents($this->getDataPath() . "players/" . strtolower($name) . ".dat", $nbt->writeCompressed());
if($async){
$this->getScheduler()->scheduleAsyncTask(new FileWriteTask($this->getDataPath() . "players/" . strtolower($name) . ".dat", $nbt->writeCompressed()));
}else{
file_put_contents($this->getDataPath() . "players/" . strtolower($name) . ".dat", $nbt->writeCompressed());
}
}catch(\Throwable $e){
$this->logger->critical($this->getLanguage()->translateString("pocketmine.data.saveError", [$name, $e->getMessage()]));
$this->logger->logException($e);
}
}catch(\Throwable $e){
$this->logger->critical($this->getLanguage()->translateString("pocketmine.data.saveError", [$name, $e->getMessage()]));
$this->logger->logException($e);
}
}
@ -1016,10 +975,6 @@ class Server{
return false;
}
//$entities = new Config($path."entities.yml", Config::YAML);
//if(file_exists($path . "tileEntities.yml")){
// @rename($path . "tileEntities.yml", $path . "tiles.yml");
//}
try{
$level = new Level($this, $name, $path, $provider);
@ -1056,7 +1011,7 @@ class Server{
return false;
}
$seed = $seed === null ? Binary::readInt(@Utils::getRandomBytes(4, false)) : (int) $seed;
$seed = $seed === null ? Binary::readInt(random_bytes(4)) : (int) $seed;
if(!isset($options["preset"])){
$options["preset"] = $this->getConfigString("generator-settings", "");
@ -1133,14 +1088,6 @@ class Server{
if(LevelProviderManager::getProvider($path) === null){
return false;
}
/*if(file_exists($path)){
$level = new LevelImport($path);
if($level->import() === false){ //Try importing a world
return false;
}
}else{
return false;
}*/
}
return true;
@ -1452,7 +1399,7 @@ class Server{
"level-type" => "DEFAULT",
"enable-query" => true,
"enable-rcon" => false,
"rcon.password" => substr(base64_encode(@Utils::getRandomBytes(20, false)), 3, 10),
"rcon.password" => substr(base64_encode(random_bytes(20)), 3, 10),
"auto-save" => true,
]);
@ -1530,7 +1477,7 @@ class Server{
}
$this->logger->info($this->getLanguage()->translateString("pocketmine.server.networkStart", [$this->getIp() === "" ? "*" : $this->getIp(), $this->getPort()]));
define("BOOTUP_RANDOM", @Utils::getRandomBytes(16));
define("BOOTUP_RANDOM", random_bytes(16));
$this->serverID = Utils::getMachineUniqueId($this->getIp() . $this->getPort());
$this->getLogger()->debug("Server unique id: " . $this->getServerUniqueId());
@ -1558,10 +1505,10 @@ class Server{
InventoryType::init();
Block::init();
Enchantment::init();
Item::init();
Biome::init();
Effect::init();
Enchantment::init();
Attribute::init();
$this->craftingManager = new CraftingManager();
@ -1700,7 +1647,7 @@ class Server{
return count($recipients);
}
/**
* @param string $popup
* @param Player[]|null $recipients
@ -1718,7 +1665,7 @@ class Server{
}
}
}
/** @var Player[] $recipients */
foreach($recipients as $recipient){
$recipient->sendPopup($popup);
@ -1778,7 +1725,7 @@ class Server{
*
* @param Player[] $players
* @param DataPacket[]|string $packets
* @param bool $forceSync
* @param bool $forceSync
*/
public function batchPackets(array $players, array $packets, $forceSync = false){
Timings::$playerNetworkTimer->startTiming();
@ -1789,9 +1736,9 @@ class Server{
if(!$p->isEncoded){
$p->encode();
}
$str .= Binary::writeInt(strlen($p->buffer)) . $p->buffer;
$str .= Binary::writeUnsignedVarInt(strlen($p->buffer)) . $p->buffer;
}else{
$str .= Binary::writeInt(strlen($p)) . $p;
$str .= Binary::writeUnsignedVarInt(strlen($p)) . $p;
}
}
@ -1880,7 +1827,7 @@ class Server{
}
$sender->sendMessage(new TranslationContainer(TextFormat::RED . "%commands.generic.notFound"));
$sender->sendMessage(new TranslationContainer(TextFormat::GOLD . "%commands.generic.notFound"));
return false;
}
@ -1984,8 +1931,8 @@ class Server{
gc_collect_cycles();
}catch(\Throwable $e){
$this->logger->logException($e);
$this->logger->emergency("Crashed while crashing, killing process");
$this->logger->emergency(get_class($e) . ": ". $e->getMessage());
@kill(getmypid());
}
@ -2033,8 +1980,6 @@ class Server{
$this->tickProcessor();
$this->forceShutdown();
gc_collect_cycles();
}
public function handleSignal($signo){
@ -2212,6 +2157,9 @@ class Server{
$pk = new PlayerListPacket();
$pk->type = PlayerListPacket::TYPE_ADD;
foreach($this->playerList as $player){
if($p === $player){
continue; //fixes duplicates
}
$pk->entries[] = [$player->getUniqueId(), $player->getId(), $player->getDisplayName(), $player->getSkinId(), $player->getSkinData()];
}
@ -2263,14 +2211,14 @@ class Server{
if($r > $this->baseTickRate){
$level->tickRateCounter = $level->getTickRate();
}
$this->getLogger()->debug("Raising level \"".$level->getName()."\" tick rate to ".$level->getTickRate()." ticks");
$this->getLogger()->debug("Raising level \"{$level->getName()}\" tick rate to {$level->getTickRate()} ticks");
}elseif($tickMs >= 50){
if($level->getTickRate() === $this->baseTickRate){
$level->setTickRate(max($this->baseTickRate + 1, min($this->autoTickRateLimit, floor($tickMs / 50))));
$this->getLogger()->debug("Level \"".$level->getName()."\" took ".round($tickMs, 2)."ms, setting tick rate to ".$level->getTickRate()." ticks");
$this->getLogger()->debug(sprintf("Level \"%s\" took %gms, setting tick rate to %d ticks", $level->getName(), round($tickMs, 2), $level->getTickRate()));
}elseif(($tickMs / $level->getTickRate()) >= 50 and $level->getTickRate() < $this->autoTickRateLimit){
$level->setTickRate($level->getTickRate() + 1);
$this->getLogger()->debug("Level \"".$level->getName()."\" took ".round($tickMs, 2)."ms, setting tick rate to ".$level->getTickRate()." ticks");
$this->getLogger()->debug(sprintf("Level \"%s\" took %gms, setting tick rate to %d ticks", $level->getName(), round($tickMs, 2), $level->getTickRate()));
}
$level->tickRateCounter = $level->getTickRate();
}
@ -2340,9 +2288,9 @@ class Server{
}
$d = Utils::getRealMemoryUsage();
$u = Utils::getMemoryUsage(true);
$usage = round(($u[0] / 1024) / 1024, 2) . "/" . round(($d[0] / 1024) / 1024, 2) . "/" . round(($u[1] / 1024) / 1024, 2) . "/".round(($u[2] / 1024) / 1024, 2)." MB @ " . Utils::getThreadCount() . " threads";
$usage = sprintf("%g/%g/%g/%g MB @ %d threads", round(($u[0] / 1024) / 1024, 2), round(($d[0] / 1024) / 1024, 2), round(($u[1] / 1024) / 1024, 2), round(($u[2] / 1024) / 1024, 2), Utils::getThreadCount());
echo "\x1b]0;" . $this->getName() . " " .
$this->getPocketMineVersion() .
@ -2503,10 +2451,11 @@ class Server{
private function registerTiles(){
Tile::registerTile(Chest::class);
Tile::registerTile(EnchantTable::class);
Tile::registerTile(FlowerPot::class);
Tile::registerTile(Furnace::class);
Tile::registerTile(Sign::class);
Tile::registerTile(Skull::class);
Tile::registerTile(EnchantTable::class);
}
}

View File

@ -28,7 +28,7 @@ abstract class Worker extends \Worker{
/** @var \ClassLoader */
protected $classLoader;
protected $isKilled = false;
public function getClassLoader(){
@ -73,7 +73,7 @@ abstract class Worker extends \Worker{
$this->isKilled = true;
$this->notify();
if($this->isRunning()){
$this->shutdown();
$this->notify();

View File

@ -21,36 +21,11 @@
namespace pocketmine\block;
use pocketmine\item\Item;
use pocketmine\item\Tool;
class AcaciaWoodStairs extends Stair{
class AcaciaWoodStairs extends WoodStairs{
protected $id = self::ACACIA_WOOD_STAIRS;
public function __construct($meta = 0){
$this->meta = $meta;
}
public function getName(){
return "Acacia Wood Stairs";
}
public function getDrops(Item $item){
return [
[$this->id, 0, 1],
];
}
public function getHardness(){
return 2;
}
public function getResistance(){
return 15;
}
public function getToolType(){
return Tool::TYPE_AXE;
}
}

View File

@ -21,15 +21,15 @@
namespace pocketmine\block;
class ActivatorRail extends Solid {
class ActivatorRail extends Solid{
protected $id = self::ACTIVATOR_RAIL;
protected $id = self::ACTIVATOR_RAIL;
public function __construct($meta = 0){
$this->meta = $meta;
}
public function __construct($meta = 0){
$this->meta = $meta;
}
public function getName(){
return "Activator Rail";
}
public function getName(){
return "Activator Rail";
}
}

View File

@ -28,6 +28,10 @@ use pocketmine\Player;
class Anvil extends Fallable{
const TYPE_NORMAL = 0;
const TYPE_SLIGHTLY_DAMAGED = 4;
const TYPE_VERY_DAMAGED = 8;
protected $id = self::ANVIL;
public function isSolid(){
@ -51,7 +55,12 @@ class Anvil extends Fallable{
}
public function getName(){
return "Anvil";
static $names = [
self::TYPE_NORMAL => "Anvil",
self::TYPE_SLIGHTLY_DAMAGED => "Slightly Damaged Anvil",
self::TYPE_VERY_DAMAGED => "Very Damaged Anvil"
];
return $names[$this->meta & 0x0c] ?? "Anvil";
}
public function getToolType(){
@ -60,20 +69,22 @@ class Anvil extends Fallable{
public function onActivate(Item $item, Player $player = null){
if($player instanceof Player){
if($player->isCreative()){
return true;
}
$player->addWindow(new AnvilInventory($this));
}
return true;
}
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){
$direction = ($player !== null ? $player->getDirection() : 0) & 0x03;
$this->meta = ($this->meta & 0x0c) | $direction;
$this->getLevel()->setBlock($block, $this, true, true);
}
public function getDrops(Item $item){
if($item->isPickaxe() >= Tool::TIER_WOODEN){
return [
[$this->id, 0, 1], //TODO break level
[$this->id, $this->meta & 0x0c, 1],
];
}else{
return [];

View File

@ -21,36 +21,11 @@
namespace pocketmine\block;
use pocketmine\item\Item;
use pocketmine\item\Tool;
class BirchWoodStairs extends Stair{
class BirchWoodStairs extends WoodStairs{
protected $id = self::BIRCH_WOOD_STAIRS;
public function __construct($meta = 0){
$this->meta = $meta;
}
public function getName(){
return "Birch Wood Stairs";
}
public function getDrops(Item $item){
return [
[$this->id, 0, 1],
];
}
public function getHardness(){
return 2;
}
public function getResistance(){
return 15;
}
public function getToolType(){
return Tool::TYPE_AXE;
}
}

View File

@ -25,8 +25,6 @@
namespace pocketmine\block;
use pocketmine\entity\Entity;
use pocketmine\item\Item;
use pocketmine\item\Tool;
use pocketmine\level\Level;
@ -39,242 +37,7 @@ use pocketmine\metadata\MetadataValue;
use pocketmine\Player;
use pocketmine\plugin\Plugin;
class Block extends Position implements Metadatable{
const AIR = 0;
const STONE = 1;
const GRASS = 2;
const DIRT = 3;
const COBBLESTONE = 4;
const COBBLE = 4;
const PLANK = 5;
const PLANKS = 5;
const WOODEN_PLANK = 5;
const WOODEN_PLANKS = 5;
const SAPLING = 6;
const SAPLINGS = 6;
const BEDROCK = 7;
const WATER = 8;
const STILL_WATER = 9;
const LAVA = 10;
const STILL_LAVA = 11;
const SAND = 12;
const GRAVEL = 13;
const GOLD_ORE = 14;
const IRON_ORE = 15;
const COAL_ORE = 16;
const LOG = 17;
const WOOD = 17;
const TRUNK = 17;
const LEAVES = 18;
const LEAVE = 18;
const SPONGE = 19;
const GLASS = 20;
const LAPIS_ORE = 21;
const LAPIS_BLOCK = 22;
const SANDSTONE = 24;
const NOTE_BLOCK = 25;
const BED_BLOCK = 26;
const POWERED_RAIL = 27;
const DETECTOR_RAIL = 28;
const COBWEB = 30;
const TALL_GRASS = 31;
const BUSH = 32;
const DEAD_BUSH = 32;
const WOOL = 35;
const DANDELION = 37;
const POPPY = 38;
const ROSE = 38;
const RED_FLOWER = 38;
const BROWN_MUSHROOM = 39;
const RED_MUSHROOM = 40;
const GOLD_BLOCK = 41;
const IRON_BLOCK = 42;
const DOUBLE_SLAB = 43;
const DOUBLE_SLABS = 43;
const SLAB = 44;
const SLABS = 44;
const BRICKS = 45;
const BRICKS_BLOCK = 45;
const TNT = 46;
const BOOKSHELF = 47;
const MOSS_STONE = 48;
const MOSSY_STONE = 48;
const OBSIDIAN = 49;
const TORCH = 50;
const FIRE = 51;
const MONSTER_SPAWNER = 52;
const WOOD_STAIRS = 53;
const WOODEN_STAIRS = 53;
const OAK_WOOD_STAIRS = 53;
const OAK_WOODEN_STAIRS = 53;
const CHEST = 54;
const REDSTONE_WIRE = 55;
const DIAMOND_ORE = 56;
const DIAMOND_BLOCK = 57;
const CRAFTING_TABLE = 58;
const WORKBENCH = 58;
const WHEAT_BLOCK = 59;
const FARMLAND = 60;
const FURNACE = 61;
const BURNING_FURNACE = 62;
const LIT_FURNACE = 62;
const SIGN_POST = 63;
const DOOR_BLOCK = 64;
const WOODEN_DOOR_BLOCK = 64;
const WOOD_DOOR_BLOCK = 64;
const LADDER = 65;
const RAIL = 66;
const COBBLE_STAIRS = 67;
const COBBLESTONE_STAIRS = 67;
const WALL_SIGN = 68;
const LEVER = 69;
const STONE_PRESSURE_PLATE = 70;
const IRON_DOOR_BLOCK = 71;
const WOODEN_PRESSURE_PLATE = 72;
const REDSTONE_ORE = 73;
const GLOWING_REDSTONE_ORE = 74;
const LIT_REDSTONE_ORE = 74;
const REDSTONE_TORCH = 75;
const LIT_REDSTONE_TORCH = 76;
const STONE_BUTTON = 77;
const SNOW = 78;
const SNOW_LAYER = 78;
const ICE = 79;
const SNOW_BLOCK = 80;
const CACTUS = 81;
const CLAY_BLOCK = 82;
const REEDS = 83;
const SUGARCANE_BLOCK = 83;
const FENCE = 85;
const PUMPKIN = 86;
const NETHERRACK = 87;
const SOUL_SAND = 88;
const GLOWSTONE = 89;
const GLOWSTONE_BLOCK = 89;
const PORTAL_BLOCK = 90;
const LIT_PUMPKIN = 91;
const JACK_O_LANTERN = 91;
const CAKE_BLOCK = 92;
const TRAPDOOR = 96;
const MONSTER_EGG_BLOCK = 97;
const STONE_BRICKS = 98;
const STONE_BRICK = 98;
const BROWN_MUSHROOM_BLOCK = 99;
const RED_MUSHROOM_BLOCK = 100;
const IRON_BAR = 101;
const IRON_BARS = 101;
const GLASS_PANE = 102;
const GLASS_PANEL = 102;
const MELON_BLOCK = 103;
const PUMPKIN_STEM = 104;
const MELON_STEM = 105;
const VINE = 106;
const VINES = 106;
const FENCE_GATE = 107;
const BRICK_STAIRS = 108;
const STONE_BRICK_STAIRS = 109;
const MYCELIUM = 110;
const WATER_LILY = 111;
const LILY_PAD = 111;
const NETHER_BRICKS = 112;
const NETHER_BRICK_BLOCK = 112;
const NETHER_BRICK_FENCE = 113;
const NETHER_BRICKS_STAIRS = 114;
const NETHER_WART_BLOCK = 115;
const ENCHANTING_TABLE = 116;
const ENCHANT_TABLE = 116;
const ENCHANTMENT_TABLE = 116;
const BREWING_STAND = 117;
const END_PORTAL_FRAME = 120;
const END_STONE = 121;
const REDSTONE_LAMP = 122;
const LIT_REDSTONE_LAMP = 123;
const ACTIVATOR_RAIL = 126;
const COCOA_BLOCK = 127;
const SANDSTONE_STAIRS = 128;
const EMERALD_ORE = 129;
const TRIPWIRE_HOOK = 131;
const TRIPWIRE = 132;
const EMERALD_BLOCK = 133;
const SPRUCE_WOOD_STAIRS = 134;
const SPRUCE_WOODEN_STAIRS = 134;
const BIRCH_WOOD_STAIRS = 135;
const BIRCH_WOODEN_STAIRS = 135;
const JUNGLE_WOOD_STAIRS = 136;
const JUNGLE_WOODEN_STAIRS = 136;
const COBBLE_WALL = 139;
const STONE_WALL = 139;
const COBBLESTONE_WALL = 139;
const FLOWER_POT_BLOCK = 140;
const CARROT_BLOCK = 141;
const POTATO_BLOCK = 142;
const WOODEN_BUTTON = 143;
const MOB_HEAD = 144;
const SKULL = 144;
const ANVIL = 145;
const TRAPPED_CHEST = 146;
const WEIGHTED_PRESSURE_PLATE_LIGHT = 147;
const WEIGHTED_PRESSURE_PLATE_HEAVY = 148;
const DAYLIGHT_SENSOR = 151;
const REDSTONE_BLOCK = 152;
const NETHER_QUARTZ_ORE = 153;
const QUARTZ_BLOCK = 155;
const QUARTZ_STAIRS = 156;
const DOUBLE_WOOD_SLAB = 157;
const DOUBLE_WOODEN_SLAB = 157;
const DOUBLE_WOOD_SLABS = 157;
const DOUBLE_WOODEN_SLABS = 157;
const WOOD_SLAB = 158;
const WOODEN_SLAB = 158;
const WOOD_SLABS = 158;
const WOODEN_SLABS = 158;
const STAINED_CLAY = 159;
const STAINED_HARDENED_CLAY = 159;
const LEAVES2 = 161;
const LEAVE2 = 161;
const WOOD2 = 162;
const TRUNK2 = 162;
const LOG2 = 162;
const ACACIA_WOOD_STAIRS = 163;
const ACACIA_WOODEN_STAIRS = 163;
const DARK_OAK_WOOD_STAIRS = 164;
const DARK_OAK_WOODEN_STAIRS = 164;
const IRON_TRAPDOOR = 167;
const HAY_BALE = 170;
const CARPET = 171;
const HARDENED_CLAY = 172;
const COAL_BLOCK = 173;
const PACKED_ICE = 174;
const DOUBLE_PLANT = 175;
const INVERTED_DAYLIGHT_SENSOR = 178;
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 GRASS_PATH = 198;
const PODZOL = 243;
const BEETROOT_BLOCK = 244;
const STONECUTTER = 245;
const GLOWING_OBSIDIAN = 246;
class Block extends Position implements BlockIds, Metadatable{
/** @var \SplFixedArray */
public static $list = null;
@ -421,7 +184,7 @@ class Block extends Position implements Metadatable{
self::$list[self::NETHER_BRICKS_STAIRS] = NetherBrickStairs::class;
self::$list[self::ENCHANTING_TABLE] = EnchantingTable::class;
self::$list[self::BREWING_STAND] = BrewingStand::class;
self::$list[self::BREWING_STAND_BLOCK] = BrewingStand::class;
self::$list[self::END_PORTAL_FRAME] = EndPortalFrame::class;
self::$list[self::END_STONE] = EndStone::class;
self::$list[self::REDSTONE_LAMP] = RedstoneLamp::class;
@ -439,12 +202,12 @@ class Block extends Position implements Metadatable{
self::$list[self::CARROT_BLOCK] = Carrot::class;
self::$list[self::POTATO_BLOCK] = Potato::class;
self::$list[self::WOODEN_BUTTON] = WoodenButton::class;
self::$list[self::MOB_HEAD] = MobHead::class;
self::$list[self::MOB_HEAD_BLOCK] = MobHead::class;
self::$list[self::ANVIL] = Anvil::class;
self::$list[self::TRAPPED_CHEST] = TrappedChest::class;
self::$list[self::WEIGHTED_PRESSURE_PLATE_LIGHT] = WeightedPressurePlateLight::class;
self::$list[self::WEIGHTED_PRESSURE_PLATE_HEAVY] = WeightedPressurePlateHeavy::class;
self::$list[self::DAYLIGHT_SENSOR] = DaylightSensor::class;
self::$list[self::REDSTONE_BLOCK] = Redstone::class;

View File

@ -0,0 +1,230 @@
<?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;
interface BlockIds{
const AIR = 0;
const STONE = 1;
const GRASS = 2;
const DIRT = 3;
const COBBLESTONE = 4, COBBLE = 4;
const PLANK = 5, PLANKS = 5, WOODEN_PLANK = 5, WOODEN_PLANKS = 5;
const SAPLING = 6, SAPLINGS = 6;
const BEDROCK = 7;
const WATER = 8;
const STILL_WATER = 9;
const LAVA = 10;
const STILL_LAVA = 11;
const SAND = 12;
const GRAVEL = 13;
const GOLD_ORE = 14;
const IRON_ORE = 15;
const COAL_ORE = 16;
const LOG = 17, WOOD = 17, TRUNK = 17;
const LEAVES = 18;
const SPONGE = 19;
const GLASS = 20;
const LAPIS_ORE = 21;
const LAPIS_BLOCK = 22;
const DISPENSER = 23;
const SANDSTONE = 24;
const NOTE_BLOCK = 25, NOTEBLOCK = 25;
const BED_BLOCK = 26;
const POWERED_RAIL = 27;
const DETECTOR_RAIL = 28;
const STICKY_PISTON = 29;
const COBWEB = 30;
const TALL_GRASS = 31;
const BUSH = 32, DEAD_BUSH = 32;
const PISTON = 33;
const PISTON_HEAD = 34;
const WOOL = 35;
const DANDELION = 37;
const POPPY = 38, ROSE = 38, RED_FLOWER = 38;
const BROWN_MUSHROOM = 39;
const RED_MUSHROOM = 40;
const GOLD_BLOCK = 41;
const IRON_BLOCK = 42;
const DOUBLE_SLAB = 43, DOUBLE_SLABS = 43;
const SLAB = 44, SLABS = 44, STONE_SLAB = 44;
const BRICKS = 45, BRICKS_BLOCK = 45;
const TNT = 46;
const BOOKSHELF = 47;
const MOSS_STONE = 48, MOSSY_STONE = 48;
const OBSIDIAN = 49;
const TORCH = 50;
const FIRE = 51;
const MONSTER_SPAWNER = 52;
const WOOD_STAIRS = 53, WOODEN_STAIRS = 53, OAK_WOOD_STAIRS = 53, OAK_WOODEN_STAIRS = 53;
const CHEST = 54;
const REDSTONE_WIRE = 55;
const DIAMOND_ORE = 56;
const DIAMOND_BLOCK = 57;
const CRAFTING_TABLE = 58, WORKBENCH = 58;
const WHEAT_BLOCK = 59;
const FARMLAND = 60;
const FURNACE = 61;
const BURNING_FURNACE = 62, LIT_FURNACE = 62;
const SIGN_POST = 63;
const DOOR_BLOCK = 64, WOODEN_DOOR_BLOCK = 64, WOOD_DOOR_BLOCK = 64;
const LADDER = 65;
const RAIL = 66;
const COBBLESTONE_STAIRS = 67, COBBLE_STAIRS = 67;
const WALL_SIGN = 68;
const LEVER = 69;
const STONE_PRESSURE_PLATE = 70;
const IRON_DOOR_BLOCK = 71;
const WOODEN_PRESSURE_PLATE = 72;
const REDSTONE_ORE = 73;
const GLOWING_REDSTONE_ORE = 74, LIT_REDSTONE_ORE = 74;
const UNLIT_REDSTONE_TORCH = 75;
const REDSTONE_TORCH = 76, LIT_REDSTONE_TORCH = 76;
const STONE_BUTTON = 77;
const SNOW = 78, SNOW_LAYER = 78;
const ICE = 79;
const SNOW_BLOCK = 80;
const CACTUS = 81;
const CLAY_BLOCK = 82;
const REEDS = 83, SUGARCANE_BLOCK = 83;
const FENCE = 85;
const PUMPKIN = 86;
const NETHERRACK = 87;
const SOUL_SAND = 88;
const GLOWSTONE = 89, GLOWSTONE_BLOCK = 89;
const PORTAL_BLOCK = 90, PORTAL = 90;
const JACK_O_LANTERN = 91, LIT_PUMPKIN = 91;
const CAKE_BLOCK = 92;
const REPEATER_BLOCK = 93, UNPOWERED_REPEATER_BLOCK = 93;
const POWERED_REPEATER_BLOCK = 94;
const INVISIBLE_BEDROCK = 95;
const TRAPDOOR = 96, WOODEN_TRAPDOOR = 96;
const MONSTER_EGG_BLOCK = 97;
const STONE_BRICKS = 98, STONE_BRICK = 98;
const BROWN_MUSHROOM_BLOCK = 99;
const RED_MUSHROOM_BLOCK = 100;
const IRON_BARS = 101, IRON_BAR = 101;
const GLASS_PANE = 102, GLASS_PANEL = 102;
const MELON_BLOCK = 103;
const PUMPKIN_STEM = 104;
const MELON_STEM = 105;
const VINES = 106, VINE = 106;
const FENCE_GATE = 107, OAK_FENCE_GATE = 107;
const BRICK_STAIRS = 108;
const STONE_BRICK_STAIRS = 109;
const MYCELIUM = 110;
const LILY_PAD = 111, WATER_LILY = 111;
const NETHER_BRICKS = 112, NETHER_BRICK_BLOCK = 112;
const NETHER_BRICK_FENCE = 113;
const NETHER_BRICK_STAIRS = 114, NETHER_BRICKS_STAIRS = 114;
const NETHER_WART_BLOCK = 115;
const ENCHANTING_TABLE = 116, ENCHANT_TABLE = 116, ENCHANTMENT_TABLE = 116;
const BREWING_STAND_BLOCK = 117;
const CAULDRON_BLOCK = 118;
const END_PORTAL_FRAME = 120, END_PORTAL = 120;
const END_STONE = 121;
const REDSTONE_LAMP = 123, INACTIVE_REDSTONE_LAMP = 123;
const LIT_REDSTONE_LAMP = 124, ACTIVE_REDSTONE_LAMP = 124;
const DROPPER = 125;
const ACTIVATOR_RAIL = 126;
const COCOA_BLOCK = 127, COCOA_PODS = 127;
const SANDSTONE_STAIRS = 128;
const EMERALD_ORE = 129;
const TRIPWIRE_HOOK = 131;
const TRIPWIRE = 132;
const EMERALD_BLOCK = 133;
const SPRUCE_WOOD_STAIRS = 134, SPRUCE_WOODEN_STAIRS = 134;
const BIRCH_WOOD_STAIRS = 135, BIRCH_WOODEN_STAIRS = 135;
const JUNGLE_WOOD_STAIRS = 136, JUNGLE_WOODEN_STAIRS = 136;
const COBBLESTONE_WALL = 139, COBBLE_WALL = 139, STONE_WALL = 139;
const FLOWER_POT_BLOCK = 140;
const CARROT_BLOCK = 141;
const POTATO_BLOCK = 142;
const WOODEN_BUTTON = 143;
const MOB_HEAD_BLOCK = 144, SKULL_BLOCK = 144;
const ANVIL = 145;
const TRAPPED_CHEST = 146;
const WEIGHTED_PRESSURE_PLATE_LIGHT = 147, LIGHT_WEIGHTED_PRESSURE_PLATE = 147, GOLD_PRESSURE_PLATE = 147;
const WEIGHTED_PRESSURE_PLATE_HEAVY = 148, HEAVY_WEIGHTED_PRESSURE_PLATE = 148, IRON_PRESSURE_PLATE = 148;
const COMPARATOR_BLOCK = 149, UNPOWERED_COMPARATOR_BLOCK = 149;
const POWERED_COMPARATOR_BLOCK = 150;
const DAYLIGHT_SENSOR = 151;
const REDSTONE_BLOCK = 152;
const NETHER_QUARTZ_ORE = 153;
const HOPPER_BLOCK = 154;
const QUARTZ_BLOCK = 155;
const QUARTZ_STAIRS = 156;
const DOUBLE_WOOD_SLAB = 157, DOUBLE_WOODEN_SLAB = 157, DOUBLE_WOOD_SLABS = 157, DOUBLE_WOODEN_SLABS = 157;
const WOOD_SLAB = 158, WOODEN_SLAB = 158, WOOD_SLABS = 158, WOODEN_SLABS = 158;
const STAINED_CLAY = 159, STAINED_HARDENED_CLAY = 159;
const LEAVES2 = 161;
const WOOD2 = 162, TRUNK2 = 162, LOG2 = 162;
const ACACIA_WOOD_STAIRS = 163, ACACIA_WOODEN_STAIRS = 163;
const DARK_OAK_WOOD_STAIRS = 164, DARK_OAK_WOODEN_STAIRS = 164;
const SLIME_BLOCK = 165;
const IRON_TRAPDOOR = 167;
const HAY_BALE = 170;
const CARPET = 171;
const HARDENED_CLAY = 172;
const COAL_BLOCK = 173;
const PACKED_ICE = 174;
const DOUBLE_PLANT = 175;
const INVERTED_DAYLIGHT_SENSOR = 178, DAYLIGHT_SENSOR_INVERTED = 178;
const RED_SANDSTONE = 179;
const RED_SANDSTONE_STAIRS = 180;
const DOUBLE_RED_SANDSTONE_SLAB = 181;
const RED_SANDSTONE_SLAB = 182;
const SPRUCE_FENCE_GATE = 183, FENCE_GATE_SPRUCE = 183;
const BIRCH_FENCE_GATE = 184, FENCE_GATE_BIRCH = 184;
const JUNGLE_FENCE_GATE = 185, FENCE_GATE_JUNGLE = 185;
const DARK_OAK_FENCE_GATE = 186, FENCE_GATE_DARK_OAK = 186;
const ACACIA_FENCE_GATE = 187, FENCE_GATE_ACACIA = 187;
const SPRUCE_DOOR_BLOCK = 193;
const BIRCH_DOOR_BLOCK = 194;
const JUNGLE_DOOR_BLOCK = 195;
const ACACIA_DOOR_BLOCK = 196;
const DARK_OAK_DOOR_BLOCK = 197;
const GRASS_PATH = 198;
const ITEM_FRAME_BLOCK = 199;
const PODZOL = 243;
const BEETROOT_BLOCK = 244;
const STONECUTTER = 245;
const GLOWING_OBSIDIAN = 246;
const NETHER_REACTOR = 247;
const UPDATE_BLOCK = 248;
const ATEUPD_BLOCK = 249;
const BLOCK_MOVED_BY_PISTON = 250;
const OBSERVER = 251;
const INFO_RESERVED6 = 255;
}

View File

@ -21,7 +21,6 @@
namespace pocketmine\block;
use pocketmine\item\Tool;
class Bookshelf extends Solid{

View File

@ -21,12 +21,11 @@
namespace pocketmine\block;
use pocketmine\item\Item;
use pocketmine\item\Tool;
class BrewingStand extends Transparent{
protected $id = self::BREWING_STAND;
protected $id = self::BREWING_STAND_BLOCK;
public function __construct(){

View File

@ -21,7 +21,6 @@
namespace pocketmine\block;
use pocketmine\item\Tool;
class BrickStairs extends Stair{

View File

@ -25,8 +25,8 @@ use pocketmine\item\Item;
use pocketmine\item\Tool;
use pocketmine\nbt\NBT;
use pocketmine\nbt\tag\CompoundTag;
use pocketmine\nbt\tag\ListTag;
use pocketmine\nbt\tag\IntTag;
use pocketmine\nbt\tag\ListTag;
use pocketmine\nbt\tag\StringTag;
use pocketmine\Player;
use pocketmine\tile\Furnace;
@ -123,10 +123,6 @@ class BurningFurnace extends Solid{
}
}
if($player->isCreative()){
return true;
}
$player->addWindow($furnace->getInventory());
}

View File

@ -26,8 +26,8 @@ use pocketmine\item\Tool;
use pocketmine\math\AxisAlignedBB;
use pocketmine\nbt\NBT;
use pocketmine\nbt\tag\CompoundTag;
use pocketmine\nbt\tag\ListTag;
use pocketmine\nbt\tag\IntTag;
use pocketmine\nbt\tag\ListTag;
use pocketmine\nbt\tag\StringTag;
use pocketmine\Player;
use pocketmine\tile\Chest as TileChest;
@ -86,7 +86,7 @@ class Chest extends Transparent{
continue;
}
$c = $this->getSide($side);
if($c instanceof Chest and $c->getDamage() === $this->meta){
if($c->getId() === $this->id and $c->getDamage() === $this->meta){
$tile = $this->getLevel()->getTile($c);
if($tile instanceof TileChest and !$tile->isPaired()){
$chest = $tile;
@ -164,9 +164,6 @@ class Chest extends Transparent{
}
}
if($player->isCreative()){
return true;
}
$player->addWindow($chest->getInventory());
}

View File

@ -21,7 +21,6 @@
namespace pocketmine\block;
use pocketmine\item\Tool;
class CobblestoneStairs extends Stair{

View File

@ -21,15 +21,15 @@
namespace pocketmine\block;
class CocoaBlock extends Solid {
class CocoaBlock extends Solid{
protected $id = self::COCOA_BLOCK;
protected $id = self::COCOA_BLOCK;
public function __construct($meta = 0){
$this->meta = $meta;
}
public function __construct($meta = 0){
$this->meta = $meta;
}
public function getName(){
return "Cocoa Block";
}
public function getName(){
return "Cocoa Block";
}
}

View File

@ -21,28 +21,11 @@
namespace pocketmine\block;
use pocketmine\item\Item;
use pocketmine\item\Tool;
class DarkOakWoodStairs extends Stair{
class DarkOakWoodStairs extends WoodStairs{
protected $id = self::DARK_OAK_WOOD_STAIRS;
public function __construct($meta = 0){
$this->meta = $meta;
}
public function getName(){
return "Dark Oak Wood Stairs";
}
public function getToolType(){
return Tool::TYPE_AXE;
}
public function getDrops(Item $item){
return [
[$this->id, 0, 1],
];
}
}

View File

@ -21,15 +21,15 @@
namespace pocketmine\block;
class DaylightSensor extends Solid {
class DaylightSensor extends Solid{
protected $id = self::DAYLIGHT_SENSOR;
protected $id = self::DAYLIGHT_SENSOR;
public function __construct($meta = 0){
$this->meta = $meta;
}
public function __construct($meta = 0){
$this->meta = $meta;
}
public function getName(){
return "Daylight Sensor";
}
public function getName(){
return "Daylight Sensor";
}
}

View File

@ -21,15 +21,15 @@
namespace pocketmine\block;
class DetectorRail extends Solid {
class DetectorRail extends Solid{
protected $id = self::DETECTOR_RAIL;
protected $id = self::DETECTOR_RAIL;
public function __construct($meta = 0){
$this->meta = $meta;
}
public function __construct($meta = 0){
$this->meta = $meta;
}
public function getName(){
return "Detector Rail";
}
public function getName(){
return "Detector Rail";
}
}

View File

@ -24,7 +24,6 @@ namespace pocketmine\block;
use pocketmine\inventory\EnchantInventory;
use pocketmine\item\Item;
use pocketmine\item\Tool;
use pocketmine\nbt\tag\CompoundTag;
use pocketmine\nbt\tag\IntTag;
use pocketmine\nbt\tag\StringTag;
@ -86,9 +85,6 @@ class EnchantingTable extends Transparent{
public function onActivate(Item $item, Player $player = null){
if($player instanceof Player){
//TODO lock
if($player->isCreative()){
return true;
}
$player->addWindow(new EnchantInventory($this));
}

View File

@ -21,7 +21,6 @@
namespace pocketmine\block;
use pocketmine\item\Tool;
class EndStone extends Solid{

View File

@ -28,9 +28,9 @@ use pocketmine\math\Vector3;
use pocketmine\nbt\tag\ByteTag;
use pocketmine\nbt\tag\CompoundTag;
use pocketmine\nbt\tag\DoubleTag;
use pocketmine\nbt\tag\ListTag;
use pocketmine\nbt\tag\FloatTag;
use pocketmine\nbt\tag\IntTag;
use pocketmine\nbt\tag\ListTag;
use pocketmine\Player;
abstract class Fallable extends Solid{

View File

@ -26,13 +26,13 @@ use pocketmine\math\AxisAlignedBB;
use pocketmine\math\Vector3;
class Fence extends Transparent{
const FENCE_OAK = 0;
const FENCE_OAK = 0;
const FENCE_SPRUCE = 1;
const FENCE_BIRCH = 2;
const FENCE_JUNGLE = 3;
const FENCE_ACACIA = 4;
const FENCE_DARKOAK = 5;
protected $id = self::FENCE;
public function __construct($meta = 0){

View File

@ -59,7 +59,7 @@ class FenceGate extends Transparent{
}
$i = ($this->getDamage() & 0x03);
if($i === 2 and $i === 0){
if($i === 2 or $i === 0){
return new AxisAlignedBB(
$this->x,
$this->y,
@ -100,13 +100,9 @@ class FenceGate extends Transparent{
}
public function onActivate(Item $item, Player $player = null){
$faces = [
0 => 3,
1 => 0,
2 => 1,
3 => 2,
];
$this->meta = ($faces[$player instanceof Player ? $player->getDirection() : 0] & 0x03) | ((~$this->meta) & 0x04);
$this->meta ^= 0x04; //Flip open/close state
//TODO: Face player when opened
$this->getLevel()->setBlock($this, $this, true);
$this->level->addSound(new DoorSound($this));
return true;

View File

@ -21,9 +21,6 @@
namespace pocketmine\block;
abstract class Flowable extends Transparent{
public function canBeFlowedInto(){
@ -42,7 +39,7 @@ abstract class Flowable extends Transparent{
return false;
}
public function getBoundingBox(){
protected function recalculateBoundingBox(){
return null;
}
}

View File

@ -22,8 +22,21 @@
namespace pocketmine\block;
use pocketmine\item\Item;
use pocketmine\level\Level;
use pocketmine\math\AxisAlignedBB;
use pocketmine\math\Vector3;
use pocketmine\nbt\tag\CompoundTag;
use pocketmine\nbt\tag\IntTag;
use pocketmine\nbt\tag\ShortTag;
use pocketmine\nbt\tag\StringTag;
use pocketmine\Player;
use pocketmine\tile\FlowerPot as TileFlowerPot;
use pocketmine\tile\Tile;
class FlowerPot extends Transparent{
class FlowerPot extends Flowable{
const STATE_EMPTY = 0;
const STATE_FULL = 1;
protected $id = self::FLOWER_POT_BLOCK;
@ -35,4 +48,90 @@ class FlowerPot extends Transparent{
return "Flower Pot Block";
}
public function canBeActivated(): bool{
return true;
}
public function getBoundingBox(){
return new AxisAlignedBB(
$this->x + (5 / 16),
$this->y,
$this->z + (5 / 16),
$this->x + (11 / 16),
$this->y + (6 / 16),
$this->z + (11 / 16)
);
}
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){
if($this->getSide(Vector3::SIDE_DOWN)->isTransparent()){
return false;
}
$this->getLevel()->setBlock($block, $this, true, true);
$nbt = new CompoundTag("", [
new StringTag("id", Tile::FLOWER_POT),
new IntTag("x", $block->x),
new IntTag("y", $block->y),
new IntTag("z", $block->z),
new ShortTag("item", 0),
new IntTag("mData", 0),
]);
if($item->hasCustomBlockData()){
foreach($item->getCustomBlockData() as $key => $v){
$nbt->{$key} = $v;
}
}
Tile::createTile(Tile::FLOWER_POT, $this->getLevel()->getChunk($this->x >> 4, $this->z >> 4), $nbt);
return true;
}
public function onUpdate($type){
if($type === Level::BLOCK_UPDATE_NORMAL){
if($this->getSide(0)->isTransparent() === true){
$this->getLevel()->useBreakOn($this);
return Level::BLOCK_UPDATE_NORMAL;
}
}
return false;
}
public function onActivate(Item $item, Player $player = null){
$pot = $this->getLevel()->getTile($this);
if(!($pot instanceof TileFlowerPot)){
return false;
}
if(!$pot->canAddItem($item)){
return false;
}
$this->setDamage(self::STATE_FULL); //specific damage value is unnecessary, it just needs to be non-zero to show an item.
$this->getLevel()->setBlock($this, $this, true, false);
$pot->setItem($item);
if($player instanceof Player){
if($player->isSurvival()){
$item->setCount($item->getCount() - 1);
$player->getInventory()->setItemInHand($item->getCount() > 0 ? $item : Item::get(Item::AIR));
}
}
return true;
}
public function getDrops(Item $item){
$items = [[Item::FLOWER_POT, 0, 1]];
$tile = $this->getLevel()->getTile($this);
if($tile instanceof TileFlowerPot){
if(($item = $tile->getItem())->getId() !== Item::AIR){
$items[] = [$item->getId(), $item->getDamage(), 1];
}
}
return $items;
}
}

View File

@ -21,7 +21,6 @@
namespace pocketmine\block;
use pocketmine\item\Item;
class GlassPane extends Thin{

View File

@ -22,7 +22,7 @@
namespace pocketmine\block;
class GlowingObsidian extends Solid{
class GlowingObsidian extends Transparent{
protected $id = self::GLOWING_OBSIDIAN;

View File

@ -21,14 +21,10 @@
namespace pocketmine\block;
use pocketmine\item\Item;
use pocketmine\item\Tool;
use pocketmine\math\AxisAlignedBB;
class GrassPath extends Transparent{
protected $id = self::GRASS_PATH;

View File

@ -21,7 +21,6 @@
namespace pocketmine\block;
use pocketmine\item\Tool;
class HardenedClay extends Solid{

View File

@ -21,28 +21,11 @@
namespace pocketmine\block;
use pocketmine\item\Item;
use pocketmine\item\Tool;
class JungleWoodStairs extends Stair{
class JungleWoodStairs extends WoodStairs{
protected $id = self::JUNGLE_WOOD_STAIRS;
public function __construct($meta = 0){
$this->meta = $meta;
}
public function getName(){
return "Jungle Wood Stairs";
}
public function getToolType(){
return Tool::TYPE_AXE;
}
public function getDrops(Item $item){
return [
[$this->id, 0, 1],
];
}
}

View File

@ -21,15 +21,15 @@
namespace pocketmine\block;
class Lever extends Solid {
class Lever extends Solid{
protected $id = self::LEVER;
protected $id = self::LEVER;
public function __construct($meta = 0){
$this->meta = $meta;
}
public function __construct($meta = 0){
$this->meta = $meta;
}
public function getName(){
return "Lever";
}
public function getName(){
return "Lever";
}
}

View File

@ -21,7 +21,6 @@
namespace pocketmine\block;
use pocketmine\entity\Entity;
use pocketmine\item\Item;
use pocketmine\level\Level;

View File

@ -21,15 +21,15 @@
namespace pocketmine\block;
class LitRedstoneLamp extends Solid {
class LitRedstoneLamp extends Solid{
protected $id = self::LIT_REDSTONE_LAMP;
protected $id = self::LIT_REDSTONE_LAMP;
public function __construct($meta = 0){
$this->meta = $meta;
}
public function __construct($meta = 0){
$this->meta = $meta;
}
public function getName(){
return "Lit Redstone Lamp";
}
public function getName(){
return "Lit Redstone Lamp";
}
}

View File

@ -21,15 +21,15 @@
namespace pocketmine\block;
class LitRedstoneTorch extends Solid {
class LitRedstoneTorch extends Solid{
protected $id = self::REDSTONE_TORCH;
protected $id = self::REDSTONE_TORCH;
public function __construct($meta = 0){
$this->meta = $meta;
}
public function __construct($meta = 0){
$this->meta = $meta;
}
public function getName(){
return "Lit Redstone Torch";
}
public function getName(){
return "Lit Redstone Torch";
}
}

View File

@ -32,7 +32,9 @@ use pocketmine\tile\Spawnable;
use pocketmine\tile\Tile;
class MobHead extends Solid{
protected $id = self::MOB_HEAD;
protected $id = self::MOB_HEAD_BLOCK;
protected $type;
public function __construct($meta = 0){
@ -59,7 +61,7 @@ class MobHead extends Solid{
$nbt = new CompoundTag("", [
new StringTag("id", Tile::SKULL),
new ByteTag("SkullType", $item->getDamage()),
new ByteTag("Rot", $rot),
new ByteTag("Rot", $rot),
new IntTag("x", (int) $this->x),
new IntTag("y", (int) $this->y),
new IntTag("z", (int) $this->z)

View File

@ -23,20 +23,19 @@ namespace pocketmine\block;
use pocketmine\item\Item;
use pocketmine\item\Tool;
class NetherBrickFence extends Transparent {
class NetherBrickFence extends Transparent{
protected $id = self::NETHER_BRICK_FENCE;
public function __construct($meta = 0){
$this->meta = $meta;
}
public function getBreakTime(Item $item){
if ($item instanceof Air){
if($item instanceof Air){
//Breaking by hand
return 10;
}
else{
}else{
// Other breaktimes are equal to woodfences.
return parent::getBreakTime($item);
}
@ -45,18 +44,17 @@ class NetherBrickFence extends Transparent {
public function getHardness(){
return 2;
}
public function getToolType(){
return Tool::TYPE_PICKAXE;
}
public function getName(){
return "Nether Brick Fence";
}
public function canConnect(Block $block){
//TODO: activate comments when the NetherBrickFenceGate class has been created.
return ($block instanceof NetherBrickFence /* or $block instanceof NetherBrickFenceGate */) ? true : $block->isSolid() and !$block->isTransparent();
return ($block instanceof NetherBrickFence) or ($block->isSolid() and !$block->isTransparent());
}
public function getDrops(Item $item){
@ -67,5 +65,5 @@ class NetherBrickFence extends Transparent {
}else{
return [];
}
}
}
}

View File

@ -21,7 +21,6 @@
namespace pocketmine\block;
use pocketmine\item\Tool;
class NetherBrickStairs extends Stair{

View File

@ -21,15 +21,15 @@
namespace pocketmine\block;
class NoteBlock extends Solid {
class NoteBlock extends Solid{
protected $id = self::NOTE_BLOCK;
protected $id = self::NOTE_BLOCK;
public function __construct($meta = 0){
$this->meta = $meta;
}
public function __construct($meta = 0){
$this->meta = $meta;
}
public function getName(){
return "Note Block";
}
public function getName(){
return "Note Block";
}
}

View File

@ -21,7 +21,6 @@
namespace pocketmine\block;
use pocketmine\item\Item;
use pocketmine\item\Tool;
class PackedIce extends Solid{

View File

@ -21,7 +21,6 @@
namespace pocketmine\block;
use pocketmine\item\Tool;
class Planks extends Solid{

View File

@ -21,14 +21,14 @@
namespace pocketmine\block;
class PoweredRail extends Solid {
protected $id = self::POWERED_RAIL;
class PoweredRail extends Solid{
protected $id = self::POWERED_RAIL;
public function __construct($meta = 0){
$this->meta = $meta;
}
public function __construct($meta = 0){
$this->meta = $meta;
}
public function getName(){
return "Powered Rail";
}
public function getName(){
return "Powered Rail";
}
}

View File

@ -30,7 +30,7 @@ class Quartz extends Solid{
const QUARTZ_CHISELED = 1;
const QUARTZ_PILLAR = 2;
const QUARTZ_PILLAR2 = 3;
protected $id = self::QUARTZ_BLOCK;
public function __construct($meta = 0){

View File

@ -21,7 +21,6 @@
namespace pocketmine\block;
use pocketmine\item\Tool;
class QuartzStairs extends Stair{

View File

@ -21,15 +21,15 @@
namespace pocketmine\block;
class Rail extends Solid {
class Rail extends Solid{
protected $id = self::RAIL;
protected $id = self::RAIL;
public function __construct($meta = 0){
$this->meta = $meta;
}
public function __construct($meta = 0){
$this->meta = $meta;
}
public function getName(){
return "Rail";
}
public function getName(){
return "Rail";
}
}

View File

@ -21,15 +21,15 @@
namespace pocketmine\block;
class RedstoneLamp extends Solid {
class RedstoneLamp extends Solid{
protected $id = self::REDSTONE_LAMP;
protected $id = self::REDSTONE_LAMP;
public function __construct($meta = 0){
$this->meta = $meta;
}
public function __construct($meta = 0){
$this->meta = $meta;
}
public function getName(){
return "Redstone Lamp";
}
public function getName(){
return "Redstone Lamp";
}
}

View File

@ -24,6 +24,7 @@ namespace pocketmine\block;
use pocketmine\item\Item;
use pocketmine\item\Tool;
use pocketmine\level\Level;
use pocketmine\Player;
class RedstoneOre extends Solid{
@ -41,6 +42,10 @@ class RedstoneOre extends Solid{
return 3;
}
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){
return $this->getLevel()->setBlock($this, $this, true, false);
}
public function onUpdate($type){
if($type === Level::BLOCK_UPDATE_NORMAL or $type === Level::BLOCK_UPDATE_TOUCH){
$this->getLevel()->setBlock($this, Block::get(Item::GLOWING_REDSTONE_ORE, $this->meta));

View File

@ -21,15 +21,15 @@
namespace pocketmine\block;
class RedstoneTorch extends Solid {
class RedstoneTorch extends Solid{
protected $id = self::REDSTONE_TORCH;
protected $id = self::REDSTONE_TORCH;
public function __construct($meta = 0){
$this->meta = $meta;
}
public function __construct($meta = 0){
$this->meta = $meta;
}
public function getName(){
return "Redstone Torch";
}
public function getName(){
return "Redstone Torch";
}
}

View File

@ -21,7 +21,6 @@
namespace pocketmine\block;
use pocketmine\item\Tool;
class Sand extends Fallable{

View File

@ -21,7 +21,6 @@
namespace pocketmine\block;
use pocketmine\item\Tool;
class SandstoneStairs extends Stair{

View File

@ -24,7 +24,12 @@ namespace pocketmine\block;
use pocketmine\item\Item;
use pocketmine\item\Tool;
use pocketmine\level\Level;
use pocketmine\math\Vector3;
use pocketmine\nbt\tag\CompoundTag;
use pocketmine\nbt\tag\IntTag;
use pocketmine\nbt\tag\StringTag;
use pocketmine\Player;
use pocketmine\tile\Tile;
class SignPost extends Transparent{
@ -53,17 +58,38 @@ class SignPost extends Transparent{
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){
if($face !== 0){
if($face === 1){
$this->meta = floor((($player->yaw + 180) * 16 / 360) + 0.5) & 0x0F;
$this->getLevel()->setBlock($block, Block::get(Item::SIGN_POST, $this->meta), true);
$nbt = new CompoundTag("", [
"id" => new StringTag("id", Tile::SIGN),
"x" => new IntTag("x", $block->x),
"y" => new IntTag("y", $block->y),
"z" => new IntTag("z", $block->z),
"Text1" => new StringTag("Text1", ""),
"Text2" => new StringTag("Text2", ""),
"Text3" => new StringTag("Text3", ""),
"Text4" => new StringTag("Text4", "")
]);
return true;
if($player !== null){
$nbt->Creator = new StringTag("Creator", $player->getRawUniqueId());
}
if($item->hasCustomBlockData()){
foreach($item->getCustomBlockData() as $key => $v){
$nbt->{$key} = $v;
}
}
if($face === 1){
$this->meta = floor((($player->yaw + 180) * 16 / 360) + 0.5) & 0x0f;
$this->getLevel()->setBlock($block, $this, true);
}else{
$this->meta = $face;
$this->getLevel()->setBlock($block, Block::get(Item::WALL_SIGN, $this->meta), true);
return true;
$this->getLevel()->setBlock($block, new WallSign($this->meta), true);
}
Tile::createTile(Tile::SIGN, $this->getLevel()->getChunk($block->x >> 4, $block->z >> 4), $nbt);
return true;
}
return false;
@ -71,7 +97,7 @@ class SignPost extends Transparent{
public function onUpdate($type){
if($type === Level::BLOCK_UPDATE_NORMAL){
if($this->getSide(0)->getId() === self::AIR){
if($this->getSide(Vector3::SIDE_DOWN)->getId() === self::AIR){
$this->getLevel()->useBreakOn($this);
return Level::BLOCK_UPDATE_NORMAL;
@ -81,12 +107,6 @@ class SignPost extends Transparent{
return false;
}
public function onBreak(Item $item){
$this->getLevel()->setBlock($this, new Air(), true, true);
return true;
}
public function getDrops(Item $item){
return [
[Item::SIGN, 0, 1],

View File

@ -143,7 +143,6 @@ class Slab extends Transparent{
}
public function getToolType(){
return Tool::TYPE_PICKAXE;
}

View File

@ -21,7 +21,6 @@
namespace pocketmine\block;
use pocketmine\item\Tool;
class Snow extends Solid{

View File

@ -21,7 +21,6 @@
namespace pocketmine\block;
use pocketmine\item\Tool;
use pocketmine\math\AxisAlignedBB;

View File

@ -21,28 +21,11 @@
namespace pocketmine\block;
use pocketmine\item\Item;
use pocketmine\item\Tool;
class SpruceWoodStairs extends Stair{
class SpruceWoodStairs extends WoodStairs{
protected $id = self::SPRUCE_WOOD_STAIRS;
public function __construct($meta = 0){
$this->meta = $meta;
}
public function getName(){
return "Spruce Wood Stairs";
}
public function getToolType(){
return Tool::TYPE_AXE;
}
public function getDrops(Item $item){
return [
[$this->id, 0, 1],
];
}
}

View File

@ -21,7 +21,6 @@
namespace pocketmine\block;
use pocketmine\item\Tool;
class StainedClay extends Solid{

View File

@ -21,7 +21,6 @@
namespace pocketmine\block;
use pocketmine\item\Tool;
class StoneBrickStairs extends Stair{

View File

@ -53,7 +53,7 @@ class StoneBricks extends Solid{
];
return $names[$this->meta & 0x03];
}
public function getDrops(Item $item){
if($item->isPickaxe() >= Tool::TIER_WOODEN){
return [

View File

@ -21,15 +21,15 @@
namespace pocketmine\block;
class StoneButton extends Solid {
class StoneButton extends Solid{
protected $id = self::STONE_BUTTON;
protected $id = self::STONE_BUTTON;
public function __construct($meta = 0){
$this->meta = $meta;
}
public function __construct($meta = 0){
$this->meta = $meta;
}
public function getName(){
return "Stone Button";
}
public function getName(){
return "Stone Button";
}
}

View File

@ -21,7 +21,7 @@
namespace pocketmine\block;
class StonePressurePlate extends Solid {
class StonePressurePlate extends Solid{
protected $id = self::STONE_PRESSURE_PLATE;

View File

@ -21,7 +21,6 @@
namespace pocketmine\block;
use pocketmine\item\Tool;
use pocketmine\math\AxisAlignedBB;
use pocketmine\math\Vector3;

View File

@ -23,7 +23,6 @@ namespace pocketmine\block;
use pocketmine\item\Item;
use pocketmine\item\Tool;
use pocketmine\Player;
//TODO: check orientation
class Stonecutter extends Solid{
@ -42,18 +41,6 @@ class Stonecutter extends Solid{
return Tool::TYPE_PICKAXE;
}
public function canBeActivated(){
return true;
}
public function onActivate(Item $item, Player $player = null){
if($player instanceof Player){
$player->craftingType = 2;
}
return true;
}
public function getDrops(Item $item){
if($item->isPickaxe() >= Tool::TIER_WOODEN){
return [

View File

@ -26,8 +26,8 @@ use pocketmine\item\Item;
use pocketmine\nbt\tag\ByteTag;
use pocketmine\nbt\tag\CompoundTag;
use pocketmine\nbt\tag\DoubleTag;
use pocketmine\nbt\tag\ListTag;
use pocketmine\nbt\tag\FloatTag;
use pocketmine\nbt\tag\ListTag;
use pocketmine\Player;
use pocketmine\utils\Random;

View File

@ -46,7 +46,7 @@ class TallGrass extends Flowable{
];
return $names[$this->meta & 0x03];
}
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){
$down = $this->getSide(0);
if($down->getId() === self::GRASS){

View File

@ -21,7 +21,6 @@
namespace pocketmine\block;
use pocketmine\math\AxisAlignedBB;
abstract class Thin extends Transparent{

View File

@ -23,8 +23,8 @@ namespace pocketmine\block;
use pocketmine\item\Item;
use pocketmine\item\Tool;
use pocketmine\math\AxisAlignedBB;
use pocketmine\level\sound\DoorSound;
use pocketmine\math\AxisAlignedBB;
use pocketmine\Player;
class Trapdoor extends Transparent{
@ -126,24 +126,20 @@ class Trapdoor extends Transparent{
}
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){
if(($target->isTransparent() === false or $target->getId() === self::SLAB) and $face !== 0 and $face !== 1){
$faces = [
self::SIDE_SOUTH => self::MASK_SIDE_SOUTH,
self::SIDE_NORTH => self::MASK_SIDE_NORTH,
self::SIDE_EAST => self::MASK_SIDE_EAST,
self::SIDE_WEST => self::MASK_SIDE_WEST,
];
echo $face, PHP_EOL, $faces[$face], PHP_EOL;
$this->meta = $faces[$face] & self::MASK_SIDE;
if($fy > 0.5){
$this->meta |= self::MASK_UPPER;
}
$this->getLevel()->setBlock($block, $this, true, true);
return true;
$directions = [
0 => 1,
1 => 3,
2 => 0,
3 => 2
];
if($player !== null){
$this->meta = $directions[$player->getDirection() & 0x03];
}
return false;
if(($fy > 0.5 and $face !== self::SIDE_UP) or $face === self::SIDE_DOWN){
$this->meta |= self::MASK_UPPER; //top half of block
}
$this->getLevel()->setBlock($block, $this, true, true);
return true;
}
public function getDrops(Item $item){

View File

@ -21,161 +21,13 @@
namespace pocketmine\block;
use pocketmine\item\Item;
use pocketmine\item\Tool;
use pocketmine\math\AxisAlignedBB;
use pocketmine\nbt\NBT;
use pocketmine\nbt\tag\CompoundTag;
use pocketmine\nbt\tag\Enum;
use pocketmine\nbt\tag\Int as IntTag;
use pocketmine\nbt\tag\String as StringTag;
use pocketmine\Player;
use pocketmine\tile\Chest as TileChest;
use pocketmine\tile\Tile;
class TrappedChest extends Chest{
class TrappedChest extends Transparent{
//TODO: Redstone!
protected $id = self::CHEST;
public function __construct($meta = 0){
$this->meta = $meta;
}
public function canBeActivated(){
return true;
}
public function getHardness(){
return 2.5;
}
protected $id = self::TRAPPED_CHEST;
public function getName(){
return "Trapped Chest";
}
public function getToolType(){
return Tool::TYPE_AXE;
}
protected function recalculateBoundingBox(){
return new AxisAlignedBB(
$this->x + 0.0625,
$this->y,
$this->z + 0.0625,
$this->x + 0.9375,
$this->y + 0.9475,
$this->z + 0.9375
);
}
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){
$faces = [
0 => 4,
1 => 2,
2 => 5,
3 => 3,
];
$chest = null;
$this->meta = $faces[$player instanceof Player ? $player->getDirection() : 0];
for($side = 2; $side <= 5; ++$side){
if(($this->meta === 4 or $this->meta === 5) and ($side === 4 or $side === 5)){
continue;
}elseif(($this->meta === 3 or $this->meta === 2) and ($side === 2 or $side === 3)){
continue;
}
$c = $this->getSide($side);
if($c instanceof Chest and $c->getDamage() === $this->meta){
$tile = $this->getLevel()->getTile($c);
if($tile instanceof TileChest and !$tile->isPaired()){
$chest = $tile;
break;
}
}
}
$this->getLevel()->setBlock($block, $this, true, true);
$nbt = new CompoundTag("", [
new Enum("Items", []),
new StringTag("id", Tile::CHEST),
new IntTag("x", $this->x),
new IntTag("y", $this->y),
new IntTag("z", $this->z)
]);
$nbt->Items->setTagType(NBT::TAG_Compound);
if($item->hasCustomName()){
$nbt->CustomName = new StringTag("CustomName", $item->getCustomName());
}
if($item->hasCustomBlockData()){
foreach($item->getCustomBlockData() as $key => $v){
$nbt->{$key} = $v;
}
}
$tile = Tile::createTile("Chest", $this->getLevel()->getChunk($this->x >> 4, $this->z >> 4), $nbt);
if($chest instanceof TileChest and $tile instanceof TileChest){
$chest->pairWith($tile);
$tile->pairWith($chest);
}
return true;
}
public function onBreak(Item $item){
$t = $this->getLevel()->getTile($this);
if($t instanceof TileChest){
$t->unpair();
}
$this->getLevel()->setBlock($this, new Air(), true, true);
return true;
}
public function onActivate(Item $item, Player $player = null){
if($player instanceof Player){
$top = $this->getSide(1);
if($top->isTransparent() !== true){
return true;
}
$t = $this->getLevel()->getTile($this);
$chest = null;
if($t instanceof TileChest){
$chest = $t;
}else{
$nbt = new CompoundTag("", [
new Enum("Items", []),
new StringTag("id", Tile::CHEST),
new IntTag("x", $this->x),
new IntTag("y", $this->y),
new IntTag("z", $this->z)
]);
$nbt->Items->setTagType(NBT::TAG_Compound);
$chest = Tile::createTile("Chest", $this->getLevel()->getChunk($this->x >> 4, $this->z >> 4), $nbt);
}
if(isset($chest->namedtag->Lock) and $chest->namedtag->Lock instanceof String){
if($chest->namedtag->Lock->getValue() !== $item->getCustomName()){
return true;
}
}
if($player->isCreative()){
return true;
}
$player->addWindow($chest->getInventory());
}
return true;
}
public function getDrops(Item $item){
return [
[$this->id, 0, 1],
];
}
}

View File

@ -21,15 +21,15 @@
namespace pocketmine\block;
class Tripwire extends Solid {
class Tripwire extends Solid{
protected $id = self::TRIPWIRE;
protected $id = self::TRIPWIRE;
public function __construct($meta = 0){
$this->meta = $meta;
}
public function __construct($meta = 0){
$this->meta = $meta;
}
public function getName(){
return "Tripwire";
}
public function getName(){
return "Tripwire";
}
}

View File

@ -21,15 +21,15 @@
namespace pocketmine\block;
class TripwireHook extends Solid {
class TripwireHook extends Solid{
protected $id = self::TRIPWIRE_HOOK;
protected $id = self::TRIPWIRE_HOOK;
public function __construct($meta = 0){
$this->meta = $meta;
}
public function __construct($meta = 0){
$this->meta = $meta;
}
public function getName(){
return "Tripwire Hook";
}
public function getName(){
return "Tripwire Hook";
}
}

View File

@ -21,7 +21,6 @@
namespace pocketmine\block;
use pocketmine\level\Level;
class WallSign extends SignPost{
@ -40,8 +39,8 @@ class WallSign extends SignPost{
5 => 4,
];
if($type === Level::BLOCK_UPDATE_NORMAL){
if(isset($faces[$this->meta])) {
if ($this->getSide($faces[$this->meta])->getId() === self::AIR) {
if(isset($faces[$this->meta])){
if($this->getSide($faces[$this->meta])->getId() === self::AIR){
$this->getLevel()->useBreakOn($this);
}
return Level::BLOCK_UPDATE_NORMAL;

View File

@ -21,9 +21,7 @@
namespace pocketmine\block;
use pocketmine\item\Item;
use pocketmine\level\Level;
use pocketmine\math\AxisAlignedBB;
use pocketmine\math\Vector3;
@ -37,10 +35,6 @@ class WaterLily extends Flowable{
$this->meta = $meta;
}
public function isSolid(){
return false;
}
public function getName(){
return "Lily Pad";
}
@ -49,18 +43,14 @@ class WaterLily extends Flowable{
return 0.6;
}
public function canPassThrough(){
return true;
}
protected function recalculateBoundingBox(){
return new AxisAlignedBB(
$this->x,
$this->x + 0.0625,
$this->y,
$this->z,
$this->x,
$this->y + 0.0625,
$this->z
$this->z + 0.0625,
$this->x + 0.9375,
$this->y + 0.015625,
$this->z + 0.9375
);
}

View File

@ -21,15 +21,15 @@
namespace pocketmine\block;
class WeightedPressurePlateHeavy extends Solid {
class WeightedPressurePlateHeavy extends Solid{
protected $id = self::WEIGHTED_PRESSURE_PLATE_HEAVY;
protected $id = self::WEIGHTED_PRESSURE_PLATE_HEAVY;
public function __construct($meta = 0){
$this->meta = $meta;
}
public function __construct($meta = 0){
$this->meta = $meta;
}
public function getName(){
return "Weighted Pressure Plate Heavy";
}
public function getName(){
return "Weighted Pressure Plate Heavy";
}
}

View File

@ -21,15 +21,15 @@
namespace pocketmine\block;
class WeightedPressurePlateLight extends Solid {
class WeightedPressurePlateLight extends Solid{
protected $id = self::WEIGHTED_PRESSURE_PLATE_LIGHT;
protected $id = self::WEIGHTED_PRESSURE_PLATE_LIGHT;
public function __construct($meta = 0){
$this->meta = $meta;
}
public function __construct($meta = 0){
$this->meta = $meta;
}
public function getName(){
return "Weighted Pressure Plate Light";
}
public function getName(){
return "Weighted Pressure Plate Light";
}
}

View File

@ -33,7 +33,8 @@ class Wood2 extends Wood{
static $names = [
0 => "Acacia Wood",
1 => "Dark Oak Wood",
2 => ""
2 => "Unknown",
3 => "Unknown"
];
return $names[$this->meta & 0x03];
}

View File

@ -36,6 +36,14 @@ class WoodStairs extends Stair{
return "Wood Stairs";
}
public function getHardness(){
return 2;
}
public function getResistance(){
return 15;
}
public function getToolType(){
return Tool::TYPE_AXE;
}
@ -45,8 +53,4 @@ class WoodStairs extends Stair{
[$this->id, 0, 1],
];
}
public function getHardness(){
return 2;
}
}

View File

@ -21,15 +21,15 @@
namespace pocketmine\block;
class WoodenButton extends Solid {
class WoodenButton extends Solid{
protected $id = self::WOODEN_BUTTON;
protected $id = self::WOODEN_BUTTON;
public function __construct($meta = 0){
$this->meta = $meta;
}
public function __construct($meta = 0){
$this->meta = $meta;
}
public function getName(){
return "Wooden Button";
}
public function getName(){
return "Wooden Button";
}
}

View File

@ -22,10 +22,10 @@
namespace pocketmine\block;
class WoodenPressurePlate extends Solid{
protected $id = self::WOODEN_PRESSURE_PLATE;
public function __construct($meta = 0) {
public function __construct($meta = 0){
$this->meta = $meta;
}

View File

@ -21,7 +21,6 @@
namespace pocketmine\block;
use pocketmine\item\Tool;
class Wool extends Solid{

View File

@ -27,12 +27,18 @@ namespace pocketmine\command;
use pocketmine\event\TextContainer;
use pocketmine\event\TimingsHandler;
use pocketmine\event\TranslationContainer;
use pocketmine\Player;
use pocketmine\Server;
use pocketmine\utils\TextFormat;
abstract class Command{
/** @var \stdClass */
private static $defaultDataTemplate = null;
/** @var string */
private $name;
/** @var \stdClass */
protected $commandData = null;
/** @var string */
private $nextLabel;
@ -75,16 +81,50 @@ abstract class Command{
* @param string[] $aliases
*/
public function __construct($name, $description = "", $usageMessage = null, array $aliases = []){
$this->name = $name;
$this->nextLabel = $name;
$this->label = $name;
$this->description = $description;
$this->commandData = self::generateDefaultData();
$this->name = $this->nextLabel = $this->label = $name;
$this->setDescription($description);
$this->usageMessage = $usageMessage === null ? "/" . $name : $usageMessage;
$this->aliases = $aliases;
$this->activeAliases = (array) $aliases;
$this->setAliases($aliases);
$this->timings = new TimingsHandler("** Command: " . $name);
}
/**
* Returns an \stdClass containing command data
*
* @return \stdClass
*/
public function getDefaultCommandData() : \stdClass{
return $this->commandData;
}
/**
* Generates modified command data for the specified player
* for AvailableCommandsPacket.
*
* @param Player $player
*
* @return \stdClass|null
*/
public function generateCustomCommandData(Player $player){
//TODO: fix command permission filtering on join
/*if(!$this->testPermission($player)){
return null;
}*/
$customData = clone $this->commandData;
$customData->aliases = $this->getAliases();
/*foreach($customData->overloads as &$overload){
if(($p = @$overload->pocketminePermission) !== null and !$player->hasPermission($p)){
unset($overload);
}
}*/
return $customData;
}
public function getOverloads(): \stdClass{
return $this->commandData->overloads;
}
/**
* @param CommandSender $sender
* @param string $commandLabel
@ -105,14 +145,19 @@ abstract class Command{
* @return string
*/
public function getPermission(){
return $this->permission;
return $this->commandData->pocketminePermission ?? null;
}
/**
* @param string|null $permission
*/
public function setPermission($permission){
$this->permission = $permission;
if($permission !== null){
$this->commandData->pocketminePermission = $permission;
}else{
unset($this->commandData->pocketminePermission);
}
}
/**
@ -128,7 +173,7 @@ abstract class Command{
if($this->permissionMessage === null){
$target->sendMessage(new TranslationContainer(TextFormat::RED . "%commands.generic.permission"));
}elseif($this->permissionMessage !== ""){
$target->sendMessage(str_replace("<permission>", $this->permission, $this->permissionMessage));
$target->sendMessage(str_replace("<permission>", $this->getPermission(), $this->permissionMessage));
}
return false;
@ -140,11 +185,11 @@ abstract class Command{
* @return bool
*/
public function testPermissionSilent(CommandSender $target){
if($this->permission === null or $this->permission === ""){
if(($perm = $this->getPermission()) === null or $perm === ""){
return true;
}
foreach(explode(";", $this->permission) as $permission){
foreach(explode(";", $perm) as $permission){
if($target->hasPermission($permission)){
return true;
}
@ -197,7 +242,7 @@ abstract class Command{
public function unregister(CommandMap $commandMap){
if($this->allowChangesFrom($commandMap)){
$this->commandMap = null;
$this->activeAliases = $this->aliases;
$this->activeAliases = $this->commandData->aliases;
$this->label = $this->nextLabel;
return true;
@ -240,7 +285,7 @@ abstract class Command{
* @return string
*/
public function getDescription(){
return $this->description;
return $this->commandData->description;
}
/**
@ -254,7 +299,7 @@ abstract class Command{
* @param string[] $aliases
*/
public function setAliases(array $aliases){
$this->aliases = $aliases;
$this->commandData->aliases = $aliases;
if(!$this->isRegistered()){
$this->activeAliases = (array) $aliases;
}
@ -264,7 +309,7 @@ abstract class Command{
* @param string $description
*/
public function setDescription($description){
$this->description = $description;
$this->commandData->description = $description;
}
/**
@ -281,6 +326,13 @@ abstract class Command{
$this->usageMessage = $usage;
}
public static final function generateDefaultData() : \stdClass{
if(self::$defaultDataTemplate === null){
self::$defaultDataTemplate = json_decode(file_get_contents(Server::getInstance()->getFilePath() . "src/pocketmine/resources/command_default.json"));
}
return clone self::$defaultDataTemplate;
}
/**
* @param CommandSender $source
* @param string $message
@ -289,7 +341,7 @@ abstract class Command{
public static function broadcastCommandMessage(CommandSender $source, $message, $sendToSource = true){
if($message instanceof TextContainer){
$m = clone $message;
$result = "[".$source->getName().": ".($source->getServer()->getLanguage()->get($m->getText()) !== $m->getText() ? "%" : "") . $m->getText() ."]";
$result = "[" . $source->getName() . ": " . ($source->getServer()->getLanguage()->get($m->getText()) !== $m->getText() ? "%" : "") . $m->getText() . "]";
$users = $source->getServer()->getPluginManager()->getPermissionSubscriptions(Server::BROADCAST_CHANNEL_ADMINISTRATIVE);
$colored = TextFormat::GRAY . TextFormat::ITALIC . $result;

View File

@ -31,6 +31,8 @@ class CommandReader extends Thread{
public function __construct(){
$this->buffer = new \Threaded;
$opts = getopt("", ["disable-readline"]);
$this->readline = (extension_loaded("readline") and !isset($opts["disable-readline"]));
$this->start();
}
@ -71,14 +73,10 @@ class CommandReader extends Thread{
}
public function run(){
$opts = getopt("", ["disable-readline"]);
if(extension_loaded("readline") and !isset($opts["disable-readline"])){
$this->readline = true;
}else{
if(!$this->readline){
global $stdin;
$stdin = fopen("php://stdin", "r");
stream_set_blocking($stdin, 0);
$this->readline = false;
}
$lastLine = microtime(true);

View File

@ -23,7 +23,6 @@ namespace pocketmine\command;
use pocketmine\event\TranslationContainer;
use pocketmine\Server;
use pocketmine\utils\MainLogger;
use pocketmine\utils\TextFormat;
class FormattedCommandAlias extends Command{

View File

@ -24,7 +24,6 @@ namespace pocketmine\command;
use pocketmine\event\TranslationContainer;
use pocketmine\plugin\Plugin;
class PluginCommand extends Command implements PluginIdentifiableCommand{
/** @var Plugin */

View File

@ -21,7 +21,6 @@
namespace pocketmine\command;
use pocketmine\event\TextContainer;
class RemoteConsoleCommandSender extends ConsoleCommandSender{

View File

@ -62,7 +62,6 @@ use pocketmine\command\defaults\VersionCommand;
use pocketmine\command\defaults\WhitelistCommand;
use pocketmine\event\TranslationContainer;
use pocketmine\Server;
use pocketmine\utils\MainLogger;
use pocketmine\utils\TextFormat;
class SimpleCommandMap implements CommandMap{

View File

@ -26,7 +26,6 @@ use pocketmine\command\CommandSender;
use pocketmine\event\TranslationContainer;
use pocketmine\Player;
class BanCommand extends VanillaCommand{
public function __construct($name){

View File

@ -26,7 +26,6 @@ use pocketmine\command\CommandSender;
use pocketmine\event\TranslationContainer;
use pocketmine\Player;
class BanIpCommand extends VanillaCommand{
public function __construct($name){

View File

@ -24,7 +24,6 @@ namespace pocketmine\command\defaults;
use pocketmine\command\CommandSender;
use pocketmine\event\TranslationContainer;
class BanListCommand extends VanillaCommand{
public function __construct($name){

View File

@ -25,7 +25,6 @@ use pocketmine\command\CommandSender;
use pocketmine\event\TranslationContainer;
use pocketmine\Server;
class DefaultGamemodeCommand extends VanillaCommand{
public function __construct($name){

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