mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-10 11:38:08 +00:00
Compare commits
680 Commits
Alpha_1.4d
...
1.5dev
Author | SHA1 | Date | |
---|---|---|---|
2b2a1b18e7 | |||
1b812d373c | |||
5621ab0c49 | |||
4258e22c02 | |||
0380e9009a | |||
866fde5351 | |||
9f953fa675 | |||
4d95c65d95 | |||
26c9eed82e | |||
f3c46b12c5 | |||
b14d14d3d5 | |||
60ab35774a | |||
2df901b064 | |||
0c09361c46 | |||
1ebf2476df | |||
fe85b5026d | |||
bfd3fb6636 | |||
0723112207 | |||
be9f5521e1 | |||
6063738e69 | |||
ef738ef299 | |||
5796784442 | |||
a1cc60d472 | |||
f7ec1de0fd | |||
b856e5e909 | |||
f7e6246dc2 | |||
b166628940 | |||
4e76c30788 | |||
33e312c7d0 | |||
2ac27bd382 | |||
f490ff8074 | |||
eeef81e2b1 | |||
4a8ca96aaa | |||
eef33d64e6 | |||
7cf5df7e46 | |||
ac2bcf7e30 | |||
ec226105e4 | |||
2a1a09a923 | |||
20911930cf | |||
2eaa12005e | |||
fdcddcc04b | |||
4fd5e9ba7d | |||
7b17bf416e | |||
d0f743a99e | |||
cbb1c55a06 | |||
d881dbf1a2 | |||
383fcba8e1 | |||
e5f28e0f7a | |||
cf3f32fdae | |||
c4bdbc5443 | |||
62a8f58bb0 | |||
f21ed39c1c | |||
b358a2e474 | |||
21c6eeef11 | |||
96f67bdadf | |||
6ee61cce7b | |||
7f6704f761 | |||
9e4d88a852 | |||
5682026eae | |||
2a805dc0ed | |||
bdb9b1865b | |||
1e03c5b795 | |||
ec82434ef4 | |||
7bafa217c8 | |||
fe55023761 | |||
ac4194eb3f | |||
6e69e15dfd | |||
a53b041984 | |||
d542dfc2ce | |||
188f4d7778 | |||
71490f60f2 | |||
05dbf7b47f | |||
14ff537e71 | |||
9e14435dbb | |||
32680843fa | |||
9768bf4f8a | |||
7c806c7920 | |||
b61c54c9cb | |||
a349f6d4dd | |||
9541c9751b | |||
3c0efe9af2 | |||
24c1e6880d | |||
74917923b6 | |||
f20d5b2c69 | |||
eaa42f8449 | |||
1e2038fac5 | |||
c8abbf4f2f | |||
009a3b657f | |||
5b57fe6967 | |||
f133154919 | |||
8d4decc548 | |||
3bb037204e | |||
c578898aa4 | |||
0f5f71e612 | |||
75cab3dfc3 | |||
03f178379e | |||
ce59703dd0 | |||
a77d82ac81 | |||
1833da01fe | |||
c97e1fdce0 | |||
0e9bff6f4e | |||
3dd4fe706c | |||
9a2170d296 | |||
8a41512194 | |||
51062940c5 | |||
66435d4f6a | |||
c4d63326be | |||
f91a3a2666 | |||
d429992f5b | |||
76c27fc18b | |||
a0f8bc15dc | |||
adc5aa11ac | |||
388f5c2c91 | |||
f64caf6c96 | |||
b2b4cf788c | |||
d7be531868 | |||
5ad4f44dce | |||
7201372b0d | |||
744ea6af8f | |||
1da0a48edb | |||
be6b0656a0 | |||
4f7aac50d3 | |||
149234f125 | |||
cfe5ca91b2 | |||
46f20d36b3 | |||
cde2d39029 | |||
36ddbf286d | |||
8d4abe2f39 | |||
32722856ea | |||
7753b1d8be | |||
92a2be024a | |||
66f28f6dc4 | |||
1122a3c511 | |||
0c6d8b9815 | |||
70a7c4c552 | |||
840690d801 | |||
f3a53be117 | |||
ea7c0cb357 | |||
85c43ba011 | |||
fbbe02a3bc | |||
fb05636694 | |||
63a5269313 | |||
7705d8c52f | |||
419abdaad6 | |||
d6ebff412c | |||
7a34417e67 | |||
76e6ccebd5 | |||
e61db8ad06 | |||
b1edfd7631 | |||
f3bdef7513 | |||
9791071262 | |||
aa38a4885f | |||
de0f653027 | |||
13906b32b8 | |||
925b0c1b07 | |||
db409851e9 | |||
ab18b7833f | |||
1a1b8830a4 | |||
7e539ec85a | |||
563f6f8e4f | |||
82b0dbfe8e | |||
a4769248fb | |||
fb03df3d06 | |||
44b5c23ee1 | |||
bff51322af | |||
cc58d96071 | |||
001915fcd6 | |||
cd607b0cec | |||
5ec4b3f46f | |||
d9a9808844 | |||
f718d06a7d | |||
563f7404fe | |||
0ddf396b08 | |||
d830386786 | |||
49f34ec524 | |||
9ec609d025 | |||
0ead3ec781 | |||
fdf395721e | |||
211e1ae121 | |||
923be2fffc | |||
fb257c16f1 | |||
b33706d427 | |||
6bcb319fb5 | |||
d4b2e3d1b7 | |||
7754aa71a3 | |||
978aa2ba0f | |||
c2b3f7cd7f | |||
3872a21474 | |||
11e2d23b83 | |||
2cd78d4ae3 | |||
08f09cc3c8 | |||
1b13a4c1ec | |||
71587db2be | |||
8caf04ade5 | |||
488fbc27fe | |||
84d1f4596b | |||
6fc7ee2775 | |||
ef00103fec | |||
bdf069ebe1 | |||
5942cafa53 | |||
fbdbac06cc | |||
fba12f2a13 | |||
7ad98d4659 | |||
1d8c29add7 | |||
d4cae729c3 | |||
529f9b148b | |||
20842636f9 | |||
7b699d9afd | |||
ba635b8858 | |||
04f3cc4905 | |||
4a1e122605 | |||
a0739a7b03 | |||
f73bd02198 | |||
ec7db3be4f | |||
2ea8835b12 | |||
0aebcb9f81 | |||
1578fc3ddb | |||
514ce0fb04 | |||
f6e88ec055 | |||
15b4cd8fb3 | |||
f88aed1208 | |||
6ed63edd89 | |||
897774f848 | |||
bf4a8398c4 | |||
05385acb36 | |||
094234dc0f | |||
c2f72ea9ac | |||
e3c48b22cb | |||
5860bdcc4d | |||
1b84340e3f | |||
61828baa8f | |||
11ecaaa87f | |||
b2c25eaf36 | |||
ddc152ae0a | |||
08a612954e | |||
5b10ccf431 | |||
2add19a4c8 | |||
7ee21f6254 | |||
f79476f530 | |||
4fbafe7c2f | |||
d6186fa7c6 | |||
88797d4c6c | |||
fc2e4ddc63 | |||
7f28deefcb | |||
81fe98d4cc | |||
dfec44645b | |||
1ef6328635 | |||
c0782caab9 | |||
298b973604 | |||
5ca4f5416c | |||
c36c0dfa66 | |||
64c366bdb5 | |||
68ea9b067f | |||
79adbdeafe | |||
e09ebb0623 | |||
91388c6b86 | |||
42eda170b5 | |||
6ee3a7b8d7 | |||
18f6e1805f | |||
0b176b3fe0 | |||
bb945446b7 | |||
1d1766a876 | |||
bd560ab3b1 | |||
547aa2ae31 | |||
a993f15387 | |||
1865622b89 | |||
31387ff0be | |||
928660d59a | |||
5e2a21fc26 | |||
410f6ba618 | |||
05a9ad57bd | |||
ba226d03c3 | |||
674a486654 | |||
e9963b603d | |||
e2bae92df8 | |||
8d468a1efb | |||
ddeea2942c | |||
a65c300a0a | |||
363e0e3b13 | |||
6504047292 | |||
87a779afaf | |||
6b1b6711bd | |||
f71cf1c749 | |||
3685d967a8 | |||
d1006de421 | |||
3cf42b558c | |||
5a0d1affcc | |||
414549659a | |||
3b6e10b759 | |||
c2138aa30c | |||
de052a79de | |||
c29ae333a2 | |||
0c041ebca3 | |||
3224cd7dc5 | |||
3f60f7c0fb | |||
c786ace355 | |||
60ac8f91ba | |||
5720cb2be7 | |||
c32a7467bb | |||
0626d27003 | |||
2ae095a15a | |||
5d102c2ede | |||
a7b1c6e086 | |||
d855bbba0b | |||
73d1d131e1 | |||
0aa9586a52 | |||
205f6d50c1 | |||
ac6e2f9bf7 | |||
1ddd58fd3b | |||
66b58e36a1 | |||
86184a230e | |||
b4a0afc2c8 | |||
f2e2cec024 | |||
0117e8dfae | |||
69f841a00c | |||
02ba9ffc16 | |||
71657a2a4e | |||
76767294bf | |||
3cae81c01b | |||
141c0a297e | |||
45c6694ef9 | |||
9b09b7ddd1 | |||
c9adc336ee | |||
d5ba2a72a5 | |||
9f6b5992e3 | |||
e51858ae17 | |||
c2baaf435d | |||
c422b83abf | |||
e0a6d0feab | |||
0a85ad0d1f | |||
91315645cd | |||
47de616ac5 | |||
e0522d8b1a | |||
08f2b7f291 | |||
72c4c01542 | |||
668ddeeb13 | |||
286c1ee880 | |||
ed2ba70a29 | |||
962c28aaca | |||
7d1313c63d | |||
d19631226f | |||
6836e4fe58 | |||
4a79c65544 | |||
d1760d9bb8 | |||
355ddc469c | |||
4e934654ef | |||
38f3dda13b | |||
c68cd2c496 | |||
a6b8170d9c | |||
9da26fdb88 | |||
1666602652 | |||
d2bf92c3ed | |||
93a50d08e7 | |||
1f977f68c0 | |||
91a26c15dd | |||
add380c7ed | |||
652987110a | |||
58253be0a0 | |||
b42424eb22 | |||
1d1a8a316e | |||
a2b3e48b45 | |||
ebc8928c21 | |||
62ba36b474 | |||
2c59983672 | |||
8ae9cd4eaf | |||
275a1e3f60 | |||
6735234bf4 | |||
d66a2d7105 | |||
c882df7465 | |||
f21e457dc0 | |||
6bf30c133a | |||
d34499e67b | |||
c2a3298a7e | |||
b31604a536 | |||
c00370cfbf | |||
7c0bd45d1d | |||
5f2254cc42 | |||
8169803bb4 | |||
5a35e7b058 | |||
1b25cd6ffa | |||
891eeff75a | |||
b4f62bf423 | |||
7c76c1e3d7 | |||
37bc1273ee | |||
ffcdf49912 | |||
3e893ed0f7 | |||
bfb7e8bb9e | |||
5067b96184 | |||
cb2157ea80 | |||
6af87814e3 | |||
5b3e65345f | |||
8aa8ae5094 | |||
b5b46bfd7e | |||
2ae80031f0 | |||
85c5714cbf | |||
bc31df37d0 | |||
29ca349b3d | |||
4ec584d800 | |||
4383e272eb | |||
f9361aa931 | |||
220d2b7bee | |||
d5601b0c9f | |||
5bfc747622 | |||
b0f8c14640 | |||
328cd585c0 | |||
807107e581 | |||
94c2ec8498 | |||
9158cc4f19 | |||
11c13cd666 | |||
284958a21e | |||
91e8bdbd37 | |||
9e0b9a6e5b | |||
e48a3e5713 | |||
1ce7cc64a6 | |||
7f9aad6840 | |||
3af784012c | |||
a6c19734ce | |||
8ddd701d76 | |||
15ee0c37c6 | |||
fc128affc5 | |||
218fd999b0 | |||
eeeaac04e9 | |||
8679ad5b86 | |||
2cd757d80a | |||
be20f61a93 | |||
59e9446fe5 | |||
4f47dac8ec | |||
b54c0835b7 | |||
1e00ff9e4a | |||
1ac7f9f061 | |||
5b3ce2da9d | |||
00942d3a2b | |||
4b442a9d7c | |||
44dfb59409 | |||
696ba08a81 | |||
d80b8524fb | |||
2175d7922a | |||
5fcb0d6aa5 | |||
9ca3ad8971 | |||
a644b46ec4 | |||
9d3f59fab6 | |||
6309d4abf1 | |||
39291e4061 | |||
bb71a3c4a6 | |||
eb0525e892 | |||
f49db47b2e | |||
3ff5e12302 | |||
99ad65ba44 | |||
5f4f996efe | |||
21e0739845 | |||
3a157d0f02 | |||
8e56782138 | |||
116ede3679 | |||
7c0f5987d3 | |||
547e152e40 | |||
7905fbdd29 | |||
ae65701a23 | |||
9134a69936 | |||
907fe8aff6 | |||
afa9acf22f | |||
9a5afff4ab | |||
2f8c281a2e | |||
2096dace68 | |||
8421985102 | |||
f63e859b3a | |||
c56eb0b9df | |||
3f2e5bbef4 | |||
9886eb4768 | |||
ea44eee5df | |||
9173f930ca | |||
80b6a8ebaf | |||
7c64a33389 | |||
9fac896f28 | |||
5bd76e955c | |||
63f1a50be4 | |||
24c6cca664 | |||
9fac990b19 | |||
e8e7938490 | |||
f6c4a726b3 | |||
8eec5e6b5e | |||
bd7fa71d7f | |||
7d406066a7 | |||
3e9196d224 | |||
f30986d187 | |||
f8c144be31 | |||
c61e4adcf1 | |||
5a55040ab9 | |||
83360187c9 | |||
a893174473 | |||
9d97a940a6 | |||
cd21c28d46 | |||
a76be6cf38 | |||
37fd0372cc | |||
ed02026815 | |||
042a143dd6 | |||
4b73dbd9f8 | |||
d4e4430df0 | |||
469ef84733 | |||
efe75f2836 | |||
53f2f21f2d | |||
9c28f0a5be | |||
5bf5014b60 | |||
f37e79b611 | |||
7a0118820c | |||
c8b5c023cd | |||
f9dd929e04 | |||
87970726e4 | |||
1daf9a96a3 | |||
6c8b33fcc8 | |||
438591bd75 | |||
7ef8edccf4 | |||
074c8b876d | |||
f9762c870a | |||
4039895d3c | |||
d207a5daea | |||
8e3667c95b | |||
0da628deca | |||
04bdb13103 | |||
e8ad828498 | |||
f46473bbe8 | |||
692045d714 | |||
47cbf56725 | |||
3de14d8ba6 | |||
5fffabe05b | |||
3128ae9736 | |||
7be4e2fa81 | |||
95b305ce87 | |||
767800662c | |||
fe32e6f5d0 | |||
2cec0d9f36 | |||
d800a21bd4 | |||
8d9fbec4ce | |||
ab72c32769 | |||
346626305c | |||
fafbd500e1 | |||
2db2e8cfc4 | |||
854479180f | |||
902ba81e02 | |||
1ac17abec0 | |||
714ea54121 | |||
aa992684ba | |||
0c58de86b7 | |||
7ecac019a9 | |||
6cb88afe1a | |||
a677bcb331 | |||
2f6007342c | |||
b6c0eb8c96 | |||
afa8496767 | |||
d7be2ce439 | |||
6dcb5da069 | |||
3cf1692c96 | |||
d04af590d1 | |||
d4c43215b1 | |||
a40918aabf | |||
20f9352714 | |||
a605e90dfc | |||
9fc250956f | |||
db2dfc47a6 | |||
408a537001 | |||
922bfb33ac | |||
8e47c93fbc | |||
c175485cd8 | |||
b6981cc31d | |||
1f9cd6a99b | |||
ded7ada7d7 | |||
1b50879823 | |||
1bd9cbd4d3 | |||
96122d3be7 | |||
71d602a4cf | |||
c81bbdaaa9 | |||
2752393c42 | |||
312e064b07 | |||
94f91967f3 | |||
fe900b417e | |||
4c30b6b8a1 | |||
c41ac7b0a2 | |||
b220bd2a45 | |||
04ee94dc91 | |||
ea8f10efa4 | |||
04ecbd1a76 | |||
ddfc9d9ce1 | |||
a4735eaf76 | |||
306f492fc0 | |||
5e5f8bf33d | |||
3bb2f12cde | |||
1041bb0e6a | |||
49e93cee80 | |||
8b6681c56d | |||
9e3d432b9e | |||
841a3d5ee6 | |||
a5294d5ec7 | |||
5373e6be07 | |||
075137bd3c | |||
68da4b5b39 | |||
e4557a2e8e | |||
964bf98ca6 | |||
747f7685e7 | |||
bb82e7be50 | |||
7506f01302 | |||
a98da3bab1 | |||
f0d6128282 | |||
161e7ae7ec | |||
6104c5b5a3 | |||
af82d616c1 | |||
a0d4bff385 | |||
79236c971c | |||
20e63ae543 | |||
add7879720 | |||
1a064d38b1 | |||
294e680d5d | |||
811970e58d | |||
941961f5ef | |||
1963d8fde0 | |||
e44ed4da3b | |||
a72488d41e | |||
3930f379cf | |||
66ba327e62 | |||
329ca62465 | |||
26e47ef694 | |||
61ea149ff0 | |||
b3c3f896a3 | |||
d139e5f342 | |||
3abf36ad07 | |||
0bc9a9bdab | |||
98340522d9 | |||
6d09754ea7 | |||
a3b1d318cc | |||
f866efb622 | |||
b1c4578726 | |||
f4181a6e36 | |||
38089af098 | |||
cd135b39ad | |||
dd3207cbd8 | |||
a7abd5ff9d | |||
a3e50f6337 | |||
441a98e60a | |||
4a90ac270f | |||
a906a2988b | |||
545f68382c | |||
8249cac592 | |||
7b7bbe9105 | |||
05679c7872 | |||
8eb80be691 | |||
f55b0d0b45 | |||
754e0dbb49 | |||
525c8db779 | |||
c7f578f297 | |||
19c030281f | |||
ca9fe1b89a | |||
9fd6a695f6 | |||
c07b0ff35b | |||
00be3f0dd3 | |||
6796fca2b6 | |||
5657cce3db | |||
05ac256cc3 | |||
49977c5410 | |||
ca40bb678c | |||
2068cc9cdf | |||
ea4617cedd | |||
1a5544f68c | |||
0128a7aeb2 | |||
fd954ce708 | |||
d63a82de0a | |||
92143d523c | |||
1818e64c8e | |||
522b75645c | |||
4fba6d7c86 | |||
577a7a1c3d | |||
1fc066fc37 | |||
b565844062 | |||
5cb428e5cc | |||
d2f4a14d66 | |||
5437567e95 | |||
7d9a98ec6b | |||
92facc94b9 | |||
d3327f450c | |||
570cab9c66 | |||
582ba100b0 | |||
4c0daa462d | |||
a879104a6f |
1
.gitignore
vendored
1
.gitignore
vendored
@ -2,6 +2,7 @@ players/*
|
||||
worlds/*
|
||||
plugins/*
|
||||
bin/*
|
||||
timings/*
|
||||
*.log
|
||||
*.txt
|
||||
*.phar
|
||||
|
6
.gitmodules
vendored
6
.gitmodules
vendored
@ -9,3 +9,9 @@
|
||||
[submodule "src/spl"]
|
||||
path = src/spl
|
||||
url = https://github.com/PocketMine/PocketMine-SPL.git
|
||||
[submodule "tests/TesterPlugin"]
|
||||
path = tests/TesterPlugin
|
||||
url = https://github.com/PocketMine/TesterPlugin.git
|
||||
[submodule "src/pocketmine/lang/locale"]
|
||||
path = src/pocketmine/lang/locale
|
||||
url = https://github.com/PocketMine/PocketMine-Language.git
|
||||
|
@ -10,7 +10,7 @@ before_script:
|
||||
- mkdir plugins
|
||||
- wget -O plugins/DevTools.phar https://github.com/PocketMine/DevTools/releases/download/v1.9.0/DevTools_v1.9.0.phar
|
||||
- pecl install channel://pecl.php.net/pthreads-2.0.10
|
||||
- pecl install channel://pecl.php.net/weakref-0.2.4
|
||||
- pecl install channel://pecl.php.net/weakref-0.2.6
|
||||
- echo | pecl install channel://pecl.php.net/yaml-1.1.1
|
||||
|
||||
script:
|
||||
@ -18,4 +18,4 @@ script:
|
||||
|
||||
notifications:
|
||||
email: false
|
||||
#webhooks: http://n.tkte.ch/h/214/wsNvmG43-ncxUVRrFPwSM-r0
|
||||
#webhooks: http://n.tkte.ch/h/214/wsNvmG43-ncxUVRrFPwSM-r0
|
||||
|
@ -34,14 +34,13 @@ You must follow these guidelines if you wish to contribute to the PocketMine-MP
|
||||
It is mainly [PSR-2](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-1-basic-coding-standard.md) with a few exceptions.
|
||||
* Opening braces MUST go on the same line, and MUST NOT have spaces before.
|
||||
* `else if` MUST be written as `elseif`. _(It is in PSR-2, but using a SHOULD)_
|
||||
* Control structure keywords or opening braces MUST NOT have one space after them.
|
||||
* Control structure keywords or opening braces MUST NOT have one space before or after them.
|
||||
* Code MUST use tabs for indenting.
|
||||
* Long arrays MAY be split across multiple lines, where each subsequent line is indented once.
|
||||
* Files MUST use only the `<?php` tag.
|
||||
* Files MUST NOT have an ending `?>` tag.
|
||||
* Code MUST use namespaces.
|
||||
* Strings SHOULD use the double quote `"` except when the single quote is required.
|
||||
* Argument lists MAY NOT be split across multiple lines, except long arrays.
|
||||
|
||||
```php
|
||||
<?php
|
||||
|
@ -2,11 +2,11 @@
|
||||
|
||||
/*
|
||||
*
|
||||
* ____ _ _ __ __ _ __ __ ____
|
||||
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
|
||||
* ____ _ _ __ __ _ __ __ ____
|
||||
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
|
||||
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
|
||||
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
|
||||
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
|
||||
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
|
||||
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
@ -14,13 +14,14 @@
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* @author PocketMine Team
|
||||
|
||||
*
|
||||
* @link http://www.pocketmine.net/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
namespace pocketmine;
|
||||
|
||||
use pocketmine\event\TranslationContainer;
|
||||
use pocketmine\utils\TextFormat;
|
||||
|
||||
/**
|
||||
@ -106,10 +107,11 @@ abstract class Achievement{
|
||||
|
||||
public static function broadcast(Player $player, $achievementId){
|
||||
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){
|
||||
Server::getInstance()->broadcastMessage($player->getDisplayName() . " has just earned the achievement " . TextFormat::GREEN . Achievement::$list[$achievementId]["name"]);
|
||||
Server::getInstance()->broadcastMessage($translation);
|
||||
}else{
|
||||
$player->sendMessage("You have just earned the achievement " . TextFormat::GREEN . Achievement::$list[$achievementId]["name"]);
|
||||
$player->sendMessage($translation);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -14,7 +14,7 @@
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* @author PocketMine Team
|
||||
|
||||
* @link http://www.pocketmine.net/
|
||||
*
|
||||
*
|
||||
*/
|
||||
@ -42,7 +42,10 @@ class CrashDump{
|
||||
$this->time = time();
|
||||
$this->server = $server;
|
||||
$this->path = $this->server->getDataPath() . "CrashDump_" . date("D_M_j-H.i.s-T_Y", $this->time) . ".log";
|
||||
$this->fp = fopen($this->path, "wb");
|
||||
$this->fp = @fopen($this->path, "wb");
|
||||
if(!is_resource($this->fp)){
|
||||
throw new \RuntimeException("Could not create Crash Dump");
|
||||
}
|
||||
$this->data["time"] = $this->time;
|
||||
$this->addLine($this->server->getName() . " Crash Dump " . date("D M j H:i:s T Y", $this->time));
|
||||
$this->addLine();
|
||||
@ -137,7 +140,7 @@ class CrashDump{
|
||||
$error = $lastExceptionError;
|
||||
}else{
|
||||
$error = (array) error_get_last();
|
||||
$error["trace"] = @getTrace(4);
|
||||
$error["trace"] = @getTrace(3);
|
||||
$errorConversion = [
|
||||
E_ERROR => "E_ERROR",
|
||||
E_WARNING => "E_WARNING",
|
||||
|
422
src/pocketmine/MemoryManager.php
Normal file
422
src/pocketmine/MemoryManager.php
Normal file
@ -0,0 +1,422 @@
|
||||
<?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;
|
||||
|
||||
use pocketmine\event\server\LowMemoryEvent;
|
||||
use pocketmine\event\Timings;
|
||||
use pocketmine\scheduler\GarbageCollectionTask;
|
||||
use pocketmine\utils\Utils;
|
||||
use pocketmine\utils\UUID;
|
||||
|
||||
class MemoryManager{
|
||||
|
||||
/** @var Server */
|
||||
private $server;
|
||||
|
||||
private $memoryLimit;
|
||||
private $globalMemoryLimit;
|
||||
private $checkRate;
|
||||
private $checkTicker = 0;
|
||||
private $lowMemory = false;
|
||||
|
||||
private $continuousTrigger = true;
|
||||
private $continuousTriggerRate;
|
||||
private $continuousTriggerCount = 0;
|
||||
private $continuousTriggerTicker = 0;
|
||||
|
||||
private $garbageCollectionPeriod;
|
||||
private $garbageCollectionTicker = 0;
|
||||
private $garbageCollectionTrigger;
|
||||
private $garbageCollectionAsync;
|
||||
|
||||
private $chunkLimit;
|
||||
private $chunkCollect;
|
||||
private $chunkTrigger;
|
||||
|
||||
private $chunkCache;
|
||||
private $cacheTrigger;
|
||||
|
||||
/** @var \WeakRef[] */
|
||||
private $leakWatch = [];
|
||||
|
||||
private $leakInfo = [];
|
||||
|
||||
private $leakSeed = 0;
|
||||
|
||||
public function __construct(Server $server){
|
||||
$this->server = $server;
|
||||
|
||||
$this->init();
|
||||
}
|
||||
|
||||
private function init(){
|
||||
$this->memoryLimit = ((int) $this->server->getProperty("memory.main-limit", 0)) * 1024 * 1024;
|
||||
|
||||
$defaultMemory = 1024;
|
||||
|
||||
if(preg_match("/([0-9]+)([KMGkmg])/", $this->server->getConfigString("memory-limit", ""), $matches) > 0){
|
||||
$m = (int) $matches[1];
|
||||
if($m <= 0){
|
||||
$defaultMemory = 0;
|
||||
}else{
|
||||
switch(strtoupper($matches[2])){
|
||||
case "K":
|
||||
$defaultMemory = $m / 1024;
|
||||
break;
|
||||
case "M":
|
||||
$defaultMemory = $m;
|
||||
break;
|
||||
case "G":
|
||||
$defaultMemory = $m * 1024;
|
||||
break;
|
||||
default:
|
||||
$defaultMemory = $m;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$hardLimit = ((int) $this->server->getProperty("memory.main-hard-limit", $defaultMemory));
|
||||
|
||||
if($hardLimit <= 0){
|
||||
ini_set("memory_limit", -1);
|
||||
}else{
|
||||
ini_set("memory_limit", $hardLimit . "M");
|
||||
}
|
||||
|
||||
$this->globalMemoryLimit = ((int) $this->server->getProperty("memory.global-limit", 0)) * 1024 * 1024;
|
||||
$this->checkRate = (int) $this->server->getProperty("memory.check-rate", 20);
|
||||
$this->continuousTrigger = (bool) $this->server->getProperty("memory.continuous-trigger", true);
|
||||
$this->continuousTriggerRate = (int) $this->server->getProperty("memory.continuous-trigger-rate", 30);
|
||||
|
||||
$this->garbageCollectionPeriod = (int) $this->server->getProperty("memory.garbage-collection.period", 36000);
|
||||
$this->garbageCollectionTrigger = (bool) $this->server->getProperty("memory.garbage-collection.low-memory-trigger", true);
|
||||
$this->garbageCollectionAsync = (bool) $this->server->getProperty("memory.garbage-collection.collect-async-worker", true);
|
||||
|
||||
$this->chunkLimit = (int) $this->server->getProperty("memory.max-chunks.trigger-limit", 96);
|
||||
$this->chunkCollect = (bool) $this->server->getProperty("memory.max-chunks.trigger-chunk-collect", true);
|
||||
$this->chunkTrigger = (bool) $this->server->getProperty("memory.max-chunks.low-memory-trigger", true);
|
||||
|
||||
$this->chunkCache = (bool) $this->server->getProperty("memory.world-caches.disable-chunk-cache", true);
|
||||
$this->cacheTrigger = (bool) $this->server->getProperty("memory.world-caches.low-memory-trigger", true);
|
||||
|
||||
gc_enable();
|
||||
}
|
||||
|
||||
public function isLowMemory(){
|
||||
return $this->lowMemory;
|
||||
}
|
||||
|
||||
public function canUseChunkCache(){
|
||||
return !($this->lowMemory and $this->chunkTrigger);
|
||||
}
|
||||
|
||||
public function getViewDistance($distance){
|
||||
return $this->lowMemory ? min($this->chunkLimit, $distance) : $distance;
|
||||
}
|
||||
|
||||
public function trigger($memory, $limit, $global = false, $triggerCount = 0){
|
||||
$this->server->getLogger()->debug("[Memory Manager] ".($global ? "Global " : "") ."Low memory triggered, limit ". round(($limit / 1024) / 1024, 2)."MB, using ". round(($memory / 1024) / 1024, 2)."MB");
|
||||
|
||||
if($this->cacheTrigger){
|
||||
foreach($this->server->getLevels() as $level){
|
||||
$level->clearCache(true);
|
||||
}
|
||||
}
|
||||
|
||||
if($this->chunkTrigger and $this->chunkCollect){
|
||||
foreach($this->server->getLevels() as $level){
|
||||
$level->doChunkGarbageCollection();
|
||||
}
|
||||
}
|
||||
|
||||
$ev = new LowMemoryEvent($memory, $limit, $global, $triggerCount);
|
||||
$this->server->getPluginManager()->callEvent($ev);
|
||||
|
||||
$cycles = 0;
|
||||
if($this->garbageCollectionTrigger){
|
||||
$cycles = $this->triggerGarbageCollector();
|
||||
}
|
||||
|
||||
$this->server->getLogger()->debug("[Memory Manager] Freed " . round(($ev->getMemoryFreed() / 1024) / 1024, 2)."MB, $cycles cycles");
|
||||
}
|
||||
|
||||
public function check(){
|
||||
Timings::$memoryManagerTimer->startTiming();
|
||||
|
||||
if(($this->memoryLimit > 0 or $this->globalMemoryLimit > 0) and ++$this->checkTicker >= $this->checkRate){
|
||||
$this->checkTicker = 0;
|
||||
$memory = Utils::getMemoryUsage(true);
|
||||
$trigger = false;
|
||||
if($this->memoryLimit > 0 and $memory[0] > $this->memoryLimit){
|
||||
$trigger = 0;
|
||||
}elseif($this->globalMemoryLimit > 0 and $memory[1] > $this->globalMemoryLimit){
|
||||
$trigger = 1;
|
||||
}
|
||||
|
||||
if($trigger !== false){
|
||||
if($this->lowMemory and $this->continuousTrigger){
|
||||
if(++$this->continuousTriggerTicker >= $this->continuousTriggerRate){
|
||||
$this->continuousTriggerTicker = 0;
|
||||
$this->trigger($memory[$trigger], $this->memoryLimit, $trigger > 0, ++$this->continuousTriggerCount);
|
||||
}
|
||||
}else{
|
||||
$this->lowMemory = true;
|
||||
$this->continuousTriggerCount = 0;
|
||||
$this->trigger($memory[$trigger], $this->memoryLimit, $trigger > 0);
|
||||
}
|
||||
}else{
|
||||
$this->lowMemory = false;
|
||||
}
|
||||
}
|
||||
|
||||
if($this->garbageCollectionPeriod > 0 and ++$this->garbageCollectionTicker >= $this->garbageCollectionPeriod){
|
||||
$this->garbageCollectionTicker = 0;
|
||||
$this->triggerGarbageCollector();
|
||||
}
|
||||
|
||||
Timings::$memoryManagerTimer->stopTiming();
|
||||
}
|
||||
|
||||
public function triggerGarbageCollector(){
|
||||
Timings::$garbageCollectorTimer->startTiming();
|
||||
|
||||
if($this->garbageCollectionAsync){
|
||||
$size = $this->server->getScheduler()->getAsyncTaskPoolSize();
|
||||
for($i = 0; $i < $size; ++$i){
|
||||
$this->server->getScheduler()->scheduleAsyncTaskToWorker(new GarbageCollectionTask(), $i);
|
||||
}
|
||||
}
|
||||
|
||||
$cycles = gc_collect_cycles();
|
||||
|
||||
Timings::$garbageCollectorTimer->stopTiming();
|
||||
|
||||
return $cycles;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param object $object
|
||||
*
|
||||
* @return string Object identifier for future checks
|
||||
*/
|
||||
public function addObjectWatcher($object){
|
||||
if(!is_object($object)){
|
||||
throw new \InvalidArgumentException("Not an object!");
|
||||
}
|
||||
|
||||
|
||||
$identifier = spl_object_hash($object) . ":" . get_class($object);
|
||||
|
||||
if(isset($this->leakInfo[$identifier])){
|
||||
return $this->leakInfo["id"];
|
||||
}
|
||||
|
||||
$this->leakInfo[$identifier] = [
|
||||
"id" => $id = md5($identifier . ":" . $this->leakSeed++),
|
||||
"class" => get_class($object),
|
||||
"hash" => $identifier
|
||||
];
|
||||
$this->leakInfo[$id] = $this->leakInfo[$identifier];
|
||||
|
||||
$this->leakWatch[$id] = new \WeakRef($object);
|
||||
|
||||
return $id;
|
||||
}
|
||||
|
||||
public function isObjectAlive($id){
|
||||
if(isset($this->leakWatch[$id])){
|
||||
return $this->leakWatch[$id]->valid();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public function removeObjectWatch($id){
|
||||
if(!isset($this->leakWatch[$id])){
|
||||
return;
|
||||
}
|
||||
unset($this->leakInfo[$this->leakInfo[$id]["hash"]]);
|
||||
unset($this->leakInfo[$id]);
|
||||
unset($this->leakWatch[$id]);
|
||||
}
|
||||
|
||||
public function doObjectCleanup(){
|
||||
foreach($this->leakWatch as $id => $w){
|
||||
if(!$w->valid()){
|
||||
$this->removeObjectWatch($id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function getObjectInformation($id, $includeObject = false){
|
||||
if(!isset($this->leakWatch[$id])){
|
||||
return null;
|
||||
}
|
||||
|
||||
$valid = false;
|
||||
$references = 0;
|
||||
$object = null;
|
||||
|
||||
if($this->leakWatch[$id]->acquire()){
|
||||
$object = $this->leakWatch[$id]->get();
|
||||
$this->leakWatch[$id]->release();
|
||||
|
||||
$valid = true;
|
||||
$references = getReferenceCount($object, false);
|
||||
}
|
||||
|
||||
return [
|
||||
"id" => $id,
|
||||
"class" => $this->leakInfo[$id]["class"],
|
||||
"hash" => $this->leakInfo[$id]["hash"],
|
||||
"valid" => $valid,
|
||||
"references" => $references,
|
||||
"object" => $includeObject ? $object : null
|
||||
];
|
||||
}
|
||||
|
||||
public function dumpServerMemory($outputFolder, $maxNesting, $maxStringSize){
|
||||
gc_disable();
|
||||
|
||||
if(!file_exists($outputFolder)){
|
||||
mkdir($outputFolder, 0777, true);
|
||||
}
|
||||
|
||||
$this->server->getLogger()->notice("[Dump] After the memory dump is done, the server might crash");
|
||||
|
||||
$obData = fopen($outputFolder . "/objects.js", "wb+");
|
||||
|
||||
$staticProperties = [];
|
||||
|
||||
$data = [];
|
||||
|
||||
$objects = [];
|
||||
|
||||
$refCounts = [];
|
||||
|
||||
$this->continueDump($this->server, $data, $objects, $refCounts, 0, $maxNesting, $maxStringSize);
|
||||
|
||||
do{
|
||||
$continue = false;
|
||||
foreach($objects as $hash => $object){
|
||||
if(!is_object($object)){
|
||||
continue;
|
||||
}
|
||||
$continue = true;
|
||||
|
||||
$className = get_class($object);
|
||||
|
||||
$objects[$hash] = true;
|
||||
|
||||
$reflection = new \ReflectionObject($object);
|
||||
|
||||
$info = [
|
||||
"information" => "$hash@$className",
|
||||
"properties" => []
|
||||
];
|
||||
|
||||
if($reflection->getParentClass()){
|
||||
$info["parent"] = $reflection->getParentClass()->getName();
|
||||
}
|
||||
|
||||
if(count($reflection->getInterfaceNames()) > 0){
|
||||
$info["implements"] = implode(", ", $reflection->getInterfaceNames());
|
||||
}
|
||||
|
||||
foreach($reflection->getProperties() as $property){
|
||||
if($property->isStatic()){
|
||||
continue;
|
||||
}
|
||||
|
||||
if(!$property->isPublic()){
|
||||
$property->setAccessible(true);
|
||||
}
|
||||
$this->continueDump($property->getValue($object), $info["properties"][$property->getName()], $objects, $refCounts, 0, $maxNesting, $maxStringSize);
|
||||
}
|
||||
|
||||
fwrite($obData, "$hash@$className: ". json_encode($info, JSON_UNESCAPED_SLASHES) . "\n");
|
||||
|
||||
if(!isset($objects["staticProperties"][$className])){
|
||||
$staticProperties[$className] = [];
|
||||
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);
|
||||
|
||||
file_put_contents($outputFolder . "/staticProperties.js", json_encode($staticProperties, JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT));
|
||||
file_put_contents($outputFolder . "/serverEntry.js", json_encode($data, JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT));
|
||||
file_put_contents($outputFolder . "/referenceCounts.js", json_encode($refCounts, JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT));
|
||||
|
||||
echo "[Dump] Finished!\n";
|
||||
|
||||
gc_enable();
|
||||
|
||||
$this->server->forceShutdown();
|
||||
}
|
||||
|
||||
private function continueDump($from, &$data, &$objects, &$refCounts, $recursion, $maxNesting, $maxStringSize){
|
||||
if($maxNesting <= 0){
|
||||
$data = "(error) NESTING LIMIT REACHED";
|
||||
return;
|
||||
}
|
||||
|
||||
--$maxNesting;
|
||||
|
||||
if(is_object($from)){
|
||||
if(!isset($objects[$hash = spl_object_hash($from)])){
|
||||
$objects[$hash] = $from;
|
||||
$refCounts[$hash] = 0;
|
||||
}
|
||||
|
||||
++$refCounts[$hash];
|
||||
|
||||
$data = "(object) $hash@" . get_class($from);
|
||||
}elseif(is_array($from)){
|
||||
if($recursion >= 5){
|
||||
$data = "(error) ARRAY RECURSION LIMIT REACHED";
|
||||
return;
|
||||
}
|
||||
$data = [];
|
||||
foreach($from as $key => $value){
|
||||
$this->continueDump($value, $data[$key], $objects, $refCounts, $recursion + 1, $maxNesting, $maxStringSize);
|
||||
}
|
||||
}elseif(is_string($from)){
|
||||
$data = "(string) len(".strlen($from).") " . substr(Utils::printable($from), 0, $maxStringSize);
|
||||
}elseif(is_resource($from)){
|
||||
$data = "(resource) " . print_r($from, true);
|
||||
}else{
|
||||
$data = $from;
|
||||
}
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@ -34,7 +34,7 @@ namespace {
|
||||
}
|
||||
echo str_repeat(" ", $cnt) . "}" . PHP_EOL;
|
||||
break;
|
||||
case is_integer($var):
|
||||
case is_int($var):
|
||||
echo str_repeat(" ", $cnt) . "int(" . $var . ")" . PHP_EOL;
|
||||
break;
|
||||
case is_float($var):
|
||||
@ -67,13 +67,16 @@ namespace {
|
||||
namespace pocketmine {
|
||||
use pocketmine\utils\Binary;
|
||||
use pocketmine\utils\MainLogger;
|
||||
use pocketmine\utils\ServerKiller;
|
||||
use pocketmine\utils\Terminal;
|
||||
use pocketmine\utils\Utils;
|
||||
use pocketmine\wizard\Installer;
|
||||
|
||||
const VERSION = "Alpha_1.4dev";
|
||||
const API_VERSION = "1.7.0";
|
||||
const CODENAME = "絶好(Zekkou)ケーキ(Cake)";
|
||||
const MINECRAFT_VERSION = "v0.9.5 alpha";
|
||||
const VERSION = "1.5dev";
|
||||
const API_VERSION = "1.12.0";
|
||||
const CODENAME = "活発(Kappatsu)フグ(Fugu)";
|
||||
const MINECRAFT_VERSION = "v0.11.0 alpha";
|
||||
const MINECRAFT_VERSION_NETWORK = "0.11.0";
|
||||
|
||||
/*
|
||||
* Startup code. Do not look at it, it may harm you.
|
||||
@ -95,6 +98,7 @@ namespace pocketmine {
|
||||
}
|
||||
|
||||
if(!class_exists("ClassLoader", false)){
|
||||
require_once(\pocketmine\PATH . "src/spl/ThreadedFactory.php");
|
||||
require_once(\pocketmine\PATH . "src/spl/ClassLoader.php");
|
||||
require_once(\pocketmine\PATH . "src/spl/BaseClassLoader.php");
|
||||
require_once(\pocketmine\PATH . "src/pocketmine/CompatibleClassLoader.php");
|
||||
@ -103,7 +107,6 @@ namespace pocketmine {
|
||||
$autoloader = new CompatibleClassLoader();
|
||||
$autoloader->addPath(\pocketmine\PATH . "src");
|
||||
$autoloader->addPath(\pocketmine\PATH . "src" . DIRECTORY_SEPARATOR . "spl");
|
||||
$autoloader->addPath(\pocketmine\PATH . "src" . DIRECTORY_SEPARATOR . "raklib");
|
||||
$autoloader->register(true);
|
||||
|
||||
|
||||
@ -116,18 +119,21 @@ namespace pocketmine {
|
||||
ini_set("display_startup_errors", 1);
|
||||
ini_set("default_charset", "utf-8");
|
||||
|
||||
ini_set("memory_limit", "256M"); //Default
|
||||
ini_set("memory_limit", -1);
|
||||
define("pocketmine\\START_TIME", microtime(true));
|
||||
|
||||
$opts = getopt("", ["enable-ansi", "disable-ansi", "data:", "plugins:", "no-wizard", "enable-profiler"]);
|
||||
$opts = getopt("", ["data:", "plugins:", "no-wizard", "enable-profiler"]);
|
||||
|
||||
define("pocketmine\\DATA", isset($opts["data"]) ? $opts["data"] . DIRECTORY_SEPARATOR : \getcwd() . DIRECTORY_SEPARATOR);
|
||||
define("pocketmine\\PLUGIN_PATH", isset($opts["plugins"]) ? $opts["plugins"] . DIRECTORY_SEPARATOR : \getcwd() . DIRECTORY_SEPARATOR . "plugins" . DIRECTORY_SEPARATOR);
|
||||
|
||||
define("pocketmine\\ANSI", (Utils::getOS() !== "win" or isset($opts["enable-ansi"])) and !isset($opts["disable-ansi"]));
|
||||
Terminal::init();
|
||||
|
||||
define("pocketmine\\ANSI", Terminal::hasFormattingCodes());
|
||||
|
||||
@mkdir(\pocketmine\DATA, 0777, true);
|
||||
if(!file_exists(\pocketmine\DATA)){
|
||||
mkdir(\pocketmine\DATA, 0777, true);
|
||||
}
|
||||
|
||||
//Logger has a dependency on timezone, so we'll set it to UTC until we can get the actual timezone.
|
||||
date_default_timezone_set("UTC");
|
||||
@ -136,15 +142,15 @@ namespace pocketmine {
|
||||
if(!ini_get("date.timezone")){
|
||||
if(($timezone = detect_system_timezone()) and date_default_timezone_set($timezone)){
|
||||
//Success! Timezone has already been set and validated in the if statement.
|
||||
//This here is just for redundancy just in case some stupid program wants to read timezone data from the ini.
|
||||
//This here is just for redundancy just in case some program wants to read timezone data from the ini.
|
||||
ini_set("date.timezone", $timezone);
|
||||
}else{
|
||||
//If system timezone detection fails or timezone is an invalid value.
|
||||
if($response = Utils::getURL("http://ip-api.com/json")
|
||||
and $ip_geolocation_data = json_decode($response, true)
|
||||
and $ip_geolocation_data['status'] != 'fail'
|
||||
and date_default_timezone_set($ip_geolocation_data['timezone']))
|
||||
{
|
||||
and date_default_timezone_set($ip_geolocation_data['timezone'])
|
||||
){
|
||||
//Again, for redundancy.
|
||||
ini_set("date.timezone", $ip_geolocation_data['timezone']);
|
||||
}else{
|
||||
@ -155,7 +161,8 @@ namespace pocketmine {
|
||||
}
|
||||
}else{
|
||||
/*
|
||||
* This is here so that stupid idiots don't come to us complaining and fill up the issue tracker when they put an incorrect timezone abbreviation in php.ini apparently.
|
||||
* This is here so that people don't come to us complaining and fill up the issue tracker when they put
|
||||
* an incorrect timezone abbreviation in php.ini apparently.
|
||||
*/
|
||||
$default_timezone = date_default_timezone_get();
|
||||
if(strpos($default_timezone, "/") === false){
|
||||
@ -168,17 +175,30 @@ namespace pocketmine {
|
||||
function detect_system_timezone(){
|
||||
switch(Utils::getOS()){
|
||||
case 'win':
|
||||
$regex = '/(?:Time Zone:\s*\()(UTC)(\+*\-*\d*\d*\:*\d*\d*)(?:\))/';
|
||||
$regex = '/(UTC)(\+*\-*\d*\d*\:*\d*\d*)/';
|
||||
|
||||
exec("systeminfo", $output);
|
||||
/*
|
||||
* wmic timezone get Caption
|
||||
* Get the timezone offset
|
||||
*
|
||||
* Sample Output var_dump
|
||||
* array(3) {
|
||||
* [0] =>
|
||||
* string(7) "Caption"
|
||||
* [1] =>
|
||||
* string(20) "(UTC+09:30) Adelaide"
|
||||
* [2] =>
|
||||
* string(0) ""
|
||||
* }
|
||||
*/
|
||||
exec("wmic timezone get Caption", $output);
|
||||
|
||||
$string = trim(implode("\n", $output));
|
||||
|
||||
//Detect the Time Zone string in systeminfo
|
||||
//Detect the Time Zone string
|
||||
preg_match($regex, $string, $matches);
|
||||
|
||||
if(!isset($matches[2]))
|
||||
{
|
||||
if(!isset($matches[2])){
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -236,6 +256,7 @@ namespace pocketmine {
|
||||
|
||||
/**
|
||||
* @param string $offset In the format of +09:00, +02:00, -04:00 etc.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function parse_offset($offset){
|
||||
@ -295,6 +316,24 @@ namespace pocketmine {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param object $value
|
||||
* @param bool $includeCurrent
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
function getReferenceCount($value, $includeCurrent = true){
|
||||
ob_start();
|
||||
debug_zval_dump($value);
|
||||
$ret = explode("\n", ob_get_contents());
|
||||
ob_end_clean();
|
||||
|
||||
if(count($ret) >= 1 and preg_match('/^.* refcount\\(([0-9]+)\\)\\{$/', trim($ret[0]), $m) > 0){
|
||||
return ((int) $m[1]) - ($includeCurrent ? 3 : 4); //$value + zval call + extra call
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
function getTrace($start = 1, $trace = null){
|
||||
if($trace === null){
|
||||
if(function_exists("xdebug_get_function_stack")){
|
||||
@ -316,10 +355,10 @@ namespace pocketmine {
|
||||
$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) . " " . @strval($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)))) . ", ";
|
||||
}
|
||||
}
|
||||
$messages[] = "#$j " . (isset($trace[$i]["file"]) ? cleanPath($trace[$i]["file"]) : "") . "(" . (isset($trace[$i]["line"]) ? $trace[$i]["line"] : "") . "): " . (isset($trace[$i]["class"]) ? $trace[$i]["class"] . (($trace[$i]["type"] === "dynamic" or $trace[$i]["type"] === "->") ? "->" : "::") : "") . $trace[$i]["function"] . "(" . substr($params, 0, -2) . ")";
|
||||
$messages[] = "#$j " . (isset($trace[$i]["file"]) ? cleanPath($trace[$i]["file"]) : "") . "(" . (isset($trace[$i]["line"]) ? $trace[$i]["line"] : "") . "): " . (isset($trace[$i]["class"]) ? $trace[$i]["class"] . (($trace[$i]["type"] === "dynamic" or $trace[$i]["type"] === "->") ? "->" : "::") : "") . $trace[$i]["function"] . "(" . Utils::printable(substr($params, 0, -2)) . ")";
|
||||
}
|
||||
|
||||
return $messages;
|
||||
@ -352,8 +391,8 @@ namespace pocketmine {
|
||||
if(substr_count($pthreads_version, ".") < 2){
|
||||
$pthreads_version = "0.$pthreads_version";
|
||||
}
|
||||
if(version_compare($pthreads_version, "2.0.8") < 0){
|
||||
$logger->critical("pthreads >= 2.0.8 is required, while you have $pthreads_version.");
|
||||
if(version_compare($pthreads_version, "2.0.9") < 0){
|
||||
$logger->critical("pthreads >= 2.0.9 is required, while you have $pthreads_version.");
|
||||
++$errors;
|
||||
}
|
||||
|
||||
@ -417,7 +456,7 @@ namespace pocketmine {
|
||||
new Installer();
|
||||
}
|
||||
|
||||
if(substr(__FILE__, 0, 7) !== "phar://"){
|
||||
if(\Phar::running(true) === ""){
|
||||
$logger->warning("Non-packaged PocketMine-MP installation detected, do not use on production.");
|
||||
}
|
||||
|
||||
@ -427,30 +466,19 @@ namespace pocketmine {
|
||||
$logger->info("Stopping other threads");
|
||||
|
||||
foreach(ThreadManager::getInstance()->getAll() as $id => $thread){
|
||||
if($thread->isRunning()){
|
||||
$logger->debug("Stopping " . (new \ReflectionClass($thread))->getShortName() . " thread");
|
||||
if($thread instanceof Thread){
|
||||
$thread->kill();
|
||||
sleep(1);
|
||||
if($thread->isRunning()){
|
||||
$thread->detach();
|
||||
}
|
||||
}elseif($thread instanceof Worker){
|
||||
$thread->kill();
|
||||
sleep(1);
|
||||
if($thread->isRunning()){
|
||||
$thread->detach();
|
||||
}
|
||||
}
|
||||
}elseif(!$thread->isJoined()){
|
||||
$logger->debug("Joining " . (new \ReflectionClass($thread))->getShortName() . " thread");
|
||||
$thread->join();
|
||||
}
|
||||
$logger->debug("Stopping " . (new \ReflectionClass($thread))->getShortName() . " thread");
|
||||
$thread->quit();
|
||||
}
|
||||
|
||||
$killer = new ServerKiller(8);
|
||||
$killer->start();
|
||||
$killer->detach();
|
||||
|
||||
$logger->shutdown();
|
||||
$logger->join();
|
||||
|
||||
echo Terminal::$FORMAT_RESET . "\n";
|
||||
|
||||
exit(0);
|
||||
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -26,9 +26,66 @@ namespace pocketmine;
|
||||
*/
|
||||
abstract class Thread extends \Thread{
|
||||
|
||||
public final function start($options = PTHREADS_INHERIT_ALL){
|
||||
/** @var \ClassLoader */
|
||||
protected $classLoader;
|
||||
|
||||
public function getClassLoader(){
|
||||
return $this->classLoader;
|
||||
}
|
||||
|
||||
public function setClassLoader(\ClassLoader $loader = null){
|
||||
if($loader === null){
|
||||
$loader = Server::getInstance()->getLoader();
|
||||
}
|
||||
$this->classLoader = $loader;
|
||||
}
|
||||
|
||||
public function registerClassLoader(){
|
||||
if(!interface_exists("ClassLoader", false)){
|
||||
require(\pocketmine\PATH . "src/spl/ClassLoader.php");
|
||||
require(\pocketmine\PATH . "src/spl/BaseClassLoader.php");
|
||||
require(\pocketmine\PATH . "src/pocketmine/CompatibleClassLoader.php");
|
||||
}
|
||||
if($this->classLoader !== null){
|
||||
$this->classLoader->register(true);
|
||||
}
|
||||
}
|
||||
|
||||
public function start($options = PTHREADS_INHERIT_ALL){
|
||||
ThreadManager::getInstance()->add($this);
|
||||
|
||||
return parent::start($options);
|
||||
if(!$this->isRunning() and !$this->isJoined() and !$this->isTerminated()){
|
||||
if($this->getClassLoader() === null){
|
||||
$this->setClassLoader();
|
||||
}
|
||||
return parent::start($options);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Stops the thread using the best way possible. Try to stop it yourself before calling this.
|
||||
*/
|
||||
public function quit(){
|
||||
if($this->isRunning()){
|
||||
$this->kill();
|
||||
$this->detach();
|
||||
}elseif(!$this->isJoined()){
|
||||
if(!$this->isTerminated()){
|
||||
$this->join();
|
||||
}else{
|
||||
$this->kill();
|
||||
$this->detach();
|
||||
}
|
||||
}else{
|
||||
$this->detach();
|
||||
}
|
||||
|
||||
ThreadManager::getInstance()->remove($this);
|
||||
}
|
||||
|
||||
public function getThreadName(){
|
||||
return (new \ReflectionClass($this))->getShortName();
|
||||
}
|
||||
}
|
@ -26,9 +26,67 @@ namespace pocketmine;
|
||||
*/
|
||||
abstract class Worker extends \Worker{
|
||||
|
||||
public final function start($options = PTHREADS_INHERIT_ALL){
|
||||
/** @var \ClassLoader */
|
||||
protected $classLoader;
|
||||
|
||||
public function getClassLoader(){
|
||||
return $this->classLoader;
|
||||
}
|
||||
|
||||
public function setClassLoader(\ClassLoader $loader = null){
|
||||
if($loader === null){
|
||||
$loader = Server::getInstance()->getLoader();
|
||||
}
|
||||
$this->classLoader = $loader;
|
||||
}
|
||||
|
||||
public function registerClassLoader(){
|
||||
if(!interface_exists("ClassLoader", false)){
|
||||
require(\pocketmine\PATH . "src/spl/ClassLoader.php");
|
||||
require(\pocketmine\PATH . "src/spl/BaseClassLoader.php");
|
||||
require(\pocketmine\PATH . "src/pocketmine/CompatibleClassLoader.php");
|
||||
}
|
||||
if($this->classLoader !== null){
|
||||
$this->classLoader->register(true);
|
||||
}
|
||||
}
|
||||
|
||||
public function start($options = PTHREADS_INHERIT_ALL){
|
||||
ThreadManager::getInstance()->add($this);
|
||||
|
||||
return parent::start($options);
|
||||
if(!$this->isRunning() and !$this->isJoined() and !$this->isTerminated()){
|
||||
if($this->getClassLoader() === null){
|
||||
$this->setClassLoader();
|
||||
}
|
||||
return parent::start($options);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Stops the thread using the best way possible. Try to stop it yourself before calling this.
|
||||
*/
|
||||
public function quit(){
|
||||
if($this->isRunning()){
|
||||
$this->unstack();
|
||||
$this->kill();
|
||||
$this->detach();
|
||||
}elseif(!$this->isJoined()){
|
||||
if(!$this->isTerminated()){
|
||||
$this->join();
|
||||
}else{
|
||||
$this->kill();
|
||||
$this->detach();
|
||||
}
|
||||
}else{
|
||||
$this->detach();
|
||||
}
|
||||
|
||||
ThreadManager::getInstance()->remove($this);
|
||||
}
|
||||
|
||||
public function getThreadName(){
|
||||
return (new \ReflectionClass($this))->getShortName();
|
||||
}
|
||||
}
|
@ -22,10 +22,18 @@
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\item\Tool;
|
||||
|
||||
class AcaciaWoodStairs extends Stair{
|
||||
|
||||
protected $id = self::ACACIA_WOOD_STAIRS;
|
||||
|
||||
public function __construct($meta = 0){
|
||||
parent::__construct(self::ACACIA_WOOD_STAIRS, $meta, "Acacia Wood Stairs");
|
||||
$this->meta = $meta;
|
||||
}
|
||||
|
||||
public function getName(){
|
||||
return "Acacia Wood Stairs";
|
||||
}
|
||||
|
||||
public function getDrops(Item $item){
|
||||
@ -33,4 +41,16 @@ class AcaciaWoodStairs extends Stair{
|
||||
[$this->id, 0, 1],
|
||||
];
|
||||
}
|
||||
|
||||
public function getHardness(){
|
||||
return 2;
|
||||
}
|
||||
|
||||
public function getResistance(){
|
||||
return 15;
|
||||
}
|
||||
|
||||
public function getToolType(){
|
||||
return Tool::TYPE_AXE;
|
||||
}
|
||||
}
|
@ -21,31 +21,59 @@
|
||||
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\item\Item;
|
||||
|
||||
|
||||
/**
|
||||
* Air block
|
||||
*/
|
||||
class Air extends Transparent{
|
||||
public $isActivable = false;
|
||||
public $breakable = false;
|
||||
public $isFlowable = true;
|
||||
public $isTransparent = true;
|
||||
public $isReplaceable = true;
|
||||
public $isPlaceable = false;
|
||||
public $hasPhysics = false;
|
||||
public $isSolid = false;
|
||||
public $isFullBlock = true;
|
||||
|
||||
protected $id = self::AIR;
|
||||
protected $meta = 0;
|
||||
protected $name = "Air";
|
||||
protected $hardness = 0;
|
||||
|
||||
public function __construct(){
|
||||
|
||||
}
|
||||
|
||||
public function getName(){
|
||||
return "Air";
|
||||
}
|
||||
|
||||
public function canPassThrough(){
|
||||
return true;
|
||||
}
|
||||
|
||||
public function isBreakable(Item $item){
|
||||
return false;
|
||||
}
|
||||
|
||||
public function canBeFlowedInto(){
|
||||
return true;
|
||||
}
|
||||
|
||||
public function canBeReplaced(){
|
||||
return true;
|
||||
}
|
||||
|
||||
public function canBePlaced(){
|
||||
return false;
|
||||
}
|
||||
|
||||
public function isSolid(){
|
||||
return false;
|
||||
}
|
||||
|
||||
public function getBoundingBox(){
|
||||
return null;
|
||||
}
|
||||
|
||||
public function getHardness(){
|
||||
return -1;
|
||||
}
|
||||
|
||||
public function getResistance(){
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
@ -24,15 +24,27 @@ namespace pocketmine\block;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\level\Level;
|
||||
use pocketmine\math\AxisAlignedBB;
|
||||
use pocketmine\network\protocol\ChatPacket;
|
||||
use pocketmine\Player;
|
||||
use pocketmine\utils\TextFormat;
|
||||
|
||||
class Bed extends Transparent{
|
||||
public function __construct($type = 0){
|
||||
parent::__construct(self::BED_BLOCK, $type, "Bed Block");
|
||||
$this->isActivable = true;
|
||||
$this->isFullBlock = false;
|
||||
$this->hardness = 1;
|
||||
|
||||
protected $id = self::BED_BLOCK;
|
||||
|
||||
public function __construct($meta = 0){
|
||||
$this->meta = $meta;
|
||||
}
|
||||
|
||||
public function canBeActivated(){
|
||||
return true;
|
||||
}
|
||||
|
||||
public function getHardness(){
|
||||
return 0.2;
|
||||
}
|
||||
|
||||
public function getName(){
|
||||
return "Bed Block";
|
||||
}
|
||||
|
||||
protected function recalculateBoundingBox(){
|
||||
@ -53,10 +65,7 @@ class Bed extends Transparent{
|
||||
$isNight = ($time >= Level::TIME_NIGHT and $time < Level::TIME_SUNRISE);
|
||||
|
||||
if($player instanceof Player and !$isNight){
|
||||
$pk = new ChatPacket();
|
||||
$pk->message = "You can only sleep at night";
|
||||
$player->dataPacket($pk);
|
||||
|
||||
$player->sendMessage(TextFormat::GRAY . "You can only sleep at night");
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -67,19 +76,17 @@ class Bed extends Transparent{
|
||||
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){
|
||||
if($blockNorth->getId() === $this->id and ($blockNorth->meta & 0x08) === 0x08){
|
||||
$b = $blockNorth;
|
||||
}elseif($blockSouth->getID() === $this->id and ($blockSouth->meta & 0x08) === 0x08){
|
||||
}elseif($blockSouth->getId() === $this->id and ($blockSouth->meta & 0x08) === 0x08){
|
||||
$b = $blockSouth;
|
||||
}elseif($blockEast->getID() === $this->id and ($blockEast->meta & 0x08) === 0x08){
|
||||
}elseif($blockEast->getId() === $this->id and ($blockEast->meta & 0x08) === 0x08){
|
||||
$b = $blockEast;
|
||||
}elseif($blockWest->getID() === $this->id and ($blockWest->meta & 0x08) === 0x08){
|
||||
}elseif($blockWest->getId() === $this->id and ($blockWest->meta & 0x08) === 0x08){
|
||||
$b = $blockWest;
|
||||
}else{
|
||||
if($player instanceof Player){
|
||||
$pk = new ChatPacket();
|
||||
$pk->message = "This bed is incomplete";
|
||||
$player->dataPacket($pk);
|
||||
$player->sendMessage(TextFormat::GRAY . "This bed is incomplete");
|
||||
}
|
||||
|
||||
return true;
|
||||
@ -87,9 +94,7 @@ class Bed extends Transparent{
|
||||
}
|
||||
|
||||
if($player instanceof Player and $player->sleepOn($b) === false){
|
||||
$pk = new ChatPacket();
|
||||
$pk->message = "This bed is occupied";
|
||||
$player->dataPacket($pk);
|
||||
$player->sendMessage(TextFormat::GRAY . "This bed is occupied");
|
||||
}
|
||||
|
||||
return true;
|
||||
@ -97,7 +102,7 @@ class Bed extends Transparent{
|
||||
|
||||
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){
|
||||
$down = $this->getSide(0);
|
||||
if($down->isTransparent === false){
|
||||
if($down->isTransparent() === false){
|
||||
$faces = [
|
||||
0 => 3,
|
||||
1 => 4,
|
||||
@ -107,7 +112,7 @@ class Bed extends Transparent{
|
||||
$d = $player instanceof Player ? $player->getDirection() : 0;
|
||||
$next = $this->getSide($faces[(($d + 3) % 4)]);
|
||||
$downNext = $this->getSide(0);
|
||||
if($next->isReplaceable === true and $downNext->isTransparent === false){
|
||||
if($next->canBeReplaced() === true and $downNext->isTransparent() === false){
|
||||
$meta = (($d + 3) % 4) & 0x03;
|
||||
$this->getLevel()->setBlock($block, Block::get($this->id, $meta), true, true);
|
||||
$this->getLevel()->setBlock($next, Block::get($this->id, $meta | 0x08), true, true);
|
||||
@ -126,23 +131,23 @@ class Bed extends Transparent{
|
||||
$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
|
||||
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){
|
||||
}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){
|
||||
}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){
|
||||
}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){
|
||||
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){
|
||||
}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){
|
||||
}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){
|
||||
}elseif($blockWest->getId() === $this->id and ($blockWest->meta & 0x08) === 0x08){
|
||||
$this->getLevel()->setBlock($blockWest, new Air(), true, true);
|
||||
}
|
||||
}
|
||||
|
@ -24,10 +24,23 @@ namespace pocketmine\block;
|
||||
use pocketmine\item\Item;
|
||||
|
||||
class Bedrock extends Solid{
|
||||
|
||||
protected $id = self::BEDROCK;
|
||||
|
||||
public function __construct(){
|
||||
parent::__construct(self::BEDROCK, 0, "Bedrock");
|
||||
$this->breakable = false;
|
||||
$this->hardness = 18000000;
|
||||
|
||||
}
|
||||
|
||||
public function getName(){
|
||||
return "Bedrock";
|
||||
}
|
||||
|
||||
public function getHardness(){
|
||||
return -1;
|
||||
}
|
||||
|
||||
public function getResistance(){
|
||||
return 18000000;
|
||||
}
|
||||
|
||||
public function isBreakable(Item $item){
|
||||
|
@ -24,8 +24,15 @@ namespace pocketmine\block;
|
||||
use pocketmine\item\Item;
|
||||
|
||||
class Beetroot extends Crops{
|
||||
|
||||
protected $id = self::BEETROOT_BLOCK;
|
||||
|
||||
public function __construct($meta = 0){
|
||||
parent::__construct(self::BEETROOT_BLOCK, $meta, "Beetroot Block");
|
||||
$this->meta = $meta;
|
||||
}
|
||||
|
||||
public function getName(){
|
||||
return "Beetroot Block";
|
||||
}
|
||||
|
||||
public function getDrops(Item $item){
|
||||
|
@ -22,10 +22,18 @@
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\item\Tool;
|
||||
|
||||
class BirchWoodStairs extends Stair{
|
||||
|
||||
protected $id = self::BIRCH_WOOD_STAIRS;
|
||||
|
||||
public function __construct($meta = 0){
|
||||
parent::__construct(self::BIRCH_WOOD_STAIRS, $meta, "Birch Wood Stairs");
|
||||
$this->meta = $meta;
|
||||
}
|
||||
|
||||
public function getName(){
|
||||
return "Birch Wood Stairs";
|
||||
}
|
||||
|
||||
public function getDrops(Item $item){
|
||||
@ -33,4 +41,16 @@ class BirchWoodStairs extends Stair{
|
||||
[$this->id, 0, 1],
|
||||
];
|
||||
}
|
||||
|
||||
public function getHardness(){
|
||||
return 2;
|
||||
}
|
||||
|
||||
public function getResistance(){
|
||||
return 15;
|
||||
}
|
||||
|
||||
public function getToolType(){
|
||||
return Tool::TYPE_AXE;
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@ -22,10 +22,26 @@
|
||||
namespace pocketmine\block;
|
||||
|
||||
|
||||
use pocketmine\item\Tool;
|
||||
|
||||
class Bookshelf extends Solid{
|
||||
|
||||
protected $id = self::BOOKSHELF;
|
||||
|
||||
public function __construct(){
|
||||
parent::__construct(self::BOOKSHELF, 0, "Bookshelf");
|
||||
$this->hardness = 7.5;
|
||||
|
||||
}
|
||||
|
||||
public function getName(){
|
||||
return "Bookshelf";
|
||||
}
|
||||
|
||||
public function getHardness(){
|
||||
return 1.5;
|
||||
}
|
||||
|
||||
public function getToolType(){
|
||||
return Tool::TYPE_AXE;
|
||||
}
|
||||
|
||||
}
|
@ -22,9 +22,30 @@
|
||||
namespace pocketmine\block;
|
||||
|
||||
|
||||
use pocketmine\item\Tool;
|
||||
|
||||
class BrickStairs extends Stair{
|
||||
|
||||
protected $id = self::BRICK_STAIRS;
|
||||
|
||||
public function __construct($meta = 0){
|
||||
parent::__construct(self::BRICK_STAIRS, $meta, "Brick Stairs");
|
||||
$this->meta = $meta;
|
||||
}
|
||||
|
||||
public function getHardness(){
|
||||
return 2;
|
||||
}
|
||||
|
||||
public function getResistance(){
|
||||
return 30;
|
||||
}
|
||||
|
||||
public function getToolType(){
|
||||
return Tool::TYPE_PICKAXE;
|
||||
}
|
||||
|
||||
public function getName(){
|
||||
return "Brick Stairs";
|
||||
}
|
||||
|
||||
}
|
@ -22,28 +22,30 @@
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\item\Tool;
|
||||
|
||||
class Bricks extends Solid{
|
||||
|
||||
protected $id = self::BRICKS_BLOCK;
|
||||
|
||||
public function __construct(){
|
||||
parent::__construct(self::BRICKS_BLOCK, 0, "Bricks");
|
||||
$this->hardness = 30;
|
||||
|
||||
}
|
||||
|
||||
public function getBreakTime(Item $item){
|
||||
switch($item->isPickaxe()){
|
||||
case 5:
|
||||
return 0.4;
|
||||
case 4:
|
||||
return 0.5;
|
||||
case 3:
|
||||
return 0.75;
|
||||
case 2:
|
||||
return 0.25;
|
||||
case 1:
|
||||
return 1.5;
|
||||
default:
|
||||
return 10;
|
||||
}
|
||||
public function getHardness(){
|
||||
return 2;
|
||||
}
|
||||
|
||||
public function getResistance(){
|
||||
return 30;
|
||||
}
|
||||
|
||||
public function getToolType(){
|
||||
return Tool::TYPE_PICKAXE;
|
||||
}
|
||||
|
||||
public function getName(){
|
||||
return "Bricks";
|
||||
}
|
||||
|
||||
public function getDrops(Item $item){
|
||||
|
@ -26,14 +26,24 @@ use pocketmine\level\Level;
|
||||
use pocketmine\Player;
|
||||
|
||||
class BrownMushroom extends Flowable{
|
||||
public function __construct(){
|
||||
parent::__construct(self::BROWN_MUSHROOM, 0, "Brown Mushroom");
|
||||
$this->hardness = 0;
|
||||
|
||||
protected $id = self::BROWN_MUSHROOM;
|
||||
|
||||
public function __construct($meta = 0){
|
||||
$this->meta = $meta;
|
||||
}
|
||||
|
||||
public function getName(){
|
||||
return "Brown Mushroom";
|
||||
}
|
||||
|
||||
public function getLightLevel(){
|
||||
return 1;
|
||||
}
|
||||
|
||||
public function onUpdate($type){
|
||||
if($type === Level::BLOCK_UPDATE_NORMAL){
|
||||
if($this->getSide(0)->isTransparent === true){
|
||||
if($this->getSide(0)->isTransparent() === true){
|
||||
$this->getLevel()->useBreakOn($this);
|
||||
|
||||
return Level::BLOCK_UPDATE_NORMAL;
|
||||
@ -45,7 +55,7 @@ class BrownMushroom extends Flowable{
|
||||
|
||||
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){
|
||||
$down = $this->getSide(0);
|
||||
if($down->isTransparent === false){
|
||||
if($down->isTransparent() === false){
|
||||
$this->getLevel()->setBlock($block, $this, true, true);
|
||||
|
||||
return true;
|
||||
|
@ -22,6 +22,7 @@
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\item\Tool;
|
||||
use pocketmine\nbt\NBT;
|
||||
use pocketmine\nbt\tag\Compound;
|
||||
use pocketmine\nbt\tag\Enum;
|
||||
@ -32,10 +33,31 @@ use pocketmine\tile\Furnace;
|
||||
use pocketmine\tile\Tile;
|
||||
|
||||
class BurningFurnace extends Solid{
|
||||
|
||||
protected $id = self::BURNING_FURNACE;
|
||||
|
||||
public function __construct($meta = 0){
|
||||
parent::__construct(self::BURNING_FURNACE, $meta, "Burning Furnace");
|
||||
$this->isActivable = true;
|
||||
$this->hardness = 17.5;
|
||||
$this->meta = $meta;
|
||||
}
|
||||
|
||||
public function getName(){
|
||||
return "Burning Furnace";
|
||||
}
|
||||
|
||||
public function canBeActivated(){
|
||||
return true;
|
||||
}
|
||||
|
||||
public function getHardness(){
|
||||
return 3.5;
|
||||
}
|
||||
|
||||
public function getToolType(){
|
||||
return Tool::TYPE_PICKAXE;
|
||||
}
|
||||
|
||||
public function getLightLevel(){
|
||||
return 13;
|
||||
}
|
||||
|
||||
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){
|
||||
@ -47,7 +69,7 @@ class BurningFurnace extends Solid{
|
||||
];
|
||||
$this->meta = $faces[$player instanceof Player ? $player->getDirection() : 0];
|
||||
$this->getLevel()->setBlock($block, $this, true, true);
|
||||
$nbt = new Compound(false, [
|
||||
$nbt = new Compound("", [
|
||||
new Enum("Items", []),
|
||||
new String("id", Tile::FURNACE),
|
||||
new Int("x", $this->x),
|
||||
@ -73,7 +95,7 @@ class BurningFurnace extends Solid{
|
||||
if($t instanceof Furnace){
|
||||
$furnace = $t;
|
||||
}else{
|
||||
$nbt = new Compound(false, [
|
||||
$nbt = new Compound("", [
|
||||
new Enum("Items", []),
|
||||
new String("id", Tile::FURNACE),
|
||||
new Int("x", $this->x),
|
||||
@ -84,7 +106,7 @@ class BurningFurnace extends Solid{
|
||||
$furnace = Tile::createTile("Furnace", $this->getLevel()->getChunk($this->x >> 4, $this->z >> 4), $nbt);
|
||||
}
|
||||
|
||||
if(($player->getGamemode() & 0x01) === 0x01){
|
||||
if($player->isCreative()){
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -94,23 +116,6 @@ class BurningFurnace extends Solid{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function getBreakTime(Item $item){
|
||||
switch($item->isPickaxe()){
|
||||
case 5:
|
||||
return 0.7;
|
||||
case 4:
|
||||
return 0.9;
|
||||
case 3:
|
||||
return 1.35;
|
||||
case 2:
|
||||
return 0.45;
|
||||
case 1:
|
||||
return 2.65;
|
||||
default:
|
||||
return 17.5;
|
||||
}
|
||||
}
|
||||
|
||||
public function getDrops(Item $item){
|
||||
$drops = [];
|
||||
if($item->isPickaxe() >= 1){
|
||||
|
@ -34,22 +34,32 @@ use pocketmine\Server;
|
||||
|
||||
class Cactus extends Transparent{
|
||||
|
||||
public $hasEntityCollision = true;
|
||||
protected $id = self::CACTUS;
|
||||
|
||||
public function __construct($meta = 0){
|
||||
parent::__construct(self::CACTUS, $meta, "Cactus");
|
||||
$this->isFullBlock = false;
|
||||
$this->hardness = 2;
|
||||
$this->meta = $meta;
|
||||
}
|
||||
|
||||
public function getHardness(){
|
||||
return 0.4;
|
||||
}
|
||||
|
||||
public function hasEntityCollision(){
|
||||
return true;
|
||||
}
|
||||
|
||||
public function getName(){
|
||||
return "Cactus";
|
||||
}
|
||||
|
||||
protected function recalculateBoundingBox(){
|
||||
|
||||
return new AxisAlignedBB(
|
||||
$this->x + 0.0625,
|
||||
$this->y,
|
||||
$this->y + 0.0625,
|
||||
$this->z + 0.0625,
|
||||
$this->x + 0.9375,
|
||||
$this->y + 1,
|
||||
$this->y + 0.9375,
|
||||
$this->z + 0.9375
|
||||
);
|
||||
}
|
||||
@ -62,22 +72,22 @@ class Cactus extends Transparent{
|
||||
public function onUpdate($type){
|
||||
if($type === Level::BLOCK_UPDATE_NORMAL){
|
||||
$down = $this->getSide(0);
|
||||
if($down->getID() !== self::SAND and $down->getID() !== self::CACTUS){
|
||||
if($down->getId() !== self::SAND and $down->getId() !== self::CACTUS){
|
||||
$this->getLevel()->useBreakOn($this);
|
||||
}else{
|
||||
for($side = 2; $side <= 5; ++$side){
|
||||
$b = $this->getSide($side);
|
||||
if(!$b->isFlowable){
|
||||
if(!$b->canBeFlowedInto()){
|
||||
$this->getLevel()->useBreakOn($this);
|
||||
}
|
||||
}
|
||||
}
|
||||
}elseif($type === Level::BLOCK_UPDATE_RANDOM){
|
||||
if($this->getSide(0)->getID() !== self::CACTUS){
|
||||
if($this->getSide(0)->getId() !== self::CACTUS){
|
||||
if($this->meta == 0x0F){
|
||||
for($y = 1; $y < 3; ++$y){
|
||||
$b = $this->getLevel()->getBlock(new Vector3($this->x, $this->y + $y, $this->z));
|
||||
if($b->getID() === self::AIR){
|
||||
if($b->getId() === self::AIR){
|
||||
Server::getInstance()->getPluginManager()->callEvent($ev = new BlockGrowEvent($b, new Cactus()));
|
||||
if(!$ev->isCancelled()){
|
||||
$this->getLevel()->setBlock($b, $ev->getNewState(), true);
|
||||
@ -98,12 +108,12 @@ class Cactus extends Transparent{
|
||||
|
||||
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){
|
||||
$down = $this->getSide(0);
|
||||
if($down->getID() === self::SAND or $down->getID() === self::CACTUS){
|
||||
if($down->getId() === self::SAND or $down->getId() === self::CACTUS){
|
||||
$block0 = $this->getSide(2);
|
||||
$block1 = $this->getSide(3);
|
||||
$block2 = $this->getSide(4);
|
||||
$block3 = $this->getSide(5);
|
||||
if($block0->isTransparent === true and $block1->isTransparent === true and $block2->isTransparent === true and $block3->isTransparent === true){
|
||||
if($block0->isTransparent() === true and $block1->isTransparent() === true and $block2->isTransparent() === true and $block3->isTransparent() === true){
|
||||
$this->getLevel()->setBlock($this, $this, true);
|
||||
|
||||
return true;
|
||||
|
@ -29,12 +29,23 @@ use pocketmine\Player;
|
||||
use pocketmine\Server;
|
||||
|
||||
class Cake extends Transparent{
|
||||
|
||||
protected $id = self::CAKE_BLOCK;
|
||||
|
||||
public function __construct($meta = 0){
|
||||
parent::__construct(self::CAKE_BLOCK, 0, "Cake Block");
|
||||
$this->isFullBlock = false;
|
||||
$this->isActivable = true;
|
||||
$this->meta = $meta & 0x07;
|
||||
$this->hardness = 2.5;
|
||||
$this->meta = $meta;
|
||||
}
|
||||
|
||||
public function canBeActivated(){
|
||||
return true;
|
||||
}
|
||||
|
||||
public function getHardness(){
|
||||
return 0.5;
|
||||
}
|
||||
|
||||
public function getName(){
|
||||
return "Cake Block";
|
||||
}
|
||||
|
||||
protected function recalculateBoundingBox(){
|
||||
@ -53,7 +64,7 @@ class Cake extends Transparent{
|
||||
|
||||
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){
|
||||
$down = $this->getSide(0);
|
||||
if($down->getID() !== self::AIR){
|
||||
if($down->getId() !== self::AIR){
|
||||
$this->getLevel()->setBlock($block, $this, true, true);
|
||||
|
||||
return true;
|
||||
@ -64,7 +75,7 @@ class Cake extends Transparent{
|
||||
|
||||
public function onUpdate($type){
|
||||
if($type === Level::BLOCK_UPDATE_NORMAL){
|
||||
if($this->getSide(0)->getID() === self::AIR){ //Replace with common break method
|
||||
if($this->getSide(0)->getId() === self::AIR){ //Replace with common break method
|
||||
$this->getLevel()->setBlock($this, new Air(), true);
|
||||
|
||||
return Level::BLOCK_UPDATE_NORMAL;
|
||||
@ -79,12 +90,12 @@ class Cake extends Transparent{
|
||||
}
|
||||
|
||||
public function onActivate(Item $item, Player $player = null){
|
||||
if($player instanceof Player and $player->getHealth() < 20){
|
||||
if($player instanceof Player and $player->getHealth() < $player->getMaxHealth()){
|
||||
++$this->meta;
|
||||
Server::getInstance()->getPluginManager()->callEvent($ev = new EntityRegainHealthEvent($player, 3, EntityRegainHealthEvent::CAUSE_EATING));
|
||||
if(!$ev->isCancelled()){
|
||||
$player->heal($ev->getAmount(), $ev);
|
||||
}
|
||||
|
||||
$ev = new EntityRegainHealthEvent($player, 3, EntityRegainHealthEvent::CAUSE_EATING);
|
||||
$player->heal($ev->getAmount(), $ev);
|
||||
|
||||
if($this->meta >= 0x06){
|
||||
$this->getLevel()->setBlock($this, new Air(), true);
|
||||
}else{
|
||||
|
@ -27,9 +27,23 @@ use pocketmine\math\AxisAlignedBB;
|
||||
use pocketmine\Player;
|
||||
|
||||
class Carpet extends Flowable{
|
||||
|
||||
protected $id = self::CARPET;
|
||||
|
||||
public function __construct($meta = 0){
|
||||
parent::__construct(self::CARPET, $meta, "Carpet");
|
||||
$names = [
|
||||
$this->meta = $meta;
|
||||
}
|
||||
|
||||
public function getHardness(){
|
||||
return 0.1;
|
||||
}
|
||||
|
||||
public function isSolid(){
|
||||
return true;
|
||||
}
|
||||
|
||||
public function getName(){
|
||||
static $names = [
|
||||
0 => "White Carpet",
|
||||
1 => "Orange Carpet",
|
||||
2 => "Magenta Carpet",
|
||||
@ -47,10 +61,7 @@ class Carpet extends Flowable{
|
||||
14 => "Red Carpet",
|
||||
15 => "Black Carpet",
|
||||
];
|
||||
$this->name = $names[$this->meta];
|
||||
$this->hardness = 0;
|
||||
$this->isFullBlock = false;
|
||||
$this->isSolid = true;
|
||||
return $names[$this->meta & 0x0f];
|
||||
}
|
||||
|
||||
protected function recalculateBoundingBox(){
|
||||
@ -67,7 +78,7 @@ class Carpet extends Flowable{
|
||||
|
||||
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){
|
||||
$down = $this->getSide(0);
|
||||
if($down->getID() !== self::AIR){
|
||||
if($down->getId() !== self::AIR){
|
||||
$this->getLevel()->setBlock($block, $this, true, true);
|
||||
|
||||
return true;
|
||||
@ -78,7 +89,7 @@ class Carpet extends Flowable{
|
||||
|
||||
public function onUpdate($type){
|
||||
if($type === Level::BLOCK_UPDATE_NORMAL){
|
||||
if($this->getSide(0)->getID() === self::AIR){
|
||||
if($this->getSide(0)->getId() === self::AIR){
|
||||
$this->getLevel()->useBreakOn($this);
|
||||
|
||||
return Level::BLOCK_UPDATE_NORMAL;
|
||||
|
@ -24,8 +24,15 @@ namespace pocketmine\block;
|
||||
use pocketmine\item\Item;
|
||||
|
||||
class Carrot extends Crops{
|
||||
|
||||
protected $id = self::CARROT_BLOCK;
|
||||
|
||||
public function __construct($meta = 0){
|
||||
parent::__construct(self::CARROT_BLOCK, $meta, "Carrot Block");
|
||||
$this->meta = $meta;
|
||||
}
|
||||
|
||||
public function getName(){
|
||||
return "Carrot Block";
|
||||
}
|
||||
|
||||
public function getDrops(Item $item){
|
||||
|
@ -22,6 +22,7 @@
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\item\Tool;
|
||||
use pocketmine\math\AxisAlignedBB;
|
||||
use pocketmine\nbt\NBT;
|
||||
use pocketmine\nbt\tag\Compound;
|
||||
@ -34,16 +35,29 @@ use pocketmine\tile\Tile;
|
||||
|
||||
class Chest extends Transparent{
|
||||
|
||||
const SLOTS = 27;
|
||||
protected $id = self::CHEST;
|
||||
|
||||
public function __construct($meta = 0){
|
||||
parent::__construct(self::CHEST, $meta, "Chest");
|
||||
$this->isActivable = true;
|
||||
$this->hardness = 15;
|
||||
$this->meta = $meta;
|
||||
}
|
||||
|
||||
public function canBeActivated(){
|
||||
return true;
|
||||
}
|
||||
|
||||
public function getHardness(){
|
||||
return 2.5;
|
||||
}
|
||||
|
||||
public function getName(){
|
||||
return "Chest";
|
||||
}
|
||||
|
||||
public function getToolType(){
|
||||
return Tool::TYPE_AXE;
|
||||
}
|
||||
|
||||
protected function recalculateBoundingBox(){
|
||||
|
||||
return new AxisAlignedBB(
|
||||
$this->x + 0.0625,
|
||||
$this->y,
|
||||
@ -82,7 +96,7 @@ class Chest extends Transparent{
|
||||
}
|
||||
|
||||
$this->getLevel()->setBlock($block, $this, true, true);
|
||||
$nbt = new Compound(false, [
|
||||
$nbt = new Compound("", [
|
||||
new Enum("Items", []),
|
||||
new String("id", Tile::CHEST),
|
||||
new Int("x", $this->x),
|
||||
@ -113,7 +127,7 @@ class Chest extends Transparent{
|
||||
public function onActivate(Item $item, Player $player = null){
|
||||
if($player instanceof Player){
|
||||
$top = $this->getSide(1);
|
||||
if($top->isTransparent !== true){
|
||||
if($top->isTransparent() !== true){
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -122,7 +136,7 @@ class Chest extends Transparent{
|
||||
if($t instanceof TileChest){
|
||||
$chest = $t;
|
||||
}else{
|
||||
$nbt = new Compound(false, [
|
||||
$nbt = new Compound("", [
|
||||
new Enum("Items", []),
|
||||
new String("id", Tile::CHEST),
|
||||
new Int("x", $this->x),
|
||||
|
@ -22,11 +22,26 @@
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\item\Tool;
|
||||
|
||||
class Clay extends Solid{
|
||||
|
||||
protected $id = self::CLAY_BLOCK;
|
||||
|
||||
public function __construct(){
|
||||
parent::__construct(self::CLAY_BLOCK, 0, "Clay Block");
|
||||
$this->hardness = 3;
|
||||
|
||||
}
|
||||
|
||||
public function getHardness(){
|
||||
return 0.6;
|
||||
}
|
||||
|
||||
public function getToolType(){
|
||||
return Tool::TYPE_SHOVEL;
|
||||
}
|
||||
|
||||
public function getName(){
|
||||
return "Clay Block";
|
||||
}
|
||||
|
||||
public function getDrops(Item $item){
|
||||
|
@ -22,28 +22,26 @@
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\item\Tool;
|
||||
|
||||
class Coal extends Solid{
|
||||
|
||||
protected $id = self::COAL_BLOCK;
|
||||
|
||||
public function __construct(){
|
||||
parent::__construct(self::COAL_BLOCK, 0, "Coal Block");
|
||||
$this->hardness = 30;
|
||||
|
||||
}
|
||||
|
||||
public function getBreakTime(Item $item){
|
||||
switch($item->isPickaxe()){
|
||||
case 5:
|
||||
return 0.95;
|
||||
case 4:
|
||||
return 1.25;
|
||||
case 3:
|
||||
return 1.9;
|
||||
case 2:
|
||||
return 0.65;
|
||||
case 1:
|
||||
return 3.75;
|
||||
default:
|
||||
return 25;
|
||||
}
|
||||
public function getHardness(){
|
||||
return 5;
|
||||
}
|
||||
|
||||
public function getToolType(){
|
||||
return Tool::TYPE_PICKAXE;
|
||||
}
|
||||
|
||||
public function getName(){
|
||||
return "Coal Block";
|
||||
}
|
||||
|
||||
public function getDrops(Item $item){
|
||||
|
@ -22,28 +22,26 @@
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\item\Tool;
|
||||
|
||||
class CoalOre extends Solid{
|
||||
|
||||
protected $id = self::COAL_ORE;
|
||||
|
||||
public function __construct(){
|
||||
parent::__construct(self::COAL_ORE, 0, "Coal Ore");
|
||||
$this->hardness = 15;
|
||||
|
||||
}
|
||||
|
||||
public function getBreakTime(Item $item){
|
||||
switch($item->isPickaxe()){
|
||||
case 5:
|
||||
return 0.6;
|
||||
case 4:
|
||||
return 0.75;
|
||||
case 3:
|
||||
return 1.15;
|
||||
case 2:
|
||||
return 0.4;
|
||||
case 1:
|
||||
return 2.25;
|
||||
default:
|
||||
return 15;
|
||||
}
|
||||
public function getHardness(){
|
||||
return 3;
|
||||
}
|
||||
|
||||
public function getToolType(){
|
||||
return Tool::TYPE_PICKAXE;
|
||||
}
|
||||
|
||||
public function getName(){
|
||||
return "Coal Ore";
|
||||
}
|
||||
|
||||
public function getDrops(Item $item){
|
||||
|
@ -22,28 +22,26 @@
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\item\Tool;
|
||||
|
||||
class Cobblestone extends Solid{
|
||||
|
||||
protected $id = self::COBBLESTONE;
|
||||
|
||||
public function __construct(){
|
||||
parent::__construct(self::COBBLESTONE, 0, "Cobblestone");
|
||||
$this->hardness = 30;
|
||||
|
||||
}
|
||||
|
||||
public function getBreakTime(Item $item){
|
||||
switch($item->isPickaxe()){
|
||||
case 5:
|
||||
return 0.4;
|
||||
case 4:
|
||||
return 0.5;
|
||||
case 3:
|
||||
return 0.75;
|
||||
case 2:
|
||||
return 0.25;
|
||||
case 1:
|
||||
return 1.5;
|
||||
default:
|
||||
return 10;
|
||||
}
|
||||
public function getToolType(){
|
||||
return Tool::TYPE_PICKAXE;
|
||||
}
|
||||
|
||||
public function getName(){
|
||||
return "Cobblestone";
|
||||
}
|
||||
|
||||
public function getHardness(){
|
||||
return 2;
|
||||
}
|
||||
|
||||
public function getDrops(Item $item){
|
||||
|
@ -22,9 +22,26 @@
|
||||
namespace pocketmine\block;
|
||||
|
||||
|
||||
use pocketmine\item\Tool;
|
||||
|
||||
class CobblestoneStairs extends Stair{
|
||||
|
||||
protected $id = self::COBBLESTONE_STAIRS;
|
||||
|
||||
public function __construct($meta = 0){
|
||||
parent::__construct(self::COBBLESTONE_STAIRS, $meta, "Cobblestone Stairs");
|
||||
$this->meta = $meta;
|
||||
}
|
||||
|
||||
public function getHardness(){
|
||||
return 2;
|
||||
}
|
||||
|
||||
public function getToolType(){
|
||||
return Tool::TYPE_PICKAXE;
|
||||
}
|
||||
|
||||
public function getName(){
|
||||
return "Cobblestone Stairs";
|
||||
}
|
||||
|
||||
}
|
@ -23,23 +23,38 @@ namespace pocketmine\block;
|
||||
|
||||
use pocketmine\entity\Entity;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\item\Tool;
|
||||
|
||||
class Cobweb extends Flowable{
|
||||
|
||||
public $hasEntityCollision = true;
|
||||
protected $id = self::COBWEB;
|
||||
|
||||
public function __construct(){
|
||||
parent::__construct(self::COBWEB, 0, "Cobweb");
|
||||
$this->isSolid = true;
|
||||
$this->isFullBlock = false;
|
||||
$this->hardness = 25;
|
||||
|
||||
}
|
||||
|
||||
public function hasEntityCollision(){
|
||||
return true;
|
||||
}
|
||||
|
||||
public function getName(){
|
||||
return "Cobweb";
|
||||
}
|
||||
|
||||
public function getHardness(){
|
||||
return 4;
|
||||
}
|
||||
|
||||
public function getToolType(){
|
||||
return Tool::TYPE_SWORD;
|
||||
}
|
||||
|
||||
public function onEntityCollide(Entity $entity){
|
||||
$entity->fallDistance = 0;
|
||||
$entity->resetFallDistance();
|
||||
}
|
||||
|
||||
public function getDrops(Item $item){
|
||||
//TODO: correct drops
|
||||
return [];
|
||||
}
|
||||
}
|
@ -29,17 +29,13 @@ use pocketmine\Server;
|
||||
|
||||
abstract class Crops extends Flowable{
|
||||
|
||||
public $isActivable = true;
|
||||
public $hardness = 0;
|
||||
|
||||
|
||||
public function getBoundingBox(){
|
||||
return null;
|
||||
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){
|
||||
if($down->getId() === self::FARMLAND){
|
||||
$this->getLevel()->setBlock($block, $this, true, true);
|
||||
|
||||
return true;
|
||||
@ -50,7 +46,7 @@ abstract class Crops extends Flowable{
|
||||
|
||||
|
||||
public function onActivate(Item $item, Player $player = null){
|
||||
if($item->getID() === Item::DYE and $item->getDamage() === 0x0F){ //Bonemeal
|
||||
if($item->getId() === Item::DYE and $item->getDamage() === 0x0F){ //Bonemeal
|
||||
$block = clone $this;
|
||||
$block->meta += mt_rand(2, 5);
|
||||
if($block->meta > 7){
|
||||
@ -73,7 +69,7 @@ abstract class Crops extends Flowable{
|
||||
|
||||
public function onUpdate($type){
|
||||
if($type === Level::BLOCK_UPDATE_NORMAL){
|
||||
if($this->getSide(0)->isTransparent === true){
|
||||
if($this->getSide(0)->isTransparent() === true){
|
||||
$this->getLevel()->useBreakOn($this);
|
||||
return Level::BLOCK_UPDATE_NORMAL;
|
||||
}
|
||||
|
@ -26,19 +26,21 @@ use pocketmine\level\Level;
|
||||
use pocketmine\Player;
|
||||
|
||||
class Dandelion extends Flowable{
|
||||
|
||||
protected $id = self::DANDELION;
|
||||
|
||||
public function __construct(){
|
||||
parent::__construct(self::DANDELION, 0, "Dandelion");
|
||||
$this->hardness = 0;
|
||||
|
||||
}
|
||||
|
||||
public function getBoundingBox(){
|
||||
return null;
|
||||
public function getName(){
|
||||
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){
|
||||
if($down->getId() === 2 or $down->getId() === 3 or $down->getId() === 60){
|
||||
$this->getLevel()->setBlock($block, $this, true, true);
|
||||
|
||||
return true;
|
||||
@ -49,7 +51,7 @@ class Dandelion extends Flowable{
|
||||
|
||||
public function onUpdate($type){
|
||||
if($type === Level::BLOCK_UPDATE_NORMAL){
|
||||
if($this->getSide(0)->isTransparent === true){
|
||||
if($this->getSide(0)->isTransparent() === true){
|
||||
$this->getLevel()->useBreakOn($this);
|
||||
|
||||
return Level::BLOCK_UPDATE_NORMAL;
|
||||
|
@ -22,10 +22,22 @@
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\item\Tool;
|
||||
|
||||
class DarkOakWoodStairs extends Stair{
|
||||
|
||||
protected $id = self::DARK_OAK_WOOD_STAIRS;
|
||||
|
||||
public function __construct($meta = 0){
|
||||
parent::__construct(self::DARK_OAK_WOOD_STAIRS, $meta, "Dark Oak Wood Stairs");
|
||||
$this->meta = $meta;
|
||||
}
|
||||
|
||||
public function getName(){
|
||||
return "Dark Oak Wood Stairs";
|
||||
}
|
||||
|
||||
public function getToolType(){
|
||||
return Tool::TYPE_AXE;
|
||||
}
|
||||
|
||||
public function getDrops(Item $item){
|
||||
|
@ -24,21 +24,22 @@ namespace pocketmine\block;
|
||||
use pocketmine\level\Level;
|
||||
|
||||
class DeadBush extends Flowable{
|
||||
public function __construct(){
|
||||
parent::__construct(self::DEAD_BUSH, 0, "Dead Bush");
|
||||
//$this->isReplaceable = true;
|
||||
$this->hardness = 0;
|
||||
|
||||
protected $id = self::DEAD_BUSH;
|
||||
|
||||
public function __construct($meta = 0){
|
||||
$this->meta = $meta;
|
||||
}
|
||||
|
||||
public function getBoundingBox(){
|
||||
return null;
|
||||
public function getName(){
|
||||
return "Dead Bush";
|
||||
}
|
||||
|
||||
|
||||
public function onUpdate($type){
|
||||
if($type === Level::BLOCK_UPDATE_NORMAL){
|
||||
if($this->getSide(0)->isTransparent === true){ //Replace with common break method
|
||||
$this->getLevel()->setBlock($this, new Air(), false, false, true);
|
||||
if($this->getSide(0)->isTransparent() === true){
|
||||
$this->getLevel()->useBreakOn($this);
|
||||
|
||||
return Level::BLOCK_UPDATE_NORMAL;
|
||||
}
|
||||
|
@ -22,22 +22,26 @@
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\item\Tool;
|
||||
|
||||
class Diamond extends Solid{
|
||||
|
||||
protected $id = self::DIAMOND_BLOCK;
|
||||
|
||||
public function __construct(){
|
||||
parent::__construct(self::DIAMOND_BLOCK, 0, "Diamond Block");
|
||||
$this->hardness = 30;
|
||||
|
||||
}
|
||||
|
||||
public function getBreakTime(Item $item){
|
||||
switch($item->isPickaxe()){
|
||||
case 5:
|
||||
return 0.95;
|
||||
case 4:
|
||||
return 1.25;
|
||||
default:
|
||||
return 25;
|
||||
}
|
||||
public function getHardness(){
|
||||
return 5;
|
||||
}
|
||||
|
||||
public function getName(){
|
||||
return "Diamond Block";
|
||||
}
|
||||
|
||||
public function getToolType(){
|
||||
return Tool::TYPE_PICKAXE;
|
||||
}
|
||||
|
||||
public function getDrops(Item $item){
|
||||
|
@ -22,22 +22,26 @@
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\item\Tool;
|
||||
|
||||
class DiamondOre extends Solid{
|
||||
|
||||
protected $id = self::DIAMOND_ORE;
|
||||
|
||||
public function __construct(){
|
||||
parent::__construct(self::DIAMOND_ORE, 0, "Diamond Ore");
|
||||
$this->hardness = 15;
|
||||
|
||||
}
|
||||
|
||||
public function getBreakTime(Item $item){
|
||||
switch($item->isPickaxe()){
|
||||
case 5:
|
||||
return 0.6;
|
||||
case 4:
|
||||
return 0.75;
|
||||
default:
|
||||
return 15;
|
||||
}
|
||||
public function getHardness(){
|
||||
return 3;
|
||||
}
|
||||
|
||||
public function getName(){
|
||||
return "Diamond Ore";
|
||||
}
|
||||
|
||||
public function getToolType(){
|
||||
return Tool::TYPE_PICKAXE;
|
||||
}
|
||||
|
||||
public function getDrops(Item $item){
|
||||
|
@ -22,20 +22,33 @@
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\item\Tool;
|
||||
use pocketmine\Player;
|
||||
|
||||
class Dirt extends Solid{
|
||||
|
||||
public $isActivable = true;
|
||||
protected $hardness = 2.5;
|
||||
protected $id = self::DIRT;
|
||||
protected $meta = 0;
|
||||
protected $name = "Dirt";
|
||||
|
||||
public function __construct(){
|
||||
|
||||
}
|
||||
|
||||
public function canBeActivated(){
|
||||
return true;
|
||||
}
|
||||
|
||||
public function getHardness(){
|
||||
return 0.5;
|
||||
}
|
||||
|
||||
public function getToolType(){
|
||||
return Tool::TYPE_SHOVEL;
|
||||
}
|
||||
|
||||
public function getName(){
|
||||
return "Dirt";
|
||||
}
|
||||
|
||||
public function onActivate(Item $item, Player $player = null){
|
||||
if($item->isHoe()){
|
||||
$item->useOn($this);
|
||||
|
@ -23,33 +23,39 @@ namespace pocketmine\block;
|
||||
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\level\Level;
|
||||
use pocketmine\level\sound\DoorSound;
|
||||
use pocketmine\math\AxisAlignedBB;
|
||||
use pocketmine\math\Vector3;
|
||||
use pocketmine\network\protocol\LevelEventPacket;
|
||||
use pocketmine\Player;
|
||||
use pocketmine\Server;
|
||||
|
||||
|
||||
abstract class Door extends Transparent{
|
||||
public function __construct($id, $meta = 0, $name = "Unknown"){
|
||||
parent::__construct($id, $meta, $name);
|
||||
$this->isSolid = false;
|
||||
|
||||
public function canBeActivated(){
|
||||
return true;
|
||||
}
|
||||
|
||||
public function isSolid(){
|
||||
return false;
|
||||
}
|
||||
|
||||
private function getFullDamage(){
|
||||
$damage = $this->getDamage();
|
||||
$flag = ($damage & 0x08) > 0;
|
||||
$isUp = ($damage & 0x08) > 0;
|
||||
|
||||
if($flag){
|
||||
$first = $this->getSide(0)->getDamage();
|
||||
$second = $damage;
|
||||
if($isUp){
|
||||
$down = $this->getSide(Vector3::SIDE_DOWN)->getDamage();
|
||||
$up = $damage;
|
||||
}else{
|
||||
$first = $damage;
|
||||
$second = $this->getSide(1)->getDamage();
|
||||
$down = $damage;
|
||||
$up = $this->getSide(Vector3::SIDE_UP)->getDamage();
|
||||
}
|
||||
|
||||
$flag1 = ($second & 0x01) > 0;
|
||||
$isRight = ($up & 0x01) > 0;
|
||||
|
||||
return $first & 0x07 | ($flag ? 8 : 0) | ($flag1 ? 0x10 : 0);
|
||||
return $down & 0x07 | ($isUp ? 8 : 0) | ($isRight ? 0x10 : 0);
|
||||
}
|
||||
|
||||
protected function recalculateBoundingBox(){
|
||||
@ -67,12 +73,12 @@ abstract class Door extends Transparent{
|
||||
);
|
||||
|
||||
$j = $damage & 0x03;
|
||||
$flag = (($damage & 0x04) > 0);
|
||||
$flag1 = (($damage & 0x10) > 0);
|
||||
$isOpen = (($damage & 0x04) > 0);
|
||||
$isRight = (($damage & 0x10) > 0);
|
||||
|
||||
if($j === 0){
|
||||
if($flag){
|
||||
if(!$flag1){
|
||||
if($isOpen){
|
||||
if(!$isRight){
|
||||
$bb->setBounds(
|
||||
$this->x,
|
||||
$this->y,
|
||||
@ -102,8 +108,8 @@ abstract class Door extends Transparent{
|
||||
);
|
||||
}
|
||||
}elseif($j === 1){
|
||||
if($flag){
|
||||
if(!$flag1){
|
||||
if($isOpen){
|
||||
if(!$isRight){
|
||||
$bb->setBounds(
|
||||
$this->x + 1 - $f,
|
||||
$this->y,
|
||||
@ -133,8 +139,8 @@ abstract class Door extends Transparent{
|
||||
);
|
||||
}
|
||||
}elseif($j === 2){
|
||||
if($flag){
|
||||
if(!$flag1){
|
||||
if($isOpen){
|
||||
if(!$isRight){
|
||||
$bb->setBounds(
|
||||
$this->x,
|
||||
$this->y,
|
||||
@ -164,8 +170,8 @@ abstract class Door extends Transparent{
|
||||
);
|
||||
}
|
||||
}elseif($j === 3){
|
||||
if($flag){
|
||||
if(!$flag1){
|
||||
if($isOpen){
|
||||
if(!$isRight){
|
||||
$bb->setBounds(
|
||||
$this->x,
|
||||
$this->y,
|
||||
@ -201,7 +207,7 @@ abstract class Door extends Transparent{
|
||||
|
||||
public function onUpdate($type){
|
||||
if($type === Level::BLOCK_UPDATE_NORMAL){
|
||||
if($this->getSide(0)->getID() === self::AIR){ //Replace with common break method
|
||||
if($this->getSide(0)->getId() === self::AIR){ //Replace with common break method
|
||||
$this->getLevel()->setBlock($this, new Air(), false);
|
||||
if($this->getSide(1) instanceof Door){
|
||||
$this->getLevel()->setBlock($this->getSide(1), new Air(), false);
|
||||
@ -218,7 +224,7 @@ abstract class Door extends Transparent{
|
||||
if($face === 1){
|
||||
$blockUp = $this->getSide(1);
|
||||
$blockDown = $this->getSide(0);
|
||||
if($blockUp->isReplaceable === false or $blockDown->isTransparent === true){
|
||||
if($blockUp->canBeReplaced() === false or $blockDown->isTransparent() === true){
|
||||
return false;
|
||||
}
|
||||
$direction = $player instanceof Player ? $player->getDirection() : 0;
|
||||
@ -231,13 +237,13 @@ abstract class Door extends Transparent{
|
||||
$next = $this->getSide($face[(($direction + 2) % 4)]);
|
||||
$next2 = $this->getSide($face[$direction]);
|
||||
$metaUp = 0x08;
|
||||
if($next->getID() === $this->id or ($next2->isTransparent === false and $next->isTransparent === true)){ //Door hinge
|
||||
if($next->getId() === $this->getId() or ($next2->isTransparent() === false and $next->isTransparent() === true)){ //Door hinge
|
||||
$metaUp |= 0x01;
|
||||
}
|
||||
|
||||
$this->meta = $player->getDirection() & 0x03;
|
||||
$this->setDamage($player->getDirection() & 0x03);
|
||||
$this->getLevel()->setBlock($block, $this, true, true); //Bottom
|
||||
$this->getLevel()->setBlock($blockUp, $b = Block::get($this->id, $metaUp), true); //Top
|
||||
$this->getLevel()->setBlock($blockUp, $b = Block::get($this->getId(), $metaUp), true); //Top
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -245,14 +251,14 @@ abstract class Door extends Transparent{
|
||||
}
|
||||
|
||||
public function onBreak(Item $item){
|
||||
if(($this->meta & 0x08) === 0x08){
|
||||
if(($this->getDamage() & 0x08) === 0x08){
|
||||
$down = $this->getSide(0);
|
||||
if($down->getID() === $this->id){
|
||||
if($down->getId() === $this->getId()){
|
||||
$this->getLevel()->setBlock($down, new Air(), true);
|
||||
}
|
||||
}else{
|
||||
$up = $this->getSide(1);
|
||||
if($up->getID() === $this->id){
|
||||
if($up->getId() === $this->getId()){
|
||||
$this->getLevel()->setBlock($up, new Air(), true);
|
||||
}
|
||||
}
|
||||
@ -262,23 +268,17 @@ abstract class Door extends Transparent{
|
||||
}
|
||||
|
||||
public function onActivate(Item $item, Player $player = null){
|
||||
if(($this->meta & 0x08) === 0x08){ //Top
|
||||
if(($this->getDamage() & 0x08) === 0x08){ //Top
|
||||
$down = $this->getSide(0);
|
||||
if($down->getID() === $this->id){
|
||||
if($down->getId() === $this->getId()){
|
||||
$meta = $down->getDamage() ^ 0x04;
|
||||
$this->getLevel()->setBlock($down, Block::get($this->id, $meta), true);
|
||||
$players = $this->getLevel()->getUsingChunk($this->x >> 4, $this->z >> 4);
|
||||
$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->getID()]);
|
||||
unset($players[$player->getLoaderId()]);
|
||||
}
|
||||
$pk = new LevelEventPacket();
|
||||
$pk->x = $this->x;
|
||||
$pk->y = $this->y;
|
||||
$pk->z = $this->z;
|
||||
$pk->evid = 1003;
|
||||
$pk->data = 0;
|
||||
Server::broadcastPacket($players, $pk);
|
||||
|
||||
$this->level->addSound(new DoorSound($this));
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -286,17 +286,11 @@ abstract class Door extends Transparent{
|
||||
}else{
|
||||
$this->meta ^= 0x04;
|
||||
$this->getLevel()->setBlock($this, $this, true);
|
||||
$players = $this->getLevel()->getUsingChunk($this->x >> 4, $this->z >> 4);
|
||||
$players = $this->getLevel()->getChunkPlayers($this->x >> 4, $this->z >> 4);
|
||||
if($player instanceof Player){
|
||||
unset($players[$player->getID()]);
|
||||
unset($players[$player->getLoaderId()]);
|
||||
}
|
||||
$pk = new LevelEventPacket();
|
||||
$pk->x = $this->x;
|
||||
$pk->y = $this->y;
|
||||
$pk->z = $this->z;
|
||||
$pk->evid = 1003;
|
||||
$pk->data = 0;
|
||||
Server::broadcastPacket($players, $pk);
|
||||
$this->level->addSound(new DoorSound($this));
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -23,34 +23,36 @@ namespace pocketmine\block;
|
||||
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\level\Level;
|
||||
use pocketmine\Player;
|
||||
|
||||
class CyanFlower extends Flowable{
|
||||
public function __construct(){
|
||||
parent::__construct(self::POPPY, 0, "Cyan Flower");
|
||||
$this->hardness = 0;
|
||||
class DoublePlant extends Flowable{
|
||||
|
||||
protected $id = self::DOUBLE_PLANT;
|
||||
|
||||
public function __construct($meta = 0){
|
||||
$this->meta = $meta;
|
||||
}
|
||||
|
||||
public function getBoundingBox(){
|
||||
return null;
|
||||
public function canBeReplaced(){
|
||||
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() === 2 or $down->getID() === 3 or $down->getID() === 60){
|
||||
$this->getLevel()->setBlock($block, $this, true, true);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
public function getName(){
|
||||
static $names = [
|
||||
0 => "Sunflower",
|
||||
1 => "Lilac",
|
||||
2 => "Double Tallgrass",
|
||||
3 => "Large Fern",
|
||||
4 => "Rose Bush",
|
||||
5 => "Peony"
|
||||
];
|
||||
return $names[$this->meta & 0x07];
|
||||
}
|
||||
|
||||
|
||||
public function onUpdate($type){
|
||||
if($type === Level::BLOCK_UPDATE_NORMAL){
|
||||
if($this->getSide(0)->isTransparent === true){
|
||||
$this->getLevel()->useBreakOn($this);
|
||||
if($this->getSide(0)->isTransparent() === true){ //Replace with common break method
|
||||
$this->getLevel()->setBlock($this, new Air(), false, false, true);
|
||||
|
||||
return Level::BLOCK_UPDATE_NORMAL;
|
||||
}
|
||||
@ -58,4 +60,11 @@ class CyanFlower extends Flowable{
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public function getDrops(Item $item){
|
||||
//TODO
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
}
|
@ -22,11 +22,26 @@
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\item\Tool;
|
||||
|
||||
class DoubleSlab extends Solid{
|
||||
|
||||
protected $id = self::DOUBLE_SLAB;
|
||||
|
||||
public function __construct($meta = 0){
|
||||
parent::__construct(self::DOUBLE_SLAB, $meta, "Double Slab");
|
||||
$names = [
|
||||
$this->meta = $meta;
|
||||
}
|
||||
|
||||
public function getHardness(){
|
||||
return 2;
|
||||
}
|
||||
|
||||
public function getToolType(){
|
||||
return Tool::TYPE_PICKAXE;
|
||||
}
|
||||
|
||||
public function getName(){
|
||||
static $names = [
|
||||
0 => "Stone",
|
||||
1 => "Sandstone",
|
||||
2 => "Wooden",
|
||||
@ -36,25 +51,7 @@ class DoubleSlab extends Solid{
|
||||
6 => "Quartz",
|
||||
7 => "",
|
||||
];
|
||||
$this->name = "Double " . $names[$this->meta & 0x07] . " Slab";
|
||||
$this->hardness = 30;
|
||||
}
|
||||
|
||||
public function getBreakTime(Item $item){
|
||||
switch($item->isPickaxe()){
|
||||
case 5:
|
||||
return 0.4;
|
||||
case 4:
|
||||
return 0.5;
|
||||
case 3:
|
||||
return 0.75;
|
||||
case 2:
|
||||
return 0.25;
|
||||
case 1:
|
||||
return 1.5;
|
||||
default:
|
||||
return 10;
|
||||
}
|
||||
return "Double " . $names[$this->meta & 0x07] . " Slab";
|
||||
}
|
||||
|
||||
public function getDrops(Item $item){
|
||||
|
@ -24,35 +24,33 @@ namespace pocketmine\block;
|
||||
use pocketmine\item\Item;
|
||||
|
||||
class DoubleWoodSlab extends Solid{
|
||||
|
||||
protected $id = self::DOUBLE_WOOD_SLAB;
|
||||
|
||||
public function __construct($meta = 0){
|
||||
parent::__construct(self::DOUBLE_WOOD_SLAB, $meta, "Double Wooden Slab");
|
||||
$names = [
|
||||
$this->meta = $meta;
|
||||
}
|
||||
|
||||
public function getHardness(){
|
||||
return 2;
|
||||
}
|
||||
|
||||
public function getToolType(){
|
||||
return Tool::TYPE_AXE;
|
||||
}
|
||||
|
||||
public function getName(){
|
||||
static $names = [
|
||||
0 => "Oak",
|
||||
1 => "Spruce",
|
||||
2 => "Birch",
|
||||
3 => "Jungle",
|
||||
4 => "Acacia",
|
||||
5 => "Dark Oak",
|
||||
6 => "",
|
||||
7 => ""
|
||||
];
|
||||
$this->name = "Double " . $names[$this->meta & 0x07] . " Wooden Slab";
|
||||
$this->hardness = 15;
|
||||
}
|
||||
|
||||
public function getBreakTime(Item $item){
|
||||
switch($item->isAxe()){
|
||||
case 5:
|
||||
return 0.4;
|
||||
case 4:
|
||||
return 0.5;
|
||||
case 3:
|
||||
return 0.75;
|
||||
case 2:
|
||||
return 0.25;
|
||||
case 1:
|
||||
return 1.5;
|
||||
default:
|
||||
return 3;
|
||||
}
|
||||
return "Double " . $names[$this->meta & 0x07] . " Wooden Slab";
|
||||
}
|
||||
|
||||
public function getDrops(Item $item){
|
||||
|
@ -22,22 +22,26 @@
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\item\Tool;
|
||||
|
||||
class Emerald extends Solid{
|
||||
|
||||
protected $id = self::EMERALD_BLOCK;
|
||||
|
||||
public function __construct(){
|
||||
parent::__construct(self::EMERALD_BLOCK, 0, "Emerald Block");
|
||||
$this->hardness = 30;
|
||||
|
||||
}
|
||||
|
||||
public function getBreakTime(Item $item){
|
||||
switch($item->isPickaxe()){
|
||||
case 5:
|
||||
return 0.95;
|
||||
case 4:
|
||||
return 1.25;
|
||||
default:
|
||||
return 25;
|
||||
}
|
||||
public function getHardness(){
|
||||
return 5;
|
||||
}
|
||||
|
||||
public function getToolType(){
|
||||
return Tool::TYPE_PICKAXE;
|
||||
}
|
||||
|
||||
public function getName(){
|
||||
return "Emerald Block";
|
||||
}
|
||||
|
||||
public function getDrops(Item $item){
|
||||
|
@ -22,22 +22,26 @@
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\item\Tool;
|
||||
|
||||
class EmeraldOre extends Solid{
|
||||
|
||||
protected $id = self::EMERALD_ORE;
|
||||
|
||||
public function __construct(){
|
||||
parent::__construct(self::EMERALD_ORE, 0, "Emerald Ore");
|
||||
$this->hardness = 15;
|
||||
|
||||
}
|
||||
|
||||
public function getBreakTime(Item $item){
|
||||
switch($item->isPickaxe()){
|
||||
case 5:
|
||||
return 0.6;
|
||||
case 4:
|
||||
return 0.75;
|
||||
default:
|
||||
return 15;
|
||||
}
|
||||
public function getName(){
|
||||
return "Emerald Ore";
|
||||
}
|
||||
|
||||
public function getToolType(){
|
||||
return Tool::TYPE_PICKAXE;
|
||||
}
|
||||
|
||||
public function getHardness(){
|
||||
return 3;
|
||||
}
|
||||
|
||||
public function getDrops(Item $item){
|
||||
|
@ -21,12 +21,35 @@
|
||||
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\math\AxisAlignedBB;
|
||||
|
||||
class EndPortal extends Solid{
|
||||
class EndPortalFrame extends Solid{
|
||||
|
||||
protected $id = self::END_PORTAL_FRAME;
|
||||
|
||||
public function __construct($meta = 0){
|
||||
parent::__construct(self::END_PORTAL, $meta, "End Portal");
|
||||
$this->hardness = 18000000;
|
||||
$this->meta = $meta;
|
||||
}
|
||||
|
||||
public function getLightLevel(){
|
||||
return 1;
|
||||
}
|
||||
|
||||
public function getName(){
|
||||
return "End Portal Frame";
|
||||
}
|
||||
|
||||
public function getHardness(){
|
||||
return -1;
|
||||
}
|
||||
|
||||
public function getResistance(){
|
||||
return 18000000;
|
||||
}
|
||||
|
||||
public function isBreakable(Item $item){
|
||||
return false;
|
||||
}
|
||||
|
||||
protected function recalculateBoundingBox(){
|
@ -22,27 +22,25 @@
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\item\Tool;
|
||||
|
||||
class EndStone extends Solid{
|
||||
|
||||
protected $id = self::END_STONE;
|
||||
|
||||
public function __construct(){
|
||||
parent::__construct(self::END_STONE, 0, "End Stone");
|
||||
$this->hardness = 45;
|
||||
|
||||
}
|
||||
|
||||
public function getBreakTime(Item $item){
|
||||
switch($item->isPickaxe()){
|
||||
case 5:
|
||||
return 0.6;
|
||||
case 4:
|
||||
return 0.75;
|
||||
case 3:
|
||||
return 1.15;
|
||||
case 2:
|
||||
return 0.4;
|
||||
case 1:
|
||||
return 2.25;
|
||||
default:
|
||||
return 15;
|
||||
}
|
||||
public function getName(){
|
||||
return "End Stone";
|
||||
}
|
||||
|
||||
public function getToolType(){
|
||||
return Tool::TYPE_PICKAXE;
|
||||
}
|
||||
|
||||
public function getHardness(){
|
||||
return 3;
|
||||
}
|
||||
}
|
@ -24,6 +24,7 @@ namespace pocketmine\block;
|
||||
use pocketmine\entity\Entity;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\level\Level;
|
||||
use pocketmine\math\Vector3;
|
||||
use pocketmine\nbt\tag\Byte;
|
||||
use pocketmine\nbt\tag\Compound;
|
||||
use pocketmine\nbt\tag\Double;
|
||||
@ -34,8 +35,6 @@ use pocketmine\Player;
|
||||
|
||||
abstract class Fallable extends Solid{
|
||||
|
||||
public $hasPhysics = true;
|
||||
|
||||
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){
|
||||
$ret = $this->getLevel()->setBlock($this, $this, true, true);
|
||||
|
||||
@ -43,9 +42,9 @@ abstract class Fallable extends Solid{
|
||||
}
|
||||
|
||||
public function onUpdate($type){
|
||||
if($this->hasPhysics === true and $type === Level::BLOCK_UPDATE_NORMAL){
|
||||
$down = $this->getSide(0);
|
||||
if($down->getID() === self::AIR or ($down instanceof Liquid)){
|
||||
if($type === Level::BLOCK_UPDATE_NORMAL){
|
||||
$down = $this->getSide(Vector3::SIDE_DOWN);
|
||||
if($down->getId() === self::AIR or ($down instanceof Liquid)){
|
||||
$fall = Entity::createEntity("FallingSand", $this->getLevel()->getChunk($this->x >> 4, $this->z >> 4), new Compound("", [
|
||||
"Pos" => new Enum("Pos", [
|
||||
new Double("", $this->x + 0.5),
|
||||
@ -61,7 +60,7 @@ abstract class Fallable extends Solid{
|
||||
new Float("", 0),
|
||||
new Float("", 0)
|
||||
]),
|
||||
"TileID" => new Int("TileID", $this->getID()),
|
||||
"TileID" => new Int("TileID", $this->getId()),
|
||||
"Data" => new Byte("Data", $this->getDamage()),
|
||||
]));
|
||||
|
||||
|
@ -22,16 +22,30 @@
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\item\Tool;
|
||||
use pocketmine\math\AxisAlignedBB;
|
||||
|
||||
class Farmland extends Solid{
|
||||
|
||||
protected $id = self::FARMLAND;
|
||||
|
||||
public function __construct($meta = 0){
|
||||
parent::__construct(self::FARMLAND, $meta, "Farmland");
|
||||
$this->hardness = 3;
|
||||
$this->meta = $meta;
|
||||
}
|
||||
|
||||
public function getName(){
|
||||
return "Farmland";
|
||||
}
|
||||
|
||||
public function getHardness(){
|
||||
return 0.6;
|
||||
}
|
||||
|
||||
public function getToolType(){
|
||||
return Tool::TYPE_SHOVEL;
|
||||
}
|
||||
|
||||
protected function recalculateBoundingBox(){
|
||||
|
||||
return new AxisAlignedBB(
|
||||
$this->x,
|
||||
$this->y,
|
||||
|
@ -21,40 +21,65 @@
|
||||
|
||||
namespace pocketmine\block;
|
||||
|
||||
|
||||
use pocketmine\item\Tool;
|
||||
use pocketmine\math\AxisAlignedBB;
|
||||
use pocketmine\math\Vector3;
|
||||
|
||||
class Fence extends Transparent{
|
||||
public function __construct(){
|
||||
parent::__construct(self::FENCE, 0, "Fence");
|
||||
$this->isFullBlock = false;
|
||||
$this->hardness = 15;
|
||||
|
||||
protected $id = self::FENCE;
|
||||
|
||||
public function __construct($meta = 0){
|
||||
$this->meta = $meta;
|
||||
}
|
||||
|
||||
public function getHardness(){
|
||||
return 2;
|
||||
}
|
||||
|
||||
public function getToolType(){
|
||||
return Tool::TYPE_PICKAXE;
|
||||
}
|
||||
|
||||
|
||||
public function getName(){
|
||||
static $names = [
|
||||
0 => "Oak Fence",
|
||||
1 => "Spruce Fence",
|
||||
2 => "Birch Fence",
|
||||
3 => "Jungle Fence",
|
||||
4 => "Acacia Fence",
|
||||
5 => "Dark Oak Fence",
|
||||
"",
|
||||
""
|
||||
];
|
||||
return $names[$this->meta & 0x07];
|
||||
}
|
||||
|
||||
protected function recalculateBoundingBox(){
|
||||
|
||||
$flag = $this->canConnect($this->getSide(2));
|
||||
$flag1 = $this->canConnect($this->getSide(3));
|
||||
$flag2 = $this->canConnect($this->getSide(4));
|
||||
$flag3 = $this->canConnect($this->getSide(5));
|
||||
$north = $this->canConnect($this->getSide(Vector3::SIDE_NORTH));
|
||||
$south = $this->canConnect($this->getSide(Vector3::SIDE_SOUTH));
|
||||
$west = $this->canConnect($this->getSide(Vector3::SIDE_WEST));
|
||||
$east = $this->canConnect($this->getSide(Vector3::SIDE_EAST));
|
||||
|
||||
$f = $flag2 ? 0 : 0.375;
|
||||
$f1 = $flag3 ? 1 : 0.625;
|
||||
$f2 = $flag ? 0 : 0.375;
|
||||
$f3 = $flag1 ? 1 : 0.625;
|
||||
$n = $north ? 0 : 0.375;
|
||||
$s = $south ? 1 : 0.625;
|
||||
$w = $west ? 0 : 0.375;
|
||||
$e = $east ? 1 : 0.625;
|
||||
|
||||
return new AxisAlignedBB(
|
||||
$this->x + $f,
|
||||
$this->x + $w,
|
||||
$this->y,
|
||||
$this->z + $f2,
|
||||
$this->x + $f1,
|
||||
$this->y + 1,
|
||||
$this->z + $f3
|
||||
$this->z + $n,
|
||||
$this->x + $e,
|
||||
$this->y + 1.5,
|
||||
$this->z + $s
|
||||
);
|
||||
}
|
||||
|
||||
public function canConnect(Block $block){
|
||||
return ($block->getID() !== self::FENCE and $block->getID() !== self::FENCE_GATE) ? $block->isSolid : true;
|
||||
return ($block instanceof Fence or $block instanceof FenceGate) ? true : $block->isSolid() and !$block->isTransparent();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -22,19 +22,32 @@
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\item\Tool;
|
||||
use pocketmine\math\AxisAlignedBB;
|
||||
use pocketmine\Player;
|
||||
|
||||
class FenceGate extends Transparent{
|
||||
|
||||
protected $id = self::FENCE_GATE;
|
||||
|
||||
public function __construct($meta = 0){
|
||||
parent::__construct(self::FENCE_GATE, $meta, "Fence Gate");
|
||||
$this->isActivable = true;
|
||||
if(($this->meta & 0x04) === 0x04){
|
||||
$this->isFullBlock = true;
|
||||
}else{
|
||||
$this->isFullBlock = false;
|
||||
}
|
||||
$this->hardness = 15;
|
||||
$this->meta = $meta;
|
||||
}
|
||||
|
||||
public function getName(){
|
||||
return "Oak Fence Gate";
|
||||
}
|
||||
|
||||
public function getHardness(){
|
||||
return 2;
|
||||
}
|
||||
|
||||
public function canBeActivated(){
|
||||
return true;
|
||||
}
|
||||
|
||||
public function getToolType(){
|
||||
return Tool::TYPE_AXE;
|
||||
}
|
||||
|
||||
|
||||
@ -51,7 +64,7 @@ class FenceGate extends Transparent{
|
||||
$this->y,
|
||||
$this->z + 0.375,
|
||||
$this->x + 1,
|
||||
$this->y + 1,
|
||||
$this->y + 1.5,
|
||||
$this->z + 0.625
|
||||
);
|
||||
}else{
|
||||
@ -60,7 +73,7 @@ class FenceGate extends Transparent{
|
||||
$this->y,
|
||||
$this->z,
|
||||
$this->x + 0.625,
|
||||
$this->y + 1,
|
||||
$this->y + 1.5,
|
||||
$this->z + 1
|
||||
);
|
||||
}
|
||||
@ -93,11 +106,6 @@ class FenceGate extends Transparent{
|
||||
3 => 2,
|
||||
];
|
||||
$this->meta = ($faces[$player instanceof Player ? $player->getDirection() : 0] & 0x03) | ((~$this->meta) & 0x04);
|
||||
if(($this->meta & 0x04) === 0x04){
|
||||
$this->isFullBlock = true;
|
||||
}else{
|
||||
$this->isFullBlock = false;
|
||||
}
|
||||
$this->getLevel()->setBlock($this, $this, true);
|
||||
|
||||
return true;
|
||||
|
32
src/pocketmine/block/FenceGateAcacia.php
Normal file
32
src/pocketmine/block/FenceGateAcacia.php
Normal file
@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
*
|
||||
* ____ _ _ __ __ _ __ __ ____
|
||||
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
|
||||
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
|
||||
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
|
||||
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* @author PocketMine Team
|
||||
* @link http://www.pocketmine.net/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
namespace pocketmine\block;
|
||||
|
||||
|
||||
class FenceGateAcacia extends FenceGate{
|
||||
|
||||
protected $id = self::FENCE_GATE_ACACIA;
|
||||
|
||||
public function getName(){
|
||||
return "Acacia Fence Gate";
|
||||
}
|
||||
}
|
32
src/pocketmine/block/FenceGateBirch.php
Normal file
32
src/pocketmine/block/FenceGateBirch.php
Normal file
@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
*
|
||||
* ____ _ _ __ __ _ __ __ ____
|
||||
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
|
||||
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
|
||||
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
|
||||
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* @author PocketMine Team
|
||||
* @link http://www.pocketmine.net/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
namespace pocketmine\block;
|
||||
|
||||
|
||||
class FenceGateBirch extends FenceGate{
|
||||
|
||||
protected $id = self::FENCE_GATE_BIRCH;
|
||||
|
||||
public function getName(){
|
||||
return "Birch Fence Gate";
|
||||
}
|
||||
}
|
32
src/pocketmine/block/FenceGateDarkOak.php
Normal file
32
src/pocketmine/block/FenceGateDarkOak.php
Normal file
@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
*
|
||||
* ____ _ _ __ __ _ __ __ ____
|
||||
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
|
||||
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
|
||||
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
|
||||
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* @author PocketMine Team
|
||||
* @link http://www.pocketmine.net/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
namespace pocketmine\block;
|
||||
|
||||
|
||||
class FenceGateDarkOak extends FenceGate{
|
||||
|
||||
protected $id = self::FENCE_GATE_DARK_OAK;
|
||||
|
||||
public function getName(){
|
||||
return "Dark Oak Fence Gate";
|
||||
}
|
||||
}
|
32
src/pocketmine/block/FenceGateJungle.php
Normal file
32
src/pocketmine/block/FenceGateJungle.php
Normal file
@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
*
|
||||
* ____ _ _ __ __ _ __ __ ____
|
||||
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
|
||||
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
|
||||
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
|
||||
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* @author PocketMine Team
|
||||
* @link http://www.pocketmine.net/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
namespace pocketmine\block;
|
||||
|
||||
|
||||
class FenceGateJungle extends FenceGate{
|
||||
|
||||
protected $id = self::FENCE_GATE_JUNGLE;
|
||||
|
||||
public function getName(){
|
||||
return "Jungle Fence Gate";
|
||||
}
|
||||
}
|
32
src/pocketmine/block/FenceGateSpruce.php
Normal file
32
src/pocketmine/block/FenceGateSpruce.php
Normal file
@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
*
|
||||
* ____ _ _ __ __ _ __ __ ____
|
||||
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
|
||||
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
|
||||
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
|
||||
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* @author PocketMine Team
|
||||
* @link http://www.pocketmine.net/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
namespace pocketmine\block;
|
||||
|
||||
|
||||
class FenceGateSpruce extends FenceGate{
|
||||
|
||||
protected $id = self::FENCE_GATE_SPRUCE;
|
||||
|
||||
public function getName(){
|
||||
return "Spruce Fence Gate";
|
||||
}
|
||||
}
|
@ -21,6 +21,7 @@
|
||||
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\entity\Effect;
|
||||
use pocketmine\entity\Entity;
|
||||
use pocketmine\event\entity\EntityCombustByBlockEvent;
|
||||
use pocketmine\event\entity\EntityDamageByBlockEvent;
|
||||
@ -31,23 +32,37 @@ use pocketmine\Server;
|
||||
|
||||
class Fire extends Flowable{
|
||||
|
||||
public $hasEntityCollision = true;
|
||||
protected $id = self::FIRE;
|
||||
|
||||
public function __construct($meta = 0){
|
||||
parent::__construct(self::FIRE, $meta, "Fire");
|
||||
$this->isReplaceable = true;
|
||||
$this->breakable = false;
|
||||
$this->isFullBlock = true;
|
||||
$this->hardness = 0;
|
||||
$this->meta = $meta;
|
||||
}
|
||||
|
||||
public function getBoundingBox(){
|
||||
return null;
|
||||
public function hasEntityCollision(){
|
||||
return true;
|
||||
}
|
||||
|
||||
public function getName(){
|
||||
return "Fire Block";
|
||||
}
|
||||
|
||||
public function getLightLevel(){
|
||||
return 15;
|
||||
}
|
||||
|
||||
public function isBreakable(Item $item){
|
||||
return false;
|
||||
}
|
||||
|
||||
public function canBeReplaced(){
|
||||
return true;
|
||||
}
|
||||
|
||||
public function onEntityCollide(Entity $entity){
|
||||
$ev = new EntityDamageByBlockEvent($this, $entity, EntityDamageEvent::CAUSE_FIRE, 1);
|
||||
$entity->attack($ev->getFinalDamage(), $ev);
|
||||
if(!$entity->hasEffect(Effect::FIRE_RESISTANCE)){
|
||||
$ev = new EntityDamageByBlockEvent($this, $entity, EntityDamageEvent::CAUSE_FIRE, 1);
|
||||
$entity->attack($ev->getFinalDamage(), $ev);
|
||||
}
|
||||
|
||||
$ev = new EntityCombustByBlockEvent($this, $entity, 8);
|
||||
Server::getInstance()->getPluginManager()->callEvent($ev);
|
||||
@ -64,7 +79,7 @@ class Fire extends Flowable{
|
||||
if($type === Level::BLOCK_UPDATE_NORMAL){
|
||||
for($s = 0; $s <= 5; ++$s){
|
||||
$side = $this->getSide($s);
|
||||
if($side->getID() !== self::AIR and !($side instanceof Liquid)){
|
||||
if($side->getId() !== self::AIR and !($side instanceof Liquid)){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -72,7 +87,7 @@ class Fire extends Flowable{
|
||||
|
||||
return Level::BLOCK_UPDATE_NORMAL;
|
||||
}elseif($type === Level::BLOCK_UPDATE_RANDOM){
|
||||
if($this->getSide(0)->getID() !== self::NETHERRACK){
|
||||
if($this->getSide(0)->getId() !== self::NETHERRACK){
|
||||
$this->getLevel()->setBlock($this, new Air(), true);
|
||||
|
||||
return Level::BLOCK_UPDATE_NORMAL;
|
||||
|
@ -22,10 +22,27 @@
|
||||
namespace pocketmine\block;
|
||||
|
||||
|
||||
use pocketmine\item\Item;
|
||||
|
||||
abstract class Flowable extends Transparent{
|
||||
|
||||
public $isFlowable = true;
|
||||
public $isFullBlock = false;
|
||||
public $isSolid = false;
|
||||
public function canBeFlowedInto(){
|
||||
return true;
|
||||
}
|
||||
|
||||
public function getHardness(){
|
||||
return 0;
|
||||
}
|
||||
|
||||
public function getResistance(){
|
||||
return 0;
|
||||
}
|
||||
|
||||
public function isSolid(){
|
||||
return false;
|
||||
}
|
||||
|
||||
public function getBoundingBox(){
|
||||
return null;
|
||||
}
|
||||
}
|
91
src/pocketmine/block/Flower.php
Normal file
91
src/pocketmine/block/Flower.php
Normal file
@ -0,0 +1,91 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
*
|
||||
* ____ _ _ __ __ _ __ __ ____
|
||||
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
|
||||
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
|
||||
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
|
||||
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* @author PocketMine Team
|
||||
* @link http://www.pocketmine.net/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\level\Level;
|
||||
use pocketmine\math\Vector3;
|
||||
use pocketmine\Player;
|
||||
|
||||
class Flower extends Flowable{
|
||||
const TYPE_POPPY = 0;
|
||||
const TYPE_BLUE_ORCHID = 1;
|
||||
const TYPE_ALLIUM = 2;
|
||||
const TYPE_AZURE_BLUET = 3;
|
||||
const TYPE_RED_TULIP = 4;
|
||||
const TYPE_ORANGE_TULIP = 5;
|
||||
const TYPE_WHITE_TULIP = 6;
|
||||
const TYPE_PINK_TULIP = 7;
|
||||
const TYPE_OXEYE_DAISY = 8;
|
||||
|
||||
protected $id = self::RED_FLOWER;
|
||||
|
||||
public function __construct($meta = 0){
|
||||
$this->meta = $meta;
|
||||
}
|
||||
|
||||
public function getName(){
|
||||
static $names = [
|
||||
self::TYPE_POPPY => "Poppy",
|
||||
self::TYPE_BLUE_ORCHID => "Blue Orchid",
|
||||
self::TYPE_ALLIUM => "Allium",
|
||||
self::TYPE_AZURE_BLUET => "Azure Bluet",
|
||||
self::TYPE_RED_TULIP => "Red Tulip",
|
||||
self::TYPE_ORANGE_TULIP => "Orange Tulip",
|
||||
self::TYPE_WHITE_TULIP => "White Tulip",
|
||||
self::TYPE_PINK_TULIP => "Pink Tulip",
|
||||
self::TYPE_OXEYE_DAISY => "Oxeye Daisy",
|
||||
9 => "Unknown",
|
||||
10 => "Unknown",
|
||||
11 => "Unknown",
|
||||
12 => "Unknown",
|
||||
13 => "Unknown",
|
||||
14 => "Unknown",
|
||||
15 => "Unknown"
|
||||
];
|
||||
return $names[$this->meta];
|
||||
}
|
||||
|
||||
|
||||
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){
|
||||
$down = $this->getSide(0);
|
||||
if($down->getId() === Block::GRASS or $down->getId() === Block::DIRT or $down->getId() === Block::FARMLAND){
|
||||
$this->getLevel()->setBlock($block, $this, true);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public function onUpdate($type){
|
||||
if($type === Level::BLOCK_UPDATE_NORMAL){
|
||||
if($this->getSide(Vector3::SIDE_DOWN)->isTransparent()){
|
||||
$this->getLevel()->useBreakOn($this);
|
||||
|
||||
return Level::BLOCK_UPDATE_NORMAL;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
@ -23,10 +23,10 @@ namespace pocketmine\block;
|
||||
|
||||
|
||||
class Furnace extends BurningFurnace{
|
||||
public function __construct($meta = 0){
|
||||
parent::__construct($meta);
|
||||
$this->id = self::FURNACE;
|
||||
$this->name = "Furnace";
|
||||
$this->isActivable = true;
|
||||
|
||||
protected $id = self::FURNACE;
|
||||
|
||||
public function getName(){
|
||||
return "Furnace";
|
||||
}
|
||||
}
|
@ -24,9 +24,19 @@ namespace pocketmine\block;
|
||||
use pocketmine\item\Item;
|
||||
|
||||
class Glass extends Transparent{
|
||||
|
||||
protected $id = self::GLASS;
|
||||
|
||||
public function __construct(){
|
||||
parent::__construct(self::GLASS, 0, "Glass");
|
||||
$this->hardness = 1.5;
|
||||
|
||||
}
|
||||
|
||||
public function getName(){
|
||||
return "Glass";
|
||||
}
|
||||
|
||||
public function getHardness(){
|
||||
return 0.3;
|
||||
}
|
||||
|
||||
public function getDrops(Item $item){
|
||||
|
@ -22,9 +22,25 @@
|
||||
namespace pocketmine\block;
|
||||
|
||||
|
||||
use pocketmine\item\Item;
|
||||
|
||||
class GlassPane extends Thin{
|
||||
|
||||
protected $id = self::GLASS_PANE;
|
||||
|
||||
public function __construct(){
|
||||
parent::__construct(self::GLASS_PANE, 0, "Glass Pane");
|
||||
|
||||
}
|
||||
|
||||
public function getName(){
|
||||
return "Glass Pane";
|
||||
}
|
||||
|
||||
public function getHardness(){
|
||||
return 0.3;
|
||||
}
|
||||
|
||||
public function getDrops(Item $item){
|
||||
return [];
|
||||
}
|
||||
}
|
@ -23,8 +23,19 @@ namespace pocketmine\block;
|
||||
|
||||
|
||||
class GlowingObsidian extends Solid{
|
||||
|
||||
protected $id = self::GLOWING_OBSIDIAN;
|
||||
|
||||
public function __construct($meta = 0){
|
||||
parent::__construct(self::GLOWING_OBSIDIAN, $meta, "Glowing Obsidian");
|
||||
$this->meta = $meta;
|
||||
}
|
||||
|
||||
public function getName(){
|
||||
return "Glowing Obsidian";
|
||||
}
|
||||
|
||||
public function getLightLevel(){
|
||||
return 12;
|
||||
}
|
||||
|
||||
}
|
@ -22,12 +22,31 @@
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\item\Tool;
|
||||
use pocketmine\level\Level;
|
||||
|
||||
class GlowingRedstoneOre extends Solid{
|
||||
|
||||
protected $id = self::GLOWING_REDSTONE_ORE;
|
||||
|
||||
public function __construct(){
|
||||
parent::__construct(self::GLOWING_REDSTONE_ORE, 0, "Glowing Redstone Ore");
|
||||
$this->hardness = 15;
|
||||
|
||||
}
|
||||
|
||||
public function getHardness(){
|
||||
return 15;
|
||||
}
|
||||
|
||||
public function getName(){
|
||||
return "Glowing Redstone Ore";
|
||||
}
|
||||
|
||||
public function getToolType(){
|
||||
return Tool::TYPE_PICKAXE;
|
||||
}
|
||||
|
||||
public function getLightLevel(){
|
||||
return 9;
|
||||
}
|
||||
|
||||
public function onUpdate($type){
|
||||
@ -40,18 +59,6 @@ class GlowingRedstoneOre extends Solid{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
public function getBreakTime(Item $item){
|
||||
switch($item->isPickaxe()){
|
||||
case 5:
|
||||
return 0.6;
|
||||
case 4:
|
||||
return 0.75;
|
||||
default:
|
||||
return 15;
|
||||
}
|
||||
}
|
||||
|
||||
public function getDrops(Item $item){
|
||||
if($item->isPickaxe() >= 4){
|
||||
return [
|
||||
|
@ -22,11 +22,30 @@
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\item\Tool;
|
||||
|
||||
class Glowstone extends Transparent{
|
||||
|
||||
protected $id = self::GLOWSTONE_BLOCK;
|
||||
|
||||
public function __construct(){
|
||||
parent::__construct(self::GLOWSTONE_BLOCK, 0, "Glowstone");
|
||||
$this->hardness = 1.5;
|
||||
|
||||
}
|
||||
|
||||
public function getName(){
|
||||
return "Glowstone";
|
||||
}
|
||||
|
||||
public function getHardness(){
|
||||
return 0.3;
|
||||
}
|
||||
|
||||
public function getToolType(){
|
||||
return Tool::TYPE_PICKAXE;
|
||||
}
|
||||
|
||||
public function getLightLevel(){
|
||||
return 15;
|
||||
}
|
||||
|
||||
public function getDrops(Item $item){
|
||||
|
@ -22,22 +22,26 @@
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\item\Tool;
|
||||
|
||||
class Gold extends Solid{
|
||||
|
||||
protected $id = self::GOLD_BLOCK;
|
||||
|
||||
public function __construct(){
|
||||
parent::__construct(self::GOLD_BLOCK, 0, "Gold Block");
|
||||
$this->hardness = 30;
|
||||
|
||||
}
|
||||
|
||||
public function getBreakTime(Item $item){
|
||||
switch($item->isPickaxe()){
|
||||
case 5:
|
||||
return 0.6;
|
||||
case 4:
|
||||
return 0.75;
|
||||
default:
|
||||
return 15;
|
||||
}
|
||||
public function getName(){
|
||||
return "Gold Block";
|
||||
}
|
||||
|
||||
public function getHardness(){
|
||||
return 3;
|
||||
}
|
||||
|
||||
public function getToolType(){
|
||||
return Tool::TYPE_PICKAXE;
|
||||
}
|
||||
|
||||
public function getDrops(Item $item){
|
||||
|
@ -22,22 +22,26 @@
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\item\Tool;
|
||||
|
||||
class GoldOre extends Solid{
|
||||
|
||||
protected $id = self::GOLD_ORE;
|
||||
|
||||
public function __construct(){
|
||||
parent::__construct(self::GOLD_ORE, 0, "Gold Ore");
|
||||
$this->hardness = 15;
|
||||
|
||||
}
|
||||
|
||||
public function getBreakTime(Item $item){
|
||||
switch($item->isPickaxe()){
|
||||
case 5:
|
||||
return 0.6;
|
||||
case 4:
|
||||
return 0.75;
|
||||
default:
|
||||
return 15;
|
||||
}
|
||||
public function getName(){
|
||||
return "Gold Ore";
|
||||
}
|
||||
|
||||
public function getHardness(){
|
||||
return 3;
|
||||
}
|
||||
|
||||
public function getToolType(){
|
||||
return Tool::TYPE_PICKAXE;
|
||||
}
|
||||
|
||||
public function getDrops(Item $item){
|
||||
|
@ -23,6 +23,7 @@ namespace pocketmine\block;
|
||||
|
||||
use pocketmine\event\block\BlockSpreadEvent;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\item\Tool;
|
||||
use pocketmine\level\generator\object\TallGrass as TallGrassObject;
|
||||
use pocketmine\level\Level;
|
||||
use pocketmine\math\Vector3;
|
||||
@ -32,16 +33,28 @@ use pocketmine\utils\Random;
|
||||
|
||||
class Grass extends Solid{
|
||||
|
||||
public $isActivable = true;
|
||||
protected $hardness = 3;
|
||||
protected $id = self::GRASS;
|
||||
protected $meta = 0;
|
||||
protected $name = "Grass";
|
||||
|
||||
public function __construct(){
|
||||
|
||||
}
|
||||
|
||||
public function canBeActivated(){
|
||||
return true;
|
||||
}
|
||||
|
||||
public function getName(){
|
||||
return "Grass";
|
||||
}
|
||||
|
||||
public function getHardness(){
|
||||
return 0.6;
|
||||
}
|
||||
|
||||
public function getToolType(){
|
||||
return Tool::TYPE_SHOVEL;
|
||||
}
|
||||
|
||||
public function getDrops(Item $item){
|
||||
return [
|
||||
[Item::DIRT, 0, 1],
|
||||
@ -55,7 +68,7 @@ class Grass extends Solid{
|
||||
$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){
|
||||
if($block->getId() === Block::DIRT){
|
||||
if($block->getSide(1) instanceof Transparent){
|
||||
Server::getInstance()->getPluginManager()->callEvent($ev = new BlockSpreadEvent($block, $this, new Grass()));
|
||||
if(!$ev->isCancelled()){
|
||||
@ -67,7 +80,7 @@ class Grass extends Solid{
|
||||
}
|
||||
|
||||
public function onActivate(Item $item, Player $player = null){
|
||||
if($item->getID() === Item::DYE and $item->getDamage() === 0x0F){
|
||||
if($item->getId() === Item::DYE and $item->getDamage() === 0x0F){
|
||||
$item->count--;
|
||||
TallGrassObject::growGrass($this->getLevel(), $this, new Random(mt_rand()), 8, 2);
|
||||
|
||||
@ -76,6 +89,11 @@ class Grass extends Solid{
|
||||
$item->useOn($this);
|
||||
$this->getLevel()->setBlock($this, new Farmland());
|
||||
|
||||
return true;
|
||||
}elseif($item->isShovel() and $this->getSide(1)->getId() === Block::AIR){
|
||||
$item->useOn($this);
|
||||
$this->getLevel()->setBlock($this, new GrassPath());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
71
src/pocketmine/block/GrassPath.php
Normal file
71
src/pocketmine/block/GrassPath.php
Normal file
@ -0,0 +1,71 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
*
|
||||
* ____ _ _ __ __ _ __ __ ____
|
||||
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
|
||||
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
|
||||
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
|
||||
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* @author PocketMine Team
|
||||
* @link http://www.pocketmine.net/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\event\block\BlockSpreadEvent;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\item\Tool;
|
||||
use pocketmine\level\generator\object\TallGrass as TallGrassObject;
|
||||
use pocketmine\level\Level;
|
||||
use pocketmine\math\AxisAlignedBB;
|
||||
use pocketmine\math\Vector3;
|
||||
use pocketmine\Player;
|
||||
use pocketmine\Server;
|
||||
use pocketmine\utils\Random;
|
||||
|
||||
class GrassPath extends Transparent{
|
||||
|
||||
protected $id = self::GRASS_PATH;
|
||||
|
||||
public function __construct(){
|
||||
|
||||
}
|
||||
|
||||
public function getName(){
|
||||
return "Grass Path";
|
||||
}
|
||||
|
||||
public function getToolType(){
|
||||
return Tool::TYPE_SHOVEL;
|
||||
}
|
||||
|
||||
protected function recalculateBoundingBox(){
|
||||
return new AxisAlignedBB(
|
||||
$this->x,
|
||||
$this->y,
|
||||
$this->z,
|
||||
$this->x + 1,
|
||||
$this->y + 0.9375,
|
||||
$this->z + 1
|
||||
);
|
||||
}
|
||||
|
||||
public function getHardness(){
|
||||
return 0.6;
|
||||
}
|
||||
|
||||
public function getDrops(Item $item){
|
||||
return [
|
||||
[Item::DIRT, 0, 1],
|
||||
];
|
||||
}
|
||||
}
|
@ -22,11 +22,26 @@
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\item\Tool;
|
||||
|
||||
class Gravel extends Fallable{
|
||||
|
||||
protected $id = self::GRAVEL;
|
||||
|
||||
public function __construct(){
|
||||
parent::__construct(self::GRAVEL, 0, "Gravel");
|
||||
$this->hardness = 3;
|
||||
|
||||
}
|
||||
|
||||
public function getName(){
|
||||
return "Gravel";
|
||||
}
|
||||
|
||||
public function getHardness(){
|
||||
return 0.6;
|
||||
}
|
||||
|
||||
public function getToolType(){
|
||||
return Tool::TYPE_SHOVEL;
|
||||
}
|
||||
|
||||
public function getDrops(Item $item){
|
||||
|
@ -22,28 +22,25 @@
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\item\Tool;
|
||||
|
||||
class HardenedClay extends Solid{
|
||||
|
||||
protected $id = self::HARDENED_CLAY;
|
||||
|
||||
public function __construct(){
|
||||
parent::__construct(self::HARDENED_CLAY, 0, "Hardened Clay");
|
||||
$this->hardness = 30;
|
||||
|
||||
}
|
||||
|
||||
public function getBreakTime(Item $item){
|
||||
switch($item->isPickaxe()){
|
||||
case 5:
|
||||
return 0.25;
|
||||
case 4:
|
||||
return 0.35;
|
||||
case 3:
|
||||
return 0.5;
|
||||
case 2:
|
||||
return 0.2;
|
||||
case 1:
|
||||
return 0.95;
|
||||
default:
|
||||
return 6.25;
|
||||
}
|
||||
public function getName(){
|
||||
return "Hardened Clay";
|
||||
}
|
||||
|
||||
public function getToolType(){
|
||||
return Tool::TYPE_PICKAXE;
|
||||
}
|
||||
|
||||
public function getHardness(){
|
||||
return 1.25;
|
||||
}
|
||||
}
|
@ -25,9 +25,19 @@ use pocketmine\item\Item;
|
||||
use pocketmine\Player;
|
||||
|
||||
class HayBale extends Solid{
|
||||
|
||||
protected $id = self::HAY_BALE;
|
||||
|
||||
public function __construct($meta = 0){
|
||||
parent::__construct(self::HAY_BALE, $meta, "Hay Bale");
|
||||
$this->hardness = 10;
|
||||
$this->meta = $meta;
|
||||
}
|
||||
|
||||
public function getName(){
|
||||
return "Hay Bale";
|
||||
}
|
||||
|
||||
public function getHardness(){
|
||||
return 0.5;
|
||||
}
|
||||
|
||||
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){
|
||||
|
@ -22,11 +22,26 @@
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\item\Tool;
|
||||
|
||||
class Ice extends Transparent{
|
||||
|
||||
protected $id = self::ICE;
|
||||
|
||||
public function __construct(){
|
||||
parent::__construct(self::ICE, 0, "Ice");
|
||||
$this->hardness = 2.5;
|
||||
|
||||
}
|
||||
|
||||
public function getName(){
|
||||
return "Ice";
|
||||
}
|
||||
|
||||
public function getHardness(){
|
||||
return 0.5;
|
||||
}
|
||||
|
||||
public function getToolType(){
|
||||
return Tool::TYPE_PICKAXE;
|
||||
}
|
||||
|
||||
public function onBreak(Item $item){
|
||||
@ -35,23 +50,6 @@ class Ice extends Transparent{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function getBreakTime(Item $item){
|
||||
switch($item->isPickaxe()){
|
||||
case 5:
|
||||
return 0.1;
|
||||
case 4:
|
||||
return 0.15;
|
||||
case 3:
|
||||
return 0.2;
|
||||
case 2:
|
||||
return 0.1;
|
||||
case 1:
|
||||
return 0.4;
|
||||
default:
|
||||
return 0.75;
|
||||
}
|
||||
}
|
||||
|
||||
public function getDrops(Item $item){
|
||||
return [];
|
||||
}
|
||||
|
@ -22,24 +22,26 @@
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\item\Tool;
|
||||
|
||||
class Iron extends Solid{
|
||||
|
||||
protected $id = self::IRON_BLOCK;
|
||||
|
||||
public function __construct(){
|
||||
parent::__construct(self::IRON_BLOCK, 0, "Iron Block");
|
||||
$this->hardness = 30;
|
||||
|
||||
}
|
||||
|
||||
public function getBreakTime(Item $item){
|
||||
switch($item->isPickaxe()){
|
||||
case 5:
|
||||
return 0.95;
|
||||
case 4:
|
||||
return 1.25;
|
||||
case 3:
|
||||
return 1.9;
|
||||
default:
|
||||
return 25;
|
||||
}
|
||||
public function getName(){
|
||||
return "Iron Block";
|
||||
}
|
||||
|
||||
public function getToolType(){
|
||||
return Tool::TYPE_PICKAXE;
|
||||
}
|
||||
|
||||
public function getHardness(){
|
||||
return 5;
|
||||
}
|
||||
|
||||
public function getDrops(Item $item){
|
||||
|
@ -21,10 +21,38 @@
|
||||
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\item\Tool;
|
||||
|
||||
class IronBars extends Thin{
|
||||
|
||||
protected $id = self::IRON_BARS;
|
||||
|
||||
public function __construct(){
|
||||
parent::__construct(self::IRON_BARS, 0, "Iron Bars");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
public function getName(){
|
||||
return "Iron Bars";
|
||||
}
|
||||
|
||||
public function getHardness(){
|
||||
return 5;
|
||||
}
|
||||
|
||||
public function getToolType(){
|
||||
return Tool::TYPE_PICKAXE;
|
||||
}
|
||||
|
||||
public function getDrops(Item $item){
|
||||
if($item->isPickaxe() >= 1){
|
||||
return [
|
||||
[Item::IRON_BARS, 0, 1],
|
||||
];
|
||||
}else{
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -22,29 +22,26 @@
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\item\Tool;
|
||||
|
||||
class IronDoor extends Door{
|
||||
|
||||
protected $id = self::IRON_DOOR_BLOCK;
|
||||
|
||||
public function __construct($meta = 0){
|
||||
parent::__construct(self::IRON_DOOR_BLOCK, $meta, "Iron Door Block");
|
||||
//$this->isActivable = true;
|
||||
$this->hardness = 25;
|
||||
$this->meta = $meta;
|
||||
}
|
||||
|
||||
public function getBreakTime(Item $item){
|
||||
switch($item->isPickaxe()){
|
||||
case 5:
|
||||
return 0.95;
|
||||
case 4:
|
||||
return 1.25;
|
||||
case 3:
|
||||
return 1.9;
|
||||
case 2:
|
||||
return 0.65;
|
||||
case 1:
|
||||
return 3.75;
|
||||
default:
|
||||
return 25;
|
||||
}
|
||||
public function getName(){
|
||||
return "Iron Door Block";
|
||||
}
|
||||
|
||||
public function getToolType(){
|
||||
return Tool::TYPE_PICKAXE;
|
||||
}
|
||||
|
||||
public function getHardness(){
|
||||
return 5;
|
||||
}
|
||||
|
||||
public function getDrops(Item $item){
|
||||
|
@ -22,24 +22,26 @@
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\item\Tool;
|
||||
|
||||
class IronOre extends Solid{
|
||||
|
||||
protected $id = self::IRON_ORE;
|
||||
|
||||
public function __construct(){
|
||||
parent::__construct(self::IRON_ORE, 0, "Iron Ore");
|
||||
$this->hardness = 15;
|
||||
|
||||
}
|
||||
|
||||
public function getBreakTime(Item $item){
|
||||
switch($item->isPickaxe()){
|
||||
case 5:
|
||||
return 0.6;
|
||||
case 4:
|
||||
return 0.75;
|
||||
case 3:
|
||||
return 1.15;
|
||||
default:
|
||||
return 15;
|
||||
}
|
||||
public function getName(){
|
||||
return "Iron Ore";
|
||||
}
|
||||
|
||||
public function getToolType(){
|
||||
return Tool::TYPE_PICKAXE;
|
||||
}
|
||||
|
||||
public function getHardness(){
|
||||
return 3;
|
||||
}
|
||||
|
||||
public function getDrops(Item $item){
|
||||
|
@ -22,10 +22,22 @@
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\item\Tool;
|
||||
|
||||
class JungleWoodStairs extends Stair{
|
||||
|
||||
protected $id = self::JUNGLE_WOOD_STAIRS;
|
||||
|
||||
public function __construct($meta = 0){
|
||||
parent::__construct(self::JUNGLE_WOOD_STAIRS, $meta, "Jungle Wood Stairs");
|
||||
$this->meta = $meta;
|
||||
}
|
||||
|
||||
public function getName(){
|
||||
return "Jungle Wood Stairs";
|
||||
}
|
||||
|
||||
public function getToolType(){
|
||||
return Tool::TYPE_AXE;
|
||||
}
|
||||
|
||||
public function getDrops(Item $item){
|
||||
|
@ -23,23 +23,37 @@ namespace pocketmine\block;
|
||||
|
||||
use pocketmine\entity\Entity;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\item\Tool;
|
||||
use pocketmine\level\Level;
|
||||
use pocketmine\math\AxisAlignedBB;
|
||||
use pocketmine\Player;
|
||||
|
||||
class Ladder extends Transparent{
|
||||
|
||||
public $hasEntityCollision = true;
|
||||
protected $id = self::LADDER;
|
||||
|
||||
public function __construct($meta = 0){
|
||||
parent::__construct(self::LADDER, $meta, "Ladder");
|
||||
$this->isSolid = false;
|
||||
$this->isFullBlock = false;
|
||||
$this->hardness = 2;
|
||||
$this->meta = $meta;
|
||||
}
|
||||
|
||||
public function getName(){
|
||||
return "Ladder";
|
||||
}
|
||||
|
||||
public function hasEntityCollision(){
|
||||
return true;
|
||||
}
|
||||
|
||||
public function isSolid(){
|
||||
return false;
|
||||
}
|
||||
|
||||
public function getHardness(){
|
||||
return 0.4;
|
||||
}
|
||||
|
||||
public function onEntityCollide(Entity $entity){
|
||||
$entity->fallDistance = 0;
|
||||
$entity->resetFallDistance();
|
||||
$entity->onGround = true;
|
||||
}
|
||||
|
||||
@ -90,7 +104,7 @@ class Ladder extends Transparent{
|
||||
|
||||
|
||||
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){
|
||||
if($target->isTransparent === false){
|
||||
if($target->isTransparent() === false){
|
||||
$faces = [
|
||||
2 => 2,
|
||||
3 => 3,
|
||||
@ -110,7 +124,7 @@ class Ladder extends Transparent{
|
||||
|
||||
public function onUpdate($type){
|
||||
if($type === Level::BLOCK_UPDATE_NORMAL){
|
||||
/*if($this->getSide(0)->getID() === self::AIR){ //Replace with common break method
|
||||
/*if($this->getSide(0)->getId() === self::AIR){ //Replace with common break method
|
||||
Server::getInstance()->api->entity->drop($this, Item::get(LADDER, 0, 1));
|
||||
$this->getLevel()->setBlock($this, new Air(), true, true, true);
|
||||
return Level::BLOCK_UPDATE_NORMAL;
|
||||
@ -120,6 +134,10 @@ class Ladder extends Transparent{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function getToolType(){
|
||||
return Tool::TYPE_AXE;
|
||||
}
|
||||
|
||||
public function getDrops(Item $item){
|
||||
return [
|
||||
[$this->id, 0, 1],
|
||||
|
@ -22,24 +22,26 @@
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\item\Tool;
|
||||
|
||||
class Lapis extends Solid{
|
||||
|
||||
protected $id = self::LAPIS_BLOCK;
|
||||
|
||||
public function __construct(){
|
||||
parent::__construct(self::LAPIS_BLOCK, 0, "Lapis Block");
|
||||
$this->hardness = 15;
|
||||
|
||||
}
|
||||
|
||||
public function getBreakTime(Item $item){
|
||||
switch($item->isPickaxe()){
|
||||
case 5:
|
||||
return 0.6;
|
||||
case 4:
|
||||
return 0.75;
|
||||
case 3:
|
||||
return 1.15;
|
||||
default:
|
||||
return 15;
|
||||
}
|
||||
public function getName(){
|
||||
return "Lapis Lazuli Block";
|
||||
}
|
||||
|
||||
public function getToolType(){
|
||||
return Tool::TYPE_PICKAXE;
|
||||
}
|
||||
|
||||
public function getHardness(){
|
||||
return 3;
|
||||
}
|
||||
|
||||
public function getDrops(Item $item){
|
||||
|
@ -22,25 +22,26 @@
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\item\Tool;
|
||||
|
||||
class LapisOre extends Solid{
|
||||
|
||||
protected $id = self::LAPIS_ORE;
|
||||
|
||||
public function __construct(){
|
||||
parent::__construct(self::LAPIS_ORE, 0, "Lapis Ore");
|
||||
$this->hardness = 15;
|
||||
|
||||
}
|
||||
|
||||
public function getBreakTime(Item $item){
|
||||
public function getHardness(){
|
||||
return 3;
|
||||
}
|
||||
|
||||
switch($item->isPickaxe()){
|
||||
case 5:
|
||||
return 0.6;
|
||||
case 4:
|
||||
return 0.75;
|
||||
case 3:
|
||||
return 1.15;
|
||||
default:
|
||||
return 15;
|
||||
}
|
||||
public function getToolType(){
|
||||
return Tool::TYPE_PICKAXE;
|
||||
}
|
||||
|
||||
public function getName(){
|
||||
return "Lapis Lazuli Ore";
|
||||
}
|
||||
|
||||
public function getDrops(Item $item){
|
||||
|
@ -21,6 +21,7 @@
|
||||
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\entity\Effect;
|
||||
use pocketmine\entity\Entity;
|
||||
use pocketmine\event\entity\EntityCombustByBlockEvent;
|
||||
use pocketmine\event\entity\EntityDamageByBlockEvent;
|
||||
@ -31,15 +32,26 @@ use pocketmine\Server;
|
||||
|
||||
class Lava extends Liquid{
|
||||
|
||||
protected $id = self::LAVA;
|
||||
|
||||
public function __construct($meta = 0){
|
||||
parent::__construct(self::LAVA, $meta, "Lava");
|
||||
$this->hardness = 0;
|
||||
$this->meta = $meta;
|
||||
}
|
||||
|
||||
public function getLightLevel(){
|
||||
return 15;
|
||||
}
|
||||
|
||||
public function getName(){
|
||||
return "Lava";
|
||||
}
|
||||
|
||||
public function onEntityCollide(Entity $entity){
|
||||
$entity->fallDistance *= 0.5;
|
||||
$ev = new EntityDamageByBlockEvent($this, $entity, EntityDamageEvent::CAUSE_LAVA, 4);
|
||||
$entity->attack($ev->getFinalDamage(), $ev);
|
||||
if(!$entity->hasEffect(Effect::FIRE_RESISTANCE)){
|
||||
$ev = new EntityDamageByBlockEvent($this, $entity, EntityDamageEvent::CAUSE_LAVA, 4);
|
||||
$entity->attack($ev->getFinalDamage(), $ev);
|
||||
}
|
||||
|
||||
$ev = new EntityCombustByBlockEvent($this, $entity, 15);
|
||||
Server::getInstance()->getPluginManager()->callEvent($ev);
|
||||
@ -47,9 +59,7 @@ class Lava extends Liquid{
|
||||
$entity->setOnFire($ev->getDuration());
|
||||
}
|
||||
|
||||
if($entity instanceof Player){
|
||||
$entity->onGround = true;
|
||||
}
|
||||
$entity->resetFallDistance();
|
||||
}
|
||||
|
||||
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){
|
||||
|
@ -23,6 +23,7 @@ namespace pocketmine\block;
|
||||
|
||||
use pocketmine\event\block\LeavesDecayEvent;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\item\Tool;
|
||||
use pocketmine\level\Level;
|
||||
use pocketmine\Player;
|
||||
use pocketmine\Server;
|
||||
@ -35,16 +36,28 @@ class Leaves extends Transparent{
|
||||
const ACACIA = 0;
|
||||
const DARK_OAK = 1;
|
||||
|
||||
protected $id = self::LEAVES;
|
||||
|
||||
public function __construct($meta = 0){
|
||||
parent::__construct(self::LEAVES, $meta, "Leaves");
|
||||
$names = [
|
||||
$this->meta = $meta;
|
||||
}
|
||||
|
||||
public function getHardness(){
|
||||
return 0.2;
|
||||
}
|
||||
|
||||
public function getToolType(){
|
||||
return Tool::TYPE_SHEARS;
|
||||
}
|
||||
|
||||
public function getName(){
|
||||
static $names = [
|
||||
self::OAK => "Oak Leaves",
|
||||
self::SPRUCE => "Spruce Leaves",
|
||||
self::BIRCH => "Birch Leaves",
|
||||
self::JUNGLE => "Jungle Leaves",
|
||||
];
|
||||
$this->name = $names[$this->meta & 0x03];
|
||||
$this->hardness = 1;
|
||||
return $names[$this->meta & 0x03];
|
||||
}
|
||||
|
||||
private function findLog(Block $pos, array $visited, $distance, &$check, $fromSide = null){
|
||||
@ -53,11 +66,11 @@ class Leaves extends Transparent{
|
||||
if(isset($visited[$index])){
|
||||
return false;
|
||||
}
|
||||
if($pos->getID() === self::WOOD){
|
||||
if($pos->getId() === self::WOOD){
|
||||
return true;
|
||||
}elseif($pos->getID() === self::LEAVES and $distance < 3){
|
||||
}elseif($pos->getId() === self::LEAVES and $distance < 3){
|
||||
$visited[$index] = true;
|
||||
$down = $pos->getSide(0)->getID();
|
||||
$down = $pos->getSide(0)->getId();
|
||||
if($down === Item::WOOD){
|
||||
return true;
|
||||
}
|
||||
|
@ -29,14 +29,18 @@ use pocketmine\Server;
|
||||
|
||||
class Leaves2 extends Leaves{
|
||||
|
||||
protected $id = self::LEAVES2;
|
||||
|
||||
public function __construct($meta = 0){
|
||||
Transparent::__construct(self::LEAVES, $meta, "Leaves");
|
||||
$names = [
|
||||
$this->meta = $meta;
|
||||
}
|
||||
|
||||
public function getName(){
|
||||
static $names = [
|
||||
self::ACACIA => "Acacia Leaves",
|
||||
self::DARK_OAK => "Dark Oak Leaves",
|
||||
];
|
||||
$this->name = $names[$this->meta & 0x03];
|
||||
$this->hardness = 1;
|
||||
return $names[$this->meta & 0x01];
|
||||
}
|
||||
|
||||
private function findLog(Block $pos, array $visited, $distance, &$check, $fromSide = null){
|
||||
@ -45,11 +49,11 @@ class Leaves2 extends Leaves{
|
||||
if(isset($visited[$index])){
|
||||
return false;
|
||||
}
|
||||
if($pos->getID() === self::WOOD2){
|
||||
if($pos->getId() === self::WOOD2){
|
||||
return true;
|
||||
}elseif($pos->getID() === self::LEAVES2 and $distance < 3){
|
||||
}elseif($pos->getId() === self::LEAVES2 and $distance < 3){
|
||||
$visited[$index] = true;
|
||||
$down = $pos->getSide(0)->getID();
|
||||
$down = $pos->getSide(0)->getId();
|
||||
if($down === Item::WOOD2){
|
||||
return true;
|
||||
}
|
||||
|
@ -28,13 +28,25 @@ use pocketmine\level\Level;
|
||||
use pocketmine\math\Vector3;
|
||||
|
||||
abstract class Liquid extends Transparent{
|
||||
public $hasEntityCollision = true;
|
||||
|
||||
public $isLiquid = true;
|
||||
public $breakable = false;
|
||||
public $isReplaceable = true;
|
||||
public $isSolid = false;
|
||||
public $isFullBlock = true;
|
||||
/** @var Vector3 */
|
||||
private $temporalVector = null;
|
||||
|
||||
public function hasEntityCollision(){
|
||||
return true;
|
||||
}
|
||||
|
||||
public function isBreakable(Item $item){
|
||||
return false;
|
||||
}
|
||||
|
||||
public function canBeReplaced(){
|
||||
return true;
|
||||
}
|
||||
|
||||
public function isSolid(){
|
||||
return false;
|
||||
}
|
||||
|
||||
public $adjacentSources = 0;
|
||||
public $isOptimalFlowDirection = [0, 0, 0, 0];
|
||||
@ -54,7 +66,7 @@ abstract class Liquid extends Transparent{
|
||||
$pos = $this->getLevel()->getBlock($pos);
|
||||
}
|
||||
|
||||
if($pos->getID() !== $this->getID()){
|
||||
if($pos->getId() !== $this->getId()){
|
||||
return -1;
|
||||
}else{
|
||||
return $pos->getDamage();
|
||||
@ -66,7 +78,7 @@ abstract class Liquid extends Transparent{
|
||||
$pos = $this->getLevel()->getBlock($pos);
|
||||
}
|
||||
|
||||
if($pos->getID() !== $this->getID()){
|
||||
if($pos->getId() !== $this->getId()){
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -82,6 +94,10 @@ abstract class Liquid extends Transparent{
|
||||
public function getFlowVector(){
|
||||
$vector = new Vector3(0, 0, 0);
|
||||
|
||||
if($this->temporalVector === null){
|
||||
$this->temporalVector = new Vector3(0, 0, 0);
|
||||
}
|
||||
|
||||
$decay = $this->getEffectiveFlowDecay($this);
|
||||
|
||||
for($j = 0; $j < 4; ++$j){
|
||||
@ -99,46 +115,50 @@ abstract class Liquid extends Transparent{
|
||||
}elseif($j === 3){
|
||||
++$z;
|
||||
}
|
||||
$sideBlock = $this->getLevel()->getBlock(new Vector3($x, $y, $z));
|
||||
$sideBlock = $this->getLevel()->getBlock($this->temporalVector->setComponents($x, $y, $z));
|
||||
$blockDecay = $this->getEffectiveFlowDecay($sideBlock);
|
||||
|
||||
if($blockDecay < 0){
|
||||
if(!$sideBlock->isFlowable){
|
||||
if(!$sideBlock->canBeFlowedInto()){
|
||||
continue;
|
||||
}
|
||||
|
||||
$blockDecay = $this->getEffectiveFlowDecay($sideBlock->getSide(0));
|
||||
$blockDecay = $this->getEffectiveFlowDecay($this->getLevel()->getBlock($this->temporalVector->setComponents($x, $y - 1, $z)));
|
||||
|
||||
if($blockDecay >= 0){
|
||||
$realDecay = $blockDecay - ($decay - 8);
|
||||
$vector = $vector->add(($sideBlock->x - $this->x) * $realDecay, ($sideBlock->y - $this->y) * $realDecay, ($sideBlock->z - $this->z) * $realDecay);
|
||||
$vector->x += ($sideBlock->x - $this->x) * $realDecay;
|
||||
$vector->y += ($sideBlock->y - $this->y) * $realDecay;
|
||||
$vector->z += ($sideBlock->z - $this->z) * $realDecay;
|
||||
}
|
||||
|
||||
continue;
|
||||
}else{
|
||||
$realDecay = $blockDecay - $decay;
|
||||
$vector = $vector->add(($sideBlock->x - $this->x) * $realDecay, ($sideBlock->y - $this->y) * $realDecay, ($sideBlock->z - $this->z) * $realDecay);
|
||||
$vector->x += ($sideBlock->x - $this->x) * $realDecay;
|
||||
$vector->y += ($sideBlock->y - $this->y) * $realDecay;
|
||||
$vector->z += ($sideBlock->z - $this->z) * $realDecay;
|
||||
}
|
||||
}
|
||||
|
||||
if($this->getDamage() >= 8){
|
||||
$falling = false;
|
||||
|
||||
if(!$this->getLevel()->getBlock($this->add(0, 0, -1))->isFlowable){
|
||||
if(!$this->getLevel()->getBlock($this->temporalVector->setComponents($this->x, $this->y, $this->z - 1))->canBeFlowedInto()){
|
||||
$falling = true;
|
||||
}elseif(!$this->getLevel()->getBlock($this->add(0, 0, 1))->isFlowable){
|
||||
}elseif(!$this->getLevel()->getBlock($this->temporalVector->setComponents($this->x, $this->y, $this->z + 1))->canBeFlowedInto()){
|
||||
$falling = true;
|
||||
}elseif(!$this->getLevel()->getBlock($this->add(-1, 0, 0))->isFlowable){
|
||||
}elseif(!$this->getLevel()->getBlock($this->temporalVector->setComponents($this->x - 1, $this->y, $this->z))->canBeFlowedInto()){
|
||||
$falling = true;
|
||||
}elseif(!$this->getLevel()->getBlock($this->add(1, 0, 0))->isFlowable){
|
||||
}elseif(!$this->getLevel()->getBlock($this->temporalVector->setComponents($this->x + 1, $this->y, $this->z))->canBeFlowedInto()){
|
||||
$falling = true;
|
||||
}elseif(!$this->getLevel()->getBlock($this->add(0, 1, -1))->isFlowable){
|
||||
}elseif(!$this->getLevel()->getBlock($this->temporalVector->setComponents($this->x, $this->y + 1, $this->z - 1))->canBeFlowedInto()){
|
||||
$falling = true;
|
||||
}elseif(!$this->getLevel()->getBlock($this->add(0, 1, 1))->isFlowable){
|
||||
}elseif(!$this->getLevel()->getBlock($this->temporalVector->setComponents($this->x, $this->y + 1, $this->z + 1))->canBeFlowedInto()){
|
||||
$falling = true;
|
||||
}elseif(!$this->getLevel()->getBlock($this->add(-1, 1, 0))->isFlowable){
|
||||
}elseif(!$this->getLevel()->getBlock($this->temporalVector->setComponents($this->x - 1, $this->y + 1, $this->z))->canBeFlowedInto()){
|
||||
$falling = true;
|
||||
}elseif(!$this->getLevel()->getBlock($this->add(1, 1, 0))->isFlowable){
|
||||
}elseif(!$this->getLevel()->getBlock($this->temporalVector->setComponents($this->x + 1, $this->y + 1, $this->z))->canBeFlowedInto()){
|
||||
$falling = true;
|
||||
}
|
||||
|
||||
@ -172,6 +192,10 @@ abstract class Liquid extends Transparent{
|
||||
$this->checkForHarden();
|
||||
$this->getLevel()->scheduleUpdate($this, $this->tickRate());
|
||||
}elseif($type === Level::BLOCK_UPDATE_SCHEDULED){
|
||||
if($this->temporalVector === null){
|
||||
$this->temporalVector = new Vector3(0, 0, 0);
|
||||
}
|
||||
|
||||
$decay = $this->getFlowDecay($this);
|
||||
$multiplier = $this instanceof Lava ? 2 : 1;
|
||||
|
||||
@ -180,10 +204,10 @@ abstract class Liquid extends Transparent{
|
||||
if($decay > 0){
|
||||
$smallestFlowDecay = -100;
|
||||
$this->adjacentSources = 0;
|
||||
$smallestFlowDecay = $this->getSmallestFlowDecay($this->getSide(4), $smallestFlowDecay);
|
||||
$smallestFlowDecay = $this->getSmallestFlowDecay($this->getSide(5), $smallestFlowDecay);
|
||||
$smallestFlowDecay = $this->getSmallestFlowDecay($this->getSide(2), $smallestFlowDecay);
|
||||
$smallestFlowDecay = $this->getSmallestFlowDecay($this->getSide(3), $smallestFlowDecay);
|
||||
$smallestFlowDecay = $this->getSmallestFlowDecay($this->level->getBlock($this->temporalVector->setComponents($this->x, $this->y, $this->z - 1)), $smallestFlowDecay);
|
||||
$smallestFlowDecay = $this->getSmallestFlowDecay($this->level->getBlock($this->temporalVector->setComponents($this->x, $this->y, $this->z + 1)), $smallestFlowDecay);
|
||||
$smallestFlowDecay = $this->getSmallestFlowDecay($this->level->getBlock($this->temporalVector->setComponents($this->x - 1, $this->y, $this->z)), $smallestFlowDecay);
|
||||
$smallestFlowDecay = $this->getSmallestFlowDecay($this->level->getBlock($this->temporalVector->setComponents($this->x + 1, $this->y, $this->z)), $smallestFlowDecay);
|
||||
|
||||
$k = $smallestFlowDecay + $multiplier;
|
||||
|
||||
@ -191,7 +215,7 @@ abstract class Liquid extends Transparent{
|
||||
$k = -1;
|
||||
}
|
||||
|
||||
if(($topFlowDecay = $this->getFlowDecay($this->getSide(1))) >= 0){
|
||||
if(($topFlowDecay = $this->getFlowDecay($this->level->getBlock($this->level->getBlock($this->temporalVector->setComponents($this->x, $this->y + 1, $this->z))))) >= 0){
|
||||
if($topFlowDecay >= 8){
|
||||
$k = $topFlowDecay;
|
||||
}else{
|
||||
@ -200,8 +224,8 @@ abstract class Liquid extends Transparent{
|
||||
}
|
||||
|
||||
if($this->adjacentSources >= 2 and $this instanceof Water){
|
||||
$bottomBlock = $this->getSide(0);
|
||||
if($bottomBlock->isSolid){
|
||||
$bottomBlock = $this->level->getBlock($this->level->getBlock($this->temporalVector->setComponents($this->x, $this->y - 1, $this->z)));
|
||||
if($bottomBlock->isSolid()){
|
||||
$k = 0;
|
||||
}elseif($bottomBlock instanceof Water and $bottomBlock->getDamage() === 0){
|
||||
$k = 0;
|
||||
@ -216,7 +240,7 @@ abstract class Liquid extends Transparent{
|
||||
if($k !== $decay){
|
||||
$decay = $k;
|
||||
if($decay < 0){
|
||||
$this->getLevel()->setBlock($this, Block::get(Item::AIR), true);
|
||||
$this->getLevel()->setBlock($this, new Air(), true);
|
||||
}else{
|
||||
$this->getLevel()->setBlock($this, Block::get($this->id, $decay), true);
|
||||
$this->getLevel()->scheduleUpdate($this, $this->tickRate());
|
||||
@ -229,9 +253,9 @@ abstract class Liquid extends Transparent{
|
||||
//$this->updateFlow();
|
||||
}
|
||||
|
||||
$bottomBlock = $this->getSide(0);
|
||||
$bottomBlock = $this->level->getBlock($this->temporalVector->setComponents($this->x, $this->y - 1, $this->z));
|
||||
|
||||
if($bottomBlock->isFlowable or $bottomBlock instanceof Liquid){
|
||||
if($bottomBlock->canBeFlowedInto() or $bottomBlock instanceof Liquid){
|
||||
if($this instanceof Lava and $bottomBlock instanceof Water){
|
||||
$this->getLevel()->setBlock($bottomBlock, Block::get(Item::STONE), true);
|
||||
return;
|
||||
@ -244,7 +268,7 @@ abstract class Liquid extends Transparent{
|
||||
$this->getLevel()->setBlock($bottomBlock, Block::get($this->id, $decay + 8), true);
|
||||
$this->getLevel()->scheduleUpdate($bottomBlock, $this->tickRate());
|
||||
}
|
||||
}elseif($decay >= 0 and ($decay === 0 or !$bottomBlock->isFlowable)){
|
||||
}elseif($decay >= 0 and ($decay === 0 or !$bottomBlock->canBeFlowedInto())){
|
||||
$flags = $this->getOptimalFlowDirections();
|
||||
|
||||
$l = $decay + $multiplier;
|
||||
@ -259,19 +283,19 @@ abstract class Liquid extends Transparent{
|
||||
}
|
||||
|
||||
if($flags[0]){
|
||||
$this->flowIntoBlock($this->getSide(4), $l);
|
||||
$this->flowIntoBlock($this->level->getBlock($this->temporalVector->setComponents($this->x - 1, $this->y, $this->z)), $l);
|
||||
}
|
||||
|
||||
if($flags[1]){
|
||||
$this->flowIntoBlock($this->getSide(5), $l);
|
||||
$this->flowIntoBlock($this->level->getBlock($this->temporalVector->setComponents($this->x + 1, $this->y, $this->z)), $l);
|
||||
}
|
||||
|
||||
if($flags[2]){
|
||||
$this->flowIntoBlock($this->getSide(2), $l);
|
||||
$this->flowIntoBlock($this->level->getBlock($this->temporalVector->setComponents($this->x, $this->y, $this->z - 1)), $l);
|
||||
}
|
||||
|
||||
if($flags[3]){
|
||||
$this->flowIntoBlock($this->getSide(3), $l);
|
||||
$this->flowIntoBlock($this->level->getBlock($this->temporalVector->setComponents($this->x, $this->y, $this->z + 1)), $l);
|
||||
}
|
||||
}
|
||||
|
||||
@ -281,12 +305,12 @@ abstract class Liquid extends Transparent{
|
||||
}
|
||||
|
||||
private function flowIntoBlock(Block $block, $newFlowDecay){
|
||||
if($block->isFlowable){
|
||||
if($block->getID() > 0){
|
||||
if($block->canBeFlowedInto()){
|
||||
if($block->getId() > 0){
|
||||
$this->getLevel()->useBreakOn($block);
|
||||
}
|
||||
|
||||
$this->getLevel()->setBlock($block, Block::get($this->id, $newFlowDecay), true);
|
||||
$this->getLevel()->setBlock($block, Block::get($this->getId(), $newFlowDecay), true);
|
||||
$this->getLevel()->scheduleUpdate($block, $this->tickRate());
|
||||
}
|
||||
}
|
||||
@ -314,13 +338,13 @@ abstract class Liquid extends Transparent{
|
||||
}elseif($j === 3){
|
||||
++$z;
|
||||
}
|
||||
$blockSide = $this->getLevel()->getBlock(new Vector3($x, $y, $z));
|
||||
$blockSide = $this->getLevel()->getBlock($this->temporalVector->setComponents($x, $y, $z));
|
||||
|
||||
if(!$blockSide->isFlowable and !($blockSide instanceof Liquid)){
|
||||
if(!$blockSide->canBeFlowedInto() and !($blockSide instanceof Liquid)){
|
||||
continue;
|
||||
}elseif($blockSide instanceof Liquid and $blockSide->getDamage() === 0){
|
||||
continue;
|
||||
}elseif($blockSide->getSide(0)->isFlowable){
|
||||
}elseif($this->getLevel()->getBlock($this->temporalVector->setComponents($x, $y - 1, $z))->canBeFlowedInto()){
|
||||
return $accumulatedCost;
|
||||
}
|
||||
|
||||
@ -339,7 +363,15 @@ abstract class Liquid extends Transparent{
|
||||
return $cost;
|
||||
}
|
||||
|
||||
public function getHardness(){
|
||||
return 100;
|
||||
}
|
||||
|
||||
private function getOptimalFlowDirections(){
|
||||
if($this->temporalVector === null){
|
||||
$this->temporalVector = new Vector3(0, 0, 0);
|
||||
}
|
||||
|
||||
for($j = 0; $j < 4; ++$j){
|
||||
$this->flowCost[$j] = 1000;
|
||||
|
||||
@ -356,13 +388,13 @@ abstract class Liquid extends Transparent{
|
||||
}elseif($j === 3){
|
||||
++$z;
|
||||
}
|
||||
$block = $this->getLevel()->getBlock(new Vector3($x, $y, $z));
|
||||
$block = $this->getLevel()->getBlock($this->temporalVector->setComponents($x, $y, $z));
|
||||
|
||||
if(!$block->isFlowable and !($block instanceof Liquid)){
|
||||
if(!$block->canBeFlowedInto() and !($block instanceof Liquid)){
|
||||
continue;
|
||||
}elseif($block instanceof Liquid and $block->getDamage() === 0){
|
||||
continue;
|
||||
}elseif($block->getSide(0)->isFlowable){
|
||||
}elseif($this->getLevel()->getBlock($this->temporalVector->setComponents($x, $y - 1, $z))->canBeFlowedInto()){
|
||||
$this->flowCost[$j] = 0;
|
||||
}else{
|
||||
$this->flowCost[$j] = $this->calculateFlowCost($block, 1, $j);
|
||||
@ -418,4 +450,8 @@ abstract class Liquid extends Transparent{
|
||||
public function getBoundingBox(){
|
||||
return null;
|
||||
}
|
||||
|
||||
public function getDrops(Item $item){
|
||||
return [];
|
||||
}
|
||||
}
|
@ -22,12 +22,31 @@
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\item\Tool;
|
||||
use pocketmine\Player;
|
||||
|
||||
class LitPumpkin extends Solid{
|
||||
public function __construct(){
|
||||
parent::__construct(self::LIT_PUMPKIN, "Jack o'Lantern");
|
||||
$this->hardness = 5;
|
||||
|
||||
protected $id = self::LIT_PUMPKIN;
|
||||
|
||||
public function getLightLevel(){
|
||||
return 15;
|
||||
}
|
||||
|
||||
public function getHardness(){
|
||||
return 1;
|
||||
}
|
||||
|
||||
public function getToolType(){
|
||||
return Tool::TYPE_AXE;
|
||||
}
|
||||
|
||||
public function getName(){
|
||||
return "Jack o'Lantern";
|
||||
}
|
||||
|
||||
public function __construct($meta = 0){
|
||||
$this->meta = $meta;
|
||||
}
|
||||
|
||||
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){
|
||||
|
@ -22,11 +22,26 @@
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\item\Tool;
|
||||
|
||||
class Melon extends Transparent{
|
||||
|
||||
protected $id = self::MELON_BLOCK;
|
||||
|
||||
public function __construct(){
|
||||
parent::__construct(self::MELON_BLOCK, 0, "Melon Block");
|
||||
$this->hardness = 5;
|
||||
|
||||
}
|
||||
|
||||
public function getName(){
|
||||
return "Melon Block";
|
||||
}
|
||||
|
||||
public function getHardness(){
|
||||
return 1;
|
||||
}
|
||||
|
||||
public function getToolType(){
|
||||
return Tool::TYPE_AXE;
|
||||
}
|
||||
|
||||
public function getDrops(Item $item){
|
||||
|
@ -27,13 +27,20 @@ use pocketmine\level\Level;
|
||||
use pocketmine\Server;
|
||||
|
||||
class MelonStem extends Crops{
|
||||
|
||||
protected $id = self::MELON_STEM;
|
||||
|
||||
public function getName(){
|
||||
return "Melon Stem";
|
||||
}
|
||||
|
||||
public function __construct($meta = 0){
|
||||
parent::__construct(self::MELON_STEM, $meta, "Melon Stem");
|
||||
$this->meta = $meta;
|
||||
}
|
||||
|
||||
public function onUpdate($type){
|
||||
if($type === Level::BLOCK_UPDATE_NORMAL){
|
||||
if($this->getSide(0)->isTransparent === true){
|
||||
if($this->getSide(0)->isTransparent() === true){
|
||||
$this->getLevel()->useBreakOn($this);
|
||||
return Level::BLOCK_UPDATE_NORMAL;
|
||||
}
|
||||
@ -51,13 +58,13 @@ class MelonStem extends Crops{
|
||||
}else{
|
||||
for($side = 2; $side <= 5; ++$side){
|
||||
$b = $this->getSide($side);
|
||||
if($b->getID() === self::MELON_BLOCK){
|
||||
if($b->getId() === self::MELON_BLOCK){
|
||||
return Level::BLOCK_UPDATE_RANDOM;
|
||||
}
|
||||
}
|
||||
$side = $this->getSide(mt_rand(2, 5));
|
||||
$d = $side->getSide(0);
|
||||
if($side->getID() === self::AIR and ($d->getID() === self::FARMLAND or $d->getID() === self::GRASS or $d->getID() === self::DIRT)){
|
||||
if($side->getId() === self::AIR and ($d->getId() === self::FARMLAND or $d->getId() === self::GRASS or $d->getId() === self::DIRT)){
|
||||
Server::getInstance()->getPluginManager()->callEvent($ev = new BlockGrowEvent($side, new Melon()));
|
||||
if(!$ev->isCancelled()){
|
||||
$this->getLevel()->setBlock($side, $ev->getNewState(), true);
|
||||
|
@ -22,31 +22,29 @@
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\item\Tool;
|
||||
|
||||
class MonsterSpawner extends Solid{
|
||||
public function __construct(){
|
||||
parent::__construct(self::MONSTER_SPAWNER, 0, "Monster Spawner");
|
||||
$this->hardness = 25;
|
||||
|
||||
protected $id = self::MONSTER_SPAWNER;
|
||||
|
||||
public function __construct($meta = 0){
|
||||
$this->meta = $meta;
|
||||
}
|
||||
|
||||
public function getBreakTime(Item $item){
|
||||
switch($item->isPickaxe()){
|
||||
case 5:
|
||||
return 0.95;
|
||||
case 4:
|
||||
return 1.25;
|
||||
case 3:
|
||||
return 1.9;
|
||||
case 2:
|
||||
return 0.65;
|
||||
case 1:
|
||||
return 3.75;
|
||||
default:
|
||||
return 25;
|
||||
}
|
||||
}
|
||||
public function getHardness(){
|
||||
return 5;
|
||||
}
|
||||
|
||||
public function getDrops(Item $item){
|
||||
return [];
|
||||
}
|
||||
public function getToolType(){
|
||||
return Tool::TYPE_PICKAXE;
|
||||
}
|
||||
|
||||
public function getName(){
|
||||
return "Monster Spawner";
|
||||
}
|
||||
|
||||
public function getDrops(Item $item){
|
||||
return [];
|
||||
}
|
||||
}
|
@ -22,29 +22,26 @@
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\item\Tool;
|
||||
|
||||
class MossStone extends Solid{
|
||||
|
||||
protected $id = self::MOSS_STONE;
|
||||
|
||||
public function __construct($meta = 0){
|
||||
parent::__construct(self::MOSS_STONE, $meta, "Moss Stone");
|
||||
$this->hardness = 30;
|
||||
$this->meta = $meta;
|
||||
}
|
||||
|
||||
public function getBreakTime(Item $item){
|
||||
public function getName(){
|
||||
return "Moss Stone";
|
||||
}
|
||||
|
||||
switch($item->isPickaxe()){
|
||||
case 5:
|
||||
return 0.4;
|
||||
case 4:
|
||||
return 0.5;
|
||||
case 3:
|
||||
return 0.75;
|
||||
case 2:
|
||||
return 0.25;
|
||||
case 1:
|
||||
return 1.5;
|
||||
default:
|
||||
return 10;
|
||||
}
|
||||
public function getHardness(){
|
||||
return 2;
|
||||
}
|
||||
|
||||
public function getToolType(){
|
||||
return Tool::TYPE_PICKAXE;
|
||||
}
|
||||
|
||||
public function getDrops(Item $item){
|
||||
|
@ -23,14 +23,29 @@ namespace pocketmine\block;
|
||||
|
||||
use pocketmine\event\block\BlockSpreadEvent;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\item\Tool;
|
||||
use pocketmine\level\Level;
|
||||
use pocketmine\math\Vector3;
|
||||
use pocketmine\Server;
|
||||
|
||||
class Mycelium extends Solid{
|
||||
|
||||
protected $id = self::MYCELIUM;
|
||||
|
||||
public function __construct(){
|
||||
parent::__construct(self::MYCELIUM, 0, "Mycelium");
|
||||
$this->hardness = 2.5;
|
||||
|
||||
}
|
||||
|
||||
public function getName(){
|
||||
return "Mycelium";
|
||||
}
|
||||
|
||||
public function getToolType(){
|
||||
return Tool::TYPE_SHOVEL;
|
||||
}
|
||||
|
||||
public function getHardness(){
|
||||
return 0.6;
|
||||
}
|
||||
|
||||
public function getDrops(Item $item){
|
||||
@ -46,7 +61,7 @@ class Mycelium extends Solid{
|
||||
$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){
|
||||
if($block->getId() === Block::DIRT){
|
||||
if($block->getSide(1) instanceof Transparent){
|
||||
Server::getInstance()->getPluginManager()->callEvent($ev = new BlockSpreadEvent($block, $this, new Mycelium()));
|
||||
if(!$ev->isCancelled()){
|
||||
|
@ -22,29 +22,26 @@
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\item\Tool;
|
||||
|
||||
class NetherBrick extends Solid{
|
||||
|
||||
protected $id = self::NETHER_BRICKS;
|
||||
|
||||
public function __construct(){
|
||||
parent::__construct(self::NETHER_BRICKS, 0, "Nether Bricks");
|
||||
$this->hardness = 30;
|
||||
|
||||
}
|
||||
|
||||
public function getBreakTime(Item $item){
|
||||
public function getToolType(){
|
||||
return Tool::TYPE_PICKAXE;
|
||||
}
|
||||
|
||||
switch($item->isPickaxe()){
|
||||
case 5:
|
||||
return 0.4;
|
||||
case 4:
|
||||
return 0.5;
|
||||
case 3:
|
||||
return 0.75;
|
||||
case 2:
|
||||
return 0.25;
|
||||
case 1:
|
||||
return 1.5;
|
||||
default:
|
||||
return 10;
|
||||
}
|
||||
public function getName(){
|
||||
return "Nether Bricks";
|
||||
}
|
||||
|
||||
public function getHardness(){
|
||||
return 2;
|
||||
}
|
||||
|
||||
public function getDrops(Item $item){
|
||||
|
@ -22,9 +22,26 @@
|
||||
namespace pocketmine\block;
|
||||
|
||||
|
||||
use pocketmine\item\Tool;
|
||||
|
||||
class NetherBrickStairs extends Stair{
|
||||
|
||||
protected $id = self::NETHER_BRICKS_STAIRS;
|
||||
|
||||
public function getName(){
|
||||
return "Nether Bricks Stairs";
|
||||
}
|
||||
|
||||
public function getHardness(){
|
||||
return 2;
|
||||
}
|
||||
|
||||
public function getToolType(){
|
||||
return Tool::TYPE_PICKAXE;
|
||||
}
|
||||
|
||||
public function __construct($meta = 0){
|
||||
parent::__construct(self::NETHER_BRICKS_STAIRS, $meta, "Nether Bricks Stairs");
|
||||
$this->meta = $meta;
|
||||
}
|
||||
|
||||
}
|
@ -23,9 +23,19 @@ namespace pocketmine\block;
|
||||
|
||||
|
||||
class NetherReactor extends Solid{
|
||||
|
||||
protected $id = self::NETHER_REACTOR;
|
||||
|
||||
public function __construct($meta = 0){
|
||||
parent::__construct(self::NETHER_REACTOR, $meta, "Nether Reactor");
|
||||
$this->isActivable = true;
|
||||
$this->meta = $meta;
|
||||
}
|
||||
|
||||
public function getName(){
|
||||
return "Nether Reactor";
|
||||
}
|
||||
|
||||
public function canBeActivated(){
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
@ -22,29 +22,26 @@
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\item\Tool;
|
||||
|
||||
class Netherrack extends Solid{
|
||||
|
||||
protected $id = self::NETHERRACK;
|
||||
|
||||
public function __construct(){
|
||||
parent::__construct(self::NETHERRACK, 0, "Netherrack");
|
||||
$this->hardness = 2;
|
||||
|
||||
}
|
||||
|
||||
public function getBreakTime(Item $item){
|
||||
public function getName(){
|
||||
return "Netherrack";
|
||||
}
|
||||
|
||||
switch($item->isPickaxe()){
|
||||
case 5:
|
||||
return 0.1;
|
||||
case 4:
|
||||
return 0.1;
|
||||
case 3:
|
||||
return 0.15;
|
||||
case 2:
|
||||
return 0.05;
|
||||
case 1:
|
||||
return 0.3;
|
||||
default:
|
||||
return 2;
|
||||
}
|
||||
public function getHardness(){
|
||||
return 2;
|
||||
}
|
||||
|
||||
public function getToolType(){
|
||||
return Tool::TYPE_PICKAXE;
|
||||
}
|
||||
|
||||
public function getDrops(Item $item){
|
||||
|
@ -22,20 +22,26 @@
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\item\Tool;
|
||||
|
||||
class Obsidian extends Solid{
|
||||
|
||||
protected $id = self::OBSIDIAN;
|
||||
|
||||
public function __construct(){
|
||||
parent::__construct(self::OBSIDIAN, 0, "Obsidian");
|
||||
$this->hardness = 6000;
|
||||
|
||||
}
|
||||
|
||||
public function getBreakTime(Item $item){
|
||||
public function getName(){
|
||||
return "Obsidian";
|
||||
}
|
||||
|
||||
if($item->isPickaxe() >= 5){
|
||||
return 9.4;
|
||||
}else{
|
||||
return 250;
|
||||
}
|
||||
public function getToolType(){
|
||||
return Tool::TYPE_PICKAXE;
|
||||
}
|
||||
|
||||
public function getHardness(){
|
||||
return 50;
|
||||
}
|
||||
|
||||
public function getDrops(Item $item){
|
||||
|
@ -22,6 +22,8 @@
|
||||
namespace pocketmine\block;
|
||||
|
||||
|
||||
use pocketmine\item\Tool;
|
||||
|
||||
class Planks extends Solid{
|
||||
const OAK = 0;
|
||||
const SPRUCE = 1;
|
||||
@ -30,18 +32,32 @@ class Planks extends Solid{
|
||||
const ACACIA = 4;
|
||||
const DARK_OAK = 5;
|
||||
|
||||
protected $id = self::WOODEN_PLANKS;
|
||||
|
||||
public function __construct($meta = 0){
|
||||
parent::__construct(self::PLANKS, $meta, "Wood Planks");
|
||||
$names = [
|
||||
$this->meta = $meta;
|
||||
}
|
||||
|
||||
public function getHardness(){
|
||||
return 2;
|
||||
}
|
||||
|
||||
public function getToolType(){
|
||||
return Tool::TYPE_AXE;
|
||||
}
|
||||
|
||||
public function getName(){
|
||||
static $names = [
|
||||
self::OAK => "Oak Wood Planks",
|
||||
self::SPRUCE => "Spruce Wood Planks",
|
||||
self::BIRCH => "Birch Wood Planks",
|
||||
self::JUNGLE => "Jungle Wood Planks",
|
||||
self::ACACIA => "Acacia Wood Planks",
|
||||
self::DARK_OAK => "Jungle Wood Planks",
|
||||
"",
|
||||
""
|
||||
];
|
||||
$this->name = $names[$this->meta & 0x07];
|
||||
$this->hardness = 15;
|
||||
return $names[$this->meta & 0x07];
|
||||
}
|
||||
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user