Compare commits

...

600 Commits

Author SHA1 Message Date
2c6205e3f3 Added new events for network interface handling, close #1232 (#1250)
Added 
- NetworkInterfaceRegisterEvent (cancellable)
- NetworkInterfaceUnregisterEvent
- NetworkInterfaceCrashEvent
2017-09-06 11:22:10 +01:00
2215543e39 Fixed not being able to remove logger attachments, closes #1141 2017-09-05 20:04:19 +01:00
b310959fd1 Added --php parameter to start.ps1 2017-09-05 19:57:38 +01:00
d065e76a41 Fixed plugins with unknown dependencies saying they have circular dependencies, close #356 (#1342) 2017-09-04 19:41:21 +01:00
f0c1ea7dd7 Fixed string seeds in pocketmine.yml crash the server, close #1355 2017-09-04 10:01:21 +01:00
6aaef1660a Added dependency checks for BC Math 2017-09-04 08:08:04 +01:00
815c697767 Fixed sticks being useless as furnace fuel 2017-09-03 14:59:04 +01:00
231617b9d0 fuel time should be ticks here, not seconds 2017-09-03 14:27:17 +01:00
90cb3c010f Added some new items (the basic ones) 2017-09-03 14:24:21 +01:00
2398e2450a Allow building inside spectators
This check is pretty ugly, it'll need cleaning up later. For now, this will suffice.
2017-09-03 13:47:44 +01:00
bb9299070d Fixed several Cake bugs
fixed cake flat-out doesn't work
fixed last slice of cake vanishing (NOOOOO)
fixed EntityEatBlockEvent not getting called
made AABB calculation less confusing
2017-09-03 13:09:53 +01:00
58bf5d6679 Use null coalesce in EntityDamageEvent 2017-09-03 12:48:57 +01:00
cb7911ee9c Improved Absorption, now only applies to living entities, now controllable by plugins 2017-09-03 12:37:34 +01:00
aa9fd1b4f9 Remove redundant gamemode checks
The caller will check the player's gamemode, so there is no use for these checks.
2017-09-03 12:22:37 +01:00
7483f22e8b Fixed a PhpStorm inspection 2017-09-03 12:10:56 +01:00
89f5567476 Use Entity->getDirectionVector() more 2017-09-03 12:08:40 +01:00
4df261b75a Made some variable names in Bucket less confusing 2017-09-03 12:00:24 +01:00
41780fd195 Made entity collision checks for block placement more logical and less wasteful
We don't care how many entities collide, only that a non-zero number collided.
2017-09-03 11:50:15 +01:00
0b83c61494 Fixed cyclic reference with chest tiles and DoubleChestInventory 2017-09-03 11:24:34 +01:00
1d338bfdf9 Fixed uncaught exceptions during Task->onCancel() causing all kinds of nasty behaviour
including crashing the server on shutdown, preventing self-cancellation, and causing memory leaks
2017-09-02 19:28:51 +01:00
2f614c5dc2 don't break the preprocessor 2017-09-02 19:04:10 +01:00
4d8d57ca5e Fixed LongTags in tile NBT 2017-09-02 18:57:23 +01:00
62aba15f9e Updated RakLib submodule 2017-09-02 16:52:55 +01:00
22d8626e23 Fixed sign bug introduced in #1204 rebase, close #1346 2017-09-02 13:12:55 +01:00
b071ce9c5a Refactored projectile handling, added Item->onClickAir() 2017-09-02 11:57:26 +01:00
2603f5cc63 Fixed RakLib crashing when exceptions are thrown in packet handlers after the player was closed
This occurred if the player happened to be closed during the packet being handled, and then an uncaught exception bubbled up to the RakLibInterface. This resulted in a crash due to trying to get the address of a player who no longer had a network session, in order to block their IP address.
2017-09-01 20:22:02 +01:00
14ea76ecd7 Fixed PlayerBucketEmptyEvent never called, close #1339 2017-09-01 19:36:57 +01:00
c81b76cbf6 Make plugin load errors more descriptive 2017-09-01 18:52:55 +01:00
517609dc2e Cleaned up plugin property reading 2017-09-01 18:36:31 +01:00
506118e28f Fixed exception thrown when plugins specify API version like 3.0 instead of 3.0.0
This could only be seen in a build with a non-suffixed API version, for example 3.0.0. When attempting to load plugins which specify API like 3.0 the server would raise errors.
2017-09-01 18:13:07 +01:00
6e8631347d Added capability to specify compatible protocol versions in plugin.yml (#1247)
Protocol-dependent plugins may specify the `mcpe-protocol` attribute in plugin.yml to disallow plugin loading when the protocol changes.
2017-09-01 17:57:40 +01:00
138d85307b Fixed double chests being openable when the other half has a solid block above it, close #1165 2017-09-01 16:50:55 +01:00
226175f961 setText now nullable instead of overwriting with empty lines (#1204) 2017-09-01 08:34:40 +01:00
297cfcf168 Check for existence of ChunkUtils extension 2017-08-31 21:42:24 +01:00
9ea39ea3d7 Stop clearing chunk cache after 768 batched packets are cached. (#1320) 2017-08-31 21:14:18 +01:00
b9c4a65307 Don't save players with chunks!
I can't believe I didn't notice this
2017-08-30 16:55:17 +01:00
23752548fe Address several LevelDB related crashdumps in the crash archive 2017-08-30 15:42:31 +01:00
120cf56a47 Misc return typehints 2017-08-30 12:59:26 +01:00
21f09d5fdb Cleaned up Effect handling and replacement 2017-08-30 12:53:41 +01:00
bde6d7db8d Remove redundant duplicate implements 2017-08-30 12:21:09 +01:00
adc6b03d4c Typehinted up Entity API and some cleanup 2017-08-30 12:17:56 +01:00
fd52022065 Refactor of health int -> float and fixed armor being useless when
computed damage reduction is less than 1
2017-08-30 11:03:07 +01:00
ea5bd0348a Fixed liquid flow attempting to set negative block damage values
This should only execute if the current liquid block is actually still existent. When decay is negative, it means the water block doesn't exist anymore.
2017-08-29 14:22:12 +01:00
c3cf82ab26 Updated RakLib submodule 2017-08-29 11:05:25 +01:00
6abef6b22d Made block and item factory lists private to stop people doing stupid things with them 2017-08-29 10:53:01 +01:00
9902d29734 ServerScheduler::scheduleAsyncTask() returns the worker used (#1312) 2017-08-29 10:29:24 +01:00
7475aa3a18 Do not allow use of PHP 7.1 due to not compatible 2017-08-28 23:42:22 +01:00
6a717d8050 Fixed PlaySoundPacket
thanks @undrfined
2017-08-28 18:32:56 +01:00
37b050f864 Return an UnknownBlock if the BlockFactory hasn't been initialized yet 2017-08-28 17:07:39 +01:00
d07b5ba1e1 Added missing return to Bow, fixed #1329 2017-08-27 20:40:30 +01:00
697ea55fb7 Another typehint 2017-08-27 20:01:38 +01:00
8b3fad8a7b Removed redundant condition 2017-08-27 19:44:40 +01:00
f2402f2122 Strict-compare these to strings since they cannot return anything but 2017-08-27 19:32:57 +01:00
b548c4fdbe Use null coalesce in BanList->addBan() 2017-08-27 19:29:04 +01:00
a982344b96 Cleaned up Level->addSound() and Level->addParticle() 2017-08-27 19:09:05 +01:00
0b2b9126a2 Improved tile spawning
There's no need to recreate the spawn packet for every single player, or re-serialize the NBT.
2017-08-27 18:40:18 +01:00
f4f2323518 Fixed entityBaseTick not being timed for Players 2017-08-27 18:29:54 +01:00
badd669b3d Removed use of literal ints for block ID checks in Dandelion 2017-08-27 16:16:37 +01:00
a5f5502380 Moved bow functionality out of Player 2017-08-26 19:04:04 +01:00
6d5620606e Block->place() parameter refactor to make things clearer 2017-08-26 14:41:49 +01:00
20f34fba53 Missed another dupe 2017-08-26 14:34:21 +01:00
61968cca28 Cleaned up duplicated spawn protection code and refactor some variable names 2017-08-26 14:25:34 +01:00
13187e1749 Removed damage-table mess and added API methods Item->getAttackPoints() and Item->getDefensePoints() 2017-08-26 12:59:03 +01:00
7c212d3d53 Fix formatting issue in AsyncPool 2017-08-25 19:15:57 +01:00
9e142655ea Removed redundant count parameter from item constructors, added some documentation and tightened safety checks
the count parameter is useless since Item ctor should now only be used for constructing item _types_, not actual items. All item creations for inventories etc, should go through the ItemFactory.
2017-08-25 19:06:23 +01:00
1fec16f167 Fix Block::get() regression introduced in 02f42eba 2017-08-25 18:15:53 +01:00
4ab286a142 Generated some Item TODOs 2017-08-25 14:35:50 +01:00
44dd7c2222 Removed some redundant item classes 2017-08-25 14:07:50 +01:00
97911aa9cf Fix undetected collision of nether brick block and nether brick item 2017-08-25 13:36:36 +01:00
7ff143c793 Some minor tool cleanup 2017-08-25 13:19:21 +01:00
cd7724d94a Added concrete 2017-08-25 13:13:11 +01:00
76e213ae73 Cleaned up shared rotation code, fixed quartz pillar rotation, added bone blocks 2017-08-25 13:06:16 +01:00
8ce833bf74 Stripped redundant trailing commas 2017-08-25 12:41:49 +01:00
ba27fff853 Fix formatting derp 2017-08-25 11:53:41 +01:00
80f2519d7d Fixed obsidian hardness, no more destroying obsidian with TNT 2017-08-25 11:52:46 +01:00
ebda6ec19b Cleaned up random-block-ticking registration 2017-08-25 11:47:38 +01:00
6553c82320 Fix random block ticking losing randomness on third iteration
More expensive to do it this way, but this should be foolproof. The old method ran short by 4 or 5 bits, causing the Y coordinate of the third loop to be always < 8 and the Z coordinate to always be 0.
2017-08-24 22:14:07 +01:00
1b0ed0f1b8 Use metadata for git hashes 2017-08-24 20:01:19 +01:00
3ee8f2b182 Require RakLib version 0.8.1 2017-08-24 19:26:30 +01:00
238b3ca4c1 Fixed UUID variant corruption in UUID->toString(), close #1286
This class may encapsulate any type of UUID, not just RFC 4122. Additionally, an RFC 4122 UUID may have this set as 8, 9, A or B.
2017-08-24 12:51:46 +01:00
90edb8ebe7 Make decoding accessible 2017-08-24 10:45:30 +01:00
55e32424a0 Ability to get a player's quit reason from PlayerQuitEvent (#1308) 2017-08-23 19:26:24 +01:00
d6266d19b6 Added correct friction factor for ice & packed-ice 2017-08-23 18:38:09 +01:00
84c8ac03fb Fixed #1179
This solution isn't ideal, but it works...
2017-08-23 13:19:34 +01:00
0f2ca99c67 Merge remote-tracking branch 'origin/pr/1310' 2017-08-23 10:44:33 +01:00
a7674c52e6 Micro optimization to movement update checking
No need to keep abs()ing this, because next time we have a movement update, motion < 0.00001 will be flattened to zero anyway.
2017-08-23 10:42:23 +01:00
a52fa93998 Remove Entity->length 2017-08-23 02:21:33 -04:00
d1852834de Revert "Added capability to dump AsyncWorker memory"
This reverts commit eb4594348b.

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

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

in powersave mode (0.9GHz):
- before changes: 170ms
- after changes: 60ms
2017-08-20 16:12:30 +01:00
d1fd6aef44 add type doc 2017-08-20 14:04:02 +01:00
cd02f1e4be Minor performance improvement to explosions
This improves calculation time by 20-25% per explosion on flat terrain.
2017-08-20 13:28:31 +01:00
eeedcf7332 Refactor Block->getResistance() -> Block->getBlastResistance() and added some documentation 2017-08-20 13:25:43 +01:00
216fc6fe31 Fixed incorrect comment 2017-08-20 12:17:44 +01:00
17053389b0 Added memory limits for AsyncWorkers 2017-08-20 12:15:48 +01:00
8475c63426 Remove redundant brackets from WoodenSlab 2017-08-20 11:02:34 +01:00
f2ff0198cc Fixed slab placement, close #145 2017-08-20 10:52:07 +01:00
c394aea803 Replaced more literal ints with Vector3 constants 2017-08-20 10:43:48 +01:00
e1d894057c Changed face position floating-point params to Vector3s 2017-08-20 10:23:34 +01:00
5b3bed8b06 Don't check entity movement or in-air ticks if player dies due to movement, close #1226
Not an ideal solution but it'll do.
2017-08-20 09:49:02 +01:00
bed68a012d Don't bother doing null checks for block copy
This will never be null if the block factory was initialized correctly. This will also cause a crash if bugs like e88053faf4 occur again in the future instead of silently causing unexpected behaviour.
2017-08-19 21:29:24 +01:00
e88053faf4 ... 2017-08-19 18:25:08 +01:00
e51106e64c Fixed bad overrides of getBoundingBox() 2017-08-19 17:16:22 +01:00
0e24596aed Changed block construction calls to Block::get() 2017-08-19 13:46:17 +01:00
276fccf4bb Typehinted block events API 2017-08-19 11:25:32 +01:00
64f2e7587d Some cleanup and added missing strict types declare for EndRod 2017-08-19 11:11:49 +01:00
bedfca8698 Fix some type errors on custom ExplodePacket use (#1297) 2017-08-19 08:16:10 +01:00
4a3f01703e Removed redundant override method 2017-08-18 19:52:23 +01:00
41c6cb6f97 Added Block->getVariantBitmask(0 to cut down on getDrops() boilerplate, fixed several blocks incorrectly retaining meta when broken 2017-08-18 19:49:28 +01:00
384a4b3a09 Who put this here? 2017-08-18 18:59:34 +01:00
a7ad26426f Add stained glass and stained glass pane (#1298) 2017-08-18 18:30:03 +01:00
f73d3d086e Added some new blocks, fixed collisions not being detected when standing on top of a full block 2017-08-18 13:58:05 +01:00
41f5cba971 Added End Rods, close #940 2017-08-18 13:05:39 +01:00
d8f0dd6db8 Changed Block->getDrops() to return Item[] 2017-08-18 11:21:33 +01:00
c8ed2406d7 Fix bad setChunk() documentation 2017-08-17 21:03:07 +01:00
a4ec2b7f2c Removed copy-pasted code from Player 2017-08-17 19:50:17 +01:00
9efd350e78 Return unhandled on desktop crafting instead of hitting errors 2017-08-17 18:34:21 +01:00
be4f48a119 Updating submodules 2017-08-17 18:26:06 +01:00
83f29e5639 Fixed tests failing since 83af4dcd 2017-08-17 17:02:13 +01:00
e825ebd8fa Added some wrapper methods to make data flags less of a pain in the ass to work with 2017-08-17 16:52:17 +01:00
83af4dcd59 Block API typehints 2017-08-17 13:50:19 +01:00
f6c31680f6 Fixed unknown blocks dropping themselves 2017-08-17 13:25:11 +01:00
6320a63ca5 Use standard format for color hex, some minor name alteration 2017-08-17 13:08:18 +01:00
9e02f3c4e3 Fixed redstone lamp light levels and hardness 2017-08-17 11:47:10 +01:00
2cd05bf5b5 Removed redundant Block constructor overrides 2017-08-17 11:42:26 +01:00
5b4035253b Casting cleanup and removed some 32-bit string-int leftovers 2017-08-17 11:24:49 +01:00
77376d3e33 No idea how this happened 2017-08-17 11:15:42 +01:00
56e45a031b Fixed missing returns for Player->switchLevel() 2017-08-17 11:15:22 +01:00
21a1e0eb6b Player API typehints 2017-08-17 11:08:54 +01:00
670a9fe44f Fix some crashy issues when incompatible players get disconnected 2017-08-17 10:29:12 +01:00
6efa4343b1 Cleaned up fuel duration handling, fixed some fuel items not working in furnaces 2017-08-17 10:22:47 +01:00
dc3f13cd30 Cleanup from previous commit 2017-08-17 09:42:00 +01:00
b4c4005009 Some condition simplifications suggested by static analysis 2017-08-16 20:06:48 +01:00
eebc52e00b Added API method Entity->isClosed() and made Entity->closed protected 2017-08-16 19:30:23 +01:00
20aa519f3a Added capability to remove owners/target entities 2017-08-16 19:14:15 +01:00
741394dab1 Typehinted up entity API
Did you guys think ALPHA7 changes were done?!
Sone stuff still needs some work, most notably data-properties can't be typed yet because they are just mushed into a couple of methods.
2017-08-16 19:04:30 +01:00
ea414ea72d Fixed MetadataStore 2017-08-16 17:09:03 +01:00
696c67f541 Missed a couple 2017-08-16 14:43:18 +01:00
021dbd65d7 Cleaned up some copy-pasted code for coloured blocks names 2017-08-16 14:38:41 +01:00
8510be062c Nether Reactor block is back
This should never have been removed, it exists as an unobtainable block in vanilla which drops iron and diamond.
2017-08-16 14:17:14 +01:00
7b142d4742 Generated some TODO comments for blocks 2017-08-16 13:25:36 +01:00
0257432afc Fixed a typo in BlockIds 2017-08-16 13:17:22 +01:00
4950157f1d How did this escape notice? 2017-08-16 13:08:30 +01:00
c4d8c28338 Some inspection fixes 2017-08-16 13:07:33 +01:00
9a0b3a6e22 Updated RakLib submodule 2017-08-16 12:28:44 +01:00
ebb71fc6c5 Typehints and docs for MemoryManager 2017-08-15 19:48:19 +01:00
ae3a8a5493 Added capability to unblock addresses without a restart 2017-08-14 14:12:06 +01:00
0c798222a4 ... blame PhpStorm EAP 2017-08-10 18:04:44 +01:00
e8bd0c3e09 add typehints to Metadatable interface and implementations, fix missing return for Block->hasMetadata() reported in #1285 2017-08-10 18:02:01 +01:00
82fd3b540e Fixed a mistake in Block->isBreakable() doc 2017-08-08 22:15:44 +01:00
06083d6dc4 s/Item/Block 2017-08-07 16:26:27 +01:00
2d8395f70e Absorption should be a float. Fixed #1071 2017-08-07 16:09:10 +01:00
6b5c0af161 Separation of effect handling from Entity, fixes #886 2017-08-07 16:03:54 +01:00
c84218c55b Remove overloaded parameter from GeneratorUnregisterTask construction
PhpStorm, pls tell me why you only found this _now_ and not back in January when I started using PhpStorm...
2017-08-07 15:46:57 +01:00
6b7a382625 import cleanup and missing strict types declare 2017-08-07 15:42:46 +01:00
54b6a5710e Fixed entityBaseTickTimer doesn't cover child overrides 2017-08-07 14:21:06 +01:00
44f1dedbf8 Give creative players carte blanche
Close #879, close #431

This will be solved properly in 1.2 when creative transactions are
actually trackable. For now... HACK!
2017-08-06 21:16:08 +01:00
23eb8600ab Added methods for endian-flipping 2017-08-06 18:46:03 +01:00
10ff2948ac Fixed double wooden slab name inconsistency 2017-08-06 17:15:35 +01:00
0d0df3390a Added glazed terracotta 2017-08-06 17:10:06 +01:00
e4a5cb6021 Changed NBT representation in JSON to hex, fix encoding problems with UTF-8 2017-08-06 14:50:18 +01:00
71e354cf1d Added chest open/close sounds and cleanup duplicated code 2017-08-06 12:48:46 +01:00
7d3fca83f0 Tile NBT usage enhancements (#1259)
* Do not create new NBT objects on Tile::getSpawnCompound()

* PocketMine's string formatting

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

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

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

* Fix formatting

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

* Make the same changes for Bed tile

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

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

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

* PHP

* Throw exceptions if out of range

* Fix phpdocs

* Formatting, additional checks in the SignChangeEvent.

* Blame php storm

* require line count to always be 4

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

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

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

* This causes too much unexpected behaviour to be useful

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

This reverts commit c2dfef700f.

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

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

* Position::$level can be null.

* Use getLevel() in place of $level

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

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

Squashed:

oops

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

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

* Byeeeeee

* Removing legacy code

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

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

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

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

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

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

* Added getPlayer() to PlayerDataSaveEvent
may return an IPlayer

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

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

* Renamed getExtensions() to getRequiredExtensions()

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

1
.gitattributes vendored
View File

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

View File

@ -1,5 +1,9 @@
### Issue description
<!--- use our forum https://forums.pmmp.io for questions -->
<!---
THIS ISSUE TRACKER IS FOR BUG REPORTING, NOT FOR HELP & SUPPORT. If you need help, use the links below.
- http://pmmp.readthedocs.io/en/rtfd/ - Documentation
- https://forums.pmmp.io - PMMP Forums
-->
<!--- Any issues requesting updates to new versions of MCPE will be treated as spam. We do not need issues to tell us that there is a new version available. -->
<!---
Write a short description about the issue
@ -16,15 +20,28 @@ Actual result: What actually happened?
### OS and versions
<!--- use the 'version' command in PocketMine-MP
NOTE: LATEST is not a valid version.
PocketMine version should include Jenkins build number and/or git commit hash.
ALSO NOTE: NO support whatsoever will be provided for forks or spoons of PocketMine. Issues relating to non-official distributions will be closed as spam. Please send such issues to whoever is responsible for the fork or spoon you are using.
NOTE: LATEST is not a valid version. PocketMine version should include Jenkins build number and/or git commit hash.
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.
Note that 32-bit platforms are no longer supported by PocketMine-MP and issues concerning 32-bit platforms will be closed.
-->
* PocketMine-MP:
* PHP:
* Server OS:
* Game version: PE/Win10 (delete as appropriate)
### Plugins
- Test on a clean server without plugins: is the issue reproducible without any plugins loaded?
If the issue is **not** reproducible without plugins:
- Have you asked for help on our forums before creating an issue?
- Can you provide sample, *minimal* reproducing code for the issue? If so, paste it in the bottom section
- Paste your list of plugins here (use the 'plugins' command in PocketMine-MP)
### Crashdump, backtrace or other files
<!--- please use gist or anything else and add links here -->
- Do not paste crashdumps into an issue - please use our Crash Archive at https://crash.pmmp.io for submitting crash reports to not spam the issue tracker. Add links to your reports in the Crash Archive here.
- Please use gist or anything else to add other files and add links here
* ...

3
.gitmodules vendored
View File

@ -14,3 +14,6 @@
[submodule "tests/plugins/PocketMine-DevTools"]
path = tests/plugins/PocketMine-DevTools
url = https://github.com/pmmp/PocketMine-DevTools.git
[submodule "tests/plugins/PocketMine-TesterPlugin"]
path = tests/plugins/PocketMine-TesterPlugin
url = https://github.com/pmmp/PocketMine-TesterPlugin.git

View File

@ -18,8 +18,10 @@
- Information must be provided in the issue body, not in the title. No tags like `[BUG]` are allowed in the title, including `[SOLVED]` for solved issues.
- Similarly, no generic issue reports. For bugs, it is the issue author's responsibility to provide us an issue that is **trackable, debuggable, reproducible, reported professionally and is an actual bug**. If you do not provide us with a summary or instructions on how to reproduce the issue, it will be treated as spam and will therefore be closed.
<br>In simple words, if your issue does not appear to be a bug or a feature request, or if the issue cannot be properly confirmed to be valid, the issue will be closed until further information is provided.
- 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**.
<br><br>Valid issue reports must include instructions how to reproduce the issue or a crashdump/backtrace (unless the cause of the issue is obvious).
<br><br>**If you do not provide us with a summary or instructions on how to reproduce the issue, it will be treated as spam and will therefore be closed.**
<br><br>In simple words, if the issue cannot be properly confirmed to be valid or lacks required information, the issue will be closed until further information is provided.
- To express appreciation, objection, confusion or other supported reactions on pull requests, issues or comments on them, use GitHub [reactions](https://github.com/blog/2119-add-reactions-to-pull-requests-issues-and-comments) rather than posting an individual comment with an emoji only. This helps keeping the issue/pull request conversation clean and readable.

View File

@ -13,7 +13,7 @@ If you don't find what you're looking for there, [talk to a human](#discussion).
- [#pmmp + #pocketmine channel IRC](http://webchat.freenode.net/?channels=pmmp,pocketmine)
### Plugins
There are a very wide range of already-written plugins available which you can use to customise your server. Check out [the old plugin repository](http://plugins.pocketmine.net/) and [Poggit](https://poggit.pmmp.io), or just search GitHub.
There are a very wide range of already-written plugins available which you can use to customise your server. Check out [Poggit](https://poggit.pmmp.io), or just search GitHub.
### For developers
* [Latest API documentation](https://jenkins.pmmp.io/job/PocketMine-MP-doc/doxygen/) - Doxygen documentation generated from development

View File

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

View File

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

View File

@ -19,11 +19,14 @@
*
*/
declare(strict_types=1);
namespace pocketmine;
use pocketmine\network\mcpe\protocol\ProtocolInfo;
use pocketmine\plugin\PluginBase;
use pocketmine\plugin\PluginLoadOrder;
use pocketmine\plugin\PluginManager;
use pocketmine\utils\Utils;
use pocketmine\utils\VersionString;
use raklib\RakLib;
@ -35,7 +38,9 @@ class CrashDump{
private $fp;
private $time;
private $data = [];
private $encodedData = null;
/** @var string */
private $encodedData = "";
/** @var string */
private $path;
public function __construct(Server $server){
@ -61,7 +66,7 @@ class CrashDump{
$this->encodeData();
}
public function getPath(){
public function getPath() : string{
return $this->path;
}
@ -69,7 +74,7 @@ class CrashDump{
return $this->encodedData;
}
public function getData(){
public function getData() : array{
return $this->data;
}
@ -86,7 +91,7 @@ class CrashDump{
}
private function pluginsData(){
if(class_exists("pocketmine\\plugin\\PluginManager", false)){
if($this->server->getPluginManager() instanceof PluginManager){
$this->addLine();
$this->addLine("Loaded plugins:");
$this->data["plugins"] = [];
@ -159,7 +164,7 @@ class CrashDump{
E_STRICT => "E_STRICT",
E_RECOVERABLE_ERROR => "E_RECOVERABLE_ERROR",
E_DEPRECATED => "E_DEPRECATED",
E_USER_DEPRECATED => "E_USER_DEPRECATED",
E_USER_DEPRECATED => "E_USER_DEPRECATED"
];
$error["fullFile"] = $error["file"];
$error["file"] = cleanPath($error["file"]);
@ -224,6 +229,7 @@ class CrashDump{
private function generalData(){
$version = new VersionString();
$this->data["general"] = [];
$this->data["general"]["name"] = $this->server->getName();
$this->data["general"]["version"] = $version->get(false);
$this->data["general"]["build"] = $version->getBuild();
$this->data["general"]["protocol"] = ProtocolInfo::CURRENT_PROTOCOL;
@ -235,7 +241,7 @@ class CrashDump{
$this->data["general"]["zend"] = zend_version();
$this->data["general"]["php_os"] = PHP_OS;
$this->data["general"]["os"] = Utils::getOS();
$this->addLine("PocketMine-MP version: " . $version->get(false) . " #" . $version->getBuild() . " [Protocol " . ProtocolInfo::CURRENT_PROTOCOL . "; API " . API_VERSION . "]");
$this->addLine($this->server->getName() . " version: " . $version->get(false) . " #" . $version->getBuild() . " [Protocol " . ProtocolInfo::CURRENT_PROTOCOL . "; API " . API_VERSION . "]");
$this->addLine("Git commit: " . GIT_COMMIT);
$this->addLine("uname -a: " . php_uname("a"));
$this->addLine("PHP Version: " . phpversion());

View File

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

View File

@ -19,6 +19,8 @@
*
*/
declare(strict_types=1);
namespace pocketmine;
use pocketmine\event\server\LowMemoryEvent;
@ -31,27 +33,45 @@ class MemoryManager{
/** @var Server */
private $server;
/** @var int */
private $memoryLimit;
/** @var int */
private $globalMemoryLimit;
/** @var int */
private $checkRate;
/** @var int */
private $checkTicker = 0;
/** @var bool */
private $lowMemory = false;
/** @var bool */
private $continuousTrigger = true;
/** @var int */
private $continuousTriggerRate;
/** @var int */
private $continuousTriggerCount = 0;
/** @var int */
private $continuousTriggerTicker = 0;
/** @var int */
private $garbageCollectionPeriod;
/** @var int */
private $garbageCollectionTicker = 0;
/** @var bool */
private $garbageCollectionTrigger;
/** @var bool */
private $garbageCollectionAsync;
/** @var int */
private $chunkRadiusOverride;
/** @var bool */
private $chunkCollect;
/** @var bool */
private $chunkTrigger;
/** @var bool */
private $chunkCache;
/** @var bool */
private $cacheTrigger;
public function __construct(Server $server){
@ -90,7 +110,7 @@ class MemoryManager{
$hardLimit = ((int) $this->server->getProperty("memory.main-hard-limit", $defaultMemory));
if($hardLimit <= 0){
ini_set("memory_limit", -1);
ini_set("memory_limit", '-1');
}else{
ini_set("memory_limit", $hardLimit . "M");
}
@ -114,11 +134,17 @@ class MemoryManager{
gc_enable();
}
public function isLowMemory(){
/**
* @return bool
*/
public function isLowMemory() : bool{
return $this->lowMemory;
}
public function canUseChunkCache(){
/**
* @return bool
*/
public function canUseChunkCache() : bool{
return !($this->lowMemory and $this->chunkTrigger);
}
@ -130,10 +156,18 @@ class MemoryManager{
* @return int
*/
public function getViewDistance(int $distance) : int{
return $this->lowMemory ? min($this->chunkRadiusOverride, $distance) : $distance;
return $this->lowMemory ? (int) min($this->chunkRadiusOverride, $distance) : $distance;
}
public function trigger($memory, $limit, $global = false, $triggerCount = 0){
/**
* Triggers garbage collection and cache cleanup to try and free memory.
*
* @param int $memory
* @param int $limit
* @param bool $global
* @param int $triggerCount
*/
public function trigger(int $memory, int $limit, bool $global = false, int $triggerCount = 0){
$this->server->getLogger()->debug(sprintf("[Memory Manager] %sLow memory triggered, limit %gMB, using %gMB",
$global ? "Global " : "", round(($limit / 1024) / 1024, 2), round(($memory / 1024) / 1024, 2)));
if($this->cacheTrigger){
@ -159,6 +193,9 @@ class MemoryManager{
$this->server->getLogger()->debug(sprintf("[Memory Manager] Freed %gMB, $cycles cycles", round(($ev->getMemoryFreed() / 1024) / 1024, 2)));
}
/**
* Called every tick to update the memory manager state.
*/
public function check(){
Timings::$memoryManagerTimer->startTiming();
@ -196,7 +233,10 @@ class MemoryManager{
Timings::$memoryManagerTimer->stopTiming();
}
public function triggerGarbageCollector(){
/**
* @return int
*/
public function triggerGarbageCollector() : int{
Timings::$garbageCollectorTimer->startTiming();
if($this->garbageCollectionAsync){
@ -213,7 +253,16 @@ class MemoryManager{
return $cycles;
}
public function dumpServerMemory($outputFolder, $maxNesting, $maxStringSize){
/**
* Dumps the server memory into the specified output folder.
*
* @param string $outputFolder
* @param int $maxNesting
* @param int $maxStringSize
*/
public function dumpServerMemory(string $outputFolder, int $maxNesting, int $maxStringSize){
$hardLimit = ini_get('memory_limit');
ini_set('memory_limit', '-1');
gc_disable();
if(!file_exists($outputFolder)){
@ -232,6 +281,32 @@ class MemoryManager{
$refCounts = [];
$instanceCounts = [];
$staticCount = 0;
foreach($this->server->getLoader()->getClasses() as $className){
$reflection = new \ReflectionClass($className);
$staticProperties[$className] = [];
foreach($reflection->getProperties() as $property){
if(!$property->isStatic() or $property->getDeclaringClass()->getName() !== $className){
continue;
}
if(!$property->isPublic()){
$property->setAccessible(true);
}
$staticCount++;
$this->continueDump($property->getValue(), $staticProperties[$className][$property->getName()], $objects, $refCounts, 0, $maxNesting, $maxStringSize);
}
if(count($staticProperties[$className]) === 0){
unset($staticProperties[$className]);
}
}
echo "[Dump] Wrote $staticCount static properties\n";
$this->continueDump($this->server, $data, $objects, $refCounts, 0, $maxNesting, $maxStringSize);
do{
@ -243,6 +318,11 @@ class MemoryManager{
$continue = true;
$className = get_class($object);
if(!isset($instanceCounts[$className])){
$instanceCounts[$className] = 1;
}else{
$instanceCounts[$className]++;
}
$objects[$hash] = true;
@ -273,37 +353,36 @@ class MemoryManager{
}
fwrite($obData, "$hash@$className: " . json_encode($info, JSON_UNESCAPED_SLASHES) . "\n");
if(!isset($objects["staticProperties"][$className])){
$staticProperties[$className] = [];
foreach($reflection->getProperties() as $property){
if(!$property->isStatic() or $property->getDeclaringClass()->getName() !== $className){
continue;
}
if(!$property->isPublic()){
$property->setAccessible(true);
}
$this->continueDump($property->getValue($object), $staticProperties[$className][$property->getName()], $objects, $refCounts, 0, $maxNesting, $maxStringSize);
}
}
}
echo "[Dump] Wrote " . count($objects) . " objects\n";
}while($continue);
fclose($obData);
file_put_contents($outputFolder . "/staticProperties.js", json_encode($staticProperties, JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT));
file_put_contents($outputFolder . "/serverEntry.js", json_encode($data, JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT));
file_put_contents($outputFolder . "/referenceCounts.js", json_encode($refCounts, JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT));
arsort($instanceCounts, SORT_NUMERIC);
file_put_contents($outputFolder . "/instanceCounts.js", json_encode($instanceCounts, JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT));
echo "[Dump] Finished!\n";
ini_set('memory_limit', $hardLimit);
gc_enable();
}
private function continueDump($from, &$data, &$objects, &$refCounts, $recursion, $maxNesting, $maxStringSize){
/**
* @param mixed $from
* @param mixed &$data
* @param object[] &$objects
* @param int[] &$refCounts
* @param int $recursion
* @param int $maxNesting
* @param int $maxStringSize
*/
private function continueDump($from, &$data, array &$objects, array &$refCounts, int $recursion, int $maxNesting, int $maxStringSize){
if($maxNesting <= 0){
$data = "(error) NESTING LIMIT REACHED";
return;

View File

@ -19,6 +19,8 @@
*
*/
declare(strict_types=1);
namespace pocketmine;
use pocketmine\metadata\Metadatable;
@ -28,15 +30,18 @@ use pocketmine\plugin\Plugin;
class OfflinePlayer implements IPlayer, Metadatable{
/** @var string */
private $name;
/** @var Server */
private $server;
/** @var CompoundTag|null */
private $namedtag;
/**
* @param Server $server
* @param string $name
*/
public function __construct(Server $server, $name){
public function __construct(Server $server, string $name){
$this->server = $server;
$this->name = $name;
if(file_exists($this->server->getDataPath() . "players/" . strtolower($this->getName()) . ".dat")){
@ -46,11 +51,11 @@ class OfflinePlayer implements IPlayer, Metadatable{
}
}
public function isOnline(){
public function isOnline() : bool{
return $this->getPlayer() !== null;
}
public function getName(){
public function getName() : string{
return $this->name;
}
@ -58,11 +63,11 @@ class OfflinePlayer implements IPlayer, Metadatable{
return $this->server;
}
public function isOp(){
public function isOp() : bool{
return $this->server->isOp(strtolower($this->getName()));
}
public function setOp($value){
public function setOp(bool $value){
if($value === $this->isOp()){
return;
}
@ -74,11 +79,11 @@ class OfflinePlayer implements IPlayer, Metadatable{
}
}
public function isBanned(){
public function isBanned() : bool{
return $this->server->getNameBans()->isBanned(strtolower($this->getName()));
}
public function setBanned($value){
public function setBanned(bool $value){
if($value === true){
$this->server->getNameBans()->addBan($this->getName(), null, null, null);
}else{
@ -86,11 +91,11 @@ class OfflinePlayer implements IPlayer, Metadatable{
}
}
public function isWhitelisted(){
public function isWhitelisted() : bool{
return $this->server->isWhitelisted(strtolower($this->getName()));
}
public function setWhitelisted($value){
public function setWhitelisted(bool $value){
if($value === true){
$this->server->addWhitelist(strtolower($this->getName()));
}else{
@ -110,24 +115,24 @@ class OfflinePlayer implements IPlayer, Metadatable{
return $this->namedtag instanceof CompoundTag ? $this->namedtag["lastPlayed"] : null;
}
public function hasPlayedBefore(){
public function hasPlayedBefore() : bool{
return $this->namedtag instanceof CompoundTag;
}
public function setMetadata($metadataKey, MetadataValue $metadataValue){
$this->server->getPlayerMetadata()->setMetadata($this, $metadataKey, $metadataValue);
public function setMetadata(string $metadataKey, MetadataValue $newMetadataValue){
$this->server->getPlayerMetadata()->setMetadata($this, $metadataKey, $newMetadataValue);
}
public function getMetadata($metadataKey){
public function getMetadata(string $metadataKey){
return $this->server->getPlayerMetadata()->getMetadata($this, $metadataKey);
}
public function hasMetadata($metadataKey){
public function hasMetadata(string $metadataKey) : bool{
return $this->server->getPlayerMetadata()->hasMetadata($this, $metadataKey);
}
public function removeMetadata($metadataKey, Plugin $plugin){
$this->server->getPlayerMetadata()->removeMetadata($this, $metadataKey, $plugin);
public function removeMetadata(string $metadataKey, Plugin $owningPlugin){
$this->server->getPlayerMetadata()->removeMetadata($this, $metadataKey, $owningPlugin);
}

File diff suppressed because it is too large Load Diff

View File

@ -19,7 +19,12 @@
*
*/
declare(strict_types=1);
namespace {
const INT32_MIN = -0x80000000;
const INT32_MAX = 0x7fffffff;
function safe_var_dump(){
static $cnt = 0;
foreach(func_get_args() as $var){
@ -74,7 +79,7 @@ namespace pocketmine {
use raklib\RakLib;
const VERSION = "1.6.2dev";
const API_VERSION = "3.0.0-ALPHA5";
const API_VERSION = "3.0.0-ALPHA7";
const CODENAME = "Unleashed";
/*
@ -84,14 +89,8 @@ namespace pocketmine {
* Enjoy it as much as I did writing it. I don't want to do it again.
*/
if(\Phar::running(true) !== ""){
@define('pocketmine\PATH', \Phar::running(true) . "/");
}else{
@define('pocketmine\PATH', \getcwd() . DIRECTORY_SEPARATOR);
}
if(version_compare("7.0", PHP_VERSION) > 0){
echo "[CRITICAL] You must use PHP >= 7.0" . PHP_EOL;
if(version_compare("7.0", PHP_VERSION) > 0 or version_compare("7.1", PHP_VERSION) <= 0){
echo "[CRITICAL] You must use PHP 7.0" . PHP_EOL;
echo "[CRITICAL] Please use the installer provided on the homepage." . PHP_EOL;
exit(1);
}
@ -102,6 +101,35 @@ namespace pocketmine {
exit(1);
}
error_reporting(-1);
set_error_handler(function($severity, $message, $file, $line){
if(error_reporting() & $severity){
throw new \ErrorException($message, 0, $severity, $file, $line);
}else{ //stfu operator
return true;
}
});
if(!extension_loaded("phar")){
echo "[CRITICAL] Unable to find the Phar extension." . PHP_EOL;
echo "[CRITICAL] Please use the installer provided on the homepage." . PHP_EOL;
exit(1);
}
if(\Phar::running(true) !== ""){
define('pocketmine\PATH', \Phar::running(true) . "/");
}else{
define('pocketmine\PATH', realpath(getcwd()) . DIRECTORY_SEPARATOR);
}
$requiredSplVer = "0.0.1";
if(!is_file(\pocketmine\PATH . "src/spl/version.php") or version_compare($requiredSplVer, require(\pocketmine\PATH . "src/spl/version.php")) > 0){
echo "[CRITICAL] Incompatible PocketMine-SPL submodule version ($requiredSplVer is required)." . PHP_EOL;
echo "[CRITICAL] Please update your submodules or use provided builds." . PHP_EOL;
exit(1);
}
if(!class_exists("ClassLoader", false)){
if(!is_file(\pocketmine\PATH . "src/spl/ClassLoader.php")){
echo "[CRITICAL] Unable to find the PocketMine-SPL library." . PHP_EOL;
@ -117,24 +145,26 @@ 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){
if(!class_exists(RakLib::class)){
echo "[CRITICAL] Unable to find the RakLib library." . PHP_EOL;
echo "[CRITICAL] Please use provided builds or clone the repository recursively." . PHP_EOL;
exit(1);
}
if(version_compare(RakLib::VERSION, "0.8.1") < 0){
echo "[CRITICAL] RakLib version 0.8.1 is required, while you have version " . RakLib::VERSION . "." . PHP_EOL;
echo "[CRITICAL] Please update your submodules or use provided builds." . PHP_EOL;
exit(1);
}
set_time_limit(0); //Who set it to 30 seconds?!?!
error_reporting(-1);
ini_set("allow_url_fopen", 1);
ini_set("display_errors", 1);
ini_set("display_startup_errors", 1);
ini_set("allow_url_fopen", '1');
ini_set("display_errors", '1');
ini_set("display_startup_errors", '1');
ini_set("default_charset", "utf-8");
ini_set("memory_limit", -1);
ini_set("memory_limit", '-1');
define('pocketmine\START_TIME', microtime(true));
$opts = getopt("", ["data:", "plugins:", "no-wizard", "enable-profiler"]);
@ -153,7 +183,8 @@ namespace pocketmine {
//Logger has a dependency on timezone, so we'll set it to UTC until we can get the actual timezone.
date_default_timezone_set("UTC");
$logger = new MainLogger(\pocketmine\DATA . "server.log", \pocketmine\ANSI);
$logger = new MainLogger(\pocketmine\DATA . "server.log");
$logger->registerStatic();
if(!ini_get("date.timezone")){
if(($timezone = detect_system_timezone()) and date_default_timezone_set($timezone)){
@ -227,7 +258,6 @@ namespace pocketmine {
}
return parse_offset($offset);
break;
case 'linux':
// Ubuntu / Debian.
if(file_exists('/etc/timezone')){
@ -254,7 +284,6 @@ namespace pocketmine {
}
return parse_offset($offset);
break;
case 'mac':
if(is_link('/etc/localtime')){
$filename = readlink('/etc/localtime');
@ -265,17 +294,15 @@ namespace pocketmine {
}
return false;
break;
default:
return false;
break;
}
}
/**
* @param string $offset In the format of +09:00, +02:00, -04:00 etc.
*
* @return string
* @return string|bool
*/
function parse_offset($offset){
//Make signed offsets unsigned for date_parse
@ -376,150 +403,163 @@ namespace pocketmine {
}else{
$args = $trace[$i]["params"];
}
foreach($args as $name => $value){
$params .= (is_object($value) ? get_class($value) . " " . (method_exists($value, "__toString") ? $value->__toString() : "object") : gettype($value) . " " . (is_array($value) ? "Array()" : Utils::printable(@strval($value)))) . ", ";
}
$params = implode(", ", array_map(function($value){
return (is_object($value) ? get_class($value) . " object" : gettype($value) . " " . (is_array($value) ? "Array()" : Utils::printable(@strval($value))));
}, $args));
}
$messages[] = "#$j " . (isset($trace[$i]["file"]) ? cleanPath($trace[$i]["file"]) : "") . "(" . (isset($trace[$i]["line"]) ? $trace[$i]["line"] : "") . "): " . (isset($trace[$i]["class"]) ? $trace[$i]["class"] . (($trace[$i]["type"] === "dynamic" or $trace[$i]["type"] === "->") ? "->" : "::") : "") . $trace[$i]["function"] . "(" . Utils::printable(substr($params, 0, -2)) . ")";
$messages[] = "#$j " . (isset($trace[$i]["file"]) ? cleanPath($trace[$i]["file"]) : "") . "(" . ($trace[$i]["line"] ?? "") . "): " . (isset($trace[$i]["class"]) ? $trace[$i]["class"] . (($trace[$i]["type"] === "dynamic" or $trace[$i]["type"] === "->") ? "->" : "::") : "") . $trace[$i]["function"] . "(" . Utils::printable($params) . ")";
}
return $messages;
}
function cleanPath($path){
return rtrim(str_replace(["\\", ".php", "phar://", rtrim(str_replace(["\\", "phar://"], ["/", ""], \pocketmine\PATH), "/"), rtrim(str_replace(["\\", "phar://"], ["/", ""], \pocketmine\PLUGIN_PATH), "/")], ["/", "", "", "", ""], $path), "/");
return str_replace(["\\", ".php", "phar://", str_replace(["\\", "phar://"], ["/", ""], \pocketmine\PATH), str_replace(["\\", "phar://"], ["/", ""], \pocketmine\PLUGIN_PATH)], ["/", "", "", "", ""], $path);
}
$errors = 0;
$exitCode = 0;
if(php_sapi_name() !== "cli"){
$logger->critical("You must run PocketMine-MP using the CLI.");
++$errors;
}
do{
$errors = 0;
$pthreads_version = phpversion("pthreads");
if(substr_count($pthreads_version, ".") < 2){
$pthreads_version = "0.$pthreads_version";
}
if(version_compare($pthreads_version, "3.1.5") < 0){
$logger->critical("pthreads >= 3.1.5 is required, while you have $pthreads_version.");
++$errors;
}
if(PHP_INT_SIZE < 8){
$logger->critical("Running PocketMine-MP with 32-bit systems/PHP is no longer supported. Please upgrade to a 64-bit system or use a 64-bit PHP binary.");
$exitCode = 1;
break;
}
if(extension_loaded("pocketmine")){
if(version_compare(phpversion("pocketmine"), "0.0.1") < 0){
$logger->critical("You have the native PocketMine extension, but your version is lower than 0.0.1.");
++$errors;
}elseif(version_compare(phpversion("pocketmine"), "0.0.4") > 0){
$logger->critical("You have the native PocketMine extension, but your version is higher than 0.0.4.");
if(php_sapi_name() !== "cli"){
$logger->critical("You must run PocketMine-MP using the CLI.");
++$errors;
}
}
if(extension_loaded("xdebug")){
$logger->warning("
You are running PocketMine with xdebug enabled. This has a major impact on performance.
");
}
$extensions = [
"curl" => "cURL",
"json" => "JSON",
"mbstring" => "Multibyte String",
"yaml" => "YAML",
"sockets" => "Sockets",
"zip" => "Zip",
"zlib" => "Zlib"
];
foreach($extensions as $ext => $name){
if(!extension_loaded($ext)){
$logger->critical("Unable to find the $name ($ext) extension.");
$pthreads_version = phpversion("pthreads");
if(substr_count($pthreads_version, ".") < 2){
$pthreads_version = "0.$pthreads_version";
}
if(version_compare($pthreads_version, "3.1.5") < 0){
$logger->critical("pthreads >= 3.1.5 is required, while you have $pthreads_version.");
++$errors;
}
}
if($errors > 0){
$logger->critical("Please use the installer provided on the homepage, or recompile PHP again.");
$logger->shutdown();
$logger->join();
exit(1); //Exit with error
}
if(PHP_INT_SIZE < 8){
$logger->warning("Running PocketMine-MP with 32-bit systems/PHP is deprecated. Support for 32-bit may be dropped in the future.");
}
$gitHash = str_repeat("00", 20);
if(file_exists(\pocketmine\PATH . ".git/HEAD")){ //Found Git information!
$ref = trim(file_get_contents(\pocketmine\PATH . ".git/HEAD"));
if(preg_match('/^[0-9a-f]{40}$/i', $ref)){
$gitHash = strtolower($ref);
}elseif(substr($ref, 0, 5) === "ref: "){
$refFile = \pocketmine\PATH . ".git/" . substr($ref, 5);
if(is_file($refFile)){
$gitHash = strtolower(trim(file_get_contents($refFile)));
if(extension_loaded("leveldb")){
$leveldb_version = phpversion("leveldb");
if(version_compare($leveldb_version, "0.2.0") < 0){
$logger->critical("php-leveldb >= 0.2.0 is required, while you have $leveldb_version");
++$errors;
}
}
}
define('pocketmine\GIT_COMMIT', $gitHash);
@define("ENDIANNESS", (pack("d", 1) === "\77\360\0\0\0\0\0\0" ? Binary::BIG_ENDIAN : Binary::LITTLE_ENDIAN));
@define("INT32_MASK", is_int(0xffffffff) ? 0xffffffff : -1);
@ini_set("opcache.mmap_base", bin2hex(random_bytes(8))); //Fix OPCache address errors
if(!file_exists(\pocketmine\DATA . "server.properties") and !isset($opts["no-wizard"])){
$installer = new SetupWizard();
if(!$installer->run()){
$logger->shutdown();
$logger->join();
exit(-1);
if(extension_loaded("pocketmine")){
if(version_compare(phpversion("pocketmine"), "0.0.1") < 0){
$logger->critical("You have the native PocketMine extension, but your version is lower than 0.0.1.");
++$errors;
}elseif(version_compare(phpversion("pocketmine"), "0.0.4") > 0){
$logger->critical("You have the native PocketMine extension, but your version is higher than 0.0.4.");
++$errors;
}
}
}
if(\Phar::running(true) === ""){
$logger->warning("Non-packaged PocketMine-MP installation detected, do not use on production.");
}
ThreadManager::init();
new Server($autoloader, $logger, \pocketmine\PATH, \pocketmine\DATA, \pocketmine\PLUGIN_PATH);
$logger->info("Stopping other threads");
$killer = new ServerKiller(8);
$killer->start();
$erroredThreads = 0;
foreach(ThreadManager::getInstance()->getAll() as $id => $thread){
$logger->debug("Stopping " . $thread->getThreadName() . " thread");
try{
$thread->quit();
$logger->debug($thread->getThreadName() . " thread stopped successfully.");
}catch(\ThreadException $e){
++$erroredThreads;
$logger->debug("Could not stop " . $thread->getThreadName() . " thread: " . $e->getMessage());
if(extension_loaded("xdebug")){
$logger->warning(PHP_EOL . PHP_EOL . PHP_EOL . "\tYou are running PocketMine with xdebug enabled. This has a major impact on performance." . PHP_EOL . PHP_EOL);
}
}
$extensions = [
"bcmath" => "BC Math",
"curl" => "cURL",
"json" => "JSON",
"mbstring" => "Multibyte String",
"yaml" => "YAML",
"sockets" => "Sockets",
"zip" => "Zip",
"zlib" => "Zlib"
];
foreach($extensions as $ext => $name){
if(!extension_loaded($ext)){
$logger->critical("Unable to find the $name ($ext) extension.");
++$errors;
}
}
if($errors > 0){
$logger->critical("Please use the installer provided on the homepage, or recompile PHP again.");
$exitCode = 1;
break;
}
$gitHash = str_repeat("00", 20);
if(\Phar::running(true) === ""){
if(Utils::execute("git rev-parse HEAD", $out) === 0){
$gitHash = trim($out);
if(Utils::execute("git diff --quiet") === 1 or Utils::execute("git diff --cached --quiet") === 1){ //Locally-modified
$gitHash .= "-dirty";
}
}
}else{
$phar = new \Phar(\Phar::running(false));
$meta = $phar->getMetadata();
if(isset($meta["git"])){
$gitHash = $meta["git"];
}
}
define('pocketmine\GIT_COMMIT', $gitHash);
@define("ENDIANNESS", (pack("d", 1) === "\77\360\0\0\0\0\0\0" ? Binary::BIG_ENDIAN : Binary::LITTLE_ENDIAN));
@define("INT32_MASK", is_int(0xffffffff) ? 0xffffffff : -1);
@ini_set("opcache.mmap_base", bin2hex(random_bytes(8))); //Fix OPCache address errors
if(!file_exists(\pocketmine\DATA . "server.properties") and !isset($opts["no-wizard"])){
$installer = new SetupWizard();
if(!$installer->run()){
$exitCode = -1;
break;
}
}
if(\Phar::running(true) === ""){
$logger->warning("Non-packaged PocketMine-MP installation detected, do not use on production.");
}
ThreadManager::init();
new Server($autoloader, $logger, \pocketmine\PATH, \pocketmine\DATA, \pocketmine\PLUGIN_PATH);
$logger->info("Stopping other threads");
$killer = new ServerKiller(8);
$killer->start();
usleep(10000); //Fixes ServerKiller not being able to start on single-core machines
$erroredThreads = 0;
foreach(ThreadManager::getInstance()->getAll() as $id => $thread){
$logger->debug("Stopping " . $thread->getThreadName() . " thread");
try{
$thread->quit();
$logger->debug($thread->getThreadName() . " thread stopped successfully.");
}catch(\ThreadException $e){
++$erroredThreads;
$logger->debug("Could not stop " . $thread->getThreadName() . " thread: " . $e->getMessage());
}
}
if($erroredThreads > 0){
if(\pocketmine\DEBUG > 1){
echo "Some threads could not be stopped, performing a force-kill" . PHP_EOL . PHP_EOL;
}
kill(getmypid());
}
}while(false);
$logger->shutdown();
$logger->join();
echo Terminal::$FORMAT_RESET . PHP_EOL;
if($erroredThreads > 0){
if(\pocketmine\DEBUG > 1){
echo "Some threads could not be stopped, performing a force-kill" . PHP_EOL . PHP_EOL;
}
kill(getmypid());
}else{
exit(0);
}
exit($exitCode);
}

File diff suppressed because it is too large Load Diff

View File

@ -19,6 +19,8 @@
*
*/
declare(strict_types=1);
namespace pocketmine;
/**
@ -41,6 +43,13 @@ abstract class Thread extends \Thread{
$this->classLoader = $loader;
}
/**
* Registers the class loader for this thread.
*
* WARNING: This method MUST be called from any descendent threads' run() method to make autoloading usable.
* If you do not do this, you will not be able to use new classes that were not loaded when the thread was started
* (unless you are using a custom autoloader).
*/
public function registerClassLoader(){
if(!interface_exists("ClassLoader", false)){
require(\pocketmine\PATH . "src/spl/ClassLoader.php");
@ -81,7 +90,7 @@ abstract class Thread extends \Thread{
ThreadManager::getInstance()->remove($this);
}
public function getThreadName(){
public function getThreadName() : string{
return (new \ReflectionClass($this))->getShortName();
}
}

View File

@ -19,6 +19,8 @@
*
*/
declare(strict_types=1);
namespace pocketmine;
class ThreadManager extends \Volatile{
@ -58,7 +60,7 @@ class ThreadManager extends \Volatile{
/**
* @return Worker[]|Thread[]
*/
public function getAll(){
public function getAll() : array{
$array = [];
foreach($this as $key => $thread){
$array[$key] = $thread;

View File

@ -19,6 +19,8 @@
*
*/
declare(strict_types=1);
namespace pocketmine;
/**
@ -42,6 +44,13 @@ abstract class Worker extends \Worker{
$this->classLoader = $loader;
}
/**
* Registers the class loader for this thread.
*
* WARNING: This method MUST be called from any descendent threads' run() method to make autoloading usable.
* If you do not do this, you will not be able to use new classes that were not loaded when the thread was started
* (unless you are using a custom autoloader).
*/
public function registerClassLoader(){
if(!interface_exists("ClassLoader", false)){
require(\pocketmine\PATH . "src/spl/ClassLoader.php");
@ -86,7 +95,7 @@ abstract class Worker extends \Worker{
ThreadManager::getInstance()->remove($this);
}
public function getThreadName(){
public function getThreadName() : string{
return (new \ReflectionClass($this))->getShortName();
}
}

View File

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

View File

@ -19,6 +19,8 @@
*
*/
declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\item\Item;
@ -32,35 +34,35 @@ class Air extends Transparent{
protected $id = self::AIR;
protected $meta = 0;
public function __construct(){
public function __construct(int $meta = 0){
$this->meta = $meta;
}
public function getName(){
public function getName() : string{
return "Air";
}
public function canPassThrough(){
public function canPassThrough() : bool{
return true;
}
public function isBreakable(Item $item){
public function isBreakable(Item $item) : bool{
return false;
}
public function canBeFlowedInto(){
public function canBeFlowedInto() : bool{
return true;
}
public function canBeReplaced(){
public function canBeReplaced(Block $with = null) : bool{
return true;
}
public function canBePlaced(){
public function canBePlaced() : bool{
return false;
}
public function isSolid(){
public function isSolid() : bool{
return false;
}
@ -68,11 +70,11 @@ class Air extends Transparent{
return null;
}
public function getHardness(){
public function getHardness() : float{
return -1;
}
public function getResistance(){
public function getBlastResistance() : float{
return 0;
}

View File

@ -19,11 +19,15 @@
*
*/
declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\inventory\AnvilInventory;
use pocketmine\item\Item;
use pocketmine\item\ItemFactory;
use pocketmine\item\Tool;
use pocketmine\math\Vector3;
use pocketmine\Player;
class Anvil extends Fallable{
@ -34,27 +38,23 @@ class Anvil extends Fallable{
protected $id = self::ANVIL;
public function isSolid(){
public function isSolid() : bool{
return false;
}
public function __construct($meta = 0){
public function __construct(int $meta = 0){
$this->meta = $meta;
}
public function canBeActivated(){
return true;
}
public function getHardness(){
public function getHardness() : float{
return 5;
}
public function getResistance(){
public function getBlastResistance() : float{
return 6000;
}
public function getName(){
public function getName() : string{
static $names = [
self::TYPE_NORMAL => "Anvil",
self::TYPE_SLIGHTLY_DAMAGED => "Slightly Damaged Anvil",
@ -63,11 +63,11 @@ class Anvil extends Fallable{
return $names[$this->meta & 0x0c] ?? "Anvil";
}
public function getToolType(){
public function getToolType() : int{
return Tool::TYPE_PICKAXE;
}
public function onActivate(Item $item, Player $player = null){
public function onActivate(Item $item, Player $player = null) : bool{
if($player instanceof Player){
$player->addWindow(new AnvilInventory($this));
}
@ -75,19 +75,19 @@ class Anvil extends Fallable{
return true;
}
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){
public function place(Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $facePos, Player $player = null) : bool{
$direction = ($player !== null ? $player->getDirection() : 0) & 0x03;
$this->meta = ($this->meta & 0x0c) | $direction;
$this->getLevel()->setBlock($block, $this, true, true);
return $this->getLevel()->setBlock($blockReplace, $this, true, true);
}
public function getDrops(Item $item){
public function getDrops(Item $item) : array{
if($item->isPickaxe() >= Tool::TIER_WOODEN){
return [
[$this->id, $this->meta & 0x0c, 1],
ItemFactory::get($this->getItemId(), $this->getDamage() & 0x0c, 1)
];
}else{
return [];
}
return [];
}
}

View File

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

View File

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

View File

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

View File

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

View File

@ -19,6 +19,8 @@
*
*/
declare(strict_types=1);
/**
* All Block classes are in here
*/
@ -26,6 +28,7 @@ namespace pocketmine\block;
use pocketmine\entity\Entity;
use pocketmine\item\Item;
use pocketmine\item\ItemFactory;
use pocketmine\item\Tool;
use pocketmine\level\Level;
use pocketmine\level\MovingObjectPosition;
@ -39,326 +42,137 @@ use pocketmine\plugin\Plugin;
class Block extends Position implements BlockIds, Metadatable{
/** @var \SplFixedArray */
public static $list = null;
/** @var \SplFixedArray */
public static $fullList = null;
/** @var \SplFixedArray */
public static $light = null;
/** @var \SplFixedArray */
public static $lightFilter = null;
/** @var \SplFixedArray */
public static $solid = null;
/** @var \SplFixedArray */
public static $hardness = null;
/** @var \SplFixedArray */
public static $transparent = null;
/**
* Returns a new Block instance with the specified ID, meta and position.
*
* This function redirects to {@link BlockFactory#get}.
*
* @param int $id
* @param int $meta
* @param Position|null $pos
*
* @return Block
*/
public static function get(int $id, int $meta = 0, Position $pos = null) : Block{
return BlockFactory::get($id, $meta, $pos);
}
/** @var int */
protected $id;
/** @var int */
protected $meta = 0;
/** @var string */
protected $fallbackName;
/** @var int|null */
protected $itemId;
/** @var AxisAlignedBB */
public $boundingBox = null;
public static function init(){
if(self::$list === null){
self::$list = new \SplFixedArray(256);
self::$fullList = new \SplFixedArray(4096);
self::$light = new \SplFixedArray(256);
self::$lightFilter = new \SplFixedArray(256);
self::$solid = new \SplFixedArray(256);
self::$hardness = new \SplFixedArray(256);
self::$transparent = new \SplFixedArray(256);
self::$list[self::AIR] = Air::class;
self::$list[self::STONE] = Stone::class;
self::$list[self::GRASS] = Grass::class;
self::$list[self::DIRT] = Dirt::class;
self::$list[self::COBBLESTONE] = Cobblestone::class;
self::$list[self::PLANKS] = Planks::class;
self::$list[self::SAPLING] = Sapling::class;
self::$list[self::BEDROCK] = Bedrock::class;
self::$list[self::WATER] = Water::class;
self::$list[self::STILL_WATER] = StillWater::class;
self::$list[self::LAVA] = Lava::class;
self::$list[self::STILL_LAVA] = StillLava::class;
self::$list[self::SAND] = Sand::class;
self::$list[self::GRAVEL] = Gravel::class;
self::$list[self::GOLD_ORE] = GoldOre::class;
self::$list[self::IRON_ORE] = IronOre::class;
self::$list[self::COAL_ORE] = CoalOre::class;
self::$list[self::WOOD] = Wood::class;
self::$list[self::LEAVES] = Leaves::class;
self::$list[self::SPONGE] = Sponge::class;
self::$list[self::GLASS] = Glass::class;
self::$list[self::LAPIS_ORE] = LapisOre::class;
self::$list[self::LAPIS_BLOCK] = Lapis::class;
self::$list[self::ACTIVATOR_RAIL] = ActivatorRail::class;
self::$list[self::COCOA_BLOCK] = CocoaBlock::class;
self::$list[self::SANDSTONE] = Sandstone::class;
self::$list[self::NOTE_BLOCK] = NoteBlock::class;
self::$list[self::BED_BLOCK] = Bed::class;
self::$list[self::POWERED_RAIL] = PoweredRail::class;
self::$list[self::DETECTOR_RAIL] = DetectorRail::class;
self::$list[self::COBWEB] = Cobweb::class;
self::$list[self::TALL_GRASS] = TallGrass::class;
self::$list[self::DEAD_BUSH] = DeadBush::class;
self::$list[self::WOOL] = Wool::class;
self::$list[self::DANDELION] = Dandelion::class;
self::$list[self::RED_FLOWER] = Flower::class;
self::$list[self::BROWN_MUSHROOM] = BrownMushroom::class;
self::$list[self::RED_MUSHROOM] = RedMushroom::class;
self::$list[self::GOLD_BLOCK] = Gold::class;
self::$list[self::IRON_BLOCK] = Iron::class;
self::$list[self::DOUBLE_SLAB] = DoubleSlab::class;
self::$list[self::SLAB] = Slab::class;
self::$list[self::BRICKS_BLOCK] = Bricks::class;
self::$list[self::TNT] = TNT::class;
self::$list[self::BOOKSHELF] = Bookshelf::class;
self::$list[self::MOSS_STONE] = MossStone::class;
self::$list[self::OBSIDIAN] = Obsidian::class;
self::$list[self::TORCH] = Torch::class;
self::$list[self::FIRE] = Fire::class;
self::$list[self::MONSTER_SPAWNER] = MonsterSpawner::class;
self::$list[self::WOOD_STAIRS] = WoodStairs::class;
self::$list[self::CHEST] = Chest::class;
self::$list[self::DIAMOND_ORE] = DiamondOre::class;
self::$list[self::DIAMOND_BLOCK] = Diamond::class;
self::$list[self::WORKBENCH] = Workbench::class;
self::$list[self::WHEAT_BLOCK] = Wheat::class;
self::$list[self::FARMLAND] = Farmland::class;
self::$list[self::FURNACE] = Furnace::class;
self::$list[self::BURNING_FURNACE] = BurningFurnace::class;
self::$list[self::SIGN_POST] = SignPost::class;
self::$list[self::WOOD_DOOR_BLOCK] = WoodDoor::class;
self::$list[self::LADDER] = Ladder::class;
self::$list[self::RAIL] = Rail::class;
self::$list[self::COBBLESTONE_STAIRS] = CobblestoneStairs::class;
self::$list[self::WALL_SIGN] = WallSign::class;
self::$list[self::LEVER] = Lever::class;
self::$list[self::STONE_PRESSURE_PLATE] = StonePressurePlate::class;
self::$list[self::IRON_DOOR_BLOCK] = IronDoor::class;
self::$list[self::WOODEN_PRESSURE_PLATE] = WoodenPressurePlate::class;
self::$list[self::REDSTONE_ORE] = RedstoneOre::class;
self::$list[self::GLOWING_REDSTONE_ORE] = GlowingRedstoneOre::class;
self::$list[self::REDSTONE_TORCH] = RedstoneTorch::class;
self::$list[self::LIT_REDSTONE_TORCH] = LitRedstoneTorch::class;
self::$list[self::STONE_BUTTON] = StoneButton::class;
self::$list[self::SNOW_LAYER] = SnowLayer::class;
self::$list[self::ICE] = Ice::class;
self::$list[self::SNOW_BLOCK] = Snow::class;
self::$list[self::CACTUS] = Cactus::class;
self::$list[self::CLAY_BLOCK] = Clay::class;
self::$list[self::SUGARCANE_BLOCK] = Sugarcane::class;
self::$list[self::FENCE] = Fence::class;
self::$list[self::PUMPKIN] = Pumpkin::class;
self::$list[self::NETHERRACK] = Netherrack::class;
self::$list[self::SOUL_SAND] = SoulSand::class;
self::$list[self::GLOWSTONE_BLOCK] = Glowstone::class;
self::$list[self::LIT_PUMPKIN] = LitPumpkin::class;
self::$list[self::CAKE_BLOCK] = Cake::class;
self::$list[self::TRAPDOOR] = Trapdoor::class;
self::$list[self::STONE_BRICKS] = StoneBricks::class;
self::$list[self::IRON_BARS] = IronBars::class;
self::$list[self::GLASS_PANE] = GlassPane::class;
self::$list[self::MELON_BLOCK] = Melon::class;
self::$list[self::PUMPKIN_STEM] = PumpkinStem::class;
self::$list[self::MELON_STEM] = MelonStem::class;
self::$list[self::VINE] = Vine::class;
self::$list[self::FENCE_GATE] = FenceGate::class;
self::$list[self::BRICK_STAIRS] = BrickStairs::class;
self::$list[self::STONE_BRICK_STAIRS] = StoneBrickStairs::class;
self::$list[self::MYCELIUM] = Mycelium::class;
self::$list[self::WATER_LILY] = WaterLily::class;
self::$list[self::NETHER_BRICKS] = NetherBrick::class;
self::$list[self::NETHER_BRICK_FENCE] = NetherBrickFence::class;
self::$list[self::NETHER_BRICKS_STAIRS] = NetherBrickStairs::class;
self::$list[self::ENCHANTING_TABLE] = EnchantingTable::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;
self::$list[self::LIT_REDSTONE_LAMP] = LitRedstoneLamp::class;
self::$list[self::SANDSTONE_STAIRS] = SandstoneStairs::class;
self::$list[self::EMERALD_ORE] = EmeraldOre::class;
self::$list[self::TRIPWIRE_HOOK] = TripwireHook::class;
self::$list[self::TRIPWIRE] = Tripwire::class;
self::$list[self::EMERALD_BLOCK] = Emerald::class;
self::$list[self::SPRUCE_WOOD_STAIRS] = SpruceWoodStairs::class;
self::$list[self::BIRCH_WOOD_STAIRS] = BirchWoodStairs::class;
self::$list[self::JUNGLE_WOOD_STAIRS] = JungleWoodStairs::class;
self::$list[self::STONE_WALL] = StoneWall::class;
self::$list[self::FLOWER_POT_BLOCK] = FlowerPot::class;
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_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;
self::$list[self::QUARTZ_BLOCK] = Quartz::class;
self::$list[self::QUARTZ_STAIRS] = QuartzStairs::class;
self::$list[self::DOUBLE_WOOD_SLAB] = DoubleWoodSlab::class;
self::$list[self::WOOD_SLAB] = WoodSlab::class;
self::$list[self::STAINED_CLAY] = StainedClay::class;
self::$list[self::LEAVES2] = Leaves2::class;
self::$list[self::WOOD2] = Wood2::class;
self::$list[self::ACACIA_WOOD_STAIRS] = AcaciaWoodStairs::class;
self::$list[self::DARK_OAK_WOOD_STAIRS] = DarkOakWoodStairs::class;
self::$list[self::PRISMARINE] = Prismarine::class;
self::$list[self::SEA_LANTERN] = SeaLantern::class;
self::$list[self::IRON_TRAPDOOR] = IronTrapdoor::class;
self::$list[self::HAY_BALE] = HayBale::class;
self::$list[self::CARPET] = Carpet::class;
self::$list[self::HARDENED_CLAY] = HardenedClay::class;
self::$list[self::COAL_BLOCK] = Coal::class;
self::$list[self::PACKED_ICE] = PackedIce::class;
self::$list[self::DOUBLE_PLANT] = DoublePlant::class;
self::$list[self::FENCE_GATE_SPRUCE] = FenceGateSpruce::class;
self::$list[self::FENCE_GATE_BIRCH] = FenceGateBirch::class;
self::$list[self::FENCE_GATE_JUNGLE] = FenceGateJungle::class;
self::$list[self::FENCE_GATE_DARK_OAK] = FenceGateDarkOak::class;
self::$list[self::FENCE_GATE_ACACIA] = FenceGateAcacia::class;
self::$list[self::ITEM_FRAME_BLOCK] = ItemFrame::class;
self::$list[self::GRASS_PATH] = GrassPath::class;
self::$list[self::PODZOL] = Podzol::class;
self::$list[self::BEETROOT_BLOCK] = Beetroot::class;
self::$list[self::STONECUTTER] = Stonecutter::class;
self::$list[self::GLOWING_OBSIDIAN] = GlowingObsidian::class;
foreach(self::$list as $id => $class){
if($class !== null){
/** @var Block $block */
$block = new $class();
for($data = 0; $data < 16; ++$data){
self::$fullList[($id << 4) | $data] = new $class($data);
}
self::$solid[$id] = $block->isSolid();
self::$transparent[$id] = $block->isTransparent();
self::$hardness[$id] = $block->getHardness();
self::$light[$id] = $block->getLightLevel();
if($block->isSolid()){
if($block->isTransparent()){
if($block instanceof Liquid or $block instanceof Ice){
self::$lightFilter[$id] = 2;
}else{
self::$lightFilter[$id] = 1;
}
}else{
self::$lightFilter[$id] = 15;
}
}else{
self::$lightFilter[$id] = 1;
}
}else{
self::$lightFilter[$id] = 1;
for($data = 0; $data < 16; ++$data){
self::$fullList[($id << 4) | $data] = new UnknownBlock($id, $data);
}
}
}
}
}
/**
* @param int $id
* @param int $meta
* @param Position $pos
*
* @return Block
* @param int $id The block type's ID, 0-255
* @param int $meta Meta value of the block type
* @param string $name English name of the block type (TODO: implement translations)
* @param int $itemId The item ID of the block type, used for block picking and dropping items.
*/
public static function get($id, $meta = 0, Position $pos = null){
try{
$block = self::$list[$id];
if($block !== null){
$block = new $block($meta);
}else{
$block = new UnknownBlock($id, $meta);
}
}catch(\RuntimeException $e){
$block = new UnknownBlock($id, $meta);
}
if($pos !== null){
$block->x = $pos->x;
$block->y = $pos->y;
$block->z = $pos->z;
$block->level = $pos->level;
}
return $block;
public function __construct(int $id, int $meta = 0, string $name = "Unknown", int $itemId = null){
$this->id = $id;
$this->meta = $meta;
$this->fallbackName = $name;
$this->itemId = $itemId;
}
/**
* @return string
*/
public function getName() : string{
return $this->fallbackName;
}
/**
* @return int
*/
final public function getId() : int{
return $this->id;
}
/**
* Returns the ID of the item form of the block.
* Used for drops for blocks (some blocks such as doors have a different item ID).
*
* @return int
*/
public function getItemId() : int{
return $this->itemId ?? $this->getId();
}
/**
* @return int
*/
final public function getDamage() : int{
return $this->meta;
}
/**
* @param int $id
* @param int $meta
*/
public function __construct($id, $meta = 0){
$this->id = (int) $id;
$this->meta = (int) $meta;
final public function setDamage(int $meta){
if($meta < 0 or $meta > 0xf){
throw new \InvalidArgumentException("Block damage values must be 0-15, not $meta");
}
$this->meta = $meta;
}
/**
* Bitmask to use to remove superfluous information from block meta when getting its item form or name.
* This defaults to -1 (don't remove any data). Used to remove rotation data and bitflags from block drops.
*
* If your block should not have any meta value when it's dropped as an item, override this to return 0 in
* descendent classes.
*
* @return int
*/
public function getVariantBitmask() : int{
return -1;
}
/**
* Places the Block, using block space and block target, and side. Returns if the block has been placed.
*
* @param Item $item
* @param Block $block
* @param Block $target
* @param int $face
* @param float $fx
* @param float $fy
* @param float $fz
* @param Player $player = null
* @param Item $item
* @param Block $blockReplace
* @param Block $blockClicked
* @param int $face
* @param Vector3 $facePos
* @param Player|null $player
*
* @return bool
*/
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){
public function place(Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $facePos, Player $player = null) : bool{
return $this->getLevel()->setBlock($this, $this, true, true);
}
/**
* Returns if the item can be broken with an specific Item
* Returns if the block can be broken with an specific Item
*
* @param Item $item
*
* @return bool
*/
public function isBreakable(Item $item){
public function isBreakable(Item $item) : bool{
return true;
}
/**
* Do the actions needed so the block is broken with the Item
*
* @param Item $item
* @param Item $item
* @param Player|null $player
*
* @return mixed
* @return bool
*/
public function onBreak(Item $item){
return $this->getLevel()->setBlock($this, new Air(), true, true);
public function onBreak(Item $item, Player $player = null) : bool{
return $this->getLevel()->setBlock($this, BlockFactory::get(Block::AIR), true, true);
}
/**
@ -366,144 +180,158 @@ class Block extends Position implements BlockIds, Metadatable{
*
* @param int $type
*
* @return int|bool
* @return bool|int
*/
public function onUpdate($type){
public function onUpdate(int $type){
return false;
}
/**
* Do actions when activated by Item. Returns if it has done anything
*
* @param Item $item
* @param Player $player
* @param Item $item
* @param Player|null $player
*
* @return bool
*/
public function onActivate(Item $item, Player $player = null){
public function onActivate(Item $item, Player $player = null) : bool{
return false;
}
/**
* @return int
* Returns a base value used to compute block break times.
* @return float
*/
public function getHardness(){
public function getHardness() : float{
return 10;
}
/**
* @return int
* @deprecated
* @return float
*/
public function getResistance(){
public function getResistance() : float{
return $this->getBlastResistance();
}
/**
* Returns the block's resistance to explosions. Usually 5x hardness.
* @return float
*/
public function getBlastResistance() : float{
return $this->getHardness() * 5;
}
/**
* @return int
*/
public function getToolType(){
public function getToolType() : int{
return Tool::TYPE_NONE;
}
/**
* @return float
*/
public function getFrictionFactor(){
public function getFrictionFactor() : float{
return 0.6;
}
/**
* @return int 0-15
*/
public function getLightLevel(){
public function getLightLevel() : int{
return 0;
}
/**
* AKA: Block->isPlaceable
* Returns the amount of light this block will filter out when light passes through this block.
* This value is used in light spread calculation.
*
* @return int 0-15
*/
public function getLightFilter() : int{
return 15;
}
/**
* Returns whether this block will diffuse sky light passing through it vertically.
* Diffusion means that full-strength sky light passing through this block will not be reduced, but will start being filtered below the block.
* Examples of this behaviour include leaves and cobwebs.
*
* Light-diffusing blocks are included by the heightmap.
*
* @return bool
*/
public function canBePlaced(){
public function diffusesSkyLight() : bool{
return false;
}
/**
* Returns whether random block updates will be done on this block.
*
* @return bool
*/
public function ticksRandomly() : bool{
return false;
}
/**
* AKA: Block->isPlaceable
* @return bool
*/
public function canBePlaced() : bool{
return true;
}
/**
* @param Block|null $with
*
* @return bool
*/
public function canBeReplaced(){
public function canBeReplaced(Block $with = null) : bool{
return false;
}
/**
* @return bool
*/
public function isTransparent(){
public function isTransparent() : bool{
return false;
}
public function isSolid(){
public function isSolid() : bool{
return true;
}
/**
* AKA: Block->isFlowable
*
* @return bool
*/
public function canBeFlowedInto(){
public function canBeFlowedInto() : bool{
return false;
}
public function hasEntityCollision() : bool{
return false;
}
public function canPassThrough() : bool{
return false;
}
/**
* AKA: Block->isActivable
*
* Returns whether entities can climb up this block.
* @return bool
*/
public function canBeActivated(){
public function canClimb() : bool{
return false;
}
public function hasEntityCollision(){
return false;
}
public function canPassThrough(){
return false;
}
/**
* @return string
*/
public function getName(){
return "Unknown";
}
/**
* @return int
*/
final public function getId(){
return $this->id;
}
public function addVelocityToEntity(Entity $entity, Vector3 $vector){
}
/**
* @return int
*/
final public function getDamage(){
return $this->meta;
}
/**
* @param int $meta
*/
final public function setDamage($meta){
$this->meta = $meta & 0x0f;
}
/**
* Sets the block position to a new Position object
*
@ -522,16 +350,12 @@ class Block extends Position implements BlockIds, Metadatable{
*
* @param Item $item
*
* @return array
* @return Item[]
*/
public function getDrops(Item $item){
if(!isset(self::$list[$this->getId()])){ //Unknown blocks
return [];
}else{
return [
[$this->getId(), $this->getDamage(), 1],
];
}
public function getDrops(Item $item) : array{
return [
ItemFactory::get($this->getItemId(), $this->getDamage() & $this->getVariantBitmask(), 1)
];
}
/**
@ -541,7 +365,7 @@ class Block extends Position implements BlockIds, Metadatable{
*
* @return float
*/
public function getBreakTime(Item $item){
public function getBreakTime(Item $item) : float{
$base = $this->getHardness() * 1.5;
if($this->canBeBrokenWith($item)){
if($this->getToolType() === Tool::TYPE_SHEARS and $item->isShears()){
@ -580,10 +404,18 @@ class Block extends Position implements BlockIds, Metadatable{
return $base;
}
public function canBeBrokenWith(Item $item){
public function canBeBrokenWith(Item $item) : bool{
return $this->getHardness() !== -1;
}
/**
* Returns the time in ticks which the block will fuel a furnace for.
* @return int
*/
public function getFuelTime() : int{
return 0;
}
/**
* Returns the Block on the side $side, works like Vector3::side()
*
@ -597,7 +429,7 @@ class Block extends Position implements BlockIds, Metadatable{
return $this->getLevel()->getBlock(Vector3::getSide($side, $step));
}
return Block::get(Item::AIR, 0, Position::fromObject(Vector3::getSide($side, $step)));
return BlockFactory::get(Block::AIR, 0, Position::fromObject(Vector3::getSide($side, $step)));
}
/**
@ -614,7 +446,7 @@ class Block extends Position implements BlockIds, Metadatable{
*
* @return bool
*/
public function collidesWithBB(AxisAlignedBB $bb){
public function collidesWithBB(AxisAlignedBB $bb) : bool{
$bb2 = $this->getBoundingBox();
return $bb2 !== null and $bb->intersectsWith($bb2);
@ -628,7 +460,7 @@ class Block extends Position implements BlockIds, Metadatable{
}
/**
* @return AxisAlignedBB
* @return AxisAlignedBB|null
*/
public function getBoundingBox(){
if($this->boundingBox === null){
@ -638,7 +470,7 @@ class Block extends Position implements BlockIds, Metadatable{
}
/**
* @return AxisAlignedBB
* @return AxisAlignedBB|null
*/
protected function recalculateBoundingBox(){
return new AxisAlignedBB(
@ -655,7 +487,7 @@ class Block extends Position implements BlockIds, Metadatable{
* @param Vector3 $pos1
* @param Vector3 $pos2
*
* @return MovingObjectPosition
* @return MovingObjectPosition|null
*/
public function calculateIntercept(Vector3 $pos1, Vector3 $pos2){
$bb = $this->getBoundingBox();
@ -739,13 +571,13 @@ class Block extends Position implements BlockIds, Metadatable{
return MovingObjectPosition::fromBlock($this->x, $this->y, $this->z, $f, $vector->add($this->x, $this->y, $this->z));
}
public function setMetadata($metadataKey, MetadataValue $metadataValue){
public function setMetadata(string $metadataKey, MetadataValue $newMetadataValue){
if($this->getLevel() instanceof Level){
$this->getLevel()->getBlockMetadata()->setMetadata($this, $metadataKey, $metadataValue);
$this->getLevel()->getBlockMetadata()->setMetadata($this, $metadataKey, $newMetadataValue);
}
}
public function getMetadata($metadataKey){
public function getMetadata(string $metadataKey){
if($this->getLevel() instanceof Level){
return $this->getLevel()->getBlockMetadata()->getMetadata($this, $metadataKey);
}
@ -753,15 +585,17 @@ class Block extends Position implements BlockIds, Metadatable{
return null;
}
public function hasMetadata($metadataKey){
public function hasMetadata(string $metadataKey) : bool{
if($this->getLevel() instanceof Level){
$this->getLevel()->getBlockMetadata()->hasMetadata($this, $metadataKey);
return $this->getLevel()->getBlockMetadata()->hasMetadata($this, $metadataKey);
}
return false;
}
public function removeMetadata($metadataKey, Plugin $plugin){
public function removeMetadata(string $metadataKey, Plugin $owningPlugin){
if($this->getLevel() instanceof Level){
$this->getLevel()->getBlockMetadata()->removeMetadata($this, $metadataKey, $plugin);
$this->getLevel()->getBlockMetadata()->removeMetadata($this, $metadataKey, $owningPlugin);
}
}
}

View File

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

View File

@ -19,6 +19,8 @@
*
*/
declare(strict_types=1);
namespace pocketmine\block;
interface BlockIds{
@ -27,20 +29,20 @@ interface BlockIds{
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 COBBLESTONE = 4;
const PLANKS = 5, WOODEN_PLANKS = 5;
const SAPLING = 6;
const BEDROCK = 7;
const WATER = 8;
const STILL_WATER = 9;
const LAVA = 10;
const STILL_LAVA = 11;
const FLOWING_WATER = 8;
const STILL_WATER = 9, WATER = 9;
const FLOWING_LAVA = 10;
const LAVA = 11, 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 LOG = 17, WOOD = 17;
const LEAVES = 18;
const SPONGE = 19;
const GLASS = 20;
@ -48,35 +50,35 @@ interface BlockIds{
const LAPIS_BLOCK = 22;
const DISPENSER = 23;
const SANDSTONE = 24;
const NOTE_BLOCK = 25, NOTEBLOCK = 25;
const NOTEBLOCK = 25, NOTE_BLOCK = 25;
const BED_BLOCK = 26;
const POWERED_RAIL = 27;
const GOLDEN_RAIL = 27, 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 COBWEB = 30, WEB = 30;
const TALLGRASS = 31, TALL_GRASS = 31;
const DEADBUSH = 32, DEAD_BUSH = 32;
const PISTON = 33;
const PISTON_HEAD = 34;
const PISTONARMCOLLISION = 34, PISTON_ARM_COLLISION = 34;
const WOOL = 35;
const DANDELION = 37;
const POPPY = 38, ROSE = 38, RED_FLOWER = 38;
const DANDELION = 37, YELLOW_FLOWER = 37;
const POPPY = 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 DOUBLE_STONE_SLAB = 43;
const STONE_SLAB = 44;
const BRICK_BLOCK = 45;
const TNT = 46;
const BOOKSHELF = 47;
const MOSS_STONE = 48, MOSSY_STONE = 48;
const MOSSY_COBBLESTONE = 48, MOSS_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 MOB_SPAWNER = 52, MONSTER_SPAWNER = 52;
const OAK_STAIRS = 53, WOODEN_STAIRS = 53;
const CHEST = 54;
const REDSTONE_WIRE = 55;
const DIAMOND_ORE = 56;
@ -86,11 +88,11 @@ interface BlockIds{
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 SIGN_POST = 63, STANDING_SIGN = 63;
const OAK_DOOR_BLOCK = 64, WOODEN_DOOR_BLOCK = 64;
const LADDER = 65;
const RAIL = 66;
const COBBLESTONE_STAIRS = 67, COBBLE_STAIRS = 67;
const COBBLESTONE_STAIRS = 67, STONE_STAIRS = 67;
const WALL_SIGN = 68;
const LEVER = 69;
const STONE_PRESSURE_PLATE = 70;
@ -99,117 +101,119 @@ interface BlockIds{
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 LIT_REDSTONE_TORCH = 76, REDSTONE_TORCH = 76;
const STONE_BUTTON = 77;
const SNOW = 78, SNOW_LAYER = 78;
const SNOW_LAYER = 78;
const ICE = 79;
const SNOW_BLOCK = 80;
const SNOW = 80, SNOW_BLOCK = 80;
const CACTUS = 81;
const CLAY_BLOCK = 82;
const REEDS = 83, SUGARCANE_BLOCK = 83;
const REEDS_BLOCK = 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 GLOWSTONE = 89;
const 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 REPEATER_BLOCK = 93, UNPOWERED_REPEATER = 93;
const POWERED_REPEATER = 94;
const INVISIBLEBEDROCK = 95, INVISIBLE_BEDROCK = 95;
const TRAPDOOR = 96, WOODEN_TRAPDOOR = 96;
const MONSTER_EGG_BLOCK = 97;
const STONE_BRICKS = 98, STONE_BRICK = 98;
const MONSTER_EGG = 97;
const STONEBRICK = 98, STONE_BRICK = 98, STONE_BRICKS = 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 IRON_BARS = 101;
const GLASS_PANE = 102;
const MELON_BLOCK = 103;
const PUMPKIN_STEM = 104;
const MELON_STEM = 105;
const VINES = 106, VINE = 106;
const VINE = 106, VINES = 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 LILY_PAD = 111, WATERLILY = 111, WATER_LILY = 111;
const 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 NETHER_BRICK_STAIRS = 114;
const NETHER_WART_PLANT = 115;
const ENCHANTING_TABLE = 116, ENCHANTMENT_TABLE = 116;
const BREWING_STAND_BLOCK = 117;
const CAULDRON_BLOCK = 118;
const END_PORTAL_FRAME = 120, END_PORTAL = 120;
const END_PORTAL = 119;
const END_PORTAL_FRAME = 120;
const END_STONE = 121;
const REDSTONE_LAMP = 123, INACTIVE_REDSTONE_LAMP = 123;
const LIT_REDSTONE_LAMP = 124, ACTIVE_REDSTONE_LAMP = 124;
const DRAGON_EGG = 122;
const REDSTONE_LAMP = 123;
const LIT_REDSTONE_LAMP = 124;
const DROPPER = 125;
const ACTIVATOR_RAIL = 126;
const COCOA_BLOCK = 127, COCOA_PODS = 127;
const COCOA = 127, COCOA_BLOCK = 127;
const SANDSTONE_STAIRS = 128;
const EMERALD_ORE = 129;
const ENDER_CHEST = 130;
const TRIPWIRE_HOOK = 131;
const TRIPWIRE = 132;
const TRIPWIRE = 132, TRIP_WIRE = 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 SPRUCE_STAIRS = 134;
const BIRCH_STAIRS = 135;
const JUNGLE_STAIRS = 136;
const COMMAND_BLOCK = 137;
const BEACON = 138;
const COBBLESTONE_WALL = 139, COBBLE_WALL = 139, STONE_WALL = 139;
const COBBLESTONE_WALL = 139, STONE_WALL = 139;
const FLOWER_POT_BLOCK = 140;
const CARROT_BLOCK = 141;
const POTATO_BLOCK = 142;
const CARROTS = 141, CARROT_BLOCK = 141;
const POTATOES = 142, 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 LIGHT_WEIGHTED_PRESSURE_PLATE = 147;
const HEAVY_WEIGHTED_PRESSURE_PLATE = 148;
const COMPARATOR_BLOCK = 149, UNPOWERED_COMPARATOR = 149;
const POWERED_COMPARATOR = 150;
const DAYLIGHT_DETECTOR = 151, DAYLIGHT_SENSOR = 151;
const REDSTONE_BLOCK = 152;
const NETHER_QUARTZ_ORE = 153;
const NETHER_QUARTZ_ORE = 153, 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 DOUBLE_WOODEN_SLAB = 157;
const WOODEN_SLAB = 158;
const STAINED_CLAY = 159, STAINED_HARDENED_CLAY = 159, TERRACOTTA = 159;
const STAINED_GLASS_PANE = 160;
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 LOG2 = 162, WOOD2 = 162;
const ACACIA_STAIRS = 163;
const DARK_OAK_STAIRS = 164;
const SLIME = 165, SLIME_BLOCK = 165;
const IRON_TRAPDOOR = 167;
const PRISMARINE = 168;
const SEA_LANTERN = 169;
const HAY_BALE = 170;
const SEALANTERN = 169, SEA_LANTERN = 169;
const HAY_BALE = 170, HAY_BLOCK = 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 DAYLIGHT_DETECTOR_INVERTED = 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 DOUBLE_STONE_SLAB2 = 181;
const STONE_SLAB2 = 182;
const SPRUCE_FENCE_GATE = 183;
const BIRCH_FENCE_GATE = 184;
const JUNGLE_FENCE_GATE = 185;
const DARK_OAK_FENCE_GATE = 186;
const ACACIA_FENCE_GATE = 187;
const REPEATING_COMMAND_BLOCK = 188;
const CHAIN_COMMAND_BLOCK = 189;
const SPRUCE_DOOR_BLOCK = 193;
const BIRCH_DOOR_BLOCK = 194;
@ -217,16 +221,56 @@ interface BlockIds{
const ACACIA_DOOR_BLOCK = 196;
const DARK_OAK_DOOR_BLOCK = 197;
const GRASS_PATH = 198;
const ITEM_FRAME_BLOCK = 199;
const FRAME_BLOCK = 199, ITEM_FRAME_BLOCK = 199;
const CHORUS_FLOWER = 200;
const PURPUR_BLOCK = 201;
const PURPUR_STAIRS = 203;
const END_BRICKS = 206;
const FROSTED_ICE = 207;
const END_ROD = 208;
const END_GATEWAY = 209;
const MAGMA = 213;
const NETHER_WART_BLOCK = 214;
const RED_NETHER_BRICK = 215;
const BONE_BLOCK = 216;
const SHULKER_BOX = 218;
const PURPLE_GLAZED_TERRACOTTA = 219;
const WHITE_GLAZED_TERRACOTTA = 220;
const ORANGE_GLAZED_TERRACOTTA = 221;
const MAGENTA_GLAZED_TERRACOTTA = 222;
const LIGHT_BLUE_GLAZED_TERRACOTTA = 223;
const YELLOW_GLAZED_TERRACOTTA = 224;
const LIME_GLAZED_TERRACOTTA = 225;
const PINK_GLAZED_TERRACOTTA = 226;
const GRAY_GLAZED_TERRACOTTA = 227;
const SILVER_GLAZED_TERRACOTTA = 228;
const CYAN_GLAZED_TERRACOTTA = 229;
const BLUE_GLAZED_TERRACOTTA = 231;
const BROWN_GLAZED_TERRACOTTA = 232;
const GREEN_GLAZED_TERRACOTTA = 233;
const RED_GLAZED_TERRACOTTA = 234;
const BLACK_GLAZED_TERRACOTTA = 235;
const CONCRETE = 236;
const CONCRETEPOWDER = 237, CONCRETE_POWDER = 237;
const CHORUS_PLANT = 240;
const STAINED_GLASS = 241;
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 GLOWINGOBSIDIAN = 246, GLOWING_OBSIDIAN = 246;
const NETHERREACTOR = 247, NETHER_REACTOR = 247;
const INFO_UPDATE = 248;
const INFO_UPDATE2 = 249;
const MOVINGBLOCK = 250, MOVING_BLOCK = 250;
const OBSERVER = 251;
const INFO_RESERVED6 = 255;
const RESERVED6 = 255;
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -19,10 +19,13 @@
*
*/
declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\item\Item;
use pocketmine\item\Tool;
use pocketmine\math\Vector3;
use pocketmine\nbt\NBT;
use pocketmine\nbt\tag\CompoundTag;
use pocketmine\nbt\tag\IntTag;
@ -36,39 +39,35 @@ class BurningFurnace extends Solid{
protected $id = self::BURNING_FURNACE;
public function __construct($meta = 0){
public function __construct(int $meta = 0){
$this->meta = $meta;
}
public function getName(){
public function getName() : string{
return "Burning Furnace";
}
public function canBeActivated(){
return true;
}
public function getHardness(){
public function getHardness() : float{
return 3.5;
}
public function getToolType(){
public function getToolType() : int{
return Tool::TYPE_PICKAXE;
}
public function getLightLevel(){
public function getLightLevel() : int{
return 13;
}
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){
public function place(Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $facePos, Player $player = null) : bool{
$faces = [
0 => 4,
1 => 2,
2 => 5,
3 => 3,
3 => 3
];
$this->meta = $faces[$player instanceof Player ? $player->getDirection() : 0];
$this->getLevel()->setBlock($block, $this, true, true);
$this->getLevel()->setBlock($blockReplace, $this, true, true);
$nbt = new CompoundTag("", [
new ListTag("Items", []),
new StringTag("id", Tile::FURNACE),
@ -93,13 +92,7 @@ class BurningFurnace extends Solid{
return true;
}
public function onBreak(Item $item){
$this->getLevel()->setBlock($this, new Air(), true, true);
return true;
}
public function onActivate(Item $item, Player $player = null){
public function onActivate(Item $item, Player $player = null) : bool{
if($player instanceof Player){
$furnace = $this->getLevel()->getTile($this);
if(!($furnace instanceof TileFurnace)){
@ -126,12 +119,15 @@ class BurningFurnace extends Solid{
return true;
}
public function getDrops(Item $item){
$drops = [];
public function getVariantBitmask() : int{
return 0;
}
public function getDrops(Item $item) : array{
if($item->isPickaxe() >= Tool::TIER_WOODEN){
$drops[] = [Item::FURNACE, 0, 1];
return parent::getDrops($item);
}
return $drops;
return [];
}
}

View File

@ -19,6 +19,8 @@
*
*/
declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\entity\Entity;
@ -36,19 +38,19 @@ class Cactus extends Transparent{
protected $id = self::CACTUS;
public function __construct($meta = 0){
public function __construct(int $meta = 0){
$this->meta = $meta;
}
public function getHardness(){
public function getHardness() : float{
return 0.4;
}
public function hasEntityCollision(){
public function hasEntityCollision() : bool{
return true;
}
public function getName(){
public function getName() : string{
return "Cactus";
}
@ -64,14 +66,18 @@ class Cactus extends Transparent{
);
}
public function onEntityCollide(Entity $entity){
$ev = new EntityDamageByBlockEvent($this, $entity, EntityDamageEvent::CAUSE_CONTACT, 1);
$entity->attack($ev->getFinalDamage(), $ev);
public function ticksRandomly() : bool{
return true;
}
public function onUpdate($type){
public function onEntityCollide(Entity $entity){
$ev = new EntityDamageByBlockEvent($this, $entity, EntityDamageEvent::CAUSE_CONTACT, 1);
$entity->attack($ev);
}
public function onUpdate(int $type){
if($type === Level::BLOCK_UPDATE_NORMAL){
$down = $this->getSide(0);
$down = $this->getSide(Vector3::SIDE_DOWN);
if($down->getId() !== self::SAND and $down->getId() !== self::CACTUS){
$this->getLevel()->useBreakOn($this);
}else{
@ -83,12 +89,12 @@ class Cactus extends Transparent{
}
}
}elseif($type === Level::BLOCK_UPDATE_RANDOM){
if($this->getSide(0)->getId() !== self::CACTUS){
if($this->meta == 0x0F){
if($this->getSide(Vector3::SIDE_DOWN)->getId() !== self::CACTUS){
if($this->meta === 0x0f){
for($y = 1; $y < 3; ++$y){
$b = $this->getLevel()->getBlock(new Vector3($this->x, $this->y + $y, $this->z));
if($b->getId() === self::AIR){
Server::getInstance()->getPluginManager()->callEvent($ev = new BlockGrowEvent($b, new Cactus()));
Server::getInstance()->getPluginManager()->callEvent($ev = new BlockGrowEvent($b, BlockFactory::get(Block::CACTUS)));
if(!$ev->isCancelled()){
$this->getLevel()->setBlock($b, $ev->getNewState(), true);
}
@ -106,13 +112,13 @@ class Cactus extends Transparent{
return false;
}
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){
$down = $this->getSide(0);
public function place(Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $facePos, Player $player = null) : bool{
$down = $this->getSide(Vector3::SIDE_DOWN);
if($down->getId() === self::SAND or $down->getId() === self::CACTUS){
$block0 = $this->getSide(2);
$block1 = $this->getSide(3);
$block2 = $this->getSide(4);
$block3 = $this->getSide(5);
$block0 = $this->getSide(Vector3::SIDE_NORTH);
$block1 = $this->getSide(Vector3::SIDE_SOUTH);
$block2 = $this->getSide(Vector3::SIDE_WEST);
$block3 = $this->getSide(Vector3::SIDE_EAST);
if($block0->isTransparent() === true and $block1->isTransparent() === true and $block2->isTransparent() === true and $block3->isTransparent() === true){
$this->getLevel()->setBlock($this, $this, true);
@ -123,9 +129,7 @@ class Cactus extends Transparent{
return false;
}
public function getDrops(Item $item){
return [
[$this->id, 0, 1],
];
public function getVariantBitmask() : int{
return 0;
}
}

View File

@ -19,6 +19,8 @@
*
*/
declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\entity\Effect;
@ -27,34 +29,31 @@ use pocketmine\item\FoodSource;
use pocketmine\item\Item;
use pocketmine\level\Level;
use pocketmine\math\AxisAlignedBB;
use pocketmine\math\Vector3;
use pocketmine\Player;
class Cake extends Transparent implements FoodSource{
protected $id = self::CAKE_BLOCK;
public function __construct($meta = 0){
public function __construct(int $meta = 0){
$this->meta = $meta;
}
public function canBeActivated(){
return true;
}
public function getHardness(){
public function getHardness() : float{
return 0.5;
}
public function getName(){
public function getName() : string{
return "Cake Block";
}
protected function recalculateBoundingBox(){
$f = (1 + $this->getDamage() * 2) / 16;
$f = $this->getDamage() * 0.125; //1 slice width
return new AxisAlignedBB(
$this->x + $f,
$this->x + 0.0625 + $f,
$this->y,
$this->z + 0.0625,
$this->x + 1 - 0.0625,
@ -63,10 +62,10 @@ class Cake extends Transparent implements FoodSource{
);
}
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){
$down = $this->getSide(0);
public function place(Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $facePos, Player $player = null) : bool{
$down = $this->getSide(Vector3::SIDE_DOWN);
if($down->getId() !== self::AIR){
$this->getLevel()->setBlock($block, $this, true, true);
$this->getLevel()->setBlock($blockReplace, $this, true, true);
return true;
}
@ -74,10 +73,10 @@ class Cake extends Transparent implements FoodSource{
return false;
}
public function onUpdate($type){
public function onUpdate(int $type){
if($type === Level::BLOCK_UPDATE_NORMAL){
if($this->getSide(0)->getId() === self::AIR){ //Replace with common break method
$this->getLevel()->setBlock($this, new Air(), true);
if($this->getSide(Vector3::SIDE_DOWN)->getId() === self::AIR){ //Replace with common break method
$this->getLevel()->setBlock($this, BlockFactory::get(Block::AIR), true);
return Level::BLOCK_UPDATE_NORMAL;
}
@ -86,15 +85,22 @@ class Cake extends Transparent implements FoodSource{
return false;
}
public function getDrops(Item $item){
public function getDrops(Item $item) : array{
return [];
}
public function onActivate(Item $item, Player $player = null){
if($player instanceof Player and $player->getHealth() < $player->getMaxHealth()){
$ev = new EntityEatBlockEvent($player, $this);
public function onActivate(Item $item, Player $player = null) : bool{
//TODO: refactor this into generic food handling
if($player instanceof Player and $player->getFood() < $player->getMaxFood()){
$player->getServer()->getPluginManager()->callEvent($ev = new EntityEatBlockEvent($player, $this));
if(!$ev->isCancelled()){
$player->addFood($ev->getFoodRestore());
$player->addSaturation($ev->getSaturationRestore());
foreach($ev->getAdditionalEffects() as $effect){
$player->addEffect($effect);
}
$this->getLevel()->setBlock($this, $ev->getResidue());
return true;
}
@ -114,8 +120,8 @@ class Cake extends Transparent implements FoodSource{
public function getResidue(){
$clone = clone $this;
$clone->meta++;
if($clone->meta >= 0x06){
$clone = new Air();
if($clone->meta > 0x06){
$clone = BlockFactory::get(Block::AIR);
}
return $clone;
}

View File

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

View File

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

View File

@ -19,11 +19,14 @@
*
*/
declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\item\Item;
use pocketmine\item\Tool;
use pocketmine\math\AxisAlignedBB;
use pocketmine\math\Vector3;
use pocketmine\nbt\NBT;
use pocketmine\nbt\tag\CompoundTag;
use pocketmine\nbt\tag\IntTag;
@ -37,23 +40,19 @@ class Chest extends Transparent{
protected $id = self::CHEST;
public function __construct($meta = 0){
public function __construct(int $meta = 0){
$this->meta = $meta;
}
public function canBeActivated(){
return true;
}
public function getHardness(){
public function getHardness() : float{
return 2.5;
}
public function getName(){
public function getName() : string{
return "Chest";
}
public function getToolType(){
public function getToolType() : int{
return Tool::TYPE_AXE;
}
@ -68,12 +67,12 @@ class Chest extends Transparent{
);
}
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){
public function place(Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $facePos, Player $player = null) : bool{
$faces = [
0 => 4,
1 => 2,
2 => 5,
3 => 3,
3 => 3
];
$chest = null;
@ -95,7 +94,7 @@ class Chest extends Transparent{
}
}
$this->getLevel()->setBlock($block, $this, true, true);
$this->getLevel()->setBlock($blockReplace, $this, true, true);
$nbt = new CompoundTag("", [
new ListTag("Items", []),
new StringTag("id", Tile::CHEST),
@ -125,22 +124,18 @@ class Chest extends Transparent{
return true;
}
public function onBreak(Item $item){
public function onBreak(Item $item, Player $player = null) : bool{
$t = $this->getLevel()->getTile($this);
if($t instanceof TileChest){
$t->unpair();
}
$this->getLevel()->setBlock($this, new Air(), true, true);
$this->getLevel()->setBlock($this, BlockFactory::get(Block::AIR), true, true);
return true;
}
public function onActivate(Item $item, Player $player = null){
public function onActivate(Item $item, Player $player = null) : bool{
if($player instanceof Player){
$top = $this->getSide(1);
if($top->isTransparent() !== true){
return true;
}
$t = $this->getLevel()->getTile($this);
$chest = null;
@ -158,10 +153,12 @@ class Chest extends Transparent{
$chest = Tile::createTile("Chest", $this->getLevel(), $nbt);
}
if(isset($chest->namedtag->Lock) and $chest->namedtag->Lock instanceof StringTag){
if($chest->namedtag->Lock->getValue() !== $item->getCustomName()){
return true;
}
if(
!$this->getSide(Vector3::SIDE_UP)->isTransparent() or
($chest->isPaired() and !$chest->getPair()->getBlock()->getSide(Vector3::SIDE_UP)->isTransparent()) or
(isset($chest->namedtag->Lock) and $chest->namedtag->Lock instanceof StringTag and $chest->namedtag->Lock->getValue() !== $item->getCustomName())
){
return true;
}
$player->addWindow($chest->getInventory());
@ -170,9 +167,11 @@ class Chest extends Transparent{
return true;
}
public function getDrops(Item $item){
return [
[$this->id, 0, 1],
];
public function getVariantBitmask() : int{
return 0;
}
public function getFuelTime() : int{
return 300;
}
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -19,35 +19,37 @@
*
*/
declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\item\Tool;
use pocketmine\math\AxisAlignedBB;
use pocketmine\math\Vector3;
class StoneWall extends Transparent{
class CobblestoneWall extends Transparent{
const NONE_MOSSY_WALL = 0;
const MOSSY_WALL = 1;
protected $id = self::STONE_WALL;
protected $id = self::COBBLESTONE_WALL;
public function __construct($meta = 0){
public function __construct(int $meta = 0){
$this->meta = $meta;
}
public function isSolid(){
public function isSolid() : bool{
return false;
}
public function getToolType(){
public function getToolType() : int{
return Tool::TYPE_PICKAXE;
}
public function getHardness(){
public function getHardness() : float{
return 2;
}
public function getName(){
public function getName() : string{
if($this->meta === 0x01){
return "Mossy Cobblestone Wall";
}
@ -86,7 +88,7 @@ class StoneWall extends Transparent{
}
public function canConnect(Block $block){
return ($block->getId() !== self::COBBLE_WALL and $block->getId() !== self::FENCE_GATE) ? $block->isSolid() and !$block->isTransparent() : true;
return ($block->getId() !== self::COBBLESTONE_WALL and $block->getId() !== self::FENCE_GATE) ? $block->isSolid() and !$block->isTransparent() : true;
}
}

View File

@ -19,6 +19,8 @@
*
*/
declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\entity\Entity;
@ -29,23 +31,23 @@ class Cobweb extends Flowable{
protected $id = self::COBWEB;
public function __construct(){
public function __construct(int $meta = 0){
$this->meta = $meta;
}
public function hasEntityCollision(){
public function hasEntityCollision() : bool{
return true;
}
public function getName(){
public function getName() : string{
return "Cobweb";
}
public function getHardness(){
public function getHardness() : float{
return 4;
}
public function getToolType(){
public function getToolType() : int{
return Tool::TYPE_SWORD;
}
@ -53,8 +55,12 @@ class Cobweb extends Flowable{
$entity->resetFallDistance();
}
public function getDrops(Item $item){
public function getDrops(Item $item) : array{
//TODO: correct drops
return [];
}
public function diffusesSkyLight() : bool{
return true;
}
}

View File

@ -19,17 +19,21 @@
*
*/
declare(strict_types=1);
namespace pocketmine\block;
class CocoaBlock extends Solid{
protected $id = self::COCOA_BLOCK;
public function __construct($meta = 0){
public function __construct(int $meta = 0){
$this->meta = $meta;
}
public function getName(){
public function getName() : string{
return "Cocoa Block";
}
//TODO
}

View File

@ -19,38 +19,40 @@
*
*/
declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\block\utils\ColorBlockMetaHelper;
use pocketmine\item\Item;
use pocketmine\item\Tool;
class WoodDoor extends Door{
class Concrete extends Solid{
protected $id = self::WOOD_DOOR_BLOCK;
protected $id = Block::CONCRETE;
public function __construct($meta = 0){
public function __construct(int $meta = 0){
$this->meta = $meta;
}
public function getName(){
return "Wood Door Block";
public function getName() : string{
return ColorBlockMetaHelper::getColorFromMeta($this->meta) . " Concrete";
}
public function canBeActivated(){
return true;
public function getHardness() : float{
return 1.8;
}
public function getHardness(){
return 3;
public function getToolType() : int{
return Tool::TYPE_PICKAXE;
}
public function getToolType(){
return Tool::TYPE_AXE;
public function getDrops(Item $item) : array{
if($item->isPickaxe() >= Tool::TIER_WOODEN){
return parent::getDrops($item);
}
return [];
}
public function getDrops(Item $item){
return [
[Item::WOODEN_DOOR, 0, 1],
];
}
}

View File

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

View File

@ -19,24 +19,22 @@
*
*/
declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\event\block\BlockGrowEvent;
use pocketmine\item\Item;
use pocketmine\level\Level;
use pocketmine\math\Vector3;
use pocketmine\Player;
use pocketmine\Server;
abstract class Crops extends Flowable{
public function canBeActivated(){
return true;
}
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){
$down = $this->getSide(0);
if($down->getId() === self::FARMLAND){
$this->getLevel()->setBlock($block, $this, true, true);
public function place(Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $facePos, Player $player = null) : bool{
if($blockReplace->getSide(Vector3::SIDE_DOWN)->getId() === Block::FARMLAND){
$this->getLevel()->setBlock($blockReplace, $this, true, true);
return true;
}
@ -45,7 +43,7 @@ abstract class Crops extends Flowable{
}
public function onActivate(Item $item, Player $player = null){
public function onActivate(Item $item, Player $player = null) : bool{
if($item->getId() === Item::DYE and $item->getDamage() === 0x0F){ //Bonemeal
$block = clone $this;
$block->meta += mt_rand(2, 5);
@ -67,14 +65,18 @@ abstract class Crops extends Flowable{
return false;
}
public function onUpdate($type){
public function ticksRandomly() : bool{
return true;
}
public function onUpdate(int $type){
if($type === Level::BLOCK_UPDATE_NORMAL){
if($this->getSide(0)->isTransparent() === true){
if($this->getSide(Vector3::SIDE_DOWN)->getId() !== Block::FARMLAND){
$this->getLevel()->useBreakOn($this);
return Level::BLOCK_UPDATE_NORMAL;
}
}elseif($type === Level::BLOCK_UPDATE_RANDOM){
if(mt_rand(0, 2) == 1){
if(mt_rand(0, 2) === 1){
if($this->meta < 0x07){
$block = clone $this;
++$block->meta;

View File

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

View File

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

View File

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

View File

@ -19,26 +19,29 @@
*
*/
declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\level\Level;
use pocketmine\math\Vector3;
class DeadBush extends Flowable{
protected $id = self::DEAD_BUSH;
public function __construct($meta = 0){
public function __construct(int $meta = 0){
$this->meta = $meta;
}
public function getName(){
public function getName() : string{
return "Dead Bush";
}
public function onUpdate($type){
public function onUpdate(int $type){
if($type === Level::BLOCK_UPDATE_NORMAL){
if($this->getSide(0)->isTransparent() === true){
if($this->getSide(Vector3::SIDE_DOWN)->isTransparent() === true){
$this->getLevel()->useBreakOn($this);
return Level::BLOCK_UPDATE_NORMAL;

View File

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

View File

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

View File

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

View File

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

View File

@ -19,6 +19,8 @@
*
*/
declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\item\Item;
@ -31,11 +33,7 @@ use pocketmine\Player;
abstract class Door extends Transparent{
public function canBeActivated(){
return true;
}
public function isSolid(){
public function isSolid() : bool{
return false;
}
@ -203,12 +201,12 @@ abstract class Door extends Transparent{
return $bb;
}
public function onUpdate($type){
public function onUpdate(int $type){
if($type === Level::BLOCK_UPDATE_NORMAL){
if($this->getSide(0)->getId() === self::AIR){ //Replace with common break method
$this->getLevel()->setBlock($this, new Air(), false);
if($this->getSide(1) instanceof Door){
$this->getLevel()->setBlock($this->getSide(1), new Air(), false);
if($this->getSide(Vector3::SIDE_DOWN)->getId() === self::AIR){ //Replace with common break method
$this->getLevel()->setBlock($this, BlockFactory::get(Block::AIR), false);
if($this->getSide(Vector3::SIDE_UP) instanceof Door){
$this->getLevel()->setBlock($this->getSide(Vector3::SIDE_UP), BlockFactory::get(Block::AIR), false);
}
return Level::BLOCK_UPDATE_NORMAL;
@ -218,64 +216,59 @@ abstract class Door extends Transparent{
return false;
}
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){
if($face === 1){
$blockUp = $this->getSide(1);
$blockDown = $this->getSide(0);
public function place(Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $facePos, Player $player = null) : bool{
if($face === Vector3::SIDE_UP){
$blockUp = $this->getSide(Vector3::SIDE_UP);
$blockDown = $this->getSide(Vector3::SIDE_DOWN);
if($blockUp->canBeReplaced() === false or $blockDown->isTransparent() === true){
return false;
}
$direction = $player instanceof Player ? $player->getDirection() : 0;
$face = [
$faces = [
0 => 3,
1 => 4,
2 => 2,
3 => 5,
3 => 5
];
$next = $this->getSide($face[(($direction + 2) % 4)]);
$next2 = $this->getSide($face[$direction]);
$next = $this->getSide($faces[($direction + 2) % 4]);
$next2 = $this->getSide($faces[$direction]);
$metaUp = 0x08;
if($next->getId() === $this->getId() or ($next2->isTransparent() === false and $next->isTransparent() === true)){ //Door hinge
$metaUp |= 0x01;
}
$this->setDamage($player->getDirection() & 0x03);
$this->getLevel()->setBlock($block, $this, true, true); //Bottom
$this->getLevel()->setBlock($blockUp, $b = Block::get($this->getId(), $metaUp), true); //Top
$this->getLevel()->setBlock($blockReplace, $this, true, true); //Bottom
$this->getLevel()->setBlock($blockUp, $b = BlockFactory::get($this->getId(), $metaUp), true); //Top
return true;
}
return false;
}
public function onBreak(Item $item){
public function onBreak(Item $item, Player $player = null) : bool{
if(($this->getDamage() & 0x08) === 0x08){
$down = $this->getSide(0);
$down = $this->getSide(Vector3::SIDE_DOWN);
if($down->getId() === $this->getId()){
$this->getLevel()->setBlock($down, new Air(), true);
$this->getLevel()->setBlock($down, BlockFactory::get(Block::AIR), true);
}
}else{
$up = $this->getSide(1);
$up = $this->getSide(Vector3::SIDE_UP);
if($up->getId() === $this->getId()){
$this->getLevel()->setBlock($up, new Air(), true);
$this->getLevel()->setBlock($up, BlockFactory::get(Block::AIR), true);
}
}
$this->getLevel()->setBlock($this, new Air(), true);
$this->getLevel()->setBlock($this, BlockFactory::get(Block::AIR), true);
return true;
}
public function onActivate(Item $item, Player $player = null){
public function onActivate(Item $item, Player $player = null) : bool{
if(($this->getDamage() & 0x08) === 0x08){ //Top
$down = $this->getSide(0);
$down = $this->getSide(Vector3::SIDE_DOWN);
if($down->getId() === $this->getId()){
$meta = $down->getDamage() ^ 0x04;
$this->getLevel()->setBlock($down, Block::get($this->getId(), $meta), true);
$players = $this->getLevel()->getChunkPlayers($this->x >> 4, $this->z >> 4);
if($player instanceof Player){
unset($players[$player->getLoaderId()]);
}
$this->level->setBlock($down, BlockFactory::get($this->getId(), $meta), true);
$this->level->addSound(new DoorSound($this));
return true;
}
@ -283,14 +276,14 @@ abstract class Door extends Transparent{
return false;
}else{
$this->meta ^= 0x04;
$this->getLevel()->setBlock($this, $this, true);
$players = $this->getLevel()->getChunkPlayers($this->x >> 4, $this->z >> 4);
if($player instanceof Player){
unset($players[$player->getLoaderId()]);
}
$this->level->setBlock($this, $this, true);
$this->level->addSound(new DoorSound($this));
}
return true;
}
public function getVariantBitmask() : int{
return 0;
}
}

View File

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

View File

@ -19,28 +19,31 @@
*
*/
declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\item\Item;
use pocketmine\item\ItemFactory;
use pocketmine\item\Tool;
class DoubleSlab extends Solid{
class DoubleStoneSlab extends Solid{
protected $id = self::DOUBLE_SLAB;
protected $id = self::DOUBLE_STONE_SLAB;
public function __construct($meta = 0){
public function __construct(int $meta = 0){
$this->meta = $meta;
}
public function getHardness(){
public function getHardness() : float{
return 2;
}
public function getToolType(){
public function getToolType() : int{
return Tool::TYPE_PICKAXE;
}
public function getName(){
public function getName() : string{
static $names = [
0 => "Stone",
1 => "Sandstone",
@ -49,19 +52,19 @@ class DoubleSlab extends Solid{
4 => "Brick",
5 => "Stone Brick",
6 => "Quartz",
7 => "Nether Brick",
7 => "Nether Brick"
];
return "Double " . $names[$this->meta & 0x07] . " Slab";
}
public function getDrops(Item $item){
public function getDrops(Item $item) : array{
if($item->isPickaxe() >= Tool::TIER_WOODEN){
return [
[Item::SLAB, $this->meta & 0x07, 2],
ItemFactory::get(Item::STONE_SLAB, $this->getDamage() & 0x07, 2)
];
}else{
return [];
}
return [];
}
}

View File

@ -19,44 +19,45 @@
*
*/
declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\item\Item;
use pocketmine\item\ItemFactory;
use pocketmine\item\Tool;
class DoubleWoodSlab extends Solid{
class DoubleWoodenSlab extends Solid{
protected $id = self::DOUBLE_WOOD_SLAB;
protected $id = self::DOUBLE_WOODEN_SLAB;
public function __construct($meta = 0){
public function __construct(int $meta = 0){
$this->meta = $meta;
}
public function getHardness(){
public function getHardness() : float{
return 2;
}
public function getToolType(){
public function getToolType() : int{
return Tool::TYPE_AXE;
}
public function getName(){
public function getName() : string{
static $names = [
0 => "Oak",
1 => "Spruce",
2 => "Birch",
3 => "Jungle",
4 => "Acacia",
5 => "Dark Oak",
6 => "",
7 => ""
5 => "Dark Oak"
];
return "Double " . $names[$this->meta & 0x07] . " Wooden Slab";
return "Double " . ($names[$this->meta & 0x07] ?? "") . " Wooden Slab";
}
public function getDrops(Item $item){
public function getDrops(Item $item) : array{
return [
[Item::WOOD_SLAB, $this->meta & 0x07, 2],
ItemFactory::get(Item::WOODEN_SLAB, $this->getDamage() & 0x07, 2)
];
}

View File

@ -19,6 +19,8 @@
*
*/
declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\item\Item;
@ -28,29 +30,27 @@ class Emerald extends Solid{
protected $id = self::EMERALD_BLOCK;
public function __construct(){
public function __construct(int $meta = 0){
$this->meta = $meta;
}
public function getHardness(){
public function getHardness() : float{
return 5;
}
public function getToolType(){
public function getToolType() : int{
return Tool::TYPE_PICKAXE;
}
public function getName(){
public function getName() : string{
return "Emerald Block";
}
public function getDrops(Item $item){
public function getDrops(Item $item) : array{
if($item->isPickaxe() >= Tool::TIER_IRON){
return [
[Item::EMERALD_BLOCK, 0, 1],
];
}else{
return [];
return parent::getDrops($item);
}
return [];
}
}

View File

@ -19,38 +19,41 @@
*
*/
declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\item\Item;
use pocketmine\item\ItemFactory;
use pocketmine\item\Tool;
class EmeraldOre extends Solid{
protected $id = self::EMERALD_ORE;
public function __construct(){
public function __construct(int $meta = 0){
$this->meta = $meta;
}
public function getName(){
public function getName() : string{
return "Emerald Ore";
}
public function getToolType(){
public function getToolType() : int{
return Tool::TYPE_PICKAXE;
}
public function getHardness(){
public function getHardness() : float{
return 3;
}
public function getDrops(Item $item){
public function getDrops(Item $item) : array{
if($item->isPickaxe() >= Tool::TIER_IRON){
return [
[Item::EMERALD, 0, 1],
ItemFactory::get(Item::EMERALD, 0, 1)
];
}else{
return [];
}
return [];
}
}

View File

@ -19,11 +19,14 @@
*
*/
declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\inventory\EnchantInventory;
use pocketmine\item\Item;
use pocketmine\item\Tool;
use pocketmine\math\Vector3;
use pocketmine\nbt\tag\CompoundTag;
use pocketmine\nbt\tag\IntTag;
use pocketmine\nbt\tag\StringTag;
@ -34,12 +37,12 @@ class EnchantingTable extends Transparent{
protected $id = self::ENCHANTING_TABLE;
public function __construct(){
public function __construct(int $meta = 0){
$this->meta = $meta;
}
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){
$this->getLevel()->setBlock($block, $this, true, true);
public function place(Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $facePos, Player $player = null) : bool{
$this->getLevel()->setBlock($blockReplace, $this, true, true);
$nbt = new CompoundTag("", [
new StringTag("id", Tile::ENCHANT_TABLE),
new IntTag("x", $this->x),
@ -62,27 +65,23 @@ class EnchantingTable extends Transparent{
return true;
}
public function canBeActivated(){
return true;
}
public function getHardness(){
public function getHardness() : float{
return 5;
}
public function getResistance(){
public function getBlastResistance() : float{
return 6000;
}
public function getName(){
public function getName() : string{
return "Enchanting Table";
}
public function getToolType(){
public function getToolType() : int{
return Tool::TYPE_PICKAXE;
}
public function onActivate(Item $item, Player $player = null){
public function onActivate(Item $item, Player $player = null) : bool{
if($player instanceof Player){
//TODO lock
@ -92,13 +91,11 @@ class EnchantingTable extends Transparent{
return true;
}
public function getDrops(Item $item){
public function getDrops(Item $item) : array{
if($item->isPickaxe() >= Tool::TIER_WOODEN){
return [
[$this->id, 0, 1],
];
}else{
return [];
return parent::getDrops($item);
}
return [];
}
}

View File

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

View File

@ -0,0 +1,104 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\item\Item;
use pocketmine\math\AxisAlignedBB;
use pocketmine\math\Vector3;
use pocketmine\Player;
class EndRod extends Flowable{
protected $id = Block::END_ROD;
public function __construct(int $meta = 0){
$this->meta = $meta;
}
public function getName() : string{
return "End Rod";
}
public function place(Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $facePos, Player $player = null) : bool{
if($face === Vector3::SIDE_UP or $face === Vector3::SIDE_DOWN){
$this->meta = $face;
}else{
$this->meta = $face ^ 0x01;
}
if($blockClicked instanceof EndRod and $blockClicked->getDamage() === $this->meta){
$this->meta ^= 0x01;
}
return $this->level->setBlock($blockReplace, $this, true, true);
}
public function isSolid() : bool{
return true;
}
public function getLightLevel() : int{
return 14;
}
protected function recalculateBoundingBox(){
$m = $this->meta & ~0x01;
$width = 0.375;
switch($m){
case 0x00: //up/down
return new AxisAlignedBB(
$this->x + $width,
$this->y,
$this->z + $width,
$this->x + 1 - $width,
$this->y + 1,
$this->z + 1 - $width
);
case 0x02: //north/south
return new AxisAlignedBB(
$this->x,
$this->y + $width,
$this->z + $width,
$this->x + 1,
$this->y + 1 - $width,
$this->z + 1 - $width
);
case 0x04: //east/west
return new AxisAlignedBB(
$this->x + $width,
$this->y + $width,
$this->z,
$this->x + 1 - $width,
$this->y + 1 - $width,
$this->z + 1
);
}
return null;
}
public function getVariantBitmask() : int{
return 0;
}
}

View File

@ -19,6 +19,8 @@
*
*/
declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\item\Tool;
@ -27,19 +29,19 @@ class EndStone extends Solid{
protected $id = self::END_STONE;
public function __construct(){
public function __construct(int $meta = 0){
$this->meta = $meta;
}
public function getName(){
public function getName() : string{
return "End Stone";
}
public function getToolType(){
public function getToolType() : int{
return Tool::TYPE_PICKAXE;
}
public function getHardness(){
public function getHardness() : float{
return 3;
}
}

View File

@ -19,6 +19,8 @@
*
*/
declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\entity\Entity;
@ -33,27 +35,28 @@ use pocketmine\nbt\tag\ListTag;
abstract class Fallable extends Solid{
public function onUpdate($type){
public function onUpdate(int $type){
if($type === Level::BLOCK_UPDATE_NORMAL){
$down = $this->getSide(Vector3::SIDE_DOWN);
if($down->getId() === self::AIR or ($down instanceof Liquid)){
$this->level->setBlock($this, BlockFactory::get(Block::AIR), true, true);
$fall = Entity::createEntity("FallingSand", $this->getLevel(), new CompoundTag("", [
"Pos" => new ListTag("Pos", [
new ListTag("Pos", [
new DoubleTag("", $this->x + 0.5),
new DoubleTag("", $this->y),
new DoubleTag("", $this->z + 0.5)
]),
"Motion" => new ListTag("Motion", [
new ListTag("Motion", [
new DoubleTag("", 0),
new DoubleTag("", 0),
new DoubleTag("", 0)
]),
"Rotation" => new ListTag("Rotation", [
new ListTag("Rotation", [
new FloatTag("", 0),
new FloatTag("", 0)
]),
"TileID" => new IntTag("TileID", $this->getId()),
"Data" => new ByteTag("Data", $this->getDamage()),
new IntTag("TileID", $this->getId()),
new ByteTag("Data", $this->getDamage())
]));
$fall->spawnToAll();

View File

@ -19,46 +19,62 @@
*
*/
declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\item\Item;
use pocketmine\item\ItemFactory;
use pocketmine\item\Tool;
use pocketmine\level\Level;
use pocketmine\math\AxisAlignedBB;
class Farmland extends Solid{
class Farmland extends Transparent{
protected $id = self::FARMLAND;
public function __construct($meta = 0){
public function __construct(int $meta = 0){
$this->meta = $meta;
}
public function getName(){
public function getName() : string{
return "Farmland";
}
public function getHardness(){
public function getHardness() : float{
return 0.6;
}
public function getToolType(){
public function getToolType() : int{
return Tool::TYPE_SHOVEL;
}
public function ticksRandomly() : bool{
return true;
}
protected function recalculateBoundingBox(){
return new AxisAlignedBB(
$this->x,
$this->y,
$this->z,
$this->x + 1,
$this->y + 0.9375,
$this->y + 1, //TODO: this should be 0.9375, but MCPE currently treats them as a full block (https://bugs.mojang.com/browse/MCPE-12109)
$this->z + 1
);
}
public function getDrops(Item $item){
public function onUpdate(int $type){
if($type === Level::BLOCK_UPDATE_RANDOM){
//TODO: hydration
}
return false;
}
public function getDrops(Item $item) : array{
return [
[Item::DIRT, 0, 1],
ItemFactory::get(Item::DIRT, 0, 1)
];
}
}

View File

@ -19,6 +19,8 @@
*
*/
declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\item\Tool;
@ -35,31 +37,29 @@ class Fence extends Transparent{
protected $id = self::FENCE;
public function __construct($meta = 0){
public function __construct(int $meta = 0){
$this->meta = $meta;
}
public function getHardness(){
public function getHardness() : float{
return 2;
}
public function getToolType(){
public function getToolType() : int{
return Tool::TYPE_AXE;
}
public function getName(){
public function getName() : string{
static $names = [
self::FENCE_OAK => "Oak Fence",
self::FENCE_SPRUCE => "Spruce Fence",
self::FENCE_BIRCH => "Birch Fence",
self::FENCE_JUNGLE => "Jungle Fence",
self::FENCE_ACACIA => "Acacia Fence",
self::FENCE_DARKOAK => "Dark Oak Fence",
"",
""
self::FENCE_DARKOAK => "Dark Oak Fence"
];
return $names[$this->meta & 0x07];
return $names[$this->meta & 0x07] ?? "Unknown";
}
protected function recalculateBoundingBox(){
@ -88,4 +88,8 @@ class Fence extends Transparent{
return ($block instanceof Fence or $block instanceof FenceGate) ? true : $block->isSolid() and !$block->isTransparent();
}
public function getFuelTime() : int{
return 300;
}
}

View File

@ -19,35 +19,24 @@
*
*/
declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\item\Item;
use pocketmine\item\Tool;
use pocketmine\level\sound\DoorSound;
use pocketmine\math\AxisAlignedBB;
use pocketmine\math\Vector3;
use pocketmine\Player;
class FenceGate extends Transparent{
protected $id = self::FENCE_GATE;
public function __construct($meta = 0){
$this->meta = $meta;
}
public function getName(){
return "Oak Fence Gate";
}
public function getHardness(){
public function getHardness() : float{
return 2;
}
public function canBeActivated(){
return true;
}
public function getToolType(){
public function getToolType() : int{
return Tool::TYPE_AXE;
}
@ -80,20 +69,18 @@ class FenceGate extends Transparent{
}
}
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){
public function place(Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $facePos, Player $player = null) : bool{
$this->meta = ($player instanceof Player ? ($player->getDirection() - 1) & 0x03 : 0);
$this->getLevel()->setBlock($block, $this, true, true);
$this->getLevel()->setBlock($blockReplace, $this, true, true);
return true;
}
public function getDrops(Item $item){
return [
[$this->id, 0, 1],
];
public function getVariantBitmask() : int{
return 0;
}
public function onActivate(Item $item, Player $player = null){
public function onActivate(Item $item, Player $player = null) : bool{
$this->meta = (($this->meta ^ 0x04) & ~0x02);
if($player !== null){
@ -104,4 +91,8 @@ class FenceGate extends Transparent{
$this->level->addSound(new DoorSound($this));
return true;
}
public function getFuelTime() : int{
return 300;
}
}

View File

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

View File

@ -19,51 +19,55 @@
*
*/
declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\entity\Arrow;
use pocketmine\entity\Effect;
use pocketmine\entity\Entity;
use pocketmine\event\entity\EntityCombustByBlockEvent;
use pocketmine\event\entity\EntityDamageByBlockEvent;
use pocketmine\event\entity\EntityDamageEvent;
use pocketmine\item\Item;
use pocketmine\level\Level;
use pocketmine\math\Vector3;
use pocketmine\Server;
class Fire extends Flowable{
protected $id = self::FIRE;
public function __construct($meta = 0){
public function __construct(int $meta = 0){
$this->meta = $meta;
}
public function hasEntityCollision(){
public function hasEntityCollision() : bool{
return true;
}
public function getName(){
public function getName() : string{
return "Fire Block";
}
public function getLightLevel(){
public function getLightLevel() : int{
return 15;
}
public function isBreakable(Item $item){
public function isBreakable(Item $item) : bool{
return false;
}
public function canBeReplaced(){
public function canBeReplaced(Block $with = null) : bool{
return true;
}
public function ticksRandomly() : bool{
return true;
}
public function onEntityCollide(Entity $entity){
if(!$entity->hasEffect(Effect::FIRE_RESISTANCE)){
$ev = new EntityDamageByBlockEvent($this, $entity, EntityDamageEvent::CAUSE_FIRE, 1);
$entity->attack($ev->getFinalDamage(), $ev);
}
$ev = new EntityDamageByBlockEvent($this, $entity, EntityDamageEvent::CAUSE_FIRE, 1);
$entity->attack($ev);
$ev = new EntityCombustByBlockEvent($this, $entity, 8);
if($entity instanceof Arrow){
@ -75,11 +79,11 @@ class Fire extends Flowable{
}
}
public function getDrops(Item $item){
public function getDrops(Item $item) : array{
return [];
}
public function onUpdate($type){
public function onUpdate(int $type){
if($type === Level::BLOCK_UPDATE_NORMAL){
for($s = 0; $s <= 5; ++$s){
$side = $this->getSide($s);
@ -87,14 +91,14 @@ class Fire extends Flowable{
return false;
}
}
$this->getLevel()->setBlock($this, new Air(), true);
$this->getLevel()->setBlock($this, BlockFactory::get(Block::AIR), true);
return Level::BLOCK_UPDATE_NORMAL;
}elseif($type === Level::BLOCK_UPDATE_RANDOM){
if($this->getSide(0)->getId() !== self::NETHERRACK){
if($this->getSide(Vector3::SIDE_DOWN)->getId() !== self::NETHERRACK){
if(mt_rand(0, 2) === 0){
if($this->meta === 0x0F){
$this->level->setBlock($this, new Air());
$this->level->setBlock($this, BlockFactory::get(Block::AIR));
}else{
$this->meta++;
$this->level->setBlock($this, $this);
@ -103,6 +107,8 @@ class Fire extends Flowable{
return Level::BLOCK_UPDATE_NORMAL;
}
}
//TODO: fire spread
}
return false;

View File

@ -19,23 +19,25 @@
*
*/
declare(strict_types=1);
namespace pocketmine\block;
abstract class Flowable extends Transparent{
public function canBeFlowedInto(){
public function canBeFlowedInto() : bool{
return true;
}
public function getHardness(){
public function getHardness() : float{
return 0;
}
public function getResistance(){
public function getBlastResistance() : float{
return 0;
}
public function isSolid(){
public function isSolid() : bool{
return false;
}

View File

@ -19,6 +19,8 @@
*
*/
declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\item\Item;
@ -39,11 +41,11 @@ class Flower extends Flowable{
protected $id = self::RED_FLOWER;
public function __construct($meta = 0){
public function __construct(int $meta = 0){
$this->meta = $meta;
}
public function getName(){
public function getName() : string{
static $names = [
self::TYPE_POPPY => "Poppy",
self::TYPE_BLUE_ORCHID => "Blue Orchid",
@ -53,23 +55,15 @@ class Flower extends Flowable{
self::TYPE_ORANGE_TULIP => "Orange Tulip",
self::TYPE_WHITE_TULIP => "White Tulip",
self::TYPE_PINK_TULIP => "Pink Tulip",
self::TYPE_OXEYE_DAISY => "Oxeye Daisy",
9 => "Unknown",
10 => "Unknown",
11 => "Unknown",
12 => "Unknown",
13 => "Unknown",
14 => "Unknown",
15 => "Unknown"
self::TYPE_OXEYE_DAISY => "Oxeye Daisy"
];
return $names[$this->meta];
return $names[$this->meta] ?? "Unknown";
}
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){
$down = $this->getSide(0);
public function place(Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $facePos, Player $player = null) : bool{
$down = $this->getSide(Vector3::SIDE_DOWN);
if($down->getId() === Block::GRASS or $down->getId() === Block::DIRT or $down->getId() === Block::FARMLAND){
$this->getLevel()->setBlock($block, $this, true);
$this->getLevel()->setBlock($blockReplace, $this, true);
return true;
}
@ -77,7 +71,7 @@ class Flower extends Flowable{
return false;
}
public function onUpdate($type){
public function onUpdate(int $type){
if($type === Level::BLOCK_UPDATE_NORMAL){
if($this->getSide(Vector3::SIDE_DOWN)->isTransparent()){
$this->getLevel()->useBreakOn($this);

View File

@ -19,9 +19,12 @@
*
*/
declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\item\Item;
use pocketmine\item\ItemFactory;
use pocketmine\level\Level;
use pocketmine\math\AxisAlignedBB;
use pocketmine\math\Vector3;
@ -39,19 +42,16 @@ class FlowerPot extends Flowable{
const STATE_FULL = 1;
protected $id = self::FLOWER_POT_BLOCK;
protected $itemId = Item::FLOWER_POT;
public function __construct($meta = 0){
public function __construct(int $meta = 0){
$this->meta = $meta;
}
public function getName(){
public function getName() : string{
return "Flower Pot Block";
}
public function canBeActivated(): bool{
return true;
}
protected function recalculateBoundingBox(){
return new AxisAlignedBB(
$this->x + 0.3125,
@ -63,20 +63,20 @@ class FlowerPot extends Flowable{
);
}
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){
public function place(Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $facePos, Player $player = null) : bool{
if($this->getSide(Vector3::SIDE_DOWN)->isTransparent()){
return false;
}
$this->getLevel()->setBlock($block, $this, true, true);
$this->getLevel()->setBlock($blockReplace, $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 IntTag("x", $blockReplace->x),
new IntTag("y", $blockReplace->y),
new IntTag("z", $blockReplace->z),
new ShortTag("item", 0),
new IntTag("mData", 0),
new IntTag("mData", 0)
]);
if($item->hasCustomBlockData()){
@ -89,9 +89,9 @@ class FlowerPot extends Flowable{
return true;
}
public function onUpdate($type){
public function onUpdate(int $type){
if($type === Level::BLOCK_UPDATE_NORMAL){
if($this->getSide(0)->isTransparent() === true){
if($this->getSide(Vector3::SIDE_DOWN)->isTransparent() === true){
$this->getLevel()->useBreakOn($this);
return Level::BLOCK_UPDATE_NORMAL;
@ -101,7 +101,7 @@ class FlowerPot extends Flowable{
return false;
}
public function onActivate(Item $item, Player $player = null){
public function onActivate(Item $item, Player $player = null) : bool{
$pot = $this->getLevel()->getTile($this);
if(!($pot instanceof TileFlowerPot)){
return false;
@ -117,20 +117,23 @@ class FlowerPot extends Flowable{
if($player instanceof Player){
if($player->isSurvival()){
$item->setCount($item->getCount() - 1);
$player->getInventory()->setItemInHand($item->getCount() > 0 ? $item : Item::get(Item::AIR));
$player->getInventory()->setItemInHand($item->getCount() > 0 ? $item : ItemFactory::get(Item::AIR));
}
}
return true;
}
public function getDrops(Item $item){
$items = [[Item::FLOWER_POT, 0, 1]];
public function getDrops(Item $item) : array{
$items = parent::getDrops($item);
$tile = $this->getLevel()->getTile($this);
if($tile instanceof TileFlowerPot){
if(($item = $tile->getItem())->getId() !== Item::AIR){
$items[] = [$item->getId(), $item->getDamage(), 1];
$item = $tile->getItem();
if($item->getId() !== Item::AIR){
$items[] = $item;
}
}
return $items;
}

View File

@ -19,6 +19,8 @@
*
*/
declare(strict_types=1);
namespace pocketmine\block;
@ -26,11 +28,11 @@ class Furnace extends BurningFurnace{
protected $id = self::FURNACE;
public function getName(){
public function getName() : string{
return "Furnace";
}
public function getLightLevel(){
public function getLightLevel() : int{
return 0;
}
}

View File

@ -19,6 +19,8 @@
*
*/
declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\item\Item;
@ -27,19 +29,19 @@ class Glass extends Transparent{
protected $id = self::GLASS;
public function __construct(){
public function __construct(int $meta = 0){
$this->meta = $meta;
}
public function getName(){
public function getName() : string{
return "Glass";
}
public function getHardness(){
public function getHardness() : float{
return 0.3;
}
public function getDrops(Item $item){
public function getDrops(Item $item) : array{
return [];
}
}

View File

@ -19,6 +19,8 @@
*
*/
declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\item\Item;
@ -27,19 +29,19 @@ class GlassPane extends Thin{
protected $id = self::GLASS_PANE;
public function __construct(){
public function __construct(int $meta = 0){
$this->meta = $meta;
}
public function getName(){
public function getName() : string{
return "Glass Pane";
}
public function getHardness(){
public function getHardness() : float{
return 0.3;
}
public function getDrops(Item $item){
public function getDrops(Item $item) : array{
return [];
}
}

View File

@ -0,0 +1,67 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\item\Item;
use pocketmine\item\Tool;
use pocketmine\math\Vector3;
use pocketmine\Player;
class GlazedTerracotta extends Solid{
public function getHardness() : float{
return 1.4;
}
public function getToolType() : int{
return Tool::TYPE_PICKAXE;
}
public function place(Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $facePos, Player $player = null) : bool{
if($player !== null){
$faces = [
0 => 4,
1 => 3,
2 => 5,
3 => 2
];
$this->meta = $faces[(~($player->getDirection() - 1)) & 0x03];
}
return $this->getLevel()->setBlock($blockReplace, $this, true, true);
}
public function getVariantBitmask() : int{
return 0;
}
public function getDrops(Item $item) : array{
if($item->isPickaxe() >= Tool::TIER_WOODEN){
return parent::getDrops($item);
}
return [];
}
}

View File

@ -19,6 +19,8 @@
*
*/
declare(strict_types=1);
namespace pocketmine\block;
@ -26,16 +28,23 @@ class GlowingObsidian extends Solid{
protected $id = self::GLOWING_OBSIDIAN;
public function __construct($meta = 0){
public function __construct(int $meta = 0){
$this->meta = $meta;
}
public function getName(){
public function getName() : string{
return "Glowing Obsidian";
}
public function getLightLevel(){
public function getLightLevel() : int{
return 12;
}
public function getHardness() : float{
return 10;
}
public function getBlastResistance() : float{
return 50;
}
}

View File

@ -19,26 +19,27 @@
*
*/
declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\item\Item;
use pocketmine\level\Level;
class GlowingRedstoneOre extends RedstoneOre{
protected $id = self::GLOWING_REDSTONE_ORE;
public function getName(){
public function getName() : string{
return "Glowing Redstone Ore";
}
public function getLightLevel(){
public function getLightLevel() : int{
return 9;
}
public function onUpdate($type){
public function onUpdate(int $type){
if($type === Level::BLOCK_UPDATE_SCHEDULED or $type === Level::BLOCK_UPDATE_RANDOM){
$this->getLevel()->setBlock($this, Block::get(Item::REDSTONE_ORE, $this->meta), false, false);
$this->getLevel()->setBlock($this, BlockFactory::get(Block::REDSTONE_ORE, $this->meta), false, false);
return Level::BLOCK_UPDATE_WEAK;
}

View File

@ -19,38 +19,41 @@
*
*/
declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\item\Item;
use pocketmine\item\ItemFactory;
use pocketmine\item\Tool;
class Glowstone extends Transparent{
protected $id = self::GLOWSTONE_BLOCK;
public function __construct(){
protected $id = self::GLOWSTONE;
public function __construct(int $meta = 0){
$this->meta = $meta;
}
public function getName(){
public function getName() : string{
return "Glowstone";
}
public function getHardness(){
public function getHardness() : float{
return 0.3;
}
public function getToolType(){
public function getToolType() : int{
return Tool::TYPE_PICKAXE;
}
public function getLightLevel(){
public function getLightLevel() : int{
return 15;
}
public function getDrops(Item $item){
public function getDrops(Item $item) : array{
return [
[Item::GLOWSTONE_DUST, 0, mt_rand(2, 4)],
ItemFactory::get(Item::GLOWSTONE_DUST, 0, mt_rand(2, 4))
];
}
}

View File

@ -19,6 +19,8 @@
*
*/
declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\item\Item;
@ -28,29 +30,27 @@ class Gold extends Solid{
protected $id = self::GOLD_BLOCK;
public function __construct(){
public function __construct(int $meta = 0){
$this->meta = $meta;
}
public function getName(){
public function getName() : string{
return "Gold Block";
}
public function getHardness(){
public function getHardness() : float{
return 3;
}
public function getToolType(){
public function getToolType() : int{
return Tool::TYPE_PICKAXE;
}
public function getDrops(Item $item){
public function getDrops(Item $item) : array{
if($item->isPickaxe() >= Tool::TIER_IRON){
return [
[Item::GOLD_BLOCK, 0, 1],
];
}else{
return [];
return parent::getDrops($item);
}
return [];
}
}

View File

@ -19,6 +19,8 @@
*
*/
declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\item\Item;
@ -28,29 +30,27 @@ class GoldOre extends Solid{
protected $id = self::GOLD_ORE;
public function __construct(){
public function __construct(int $meta = 0){
$this->meta = $meta;
}
public function getName(){
public function getName() : string{
return "Gold Ore";
}
public function getHardness(){
public function getHardness() : float{
return 3;
}
public function getToolType(){
public function getToolType() : int{
return Tool::TYPE_PICKAXE;
}
public function getDrops(Item $item){
public function getDrops(Item $item) : array{
if($item->isPickaxe() >= Tool::TIER_IRON){
return [
[Item::GOLD_ORE, 0, 1],
];
}else{
return [];
return parent::getDrops($item);
}
return [];
}
}

View File

@ -19,71 +19,90 @@
*
*/
declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\event\block\BlockSpreadEvent;
use pocketmine\item\Item;
use pocketmine\item\ItemFactory;
use pocketmine\item\Tool;
use pocketmine\level\generator\object\TallGrass as TallGrassObject;
use pocketmine\level\Level;
use pocketmine\math\Vector3;
use pocketmine\Player;
use pocketmine\Server;
use pocketmine\utils\Random;
class Grass extends Solid{
protected $id = self::GRASS;
public function __construct(){
public function __construct(int $meta = 0){
$this->meta = $meta;
}
public function canBeActivated(){
return true;
}
public function getName(){
public function getName() : string{
return "Grass";
}
public function getHardness(){
public function getHardness() : float{
return 0.6;
}
public function getToolType(){
public function getToolType() : int{
return Tool::TYPE_SHOVEL;
}
public function getDrops(Item $item){
public function getDrops(Item $item) : array{
return [
[Item::DIRT, 0, 1],
ItemFactory::get(Item::DIRT, 0, 1)
];
}
public function onUpdate($type){
if($type === Level::BLOCK_UPDATE_RANDOM){
$block = $this->getLevel()->getBlock(new Vector3($this->x, $this->y, $this->z));
if($block->getSide(1)->getLightLevel() < 4){
Server::getInstance()->getPluginManager()->callEvent($ev = new BlockSpreadEvent($block, $this, new Dirt()));
}elseif($block->getSide(1)->getLightLevel() >= 9){
for($l = 0; $l < 4; ++$l){
$x = mt_rand($this->x - 1, $this->x + 1);
$y = mt_rand($this->y - 2, $this->y + 2);
$z = mt_rand($this->z - 1, $this->z + 1);
$block = $this->getLevel()->getBlock(new Vector3($x, $y, $z));
if($block->getId() === Block::DIRT && $block->getDamage() === 0x0F && $block->getSide(1)->getLightLevel() >= 4 && $block->z <= 2){
Server::getInstance()->getPluginManager()->callEvent($ev = new BlockSpreadEvent($block, $this, new Grass()));
if(!$ev->isCancelled()){
$this->getLevel()->setBlock($block, $ev->getNewState());
}
}
}
}
}
public function ticksRandomly() : bool{
return true;
}
public function onActivate(Item $item, Player $player = null){
public function onUpdate(int $type){
if($type === Level::BLOCK_UPDATE_RANDOM){
$lightAbove = $this->level->getFullLightAt($this->x, $this->y + 1, $this->z);
if($lightAbove < 4 and BlockFactory::$lightFilter[$this->level->getBlockIdAt($this->x, $this->y + 1, $this->z)] >= 3){ //2 plus 1 standard filter amount
//grass dies
$this->level->getServer()->getPluginManager()->callEvent($ev = new BlockSpreadEvent($this, $this, BlockFactory::get(Block::DIRT)));
if(!$ev->isCancelled()){
$this->level->setBlock($this, $ev->getNewState(), false, false);
}
return Level::BLOCK_UPDATE_RANDOM;
}elseif($lightAbove >= 9){
//try grass spread
$vector = $this->asVector3();
for($i = 0; $i < 4; ++$i){
$vector->x = mt_rand($this->x - 1, $this->x + 1);
$vector->y = mt_rand($this->y - 3, $this->y + 1);
$vector->z = mt_rand($this->z - 1, $this->z + 1);
if(
$this->level->getBlockIdAt($vector->x, $vector->y, $vector->z) !== Block::DIRT or
$this->level->getFullLightAt($vector->x, $vector->y + 1, $vector->z) < 4 or
BlockFactory::$lightFilter[$this->level->getBlockIdAt($vector->x, $vector->y + 1, $vector->z)] >= 3
){
continue;
}
$this->level->getServer()->getPluginManager()->callEvent($ev = new BlockSpreadEvent($this->level->getBlock($vector), $this, BlockFactory::get(Block::GRASS)));
if(!$ev->isCancelled()){
$this->level->setBlock($vector, $ev->getNewState(), false, false);
}
}
return Level::BLOCK_UPDATE_RANDOM;
}
}
return false;
}
public function onActivate(Item $item, Player $player = null) : bool{
if($item->getId() === Item::DYE and $item->getDamage() === 0x0F){
$item->count--;
TallGrassObject::growGrass($this->getLevel(), $this, new Random(mt_rand()), 8, 2);
@ -91,12 +110,12 @@ class Grass extends Solid{
return true;
}elseif($item->isHoe()){
$item->useOn($this);
$this->getLevel()->setBlock($this, new Farmland());
$this->getLevel()->setBlock($this, BlockFactory::get(Block::FARMLAND));
return true;
}elseif($item->isShovel() and $this->getSide(1)->getId() === Block::AIR){
}elseif($item->isShovel() and $this->getSide(Vector3::SIDE_UP)->getId() === Block::AIR){
$item->useOn($this);
$this->getLevel()->setBlock($this, new GrassPath());
$this->getLevel()->setBlock($this, BlockFactory::get(Block::GRASS_PATH));
return true;
}

View File

@ -19,9 +19,12 @@
*
*/
declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\item\Item;
use pocketmine\item\ItemFactory;
use pocketmine\item\Tool;
use pocketmine\math\AxisAlignedBB;
@ -29,15 +32,15 @@ class GrassPath extends Transparent{
protected $id = self::GRASS_PATH;
public function __construct(){
public function __construct(int $meta = 0){
$this->meta = $meta;
}
public function getName(){
public function getName() : string{
return "Grass Path";
}
public function getToolType(){
public function getToolType() : int{
return Tool::TYPE_SHOVEL;
}
@ -47,18 +50,18 @@ class GrassPath extends Transparent{
$this->y,
$this->z,
$this->x + 1,
$this->y + 0.9375,
$this->y + 1, //TODO: this should be 0.9375, but MCPE currently treats them as a full block (https://bugs.mojang.com/browse/MCPE-12109)
$this->z + 1
);
}
public function getHardness(){
public function getHardness() : float{
return 0.6;
}
public function getDrops(Item $item){
public function getDrops(Item $item) : array{
return [
[Item::DIRT, 0, 1],
ItemFactory::get(Item::DIRT, 0, 1)
];
}
}

View File

@ -19,41 +19,42 @@
*
*/
declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\item\Item;
use pocketmine\item\ItemFactory;
use pocketmine\item\Tool;
class Gravel extends Fallable{
protected $id = self::GRAVEL;
public function __construct(){
public function __construct(int $meta = 0){
$this->meta = $meta;
}
public function getName(){
public function getName() : string{
return "Gravel";
}
public function getHardness(){
public function getHardness() : float{
return 0.6;
}
public function getToolType(){
public function getToolType() : int{
return Tool::TYPE_SHOVEL;
}
public function getDrops(Item $item){
public function getDrops(Item $item) : array{
if(mt_rand(1, 10) === 1){
return [
[Item::FLINT, 0, 1],
ItemFactory::get(Item::FLINT, 0, 1)
];
}
return [
[Item::GRAVEL, 0, 1],
];
return parent::getDrops($item);
}
}

View File

@ -19,6 +19,8 @@
*
*/
declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\item\Tool;
@ -27,19 +29,19 @@ class HardenedClay extends Solid{
protected $id = self::HARDENED_CLAY;
public function __construct(){
public function __construct(int $meta = 0){
$this->meta = $meta;
}
public function getName(){
public function getName() : string{
return "Hardened Clay";
}
public function getToolType(){
public function getToolType() : int{
return Tool::TYPE_PICKAXE;
}
public function getHardness(){
public function getHardness() : float{
return 1.25;
}
}

View File

@ -19,47 +19,47 @@
*
*/
declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\item\Item;
use pocketmine\math\Vector3;
use pocketmine\Player;
class HayBale extends Solid{
protected $id = self::HAY_BALE;
public function __construct($meta = 0){
public function __construct(int $meta = 0){
$this->meta = $meta;
}
public function getName(){
public function getName() : string{
return "Hay Bale";
}
public function getHardness(){
public function getHardness() : float{
return 0.5;
}
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){
public function place(Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $facePos, Player $player = null) : bool{
$faces = [
0 => 0,
1 => 0,
2 => 0b1000,
3 => 0b1000,
4 => 0b0100,
5 => 0b0100,
5 => 0b0100
];
$this->meta = ($this->meta & 0x03) | $faces[$face];
$this->getLevel()->setBlock($block, $this, true, true);
$this->getLevel()->setBlock($blockReplace, $this, true, true);
return true;
}
public function getDrops(Item $item){
return [
[$this->id, 0, 1],
];
public function getVariantBitmask() : int{
return 0x03;
}
}

View File

@ -19,38 +19,63 @@
*
*/
declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\item\Item;
use pocketmine\item\Tool;
use pocketmine\level\Level;
use pocketmine\Player;
class Ice extends Transparent{
protected $id = self::ICE;
public function __construct(){
public function __construct(int $meta = 0){
$this->meta = $meta;
}
public function getName(){
public function getName() : string{
return "Ice";
}
public function getHardness(){
public function getHardness() : float{
return 0.5;
}
public function getToolType(){
public function getLightFilter() : int{
return 2;
}
public function getFrictionFactor() : float{
return 0.98;
}
public function getToolType() : int{
return Tool::TYPE_PICKAXE;
}
public function onBreak(Item $item){
$this->getLevel()->setBlock($this, new Water(), true);
public function onBreak(Item $item, Player $player = null) : bool{
return $this->getLevel()->setBlock($this, BlockFactory::get(Block::WATER), true);
}
public function ticksRandomly() : bool{
return true;
}
public function getDrops(Item $item){
public function onUpdate(int $type){
if($type === Level::BLOCK_UPDATE_RANDOM){
if($this->level->getHighestAdjacentBlockLight($this->x, $this->y, $this->z) >= 12){
$this->level->useBreakOn($this);
return $type;
}
}
return false;
}
public function getDrops(Item $item) : array{
return [];
}
}

View File

@ -19,6 +19,8 @@
*
*/
declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\item\Item;
@ -28,29 +30,27 @@ class Iron extends Solid{
protected $id = self::IRON_BLOCK;
public function __construct(){
public function __construct(int $meta = 0){
$this->meta = $meta;
}
public function getName(){
public function getName() : string{
return "Iron Block";
}
public function getToolType(){
public function getToolType() : int{
return Tool::TYPE_PICKAXE;
}
public function getHardness(){
public function getHardness() : float{
return 5;
}
public function getDrops(Item $item){
public function getDrops(Item $item) : array{
if($item->isPickaxe() >= Tool::TIER_STONE){
return [
[Item::IRON_BLOCK, 0, 1],
];
}else{
return [];
return parent::getDrops($item);
}
return [];
}
}

View File

@ -19,6 +19,8 @@
*
*/
declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\item\Item;
@ -28,30 +30,32 @@ class IronBars extends Thin{
protected $id = self::IRON_BARS;
public function __construct(){
public function __construct(int $meta = 0){
$this->meta = $meta;
}
public function getName(){
public function getName() : string{
return "Iron Bars";
}
public function getHardness(){
public function getHardness() : float{
return 5;
}
public function getToolType(){
public function getToolType() : int{
return Tool::TYPE_PICKAXE;
}
public function getDrops(Item $item){
public function getVariantBitmask() : int{
return 0;
}
public function getDrops(Item $item) : array{
if($item->isPickaxe() >= Tool::TIER_WOODEN){
return [
[Item::IRON_BARS, 0, 1],
];
}else{
return [];
return parent::getDrops($item);
}
return [];
}
}

View File

@ -19,6 +19,8 @@
*
*/
declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\item\Item;
@ -28,29 +30,29 @@ class IronDoor extends Door{
protected $id = self::IRON_DOOR_BLOCK;
public function __construct($meta = 0){
protected $itemId = Item::IRON_DOOR;
public function __construct(int $meta = 0){
$this->meta = $meta;
}
public function getName(){
public function getName() : string{
return "Iron Door Block";
}
public function getToolType(){
public function getToolType() : int{
return Tool::TYPE_PICKAXE;
}
public function getHardness(){
public function getHardness() : float{
return 5;
}
public function getDrops(Item $item){
public function getDrops(Item $item) : array{
if($item->isPickaxe() >= Tool::TIER_WOODEN){
return [
[Item::IRON_DOOR, 0, 1],
];
}else{
return [];
return parent::getDrops($item);
}
return [];
}
}

View File

@ -19,6 +19,8 @@
*
*/
declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\item\Item;
@ -28,29 +30,27 @@ class IronOre extends Solid{
protected $id = self::IRON_ORE;
public function __construct(){
public function __construct(int $meta = 0){
$this->meta = $meta;
}
public function getName(){
public function getName() : string{
return "Iron Ore";
}
public function getToolType(){
public function getToolType() : int{
return Tool::TYPE_PICKAXE;
}
public function getHardness(){
public function getHardness() : float{
return 3;
}
public function getDrops(Item $item){
public function getDrops(Item $item) : array{
if($item->isPickaxe() >= Tool::TIER_STONE){
return [
[Item::IRON_ORE, 0, 1],
];
}else{
return [];
return parent::getDrops($item);
}
return [];
}
}

View File

@ -19,6 +19,8 @@
*
*/
declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\item\Tool;
@ -27,15 +29,15 @@ class IronTrapdoor extends Trapdoor{
protected $id = self::IRON_TRAPDOOR;
public function getName(){
public function getName() : string{
return "Iron Trapdoor";
}
public function getHardness(){
public function getHardness() : float{
return 5;
}
public function getToolType(){
public function getToolType() : int{
return Tool::TYPE_PICKAXE;
}
}

View File

@ -2,11 +2,11 @@
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
@ -19,10 +19,14 @@
*
*/
declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\item\Item;
use pocketmine\item\ItemFactory;
use pocketmine\level\Level;
use pocketmine\math\Vector3;
use pocketmine\nbt\tag\{
ByteTag, CompoundTag, FloatTag, IntTag, StringTag
};
@ -33,19 +37,17 @@ use pocketmine\tile\Tile;
class ItemFrame extends Flowable{
protected $id = Block::ITEM_FRAME_BLOCK;
public function __construct($meta = 0){
protected $itemId = Item::ITEM_FRAME;
public function __construct(int $meta = 0){
$this->meta = $meta;
}
public function getName(){
public function getName() : string{
return "Item Frame";
}
public function canBeActivated(){
return true;
}
public function onActivate(Item $item, Player $player = null){
public function onActivate(Item $item, Player $player = null) : bool{
$tile = $this->level->getTile($this);
if(!($tile instanceof TileItemFrame)){
$nbt = new CompoundTag("", [
@ -68,7 +70,7 @@ class ItemFrame extends Flowable{
$item->setCount($item->getCount() - 1);
$tile->setItem($frameItem);
if($player instanceof Player and $player->isSurvival()){
$player->getInventory()->setItemInHand($item->getCount() <= 0 ? Item::get(Item::AIR) : $item);
$player->getInventory()->setItemInHand($item->getCount() <= 0 ? ItemFactory::get(Item::AIR) : $item);
}
}
}
@ -76,7 +78,7 @@ class ItemFrame extends Flowable{
return true;
}
public function onBreak(Item $item){
public function onBreak(Item $item, Player $player = null) : bool{
$tile = $this->level->getTile($this);
if($tile instanceof TileItemFrame){
//TODO: add events
@ -84,10 +86,10 @@ class ItemFrame extends Flowable{
$this->level->dropItem($tile->getBlock(), $tile->getItem());
}
}
return parent::onBreak($item);
return parent::onBreak($item, $player);
}
public function onUpdate($type){
public function onUpdate(int $type){
if($type === Level::BLOCK_UPDATE_NORMAL){
$sides = [
0 => 4,
@ -103,26 +105,26 @@ class ItemFrame extends Flowable{
return false;
}
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){
if($face === 0 or $face === 1){
public function place(Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $facePos, Player $player = null) : bool{
if($face === Vector3::SIDE_DOWN or $face === Vector3::SIDE_UP){
return false;
}
$faces = [
2 => 3,
3 => 2,
4 => 1,
5 => 0
Vector3::SIDE_NORTH => 3,
Vector3::SIDE_SOUTH => 2,
Vector3::SIDE_WEST => 1,
Vector3::SIDE_EAST => 0
];
$this->meta = $faces[$face];
$this->level->setBlock($block, $this, true, true);
$this->level->setBlock($blockReplace, $this, true, true);
$nbt = new CompoundTag("", [
new StringTag("id", Tile::ITEM_FRAME),
new IntTag("x", $block->x),
new IntTag("y", $block->y),
new IntTag("z", $block->z),
new IntTag("x", $blockReplace->x),
new IntTag("y", $blockReplace->y),
new IntTag("z", $blockReplace->z),
new FloatTag("ItemDropChance", 1.0),
new ByteTag("ItemRotation", 0)
]);
@ -139,10 +141,7 @@ class ItemFrame extends Flowable{
}
public function getDrops(Item $item){
return [
[Item::ITEM_FRAME, 0, 1]
];
public function getVariantBitmask() : int{
return 0;
}
}

View File

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

View File

@ -19,6 +19,8 @@
*
*/
declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\entity\Entity;
@ -26,32 +28,37 @@ use pocketmine\item\Item;
use pocketmine\item\Tool;
use pocketmine\level\Level;
use pocketmine\math\AxisAlignedBB;
use pocketmine\math\Vector3;
use pocketmine\Player;
class Ladder extends Transparent{
protected $id = self::LADDER;
public function __construct($meta = 0){
public function __construct(int $meta = 0){
$this->meta = $meta;
}
public function getName(){
public function getName() : string{
return "Ladder";
}
public function hasEntityCollision(){
public function hasEntityCollision() : bool{
return true;
}
public function isSolid(){
public function isSolid() : bool{
return false;
}
public function getHardness(){
public function getHardness() : float{
return 0.4;
}
public function canClimb() : bool{
return true;
}
public function onEntityCollide(Entity $entity){
$entity->resetFallDistance();
$entity->onGround = true;
@ -103,17 +110,17 @@ class Ladder extends Transparent{
}
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){
if($target->isTransparent() === false){
public function place(Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $facePos, Player $player = null) : bool{
if($blockClicked->isTransparent() === false){
$faces = [
2 => 2,
3 => 3,
4 => 4,
5 => 5,
5 => 5
];
if(isset($faces[$face])){
$this->meta = $faces[$face];
$this->getLevel()->setBlock($block, $this, true, true);
$this->getLevel()->setBlock($blockReplace, $this, true, true);
return true;
}
@ -122,7 +129,7 @@ class Ladder extends Transparent{
return false;
}
public function onUpdate($type){
public function onUpdate(int $type){
if($type === Level::BLOCK_UPDATE_NORMAL){
$sides = [
2 => 3,
@ -139,13 +146,11 @@ class Ladder extends Transparent{
return false;
}
public function getToolType(){
public function getToolType() : int{
return Tool::TYPE_AXE;
}
public function getDrops(Item $item){
return [
[$this->id, 0, 1],
];
public function getVariantBitmask() : int{
return 0;
}
}

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