mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-14 13:25:11 +00:00
Compare commits
1087 Commits
Alpha_1.4d
...
api/2.0.0
Author | SHA1 | Date | |
---|---|---|---|
6fb41c5c7f | |||
df8e1e8702 | |||
ef8227a074 | |||
80d6f8dfb3 | |||
e2d079a7df | |||
ee9ba9f1a0 | |||
292a212827 | |||
ac482621a1 | |||
754ff9b4c4 | |||
aade3fe390 | |||
8441169365 | |||
e51c6b4b42 | |||
73f24786cd | |||
13d1089d30 | |||
eb3c1f95b0 | |||
012d46dfd8 | |||
2fb3b41b8d | |||
085ff56362 | |||
23da42f8a4 | |||
f82c59bdc4 | |||
3f801ff6f4 | |||
6ba0abf587 | |||
0b06a4f703 | |||
8a0c2b7c4a | |||
8e909f05ca | |||
27b7260c0a | |||
dd22e4963f | |||
54254ffc88 | |||
9a3929d8ad | |||
913a1fdce4 | |||
6e41e6837f | |||
df7eaa7242 | |||
08e6caad88 | |||
fc08759199 | |||
09ce8fab82 | |||
781de3efab | |||
95abec1886 | |||
5e1f38bdb3 | |||
de10dfa737 | |||
a43db5ca25 | |||
ccadb5f2bb | |||
218eed1e7a | |||
d39f3059dd | |||
2c1ef0ada3 | |||
e11b76318c | |||
b766b969e2 | |||
d6c9bcbabb | |||
f00b52f04d | |||
35f0f36524 | |||
e9eaf69a41 | |||
f34f54664f | |||
7ba7eaf303 | |||
16c36d5a50 | |||
ad70e23659 | |||
ccb60ff81e | |||
eb00dee8a6 | |||
068ad5e924 | |||
ed9888a2cb | |||
41a847567c | |||
d59fd42fc6 | |||
86ec7ed771 | |||
1574a823d4 | |||
17c73e9764 | |||
6945256e30 | |||
56644fed9d | |||
e2f7d657e8 | |||
83f29fd871 | |||
a2641f923d | |||
36028679d8 | |||
542781c2b1 | |||
3640e13f17 | |||
f98f180bbd | |||
a6cd526e60 | |||
9acbd85b25 | |||
ffa835d730 | |||
80250aa78e | |||
675583293f | |||
fc42fc534b | |||
302fb9e65e | |||
fe2957c315 | |||
21c2e2d429 | |||
3a184ddf97 | |||
92ee4b3c73 | |||
420007cef8 | |||
5459576833 | |||
05530bedc6 | |||
1b4880a22f | |||
a75c713d34 | |||
ef0f74bbd8 | |||
03c19aefbf | |||
3b51d2c217 | |||
e79976bdac | |||
8807617480 | |||
cfca0a8726 | |||
28967ca495 | |||
52e8781d36 | |||
329a525ea1 | |||
d538a254ee | |||
074d7ed95c | |||
1b6e8c14f0 | |||
1082e32fd7 | |||
d5d2f46db2 | |||
e5937926cd | |||
e597314331 | |||
8a0bd85656 | |||
b7d8956f23 | |||
bc3dca4736 | |||
d5f3c19054 | |||
c7c78b1159 | |||
e2a400dd6b | |||
99855773d7 | |||
a2734f6dc0 | |||
b66ce90c94 | |||
73b97c9490 | |||
ee0d4aa124 | |||
0b42ead2ab | |||
78525e1f74 | |||
fb87165cd5 | |||
9f481fbdbe | |||
7125148756 | |||
9ca8c06f82 | |||
32a0b61c2d | |||
15d6bf663d | |||
d67fb9a721 | |||
9ff58f6ab3 | |||
b83964e527 | |||
c3e756a712 | |||
55ce453e17 | |||
e4ab7a08ec | |||
c1a484ee5c | |||
261ce1ba8b | |||
90c3e66e6b | |||
7954754d4c | |||
2ddc4455c5 | |||
c803dd8e69 | |||
2e5490fb5b | |||
4f12533ad3 | |||
8edebed11c | |||
963f7ee077 | |||
734736492a | |||
58709293cf | |||
2ea81710ad | |||
f35db4a183 | |||
815411968b | |||
cbed8d40ff | |||
680d40d070 | |||
ea8ba995ac | |||
6ae0f3c8d8 | |||
4d5da41cd0 | |||
f9d7e204c8 | |||
94b79ac28a | |||
958c3589c9 | |||
8ce02d8687 | |||
09b4d4dc7a | |||
813acc54dc | |||
c4fb469b4e | |||
04fc062b2a | |||
4e59d85cca | |||
ae9a3dbd81 | |||
84be56fefb | |||
19b2e1b4af | |||
cc8eca3084 | |||
6013213159 | |||
a7413dac92 | |||
34df516d94 | |||
85dc136631 | |||
72e9765ec8 | |||
cf3d8f449e | |||
eaef40618b | |||
f560d07c97 | |||
606948ef8e | |||
46760abafc | |||
a7e5e33db8 | |||
ddc140af5e | |||
a3ad5783b7 | |||
cbef0e25a1 | |||
6273875a22 | |||
0b9ef5b856 | |||
a3bce67d35 | |||
cd6afb2020 | |||
0bcf639a98 | |||
472fcfa4c7 | |||
8768b7fdbd | |||
86c1198648 | |||
9665dfd63e | |||
ed559fdf98 | |||
24f8de2cc3 | |||
885fc07e5c | |||
3892d5d74f | |||
c7b915639d | |||
21c3d03000 | |||
2d1b2050dc | |||
3ffdb8e552 | |||
79aa7583ec | |||
0d6f13cb4f | |||
29a5012c02 | |||
a1a1327415 | |||
16ff2d99b0 | |||
cb222601fd | |||
922e9d93d5 | |||
e137ac4c56 | |||
9501d03552 | |||
ccca3ec0bf | |||
8f24306d65 | |||
59a775f82c | |||
5baa87e9fe | |||
bdf5c46793 | |||
4bd14e7424 | |||
a18826473b | |||
9adcc19154 | |||
66b86c3685 | |||
7d18b92ea1 | |||
0348d181d4 | |||
0b9b1738b3 | |||
244cef3b00 | |||
b47cebb1d5 | |||
7f8b39a63c | |||
34dc6ea0d6 | |||
d7d05c20a9 | |||
91bda131be | |||
1a9ec65983 | |||
4e0fc6d1de | |||
fabb632286 | |||
99df6f8edc | |||
6e2ea63ce1 | |||
31ef7721b1 | |||
f1cc8ddde4 | |||
25b9946d9e | |||
5a626405e3 | |||
311d8d94dd | |||
7d0810a5af | |||
a5efd0bdf8 | |||
ff232a9f04 | |||
8889e687c9 | |||
0f993f8beb | |||
d5c2702908 | |||
62848b914d | |||
0ce343d8ca | |||
534b988a1c | |||
a9ead5567b | |||
f5429ef585 | |||
d729961bde | |||
f093a6498d | |||
4dd0469792 | |||
fe196c6404 | |||
fdf10b60dc | |||
d4163ea01c | |||
b3efb733a2 | |||
fcba9596d6 | |||
01d93d6e10 | |||
1fa467eb58 | |||
3e2cce3c2c | |||
d026e2ecf0 | |||
696edfd31f | |||
e9c981b586 | |||
75b7b03857 | |||
d1bfb304cb | |||
cba9ff393c | |||
02cb9d69a9 | |||
554bfb4855 | |||
091d0b3ff9 | |||
a65109ff34 | |||
8a3c5ab6a1 | |||
2cec6812a8 | |||
d0bfc826ea | |||
2e0ef645fa | |||
09720a2d90 | |||
9456e20770 | |||
7fd053fb09 | |||
522932d7c0 | |||
2b2a1b18e7 | |||
1b812d373c | |||
5621ab0c49 | |||
4258e22c02 | |||
ff16f2ef05 | |||
9bbaf5d00d | |||
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 | |||
f74f5cfde7 | |||
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 | |||
7e1095e28d | |||
f1519e6d13 | |||
3b9a9bcd5d | |||
263bff01c8 | |||
987d647b76 | |||
522b75645c | |||
9eed0a579c | |||
064976d32b | |||
2abb577178 | |||
127855c220 | |||
93c7a3c170 | |||
31903a764a | |||
79bc1d6c85 | |||
cc7f12739d | |||
32dae93ef9 | |||
8fd6582e74 | |||
a5369b3570 | |||
abbd33210a | |||
6b6222c09c | |||
a8c997d88a | |||
6993718a83 | |||
86afecec89 | |||
29d1fd1fc8 | |||
af4eb2ab1e | |||
f7baf46a54 | |||
75c0d8324c | |||
da4334f06b | |||
413bd3c0df | |||
1a0428654b | |||
2803a38fd1 | |||
95a5ca7889 | |||
240f14c425 | |||
cb9b6ab1d1 | |||
8a87280566 | |||
4d97827d44 | |||
f8f1e0e9df | |||
bf596ebf05 | |||
90777014b6 | |||
4a78ffd2dd | |||
7c361a52d2 | |||
13fc0df92c | |||
d5012f6fcf | |||
4569a73f3d | |||
66acb5cdd7 | |||
8601405a88 | |||
ae06681b60 | |||
01ffb14e39 | |||
ce989876af | |||
f8d6ebabf3 | |||
094b600a0c | |||
82cfe6ea9c | |||
4fba6d7c86 | |||
f72d7284b9 | |||
8f0527832f | |||
f66944368d | |||
7ab3c57b00 | |||
673b867ee8 | |||
2424c8a76c | |||
92eb5cb0b8 | |||
fd46c71120 | |||
6a4259bf24 | |||
9a65279c6a | |||
09a01be709 | |||
57d1847c50 | |||
6e8e2a79dd | |||
d8f9def7f4 | |||
8cb9dd9a14 | |||
c4c374e3fa | |||
d57e37896d | |||
022a978ffb | |||
00b282d40c | |||
8a768cea33 | |||
289bc56b4b | |||
6f64af3066 | |||
72c09045d5 | |||
5e55c3a8f0 | |||
afaa2cf722 | |||
50cfeaa393 | |||
dda8b03349 | |||
56e848488a | |||
7e4f862634 | |||
577a7a1c3d | |||
78f8d0280d | |||
0680b98380 | |||
cbe0fe5e46 | |||
7eed92e8fb | |||
f772391866 | |||
8c4faa8622 | |||
b6f7ee20fc | |||
0fce83c671 | |||
8080643cc9 | |||
5bf2174cad | |||
34ae760def | |||
a5b85c549a | |||
b9f1812f61 | |||
350cee3d41 | |||
144a871c07 | |||
69492474e4 | |||
4299ebebcc | |||
119b429ab8 | |||
8f1eb41ca5 | |||
ca92d2a0d3 | |||
db82f76c11 | |||
3f5b129cf5 | |||
f6aac8728b | |||
809fc44813 | |||
64f1ff066d | |||
a5a3f4801a | |||
23d1532ff9 | |||
ecbbcc2e8e | |||
7abf52e615 | |||
9e01e2ef49 | |||
df81b365e5 | |||
db8ac0b9cb | |||
ee4f416d93 | |||
8feea721e3 | |||
8e7077ff4b | |||
4f4a6e7446 | |||
1fc066fc37 | |||
b565844062 | |||
be948f99cc | |||
5cb428e5cc | |||
d2f4a14d66 | |||
516bb37a50 | |||
580ade9092 | |||
8f7dfe0b71 | |||
5310ba3ae6 | |||
ef97efcd96 | |||
30c3718ea8 | |||
5437567e95 | |||
e3e97a4205 | |||
fec387d2ec | |||
481e2b08ee | |||
15de0eece7 | |||
2f8267aa1e | |||
f2b573c32f | |||
34946faf94 | |||
3b47513439 | |||
7d9a98ec6b | |||
92facc94b9 | |||
d3327f450c | |||
570cab9c66 | |||
582ba100b0 | |||
4c0daa462d | |||
2e6366868d | |||
245e9b4f18 | |||
68e73d4e3a | |||
684617d370 | |||
a879104a6f |
18
.github/ISSUE_TEMPLATE.md
vendored
Normal file
18
.github/ISSUE_TEMPLATE.md
vendored
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
### Issue description
|
||||||
|
<!--- use our forum https://forums.pocketmine.net for questions -->
|
||||||
|
Write a short description about the issue
|
||||||
|
|
||||||
|
### Steps to reproduce the issue
|
||||||
|
<!--- help us find the problem by adding steps to reproduce the issue -->
|
||||||
|
1. ...
|
||||||
|
2. ...
|
||||||
|
|
||||||
|
### OS and versions
|
||||||
|
<!--- use the 'version' command in PocketMine-MP -->
|
||||||
|
* PocketMine-MP:
|
||||||
|
* PHP:
|
||||||
|
* OS:
|
||||||
|
|
||||||
|
### Crashdump, backtrace or other files
|
||||||
|
<!--- please use gist or anything else and add links here -->
|
||||||
|
* ...
|
3
.gitignore
vendored
3
.gitignore
vendored
@ -2,11 +2,12 @@ players/*
|
|||||||
worlds/*
|
worlds/*
|
||||||
plugins/*
|
plugins/*
|
||||||
bin/*
|
bin/*
|
||||||
|
timings/*
|
||||||
*.log
|
*.log
|
||||||
*.txt
|
*.txt
|
||||||
*.phar
|
*.phar
|
||||||
server.properties
|
server.properties
|
||||||
pocketmine.yml
|
/pocketmine.yml
|
||||||
|
|
||||||
# Common IDEs
|
# Common IDEs
|
||||||
.idea/*
|
.idea/*
|
||||||
|
6
.gitmodules
vendored
6
.gitmodules
vendored
@ -9,3 +9,9 @@
|
|||||||
[submodule "src/spl"]
|
[submodule "src/spl"]
|
||||||
path = src/spl
|
path = src/spl
|
||||||
url = https://github.com/PocketMine/PocketMine-SPL.git
|
url = https://github.com/PocketMine/PocketMine-SPL.git
|
||||||
|
[submodule "tests/TesterPlugin"]
|
||||||
|
path = tests/TesterPlugin
|
||||||
|
url = https://github.com/PocketMine/TesterPlugin.git
|
||||||
|
[submodule "src/pocketmine/lang/locale"]
|
||||||
|
path = src/pocketmine/lang/locale
|
||||||
|
url = https://github.com/PocketMine/PocketMine-Language.git
|
||||||
|
10
.travis.yml
10
.travis.yml
@ -1,17 +1,17 @@
|
|||||||
language: php
|
language: php
|
||||||
|
|
||||||
php:
|
php:
|
||||||
- 5.6
|
- 7.0
|
||||||
|
|
||||||
branches:
|
branches:
|
||||||
- master
|
- master
|
||||||
|
|
||||||
before_script:
|
before_script:
|
||||||
- mkdir plugins
|
- mkdir plugins
|
||||||
- wget -O plugins/DevTools.phar https://github.com/PocketMine/DevTools/releases/download/v1.9.0/DevTools_v1.9.0.phar
|
- wget -O plugins/DevTools.phar https://github.com/PocketMine/DevTools/releases/download/v1.11.0/DevTools_v1.11.0.phar
|
||||||
- pecl install channel://pecl.php.net/pthreads-2.0.10
|
- pecl install channel://pecl.php.net/pthreads-3.1.6
|
||||||
- pecl install channel://pecl.php.net/weakref-0.2.4
|
- pecl install channel://pecl.php.net/weakref-0.3.2
|
||||||
- echo | pecl install channel://pecl.php.net/yaml-1.1.1
|
- echo | pecl install channel://pecl.php.net/yaml-2.0.0RC7
|
||||||
|
|
||||||
script:
|
script:
|
||||||
- php tests/TravisTest.php
|
- php tests/TravisTest.php
|
||||||
|
@ -18,6 +18,7 @@ You must follow these guidelines if you wish to contribute to the PocketMine-MP
|
|||||||
- **No generic titles** such as "Question", "Help", "Crash Report" etc. If an issue has a generic title they will either be closed on the spot, or a collaborator will edit it to describe the actual symptom.
|
- **No generic titles** such as "Question", "Help", "Crash Report" etc. If an issue has a generic title they will either be closed on the spot, or a collaborator will edit it to describe the actual symptom.
|
||||||
- Information must be provided in the issue body, not in the title. No tags are allowed in the title, and do not change the title if the issue has been solved.
|
- Information must be provided in the issue body, not in the title. No tags are allowed in the title, and do not change the title if the issue has been solved.
|
||||||
- Similarly, no generic issue reports. It is the issue submitter's responsibility to provide us an issue that is **trackable, debuggable, reproducible, reported professionally and is an actual bug**. If you do not provide us with a summary or instructions on how to reproduce the issue, it is a support request until the actual bug has been found and therefore the issue is closed.
|
- Similarly, no generic issue reports. It is the issue submitter's responsibility to provide us an issue that is **trackable, debuggable, reproducible, reported professionally and is an actual bug**. If you do not provide us with a summary or instructions on how to reproduce the issue, it is a support request until the actual bug has been found and therefore the issue is closed.
|
||||||
|
- To express appreciation, objection, confusion or other supported reactions on pull requests, issues or comments on them, use GitHub [reactions](https://github.com/blog/2119-add-reactions-to-pull-requests-issues-and-comments) rather than posting an individual comment with an emoji only. This helps keeping the issue/pull rqeuest conversation clean and readable.
|
||||||
|
|
||||||
## Contributing Code
|
## Contributing Code
|
||||||
* Use the [Pull Request](https://github.com/PocketMine/PocketMine-MP/pull/new) system, your request will be checked and discussed.
|
* Use the [Pull Request](https://github.com/PocketMine/PocketMine-MP/pull/new) system, your request will be checked and discussed.
|
||||||
@ -34,14 +35,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.
|
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.
|
* 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)_
|
* `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.
|
* Code MUST use tabs for indenting.
|
||||||
* Long arrays MAY be split across multiple lines, where each subsequent line is indented once.
|
* Long arrays MAY be split across multiple lines, where each subsequent line is indented once.
|
||||||
* Files MUST use only the `<?php` tag.
|
* Files MUST use only the `<?php` tag.
|
||||||
* Files MUST NOT have an ending `?>` tag.
|
* Files MUST NOT have an ending `?>` tag.
|
||||||
* Code MUST use namespaces.
|
* Code MUST use namespaces.
|
||||||
* Strings SHOULD use the double quote `"` except when the single quote is required.
|
* 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
|
||||||
<?php
|
<?php
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
# 
|
# 
|
||||||
|
[](https://travis-ci.org/PocketMine/PocketMine-MP)
|
||||||
|
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
This program is free software: you can redistribute it and/or modify
|
||||||
@ -44,6 +45,7 @@ __PocketMine-MP is a free, open-source software that creates Minecraft: Pocket E
|
|||||||
|
|
||||||
## Third-party Libraries/Protocols Used
|
## Third-party Libraries/Protocols Used
|
||||||
* __[PHP Sockets](http://php.net/manual/en/book.sockets.php)__
|
* __[PHP Sockets](http://php.net/manual/en/book.sockets.php)__
|
||||||
|
* __[PHP mbstring](http://php.net/manual/en/book.mbstring.php)__
|
||||||
* __[PHP SQLite3](http://php.net/manual/en/book.sqlite3.php)__
|
* __[PHP SQLite3](http://php.net/manual/en/book.sqlite3.php)__
|
||||||
* __[PHP BCMath](http://php.net/manual/en/book.bc.php)__
|
* __[PHP BCMath](http://php.net/manual/en/book.bc.php)__
|
||||||
* __[PHP pthreads](http://pthreads.org/)__ by _[krakjoe](https://github.com/krakjoe)_: Threading for PHP - Share Nothing, Do Everything.
|
* __[PHP pthreads](http://pthreads.org/)__ by _[krakjoe](https://github.com/krakjoe)_: Threading for PHP - Share Nothing, Do Everything.
|
||||||
|
@ -14,13 +14,14 @@
|
|||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* @author PocketMine Team
|
* @author PocketMine Team
|
||||||
|
* @link http://www.pocketmine.net/
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace pocketmine;
|
namespace pocketmine;
|
||||||
|
|
||||||
|
use pocketmine\event\TranslationContainer;
|
||||||
use pocketmine\utils\TextFormat;
|
use pocketmine\utils\TextFormat;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -106,10 +107,11 @@ abstract class Achievement{
|
|||||||
|
|
||||||
public static function broadcast(Player $player, $achievementId){
|
public static function broadcast(Player $player, $achievementId){
|
||||||
if(isset(Achievement::$list[$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){
|
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{
|
}else{
|
||||||
$player->sendMessage("You have just earned the achievement " . TextFormat::GREEN . Achievement::$list[$achievementId]["name"]);
|
$player->sendMessage($translation);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
35
src/pocketmine/Collectable.php
Normal file
35
src/pocketmine/Collectable.php
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
*
|
||||||
|
* ____ _ _ __ __ _ __ __ ____
|
||||||
|
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
|
||||||
|
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
|
||||||
|
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
|
||||||
|
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* @author PocketMine Team
|
||||||
|
* @link http://www.pocketmine.net/
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace pocketmine;
|
||||||
|
|
||||||
|
abstract class Collectable extends \Threaded implements \Collectable{
|
||||||
|
|
||||||
|
private $isGarbage = false;
|
||||||
|
|
||||||
|
public function isGarbage() : bool{
|
||||||
|
return $this->isGarbage;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setGarbage(){
|
||||||
|
$this->isGarbage = true;
|
||||||
|
}
|
||||||
|
}
|
@ -23,10 +23,4 @@ namespace pocketmine;
|
|||||||
|
|
||||||
class CompatibleClassLoader extends \BaseClassLoader{
|
class CompatibleClassLoader extends \BaseClassLoader{
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated
|
|
||||||
*/
|
|
||||||
public function add($namespace, $paths){
|
|
||||||
$this->addPath(array_shift($paths));
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -14,7 +14,7 @@
|
|||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* @author PocketMine Team
|
* @author PocketMine Team
|
||||||
|
* @link http://www.pocketmine.net/
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@ -42,7 +42,10 @@ class CrashDump{
|
|||||||
$this->time = time();
|
$this->time = time();
|
||||||
$this->server = $server;
|
$this->server = $server;
|
||||||
$this->path = $this->server->getDataPath() . "CrashDump_" . date("D_M_j-H.i.s-T_Y", $this->time) . ".log";
|
$this->path = $this->server->getDataPath() . "CrashDump_" . date("D_M_j-H.i.s-T_Y", $this->time) . ".log";
|
||||||
$this->fp = fopen($this->path, "wb");
|
$this->fp = @fopen($this->path, "wb");
|
||||||
|
if(!is_resource($this->fp)){
|
||||||
|
throw new \RuntimeException("Could not create Crash Dump");
|
||||||
|
}
|
||||||
$this->data["time"] = $this->time;
|
$this->data["time"] = $this->time;
|
||||||
$this->addLine($this->server->getName() . " Crash Dump " . date("D M j H:i:s T Y", $this->time));
|
$this->addLine($this->server->getName() . " Crash Dump " . date("D M j H:i:s T Y", $this->time));
|
||||||
$this->addLine();
|
$this->addLine();
|
||||||
@ -137,7 +140,7 @@ class CrashDump{
|
|||||||
$error = $lastExceptionError;
|
$error = $lastExceptionError;
|
||||||
}else{
|
}else{
|
||||||
$error = (array) error_get_last();
|
$error = (array) error_get_last();
|
||||||
$error["trace"] = getTrace(4);
|
$error["trace"] = @getTrace(3);
|
||||||
$errorConversion = [
|
$errorConversion = [
|
||||||
E_ERROR => "E_ERROR",
|
E_ERROR => "E_ERROR",
|
||||||
E_WARNING => "E_WARNING",
|
E_WARNING => "E_WARNING",
|
||||||
|
334
src/pocketmine/MemoryManager.php
Normal file
334
src/pocketmine/MemoryManager.php
Normal file
@ -0,0 +1,334 @@
|
|||||||
|
<?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;
|
||||||
|
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -23,7 +23,7 @@ namespace pocketmine;
|
|||||||
|
|
||||||
|
|
||||||
use pocketmine\metadata\MetadataValue;
|
use pocketmine\metadata\MetadataValue;
|
||||||
use pocketmine\nbt\tag\Compound;
|
use pocketmine\nbt\tag\CompoundTag;
|
||||||
use pocketmine\plugin\Plugin;
|
use pocketmine\plugin\Plugin;
|
||||||
|
|
||||||
class OfflinePlayer implements IPlayer{
|
class OfflinePlayer implements IPlayer{
|
||||||
@ -103,15 +103,15 @@ class OfflinePlayer implements IPlayer{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function getFirstPlayed(){
|
public function getFirstPlayed(){
|
||||||
return $this->namedtag instanceof Compound ? $this->namedtag["firstPlayed"] : null;
|
return $this->namedtag instanceof CompoundTag ? $this->namedtag["firstPlayed"] : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getLastPlayed(){
|
public function getLastPlayed(){
|
||||||
return $this->namedtag instanceof Compound ? $this->namedtag["lastPlayed"] : null;
|
return $this->namedtag instanceof CompoundTag ? $this->namedtag["lastPlayed"] : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function hasPlayedBefore(){
|
public function hasPlayedBefore(){
|
||||||
return $this->namedtag instanceof Compound;
|
return $this->namedtag instanceof CompoundTag;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setMetadata($metadataKey, MetadataValue $metadataValue){
|
public function setMetadata($metadataKey, MetadataValue $metadataValue){
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -34,7 +34,7 @@ namespace {
|
|||||||
}
|
}
|
||||||
echo str_repeat(" ", $cnt) . "}" . PHP_EOL;
|
echo str_repeat(" ", $cnt) . "}" . PHP_EOL;
|
||||||
break;
|
break;
|
||||||
case is_integer($var):
|
case is_int($var):
|
||||||
echo str_repeat(" ", $cnt) . "int(" . $var . ")" . PHP_EOL;
|
echo str_repeat(" ", $cnt) . "int(" . $var . ")" . PHP_EOL;
|
||||||
break;
|
break;
|
||||||
case is_float($var):
|
case is_float($var):
|
||||||
@ -65,16 +65,18 @@ namespace {
|
|||||||
}
|
}
|
||||||
|
|
||||||
namespace pocketmine {
|
namespace pocketmine {
|
||||||
use LogLevel;
|
|
||||||
use pocketmine\utils\Binary;
|
use pocketmine\utils\Binary;
|
||||||
use pocketmine\utils\MainLogger;
|
use pocketmine\utils\MainLogger;
|
||||||
|
use pocketmine\utils\ServerKiller;
|
||||||
|
use pocketmine\utils\Terminal;
|
||||||
use pocketmine\utils\Utils;
|
use pocketmine\utils\Utils;
|
||||||
use pocketmine\wizard\Installer;
|
use pocketmine\wizard\Installer;
|
||||||
|
|
||||||
const VERSION = "Alpha_1.4dev";
|
const VERSION = "1.6dev";
|
||||||
const API_VERSION = "1.6.0";
|
const API_VERSION = "2.0.0";
|
||||||
const CODENAME = "絶好(Zekkou)ケーキ(Cake)";
|
const CODENAME = "Unleashed";
|
||||||
const MINECRAFT_VERSION = "v0.9.5 alpha";
|
const MINECRAFT_VERSION = "v0.15.0.0 alpha";
|
||||||
|
const MINECRAFT_VERSION_NETWORK = "0.15.0.0";
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Startup code. Do not look at it, it may harm you.
|
* Startup code. Do not look at it, it may harm you.
|
||||||
@ -84,9 +86,15 @@ namespace pocketmine {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
if(\Phar::running(true) !== ""){
|
if(\Phar::running(true) !== ""){
|
||||||
@define("pocketmine\\PATH", \Phar::running(true) . "/");
|
@define('pocketmine\PATH', \Phar::running(true) . "/");
|
||||||
}else{
|
}else{
|
||||||
@define("pocketmine\\PATH", \getcwd() . DIRECTORY_SEPARATOR);
|
@define('pocketmine\PATH', \getcwd() . DIRECTORY_SEPARATOR);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(version_compare("7.0", PHP_VERSION) > 0){
|
||||||
|
echo "[CRITICAL] You must use PHP >= 7.0" . PHP_EOL;
|
||||||
|
echo "[CRITICAL] Please use the installer provided on the homepage." . PHP_EOL;
|
||||||
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!extension_loaded("pthreads")){
|
if(!extension_loaded("pthreads")){
|
||||||
@ -104,7 +112,6 @@ namespace pocketmine {
|
|||||||
$autoloader = new CompatibleClassLoader();
|
$autoloader = new CompatibleClassLoader();
|
||||||
$autoloader->addPath(\pocketmine\PATH . "src");
|
$autoloader->addPath(\pocketmine\PATH . "src");
|
||||||
$autoloader->addPath(\pocketmine\PATH . "src" . DIRECTORY_SEPARATOR . "spl");
|
$autoloader->addPath(\pocketmine\PATH . "src" . DIRECTORY_SEPARATOR . "spl");
|
||||||
$autoloader->addPath(\pocketmine\PATH . "src" . DIRECTORY_SEPARATOR . "raklib");
|
|
||||||
$autoloader->register(true);
|
$autoloader->register(true);
|
||||||
|
|
||||||
|
|
||||||
@ -117,32 +124,39 @@ namespace pocketmine {
|
|||||||
ini_set("display_startup_errors", 1);
|
ini_set("display_startup_errors", 1);
|
||||||
ini_set("default_charset", "utf-8");
|
ini_set("default_charset", "utf-8");
|
||||||
|
|
||||||
ini_set("memory_limit", "256M"); //Default
|
ini_set("memory_limit", -1);
|
||||||
define("pocketmine\\START_TIME", microtime(true));
|
define('pocketmine\START_TIME', microtime(true));
|
||||||
|
|
||||||
$opts = getopt("", ["enable-ansi", "disable-ansi", "data:", "plugins:", "no-wizard", "enable-profiler"]);
|
$opts = getopt("", ["data:", "plugins:", "no-wizard", "enable-profiler"]);
|
||||||
|
|
||||||
define("pocketmine\\DATA", isset($opts["data"]) ? realpath($opts["data"]) . DIRECTORY_SEPARATOR : \getcwd() . DIRECTORY_SEPARATOR);
|
define('pocketmine\DATA', isset($opts["data"]) ? $opts["data"] . DIRECTORY_SEPARATOR : \getcwd() . DIRECTORY_SEPARATOR);
|
||||||
define("pocketmine\\PLUGIN_PATH", isset($opts["plugins"]) ? realpath($opts["plugins"]) . DIRECTORY_SEPARATOR : \getcwd() . DIRECTORY_SEPARATOR . "plugins" . DIRECTORY_SEPARATOR);
|
define('pocketmine\PLUGIN_PATH', isset($opts["plugins"]) ? $opts["plugins"] . DIRECTORY_SEPARATOR : \getcwd() . DIRECTORY_SEPARATOR . "plugins" . DIRECTORY_SEPARATOR);
|
||||||
|
|
||||||
define("pocketmine\\ANSI", (Utils::getOS() !== "win" or isset($opts["enable-ansi"])) and !isset($opts["disable-ansi"]));
|
Terminal::init();
|
||||||
|
|
||||||
|
define('pocketmine\ANSI', Terminal::hasFormattingCodes());
|
||||||
|
|
||||||
|
if(!file_exists(\pocketmine\DATA)){
|
||||||
|
mkdir(\pocketmine\DATA, 0777, true);
|
||||||
|
}
|
||||||
|
|
||||||
//Logger has a dependency on timezone, so we'll set it to UTC until we can get the actual timezone.
|
//Logger has a dependency on timezone, so we'll set it to UTC until we can get the actual timezone.
|
||||||
date_default_timezone_set("UTC");
|
date_default_timezone_set("UTC");
|
||||||
|
|
||||||
$logger = new MainLogger(\pocketmine\DATA . "server.log", \pocketmine\ANSI);
|
$logger = new MainLogger(\pocketmine\DATA . "server.log", \pocketmine\ANSI);
|
||||||
|
|
||||||
if(!ini_get("date.timezone")){
|
if(!ini_get("date.timezone")){
|
||||||
if(($timezone = detect_system_timezone()) and date_default_timezone_set($timezone)){
|
if(($timezone = detect_system_timezone()) and date_default_timezone_set($timezone)){
|
||||||
//Success! Timezone has already been set and validated in the if statement.
|
//Success! Timezone has already been set and validated in the if statement.
|
||||||
//This here is just for redundancy just in case some stupid program wants to read timezone data from the ini.
|
//This here is just for redundancy just in case some program wants to read timezone data from the ini.
|
||||||
ini_set("date.timezone", $timezone);
|
ini_set("date.timezone", $timezone);
|
||||||
}else{
|
}else{
|
||||||
//If system timezone detection fails or timezone is an invalid value.
|
//If system timezone detection fails or timezone is an invalid value.
|
||||||
if($response = Utils::getURL("http://ip-api.com/json")
|
if($response = Utils::getURL("http://ip-api.com/json")
|
||||||
and $ip_geolocation_data = json_decode($response, true)
|
and $ip_geolocation_data = json_decode($response, true)
|
||||||
and $ip_geolocation_data['status'] != 'fail'
|
and $ip_geolocation_data['status'] != 'fail'
|
||||||
and date_default_timezone_set($ip_geolocation_data['timezone']))
|
and date_default_timezone_set($ip_geolocation_data['timezone'])
|
||||||
{
|
){
|
||||||
//Again, for redundancy.
|
//Again, for redundancy.
|
||||||
ini_set("date.timezone", $ip_geolocation_data['timezone']);
|
ini_set("date.timezone", $ip_geolocation_data['timezone']);
|
||||||
}else{
|
}else{
|
||||||
@ -153,30 +167,46 @@ namespace pocketmine {
|
|||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
/*
|
/*
|
||||||
* This is here so that stupid idiots don't come to us complaining and fill up the issue tracker when they put an incorrect timezone abbreviation in php.ini apparently.
|
* This is here so that people don't come to us complaining and fill up the issue tracker when they put
|
||||||
|
* an incorrect timezone abbreviation in php.ini apparently.
|
||||||
*/
|
*/
|
||||||
$default_timezone = date_default_timezone_get();
|
$timezone = ini_get("date.timezone");
|
||||||
if(strpos($default_timezone, "/") === false){
|
if(strpos($timezone, "/") === false){
|
||||||
$default_timezone = timezone_name_from_abbr($default_timezone);
|
$default_timezone = timezone_name_from_abbr($timezone);
|
||||||
ini_set("date.timezone", $default_timezone);
|
ini_set("date.timezone", $default_timezone);
|
||||||
date_default_timezone_set($default_timezone);
|
date_default_timezone_set($default_timezone);
|
||||||
|
} else {
|
||||||
|
date_default_timezone_set($timezone);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function detect_system_timezone(){
|
function detect_system_timezone(){
|
||||||
switch(Utils::getOS()){
|
switch(Utils::getOS()){
|
||||||
case 'win':
|
case 'win':
|
||||||
$regex = '/(?:Time Zone:\s*\()(UTC)(\+*\-*\d*\d*\:*\d*\d*)(?:\))/';
|
$regex = '/(UTC)(\+*\-*\d*\d*\:*\d*\d*)/';
|
||||||
|
|
||||||
exec("systeminfo", $output);
|
/*
|
||||||
|
* wmic timezone get Caption
|
||||||
|
* Get the timezone offset
|
||||||
|
*
|
||||||
|
* Sample Output var_dump
|
||||||
|
* array(3) {
|
||||||
|
* [0] =>
|
||||||
|
* string(7) "Caption"
|
||||||
|
* [1] =>
|
||||||
|
* string(20) "(UTC+09:30) Adelaide"
|
||||||
|
* [2] =>
|
||||||
|
* string(0) ""
|
||||||
|
* }
|
||||||
|
*/
|
||||||
|
exec("wmic timezone get Caption", $output);
|
||||||
|
|
||||||
$string = trim(implode("\n", $output));
|
$string = trim(implode("\n", $output));
|
||||||
|
|
||||||
//Detect the Time Zone string in systeminfo
|
//Detect the Time Zone string
|
||||||
preg_match($regex, $string, $matches);
|
preg_match($regex, $string, $matches);
|
||||||
|
|
||||||
if(!isset($matches[2]))
|
if(!isset($matches[2])){
|
||||||
{
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -234,6 +264,7 @@ namespace pocketmine {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $offset In the format of +09:00, +02:00, -04:00 etc.
|
* @param string $offset In the format of +09:00, +02:00, -04:00 etc.
|
||||||
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
function parse_offset($offset){
|
function parse_offset($offset){
|
||||||
@ -289,10 +320,32 @@ namespace pocketmine {
|
|||||||
case "mac":
|
case "mac":
|
||||||
case "linux":
|
case "linux":
|
||||||
default:
|
default:
|
||||||
exec("kill -9 " . ((int) $pid) . " > /dev/null 2>&1");
|
if(function_exists("posix_kill")){
|
||||||
|
posix_kill($pid, SIGKILL);
|
||||||
|
}else{
|
||||||
|
exec("kill -9 " . ((int)$pid) . " > /dev/null 2>&1");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @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){
|
function getTrace($start = 1, $trace = null){
|
||||||
if($trace === null){
|
if($trace === null){
|
||||||
if(function_exists("xdebug_get_function_stack")){
|
if(function_exists("xdebug_get_function_stack")){
|
||||||
@ -314,10 +367,10 @@ namespace pocketmine {
|
|||||||
$args = $trace[$i]["params"];
|
$args = $trace[$i]["params"];
|
||||||
}
|
}
|
||||||
foreach($args as $name => $value){
|
foreach($args as $name => $value){
|
||||||
$params .= (is_object($value) ? get_class($value) . " " . (method_exists($value, "__toString") ? $value->__toString() : "object") : gettype($value) . " " . @strval($value)) . ", ";
|
$params .= (is_object($value) ? get_class($value) . " " . (method_exists($value, "__toString") ? $value->__toString() : "object") : gettype($value) . " " . (is_array($value) ? "Array()" : 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;
|
return $messages;
|
||||||
@ -327,63 +380,8 @@ namespace pocketmine {
|
|||||||
return rtrim(str_replace(["\\", ".php", "phar://", rtrim(str_replace(["\\", "phar://"], ["/", ""], \pocketmine\PATH), "/"), rtrim(str_replace(["\\", "phar://"], ["/", ""], \pocketmine\PLUGIN_PATH), "/")], ["/", "", "", "", ""], $path), "/");
|
return rtrim(str_replace(["\\", ".php", "phar://", rtrim(str_replace(["\\", "phar://"], ["/", ""], \pocketmine\PATH), "/"), rtrim(str_replace(["\\", "phar://"], ["/", ""], \pocketmine\PLUGIN_PATH), "/")], ["/", "", "", "", ""], $path), "/");
|
||||||
}
|
}
|
||||||
|
|
||||||
function error_handler($errno, $errstr, $errfile, $errline, $context, $trace = null){
|
|
||||||
global $lastError;
|
|
||||||
if(error_reporting() === 0){ //@ error-con..trol
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
$errorConversion = [
|
|
||||||
E_ERROR => "E_ERROR",
|
|
||||||
E_WARNING => "E_WARNING",
|
|
||||||
E_PARSE => "E_PARSE",
|
|
||||||
E_NOTICE => "E_NOTICE",
|
|
||||||
E_CORE_ERROR => "E_CORE_ERROR",
|
|
||||||
E_CORE_WARNING => "E_CORE_WARNING",
|
|
||||||
E_COMPILE_ERROR => "E_COMPILE_ERROR",
|
|
||||||
E_COMPILE_WARNING => "E_COMPILE_WARNING",
|
|
||||||
E_USER_ERROR => "E_USER_ERROR",
|
|
||||||
E_USER_WARNING => "E_USER_WARNING",
|
|
||||||
E_USER_NOTICE => "E_USER_NOTICE",
|
|
||||||
E_STRICT => "E_STRICT",
|
|
||||||
E_RECOVERABLE_ERROR => "E_RECOVERABLE_ERROR",
|
|
||||||
E_DEPRECATED => "E_DEPRECATED",
|
|
||||||
E_USER_DEPRECATED => "E_USER_DEPRECATED",
|
|
||||||
];
|
|
||||||
$type = ($errno === E_ERROR or $errno === E_USER_ERROR) ? LogLevel::ERROR : (($errno === E_USER_WARNING or $errno === E_WARNING) ? LogLevel::WARNING : LogLevel::NOTICE);
|
|
||||||
$errno = isset($errorConversion[$errno]) ? $errorConversion[$errno] : $errno;
|
|
||||||
if(($pos = strpos($errstr, "\n")) !== false){
|
|
||||||
$errstr = substr($errstr, 0, $pos);
|
|
||||||
}
|
|
||||||
$logger = MainLogger::getLogger();
|
|
||||||
$oldFile = $errfile;
|
|
||||||
$errfile = cleanPath($errfile);
|
|
||||||
$logger->log($type, "An $errno error happened: \"$errstr\" in \"$errfile\" at line $errline");
|
|
||||||
|
|
||||||
foreach(($trace = getTrace($trace === null ? 3 : 0, $trace)) as $i => $line){
|
|
||||||
$logger->debug($line);
|
|
||||||
}
|
|
||||||
|
|
||||||
$lastError = [
|
|
||||||
"type" => $type,
|
|
||||||
"message" => $errstr,
|
|
||||||
"fullFile" => $oldFile,
|
|
||||||
"file" => $errfile,
|
|
||||||
"line" => $errline,
|
|
||||||
"trace" => $trace
|
|
||||||
];
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
set_error_handler("\\pocketmine\\error_handler", E_ALL);
|
|
||||||
|
|
||||||
$errors = 0;
|
$errors = 0;
|
||||||
|
|
||||||
if(version_compare("5.6.0", PHP_VERSION) > 0){
|
|
||||||
$logger->critical("You must use PHP >= 5.6");
|
|
||||||
++$errors;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(php_sapi_name() !== "cli"){
|
if(php_sapi_name() !== "cli"){
|
||||||
$logger->critical("You must run PocketMine-MP using the CLI.");
|
$logger->critical("You must run PocketMine-MP using the CLI.");
|
||||||
++$errors;
|
++$errors;
|
||||||
@ -398,8 +396,8 @@ namespace pocketmine {
|
|||||||
if(substr_count($pthreads_version, ".") < 2){
|
if(substr_count($pthreads_version, ".") < 2){
|
||||||
$pthreads_version = "0.$pthreads_version";
|
$pthreads_version = "0.$pthreads_version";
|
||||||
}
|
}
|
||||||
if(version_compare($pthreads_version, "2.0.8") < 0){
|
if(version_compare($pthreads_version, "3.1.5") < 0){
|
||||||
$logger->critical("pthreads >= 2.0.8 is required, while you have $pthreads_version.");
|
$logger->critical("pthreads >= 3.1.5 is required, while you have $pthreads_version.");
|
||||||
++$errors;
|
++$errors;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -417,23 +415,18 @@ namespace pocketmine {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!extension_loaded("Weakref") and !extension_loaded("weakref")){
|
|
||||||
$logger->critical("Unable to find the Weakref extension.");
|
|
||||||
++$errors;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!extension_loaded("curl")){
|
if(!extension_loaded("curl")){
|
||||||
$logger->critical("Unable to find the cURL extension.");
|
$logger->critical("Unable to find the cURL extension.");
|
||||||
++$errors;
|
++$errors;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!extension_loaded("sqlite3")){
|
if(!extension_loaded("yaml")){
|
||||||
$logger->critical("Unable to find the SQLite3 extension.");
|
$logger->critical("Unable to find the YAML extension.");
|
||||||
++$errors;
|
++$errors;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!extension_loaded("yaml")){
|
if(!extension_loaded("sqlite3")){
|
||||||
$logger->critical("Unable to find the YAML extension.");
|
$logger->critical("Unable to find the SQLite3 extension.");
|
||||||
++$errors;
|
++$errors;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -450,9 +443,9 @@ namespace pocketmine {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(file_exists(\pocketmine\PATH . ".git/refs/heads/master")){ //Found Git information!
|
if(file_exists(\pocketmine\PATH . ".git/refs/heads/master")){ //Found Git information!
|
||||||
define("pocketmine\\GIT_COMMIT", strtolower(trim(file_get_contents(\pocketmine\PATH . ".git/refs/heads/master"))));
|
define('pocketmine\GIT_COMMIT', strtolower(trim(file_get_contents(\pocketmine\PATH . ".git/refs/heads/master"))));
|
||||||
}else{ //Unknown :(
|
}else{ //Unknown :(
|
||||||
define("pocketmine\\GIT_COMMIT", str_repeat("00", 20));
|
define('pocketmine\GIT_COMMIT', str_repeat("00", 20));
|
||||||
}
|
}
|
||||||
|
|
||||||
@define("ENDIANNESS", (pack("d", 1) === "\77\360\0\0\0\0\0\0" ? Binary::BIG_ENDIAN : Binary::LITTLE_ENDIAN));
|
@define("ENDIANNESS", (pack("d", 1) === "\77\360\0\0\0\0\0\0" ? Binary::BIG_ENDIAN : Binary::LITTLE_ENDIAN));
|
||||||
@ -463,7 +456,7 @@ namespace pocketmine {
|
|||||||
new Installer();
|
new Installer();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(substr(__FILE__, 0, 7) !== "phar://"){
|
if(\Phar::running(true) === ""){
|
||||||
$logger->warning("Non-packaged PocketMine-MP installation detected, do not use on production.");
|
$logger->warning("Non-packaged PocketMine-MP installation detected, do not use on production.");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -473,30 +466,18 @@ namespace pocketmine {
|
|||||||
$logger->info("Stopping other threads");
|
$logger->info("Stopping other threads");
|
||||||
|
|
||||||
foreach(ThreadManager::getInstance()->getAll() as $id => $thread){
|
foreach(ThreadManager::getInstance()->getAll() as $id => $thread){
|
||||||
if($thread->isRunning()){
|
$logger->debug("Stopping " . (new \ReflectionClass($thread))->getShortName() . " thread");
|
||||||
$logger->debug("Stopping " . (new \ReflectionClass($thread))->getShortName() . " thread");
|
$thread->quit();
|
||||||
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();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$killer = new ServerKiller(8);
|
||||||
|
$killer->start();
|
||||||
|
|
||||||
$logger->shutdown();
|
$logger->shutdown();
|
||||||
$logger->join();
|
$logger->join();
|
||||||
|
|
||||||
|
echo Terminal::$FORMAT_RESET . "\n";
|
||||||
|
|
||||||
exit(0);
|
exit(0);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -26,9 +26,63 @@ namespace pocketmine;
|
|||||||
*/
|
*/
|
||||||
abstract class Thread extends \Thread{
|
abstract class Thread extends \Thread{
|
||||||
|
|
||||||
public final function start($options = PTHREADS_INHERIT_ALL){
|
/** @var \ClassLoader */
|
||||||
|
protected $classLoader;
|
||||||
|
protected $isKilled = false;
|
||||||
|
|
||||||
|
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(int $options = PTHREADS_INHERIT_ALL){
|
||||||
ThreadManager::getInstance()->add($this);
|
ThreadManager::getInstance()->add($this);
|
||||||
|
|
||||||
return parent::start($options);
|
if(!$this->isRunning() and !$this->isJoined() and !$this->isTerminated()){
|
||||||
|
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(){
|
||||||
|
$this->isKilled = true;
|
||||||
|
|
||||||
|
$this->notify();
|
||||||
|
|
||||||
|
if(!$this->isJoined()){
|
||||||
|
if(!$this->isTerminated()){
|
||||||
|
$this->join();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ThreadManager::getInstance()->remove($this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getThreadName(){
|
||||||
|
return (new \ReflectionClass($this))->getShortName();
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -21,7 +21,7 @@
|
|||||||
|
|
||||||
namespace pocketmine;
|
namespace pocketmine;
|
||||||
|
|
||||||
class ThreadManager extends \Threaded{
|
class ThreadManager extends \Volatile{
|
||||||
|
|
||||||
/** @var ThreadManager */
|
/** @var ThreadManager */
|
||||||
private static $instance = null;
|
private static $instance = null;
|
||||||
|
@ -26,9 +26,68 @@ namespace pocketmine;
|
|||||||
*/
|
*/
|
||||||
abstract class Worker extends \Worker{
|
abstract class Worker extends \Worker{
|
||||||
|
|
||||||
public final function start($options = PTHREADS_INHERIT_ALL){
|
/** @var \ClassLoader */
|
||||||
|
protected $classLoader;
|
||||||
|
|
||||||
|
protected $isKilled = false;
|
||||||
|
|
||||||
|
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(int $options = PTHREADS_INHERIT_ALL){
|
||||||
ThreadManager::getInstance()->add($this);
|
ThreadManager::getInstance()->add($this);
|
||||||
|
|
||||||
return parent::start($options);
|
if(!$this->isRunning() and !$this->isJoined() and !$this->isTerminated()){
|
||||||
|
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(){
|
||||||
|
$this->isKilled = true;
|
||||||
|
|
||||||
|
$this->notify();
|
||||||
|
|
||||||
|
if($this->isRunning()){
|
||||||
|
$this->shutdown();
|
||||||
|
$this->notify();
|
||||||
|
$this->unstack();
|
||||||
|
}elseif(!$this->isJoined()){
|
||||||
|
if(!$this->isTerminated()){
|
||||||
|
$this->join();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ThreadManager::getInstance()->remove($this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getThreadName(){
|
||||||
|
return (new \ReflectionClass($this))->getShortName();
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -22,10 +22,18 @@
|
|||||||
namespace pocketmine\block;
|
namespace pocketmine\block;
|
||||||
|
|
||||||
use pocketmine\item\Item;
|
use pocketmine\item\Item;
|
||||||
|
use pocketmine\item\Tool;
|
||||||
|
|
||||||
class AcaciaWoodStairs extends Stair{
|
class AcaciaWoodStairs extends Stair{
|
||||||
|
|
||||||
|
protected $id = self::ACACIA_WOOD_STAIRS;
|
||||||
|
|
||||||
public function __construct($meta = 0){
|
public function __construct($meta = 0){
|
||||||
parent::__construct(self::ACACIA_WOOD_STAIRS, $meta, "Acacia Wood Stairs");
|
$this->meta = $meta;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getName(){
|
||||||
|
return "Acacia Wood Stairs";
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getDrops(Item $item){
|
public function getDrops(Item $item){
|
||||||
@ -33,4 +41,16 @@ class AcaciaWoodStairs extends Stair{
|
|||||||
[$this->id, 0, 1],
|
[$this->id, 0, 1],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getHardness(){
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getResistance(){
|
||||||
|
return 15;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getToolType(){
|
||||||
|
return Tool::TYPE_AXE;
|
||||||
|
}
|
||||||
}
|
}
|
35
src/pocketmine/block/ActivatorRail.php
Normal file
35
src/pocketmine/block/ActivatorRail.php
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
*
|
||||||
|
* ____ _ _ __ __ _ __ __ ____
|
||||||
|
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
|
||||||
|
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
|
||||||
|
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
|
||||||
|
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* @author PocketMine Team
|
||||||
|
* @link http://www.pocketmine.net/
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace pocketmine\block;
|
||||||
|
|
||||||
|
class ActivatorRail extends Solid {
|
||||||
|
|
||||||
|
protected $id = self::ACTIVATOR_RAIL;
|
||||||
|
|
||||||
|
public function __construct($meta = 0){
|
||||||
|
$this->meta = $meta;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getName(){
|
||||||
|
return "Activator Rail";
|
||||||
|
}
|
||||||
|
}
|
@ -21,31 +21,59 @@
|
|||||||
|
|
||||||
namespace pocketmine\block;
|
namespace pocketmine\block;
|
||||||
|
|
||||||
|
use pocketmine\item\Item;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Air block
|
* Air block
|
||||||
*/
|
*/
|
||||||
class Air extends Transparent{
|
class Air extends Transparent{
|
||||||
public $isActivable = false;
|
|
||||||
public $breakable = false;
|
|
||||||
public $isFlowable = true;
|
|
||||||
public $isTransparent = true;
|
|
||||||
public $isReplaceable = true;
|
|
||||||
public $isPlaceable = false;
|
|
||||||
public $hasPhysics = false;
|
|
||||||
public $isSolid = false;
|
|
||||||
public $isFullBlock = true;
|
|
||||||
protected $id = self::AIR;
|
protected $id = self::AIR;
|
||||||
protected $meta = 0;
|
protected $meta = 0;
|
||||||
protected $name = "Air";
|
|
||||||
protected $hardness = 0;
|
|
||||||
|
|
||||||
public function __construct(){
|
public function __construct(){
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getName(){
|
||||||
|
return "Air";
|
||||||
|
}
|
||||||
|
|
||||||
|
public function 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(){
|
public function getBoundingBox(){
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getHardness(){
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getResistance(){
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
82
src/pocketmine/block/Anvil.php
Normal file
82
src/pocketmine/block/Anvil.php
Normal file
@ -0,0 +1,82 @@
|
|||||||
|
<?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\inventory\AnvilInventory;
|
||||||
|
use pocketmine\item\Item;
|
||||||
|
use pocketmine\item\Tool;
|
||||||
|
use pocketmine\Player;
|
||||||
|
|
||||||
|
class Anvil extends Fallable{
|
||||||
|
|
||||||
|
protected $id = self::ANVIL;
|
||||||
|
|
||||||
|
public function isSolid(){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function __construct($meta = 0){
|
||||||
|
$this->meta = $meta;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function canBeActivated(){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getHardness(){
|
||||||
|
return 5;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getResistance(){
|
||||||
|
return 6000;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getName(){
|
||||||
|
return "Anvil";
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getToolType(){
|
||||||
|
return Tool::TYPE_PICKAXE;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function onActivate(Item $item, Player $player = null){
|
||||||
|
if($player instanceof Player){
|
||||||
|
if($player->isCreative()){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
$player->addWindow(new AnvilInventory($this));
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getDrops(Item $item){
|
||||||
|
if($item->isPickaxe() >= Tool::TIER_WOODEN){
|
||||||
|
return [
|
||||||
|
[$this->id, 0, 1], //TODO break level
|
||||||
|
];
|
||||||
|
}else{
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -24,23 +24,31 @@ namespace pocketmine\block;
|
|||||||
use pocketmine\item\Item;
|
use pocketmine\item\Item;
|
||||||
use pocketmine\level\Level;
|
use pocketmine\level\Level;
|
||||||
use pocketmine\math\AxisAlignedBB;
|
use pocketmine\math\AxisAlignedBB;
|
||||||
use pocketmine\network\protocol\ChatPacket;
|
|
||||||
use pocketmine\Player;
|
use pocketmine\Player;
|
||||||
|
use pocketmine\utils\TextFormat;
|
||||||
|
|
||||||
class Bed extends Transparent{
|
class Bed extends Transparent{
|
||||||
public function __construct($type = 0){
|
|
||||||
parent::__construct(self::BED_BLOCK, $type, "Bed Block");
|
protected $id = self::BED_BLOCK;
|
||||||
$this->isActivable = true;
|
|
||||||
$this->isFullBlock = false;
|
public function __construct($meta = 0){
|
||||||
$this->hardness = 1;
|
$this->meta = $meta;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getBoundingBox(){
|
public function canBeActivated(){
|
||||||
if($this->boundingBox !== null){
|
return true;
|
||||||
return $this->boundingBox;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return $this->boundingBox = new AxisAlignedBB(
|
public function getHardness(){
|
||||||
|
return 0.2;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getName(){
|
||||||
|
return "Bed Block";
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function recalculateBoundingBox(){
|
||||||
|
return new AxisAlignedBB(
|
||||||
$this->x,
|
$this->x,
|
||||||
$this->y,
|
$this->y,
|
||||||
$this->z,
|
$this->z,
|
||||||
@ -57,10 +65,7 @@ class Bed extends Transparent{
|
|||||||
$isNight = ($time >= Level::TIME_NIGHT and $time < Level::TIME_SUNRISE);
|
$isNight = ($time >= Level::TIME_NIGHT and $time < Level::TIME_SUNRISE);
|
||||||
|
|
||||||
if($player instanceof Player and !$isNight){
|
if($player instanceof Player and !$isNight){
|
||||||
$pk = new ChatPacket;
|
$player->sendMessage(TextFormat::GRAY . "You can only sleep at night");
|
||||||
$pk->message = "You can only sleep at night";
|
|
||||||
$player->dataPacket($pk);
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -71,19 +76,17 @@ class Bed extends Transparent{
|
|||||||
if(($this->meta & 0x08) === 0x08){ //This is the Top part of bed
|
if(($this->meta & 0x08) === 0x08){ //This is the Top part of bed
|
||||||
$b = $this;
|
$b = $this;
|
||||||
}else{ //Bottom Part of Bed
|
}else{ //Bottom Part of Bed
|
||||||
if($blockNorth->getID() === $this->id and ($blockNorth->meta & 0x08) === 0x08){
|
if($blockNorth->getId() === $this->id and ($blockNorth->meta & 0x08) === 0x08){
|
||||||
$b = $blockNorth;
|
$b = $blockNorth;
|
||||||
}elseif($blockSouth->getID() === $this->id and ($blockSouth->meta & 0x08) === 0x08){
|
}elseif($blockSouth->getId() === $this->id and ($blockSouth->meta & 0x08) === 0x08){
|
||||||
$b = $blockSouth;
|
$b = $blockSouth;
|
||||||
}elseif($blockEast->getID() === $this->id and ($blockEast->meta & 0x08) === 0x08){
|
}elseif($blockEast->getId() === $this->id and ($blockEast->meta & 0x08) === 0x08){
|
||||||
$b = $blockEast;
|
$b = $blockEast;
|
||||||
}elseif($blockWest->getID() === $this->id and ($blockWest->meta & 0x08) === 0x08){
|
}elseif($blockWest->getId() === $this->id and ($blockWest->meta & 0x08) === 0x08){
|
||||||
$b = $blockWest;
|
$b = $blockWest;
|
||||||
}else{
|
}else{
|
||||||
if($player instanceof Player){
|
if($player instanceof Player){
|
||||||
$pk = new ChatPacket;
|
$player->sendMessage(TextFormat::GRAY . "This bed is incomplete");
|
||||||
$pk->message = "This bed is incomplete";
|
|
||||||
$player->dataPacket($pk);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -91,9 +94,7 @@ class Bed extends Transparent{
|
|||||||
}
|
}
|
||||||
|
|
||||||
if($player instanceof Player and $player->sleepOn($b) === false){
|
if($player instanceof Player and $player->sleepOn($b) === false){
|
||||||
$pk = new ChatPacket;
|
$player->sendMessage(TextFormat::GRAY . "This bed is occupied");
|
||||||
$pk->message = "This bed is occupied";
|
|
||||||
$player->dataPacket($pk);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -101,7 +102,7 @@ class Bed extends Transparent{
|
|||||||
|
|
||||||
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){
|
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){
|
||||||
$down = $this->getSide(0);
|
$down = $this->getSide(0);
|
||||||
if($down->isTransparent === false){
|
if($down->isTransparent() === false){
|
||||||
$faces = [
|
$faces = [
|
||||||
0 => 3,
|
0 => 3,
|
||||||
1 => 4,
|
1 => 4,
|
||||||
@ -111,7 +112,7 @@ class Bed extends Transparent{
|
|||||||
$d = $player instanceof Player ? $player->getDirection() : 0;
|
$d = $player instanceof Player ? $player->getDirection() : 0;
|
||||||
$next = $this->getSide($faces[(($d + 3) % 4)]);
|
$next = $this->getSide($faces[(($d + 3) % 4)]);
|
||||||
$downNext = $this->getSide(0);
|
$downNext = $this->getSide(0);
|
||||||
if($next->isReplaceable === true and $downNext->isTransparent === false){
|
if($next->canBeReplaced() === true and $downNext->isTransparent() === false){
|
||||||
$meta = (($d + 3) % 4) & 0x03;
|
$meta = (($d + 3) % 4) & 0x03;
|
||||||
$this->getLevel()->setBlock($block, Block::get($this->id, $meta), true, true);
|
$this->getLevel()->setBlock($block, Block::get($this->id, $meta), true, true);
|
||||||
$this->getLevel()->setBlock($next, Block::get($this->id, $meta | 0x08), true, true);
|
$this->getLevel()->setBlock($next, Block::get($this->id, $meta | 0x08), true, true);
|
||||||
@ -130,23 +131,23 @@ class Bed extends Transparent{
|
|||||||
$blockWest = $this->getSide(4);
|
$blockWest = $this->getSide(4);
|
||||||
|
|
||||||
if(($this->meta & 0x08) === 0x08){ //This is the Top part of bed
|
if(($this->meta & 0x08) === 0x08){ //This is the Top part of bed
|
||||||
if($blockNorth->getID() === $this->id and $blockNorth->meta !== 0x08){ //Checks if the block ID and meta are right
|
if($blockNorth->getId() === $this->id and $blockNorth->meta !== 0x08){ //Checks if the block ID and meta are right
|
||||||
$this->getLevel()->setBlock($blockNorth, new Air(), true, true);
|
$this->getLevel()->setBlock($blockNorth, new Air(), true, true);
|
||||||
}elseif($blockSouth->getID() === $this->id and $blockSouth->meta !== 0x08){
|
}elseif($blockSouth->getId() === $this->id and $blockSouth->meta !== 0x08){
|
||||||
$this->getLevel()->setBlock($blockSouth, new Air(), true, true);
|
$this->getLevel()->setBlock($blockSouth, new Air(), true, true);
|
||||||
}elseif($blockEast->getID() === $this->id and $blockEast->meta !== 0x08){
|
}elseif($blockEast->getId() === $this->id and $blockEast->meta !== 0x08){
|
||||||
$this->getLevel()->setBlock($blockEast, new Air(), true, true);
|
$this->getLevel()->setBlock($blockEast, new Air(), true, true);
|
||||||
}elseif($blockWest->getID() === $this->id and $blockWest->meta !== 0x08){
|
}elseif($blockWest->getId() === $this->id and $blockWest->meta !== 0x08){
|
||||||
$this->getLevel()->setBlock($blockWest, new Air(), true, true);
|
$this->getLevel()->setBlock($blockWest, new Air(), true, true);
|
||||||
}
|
}
|
||||||
}else{ //Bottom Part of Bed
|
}else{ //Bottom Part of Bed
|
||||||
if($blockNorth->getID() === $this->id and ($blockNorth->meta & 0x08) === 0x08){
|
if($blockNorth->getId() === $this->id and ($blockNorth->meta & 0x08) === 0x08){
|
||||||
$this->getLevel()->setBlock($blockNorth, new Air(), true, true);
|
$this->getLevel()->setBlock($blockNorth, new Air(), true, true);
|
||||||
}elseif($blockSouth->getID() === $this->id and ($blockSouth->meta & 0x08) === 0x08){
|
}elseif($blockSouth->getId() === $this->id and ($blockSouth->meta & 0x08) === 0x08){
|
||||||
$this->getLevel()->setBlock($blockSouth, new Air(), true, true);
|
$this->getLevel()->setBlock($blockSouth, new Air(), true, true);
|
||||||
}elseif($blockEast->getID() === $this->id and ($blockEast->meta & 0x08) === 0x08){
|
}elseif($blockEast->getId() === $this->id and ($blockEast->meta & 0x08) === 0x08){
|
||||||
$this->getLevel()->setBlock($blockEast, new Air(), true, true);
|
$this->getLevel()->setBlock($blockEast, new Air(), true, true);
|
||||||
}elseif($blockWest->getID() === $this->id and ($blockWest->meta & 0x08) === 0x08){
|
}elseif($blockWest->getId() === $this->id and ($blockWest->meta & 0x08) === 0x08){
|
||||||
$this->getLevel()->setBlock($blockWest, new Air(), true, true);
|
$this->getLevel()->setBlock($blockWest, new Air(), true, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -24,10 +24,23 @@ namespace pocketmine\block;
|
|||||||
use pocketmine\item\Item;
|
use pocketmine\item\Item;
|
||||||
|
|
||||||
class Bedrock extends Solid{
|
class Bedrock extends Solid{
|
||||||
|
|
||||||
|
protected $id = self::BEDROCK;
|
||||||
|
|
||||||
public function __construct(){
|
public function __construct(){
|
||||||
parent::__construct(self::BEDROCK, 0, "Bedrock");
|
|
||||||
$this->breakable = false;
|
}
|
||||||
$this->hardness = 18000000;
|
|
||||||
|
public function getName(){
|
||||||
|
return "Bedrock";
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getHardness(){
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getResistance(){
|
||||||
|
return 18000000;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function isBreakable(Item $item){
|
public function isBreakable(Item $item){
|
||||||
|
@ -24,8 +24,15 @@ namespace pocketmine\block;
|
|||||||
use pocketmine\item\Item;
|
use pocketmine\item\Item;
|
||||||
|
|
||||||
class Beetroot extends Crops{
|
class Beetroot extends Crops{
|
||||||
|
|
||||||
|
protected $id = self::BEETROOT_BLOCK;
|
||||||
|
|
||||||
public function __construct($meta = 0){
|
public function __construct($meta = 0){
|
||||||
parent::__construct(self::BEETROOT_BLOCK, $meta, "Beetroot Block");
|
$this->meta = $meta;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getName(){
|
||||||
|
return "Beetroot Block";
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getDrops(Item $item){
|
public function getDrops(Item $item){
|
||||||
|
@ -22,10 +22,18 @@
|
|||||||
namespace pocketmine\block;
|
namespace pocketmine\block;
|
||||||
|
|
||||||
use pocketmine\item\Item;
|
use pocketmine\item\Item;
|
||||||
|
use pocketmine\item\Tool;
|
||||||
|
|
||||||
class BirchWoodStairs extends Stair{
|
class BirchWoodStairs extends Stair{
|
||||||
|
|
||||||
|
protected $id = self::BIRCH_WOOD_STAIRS;
|
||||||
|
|
||||||
public function __construct($meta = 0){
|
public function __construct($meta = 0){
|
||||||
parent::__construct(self::BIRCH_WOOD_STAIRS, $meta, "Birch Wood Stairs");
|
$this->meta = $meta;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getName(){
|
||||||
|
return "Birch Wood Stairs";
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getDrops(Item $item){
|
public function getDrops(Item $item){
|
||||||
@ -33,4 +41,16 @@ class BirchWoodStairs extends Stair{
|
|||||||
[$this->id, 0, 1],
|
[$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;
|
namespace pocketmine\block;
|
||||||
|
|
||||||
|
|
||||||
|
use pocketmine\item\Tool;
|
||||||
|
|
||||||
class Bookshelf extends Solid{
|
class Bookshelf extends Solid{
|
||||||
|
|
||||||
|
protected $id = self::BOOKSHELF;
|
||||||
|
|
||||||
public function __construct(){
|
public function __construct(){
|
||||||
parent::__construct(self::BOOKSHELF, 0, "Bookshelf");
|
|
||||||
$this->hardness = 7.5;
|
}
|
||||||
|
|
||||||
|
public function getName(){
|
||||||
|
return "Bookshelf";
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getHardness(){
|
||||||
|
return 1.5;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getToolType(){
|
||||||
|
return Tool::TYPE_AXE;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
46
src/pocketmine/block/BrewingStand.php
Normal file
46
src/pocketmine/block/BrewingStand.php
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
<?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\item\Tool;
|
||||||
|
|
||||||
|
class BrewingStand extends Transparent{
|
||||||
|
|
||||||
|
protected $id = self::BREWING_STAND;
|
||||||
|
|
||||||
|
public function __construct(){
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getName(){
|
||||||
|
return "Brewing Stand";
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getHardness(){
|
||||||
|
return 0.5;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getToolType(){
|
||||||
|
return Tool::TYPE_PICKAXE;
|
||||||
|
}
|
||||||
|
}
|
@ -22,9 +22,30 @@
|
|||||||
namespace pocketmine\block;
|
namespace pocketmine\block;
|
||||||
|
|
||||||
|
|
||||||
|
use pocketmine\item\Tool;
|
||||||
|
|
||||||
class BrickStairs extends Stair{
|
class BrickStairs extends Stair{
|
||||||
|
|
||||||
|
protected $id = self::BRICK_STAIRS;
|
||||||
|
|
||||||
public function __construct($meta = 0){
|
public function __construct($meta = 0){
|
||||||
parent::__construct(self::BRICK_STAIRS, $meta, "Brick Stairs");
|
$this->meta = $meta;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getHardness(){
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getResistance(){
|
||||||
|
return 30;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getToolType(){
|
||||||
|
return Tool::TYPE_PICKAXE;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getName(){
|
||||||
|
return "Brick Stairs";
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -22,32 +22,34 @@
|
|||||||
namespace pocketmine\block;
|
namespace pocketmine\block;
|
||||||
|
|
||||||
use pocketmine\item\Item;
|
use pocketmine\item\Item;
|
||||||
|
use pocketmine\item\Tool;
|
||||||
|
|
||||||
class Bricks extends Solid{
|
class Bricks extends Solid{
|
||||||
|
|
||||||
|
protected $id = self::BRICKS_BLOCK;
|
||||||
|
|
||||||
public function __construct(){
|
public function __construct(){
|
||||||
parent::__construct(self::BRICKS_BLOCK, 0, "Bricks");
|
|
||||||
$this->hardness = 30;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getBreakTime(Item $item){
|
public function getHardness(){
|
||||||
switch($item->isPickaxe()){
|
return 2;
|
||||||
case 5:
|
}
|
||||||
return 0.4;
|
|
||||||
case 4:
|
public function getResistance(){
|
||||||
return 0.5;
|
return 30;
|
||||||
case 3:
|
}
|
||||||
return 0.75;
|
|
||||||
case 2:
|
public function getToolType(){
|
||||||
return 0.25;
|
return Tool::TYPE_PICKAXE;
|
||||||
case 1:
|
}
|
||||||
return 1.5;
|
|
||||||
default:
|
public function getName(){
|
||||||
return 10;
|
return "Bricks";
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getDrops(Item $item){
|
public function getDrops(Item $item){
|
||||||
if($item->isPickaxe() >= 1){
|
if($item->isPickaxe() >= Tool::TIER_WOODEN){
|
||||||
return [
|
return [
|
||||||
[Item::BRICKS_BLOCK, 0, 1],
|
[Item::BRICKS_BLOCK, 0, 1],
|
||||||
];
|
];
|
||||||
|
@ -26,14 +26,24 @@ use pocketmine\level\Level;
|
|||||||
use pocketmine\Player;
|
use pocketmine\Player;
|
||||||
|
|
||||||
class BrownMushroom extends Flowable{
|
class BrownMushroom extends Flowable{
|
||||||
public function __construct(){
|
|
||||||
parent::__construct(self::BROWN_MUSHROOM, 0, "Brown Mushroom");
|
protected $id = self::BROWN_MUSHROOM;
|
||||||
$this->hardness = 0;
|
|
||||||
|
public function __construct($meta = 0){
|
||||||
|
$this->meta = $meta;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getName(){
|
||||||
|
return "Brown Mushroom";
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getLightLevel(){
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onUpdate($type){
|
public function onUpdate($type){
|
||||||
if($type === Level::BLOCK_UPDATE_NORMAL){
|
if($type === Level::BLOCK_UPDATE_NORMAL){
|
||||||
if($this->getSide(0)->isTransparent === true){
|
if($this->getSide(0)->isTransparent() === true){
|
||||||
$this->getLevel()->useBreakOn($this);
|
$this->getLevel()->useBreakOn($this);
|
||||||
|
|
||||||
return Level::BLOCK_UPDATE_NORMAL;
|
return Level::BLOCK_UPDATE_NORMAL;
|
||||||
@ -45,7 +55,7 @@ class BrownMushroom extends Flowable{
|
|||||||
|
|
||||||
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){
|
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){
|
||||||
$down = $this->getSide(0);
|
$down = $this->getSide(0);
|
||||||
if($down->isTransparent === false){
|
if($down->isTransparent() === false){
|
||||||
$this->getLevel()->setBlock($block, $this, true, true);
|
$this->getLevel()->setBlock($block, $this, true, true);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -22,20 +22,42 @@
|
|||||||
namespace pocketmine\block;
|
namespace pocketmine\block;
|
||||||
|
|
||||||
use pocketmine\item\Item;
|
use pocketmine\item\Item;
|
||||||
|
use pocketmine\item\Tool;
|
||||||
use pocketmine\nbt\NBT;
|
use pocketmine\nbt\NBT;
|
||||||
use pocketmine\nbt\tag\Compound;
|
use pocketmine\nbt\tag\CompoundTag;
|
||||||
use pocketmine\nbt\tag\Enum;
|
use pocketmine\nbt\tag\ListTag;
|
||||||
use pocketmine\nbt\tag\Int;
|
use pocketmine\nbt\tag\IntTag;
|
||||||
use pocketmine\nbt\tag\String;
|
use pocketmine\nbt\tag\StringTag;
|
||||||
use pocketmine\Player;
|
use pocketmine\Player;
|
||||||
use pocketmine\tile\Furnace;
|
use pocketmine\tile\Furnace;
|
||||||
use pocketmine\tile\Tile;
|
use pocketmine\tile\Tile;
|
||||||
|
|
||||||
class BurningFurnace extends Solid{
|
class BurningFurnace extends Solid{
|
||||||
|
|
||||||
|
protected $id = self::BURNING_FURNACE;
|
||||||
|
|
||||||
public function __construct($meta = 0){
|
public function __construct($meta = 0){
|
||||||
parent::__construct(self::BURNING_FURNACE, $meta, "Burning Furnace");
|
$this->meta = $meta;
|
||||||
$this->isActivable = true;
|
}
|
||||||
$this->hardness = 17.5;
|
|
||||||
|
public function getName(){
|
||||||
|
return "Burning Furnace";
|
||||||
|
}
|
||||||
|
|
||||||
|
public function canBeActivated(){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getHardness(){
|
||||||
|
return 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){
|
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){
|
||||||
@ -47,15 +69,26 @@ class BurningFurnace extends Solid{
|
|||||||
];
|
];
|
||||||
$this->meta = $faces[$player instanceof Player ? $player->getDirection() : 0];
|
$this->meta = $faces[$player instanceof Player ? $player->getDirection() : 0];
|
||||||
$this->getLevel()->setBlock($block, $this, true, true);
|
$this->getLevel()->setBlock($block, $this, true, true);
|
||||||
$nbt = new Compound(false, [
|
$nbt = new CompoundTag("", [
|
||||||
new Enum("Items", []),
|
new ListTag("Items", []),
|
||||||
new String("id", Tile::FURNACE),
|
new StringTag("id", Tile::FURNACE),
|
||||||
new Int("x", $this->x),
|
new IntTag("x", $this->x),
|
||||||
new Int("y", $this->y),
|
new IntTag("y", $this->y),
|
||||||
new Int("z", $this->z)
|
new IntTag("z", $this->z)
|
||||||
]);
|
]);
|
||||||
$nbt->Items->setTagType(NBT::TAG_Compound);
|
$nbt->Items->setTagType(NBT::TAG_Compound);
|
||||||
new Furnace($this->getLevel()->getChunk($this->x >> 4, $this->z >> 4), $nbt);
|
|
||||||
|
if($item->hasCustomName()){
|
||||||
|
$nbt->CustomName = new StringTag("CustomName", $item->getCustomName());
|
||||||
|
}
|
||||||
|
|
||||||
|
if($item->hasCustomBlockData()){
|
||||||
|
foreach($item->getCustomBlockData() as $key => $v){
|
||||||
|
$nbt->{$key} = $v;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Tile::createTile("Furnace", $this->getLevel()->getChunk($this->x >> 4, $this->z >> 4), $nbt);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -73,18 +106,24 @@ class BurningFurnace extends Solid{
|
|||||||
if($t instanceof Furnace){
|
if($t instanceof Furnace){
|
||||||
$furnace = $t;
|
$furnace = $t;
|
||||||
}else{
|
}else{
|
||||||
$nbt = new Compound(false, [
|
$nbt = new CompoundTag("", [
|
||||||
new Enum("Items", []),
|
new ListTag("Items", []),
|
||||||
new String("id", Tile::FURNACE),
|
new StringTag("id", Tile::FURNACE),
|
||||||
new Int("x", $this->x),
|
new IntTag("x", $this->x),
|
||||||
new Int("y", $this->y),
|
new IntTag("y", $this->y),
|
||||||
new Int("z", $this->z)
|
new IntTag("z", $this->z)
|
||||||
]);
|
]);
|
||||||
$nbt->Items->setTagType(NBT::TAG_Compound);
|
$nbt->Items->setTagType(NBT::TAG_Compound);
|
||||||
$furnace = new Furnace($this->getLevel()->getChunk($this->x >> 4, $this->z >> 4), $nbt);
|
$furnace = Tile::createTile("Furnace", $this->getLevel()->getChunk($this->x >> 4, $this->z >> 4), $nbt);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(($player->getGamemode() & 0x01) === 0x01){
|
if(isset($furnace->namedtag->Lock) and $furnace->namedtag->Lock instanceof StringTag){
|
||||||
|
if($furnace->namedtag->Lock->getValue() !== $item->getCustomName()){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if($player->isCreative()){
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -94,26 +133,9 @@ class BurningFurnace extends Solid{
|
|||||||
return true;
|
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){
|
public function getDrops(Item $item){
|
||||||
$drops = [];
|
$drops = [];
|
||||||
if($item->isPickaxe() >= 1){
|
if($item->isPickaxe() >= Tool::TIER_WOODEN){
|
||||||
$drops[] = [Item::FURNACE, 0, 1];
|
$drops[] = [Item::FURNACE, 0, 1];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,62 +28,66 @@ use pocketmine\event\entity\EntityDamageEvent;
|
|||||||
use pocketmine\item\Item;
|
use pocketmine\item\Item;
|
||||||
use pocketmine\level\Level;
|
use pocketmine\level\Level;
|
||||||
use pocketmine\math\AxisAlignedBB;
|
use pocketmine\math\AxisAlignedBB;
|
||||||
use pocketmine\math\Vector3 as Vector3;
|
use pocketmine\math\Vector3;
|
||||||
use pocketmine\Player;
|
use pocketmine\Player;
|
||||||
use pocketmine\Server;
|
use pocketmine\Server;
|
||||||
|
|
||||||
class Cactus extends Transparent{
|
class Cactus extends Transparent{
|
||||||
|
|
||||||
public $hasEntityCollision = true;
|
protected $id = self::CACTUS;
|
||||||
|
|
||||||
public function __construct($meta = 0){
|
public function __construct($meta = 0){
|
||||||
parent::__construct(self::CACTUS, $meta, "Cactus");
|
$this->meta = $meta;
|
||||||
$this->isFullBlock = false;
|
|
||||||
$this->hardness = 2;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getBoundingBox(){
|
public function getHardness(){
|
||||||
if($this->boundingBox !== null){
|
return 0.4;
|
||||||
return $this->boundingBox;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return $this->boundingBox = new AxisAlignedBB(
|
public function hasEntityCollision(){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getName(){
|
||||||
|
return "Cactus";
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function recalculateBoundingBox(){
|
||||||
|
|
||||||
|
return new AxisAlignedBB(
|
||||||
$this->x + 0.0625,
|
$this->x + 0.0625,
|
||||||
$this->y,
|
$this->y + 0.0625,
|
||||||
$this->z + 0.0625,
|
$this->z + 0.0625,
|
||||||
$this->x + 0.9375,
|
$this->x + 0.9375,
|
||||||
$this->y + 1,
|
$this->y + 0.9375,
|
||||||
$this->z + 0.9375
|
$this->z + 0.9375
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onEntityCollide(Entity $entity){
|
public function onEntityCollide(Entity $entity){
|
||||||
$ev = new EntityDamageByBlockEvent($this, $entity, EntityDamageEvent::CAUSE_CONTACT, 1);
|
$ev = new EntityDamageByBlockEvent($this, $entity, EntityDamageEvent::CAUSE_CONTACT, 1);
|
||||||
Server::getInstance()->getPluginManager()->callEvent($ev);
|
$entity->attack($ev->getFinalDamage(), $ev);
|
||||||
if(!$ev->isCancelled()){
|
|
||||||
$entity->attack($ev->getFinalDamage(), $ev);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onUpdate($type){
|
public function onUpdate($type){
|
||||||
if($type === Level::BLOCK_UPDATE_NORMAL){
|
if($type === Level::BLOCK_UPDATE_NORMAL){
|
||||||
$down = $this->getSide(0);
|
$down = $this->getSide(0);
|
||||||
if($down->getID() !== self::SAND and $down->getID() !== self::CACTUS){
|
if($down->getId() !== self::SAND and $down->getId() !== self::CACTUS){
|
||||||
$this->getLevel()->useBreakOn($this);
|
$this->getLevel()->useBreakOn($this);
|
||||||
}else{
|
}else{
|
||||||
for($side = 2; $side <= 5; ++$side){
|
for($side = 2; $side <= 5; ++$side){
|
||||||
$b = $this->getSide($side);
|
$b = $this->getSide($side);
|
||||||
if(!$b->isFlowable){
|
if(!$b->canBeFlowedInto()){
|
||||||
$this->getLevel()->useBreakOn($this);
|
$this->getLevel()->useBreakOn($this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}elseif($type === Level::BLOCK_UPDATE_RANDOM){
|
}elseif($type === Level::BLOCK_UPDATE_RANDOM){
|
||||||
if($this->getSide(0)->getID() !== self::CACTUS){
|
if($this->getSide(0)->getId() !== self::CACTUS){
|
||||||
if($this->meta == 0x0F){
|
if($this->meta == 0x0F){
|
||||||
for($y = 1; $y < 3; ++$y){
|
for($y = 1; $y < 3; ++$y){
|
||||||
$b = $this->getLevel()->getBlock(new Vector3($this->x, $this->y + $y, $this->z));
|
$b = $this->getLevel()->getBlock(new Vector3($this->x, $this->y + $y, $this->z));
|
||||||
if($b->getID() === self::AIR){
|
if($b->getId() === self::AIR){
|
||||||
Server::getInstance()->getPluginManager()->callEvent($ev = new BlockGrowEvent($b, new Cactus()));
|
Server::getInstance()->getPluginManager()->callEvent($ev = new BlockGrowEvent($b, new Cactus()));
|
||||||
if(!$ev->isCancelled()){
|
if(!$ev->isCancelled()){
|
||||||
$this->getLevel()->setBlock($b, $ev->getNewState(), true);
|
$this->getLevel()->setBlock($b, $ev->getNewState(), true);
|
||||||
@ -104,12 +108,12 @@ class Cactus extends Transparent{
|
|||||||
|
|
||||||
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){
|
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){
|
||||||
$down = $this->getSide(0);
|
$down = $this->getSide(0);
|
||||||
if($down->getID() === self::SAND or $down->getID() === self::CACTUS){
|
if($down->getId() === self::SAND or $down->getId() === self::CACTUS){
|
||||||
$block0 = $this->getSide(2);
|
$block0 = $this->getSide(2);
|
||||||
$block1 = $this->getSide(3);
|
$block1 = $this->getSide(3);
|
||||||
$block2 = $this->getSide(4);
|
$block2 = $this->getSide(4);
|
||||||
$block3 = $this->getSide(5);
|
$block3 = $this->getSide(5);
|
||||||
if($block0->isTransparent === true and $block1->isTransparent === true and $block2->isTransparent === true and $block3->isTransparent === true){
|
if($block0->isTransparent() === true and $block1->isTransparent() === true and $block2->isTransparent() === true and $block3->isTransparent() === true){
|
||||||
$this->getLevel()->setBlock($this, $this, true);
|
$this->getLevel()->setBlock($this, $this, true);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -21,30 +21,39 @@
|
|||||||
|
|
||||||
namespace pocketmine\block;
|
namespace pocketmine\block;
|
||||||
|
|
||||||
use pocketmine\event\entity\EntityRegainHealthEvent;
|
use pocketmine\entity\Effect;
|
||||||
|
use pocketmine\event\entity\EntityEatBlockEvent;
|
||||||
|
use pocketmine\item\FoodSource;
|
||||||
use pocketmine\item\Item;
|
use pocketmine\item\Item;
|
||||||
use pocketmine\level\Level;
|
use pocketmine\level\Level;
|
||||||
use pocketmine\math\AxisAlignedBB;
|
use pocketmine\math\AxisAlignedBB;
|
||||||
use pocketmine\Player;
|
use pocketmine\Player;
|
||||||
use pocketmine\Server;
|
|
||||||
|
|
||||||
class Cake extends Transparent{
|
class Cake extends Transparent implements FoodSource{
|
||||||
|
|
||||||
|
protected $id = self::CAKE_BLOCK;
|
||||||
|
|
||||||
public function __construct($meta = 0){
|
public function __construct($meta = 0){
|
||||||
parent::__construct(self::CAKE_BLOCK, 0, "Cake Block");
|
$this->meta = $meta;
|
||||||
$this->isFullBlock = false;
|
|
||||||
$this->isActivable = true;
|
|
||||||
$this->meta = $meta & 0x07;
|
|
||||||
$this->hardness = 2.5;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getBoundingBox(){
|
public function canBeActivated(){
|
||||||
if($this->boundingBox !== null){
|
return true;
|
||||||
return $this->boundingBox;
|
}
|
||||||
}
|
|
||||||
|
public function getHardness(){
|
||||||
|
return 0.5;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getName(){
|
||||||
|
return "Cake Block";
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function recalculateBoundingBox(){
|
||||||
|
|
||||||
$f = (1 + $this->getDamage() * 2) / 16;
|
$f = (1 + $this->getDamage() * 2) / 16;
|
||||||
|
|
||||||
return $this->boundingBox = new AxisAlignedBB(
|
return new AxisAlignedBB(
|
||||||
$this->x + $f,
|
$this->x + $f,
|
||||||
$this->y,
|
$this->y,
|
||||||
$this->z + 0.0625,
|
$this->z + 0.0625,
|
||||||
@ -56,7 +65,7 @@ class Cake extends Transparent{
|
|||||||
|
|
||||||
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){
|
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){
|
||||||
$down = $this->getSide(0);
|
$down = $this->getSide(0);
|
||||||
if($down->getID() !== self::AIR){
|
if($down->getId() !== self::AIR){
|
||||||
$this->getLevel()->setBlock($block, $this, true, true);
|
$this->getLevel()->setBlock($block, $this, true, true);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -67,7 +76,7 @@ class Cake extends Transparent{
|
|||||||
|
|
||||||
public function onUpdate($type){
|
public function onUpdate($type){
|
||||||
if($type === Level::BLOCK_UPDATE_NORMAL){
|
if($type === Level::BLOCK_UPDATE_NORMAL){
|
||||||
if($this->getSide(0)->getID() === self::AIR){ //Replace with common break method
|
if($this->getSide(0)->getId() === self::AIR){ //Replace with common break method
|
||||||
$this->getLevel()->setBlock($this, new Air(), true);
|
$this->getLevel()->setBlock($this, new Air(), true);
|
||||||
|
|
||||||
return Level::BLOCK_UPDATE_NORMAL;
|
return Level::BLOCK_UPDATE_NORMAL;
|
||||||
@ -82,22 +91,39 @@ class Cake extends Transparent{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function onActivate(Item $item, Player $player = null){
|
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;
|
$ev = new EntityEatBlockEvent($player, $this);
|
||||||
Server::getInstance()->getPluginManager()->callEvent($ev = new EntityRegainHealthEvent($player, 3, EntityRegainHealthEvent::CAUSE_EATING));
|
|
||||||
if(!$ev->isCancelled()){
|
|
||||||
$player->heal($ev->getAmount(), $ev);
|
|
||||||
}
|
|
||||||
if($this->meta >= 0x06){
|
|
||||||
$this->getLevel()->setBlock($this, new Air(), true);
|
|
||||||
}else{
|
|
||||||
$this->getLevel()->setBlock($this, $this, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
if(!$ev->isCancelled()){
|
||||||
|
$this->getLevel()->setBlock($this, $ev->getResidue());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getFoodRestore() : int{
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getSaturationRestore() : float{
|
||||||
|
return 0.4;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getResidue(){
|
||||||
|
$clone = clone $this;
|
||||||
|
$clone->meta++;
|
||||||
|
if($clone->meta >= 0x06){
|
||||||
|
$clone = new Air();
|
||||||
|
}
|
||||||
|
return $clone;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Effect[]
|
||||||
|
*/
|
||||||
|
public function getAdditionalEffects() : array{
|
||||||
|
return [];
|
||||||
|
}
|
||||||
}
|
}
|
@ -27,9 +27,23 @@ use pocketmine\math\AxisAlignedBB;
|
|||||||
use pocketmine\Player;
|
use pocketmine\Player;
|
||||||
|
|
||||||
class Carpet extends Flowable{
|
class Carpet extends Flowable{
|
||||||
|
|
||||||
|
protected $id = self::CARPET;
|
||||||
|
|
||||||
public function __construct($meta = 0){
|
public function __construct($meta = 0){
|
||||||
parent::__construct(self::CARPET, $meta, "Carpet");
|
$this->meta = $meta;
|
||||||
$names = [
|
}
|
||||||
|
|
||||||
|
public function getHardness(){
|
||||||
|
return 0.1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function isSolid(){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getName(){
|
||||||
|
static $names = [
|
||||||
0 => "White Carpet",
|
0 => "White Carpet",
|
||||||
1 => "Orange Carpet",
|
1 => "Orange Carpet",
|
||||||
2 => "Magenta Carpet",
|
2 => "Magenta Carpet",
|
||||||
@ -47,18 +61,12 @@ class Carpet extends Flowable{
|
|||||||
14 => "Red Carpet",
|
14 => "Red Carpet",
|
||||||
15 => "Black Carpet",
|
15 => "Black Carpet",
|
||||||
];
|
];
|
||||||
$this->name = $names[$this->meta];
|
return $names[$this->meta & 0x0f];
|
||||||
$this->hardness = 0;
|
|
||||||
$this->isFullBlock = false;
|
|
||||||
$this->isSolid = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getBoundingBox(){
|
protected function recalculateBoundingBox(){
|
||||||
if($this->boundingBox !== null){
|
|
||||||
return $this->boundingBox;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this->boundingBox = new AxisAlignedBB(
|
return new AxisAlignedBB(
|
||||||
$this->x,
|
$this->x,
|
||||||
$this->y,
|
$this->y,
|
||||||
$this->z,
|
$this->z,
|
||||||
@ -70,7 +78,7 @@ class Carpet extends Flowable{
|
|||||||
|
|
||||||
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){
|
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){
|
||||||
$down = $this->getSide(0);
|
$down = $this->getSide(0);
|
||||||
if($down->getID() !== self::AIR){
|
if($down->getId() !== self::AIR){
|
||||||
$this->getLevel()->setBlock($block, $this, true, true);
|
$this->getLevel()->setBlock($block, $this, true, true);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -81,7 +89,7 @@ class Carpet extends Flowable{
|
|||||||
|
|
||||||
public function onUpdate($type){
|
public function onUpdate($type){
|
||||||
if($type === Level::BLOCK_UPDATE_NORMAL){
|
if($type === Level::BLOCK_UPDATE_NORMAL){
|
||||||
if($this->getSide(0)->getID() === self::AIR){
|
if($this->getSide(0)->getId() === self::AIR){
|
||||||
$this->getLevel()->useBreakOn($this);
|
$this->getLevel()->useBreakOn($this);
|
||||||
|
|
||||||
return Level::BLOCK_UPDATE_NORMAL;
|
return Level::BLOCK_UPDATE_NORMAL;
|
||||||
|
@ -24,8 +24,15 @@ namespace pocketmine\block;
|
|||||||
use pocketmine\item\Item;
|
use pocketmine\item\Item;
|
||||||
|
|
||||||
class Carrot extends Crops{
|
class Carrot extends Crops{
|
||||||
|
|
||||||
|
protected $id = self::CARROT_BLOCK;
|
||||||
|
|
||||||
public function __construct($meta = 0){
|
public function __construct($meta = 0){
|
||||||
parent::__construct(self::CARROT_BLOCK, $meta, "Carrot Block");
|
$this->meta = $meta;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getName(){
|
||||||
|
return "Carrot Block";
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getDrops(Item $item){
|
public function getDrops(Item $item){
|
||||||
|
@ -22,32 +22,43 @@
|
|||||||
namespace pocketmine\block;
|
namespace pocketmine\block;
|
||||||
|
|
||||||
use pocketmine\item\Item;
|
use pocketmine\item\Item;
|
||||||
|
use pocketmine\item\Tool;
|
||||||
use pocketmine\math\AxisAlignedBB;
|
use pocketmine\math\AxisAlignedBB;
|
||||||
use pocketmine\nbt\NBT;
|
use pocketmine\nbt\NBT;
|
||||||
use pocketmine\nbt\tag\Compound;
|
use pocketmine\nbt\tag\CompoundTag;
|
||||||
use pocketmine\nbt\tag\Enum;
|
use pocketmine\nbt\tag\ListTag;
|
||||||
use pocketmine\nbt\tag\Int;
|
use pocketmine\nbt\tag\IntTag;
|
||||||
use pocketmine\nbt\tag\String;
|
use pocketmine\nbt\tag\StringTag;
|
||||||
use pocketmine\Player;
|
use pocketmine\Player;
|
||||||
use pocketmine\tile\Chest as TileChest;
|
use pocketmine\tile\Chest as TileChest;
|
||||||
use pocketmine\tile\Tile;
|
use pocketmine\tile\Tile;
|
||||||
|
|
||||||
class Chest extends Transparent{
|
class Chest extends Transparent{
|
||||||
|
|
||||||
const SLOTS = 27;
|
protected $id = self::CHEST;
|
||||||
|
|
||||||
public function __construct($meta = 0){
|
public function __construct($meta = 0){
|
||||||
parent::__construct(self::CHEST, $meta, "Chest");
|
$this->meta = $meta;
|
||||||
$this->isActivable = true;
|
|
||||||
$this->hardness = 15;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getBoundingBox(){
|
public function canBeActivated(){
|
||||||
if($this->boundingBox !== null){
|
return true;
|
||||||
return $this->boundingBox;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return $this->boundingBox = new AxisAlignedBB(
|
public function getHardness(){
|
||||||
|
return 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->x + 0.0625,
|
||||||
$this->y,
|
$this->y,
|
||||||
$this->z + 0.0625,
|
$this->z + 0.0625,
|
||||||
@ -65,7 +76,7 @@ class Chest extends Transparent{
|
|||||||
3 => 3,
|
3 => 3,
|
||||||
];
|
];
|
||||||
|
|
||||||
$chest = false;
|
$chest = null;
|
||||||
$this->meta = $faces[$player instanceof Player ? $player->getDirection() : 0];
|
$this->meta = $faces[$player instanceof Player ? $player->getDirection() : 0];
|
||||||
|
|
||||||
for($side = 2; $side <= 5; ++$side){
|
for($side = 2; $side <= 5; ++$side){
|
||||||
@ -85,17 +96,28 @@ class Chest extends Transparent{
|
|||||||
}
|
}
|
||||||
|
|
||||||
$this->getLevel()->setBlock($block, $this, true, true);
|
$this->getLevel()->setBlock($block, $this, true, true);
|
||||||
$nbt = new Compound(false, [
|
$nbt = new CompoundTag("", [
|
||||||
new Enum("Items", []),
|
new ListTag("Items", []),
|
||||||
new String("id", Tile::CHEST),
|
new StringTag("id", Tile::CHEST),
|
||||||
new Int("x", $this->x),
|
new IntTag("x", $this->x),
|
||||||
new Int("y", $this->y),
|
new IntTag("y", $this->y),
|
||||||
new Int("z", $this->z)
|
new IntTag("z", $this->z)
|
||||||
]);
|
]);
|
||||||
$nbt->Items->setTagType(NBT::TAG_Compound);
|
$nbt->Items->setTagType(NBT::TAG_Compound);
|
||||||
$tile = new TileChest($this->getLevel()->getChunk($this->x >> 4, $this->z >> 4), $nbt);
|
|
||||||
|
|
||||||
if($chest instanceof TileChest){
|
if($item->hasCustomName()){
|
||||||
|
$nbt->CustomName = new StringTag("CustomName", $item->getCustomName());
|
||||||
|
}
|
||||||
|
|
||||||
|
if($item->hasCustomBlockData()){
|
||||||
|
foreach($item->getCustomBlockData() as $key => $v){
|
||||||
|
$nbt->{$key} = $v;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$tile = Tile::createTile("Chest", $this->getLevel()->getChunk($this->x >> 4, $this->z >> 4), $nbt);
|
||||||
|
|
||||||
|
if($chest instanceof TileChest and $tile instanceof TileChest){
|
||||||
$chest->pairWith($tile);
|
$chest->pairWith($tile);
|
||||||
$tile->pairWith($chest);
|
$tile->pairWith($chest);
|
||||||
}
|
}
|
||||||
@ -116,7 +138,7 @@ class Chest extends Transparent{
|
|||||||
public function onActivate(Item $item, Player $player = null){
|
public function onActivate(Item $item, Player $player = null){
|
||||||
if($player instanceof Player){
|
if($player instanceof Player){
|
||||||
$top = $this->getSide(1);
|
$top = $this->getSide(1);
|
||||||
if($top->isTransparent !== true){
|
if($top->isTransparent() !== true){
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -125,19 +147,24 @@ class Chest extends Transparent{
|
|||||||
if($t instanceof TileChest){
|
if($t instanceof TileChest){
|
||||||
$chest = $t;
|
$chest = $t;
|
||||||
}else{
|
}else{
|
||||||
$nbt = new Compound(false, [
|
$nbt = new CompoundTag("", [
|
||||||
new Enum("Items", []),
|
new ListTag("Items", []),
|
||||||
new String("id", Tile::CHEST),
|
new StringTag("id", Tile::CHEST),
|
||||||
new Int("x", $this->x),
|
new IntTag("x", $this->x),
|
||||||
new Int("y", $this->y),
|
new IntTag("y", $this->y),
|
||||||
new Int("z", $this->z)
|
new IntTag("z", $this->z)
|
||||||
]);
|
]);
|
||||||
$nbt->Items->setTagType(NBT::TAG_Compound);
|
$nbt->Items->setTagType(NBT::TAG_Compound);
|
||||||
$chest = new TileChest($this->getLevel()->getChunk($this->x >> 4, $this->z >> 4), $nbt);
|
$chest = Tile::createTile("Chest", $this->getLevel()->getChunk($this->x >> 4, $this->z >> 4), $nbt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(isset($chest->namedtag->Lock) and $chest->namedtag->Lock instanceof StringTag){
|
||||||
|
if($chest->namedtag->Lock->getValue() !== $item->getCustomName()){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if(($player->gamemode & 0x01) === 0x01){
|
if($player->isCreative()){
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
$player->addWindow($chest->getInventory());
|
$player->addWindow($chest->getInventory());
|
||||||
|
@ -22,11 +22,26 @@
|
|||||||
namespace pocketmine\block;
|
namespace pocketmine\block;
|
||||||
|
|
||||||
use pocketmine\item\Item;
|
use pocketmine\item\Item;
|
||||||
|
use pocketmine\item\Tool;
|
||||||
|
|
||||||
class Clay extends Solid{
|
class Clay extends Solid{
|
||||||
|
|
||||||
|
protected $id = self::CLAY_BLOCK;
|
||||||
|
|
||||||
public function __construct(){
|
public function __construct(){
|
||||||
parent::__construct(self::CLAY_BLOCK, 0, "Clay Block");
|
|
||||||
$this->hardness = 3;
|
}
|
||||||
|
|
||||||
|
public function getHardness(){
|
||||||
|
return 0.6;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getToolType(){
|
||||||
|
return Tool::TYPE_SHOVEL;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getName(){
|
||||||
|
return "Clay Block";
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getDrops(Item $item){
|
public function getDrops(Item $item){
|
||||||
|
@ -22,32 +22,30 @@
|
|||||||
namespace pocketmine\block;
|
namespace pocketmine\block;
|
||||||
|
|
||||||
use pocketmine\item\Item;
|
use pocketmine\item\Item;
|
||||||
|
use pocketmine\item\Tool;
|
||||||
|
|
||||||
class Coal extends Solid{
|
class Coal extends Solid{
|
||||||
|
|
||||||
|
protected $id = self::COAL_BLOCK;
|
||||||
|
|
||||||
public function __construct(){
|
public function __construct(){
|
||||||
parent::__construct(self::COAL_BLOCK, 0, "Coal Block");
|
|
||||||
$this->hardness = 30;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getBreakTime(Item $item){
|
public function getHardness(){
|
||||||
switch($item->isPickaxe()){
|
return 5;
|
||||||
case 5:
|
}
|
||||||
return 0.95;
|
|
||||||
case 4:
|
public function getToolType(){
|
||||||
return 1.25;
|
return Tool::TYPE_PICKAXE;
|
||||||
case 3:
|
}
|
||||||
return 1.9;
|
|
||||||
case 2:
|
public function getName(){
|
||||||
return 0.65;
|
return "Coal Block";
|
||||||
case 1:
|
|
||||||
return 3.75;
|
|
||||||
default:
|
|
||||||
return 25;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getDrops(Item $item){
|
public function getDrops(Item $item){
|
||||||
if($item->isPickaxe() >= 1){
|
if($item->isPickaxe() >= Tool::TIER_WOODEN){
|
||||||
return [
|
return [
|
||||||
[Item::COAL_BLOCK, 0, 1],
|
[Item::COAL_BLOCK, 0, 1],
|
||||||
];
|
];
|
||||||
|
@ -22,32 +22,30 @@
|
|||||||
namespace pocketmine\block;
|
namespace pocketmine\block;
|
||||||
|
|
||||||
use pocketmine\item\Item;
|
use pocketmine\item\Item;
|
||||||
|
use pocketmine\item\Tool;
|
||||||
|
|
||||||
class CoalOre extends Solid{
|
class CoalOre extends Solid{
|
||||||
|
|
||||||
|
protected $id = self::COAL_ORE;
|
||||||
|
|
||||||
public function __construct(){
|
public function __construct(){
|
||||||
parent::__construct(self::COAL_ORE, 0, "Coal Ore");
|
|
||||||
$this->hardness = 15;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getBreakTime(Item $item){
|
public function getHardness(){
|
||||||
switch($item->isPickaxe()){
|
return 3;
|
||||||
case 5:
|
}
|
||||||
return 0.6;
|
|
||||||
case 4:
|
public function getToolType(){
|
||||||
return 0.75;
|
return Tool::TYPE_PICKAXE;
|
||||||
case 3:
|
}
|
||||||
return 1.15;
|
|
||||||
case 2:
|
public function getName(){
|
||||||
return 0.4;
|
return "Coal Ore";
|
||||||
case 1:
|
|
||||||
return 2.25;
|
|
||||||
default:
|
|
||||||
return 15;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getDrops(Item $item){
|
public function getDrops(Item $item){
|
||||||
if($item->isPickaxe() >= 1){
|
if($item->isPickaxe() >= Tool::TIER_WOODEN){
|
||||||
return [
|
return [
|
||||||
[Item::COAL, 0, 1],
|
[Item::COAL, 0, 1],
|
||||||
];
|
];
|
||||||
|
@ -22,32 +22,30 @@
|
|||||||
namespace pocketmine\block;
|
namespace pocketmine\block;
|
||||||
|
|
||||||
use pocketmine\item\Item;
|
use pocketmine\item\Item;
|
||||||
|
use pocketmine\item\Tool;
|
||||||
|
|
||||||
class Cobblestone extends Solid{
|
class Cobblestone extends Solid{
|
||||||
|
|
||||||
|
protected $id = self::COBBLESTONE;
|
||||||
|
|
||||||
public function __construct(){
|
public function __construct(){
|
||||||
parent::__construct(self::COBBLESTONE, 0, "Cobblestone");
|
|
||||||
$this->hardness = 30;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getBreakTime(Item $item){
|
public function getToolType(){
|
||||||
switch($item->isPickaxe()){
|
return Tool::TYPE_PICKAXE;
|
||||||
case 5:
|
}
|
||||||
return 0.4;
|
|
||||||
case 4:
|
public function getName(){
|
||||||
return 0.5;
|
return "Cobblestone";
|
||||||
case 3:
|
}
|
||||||
return 0.75;
|
|
||||||
case 2:
|
public function getHardness(){
|
||||||
return 0.25;
|
return 2;
|
||||||
case 1:
|
|
||||||
return 1.5;
|
|
||||||
default:
|
|
||||||
return 10;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getDrops(Item $item){
|
public function getDrops(Item $item){
|
||||||
if($item->isPickaxe() >= 1){
|
if($item->isPickaxe() >= Tool::TIER_WOODEN){
|
||||||
return [
|
return [
|
||||||
[Item::COBBLESTONE, 0, 1],
|
[Item::COBBLESTONE, 0, 1],
|
||||||
];
|
];
|
||||||
|
@ -22,9 +22,26 @@
|
|||||||
namespace pocketmine\block;
|
namespace pocketmine\block;
|
||||||
|
|
||||||
|
|
||||||
|
use pocketmine\item\Tool;
|
||||||
|
|
||||||
class CobblestoneStairs extends Stair{
|
class CobblestoneStairs extends Stair{
|
||||||
|
|
||||||
|
protected $id = self::COBBLESTONE_STAIRS;
|
||||||
|
|
||||||
public function __construct($meta = 0){
|
public function __construct($meta = 0){
|
||||||
parent::__construct(self::COBBLESTONE_STAIRS, $meta, "Cobblestone Stairs");
|
$this->meta = $meta;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function 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\entity\Entity;
|
||||||
use pocketmine\item\Item;
|
use pocketmine\item\Item;
|
||||||
|
use pocketmine\item\Tool;
|
||||||
|
|
||||||
class Cobweb extends Flowable{
|
class Cobweb extends Flowable{
|
||||||
|
|
||||||
public $hasEntityCollision = true;
|
protected $id = self::COBWEB;
|
||||||
|
|
||||||
public function __construct(){
|
public function __construct(){
|
||||||
parent::__construct(self::COBWEB, 0, "Cobweb");
|
|
||||||
$this->isSolid = true;
|
}
|
||||||
$this->isFullBlock = false;
|
|
||||||
$this->hardness = 25;
|
public function hasEntityCollision(){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getName(){
|
||||||
|
return "Cobweb";
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getHardness(){
|
||||||
|
return 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getToolType(){
|
||||||
|
return Tool::TYPE_SWORD;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onEntityCollide(Entity $entity){
|
public function onEntityCollide(Entity $entity){
|
||||||
$entity->fallDistance = 0;
|
$entity->resetFallDistance();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getDrops(Item $item){
|
public function getDrops(Item $item){
|
||||||
|
//TODO: correct drops
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
}
|
}
|
35
src/pocketmine/block/CocoaBlock.php
Normal file
35
src/pocketmine/block/CocoaBlock.php
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
*
|
||||||
|
* ____ _ _ __ __ _ __ __ ____
|
||||||
|
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
|
||||||
|
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
|
||||||
|
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
|
||||||
|
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* @author PocketMine Team
|
||||||
|
* @link http://www.pocketmine.net/
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace pocketmine\block;
|
||||||
|
|
||||||
|
class CocoaBlock extends Solid {
|
||||||
|
|
||||||
|
protected $id = self::COCOA_BLOCK;
|
||||||
|
|
||||||
|
public function __construct($meta = 0){
|
||||||
|
$this->meta = $meta;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getName(){
|
||||||
|
return "Cocoa Block";
|
||||||
|
}
|
||||||
|
}
|
@ -29,17 +29,13 @@ use pocketmine\Server;
|
|||||||
|
|
||||||
abstract class Crops extends Flowable{
|
abstract class Crops extends Flowable{
|
||||||
|
|
||||||
public $isActivable = true;
|
public function canBeActivated(){
|
||||||
public $hardness = 0;
|
return true;
|
||||||
|
|
||||||
|
|
||||||
public function getBoundingBox(){
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){
|
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){
|
||||||
$down = $this->getSide(0);
|
$down = $this->getSide(0);
|
||||||
if($down->getID() === self::FARMLAND){
|
if($down->getId() === self::FARMLAND){
|
||||||
$this->getLevel()->setBlock($block, $this, true, true);
|
$this->getLevel()->setBlock($block, $this, true, true);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -50,7 +46,7 @@ abstract class Crops extends Flowable{
|
|||||||
|
|
||||||
|
|
||||||
public function onActivate(Item $item, Player $player = null){
|
public function onActivate(Item $item, Player $player = null){
|
||||||
if($item->getID() === Item::DYE and $item->getDamage() === 0x0F){ //Bonemeal
|
if($item->getId() === Item::DYE and $item->getDamage() === 0x0F){ //Bonemeal
|
||||||
$block = clone $this;
|
$block = clone $this;
|
||||||
$block->meta += mt_rand(2, 5);
|
$block->meta += mt_rand(2, 5);
|
||||||
if($block->meta > 7){
|
if($block->meta > 7){
|
||||||
@ -73,7 +69,7 @@ abstract class Crops extends Flowable{
|
|||||||
|
|
||||||
public function onUpdate($type){
|
public function onUpdate($type){
|
||||||
if($type === Level::BLOCK_UPDATE_NORMAL){
|
if($type === Level::BLOCK_UPDATE_NORMAL){
|
||||||
if($this->getSide(0)->isTransparent === true){
|
if($this->getSide(0)->isTransparent() === true){
|
||||||
$this->getLevel()->useBreakOn($this);
|
$this->getLevel()->useBreakOn($this);
|
||||||
return Level::BLOCK_UPDATE_NORMAL;
|
return Level::BLOCK_UPDATE_NORMAL;
|
||||||
}
|
}
|
||||||
|
@ -26,19 +26,21 @@ use pocketmine\level\Level;
|
|||||||
use pocketmine\Player;
|
use pocketmine\Player;
|
||||||
|
|
||||||
class Dandelion extends Flowable{
|
class Dandelion extends Flowable{
|
||||||
|
|
||||||
|
protected $id = self::DANDELION;
|
||||||
|
|
||||||
public function __construct(){
|
public function __construct(){
|
||||||
parent::__construct(self::DANDELION, 0, "Dandelion");
|
|
||||||
$this->hardness = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getBoundingBox(){
|
public function getName(){
|
||||||
return null;
|
return "Dandelion";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){
|
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){
|
||||||
$down = $this->getSide(0);
|
$down = $this->getSide(0);
|
||||||
if($down->getID() === 2 or $down->getID() === 3 or $down->getID() === 60){
|
if($down->getId() === 2 or $down->getId() === 3 or $down->getId() === 60){
|
||||||
$this->getLevel()->setBlock($block, $this, true, true);
|
$this->getLevel()->setBlock($block, $this, true, true);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -49,7 +51,7 @@ class Dandelion extends Flowable{
|
|||||||
|
|
||||||
public function onUpdate($type){
|
public function onUpdate($type){
|
||||||
if($type === Level::BLOCK_UPDATE_NORMAL){
|
if($type === Level::BLOCK_UPDATE_NORMAL){
|
||||||
if($this->getSide(0)->isTransparent === true){
|
if($this->getSide(0)->isTransparent() === true){
|
||||||
$this->getLevel()->useBreakOn($this);
|
$this->getLevel()->useBreakOn($this);
|
||||||
|
|
||||||
return Level::BLOCK_UPDATE_NORMAL;
|
return Level::BLOCK_UPDATE_NORMAL;
|
||||||
|
@ -22,10 +22,22 @@
|
|||||||
namespace pocketmine\block;
|
namespace pocketmine\block;
|
||||||
|
|
||||||
use pocketmine\item\Item;
|
use pocketmine\item\Item;
|
||||||
|
use pocketmine\item\Tool;
|
||||||
|
|
||||||
class DarkOakWoodStairs extends Stair{
|
class DarkOakWoodStairs extends Stair{
|
||||||
|
|
||||||
|
protected $id = self::DARK_OAK_WOOD_STAIRS;
|
||||||
|
|
||||||
public function __construct($meta = 0){
|
public function __construct($meta = 0){
|
||||||
parent::__construct(self::DARK_OAK_WOOD_STAIRS, $meta, "Dark Oak Wood Stairs");
|
$this->meta = $meta;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getName(){
|
||||||
|
return "Dark Oak Wood Stairs";
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getToolType(){
|
||||||
|
return Tool::TYPE_AXE;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getDrops(Item $item){
|
public function getDrops(Item $item){
|
||||||
|
35
src/pocketmine/block/DaylightSensor.php
Normal file
35
src/pocketmine/block/DaylightSensor.php
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
*
|
||||||
|
* ____ _ _ __ __ _ __ __ ____
|
||||||
|
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
|
||||||
|
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
|
||||||
|
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
|
||||||
|
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* @author PocketMine Team
|
||||||
|
* @link http://www.pocketmine.net/
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace pocketmine\block;
|
||||||
|
|
||||||
|
class DaylightSensor extends Solid {
|
||||||
|
|
||||||
|
protected $id = self::DAYLIGHT_SENSOR;
|
||||||
|
|
||||||
|
public function __construct($meta = 0){
|
||||||
|
$this->meta = $meta;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getName(){
|
||||||
|
return "Daylight Sensor";
|
||||||
|
}
|
||||||
|
}
|
@ -24,21 +24,22 @@ namespace pocketmine\block;
|
|||||||
use pocketmine\level\Level;
|
use pocketmine\level\Level;
|
||||||
|
|
||||||
class DeadBush extends Flowable{
|
class DeadBush extends Flowable{
|
||||||
public function __construct(){
|
|
||||||
parent::__construct(self::DEAD_BUSH, 0, "Dead Bush");
|
protected $id = self::DEAD_BUSH;
|
||||||
//$this->isReplaceable = true;
|
|
||||||
$this->hardness = 0;
|
public function __construct($meta = 0){
|
||||||
|
$this->meta = $meta;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getBoundingBox(){
|
public function getName(){
|
||||||
return null;
|
return "Dead Bush";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function onUpdate($type){
|
public function onUpdate($type){
|
||||||
if($type === Level::BLOCK_UPDATE_NORMAL){
|
if($type === Level::BLOCK_UPDATE_NORMAL){
|
||||||
if($this->getSide(0)->isTransparent === true){ //Replace with common break method
|
if($this->getSide(0)->isTransparent() === true){
|
||||||
$this->getLevel()->setBlock($this, new Air(), false, false, true);
|
$this->getLevel()->useBreakOn($this);
|
||||||
|
|
||||||
return Level::BLOCK_UPDATE_NORMAL;
|
return Level::BLOCK_UPDATE_NORMAL;
|
||||||
}
|
}
|
||||||
|
35
src/pocketmine/block/DetectorRail.php
Normal file
35
src/pocketmine/block/DetectorRail.php
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
*
|
||||||
|
* ____ _ _ __ __ _ __ __ ____
|
||||||
|
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
|
||||||
|
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
|
||||||
|
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
|
||||||
|
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* @author PocketMine Team
|
||||||
|
* @link http://www.pocketmine.net/
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace pocketmine\block;
|
||||||
|
|
||||||
|
class DetectorRail extends Solid {
|
||||||
|
|
||||||
|
protected $id = self::DETECTOR_RAIL;
|
||||||
|
|
||||||
|
public function __construct($meta = 0){
|
||||||
|
$this->meta = $meta;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getName(){
|
||||||
|
return "Detector Rail";
|
||||||
|
}
|
||||||
|
}
|
@ -22,26 +22,30 @@
|
|||||||
namespace pocketmine\block;
|
namespace pocketmine\block;
|
||||||
|
|
||||||
use pocketmine\item\Item;
|
use pocketmine\item\Item;
|
||||||
|
use pocketmine\item\Tool;
|
||||||
|
|
||||||
class Diamond extends Solid{
|
class Diamond extends Solid{
|
||||||
|
|
||||||
|
protected $id = self::DIAMOND_BLOCK;
|
||||||
|
|
||||||
public function __construct(){
|
public function __construct(){
|
||||||
parent::__construct(self::DIAMOND_BLOCK, 0, "Diamond Block");
|
|
||||||
$this->hardness = 30;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getBreakTime(Item $item){
|
public function getHardness(){
|
||||||
switch($item->isPickaxe()){
|
return 5;
|
||||||
case 5:
|
}
|
||||||
return 0.95;
|
|
||||||
case 4:
|
public function getName(){
|
||||||
return 1.25;
|
return "Diamond Block";
|
||||||
default:
|
}
|
||||||
return 25;
|
|
||||||
}
|
public function getToolType(){
|
||||||
|
return Tool::TYPE_PICKAXE;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getDrops(Item $item){
|
public function getDrops(Item $item){
|
||||||
if($item->isPickaxe() >= 4){
|
if($item->isPickaxe() >= Tool::TIER_IRON){
|
||||||
return [
|
return [
|
||||||
[Item::DIAMOND_BLOCK, 0, 1],
|
[Item::DIAMOND_BLOCK, 0, 1],
|
||||||
];
|
];
|
||||||
|
@ -22,26 +22,30 @@
|
|||||||
namespace pocketmine\block;
|
namespace pocketmine\block;
|
||||||
|
|
||||||
use pocketmine\item\Item;
|
use pocketmine\item\Item;
|
||||||
|
use pocketmine\item\Tool;
|
||||||
|
|
||||||
class DiamondOre extends Solid{
|
class DiamondOre extends Solid{
|
||||||
|
|
||||||
|
protected $id = self::DIAMOND_ORE;
|
||||||
|
|
||||||
public function __construct(){
|
public function __construct(){
|
||||||
parent::__construct(self::DIAMOND_ORE, 0, "Diamond Ore");
|
|
||||||
$this->hardness = 15;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getBreakTime(Item $item){
|
public function getHardness(){
|
||||||
switch($item->isPickaxe()){
|
return 3;
|
||||||
case 5:
|
}
|
||||||
return 0.6;
|
|
||||||
case 4:
|
public function getName(){
|
||||||
return 0.75;
|
return "Diamond Ore";
|
||||||
default:
|
}
|
||||||
return 15;
|
|
||||||
}
|
public function getToolType(){
|
||||||
|
return Tool::TYPE_PICKAXE;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getDrops(Item $item){
|
public function getDrops(Item $item){
|
||||||
if($item->isPickaxe() >= 4){
|
if($item->isPickaxe() >= Tool::TIER_IRON){
|
||||||
return [
|
return [
|
||||||
[Item::DIAMOND, 0, 1],
|
[Item::DIAMOND, 0, 1],
|
||||||
];
|
];
|
||||||
|
@ -22,20 +22,33 @@
|
|||||||
namespace pocketmine\block;
|
namespace pocketmine\block;
|
||||||
|
|
||||||
use pocketmine\item\Item;
|
use pocketmine\item\Item;
|
||||||
|
use pocketmine\item\Tool;
|
||||||
use pocketmine\Player;
|
use pocketmine\Player;
|
||||||
|
|
||||||
class Dirt extends Solid{
|
class Dirt extends Solid{
|
||||||
|
|
||||||
public $isActivable = true;
|
|
||||||
protected $hardness = 2.5;
|
|
||||||
protected $id = self::DIRT;
|
protected $id = self::DIRT;
|
||||||
protected $meta = 0;
|
|
||||||
protected $name = "Dirt";
|
|
||||||
|
|
||||||
public function __construct(){
|
public function __construct(){
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function canBeActivated(){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getHardness(){
|
||||||
|
return 0.5;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getToolType(){
|
||||||
|
return Tool::TYPE_SHOVEL;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getName(){
|
||||||
|
return "Dirt";
|
||||||
|
}
|
||||||
|
|
||||||
public function onActivate(Item $item, Player $player = null){
|
public function onActivate(Item $item, Player $player = null){
|
||||||
if($item->isHoe()){
|
if($item->isHoe()){
|
||||||
$item->useOn($this);
|
$item->useOn($this);
|
||||||
|
@ -23,39 +23,40 @@ namespace pocketmine\block;
|
|||||||
|
|
||||||
use pocketmine\item\Item;
|
use pocketmine\item\Item;
|
||||||
use pocketmine\level\Level;
|
use pocketmine\level\Level;
|
||||||
|
use pocketmine\level\sound\DoorSound;
|
||||||
use pocketmine\math\AxisAlignedBB;
|
use pocketmine\math\AxisAlignedBB;
|
||||||
use pocketmine\network\protocol\LevelEventPacket;
|
use pocketmine\math\Vector3;
|
||||||
use pocketmine\Player;
|
use pocketmine\Player;
|
||||||
use pocketmine\Server;
|
|
||||||
|
|
||||||
|
|
||||||
abstract class Door extends Transparent{
|
abstract class Door extends Transparent{
|
||||||
public function __construct($id, $meta = 0, $name = "Unknown"){
|
|
||||||
parent::__construct($id, $meta, $name);
|
public function canBeActivated(){
|
||||||
$this->isSolid = false;
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function isSolid(){
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getFullDamage(){
|
private function getFullDamage(){
|
||||||
$damage = $this->getDamage();
|
$damage = $this->getDamage();
|
||||||
$flag = ($damage & 0x08) > 0;
|
$isUp = ($damage & 0x08) > 0;
|
||||||
|
|
||||||
if($flag){
|
if($isUp){
|
||||||
$first = $this->getSide(0)->getDamage();
|
$down = $this->getSide(Vector3::SIDE_DOWN)->getDamage();
|
||||||
$second = $damage;
|
$up = $damage;
|
||||||
}else{
|
}else{
|
||||||
$first = $damage;
|
$down = $damage;
|
||||||
$second = $this->getSide(1)->getDamage();
|
$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);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getBoundingBox(){
|
protected function recalculateBoundingBox(){
|
||||||
if($this->boundingBox !== null){
|
|
||||||
return $this->boundingBox;
|
|
||||||
}
|
|
||||||
|
|
||||||
$f = 0.1875;
|
$f = 0.1875;
|
||||||
$damage = $this->getFullDamage();
|
$damage = $this->getFullDamage();
|
||||||
@ -70,13 +71,13 @@ abstract class Door extends Transparent{
|
|||||||
);
|
);
|
||||||
|
|
||||||
$j = $damage & 0x03;
|
$j = $damage & 0x03;
|
||||||
$flag = (($damage & 0x04) > 0);
|
$isOpen = (($damage & 0x04) > 0);
|
||||||
$flag1 = (($damage & 0x10) > 0);
|
$isRight = (($damage & 0x10) > 0);
|
||||||
|
|
||||||
if($j === 0){
|
if($j === 0){
|
||||||
if($flag){
|
if($isOpen){
|
||||||
if(!$flag1){
|
if(!$isRight){
|
||||||
$bb = new AxisAlignedBB(
|
$bb->setBounds(
|
||||||
$this->x,
|
$this->x,
|
||||||
$this->y,
|
$this->y,
|
||||||
$this->z,
|
$this->z,
|
||||||
@ -85,7 +86,7 @@ abstract class Door extends Transparent{
|
|||||||
$this->z + $f
|
$this->z + $f
|
||||||
);
|
);
|
||||||
}else{
|
}else{
|
||||||
$bb = new AxisAlignedBB(
|
$bb->setBounds(
|
||||||
$this->x,
|
$this->x,
|
||||||
$this->y,
|
$this->y,
|
||||||
$this->z + 1 - $f,
|
$this->z + 1 - $f,
|
||||||
@ -95,7 +96,7 @@ abstract class Door extends Transparent{
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
$bb = new AxisAlignedBB(
|
$bb->setBounds(
|
||||||
$this->x,
|
$this->x,
|
||||||
$this->y,
|
$this->y,
|
||||||
$this->z,
|
$this->z,
|
||||||
@ -105,9 +106,9 @@ abstract class Door extends Transparent{
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}elseif($j === 1){
|
}elseif($j === 1){
|
||||||
if($flag){
|
if($isOpen){
|
||||||
if(!$flag1){
|
if(!$isRight){
|
||||||
$bb = new AxisAlignedBB(
|
$bb->setBounds(
|
||||||
$this->x + 1 - $f,
|
$this->x + 1 - $f,
|
||||||
$this->y,
|
$this->y,
|
||||||
$this->z,
|
$this->z,
|
||||||
@ -116,7 +117,7 @@ abstract class Door extends Transparent{
|
|||||||
$this->z + 1
|
$this->z + 1
|
||||||
);
|
);
|
||||||
}else{
|
}else{
|
||||||
$bb = new AxisAlignedBB(
|
$bb->setBounds(
|
||||||
$this->x,
|
$this->x,
|
||||||
$this->y,
|
$this->y,
|
||||||
$this->z,
|
$this->z,
|
||||||
@ -126,7 +127,7 @@ abstract class Door extends Transparent{
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
$bb = new AxisAlignedBB(
|
$bb->setBounds(
|
||||||
$this->x,
|
$this->x,
|
||||||
$this->y,
|
$this->y,
|
||||||
$this->z,
|
$this->z,
|
||||||
@ -136,9 +137,9 @@ abstract class Door extends Transparent{
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}elseif($j === 2){
|
}elseif($j === 2){
|
||||||
if($flag){
|
if($isOpen){
|
||||||
if(!$flag1){
|
if(!$isRight){
|
||||||
$bb = new AxisAlignedBB(
|
$bb->setBounds(
|
||||||
$this->x,
|
$this->x,
|
||||||
$this->y,
|
$this->y,
|
||||||
$this->z + 1 - $f,
|
$this->z + 1 - $f,
|
||||||
@ -147,7 +148,7 @@ abstract class Door extends Transparent{
|
|||||||
$this->z + 1
|
$this->z + 1
|
||||||
);
|
);
|
||||||
}else{
|
}else{
|
||||||
$bb = new AxisAlignedBB(
|
$bb->setBounds(
|
||||||
$this->x,
|
$this->x,
|
||||||
$this->y,
|
$this->y,
|
||||||
$this->z,
|
$this->z,
|
||||||
@ -157,7 +158,7 @@ abstract class Door extends Transparent{
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
$bb = new AxisAlignedBB(
|
$bb->setBounds(
|
||||||
$this->x + 1 - $f,
|
$this->x + 1 - $f,
|
||||||
$this->y,
|
$this->y,
|
||||||
$this->z,
|
$this->z,
|
||||||
@ -167,9 +168,9 @@ abstract class Door extends Transparent{
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}elseif($j === 3){
|
}elseif($j === 3){
|
||||||
if($flag){
|
if($isOpen){
|
||||||
if(!$flag1){
|
if(!$isRight){
|
||||||
$bb = new AxisAlignedBB(
|
$bb->setBounds(
|
||||||
$this->x,
|
$this->x,
|
||||||
$this->y,
|
$this->y,
|
||||||
$this->z,
|
$this->z,
|
||||||
@ -178,7 +179,7 @@ abstract class Door extends Transparent{
|
|||||||
$this->z + 1
|
$this->z + 1
|
||||||
);
|
);
|
||||||
}else{
|
}else{
|
||||||
$bb = new AxisAlignedBB(
|
$bb->setBounds(
|
||||||
$this->x + 1 - $f,
|
$this->x + 1 - $f,
|
||||||
$this->y,
|
$this->y,
|
||||||
$this->z,
|
$this->z,
|
||||||
@ -188,7 +189,7 @@ abstract class Door extends Transparent{
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
$bb = new AxisAlignedBB(
|
$bb->setBounds(
|
||||||
$this->x,
|
$this->x,
|
||||||
$this->y,
|
$this->y,
|
||||||
$this->z + 1 - $f,
|
$this->z + 1 - $f,
|
||||||
@ -199,12 +200,12 @@ abstract class Door extends Transparent{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->boundingBox = $bb;
|
return $bb;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onUpdate($type){
|
public function onUpdate($type){
|
||||||
if($type === Level::BLOCK_UPDATE_NORMAL){
|
if($type === Level::BLOCK_UPDATE_NORMAL){
|
||||||
if($this->getSide(0)->getID() === self::AIR){ //Replace with common break method
|
if($this->getSide(0)->getId() === self::AIR){ //Replace with common break method
|
||||||
$this->getLevel()->setBlock($this, new Air(), false);
|
$this->getLevel()->setBlock($this, new Air(), false);
|
||||||
if($this->getSide(1) instanceof Door){
|
if($this->getSide(1) instanceof Door){
|
||||||
$this->getLevel()->setBlock($this->getSide(1), new Air(), false);
|
$this->getLevel()->setBlock($this->getSide(1), new Air(), false);
|
||||||
@ -221,7 +222,7 @@ abstract class Door extends Transparent{
|
|||||||
if($face === 1){
|
if($face === 1){
|
||||||
$blockUp = $this->getSide(1);
|
$blockUp = $this->getSide(1);
|
||||||
$blockDown = $this->getSide(0);
|
$blockDown = $this->getSide(0);
|
||||||
if($blockUp->isReplaceable === false or $blockDown->isTransparent === true){
|
if($blockUp->canBeReplaced() === false or $blockDown->isTransparent() === true){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$direction = $player instanceof Player ? $player->getDirection() : 0;
|
$direction = $player instanceof Player ? $player->getDirection() : 0;
|
||||||
@ -234,13 +235,13 @@ abstract class Door extends Transparent{
|
|||||||
$next = $this->getSide($face[(($direction + 2) % 4)]);
|
$next = $this->getSide($face[(($direction + 2) % 4)]);
|
||||||
$next2 = $this->getSide($face[$direction]);
|
$next2 = $this->getSide($face[$direction]);
|
||||||
$metaUp = 0x08;
|
$metaUp = 0x08;
|
||||||
if($next->getID() === $this->id or ($next2->isTransparent === false and $next->isTransparent === true)){ //Door hinge
|
if($next->getId() === $this->getId() or ($next2->isTransparent() === false and $next->isTransparent() === true)){ //Door hinge
|
||||||
$metaUp |= 0x01;
|
$metaUp |= 0x01;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->meta = $player->getDirection() & 0x03;
|
$this->setDamage($player->getDirection() & 0x03);
|
||||||
$this->getLevel()->setBlock($block, $this, true, true); //Bottom
|
$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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -248,14 +249,14 @@ abstract class Door extends Transparent{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function onBreak(Item $item){
|
public function onBreak(Item $item){
|
||||||
if(($this->meta & 0x08) === 0x08){
|
if(($this->getDamage() & 0x08) === 0x08){
|
||||||
$down = $this->getSide(0);
|
$down = $this->getSide(0);
|
||||||
if($down->getID() === $this->id){
|
if($down->getId() === $this->getId()){
|
||||||
$this->getLevel()->setBlock($down, new Air(), true);
|
$this->getLevel()->setBlock($down, new Air(), true);
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
$up = $this->getSide(1);
|
$up = $this->getSide(1);
|
||||||
if($up->getID() === $this->id){
|
if($up->getId() === $this->getId()){
|
||||||
$this->getLevel()->setBlock($up, new Air(), true);
|
$this->getLevel()->setBlock($up, new Air(), true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -265,23 +266,17 @@ abstract class Door extends Transparent{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function onActivate(Item $item, Player $player = null){
|
public function onActivate(Item $item, Player $player = null){
|
||||||
if(($this->meta & 0x08) === 0x08){ //Top
|
if(($this->getDamage() & 0x08) === 0x08){ //Top
|
||||||
$down = $this->getSide(0);
|
$down = $this->getSide(0);
|
||||||
if($down->getID() === $this->id){
|
if($down->getId() === $this->getId()){
|
||||||
$meta = $down->getDamage() ^ 0x04;
|
$meta = $down->getDamage() ^ 0x04;
|
||||||
$this->getLevel()->setBlock($down, Block::get($this->id, $meta), true);
|
$this->getLevel()->setBlock($down, Block::get($this->getId(), $meta), 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){
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -289,17 +284,11 @@ abstract class Door extends Transparent{
|
|||||||
}else{
|
}else{
|
||||||
$this->meta ^= 0x04;
|
$this->meta ^= 0x04;
|
||||||
$this->getLevel()->setBlock($this, $this, true);
|
$this->getLevel()->setBlock($this, $this, true);
|
||||||
$players = $this->getLevel()->getUsingChunk($this->x >> 4, $this->z >> 4);
|
$players = $this->getLevel()->getChunkPlayers($this->x >> 4, $this->z >> 4);
|
||||||
if($player instanceof Player){
|
if($player instanceof Player){
|
||||||
unset($players[$player->getID()]);
|
unset($players[$player->getLoaderId()]);
|
||||||
}
|
}
|
||||||
$pk = new LevelEventPacket;
|
$this->level->addSound(new DoorSound($this));
|
||||||
$pk->x = $this->x;
|
|
||||||
$pk->y = $this->y;
|
|
||||||
$pk->z = $this->z;
|
|
||||||
$pk->evid = 1003;
|
|
||||||
$pk->data = 0;
|
|
||||||
Server::broadcastPacket($players, $pk);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -23,34 +23,36 @@ namespace pocketmine\block;
|
|||||||
|
|
||||||
use pocketmine\item\Item;
|
use pocketmine\item\Item;
|
||||||
use pocketmine\level\Level;
|
use pocketmine\level\Level;
|
||||||
use pocketmine\Player;
|
|
||||||
|
|
||||||
class CyanFlower extends Flowable{
|
class DoublePlant extends Flowable{
|
||||||
public function __construct(){
|
|
||||||
parent::__construct(self::POPPY, 0, "Cyan Flower");
|
protected $id = self::DOUBLE_PLANT;
|
||||||
$this->hardness = 0;
|
|
||||||
|
public function __construct($meta = 0){
|
||||||
|
$this->meta = $meta;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getBoundingBox(){
|
public function canBeReplaced(){
|
||||||
return null;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getName(){
|
||||||
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){
|
static $names = [
|
||||||
$down = $this->getSide(0);
|
0 => "Sunflower",
|
||||||
if($down->getID() === 2 or $down->getID() === 3 or $down->getID() === 60){
|
1 => "Lilac",
|
||||||
$this->getLevel()->setBlock($block, $this, true, true);
|
2 => "Double Tallgrass",
|
||||||
|
3 => "Large Fern",
|
||||||
return true;
|
4 => "Rose Bush",
|
||||||
}
|
5 => "Peony"
|
||||||
|
];
|
||||||
return false;
|
return $names[$this->meta & 0x07];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function onUpdate($type){
|
public function onUpdate($type){
|
||||||
if($type === Level::BLOCK_UPDATE_NORMAL){
|
if($type === Level::BLOCK_UPDATE_NORMAL){
|
||||||
if($this->getSide(0)->isTransparent === true){
|
if($this->getSide(0)->isTransparent() === true){ //Replace with common break method
|
||||||
$this->getLevel()->useBreakOn($this);
|
$this->getLevel()->setBlock($this, new Air(), false, false, true);
|
||||||
|
|
||||||
return Level::BLOCK_UPDATE_NORMAL;
|
return Level::BLOCK_UPDATE_NORMAL;
|
||||||
}
|
}
|
||||||
@ -58,4 +60,11 @@ class CyanFlower extends Flowable{
|
|||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getDrops(Item $item){
|
||||||
|
//TODO
|
||||||
|
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -22,11 +22,26 @@
|
|||||||
namespace pocketmine\block;
|
namespace pocketmine\block;
|
||||||
|
|
||||||
use pocketmine\item\Item;
|
use pocketmine\item\Item;
|
||||||
|
use pocketmine\item\Tool;
|
||||||
|
|
||||||
class DoubleSlab extends Solid{
|
class DoubleSlab extends Solid{
|
||||||
|
|
||||||
|
protected $id = self::DOUBLE_SLAB;
|
||||||
|
|
||||||
public function __construct($meta = 0){
|
public function __construct($meta = 0){
|
||||||
parent::__construct(self::DOUBLE_SLAB, $meta, "Double Slab");
|
$this->meta = $meta;
|
||||||
$names = [
|
}
|
||||||
|
|
||||||
|
public function getHardness(){
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getToolType(){
|
||||||
|
return Tool::TYPE_PICKAXE;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getName(){
|
||||||
|
static $names = [
|
||||||
0 => "Stone",
|
0 => "Stone",
|
||||||
1 => "Sandstone",
|
1 => "Sandstone",
|
||||||
2 => "Wooden",
|
2 => "Wooden",
|
||||||
@ -34,31 +49,13 @@ class DoubleSlab extends Solid{
|
|||||||
4 => "Brick",
|
4 => "Brick",
|
||||||
5 => "Stone Brick",
|
5 => "Stone Brick",
|
||||||
6 => "Quartz",
|
6 => "Quartz",
|
||||||
7 => "",
|
7 => "Nether Brick",
|
||||||
];
|
];
|
||||||
$this->name = "Double " . $names[$this->meta & 0x07] . " Slab";
|
return "DoubleTag " . $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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getDrops(Item $item){
|
public function getDrops(Item $item){
|
||||||
if($item->isPickaxe() >= 1){
|
if($item->isPickaxe() >= Tool::TIER_WOODEN){
|
||||||
return [
|
return [
|
||||||
[Item::SLAB, $this->meta & 0x07, 2],
|
[Item::SLAB, $this->meta & 0x07, 2],
|
||||||
];
|
];
|
||||||
|
@ -22,37 +22,36 @@
|
|||||||
namespace pocketmine\block;
|
namespace pocketmine\block;
|
||||||
|
|
||||||
use pocketmine\item\Item;
|
use pocketmine\item\Item;
|
||||||
|
use pocketmine\item\Tool;
|
||||||
|
|
||||||
class DoubleWoodSlab extends Solid{
|
class DoubleWoodSlab extends Solid{
|
||||||
|
|
||||||
|
protected $id = self::DOUBLE_WOOD_SLAB;
|
||||||
|
|
||||||
public function __construct($meta = 0){
|
public function __construct($meta = 0){
|
||||||
parent::__construct(self::DOUBLE_WOOD_SLAB, $meta, "Double Wooden Slab");
|
$this->meta = $meta;
|
||||||
$names = [
|
}
|
||||||
|
|
||||||
|
public function getHardness(){
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getToolType(){
|
||||||
|
return Tool::TYPE_AXE;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getName(){
|
||||||
|
static $names = [
|
||||||
0 => "Oak",
|
0 => "Oak",
|
||||||
1 => "Spruce",
|
1 => "Spruce",
|
||||||
2 => "Birch",
|
2 => "Birch",
|
||||||
3 => "Jungle",
|
3 => "Jungle",
|
||||||
4 => "Acacia",
|
4 => "Acacia",
|
||||||
5 => "Dark Oak",
|
5 => "Dark Oak",
|
||||||
|
6 => "",
|
||||||
|
7 => ""
|
||||||
];
|
];
|
||||||
$this->name = "Double " . $names[$this->meta & 0x07] . " Wooden Slab";
|
return "DoubleTag " . $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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getDrops(Item $item){
|
public function getDrops(Item $item){
|
||||||
|
@ -22,26 +22,30 @@
|
|||||||
namespace pocketmine\block;
|
namespace pocketmine\block;
|
||||||
|
|
||||||
use pocketmine\item\Item;
|
use pocketmine\item\Item;
|
||||||
|
use pocketmine\item\Tool;
|
||||||
|
|
||||||
class Emerald extends Solid{
|
class Emerald extends Solid{
|
||||||
|
|
||||||
|
protected $id = self::EMERALD_BLOCK;
|
||||||
|
|
||||||
public function __construct(){
|
public function __construct(){
|
||||||
parent::__construct(self::EMERALD_BLOCK, 0, "Emerald Block");
|
|
||||||
$this->hardness = 30;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getBreakTime(Item $item){
|
public function getHardness(){
|
||||||
switch($item->isPickaxe()){
|
return 5;
|
||||||
case 5:
|
}
|
||||||
return 0.95;
|
|
||||||
case 4:
|
public function getToolType(){
|
||||||
return 1.25;
|
return Tool::TYPE_PICKAXE;
|
||||||
default:
|
}
|
||||||
return 25;
|
|
||||||
}
|
public function getName(){
|
||||||
|
return "Emerald Block";
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getDrops(Item $item){
|
public function getDrops(Item $item){
|
||||||
if($item->isPickaxe() >= 4){
|
if($item->isPickaxe() >= Tool::TIER_IRON){
|
||||||
return [
|
return [
|
||||||
[Item::EMERALD_BLOCK, 0, 1],
|
[Item::EMERALD_BLOCK, 0, 1],
|
||||||
];
|
];
|
||||||
|
@ -22,26 +22,30 @@
|
|||||||
namespace pocketmine\block;
|
namespace pocketmine\block;
|
||||||
|
|
||||||
use pocketmine\item\Item;
|
use pocketmine\item\Item;
|
||||||
|
use pocketmine\item\Tool;
|
||||||
|
|
||||||
class EmeraldOre extends Solid{
|
class EmeraldOre extends Solid{
|
||||||
|
|
||||||
|
protected $id = self::EMERALD_ORE;
|
||||||
|
|
||||||
public function __construct(){
|
public function __construct(){
|
||||||
parent::__construct(self::EMERALD_ORE, 0, "Emerald Ore");
|
|
||||||
$this->hardness = 15;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getBreakTime(Item $item){
|
public function getName(){
|
||||||
switch($item->isPickaxe()){
|
return "Emerald Ore";
|
||||||
case 5:
|
}
|
||||||
return 0.6;
|
|
||||||
case 4:
|
public function getToolType(){
|
||||||
return 0.75;
|
return Tool::TYPE_PICKAXE;
|
||||||
default:
|
}
|
||||||
return 15;
|
|
||||||
}
|
public function getHardness(){
|
||||||
|
return 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getDrops(Item $item){
|
public function getDrops(Item $item){
|
||||||
if($item->isPickaxe() >= 4){
|
if($item->isPickaxe() >= Tool::TIER_IRON){
|
||||||
return [
|
return [
|
||||||
[Item::EMERALD, 0, 1],
|
[Item::EMERALD, 0, 1],
|
||||||
];
|
];
|
||||||
|
108
src/pocketmine/block/EnchantingTable.php
Normal file
108
src/pocketmine/block/EnchantingTable.php
Normal file
@ -0,0 +1,108 @@
|
|||||||
|
<?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\inventory\EnchantInventory;
|
||||||
|
use pocketmine\item\Item;
|
||||||
|
use pocketmine\item\Tool;
|
||||||
|
|
||||||
|
use pocketmine\nbt\tag\CompoundTag;
|
||||||
|
use pocketmine\nbt\tag\IntTag;
|
||||||
|
use pocketmine\nbt\tag\StringTag;
|
||||||
|
use pocketmine\Player;
|
||||||
|
use pocketmine\tile\Tile;
|
||||||
|
|
||||||
|
class EnchantingTable extends Transparent{
|
||||||
|
|
||||||
|
protected $id = self::ENCHANTING_TABLE;
|
||||||
|
|
||||||
|
public function __construct(){
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){
|
||||||
|
$this->getLevel()->setBlock($block, $this, true, true);
|
||||||
|
$nbt = new CompoundTag("", [
|
||||||
|
new StringTag("id", Tile::ENCHANT_TABLE),
|
||||||
|
new IntTag("x", $this->x),
|
||||||
|
new IntTag("y", $this->y),
|
||||||
|
new IntTag("z", $this->z)
|
||||||
|
]);
|
||||||
|
|
||||||
|
if($item->hasCustomName()){
|
||||||
|
$nbt->CustomName = new StringTag("CustomName", $item->getCustomName());
|
||||||
|
}
|
||||||
|
|
||||||
|
if($item->hasCustomBlockData()){
|
||||||
|
foreach($item->getCustomBlockData() as $key => $v){
|
||||||
|
$nbt->{$key} = $v;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Tile::createTile(Tile::ENCHANT_TABLE, $this->getLevel()->getChunk($this->x >> 4, $this->z >> 4), $nbt);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function canBeActivated(){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getHardness(){
|
||||||
|
return 5;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getResistance(){
|
||||||
|
return 6000;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getName(){
|
||||||
|
return "Enchanting Table";
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getToolType(){
|
||||||
|
return Tool::TYPE_PICKAXE;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function onActivate(Item $item, Player $player = null){
|
||||||
|
if($player instanceof Player){
|
||||||
|
//TODO lock
|
||||||
|
if($player->isCreative()){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
$player->addWindow(new EnchantInventory($this));
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getDrops(Item $item){
|
||||||
|
if($item->isPickaxe() >= Tool::TIER_WOODEN){
|
||||||
|
return [
|
||||||
|
[$this->id, 0, 1],
|
||||||
|
];
|
||||||
|
}else{
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -21,20 +21,40 @@
|
|||||||
|
|
||||||
namespace pocketmine\block;
|
namespace pocketmine\block;
|
||||||
|
|
||||||
|
use pocketmine\item\Item;
|
||||||
use pocketmine\math\AxisAlignedBB;
|
use pocketmine\math\AxisAlignedBB;
|
||||||
|
|
||||||
class EndPortal extends Solid{
|
class EndPortalFrame extends Solid{
|
||||||
|
|
||||||
|
protected $id = self::END_PORTAL_FRAME;
|
||||||
|
|
||||||
public function __construct($meta = 0){
|
public function __construct($meta = 0){
|
||||||
parent::__construct(self::END_PORTAL, $meta, "End Portal");
|
$this->meta = $meta;
|
||||||
$this->hardness = 18000000;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getBoundingBox(){
|
public function getLightLevel(){
|
||||||
if($this->boundingBox !== null){
|
return 1;
|
||||||
return $this->boundingBox;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return $this->boundingBox = new AxisAlignedBB(
|
public function getName(){
|
||||||
|
return "EndTag Portal Frame";
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getHardness(){
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getResistance(){
|
||||||
|
return 18000000;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function isBreakable(Item $item){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function recalculateBoundingBox(){
|
||||||
|
|
||||||
|
return new AxisAlignedBB(
|
||||||
$this->x,
|
$this->x,
|
||||||
$this->y,
|
$this->y,
|
||||||
$this->z,
|
$this->z,
|
@ -21,28 +21,26 @@
|
|||||||
|
|
||||||
namespace pocketmine\block;
|
namespace pocketmine\block;
|
||||||
|
|
||||||
use pocketmine\item\Item;
|
|
||||||
|
use pocketmine\item\Tool;
|
||||||
|
|
||||||
class EndStone extends Solid{
|
class EndStone extends Solid{
|
||||||
|
|
||||||
|
protected $id = self::END_STONE;
|
||||||
|
|
||||||
public function __construct(){
|
public function __construct(){
|
||||||
parent::__construct(self::END_STONE, 0, "End Stone");
|
|
||||||
$this->hardness = 45;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getBreakTime(Item $item){
|
public function getName(){
|
||||||
switch($item->isPickaxe()){
|
return "EndTag Stone";
|
||||||
case 5:
|
}
|
||||||
return 0.6;
|
|
||||||
case 4:
|
public function getToolType(){
|
||||||
return 0.75;
|
return Tool::TYPE_PICKAXE;
|
||||||
case 3:
|
}
|
||||||
return 1.15;
|
|
||||||
case 2:
|
public function getHardness(){
|
||||||
return 0.4;
|
return 3;
|
||||||
case 1:
|
|
||||||
return 2.25;
|
|
||||||
default:
|
|
||||||
return 15;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -21,20 +21,20 @@
|
|||||||
|
|
||||||
namespace pocketmine\block;
|
namespace pocketmine\block;
|
||||||
|
|
||||||
use pocketmine\entity\FallingBlock;
|
use pocketmine\entity\Entity;
|
||||||
use pocketmine\item\Item;
|
use pocketmine\item\Item;
|
||||||
use pocketmine\level\Level;
|
use pocketmine\level\Level;
|
||||||
use pocketmine\nbt\tag\Byte;
|
use pocketmine\math\Vector3;
|
||||||
use pocketmine\nbt\tag\Compound;
|
use pocketmine\nbt\tag\ByteTag;
|
||||||
use pocketmine\nbt\tag\Double;
|
use pocketmine\nbt\tag\CompoundTag;
|
||||||
use pocketmine\nbt\tag\Enum;
|
use pocketmine\nbt\tag\DoubleTag;
|
||||||
use pocketmine\nbt\tag\Float;
|
use pocketmine\nbt\tag\ListTag;
|
||||||
|
use pocketmine\nbt\tag\FloatTag;
|
||||||
|
use pocketmine\nbt\tag\IntTag;
|
||||||
use pocketmine\Player;
|
use pocketmine\Player;
|
||||||
|
|
||||||
abstract class Fallable extends Solid{
|
abstract class Fallable extends Solid{
|
||||||
|
|
||||||
public $hasPhysics = true;
|
|
||||||
|
|
||||||
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){
|
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){
|
||||||
$ret = $this->getLevel()->setBlock($this, $this, true, true);
|
$ret = $this->getLevel()->setBlock($this, $this, true, true);
|
||||||
|
|
||||||
@ -42,31 +42,30 @@ abstract class Fallable extends Solid{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function onUpdate($type){
|
public function onUpdate($type){
|
||||||
if($this->hasPhysics === true and $type === Level::BLOCK_UPDATE_NORMAL){
|
if($type === Level::BLOCK_UPDATE_NORMAL){
|
||||||
$down = $this->getSide(0);
|
$down = $this->getSide(Vector3::SIDE_DOWN);
|
||||||
if($down->getID() === self::AIR or ($down instanceof Liquid)){
|
if($down->getId() === self::AIR or ($down instanceof Liquid)){
|
||||||
$fall = new FallingBlock($this->getLevel()->getChunk($this->x >> 4, $this->z >> 4), new Compound("", [
|
$fall = Entity::createEntity("FallingSand", $this->getLevel()->getChunk($this->x >> 4, $this->z >> 4), new CompoundTag("", [
|
||||||
"Pos" => new Enum("Pos", [
|
"Pos" => new ListTag("Pos", [
|
||||||
new Double("", $this->x + 0.5),
|
new DoubleTag("", $this->x + 0.5),
|
||||||
new Double("", $this->y),
|
new DoubleTag("", $this->y),
|
||||||
new Double("", $this->z + 0.5)
|
new DoubleTag("", $this->z + 0.5)
|
||||||
]),
|
]),
|
||||||
"Motion" => new Enum("Motion", [
|
"Motion" => new ListTag("Motion", [
|
||||||
new Double("", 0),
|
new DoubleTag("", 0),
|
||||||
new Double("", 0),
|
new DoubleTag("", 0),
|
||||||
new Double("", 0)
|
new DoubleTag("", 0)
|
||||||
]),
|
]),
|
||||||
"Rotation" => new Enum("Rotation", [
|
"Rotation" => new ListTag("Rotation", [
|
||||||
new Float("", 0),
|
new FloatTag("", 0),
|
||||||
new Float("", 0)
|
new FloatTag("", 0)
|
||||||
]),
|
]),
|
||||||
"Tile" => new Byte("Tile", $this->getID())
|
"TileID" => new IntTag("TileID", $this->getId()),
|
||||||
|
"Data" => new ByteTag("Data", $this->getDamage()),
|
||||||
]));
|
]));
|
||||||
|
|
||||||
$fall->spawnToAll();
|
$fall->spawnToAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -22,20 +22,31 @@
|
|||||||
namespace pocketmine\block;
|
namespace pocketmine\block;
|
||||||
|
|
||||||
use pocketmine\item\Item;
|
use pocketmine\item\Item;
|
||||||
|
use pocketmine\item\Tool;
|
||||||
use pocketmine\math\AxisAlignedBB;
|
use pocketmine\math\AxisAlignedBB;
|
||||||
|
|
||||||
class Farmland extends Solid{
|
class Farmland extends Solid{
|
||||||
|
|
||||||
|
protected $id = self::FARMLAND;
|
||||||
|
|
||||||
public function __construct($meta = 0){
|
public function __construct($meta = 0){
|
||||||
parent::__construct(self::FARMLAND, $meta, "Farmland");
|
$this->meta = $meta;
|
||||||
$this->hardness = 3;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getBoundingBox(){
|
public function getName(){
|
||||||
if($this->boundingBox !== null){
|
return "Farmland";
|
||||||
return $this->boundingBox;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return $this->boundingBox = new AxisAlignedBB(
|
public function getHardness(){
|
||||||
|
return 0.6;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getToolType(){
|
||||||
|
return Tool::TYPE_SHOVEL;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function recalculateBoundingBox(){
|
||||||
|
return new AxisAlignedBB(
|
||||||
$this->x,
|
$this->x,
|
||||||
$this->y,
|
$this->y,
|
||||||
$this->z,
|
$this->z,
|
||||||
|
@ -21,43 +21,71 @@
|
|||||||
|
|
||||||
namespace pocketmine\block;
|
namespace pocketmine\block;
|
||||||
|
|
||||||
|
use pocketmine\item\Tool;
|
||||||
use pocketmine\math\AxisAlignedBB;
|
use pocketmine\math\AxisAlignedBB;
|
||||||
|
use pocketmine\math\Vector3;
|
||||||
|
|
||||||
class Fence extends Transparent{
|
class Fence extends Transparent{
|
||||||
public function __construct(){
|
const FENCE_OAK = 0;
|
||||||
parent::__construct(self::FENCE, 0, "Fence");
|
const FENCE_SPRUCE = 1;
|
||||||
$this->isFullBlock = false;
|
const FENCE_BIRCH = 2;
|
||||||
$this->hardness = 15;
|
const FENCE_JUNGLE = 3;
|
||||||
|
const FENCE_ACACIA = 4;
|
||||||
|
const FENCE_DARKOAK = 5;
|
||||||
|
|
||||||
|
protected $id = self::FENCE;
|
||||||
|
|
||||||
|
public function __construct($meta = 0){
|
||||||
|
$this->meta = $meta;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getBoundingBox(){
|
public function getHardness(){
|
||||||
if($this->boundingBox !== null){
|
return 2;
|
||||||
return $this->boundingBox;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
$flag = $this->canConnect($this->getSide(2));
|
public function getToolType(){
|
||||||
$flag1 = $this->canConnect($this->getSide(3));
|
return Tool::TYPE_AXE;
|
||||||
$flag2 = $this->canConnect($this->getSide(4));
|
}
|
||||||
$flag3 = $this->canConnect($this->getSide(5));
|
|
||||||
|
|
||||||
$f = $flag2 ? 0 : 0.375;
|
|
||||||
$f1 = $flag3 ? 1 : 0.625;
|
|
||||||
$f2 = $flag ? 0 : 0.375;
|
|
||||||
$f3 = $flag1 ? 1 : 0.625;
|
|
||||||
|
|
||||||
return $this->boundingBox = new AxisAlignedBB(
|
public function getName(){
|
||||||
$this->x + $f,
|
static $names = [
|
||||||
|
self::FENCE_OAK => "Oak Fence",
|
||||||
|
self::FENCE_SPRUCE => "Spruce Fence",
|
||||||
|
self::FENCE_BIRCH => "Birch Fence",
|
||||||
|
self::FENCE_JUNGLE => "Jungle Fence",
|
||||||
|
self::FENCE_ACACIA => "Acacia Fence",
|
||||||
|
self::FENCE_DARKOAK => "Dark Oak Fence",
|
||||||
|
"",
|
||||||
|
""
|
||||||
|
];
|
||||||
|
return $names[$this->meta & 0x07];
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function recalculateBoundingBox(){
|
||||||
|
|
||||||
|
$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));
|
||||||
|
|
||||||
|
$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 + $w,
|
||||||
$this->y,
|
$this->y,
|
||||||
$this->z + $f2,
|
$this->z + $n,
|
||||||
$this->x + $f1,
|
$this->x + $e,
|
||||||
$this->y + 1, //TODO: check this, add extra bounding box
|
$this->y + 1.5,
|
||||||
$this->z + $f3
|
$this->z + $s
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function canConnect(Block $block){
|
public function canConnect(Block $block){
|
||||||
return ($block->getID() !== self::FENCE and $block->getID() !== self::FENCE_GATE) ? $block->isSolid : true;
|
return ($block instanceof Fence or $block instanceof FenceGate) ? true : $block->isSolid() and !$block->isTransparent();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -22,26 +22,37 @@
|
|||||||
namespace pocketmine\block;
|
namespace pocketmine\block;
|
||||||
|
|
||||||
use pocketmine\item\Item;
|
use pocketmine\item\Item;
|
||||||
|
use pocketmine\item\Tool;
|
||||||
|
use pocketmine\level\sound\DoorSound;
|
||||||
use pocketmine\math\AxisAlignedBB;
|
use pocketmine\math\AxisAlignedBB;
|
||||||
use pocketmine\Player;
|
use pocketmine\Player;
|
||||||
|
|
||||||
class FenceGate extends Transparent{
|
class FenceGate extends Transparent{
|
||||||
|
|
||||||
|
protected $id = self::FENCE_GATE;
|
||||||
|
|
||||||
public function __construct($meta = 0){
|
public function __construct($meta = 0){
|
||||||
parent::__construct(self::FENCE_GATE, $meta, "Fence Gate");
|
$this->meta = $meta;
|
||||||
$this->isActivable = true;
|
}
|
||||||
if(($this->meta & 0x04) === 0x04){
|
|
||||||
$this->isFullBlock = true;
|
public function getName(){
|
||||||
}else{
|
return "Oak Fence Gate";
|
||||||
$this->isFullBlock = false;
|
}
|
||||||
}
|
|
||||||
$this->hardness = 15;
|
public function getHardness(){
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function canBeActivated(){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getToolType(){
|
||||||
|
return Tool::TYPE_AXE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function getBoundingBox(){
|
protected function recalculateBoundingBox(){
|
||||||
if($this->boundingBox !== null){
|
|
||||||
return $this->boundingBox;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(($this->getDamage() & 0x04) > 0){
|
if(($this->getDamage() & 0x04) > 0){
|
||||||
return null;
|
return null;
|
||||||
@ -49,21 +60,21 @@ class FenceGate extends Transparent{
|
|||||||
|
|
||||||
$i = ($this->getDamage() & 0x03);
|
$i = ($this->getDamage() & 0x03);
|
||||||
if($i === 2 and $i === 0){
|
if($i === 2 and $i === 0){
|
||||||
return $this->boundingBox = new AxisAlignedBB(
|
return new AxisAlignedBB(
|
||||||
$this->x,
|
$this->x,
|
||||||
$this->y,
|
$this->y,
|
||||||
$this->z + 0.375,
|
$this->z + 0.375,
|
||||||
$this->x + 1,
|
$this->x + 1,
|
||||||
$this->y + 1,
|
$this->y + 1.5,
|
||||||
$this->z + 0.625
|
$this->z + 0.625
|
||||||
);
|
);
|
||||||
}else{
|
}else{
|
||||||
return $this->boundingBox = new AxisAlignedBB(
|
return new AxisAlignedBB(
|
||||||
$this->x + 0.375,
|
$this->x + 0.375,
|
||||||
$this->y,
|
$this->y,
|
||||||
$this->z,
|
$this->z,
|
||||||
$this->x + 0.625,
|
$this->x + 0.625,
|
||||||
$this->y + 1,
|
$this->y + 1.5,
|
||||||
$this->z + 1
|
$this->z + 1
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -96,13 +107,8 @@ class FenceGate extends Transparent{
|
|||||||
3 => 2,
|
3 => 2,
|
||||||
];
|
];
|
||||||
$this->meta = ($faces[$player instanceof Player ? $player->getDirection() : 0] & 0x03) | ((~$this->meta) & 0x04);
|
$this->meta = ($faces[$player instanceof Player ? $player->getDirection() : 0] & 0x03) | ((~$this->meta) & 0x04);
|
||||||
if(($this->meta & 0x04) === 0x04){
|
|
||||||
$this->isFullBlock = true;
|
|
||||||
}else{
|
|
||||||
$this->isFullBlock = false;
|
|
||||||
}
|
|
||||||
$this->getLevel()->setBlock($this, $this, true);
|
$this->getLevel()->setBlock($this, $this, true);
|
||||||
|
$this->level->addSound(new DoorSound($this));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -22,10 +22,11 @@
|
|||||||
namespace pocketmine\block;
|
namespace pocketmine\block;
|
||||||
|
|
||||||
|
|
||||||
class NetherReactor extends Solid{
|
class FenceGateAcacia extends FenceGate{
|
||||||
public function __construct($meta = 0){
|
|
||||||
parent::__construct(self::NETHER_REACTOR, $meta, "Nether Reactor");
|
|
||||||
$this->isActivable = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
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,8 @@
|
|||||||
|
|
||||||
namespace pocketmine\block;
|
namespace pocketmine\block;
|
||||||
|
|
||||||
|
use pocketmine\entity\Arrow;
|
||||||
|
use pocketmine\entity\Effect;
|
||||||
use pocketmine\entity\Entity;
|
use pocketmine\entity\Entity;
|
||||||
use pocketmine\event\entity\EntityCombustByBlockEvent;
|
use pocketmine\event\entity\EntityCombustByBlockEvent;
|
||||||
use pocketmine\event\entity\EntityDamageByBlockEvent;
|
use pocketmine\event\entity\EntityDamageByBlockEvent;
|
||||||
@ -31,28 +33,42 @@ use pocketmine\Server;
|
|||||||
|
|
||||||
class Fire extends Flowable{
|
class Fire extends Flowable{
|
||||||
|
|
||||||
public $hasEntityCollision = true;
|
protected $id = self::FIRE;
|
||||||
|
|
||||||
public function __construct($meta = 0){
|
public function __construct($meta = 0){
|
||||||
parent::__construct(self::FIRE, $meta, "Fire");
|
$this->meta = $meta;
|
||||||
$this->isReplaceable = true;
|
|
||||||
$this->breakable = false;
|
|
||||||
$this->isFullBlock = true;
|
|
||||||
$this->hardness = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getBoundingBox(){
|
public function hasEntityCollision(){
|
||||||
return null;
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getName(){
|
||||||
|
return "Fire Block";
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getLightLevel(){
|
||||||
|
return 15;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function isBreakable(Item $item){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function canBeReplaced(){
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onEntityCollide(Entity $entity){
|
public function onEntityCollide(Entity $entity){
|
||||||
$ev = new EntityDamageByBlockEvent($this, $entity, EntityDamageEvent::CAUSE_FIRE, 1);
|
if(!$entity->hasEffect(Effect::FIRE_RESISTANCE)){
|
||||||
Server::getInstance()->getPluginManager()->callEvent($ev);
|
$ev = new EntityDamageByBlockEvent($this, $entity, EntityDamageEvent::CAUSE_FIRE, 1);
|
||||||
if(!$ev->isCancelled()){
|
|
||||||
$entity->attack($ev->getFinalDamage(), $ev);
|
$entity->attack($ev->getFinalDamage(), $ev);
|
||||||
}
|
}
|
||||||
|
|
||||||
$ev = new EntityCombustByBlockEvent($this, $entity, 8);
|
$ev = new EntityCombustByBlockEvent($this, $entity, 8);
|
||||||
|
if($entity instanceof Arrow){
|
||||||
|
$ev->setCancelled();
|
||||||
|
}
|
||||||
Server::getInstance()->getPluginManager()->callEvent($ev);
|
Server::getInstance()->getPluginManager()->callEvent($ev);
|
||||||
if(!$ev->isCancelled()){
|
if(!$ev->isCancelled()){
|
||||||
$entity->setOnFire($ev->getDuration());
|
$entity->setOnFire($ev->getDuration());
|
||||||
@ -67,7 +83,7 @@ class Fire extends Flowable{
|
|||||||
if($type === Level::BLOCK_UPDATE_NORMAL){
|
if($type === Level::BLOCK_UPDATE_NORMAL){
|
||||||
for($s = 0; $s <= 5; ++$s){
|
for($s = 0; $s <= 5; ++$s){
|
||||||
$side = $this->getSide($s);
|
$side = $this->getSide($s);
|
||||||
if($side->getID() !== self::AIR and !($side instanceof Liquid)){
|
if($side->getId() !== self::AIR and !($side instanceof Liquid)){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -75,10 +91,17 @@ class Fire extends Flowable{
|
|||||||
|
|
||||||
return Level::BLOCK_UPDATE_NORMAL;
|
return Level::BLOCK_UPDATE_NORMAL;
|
||||||
}elseif($type === Level::BLOCK_UPDATE_RANDOM){
|
}elseif($type === Level::BLOCK_UPDATE_RANDOM){
|
||||||
if($this->getSide(0)->getID() !== self::NETHERRACK){
|
if($this->getSide(0)->getId() !== self::NETHERRACK){
|
||||||
$this->getLevel()->setBlock($this, new Air(), true);
|
if(mt_rand(0, 2) === 0){
|
||||||
|
if($this->meta === 0x0F){
|
||||||
|
$this->level->setBlock($this, new Air());
|
||||||
|
}else{
|
||||||
|
$this->meta++;
|
||||||
|
$this->level->setBlock($this, $this);
|
||||||
|
}
|
||||||
|
|
||||||
return Level::BLOCK_UPDATE_NORMAL;
|
return Level::BLOCK_UPDATE_NORMAL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,10 +22,27 @@
|
|||||||
namespace pocketmine\block;
|
namespace pocketmine\block;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
abstract class Flowable extends Transparent{
|
abstract class Flowable extends Transparent{
|
||||||
|
|
||||||
public $isFlowable = true;
|
public function canBeFlowedInto(){
|
||||||
public $isFullBlock = false;
|
return true;
|
||||||
public $isSolid = false;
|
}
|
||||||
|
|
||||||
|
public function 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;
|
||||||
|
}
|
||||||
|
}
|
38
src/pocketmine/block/FlowerPot.php
Normal file
38
src/pocketmine/block/FlowerPot.php
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
<?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;
|
||||||
|
|
||||||
|
class FlowerPot extends Transparent{
|
||||||
|
|
||||||
|
protected $id = self::FLOWER_POT_BLOCK;
|
||||||
|
|
||||||
|
public function __construct($meta = 0){
|
||||||
|
$this->meta = $meta;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getName(){
|
||||||
|
return "Flower Pot Block";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -23,10 +23,10 @@ namespace pocketmine\block;
|
|||||||
|
|
||||||
|
|
||||||
class Furnace extends BurningFurnace{
|
class Furnace extends BurningFurnace{
|
||||||
public function __construct($meta = 0){
|
|
||||||
parent::__construct($meta);
|
protected $id = self::FURNACE;
|
||||||
$this->id = self::FURNACE;
|
|
||||||
$this->name = "Furnace";
|
public function getName(){
|
||||||
$this->isActivable = true;
|
return "Furnace";
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -24,9 +24,19 @@ namespace pocketmine\block;
|
|||||||
use pocketmine\item\Item;
|
use pocketmine\item\Item;
|
||||||
|
|
||||||
class Glass extends Transparent{
|
class Glass extends Transparent{
|
||||||
|
|
||||||
|
protected $id = self::GLASS;
|
||||||
|
|
||||||
public function __construct(){
|
public function __construct(){
|
||||||
parent::__construct(self::GLASS, 0, "Glass");
|
|
||||||
$this->hardness = 1.5;
|
}
|
||||||
|
|
||||||
|
public function getName(){
|
||||||
|
return "Glass";
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getHardness(){
|
||||||
|
return 0.3;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getDrops(Item $item){
|
public function getDrops(Item $item){
|
||||||
|
@ -22,9 +22,25 @@
|
|||||||
namespace pocketmine\block;
|
namespace pocketmine\block;
|
||||||
|
|
||||||
|
|
||||||
|
use pocketmine\item\Item;
|
||||||
|
|
||||||
class GlassPane extends Thin{
|
class GlassPane extends Thin{
|
||||||
|
|
||||||
|
protected $id = self::GLASS_PANE;
|
||||||
|
|
||||||
public function __construct(){
|
public function __construct(){
|
||||||
parent::__construct(self::GLASS_PANE, 0, "Glass Pane");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getName(){
|
||||||
|
return "Glass Pane";
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getHardness(){
|
||||||
|
return 0.3;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getDrops(Item $item){
|
||||||
|
return [];
|
||||||
|
}
|
||||||
}
|
}
|
@ -23,8 +23,19 @@ namespace pocketmine\block;
|
|||||||
|
|
||||||
|
|
||||||
class GlowingObsidian extends Solid{
|
class GlowingObsidian extends Solid{
|
||||||
|
|
||||||
|
protected $id = self::GLOWING_OBSIDIAN;
|
||||||
|
|
||||||
public function __construct($meta = 0){
|
public function __construct($meta = 0){
|
||||||
parent::__construct(self::GLOWING_OBSIDIAN, $meta, "Glowing Obsidian");
|
$this->meta = $meta;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getName(){
|
||||||
|
return "Glowing Obsidian";
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getLightLevel(){
|
||||||
|
return 12;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -24,42 +24,25 @@ namespace pocketmine\block;
|
|||||||
use pocketmine\item\Item;
|
use pocketmine\item\Item;
|
||||||
use pocketmine\level\Level;
|
use pocketmine\level\Level;
|
||||||
|
|
||||||
class GlowingRedstoneOre extends Solid{
|
class GlowingRedstoneOre extends RedstoneOre{
|
||||||
public function __construct(){
|
|
||||||
parent::__construct(self::GLOWING_REDSTONE_ORE, 0, "Glowing Redstone Ore");
|
protected $id = self::GLOWING_REDSTONE_ORE;
|
||||||
$this->hardness = 15;
|
|
||||||
|
public function getName(){
|
||||||
|
return "Glowing Redstone Ore";
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getLightLevel(){
|
||||||
|
return 9;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onUpdate($type){
|
public function onUpdate($type){
|
||||||
if($type === Level::BLOCK_UPDATE_SCHEDULED or $type === Level::BLOCK_UPDATE_RANDOM){
|
if($type === Level::BLOCK_UPDATE_SCHEDULED or $type === Level::BLOCK_UPDATE_RANDOM){
|
||||||
$this->getLevel()->setBlock($this, Block::get(Item::REDSTONE_ORE, $this->meta), false, false, true);
|
$this->getLevel()->setBlock($this, Block::get(Item::REDSTONE_ORE, $this->meta), false, false);
|
||||||
|
|
||||||
return Level::BLOCK_UPDATE_WEAK;
|
return Level::BLOCK_UPDATE_WEAK;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
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 [
|
|
||||||
[Item::REDSTONE_DUST, 0, mt_rand(4, 5)],
|
|
||||||
];
|
|
||||||
}else{
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
@ -22,11 +22,30 @@
|
|||||||
namespace pocketmine\block;
|
namespace pocketmine\block;
|
||||||
|
|
||||||
use pocketmine\item\Item;
|
use pocketmine\item\Item;
|
||||||
|
use pocketmine\item\Tool;
|
||||||
|
|
||||||
class Glowstone extends Transparent{
|
class Glowstone extends Transparent{
|
||||||
|
|
||||||
|
protected $id = self::GLOWSTONE_BLOCK;
|
||||||
|
|
||||||
public function __construct(){
|
public function __construct(){
|
||||||
parent::__construct(self::GLOWSTONE_BLOCK, 0, "Glowstone");
|
|
||||||
$this->hardness = 1.5;
|
}
|
||||||
|
|
||||||
|
public function getName(){
|
||||||
|
return "Glowstone";
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getHardness(){
|
||||||
|
return 0.3;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getToolType(){
|
||||||
|
return Tool::TYPE_PICKAXE;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getLightLevel(){
|
||||||
|
return 15;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getDrops(Item $item){
|
public function getDrops(Item $item){
|
||||||
|
@ -22,26 +22,30 @@
|
|||||||
namespace pocketmine\block;
|
namespace pocketmine\block;
|
||||||
|
|
||||||
use pocketmine\item\Item;
|
use pocketmine\item\Item;
|
||||||
|
use pocketmine\item\Tool;
|
||||||
|
|
||||||
class Gold extends Solid{
|
class Gold extends Solid{
|
||||||
|
|
||||||
|
protected $id = self::GOLD_BLOCK;
|
||||||
|
|
||||||
public function __construct(){
|
public function __construct(){
|
||||||
parent::__construct(self::GOLD_BLOCK, 0, "Gold Block");
|
|
||||||
$this->hardness = 30;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getBreakTime(Item $item){
|
public function getName(){
|
||||||
switch($item->isPickaxe()){
|
return "Gold Block";
|
||||||
case 5:
|
}
|
||||||
return 0.6;
|
|
||||||
case 4:
|
public function getHardness(){
|
||||||
return 0.75;
|
return 3;
|
||||||
default:
|
}
|
||||||
return 15;
|
|
||||||
}
|
public function getToolType(){
|
||||||
|
return Tool::TYPE_PICKAXE;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getDrops(Item $item){
|
public function getDrops(Item $item){
|
||||||
if($item->isPickaxe() >= 4){
|
if($item->isPickaxe() >= Tool::TIER_IRON){
|
||||||
return [
|
return [
|
||||||
[Item::GOLD_BLOCK, 0, 1],
|
[Item::GOLD_BLOCK, 0, 1],
|
||||||
];
|
];
|
||||||
|
@ -22,26 +22,30 @@
|
|||||||
namespace pocketmine\block;
|
namespace pocketmine\block;
|
||||||
|
|
||||||
use pocketmine\item\Item;
|
use pocketmine\item\Item;
|
||||||
|
use pocketmine\item\Tool;
|
||||||
|
|
||||||
class GoldOre extends Solid{
|
class GoldOre extends Solid{
|
||||||
|
|
||||||
|
protected $id = self::GOLD_ORE;
|
||||||
|
|
||||||
public function __construct(){
|
public function __construct(){
|
||||||
parent::__construct(self::GOLD_ORE, 0, "Gold Ore");
|
|
||||||
$this->hardness = 15;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getBreakTime(Item $item){
|
public function getName(){
|
||||||
switch($item->isPickaxe()){
|
return "Gold Ore";
|
||||||
case 5:
|
}
|
||||||
return 0.6;
|
|
||||||
case 4:
|
public function getHardness(){
|
||||||
return 0.75;
|
return 3;
|
||||||
default:
|
}
|
||||||
return 15;
|
|
||||||
}
|
public function getToolType(){
|
||||||
|
return Tool::TYPE_PICKAXE;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getDrops(Item $item){
|
public function getDrops(Item $item){
|
||||||
if($item->isPickaxe() >= 4){
|
if($item->isPickaxe() >= Tool::TIER_IRON){
|
||||||
return [
|
return [
|
||||||
[Item::GOLD_ORE, 0, 1],
|
[Item::GOLD_ORE, 0, 1],
|
||||||
];
|
];
|
||||||
|
@ -23,25 +23,38 @@ namespace pocketmine\block;
|
|||||||
|
|
||||||
use pocketmine\event\block\BlockSpreadEvent;
|
use pocketmine\event\block\BlockSpreadEvent;
|
||||||
use pocketmine\item\Item;
|
use pocketmine\item\Item;
|
||||||
|
use pocketmine\item\Tool;
|
||||||
use pocketmine\level\generator\object\TallGrass as TallGrassObject;
|
use pocketmine\level\generator\object\TallGrass as TallGrassObject;
|
||||||
use pocketmine\level\Level;
|
use pocketmine\level\Level;
|
||||||
use pocketmine\level\Position;
|
use pocketmine\math\Vector3;
|
||||||
use pocketmine\Player;
|
use pocketmine\Player;
|
||||||
use pocketmine\Server;
|
use pocketmine\Server;
|
||||||
use pocketmine\utils\Random;
|
use pocketmine\utils\Random;
|
||||||
|
|
||||||
class Grass extends Solid{
|
class Grass extends Solid{
|
||||||
|
|
||||||
public $isActivable = true;
|
|
||||||
protected $hardness = 3;
|
|
||||||
protected $id = self::GRASS;
|
protected $id = self::GRASS;
|
||||||
protected $meta = 0;
|
|
||||||
protected $name = "Grass";
|
|
||||||
|
|
||||||
public function __construct(){
|
public function __construct(){
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function canBeActivated(){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getName(){
|
||||||
|
return "Grass";
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getHardness(){
|
||||||
|
return 0.6;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getToolType(){
|
||||||
|
return Tool::TYPE_SHOVEL;
|
||||||
|
}
|
||||||
|
|
||||||
public function getDrops(Item $item){
|
public function getDrops(Item $item){
|
||||||
return [
|
return [
|
||||||
[Item::DIRT, 0, 1],
|
[Item::DIRT, 0, 1],
|
||||||
@ -50,17 +63,20 @@ class Grass extends Solid{
|
|||||||
|
|
||||||
public function onUpdate($type){
|
public function onUpdate($type){
|
||||||
if($type === Level::BLOCK_UPDATE_RANDOM){
|
if($type === Level::BLOCK_UPDATE_RANDOM){
|
||||||
//TODO: light levels
|
$block = $this->getLevel()->getBlock(new Vector3($this->x, $this->y, $this->z));
|
||||||
$x = mt_rand($this->x - 1, $this->x + 1);
|
if($block->getSide(1)->getLightLevel() < 4){
|
||||||
$y = mt_rand($this->y - 2, $this->y + 2);
|
Server::getInstance()->getPluginManager()->callEvent($ev = new BlockSpreadEvent($block, $this, new Dirt()));
|
||||||
$z = mt_rand($this->z - 1, $this->z + 1);
|
}elseif($block->getSide(1)->getLightLevel() >= 9){
|
||||||
$block = $this->getLevel()->getBlockIdAt($x, $y, $z);
|
for($l = 0; $l < 4; ++$l){
|
||||||
if($block === Block::DIRT){
|
$x = mt_rand($this->x - 1, $this->x + 1);
|
||||||
$block = Block::get($block, $this->getLevel()->getBlockDataAt($x, $y, $z), new Position($x, $y, $z, $this->getLevel()));
|
$y = mt_rand($this->y - 2, $this->y + 2);
|
||||||
if($block->getSide(1) instanceof Transparent){
|
$z = mt_rand($this->z - 1, $this->z + 1);
|
||||||
Server::getInstance()->getPluginManager()->callEvent($ev = new BlockSpreadEvent($block, $this, new Grass()));
|
$block = $this->getLevel()->getBlock(new Vector3($x, $y, $z));
|
||||||
if(!$ev->isCancelled()){
|
if($block->getId() === Block::DIRT && $block->getDamage() === 0x0F && $block->getSide(1)->getLightLevel() >= 4 && $block->z <= 2){
|
||||||
$this->getLevel()->setBlock($block, $ev->getNewState());
|
Server::getInstance()->getPluginManager()->callEvent($ev = new BlockSpreadEvent($block, $this, new Grass()));
|
||||||
|
if(!$ev->isCancelled()){
|
||||||
|
$this->getLevel()->setBlock($block, $ev->getNewState());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -68,7 +84,7 @@ class Grass extends Solid{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function onActivate(Item $item, Player $player = null){
|
public function onActivate(Item $item, Player $player = null){
|
||||||
if($item->getID() === Item::DYE and $item->getDamage() === 0x0F){
|
if($item->getId() === Item::DYE and $item->getDamage() === 0x0F){
|
||||||
$item->count--;
|
$item->count--;
|
||||||
TallGrassObject::growGrass($this->getLevel(), $this, new Random(mt_rand()), 8, 2);
|
TallGrassObject::growGrass($this->getLevel(), $this, new Random(mt_rand()), 8, 2);
|
||||||
|
|
||||||
@ -77,6 +93,11 @@ class Grass extends Solid{
|
|||||||
$item->useOn($this);
|
$item->useOn($this);
|
||||||
$this->getLevel()->setBlock($this, new Farmland());
|
$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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
68
src/pocketmine/block/GrassPath.php
Normal file
68
src/pocketmine/block/GrassPath.php
Normal file
@ -0,0 +1,68 @@
|
|||||||
|
<?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\item\Tool;
|
||||||
|
|
||||||
|
|
||||||
|
use pocketmine\math\AxisAlignedBB;
|
||||||
|
|
||||||
|
|
||||||
|
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;
|
namespace pocketmine\block;
|
||||||
|
|
||||||
use pocketmine\item\Item;
|
use pocketmine\item\Item;
|
||||||
|
use pocketmine\item\Tool;
|
||||||
|
|
||||||
class Gravel extends Fallable{
|
class Gravel extends Fallable{
|
||||||
|
|
||||||
|
protected $id = self::GRAVEL;
|
||||||
|
|
||||||
public function __construct(){
|
public function __construct(){
|
||||||
parent::__construct(self::GRAVEL, 0, "Gravel");
|
|
||||||
$this->hardness = 3;
|
}
|
||||||
|
|
||||||
|
public function getName(){
|
||||||
|
return "Gravel";
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getHardness(){
|
||||||
|
return 0.6;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getToolType(){
|
||||||
|
return Tool::TYPE_SHOVEL;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getDrops(Item $item){
|
public function getDrops(Item $item){
|
||||||
|
@ -21,29 +21,26 @@
|
|||||||
|
|
||||||
namespace pocketmine\block;
|
namespace pocketmine\block;
|
||||||
|
|
||||||
use pocketmine\item\Item;
|
|
||||||
|
use pocketmine\item\Tool;
|
||||||
|
|
||||||
class HardenedClay extends Solid{
|
class HardenedClay extends Solid{
|
||||||
|
|
||||||
|
protected $id = self::HARDENED_CLAY;
|
||||||
|
|
||||||
public function __construct(){
|
public function __construct(){
|
||||||
parent::__construct(self::HARDENED_CLAY, 0, "Hardened Clay");
|
|
||||||
$this->hardness = 30;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getBreakTime(Item $item){
|
public function getName(){
|
||||||
switch($item->isPickaxe()){
|
return "Hardened Clay";
|
||||||
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 getToolType(){
|
||||||
|
return Tool::TYPE_PICKAXE;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getHardness(){
|
||||||
|
return 1.25;
|
||||||
|
}
|
||||||
}
|
}
|
@ -25,9 +25,19 @@ use pocketmine\item\Item;
|
|||||||
use pocketmine\Player;
|
use pocketmine\Player;
|
||||||
|
|
||||||
class HayBale extends Solid{
|
class HayBale extends Solid{
|
||||||
|
|
||||||
|
protected $id = self::HAY_BALE;
|
||||||
|
|
||||||
public function __construct($meta = 0){
|
public function __construct($meta = 0){
|
||||||
parent::__construct(self::HAY_BALE, $meta, "Hay Bale");
|
$this->meta = $meta;
|
||||||
$this->hardness = 10;
|
}
|
||||||
|
|
||||||
|
public function getName(){
|
||||||
|
return "Hay Bale";
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getHardness(){
|
||||||
|
return 0.5;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){
|
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){
|
||||||
|
@ -22,11 +22,26 @@
|
|||||||
namespace pocketmine\block;
|
namespace pocketmine\block;
|
||||||
|
|
||||||
use pocketmine\item\Item;
|
use pocketmine\item\Item;
|
||||||
|
use pocketmine\item\Tool;
|
||||||
|
|
||||||
class Ice extends Transparent{
|
class Ice extends Transparent{
|
||||||
|
|
||||||
|
protected $id = self::ICE;
|
||||||
|
|
||||||
public function __construct(){
|
public function __construct(){
|
||||||
parent::__construct(self::ICE, 0, "Ice");
|
|
||||||
$this->hardness = 2.5;
|
}
|
||||||
|
|
||||||
|
public function getName(){
|
||||||
|
return "Ice";
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getHardness(){
|
||||||
|
return 0.5;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getToolType(){
|
||||||
|
return Tool::TYPE_PICKAXE;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onBreak(Item $item){
|
public function onBreak(Item $item){
|
||||||
@ -35,23 +50,6 @@ class Ice extends Transparent{
|
|||||||
return true;
|
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){
|
public function getDrops(Item $item){
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
@ -22,28 +22,30 @@
|
|||||||
namespace pocketmine\block;
|
namespace pocketmine\block;
|
||||||
|
|
||||||
use pocketmine\item\Item;
|
use pocketmine\item\Item;
|
||||||
|
use pocketmine\item\Tool;
|
||||||
|
|
||||||
class Iron extends Solid{
|
class Iron extends Solid{
|
||||||
|
|
||||||
|
protected $id = self::IRON_BLOCK;
|
||||||
|
|
||||||
public function __construct(){
|
public function __construct(){
|
||||||
parent::__construct(self::IRON_BLOCK, 0, "Iron Block");
|
|
||||||
$this->hardness = 30;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getBreakTime(Item $item){
|
public function getName(){
|
||||||
switch($item->isPickaxe()){
|
return "Iron Block";
|
||||||
case 5:
|
}
|
||||||
return 0.95;
|
|
||||||
case 4:
|
public function getToolType(){
|
||||||
return 1.25;
|
return Tool::TYPE_PICKAXE;
|
||||||
case 3:
|
}
|
||||||
return 1.9;
|
|
||||||
default:
|
public function getHardness(){
|
||||||
return 25;
|
return 5;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getDrops(Item $item){
|
public function getDrops(Item $item){
|
||||||
if($item->isPickaxe() >= 3){
|
if($item->isPickaxe() >= Tool::TIER_STONE){
|
||||||
return [
|
return [
|
||||||
[Item::IRON_BLOCK, 0, 1],
|
[Item::IRON_BLOCK, 0, 1],
|
||||||
];
|
];
|
||||||
|
@ -21,10 +21,38 @@
|
|||||||
|
|
||||||
namespace pocketmine\block;
|
namespace pocketmine\block;
|
||||||
|
|
||||||
|
use pocketmine\item\Item;
|
||||||
|
use pocketmine\item\Tool;
|
||||||
|
|
||||||
class IronBars extends Thin{
|
class IronBars extends Thin{
|
||||||
|
|
||||||
|
protected $id = self::IRON_BARS;
|
||||||
|
|
||||||
public function __construct(){
|
public function __construct(){
|
||||||
parent::__construct(self::IRON_BARS, 0, "Iron Bars");
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getName(){
|
||||||
|
return "Iron Bars";
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getHardness(){
|
||||||
|
return 5;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getToolType(){
|
||||||
|
return Tool::TYPE_PICKAXE;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getDrops(Item $item){
|
||||||
|
if($item->isPickaxe() >= Tool::TIER_WOODEN){
|
||||||
|
return [
|
||||||
|
[Item::IRON_BARS, 0, 1],
|
||||||
|
];
|
||||||
|
}else{
|
||||||
|
return [];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,33 +22,30 @@
|
|||||||
namespace pocketmine\block;
|
namespace pocketmine\block;
|
||||||
|
|
||||||
use pocketmine\item\Item;
|
use pocketmine\item\Item;
|
||||||
|
use pocketmine\item\Tool;
|
||||||
|
|
||||||
class IronDoor extends Door{
|
class IronDoor extends Door{
|
||||||
|
|
||||||
|
protected $id = self::IRON_DOOR_BLOCK;
|
||||||
|
|
||||||
public function __construct($meta = 0){
|
public function __construct($meta = 0){
|
||||||
parent::__construct(self::IRON_DOOR_BLOCK, $meta, "Iron Door Block");
|
$this->meta = $meta;
|
||||||
//$this->isActivable = true;
|
|
||||||
$this->hardness = 25;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getBreakTime(Item $item){
|
public function getName(){
|
||||||
switch($item->isPickaxe()){
|
return "Iron Door Block";
|
||||||
case 5:
|
}
|
||||||
return 0.95;
|
|
||||||
case 4:
|
public function getToolType(){
|
||||||
return 1.25;
|
return Tool::TYPE_PICKAXE;
|
||||||
case 3:
|
}
|
||||||
return 1.9;
|
|
||||||
case 2:
|
public function getHardness(){
|
||||||
return 0.65;
|
return 5;
|
||||||
case 1:
|
|
||||||
return 3.75;
|
|
||||||
default:
|
|
||||||
return 25;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getDrops(Item $item){
|
public function getDrops(Item $item){
|
||||||
if($item->isPickaxe() >= 1){
|
if($item->isPickaxe() >= Tool::TIER_WOODEN){
|
||||||
return [
|
return [
|
||||||
[Item::IRON_DOOR, 0, 1],
|
[Item::IRON_DOOR, 0, 1],
|
||||||
];
|
];
|
||||||
|
@ -22,28 +22,30 @@
|
|||||||
namespace pocketmine\block;
|
namespace pocketmine\block;
|
||||||
|
|
||||||
use pocketmine\item\Item;
|
use pocketmine\item\Item;
|
||||||
|
use pocketmine\item\Tool;
|
||||||
|
|
||||||
class IronOre extends Solid{
|
class IronOre extends Solid{
|
||||||
|
|
||||||
|
protected $id = self::IRON_ORE;
|
||||||
|
|
||||||
public function __construct(){
|
public function __construct(){
|
||||||
parent::__construct(self::IRON_ORE, 0, "Iron Ore");
|
|
||||||
$this->hardness = 15;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getBreakTime(Item $item){
|
public function getName(){
|
||||||
switch($item->isPickaxe()){
|
return "Iron Ore";
|
||||||
case 5:
|
}
|
||||||
return 0.6;
|
|
||||||
case 4:
|
public function getToolType(){
|
||||||
return 0.75;
|
return Tool::TYPE_PICKAXE;
|
||||||
case 3:
|
}
|
||||||
return 1.15;
|
|
||||||
default:
|
public function getHardness(){
|
||||||
return 15;
|
return 3;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getDrops(Item $item){
|
public function getDrops(Item $item){
|
||||||
if($item->isPickaxe() >= 3){
|
if($item->isPickaxe() >= Tool::TIER_STONE){
|
||||||
return [
|
return [
|
||||||
[Item::IRON_ORE, 0, 1],
|
[Item::IRON_ORE, 0, 1],
|
||||||
];
|
];
|
||||||
|
41
src/pocketmine/block/IronTrapdoor.php
Normal file
41
src/pocketmine/block/IronTrapdoor.php
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
<?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\Tool;
|
||||||
|
|
||||||
|
class IronTrapdoor extends Trapdoor{
|
||||||
|
|
||||||
|
protected $id = self::IRON_TRAPDOOR;
|
||||||
|
|
||||||
|
public function getName(){
|
||||||
|
return "Iron Trapdoor";
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getHardness(){
|
||||||
|
return 5;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getToolType(){
|
||||||
|
return Tool::TYPE_PICKAXE;
|
||||||
|
}
|
||||||
|
}
|
@ -22,10 +22,22 @@
|
|||||||
namespace pocketmine\block;
|
namespace pocketmine\block;
|
||||||
|
|
||||||
use pocketmine\item\Item;
|
use pocketmine\item\Item;
|
||||||
|
use pocketmine\item\Tool;
|
||||||
|
|
||||||
class JungleWoodStairs extends Stair{
|
class JungleWoodStairs extends Stair{
|
||||||
|
|
||||||
|
protected $id = self::JUNGLE_WOOD_STAIRS;
|
||||||
|
|
||||||
public function __construct($meta = 0){
|
public function __construct($meta = 0){
|
||||||
parent::__construct(self::JUNGLE_WOOD_STAIRS, $meta, "Jungle Wood Stairs");
|
$this->meta = $meta;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getName(){
|
||||||
|
return "Jungle Wood Stairs";
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getToolType(){
|
||||||
|
return Tool::TYPE_AXE;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getDrops(Item $item){
|
public function getDrops(Item $item){
|
||||||
|
@ -23,35 +23,46 @@ namespace pocketmine\block;
|
|||||||
|
|
||||||
use pocketmine\entity\Entity;
|
use pocketmine\entity\Entity;
|
||||||
use pocketmine\item\Item;
|
use pocketmine\item\Item;
|
||||||
|
use pocketmine\item\Tool;
|
||||||
use pocketmine\level\Level;
|
use pocketmine\level\Level;
|
||||||
use pocketmine\math\AxisAlignedBB;
|
use pocketmine\math\AxisAlignedBB;
|
||||||
use pocketmine\Player;
|
use pocketmine\Player;
|
||||||
|
|
||||||
class Ladder extends Transparent{
|
class Ladder extends Transparent{
|
||||||
|
|
||||||
public $hasEntityCollision = true;
|
protected $id = self::LADDER;
|
||||||
|
|
||||||
public function __construct($meta = 0){
|
public function __construct($meta = 0){
|
||||||
parent::__construct(self::LADDER, $meta, "Ladder");
|
$this->meta = $meta;
|
||||||
$this->isSolid = false;
|
}
|
||||||
$this->isFullBlock = false;
|
|
||||||
$this->hardness = 2;
|
public function getName(){
|
||||||
|
return "Ladder";
|
||||||
|
}
|
||||||
|
|
||||||
|
public function hasEntityCollision(){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function isSolid(){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getHardness(){
|
||||||
|
return 0.4;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onEntityCollide(Entity $entity){
|
public function onEntityCollide(Entity $entity){
|
||||||
$entity->fallDistance = 0;
|
$entity->resetFallDistance();
|
||||||
$entity->onGround = true;
|
$entity->onGround = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getBoundingBox(){
|
protected function recalculateBoundingBox(){
|
||||||
if($this->boundingBox !== null){
|
|
||||||
return $this->boundingBox;
|
|
||||||
}
|
|
||||||
|
|
||||||
$f = 0.125;
|
$f = 0.125;
|
||||||
|
|
||||||
if($this->meta === 2){
|
if($this->meta === 2){
|
||||||
return $this->boundingBox = new AxisAlignedBB(
|
return new AxisAlignedBB(
|
||||||
$this->x,
|
$this->x,
|
||||||
$this->y,
|
$this->y,
|
||||||
$this->z + 1 - $f,
|
$this->z + 1 - $f,
|
||||||
@ -60,7 +71,7 @@ class Ladder extends Transparent{
|
|||||||
$this->z + 1
|
$this->z + 1
|
||||||
);
|
);
|
||||||
}elseif($this->meta === 3){
|
}elseif($this->meta === 3){
|
||||||
return $this->boundingBox = new AxisAlignedBB(
|
return new AxisAlignedBB(
|
||||||
$this->x,
|
$this->x,
|
||||||
$this->y,
|
$this->y,
|
||||||
$this->z,
|
$this->z,
|
||||||
@ -69,7 +80,7 @@ class Ladder extends Transparent{
|
|||||||
$this->z + $f
|
$this->z + $f
|
||||||
);
|
);
|
||||||
}elseif($this->meta === 4){
|
}elseif($this->meta === 4){
|
||||||
return $this->boundingBox = new AxisAlignedBB(
|
return new AxisAlignedBB(
|
||||||
$this->x + 1 - $f,
|
$this->x + 1 - $f,
|
||||||
$this->y,
|
$this->y,
|
||||||
$this->z,
|
$this->z,
|
||||||
@ -78,7 +89,7 @@ class Ladder extends Transparent{
|
|||||||
$this->z + 1
|
$this->z + 1
|
||||||
);
|
);
|
||||||
}elseif($this->meta === 5){
|
}elseif($this->meta === 5){
|
||||||
return $this->boundingBox = new AxisAlignedBB(
|
return new AxisAlignedBB(
|
||||||
$this->x,
|
$this->x,
|
||||||
$this->y,
|
$this->y,
|
||||||
$this->z,
|
$this->z,
|
||||||
@ -93,7 +104,7 @@ class Ladder extends Transparent{
|
|||||||
|
|
||||||
|
|
||||||
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){
|
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){
|
||||||
if($target->isTransparent === false){
|
if($target->isTransparent() === false){
|
||||||
$faces = [
|
$faces = [
|
||||||
2 => 2,
|
2 => 2,
|
||||||
3 => 3,
|
3 => 3,
|
||||||
@ -113,7 +124,7 @@ class Ladder extends Transparent{
|
|||||||
|
|
||||||
public function onUpdate($type){
|
public function onUpdate($type){
|
||||||
if($type === Level::BLOCK_UPDATE_NORMAL){
|
if($type === Level::BLOCK_UPDATE_NORMAL){
|
||||||
/*if($this->getSide(0)->getID() === self::AIR){ //Replace with common break method
|
/*if($this->getSide(0)->getId() === self::AIR){ //Replace with common break method
|
||||||
Server::getInstance()->api->entity->drop($this, Item::get(LADDER, 0, 1));
|
Server::getInstance()->api->entity->drop($this, Item::get(LADDER, 0, 1));
|
||||||
$this->getLevel()->setBlock($this, new Air(), true, true, true);
|
$this->getLevel()->setBlock($this, new Air(), true, true, true);
|
||||||
return Level::BLOCK_UPDATE_NORMAL;
|
return Level::BLOCK_UPDATE_NORMAL;
|
||||||
@ -123,6 +134,10 @@ class Ladder extends Transparent{
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getToolType(){
|
||||||
|
return Tool::TYPE_AXE;
|
||||||
|
}
|
||||||
|
|
||||||
public function getDrops(Item $item){
|
public function getDrops(Item $item){
|
||||||
return [
|
return [
|
||||||
[$this->id, 0, 1],
|
[$this->id, 0, 1],
|
||||||
|
@ -22,28 +22,30 @@
|
|||||||
namespace pocketmine\block;
|
namespace pocketmine\block;
|
||||||
|
|
||||||
use pocketmine\item\Item;
|
use pocketmine\item\Item;
|
||||||
|
use pocketmine\item\Tool;
|
||||||
|
|
||||||
class Lapis extends Solid{
|
class Lapis extends Solid{
|
||||||
|
|
||||||
|
protected $id = self::LAPIS_BLOCK;
|
||||||
|
|
||||||
public function __construct(){
|
public function __construct(){
|
||||||
parent::__construct(self::LAPIS_BLOCK, 0, "Lapis Block");
|
|
||||||
$this->hardness = 15;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getBreakTime(Item $item){
|
public function getName(){
|
||||||
switch($item->isPickaxe()){
|
return "Lapis Lazuli Block";
|
||||||
case 5:
|
}
|
||||||
return 0.6;
|
|
||||||
case 4:
|
public function getToolType(){
|
||||||
return 0.75;
|
return Tool::TYPE_PICKAXE;
|
||||||
case 3:
|
}
|
||||||
return 1.15;
|
|
||||||
default:
|
public function getHardness(){
|
||||||
return 15;
|
return 3;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getDrops(Item $item){
|
public function getDrops(Item $item){
|
||||||
if($item->isPickaxe() >= 3){
|
if($item->isPickaxe() >= Tool::TIER_STONE){
|
||||||
return [
|
return [
|
||||||
[Item::LAPIS_BLOCK, 0, 1],
|
[Item::LAPIS_BLOCK, 0, 1],
|
||||||
];
|
];
|
||||||
|
@ -22,29 +22,30 @@
|
|||||||
namespace pocketmine\block;
|
namespace pocketmine\block;
|
||||||
|
|
||||||
use pocketmine\item\Item;
|
use pocketmine\item\Item;
|
||||||
|
use pocketmine\item\Tool;
|
||||||
|
|
||||||
class LapisOre extends Solid{
|
class LapisOre extends Solid{
|
||||||
|
|
||||||
|
protected $id = self::LAPIS_ORE;
|
||||||
|
|
||||||
public function __construct(){
|
public function __construct(){
|
||||||
parent::__construct(self::LAPIS_ORE, 0, "Lapis Ore");
|
|
||||||
$this->hardness = 15;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getBreakTime(Item $item){
|
public function getHardness(){
|
||||||
|
return 3;
|
||||||
|
}
|
||||||
|
|
||||||
switch($item->isPickaxe()){
|
public function getToolType(){
|
||||||
case 5:
|
return Tool::TYPE_PICKAXE;
|
||||||
return 0.6;
|
}
|
||||||
case 4:
|
|
||||||
return 0.75;
|
public function getName(){
|
||||||
case 3:
|
return "Lapis Lazuli Ore";
|
||||||
return 1.15;
|
|
||||||
default:
|
|
||||||
return 15;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getDrops(Item $item){
|
public function getDrops(Item $item){
|
||||||
if($item->isPickaxe() >= 3){
|
if($item->isPickaxe() >= Tool::TIER_STONE){
|
||||||
return [
|
return [
|
||||||
[Item::DYE, 4, mt_rand(4, 8)],
|
[Item::DYE, 4, mt_rand(4, 8)],
|
||||||
];
|
];
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
|
|
||||||
namespace pocketmine\block;
|
namespace pocketmine\block;
|
||||||
|
|
||||||
|
use pocketmine\entity\Effect;
|
||||||
use pocketmine\entity\Entity;
|
use pocketmine\entity\Entity;
|
||||||
use pocketmine\event\entity\EntityCombustByBlockEvent;
|
use pocketmine\event\entity\EntityCombustByBlockEvent;
|
||||||
use pocketmine\event\entity\EntityDamageByBlockEvent;
|
use pocketmine\event\entity\EntityDamageByBlockEvent;
|
||||||
@ -31,16 +32,24 @@ use pocketmine\Server;
|
|||||||
|
|
||||||
class Lava extends Liquid{
|
class Lava extends Liquid{
|
||||||
|
|
||||||
|
protected $id = self::LAVA;
|
||||||
|
|
||||||
public function __construct($meta = 0){
|
public function __construct($meta = 0){
|
||||||
parent::__construct(self::LAVA, $meta, "Lava");
|
$this->meta = $meta;
|
||||||
$this->hardness = 0;
|
}
|
||||||
|
|
||||||
|
public function getLightLevel(){
|
||||||
|
return 15;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getName(){
|
||||||
|
return "Lava";
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onEntityCollide(Entity $entity){
|
public function onEntityCollide(Entity $entity){
|
||||||
$entity->fallDistance *= 0.5;
|
$entity->fallDistance *= 0.5;
|
||||||
$ev = new EntityDamageByBlockEvent($this, $entity, EntityDamageEvent::CAUSE_LAVA, 4);
|
if(!$entity->hasEffect(Effect::FIRE_RESISTANCE)){
|
||||||
Server::getInstance()->getPluginManager()->callEvent($ev);
|
$ev = new EntityDamageByBlockEvent($this, $entity, EntityDamageEvent::CAUSE_LAVA, 4);
|
||||||
if(!$ev->isCancelled()){
|
|
||||||
$entity->attack($ev->getFinalDamage(), $ev);
|
$entity->attack($ev->getFinalDamage(), $ev);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -49,6 +58,8 @@ class Lava extends Liquid{
|
|||||||
if(!$ev->isCancelled()){
|
if(!$ev->isCancelled()){
|
||||||
$entity->setOnFire($ev->getDuration());
|
$entity->setOnFire($ev->getDuration());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$entity->resetFallDistance();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){
|
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user