mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-08 19:02:59 +00:00
Compare commits
660 Commits
5.0.0-BETA
...
5.6.1
Author | SHA1 | Date | |
---|---|---|---|
decc188302 | |||
8fa5c7cdab | |||
7dd3a70d2e | |||
b3390458b4 | |||
b4d55e4384 | |||
932116fa52 | |||
7b5c30bc2c | |||
c14eb63f9b | |||
224a69b11a | |||
15ba642258 | |||
edea793a98 | |||
1da7e3586b | |||
7d200247f8 | |||
2d697c5f04 | |||
364f408eb1 | |||
660e2b8173 | |||
9facb98327 | |||
7e42a03db3 | |||
94a17f59d2 | |||
ed4088755f | |||
ff89d4d055 | |||
8f804f6f34 | |||
c3bca9e172 | |||
c028bb9055 | |||
f151047b5e | |||
77566db766 | |||
dd2e6ea33f | |||
d138a15a32 | |||
7a2cfa92b6 | |||
912fd3f5c6 | |||
5eca90d478 | |||
338bb3fe6d | |||
f485f7fb46 | |||
63eba3eb53 | |||
914eb62e94 | |||
a85814d0c9 | |||
eb2e472b01 | |||
6553852d99 | |||
540476365f | |||
efafc2c6ca | |||
d7f69c5e24 | |||
0e87ee1e0e | |||
03ecc98a24 | |||
a5aeabd836 | |||
fe94379a93 | |||
79acc4fed4 | |||
c8d357f4eb | |||
ec1cd5967d | |||
5a010e8213 | |||
73a44d50ee | |||
6aab07debd | |||
b160b87e24 | |||
690ee4c574 | |||
a0c7587b68 | |||
be4e091d40 | |||
857c2edc2c | |||
b1ab69ac6c | |||
e95a920fb8 | |||
67f399b238 | |||
a7c806d549 | |||
0920c76a35 | |||
a91ca999fe | |||
ce04478395 | |||
28ce7ac5fd | |||
540f088eda | |||
19e3d339f6 | |||
9fdb6ba5aa | |||
4a0a538278 | |||
2912e7ca29 | |||
31d8cc1cb5 | |||
506d8d1064 | |||
d1a7c1d453 | |||
b56f1b679e | |||
1a18e32011 | |||
09c9dfb576 | |||
f2b710c083 | |||
c7a311c17a | |||
ce53a221a5 | |||
c8100480ac | |||
8814d06dfd | |||
923f7561fb | |||
f4e1c31dcf | |||
998fcf20db | |||
1504fdca24 | |||
bf668c0f6c | |||
d942748203 | |||
29fdc8b08d | |||
20a41b00ba | |||
df96e023dc | |||
f4d5605de1 | |||
d03e4d17ec | |||
4cc858829f | |||
e852a43821 | |||
05f40b1315 | |||
7aaef8cb89 | |||
9d4c37fc3a | |||
cd6abbe0bb | |||
22778583cf | |||
d44e0e87d0 | |||
47b448965d | |||
cfa2df82eb | |||
7f78ec0a32 | |||
8572311bf4 | |||
18ca3a37d9 | |||
b2414b4c29 | |||
b3c740081e | |||
4b41fca991 | |||
9f09acc079 | |||
beaca8bb6d | |||
e323c5dd76 | |||
b65b7a7f74 | |||
f516c3c502 | |||
5afbb9d807 | |||
b330cbe8e2 | |||
39867b97c5 | |||
4c25d38b44 | |||
983aa79a0b | |||
af9ae445fc | |||
91d5a3ddfe | |||
e48b5b2ec0 | |||
f03e708f64 | |||
37f2dafae1 | |||
7826e0a11e | |||
97700636c6 | |||
447f061566 | |||
b86b389fc5 | |||
e27121a437 | |||
2d5c9e64ce | |||
78f5fbddf3 | |||
aa3f4f2545 | |||
f7279b6672 | |||
2711ab4f00 | |||
b4c5f5d58d | |||
a5d8ef7a6c | |||
59c88fe7f7 | |||
735d9a5bf4 | |||
f4a06605b1 | |||
77dfbc4e23 | |||
662f2495e9 | |||
b8a4ca45e4 | |||
ebcd6a0bb2 | |||
baefbce863 | |||
b45b4b5edf | |||
9f14901820 | |||
dd79d4c463 | |||
9c1ab943bc | |||
2c74124e2e | |||
514fc1ebb5 | |||
c1638ffaab | |||
710177ceb5 | |||
2559d1719f | |||
2e58387a43 | |||
515f8eae4c | |||
35a28300f6 | |||
1cf508abdb | |||
6ac45526f9 | |||
c91c8c2f9e | |||
81941ae9e5 | |||
1a2c10e844 | |||
d88c3d8ced | |||
82f87cc2da | |||
bb0e648276 | |||
6000bcccdd | |||
0b86fafafb | |||
2608637210 | |||
442d65143d | |||
53de55dcde | |||
01664d2e81 | |||
0a90a5928a | |||
46f24b165a | |||
6f09286fed | |||
774eb3e72b | |||
cd8219d9fd | |||
52ce3444d8 | |||
e9e5923639 | |||
49a9da147b | |||
4c0df5ee4e | |||
4c737b2ee3 | |||
eb53b795d5 | |||
befd3637f6 | |||
9b2a7b43c2 | |||
5ec3f4655f | |||
c972e65741 | |||
a45763328b | |||
82a5ea9ed3 | |||
bbdcab7277 | |||
6086ef667c | |||
486d4099df | |||
a1f34a460b | |||
5ff03c81f8 | |||
1c611a03e6 | |||
948875b025 | |||
fb43f59458 | |||
16dfd27935 | |||
2a4909d328 | |||
b078e01b65 | |||
4eb9dacd3c | |||
43770313ba | |||
3afe3b7f44 | |||
fd23281183 | |||
70dd8732e2 | |||
cdf72563f4 | |||
2779f92828 | |||
5899f2fc1d | |||
9ef835c82d | |||
d65d8c3356 | |||
9b43ddecbd | |||
4bdd6410db | |||
6ea7fd7d6b | |||
5e7f18cbcf | |||
4517948297 | |||
777a901932 | |||
24d979bd08 | |||
86810c5e1c | |||
b33a9690e9 | |||
1b9c282194 | |||
82b75e0ccb | |||
6c59912ed5 | |||
3c34841dfc | |||
914dd90b3d | |||
537721fe7d | |||
fba51e3bf9 | |||
763241b11f | |||
8414c78969 | |||
4637aae621 | |||
6fbc133e5d | |||
f38aee1fc5 | |||
69abd5eb53 | |||
f6ee7ddc9e | |||
cff4a8d2bc | |||
20b7e8d702 | |||
c6110be051 | |||
c053742f5d | |||
0051b34797 | |||
a74ab756bd | |||
90520c8962 | |||
2e9a4f2be2 | |||
e23806d417 | |||
30db658d70 | |||
83d11c7429 | |||
4c6b82f30a | |||
fb6a7d279f | |||
0c1bfb058a | |||
45d1ce9bb8 | |||
8c8794ec71 | |||
b399eda21e | |||
f7c08dedee | |||
250d18e41b | |||
86bd6777a3 | |||
935df62006 | |||
489a7ba365 | |||
2709dd359c | |||
4e646d19a4 | |||
2a11762e61 | |||
dca752c72f | |||
259cc305df | |||
7132ac0ad3 | |||
0d8a06732a | |||
d2f4ba74c6 | |||
d4716ef457 | |||
d630b3af7b | |||
c2bb51cb37 | |||
7e0b5cf73d | |||
e903da8998 | |||
b7210755a7 | |||
f2193d1ba7 | |||
4daacb2ab7 | |||
f7977c9668 | |||
93d3f439bf | |||
200e5f940c | |||
9365ffa7fa | |||
cfd9950b02 | |||
8ebcdb452d | |||
ef85fbffe1 | |||
aacc00a911 | |||
0c250a2ef0 | |||
c01d2dc718 | |||
8f217ca6e0 | |||
f0d5647aa2 | |||
e6de9a70a2 | |||
a34514c6a1 | |||
6a80b210d4 | |||
02ffb04b92 | |||
6cbb03bf9b | |||
3abd592b1f | |||
644b417d2c | |||
588a754f1c | |||
70dd9c7371 | |||
f8e6f036af | |||
5d51ffdfe3 | |||
a2a7006878 | |||
b78c18ad2d | |||
41281db6a5 | |||
2278275505 | |||
53a6d8451b | |||
bbabccfc89 | |||
1698eac6dc | |||
83378d9403 | |||
321972b87b | |||
24b74a96eb | |||
e61796b146 | |||
c86c9b3ead | |||
249ef9c534 | |||
17842703a1 | |||
f4dab17a1b | |||
eed423505e | |||
c165670e0a | |||
882d50b14e | |||
0b0b72f596 | |||
2654fb294b | |||
2b40c1a5be | |||
74d219dcb6 | |||
470a3e1a3a | |||
ad67fb7291 | |||
3eed0a4620 | |||
b8788c55c5 | |||
c06763c59b | |||
881451c40c | |||
36f52f1ade | |||
0240d35c05 | |||
8dedbb7471 | |||
6f82942c64 | |||
9d0d60afd1 | |||
391732f00c | |||
ad3f854701 | |||
64e09525f3 | |||
774f92435a | |||
be8cca1d55 | |||
eb9f804781 | |||
bccda4fe44 | |||
8f48f8a596 | |||
288ebfa08a | |||
a3046eb6fa | |||
ff0199cdf8 | |||
39a6a9ee70 | |||
0939301938 | |||
202be92c06 | |||
df4a8d4788 | |||
1d25e15ec8 | |||
1b35c352cc | |||
ab75838c89 | |||
1533dc4e56 | |||
3800c0480f | |||
0f8e61eda4 | |||
0eb5f9b684 | |||
0f9283fda1 | |||
ab8386ed5a | |||
64c1776910 | |||
e85605af7f | |||
92bd88c77c | |||
7cd317bf39 | |||
35fc9abacf | |||
dfd70615ad | |||
ee903cad1f | |||
9a04481bec | |||
833f9401f9 | |||
a46dfaf677 | |||
4a3b175468 | |||
73ee94b62c | |||
ab83210aa0 | |||
3f2d51c58a | |||
13dee2a615 | |||
5d514a274f | |||
2220dc557e | |||
b5fc31a781 | |||
9a67e3d660 | |||
132330e16f | |||
179eec9754 | |||
441f1f534f | |||
e747478afd | |||
92c45dd7e1 | |||
2538880408 | |||
4af981d726 | |||
ab3ebc1aa8 | |||
57cbc25080 | |||
b9bdfe580b | |||
6d7f44d8fe | |||
f9818efff4 | |||
7fef8f0ab6 | |||
2f43ccea6f | |||
af1f7e098b | |||
1706fb43eb | |||
8d7f8ff3f5 | |||
c715efb18e | |||
40be564689 | |||
4e031e7b3e | |||
4340c26029 | |||
9c6d4093ae | |||
007ef833d4 | |||
6678360c00 | |||
102fd4d63a | |||
2c0715ac6e | |||
f75bb061ce | |||
73e7201acb | |||
b16cc69974 | |||
5de4215169 | |||
e128a4e1e7 | |||
c95c600100 | |||
3db45b6a68 | |||
3e87ad281f | |||
b72da777eb | |||
de49910e84 | |||
d2fe537159 | |||
bb31df051d | |||
1101f35c17 | |||
07225df936 | |||
3948dc4f75 | |||
4f4dca7fc0 | |||
0ed5e94a72 | |||
3a4e958e84 | |||
20942b37eb | |||
d343db8750 | |||
f2df702c67 | |||
481270e6aa | |||
e7bdaa8579 | |||
76749cbaa7 | |||
a897bdfaa0 | |||
09668a37d6 | |||
ea92a23d0d | |||
691e67018d | |||
fe2140a716 | |||
8744032ab6 | |||
5a9cdef40c | |||
a49842278a | |||
d57954dff0 | |||
ce5e663a73 | |||
c10be0f346 | |||
f5a1a0c9cb | |||
7f1550ef04 | |||
9baf59702b | |||
473c062b40 | |||
b8ba2d03ba | |||
06b0fa4d67 | |||
fddab29e87 | |||
bdb0ed0701 | |||
edafe9d21f | |||
cc77f18ff0 | |||
24e897f813 | |||
ffe3556be1 | |||
57330a7186 | |||
2ebf8757c1 | |||
1c69116717 | |||
9d9c628acd | |||
cbda24d77e | |||
ed64eac76f | |||
a7aebed0a0 | |||
c66a3a8b3e | |||
4aba9d9725 | |||
d2c34615f5 | |||
815b4e2bab | |||
69273f3ff7 | |||
9ddac21de0 | |||
fdb724c646 | |||
3109a179db | |||
5afeeb8f89 | |||
1cb7846f7c | |||
097feba4d5 | |||
9509d7e04d | |||
3116fb8187 | |||
e0630fbb25 | |||
8245cfab0e | |||
8454076235 | |||
4a3843a881 | |||
bd6af68f91 | |||
b27d3a5fce | |||
c91aa24daa | |||
b8a1b32461 | |||
9c82507168 | |||
db95bf8b9b | |||
edcf0f8405 | |||
b8abe34904 | |||
7ac74180c9 | |||
6186fc0bfe | |||
ef40934d24 | |||
69b668355f | |||
ee9ce8a4f4 | |||
59ca7b75e1 | |||
9621836e36 | |||
0547383296 | |||
c7dff9ea40 | |||
043350753b | |||
5ad8016b99 | |||
2e5b2eed6e | |||
5a0cde49cc | |||
008a022ec1 | |||
5c85a7c306 | |||
599c4284f5 | |||
9499e2e595 | |||
a4fea1444a | |||
c9bb4335a1 | |||
015c668885 | |||
ccb22ceb3f | |||
1ba47802a8 | |||
9d111e13f1 | |||
44bc4d8c7c | |||
30f1d3e016 | |||
7b1a1e5a18 | |||
1b452f3a88 | |||
fa719f37d5 | |||
d834266635 | |||
d317347a9b | |||
077fac84bf | |||
6f0eb019d2 | |||
fdb3a5b121 | |||
8e6c1762d7 | |||
e3bc36ab5b | |||
283ff28aa9 | |||
c3ceeeace7 | |||
aac4f6c0e1 | |||
926f68d8c5 | |||
ed11fd5a83 | |||
e0a6ec0c24 | |||
7cdf6b0946 | |||
5c7f4570b4 | |||
bb60a9057f | |||
3b893961e4 | |||
325ffec1be | |||
fa715a074a | |||
4caa2c7690 | |||
d04da9b1d8 | |||
8a374df801 | |||
02cf5ed388 | |||
6cad559dbe | |||
84a943bcec | |||
f2c6a75145 | |||
09e823e304 | |||
289ede669d | |||
4f32f5e0b7 | |||
633e77a34c | |||
092d130c96 | |||
c09390d20f | |||
22f8623e17 | |||
d8e77c1920 | |||
85372633eb | |||
2c81446e5b | |||
299ff5d912 | |||
896dd2ec9d | |||
f1417e8dc9 | |||
897ba9f2d9 | |||
d2c37d8bcf | |||
43fe819862 | |||
f9d9cbd0f6 | |||
ed021d193d | |||
32e6fdd95a | |||
01f340985a | |||
5e462db0f8 | |||
6beb80b8fe | |||
4d0cecbac2 | |||
5fcf5e0c40 | |||
f29e2f7110 | |||
d0d263191d | |||
3366e1084b | |||
d0b9234841 | |||
d80f65ae7c | |||
096daef0d0 | |||
29694c19af | |||
b3e94ef1dc | |||
f04151dbe6 | |||
5dcd8bf289 | |||
17fe894229 | |||
728e0bc869 | |||
a1d44de487 | |||
263e1e9950 | |||
2121152b76 | |||
a1cd1d7433 | |||
04aabaee5e | |||
75410a5412 | |||
e2108557ab | |||
ff8301b86c | |||
869c836e2d | |||
b70ff32548 | |||
73bf5d4b29 | |||
eb136e60c8 | |||
4228880509 | |||
709d874204 | |||
07dc10d6e6 | |||
7f6269c432 | |||
194714b448 | |||
023460db2c | |||
2910ffebf4 | |||
fea820a99e | |||
7c19f14cf5 | |||
5a54d09869 | |||
a8dec1adb1 | |||
0dca85af44 | |||
4def4d52d9 | |||
1d10107024 | |||
54ae4d0ea2 | |||
0d21e591d1 | |||
408616723c | |||
9bfcd39f2a | |||
8102616ff4 | |||
b162d688a3 | |||
eb130f2906 | |||
3b09c3a48a | |||
87781cff4d | |||
db0cf4bb5a | |||
a0346fb6d3 | |||
eb4679fefd | |||
a4f2b99ed5 | |||
3ecc980bc4 | |||
107b56154b | |||
f86fde064d | |||
edcaeef831 | |||
d4ca566fd0 | |||
6c0ad9589b | |||
84a16ce69a | |||
d06d3bc871 | |||
11e34b3e5c | |||
f9318bf286 | |||
769be8e140 | |||
c878bd8289 | |||
71b78b02d3 | |||
4147d0dc75 | |||
674b65f789 | |||
a77fc8109f | |||
6102740ee3 | |||
40168a457e | |||
d07acd0013 | |||
0629d11e13 | |||
9561ae5af7 | |||
56fbd45dd5 | |||
b5dc72b0ee | |||
4ba57f2b03 | |||
1026811741 | |||
84cb070d56 | |||
df0d72bf61 | |||
a534ac759a | |||
5ab954b7a0 | |||
6c6f686f8e | |||
bf7975da57 | |||
7aeedd8220 | |||
3dd1ce2d02 | |||
5a29d07021 | |||
692e1253c6 | |||
ab0c444823 | |||
e48a4aaa55 | |||
6fc4ce0f86 | |||
6acabf7a1b | |||
10243c7b2c | |||
b122703fd0 | |||
e40774d62f | |||
027d8f7377 | |||
5950707267 | |||
6cace51a21 | |||
6703f46a08 | |||
874fdf5adb | |||
1c626baf1a | |||
c3a2199f0e | |||
499b29b53a | |||
8102586ee0 | |||
18b528f72d | |||
0336394098 | |||
7e92da126d | |||
b80d7a57e3 | |||
1569bed37a | |||
ba62e0f9cb | |||
a6e79c5004 | |||
858d4a2ed2 | |||
18658cb74d |
Before Width: | Height: | Size: 1.9 KiB After Width: | Height: | Size: 1.9 KiB |
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 1.7 KiB |
BIN
.github/readme/pocketmine-dark-rgb.gif
vendored
Normal file
BIN
.github/readme/pocketmine-dark-rgb.gif
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 173 KiB |
BIN
.github/readme/pocketmine-rgb.gif
vendored
Normal file
BIN
.github/readme/pocketmine-rgb.gif
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 173 KiB |
16
.github/workflows/build-docker-image.yml
vendored
16
.github/workflows/build-docker-image.yml
vendored
@ -12,23 +12,23 @@ jobs:
|
||||
|
||||
steps:
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v2
|
||||
uses: docker/setup-buildx-action@v3
|
||||
|
||||
- name: Login to DockerHub
|
||||
uses: docker/login-action@v2
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||
|
||||
- name: Login to GitHub Container Registry
|
||||
uses: docker/login-action@v2
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
registry: ghcr.io
|
||||
username: ${{ github.actor }}
|
||||
password: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Clone pmmp/PocketMine-Docker repository
|
||||
uses: actions/checkout@v3
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
repository: pmmp/PocketMine-Docker
|
||||
fetch-depth: 1
|
||||
@ -53,7 +53,7 @@ jobs:
|
||||
run: echo NAME=$(echo "${GITHUB_REPOSITORY,,}") >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Build image for tag
|
||||
uses: docker/build-push-action@v4.0.0
|
||||
uses: docker/build-push-action@v5.0.0
|
||||
with:
|
||||
push: true
|
||||
context: ./pocketmine-mp
|
||||
@ -66,7 +66,7 @@ jobs:
|
||||
|
||||
- name: Build image for major tag
|
||||
if: steps.channel.outputs.CHANNEL == 'stable'
|
||||
uses: docker/build-push-action@v4.0.0
|
||||
uses: docker/build-push-action@v5.0.0
|
||||
with:
|
||||
push: true
|
||||
context: ./pocketmine-mp
|
||||
@ -79,7 +79,7 @@ jobs:
|
||||
|
||||
- name: Build image for minor tag
|
||||
if: steps.channel.outputs.CHANNEL == 'stable'
|
||||
uses: docker/build-push-action@v4.0.0
|
||||
uses: docker/build-push-action@v5.0.0
|
||||
with:
|
||||
push: true
|
||||
context: ./pocketmine-mp
|
||||
@ -92,7 +92,7 @@ jobs:
|
||||
|
||||
- name: Build image for latest tag
|
||||
if: steps.channel.outputs.CHANNEL == 'stable'
|
||||
uses: docker/build-push-action@v4.0.0
|
||||
uses: docker/build-push-action@v5.0.0
|
||||
with:
|
||||
push: true
|
||||
context: ./pocketmine-mp
|
||||
|
22
.github/workflows/discord-release-embed.php
vendored
22
.github/workflows/discord-release-embed.php
vendored
@ -18,7 +18,12 @@ require dirname(__DIR__, 2) . '/vendor/autoload.php';
|
||||
/**
|
||||
* @phpstan-return array<string, mixed>
|
||||
*/
|
||||
function generateDiscordEmbed(string $version, string $channel, string $description, string $detailsUrl, string $sourceUrl, string $pharDownloadUrl, string $buildLogUrl, int $newsPingRoleId) : array{
|
||||
function generateDiscordEmbed(string $version, string $channel, string $description, string $detailsUrl, string $sourceUrl, string $pharDownloadUrl, string $buildLogUrl, int $newsPingRoleId, ?string $phpDownloadUrl) : array{
|
||||
if($phpDownloadUrl !== null){
|
||||
$phpEmbedLink = " | [PHP Binaries]($phpDownloadUrl)";
|
||||
}else{
|
||||
$phpEmbedLink = "";
|
||||
}
|
||||
return [
|
||||
"content" => "<@&$newsPingRoleId> New PocketMine-MP release: $version ($channel)",
|
||||
"embeds" => [
|
||||
@ -27,7 +32,7 @@ function generateDiscordEmbed(string $version, string $channel, string $descript
|
||||
"description" => <<<DESCRIPTION
|
||||
$description
|
||||
|
||||
[Details]($detailsUrl) | [Source Code]($sourceUrl) | [Build Log]($buildLogUrl) | [Download]($pharDownloadUrl)
|
||||
[Details]($detailsUrl) | [Source Code]($sourceUrl) | [Build Log]($buildLogUrl) | [Download]($pharDownloadUrl)$phpEmbedLink
|
||||
DESCRIPTION,
|
||||
"url" => $detailsUrl,
|
||||
"color" => $channel === "stable" ? 0x57ab5a : 0xc69026
|
||||
@ -84,10 +89,21 @@ $detailsUrl = $buildInfoJson["details_url"];
|
||||
$sourceUrl = $buildInfoJson["source_url"];
|
||||
$pharDownloadUrl = $buildInfoJson["download_url"];
|
||||
$buildLogUrl = $buildInfoJson["build_log_url"];
|
||||
$phpBinaryUrl = $buildInfoJson["php_download_url"] ?? null;
|
||||
|
||||
$description = $releaseInfoJson["body"];
|
||||
|
||||
$discordPayload = generateDiscordEmbed($buildInfoJson["base_version"], $buildInfoJson["channel"], $description, $detailsUrl, $sourceUrl, $pharDownloadUrl, $buildLogUrl, (int) $newsPingRoleId);
|
||||
$discordPayload = generateDiscordEmbed(
|
||||
$buildInfoJson["base_version"],
|
||||
$buildInfoJson["channel"],
|
||||
$description,
|
||||
$detailsUrl,
|
||||
$sourceUrl,
|
||||
$pharDownloadUrl,
|
||||
$buildLogUrl,
|
||||
(int) $newsPingRoleId,
|
||||
$phpBinaryUrl
|
||||
);
|
||||
|
||||
$response = Internet::postURL(
|
||||
$hookURL,
|
||||
|
6
.github/workflows/discord-release-notify.yml
vendored
6
.github/workflows/discord-release-notify.yml
vendored
@ -10,12 +10,12 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Setup PHP and tools
|
||||
uses: shivammathur/setup-php@2.24.0
|
||||
uses: shivammathur/setup-php@2.26.0
|
||||
with:
|
||||
php-version: 8.0
|
||||
php-version: 8.1
|
||||
|
||||
- name: Restore Composer package cache
|
||||
uses: actions/cache@v3
|
||||
|
27
.github/workflows/draft-release.yml
vendored
27
.github/workflows/draft-release.yml
vendored
@ -11,16 +11,18 @@ jobs:
|
||||
runs-on: ubuntu-20.04
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
php-version: [8.1]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: true
|
||||
|
||||
- name: Setup PHP
|
||||
uses: shivammathur/setup-php@2.24.0
|
||||
uses: shivammathur/setup-php@2.26.0
|
||||
with:
|
||||
php-version: 8.0
|
||||
php-version: ${{ matrix.php-version }}
|
||||
|
||||
- name: Restore Composer package cache
|
||||
uses: actions/cache@v3
|
||||
@ -58,8 +60,21 @@ jobs:
|
||||
echo CHANGELOG_SUFFIX=$(php -r 'require "vendor/autoload.php"; echo \pocketmine\VersionInfo::BUILD_CHANNEL === "stable" ? "" : "-" . \pocketmine\VersionInfo::BUILD_CHANNEL;') >> $GITHUB_OUTPUT
|
||||
echo PRERELEASE=$(php -r 'require "vendor/autoload.php"; echo \pocketmine\VersionInfo::BUILD_CHANNEL === "stable" ? "false" : "true";') >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Generate PHP binary download URL
|
||||
id: php-binary-url
|
||||
run: |
|
||||
echo PHP_BINARY_URL="${{ github.server_url }}/${{ github.repository_owner }}/PHP-Binaries/releases/tag/php-${{ matrix.php-version }}-latest" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Generate build info
|
||||
run: php build/generate-build-info-json.php ${{ github.sha }} ${{ steps.get-pm-version.outputs.PM_VERSION }} ${{ github.repository }} ${{ steps.build-number.outputs.BUILD_NUMBER }} ${{ github.run_id }} > build_info.json
|
||||
run: |
|
||||
php build/generate-build-info-json.php \
|
||||
${{ github.sha }} \
|
||||
${{ steps.get-pm-version.outputs.PM_VERSION }} \
|
||||
${{ github.repository }} \
|
||||
${{ steps.build-number.outputs.BUILD_NUMBER }} \
|
||||
${{ github.run_id }} \
|
||||
${{ steps.php-binary-url.outputs.PHP_BINARY_URL }} \
|
||||
> build_info.json
|
||||
|
||||
- name: Upload release artifacts
|
||||
uses: actions/upload-artifact@v3
|
||||
@ -71,7 +86,7 @@ jobs:
|
||||
${{ github.workspace }}/build_info.json
|
||||
|
||||
- name: Create draft release
|
||||
uses: ncipollo/release-action@v1.12.0
|
||||
uses: ncipollo/release-action@v1.13.0
|
||||
with:
|
||||
artifacts: ${{ github.workspace }}/PocketMine-MP.phar,${{ github.workspace }}/start.*,${{ github.workspace }}/build_info.json
|
||||
commit: ${{ github.sha }}
|
||||
@ -84,3 +99,5 @@ jobs:
|
||||
**For Minecraft: Bedrock Edition ${{ steps.get-pm-version.outputs.MCPE_VERSION }}**
|
||||
|
||||
Please see the [changelogs](${{ github.server_url }}/${{ github.repository }}/blob/${{ steps.get-pm-version.outputs.PM_VERSION }}/changelogs/${{ steps.get-pm-version.outputs.PM_VERSION_SHORT }}${{ steps.get-pm-version.outputs.CHANGELOG_SUFFIX }}.md#${{ steps.get-pm-version.outputs.PM_VERSION_MD }}) for details.
|
||||
|
||||
:information_source: Download the recommended PHP binary [here](${{ steps.php-binary-url.outputs.PHP_BINARY_URL }}).
|
||||
|
76
.github/workflows/main.yml
vendored
76
.github/workflows/main.yml
vendored
@ -6,47 +6,26 @@ on:
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
build-php:
|
||||
name: Prepare PHP
|
||||
runs-on: ${{ matrix.image }}
|
||||
|
||||
strategy:
|
||||
matrix:
|
||||
image: [ubuntu-20.04]
|
||||
php: [8.0.28, 8.1.16, 8.2.3]
|
||||
|
||||
steps:
|
||||
- name: Build and prepare PHP cache
|
||||
uses: pmmp/setup-php-action@6dd74c145250109942b08fc63cd5118edd2fd256
|
||||
with:
|
||||
php-version: ${{ matrix.php }}
|
||||
install-path: "./bin"
|
||||
pm-version-major: "5"
|
||||
|
||||
phpstan:
|
||||
name: PHPStan analysis
|
||||
needs: build-php
|
||||
runs-on: ${{ matrix.image }}
|
||||
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
image: [ubuntu-20.04]
|
||||
php: [8.0.28, 8.1.16, 8.2.3]
|
||||
php: ["8.1", "8.2"]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Setup PHP
|
||||
uses: pmmp/setup-php-action@6dd74c145250109942b08fc63cd5118edd2fd256
|
||||
uses: pmmp/setup-php-action@2.0.0
|
||||
with:
|
||||
php-version: ${{ matrix.php }}
|
||||
install-path: "./bin"
|
||||
pm-version-major: "5"
|
||||
|
||||
- name: Install Composer
|
||||
run: curl -sS https://getcomposer.org/installer | php
|
||||
|
||||
- name: Restore Composer package cache
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
@ -58,34 +37,30 @@ jobs:
|
||||
composer-v2-cache-
|
||||
|
||||
- name: Install Composer dependencies
|
||||
run: php composer.phar install --prefer-dist --no-interaction
|
||||
run: composer install --prefer-dist --no-interaction
|
||||
|
||||
- name: Run PHPStan
|
||||
run: ./vendor/bin/phpstan analyze --no-progress --memory-limit=2G
|
||||
|
||||
phpunit:
|
||||
name: PHPUnit tests
|
||||
needs: build-php
|
||||
runs-on: ${{ matrix.image }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
image: [ubuntu-20.04]
|
||||
php: [8.0.28, 8.1.16, 8.2.3]
|
||||
php: ["8.1", "8.2"]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Setup PHP
|
||||
uses: pmmp/setup-php-action@6dd74c145250109942b08fc63cd5118edd2fd256
|
||||
uses: pmmp/setup-php-action@2.0.0
|
||||
with:
|
||||
php-version: ${{ matrix.php }}
|
||||
install-path: "./bin"
|
||||
pm-version-major: "5"
|
||||
|
||||
- name: Install Composer
|
||||
run: curl -sS https://getcomposer.org/installer | php
|
||||
|
||||
- name: Restore Composer package cache
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
@ -97,36 +72,32 @@ jobs:
|
||||
composer-v2-cache-
|
||||
|
||||
- name: Install Composer dependencies
|
||||
run: php composer.phar install --prefer-dist --no-interaction
|
||||
run: composer install --prefer-dist --no-interaction
|
||||
|
||||
- name: Run PHPUnit tests
|
||||
run: ./vendor/bin/phpunit --bootstrap vendor/autoload.php --fail-on-warning tests/phpunit
|
||||
|
||||
integration:
|
||||
name: Integration tests
|
||||
needs: build-php
|
||||
runs-on: ${{ matrix.image }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
image: [ubuntu-20.04]
|
||||
php: [8.0.28, 8.1.16, 8.2.3]
|
||||
php: ["8.1", "8.2"]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: true
|
||||
|
||||
- name: Setup PHP
|
||||
uses: pmmp/setup-php-action@6dd74c145250109942b08fc63cd5118edd2fd256
|
||||
uses: pmmp/setup-php-action@2.0.0
|
||||
with:
|
||||
php-version: ${{ matrix.php }}
|
||||
install-path: "./bin"
|
||||
pm-version-major: "5"
|
||||
|
||||
- name: Install Composer
|
||||
run: curl -sS https://getcomposer.org/installer | php
|
||||
|
||||
- name: Restore Composer package cache
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
@ -138,34 +109,30 @@ jobs:
|
||||
composer-v2-cache-
|
||||
|
||||
- name: Install Composer dependencies
|
||||
run: php composer.phar install --no-dev --prefer-dist --no-interaction
|
||||
run: composer install --no-dev --prefer-dist --no-interaction
|
||||
|
||||
- name: Run integration tests
|
||||
run: ./tests/travis.sh -t4
|
||||
|
||||
codegen:
|
||||
name: Generated Code consistency checks
|
||||
needs: build-php
|
||||
runs-on: ${{ matrix.image }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
image: [ubuntu-20.04]
|
||||
php: [8.0.28, 8.1.16, 8.2.3]
|
||||
php: ["8.1", "8.2"]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Setup PHP
|
||||
uses: pmmp/setup-php-action@6dd74c145250109942b08fc63cd5118edd2fd256
|
||||
uses: pmmp/setup-php-action@2.0.0
|
||||
with:
|
||||
php-version: ${{ matrix.php }}
|
||||
install-path: "./bin"
|
||||
pm-version-major: "5"
|
||||
|
||||
- name: Install Composer
|
||||
run: curl -sS https://getcomposer.org/installer | php
|
||||
|
||||
- name: Restore Composer package cache
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
@ -177,7 +144,7 @@ jobs:
|
||||
composer-v2-cache-
|
||||
|
||||
- name: Install Composer dependencies
|
||||
run: php composer.phar install --no-dev --prefer-dist --no-interaction
|
||||
run: composer install --no-dev --prefer-dist --no-interaction
|
||||
|
||||
- name: Regenerate registry annotations
|
||||
run: php build/generate-registry-annotations.php src
|
||||
@ -191,6 +158,9 @@ jobs:
|
||||
- name: Regenerate BedrockData available files constants
|
||||
run: php build/generate-bedrockdata-path-consts.php
|
||||
|
||||
- name: Regenerate YmlServerProperties constants
|
||||
run: php build/generate-pocketmine-yml-property-consts.php
|
||||
|
||||
- name: Verify code is unchanged
|
||||
run: |
|
||||
git diff
|
||||
@ -203,13 +173,13 @@ jobs:
|
||||
fail-fast: false
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Setup PHP and tools
|
||||
uses: shivammathur/setup-php@2.24.0
|
||||
uses: shivammathur/setup-php@2.26.0
|
||||
with:
|
||||
php-version: 8.0
|
||||
tools: php-cs-fixer:3.11
|
||||
php-version: 8.1
|
||||
tools: php-cs-fixer:3.17
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
|
51
.github/workflows/update-php-versions.php
vendored
51
.github/workflows/update-php-versions.php
vendored
@ -1,51 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
*
|
||||
* ____ _ _ __ __ _ __ __ ____
|
||||
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
|
||||
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
|
||||
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
|
||||
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* @author PocketMine Team
|
||||
* @link http://www.pocketmine.net/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
const VERSIONS = [
|
||||
"8.0",
|
||||
"8.1",
|
||||
"8.2"
|
||||
];
|
||||
|
||||
$workflowFile = file_get_contents(__DIR__ . '/main.yml');
|
||||
$newWorkflowFile = $workflowFile;
|
||||
foreach(VERSIONS as $v){
|
||||
$releaseInfo = file_get_contents("https://secure.php.net/releases?json&version=$v");
|
||||
if($releaseInfo === false){
|
||||
throw new \RuntimeException("Failed to contact php.net API");
|
||||
}
|
||||
$data = json_decode($releaseInfo, true);
|
||||
if(!is_array($data) || !isset($data["version"]) || !is_string($data["version"]) || preg_match('/^\d+\.\d+\.\d+(-[A-Za-z\d]+)?$/', $data["version"]) === 0){
|
||||
throw new \RuntimeException("Invalid data returned by API");
|
||||
}
|
||||
$updated = preg_replace("/$v\.\d+/", $data["version"], $newWorkflowFile);
|
||||
if($updated !== $newWorkflowFile){
|
||||
echo "Updated $v revision to " . $data["version"] . "\n";
|
||||
}
|
||||
$newWorkflowFile = $updated;
|
||||
}
|
||||
|
||||
if($workflowFile !== $newWorkflowFile){
|
||||
echo "Writing modified workflow file\n";
|
||||
file_put_contents(__DIR__ . '/main.yml', $newWorkflowFile);
|
||||
}
|
3
.github/workflows/update-updater-api.yml
vendored
3
.github/workflows/update-updater-api.yml
vendored
@ -8,12 +8,13 @@ on:
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
concurrency: update-updater-api # only one job can run at a time, to avoid git conflicts when updating the repository
|
||||
|
||||
steps:
|
||||
- name: Install jq
|
||||
run: sudo apt update && sudo apt install jq -y
|
||||
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
repository: ${{ github.repository_owner }}/update.pmmp.io
|
||||
ssh-key: ${{ secrets.UPDATE_PMMP_IO_DEPLOY_KEY }}
|
||||
|
7
.idea/codeStyles/Project.xml
generated
7
.idea/codeStyles/Project.xml
generated
@ -30,6 +30,13 @@
|
||||
<option name="USE_TAB_CHARACTER" value="true" />
|
||||
</indentOptions>
|
||||
</codeStyleSettings>
|
||||
<codeStyleSettings language="Markdown">
|
||||
<indentOptions>
|
||||
<option name="INDENT_SIZE" value="2" />
|
||||
<option name="CONTINUATION_INDENT_SIZE" value="2" />
|
||||
<option name="TAB_SIZE" value="2" />
|
||||
</indentOptions>
|
||||
</codeStyleSettings>
|
||||
<codeStyleSettings language="PHP">
|
||||
<option name="CLASS_BRACE_STYLE" value="1" />
|
||||
<option name="METHOD_BRACE_STYLE" value="1" />
|
||||
|
10
BUILDING.md
10
BUILDING.md
@ -2,13 +2,13 @@
|
||||
## Pre-requisites
|
||||
- A bash shell (git bash is sufficient for Windows)
|
||||
- [`git`](https://git-scm.com) available in your shell
|
||||
- PHP 8.0 or newer available in your shell
|
||||
- PHP 8.1 or newer available in your shell
|
||||
- [`composer`](https://getcomposer.org) available in your shell
|
||||
|
||||
## Custom PHP binaries
|
||||
Because PocketMine-MP requires several non-standard PHP extensions and configuration, PMMP provides scripts to build custom binaries for running PocketMine-MP, as well as prebuilt binaries.
|
||||
|
||||
- [Prebuilt binaries](https://jenkins.pmmp.io/job/PHP-8.0-Aggregate)
|
||||
- [Prebuilt binaries](https://github.com/pmmp/PHP-Binaries/releases)
|
||||
- [Compile scripts](https://github.com/pmmp/php-build-scripts) are provided as a submodule in the path `build/php`
|
||||
|
||||
If you use a custom binary, you'll need to replace `composer` usages in this guide with `path/to/your/php path/to/your/composer.phar`.
|
||||
@ -29,11 +29,5 @@ Run `composer make-server` using your preferred PHP binary. It'll drop a `Pocket
|
||||
|
||||
You can also use the `--out` option to change the output filename.
|
||||
|
||||
There is a bug in PHP that might cause an error which looks like this:
|
||||
```
|
||||
Fatal error: Uncaught BadMethodCallException: unable to create temporary file in PocketMine-MP/build/server-phar.php:119
|
||||
```
|
||||
You can work around it by setting `ulimit -n` to some bigger number, e.g. `8192`, or by updating your PHP version to at least 8.0.3.
|
||||
|
||||
## Running PocketMine-MP from source code
|
||||
Run `src/PocketMine.php` using your preferred PHP binary.
|
||||
|
@ -18,6 +18,28 @@ Larger contributions like feature additions should be preceded by a [Change Prop
|
||||
## Other things you'll need
|
||||
- [git](https://git-scm.com/)
|
||||
|
||||
## List of `pocketmine` namespaces which are in other repos
|
||||
PocketMine-MP has several dependencies which are independent from the main server code. Most of them use the `pocketmine` namespace.
|
||||
Some of these add extra classes to packages which already exist in PocketMine-MP.
|
||||
|
||||
Take a look at the table below if you can't find the class or function you're looking for.
|
||||
|
||||
| Source URL | Namespace, class or function |
|
||||
|:----------------------------------------------------------------|:-----------------------------------------------------------------------------------------------------------------------------------------|
|
||||
| [pmmp/BedrockProtocol](https://github.com/pmmp/BedrockProtocol) | `pocketmine\network\mcpe\protocol` |
|
||||
| [pmmp/BinaryUtils](https://github.com/pmmp/BinaryUtils) | `pocketmine\utils\BinaryDataException`</br>`pocketmine\utils\BinaryStream`</br>`pocketmine\utils\Binary` |
|
||||
| [pmmp/Color](https://github.com/pmmp/Color) | `pocketmine\color` |
|
||||
| [pmmp/ErrorHandler](https://github.com/pmmp/ErrorHandler) | `pocketmine\errorhandler` |
|
||||
| [pmmp/Log](https://github.com/pmmp/Log) | `AttachableLogger`</br>`BufferedLogger`</br>`GlobalLogger`</br>`LogLevel`</br>`Logger`</br>`PrefixedLogger`</br>`SimpleLogger` |
|
||||
| [pmmp/Math](https://github.com/pmmp/Math) | `pocketmine\math` |
|
||||
| [pmmp/NBT](https://github.com/pmmp/NBT) | `pocketmine\nbt` |
|
||||
| [pmmp/RakLibIpc](https://github.com/pmmp/RakLibIpc) | `raklib\server\ipc` |
|
||||
| [pmmp/RakLib](https://github.com/pmmp/RakLib) | `raklib` |
|
||||
| [pmmp/Snooze](https://github.com/pmmp/Snooze) | `pocketmine\snooze` |
|
||||
| [pmmp/ext-chunkutils2](https://github.com/pmmp/ext-chunkutils2) | `pocketmine\world\format\LightArray`</br>`pocketmine\world\format\PalettedBlockArray`</br>`pocketmine\world\format\io\SubChunkConverter` |
|
||||
| [pmmp/ext-morton](https://github.com/pmmp/ext-morton) | `morton2d_decode`</br>`morton2d_encode`</br>`morton3d_decode`</br>`morton3d_encode` |
|
||||
| [pmmp/ext-libdeflate](https://github.com/pmmp/ext-libdeflate) | `libdeflate_deflate_compress`</br>`libdeflate_gzip_compress`</br>`libdeflate_zlib_compress` |
|
||||
|
||||
## Choosing a target branch
|
||||
PocketMine-MP has three primary branches of development.
|
||||
|
||||
|
@ -4,8 +4,8 @@
|
||||
<img src="https://github.com/pmmp/PocketMine-MP/blob/stable/.github/readme/pocketmine.png" alt="The PocketMine-MP logo" title="PocketMine" loading="eager" />
|
||||
<![endif]-->
|
||||
<picture>
|
||||
<source srcset="https://github.com/pmmp/PocketMine-MP/raw/stable/.github/readme/pocketmine-dark.png" media="(prefers-color-scheme: dark)">
|
||||
<img src="https://github.com/pmmp/PocketMine-MP/raw/stable/.github/readme/pocketmine.png" loading="eager" />
|
||||
<source srcset="https://raw.githubusercontent.com/pmmp/PocketMine-MP/stable/.github/readme/pocketmine-dark-rgb.gif" media="(prefers-color-scheme: dark)">
|
||||
<img src="https://raw.githubusercontent.com/pmmp/PocketMine-MP/stable/.github/readme/pocketmine-rgb.gif" loading="eager" />
|
||||
</picture>
|
||||
</a><br>
|
||||
<b>A highly customisable, open source server software for Minecraft: Bedrock Edition written in PHP</b>
|
||||
@ -26,7 +26,7 @@
|
||||
- [Docker image](https://github.com/pmmp/PocketMine-MP/pkgs/container/pocketmine-mp)
|
||||
- [Plugin repository](https://poggit.pmmp.io/plugins)
|
||||
|
||||
## Discussion/Help
|
||||
## Community & Support
|
||||
- [Forums](https://forums.pmmp.io/)
|
||||
- [Discord](https://discord.gg/bmSAZBG)
|
||||
- [StackOverflow](https://stackoverflow.com/tags/pocketmine)
|
||||
@ -35,7 +35,7 @@
|
||||
* [Building and running from source](BUILDING.md)
|
||||
* [Developer documentation](https://devdoc.pmmp.io) - General documentation for PocketMine-MP plugin developers
|
||||
* [Latest release API documentation](https://apidoc.pmmp.io) - Doxygen API documentation generated for each release
|
||||
* [Latest bleeding-edge API documentation](https://apidoc-dev.pmmp.io) - Doxygen API documentation generated weekly from `next-major` branch
|
||||
* [Latest bleeding-edge API documentation](https://apidoc-dev.pmmp.io) - Doxygen API documentation generated weekly from `major-next` branch
|
||||
* [DevTools](https://github.com/pmmp/DevTools/) - Development tools plugin for creating plugins
|
||||
* [ExamplePlugin](https://github.com/pmmp/ExamplePlugin/) - Example plugin demonstrating some basic API features
|
||||
* [Contributing Guidelines](CONTRIBUTING.md)
|
||||
|
@ -44,6 +44,7 @@ use function fwrite;
|
||||
use function is_string;
|
||||
use function ksort;
|
||||
use function mb_strtoupper;
|
||||
use function preg_replace;
|
||||
use function sort;
|
||||
use function strrpos;
|
||||
use function strtoupper;
|
||||
@ -138,7 +139,7 @@ function generateBlockStateNames(BlockPaletteReport $data) : void{
|
||||
|
||||
fwrite($output, generateClassHeader(BlockStateNames::class));
|
||||
foreach(Utils::stringifyKeys($data->seenStateValues) as $state => $values){
|
||||
$constName = mb_strtoupper($state, 'US-ASCII');
|
||||
$constName = mb_strtoupper(preg_replace("/^minecraft:/", "mc_", $state) ?? throw new AssumptionFailedError("This regex is not invalid"), 'US-ASCII');
|
||||
fwrite($output, "\tpublic const $constName = \"$state\";\n");
|
||||
}
|
||||
|
||||
@ -158,7 +159,7 @@ function generateBlockStringValues(BlockPaletteReport $data) : void{
|
||||
continue;
|
||||
}
|
||||
$anyWritten = true;
|
||||
$constName = mb_strtoupper($stateName . "_" . $value, 'US-ASCII');
|
||||
$constName = mb_strtoupper(preg_replace("/^minecraft:/", "mc_", $stateName) . "_" . $value, 'US-ASCII');
|
||||
fwrite($output, "\tpublic const $constName = \"$value\";\n");
|
||||
}
|
||||
if($anyWritten){
|
||||
|
@ -23,13 +23,13 @@ declare(strict_types=1);
|
||||
|
||||
require dirname(__DIR__) . '/vendor/autoload.php';
|
||||
|
||||
if(count($argv) !== 6){
|
||||
fwrite(STDERR, "required args: <git hash> <tag name> <github repo (owner/name)> <build number> <github actions run ID>\n");
|
||||
if(count($argv) !== 7){
|
||||
fwrite(STDERR, "required args: <git hash> <tag name> <github repo (owner/name)> <build number> <github actions run ID> <PHP binary download URL>\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
echo json_encode([
|
||||
"php_version" => sprintf("%d.%d", PHP_MAJOR_VERSION, PHP_MINOR_VERSION),
|
||||
"php_version" => sprintf("%d.%d", PHP_MAJOR_VERSION, PHP_MINOR_VERSION), //deprecated
|
||||
"base_version" => \pocketmine\VersionInfo::BASE_VERSION,
|
||||
"build" => (int) $argv[4],
|
||||
"is_dev" => \pocketmine\VersionInfo::IS_DEVELOPMENT_BUILD,
|
||||
@ -41,4 +41,5 @@ echo json_encode([
|
||||
"download_url" => "https://github.com/$argv[3]/releases/download/$argv[2]/PocketMine-MP.phar",
|
||||
"source_url" => "https://github.com/$argv[3]/tree/$argv[2]",
|
||||
"build_log_url" => "https://github.com/$argv[3]/actions/runs/$argv[5]",
|
||||
"php_download_url" => $argv[6],
|
||||
], JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_THROW_ON_ERROR) . "\n";
|
||||
|
@ -23,6 +23,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\build\generate_item_serializer_ids;
|
||||
|
||||
use pocketmine\data\bedrock\item\BlockItemIdMap;
|
||||
use pocketmine\errorhandler\ErrorToExceptionHandler;
|
||||
use pocketmine\network\mcpe\convert\ItemTypeDictionaryFromDataHelper;
|
||||
use pocketmine\network\mcpe\protocol\serializer\ItemTypeDictionary;
|
||||
@ -45,10 +46,10 @@ function constifyMcId(string $id) : string{
|
||||
return strtoupper(explode(":", $id, 2)[1]);
|
||||
}
|
||||
|
||||
function generateItemIds(ItemTypeDictionary $dictionary) : void{
|
||||
function generateItemIds(ItemTypeDictionary $dictionary, BlockItemIdMap $blockItemIdMap) : void{
|
||||
$ids = [];
|
||||
foreach($dictionary->getEntries() as $entry){
|
||||
if($entry->getNumericId() < 256){ //blockitems are serialized via BlockStateSerializer
|
||||
if($entry->getStringId() === "minecraft:air" || $blockItemIdMap->lookupBlockId($entry->getStringId()) !== null){ //blockitems are serialized via BlockStateSerializer
|
||||
continue;
|
||||
}
|
||||
$ids[$entry->getStringId()] = $entry->getStringId();
|
||||
@ -92,6 +93,7 @@ if($raw === false){
|
||||
}
|
||||
|
||||
$dictionary = ItemTypeDictionaryFromDataHelper::loadFromString($raw);
|
||||
generateItemIds($dictionary);
|
||||
$blockItemIdMap = BlockItemIdMap::getInstance();
|
||||
generateItemIds($dictionary, $blockItemIdMap);
|
||||
|
||||
echo "Done. Don't forget to run CS fixup after generating code.\n";
|
||||
|
120
build/generate-pocketmine-yml-property-consts.php
Normal file
120
build/generate-pocketmine-yml-property-consts.php
Normal file
@ -0,0 +1,120 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
*
|
||||
* ____ _ _ __ __ _ __ __ ____
|
||||
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
|
||||
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
|
||||
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
|
||||
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* @author PocketMine Team
|
||||
* @link http://www.pocketmine.net/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use pocketmine\utils\Filesystem;
|
||||
use pocketmine\utils\Utils;
|
||||
|
||||
require dirname(__DIR__) . '/vendor/autoload.php';
|
||||
|
||||
$defaultConfig = yaml_parse(Filesystem::fileGetContents(dirname(__DIR__) . '/resources/pocketmine.yml'));
|
||||
|
||||
if(!is_array($defaultConfig)){
|
||||
fwrite(STDERR, "Invalid default pocketmine.yml\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
$constants = [];
|
||||
|
||||
/**
|
||||
* @param mixed[] $properties
|
||||
* @param string[] $constants
|
||||
* @phpstan-param array<string, string> $constants
|
||||
* @phpstan-param-out array<string, string> $constants
|
||||
*/
|
||||
function collectProperties(string $prefix, array $properties, array &$constants) : void{
|
||||
foreach($properties as $propertyName => $property){
|
||||
$fullPropertyName = ($prefix !== "" ? $prefix . "." : "") . $propertyName;
|
||||
|
||||
$constName = str_replace([".", "-"], "_", strtoupper($fullPropertyName));
|
||||
$constants[$constName] = $fullPropertyName;
|
||||
|
||||
if(is_array($property)){
|
||||
collectProperties($fullPropertyName, $property, $constants);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
collectProperties("", $defaultConfig, $constants);
|
||||
ksort($constants, SORT_STRING);
|
||||
|
||||
$file = fopen(dirname(__DIR__) . '/src/YmlServerProperties.php', 'wb');
|
||||
if($file === false){
|
||||
fwrite(STDERR, "Failed to open output file\n");
|
||||
exit(1);
|
||||
}
|
||||
fwrite($file, "<?php\n");
|
||||
fwrite($file, <<<'HEADER'
|
||||
|
||||
/*
|
||||
*
|
||||
* ____ _ _ __ __ _ __ __ ____
|
||||
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
|
||||
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
|
||||
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
|
||||
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
|
||||
*
|
||||
* 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/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
HEADER
|
||||
);
|
||||
fwrite($file, "declare(strict_types=1);\n\n");
|
||||
fwrite($file, "namespace pocketmine;\n\n");
|
||||
|
||||
fwrite($file, <<<'DOC'
|
||||
/**
|
||||
* @internal
|
||||
* Constants for all properties available in pocketmine.yml.
|
||||
* This is generated by build/generate-pocketmine-yml-property-consts.php.
|
||||
* Do not edit this file manually.
|
||||
*/
|
||||
|
||||
DOC
|
||||
);
|
||||
fwrite($file, "final class YmlServerProperties{\n");
|
||||
fwrite($file, <<<'CONSTRUCTOR'
|
||||
|
||||
private function __construct(){
|
||||
//NOOP
|
||||
}
|
||||
|
||||
|
||||
CONSTRUCTOR
|
||||
);
|
||||
foreach(Utils::stringifyKeys($constants) as $constName => $propertyName){
|
||||
fwrite($file, "\tpublic const $constName = '$propertyName';\n");
|
||||
}
|
||||
fwrite($file, "}\n");
|
||||
|
||||
fclose($file);
|
||||
|
||||
echo "Done. Don't forget to run CS fixup after generating code.\n";
|
@ -27,11 +27,12 @@ use pocketmine\block\utils\BellAttachmentType;
|
||||
use pocketmine\block\utils\CopperOxidation;
|
||||
use pocketmine\block\utils\CoralType;
|
||||
use pocketmine\block\utils\DirtType;
|
||||
use pocketmine\block\utils\DripleafState;
|
||||
use pocketmine\block\utils\DyeColor;
|
||||
use pocketmine\block\utils\FroglightType;
|
||||
use pocketmine\block\utils\LeverFacing;
|
||||
use pocketmine\block\utils\MobHeadType;
|
||||
use pocketmine\block\utils\MushroomBlockType;
|
||||
use pocketmine\block\utils\SkullType;
|
||||
use pocketmine\block\utils\SlabType;
|
||||
use pocketmine\item\MedicineType;
|
||||
use pocketmine\item\PotionType;
|
||||
@ -145,12 +146,13 @@ $enumsUsed = [
|
||||
CopperOxidation::getAll(),
|
||||
CoralType::getAll(),
|
||||
DirtType::getAll(),
|
||||
DripleafState::getAll(),
|
||||
DyeColor::getAll(),
|
||||
FroglightType::getAll(),
|
||||
LeverFacing::getAll(),
|
||||
MedicineType::getAll(),
|
||||
MushroomBlockType::getAll(),
|
||||
SkullType::getAll(),
|
||||
MobHeadType::getAll(),
|
||||
SlabType::getAll(),
|
||||
SuspiciousStewType::getAll(),
|
||||
PotionType::getAll()
|
||||
|
Submodule build/php updated: 9d8807be82...a34e48e7da
@ -54,13 +54,13 @@ Released 11th April 2023.
|
||||
|
||||
### `pocketmine\timings`
|
||||
- The following API constants have been deprecated:
|
||||
- `Timings::INCLUDED_BY_OTHER_TIMINGS_PREFIX` - this is superseded by timings group support (see `Timings::GROUP_BREAKDOWN`)
|
||||
- `Timings::INCLUDED_BY_OTHER_TIMINGS_PREFIX` - this is superseded by timings group support (see `Timings::GROUP_BREAKDOWN`)
|
||||
- The following API constants have been added:
|
||||
- `Timings::GROUP_BREAKDOWN` - this group makes a timer appear in the `Minecraft - Breakdown` section of a timings report
|
||||
- `Timings::GROUP_BREAKDOWN` - this group makes a timer appear in the `Minecraft - Breakdown` section of a timings report
|
||||
- The following API methods have been added:
|
||||
- `public TimingsHandler->getGroup() : string` - returns the name of the table in which this timer will appear in a timings report
|
||||
- `public TimingsHandler->getGroup() : string` - returns the name of the table in which this timer will appear in a timings report
|
||||
- The following API methods have changed signatures:
|
||||
- `TimingsHandler->__construct()` now accepts an additional, optional `string $group` parameter, which defaults to `Minecraft`.
|
||||
- `TimingsHandler->__construct()` now accepts an additional, optional `string $group` parameter, which defaults to `Minecraft`.
|
||||
|
||||
### `pocketmine\world`
|
||||
#### Highlights
|
||||
@ -75,3 +75,37 @@ It works similarly to the `ChunkLoader` system, in that chunks will be ticked as
|
||||
- The following API methods have been added:
|
||||
- `public World->registerTickingChunk(ChunkTicker $ticker, int $chunkX, int $chunkZ) : void` - registers a chunk to be ticked by the given `ChunkTicker`
|
||||
- `public World->unregisterTickingChunk(ChunkTicker $ticker, int $chunkX, int $chunkZ) : void` - unregisters a chunk from being ticked by the given `ChunkTicker`
|
||||
|
||||
# 4.19.1
|
||||
Released 14th April 2023.
|
||||
|
||||
## Fixes
|
||||
- Fixed inventory rollbacks when spreading items in ender chests.
|
||||
- Fixed inventory rollbacks when shift-clicking to craft and the outputs would have been split across multiple inventory slots.
|
||||
- Fixed incorrect spawn terrain generation for newly created worlds.
|
||||
- Fixed `chunk-ticking.tick-radius` not disabling chunk ticking when set to `0`.
|
||||
- Fixed chunks not being ticked if they previously left a player's simulation distance without leaving their view distance.
|
||||
- Fixed height of collision boxes for Grass Path and Farmland blocks.
|
||||
|
||||
# 4.19.2
|
||||
Released 14th April 2023.
|
||||
|
||||
## Fixes
|
||||
- Fixed player timings duplication leading to extremely large timings reports when timings runs for a long time with many players.
|
||||
- Packet timings are now indexed by class FQN instead of packet ID. This prevents erroneous timer reuse on packet ID reuse (e.g. multi version servers).
|
||||
- Fixed entity timings being shared by different classes with the same short name. This led to incorrect timings being reported for some entities when custom entities were used.
|
||||
|
||||
# 4.19.3
|
||||
Released 21st April 2023.
|
||||
|
||||
## General
|
||||
- Error IDs for `Packet processing error` disconnects are now split into 4-character chunks to make them easier to type (since they can't be copied from the disconnection screen of a client).
|
||||
|
||||
## Fixes
|
||||
- Fixed entity-block intersections being checked twice per tick. Besides wasting CPU time, this may have caused unexpected behaviour during entity-block interactions with blocks like water or cacti.
|
||||
- Fixed performance issue in network inventory synchronization due item NBT being prepared twice.
|
||||
- Fixed `tools/simulate-chunk-selector.php` argument parsing being completely broken (weird behaviour of PHP `getopt()`).
|
||||
|
||||
## Internals
|
||||
- `TimingsHandler->stopTiming()` now logs an error message if a subtimer wasn't stopped, rather than throwing an exception.
|
||||
- Due to interactions between `try...finally` and unexpected errors, throwing exceptions made it difficult for plugin developers to debug errors in their plugins, since it obscured the original error.
|
||||
|
79
changelogs/4.20.md
Normal file
79
changelogs/4.20.md
Normal file
@ -0,0 +1,79 @@
|
||||
**For Minecraft: Bedrock Edition 1.19.80**
|
||||
|
||||
### Note about API versions
|
||||
Plugins which don't touch the `pocketmine\network\mcpe` namespace are compatible with any previous 4.x.y version will also run on these releases and do not need API bumps.
|
||||
Plugin developers should **only** update their required API to this version if you need the changes in this build.
|
||||
|
||||
**WARNING: If your plugin uses the `pocketmine\network\mcpe` namespace, you're not shielded by API change constraints.**
|
||||
Consider using the `mcpe-protocol` directive in `plugin.yml` as a constraint if you're using packets directly.
|
||||
|
||||
### Interim releases
|
||||
If you're upgrading from 4.17.x directly to 4.20.x, please also read the following changelogs, as the interim releases contain important changes:
|
||||
|
||||
- [4.18.0](https://github.com/pmmp/PocketMine-MP/blob/4.20.0/changelogs/4.18.md#4180) - major performance improvements, internal network changes, minor API additions
|
||||
- [4.19.0](https://github.com/pmmp/PocketMine-MP/blob/4.20.0/changelogs/4.19.md#4190) - minor performance improvements, improved timings system, minor API additions
|
||||
|
||||
# 4.20.0
|
||||
Released 26th April 2023.
|
||||
|
||||
## General
|
||||
- Added support for Minecraft: Bedrock Edition 1.19.80.
|
||||
- Removed support for older versions.
|
||||
|
||||
## Fixes
|
||||
- Fixed packet processing error when attempting to use a stonecutter.
|
||||
- Fixed armor slots containing ghost items when cancelling right-click to equip armor.
|
||||
- Fixed crash in `HandlerList->getListenersByPriority()` when no listeners are registered at the given priority.
|
||||
|
||||
## API
|
||||
### `pocketmine\block`
|
||||
- The following API methods have been added:
|
||||
- `public BaseSign->getEditorEntityRuntimeId() : int` - returns the entity runtime ID of the player currently editing this sign, or `null` if none
|
||||
- `public BaseSign->setEditorEntityRuntimeId(?int $editorEntityRuntimeId) : $this` - sets the entity runtime ID of the player currently editing this sign
|
||||
|
||||
### `pocketmine\player`
|
||||
- The following API methods have been added:
|
||||
- `public Player->openSignEditor(Vector3 $position) : void` - opens the client-side sign editor GUI for the given position
|
||||
|
||||
# 4.20.1
|
||||
Released 27th April 2023.
|
||||
|
||||
## Fixes
|
||||
- Fixed server crash when firing a bow while holding arrows in the offhand slot.
|
||||
|
||||
## Internals
|
||||
- `ItemStackContainerIdTranslator::translate()` now requires an additional `int $slotId` parameter and returns `array{int, int}` (translated window ID, translated slot ID) to be used with `InventoryManager->locateWindowAndSlot()`.
|
||||
- `InventoryManager->locateWindowAndSlot()` now checks if the translated slot actually exists in the requested inventory, and returns `null` if not. Previously, it would return potentially invalid slot IDs without checking them, potentially leading to crashes.
|
||||
|
||||
# 4.20.2
|
||||
Released 4th May 2023.
|
||||
|
||||
## Fixes
|
||||
- Fixed all types of wooden logs appearing as oak in the inventory.
|
||||
- Fixed a performance issue in `BaseInventory->canAddItem()` (missing `continue` causing useless logic to run).
|
||||
|
||||
# 4.20.3
|
||||
Released 6th May 2023.
|
||||
|
||||
## Improvements
|
||||
- Reduced memory usage of `RuntimeBlockMapping` from 25 MB to 9 MB. Since every thread has its own copy of the block map, this saves a substantial amount of memory.
|
||||
|
||||
## Fixes
|
||||
- Fixed players falling through blocks in spectator mode.
|
||||
- Fixed timings reports getting bloated by prolific usage of `PluginManager->registerEvent()`.
|
||||
- This was caused by creating a new timings handler for each call, regardless of whether a timer already existed for the given event and callback.
|
||||
- Fixed `Full Server Tick` and other records being missing from timings reports.
|
||||
- This was caused by timings handler depth not getting reset when timings was disabled and later re-enabled.
|
||||
|
||||
# 4.20.4
|
||||
Released 6th May 2023.
|
||||
|
||||
## Fixes
|
||||
- Fixed players being forced into flight mode in every game mode.
|
||||
- Moral of the story: do not assume anything in Mojang internals does what its name suggests...
|
||||
|
||||
# 4.20.5
|
||||
Released 30th May 2023.
|
||||
|
||||
## Fixes
|
||||
- Fixed server crash due to a bug in upstream dependency [`netresearch/jsonmapper`](https://github.com/cweiske/JsonMapper).
|
77
changelogs/4.21.md
Normal file
77
changelogs/4.21.md
Normal file
@ -0,0 +1,77 @@
|
||||
**For Minecraft: Bedrock Edition 1.19.80**
|
||||
|
||||
### Note about API versions
|
||||
Plugins which don't touch the `pocketmine\network\mcpe` namespace, and don't use reflection or any internal methods,
|
||||
will also run on these releases and do not need API bumps.
|
||||
Plugin developers should **only** update their required API to this version if you need the changes in this build.
|
||||
|
||||
**WARNING: If your plugin uses the `pocketmine\network\mcpe` namespace, you're not shielded by API change constraints.**
|
||||
Consider using the `mcpe-protocol` directive in `plugin.yml` as a constraint if you're using packets directly.
|
||||
|
||||
# 4.21.0
|
||||
Released 17th May 2023.
|
||||
|
||||
## General
|
||||
- PHP 8.1 is now required. Most plugins should run without changes, but some might need to be updated due to language-level deprecations.
|
||||
- Ticking chunk count is now shown separately from loaded chunk count in the `/status` command, providing useful performance information.
|
||||
- Further improved performance of ticking chunk selection.
|
||||
- Improved performance of some inventory functions.
|
||||
- Reduced server memory footprint in most cases by ~9 MB per thread.
|
||||
- Due to large overhead, async network compression is now only used for packets larger than 10 KB by default.
|
||||
|
||||
## Configuration
|
||||
- Added the following new `pocketmine.yml` configuration options:
|
||||
- `network.async-compression-threshold` - minimum size of packet which will be compressed using `AsyncTask`
|
||||
- Default is 10 KB, which means that very few packets will use async compression in practice. This is because the overhead of compressing async is currently so high that it's not worth it for smaller packets.
|
||||
|
||||
## Timings
|
||||
- Timings reports no longer include the unused metadata fields `Entities` and `LivingEntities`.
|
||||
- Timings reports now correctly calculate the peak time of a timer.
|
||||
- Previously it was incorrectly recorded as the longest time spent in a single tick, rather than the longest time spent in a single activation.
|
||||
- Timings report version has been bumped to `2` to reflect this change.
|
||||
- All world-specific timers now have generic aggregate timings, making it much easier to locate performance patterns across all worlds.
|
||||
|
||||
## Gameplay
|
||||
- Players in spectator mode are no longer able to pick blocks, and now have finite resources similar to survival mode.
|
||||
|
||||
## API
|
||||
### `pocketmine\world`
|
||||
- The following API methods have been added:
|
||||
- `public World->getTickingChunks() : list<int>` - returns a list of chunk position hashes (a la `World::chunkHash()`) which are currently valid for random ticking
|
||||
|
||||
### `pocketmine\inventory`
|
||||
- The following API methods have been added:
|
||||
- `protected BaseInventory->getMatchingItemCount(int $slot, Item $test, bool $checkDamage, bool $checkTags) : int` - returns the number of items in the given stack if the content of the slot matches the test item, or zero otherwise
|
||||
- This should be overridden if directly extending `BaseInventory` to provide a performance-optimised version. A slow default implementation is provided, but it will be removed in the future.
|
||||
|
||||
## Internals
|
||||
### Entity
|
||||
- Unused `NameTag` tag is no longer saved for `Human` entities.
|
||||
|
||||
### Inventory
|
||||
- `BaseInventory` now uses a new internal method `getMatchingItemCount()` to locate items in the inventory without useless cloning. This improves performance of various API methods, such as `addItem()`, `contains()`, and more.
|
||||
- Specialization of `Inventory->isSlotEmpty()` in `BaseInventory` subclasses has been added to improve performance of some API methods.
|
||||
|
||||
### Network
|
||||
- `RuntimeBlockMapping` no longer keeps all block palette NBT data in memory.
|
||||
- This significantly reduces server idle memory footprint.
|
||||
- For multi-version implementations, this will have a significant impact on memory usage, since a different block palette is often required to support each version.
|
||||
- NBT will be lazy-loaded into memory and cached if `getBedrockKnownStates()` is called. However, this is not used by PocketMine-MP under normal circumstances.
|
||||
- Removed unnecessary usage of `Utils::validateCallableSignature()` from some internal network pathways, improving performance.
|
||||
|
||||
### Scheduler
|
||||
- `AsyncPool` no longer double-checks progress updates on completed tasks.
|
||||
|
||||
### World
|
||||
- Ticking chunks are now tracked in `World->validTickingChunks` and `World->recheckTickingChunks`.
|
||||
- This allows avoiding rechecking every ticking chunk for validity during ticking chunk selection, improving performance.
|
||||
- In some cases, this allows bypassing chunk selection entirely, reducing selection cost to zero.
|
||||
- Registered but ineligible ticking chunks are no longer rechecked every tick.
|
||||
- This was causing wasted cycles during async worker backlog.
|
||||
- The internal system must call `markTickingChunkForRecheck()` whenever a ticking chunk's eligibility for ticking has potentially changed, rather than just when it has changed from a yes to a no.
|
||||
|
||||
# 4.21.1
|
||||
Released 30th May 2023.
|
||||
|
||||
## Fixes
|
||||
- Fixed server crash due to a bug in upstream dependency [`netresearch/jsonmapper`](https://github.com/cweiske/JsonMapper).
|
58
changelogs/4.22.md
Normal file
58
changelogs/4.22.md
Normal file
@ -0,0 +1,58 @@
|
||||
# 4.22.0
|
||||
Released 7th June 2023.
|
||||
|
||||
**For Minecraft: Bedrock Edition 1.20.0**
|
||||
|
||||
This is a support release for Minecraft: Bedrock Edition 1.20.0.
|
||||
|
||||
**Plugin compatibility:** Plugins for previous 4.x versions will run unchanged on this release, unless they use internal APIs, reflection, or packages like the `pocketmine\network\mcpe` namespace.
|
||||
Do not update plugin minimum API versions unless you need new features added in this release.
|
||||
|
||||
**WARNING: If your plugin uses the `pocketmine\network\mcpe` namespace, you're not shielded by API change constraints.**
|
||||
Consider using the `mcpe-protocol` directive in `plugin.yml` as a constraint if you're using packets directly.
|
||||
|
||||
## Interim releases
|
||||
If you're upgrading from 4.20.x directly to 4.22.x, please also read the following changelogs, as the interim releases contain important changes:
|
||||
- [4.21.0](https://github.com/pmmp/PocketMine-MP/blob/4.22.0/changelogs/4.21.md#4210) - PHP 8.1 minimum version, minor performance improvements
|
||||
|
||||
## General
|
||||
- Added support for Minecraft: Bedrock Edition 1.20.0.
|
||||
- Removed support for older versions.
|
||||
|
||||
## Fixes
|
||||
- Removed deprecated `ReflectionProperty::setAccessible()` calls.
|
||||
- Fixed jukebox music not stopping when destroyed by an explosion.
|
||||
|
||||
# 4.22.1
|
||||
Released 9th June 2023.
|
||||
|
||||
## Fixes
|
||||
- Replaced workaround for an old teleporting client bug:
|
||||
- This workaround broke due to an additional client bug introduced by 1.20, causing players to become frozen to observers when teleported.
|
||||
- The original client bug has still not been fixed, meaning a new workaround was needed, but no perfect solution could be found.
|
||||
- The new workaround involves broadcasting teleport movements as regular movements, which causes unwanted interpolation between the old and new positions, but otherwise works correctly. This solution is not ideal, but it is the best we can do for now.
|
||||
- See issues [#4394](https://github.com/pmmp/PocketMine-MP/issues/4394) and [#5810](https://github.com/pmmp/PocketMine-MP/issues/5810) for more details.
|
||||
|
||||
# 4.22.2
|
||||
Released 1st July 2023.
|
||||
|
||||
## Changes
|
||||
- Added obsoletion warnings to the server log at the end of the startup sequence.
|
||||
|
||||
## Fixes
|
||||
- Fixed players being disconnected en masse with "Not authenticated" messages.
|
||||
- This occurred due to a check intended to disable the old authentication key after July 1st.
|
||||
- We expected that the new key would have been deployed by Mojang by now, but it seems like that has not yet happened.
|
||||
- Due to the lack of a hard date for the key changeover, we guessed that July 1st would be a safe bet, but this appears to have backfired.
|
||||
- This version will accept both old and new keys indefinitely.
|
||||
- A security release will be published to remove the old key after the transition occurs.
|
||||
|
||||
# 4.22.3
|
||||
Released 11th July 2023.
|
||||
|
||||
## Fixes
|
||||
- Fixed mishandling of NBT leading to a server crash when editing signs.
|
||||
- Fixed an edge case crash that could occur in `AsyncTask->__destruct()` when thread-local storage referenced other `AsyncTask` objects.
|
||||
|
||||
## Internals
|
||||
- Added a concurrency lock to prevent the `update-updater-api` GitHub Action from running for multiple releases at the same time (which would have caused one of them to fail due to git conflicts).
|
68
changelogs/4.23.md
Normal file
68
changelogs/4.23.md
Normal file
@ -0,0 +1,68 @@
|
||||
# 4.23.0
|
||||
Released 12th July 2023.
|
||||
|
||||
**For Minecraft: Bedrock Edition 1.20.10**
|
||||
|
||||
This is a support release for Minecraft: Bedrock Edition 1.20.10.
|
||||
|
||||
**Plugin compatibility:** Plugins for previous 4.x versions will run unchanged on this release, unless they use internal APIs, reflection, or packages like the `pocketmine\network\mcpe` namespace.
|
||||
Do not update plugin minimum API versions unless you need new features added in this release.
|
||||
|
||||
**WARNING: If your plugin uses the `pocketmine\network\mcpe` namespace, you're not shielded by API change constraints.**
|
||||
Consider using the `mcpe-protocol` directive in `plugin.yml` as a constraint if you're using packets directly.
|
||||
|
||||
## General
|
||||
- Added support for Minecraft: Bedrock Edition 1.20.10.
|
||||
- Removed support for older versions.
|
||||
|
||||
## Fixes
|
||||
- Fixed Docker image build failure due to outdated `build/php` submodule.
|
||||
|
||||
# 4.23.1
|
||||
Released 14th July 2023.
|
||||
|
||||
## Fixes
|
||||
- Hardened validation of JWT signing keys in `LoginPacket`.
|
||||
- Fixed server crash due to a bug in upstream dependency [`netresearch/jsonmapper`](https://github.com/cweiske/JsonMapper).
|
||||
|
||||
# 4.23.2
|
||||
Released 18th July 2023.
|
||||
|
||||
## Fixes
|
||||
- Fixed login errors due to a new `sandboxId` field appearing in the Xbox Live authentication data in `LoginPacket`. All clients, regardless of version, are affected by this change.
|
||||
|
||||
# 4.23.3
|
||||
Released 24th July 2023.
|
||||
|
||||
## Documentation
|
||||
- Fixed typo in `ChunkSelector::selectChunks()` documentation.
|
||||
|
||||
## Fixes
|
||||
- Fixed the server not stopping properly during crash conditions on *nix platforms.
|
||||
- Fixed `HORSE_EQUIP` and `SMITHING_TABLE_TEMPLATE` container UI types not being handled by `ItemStackContainerIdTranslator`. This bug prevented plugins from implementing missing inventory types.
|
||||
- Player emotes no longer broadcast messages to other players. This was unintended behaviour caused by a client-side behavioural change.
|
||||
- Shulker boxes no longer support the placement of torches or other similar blocks.
|
||||
- Fire can now be placed on upper slabs and the top of upside-down stairs.
|
||||
|
||||
# 4.23.4
|
||||
Released 1st August 2023.
|
||||
|
||||
## Fixes
|
||||
- Fixed exponentially increasing lag when many hundreds of non-mergeable dropped items occupied the same space. This disproportionately affected SkyBlock servers due to large cactus farms using water to collect items together.
|
||||
|
||||
# 4.23.5
|
||||
Released 9th August 2023.
|
||||
|
||||
## General
|
||||
- Updated translation data to [pmmp/Language 2.19.6](https://github.com/pmmp/Language/releases/tag/2.19.6).
|
||||
|
||||
## Fixes
|
||||
- Fixed `PluginBase->saveResource()` leaking file resources when the data file already exists in the plugin's data folder. This bug existed since 2014 and was only discovered recently.
|
||||
- Fixed coral blocks becoming dead after calling `getDropsForCompatibleTool()` on them.
|
||||
- Fixed `BlockDeathEvent->getOldState()` returning a block which is already dead.
|
||||
|
||||
# 4.23.6
|
||||
Released 21st August 2023.
|
||||
|
||||
## Fixes
|
||||
- Added a workaround for armor and other inventories not working correctly after inventory sync. This is caused by a client bug.
|
17
changelogs/4.24.md
Normal file
17
changelogs/4.24.md
Normal file
@ -0,0 +1,17 @@
|
||||
# 4.24.0
|
||||
Released 20th September 2023.
|
||||
|
||||
**For Minecraft: Bedrock Edition 1.20.30**
|
||||
|
||||
This is a support release for Minecraft: Bedrock Edition 1.20.30.
|
||||
|
||||
**Plugin compatibility:** Plugins for previous 4.x versions will run unchanged on this release, unless they use internal APIs, reflection, or packages like the `pocketmine\network\mcpe` namespace.
|
||||
Do not update plugin minimum API versions unless you need new features added in this release.
|
||||
|
||||
**WARNING: If your plugin uses the `pocketmine\network\mcpe` namespace, you're not shielded by API change constraints.**
|
||||
Consider using the `mcpe-protocol` directive in `plugin.yml` as a constraint if you're using packets directly.
|
||||
|
||||
## General
|
||||
- Added support for Minecraft: Bedrock Edition 1.20.30.
|
||||
- Removed support for older versions.
|
||||
- Updated 4.x obsoletion message.
|
@ -93,3 +93,123 @@ Released 11th April 2023.
|
||||
|
||||
## Internals
|
||||
- Make use of `Item->canStackWith()` instead of `Item->equals()` wherever possible, to make the code more readable.
|
||||
|
||||
# 5.0.0-BETA3
|
||||
Released 17th May 2023.
|
||||
|
||||
**This release includes changes from the following releases:**
|
||||
- [4.19.1](https://github.com/pmmp/PocketMine-MP/blob/5.0.0-BETA3/changelogs/4.19.md#4191)
|
||||
- [4.19.2](https://github.com/pmmp/PocketMine-MP/blob/5.0.0-BETA3/changelogs/4.19.md#4192)
|
||||
- [4.19.3](https://github.com/pmmp/PocketMine-MP/blob/5.0.0-BETA3/changelogs/4.19.md#4193)
|
||||
- [4.20.0](https://github.com/pmmp/PocketMine-MP/blob/5.0.0-BETA3/changelogs/4.20.md#4200)
|
||||
- [4.20.1](https://github.com/pmmp/PocketMine-MP/blob/5.0.0-BETA3/changelogs/4.20.md#4201)
|
||||
- [4.20.2](https://github.com/pmmp/PocketMine-MP/blob/5.0.0-BETA3/changelogs/4.20.md#4202)
|
||||
- [4.20.3](https://github.com/pmmp/PocketMine-MP/blob/5.0.0-BETA3/changelogs/4.20.md#4203)
|
||||
- [4.20.4](https://github.com/pmmp/PocketMine-MP/blob/5.0.0-BETA3/changelogs/4.20.md#4204)
|
||||
- [4.21.0](https://github.com/pmmp/PocketMine-MP/blob/5.0.0-BETA3/changelogs/4.21.md#4210)
|
||||
|
||||
## General
|
||||
- Improved light propagation performance by 10-15%.
|
||||
|
||||
## Fixes
|
||||
- Fixed late initialization of coral type in `BaseCoral`.
|
||||
|
||||
## Tools
|
||||
- `tools/generate-blockstate-upgrade-schema.php` has the following improvements:
|
||||
- Now generates better errors when inconsistent blockstate versions are encountered.
|
||||
- Now generates more stable outputs when re-run on the same input.
|
||||
- Output now uses `copiedState` in `remappedStates` where possible. This significantly reduces the size of the output for blocks with partially flattened states.
|
||||
|
||||
## Gameplay
|
||||
- The following blocks have been added:
|
||||
- Cave Vines
|
||||
- The following items have been added:
|
||||
- Glow Berries
|
||||
- Mangrove Boat (incomplete)
|
||||
- Fixed flower pots being able to be placed inside flower pots.
|
||||
|
||||
## API
|
||||
### `pocketmine\block`
|
||||
- The following API methods have been renamed:
|
||||
- `Block->isSameType()` -> `Block->hasSameTypeId()`
|
||||
- `Block->describeType()` -> `Block->describeBlockItemState()`
|
||||
- `Block->describeState()` -> `Block->describeBlockOnlyState()`
|
||||
- The following API methods have been removed:
|
||||
- `Block->getRequiredTypeDataBits()`
|
||||
- `Block->getRequiredStateDataBits()`
|
||||
- The following API methods have been added:
|
||||
- `public Block->generateStatePermutations() : \Generator<int, Block, void, void>` - yields all possible states this block type can be in (used for `RuntimeBlockStateRegistry`)
|
||||
- The following API methods have signature changes:
|
||||
- `Sapling::__construct()` now accepts `SaplingType $saplingType` instead of `TreeType $treeType`
|
||||
- `RuntimeBlockStateRegistry->register()` no longer accepts an `$override` parameter.
|
||||
- The following classes have been added:
|
||||
- `utils\SaplingType` - enum of all sapling types
|
||||
- `utils\TreeType` has been moved to `pocketmine\world\generator\object` namespace.
|
||||
|
||||
### `pocketmine\data\bedrock\item\upgrade`
|
||||
- The following API methods have been added:
|
||||
- `public ItemIdMetaUpgrader->getSchemas() : array<int, BlockStateUpgradeSchema>` - returns a list of loaded schemas indexed by schema ID
|
||||
- `public ItemIdMetaUpgradeSchema->getRenamedIds() : array<string, string>` - returns a map of old ID -> new ID
|
||||
- `public ItemIdMetaUpgradeSchema->getRemappedMetas() : array<string, array<int, string>>` - returns a map of old ID -> list of old meta -> new ID
|
||||
|
||||
### `pocketmine\event\block`
|
||||
- The following API methods have been added:
|
||||
- `public BlockGrowEvent->getPlayer() : ?Player` - returns the player that triggered the block growth, or `null` if it was not triggered by a player
|
||||
- The following API methods have signature changes:
|
||||
- `BlockGrowEvent::__construct()` now accepts an optional `?Player $player` parameter.
|
||||
|
||||
### `pocketmine\event\world`
|
||||
- The following classes have been added:
|
||||
- `WorldDisplayNameChangeEvent` - called when a world's display name is changed
|
||||
|
||||
### `pocketmine\item`
|
||||
- `Boat` now uses a new `BoatType` enum instead of `TreeType`. This is because not all tree types have an associated boat type, and some boat types are not made from tree materials (e.g. bamboo raft).
|
||||
- The following API methods have been removed:
|
||||
- `Boat->getWoodType()`
|
||||
- The following API methods have been added:
|
||||
- `public Boat->getType() : BoatType`
|
||||
- `public Item->getStateId() : int` - returns an encoded ID containing the item type ID and encoded item state
|
||||
- The following API methods have been renamed:
|
||||
- `Item->describeType()` -> `Item->describeState()`
|
||||
- The following classes have been added:
|
||||
- `BoatType` - enum of all boat types
|
||||
- The following API methods have signature changes:
|
||||
- `BoatType::__construct()` now accepts `BoatType $boatType` instead of `TreeType $woodType`.
|
||||
|
||||
### `pocketmine\world`
|
||||
- The following API methods have been added:
|
||||
- `public World->setDisplayName(string $name) : void`
|
||||
|
||||
### `pocketmine\world\format`
|
||||
- Fixed outdated documentation for various methods of `Chunk`.
|
||||
|
||||
### `pocketmine\world\format\io\data`
|
||||
- The following API interface requirements have been added:
|
||||
- `public WorldData->setDisplayName(string $value) : void`
|
||||
|
||||
## Internals
|
||||
- Reduced global usage in world providers. In the future, we want to have blockstate deserializers etc. injected rather than being global singletons.
|
||||
- `BlockStateUpgrader` now always updates the blockstate version, even if no changes were made. PM itself doesn't require this, but it's useful for tools to know whether to upgrade the data again (e.g. in testing scenarios).
|
||||
- `BlockStateDictionary` memory usage is now reduced from 9 MB to 3.5 MB using various techniques, including string reuse and binary-encoded states.
|
||||
- `RuntimeBlockMapping` has been renamed to `BlockTranslator`.
|
||||
- Singletons in the `pocketmine\network\mcpe\convert` package have been centralized under `TypeConverter`. In the future, this will be injected where needed, allowing different converters to be used for different sessions (useful for multiversion).
|
||||
- Overriding of serializers and deserializers of items and blocks is now consistently disallowed. Due to the lack of a good reason to allow overriding built-in blocks and items, this is no longer allowed.
|
||||
|
||||
# 5.0.0-BETA4
|
||||
Released 23rd May 2023.
|
||||
|
||||
## General
|
||||
- [`ext-pmmpthread` version 6.0.0](https://github.com/pmmp/ext-pmmpthread/releases/6.0.0) (renamed from `ext-pthreads`) is now required. This version has API changes compared to pthreads v5. Please read the linked changelog for details.
|
||||
- [`pocketmine/snooze` version 0.5.0](https://github.com/pmmp/Snooze/releases/0.5.0) is now required.
|
||||
- `pocketmine/classloader` and `pocketmine/log-pthreads` packages have been removed. The relevant classes from these packages are now included in-house in the `pocketmine/thread` namespace.
|
||||
- `BaseClassLoader` is replaced with `pocketmine\thread\ThreadSafeClassLoader`
|
||||
- `ThreadedLogger` is replaced by `pocketmine\thread\ThreadSafeLogger`
|
||||
- `AttachableThreadedLogger` is replaced by `pocketmine\thread\AttachableThreadSafeLogger`
|
||||
- `ThreadedLoggerAttachment` is replaced by `pocketmine\thread\ThreadSafeLoggerAttachment`
|
||||
|
||||
## Fixes
|
||||
- Fixed crash on unknown blocks due to late initialization of properties in `UnknownBlock`.
|
||||
|
||||
## API changes
|
||||
### `pocketmine\scheduler`
|
||||
- `AsyncTask->setResult()` now works with thread-safe objects. This was previously not possible due to limitations in the `pthreads` extension.
|
||||
|
791
changelogs/5.0.md
Normal file
791
changelogs/5.0.md
Normal file
@ -0,0 +1,791 @@
|
||||
# 5.0.0
|
||||
Released 1st June 2023.
|
||||
|
||||
**For Minecraft: Bedrock Edition 1.19.80**
|
||||
|
||||
5.0.0 is a major feature update to PocketMine-MP, including support for Bedrock worlds from 1.13 onwards, a large array of new blocks and items, and various changes to the plugin API.
|
||||
|
||||
It is **not** compatible with plugins written for 4.x.y, and plugins may require code changes to work with it.
|
||||
|
||||
**As this changelog is quite large, its accuracy and completeness cannot be guaranteed.**
|
||||
Make sure you're looking at the [latest revision](https://github.com/pmmp/PocketMine-MP/blob/stable/changelogs/5.0.md), as it may be amended after release.
|
||||
|
||||
## Core
|
||||
- Worlds are now saved according to the Bedrock 1.19.80 format.
|
||||
- Worlds generated by Bedrock from 1.13.0 and up are now supported (previously, only worlds up to 1.12 were supported).
|
||||
- `/particle` now accepts strings for particle data instead of integers.
|
||||
- `/particle` no longer accepts integers for block or item IDs.
|
||||
- The usage of `blockcrack`, `iconcrack` and `blockdust` particle types in `/particle` now follows the same pattern as
|
||||
other particle types, with the data for each being passed in the `data` parameter instead of being baked into the
|
||||
particle name.
|
||||
- Commands are now enabled by default in worlds exported from PocketMine-MP to Bedrock.
|
||||
|
||||
## Build system
|
||||
- `build/generate-block-serializer-consts.php` has been added to generate `BlockTypeNames`, `BlockStateNames` and `BlockStateStringValues` in the `pocketmine\data\bedrock\block` package.
|
||||
- `build/generate-item-type-names.php` has been added to generate `ItemTypeNames` in the `pocketmine\data\bedrock\item` package.
|
||||
- `build/generate-runtime-enum-serializers.php` has been added to generate `RuntimeEnumSerializer`, `RuntimeEnumSerializerTrait`, and `RuntimeEnumSizeCalculatorTrait` in `pocketmine\data\runtime` package.
|
||||
|
||||
## Localization
|
||||
- Localized disconnect messages are now used in the following cases:
|
||||
- Server full
|
||||
- Player not on the server whitelist
|
||||
- Player on the server ban list
|
||||
- Invalid skin
|
||||
- Invalid username
|
||||
- Kicked using `/kick`
|
||||
- Banned using `/ban`
|
||||
- Failure to find a safe spawn position
|
||||
- Session open, session close and session player name discovery messages are now localized.
|
||||
- All permissions now have localized descriptions. These are not currently used by PocketMine-MP, but may be useful for plugins.
|
||||
|
||||
## Performance
|
||||
- Improved performance of dropping block inventory contents when the block is destroyed.
|
||||
- Improved light propagation performance by 10-15%.
|
||||
- [`ext-pmmpthread` version 6.0.0](https://github.com/pmmp/ext-pmmpthread/releases/tag/6.0.0) is now used, featuring significant performance improvements for thread-safe objects and various threading use-cases.
|
||||
|
||||
## Tools
|
||||
- The following tool scripts have been added:
|
||||
- `generate-block-palette-spec.php` - generates a JSON file with a readable overview of blocks, their state
|
||||
properties, and their possible values
|
||||
- `generate-blockstate-upgrade-schema.php` - generates JSON blockstate upgrade schemas like those found
|
||||
in [BedrockBlockUpgradeSchema](https://github.com/pmmp/BedrockBlockUpgradeSchema)
|
||||
- `generate-item-upgrade-schema.php` - generates JSON item ID/meta upgrade schemas like those found
|
||||
in [BedrockItemUpgradeSchema](https://github.com/pmmp/BedrockItemUpgradeSchema)
|
||||
- `generate-bedrock-data-from-packets.php` - generates various files for [BedrockData](https://github.com/pmmp/BedrockData)
|
||||
- This script accepts a txt file containing base64-encoded packet dumps.
|
||||
- This script has been in use for several years, but has only now been open-sourced.
|
||||
- It's used to generate data such as crafting recipes, creative inventory data, and various other blobs of data needed to support the current version of Minecraft: Bedrock Edition.
|
||||
|
||||
## Gameplay
|
||||
### Blocks
|
||||
- Added the following new blocks:
|
||||
- Amethyst Block
|
||||
- Ancient Debris
|
||||
- Azalea Leaves
|
||||
- Basalt
|
||||
- Blackstone blocks, slabs, stairs, and walls
|
||||
- Cakes with Candle & Dyed Candle
|
||||
- Calcite
|
||||
- Candle & Dyed Candle
|
||||
- Cartography Table (not currently usable due to maps not being implemented)
|
||||
- Cauldron
|
||||
- Cave Vines
|
||||
- Chain
|
||||
- Chiseled Deepslate
|
||||
- Chiseled Nether Bricks
|
||||
- Chiseled Polished Blackstone
|
||||
- Chorus Flower
|
||||
- Chorus Plant
|
||||
- Cobbled Deepslate blocks, slabs, stairs, and walls
|
||||
- Copper Ore
|
||||
- Copper block (random oxidation not yet implemented)
|
||||
- Crached Deepslate Tiles
|
||||
- Cracked Deepslate Bricks
|
||||
- Cracked Nether Bricks
|
||||
- Cracked Polished Blackstone Bricks
|
||||
- Crimson buttons, doors, fences, fence gates, hyphae, planks, pressure plates, signs, slabs, stairs, stems, and trapdoors
|
||||
- Crying Obsidian
|
||||
- Cut Copper block, stairs and slabs (random oxidation not yet implemented)
|
||||
- Deepslate
|
||||
- Deepslate Bricks blocks, slabs, stairs, and walls
|
||||
- Deepslate Ores (coal, copper, diamond, emerald, gold, iron, lapis lazuli, redstone)
|
||||
- Deepslate Tiles blocks, slabs, stairs, and walls
|
||||
- Flowering Azalea Leaves
|
||||
- Froglight (pearlescent, verdant, ochre)
|
||||
- Gilded Blackstone
|
||||
- Glow Item Frame
|
||||
- Hanging Roots
|
||||
- Honeycomb Block
|
||||
- Light Block
|
||||
- Lightning Rod
|
||||
- Mangrove Leaves
|
||||
- Mangrove Roots
|
||||
- Mangrove buttons, doors, fences, fence gates, logs, planks, pressure plates, signs, slabs, stairs, trapdoors, and wood
|
||||
- Mud Bricks blocks, slabs, stairs, and walls
|
||||
- Muddy Mangrove Roots
|
||||
- Nether Gold Ore
|
||||
- Netherite Block
|
||||
- Polished Basalt
|
||||
- Polished Blackstone Bricks blocks, slabs, stairs, and walls
|
||||
- Polished Blackstone blocks, buttons, pressure plates, slabs, stairs, and walls
|
||||
- Polished Deepslate blocks, slabs, stairs, and walls
|
||||
- Quartz Bricks
|
||||
- Reinforced Deepslate
|
||||
- Rooted Dirt
|
||||
- Sculk
|
||||
- Shroomlight
|
||||
- Smithing Table
|
||||
- Smooth Basalt
|
||||
- Soul Fire
|
||||
- Soul Lantern
|
||||
- Soul Soil
|
||||
- Soul Torch
|
||||
- Spore Blossom
|
||||
- Tinted Glass
|
||||
- Tuff
|
||||
- Twisting Vines
|
||||
- Warped Wart Block
|
||||
- Warped buttons, doors, fences, fence gates, hyphae, planks, pressure plates, signs, slabs, stairs, stems, and trapdoors
|
||||
- Weeping Vines
|
||||
- Wither Rose
|
||||
- Added support for basalt generators
|
||||
- Added support for dyeing sign text and making it glow.
|
||||
- All-sided logs ("wood", for want of a better name) can now be placed in X, Y, and Z orientations.
|
||||
- Coral and coral fans now behave correctly when placed out of water (they no longer immediately die).
|
||||
- Fixed dead bush being able to be placed on some invalid blocks (e.g. stone).
|
||||
- Fixed lava setting entities on fire for an incorrect duration (Java vs Bedrock inconsistency).
|
||||
- Fixed sugarcane not being able to be placed on some blocks.
|
||||
- Iron Ore and Gold Ore now drop Raw Iron and Raw Gold respectively, instead of the ore blocks.
|
||||
- Item frames can now be placed on the top and bottom of blocks.
|
||||
- Stripping logs by right-clicking them with an axe is now supported.
|
||||
- TNT can now be ignited by fire charges.
|
||||
- Vines can now only be placed on the side of full-cube blocks.
|
||||
- Walls now connect when placed, following the pre-1.16 logic. (1.16 logic is planned to be implemented, but currently low priority.)
|
||||
- Anvils are now damaged when they hit the ground after falling.
|
||||
- Added missing sounds for anvils hitting the ground after falling.
|
||||
- Anvils now damage entities when they fall on top of them.
|
||||
|
||||
### Items
|
||||
- Added the following new items:
|
||||
- Amethyst Shard
|
||||
- Antidote (from Education Edition)
|
||||
- Copper Ingot
|
||||
- Disc Fragment (5)
|
||||
- Echo Shard
|
||||
- Elixir (from Education Edition)
|
||||
- Eye Drops (from Education Edition)
|
||||
- Fire Charge
|
||||
- Glow Berries
|
||||
- Glow Ink Sac
|
||||
- Honey Bottle
|
||||
- Honeycomb
|
||||
- Mangrove Boat (incomplete)
|
||||
- Music Disc (5)
|
||||
- Music Disc (Otherside)
|
||||
- Music Disc (Pigstep)
|
||||
- Netherite Axe
|
||||
- Netherite Boots
|
||||
- Netherite Chestplate
|
||||
- Netherite Helmet
|
||||
- Netherite Ingot
|
||||
- Netherite Leggings
|
||||
- Netherite Pickaxe
|
||||
- Netherite Scrap
|
||||
- Netherite Shovel
|
||||
- Netherite Sword
|
||||
- Phantom Membrane
|
||||
- Raw Copper
|
||||
- Raw Gold
|
||||
- Raw Iron
|
||||
- Spyglass
|
||||
- Suspicious Stew
|
||||
- Tonic (from Education Edition)
|
||||
- Glass bottles can now be filled with water by clicking on a water source block.
|
||||
- Implemented Swift Sneak enchantment.
|
||||
- Armour durability is now only reduced when the wearer receives a type of damage that the armour can protect against.
|
||||
- Bells now ring when hit by a projectile.
|
||||
|
||||
### Worlds
|
||||
- World height of -64 to 319 is now supported.
|
||||
- Added support for 3D biomes. This isn't used by PocketMine-MP yet, but is necessary to be able to fully load 1.18 worlds.
|
||||
|
||||
## API
|
||||
### General
|
||||
- Union and mixed native parameter, return and property types are now used where appropriate.
|
||||
- Protected and public properties now use native property types wherever possible.
|
||||
- Parameter and return typehints have been applied in many places where it wasn't previously possible.
|
||||
|
||||
### Dependencies
|
||||
- [`ext-pmmpthread` version 6.0.0](https://github.com/pmmp/ext-pmmpthread/releases/6.0.0) (renamed from `ext-pthreads`) is now required. This version features major API changes and improvements. Please read the [upgrading guide](https://github.com/pmmp/ext-pmmpthread/blob/fork/docs/UPGRADING_4.x_to_6.0.md) for details.
|
||||
- [`pocketmine/snooze` version 0.5.0](https://github.com/pmmp/Snooze/releases/0.5.0) is now required.
|
||||
- [`pocketmine/raklib` version 0.15.0](https://github.com/pmmp/RakLib/releases/0.15.0) is now required.
|
||||
- [`pocketmine/raklib-ipc` version 0.2.0](https://github.com/pmmp/RakLibIpc/releases/0.2.0) is now required.
|
||||
- `pocketmine/classloader` and `pocketmine/log-pthreads` packages have been removed. The relevant classes from these packages are now included in-house in the `pocketmine/thread` namespace.
|
||||
- `BaseClassLoader` is replaced with `pocketmine\thread\ThreadSafeClassLoader`
|
||||
- `ThreadedLogger` is replaced by `pocketmine\thread\ThreadSafeLogger`
|
||||
- `AttachableThreadedLogger` is replaced by `pocketmine\thread\AttachableThreadSafeLogger`
|
||||
- `ThreadedLoggerAttachment` is replaced by `pocketmine\thread\ThreadSafeLoggerAttachment`
|
||||
- `webmozart/path-util` has been removed (replaced by [`symfony/filesystem`](https://github.com/symfony/filesystem)).
|
||||
|
||||
### `pocketmine\block`
|
||||
#### Highlights
|
||||
- Blocks no longer use internal Minecraft IDs and metadata to identify themselves. All APIs associated with legacy IDs
|
||||
and meta have been removed.
|
||||
- A new set of runtime IDs generated from `VanillaBlocks` is used to identify block types. These IDs are defined
|
||||
in `BlockTypeIds`.
|
||||
- These new IDs are used for runtime representation of blocks on chunks, and for type comparison purposes.
|
||||
- Block type IDs are used at **runtime only**. **Do not store them in configs or databases**, as they are subject to
|
||||
change without warning.
|
||||
- Block type IDs are **specific to PocketMine-MP** and have no relation to the IDs used by Minecraft.
|
||||
- Block type IDs cannot be negative
|
||||
- Block type IDs must not be reused, even if overriding an already defined block
|
||||
- Block state properties (e.g. facing, colour, etc.) are now represented by PM-specific state data instead of legacy
|
||||
metadata. The state data consists of:
|
||||
- Block-item state properties - retained by items when the block is broken (colour, wet/dry, coral type, etc.) - handled by `Block->describeBlockItemState()`
|
||||
- Block-only state data - discarded when the block is broken (facing direction, lit/unlit, powered/unpowered, etc.) - handled by `Block->describeBlockOnlyState()`
|
||||
- Chunks now store dynamic state ID derived from the runtime type ID and runtime (PocketMine-MP defined) state data.
|
||||
- Introduced "type tags" concept, which allows marking certain blocks as having certain behaviours.
|
||||
- The idea for this system was borrowed from the Minecraft Java tags system.
|
||||
- It's still in very early concept stage, but is currently used for deciding which types of blocks plants can be placed on without needing to enumerate every single ID in every class, eliminating a bunch of boilerplate code and improving consistency.
|
||||
- All `Block` descendents now accept `BlockTypeInfo` in the constructor, instead of `BlockBreakInfo`. This allows for future additions without needing to change dozens of overridden constructors.
|
||||
- `&$returnedItems` reference parameter is now used in some places such as `Block->onInteract()` to enable actions to return items to players without caring about whether they are in creative or anything else.
|
||||
- This eliminates boilerplate code of deciding whether to set the player's held item or not, as well as automatically dropping any overflow items that don't fit into the inventory.
|
||||
- This is currently used when filling/emptying cauldrons using buckets or glass bottles.
|
||||
- Dependency between `RuntimeBlockStateRegistry` (previously `BlockFactory`) and `VanillaBlocks` has been inverted.
|
||||
- Now, blocks types are defined in `VanillaBlocks`
|
||||
- `RuntimeBlockStateRegistry` automatically registers states for blocks defined in `VanillaBlocks`.
|
||||
- Manual registration in `RuntimeBlockStateRegistry` is still required for custom blocks (see section below about registering new blocks).
|
||||
- `RuntimeBlockStateRegistry` now has only one purpose - to map internal blockstate IDs to `Block` objects when reading blocks from chunks. It should not be used by plugins unless registering new blocks.
|
||||
- To get a block at runtime, e.g. stone, use `VanillaBlocks::STONE()`
|
||||
- To load a block from **old** config or database data:
|
||||
1. Use `GlobalBlockStateHandlers::getUpgrader()->upgradeIntIdMeta()` to convert it to modern data
|
||||
2. Pass the data to `GlobalBlockStateHandlers::getDeserializer()` to get a blockstate ID
|
||||
3. Pass the blockstate ID to `RuntimeBlockStateRegistry::fromStateId()` to get a `Block` instance
|
||||
- Prefer using `StringToItemParser` wherever possible for configs and databases (see `lookupAliases()` and `lookupBlockAliases()`).
|
||||
|
||||
#### Registering new blocks
|
||||
##### In a plugin
|
||||
To add a vanilla block in a plugin which isn't yet supported by PocketMine-MP, do the following:
|
||||
|
||||
1. Get a new type ID using `BlockTypeIds::newId()` - _you'll want to keep this in a property somewhere if you want to
|
||||
compare using `getTypeId()` later_
|
||||
2. Set up the block type somewhere - _this can be anywhere you like, e.g. a plugin main class property, but using
|
||||
a `RegistryTrait` class is recommended - you'll need this later to create new instances of the block_
|
||||
3. Register the block in `RuntimeBlockStateRegistry` - _this informs the server of all the block's possible states so
|
||||
that it can be read from chunks at runtime_
|
||||
4. Register a deserializer for the block's Minecraft ID in `BlockStateToObjectDeserializer` - _needed for the block to
|
||||
be recognized when loaded from disk_
|
||||
5. Register a serializer for the block in `BlockObjectToStateSerializer` - _needed for the block to be saved to disk,
|
||||
and to be sent over the network_
|
||||
6. Optionally, register a string alias for the block in `StringToItemParser` - _so that it can be given via `/give`_
|
||||
|
||||
To see a demo of how to do this in a plugin, see [this example plugin](https://github.com/pmmp/RegisterBlocksDemoPM5).
|
||||
|
||||
Registering custom blocks follows a similar process, but requires additional steps to modify `BlockStateDictionary`
|
||||
which won't be covered here.
|
||||
Since this is not currently officially supported by PocketMine-MP, this won't be covered here.
|
||||
|
||||
This is admittedly rather more of a hassle than in PM4, but this system offers significantly more flexibility than the
|
||||
old system.
|
||||
|
||||
##### As a PocketMine-MP core contribution
|
||||
To register a new vanilla block into the core, the process is slightly different:
|
||||
|
||||
1. Instead of using `BlockTypeIds::newId()`, add a new constant for the block to `BlockTypeIds`
|
||||
2. Register the new block in `VanillaBlocks` - `RuntimeBlockStateRegistry` will automagically take notice of all blocks
|
||||
defined in `VanillaBlocks`
|
||||
3. Follow steps 4 onwards above
|
||||
|
||||
#### Change list
|
||||
- The following classes have been removed:
|
||||
- `BlockIdentifierFlattened`
|
||||
- `BlockLegacyIdHelper`
|
||||
- `BlockLegacyIds`
|
||||
- `BlockLegacyMetadata`
|
||||
- `utils\BlockDataSerializer`
|
||||
- `utils\ColorInMetadataTrait` - `utils\ColoredTrait` now implements colour type data serialization uniformly
|
||||
- `utils\InvalidBlockStateException` - this has been superseded by `pocketmine\data\runtime\InvalidSerializedRuntimeDataException`
|
||||
- `utils\NormalHorizontalFacingInMetadataTrait` - `utils\HorizontalFacingTrait` now implements facing type data serialization uniformly
|
||||
- `utils\PillarRotationInMetadataTrait` - `utils\PillarRotationTrait` now implements rotation type data serialization uniformly
|
||||
- The following classes have been renamed:
|
||||
- `BlockFactory` -> `RuntimeBlockStateRegistry` - this class is now exclusively used for mapping state IDs to block instances for runtime chunk block reading
|
||||
- `Skull` -> `MobHead`
|
||||
- `utils\SkullType` -> `utils\MobHeadType`
|
||||
- `utils\TreeType` -> `pocketmine\world\generator\object\TreeType`
|
||||
- The following classes have been added:
|
||||
- `BaseCake`
|
||||
- `BaseFire`
|
||||
- `BlockTypeIds` - list of type IDs, one for each entry in `VanillaBlocks`
|
||||
- `BlockTypeInfo`
|
||||
- `BlockTypeTags`
|
||||
- `CakeWithCandle`
|
||||
- `CakeWithDyedCandle`
|
||||
- `Candle`
|
||||
- `CartographyTable`
|
||||
- `Chain`
|
||||
- `CopperOre`
|
||||
- `CopperSlab`
|
||||
- `CopperStairs`
|
||||
- `Copper`
|
||||
- `DyedCandle`
|
||||
- `GildedBlackstone`
|
||||
- `GoldOre`
|
||||
- `HangingRoots`
|
||||
- `IronOre`
|
||||
- `Light`
|
||||
- `LightningRod`
|
||||
- `NetherGoldOre`
|
||||
- `Sculk`
|
||||
- `SmithingTable`
|
||||
- `SoulFire`
|
||||
- `WitherRose`
|
||||
- `utils\CandleTrait`
|
||||
- `utils\CopperOxidation`
|
||||
- `utils\CopperTrait`
|
||||
- `utils\SaplingType` - enum of all sapling types
|
||||
- `utils\WallConnectionType` - enum of all possible wall connection types
|
||||
- `utils\WoodTypeTrait`
|
||||
- `utils\WoodType` - enum of all possible wood types, used for wood material blocks like planks and logs
|
||||
- The following API methods have been removed:
|
||||
- `Block->getId()` - for type comparisons, use `Block->getTypeId()` instead
|
||||
- `Block->getMeta()` - for state comparisons, use `Block->getStateId()` instead
|
||||
- `Block->getStateBitmask()`
|
||||
- `Block->readStateFromData()`
|
||||
- `Block->writeStateToItemMeta()`
|
||||
- `Block->writeStateToMeta()`
|
||||
- `BlockFactory->get()` - see notes above about `RuntimeBlockStateRegistry`
|
||||
- `BlockIdentifier->getAllBlockIds()`
|
||||
- `BlockIdentifier->getBlockId()`
|
||||
- `BlockIdentifier->getItemId()`
|
||||
- `BlockIdentifier->getVariant()`
|
||||
- `Door->isPowered()`
|
||||
- `Door->setPowered()`
|
||||
- `MobHead->isNoDrops()` (previously `Skull->isNoDrops()`)
|
||||
- `MobHead->setNoDrops()` (previously `Skull->setNoDrops()`)
|
||||
- `VanillaBlocks::*_GLAZED_TERRACOTTA()` - use `VanillaBlocks::GLAZED_TERRACOTTA()->setColor(DyeColor::WHATEVER())` instead
|
||||
- `utils\FallableTrait->getId()` is no longer required
|
||||
- `utils\FallableTrait->getMeta()` is no longer required
|
||||
- `utils\MobHeadType->getMagicNumber()` (previously `utils\SkullType->getMagicNumber()`)
|
||||
- `utils\MobHeadType::fromMagicNumber()` (previously `utils\SkullType::fromMagicNumber()`)
|
||||
- The following constants have been removed:
|
||||
- `Block::INTERNAL_METADATA_BITS`
|
||||
- `Block::INTERNAL_METADATA_MASK`
|
||||
- The following API methods have been renamed:
|
||||
- `Block->getFullId()` -> `Block->getStateId()`
|
||||
- `Block->isSameType()` -> `Block->hasSameTypeId()`
|
||||
- `MobHead->getSkullType()` -> `MobHead->getMobHeadType()` (previously `Skull->getSkullType()`)
|
||||
- `MobHead->setSkullType()` -> `MobHead->setMobHeadType()` (previously `Skull->setSkullType()`)
|
||||
- The following API methods have signature changes:
|
||||
- `Block->onBreak()` now accepts `array<Item> &$returnedItems` reference parameter.
|
||||
- `Block->onInteract()` now accepts `array<Item> &$returnedItems` reference parameter.
|
||||
- `Block->readStateFromWorld()` now returns `Block` - this allows blocks to replace themselves with a different block entirely based on world conditions.
|
||||
- `BlockIdentifier->__construct()` now accepts `int $blockTypeId`, and no longer accepts `int $blockId, int $variant, ?int $itemId`
|
||||
- `ItemFrame->getFacing()` may now return `Facing::UP` and `Facing::DOWN`
|
||||
- `ItemFrame->setFacing()` now accepts `Facing::UP` and `Facing::DOWN`
|
||||
- `Leaves->__construct()` now accepts `LeavesType $leavesType` instead of `TreeType $treeType`
|
||||
- `RuntimeBlockStateRegistry->register()` no longer accepts an `$override` parameter.
|
||||
- `Sapling::__construct()` now accepts `SaplingType $saplingType` instead of `TreeType $treeType`
|
||||
- `utils\SignText::__construct()` now accepts two new optional parameters: `?Color $baseColor` and `bool $glowing`
|
||||
- `utils\SignText::fromBlob()` now accepts two new optional parameters: `?Color $baseColor` and `bool $glowing`
|
||||
- The following API methods have been added:
|
||||
- `protected Block->describeBlockOnlyState(RuntimeDataDescriber $w) : void` - describes state properties which are discarded when the block is broken or block-picked, such as facing, powered, etc.
|
||||
- `public Block->describeBlockItemState(RuntimeDataDescriber $w) : void` - describes state properties which are kept by the item when the block is broken or block-picked, such as dye color
|
||||
- `public Block->generateStatePermutations() : \Generator<int, Block, void, void>` - yields all possible states this block type can be in (used for `RuntimeBlockStateRegistry`)
|
||||
- `public Block->getTypeTags() : array<string>`
|
||||
- `public Block->hasTypeTag(string $tag) : bool`
|
||||
- `public Block->isFireProofAsItem() : bool`
|
||||
- `public Block->onProjectileHit(Projectile $projectile, RayTraceResult $hitResult) : void`
|
||||
- `public BlockIdentifier->getBlockTypeId() : int` - returns the block's type ID according to `BlockTypeIds`
|
||||
- `public Furnace->getFurnaceType() : utils\FurnaceType`
|
||||
- `public GlazedTerracotta->getColor() : utils\DyeColor` (from `ColoredTrait`) - this was previously unsupported due to legacy limitations
|
||||
- `public GlazedTerracotta->setColor(utils\DyeColor $color) : $this` (from `ColoredTrait`) - this was previously unsupported due to legacy limitations
|
||||
- `public Leaves->getLeavesType() : utils\LeavesType` - returns the type of leaves
|
||||
- `public Wall->getConnection(int $face) : utils\WallConnectionType`
|
||||
- `public Wall->getConnections() : array<int, utils\WallConnectionType>` - returns the wall's connections and their types (see `utils\WallConnectionType`)
|
||||
- `public Wall->isPost() : bool`
|
||||
- `public Wall->setConnection(int $face, ?utils\WallConnectionType $type) : $this`
|
||||
- `public Wall->setConnections()` - sets the wall's connections and their types (see `utils\WallConnectionType`)
|
||||
- `public Wall->setPost(bool $post) : $this`
|
||||
- `public Wood->isStripped() : bool`
|
||||
- `public Wood->setStripped(bool $stripped) : $this`
|
||||
- `public static BlockBreakInfo::axe(float $hardness, ?ToolTier $toolTier = null, ?float $blastResistance = null) : BlockBreakInfo`
|
||||
- `public static BlockBreakInfo::pickaxe(float $hardness, ?ToolTier $toolTier = null, ?float $blastResistance = null) : BlockBreakInfo`
|
||||
- `public static BlockBreakInfo::shovel(float $hardness, ?ToolTier $toolTier = null, ?float $blastResistance = null) : BlockBreakInfo`
|
||||
- `public static BlockBreakInfo::tier(float $hardness, int $toolType, ToolTier $toolTier, ?float $blastResistance = null) : BlockBreakInfo`
|
||||
- `public tile\Spawnable->getRenderUpdateBugWorkaroundStateProperties(Block $block) : array<string, Tag>` - allows spawnable tiles to spoof block state properties to work around client-side rendering bugs without actually changing the block server-side
|
||||
- `public utils\SignText->getBaseColor() : \pocketmine\color\Color`
|
||||
- `public utils\SignText->isGlowing() : bool`
|
||||
- The following classes now use new traits, adding API methods and/or properties:
|
||||
- `FenceGate` uses `utils\WoodTypeTrait`
|
||||
- `GlazedTerracotta` uses `utils\ColoredTrait`
|
||||
- `Planks` uses `utils\WoodTypeTrait`
|
||||
- `Wood` uses `utils\WoodTypeTrait`
|
||||
- `WoodenButton` uses `utils\WoodTypeTrait`
|
||||
- `WoodenDoor` uses `utils\WoodTypeTrait`
|
||||
- `WoodenFence` uses `utils\WoodTypeTrait`
|
||||
- `WoodenPressurePlate` uses `utils\WoodTypeTrait`
|
||||
- `WoodenSlab` uses `utils\WoodTypeTrait`
|
||||
- `WoodenStairs` uses `utils\WoodTypeTrait`
|
||||
- `WoodenTrapdoor` uses `utils\WoodTypeTrait`
|
||||
- The following API interface requirements have been added (BC breaking):
|
||||
- `public utils\Fallable->getFallDamagePerBlock() : float` (default implementation provided by `utils\FallableTrait`)
|
||||
- `public utils\Fallable->getLandSound() : ?Sound` (default implementation provided by `utils\FallableTrait`)
|
||||
- `public utils\Fallable->getMaxFallDamage() : float` (default implementation provided by `utils\FallableTrait`)
|
||||
- `public utils\Fallable->onHitGround(FallingBlock $blockEntity) : bool` (default implementation provided by `utils\FallableTrait`)
|
||||
|
||||
### `pocketmine\command`
|
||||
- Command permissions are now always checked by the server when running a command.
|
||||
- This only affects commands implemented by extending `Command`. Plugins using `PluginBase->onCommand()` are not affected by this change, since they already had permissions checked by the server anyway.
|
||||
- Previously, direct inheritors of `Command` were responsible for checking permissions, which required developers to duplicate the same code in every command, and opened lots of potential for security vulnerabilities.
|
||||
- If you want to do something on permission denied (e.g. sending a special message, or audit logging), you can do so by overriding `Command->testPermission()`, instead of baking the code directly into `Command->execute()`.
|
||||
- If you don't want to use permissions at all, just create a permission with a default of `true` (or belonging to `pocketmine.group.user`) and assign that.
|
||||
- `SimpleCommandMap` now requires all commands to have a permission set when registered.
|
||||
- If you actually want to allow everyone to use your command (not advised), you can add a new permission to the `pocketmine.group.user` group, or use `default: true` for `plugin.yml` permissions.
|
||||
- The following API methods have changed behaviour:
|
||||
- `Command->testPermissionSilent()` now returns `false` if there are no permissions associated with the command. This is to prevent commands with no permissions being usable by everyone, which has previously been a source of security issues.
|
||||
- The following API methods have been added:
|
||||
- `public Command->getPermissions() : list<string>` - returns a list of permissions which grant usage access to this command. A user with one or more of these permissions will be able to invoke the command's `execute()` method
|
||||
- `public Command->setPermissions(list<string> $permissions) : void` - sets the permissions which grant usage access to this command. This should be used instead of `setPermission()` with `;` separators (which is now deprecated)
|
||||
|
||||
### `pocketmine\crafting`
|
||||
- JSON models have been updated to reflect updated crafting data format.
|
||||
- The following enum classes have new members:
|
||||
- `ShapelessRecipeType` has new members `CARTOGRAPHY` and `SMITHING`
|
||||
- The following classes have been added:
|
||||
- `ExactRecipeIngredient` - matches an exact item
|
||||
- `MetaWildcardRecipeIngredient` - matches an item with the given legacy Minecraft ID, but any metadata value
|
||||
- `RecipeIngredient` interface
|
||||
- `TagWildcardRecipeIngredient` - matches an item based on its Minecraft tags, e.g. `minecraft:wooden_tier`
|
||||
- The following API methods have signature changes:
|
||||
- `FurnaceRecipe->__construct()` now accepts `RecipeIngredient` instead of `Item`
|
||||
- `FurnaceRecipe->getInput()` now returns `RecipeIngredient` instead of `Item`
|
||||
- `PotionContainerChangeRecipe->__construct()` now accepts `string, RecipeIngredient, string` (using Minecraft string IDs instead of legacy integers).
|
||||
- `PotionContainerChangeRecipe->getIngredient()` now returns `RecipeIngredient` instead of `Item`.
|
||||
- `PotionContainerChangeRecipe->getInputItemId()` now returns `string` (using Minecraft string IDs instead of legacy integers).
|
||||
- `PotionContainerChangeRecipe->getOutputItemId()` now returns `string` (using Minecraft string IDs instead of legacy integers).
|
||||
- `PotionTypeRecipe->__construct()` now accepts `RecipeIngredient` instead of `Item`
|
||||
- `PotionTypeRecipe->getIngredient()` now returns `RecipeIngredient` instead of `Item`
|
||||
- `PotionTypeRecipe->getInput()` now returns `RecipeIngredient` instead of `Item`
|
||||
- `ShapedRecipe->__construct()` now accepts `RecipeIngredient` instead of `Item`
|
||||
- `ShapedRecipe->getIngredient()` now returns `?RecipeIngredient` instead of `?Item`
|
||||
- `ShapedRecipe->getIngredientList()` now returns `RecipeIngredient[]` instead of `Item[]`
|
||||
- `ShapedRecipe->getIngredientMap()` now returns `RecipeIngredient[][]` instead of `Item[][]`
|
||||
- `ShapelessRecipe->__construct()` `$type` parameter is now mandatory.
|
||||
- `ShapelessRecipe->__construct()` now accepts `RecipeIngredient` instead of `Item`
|
||||
- `ShapelessRecipe->getIngredientList()` now returns `RecipeIngredient[]` instead of `Item[]`
|
||||
|
||||
### `pocketmine\data`
|
||||
- New packages `bedrock\block` and `bedrock\item` have been added. These packages contain all the necessary code for loading and saving Bedrock blocks and items from disk.
|
||||
- New package `runtime` has been added. This package contains code for serializing runtime data for blocks and items.
|
||||
- `LegacyToStringBidirectionalIdMap` has been reduced to `LegacyToStringIdMap`.
|
||||
- Since we never map from string ID to legacy ID, bidirectional mapping is no longer necessary.
|
||||
- This affects the following subclasses:
|
||||
- `LegacyBiomeIdToStringIdMap`
|
||||
- `LegacyBlockIdToStringIdMap`
|
||||
- `LegacyEntityIdToStringIdMap`
|
||||
- `LegacyItemIdToStringIdMap`
|
||||
- The following internal API methods have been added:
|
||||
- `public LegacyToStringIdMap->add(string $string, int $legacy) : void` - adds a mapping from a custom legacy ID to custom string ID, needed for upgrading old saved data
|
||||
|
||||
### `pocketmine\entity`
|
||||
- `Entity` now declares new abstract methods which must be implemented by subclasses:
|
||||
- `public Entity->getInitialDragMultiplier() : float`
|
||||
- `public Entity->getInitialGravity() : float`
|
||||
- The following new API methods have been added:
|
||||
- `public Living->getDisplayName() : string`
|
||||
- The following API methods have changed signatures:
|
||||
- `EntityFactory->register()` no longer accepts a `$legacyMcpeSaveId` parameter (now handled by internal conversions instead).
|
||||
- The following API methods have been renamed:
|
||||
- `Entity->isImmobile()` -> `Entity->hasNoClientPredictions()`
|
||||
- `Entity->setImmobile()` -> `Entity->setNoClientPredictions()`
|
||||
- The following internal fields have been renamed:
|
||||
- `Entity->immobile` -> `Entity->noClientPredictions`
|
||||
- The following classes have been removed:
|
||||
- `EntityLegacyIds`
|
||||
|
||||
### `pocketmine\event`
|
||||
- The following classes have inheritance changes:
|
||||
- `block\BlockPlaceEvent` no longer extends `BlockEvent`, and therefore no longer has `getBlock()`. Use `getTransaction()` instead (may contain multiple blocks).
|
||||
- `BlockFormEvent` now includes information about the block which caused the event.
|
||||
|
||||
- The following new classes have been added:
|
||||
- `world\WorldDisplayNameChangeEvent` - called when a world's display name is changed
|
||||
- The following classes have been renamed:
|
||||
- `entity\ExplosionPrimeEvent` -> `entity\EntityPreExplodeEvent`
|
||||
- The following API methods have been added:
|
||||
- `public block\BlockFormEvent->getCausingBlock() : Block`
|
||||
- `public block\BlockGrowEvent->getPlayer() : ?Player` - returns the player that triggered the block growth, or `null` if it was not triggered by a player
|
||||
- `public block\BlockPlaceEvent->getTransaction() : BlockTransaction` - returns the transaction containing a list of changed block positions and the blockstates they will be changed to
|
||||
- `public server\DataPacketSendEvent->setPackets(list<ClientboundPacket> $packets) : void`
|
||||
- The following API methods have changed signatures:
|
||||
- `block\BlockPlaceEvent->__construct()` now accepts `BlockTransaction $transaction` instead of `Block $blockPlace, Block $blockReplace`
|
||||
- `entity\EntityPreExplodeEvent->__construct()` has the `$force` parameter renamed to `$radius`
|
||||
- `entity\EntityPreExplodeEvent->getForce() : float` -> `entity\EntityPreExplodeEvent->getRadius() : float`
|
||||
- `entity\EntityPreExplodeEvent->setForce(float $force) : void` -> `entity\EntityPreExplodeEvent->setRadius(float $radius) : void`
|
||||
- The following API methods have been removed:
|
||||
- `block\BlockPlaceEvent->getBlockReplaced()` - this information is now provided in the `BlockTransaction` object returned by `BlockPlaceEvent->getTransaction()`
|
||||
- The following new API constants have been added:
|
||||
- `entity\EntityDamageEvent::CAUSE_FALLING_BLOCK`
|
||||
- `entity\EntityDamageEvent::MODIFIER_ARMOR_HELMET`
|
||||
|
||||
### `pocketmine\event\player`
|
||||
- `PlayerPreLoginEvent`, `PlayerDuplicateLoginEvent` and `PlayerKickEvent` now supports setting separate log reasons (disconnect reason) and disconnect screen messages.
|
||||
- The following classes have been removed:
|
||||
- `PlayerCommandPreprocessEvent`
|
||||
- The following API methods have changed signatures:
|
||||
- `PlayerDuplicateLoginEvent->getDisconnectMessage()` now returns `Translatable|string` instead of `string`
|
||||
- `PlayerDuplicateLoginEvent->setDisconnectMessage()` now accepts `Translatable|string` instead of `string`
|
||||
- `PlayerKickEvent->getReason()` now returns `Translatable|string` instead of `string`
|
||||
- `PlayerKickEvent->setReason()` now accepts `Translatable|string` instead of `string`
|
||||
- `PlayerLoginEvent->getKickMessage()` now returns `Translatable|string` instead of `string`
|
||||
- `PlayerLoginEvent->setKickMessage()` now accepts `Translatable|string` instead of `string`
|
||||
- `PlayerPreLoginEvent->getFinalKickMessage()` now returns `Translatable|string` instead of `string`
|
||||
- `PlayerPreLoginEvent->getKickMessage()` now returns `Translatable|string|null` instead of `string|null`
|
||||
- `PlayerPreLoginEvent->setKickFlag()` (previously `setKickReason()`) now accepts `Translatable|string $disconnectReason, Translatable|string|null $disconnectScreenMessage = null` instead of `Translatable|string $message`
|
||||
- `PlayerPreLoginEvent->setKickReason()` now accepts `Translatable|string` for the `$message` parameter instead of `string`
|
||||
- `PlayerQuitEvent->getQuitReason()` now returns `Translatable|string` instead of `string`
|
||||
- The following API methods have been removed:
|
||||
- `PlayerChatEvent->getFormat()` (use `PlayerChatEvent->getChatFormatter()` instead)
|
||||
- `PlayerChatEvent->setFormat()` (use `PlayerChatEvent->setChatFormatter()` instead)
|
||||
- `PlayerDuplicateLoginEvent->getDisconnectMessage()` - replaced by `getDisconnectReason()` and `getDisconnectScreenMessage()`
|
||||
- `PlayerDuplicateLoginEvent->setDisconnectMessage()` - replaced by `setDisconnectReason()` and `setDisconnectScreenMessage()`
|
||||
- `PlayerKickEvent->getReason()` - replaced by `getDisconnectReason()` and `getDisconnectScreenMessage()`
|
||||
- `PlayerKickEvent->setReason()` - replaced by `setDisconnectReason()` and `setDisconnectScreenMessage()`
|
||||
- The following new API methods have been added:
|
||||
- `public PlayerChatEvent->getChatFormatter() : \pocketmine\player\chat\ChatFormatter` - returns the chat formatter to be used for this event
|
||||
- `public PlayerChatEvent->setChatFormatter(\pocketmine\player\chat\ChatFormatter $formatter) : void` - sets the chat formatter to be used for this event
|
||||
- `public PlayerDeathEvent->getDeathScreenMessage() : Translatable|string` - returns the message to be displayed on the death screen
|
||||
- `public PlayerDeathEvent->setDeathScreenMessage(Translatable|string $deathScreenMessage) : void` - sets the message to be displayed on the death screen
|
||||
- `public PlayerDuplicateLoginEvent->getDisconnectReason() : Translatable|string` - returns the reason for the disconnection displayed in the console and server log
|
||||
- `public PlayerDuplicateLoginEvent->getDisconnectScreenMessage() : Translatable|string|null` - returns the message to be displayed on the disconnect screen (the message in `getDisconnectReason()` is used if null is returned)
|
||||
- `public PlayerDuplicateLoginEvent->setDisconnectReason(Translatable|string $disconnectReason) : void` - sets the reason for the disconnection displayed in the console and server log
|
||||
- `public PlayerDuplicateLoginEvent->setDisconnectScreenMessage(Translatable|string|null $disconnectScreenMessage) : void` - sets the message to be displayed on the disconnect screen (the message in `setDisconnectReason()` is used if null is passed)
|
||||
- `public PlayerKickEvent->getDisconnectReason() : Translatable|string` - returns the reason for the disconnection displayed in the console and server log
|
||||
- `public PlayerKickEvent->getDisconnectScreenMessage() : Translatable|string|null` - returns the message to be displayed on the disconnect screen (the message in `getDisconnectReason()` is used if null is returned)
|
||||
- `public PlayerKickEvent->setDisconnectReason(Translatable|string $disconnectReason) : void` - sets the reason for the disconnection displayed in the console and server log
|
||||
- `public PlayerKickEvent->setDisconnectScreenMessage(Translatable|string|null $disconnectScreenMessage) : void` - sets the message to be displayed on the disconnect screen (the message in `setDisconnectReason()` is used if null is passed)
|
||||
- `public PlayerPreLoginEvent->getDisconnectScreenMessage(int $flag) : Translatable|string|null` - returns the message to be displayed on the disconnect screen for the specified kick flag, if set
|
||||
- `public PlayerPreLoginEvent->getFinalDisconnectScreenMessage() : Translatable|string|null` - returns the message to be displayed on the disconnect screen, taking into account the kick flags set
|
||||
- The following classes have inheritance changes:
|
||||
- `PlayerPreLoginEvent` no longer implements `Cancellable`. This caused unexpected behaviour for most plugin devs due to default-ignoring cancelled events, forcing people to usually have to use `@handleCancelled` to handle the event when they wanted to use it.
|
||||
- The following API constants have been renamed:
|
||||
- `PlayerPreLoginEvent::KICK_REASON_BANNED` -> `PlayerPreLoginEvent::KICK_FLAG_BANNED`
|
||||
- `PlayerPreLoginEvent::KICK_REASON_PLUGIN` -> `PlayerPreLoginEvent::KICK_FLAG_PLUGIN`
|
||||
- `PlayerPreLoginEvent::KICK_REASON_PRIORITY` -> `PlayerPreLoginEvent::KICK_FLAG_PRIORITY`
|
||||
- `PlayerPreLoginEvent::KICK_REASON_SERVER_FULL` -> `PlayerPreLoginEvent::KICK_FLAG_SERVER_FULL`
|
||||
- `PlayerPreLoginEvent::KICK_REASON_SERVER_WHITELISTED` -> `PlayerPreLoginEvent::KICK_FLAG_SERVER_WHITELISTED`
|
||||
- The following API methods have been renamed:
|
||||
- `PlayerPreLoginEvent->clearAllKickReasons()` -> `PlayerPreLoginEvent->clearAllKickFlags()`
|
||||
- `PlayerPreLoginEvent->clearKickReason()` -> `PlayerPreLoginEvent->clearKickFlag()`
|
||||
- `PlayerPreLoginEvent->getFinalKickMessage()` -> `PlayerPreLoginEvent->getFinalDisconnectReason()` (now used for logs only, if a disconnect screen message is set for the highest priority flag)
|
||||
- `PlayerPreLoginEvent->getKickMessage()` -> `PlayerPreLoginEvent->getDisconnectReason()` (now used for logs only, if a disconnect screen message is set for the flag)
|
||||
- `PlayerPreLoginEvent->getKickReasons()` -> `PlayerPreLoginEvent->getKickFlags()`
|
||||
- `PlayerPreLoginEvent->isKickReasonSet()` -> `PlayerPreLoginEvent->isKickFlagSet()`
|
||||
- `PlayerPreLoginEvent->setKickReason()` -> `PlayerPreLoginEvent->setKickFlag()`
|
||||
|
||||
### `pocketmine\item`
|
||||
#### Highlights
|
||||
- `ItemFactory` has been removed. Vanilla item registration is now done via `VanillaItems`.
|
||||
- To get an item at runtime, e.g. iron ingot, use `VanillaItems::IRON_INGOT()`
|
||||
- To get a block as an item, e.g. stone, use `VanillaBlocks::STONE()->asItem()`
|
||||
- To load an item from legacy ID and meta:
|
||||
1. Use `GlobalItemDataHandlers::getUpgrader()->upgradeItemTypeDataInt()` to convert the legacy ID and meta to `SavedItemStackData`
|
||||
2. Pass the itemstack data to `GlobalItemDataHandlers::getDeserializer()` to get an `Item` instance
|
||||
- Items no longer use internal Minecraft string IDs and metadata to identify themselves. All APIs associated with legacy
|
||||
IDs and/or meta have been removed.
|
||||
- A new set of runtime item IDs generated from `VanillaItems` is now used to identify item types. These IDs are defined
|
||||
in `ItemTypeIds`.
|
||||
- These new IDs are primarily intended for type comparison purposes.
|
||||
- Item type IDs are used at **runtime only**. They should **NOT** be stored in configs or databases, as they are not
|
||||
guaranteed to remain the same between versions.
|
||||
- In some cases, items may have additional "type data" which provides extra type information about an item. This
|
||||
replaces item metadata in some cases.
|
||||
- Type data may be used to store dynamic type information such as dye colour, potion type, etc.
|
||||
- Items must have the same type ID **and** type data in order to be stackable.
|
||||
- Blocks, when represented as items:
|
||||
- retain their block type data, but not state data (for example, different colours of concrete don't stack, but things
|
||||
like facing don't affect stackability)
|
||||
- use the negative of their block type ID (e.g. a block with type ID `1` will have an item type ID of `-1`).
|
||||
- Durable items (e.g. tools, armour) now use NBT `Damage` tag to store durability (like Minecraft 1.13+), instead of
|
||||
legacy meta values.
|
||||
- `&$returnedItems` reference parameter is now used in some places (e.g. `onInteractBlock()`) to enable actions to return items to players without caring about whether they are in creative or anything else.
|
||||
- This eliminates boilerplate code of deciding whether to set the player's held item or not, as well as automatically dropping any overflow items that don't fit into the inventory.
|
||||
- This is used for things like filling/emptying buckets and bottles, and equipping armor.
|
||||
- Blocks which previously had separate items, such as mob heads and beds, no longer do. Their item form can be acquired using `Block->asItem()` in the same way as every other block. This is facilitated by the new serializer system.
|
||||
|
||||
#### Implementing new items
|
||||
##### In a plugin
|
||||
This follows a similar process to registering blocks.
|
||||
|
||||
1. Get a new type ID using `ItemTypeIds::newId()` - _you'll want to keep this in a property somewhere if you want to
|
||||
compare using `getTypeId()` later_
|
||||
2. Set up the item type somewhere - _this can be anywhere you like, e.g. a plugin main class property, but using
|
||||
a `RegistryTrait` class is recommended - you'll need this later to create new instances of the item_
|
||||
3. Register a deserializer in `ItemDeserializer` - _needed for the item to be recognized when loaded from disk_
|
||||
4. Register a serializer in `ItemSerializer` - _needed for the item to be saved to disk, and to be sent over the
|
||||
network_
|
||||
5. Optionally, register a string alias for the item in `StringToItemParser` - _so that it can be given via `/give`_
|
||||
|
||||
To see a demo of how to do this in a plugin, see [this example plugin](https://github.com/pmmp/RegisterBlocksDemoPM5).
|
||||
|
||||
Again, it's acknowledged this is rather more cumbersome than it should be, but this is an ongoing process.
|
||||
|
||||
##### As a PocketMine-MP core contribution
|
||||
|
||||
To register a new vanilla item into the core, the process is slightly different:
|
||||
|
||||
1. Instead of using `ItemTypeIds::newId()`, add a new constant for the block to `ItemTypeIds`
|
||||
2. Register the new item in `VanillaItems`
|
||||
3. Follow steps 3 onwards from the plugin instructions above
|
||||
|
||||
#### Change list
|
||||
- `Item` is no longer `json_encode()`-able.
|
||||
- The original purpose of this was to allow items to be serialized to JSON for crafting data generated from `CraftingDataPacket`. Due to changes in the generation methodology, bypassing `Item`s entirely, this is no longer necessary.
|
||||
- In addition, `jsonSerialize()` required the item to know about the method by which it will be serialized (since there is no way to inject context), creating a cyclic dependency between the `Item` implementation and its serialization method.
|
||||
- It's relatively easy to write a replacement method to encode items to JSON as you desire.
|
||||
- `Item::legacyJsonDeserialize()` (previously `Item::jsonDeserialize()`) is retained to allow loading legacy data, although it may be removed in the future.
|
||||
- The following classes have been removed:
|
||||
- `Bed`
|
||||
- `ItemFactory`
|
||||
- `ItemIds`
|
||||
- `Skull`
|
||||
- The following classes have been added:
|
||||
- `BoatType` - enum of all boat types
|
||||
- `CoralFan`
|
||||
- `HoneyBottle`
|
||||
- `MedicineType`
|
||||
- `Medicine`
|
||||
- `Spyglass`
|
||||
- `SuspiciousStewType`
|
||||
- `SuspiciousStew`
|
||||
- The following API methods have been added:
|
||||
- `protected Item->describeState(RuntimeDataDescriber $w) : void`
|
||||
- `public Armor->clearCustomColor() : $this` - clears the custom color of an armor item
|
||||
- `public ArmorTypeInfo->getToughness() : int`
|
||||
- `public ArmorTypeInfo->isFireProof() : bool`
|
||||
- `public Boat->getType() : BoatType`
|
||||
- `public Dye->setColor(\pocketmine\block\utils\DyeColor $color) : $this`
|
||||
- `public Item->getStateId() : int` - returns a runtime numeric state ID for comparisons including information such as coral type, dye color, etc. - DO NOT save this to disk or databases
|
||||
- `public Item->getTypeId() : int` - returns a runtime numeric type ID for comparisons - DO NOT save this to disk or databases
|
||||
- `public Item->isFireProof() : bool`
|
||||
- `public ItemIdentifer->getTypeId() : int`
|
||||
- `public Potion->setType(PotionType $type) : $this`
|
||||
- `public SplashPotion->setType(PotionType $type) : $this`
|
||||
- `public StringToItemParser->lookupAliases(Item $item) : list<string>` - returns a list of all registered aliases for the given item
|
||||
- `public StringToItemParser->lookupBlockAliases(Block $block) : list<string>` - returns a list of all registered aliases for the given block
|
||||
- `public static ItemIdentifier::fromBlock(Block $block) : self`
|
||||
- The following API methods have been removed:
|
||||
- `Boat->getWoodType()`
|
||||
- `Item->getId()` - for type comparisons, use `Item->getTypeId()` instead
|
||||
- `Item->getMeta()` - use the item's specific API methods to compare information such as colour, potion type etc.
|
||||
- `Item->hasAnyDamageValue()` - for meta wildcard recipe ingredients, use `pocketmine\crafting\MetaWildcardRecipeIngredient` instead
|
||||
- `ItemIdentifier->getId()`
|
||||
- `ItemIdentifier->getMeta()`
|
||||
- The following API methods have been renamed:
|
||||
- `Item::jsonDeserialize()` -> `Item::legacyJsonDeserialize()`
|
||||
- The following API methods have signature changes:
|
||||
- `ArmorTypeInfo->__construct()` now accepts optional parameters `int $toughness` and `bool $fireProof`
|
||||
- `BoatType::__construct()` now accepts `BoatType $boatType` instead of `TreeType $woodType`.
|
||||
- `Item->onAttackEntity()` now accepts `array<Item> &$returnedItems` reference parameter.
|
||||
- `Item->onClickAir()` now accepts `array<Item> &$returnedItems` reference parameter.
|
||||
- `Item->onDestroyBlock()` now accepts `array<Item> &$returnedItems` reference parameter.
|
||||
- `Item->onInteractBlock()` now accepts `array<Item> &$returnedItems` reference parameter.
|
||||
- `Item->onReleaseUsing()` now accepts `array<Item> &$returnedItems` reference parameter.
|
||||
- `ItemIdentifier->__construct()` no longer accepts a `$variant` parameter, and now expects an item type ID for the ID parameter
|
||||
- `LegacyStringToItemParser->addMapping()` now accepts a string for ID, instead of an integer
|
||||
- The following API methods have behaviour changes:
|
||||
- `Item->equals()`'s `$checkDamage` parameter is now ignored, as tool damage is now stored as an NBT tag. This parameter wasn't removed due to being followed by a second `bool` parameter, which would potentially end up in the wrong place and silently cause bugs in updated plugins.
|
||||
- `Item->equals()`'s `$checkTags` parameter will now cause tool and armor damage to be checked if true.
|
||||
- The following enums have new members:
|
||||
- `ToolTier` has new member `NETHERITE`
|
||||
|
||||
### `pocketmine\network`
|
||||
- The following API methods have changed signatures:
|
||||
- `NetworkSessionManager->close()` now accepts an additional `Translatable|string|null $disconnectScreenMessage` parameter.
|
||||
- The following API methods have changed signatures:
|
||||
- `query\QueryInfo->getPlayerList()` now returns `list<string>` instead of `list<Player>`
|
||||
- `query\QueryInfo->setPlayerList()` now accepts `list<string>` instead of `list<Player>`
|
||||
|
||||
### `pocketmine\player`
|
||||
- The following API methods have changed signatures:
|
||||
- `Player->disconnect()` now accepts `Translatable|string` for `$reason` instead of `string` (to allow localized disconnect messages)
|
||||
- `Player->disconnect()` now accepts an additional `Translatable|string|null $disconnectScreenMessage` parameter, which is the message to be displayed on the disconnect screen (the message in `$reason` is used if null is passed)
|
||||
- `Player->kick()` now accepts `Translatable|string` for `$reason` instead of `string` (to allow localized kick messages)
|
||||
- `Player->kick()` now accepts an additional `Translatable|string|null $disconnectScreenMessage` parameter, which is the message to be displayed on the disconnect screen (the message in `$reason` is used if null is passed)
|
||||
- `Player->sendJukeboxPopup()` now accepts `Translatable|string` instead of `string, string[]`
|
||||
- The following classes have been removed:
|
||||
- `PlayerChunkLoader` - deprecated in 4.19.0 (this was technically internal, but never marked as such)
|
||||
|
||||
### `pocketmine\player\chat`
|
||||
- The following new classes have been added:
|
||||
- `ChatFormatter` - interface implemented by chat formatters - this is far more powerful than the old API
|
||||
- `LegacyRawChatFormatter` - implements the same behaviour previously used by `PlayerChatEvent->setFormat()`
|
||||
- `StandardChatFormatter` - formats chat messages in the vanilla Minecraft style
|
||||
|
||||
### `pocketmine\scheduler`
|
||||
- `AsyncTask->setResult()` now works with thread-safe objects. This was previously not possible due to limitations in the `pthreads` extension.
|
||||
|
||||
### `pocketmine\world`
|
||||
- The following API methods have been added:
|
||||
- `public World->setDisplayName(string $name) : void`
|
||||
- The following API methods have changed signatures:
|
||||
- `Explosion->__construct()` has the `$size` parameter renamed to `$radius`
|
||||
- The following public properties have been renamed:
|
||||
- `Explosion->size` -> `Explosion->radius`
|
||||
|
||||
### `pocketmine\world\format`
|
||||
- Chunks are now considered dirty (modified) by default, unless loaded from a `WorldProvider` by `World`. Previously, chunks were considered unmodified by default, which allowed several pathways to bugs.
|
||||
- The following classes have been added:
|
||||
- `io\GlobalBlockStateHandlers` - gives access to block data serializer, deserializer, and upgraders
|
||||
- `io\GlobalItemDataHandlers` - gives access to item data serializer, deserializer, and upgraders
|
||||
- `io\LoadedChunkData` - represents a chunk loaded from disk, along with information such as whether the chunk was upgraded and what fixes it requires
|
||||
- The following new API methods have been added:
|
||||
- `public SubChunk->getBiomeArray() : PalettedBlockArray`
|
||||
- The following classes have been removed:
|
||||
- `BiomeArray` - `PalettedBlockArray` is now used for 3D biome data
|
||||
- The following API methods have changed signatures:
|
||||
- `Chunk->getBiomeId()` now accepts `int $x, int $y, int $z` instead of `int $x, int $z`
|
||||
- `Chunk->setBiomeId()` now accepts `int $x, int $y, int $z` instead of `int $x, int $z`
|
||||
- `Chunk->__construct()` no longer accepts `BiomeArray` as a parameter (contained in each subchunk instead)
|
||||
- `SubChunk->__construct()` now accepts `int $emptyBlockId, list<PalettedBlockArray> $blockLayers, PalettedBlockArray $biomes, ?LightArray $blockLight, ?LightArray $skyLight` instead of `int, list<PalettedBlockArray>, ?LightArray, ?LightArray`
|
||||
- `io\WorldProvider->loadChunk()` now returns `LoadedChunkData` instead of `ChunkData`
|
||||
- `io\WorldProvider->getAllChunks()` now yields `LoadedChunkData` instead of `ChunkData`
|
||||
- `io\ChunkData->__construct()` now accepts `array<int, SubChunk>, bool $populated` instead of `Chunk $chunk`
|
||||
- The following API methods have been renamed:
|
||||
- `Chunk->getFullBlock()` -> `Chunk->getBlockStateId()`
|
||||
- `Chunk->setFullBlock()` -> `Chunk->setBlockStateId()`
|
||||
- `SubChunk->getFullBlock()` -> `SubChunk->getBlockStateId()`
|
||||
- `SubChunk->setFullBlock()` -> `SubChunk->setBlockStateId()`
|
||||
- The following API interface requirements have been added:
|
||||
- `public io\data\WorldData->setDisplayName(string $value) : void`
|
||||
|
||||
### `pocketmine\world\generator\object`
|
||||
- The following API methods have been removed:
|
||||
- `TreeType::fromMagicNumber()`
|
||||
- `TreeType->getMagicNumber()`
|
||||
|
||||
### `pocketmine\world\sound`
|
||||
- The following classes have been added:
|
||||
- `CopperWaxApplySound`
|
||||
- `CopperWaxRemoveSound`
|
||||
- `DyeUseSound`
|
||||
- `InkSacUseSound`
|
||||
- The following enums have new members:
|
||||
- `NoteInstrument` has new members `BELL`, `FLUTE`, `CHIME`, `XYLOPHONE`, `IRON_XYLOPHONE`, `COW_BELL`, `DIDGERIDOO`, `BIT`, `BANJO`, `PLING`
|
||||
- The following API methods have been removed:
|
||||
- `NoteInstrument::fromMagicNumber()`
|
||||
- `NoteInstrument->getMagicNumber()`
|
||||
|
||||
## Internals
|
||||
- All external usages of `KnownTranslationKeys` are now removed. All localized messages are now sent using `Translatable` objects (usually from `KnownTranslationFactory`).
|
||||
- All usages of NBT keys now use class constants instead of hardcoded strings (except for an occasional overlooked one).
|
||||
- Built-in commands now declare their names inside the class constructor, rather than accepting them as parameters. This improves code consistency.
|
||||
- Commands now use an array for permissions internally, instead of a string separated by `;`.
|
||||
- Make use of `Item->canStackWith()` instead of `Item->equals()` wherever possible, to make the code more readable.
|
||||
- Moved command timings to `Timings`.
|
||||
- Overriding of serializers and deserializers of items and blocks is now consistently disallowed. Since overriding stuff is non-cooperative, it doesn't make any sense in plugins, which must coexist with other plugins. If you want to modify the functionality of built-in stuff, you have several alternative options:
|
||||
- Use existing API (e.g. events, API methods) - most uses of overrides in PM4 and earlier were abuses that could have been done with events
|
||||
- Submit feature proposals or pull requests for new API to be added (e.g. new events)
|
||||
- Register completely custom items, and reuse behaviour from the item you want to mimic
|
||||
- Fork PocketMine-MP and alter the code directly - this way your plugins aren't pretending to be cooperative with other plugins
|
||||
- `level.dat`, block, item, entity, tile and chunk data are now tagged with a version ID as per `VersionInfo::WORLD_DATA_VERSION`. This allows the server to apply fixes to older worlds if necessary.
|
||||
- Protocol creative inventory entries are now cached in `CreativeInventoryCache` to improve performance of initial join and game mode changes.
|
||||
- Singletons in the `pocketmine\network\mcpe\convert` package have been centralized under `TypeConverter`. In the future, this will be injected where needed, allowing different converters to be used for different sessions (useful for multiversion).
|
||||
- `BlockStateDictionary` memory usage is now reduced from 9 MB to 3.5 MB using various techniques, including string reuse and binary-encoded states.
|
||||
- `NetworkSession` disconnect APIs now accept `Translatable|string` instead of `string` to allow localized disconnect messages.
|
||||
- `NetworkSession` disconnect methods have been altered to allow specifying a different disconnect reason and disconnection screen message.
|
||||
- `RuntimeBlockMapping` has been renamed to `BlockTranslator`.
|
||||
|
||||
# 5.0.1
|
||||
Released 3rd June 2023.
|
||||
|
||||
## Changes
|
||||
- [`ext-pmmpthread` version 6.0.1](https://github.com/pmmp/ext-pmmpthread/releases/tag/6.0.1) is now required (for bug fixes).
|
||||
|
||||
## Fixes
|
||||
- Fixed server crash when breaking blocks placed in the same session (mishandled default block states).
|
||||
- Fixed spore blossoms not dropping when broken.
|
||||
- Fixed jukebox music not stopping when destroyed by an explosion.
|
||||
|
||||
## Documentation
|
||||
- Added documentation for `BlockSpreadEvent->__construct()` parameters.
|
52
changelogs/5.1.md
Normal file
52
changelogs/5.1.md
Normal file
@ -0,0 +1,52 @@
|
||||
# 5.1.0
|
||||
Released 7th June 2023.
|
||||
|
||||
**For Minecraft: Bedrock Edition 1.20.0**
|
||||
|
||||
This is a support release for Minecraft: Bedrock Edition 1.20.0.
|
||||
|
||||
**Plugin compatibility:** Plugins for previous 5.x versions will run unchanged on this release, unless they use internal APIs, reflection, or packages like the `pocketmine\network\mcpe` namespace.
|
||||
Do not update plugin minimum API versions unless you need new features added in this release.
|
||||
|
||||
**WARNING: If your plugin uses the `pocketmine\network\mcpe` namespace, you're not shielded by API change constraints.**
|
||||
Consider using the `mcpe-protocol` directive in `plugin.yml` as a constraint if you're using packets directly.
|
||||
|
||||
## General
|
||||
- Added support for Minecraft: Bedrock Edition 1.20.0.
|
||||
- Removed support for older versions.
|
||||
|
||||
# 5.1.1
|
||||
Released 7th June 2023.
|
||||
|
||||
## Fixes
|
||||
- Fixed blockstates being saved with the wrong version ID for 1.20.0.
|
||||
|
||||
# 5.1.2
|
||||
Released 9th June 2023.
|
||||
|
||||
**This release includes changes from the following releases:**
|
||||
- [4.22.1](https://github.com/pmmp/PocketMine-MP/blob/4.22.1/changelogs/4.22.md#4221) - Teleportation client bug workarounds
|
||||
|
||||
This release contains no other changes.
|
||||
|
||||
# 5.1.3
|
||||
Released 1st July 2023.
|
||||
|
||||
**This release includes changes from the following releases:**
|
||||
- [4.22.2](https://github.com/pmmp/PocketMine-MP/blob/4.22.2/changelogs/4.22.md#4222) - Authentication time bomb fix
|
||||
|
||||
## General
|
||||
- Updated logos to new RGB-style logo. Thanks to @MrCakeSlayer and @HBIDamian for their efforts.
|
||||
- Improved error messages generated by the world system when some version tags are missing from `level.dat` in Bedrock worlds.
|
||||
- Outsourced Composer dependencies now only receive patch updates automatically (pinned using the `~` constraint).
|
||||
- Minor and major updates now require manually updating `composer.json`, to ensure that the plugin API is not broken by libraries getting randomly updated from one patch release to the next.
|
||||
|
||||
## Documentation
|
||||
- Updated doc comment for `Player->setGamemode()` to remove outdated information.
|
||||
- Added documentation for the `$clickVector` parameter of `Block->onInteract()` to specify that it is relative to the block's position.
|
||||
- Added missing `@required` tag for `BlockStateUpgradeSchemaModelBlockRemap->newState`.
|
||||
|
||||
## Fixes
|
||||
- Fixed blue candles not appearing in the creative inventory.
|
||||
- Fixed server crash when block-picking candle cakes.
|
||||
- `World->useItemOn()` now ensures that the `$clickVector` components are always in the range of 0-1. Previously, any invalid values were accepted, potentially leading to a crash.
|
79
changelogs/5.2.md
Normal file
79
changelogs/5.2.md
Normal file
@ -0,0 +1,79 @@
|
||||
# 5.2.0
|
||||
Released 4th July 2023.
|
||||
|
||||
**For Minecraft: Bedrock Edition 1.20.0**
|
||||
|
||||
This is a minor technical update, including changes to AsyncTask error handling and support for BedrockBlockUpgradeSchema version 3.0.0.
|
||||
|
||||
**Plugin compatibility:** Plugins for previous 5.x versions will run unchanged on this release, unless they use internal APIs, reflection, or packages like the `pocketmine\network\mcpe` or `pocketmine\data` namespace.
|
||||
Do not update plugin minimum API versions unless you need new features added in this release.
|
||||
|
||||
**WARNING: If your plugin uses the `pocketmine\network\mcpe` namespace, you're not shielded by API change constraints.**
|
||||
Consider using the `mcpe-protocol` directive in `plugin.yml` as a constraint if you're using packets directly.
|
||||
|
||||
## Core
|
||||
- [BedrockBlockUpgradeSchema version 3.0.0](https://github.com/pmmp/BedrockBlockUpgradeSchema/releases/tag/3.0.0) is now supported.
|
||||
- [`ext-pmmpthread` version 6.0.4](https://github.com/pmmp/ext-pmmpthread/releases/tag/6.0.4) is now required (bug fixes required to support technical changes in this release).
|
||||
|
||||
## Performance
|
||||
- Improved performance of `AsyncPool->submitTask()` and `AsyncPool->submitTaskToWorker()`.
|
||||
- Added new timings for `AsyncTask->onProgressUpdate()` and `AsyncTask->onCompletion()`.
|
||||
|
||||
## Gameplay
|
||||
### Blocks
|
||||
- Added the following new blocks:
|
||||
- Cherry Button
|
||||
- Cherry Door
|
||||
- Cherry Fence
|
||||
- Cherry Fence Gate
|
||||
- Cherry Leaves
|
||||
- Cherry Log
|
||||
- Cherry Planks
|
||||
- Cherry Pressure Plate
|
||||
- Cherry Sign
|
||||
- Cherry Slab
|
||||
- Cherry Stairs
|
||||
- Cherry Trapdoor
|
||||
- Cherry Wood
|
||||
- Glow Lichen
|
||||
- Piglin Head
|
||||
|
||||
## Tools
|
||||
- `generate-block-upgrade-schema.php` now supports generating schemas a la BedrockBlockUpgradeSchema version 3.0.0, using `newFlattenedName` to reduce schema size.
|
||||
- Improved property remapping detection in `generate-block-upgrade-schema.php`. It now detects related properties with more confidence (even when multiple properties were change), and no longer considers unrelated properties as mapped (e.g. `mapped_type` and `deprecated` in 1.9->1.10).
|
||||
|
||||
## API
|
||||
### `pocketmine\data\bedrock\block`
|
||||
- The following new API methods have been added:
|
||||
- `public BlockStateData->toVanillaNbt() : CompoundTag` - returns the NBT for the blockstate without any PMMP extra metadata (`toNbt()` will normally include a `PMMPDataVersion` tag).
|
||||
|
||||
### `pocketmine\data\runtime`
|
||||
- The following new API methods have been added:
|
||||
- `public RuntimeDataDescriber->facingFlags(list<int> $faces) : void`
|
||||
|
||||
### `pocketmine\scheduler`
|
||||
- `AsyncTask->onRun()` no longer tolerates uncaught exceptions.
|
||||
- This means that any uncaught exceptions thrown from `AsyncTask->onRun()` will now crash the worker thread, and by extension, the server.
|
||||
- This change makes it easier to debug errors by detecting them earlier.
|
||||
- The following API methods have been deprecated:
|
||||
- `AsyncTask->onError()`
|
||||
|
||||
## Internals
|
||||
- `AsyncTask->progressUpdates` is now lazily initialized when a task publishes a progress update.
|
||||
- This was previously not possible due to technical limitations of the `ext-pmmpthread` extension.
|
||||
- This change improves performance of `AsyncPool->submitTask()` and `AsyncPool->submitTaskToWorker()`, as well as reducing the amount of work needed to check for progress updates on tick.
|
||||
- Errors in `AsyncWorker` now cascade and crash the whole server.
|
||||
- This makes it easier to debug errors by detecting them earlier.
|
||||
- This includes all types of unexpected errors, such as OOM, uncaught exceptions, etc.
|
||||
- This change is not expected to affect normal server operation, as worker threads are not expected to crash under normal circumstances.
|
||||
- `AsyncTask::$threadLocalStorage` now uses a plain `array` instead of `ArrayObject`. The `ArrayObject` was a workaround for `ext-pthreads` to prevent thread-locals getting copied to the worker thread, and is no longer necessary.
|
||||
- Regenerated `pocketmine\data\bedrock\item\ItemTypeNames` for Bedrock 1.20 (BC breaking, some item names have changed).
|
||||
- Fixed `build/generate-item-type-names.php` not including some newer blockitems, such as doors and hanging signs.
|
||||
|
||||
# 5.2.1
|
||||
Released 11th July 2023.
|
||||
|
||||
**This release includes changes from the following releases:**
|
||||
- [4.22.3](https://github.com/pmmp/PocketMine-MP/blob/4.22.3/changelogs/4.22.md#4223) - Fixes for some crash issues
|
||||
|
||||
This release contains no other changes.
|
81
changelogs/5.3.md
Normal file
81
changelogs/5.3.md
Normal file
@ -0,0 +1,81 @@
|
||||
# 5.3.0
|
||||
Released 12th July 2023.
|
||||
|
||||
**For Minecraft: Bedrock Edition 1.20.10**
|
||||
|
||||
This is a support release for Minecraft: Bedrock Edition 1.20.10.
|
||||
|
||||
**Plugin compatibility:** Plugins for previous 5.x versions will run unchanged on this release, unless they use internal APIs, reflection, or packages like the `pocketmine\network\mcpe` or `pocketmine\data` namespace.
|
||||
Do not update plugin minimum API versions unless you need new features added in this release.
|
||||
|
||||
**WARNING: If your plugin uses the `pocketmine\network\mcpe` namespace, you're not shielded by API change constraints.**
|
||||
Consider using the `mcpe-protocol` directive in `plugin.yml` as a constraint if you're using packets directly.
|
||||
|
||||
## Interim releases
|
||||
If you're upgrading directly from 5.1.x to 5.3.x, please also read the following changelogs, as the interim releases contain important changes:
|
||||
- [5.2.0](https://github.com/pmmp/PocketMine-MP/blob/5.2.0/changelogs/5.2.md#520)
|
||||
|
||||
## Included releases
|
||||
**This release includes changes from the following releases:**
|
||||
- [4.23.0](https://github.com/pmmp/PocketMine-MP/blob/4.23.0/changelogs/4.23.md#4230) - Support for Minecraft: Bedrock Edition 1.20.10
|
||||
|
||||
## Internals
|
||||
- `BlockTypeNames`, `BlockStateNames`, `BlockStateStringValues` and `ItemTypeNames` in the `pocketmine\data\bedrock` package have BC-breaking changes to accommodate Bedrock 1.20.10.
|
||||
|
||||
# 5.3.1
|
||||
Released 14th July 2023.
|
||||
|
||||
## Included releases
|
||||
**This release includes changes from the following releases:**
|
||||
- [4.23.1](https://github.com/pmmp/PocketMine-MP/blob/4.23.1/changelogs/4.23.md#4231) - Security fixes
|
||||
|
||||
## General
|
||||
- Updated `build/php` submodule to pmmp/PHP-Binaries@e0c918d1379465964acefd562d9e48f87cfc2c9e.
|
||||
|
||||
# 5.3.2
|
||||
Released 18th July 2023.
|
||||
|
||||
## Included releases
|
||||
**This release includes changes from the following releases:**
|
||||
- [4.23.2](https://github.com/pmmp/PocketMine-MP/blob/4.23.2/changelogs/4.23.md#4232) - Fix for `sandboxId`-related login errors
|
||||
|
||||
## Documentation
|
||||
- Fixed documentation error in `StringToTParser`.
|
||||
|
||||
## Fixes
|
||||
- Fixed turtle helmet not being able to be unequipped.
|
||||
|
||||
## Internals
|
||||
- Armor pieces are no longer set back into the armor inventory if no change was made. This reduces the number of slot updates sent to clients, as well as avoiding unnecessary updates for armor pieces which have Unbreaking enchantments.
|
||||
|
||||
# 5.3.3
|
||||
Released 24th July 2023.
|
||||
|
||||
## Included releases
|
||||
**This release includes changes from the following releases:**
|
||||
- [4.23.3](https://github.com/pmmp/PocketMine-MP/blob/4.23.3/changelogs/4.23.md#4233) - Various bug fixes
|
||||
|
||||
## Fixes
|
||||
- Added a workaround for PM4 worlds with chunks corrupted by [Refaltor77/CustomItemAPI](https://github.com/Refaltor77/CustomItemAPI).
|
||||
- While this was not the fault of PocketMine-MP itself, a significant number of users were affected by this problem.
|
||||
- This error was not detected by PM4 due to missing validation of certain data which should not have existed in 1.12.
|
||||
- An error will now be logged when this corruption is detected, but the affected chunks should otherwise load normally.
|
||||
- Relaxed validation of expected 3D biome array counts per chunk in LevelDB worlds.
|
||||
- Vanilla Bedrock currently saves 24 palettes (and only 24 are required), but it saved 25, 32, or 64 biome palettes per chunk in older versions.
|
||||
- Core validation for these padding biomes was very strict, enforcing exact compliance with vanilla.
|
||||
- Since only 24 palettes are actually required, the remaining palettes may now be omitted irrespective of the chunk version.
|
||||
- An error will still be logged when this mistake is detected, but the affected chunks will otherwise load normally.
|
||||
- Fixed `/kill` not working on players who had (re)spawned in the 3 seconds immediately after (re)spawning (due to `noDamageTicks`).
|
||||
- Fixed `/kill` not working correctly for players with high levels of Health Boost or other health-altering effects.
|
||||
- Fixed netherite items being destroyed by lava.
|
||||
- Fireproof entities no longer display the burning animation when in fire or lava. This does not apply to creative players, who are immortal rather than being fireproof.
|
||||
- Fixed frosted ice melting in certain conditions which didn't match vanilla Bedrock.
|
||||
|
||||
# 5.3.4
|
||||
Released 1st August 2023.
|
||||
|
||||
## Included releases
|
||||
This release includes changes from the following releases:
|
||||
- [4.23.4](https://github.com/pmmp/PocketMine-MP/blob/4.23.4/changelogs/4.23.md#4234) - Item entity lag fix
|
||||
|
||||
This release contains no other significant changes.
|
133
changelogs/5.4.md
Normal file
133
changelogs/5.4.md
Normal file
@ -0,0 +1,133 @@
|
||||
# 5.4.0
|
||||
Released 1st August 2023.
|
||||
|
||||
**For Minecraft: Bedrock Edition 1.20.10**
|
||||
|
||||
This is a minor feature update, including a handful of new gameplay features, new plugin APIs and improvements to error reporting.
|
||||
|
||||
**Plugin compatibility:** Plugins for previous 5.x versions will run unchanged on this release, unless they use internal APIs, reflection, or packages like the `pocketmine\network\mcpe` or `pocketmine\data` namespace.
|
||||
Do not update plugin minimum API versions unless you need new features added in this release.
|
||||
|
||||
**WARNING: If your plugin uses the `pocketmine\network\mcpe` namespace, you're not shielded by API change constraints.**
|
||||
Consider using the `mcpe-protocol` directive in `plugin.yml` as a constraint if you're using packets directly.
|
||||
|
||||
## General
|
||||
- Improved error reporting for async task and thread crashes.
|
||||
- Players may now have different creative inventories.
|
||||
|
||||
## Gameplay
|
||||
### General
|
||||
- Added support for 1.5-block height sneaking.
|
||||
- Fixed missing player arm swing and sounds when punching the air.
|
||||
|
||||
### Blocks
|
||||
- Implemented the following new blocks:
|
||||
- Big Dripleaf Head
|
||||
- Big Dripleaf Stem
|
||||
- Small Dripleaf
|
||||
- Acacia saplings now grow into acacia trees.
|
||||
- Fixed melon and pumpkin stems not attaching to the correct block when growing.
|
||||
- Various blocks now drop more items when mined with a compatible tool enchanted with Fortune.
|
||||
|
||||
### Items
|
||||
- Implemented Strong Slowness potion.
|
||||
- Implemented Fortune enchantment.
|
||||
|
||||
## API
|
||||
### `pocketmine\block`
|
||||
- The following new classes have been added:
|
||||
- `utils\FortuneDropHelper` - utility methods for calculating the drop counts for Fortune-affected blocks
|
||||
- The following new API methods have been added:
|
||||
- `protected Block->getAdjacentSupportType(int $facing) : utils\SupportType` - returns the type of support provided by the block in the given direction on the adjacent face
|
||||
|
||||
### `pocketmine\entity`
|
||||
- The following new API constants have been added:
|
||||
- `Living::DEFAULT_KNOCKBACK_FORCE`
|
||||
- `Living::DEFAULT_KNOCKBACK_VERTICAL_LIMIT`
|
||||
|
||||
### `pocketmine\entity\animation`
|
||||
- `ConsumingItemAnimation` now accepts `Living` instances instead of just `Human`.
|
||||
|
||||
### `pocketmine\event`
|
||||
- The following new classes have been added:
|
||||
- `PlayerMissSwingEvent` - called when the player attempts the attack action (left click on desktop) without any target
|
||||
- This is possible thanks to the introduction of new flags in `PlayerAuthInputPacket` in Bedrock 1.20.10
|
||||
- The following new API methods have been added:
|
||||
- `public EntityDamageByEntityEvent->getVerticalKnockBackLimit() : float`
|
||||
- `public EntityDamageByEntityEvent->setVerticalKnockBackLimit(float $verticalKnockBackLimit) : void` - sets the max vertical velocity that can result from the victim being knocked back
|
||||
|
||||
### `pocketmine\player`
|
||||
- The following new API methods have been added:
|
||||
- `public Player->getCreativeInventory() : pocketmine\inventory\CreativeInventory`
|
||||
- `public Player->setCreativeInventory(pocketmine\inventory\CreativeInventory $inventory) : void`
|
||||
- `public Player->missSwing() : void` - performs actions associated with the attack action when there is no target (see `PlayerMissSwingEvent`)
|
||||
|
||||
### `pocketmine\scheduler`
|
||||
- Cancellation functionality has been removed from `AsyncTask`, as it didn't make any sense and wasn't used by anything for what it was intended for.
|
||||
- It broke sequential task execution - later tasks might depend on state from earlier tasks
|
||||
- It didn't actually cancel the task anyway - at best, it prevented it from running, but couldn't interrupt it (though interrupting a task does not make sense either)
|
||||
- The following API methods have been deprecated, and their functionality has been removed:
|
||||
- `AsyncTask->hasCancelledRun()`
|
||||
- `AsyncTask->cancelRun()`
|
||||
|
||||
## Internals
|
||||
- Uncaught exceptions and fatal errors in `AsyncTask`, threads extending `pocketmine\thread\Thread`, and `pocketmine\thread\Worker` are now recorded in crashdumps, making it significantly easier to debug errors in these areas.
|
||||
- JWT signature DER <-> raw conversions are now handled in-house using code in `JwtUtils`
|
||||
- Due to the simplicity of the conversion and only requiring a tiny subset of the ASN.1 spec, it didn't make much sense to introduce another dependency.
|
||||
- `fgrosse/phpasn1` is no longer required. This package was abandoned by its author and only used by PocketMine-MP for this one purpose.
|
||||
- Various usages of `Closure::fromCallable()` have been replaced by PHP 8.1 first-class callable syntax.
|
||||
- Blocks requiring support shifted to a "can be supported at" model, rather than "can be supported by".
|
||||
- This model reduces repeated logic when placing and performing nearby block updates (no need to hardcode facing everywhere).
|
||||
- In addition, this change facilitates the use of the newly introduced `Block->getAdjacentSupportType()` API method, reducing boilerplate support-type checking code.
|
||||
- Bell block code has been simplified and cleaned up.
|
||||
- `TallGrass` and `DoubleTallGrass` now use a shared `TallGrassTrait` to reduce code duplication.
|
||||
|
||||
# 5.4.1
|
||||
Released 8th August 2023.
|
||||
|
||||
## General
|
||||
- Updated translation data to [pmmp/Language 2.19.6](https://github.com/pmmp/Language/releases/tag/2.19.6).
|
||||
- [`ext-pmmpthread` 6.0.7](https://github.com/pmmp/ext-pmmpthread/releases/tag/6.0.7) is now required (needed for bug fixes).
|
||||
|
||||
## Fixes
|
||||
- Fixed Podzol not dropping itself when mined with Silk Touch.
|
||||
- Fixed `World->getSafeSpawn()` not accepting positions below `y=0` (world height limit change).
|
||||
- Fixed `pocketmine\thread\Thread` and `pocketmine\thread\Worker` instances not logging any information when they crash.
|
||||
- Fixed `CraftItemEvent` not cloning returned items.
|
||||
|
||||
## Internals
|
||||
- Foreach by-reference is now disallowed via a custom PHPStan rule.
|
||||
|
||||
# 5.4.2
|
||||
Released 9th August 2023.
|
||||
|
||||
## Included releases
|
||||
- [4.23.5](https://github.com/pmmp/PocketMine-MP/blob/4.23.5/changelogs/4.23.md#4235) - Minor bug fixes
|
||||
|
||||
## Fixes
|
||||
- Fixed cake accepting candle placement when slices have already been eaten.
|
||||
- Fixed fire charges not lighting candles.
|
||||
|
||||
# 5.4.3
|
||||
Released 21st August 2023.
|
||||
|
||||
## Included releases
|
||||
- [4.23.6](https://github.com/pmmp/PocketMine-MP/blob/4.23.6/changelogs/4.23.md#4236) - Armor inventory client bug workaround
|
||||
|
||||
## Fixes
|
||||
- Fixed crashdumps not generating correctly on fatal errors.
|
||||
- Fixed `PotionCauldron::setPotionItem()` not validating the item type.
|
||||
- Fixed chorus fruit not considering teleport destinations below y=0.
|
||||
- Fixed cake dropping itself when mined.
|
||||
|
||||
# 5.4.4
|
||||
Released 6th September 2023.
|
||||
|
||||
## General
|
||||
- Crashdumps caused by non-phar plugins are now submitted to the Crash Archive, the same as other plugins. Previously, non-phar plugin crashes would not be submitted, causing maintainers to potentially miss important issues.
|
||||
|
||||
## Fixes
|
||||
- Fixed player Y coordinates sometimes being slightly below the top of the block they were standing on (floating point error due to subtracting eye height).
|
||||
- Fixed template slot of smithing tables not accepting any items.
|
||||
- `tools/generate-bedrock-data-from-packets.php` is now significantly less spammy when warning about duplicated recipes.
|
||||
- Fixed empty stack traces in `lastError` data of crashdumps.
|
156
changelogs/5.5-beta.md
Normal file
156
changelogs/5.5-beta.md
Normal file
@ -0,0 +1,156 @@
|
||||
# 5.5.0-BETA1
|
||||
Released 23rd August 2023.
|
||||
|
||||
**For Minecraft: Bedrock Edition 1.20.10**
|
||||
|
||||
This is a minor feature release, including performance improvements, new API methods, and new gameplay features.
|
||||
|
||||
**Plugin compatibility:** Plugins for previous 5.x versions will run unchanged on this release, unless they use internal APIs, reflection, or packages like the `pocketmine\network\mcpe` or `pocketmine\data` namespace.
|
||||
Do not update plugin minimum API versions unless you need new features added in this release.
|
||||
|
||||
**WARNING: If your plugin uses the `pocketmine\network\mcpe` namespace, you're not shielded by API change constraints.**
|
||||
Consider using the `mcpe-protocol` directive in `plugin.yml` as a constraint if you're using packets directly.
|
||||
|
||||
## Dependencies
|
||||
- Updated `pocketmine/math` dependency to [`1.0.0`](https://github.com/pmmp/Math/releases/tag/1.0.0).
|
||||
- Updated `pocketmine/nbt` dependency to [`1.0.0`](https://github.com/pmmp/NBT/releases/tag/1.0.0).
|
||||
|
||||
## Performance
|
||||
- Some events are now no longer fired if no handlers are registered.
|
||||
- This improves performance by avoiding unnecessary object allocations and function calls.
|
||||
- Events such as `DataPacketReceiveEvent`, `DataPacketSendEvent` and `PlayerMoveEvent` are optimized away almost completely by this change, offering some much-needed performance gains.
|
||||
- Significantly improved performance of small moving entities, such as dropped items.
|
||||
- This was achieved by a combination of changes, which together improved observed performance with 2000 item entities moving in water by 30-40%.
|
||||
- The benefit of this will be most noticeable in SkyBlock servers, where large cactus farms can generate thousands of dropped items.
|
||||
- `World->getCollisionBoxes()` now uses an improved search method, which reduces the work done by the function by almost 90% for small entities.
|
||||
- This improves performance of collision detection for small entities, such as dropped items.
|
||||
|
||||
## Gameplay
|
||||
### General
|
||||
- Implemented enchanting using an enchanting table (yes, finally!)
|
||||
- Thanks to [@S3v3Nice](https://github.com/S3v3Nice) for investing lots of time and effort into developing this.
|
||||
- Since this feature is quite complex, it's possible there may be bugs. Please be vigilant and report any issues you find.
|
||||
|
||||
### Blocks
|
||||
- The following new blocks have been implemented:
|
||||
- Pink Petals
|
||||
- Pressure plates are now functional, in the sense that they react when entities stand on them and perform the correct logic.
|
||||
- Note that since redstone is not yet implemented, pressure plates do not activate any redstone devices, similar to buttons and levers.
|
||||
- Signs can now be edited by right-clicking them.
|
||||
- Signs can now be waxed using a honeycomb, which prevents them from being edited.
|
||||
|
||||
### Items
|
||||
- The following new items have been implemented:
|
||||
- Enchanted Book
|
||||
|
||||
## API
|
||||
### `pocketmine\block`
|
||||
- The following new API methods have been added:
|
||||
- `public Block->getEnchantmentTags() : list<string>` returns a list of strings indicating which types of enchantment can be applied to the block when in item form
|
||||
- `public BlockTypeInfo->getEnchantmentTags() : list<string>`
|
||||
- `protected PressurePlate->getActivationBox() : AxisAlignedBB` - returns the AABB entities must intersect with in order to activate the pressure plate (not the same as the visual shape)
|
||||
- `protected PressurePlate->hasOutputSignal() : bool` - returns whether the pressure plate has an output signal - this should be implemented by subclasses
|
||||
- `protected PressurePlate->calculatePlateState() : array{Block, ?bool}` - returns the state the pressure plate will change to if the given list of entities are standing on it, and a bool indicating whether the plate activated or deactivated this tick
|
||||
- `protected PressurePlate->filterIrrelevantEntities(list<Entity> $entities) : list<Entity>` - returns the given list filtered of entities that don't affect the plate's state (e.g. dropped items don't affect stone pressure plates)
|
||||
- `public BaseSign->isWaxed() : bool`
|
||||
- `public BaseSign->setWaxed(bool $waxed) : $this`
|
||||
- `public inventory\EnchantInventory->getInput() : Item`
|
||||
- `public inventory\EnchantInventory->getLapis() : Item`
|
||||
- `public inventory\EnchantInventory->getOutput(int $optionId) : ?Item` - returns the item that would be produced if the input item was enchanted with the selected option, or `null` if the option is invalid
|
||||
- `public inventory\EnchantInventory->getOption(int $optionId) : EnchantOption` - returns the enchanting option at the given index
|
||||
- The following API methods have signature changes:
|
||||
- `BlockTypeInfo->__construct()` now accepts an optional `list<string> $enchantmentTags` parameter
|
||||
- `PressurePlate->__construct()` now accepts an optional `int $deactivationDelayTicks` parameter
|
||||
- `WeightedPressurePlate->__construct()` now accepts optional `int $deactivationDelayTicks` and `float $signalStrengthFactor` parameters
|
||||
- `SimplePressurePlate->__construct()` now accepts an optional `int $deactivationDelayTicks` parameter
|
||||
- The following new classes have been added:
|
||||
- `PinkPetals`
|
||||
- `utils\BlockEventHelper` - provides helper methods for calling block-related events
|
||||
- The following classes have been deprecated:
|
||||
- `WeightedPressurePlateLight`
|
||||
- `WeightedPressurePlateHeavy`
|
||||
|
||||
### `pocketmine\entity`
|
||||
- The following new API methods have been added:
|
||||
- `public Human->getEnchantmentSeed() : int` - returns the current seed used to randomize options shown on the enchanting table for this human
|
||||
- `public Human->setEnchantmentSeed(int $seed) : void`
|
||||
- `public Human->regenerateEnchantmentSeed() : void` - returns a new randomly generated seed which can be set with `setEnchantmentSeed()`
|
||||
|
||||
### `pocketmine\event`
|
||||
- The following new classes have been added:
|
||||
- `block\FarmlandHydrationChangeEvent` - called when farmland is hydrated or dehydrated
|
||||
- `block\PressurePlateUpdateEvent` - called when a pressure plate is activated or changes its power output
|
||||
- `player\PlayerEnchantingOptionsRequestEvent` - called when a player puts an item to be enchanted into an enchanting table, to allow plugins to modify the enchanting options shown
|
||||
- `player\PlayerItemEnchantEvent` - called when a player enchants an item in an enchanting table
|
||||
- `world\WorldDifficultyChangeEvent` - called when a world's difficulty is changed
|
||||
- The following new API methods have been added:
|
||||
- `public static Event::hasHandlers() : bool` - returns whether the event class has any registered handlers - used like `SomeEvent::hasHandlers()`
|
||||
- `public HandlerListManager->getHandlersFor(class-string<? extends Event> $event) : list<RegisteredListener>` - returns a list of all registered listeners for the given event class, using cache if available
|
||||
|
||||
### `pocketmine\inventory\transaction`
|
||||
- The following new classes have been added:
|
||||
- `EnchantingTransaction` - used when a player enchants an item in an enchanting table
|
||||
|
||||
### `pocketmine\item`
|
||||
- The following new API methods have been added:
|
||||
- `public Armor->getMaterial() : ArmorMaterial` - returns an object containing properties shared by all items of the same armor material
|
||||
- `public ArmorTypeInfo->getMaterial() : ArmorMaterial`
|
||||
- `public Item->getEnchantability() : int` - returns the enchantability value of the item - higher values increase the chance of more powerful enchantments being offered by an enchanting table
|
||||
- `public Item->getEnchantmentTags() : list<string>` - returns a list of strings indicating which types of enchantment can be applied to the item
|
||||
- `public ToolTier->getEnchantability() : int`
|
||||
- The following API methods have signature changes:
|
||||
- `Item->__construct()` now accepts an optional `list<string> $enchantmentTags` parameter
|
||||
- `ArmorTypeInfo->__construct()` now accepts an optional `?ArmorMaterial $material` parameter
|
||||
- The following new classes have been added:
|
||||
- `ArmorMaterial` - container for shared armor properties
|
||||
- `VanillaArmorMaterials` - all vanilla armor materials
|
||||
- `EnchantedBook` - represents an enchanted book item
|
||||
|
||||
### `pocketmine\item\enchantment`
|
||||
- The following new classes have been added:
|
||||
- `AvailableEnchantmentRegistry` - enchantments to be displayed on the enchanting table are selected from here - custom enchantments may be added
|
||||
- `EnchantingHelper` - static class containing various helper methods for enchanting tables
|
||||
- `EnchantingOption` - represents an option on the enchanting table menu
|
||||
- `IncompatibleEnchantmentGroups` - list of constants naming groups of enchantments that are incompatible with each other - custom enchantments may be added using these group names to make them incompatible with existing enchantments in the same group
|
||||
- `IncompatibleEnchantmentRegistry` - manages which enchantments are considered incompatible with each other - custom enchantments may be added using existing group names to make them incompatible with existing enchantments in the same group, or to entirely new groups
|
||||
- `ItemEnchantmentTagRegistry` - manages item enchantment compatibility tags and which tags include which other tags
|
||||
- `ItemEnchantmentTags` - list of constants naming item types for enchantment compatibility checks
|
||||
- The following classes have been deprecated
|
||||
- `ItemFlags`
|
||||
- The following API methods have been added:
|
||||
- `public Enchantment->isCompatibleWith(Enchantment $other) : bool`
|
||||
- `public Enchantment->getMinEnchantingPower()` - returns the minimum enchanting power (derived from enchantability and number of bookshelves) needed to allow this enchantment to show on the enchanting table with a given level
|
||||
- `public Enchantment->getMaxEnchantingPower()` - upper limit of enchanting power for this enchantment to be offered on the enchanting table with a given level
|
||||
- The following API methods have signature changes:
|
||||
- `Enchantment->__construct()` now accepts optional `(\Closure(int $level) : int)|null $minEnchantingPower` and `int $enchantingPowerRange` parameters
|
||||
- `Enchantment->__construct()` parameters `$primaryItemFlags` and `$secondaryItemFlags` are now deprecated and no longer used
|
||||
- `ProtectionEnchantment->__construct()` has extra parameters to reflect `Enchantment->__construct()` changes
|
||||
- The following API methods have been deprecated:
|
||||
- `Enchantment->getPrimaryItemFlags()` - use API methods provided by `AvailableEnchantmentRegistry` instead
|
||||
- `Enchantment->getSecondaryItemFlags()` - use API methods provided by `AvailableEnchantmentRegistry` instead
|
||||
- `Enchantment->hasPrimaryItemType()`
|
||||
- `Enchantment->hasSecondaryItemType()`
|
||||
|
||||
### `pocketmine\plugin`
|
||||
- The following new API methods have been added:
|
||||
- `public PluginBase->getResourcePath(string $filename) : string` - returns a URI to an embedded resource file that can be used with `file_get_contents()` and similar functions
|
||||
- `public PluginBase->getResourceFolder() : string` - returns a URI to the plugin's folder of embedded resources
|
||||
- The following API methods have been deprecated:
|
||||
- `PluginBase->getResource()` - prefer using `getResourcePath()` with `file_get_contents()` or other PHP built-in functions instead
|
||||
|
||||
### `pocketmine\resourcepacks`
|
||||
- The following new API methods have been added:
|
||||
- `public ResourcePackManager->setResourcePacksRequired(bool $value) : void` - sets whether players must accept resource packs in order to join
|
||||
|
||||
### `pocketmine\world\generator`
|
||||
- The following new API methods have been added:
|
||||
- `public GeneratorManager->addAlias(string $name, string $alias) : void` - allows registering a generator alias without copying the generator registration parameters
|
||||
|
||||
### `pocketmine\world\sound`
|
||||
- The following new classes have been added:
|
||||
- `PressurePlateActivateSound`
|
||||
- `PressurePlateDeactivateSound`
|
||||
|
||||
### `pocketmine\utils`
|
||||
- The following new API methods have been added:
|
||||
- `public StringToTParser->registerAlias(string $existing, string $alias) : void` - allows registering a string alias without copying registration parameters
|
162
changelogs/5.5.md
Normal file
162
changelogs/5.5.md
Normal file
@ -0,0 +1,162 @@
|
||||
# 5.5.0
|
||||
Released 6th September 2023.
|
||||
|
||||
**For Minecraft: Bedrock Edition 1.20.10**
|
||||
|
||||
This is a minor feature release, including performance improvements, new API methods, and new gameplay features.
|
||||
|
||||
**Plugin compatibility:** Plugins for previous 5.x versions will run unchanged on this release, unless they use internal APIs, reflection, or packages like the `pocketmine\network\mcpe` or `pocketmine\data` namespace.
|
||||
Do not update plugin minimum API versions unless you need new features added in this release.
|
||||
|
||||
**WARNING: If your plugin uses the `pocketmine\network\mcpe` namespace, you're not shielded by API change constraints.**
|
||||
Consider using the `mcpe-protocol` directive in `plugin.yml` as a constraint if you're using packets directly.
|
||||
|
||||
## Dependencies
|
||||
- Updated `pocketmine/math` dependency to [`1.0.0`](https://github.com/pmmp/Math/releases/tag/1.0.0).
|
||||
- Updated `pocketmine/nbt` dependency to [`1.0.0`](https://github.com/pmmp/NBT/releases/tag/1.0.0).
|
||||
|
||||
## Performance
|
||||
- Some events are now no longer fired if no handlers are registered.
|
||||
- This improves performance by avoiding unnecessary object allocations and function calls.
|
||||
- Events such as `DataPacketReceiveEvent`, `DataPacketSendEvent` and `PlayerMoveEvent` are optimized away almost completely by this change, offering some much-needed performance gains.
|
||||
- Significantly improved performance of small moving entities, such as dropped items.
|
||||
- This was achieved by a combination of changes, which together improved observed performance with 2000 item entities moving in water by 30-40%.
|
||||
- The benefit of this will be most noticeable in SkyBlock servers, where large cactus farms can generate thousands of dropped items.
|
||||
- `World->getCollisionBoxes()` now uses an improved search method, which reduces the work done by the function by almost 90% for small entities.
|
||||
- This improves performance of collision detection for small entities, such as dropped items.
|
||||
|
||||
## Gameplay
|
||||
### General
|
||||
- Implemented enchanting using an enchanting table (yes, finally!)
|
||||
- Thanks to [@S3v3Nice](https://github.com/S3v3Nice) for investing lots of time and effort into developing this.
|
||||
- Since this feature is quite complex, it's possible there may be bugs. Please be vigilant and report any issues you find.
|
||||
|
||||
### Blocks
|
||||
- The following new blocks have been implemented:
|
||||
- Pink Petals
|
||||
- Pressure plates are now functional, in the sense that they react when entities stand on them and perform the correct logic.
|
||||
- Note that since redstone is not yet implemented, pressure plates do not activate any redstone devices, similar to buttons and levers.
|
||||
- Signs can now be edited by right-clicking them.
|
||||
- Signs can now be waxed using a honeycomb, which prevents them from being edited.
|
||||
|
||||
### Items
|
||||
- The following new items have been implemented:
|
||||
- Enchanted Book
|
||||
|
||||
## API
|
||||
### `pocketmine\block`
|
||||
- The following new API methods have been added:
|
||||
- `public Block->getEnchantmentTags() : list<string>` returns a list of strings indicating which types of enchantment can be applied to the block when in item form
|
||||
- `public BlockTypeInfo->getEnchantmentTags() : list<string>`
|
||||
- `protected PressurePlate->getActivationBox() : AxisAlignedBB` - returns the AABB entities must intersect with in order to activate the pressure plate (not the same as the visual shape)
|
||||
- `protected PressurePlate->hasOutputSignal() : bool` - returns whether the pressure plate has an output signal - this should be implemented by subclasses
|
||||
- `protected PressurePlate->calculatePlateState() : array{Block, ?bool}` - returns the state the pressure plate will change to if the given list of entities are standing on it, and a bool indicating whether the plate activated or deactivated this tick
|
||||
- `protected PressurePlate->filterIrrelevantEntities(list<Entity> $entities) : list<Entity>` - returns the given list filtered of entities that don't affect the plate's state (e.g. dropped items don't affect stone pressure plates)
|
||||
- `public BaseSign->isWaxed() : bool`
|
||||
- `public BaseSign->setWaxed(bool $waxed) : $this`
|
||||
- `public inventory\EnchantInventory->getInput() : Item`
|
||||
- `public inventory\EnchantInventory->getLapis() : Item`
|
||||
- `public inventory\EnchantInventory->getOutput(int $optionId) : ?Item` - returns the item that would be produced if the input item was enchanted with the selected option, or `null` if the option is invalid
|
||||
- `public inventory\EnchantInventory->getOption(int $optionId) : EnchantOption` - returns the enchanting option at the given index
|
||||
- The following API methods have signature changes:
|
||||
- `BlockTypeInfo->__construct()` now accepts an optional `list<string> $enchantmentTags` parameter
|
||||
- `PressurePlate->__construct()` now accepts an optional `int $deactivationDelayTicks` parameter
|
||||
- `WeightedPressurePlate->__construct()` now accepts optional `int $deactivationDelayTicks` and `float $signalStrengthFactor` parameters
|
||||
- `SimplePressurePlate->__construct()` now accepts an optional `int $deactivationDelayTicks` parameter
|
||||
- The following new classes have been added:
|
||||
- `PinkPetals`
|
||||
- `utils\BlockEventHelper` - provides helper methods for calling block-related events
|
||||
- The following classes have been deprecated:
|
||||
- `WeightedPressurePlateLight`
|
||||
- `WeightedPressurePlateHeavy`
|
||||
|
||||
### `pocketmine\entity`
|
||||
- The following new API methods have been added:
|
||||
- `public Human->getEnchantmentSeed() : int` - returns the current seed used to randomize options shown on the enchanting table for this human
|
||||
- `public Human->setEnchantmentSeed(int $seed) : void`
|
||||
- `public Human->regenerateEnchantmentSeed() : void` - returns a new randomly generated seed which can be set with `setEnchantmentSeed()`
|
||||
|
||||
### `pocketmine\event`
|
||||
- The following new classes have been added:
|
||||
- `block\FarmlandHydrationChangeEvent` - called when farmland is hydrated or dehydrated
|
||||
- `block\PressurePlateUpdateEvent` - called when a pressure plate is activated or changes its power output
|
||||
- `player\PlayerEnchantingOptionsRequestEvent` - called when a player puts an item to be enchanted into an enchanting table, to allow plugins to modify the enchanting options shown
|
||||
- `player\PlayerItemEnchantEvent` - called when a player enchants an item in an enchanting table
|
||||
- `world\WorldDifficultyChangeEvent` - called when a world's difficulty is changed
|
||||
- The following new API methods have been added:
|
||||
- `public static Event::hasHandlers() : bool` - returns whether the event class has any registered handlers - used like `SomeEvent::hasHandlers()`
|
||||
- `public HandlerListManager->getHandlersFor(class-string<? extends Event> $event) : list<RegisteredListener>` - returns a list of all registered listeners for the given event class, using cache if available
|
||||
|
||||
### `pocketmine\inventory\transaction`
|
||||
- The following new classes have been added:
|
||||
- `EnchantingTransaction` - used when a player enchants an item in an enchanting table
|
||||
|
||||
### `pocketmine\item`
|
||||
- The following new API methods have been added:
|
||||
- `public Armor->getMaterial() : ArmorMaterial` - returns an object containing properties shared by all items of the same armor material
|
||||
- `public ArmorTypeInfo->getMaterial() : ArmorMaterial`
|
||||
- `public Item->getEnchantability() : int` - returns the enchantability value of the item - higher values increase the chance of more powerful enchantments being offered by an enchanting table
|
||||
- `public Item->getEnchantmentTags() : list<string>` - returns a list of strings indicating which types of enchantment can be applied to the item
|
||||
- `public ToolTier->getEnchantability() : int`
|
||||
- The following API methods have signature changes:
|
||||
- `Item->__construct()` now accepts an optional `list<string> $enchantmentTags` parameter
|
||||
- `ArmorTypeInfo->__construct()` now accepts an optional `?ArmorMaterial $material` parameter
|
||||
- The following new classes have been added:
|
||||
- `ArmorMaterial` - container for shared armor properties
|
||||
- `VanillaArmorMaterials` - all vanilla armor materials
|
||||
- `EnchantedBook` - represents an enchanted book item
|
||||
|
||||
### `pocketmine\item\enchantment`
|
||||
- The following new classes have been added:
|
||||
- `AvailableEnchantmentRegistry` - enchantments to be displayed on the enchanting table are selected from here - custom enchantments may be added
|
||||
- `EnchantingHelper` - static class containing various helper methods for enchanting tables
|
||||
- `EnchantingOption` - represents an option on the enchanting table menu
|
||||
- `IncompatibleEnchantmentGroups` - list of constants naming groups of enchantments that are incompatible with each other - custom enchantments may be added using these group names to make them incompatible with existing enchantments in the same group
|
||||
- `IncompatibleEnchantmentRegistry` - manages which enchantments are considered incompatible with each other - custom enchantments may be added using existing group names to make them incompatible with existing enchantments in the same group, or to entirely new groups
|
||||
- `ItemEnchantmentTagRegistry` - manages item enchantment compatibility tags and which tags include which other tags
|
||||
- `ItemEnchantmentTags` - list of constants naming item types for enchantment compatibility checks
|
||||
- The following classes have been deprecated
|
||||
- `ItemFlags`
|
||||
- The following API methods have been added:
|
||||
- `public Enchantment->isCompatibleWith(Enchantment $other) : bool`
|
||||
- `public Enchantment->getMinEnchantingPower()` - returns the minimum enchanting power (derived from enchantability and number of bookshelves) needed to allow this enchantment to show on the enchanting table with a given level
|
||||
- `public Enchantment->getMaxEnchantingPower()` - upper limit of enchanting power for this enchantment to be offered on the enchanting table with a given level
|
||||
- The following API methods have signature changes:
|
||||
- `Enchantment->__construct()` now accepts optional `(\Closure(int $level) : int)|null $minEnchantingPower` and `int $enchantingPowerRange` parameters
|
||||
- `Enchantment->__construct()` parameters `$primaryItemFlags` and `$secondaryItemFlags` are now deprecated and no longer used
|
||||
- `ProtectionEnchantment->__construct()` has extra parameters to reflect `Enchantment->__construct()` changes
|
||||
- The following API methods have been deprecated:
|
||||
- `Enchantment->getPrimaryItemFlags()` - use API methods provided by `AvailableEnchantmentRegistry` instead
|
||||
- `Enchantment->getSecondaryItemFlags()` - use API methods provided by `AvailableEnchantmentRegistry` instead
|
||||
- `Enchantment->hasPrimaryItemType()`
|
||||
- `Enchantment->hasSecondaryItemType()`
|
||||
|
||||
### `pocketmine\plugin`
|
||||
- The following new API methods have been added:
|
||||
- `public PluginBase->getResourcePath(string $filename) : string` - returns a URI to an embedded resource file that can be used with `file_get_contents()` and similar functions
|
||||
- `public PluginBase->getResourceFolder() : string` - returns a URI to the plugin's folder of embedded resources
|
||||
- The following API methods have been deprecated:
|
||||
- `PluginBase->getResource()` - prefer using `getResourcePath()` with `file_get_contents()` or other PHP built-in functions instead
|
||||
|
||||
### `pocketmine\resourcepacks`
|
||||
- The following new API methods have been added:
|
||||
- `public ResourcePackManager->setResourcePacksRequired(bool $value) : void` - sets whether players must accept resource packs in order to join
|
||||
|
||||
### `pocketmine\world\generator`
|
||||
- The following new API methods have been added:
|
||||
- `public GeneratorManager->addAlias(string $name, string $alias) : void` - allows registering a generator alias without copying the generator registration parameters
|
||||
|
||||
### `pocketmine\world\sound`
|
||||
- The following new classes have been added:
|
||||
- `PressurePlateActivateSound`
|
||||
- `PressurePlateDeactivateSound`
|
||||
|
||||
### `pocketmine\utils`
|
||||
- The following new API methods have been added:
|
||||
- `public StringToTParser->registerAlias(string $existing, string $alias) : void` - allows registering a string alias without copying registration parameters
|
||||
|
||||
## Internals
|
||||
- Various `TypeIdMap` classes in the `pocketmine\data\bedrock` package now use the new `IntSaveIdMapTrait` to reduce code duplication.
|
||||
- Added a new `ServerProperties` class containing constants for all known `server.properties` keys.
|
||||
- Added a new `YmlServerProperties` class containing generated constants for all known `pocketmine.yml` keys. These keys can be used with `Config->getNested()`.
|
||||
|
34
changelogs/5.6.md
Normal file
34
changelogs/5.6.md
Normal file
@ -0,0 +1,34 @@
|
||||
# 5.6.0
|
||||
Released 20th September 2023.
|
||||
|
||||
**For Minecraft: Bedrock Edition 1.20.30**
|
||||
|
||||
This is a support release for Minecraft: Bedrock Edition 1.20.30.
|
||||
|
||||
**Plugin compatibility:** Plugins for previous 5.x versions will run unchanged on this release, unless they use internal APIs, reflection, or packages like the `pocketmine\network\mcpe` or `pocketmine\data` namespace.
|
||||
Do not update plugin minimum API versions unless you need new features added in this release.
|
||||
|
||||
**WARNING: If your plugin uses the `pocketmine\network\mcpe` namespace, you're not shielded by API change constraints.**
|
||||
Consider using the `mcpe-protocol` directive in `plugin.yml` as a constraint if you're using packets directly.
|
||||
|
||||
## General
|
||||
- Added support for Minecraft: Bedrock Edition 1.20.30.
|
||||
- Removed support for older versions.
|
||||
|
||||
## Fixes
|
||||
- Fixed support conditions for hanging roots, cave vines and dead bushes.
|
||||
- Fixed connection conditions for fences, glass panes, iron bars, and walls.
|
||||
|
||||
# 5.6.1
|
||||
Released 20th October 2023.
|
||||
|
||||
## Performance
|
||||
- Improved performance of cactus growth by disabling neighbour updates when only the age property was updated. While this isn't a perfect solution, it provides significant performance gains for servers with large cactus farms.
|
||||
|
||||
## Fixes
|
||||
- Fixed `tools/generate-bedrock-data-from-packets.php` incorrectly interpreting network meta as blockstates in some cases (broken crafting recipes).
|
||||
- Fixed crafting recipes involving beds, skulls and some other items not working correctly (incorrectly interpreted data).
|
||||
- Fixed crashes when flower pot or cauldron blockentities exist in places where they shouldn't (leftovers from upgraded PM3 worlds).
|
||||
- Fixed `Entity->broadcastSound()` not firing `WorldSoundEvent` (bypassing internal sound system).
|
||||
- Fixed wooden signs, buttons and doors not being able to be used as furnace fuel.
|
||||
- Fixed bone meal and tools only working when used on the top side of dirt and grass. Bone meal now works from any side, and tools work on any side except the bottom.
|
@ -5,7 +5,7 @@
|
||||
"homepage": "https://pmmp.io",
|
||||
"license": "LGPL-3.0",
|
||||
"require": {
|
||||
"php": "^8.0",
|
||||
"php": "^8.1",
|
||||
"php-64bit": "*",
|
||||
"ext-chunkutils2": "^0.3.1",
|
||||
"ext-crypto": "^0.3.1",
|
||||
@ -22,7 +22,7 @@
|
||||
"ext-openssl": "*",
|
||||
"ext-pcre": "*",
|
||||
"ext-phar": "*",
|
||||
"ext-pthreads": "^5.1",
|
||||
"ext-pmmpthread": "^6.0.7",
|
||||
"ext-reflection": "*",
|
||||
"ext-simplexml": "*",
|
||||
"ext-sockets": "*",
|
||||
@ -31,34 +31,31 @@
|
||||
"ext-zip": "*",
|
||||
"ext-zlib": ">=1.2.11",
|
||||
"composer-runtime-api": "^2.0",
|
||||
"adhocore/json-comment": "^1.1",
|
||||
"fgrosse/phpasn1": "^2.3",
|
||||
"netresearch/jsonmapper": "^4.0",
|
||||
"pocketmine/bedrock-block-upgrade-schema": "~1.1.1+bedrock-1.19.70",
|
||||
"pocketmine/bedrock-data": "~2.1.1+bedrock-1.19.70",
|
||||
"pocketmine/bedrock-item-upgrade-schema": "~1.1.0+bedrock-1.19.70",
|
||||
"pocketmine/bedrock-protocol": "~20.1.1+bedrock-1.19.70",
|
||||
"adhocore/json-comment": "~1.2.0",
|
||||
"pocketmine/netresearch-jsonmapper": "~v4.2.1000",
|
||||
"pocketmine/bedrock-block-upgrade-schema": "~3.2.0+bedrock-1.20.30",
|
||||
"pocketmine/bedrock-data": "~2.5.0+bedrock-1.20.30",
|
||||
"pocketmine/bedrock-item-upgrade-schema": "~1.5.0+bedrock-1.20.30",
|
||||
"pocketmine/bedrock-protocol": "~24.0.0+bedrock-1.20.30",
|
||||
"pocketmine/binaryutils": "^0.2.1",
|
||||
"pocketmine/callback-validator": "^1.0.2",
|
||||
"pocketmine/classloader": "^0.3.0",
|
||||
"pocketmine/color": "^0.3.0",
|
||||
"pocketmine/errorhandler": "^0.6.0",
|
||||
"pocketmine/locale-data": "~2.19.0",
|
||||
"pocketmine/log": "^0.4.0",
|
||||
"pocketmine/log-pthreads": "^0.5.0",
|
||||
"pocketmine/math": "^0.4.0",
|
||||
"pocketmine/nbt": "^0.3.2",
|
||||
"pocketmine/math": "~1.0.0",
|
||||
"pocketmine/nbt": "~1.0.0",
|
||||
"pocketmine/raklib": "^0.15.0",
|
||||
"pocketmine/raklib-ipc": "^0.2.0",
|
||||
"pocketmine/snooze": "^0.4.0",
|
||||
"ramsey/uuid": "^4.1",
|
||||
"symfony/filesystem": "^5.4"
|
||||
"pocketmine/snooze": "^0.5.0",
|
||||
"ramsey/uuid": "~4.7.0",
|
||||
"symfony/filesystem": "~6.3.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpstan/phpstan": "1.10.11",
|
||||
"phpstan/phpstan": "1.10.39",
|
||||
"phpstan/phpstan-phpunit": "^1.1.0",
|
||||
"phpstan/phpstan-strict-rules": "^1.2.0",
|
||||
"phpunit/phpunit": "^9.2"
|
||||
"phpunit/phpunit": "~10.3.0 || ~10.2.0 || ~10.1.0"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
@ -76,7 +73,7 @@
|
||||
},
|
||||
"config": {
|
||||
"platform": {
|
||||
"php": "8.0.0"
|
||||
"php": "8.1.0"
|
||||
},
|
||||
"sort-packages": true
|
||||
},
|
||||
|
1267
composer.lock
generated
1267
composer.lock
generated
File diff suppressed because it is too large
Load Diff
@ -11,6 +11,7 @@ includes:
|
||||
|
||||
rules:
|
||||
- pocketmine\phpstan\rules\DisallowEnumComparisonRule
|
||||
- pocketmine\phpstan\rules\DisallowForeachByReferenceRule
|
||||
- pocketmine\phpstan\rules\UnsafeForeachArrayOfStringRule
|
||||
# - pocketmine\phpstan\rules\ThreadedSupportedTypesRule
|
||||
|
||||
@ -43,8 +44,7 @@ parameters:
|
||||
stubFiles:
|
||||
- tests/phpstan/stubs/JsonMapper.stub
|
||||
- tests/phpstan/stubs/leveldb.stub
|
||||
- tests/phpstan/stubs/phpasn1.stub
|
||||
- tests/phpstan/stubs/pthreads.stub
|
||||
- tests/phpstan/stubs/pmmpthread.stub
|
||||
reportUnmatchedIgnoredErrors: false #no other way to silence platform-specific non-warnings
|
||||
staticReflectionClassNamePatterns:
|
||||
- "#^COM$#"
|
||||
|
@ -85,8 +85,11 @@ network:
|
||||
batch-threshold: 256
|
||||
#Compression level used when sending batched packets. Higher = more CPU, less bandwidth usage
|
||||
compression-level: 6
|
||||
#Use AsyncTasks for compression. Adds half/one tick delay, less CPU load on main thread
|
||||
#Use AsyncTasks for compression during the main game session. Increases latency, but may reduce main thread load
|
||||
async-compression: false
|
||||
#Threshold for async compression, in bytes. Only packets larger than this will be compressed asynchronously
|
||||
#Due to large overhead of AsyncTask, async compression isn't worth it except for large packets
|
||||
async-compression-threshold: 10000
|
||||
#Experimental. Use UPnP to automatically port forward
|
||||
upnp-forwarding: false
|
||||
#Maximum size in bytes of packets sent over the network (default 1492 bytes). Packets larger than this will be
|
||||
|
@ -30,6 +30,7 @@ use pocketmine\scheduler\GarbageCollectionTask;
|
||||
use pocketmine\timings\Timings;
|
||||
use pocketmine\utils\Process;
|
||||
use pocketmine\utils\Utils;
|
||||
use pocketmine\YmlServerProperties as Yml;
|
||||
use Symfony\Component\Filesystem\Path;
|
||||
use function arsort;
|
||||
use function count;
|
||||
@ -109,7 +110,7 @@ class MemoryManager{
|
||||
}
|
||||
|
||||
private function init(ServerConfigGroup $config) : void{
|
||||
$this->memoryLimit = $config->getPropertyInt("memory.main-limit", 0) * 1024 * 1024;
|
||||
$this->memoryLimit = $config->getPropertyInt(Yml::MEMORY_MAIN_LIMIT, 0) * 1024 * 1024;
|
||||
|
||||
$defaultMemory = 1024;
|
||||
|
||||
@ -127,7 +128,7 @@ class MemoryManager{
|
||||
}
|
||||
}
|
||||
|
||||
$hardLimit = $config->getPropertyInt("memory.main-hard-limit", $defaultMemory);
|
||||
$hardLimit = $config->getPropertyInt(Yml::MEMORY_MAIN_HARD_LIMIT, $defaultMemory);
|
||||
|
||||
if($hardLimit <= 0){
|
||||
ini_set("memory_limit", '-1');
|
||||
@ -135,22 +136,22 @@ class MemoryManager{
|
||||
ini_set("memory_limit", $hardLimit . "M");
|
||||
}
|
||||
|
||||
$this->globalMemoryLimit = $config->getPropertyInt("memory.global-limit", 0) * 1024 * 1024;
|
||||
$this->checkRate = $config->getPropertyInt("memory.check-rate", self::DEFAULT_CHECK_RATE);
|
||||
$this->continuousTrigger = $config->getPropertyBool("memory.continuous-trigger", true);
|
||||
$this->continuousTriggerRate = $config->getPropertyInt("memory.continuous-trigger-rate", self::DEFAULT_CONTINUOUS_TRIGGER_RATE);
|
||||
$this->globalMemoryLimit = $config->getPropertyInt(Yml::MEMORY_GLOBAL_LIMIT, 0) * 1024 * 1024;
|
||||
$this->checkRate = $config->getPropertyInt(Yml::MEMORY_CHECK_RATE, self::DEFAULT_CHECK_RATE);
|
||||
$this->continuousTrigger = $config->getPropertyBool(Yml::MEMORY_CONTINUOUS_TRIGGER, true);
|
||||
$this->continuousTriggerRate = $config->getPropertyInt(Yml::MEMORY_CONTINUOUS_TRIGGER_RATE, self::DEFAULT_CONTINUOUS_TRIGGER_RATE);
|
||||
|
||||
$this->garbageCollectionPeriod = $config->getPropertyInt("memory.garbage-collection.period", self::DEFAULT_TICKS_PER_GC);
|
||||
$this->garbageCollectionTrigger = $config->getPropertyBool("memory.garbage-collection.low-memory-trigger", true);
|
||||
$this->garbageCollectionAsync = $config->getPropertyBool("memory.garbage-collection.collect-async-worker", true);
|
||||
$this->garbageCollectionPeriod = $config->getPropertyInt(Yml::MEMORY_GARBAGE_COLLECTION_PERIOD, self::DEFAULT_TICKS_PER_GC);
|
||||
$this->garbageCollectionTrigger = $config->getPropertyBool(Yml::MEMORY_GARBAGE_COLLECTION_LOW_MEMORY_TRIGGER, true);
|
||||
$this->garbageCollectionAsync = $config->getPropertyBool(Yml::MEMORY_GARBAGE_COLLECTION_COLLECT_ASYNC_WORKER, true);
|
||||
|
||||
$this->lowMemChunkRadiusOverride = $config->getPropertyInt("memory.max-chunks.chunk-radius", 4);
|
||||
$this->lowMemChunkGC = $config->getPropertyBool("memory.max-chunks.trigger-chunk-collect", true);
|
||||
$this->lowMemChunkRadiusOverride = $config->getPropertyInt(Yml::MEMORY_MAX_CHUNKS_CHUNK_RADIUS, 4);
|
||||
$this->lowMemChunkGC = $config->getPropertyBool(Yml::MEMORY_MAX_CHUNKS_TRIGGER_CHUNK_COLLECT, true);
|
||||
|
||||
$this->lowMemDisableChunkCache = $config->getPropertyBool("memory.world-caches.disable-chunk-cache", true);
|
||||
$this->lowMemClearWorldCache = $config->getPropertyBool("memory.world-caches.low-memory-trigger", true);
|
||||
$this->lowMemDisableChunkCache = $config->getPropertyBool(Yml::MEMORY_WORLD_CACHES_DISABLE_CHUNK_CACHE, true);
|
||||
$this->lowMemClearWorldCache = $config->getPropertyBool(Yml::MEMORY_WORLD_CACHES_LOW_MEMORY_TRIGGER, true);
|
||||
|
||||
$this->dumpWorkers = $config->getPropertyBool("memory.memory-dump.dump-async-worker", true);
|
||||
$this->dumpWorkers = $config->getPropertyBool(Yml::MEMORY_MEMORY_DUMP_DUMP_ASYNC_WORKER, true);
|
||||
gc_enable();
|
||||
}
|
||||
|
||||
@ -314,9 +315,6 @@ class MemoryManager{
|
||||
continue;
|
||||
}
|
||||
|
||||
if(!$property->isPublic()){
|
||||
$property->setAccessible(true);
|
||||
}
|
||||
if(!$property->isInitialized()){
|
||||
continue;
|
||||
}
|
||||
@ -362,7 +360,7 @@ class MemoryManager{
|
||||
'_SESSION' => true
|
||||
];
|
||||
|
||||
foreach(Utils::stringifyKeys($GLOBALS) as $varName => $value){
|
||||
foreach($GLOBALS as $varName => $value){
|
||||
if(isset($ignoredGlobals[$varName])){
|
||||
continue;
|
||||
}
|
||||
@ -440,9 +438,6 @@ class MemoryManager{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if(!$property->isPublic()){
|
||||
$property->setAccessible(true);
|
||||
}
|
||||
if(!$property->isInitialized($object)){
|
||||
continue;
|
||||
}
|
||||
|
@ -26,6 +26,7 @@ namespace pocketmine {
|
||||
use Composer\InstalledVersions;
|
||||
use pocketmine\errorhandler\ErrorToExceptionHandler;
|
||||
use pocketmine\thread\ThreadManager;
|
||||
use pocketmine\thread\ThreadSafeClassLoader;
|
||||
use pocketmine\utils\Filesystem;
|
||||
use pocketmine\utils\MainLogger;
|
||||
use pocketmine\utils\Process;
|
||||
@ -50,7 +51,7 @@ namespace pocketmine {
|
||||
|
||||
require_once __DIR__ . '/VersionInfo.php';
|
||||
|
||||
const MIN_PHP_VERSION = "8.0.0";
|
||||
const MIN_PHP_VERSION = "8.1.0";
|
||||
|
||||
/**
|
||||
* @param string $message
|
||||
@ -103,7 +104,7 @@ namespace pocketmine {
|
||||
"openssl" => "OpenSSL",
|
||||
"pcre" => "PCRE",
|
||||
"phar" => "Phar",
|
||||
"pthreads" => "pthreads",
|
||||
"pmmpthread" => "pmmpthread",
|
||||
"reflection" => "Reflection",
|
||||
"sockets" => "Sockets",
|
||||
"spl" => "SPL",
|
||||
@ -118,12 +119,9 @@ namespace pocketmine {
|
||||
}
|
||||
}
|
||||
|
||||
if(($pthreads_version = phpversion("pthreads")) !== false){
|
||||
if(substr_count($pthreads_version, ".") < 2){
|
||||
$pthreads_version = "0.$pthreads_version";
|
||||
}
|
||||
if(version_compare($pthreads_version, "5.1.0") < 0 || version_compare($pthreads_version, "6.0.0") >= 0){
|
||||
$messages[] = "pthreads ^5.0.0 is required, while you have $pthreads_version.";
|
||||
if(($pmmpthread_version = phpversion("pmmpthread")) !== false){
|
||||
if(version_compare($pmmpthread_version, "6.0.7") < 0 || version_compare($pmmpthread_version, "7.0.0") >= 0){
|
||||
$messages[] = "pmmpthread ^6.0.7 is required, while you have $pmmpthread_version.";
|
||||
}
|
||||
}
|
||||
|
||||
@ -265,9 +263,6 @@ JIT_WARNING
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
if(extension_loaded('parallel')){
|
||||
\parallel\bootstrap(\pocketmine\COMPOSER_AUTOLOADER_PATH);
|
||||
}
|
||||
|
||||
ErrorToExceptionHandler::set();
|
||||
|
||||
@ -333,7 +328,7 @@ JIT_WARNING
|
||||
/*
|
||||
* We now use the Composer autoloader, but this autoloader is still for loading plugins.
|
||||
*/
|
||||
$autoloader = new \BaseClassLoader();
|
||||
$autoloader = new ThreadSafeClassLoader();
|
||||
$autoloader->register(false);
|
||||
|
||||
new Server($autoloader, $logger, $dataPath, $pluginPath);
|
||||
@ -341,12 +336,12 @@ JIT_WARNING
|
||||
$logger->info("Stopping other threads");
|
||||
|
||||
$killer = new ServerKiller(8);
|
||||
$killer->start(PTHREADS_INHERIT_NONE);
|
||||
$killer->start();
|
||||
usleep(10000); //Fixes ServerKiller not being able to start on single-core machines
|
||||
|
||||
if(ThreadManager::getInstance()->stopAll() > 0){
|
||||
$logger->debug("Some threads could not be stopped, performing a force-kill");
|
||||
Process::kill(Process::pid(), true);
|
||||
Process::kill(Process::pid());
|
||||
}
|
||||
}while(false);
|
||||
|
||||
|
237
src/Server.php
237
src/Server.php
@ -53,7 +53,7 @@ use pocketmine\network\mcpe\compression\CompressBatchPromise;
|
||||
use pocketmine\network\mcpe\compression\CompressBatchTask;
|
||||
use pocketmine\network\mcpe\compression\Compressor;
|
||||
use pocketmine\network\mcpe\compression\ZlibCompressor;
|
||||
use pocketmine\network\mcpe\convert\GlobalItemTypeDictionary;
|
||||
use pocketmine\network\mcpe\convert\TypeConverter;
|
||||
use pocketmine\network\mcpe\encryption\EncryptionContext;
|
||||
use pocketmine\network\mcpe\EntityEventBroadcaster;
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
@ -80,7 +80,6 @@ use pocketmine\player\PlayerDataProvider;
|
||||
use pocketmine\player\PlayerDataSaveException;
|
||||
use pocketmine\player\PlayerInfo;
|
||||
use pocketmine\plugin\PharPluginLoader;
|
||||
use pocketmine\plugin\Plugin;
|
||||
use pocketmine\plugin\PluginEnableOrder;
|
||||
use pocketmine\plugin\PluginGraylist;
|
||||
use pocketmine\plugin\PluginManager;
|
||||
@ -92,6 +91,9 @@ use pocketmine\resourcepacks\ResourcePackManager;
|
||||
use pocketmine\scheduler\AsyncPool;
|
||||
use pocketmine\snooze\SleeperHandler;
|
||||
use pocketmine\stats\SendUsageTask;
|
||||
use pocketmine\thread\log\AttachableThreadSafeLogger;
|
||||
use pocketmine\thread\ThreadCrashException;
|
||||
use pocketmine\thread\ThreadSafeClassLoader;
|
||||
use pocketmine\timings\Timings;
|
||||
use pocketmine\timings\TimingsHandler;
|
||||
use pocketmine\updater\UpdateChecker;
|
||||
@ -117,6 +119,7 @@ use pocketmine\world\Position;
|
||||
use pocketmine\world\World;
|
||||
use pocketmine\world\WorldCreationOptions;
|
||||
use pocketmine\world\WorldManager;
|
||||
use pocketmine\YmlServerProperties as Yml;
|
||||
use Ramsey\Uuid\UuidInterface;
|
||||
use Symfony\Component\Filesystem\Path;
|
||||
use function array_fill;
|
||||
@ -205,6 +208,8 @@ class Server{
|
||||
private const TICKS_PER_TPS_OVERLOAD_WARNING = 5 * self::TARGET_TICKS_PER_SECOND;
|
||||
private const TICKS_PER_STATS_REPORT = 300 * self::TARGET_TICKS_PER_SECOND;
|
||||
|
||||
private const DEFAULT_ASYNC_COMPRESSION_THRESHOLD = 10_000;
|
||||
|
||||
private static ?Server $instance = null;
|
||||
|
||||
private TimeTrackingSleeperHandler $tickSleeper;
|
||||
@ -263,6 +268,7 @@ class Server{
|
||||
|
||||
private Network $network;
|
||||
private bool $networkCompressionAsync = true;
|
||||
private int $networkCompressionAsyncThreshold = self::DEFAULT_ASYNC_COMPRESSION_THRESHOLD;
|
||||
|
||||
private Language $language;
|
||||
private bool $forceLanguage = false;
|
||||
@ -351,15 +357,15 @@ class Server{
|
||||
}
|
||||
|
||||
public function getPort() : int{
|
||||
return $this->configGroup->getConfigInt("server-port", self::DEFAULT_PORT_IPV4);
|
||||
return $this->configGroup->getConfigInt(ServerProperties::SERVER_PORT_IPV4, self::DEFAULT_PORT_IPV4);
|
||||
}
|
||||
|
||||
public function getPortV6() : int{
|
||||
return $this->configGroup->getConfigInt("server-portv6", self::DEFAULT_PORT_IPV6);
|
||||
return $this->configGroup->getConfigInt(ServerProperties::SERVER_PORT_IPV6, self::DEFAULT_PORT_IPV6);
|
||||
}
|
||||
|
||||
public function getViewDistance() : int{
|
||||
return max(2, $this->configGroup->getConfigInt("view-distance", self::DEFAULT_MAX_VIEW_DISTANCE));
|
||||
return max(2, $this->configGroup->getConfigInt(ServerProperties::VIEW_DISTANCE, self::DEFAULT_MAX_VIEW_DISTANCE));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -370,12 +376,12 @@ class Server{
|
||||
}
|
||||
|
||||
public function getIp() : string{
|
||||
$str = $this->configGroup->getConfigString("server-ip");
|
||||
$str = $this->configGroup->getConfigString(ServerProperties::SERVER_IPV4);
|
||||
return $str !== "" ? $str : "0.0.0.0";
|
||||
}
|
||||
|
||||
public function getIpV6() : string{
|
||||
$str = $this->configGroup->getConfigString("server-ipv6");
|
||||
$str = $this->configGroup->getConfigString(ServerProperties::SERVER_IPV6);
|
||||
return $str !== "" ? $str : "::";
|
||||
}
|
||||
|
||||
@ -384,37 +390,37 @@ class Server{
|
||||
}
|
||||
|
||||
public function getGamemode() : GameMode{
|
||||
return GameMode::fromString($this->configGroup->getConfigString("gamemode", GameMode::SURVIVAL()->name())) ?? GameMode::SURVIVAL();
|
||||
return GameMode::fromString($this->configGroup->getConfigString(ServerProperties::GAME_MODE, GameMode::SURVIVAL()->name())) ?? GameMode::SURVIVAL();
|
||||
}
|
||||
|
||||
public function getForceGamemode() : bool{
|
||||
return $this->configGroup->getConfigBool("force-gamemode", false);
|
||||
return $this->configGroup->getConfigBool(ServerProperties::FORCE_GAME_MODE, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns Server global difficulty. Note that this may be overridden in individual worlds.
|
||||
*/
|
||||
public function getDifficulty() : int{
|
||||
return $this->configGroup->getConfigInt("difficulty", World::DIFFICULTY_NORMAL);
|
||||
return $this->configGroup->getConfigInt(ServerProperties::DIFFICULTY, World::DIFFICULTY_NORMAL);
|
||||
}
|
||||
|
||||
public function hasWhitelist() : bool{
|
||||
return $this->configGroup->getConfigBool("white-list", false);
|
||||
return $this->configGroup->getConfigBool(ServerProperties::WHITELIST, false);
|
||||
}
|
||||
|
||||
public function isHardcore() : bool{
|
||||
return $this->configGroup->getConfigBool("hardcore", false);
|
||||
return $this->configGroup->getConfigBool(ServerProperties::HARDCORE, false);
|
||||
}
|
||||
|
||||
public function getMotd() : string{
|
||||
return $this->configGroup->getConfigString("motd", self::DEFAULT_SERVER_NAME);
|
||||
return $this->configGroup->getConfigString(ServerProperties::MOTD, self::DEFAULT_SERVER_NAME);
|
||||
}
|
||||
|
||||
public function getLoader() : \DynamicClassLoader{
|
||||
public function getLoader() : ThreadSafeClassLoader{
|
||||
return $this->autoloader;
|
||||
}
|
||||
|
||||
public function getLogger() : \AttachableThreadedLogger{
|
||||
public function getLogger() : AttachableThreadSafeLogger{
|
||||
return $this->logger;
|
||||
}
|
||||
|
||||
@ -490,7 +496,7 @@ class Server{
|
||||
}
|
||||
|
||||
public function shouldSavePlayerData() : bool{
|
||||
return $this->configGroup->getPropertyBool("player.save-player-data", true);
|
||||
return $this->configGroup->getPropertyBool(Yml::PLAYER_SAVE_PLAYER_DATA, true);
|
||||
}
|
||||
|
||||
public function getOfflinePlayer(string $name) : Player|OfflinePlayer|null{
|
||||
@ -564,6 +570,7 @@ class Server{
|
||||
$playerPromiseResolver = new PromiseResolver();
|
||||
|
||||
$createPlayer = function(Location $location) use ($playerPromiseResolver, $class, $session, $playerInfo, $authenticated, $offlinePlayerData) : void{
|
||||
/** @see Player::__construct() */
|
||||
$player = new $class($this, $session, $playerInfo, $authenticated, $location, $offlinePlayerData);
|
||||
if(!$player->hasPlayedBefore()){
|
||||
$player->onGround = true; //TODO: this hack is needed for new players in-air ticks - they don't get detected as on-ground until they move
|
||||
@ -730,7 +737,7 @@ class Server{
|
||||
* @return string[][]
|
||||
*/
|
||||
public function getCommandAliases() : array{
|
||||
$section = $this->configGroup->getProperty("aliases");
|
||||
$section = $this->configGroup->getProperty(YmlServerProperties::ALIASES);
|
||||
$result = [];
|
||||
if(is_array($section)){
|
||||
foreach($section as $key => $value){
|
||||
@ -756,8 +763,8 @@ class Server{
|
||||
}
|
||||
|
||||
public function __construct(
|
||||
private \DynamicClassLoader $autoloader,
|
||||
private \AttachableThreadedLogger $logger,
|
||||
private ThreadSafeClassLoader $autoloader,
|
||||
private AttachableThreadSafeLogger $logger,
|
||||
string $dataPath,
|
||||
string $pluginPath
|
||||
){
|
||||
@ -805,36 +812,36 @@ class Server{
|
||||
$this->configGroup = new ServerConfigGroup(
|
||||
new Config($pocketmineYmlPath, Config::YAML, []),
|
||||
new Config(Path::join($this->dataPath, "server.properties"), Config::PROPERTIES, [
|
||||
"motd" => self::DEFAULT_SERVER_NAME,
|
||||
"server-port" => self::DEFAULT_PORT_IPV4,
|
||||
"server-portv6" => self::DEFAULT_PORT_IPV6,
|
||||
"enable-ipv6" => true,
|
||||
"white-list" => false,
|
||||
"max-players" => self::DEFAULT_MAX_PLAYERS,
|
||||
"gamemode" => GameMode::SURVIVAL()->name(),
|
||||
"force-gamemode" => false,
|
||||
"hardcore" => false,
|
||||
"pvp" => true,
|
||||
"difficulty" => World::DIFFICULTY_NORMAL,
|
||||
"generator-settings" => "",
|
||||
"level-name" => "world",
|
||||
"level-seed" => "",
|
||||
"level-type" => "DEFAULT",
|
||||
"enable-query" => true,
|
||||
"auto-save" => true,
|
||||
"view-distance" => self::DEFAULT_MAX_VIEW_DISTANCE,
|
||||
"xbox-auth" => true,
|
||||
"language" => "eng"
|
||||
ServerProperties::MOTD => self::DEFAULT_SERVER_NAME,
|
||||
ServerProperties::SERVER_PORT_IPV4 => self::DEFAULT_PORT_IPV4,
|
||||
ServerProperties::SERVER_PORT_IPV6 => self::DEFAULT_PORT_IPV6,
|
||||
ServerProperties::ENABLE_IPV6 => true,
|
||||
ServerProperties::WHITELIST => false,
|
||||
ServerProperties::MAX_PLAYERS => self::DEFAULT_MAX_PLAYERS,
|
||||
ServerProperties::GAME_MODE => GameMode::SURVIVAL()->name(),
|
||||
ServerProperties::FORCE_GAME_MODE => false,
|
||||
ServerProperties::HARDCORE => false,
|
||||
ServerProperties::PVP => true,
|
||||
ServerProperties::DIFFICULTY => World::DIFFICULTY_NORMAL,
|
||||
ServerProperties::DEFAULT_WORLD_GENERATOR_SETTINGS => "",
|
||||
ServerProperties::DEFAULT_WORLD_NAME => "world",
|
||||
ServerProperties::DEFAULT_WORLD_SEED => "",
|
||||
ServerProperties::DEFAULT_WORLD_GENERATOR => "DEFAULT",
|
||||
ServerProperties::ENABLE_QUERY => true,
|
||||
ServerProperties::AUTO_SAVE => true,
|
||||
ServerProperties::VIEW_DISTANCE => self::DEFAULT_MAX_VIEW_DISTANCE,
|
||||
ServerProperties::XBOX_AUTH => true,
|
||||
ServerProperties::LANGUAGE => "eng"
|
||||
])
|
||||
);
|
||||
|
||||
$debugLogLevel = $this->configGroup->getPropertyInt("debug.level", 1);
|
||||
$debugLogLevel = $this->configGroup->getPropertyInt(Yml::DEBUG_LEVEL, 1);
|
||||
if($this->logger instanceof MainLogger){
|
||||
$this->logger->setLogDebug($debugLogLevel > 1);
|
||||
}
|
||||
|
||||
$this->forceLanguage = $this->configGroup->getPropertyBool("settings.force-language", false);
|
||||
$selectedLang = $this->configGroup->getConfigString("language", $this->configGroup->getPropertyString("settings.language", Language::FALLBACK_LANGUAGE));
|
||||
$this->forceLanguage = $this->configGroup->getPropertyBool(Yml::SETTINGS_FORCE_LANGUAGE, false);
|
||||
$selectedLang = $this->configGroup->getConfigString(ServerProperties::LANGUAGE, $this->configGroup->getPropertyString("settings.language", Language::FALLBACK_LANGUAGE));
|
||||
try{
|
||||
$this->language = new Language($selectedLang);
|
||||
}catch(LanguageNotFoundException $e){
|
||||
@ -850,11 +857,11 @@ class Server{
|
||||
$this->logger->info($this->getLanguage()->translate(KnownTranslationFactory::language_selected($this->getLanguage()->getName(), $this->getLanguage()->getLang())));
|
||||
|
||||
if(VersionInfo::IS_DEVELOPMENT_BUILD){
|
||||
if(!$this->configGroup->getPropertyBool("settings.enable-dev-builds", false)){
|
||||
if(!$this->configGroup->getPropertyBool(Yml::SETTINGS_ENABLE_DEV_BUILDS, false)){
|
||||
$this->logger->emergency($this->language->translate(KnownTranslationFactory::pocketmine_server_devBuild_error1(VersionInfo::NAME)));
|
||||
$this->logger->emergency($this->language->translate(KnownTranslationFactory::pocketmine_server_devBuild_error2()));
|
||||
$this->logger->emergency($this->language->translate(KnownTranslationFactory::pocketmine_server_devBuild_error3()));
|
||||
$this->logger->emergency($this->language->translate(KnownTranslationFactory::pocketmine_server_devBuild_error4("settings.enable-dev-builds")));
|
||||
$this->logger->emergency($this->language->translate(KnownTranslationFactory::pocketmine_server_devBuild_error4(YmlServerProperties::SETTINGS_ENABLE_DEV_BUILDS)));
|
||||
$this->logger->emergency($this->language->translate(KnownTranslationFactory::pocketmine_server_devBuild_error5("https://github.com/pmmp/PocketMine-MP/releases")));
|
||||
$this->forceShutdownExit();
|
||||
|
||||
@ -872,7 +879,7 @@ class Server{
|
||||
|
||||
$this->logger->info($this->getLanguage()->translate(KnownTranslationFactory::pocketmine_server_start(TextFormat::AQUA . $this->getVersion() . TextFormat::RESET)));
|
||||
|
||||
if(($poolSize = $this->configGroup->getPropertyString("settings.async-workers", "auto")) === "auto"){
|
||||
if(($poolSize = $this->configGroup->getPropertyString(Yml::SETTINGS_ASYNC_WORKERS, "auto")) === "auto"){
|
||||
$poolSize = 2;
|
||||
$processors = Utils::getCoreCount() - 2;
|
||||
|
||||
@ -883,28 +890,32 @@ class Server{
|
||||
$poolSize = max(1, (int) $poolSize);
|
||||
}
|
||||
|
||||
$this->asyncPool = new AsyncPool($poolSize, max(-1, $this->configGroup->getPropertyInt("memory.async-worker-hard-limit", 256)), $this->autoloader, $this->logger, $this->tickSleeper);
|
||||
$this->asyncPool = new AsyncPool($poolSize, max(-1, $this->configGroup->getPropertyInt(Yml::MEMORY_ASYNC_WORKER_HARD_LIMIT, 256)), $this->autoloader, $this->logger, $this->tickSleeper);
|
||||
|
||||
$netCompressionThreshold = -1;
|
||||
if($this->configGroup->getPropertyInt("network.batch-threshold", 256) >= 0){
|
||||
$netCompressionThreshold = $this->configGroup->getPropertyInt("network.batch-threshold", 256);
|
||||
if($this->configGroup->getPropertyInt(Yml::NETWORK_BATCH_THRESHOLD, 256) >= 0){
|
||||
$netCompressionThreshold = $this->configGroup->getPropertyInt(Yml::NETWORK_BATCH_THRESHOLD, 256);
|
||||
}
|
||||
if($netCompressionThreshold < 0){
|
||||
$netCompressionThreshold = null;
|
||||
}
|
||||
|
||||
$netCompressionLevel = $this->configGroup->getPropertyInt("network.compression-level", 6);
|
||||
$netCompressionLevel = $this->configGroup->getPropertyInt(Yml::NETWORK_COMPRESSION_LEVEL, 6);
|
||||
if($netCompressionLevel < 1 || $netCompressionLevel > 9){
|
||||
$this->logger->warning("Invalid network compression level $netCompressionLevel set, setting to default 6");
|
||||
$netCompressionLevel = 6;
|
||||
}
|
||||
ZlibCompressor::setInstance(new ZlibCompressor($netCompressionLevel, $netCompressionThreshold, ZlibCompressor::DEFAULT_MAX_DECOMPRESSION_SIZE));
|
||||
|
||||
$this->networkCompressionAsync = $this->configGroup->getPropertyBool("network.async-compression", true);
|
||||
$this->networkCompressionAsync = $this->configGroup->getPropertyBool(Yml::NETWORK_ASYNC_COMPRESSION, true);
|
||||
$this->networkCompressionAsyncThreshold = max(
|
||||
$this->configGroup->getPropertyInt(Yml::NETWORK_ASYNC_COMPRESSION_THRESHOLD, self::DEFAULT_ASYNC_COMPRESSION_THRESHOLD),
|
||||
$netCompressionThreshold ?? self::DEFAULT_ASYNC_COMPRESSION_THRESHOLD
|
||||
);
|
||||
|
||||
EncryptionContext::$ENABLED = $this->configGroup->getPropertyBool("network.enable-encryption", true);
|
||||
EncryptionContext::$ENABLED = $this->configGroup->getPropertyBool(Yml::NETWORK_ENABLE_ENCRYPTION, true);
|
||||
|
||||
$this->doTitleTick = $this->configGroup->getPropertyBool("console.title-tick", true) && Terminal::hasFormattingCodes();
|
||||
$this->doTitleTick = $this->configGroup->getPropertyBool(Yml::CONSOLE_TITLE_TICK, true) && Terminal::hasFormattingCodes();
|
||||
|
||||
$this->operators = new Config(Path::join($this->dataPath, "ops.txt"), Config::ENUM);
|
||||
$this->whitelist = new Config(Path::join($this->dataPath, "white-list.txt"), Config::ENUM);
|
||||
@ -922,9 +933,9 @@ class Server{
|
||||
$this->banByIP = new BanList($bannedIpsTxt);
|
||||
$this->banByIP->load();
|
||||
|
||||
$this->maxPlayers = $this->configGroup->getConfigInt("max-players", self::DEFAULT_MAX_PLAYERS);
|
||||
$this->maxPlayers = $this->configGroup->getConfigInt(ServerProperties::MAX_PLAYERS, self::DEFAULT_MAX_PLAYERS);
|
||||
|
||||
$this->onlineMode = $this->configGroup->getConfigBool("xbox-auth", true);
|
||||
$this->onlineMode = $this->configGroup->getConfigBool(ServerProperties::XBOX_AUTH, true);
|
||||
if($this->onlineMode){
|
||||
$this->logger->info($this->getLanguage()->translate(KnownTranslationFactory::pocketmine_server_auth_enabled()));
|
||||
}else{
|
||||
@ -933,8 +944,8 @@ class Server{
|
||||
$this->logger->warning($this->getLanguage()->translate(KnownTranslationFactory::pocketmine_server_authProperty_disabled()));
|
||||
}
|
||||
|
||||
if($this->configGroup->getConfigBool("hardcore", false) && $this->getDifficulty() < World::DIFFICULTY_HARD){
|
||||
$this->configGroup->setConfigInt("difficulty", World::DIFFICULTY_HARD);
|
||||
if($this->configGroup->getConfigBool(ServerProperties::HARDCORE, false) && $this->getDifficulty() < World::DIFFICULTY_HARD){
|
||||
$this->configGroup->setConfigInt(ServerProperties::DIFFICULTY, World::DIFFICULTY_HARD);
|
||||
}
|
||||
|
||||
@cli_set_process_title($this->getName() . " " . $this->getPocketMineVersion());
|
||||
@ -953,8 +964,8 @@ class Server{
|
||||
)));
|
||||
$this->logger->info($this->getLanguage()->translate(KnownTranslationFactory::pocketmine_server_license($this->getName())));
|
||||
|
||||
TimingsHandler::setEnabled($this->configGroup->getPropertyBool("settings.enable-profiling", false));
|
||||
$this->profilingTickRate = $this->configGroup->getPropertyInt("settings.profile-report-trigger", self::TARGET_TICKS_PER_SECOND);
|
||||
TimingsHandler::setEnabled($this->configGroup->getPropertyBool(Yml::SETTINGS_ENABLE_PROFILING, false));
|
||||
$this->profilingTickRate = $this->configGroup->getPropertyInt(Yml::SETTINGS_PROFILE_REPORT_TRIGGER, self::TARGET_TICKS_PER_SECOND);
|
||||
|
||||
DefaultPermissions::registerCorePermissions();
|
||||
|
||||
@ -976,13 +987,13 @@ class Server{
|
||||
$this->forceShutdownExit();
|
||||
return;
|
||||
}
|
||||
$this->pluginManager = new PluginManager($this, $this->configGroup->getPropertyBool("plugins.legacy-data-dir", true) ? null : Path::join($this->getDataPath(), "plugin_data"), $pluginGraylist);
|
||||
$this->pluginManager = new PluginManager($this, $this->configGroup->getPropertyBool(Yml::PLUGINS_LEGACY_DATA_DIR, true) ? null : Path::join($this->getDataPath(), "plugin_data"), $pluginGraylist);
|
||||
$this->pluginManager->registerInterface(new PharPluginLoader($this->autoloader));
|
||||
$this->pluginManager->registerInterface(new ScriptPluginLoader());
|
||||
|
||||
$providerManager = new WorldProviderManager();
|
||||
if(
|
||||
($format = $providerManager->getProviderByName($formatName = $this->configGroup->getPropertyString("level-settings.default-format", ""))) !== null &&
|
||||
($format = $providerManager->getProviderByName($formatName = $this->configGroup->getPropertyString(Yml::LEVEL_SETTINGS_DEFAULT_FORMAT, ""))) !== null &&
|
||||
$format instanceof WritableWorldProviderManagerEntry
|
||||
){
|
||||
$providerManager->setDefault($format);
|
||||
@ -991,16 +1002,16 @@ class Server{
|
||||
}
|
||||
|
||||
$this->worldManager = new WorldManager($this, Path::join($this->dataPath, "worlds"), $providerManager);
|
||||
$this->worldManager->setAutoSave($this->configGroup->getConfigBool("auto-save", $this->worldManager->getAutoSave()));
|
||||
$this->worldManager->setAutoSaveInterval($this->configGroup->getPropertyInt("ticks-per.autosave", $this->worldManager->getAutoSaveInterval()));
|
||||
$this->worldManager->setAutoSave($this->configGroup->getConfigBool(ServerProperties::AUTO_SAVE, $this->worldManager->getAutoSave()));
|
||||
$this->worldManager->setAutoSaveInterval($this->configGroup->getPropertyInt(Yml::TICKS_PER_AUTOSAVE, $this->worldManager->getAutoSaveInterval()));
|
||||
|
||||
$this->updater = new UpdateChecker($this, $this->configGroup->getPropertyString("auto-updater.host", "update.pmmp.io"));
|
||||
$this->updater = new UpdateChecker($this, $this->configGroup->getPropertyString(Yml::AUTO_UPDATER_HOST, "update.pmmp.io"));
|
||||
|
||||
$this->queryInfo = new QueryInfo($this);
|
||||
|
||||
$this->playerDataProvider = new DatFilePlayerDataProvider(Path::join($this->dataPath, "players"));
|
||||
|
||||
register_shutdown_function([$this, "crashDump"]);
|
||||
register_shutdown_function($this->crashDump(...));
|
||||
|
||||
$loadErrorCount = 0;
|
||||
$this->pluginManager->loadPlugins($this->pluginPath, $loadErrorCount);
|
||||
@ -1031,7 +1042,7 @@ class Server{
|
||||
return;
|
||||
}
|
||||
|
||||
if($this->configGroup->getPropertyBool("anonymous-statistics.enabled", true)){
|
||||
if($this->configGroup->getPropertyBool(Yml::ANONYMOUS_STATISTICS_ENABLED, true)){
|
||||
$this->sendUsageTicker = self::TICKS_PER_STATS_REPORT;
|
||||
$this->sendUsage(SendUsageTask::TYPE_OPEN);
|
||||
}
|
||||
@ -1047,7 +1058,7 @@ class Server{
|
||||
$this->subscribeToBroadcastChannel(self::BROADCAST_CHANNEL_USERS, $forwarder);
|
||||
|
||||
//TODO: move console parts to a separate component
|
||||
if($this->configGroup->getPropertyBool("console.enable-input", true)){
|
||||
if($this->configGroup->getPropertyBool(Yml::CONSOLE_ENABLE_INPUT, true)){
|
||||
$this->console = new ConsoleReaderChildProcessDaemon($this->logger);
|
||||
}
|
||||
|
||||
@ -1082,7 +1093,7 @@ class Server{
|
||||
|
||||
$anyWorldFailedToLoad = false;
|
||||
|
||||
foreach((array) $this->configGroup->getProperty("worlds", []) as $name => $options){
|
||||
foreach((array) $this->configGroup->getProperty(Yml::WORLDS, []) as $name => $options){
|
||||
if($options === null){
|
||||
$options = [];
|
||||
}elseif(!is_array($options)){
|
||||
@ -1126,11 +1137,11 @@ class Server{
|
||||
}
|
||||
|
||||
if($this->worldManager->getDefaultWorld() === null){
|
||||
$default = $this->configGroup->getConfigString("level-name", "world");
|
||||
$default = $this->configGroup->getConfigString(ServerProperties::DEFAULT_WORLD_NAME, "world");
|
||||
if(trim($default) == ""){
|
||||
$this->getLogger()->warning("level-name cannot be null, using default");
|
||||
$default = "world";
|
||||
$this->configGroup->setConfigString("level-name", "world");
|
||||
$this->configGroup->setConfigString(ServerProperties::DEFAULT_WORLD_NAME, "world");
|
||||
}
|
||||
if(!$this->worldManager->loadWorld($default, true)){
|
||||
if($this->worldManager->isWorldGenerated($default)){
|
||||
@ -1138,8 +1149,8 @@ class Server{
|
||||
|
||||
return false;
|
||||
}
|
||||
$generatorName = $this->configGroup->getConfigString("level-type");
|
||||
$generatorOptions = $this->configGroup->getConfigString("generator-settings");
|
||||
$generatorName = $this->configGroup->getConfigString(ServerProperties::DEFAULT_WORLD_GENERATOR);
|
||||
$generatorOptions = $this->configGroup->getConfigString(ServerProperties::DEFAULT_WORLD_GENERATOR_SETTINGS);
|
||||
$generatorClass = $getGenerator($generatorName, $generatorOptions, $default);
|
||||
|
||||
if($generatorClass === null){
|
||||
@ -1149,7 +1160,7 @@ class Server{
|
||||
$creationOptions = WorldCreationOptions::create()
|
||||
->setGeneratorClass($generatorClass)
|
||||
->setGeneratorOptions($generatorOptions);
|
||||
$convertedSeed = Generator::convertSeed($this->configGroup->getConfigString("level-seed"));
|
||||
$convertedSeed = Generator::convertSeed($this->configGroup->getConfigString(ServerProperties::DEFAULT_WORLD_SEED));
|
||||
if($convertedSeed !== null){
|
||||
$creationOptions->setSeed($convertedSeed);
|
||||
}
|
||||
@ -1174,11 +1185,12 @@ class Server{
|
||||
bool $useQuery,
|
||||
PacketBroadcaster $packetBroadcaster,
|
||||
EntityEventBroadcaster $entityEventBroadcaster,
|
||||
PacketSerializerContext $packetSerializerContext
|
||||
PacketSerializerContext $packetSerializerContext,
|
||||
TypeConverter $typeConverter
|
||||
) : bool{
|
||||
$prettyIp = $ipV6 ? "[$ip]" : $ip;
|
||||
try{
|
||||
$rakLibRegistered = $this->network->registerInterface(new RakLibInterface($this, $ip, $port, $ipV6, $packetBroadcaster, $entityEventBroadcaster, $packetSerializerContext));
|
||||
$rakLibRegistered = $this->network->registerInterface(new RakLibInterface($this, $ip, $port, $ipV6, $packetBroadcaster, $entityEventBroadcaster, $packetSerializerContext, $typeConverter));
|
||||
}catch(NetworkInterfaceStartException $e){
|
||||
$this->logger->emergency($this->language->translate(KnownTranslationFactory::pocketmine_server_networkStartFailed(
|
||||
$ip,
|
||||
@ -1202,17 +1214,18 @@ class Server{
|
||||
}
|
||||
|
||||
private function startupPrepareNetworkInterfaces() : bool{
|
||||
$useQuery = $this->configGroup->getConfigBool("enable-query", true);
|
||||
$useQuery = $this->configGroup->getConfigBool(ServerProperties::ENABLE_QUERY, true);
|
||||
|
||||
$packetSerializerContext = new PacketSerializerContext(GlobalItemTypeDictionary::getInstance()->getDictionary());
|
||||
$typeConverter = TypeConverter::getInstance();
|
||||
$packetSerializerContext = new PacketSerializerContext($typeConverter->getItemTypeDictionary());
|
||||
$packetBroadcaster = new StandardPacketBroadcaster($this, $packetSerializerContext);
|
||||
$entityEventBroadcaster = new StandardEntityEventBroadcaster($packetBroadcaster);
|
||||
$entityEventBroadcaster = new StandardEntityEventBroadcaster($packetBroadcaster, $typeConverter);
|
||||
|
||||
if(
|
||||
!$this->startupPrepareConnectableNetworkInterfaces($this->getIp(), $this->getPort(), false, $useQuery, $packetBroadcaster, $entityEventBroadcaster, $packetSerializerContext) ||
|
||||
!$this->startupPrepareConnectableNetworkInterfaces($this->getIp(), $this->getPort(), false, $useQuery, $packetBroadcaster, $entityEventBroadcaster, $packetSerializerContext, $typeConverter) ||
|
||||
(
|
||||
$this->configGroup->getConfigBool("enable-ipv6", true) &&
|
||||
!$this->startupPrepareConnectableNetworkInterfaces($this->getIpV6(), $this->getPortV6(), true, $useQuery, $packetBroadcaster, $entityEventBroadcaster, $packetSerializerContext)
|
||||
$this->configGroup->getConfigBool(ServerProperties::ENABLE_IPV6, true) &&
|
||||
!$this->startupPrepareConnectableNetworkInterfaces($this->getIpV6(), $this->getPortV6(), true, $useQuery, $packetBroadcaster, $entityEventBroadcaster, $packetSerializerContext, $typeConverter)
|
||||
)
|
||||
){
|
||||
return false;
|
||||
@ -1226,7 +1239,7 @@ class Server{
|
||||
$this->network->blockAddress($entry->getName(), -1);
|
||||
}
|
||||
|
||||
if($this->configGroup->getPropertyBool("network.upnp-forwarding", false)){
|
||||
if($this->configGroup->getPropertyBool(Yml::NETWORK_UPNP_FORWARDING, false)){
|
||||
$this->network->registerInterface(new UPnPNetworkInterface($this->logger, Internet::getInternalIP(), $this->getPort()));
|
||||
}
|
||||
|
||||
@ -1357,7 +1370,7 @@ class Server{
|
||||
}
|
||||
|
||||
$promise = new CompressBatchPromise();
|
||||
if(!$sync){
|
||||
if(!$sync && strlen($buffer) >= $this->networkCompressionAsyncThreshold){
|
||||
$task = new CompressBatchTask($buffer, $promise, $compressor);
|
||||
$this->asyncPool->submitTask($task);
|
||||
}else{
|
||||
@ -1416,7 +1429,7 @@ class Server{
|
||||
|
||||
private function forceShutdownExit() : void{
|
||||
$this->forceShutdown();
|
||||
Process::kill(Process::pid(), true);
|
||||
Process::kill(Process::pid());
|
||||
}
|
||||
|
||||
public function forceShutdown() : void{
|
||||
@ -1446,7 +1459,7 @@ class Server{
|
||||
}
|
||||
|
||||
if(isset($this->network)){
|
||||
$this->network->getSessionManager()->close($this->configGroup->getPropertyString("settings.shutdown-message", "Server closed"));
|
||||
$this->network->getSessionManager()->close($this->configGroup->getPropertyString(YmlServerProperties::SETTINGS_SHUTDOWN_MESSAGE, "Server closed"));
|
||||
}
|
||||
|
||||
if(isset($this->worldManager)){
|
||||
@ -1484,7 +1497,7 @@ class Server{
|
||||
}catch(\Throwable $e){
|
||||
$this->logger->logException($e);
|
||||
$this->logger->emergency("Crashed while crashing, killing process");
|
||||
@Process::kill(Process::pid(), true);
|
||||
@Process::kill(Process::pid());
|
||||
}
|
||||
|
||||
}
|
||||
@ -1505,23 +1518,38 @@ class Server{
|
||||
$trace = $e->getTrace();
|
||||
}
|
||||
|
||||
$errstr = $e->getMessage();
|
||||
$errfile = $e->getFile();
|
||||
$errline = $e->getLine();
|
||||
//If this is a thread crash, this logs where the exception came from on the main thread, as opposed to the
|
||||
//crashed thread. This is intentional, and might be useful for debugging
|
||||
//Assume that the thread already logged the original exception with the correct stack trace
|
||||
$this->logger->logException($e, $trace);
|
||||
|
||||
if($e instanceof ThreadCrashException){
|
||||
$info = $e->getCrashInfo();
|
||||
$type = $info->getType();
|
||||
$errstr = $info->getMessage();
|
||||
$errfile = $info->getFile();
|
||||
$errline = $info->getLine();
|
||||
$printableTrace = $info->getTrace();
|
||||
$thread = $info->getThreadName();
|
||||
}else{
|
||||
$type = get_class($e);
|
||||
$errstr = $e->getMessage();
|
||||
$errfile = $e->getFile();
|
||||
$errline = $e->getLine();
|
||||
$printableTrace = Utils::printableTraceWithMetadata($trace);
|
||||
$thread = "Main";
|
||||
}
|
||||
|
||||
$errstr = preg_replace('/\s+/', ' ', trim($errstr));
|
||||
|
||||
$errfile = Filesystem::cleanPath($errfile);
|
||||
|
||||
$this->logger->logException($e, $trace);
|
||||
|
||||
$lastError = [
|
||||
"type" => get_class($e),
|
||||
"type" => $type,
|
||||
"message" => $errstr,
|
||||
"fullFile" => $e->getFile(),
|
||||
"file" => $errfile,
|
||||
"fullFile" => $errfile,
|
||||
"file" => Filesystem::cleanPath($errfile),
|
||||
"line" => $errline,
|
||||
"trace" => $trace
|
||||
"trace" => $printableTrace,
|
||||
"thread" => $thread
|
||||
];
|
||||
|
||||
global $lastExceptionError, $lastError;
|
||||
@ -1568,7 +1596,7 @@ class Server{
|
||||
|
||||
$this->logger->emergency($this->getLanguage()->translate(KnownTranslationFactory::pocketmine_crash_submit($crashDumpPath)));
|
||||
|
||||
if($this->configGroup->getPropertyBool("auto-report.enabled", true)){
|
||||
if($this->configGroup->getPropertyBool(Yml::AUTO_REPORT_ENABLED, true)){
|
||||
$report = true;
|
||||
|
||||
$stamp = Path::join($this->getDataPath(), "crashdumps", ".last_crash");
|
||||
@ -1579,15 +1607,6 @@ class Server{
|
||||
}
|
||||
@touch($stamp); //update file timestamp
|
||||
|
||||
$plugin = $dump->getData()->plugin;
|
||||
if($plugin !== ""){
|
||||
$p = $this->pluginManager->getPlugin($plugin);
|
||||
if($p instanceof Plugin && !($p->getPluginLoader() instanceof PharPluginLoader)){
|
||||
$this->logger->debug("Not sending crashdump due to caused by non-phar plugin");
|
||||
$report = false;
|
||||
}
|
||||
}
|
||||
|
||||
if($dump->getData()->error["type"] === \ParseError::class){
|
||||
$report = false;
|
||||
}
|
||||
@ -1598,7 +1617,7 @@ class Server{
|
||||
}
|
||||
|
||||
if($report){
|
||||
$url = ($this->configGroup->getPropertyBool("auto-report.use-https", true) ? "https" : "http") . "://" . $this->configGroup->getPropertyString("auto-report.host", "crash.pmmp.io") . "/submit/api";
|
||||
$url = ($this->configGroup->getPropertyBool(Yml::AUTO_REPORT_USE_HTTPS, true) ? "https" : "http") . "://" . $this->configGroup->getPropertyString(Yml::AUTO_REPORT_HOST, "crash.pmmp.io") . "/submit/api";
|
||||
$postUrlError = "Unknown error";
|
||||
$reply = Internet::postURL($url, [
|
||||
"report" => "yes",
|
||||
@ -1638,7 +1657,7 @@ class Server{
|
||||
echo "--- Waiting $spacing seconds to throttle automatic restart (you can kill the process safely now) ---" . PHP_EOL;
|
||||
sleep($spacing);
|
||||
}
|
||||
@Process::kill(Process::pid(), true);
|
||||
@Process::kill(Process::pid());
|
||||
exit(1);
|
||||
}
|
||||
|
||||
@ -1709,7 +1728,7 @@ class Server{
|
||||
}
|
||||
|
||||
public function sendUsage(int $type = SendUsageTask::TYPE_STATUS) : void{
|
||||
if($this->configGroup->getPropertyBool("anonymous-statistics.enabled", true)){
|
||||
if($this->configGroup->getPropertyBool(Yml::ANONYMOUS_STATISTICS_ENABLED, true)){
|
||||
$this->asyncPool->submitTask(new SendUsageTask($this, $type, $this->uniquePlayers));
|
||||
}
|
||||
$this->uniquePlayers = [];
|
||||
|
58
src/ServerProperties.php
Normal file
58
src/ServerProperties.php
Normal file
@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
*
|
||||
* ____ _ _ __ __ _ __ __ ____
|
||||
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
|
||||
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
|
||||
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
|
||||
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* @author PocketMine Team
|
||||
* @link http://www.pocketmine.net/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pocketmine;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
* Constants for all properties available in server.properties.
|
||||
*/
|
||||
final class ServerProperties{
|
||||
|
||||
private function __construct(){
|
||||
//NOOP
|
||||
}
|
||||
|
||||
public const AUTO_SAVE = "auto-save";
|
||||
public const DEFAULT_WORLD_GENERATOR = "level-type";
|
||||
public const DEFAULT_WORLD_GENERATOR_SETTINGS = "generator-settings";
|
||||
public const DEFAULT_WORLD_NAME = "level-name";
|
||||
public const DEFAULT_WORLD_SEED = "level-seed";
|
||||
public const DIFFICULTY = "difficulty";
|
||||
public const ENABLE_IPV6 = "enable-ipv6";
|
||||
public const ENABLE_QUERY = "enable-query";
|
||||
public const FORCE_GAME_MODE = "force-gamemode";
|
||||
public const GAME_MODE = "gamemode";
|
||||
public const HARDCORE = "hardcore";
|
||||
public const LANGUAGE = "language";
|
||||
public const MAX_PLAYERS = "max-players";
|
||||
public const MOTD = "motd";
|
||||
public const PVP = "pvp";
|
||||
public const SERVER_IPV4 = "server-ip";
|
||||
public const SERVER_IPV6 = "server-ipv6";
|
||||
public const SERVER_PORT_IPV4 = "server-port";
|
||||
public const SERVER_PORT_IPV6 = "server-portv6";
|
||||
public const VIEW_DISTANCE = "view-distance";
|
||||
public const WHITELIST = "white-list";
|
||||
public const XBOX_AUTH = "xbox-auth";
|
||||
}
|
@ -31,10 +31,24 @@ use function str_repeat;
|
||||
|
||||
final class VersionInfo{
|
||||
public const NAME = "PocketMine-MP";
|
||||
|
||||
public const BASE_VERSION = "5.0.0-BETA2";
|
||||
public const BASE_VERSION = "5.6.1";
|
||||
public const IS_DEVELOPMENT_BUILD = false;
|
||||
public const BUILD_CHANNEL = "beta";
|
||||
public const BUILD_CHANNEL = "stable";
|
||||
|
||||
/**
|
||||
* PocketMine-MP-specific version ID for world data. Used to determine what fixes need to be applied to old world
|
||||
* data (e.g. stuff saved wrongly by past versions).
|
||||
* This version supplements the Minecraft vanilla world version.
|
||||
*
|
||||
* This should be bumped if any **non-Mojang** BC-breaking change or bug fix is made to world save data of any kind
|
||||
* (entities, tiles, blocks, biomes etc.). For example, if PM accidentally saved a block with its facing value
|
||||
* swapped, we would bump this, but not if Mojang did the same change.
|
||||
*/
|
||||
public const WORLD_DATA_VERSION = 1;
|
||||
/**
|
||||
* Name of the NBT tag used to store the world data version.
|
||||
*/
|
||||
public const TAG_WORLD_DATA_VERSION = "PMMPDataVersion"; //TAG_Long
|
||||
|
||||
private function __construct(){
|
||||
//NOOP
|
||||
|
118
src/YmlServerProperties.php
Normal file
118
src/YmlServerProperties.php
Normal file
@ -0,0 +1,118 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
*
|
||||
* ____ _ _ __ __ _ __ __ ____
|
||||
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
|
||||
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
|
||||
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
|
||||
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* @author PocketMine Team
|
||||
* @link http://www.pocketmine.net/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pocketmine;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
* Constants for all properties available in pocketmine.yml.
|
||||
* This is generated by build/generate-pocketmine-yml-property-consts.php.
|
||||
* Do not edit this file manually.
|
||||
*/
|
||||
final class YmlServerProperties{
|
||||
|
||||
private function __construct(){
|
||||
//NOOP
|
||||
}
|
||||
|
||||
public const ALIASES = 'aliases';
|
||||
public const ANONYMOUS_STATISTICS = 'anonymous-statistics';
|
||||
public const ANONYMOUS_STATISTICS_ENABLED = 'anonymous-statistics.enabled';
|
||||
public const ANONYMOUS_STATISTICS_HOST = 'anonymous-statistics.host';
|
||||
public const AUTO_REPORT = 'auto-report';
|
||||
public const AUTO_REPORT_ENABLED = 'auto-report.enabled';
|
||||
public const AUTO_REPORT_HOST = 'auto-report.host';
|
||||
public const AUTO_REPORT_SEND_CODE = 'auto-report.send-code';
|
||||
public const AUTO_REPORT_SEND_PHPINFO = 'auto-report.send-phpinfo';
|
||||
public const AUTO_REPORT_SEND_SETTINGS = 'auto-report.send-settings';
|
||||
public const AUTO_REPORT_USE_HTTPS = 'auto-report.use-https';
|
||||
public const AUTO_UPDATER = 'auto-updater';
|
||||
public const AUTO_UPDATER_ENABLED = 'auto-updater.enabled';
|
||||
public const AUTO_UPDATER_HOST = 'auto-updater.host';
|
||||
public const AUTO_UPDATER_ON_UPDATE = 'auto-updater.on-update';
|
||||
public const AUTO_UPDATER_ON_UPDATE_WARN_CONSOLE = 'auto-updater.on-update.warn-console';
|
||||
public const AUTO_UPDATER_PREFERRED_CHANNEL = 'auto-updater.preferred-channel';
|
||||
public const AUTO_UPDATER_SUGGEST_CHANNELS = 'auto-updater.suggest-channels';
|
||||
public const CHUNK_GENERATION = 'chunk-generation';
|
||||
public const CHUNK_GENERATION_POPULATION_QUEUE_SIZE = 'chunk-generation.population-queue-size';
|
||||
public const CHUNK_SENDING = 'chunk-sending';
|
||||
public const CHUNK_SENDING_PER_TICK = 'chunk-sending.per-tick';
|
||||
public const CHUNK_SENDING_SPAWN_RADIUS = 'chunk-sending.spawn-radius';
|
||||
public const CHUNK_TICKING = 'chunk-ticking';
|
||||
public const CHUNK_TICKING_BLOCKS_PER_SUBCHUNK_PER_TICK = 'chunk-ticking.blocks-per-subchunk-per-tick';
|
||||
public const CHUNK_TICKING_DISABLE_BLOCK_TICKING = 'chunk-ticking.disable-block-ticking';
|
||||
public const CHUNK_TICKING_TICK_RADIUS = 'chunk-ticking.tick-radius';
|
||||
public const CONSOLE = 'console';
|
||||
public const CONSOLE_ENABLE_INPUT = 'console.enable-input';
|
||||
public const CONSOLE_TITLE_TICK = 'console.title-tick';
|
||||
public const DEBUG = 'debug';
|
||||
public const DEBUG_LEVEL = 'debug.level';
|
||||
public const LEVEL_SETTINGS = 'level-settings';
|
||||
public const LEVEL_SETTINGS_DEFAULT_FORMAT = 'level-settings.default-format';
|
||||
public const MEMORY = 'memory';
|
||||
public const MEMORY_ASYNC_WORKER_HARD_LIMIT = 'memory.async-worker-hard-limit';
|
||||
public const MEMORY_CHECK_RATE = 'memory.check-rate';
|
||||
public const MEMORY_CONTINUOUS_TRIGGER = 'memory.continuous-trigger';
|
||||
public const MEMORY_CONTINUOUS_TRIGGER_RATE = 'memory.continuous-trigger-rate';
|
||||
public const MEMORY_GARBAGE_COLLECTION = 'memory.garbage-collection';
|
||||
public const MEMORY_GARBAGE_COLLECTION_COLLECT_ASYNC_WORKER = 'memory.garbage-collection.collect-async-worker';
|
||||
public const MEMORY_GARBAGE_COLLECTION_LOW_MEMORY_TRIGGER = 'memory.garbage-collection.low-memory-trigger';
|
||||
public const MEMORY_GARBAGE_COLLECTION_PERIOD = 'memory.garbage-collection.period';
|
||||
public const MEMORY_GLOBAL_LIMIT = 'memory.global-limit';
|
||||
public const MEMORY_MAIN_HARD_LIMIT = 'memory.main-hard-limit';
|
||||
public const MEMORY_MAIN_LIMIT = 'memory.main-limit';
|
||||
public const MEMORY_MAX_CHUNKS = 'memory.max-chunks';
|
||||
public const MEMORY_MAX_CHUNKS_CHUNK_RADIUS = 'memory.max-chunks.chunk-radius';
|
||||
public const MEMORY_MAX_CHUNKS_TRIGGER_CHUNK_COLLECT = 'memory.max-chunks.trigger-chunk-collect';
|
||||
public const MEMORY_MEMORY_DUMP = 'memory.memory-dump';
|
||||
public const MEMORY_MEMORY_DUMP_DUMP_ASYNC_WORKER = 'memory.memory-dump.dump-async-worker';
|
||||
public const MEMORY_WORLD_CACHES = 'memory.world-caches';
|
||||
public const MEMORY_WORLD_CACHES_DISABLE_CHUNK_CACHE = 'memory.world-caches.disable-chunk-cache';
|
||||
public const MEMORY_WORLD_CACHES_LOW_MEMORY_TRIGGER = 'memory.world-caches.low-memory-trigger';
|
||||
public const NETWORK = 'network';
|
||||
public const NETWORK_ASYNC_COMPRESSION = 'network.async-compression';
|
||||
public const NETWORK_ASYNC_COMPRESSION_THRESHOLD = 'network.async-compression-threshold';
|
||||
public const NETWORK_BATCH_THRESHOLD = 'network.batch-threshold';
|
||||
public const NETWORK_COMPRESSION_LEVEL = 'network.compression-level';
|
||||
public const NETWORK_ENABLE_ENCRYPTION = 'network.enable-encryption';
|
||||
public const NETWORK_MAX_MTU_SIZE = 'network.max-mtu-size';
|
||||
public const NETWORK_UPNP_FORWARDING = 'network.upnp-forwarding';
|
||||
public const PLAYER = 'player';
|
||||
public const PLAYER_SAVE_PLAYER_DATA = 'player.save-player-data';
|
||||
public const PLAYER_VERIFY_XUID = 'player.verify-xuid';
|
||||
public const PLUGINS = 'plugins';
|
||||
public const PLUGINS_LEGACY_DATA_DIR = 'plugins.legacy-data-dir';
|
||||
public const SETTINGS = 'settings';
|
||||
public const SETTINGS_ASYNC_WORKERS = 'settings.async-workers';
|
||||
public const SETTINGS_ENABLE_DEV_BUILDS = 'settings.enable-dev-builds';
|
||||
public const SETTINGS_ENABLE_PROFILING = 'settings.enable-profiling';
|
||||
public const SETTINGS_FORCE_LANGUAGE = 'settings.force-language';
|
||||
public const SETTINGS_PROFILE_REPORT_TRIGGER = 'settings.profile-report-trigger';
|
||||
public const SETTINGS_QUERY_PLUGINS = 'settings.query-plugins';
|
||||
public const SETTINGS_SHUTDOWN_MESSAGE = 'settings.shutdown-message';
|
||||
public const TICKS_PER = 'ticks-per';
|
||||
public const TICKS_PER_AUTOSAVE = 'ticks-per.autosave';
|
||||
public const TIMINGS = 'timings';
|
||||
public const TIMINGS_HOST = 'timings.host';
|
||||
public const WORLDS = 'worlds';
|
||||
}
|
@ -51,11 +51,11 @@ class Anvil extends Transparent implements Fallable{
|
||||
|
||||
private int $damage = self::UNDAMAGED;
|
||||
|
||||
protected function describeType(RuntimeDataDescriber $w) : void{
|
||||
public function describeBlockItemState(RuntimeDataDescriber $w) : void{
|
||||
$w->boundedInt(2, self::UNDAMAGED, self::VERY_DAMAGED, $this->damage);
|
||||
}
|
||||
|
||||
protected function describeState(RuntimeDataDescriber $w) : void{
|
||||
protected function describeBlockOnlyState(RuntimeDataDescriber $w) : void{
|
||||
$w->horizontalFacing($this->facing);
|
||||
}
|
||||
|
||||
|
@ -55,7 +55,7 @@ class Bamboo extends Transparent{
|
||||
protected bool $ready = false;
|
||||
protected int $leafSize = self::NO_LEAVES;
|
||||
|
||||
protected function describeState(RuntimeDataDescriber $w) : void{
|
||||
protected function describeBlockOnlyState(RuntimeDataDescriber $w) : void{
|
||||
$w->boundedInt(2, self::NO_LEAVES, self::LARGE_LEAVES, $this->leafSize);
|
||||
$w->bool($this->thick);
|
||||
$w->bool($this->ready);
|
||||
@ -131,7 +131,7 @@ class Bamboo extends Transparent{
|
||||
private function seekToTop() : Bamboo{
|
||||
$world = $this->position->getWorld();
|
||||
$top = $this;
|
||||
while(($next = $world->getBlock($top->position->up())) instanceof Bamboo && $next->isSameType($this)){
|
||||
while(($next = $world->getBlock($top->position->up())) instanceof Bamboo && $next->hasSameTypeId($this)){
|
||||
$top = $next;
|
||||
}
|
||||
return $top;
|
||||
@ -156,7 +156,7 @@ class Bamboo extends Transparent{
|
||||
public function onNearbyBlockChange() : void{
|
||||
$world = $this->position->getWorld();
|
||||
$below = $world->getBlock($this->position->down());
|
||||
if(!$this->canBeSupportedBy($below) && !$below->isSameType($this)){
|
||||
if(!$this->canBeSupportedBy($below) && !$below->hasSameTypeId($this)){
|
||||
$world->useBreakOn($this->position);
|
||||
}
|
||||
}
|
||||
@ -168,7 +168,7 @@ class Bamboo extends Transparent{
|
||||
}
|
||||
|
||||
$height = 1;
|
||||
while($world->getBlock($this->position->subtract(0, $height, 0))->isSameType($this)){
|
||||
while($world->getBlock($this->position->subtract(0, $height, 0))->hasSameTypeId($this)){
|
||||
if(++$height >= $maxHeight){
|
||||
return false;
|
||||
}
|
||||
|
@ -36,7 +36,7 @@ use pocketmine\world\BlockTransaction;
|
||||
final class BambooSapling extends Flowable{
|
||||
private bool $ready = false;
|
||||
|
||||
protected function describeState(RuntimeDataDescriber $w) : void{
|
||||
protected function describeBlockOnlyState(RuntimeDataDescriber $w) : void{
|
||||
$w->bool($this->ready);
|
||||
}
|
||||
|
||||
|
@ -38,7 +38,7 @@ class Barrel extends Opaque{
|
||||
|
||||
protected bool $open = false;
|
||||
|
||||
protected function describeState(RuntimeDataDescriber $w) : void{
|
||||
protected function describeBlockOnlyState(RuntimeDataDescriber $w) : void{
|
||||
$w->facing($this->facing);
|
||||
$w->bool($this->open);
|
||||
}
|
||||
|
136
src/block/BaseBigDripleaf.php
Normal file
136
src/block/BaseBigDripleaf.php
Normal file
@ -0,0 +1,136 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
*
|
||||
* ____ _ _ __ __ _ __ __ ____
|
||||
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
|
||||
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
|
||||
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
|
||||
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* @author PocketMine Team
|
||||
* @link http://www.pocketmine.net/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\block\utils\HorizontalFacingTrait;
|
||||
use pocketmine\block\utils\SupportType;
|
||||
use pocketmine\event\block\StructureGrowEvent;
|
||||
use pocketmine\item\Fertilizer;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\math\Facing;
|
||||
use pocketmine\math\Vector3;
|
||||
use pocketmine\player\Player;
|
||||
use pocketmine\world\BlockTransaction;
|
||||
|
||||
abstract class BaseBigDripleaf extends Transparent{
|
||||
use HorizontalFacingTrait;
|
||||
|
||||
abstract protected function isHead() : bool;
|
||||
|
||||
private function canBeSupportedBy(Block $block, bool $head) : bool{
|
||||
//TODO: Moss block
|
||||
return
|
||||
($block instanceof BaseBigDripleaf && $block->isHead() === $head) ||
|
||||
$block->getTypeId() === BlockTypeIds::CLAY ||
|
||||
$block->hasTypeTag(BlockTypeTags::DIRT) ||
|
||||
$block->hasTypeTag(BlockTypeTags::MUD);
|
||||
}
|
||||
|
||||
public function onNearbyBlockChange() : void{
|
||||
if(
|
||||
(!$this->isHead() && !$this->getSide(Facing::UP) instanceof BaseBigDripleaf) ||
|
||||
!$this->canBeSupportedBy($this->getSide(Facing::DOWN), false)
|
||||
){
|
||||
$this->position->getWorld()->useBreakOn($this->position);
|
||||
}
|
||||
}
|
||||
|
||||
public function place(BlockTransaction $tx, Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, ?Player $player = null) : bool{
|
||||
$block = $blockReplace->getSide(Facing::DOWN);
|
||||
if(!$this->canBeSupportedBy($block, true)){
|
||||
return false;
|
||||
}
|
||||
if($player !== null){
|
||||
$this->facing = Facing::opposite($player->getHorizontalFacing());
|
||||
}
|
||||
if($block instanceof BaseBigDripleaf){
|
||||
$this->facing = $block->getFacing();
|
||||
$tx->addBlock($block->getPosition(), VanillaBlocks::BIG_DRIPLEAF_STEM()->setFacing($this->facing));
|
||||
}
|
||||
return parent::place($tx, $item, $blockReplace, $blockClicked, $face, $clickVector, $player);
|
||||
}
|
||||
|
||||
public function onInteract(Item $item, int $face, Vector3 $clickVector, ?Player $player = null, array &$returnedItems = []) : bool{
|
||||
if($item instanceof Fertilizer && $this->grow($player)){
|
||||
$item->pop();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private function seekToHead() : ?BaseBigDripleaf{
|
||||
if($this->isHead()){
|
||||
return $this;
|
||||
}
|
||||
$step = 1;
|
||||
while(($next = $this->getSide(Facing::UP, $step)) instanceof BaseBigDripleaf){
|
||||
if($next->isHead()){
|
||||
return $next;
|
||||
}
|
||||
$step++;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private function grow(?Player $player) : bool{
|
||||
$head = $this->seekToHead();
|
||||
if($head === null){
|
||||
return false;
|
||||
}
|
||||
$pos = $head->getPosition();
|
||||
$up = $pos->up();
|
||||
$world = $pos->getWorld();
|
||||
if(
|
||||
!$world->isInWorld($up->getFloorX(), $up->getFloorY(), $up->getFloorZ()) ||
|
||||
$world->getBlock($up)->getTypeId() !== BlockTypeIds::AIR
|
||||
){
|
||||
return false;
|
||||
}
|
||||
|
||||
$tx = new BlockTransaction($world);
|
||||
|
||||
$tx->addBlock($pos, VanillaBlocks::BIG_DRIPLEAF_STEM()->setFacing($head->getFacing()));
|
||||
$tx->addBlock($up, VanillaBlocks::BIG_DRIPLEAF_HEAD()->setFacing($head->getFacing()));
|
||||
|
||||
$ev = new StructureGrowEvent($head, $tx, $player);
|
||||
$ev->call();
|
||||
|
||||
if(!$ev->isCancelled()){
|
||||
return $tx->apply();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function getFlameEncouragement() : int{
|
||||
return 15;
|
||||
}
|
||||
|
||||
public function getFlammability() : int{
|
||||
return 100;
|
||||
}
|
||||
|
||||
public function getSupportType(int $facing) : SupportType{
|
||||
return SupportType::NONE();
|
||||
}
|
||||
}
|
@ -23,10 +23,10 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\block\utils\BlockEventHelper;
|
||||
use pocketmine\block\utils\CoralType;
|
||||
use pocketmine\block\utils\CoralTypeTrait;
|
||||
use pocketmine\block\utils\SupportType;
|
||||
use pocketmine\event\block\BlockDeathEvent;
|
||||
use pocketmine\item\Item;
|
||||
use function mt_rand;
|
||||
|
||||
@ -34,8 +34,8 @@ abstract class BaseCoral extends Transparent{
|
||||
use CoralTypeTrait;
|
||||
|
||||
public function __construct(BlockIdentifier $idInfo, string $name, BlockTypeInfo $typeInfo){
|
||||
parent::__construct($idInfo, $name, $typeInfo);
|
||||
$this->coralType = CoralType::TUBE();
|
||||
parent::__construct($idInfo, $name, $typeInfo);
|
||||
}
|
||||
|
||||
public function onNearbyBlockChange() : void{
|
||||
@ -46,11 +46,7 @@ abstract class BaseCoral extends Transparent{
|
||||
|
||||
public function onScheduledUpdate() : void{
|
||||
if(!$this->dead && !$this->isCoveredWithWater()){
|
||||
$ev = new BlockDeathEvent($this, $this->setDead(true));
|
||||
$ev->call();
|
||||
if(!$ev->isCancelled()){
|
||||
$this->position->getWorld()->setBlock($this->position, $ev->getNewState());
|
||||
}
|
||||
BlockEventHelper::die($this, (clone $this)->setDead(true));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -38,7 +38,7 @@ use function in_array;
|
||||
abstract class BaseRail extends Flowable{
|
||||
|
||||
public function place(BlockTransaction $tx, Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, ?Player $player = null) : bool{
|
||||
if($blockReplace->getSide(Facing::DOWN)->getSupportType(Facing::UP)->hasEdgeSupport()){
|
||||
if($blockReplace->getAdjacentSupportType(Facing::DOWN)->hasEdgeSupport()){
|
||||
return parent::place($tx, $item, $blockReplace, $blockClicked, $face, $clickVector, $player);
|
||||
}
|
||||
|
||||
@ -222,7 +222,7 @@ abstract class BaseRail extends Flowable{
|
||||
|
||||
public function onNearbyBlockChange() : void{
|
||||
$world = $this->position->getWorld();
|
||||
if(!$this->getSide(Facing::DOWN)->getSupportType(Facing::UP)->hasEdgeSupport()){
|
||||
if(!$this->getAdjacentSupportType(Facing::DOWN)->hasEdgeSupport()){
|
||||
$world->useBreakOn($this->position);
|
||||
}else{
|
||||
foreach($this->getCurrentShapeConnections() as $connection){
|
||||
|
@ -49,6 +49,8 @@ abstract class BaseSign extends Transparent{
|
||||
use WoodTypeTrait;
|
||||
|
||||
protected SignText $text;
|
||||
private bool $waxed = false;
|
||||
|
||||
protected ?int $editorEntityRuntimeId = null;
|
||||
|
||||
/** @var \Closure() : Item */
|
||||
@ -69,6 +71,7 @@ abstract class BaseSign extends Transparent{
|
||||
$tile = $this->position->getWorld()->getTile($this->position);
|
||||
if($tile instanceof TileSign){
|
||||
$this->text = $tile->getText();
|
||||
$this->waxed = $tile->isWaxed();
|
||||
$this->editorEntityRuntimeId = $tile->getEditorEntityRuntimeId();
|
||||
}
|
||||
|
||||
@ -80,6 +83,7 @@ abstract class BaseSign extends Transparent{
|
||||
$tile = $this->position->getWorld()->getTile($this->position);
|
||||
assert($tile instanceof TileSign);
|
||||
$tile->setText($this->text);
|
||||
$tile->setWaxed($this->waxed);
|
||||
$tile->setEditorEntityRuntimeId($this->editorEntityRuntimeId);
|
||||
}
|
||||
|
||||
@ -117,6 +121,15 @@ abstract class BaseSign extends Transparent{
|
||||
return parent::place($tx, $item, $blockReplace, $blockClicked, $face, $clickVector, $player);
|
||||
}
|
||||
|
||||
public function onPostPlace() : void{
|
||||
$player = $this->editorEntityRuntimeId !== null ?
|
||||
$this->position->getWorld()->getEntity($this->editorEntityRuntimeId) :
|
||||
null;
|
||||
if($player instanceof Player){
|
||||
$player->openSignEditor($this->position);
|
||||
}
|
||||
}
|
||||
|
||||
private function doSignChange(SignText $newText, Player $player, Item $item) : bool{
|
||||
$ev = new SignChangeEvent($this, $player, $newText);
|
||||
$ev->call();
|
||||
@ -138,10 +151,26 @@ abstract class BaseSign extends Transparent{
|
||||
return false;
|
||||
}
|
||||
|
||||
private function wax(Player $player, Item $item) : bool{
|
||||
if($this->waxed){
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->waxed = true;
|
||||
$this->position->getWorld()->setBlock($this->position, $this);
|
||||
$item->pop();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function onInteract(Item $item, int $face, Vector3 $clickVector, ?Player $player = null, array &$returnedItems = []) : bool{
|
||||
if($player === null){
|
||||
return false;
|
||||
}
|
||||
if($this->waxed){
|
||||
return true;
|
||||
}
|
||||
|
||||
$dyeColor = $item instanceof Dye ? $item->getColor() : match($item->getTypeId()){
|
||||
ItemTypeIds::BONE_MEAL => DyeColor::WHITE(),
|
||||
ItemTypeIds::LAPIS_LAZULI => DyeColor::BLUE(),
|
||||
@ -150,20 +179,25 @@ abstract class BaseSign extends Transparent{
|
||||
};
|
||||
if($dyeColor !== null){
|
||||
$color = $dyeColor->equals(DyeColor::BLACK()) ? new Color(0, 0, 0) : $dyeColor->getRgbValue();
|
||||
if($color->toARGB() === $this->text->getBaseColor()->toARGB()){
|
||||
return false;
|
||||
}
|
||||
|
||||
if($this->doSignChange(new SignText($this->text->getLines(), $color, $this->text->isGlowing()), $player, $item)){
|
||||
if(
|
||||
$color->toARGB() !== $this->text->getBaseColor()->toARGB() &&
|
||||
$this->doSignChange(new SignText($this->text->getLines(), $color, $this->text->isGlowing()), $player, $item)
|
||||
){
|
||||
$this->position->getWorld()->addSound($this->position, new DyeUseSound());
|
||||
return true;
|
||||
}
|
||||
}elseif($item->getTypeId() === ItemTypeIds::INK_SAC){
|
||||
return $this->changeSignGlowingState(false, $player, $item);
|
||||
}elseif($item->getTypeId() === ItemTypeIds::GLOW_INK_SAC){
|
||||
return $this->changeSignGlowingState(true, $player, $item);
|
||||
}elseif(match($item->getTypeId()){
|
||||
ItemTypeIds::INK_SAC => $this->changeSignGlowingState(false, $player, $item),
|
||||
ItemTypeIds::GLOW_INK_SAC => $this->changeSignGlowingState(true, $player, $item),
|
||||
ItemTypeIds::HONEYCOMB => $this->wax($player, $item),
|
||||
default => false
|
||||
}){
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
$player->openSignEditor($this->position);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -179,6 +213,30 @@ abstract class BaseSign extends Transparent{
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the sign has been waxed using a honeycomb. If true, the sign cannot be edited by a player.
|
||||
*/
|
||||
public function isWaxed() : bool{ return $this->waxed; }
|
||||
|
||||
/** @return $this */
|
||||
public function setWaxed(bool $waxed) : self{
|
||||
$this->waxed = $waxed;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the runtime entity ID of the player editing this sign. Only this player will be able to edit the sign.
|
||||
* This is used to prevent multiple players from editing the same sign at the same time, and to prevent players
|
||||
* from editing signs they didn't place.
|
||||
*/
|
||||
public function getEditorEntityRuntimeId() : ?int{ return $this->editorEntityRuntimeId; }
|
||||
|
||||
/** @return $this */
|
||||
public function setEditorEntityRuntimeId(?int $editorEntityRuntimeId) : self{
|
||||
$this->editorEntityRuntimeId = $editorEntityRuntimeId;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called by the player controller (network session) to update the sign text, firing events as appropriate.
|
||||
*
|
||||
@ -195,13 +253,14 @@ abstract class BaseSign extends Transparent{
|
||||
}
|
||||
$ev = new SignChangeEvent($this, $author, new SignText(array_map(function(string $line) : string{
|
||||
return TextFormat::clean($line, false);
|
||||
}, $text->getLines())));
|
||||
if($this->editorEntityRuntimeId === null || $this->editorEntityRuntimeId !== $author->getId()){
|
||||
}, $text->getLines()), $this->text->getBaseColor(), $this->text->isGlowing()));
|
||||
if($this->waxed || $this->editorEntityRuntimeId !== $author->getId()){
|
||||
$ev->cancel();
|
||||
}
|
||||
$ev->call();
|
||||
if(!$ev->isCancelled()){
|
||||
$this->setText($ev->getNewText());
|
||||
$this->setEditorEntityRuntimeId(null);
|
||||
$this->position->getWorld()->setBlock($this->position, $this);
|
||||
return true;
|
||||
}
|
||||
@ -212,4 +271,8 @@ abstract class BaseSign extends Transparent{
|
||||
public function asItem() : Item{
|
||||
return ($this->asItemCallback)();
|
||||
}
|
||||
|
||||
public function getFuelTime() : int{
|
||||
return $this->woodType->isFlammable() ? 200 : 0;
|
||||
}
|
||||
}
|
||||
|
@ -53,7 +53,7 @@ class Bed extends Transparent{
|
||||
parent::__construct($idInfo, $name, $typeInfo);
|
||||
}
|
||||
|
||||
protected function describeState(RuntimeDataDescriber $w) : void{
|
||||
protected function describeBlockOnlyState(RuntimeDataDescriber $w) : void{
|
||||
$w->horizontalFacing($this->facing);
|
||||
$w->bool($this->occupied);
|
||||
$w->bool($this->head);
|
||||
@ -177,11 +177,11 @@ class Bed extends Transparent{
|
||||
}
|
||||
|
||||
public function place(BlockTransaction $tx, Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, ?Player $player = null) : bool{
|
||||
if($this->canBeSupportedBy($this->getSide(Facing::DOWN))){
|
||||
if($this->canBeSupportedAt($blockReplace)){
|
||||
$this->facing = $player !== null ? $player->getHorizontalFacing() : Facing::NORTH;
|
||||
|
||||
$next = $this->getSide($this->getOtherHalfSide());
|
||||
if($next->canBeReplaced() && $this->canBeSupportedBy($next->getSide(Facing::DOWN))){
|
||||
if($next->canBeReplaced() && $this->canBeSupportedAt($next)){
|
||||
$nextState = clone $this;
|
||||
$nextState->head = true;
|
||||
$tx->addBlock($blockReplace->position, $this)->addBlock($next->position, $nextState);
|
||||
@ -208,8 +208,8 @@ class Bed extends Transparent{
|
||||
return parent::getAffectedBlocks();
|
||||
}
|
||||
|
||||
private function canBeSupportedBy(Block $block) : bool{
|
||||
return !$block->getSupportType(Facing::UP)->equals(SupportType::NONE());
|
||||
private function canBeSupportedAt(Block $block) : bool{
|
||||
return !$block->getAdjacentSupportType(Facing::DOWN)->equals(SupportType::NONE());
|
||||
}
|
||||
|
||||
public function getMaxStackSize() : int{ return 1; }
|
||||
|
@ -28,7 +28,7 @@ use pocketmine\data\runtime\RuntimeDataDescriber;
|
||||
class Bedrock extends Opaque{
|
||||
private bool $burnsForever = false;
|
||||
|
||||
protected function describeState(RuntimeDataDescriber $w) : void{
|
||||
protected function describeBlockOnlyState(RuntimeDataDescriber $w) : void{
|
||||
$w->bool($this->burnsForever);
|
||||
}
|
||||
|
||||
|
@ -23,9 +23,9 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\block\utils\FortuneDropHelper;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\item\VanillaItems;
|
||||
use function mt_rand;
|
||||
|
||||
class Beetroot extends Crops{
|
||||
|
||||
@ -33,7 +33,7 @@ class Beetroot extends Crops{
|
||||
if($this->age >= self::MAX_AGE){
|
||||
return [
|
||||
VanillaItems::BEETROOT(),
|
||||
VanillaItems::BEETROOT_SEEDS()->setCount(mt_rand(0, 3))
|
||||
VanillaItems::BEETROOT_SEEDS()->setCount(FortuneDropHelper::binomial($item, 0))
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -35,6 +35,7 @@ use pocketmine\math\Facing;
|
||||
use pocketmine\math\RayTraceResult;
|
||||
use pocketmine\math\Vector3;
|
||||
use pocketmine\player\Player;
|
||||
use pocketmine\utils\AssumptionFailedError;
|
||||
use pocketmine\world\BlockTransaction;
|
||||
use pocketmine\world\sound\BellRingSound;
|
||||
|
||||
@ -48,7 +49,7 @@ final class Bell extends Transparent{
|
||||
parent::__construct($idInfo, $name, $typeInfo);
|
||||
}
|
||||
|
||||
protected function describeState(RuntimeDataDescriber $w) : void{
|
||||
protected function describeBlockOnlyState(RuntimeDataDescriber $w) : void{
|
||||
$w->bellAttachmentType($this->attachmentType);
|
||||
$w->horizontalFacing($this->facing);
|
||||
}
|
||||
@ -87,46 +88,44 @@ final class Bell extends Transparent{
|
||||
return $this;
|
||||
}
|
||||
|
||||
private function canBeSupportedBy(Block $block, int $face) : bool{
|
||||
return !$block->getSupportType($face)->equals(SupportType::NONE());
|
||||
private function canBeSupportedAt(Block $block, int $face) : bool{
|
||||
return !$block->getAdjacentSupportType($face)->equals(SupportType::NONE());
|
||||
}
|
||||
|
||||
public function place(BlockTransaction $tx, Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, ?Player $player = null) : bool{
|
||||
if(!$this->canBeSupportedAt($blockReplace, Facing::opposite($face))){
|
||||
return false;
|
||||
}
|
||||
if($face === Facing::UP){
|
||||
if(!$this->canBeSupportedBy($tx->fetchBlock($this->position->down()), Facing::UP)){
|
||||
return false;
|
||||
}
|
||||
if($player !== null){
|
||||
$this->setFacing(Facing::opposite($player->getHorizontalFacing()));
|
||||
}
|
||||
$this->setAttachmentType(BellAttachmentType::FLOOR());
|
||||
}elseif($face === Facing::DOWN){
|
||||
if(!$this->canBeSupportedBy($tx->fetchBlock($this->position->up()), Facing::DOWN)){
|
||||
return false;
|
||||
}
|
||||
$this->setAttachmentType(BellAttachmentType::CEILING());
|
||||
}else{
|
||||
$this->setFacing($face);
|
||||
if($this->canBeSupportedBy($tx->fetchBlock($this->position->getSide(Facing::opposite($face))), $face)){
|
||||
$this->setAttachmentType(BellAttachmentType::ONE_WALL());
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
if($this->canBeSupportedBy($tx->fetchBlock($this->position->getSide($face)), Facing::opposite($face))){
|
||||
$this->setAttachmentType(BellAttachmentType::TWO_WALLS());
|
||||
}
|
||||
$this->setAttachmentType(
|
||||
$this->canBeSupportedAt($blockReplace, $face) ?
|
||||
BellAttachmentType::TWO_WALLS() :
|
||||
BellAttachmentType::ONE_WALL()
|
||||
);
|
||||
}
|
||||
return parent::place($tx, $item, $blockReplace, $blockClicked, $face, $clickVector, $player);
|
||||
}
|
||||
|
||||
public function onNearbyBlockChange() : void{
|
||||
if(
|
||||
($this->attachmentType->equals(BellAttachmentType::CEILING()) && !$this->canBeSupportedBy($this->getSide(Facing::UP), Facing::DOWN)) ||
|
||||
($this->attachmentType->equals(BellAttachmentType::FLOOR()) && !$this->canBeSupportedBy($this->getSide(Facing::DOWN), Facing::UP)) ||
|
||||
($this->attachmentType->equals(BellAttachmentType::ONE_WALL()) && !$this->canBeSupportedBy($this->getSide(Facing::opposite($this->facing)), $this->facing)) ||
|
||||
($this->attachmentType->equals(BellAttachmentType::TWO_WALLS()) && (!$this->canBeSupportedBy($this->getSide($this->facing), Facing::opposite($this->facing)) || !$this->canBeSupportedBy($this->getSide(Facing::opposite($this->facing)), $this->facing)))
|
||||
){
|
||||
$this->position->getWorld()->useBreakOn($this->position);
|
||||
foreach(match($this->attachmentType){
|
||||
BellAttachmentType::CEILING() => [Facing::UP],
|
||||
BellAttachmentType::FLOOR() => [Facing::DOWN],
|
||||
BellAttachmentType::ONE_WALL() => [Facing::opposite($this->facing)],
|
||||
BellAttachmentType::TWO_WALLS() => [$this->facing, Facing::opposite($this->facing)],
|
||||
default => throw new AssumptionFailedError("All cases of BellAttachmentType must be handled")
|
||||
} as $supportBlockDirection){
|
||||
if(!$this->canBeSupportedAt($this, $supportBlockDirection)){
|
||||
$this->position->getWorld()->useBreakOn($this->position);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -159,13 +158,11 @@ final class Bell extends Transparent{
|
||||
}
|
||||
|
||||
private function isValidFaceToRing(int $faceHit) : bool{
|
||||
return (
|
||||
$this->attachmentType->equals(BellAttachmentType::CEILING()) ||
|
||||
($this->attachmentType->equals(BellAttachmentType::FLOOR()) && Facing::axis($faceHit) === Facing::axis($this->facing)) ||
|
||||
(
|
||||
($this->attachmentType->equals(BellAttachmentType::ONE_WALL()) || $this->attachmentType->equals(BellAttachmentType::TWO_WALLS())) &&
|
||||
($faceHit === Facing::rotateY($this->facing, false) || $faceHit === Facing::rotateY($this->facing, true))
|
||||
)
|
||||
);
|
||||
return match($this->attachmentType){
|
||||
BellAttachmentType::CEILING() => true,
|
||||
BellAttachmentType::FLOOR() => Facing::axis($faceHit) === Facing::axis($this->facing),
|
||||
BellAttachmentType::ONE_WALL(), BellAttachmentType::TWO_WALLS() => $faceHit === Facing::rotateY($this->facing, false) || $faceHit === Facing::rotateY($this->facing, true),
|
||||
default => throw new AssumptionFailedError("All cases of BellAttachmentType must be handled")
|
||||
};
|
||||
}
|
||||
}
|
||||
|
132
src/block/BigDripleafHead.php
Normal file
132
src/block/BigDripleafHead.php
Normal file
@ -0,0 +1,132 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
*
|
||||
* ____ _ _ __ __ _ __ __ ____
|
||||
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
|
||||
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
|
||||
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
|
||||
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* @author PocketMine Team
|
||||
* @link http://www.pocketmine.net/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\block\utils\DripleafState;
|
||||
use pocketmine\data\runtime\RuntimeDataDescriber;
|
||||
use pocketmine\entity\Entity;
|
||||
use pocketmine\entity\projectile\Projectile;
|
||||
use pocketmine\math\AxisAlignedBB;
|
||||
use pocketmine\math\Facing;
|
||||
use pocketmine\math\RayTraceResult;
|
||||
use pocketmine\utils\AssumptionFailedError;
|
||||
use pocketmine\world\sound\DripleafTiltDownSound;
|
||||
use pocketmine\world\sound\DripleafTiltUpSound;
|
||||
|
||||
class BigDripleafHead extends BaseBigDripleaf{
|
||||
|
||||
protected DripleafState $leafState;
|
||||
|
||||
public function __construct(BlockIdentifier $idInfo, string $name, BlockTypeInfo $typeInfo){
|
||||
$this->leafState = DripleafState::STABLE();
|
||||
parent::__construct($idInfo, $name, $typeInfo);
|
||||
}
|
||||
|
||||
protected function describeBlockOnlyState(RuntimeDataDescriber $w) : void{
|
||||
parent::describeBlockOnlyState($w);
|
||||
$w->dripleafState($this->leafState);
|
||||
}
|
||||
|
||||
protected function isHead() : bool{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function getLeafState() : DripleafState{
|
||||
return $this->leafState;
|
||||
}
|
||||
|
||||
/** @return $this */
|
||||
public function setLeafState(DripleafState $leafState) : self{
|
||||
$this->leafState = $leafState;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function hasEntityCollision() : bool{
|
||||
return true;
|
||||
}
|
||||
|
||||
private function setTiltAndScheduleTick(DripleafState $tilt) : void{
|
||||
$this->position->getWorld()->setBlock($this->position, $this->setLeafState($tilt));
|
||||
$delay = $tilt->getScheduledUpdateDelayTicks();
|
||||
if($delay !== null){
|
||||
$this->position->getWorld()->scheduleDelayedBlockUpdate($this->position, $delay);
|
||||
}
|
||||
}
|
||||
|
||||
private function getLeafTopOffset() : float{
|
||||
return match($this->leafState){
|
||||
DripleafState::STABLE(), DripleafState::UNSTABLE() => 1 / 16,
|
||||
DripleafState::PARTIAL_TILT() => 3 / 16,
|
||||
default => 0
|
||||
};
|
||||
}
|
||||
|
||||
public function onEntityInside(Entity $entity) : bool{
|
||||
if(!$entity instanceof Projectile && $this->leafState->equals(DripleafState::STABLE())){
|
||||
//the entity must be standing on top of the leaf - do not collapse if the entity is standing underneath
|
||||
$intersection = AxisAlignedBB::one()
|
||||
->offset($this->position->x, $this->position->y, $this->position->z)
|
||||
->trim(Facing::DOWN, 1 - $this->getLeafTopOffset());
|
||||
if($entity->getBoundingBox()->intersectsWith($intersection)){
|
||||
$this->setTiltAndScheduleTick(DripleafState::UNSTABLE());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public function onProjectileHit(Projectile $projectile, RayTraceResult $hitResult) : void{
|
||||
if(!$this->leafState->equals(DripleafState::FULL_TILT())){
|
||||
$this->setTiltAndScheduleTick(DripleafState::FULL_TILT());
|
||||
$this->position->getWorld()->addSound($this->position, new DripleafTiltDownSound());
|
||||
}
|
||||
}
|
||||
|
||||
public function onScheduledUpdate() : void{
|
||||
if(!$this->leafState->equals(DripleafState::STABLE())){
|
||||
if($this->leafState->equals(DripleafState::FULL_TILT())){
|
||||
$this->position->getWorld()->setBlock($this->position, $this->setLeafState(DripleafState::STABLE()));
|
||||
$this->position->getWorld()->addSound($this->position, new DripleafTiltUpSound());
|
||||
}else{
|
||||
$this->setTiltAndScheduleTick(match($this->leafState->id()){
|
||||
DripleafState::UNSTABLE()->id() => DripleafState::PARTIAL_TILT(),
|
||||
DripleafState::PARTIAL_TILT()->id() => DripleafState::FULL_TILT(),
|
||||
default => throw new AssumptionFailedError("All types should be covered")
|
||||
});
|
||||
$this->position->getWorld()->addSound($this->position, new DripleafTiltDownSound());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected function recalculateCollisionBoxes() : array{
|
||||
if(!$this->leafState->equals(DripleafState::FULL_TILT())){
|
||||
return [
|
||||
AxisAlignedBB::one()
|
||||
->trim(Facing::DOWN, 11 / 16)
|
||||
->trim(Facing::UP, $this->getLeafTopOffset())
|
||||
];
|
||||
}
|
||||
return [];
|
||||
}
|
||||
}
|
41
src/block/BigDripleafStem.php
Normal file
41
src/block/BigDripleafStem.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/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\item\Item;
|
||||
|
||||
class BigDripleafStem extends BaseBigDripleaf{
|
||||
|
||||
protected function isHead() : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
protected function recalculateCollisionBoxes() : array{
|
||||
return [];
|
||||
}
|
||||
|
||||
public function asItem() : Item{
|
||||
return VanillaBlocks::BIG_DRIPLEAF_HEAD()->asItem();
|
||||
}
|
||||
}
|
@ -29,17 +29,22 @@ namespace pocketmine\block;
|
||||
use pocketmine\block\tile\Spawnable;
|
||||
use pocketmine\block\tile\Tile;
|
||||
use pocketmine\block\utils\SupportType;
|
||||
use pocketmine\data\runtime\InvalidSerializedRuntimeDataException;
|
||||
use pocketmine\data\runtime\RuntimeDataDescriber;
|
||||
use pocketmine\data\runtime\RuntimeDataReader;
|
||||
use pocketmine\data\runtime\RuntimeDataSizeCalculator;
|
||||
use pocketmine\data\runtime\RuntimeDataWriter;
|
||||
use pocketmine\entity\Entity;
|
||||
use pocketmine\entity\projectile\Projectile;
|
||||
use pocketmine\item\enchantment\AvailableEnchantmentRegistry;
|
||||
use pocketmine\item\enchantment\ItemEnchantmentTagRegistry;
|
||||
use pocketmine\item\enchantment\ItemEnchantmentTags;
|
||||
use pocketmine\item\enchantment\VanillaEnchantments;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\item\ItemBlock;
|
||||
use pocketmine\math\Axis;
|
||||
use pocketmine\math\AxisAlignedBB;
|
||||
use pocketmine\math\Facing;
|
||||
use pocketmine\math\RayTraceResult;
|
||||
use pocketmine\math\Vector3;
|
||||
use pocketmine\nbt\tag\CompoundTag;
|
||||
@ -57,6 +62,11 @@ class Block{
|
||||
public const INTERNAL_STATE_DATA_BITS = 8;
|
||||
public const INTERNAL_STATE_DATA_MASK = ~(~0 << self::INTERNAL_STATE_DATA_BITS);
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
public const EMPTY_STATE_ID = (BlockTypeIds::AIR << self::INTERNAL_STATE_DATA_BITS) | (BlockTypeIds::AIR & self::INTERNAL_STATE_DATA_MASK);
|
||||
|
||||
protected BlockIdentifier $idInfo;
|
||||
protected string $fallbackName;
|
||||
protected BlockTypeInfo $typeInfo;
|
||||
@ -65,16 +75,10 @@ class Block{
|
||||
/** @var AxisAlignedBB[]|null */
|
||||
protected ?array $collisionBoxes = null;
|
||||
|
||||
/**
|
||||
* @var int[]
|
||||
* @phpstan-var array<string, int>
|
||||
*/
|
||||
private static array $typeDataBits = [];
|
||||
/**
|
||||
* @var int[]
|
||||
* @phpstan-var array<string, int>
|
||||
*/
|
||||
private static array $stateDataBits = [];
|
||||
private int $requiredBlockItemStateDataBits;
|
||||
private int $requiredBlockOnlyStateDataBits;
|
||||
|
||||
private Block $defaultState;
|
||||
|
||||
/**
|
||||
* @param string $name English name of the block type (TODO: implement translations)
|
||||
@ -84,6 +88,18 @@ class Block{
|
||||
$this->fallbackName = $name;
|
||||
$this->typeInfo = $typeInfo;
|
||||
$this->position = new Position(0, 0, 0, null);
|
||||
|
||||
$calculator = new RuntimeDataSizeCalculator();
|
||||
$this->describeBlockItemState($calculator);
|
||||
$this->requiredBlockItemStateDataBits = $calculator->getBitsUsed();
|
||||
|
||||
$calculator = new RuntimeDataSizeCalculator();
|
||||
$this->describeBlockOnlyState($calculator);
|
||||
$this->requiredBlockOnlyStateDataBits = $calculator->getBitsUsed();
|
||||
|
||||
$defaultState = clone $this;
|
||||
$this->defaultState = $defaultState;
|
||||
$defaultState->defaultState = $defaultState;
|
||||
}
|
||||
|
||||
public function __clone(){
|
||||
@ -107,10 +123,10 @@ class Block{
|
||||
|
||||
/**
|
||||
* Returns a type ID that identifies this type of block. This allows comparing basic block types, e.g. wool, stone,
|
||||
* glass, etc.
|
||||
* glass, etc. Type ID will not change for a given block type.
|
||||
*
|
||||
* This does **NOT** include information like facing, open/closed, powered/unpowered, colour, etc. This means that,
|
||||
* for example, red wool and green wool have the same type ID.
|
||||
* Information such as colour, powered, open/closed, etc. is **not** included in this ID.
|
||||
* If you want to get a state ID that includes this information, use {@link Block::getStateId()} instead.
|
||||
*
|
||||
* @see BlockTypeIds
|
||||
*/
|
||||
@ -125,25 +141,37 @@ class Block{
|
||||
* blocks in chunks at runtime.
|
||||
*
|
||||
* This usually encodes all properties of the block, such as facing, open/closed, powered/unpowered, colour, etc.
|
||||
* However, some blocks (such as signs and chests) may store additional properties in an associated "tile" if they
|
||||
* State ID may change depending on the properties of the block (e.g. a torch facing east will have a different
|
||||
* state ID to one facing west).
|
||||
*
|
||||
* Some blocks (such as signs and chests) may store additional properties in an associated "tile" if they
|
||||
* have too many possible values to be encoded into the state ID. These extra properties are **NOT** included in
|
||||
* this function's result.
|
||||
*
|
||||
* This ID can be used to later obtain a copy of this block using {@link RuntimeBlockStateRegistry::fromStateId()}.
|
||||
* This ID can be used to later obtain a copy of the block with the same state properties by using
|
||||
* {@link RuntimeBlockStateRegistry::fromStateId()}.
|
||||
*/
|
||||
public function getStateId() : int{
|
||||
return ($this->getTypeId() << self::INTERNAL_STATE_DATA_BITS) | $this->computeTypeAndStateData();
|
||||
$typeId = $this->getTypeId();
|
||||
//TODO: this XOR mask improves hashtable distribution, but it's only effective if the number of unique block
|
||||
//type IDs is larger than the number of available state data bits. We should probably hash (e.g. using xxhash)
|
||||
//the type ID to create a better mask.
|
||||
//Alternatively, we could hash the whole state ID, but this is currently problematic, since we currently need
|
||||
//to be able to recover the state data from the state ID because of UnknownBlock.
|
||||
return ($typeId << self::INTERNAL_STATE_DATA_BITS) | ($this->encodeFullState() ^ ($typeId & self::INTERNAL_STATE_DATA_MASK));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the given block has an equivalent type to this one. This compares the type IDs.
|
||||
* Returns whether the given block has the same type ID as this one.
|
||||
*/
|
||||
public function isSameType(Block $other) : bool{
|
||||
public function hasSameTypeId(Block $other) : bool{
|
||||
return $this->getTypeId() === $other->getTypeId();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the given block has the same type and properties as this block.
|
||||
*
|
||||
* Note: Tile data (e.g. sign text, chest contents) are not compared here.
|
||||
*/
|
||||
public function isSameState(Block $other) : bool{
|
||||
return $this->getStateId() === $other->getStateId();
|
||||
@ -170,97 +198,74 @@ class Block{
|
||||
|
||||
/**
|
||||
* Returns the block as an item.
|
||||
* State information such as facing, powered/unpowered, open/closed, etc., is discarded.
|
||||
* Type information such as colour, wood type, etc. is preserved.
|
||||
* Block-only state such as facing, powered/unpowered, open/closed, etc., is discarded.
|
||||
* Block-item state such as colour, wood type, etc. is preserved.
|
||||
* Complex state properties stored in the tile data (e.g. inventory) are discarded.
|
||||
*/
|
||||
public function asItem() : Item{
|
||||
return new ItemBlock($this);
|
||||
$normalized = clone $this->defaultState;
|
||||
$normalized->decodeBlockItemState($this->encodeBlockItemState());
|
||||
return new ItemBlock($normalized);
|
||||
}
|
||||
|
||||
final public function getRequiredTypeDataBits() : int{
|
||||
$class = get_class($this);
|
||||
if(isset(self::$typeDataBits[$class])){
|
||||
return self::$typeDataBits[$class];
|
||||
}
|
||||
$calculator = new RuntimeDataSizeCalculator();
|
||||
$this->describeType($calculator);
|
||||
return self::$typeDataBits[$class] = $calculator->getBitsUsed();
|
||||
}
|
||||
private function decodeBlockItemState(int $data) : void{
|
||||
$reader = new RuntimeDataReader($this->requiredBlockItemStateDataBits, $data);
|
||||
|
||||
final public function getRequiredStateDataBits() : int{
|
||||
$class = get_class($this);
|
||||
if(isset(self::$stateDataBits[$class])){
|
||||
return self::$stateDataBits[$class];
|
||||
}
|
||||
$calculator = new RuntimeDataSizeCalculator();
|
||||
$this->describeState($calculator);
|
||||
return self::$stateDataBits[$class] = $calculator->getBitsUsed();
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
final public function decodeTypeData(int $data) : void{
|
||||
$typeBits = $this->getRequiredTypeDataBits();
|
||||
$reader = new RuntimeDataReader($typeBits, $data);
|
||||
|
||||
$this->describeType($reader);
|
||||
$this->describeBlockItemState($reader);
|
||||
$readBits = $reader->getOffset();
|
||||
if($typeBits !== $readBits){
|
||||
throw new \LogicException(get_class($this) . ": Exactly $typeBits bits of type data were provided, but $readBits were read");
|
||||
if($this->requiredBlockItemStateDataBits !== $readBits){
|
||||
throw new \LogicException(get_class($this) . ": Exactly $this->requiredBlockItemStateDataBits bits of block-item state data were provided, but $readBits were read");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
final public function decodeTypeAndStateData(int $data) : void{
|
||||
$typeBits = $this->getRequiredTypeDataBits();
|
||||
$stateBits = $this->getRequiredStateDataBits();
|
||||
$reader = new RuntimeDataReader($typeBits + $stateBits, $data);
|
||||
$this->decodeTypeData($reader->readInt($typeBits));
|
||||
private function decodeBlockOnlyState(int $data) : void{
|
||||
$reader = new RuntimeDataReader($this->requiredBlockOnlyStateDataBits, $data);
|
||||
|
||||
$this->describeState($reader);
|
||||
$readBits = $reader->getOffset() - $typeBits;
|
||||
if($stateBits !== $readBits){
|
||||
throw new \LogicException(get_class($this) . ": Exactly $stateBits bits of state data were provided, but $readBits were read");
|
||||
$this->describeBlockOnlyState($reader);
|
||||
$readBits = $reader->getOffset();
|
||||
if($this->requiredBlockOnlyStateDataBits !== $readBits){
|
||||
throw new \LogicException(get_class($this) . ": Exactly $this->requiredBlockOnlyStateDataBits bits of block-only state data were provided, but $readBits were read");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
final public function computeTypeData() : int{
|
||||
$typeBits = $this->getRequiredTypeDataBits();
|
||||
$writer = new RuntimeDataWriter($typeBits);
|
||||
private function decodeFullState(int $data) : void{
|
||||
$reader = new RuntimeDataReader($this->requiredBlockItemStateDataBits + $this->requiredBlockOnlyStateDataBits, $data);
|
||||
$this->decodeBlockItemState($reader->readInt($this->requiredBlockItemStateDataBits));
|
||||
$this->decodeBlockOnlyState($reader->readInt($this->requiredBlockOnlyStateDataBits));
|
||||
}
|
||||
|
||||
$this->describeType($writer);
|
||||
private function encodeBlockItemState() : int{
|
||||
$writer = new RuntimeDataWriter($this->requiredBlockItemStateDataBits);
|
||||
|
||||
$this->describeBlockItemState($writer);
|
||||
$writtenBits = $writer->getOffset();
|
||||
if($typeBits !== $writtenBits){
|
||||
throw new \LogicException(get_class($this) . ": Exactly $typeBits bits of type data were expected, but $writtenBits were written");
|
||||
if($this->requiredBlockItemStateDataBits !== $writtenBits){
|
||||
throw new \LogicException(get_class($this) . ": Exactly $this->requiredBlockItemStateDataBits bits of block-item state data were expected, but $writtenBits were written");
|
||||
}
|
||||
|
||||
return $writer->getValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
final public function computeTypeAndStateData() : int{
|
||||
$typeBits = $this->getRequiredTypeDataBits();
|
||||
$stateBits = $this->getRequiredStateDataBits();
|
||||
$writer = new RuntimeDataWriter($typeBits + $stateBits);
|
||||
$writer->writeInt($typeBits, $this->computeTypeData());
|
||||
private function encodeBlockOnlyState() : int{
|
||||
$writer = new RuntimeDataWriter($this->requiredBlockOnlyStateDataBits);
|
||||
|
||||
$this->describeState($writer);
|
||||
$writtenBits = $writer->getOffset() - $typeBits;
|
||||
if($stateBits !== $writtenBits){
|
||||
throw new \LogicException(get_class($this) . ": Exactly $stateBits bits of state data were expected, but $writtenBits were written");
|
||||
$this->describeBlockOnlyState($writer);
|
||||
$writtenBits = $writer->getOffset();
|
||||
if($this->requiredBlockOnlyStateDataBits !== $writtenBits){
|
||||
throw new \LogicException(get_class($this) . ": Exactly $this->requiredBlockOnlyStateDataBits bits of block-only state data were expected, but $writtenBits were written");
|
||||
}
|
||||
|
||||
return $writer->getValue();
|
||||
}
|
||||
|
||||
private function encodeFullState() : int{
|
||||
$writer = new RuntimeDataWriter($this->requiredBlockItemStateDataBits + $this->requiredBlockOnlyStateDataBits);
|
||||
$writer->writeInt($this->requiredBlockItemStateDataBits, $this->encodeBlockItemState());
|
||||
$writer->writeInt($this->requiredBlockOnlyStateDataBits, $this->encodeBlockOnlyState());
|
||||
|
||||
return $writer->getValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* Describes properties of this block which apply to both the block and item form of the block.
|
||||
* Examples of suitable properties include colour, skull type, and any other information which **IS** kept when the
|
||||
@ -269,7 +274,7 @@ class Block{
|
||||
* The method implementation must NOT use conditional logic to determine which properties are written. It must
|
||||
* always write the same properties in the same order, regardless of the current state of the block.
|
||||
*/
|
||||
protected function describeType(RuntimeDataDescriber $w) : void{
|
||||
public function describeBlockItemState(RuntimeDataDescriber $w) : void{
|
||||
//NOOP
|
||||
}
|
||||
|
||||
@ -281,10 +286,39 @@ class Block{
|
||||
* The method implementation must NOT use conditional logic to determine which properties are written. It must
|
||||
* always write the same properties in the same order, regardless of the current state of the block.
|
||||
*/
|
||||
protected function describeState(RuntimeDataDescriber $w) : void{
|
||||
protected function describeBlockOnlyState(RuntimeDataDescriber $w) : void{
|
||||
//NOOP
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates copies of this Block in all possible state permutations.
|
||||
* Every possible combination of known properties (e.g. facing, open/closed, powered/unpowered, on/off) will be
|
||||
* generated.
|
||||
*
|
||||
* @phpstan-return \Generator<int, Block, void, void>
|
||||
*/
|
||||
public function generateStatePermutations() : \Generator{
|
||||
//TODO: this bruteforce approach to discovering all valid states is very inefficient for larger state data sizes
|
||||
//at some point we'll need to find a better way to do this
|
||||
$bits = $this->requiredBlockItemStateDataBits + $this->requiredBlockOnlyStateDataBits;
|
||||
if($bits > Block::INTERNAL_STATE_DATA_BITS){
|
||||
throw new \LogicException("Block state data cannot use more than " . Block::INTERNAL_STATE_DATA_BITS . " bits");
|
||||
}
|
||||
for($stateData = 0; $stateData < (1 << $bits); ++$stateData){
|
||||
$v = clone $this;
|
||||
try{
|
||||
$v->decodeFullState($stateData);
|
||||
if($v->encodeFullState() !== $stateData){
|
||||
throw new \LogicException(static::class . "::decodeStateData() accepts invalid state data (returned " . $v->encodeFullState() . " for input $stateData)");
|
||||
}
|
||||
}catch(InvalidSerializedRuntimeDataException){ //invalid property combination, leave it
|
||||
continue;
|
||||
}
|
||||
|
||||
yield $v;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when this block is created, set, or has a neighbouring block update, to re-detect dynamic properties which
|
||||
* are not saved on the world.
|
||||
@ -391,6 +425,19 @@ class Block{
|
||||
return $this->typeInfo->getBreakInfo();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns tags that represent the type of item being enchanted and are used to determine
|
||||
* what enchantments can be applied to the item of this block during in-game enchanting (enchanting table, anvil, fishing, etc.).
|
||||
* @see ItemEnchantmentTags
|
||||
* @see ItemEnchantmentTagRegistry
|
||||
* @see AvailableEnchantmentRegistry
|
||||
*
|
||||
* @return string[]
|
||||
*/
|
||||
public function getEnchantmentTags() : array{
|
||||
return $this->typeInfo->getEnchantmentTags();
|
||||
}
|
||||
|
||||
/**
|
||||
* Do the actions needed so the block is broken with the Item
|
||||
*
|
||||
@ -437,7 +484,8 @@ class Block{
|
||||
/**
|
||||
* Do actions when interacted by Item. Returns if it has done anything
|
||||
*
|
||||
* @param Item[] &$returnedItems Items to be added to the target's inventory (or dropped, if the inventory is full)
|
||||
* @param Vector3 $clickVector Exact position where the click occurred, relative to the block's integer position
|
||||
* @param Item[] &$returnedItems Items to be added to the target's inventory (or dropped, if the inventory is full)
|
||||
*/
|
||||
public function onInteract(Item $item, int $face, Vector3 $clickVector, ?Player $player = null, array &$returnedItems = []) : bool{
|
||||
return false;
|
||||
@ -720,7 +768,7 @@ class Block{
|
||||
* @return string
|
||||
*/
|
||||
public function __toString(){
|
||||
return "Block[" . $this->getName() . "] (" . $this->getTypeId() . ":" . $this->computeTypeAndStateData() . ")";
|
||||
return "Block[" . $this->getName() . "] (" . $this->getTypeId() . ":" . $this->encodeFullState() . ")";
|
||||
}
|
||||
|
||||
/**
|
||||
@ -832,6 +880,10 @@ class Block{
|
||||
return SupportType::FULL();
|
||||
}
|
||||
|
||||
protected function getAdjacentSupportType(int $facing) : SupportType{
|
||||
return $this->getSide($facing)->getSupportType(Facing::opposite($facing));
|
||||
}
|
||||
|
||||
public function isFullCube() : bool{
|
||||
$bb = $this->getCollisionBoxes();
|
||||
|
||||
|
@ -24,11 +24,14 @@ declare(strict_types=1);
|
||||
namespace pocketmine\block;
|
||||
|
||||
/**
|
||||
* Enum of all the block runtime IDs used by PocketMine-MP. These IDs are specific to PocketMine-MP and have no
|
||||
* relevance to any Minecraft vanilla things.
|
||||
* Every block in {@link VanillaBlocks} has a corresponding constant in this class. These constants can be used to
|
||||
* identify and compare block types efficiently using {@link Block::getTypeId()}.
|
||||
*
|
||||
* WARNING: DO NOT STORE THESE IDS. They can and will change without warning.
|
||||
* They should ONLY be used to IDENTIFY blocks at runtime.
|
||||
* Type ID is also used internally as part of block state ID, which is used to store blocks and their simple properties
|
||||
* in a memory-efficient way in chunks at runtime.
|
||||
*
|
||||
* WARNING: These are NOT a replacement for Minecraft legacy IDs. Do **NOT** hardcode their values, or store them in
|
||||
* configs or databases. They will change without warning.
|
||||
*/
|
||||
final class BlockTypeIds{
|
||||
|
||||
@ -713,8 +716,29 @@ final class BlockTypeIds{
|
||||
public const AZALEA_LEAVES = 10686;
|
||||
public const FLOWERING_AZALEA_LEAVES = 10687;
|
||||
public const REINFORCED_DEEPSLATE = 10688;
|
||||
public const CAVE_VINES = 10689;
|
||||
public const GLOW_LICHEN = 10690;
|
||||
public const CHERRY_BUTTON = 10691;
|
||||
public const CHERRY_DOOR = 10692;
|
||||
public const CHERRY_FENCE = 10693;
|
||||
public const CHERRY_FENCE_GATE = 10694;
|
||||
public const CHERRY_LEAVES = 10695;
|
||||
public const CHERRY_LOG = 10696;
|
||||
public const CHERRY_PLANKS = 10697;
|
||||
public const CHERRY_PRESSURE_PLATE = 10698;
|
||||
public const CHERRY_SAPLING = 10699;
|
||||
public const CHERRY_SIGN = 10700;
|
||||
public const CHERRY_SLAB = 10701;
|
||||
public const CHERRY_STAIRS = 10702;
|
||||
public const CHERRY_TRAPDOOR = 10703;
|
||||
public const CHERRY_WALL_SIGN = 10704;
|
||||
public const CHERRY_WOOD = 10705;
|
||||
public const SMALL_DRIPLEAF = 10706;
|
||||
public const BIG_DRIPLEAF_HEAD = 10707;
|
||||
public const BIG_DRIPLEAF_STEM = 10708;
|
||||
public const PINK_PETALS = 10709;
|
||||
|
||||
public const FIRST_UNUSED_BLOCK_ID = 10689;
|
||||
public const FIRST_UNUSED_BLOCK_ID = 10710;
|
||||
|
||||
private static int $nextDynamicId = self::FIRST_UNUSED_BLOCK_ID;
|
||||
|
||||
|
@ -35,10 +35,12 @@ final class BlockTypeInfo{
|
||||
|
||||
/**
|
||||
* @param string[] $typeTags
|
||||
* @param string[] $enchantmentTags
|
||||
*/
|
||||
public function __construct(
|
||||
private BlockBreakInfo $breakInfo,
|
||||
array $typeTags = []
|
||||
array $typeTags = [],
|
||||
private array $enchantmentTags = []
|
||||
){
|
||||
$this->typeTags = array_fill_keys($typeTags, true);
|
||||
}
|
||||
@ -49,4 +51,17 @@ final class BlockTypeInfo{
|
||||
public function getTypeTags() : array{ return array_keys($this->typeTags); }
|
||||
|
||||
public function hasTypeTag(string $tag) : bool{ return isset($this->typeTags[$tag]); }
|
||||
|
||||
/**
|
||||
* Returns tags that represent the type of item being enchanted and are used to determine
|
||||
* what enchantments can be applied to the item of this block during in-game enchanting (enchanting table, anvil, fishing, etc.).
|
||||
* @see ItemEnchantmentTags
|
||||
* @see ItemEnchantmentTagRegistry
|
||||
* @see AvailableEnchantmentRegistry
|
||||
*
|
||||
* @return string[]
|
||||
*/
|
||||
public function getEnchantmentTags() : array{
|
||||
return $this->enchantmentTags;
|
||||
}
|
||||
}
|
||||
|
@ -43,7 +43,7 @@ class BrewingStand extends Transparent{
|
||||
*/
|
||||
protected array $slots = [];
|
||||
|
||||
protected function describeState(RuntimeDataDescriber $w) : void{
|
||||
protected function describeBlockOnlyState(RuntimeDataDescriber $w) : void{
|
||||
$w->brewingStandSlots($this->slots);
|
||||
}
|
||||
|
||||
|
@ -38,7 +38,7 @@ abstract class Button extends Flowable{
|
||||
|
||||
protected bool $pressed = false;
|
||||
|
||||
protected function describeState(RuntimeDataDescriber $w) : void{
|
||||
protected function describeBlockOnlyState(RuntimeDataDescriber $w) : void{
|
||||
$w->facing($this->facing);
|
||||
$w->bool($this->pressed);
|
||||
}
|
||||
@ -52,7 +52,7 @@ abstract class Button extends Flowable{
|
||||
}
|
||||
|
||||
public function place(BlockTransaction $tx, Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, ?Player $player = null) : bool{
|
||||
if($this->canBeSupportedBy($blockReplace->getSide(Facing::opposite($face)), $face)){
|
||||
if($this->canBeSupportedAt($blockReplace, $face)){
|
||||
$this->facing = $face;
|
||||
return parent::place($tx, $item, $blockReplace, $blockClicked, $face, $clickVector, $player);
|
||||
}
|
||||
@ -83,12 +83,12 @@ abstract class Button extends Flowable{
|
||||
}
|
||||
|
||||
public function onNearbyBlockChange() : void{
|
||||
if(!$this->canBeSupportedBy($this->getSide(Facing::opposite($this->facing)), $this->facing)){
|
||||
if(!$this->canBeSupportedAt($this, $this->facing)){
|
||||
$this->position->getWorld()->useBreakOn($this->position);
|
||||
}
|
||||
}
|
||||
|
||||
private function canBeSupportedBy(Block $support, int $face) : bool{
|
||||
return $support->getSupportType($face)->hasCenterSupport();
|
||||
private function canBeSupportedAt(Block $block, int $face) : bool{
|
||||
return $block->getAdjacentSupportType(Facing::opposite($face))->hasCenterSupport();
|
||||
}
|
||||
}
|
||||
|
@ -23,10 +23,10 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\block\utils\BlockEventHelper;
|
||||
use pocketmine\block\utils\SupportType;
|
||||
use pocketmine\data\runtime\RuntimeDataDescriber;
|
||||
use pocketmine\entity\Entity;
|
||||
use pocketmine\event\block\BlockGrowEvent;
|
||||
use pocketmine\event\entity\EntityDamageByBlockEvent;
|
||||
use pocketmine\event\entity\EntityDamageEvent;
|
||||
use pocketmine\item\Item;
|
||||
@ -41,7 +41,7 @@ class Cactus extends Transparent{
|
||||
|
||||
protected int $age = 0;
|
||||
|
||||
protected function describeState(RuntimeDataDescriber $w) : void{
|
||||
protected function describeBlockOnlyState(RuntimeDataDescriber $w) : void{
|
||||
$w->boundedInt(4, 0, self::MAX_AGE, $this->age);
|
||||
}
|
||||
|
||||
@ -79,7 +79,7 @@ class Cactus extends Transparent{
|
||||
}
|
||||
|
||||
private function canBeSupportedBy(Block $block) : bool{
|
||||
return $block->isSameType($this) || $block->hasTypeTag(BlockTypeTags::SAND);
|
||||
return $block->hasSameTypeId($this) || $block->hasTypeTag(BlockTypeTags::SAND);
|
||||
}
|
||||
|
||||
public function onNearbyBlockChange() : void{
|
||||
@ -102,7 +102,7 @@ class Cactus extends Transparent{
|
||||
}
|
||||
|
||||
public function onRandomTick() : void{
|
||||
if(!$this->getSide(Facing::DOWN)->isSameType($this)){
|
||||
if(!$this->getSide(Facing::DOWN)->hasSameTypeId($this)){
|
||||
$world = $this->position->getWorld();
|
||||
if($this->age === self::MAX_AGE){
|
||||
for($y = 1; $y < 3; ++$y){
|
||||
@ -111,21 +111,16 @@ class Cactus extends Transparent{
|
||||
}
|
||||
$b = $world->getBlockAt($this->position->x, $this->position->y + $y, $this->position->z);
|
||||
if($b->getTypeId() === BlockTypeIds::AIR){
|
||||
$ev = new BlockGrowEvent($b, VanillaBlocks::CACTUS());
|
||||
$ev->call();
|
||||
if($ev->isCancelled()){
|
||||
break;
|
||||
}
|
||||
$world->setBlock($b->position, $ev->getNewState());
|
||||
BlockEventHelper::grow($b, VanillaBlocks::CACTUS(), null);
|
||||
}else{
|
||||
break;
|
||||
}
|
||||
}
|
||||
$this->age = 0;
|
||||
$world->setBlock($this->position, $this);
|
||||
$world->setBlock($this->position, $this, update: false);
|
||||
}else{
|
||||
++$this->age;
|
||||
$world->setBlock($this->position, $this);
|
||||
$world->setBlock($this->position, $this, update: false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -36,7 +36,7 @@ class Cake extends BaseCake{
|
||||
|
||||
protected int $bites = 0;
|
||||
|
||||
protected function describeState(RuntimeDataDescriber $w) : void{
|
||||
protected function describeBlockOnlyState(RuntimeDataDescriber $w) : void{
|
||||
$w->boundedInt(3, 0, self::MAX_BITES, $this->bites);
|
||||
}
|
||||
|
||||
@ -64,7 +64,7 @@ class Cake extends BaseCake{
|
||||
}
|
||||
|
||||
public function onInteract(Item $item, int $face, Vector3 $clickVector, ?Player $player = null, array &$returnedItems = []) : bool{
|
||||
if($item instanceof ItemBlock){
|
||||
if($this->bites === 0 && $item instanceof ItemBlock){
|
||||
$block = $item->getBlock();
|
||||
$resultBlock = null;
|
||||
if($block->getTypeId() === BlockTypeIds::CANDLE){
|
||||
@ -83,6 +83,10 @@ class Cake extends BaseCake{
|
||||
return parent::onInteract($item, $face, $clickVector, $player, $returnedItems);
|
||||
}
|
||||
|
||||
public function getDropsForCompatibleTool(Item $item) : array{
|
||||
return [];
|
||||
}
|
||||
|
||||
public function getResidue() : Block{
|
||||
$clone = clone $this;
|
||||
$clone->bites++;
|
||||
|
@ -64,7 +64,7 @@ class CakeWithCandle extends BaseCake{
|
||||
}
|
||||
|
||||
public function getPickedItem(bool $addUserData = false) : Item{
|
||||
return VanillaBlocks::CAKE()->getPickedItem($addUserData);
|
||||
return VanillaBlocks::CAKE()->asItem();
|
||||
}
|
||||
|
||||
public function getResidue() : Block{
|
||||
|
@ -37,7 +37,7 @@ use pocketmine\world\BlockTransaction;
|
||||
|
||||
class Candle extends Transparent{
|
||||
use CandleTrait {
|
||||
describeState as encodeLitState;
|
||||
describeBlockOnlyState as encodeLitState;
|
||||
getLightLevel as getBaseLightLevel;
|
||||
}
|
||||
|
||||
@ -46,7 +46,7 @@ class Candle extends Transparent{
|
||||
|
||||
private int $count = self::MIN_COUNT;
|
||||
|
||||
protected function describeState(RuntimeDataDescriber $w) : void{
|
||||
protected function describeBlockOnlyState(RuntimeDataDescriber $w) : void{
|
||||
$this->encodeLitState($w);
|
||||
$w->boundedInt(2, self::MIN_COUNT, self::MAX_COUNT, $this->count);
|
||||
}
|
||||
@ -95,7 +95,7 @@ class Candle extends Transparent{
|
||||
}
|
||||
|
||||
protected function getCandleIfCompatibleType(Block $block) : ?Candle{
|
||||
return $block instanceof Candle && $block->isSameType($this) ? $block : null;
|
||||
return $block instanceof Candle && $block->hasSameTypeId($this) ? $block : null;
|
||||
}
|
||||
|
||||
public function canBePlacedAt(Block $blockReplace, Vector3 $clickVector, int $face, bool $isClickedBlock) : bool{
|
||||
@ -104,8 +104,7 @@ class Candle extends Transparent{
|
||||
}
|
||||
|
||||
public function place(BlockTransaction $tx, Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, ?Player $player = null) : bool{
|
||||
$down = $blockReplace->getSide(Facing::DOWN);
|
||||
if(!$down->getSupportType(Facing::UP)->hasCenterSupport()){
|
||||
if(!$blockReplace->getAdjacentSupportType(Facing::DOWN)->hasCenterSupport()){
|
||||
return false;
|
||||
}
|
||||
$existing = $this->getCandleIfCompatibleType($blockReplace);
|
||||
|
@ -23,15 +23,15 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\block\utils\FortuneDropHelper;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\item\VanillaItems;
|
||||
use function mt_rand;
|
||||
|
||||
class Carrot extends Crops{
|
||||
|
||||
public function getDropsForCompatibleTool(Item $item) : array{
|
||||
return [
|
||||
VanillaItems::CARROT()->setCount($this->age >= self::MAX_AGE ? mt_rand(1, 4) : 1)
|
||||
VanillaItems::CARROT()->setCount($this->age >= self::MAX_AGE ? FortuneDropHelper::binomial($item, 1) : 1)
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -24,9 +24,7 @@ declare(strict_types=1);
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\block\utils\FacesOppositePlacingPlayerTrait;
|
||||
use pocketmine\block\utils\HorizontalFacingTrait;
|
||||
|
||||
class CarvedPumpkin extends Opaque{
|
||||
use FacesOppositePlacingPlayerTrait;
|
||||
use HorizontalFacingTrait;
|
||||
}
|
||||
|
182
src/block/CaveVines.php
Normal file
182
src/block/CaveVines.php
Normal file
@ -0,0 +1,182 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
*
|
||||
* ____ _ _ __ __ _ __ __ ____
|
||||
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
|
||||
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
|
||||
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
|
||||
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* @author PocketMine Team
|
||||
* @link http://www.pocketmine.net/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\block\utils\BlockEventHelper;
|
||||
use pocketmine\block\utils\SupportType;
|
||||
use pocketmine\data\runtime\RuntimeDataDescriber;
|
||||
use pocketmine\entity\Entity;
|
||||
use pocketmine\item\Fertilizer;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\item\VanillaItems;
|
||||
use pocketmine\math\Facing;
|
||||
use pocketmine\math\Vector3;
|
||||
use pocketmine\player\Player;
|
||||
use pocketmine\world\BlockTransaction;
|
||||
use pocketmine\world\sound\GlowBerriesPickSound;
|
||||
use function mt_rand;
|
||||
|
||||
class CaveVines extends Flowable{
|
||||
public const MAX_AGE = 25;
|
||||
|
||||
protected int $age = 0;
|
||||
protected bool $berries = false;
|
||||
protected bool $head = false;
|
||||
|
||||
protected function describeBlockOnlyState(RuntimeDataDescriber $w) : void{
|
||||
$w->boundedInt(5, 0, self::MAX_AGE, $this->age);
|
||||
$w->bool($this->berries);
|
||||
$w->bool($this->head);
|
||||
}
|
||||
|
||||
public function hasBerries() : bool{ return $this->berries; }
|
||||
|
||||
/** @return $this */
|
||||
public function setBerries(bool $berries) : self{
|
||||
$this->berries = $berries;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function isHead() : bool{ return $this->head; }
|
||||
|
||||
/** @return $this */
|
||||
public function setHead(bool $head) : self{
|
||||
$this->head = $head;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getAge() : int{
|
||||
return $this->age;
|
||||
}
|
||||
|
||||
/** @return $this */
|
||||
public function setAge(int $age) : self{
|
||||
if($age < 0 || $age > self::MAX_AGE){
|
||||
throw new \InvalidArgumentException("Age must be in range 0-" . self::MAX_AGE);
|
||||
}
|
||||
$this->age = $age;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function canClimb() : bool{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function getLightLevel() : int{
|
||||
return $this->berries ? 14 : 0;
|
||||
}
|
||||
|
||||
private function canBeSupportedAt(Block $block) : bool{
|
||||
$supportBlock = $block->getSide(Facing::UP);
|
||||
return $supportBlock->getSupportType(Facing::DOWN)->equals(SupportType::FULL()) || $supportBlock->hasSameTypeId($this);
|
||||
}
|
||||
|
||||
public function onNearbyBlockChange() : void{
|
||||
if(!$this->canBeSupportedAt($this)){
|
||||
$this->position->getWorld()->useBreakOn($this->position);
|
||||
}
|
||||
}
|
||||
|
||||
public function place(BlockTransaction $tx, Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, ?Player $player = null) : bool{
|
||||
if(!$this->canBeSupportedAt($blockReplace)){
|
||||
return false;
|
||||
}
|
||||
$this->age = mt_rand(0, self::MAX_AGE);
|
||||
return parent::place($tx, $item, $blockReplace, $blockClicked, $face, $clickVector, $player);
|
||||
}
|
||||
|
||||
public function onInteract(Item $item, int $face, Vector3 $clickVector, ?Player $player = null, array &$returnedItems = []) : bool{
|
||||
if($this->berries){
|
||||
$this->position->getWorld()->dropItem($this->position, $this->asItem());
|
||||
$this->position->getWorld()->addSound($this->position, new GlowBerriesPickSound());
|
||||
|
||||
$this->position->getWorld()->setBlock($this->position, $this->setBerries(false));
|
||||
return true;
|
||||
}
|
||||
if($item instanceof Fertilizer){
|
||||
$newState = (clone $this)
|
||||
->setBerries(true)
|
||||
->setHead(!$this->getSide(Facing::DOWN)->hasSameTypeId($this));
|
||||
if(BlockEventHelper::grow($this, $newState, $player)){
|
||||
$item->pop();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function onRandomTick() : void{
|
||||
$head = !$this->getSide(Facing::DOWN)->hasSameTypeId($this);
|
||||
if($head !== $this->head){
|
||||
$this->position->getWorld()->setBlock($this->position, $this->setHead($head));
|
||||
}
|
||||
|
||||
if($this->age < self::MAX_AGE && mt_rand(1, 10) === 1){
|
||||
$growthPos = $this->position->getSide(Facing::DOWN);
|
||||
$world = $growthPos->getWorld();
|
||||
if($world->isInWorld($growthPos->getFloorX(), $growthPos->getFloorY(), $growthPos->getFloorZ())){
|
||||
$block = $world->getBlock($growthPos);
|
||||
if($block->getTypeId() === BlockTypeIds::AIR){
|
||||
$newState = VanillaBlocks::CAVE_VINES()
|
||||
->setAge($this->age + 1)
|
||||
->setBerries(mt_rand(1, 9) === 1);
|
||||
BlockEventHelper::grow($block, $newState, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function ticksRandomly() : bool{
|
||||
return true;
|
||||
}
|
||||
|
||||
protected function recalculateCollisionBoxes() : array{
|
||||
return [];
|
||||
}
|
||||
|
||||
public function hasEntityCollision() : bool{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function onEntityInside(Entity $entity) : bool{
|
||||
$entity->resetFallDistance();
|
||||
return false;
|
||||
}
|
||||
|
||||
public function getDropsForCompatibleTool(Item $item) : array{
|
||||
return $this->berries ? [$this->asItem()] : [];
|
||||
}
|
||||
|
||||
public function isAffectedBySilkTouch() : bool{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function asItem() : Item{
|
||||
return VanillaItems::GLOW_BERRIES();
|
||||
}
|
||||
|
||||
public function getSupportType(int $facing) : SupportType{
|
||||
return SupportType::NONE();
|
||||
}
|
||||
}
|
@ -24,14 +24,12 @@ declare(strict_types=1);
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\block\utils\FacesOppositePlacingPlayerTrait;
|
||||
use pocketmine\block\utils\HorizontalFacingTrait;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\math\Vector3;
|
||||
use pocketmine\player\Player;
|
||||
|
||||
final class ChemistryTable extends Opaque{
|
||||
use FacesOppositePlacingPlayerTrait;
|
||||
use HorizontalFacingTrait;
|
||||
|
||||
public function onInteract(Item $item, int $face, Vector3 $clickVector, ?Player $player = null, array &$returnedItems = []) : bool{
|
||||
//TODO
|
||||
|
@ -25,7 +25,6 @@ namespace pocketmine\block;
|
||||
|
||||
use pocketmine\block\tile\Chest as TileChest;
|
||||
use pocketmine\block\utils\FacesOppositePlacingPlayerTrait;
|
||||
use pocketmine\block\utils\HorizontalFacingTrait;
|
||||
use pocketmine\block\utils\SupportType;
|
||||
use pocketmine\event\block\ChestPairEvent;
|
||||
use pocketmine\item\Item;
|
||||
@ -36,7 +35,6 @@ use pocketmine\player\Player;
|
||||
|
||||
class Chest extends Transparent{
|
||||
use FacesOppositePlacingPlayerTrait;
|
||||
use HorizontalFacingTrait;
|
||||
|
||||
/**
|
||||
* @return AxisAlignedBB[]
|
||||
@ -57,13 +55,13 @@ class Chest extends Transparent{
|
||||
foreach([false, true] as $clockwise){
|
||||
$side = Facing::rotateY($this->facing, $clockwise);
|
||||
$c = $this->getSide($side);
|
||||
if($c instanceof Chest && $c->isSameType($this) && $c->facing === $this->facing){
|
||||
if($c instanceof Chest && $c->hasSameTypeId($this) && $c->facing === $this->facing){
|
||||
$pair = $world->getTile($c->position);
|
||||
if($pair instanceof TileChest && !$pair->isPaired()){
|
||||
[$left, $right] = $clockwise ? [$c, $this] : [$this, $c];
|
||||
$ev = new ChestPairEvent($left, $right);
|
||||
$ev->call();
|
||||
if(!$ev->isCancelled() && $world->getBlock($this->position)->isSameType($this) && $world->getBlock($c->position)->isSameType($c)){
|
||||
if(!$ev->isCancelled() && $world->getBlock($this->position)->hasSameTypeId($this) && $world->getBlock($c->position)->hasSameTypeId($c)){
|
||||
$pair->pairWith($tile);
|
||||
$tile->pairWith($pair);
|
||||
break;
|
||||
|
@ -49,7 +49,7 @@ final class ChorusFlower extends Flowable{
|
||||
|
||||
private int $age = self::MIN_AGE;
|
||||
|
||||
protected function describeState(RuntimeDataDescriber $w) : void{
|
||||
protected function describeBlockOnlyState(RuntimeDataDescriber $w) : void{
|
||||
$w->boundedInt(3, self::MIN_AGE, self::MAX_AGE, $this->age);
|
||||
}
|
||||
|
||||
|
@ -40,7 +40,7 @@ final class ChorusPlant extends Flowable{
|
||||
$bb = AxisAlignedBB::one();
|
||||
foreach($this->getAllSides() as $facing => $block){
|
||||
$id = $block->getTypeId();
|
||||
if($id !== BlockTypeIds::END_STONE && $id !== BlockTypeIds::CHORUS_FLOWER && !$block->isSameType($this)){
|
||||
if($id !== BlockTypeIds::END_STONE && $id !== BlockTypeIds::CHORUS_FLOWER && !$block->hasSameTypeId($this)){
|
||||
$bb->trim($facing, 2 / 16);
|
||||
}
|
||||
}
|
||||
@ -49,7 +49,7 @@ final class ChorusPlant extends Flowable{
|
||||
}
|
||||
|
||||
private function canBeSupportedBy(Block $block) : bool{
|
||||
return $block->isSameType($this) || $block->getTypeId() === BlockTypeIds::END_STONE;
|
||||
return $block->hasSameTypeId($this) || $block->getTypeId() === BlockTypeIds::END_STONE;
|
||||
}
|
||||
|
||||
private function canStay(Position $position) : bool{
|
||||
|
@ -23,6 +23,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\block\utils\FortuneDropHelper;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\item\VanillaItems;
|
||||
use function mt_rand;
|
||||
@ -31,7 +32,7 @@ class CoalOre extends Opaque{
|
||||
|
||||
public function getDropsForCompatibleTool(Item $item) : array{
|
||||
return [
|
||||
VanillaItems::COAL()
|
||||
VanillaItems::COAL()->setCount(FortuneDropHelper::weighted($item, min: 1, maxBase: 1))
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -23,11 +23,11 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\block\utils\BlockEventHelper;
|
||||
use pocketmine\block\utils\HorizontalFacingTrait;
|
||||
use pocketmine\block\utils\SupportType;
|
||||
use pocketmine\block\utils\WoodType;
|
||||
use pocketmine\data\runtime\RuntimeDataDescriber;
|
||||
use pocketmine\event\block\BlockGrowEvent;
|
||||
use pocketmine\item\Fertilizer;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\item\VanillaItems;
|
||||
@ -46,7 +46,7 @@ class CocoaBlock extends Transparent{
|
||||
|
||||
protected int $age = 0;
|
||||
|
||||
protected function describeState(RuntimeDataDescriber $w) : void{
|
||||
protected function describeBlockOnlyState(RuntimeDataDescriber $w) : void{
|
||||
$w->horizontalFacing($this->facing);
|
||||
$w->boundedInt(2, 0, self::MAX_AGE, $this->age);
|
||||
}
|
||||
@ -94,7 +94,7 @@ class CocoaBlock extends Transparent{
|
||||
}
|
||||
|
||||
public function onInteract(Item $item, int $face, Vector3 $clickVector, ?Player $player = null, array &$returnedItems = []) : bool{
|
||||
if($item instanceof Fertilizer && $this->grow()){
|
||||
if($item instanceof Fertilizer && $this->grow($player)){
|
||||
$item->pop();
|
||||
|
||||
return true;
|
||||
@ -119,16 +119,11 @@ class CocoaBlock extends Transparent{
|
||||
}
|
||||
}
|
||||
|
||||
private function grow() : bool{
|
||||
private function grow(?Player $player = null) : bool{
|
||||
if($this->age < self::MAX_AGE){
|
||||
$block = clone $this;
|
||||
$block->age++;
|
||||
$ev = new BlockGrowEvent($this, $block);
|
||||
$ev->call();
|
||||
if(!$ev->isCancelled()){
|
||||
$this->position->getWorld()->setBlock($this->position, $ev->getNewState());
|
||||
return true;
|
||||
}
|
||||
return BlockEventHelper::grow($this, $block, $player);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -23,11 +23,11 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\block\utils\BlockEventHelper;
|
||||
use pocketmine\block\utils\ColoredTrait;
|
||||
use pocketmine\block\utils\DyeColor;
|
||||
use pocketmine\block\utils\Fallable;
|
||||
use pocketmine\block\utils\FallableTrait;
|
||||
use pocketmine\event\block\BlockFormEvent;
|
||||
use pocketmine\math\Facing;
|
||||
|
||||
class ConcretePowder extends Opaque implements Fallable{
|
||||
@ -43,11 +43,7 @@ class ConcretePowder extends Opaque implements Fallable{
|
||||
|
||||
public function onNearbyBlockChange() : void{
|
||||
if(($water = $this->getAdjacentWater()) !== null){
|
||||
$ev = new BlockFormEvent($this, VanillaBlocks::CONCRETE()->setColor($this->color), $water);
|
||||
$ev->call();
|
||||
if(!$ev->isCancelled()){
|
||||
$this->position->getWorld()->setBlock($this->position, $ev->getNewState());
|
||||
}
|
||||
BlockEventHelper::form($this, VanillaBlocks::CONCRETE()->setColor($this->color), $water);
|
||||
}else{
|
||||
$this->startFalling();
|
||||
}
|
||||
|
@ -23,13 +23,16 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\block\utils\FortuneDropHelper;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\item\VanillaItems;
|
||||
|
||||
final class CopperOre extends Opaque{
|
||||
|
||||
public function getDropsForCompatibleTool(Item $item) : array{
|
||||
return [VanillaItems::RAW_COPPER()];
|
||||
return [
|
||||
VanillaItems::RAW_COPPER()->setCount(FortuneDropHelper::weighted($item, min: 2, maxBase: 5)),
|
||||
];
|
||||
}
|
||||
|
||||
public function isAffectedBySilkTouch() : bool{ return true; }
|
||||
|
@ -32,7 +32,7 @@ use pocketmine\world\BlockTransaction;
|
||||
final class Coral extends BaseCoral{
|
||||
|
||||
public function place(BlockTransaction $tx, Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, ?Player $player = null) : bool{
|
||||
if(!$this->canBeSupportedBy($tx->fetchBlock($blockReplace->getPosition()->down()))){
|
||||
if(!$this->canBeSupportedAt($blockReplace)){
|
||||
return false;
|
||||
}
|
||||
return parent::place($tx, $item, $blockReplace, $blockClicked, $face, $clickVector, $player);
|
||||
@ -40,14 +40,14 @@ final class Coral extends BaseCoral{
|
||||
|
||||
public function onNearbyBlockChange() : void{
|
||||
$world = $this->position->getWorld();
|
||||
if(!$this->canBeSupportedBy($world->getBlock($this->position->down()))){
|
||||
if(!$this->canBeSupportedAt($this)){
|
||||
$world->useBreakOn($this->position);
|
||||
}else{
|
||||
parent::onNearbyBlockChange();
|
||||
}
|
||||
}
|
||||
|
||||
private function canBeSupportedBy(Block $block) : bool{
|
||||
return $block->getSupportType(Facing::UP)->hasCenterSupport();
|
||||
private function canBeSupportedAt(Block $block) : bool{
|
||||
return $block->getAdjacentSupportType(Facing::DOWN)->hasCenterSupport();
|
||||
}
|
||||
}
|
||||
|
@ -23,9 +23,9 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\block\utils\BlockEventHelper;
|
||||
use pocketmine\block\utils\CoralType;
|
||||
use pocketmine\block\utils\CoralTypeTrait;
|
||||
use pocketmine\event\block\BlockDeathEvent;
|
||||
use pocketmine\item\Item;
|
||||
use function mt_rand;
|
||||
|
||||
@ -55,17 +55,13 @@ final class CoralBlock extends Opaque{
|
||||
}
|
||||
}
|
||||
if(!$hasWater){
|
||||
$ev = new BlockDeathEvent($this, $this->setDead(true));
|
||||
$ev->call();
|
||||
if(!$ev->isCancelled()){
|
||||
$world->setBlock($this->position, $ev->getNewState());
|
||||
}
|
||||
BlockEventHelper::die($this, (clone $this)->setDead(true));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function getDropsForCompatibleTool(Item $item) : array{
|
||||
return [$this->setDead(true)->asItem()];
|
||||
return [(clone $this)->setDead(true)->asItem()];
|
||||
}
|
||||
|
||||
public function isAffectedBySilkTouch() : bool{
|
||||
|
@ -23,8 +23,8 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\block\utils\BlockEventHelper;
|
||||
use pocketmine\data\runtime\RuntimeDataDescriber;
|
||||
use pocketmine\event\block\BlockGrowEvent;
|
||||
use pocketmine\item\Fertilizer;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\math\Facing;
|
||||
@ -38,7 +38,7 @@ abstract class Crops extends Flowable{
|
||||
|
||||
protected int $age = 0;
|
||||
|
||||
protected function describeState(RuntimeDataDescriber $w) : void{
|
||||
protected function describeBlockOnlyState(RuntimeDataDescriber $w) : void{
|
||||
$w->boundedInt(3, 0, self::MAX_AGE, $this->age);
|
||||
}
|
||||
|
||||
@ -68,11 +68,7 @@ abstract class Crops extends Flowable{
|
||||
if($block->age > self::MAX_AGE){
|
||||
$block->age = self::MAX_AGE;
|
||||
}
|
||||
|
||||
$ev = new BlockGrowEvent($this, $block);
|
||||
$ev->call();
|
||||
if(!$ev->isCancelled()){
|
||||
$this->position->getWorld()->setBlock($this->position, $ev->getNewState());
|
||||
if(BlockEventHelper::grow($this, $block, $player)){
|
||||
$item->pop();
|
||||
}
|
||||
|
||||
@ -96,11 +92,7 @@ abstract class Crops extends Flowable{
|
||||
if($this->age < self::MAX_AGE && mt_rand(0, 2) === 1){
|
||||
$block = clone $this;
|
||||
++$block->age;
|
||||
$ev = new BlockGrowEvent($this, $block);
|
||||
$ev->call();
|
||||
if(!$ev->isCancelled()){
|
||||
$this->position->getWorld()->setBlock($this->position, $ev->getNewState());
|
||||
}
|
||||
BlockEventHelper::grow($this, $block, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -41,7 +41,7 @@ class DaylightSensor extends Transparent{
|
||||
|
||||
protected bool $inverted = false;
|
||||
|
||||
protected function describeState(RuntimeDataDescriber $w) : void{
|
||||
protected function describeBlockOnlyState(RuntimeDataDescriber $w) : void{
|
||||
$w->boundedInt(4, 0, 15, $this->signalStrength);
|
||||
$w->bool($this->inverted);
|
||||
}
|
||||
|
@ -66,13 +66,19 @@ class DeadBush extends Flowable{
|
||||
}
|
||||
|
||||
private function canBeSupportedBy(Block $block) : bool{
|
||||
$blockId = $block->getTypeId();
|
||||
return $blockId === BlockTypeIds::SAND
|
||||
|| $blockId === BlockTypeIds::RED_SAND
|
||||
|| $blockId === BlockTypeIds::PODZOL
|
||||
|| $blockId === BlockTypeIds::MYCELIUM
|
||||
|| $blockId === BlockTypeIds::DIRT
|
||||
|| $blockId === BlockTypeIds::HARDENED_CLAY
|
||||
|| $blockId === BlockTypeIds::STAINED_CLAY;
|
||||
return
|
||||
$block->hasTypeTag(BlockTypeTags::SAND) ||
|
||||
$block->hasTypeTag(BlockTypeTags::MUD) ||
|
||||
match($block->getTypeId()){
|
||||
//can't use DIRT tag here because it includes farmland
|
||||
BlockTypeIds::PODZOL,
|
||||
BlockTypeIds::MYCELIUM,
|
||||
BlockTypeIds::DIRT,
|
||||
BlockTypeIds::GRASS,
|
||||
BlockTypeIds::HARDENED_CLAY,
|
||||
BlockTypeIds::STAINED_CLAY => true,
|
||||
//TODO: moss block
|
||||
default => false,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -28,8 +28,8 @@ use pocketmine\data\runtime\RuntimeDataDescriber;
|
||||
class DetectorRail extends StraightOnlyRail{
|
||||
protected bool $activated = false;
|
||||
|
||||
protected function describeState(RuntimeDataDescriber $w) : void{
|
||||
parent::describeState($w);
|
||||
protected function describeBlockOnlyState(RuntimeDataDescriber $w) : void{
|
||||
parent::describeBlockOnlyState($w);
|
||||
$w->bool($this->activated);
|
||||
}
|
||||
|
||||
|
@ -23,6 +23,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\block\utils\FortuneDropHelper;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\item\VanillaItems;
|
||||
use function mt_rand;
|
||||
@ -31,7 +32,7 @@ class DiamondOre extends Opaque{
|
||||
|
||||
public function getDropsForCompatibleTool(Item $item) : array{
|
||||
return [
|
||||
VanillaItems::DIAMOND()
|
||||
VanillaItems::DIAMOND()->setCount(FortuneDropHelper::weighted($item, min: 1, maxBase: 1))
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -45,7 +45,7 @@ class Dirt extends Opaque{
|
||||
parent::__construct($idInfo, $name, $typeInfo);
|
||||
}
|
||||
|
||||
protected function describeType(RuntimeDataDescriber $w) : void{
|
||||
public function describeBlockItemState(RuntimeDataDescriber $w) : void{
|
||||
$w->dirtType($this->dirtType);
|
||||
}
|
||||
|
||||
@ -59,7 +59,12 @@ class Dirt extends Opaque{
|
||||
|
||||
public function onInteract(Item $item, int $face, Vector3 $clickVector, ?Player $player = null, array &$returnedItems = []) : bool{
|
||||
$world = $this->position->getWorld();
|
||||
if($face === Facing::UP && $item instanceof Hoe){
|
||||
if($face !== Facing::DOWN && $item instanceof Hoe){
|
||||
$up = $this->getSide(Facing::UP);
|
||||
if($up->getTypeId() !== BlockTypeIds::AIR){
|
||||
return true;
|
||||
}
|
||||
|
||||
$item->applyDamage(1);
|
||||
|
||||
$newBlock = $this->dirtType->equals(DirtType::NORMAL()) ? VanillaBlocks::FARMLAND() : VanillaBlocks::DIRT();
|
||||
|
@ -41,7 +41,7 @@ class Door extends Transparent{
|
||||
protected bool $hingeRight = false;
|
||||
protected bool $open = false;
|
||||
|
||||
protected function describeState(RuntimeDataDescriber $w) : void{
|
||||
protected function describeBlockOnlyState(RuntimeDataDescriber $w) : void{
|
||||
$w->horizontalFacing($this->facing);
|
||||
$w->bool($this->top);
|
||||
$w->bool($this->hingeRight);
|
||||
@ -53,7 +53,7 @@ class Door extends Transparent{
|
||||
|
||||
//copy door properties from other half
|
||||
$other = $this->getSide($this->top ? Facing::DOWN : Facing::UP);
|
||||
if($other instanceof Door && $other->isSameType($this)){
|
||||
if($other instanceof Door && $other->hasSameTypeId($this)){
|
||||
if($this->top){
|
||||
$this->facing = $other->facing;
|
||||
$this->open = $other->open;
|
||||
@ -106,7 +106,7 @@ class Door extends Transparent{
|
||||
}
|
||||
|
||||
public function onNearbyBlockChange() : void{
|
||||
if(!$this->canBeSupportedBy($this->getSide(Facing::DOWN)) && !$this->getSide(Facing::DOWN) instanceof Door){ //Replace with common break method
|
||||
if(!$this->canBeSupportedAt($this) && !$this->getSide(Facing::DOWN) instanceof Door){ //Replace with common break method
|
||||
$this->position->getWorld()->useBreakOn($this->position); //this will delete both halves if they exist
|
||||
}
|
||||
}
|
||||
@ -114,8 +114,7 @@ class Door extends Transparent{
|
||||
public function place(BlockTransaction $tx, Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, ?Player $player = null) : bool{
|
||||
if($face === Facing::UP){
|
||||
$blockUp = $this->getSide(Facing::UP);
|
||||
$blockDown = $this->getSide(Facing::DOWN);
|
||||
if(!$blockUp->canBeReplaced() || !$this->canBeSupportedBy($blockDown)){
|
||||
if(!$blockUp->canBeReplaced() || !$this->canBeSupportedAt($blockReplace)){
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -126,7 +125,7 @@ class Door extends Transparent{
|
||||
$next = $this->getSide(Facing::rotateY($this->facing, false));
|
||||
$next2 = $this->getSide(Facing::rotateY($this->facing, true));
|
||||
|
||||
if($next->isSameType($this) || (!$next2->isTransparent() && $next->isTransparent())){ //Door hinge
|
||||
if($next->hasSameTypeId($this) || (!$next2->isTransparent() && $next->isTransparent())){ //Door hinge
|
||||
$this->hingeRight = true;
|
||||
}
|
||||
|
||||
@ -145,7 +144,7 @@ class Door extends Transparent{
|
||||
|
||||
$other = $this->getSide($this->top ? Facing::DOWN : Facing::UP);
|
||||
$world = $this->position->getWorld();
|
||||
if($other instanceof Door && $other->isSameType($this)){
|
||||
if($other instanceof Door && $other->hasSameTypeId($this)){
|
||||
$other->open = $this->open;
|
||||
$world->setBlock($other->position, $other);
|
||||
}
|
||||
@ -166,13 +165,13 @@ class Door extends Transparent{
|
||||
|
||||
public function getAffectedBlocks() : array{
|
||||
$other = $this->getSide($this->top ? Facing::DOWN : Facing::UP);
|
||||
if($other->isSameType($this)){
|
||||
if($other->hasSameTypeId($this)){
|
||||
return [$this, $other];
|
||||
}
|
||||
return parent::getAffectedBlocks();
|
||||
}
|
||||
|
||||
private function canBeSupportedBy(Block $block) : bool{
|
||||
return $block->getSupportType(Facing::UP)->hasEdgeSupport();
|
||||
private function canBeSupportedAt(Block $block) : bool{
|
||||
return $block->getAdjacentSupportType(Facing::DOWN)->hasEdgeSupport();
|
||||
}
|
||||
}
|
||||
|
@ -33,7 +33,7 @@ use pocketmine\world\BlockTransaction;
|
||||
class DoublePlant extends Flowable{
|
||||
protected bool $top = false;
|
||||
|
||||
protected function describeState(RuntimeDataDescriber $w) : void{
|
||||
protected function describeBlockOnlyState(RuntimeDataDescriber $w) : void{
|
||||
$w->bool($this->top);
|
||||
}
|
||||
|
||||
@ -65,7 +65,7 @@ class DoublePlant extends Flowable{
|
||||
|
||||
return (
|
||||
$other instanceof DoublePlant &&
|
||||
$other->isSameType($this) &&
|
||||
$other->hasSameTypeId($this) &&
|
||||
$other->top !== $this->top
|
||||
);
|
||||
}
|
||||
|
@ -23,19 +23,21 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\block\utils\TallGrassTrait;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\item\VanillaItems;
|
||||
use function mt_rand;
|
||||
|
||||
class DoubleTallGrass extends DoublePlant{
|
||||
use TallGrassTrait {
|
||||
getDropsForIncompatibleTool as traitGetDropsForIncompatibleTool;
|
||||
}
|
||||
|
||||
public function canBeReplaced() : bool{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function getDropsForIncompatibleTool(Item $item) : array{
|
||||
if($this->top && mt_rand(0, 7) === 0){
|
||||
return [VanillaItems::WHEAT_SEEDS()];
|
||||
if($this->top){
|
||||
return $this->traitGetDropsForIncompatibleTool($item);
|
||||
}
|
||||
return [];
|
||||
}
|
||||
|
@ -23,6 +23,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\block\utils\FortuneDropHelper;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\item\VanillaItems;
|
||||
use function mt_rand;
|
||||
@ -31,7 +32,7 @@ class EmeraldOre extends Opaque{
|
||||
|
||||
public function getDropsForCompatibleTool(Item $item) : array{
|
||||
return [
|
||||
VanillaItems::EMERALD()
|
||||
VanillaItems::EMERALD()->setCount(FortuneDropHelper::weighted($item, min: 1, maxBase: 1))
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -24,18 +24,16 @@ declare(strict_types=1);
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\block\utils\FacesOppositePlacingPlayerTrait;
|
||||
use pocketmine\block\utils\HorizontalFacingTrait;
|
||||
use pocketmine\data\runtime\RuntimeDataDescriber;
|
||||
use pocketmine\math\AxisAlignedBB;
|
||||
use pocketmine\math\Facing;
|
||||
|
||||
class EndPortalFrame extends Opaque{
|
||||
use FacesOppositePlacingPlayerTrait;
|
||||
use HorizontalFacingTrait;
|
||||
|
||||
protected bool $eye = false;
|
||||
|
||||
protected function describeState(RuntimeDataDescriber $w) : void{
|
||||
protected function describeBlockOnlyState(RuntimeDataDescriber $w) : void{
|
||||
$w->horizontalFacing($this->facing);
|
||||
$w->bool($this->eye);
|
||||
}
|
||||
|
@ -26,7 +26,6 @@ namespace pocketmine\block;
|
||||
use pocketmine\block\inventory\EnderChestInventory;
|
||||
use pocketmine\block\tile\EnderChest as TileEnderChest;
|
||||
use pocketmine\block\utils\FacesOppositePlacingPlayerTrait;
|
||||
use pocketmine\block\utils\HorizontalFacingTrait;
|
||||
use pocketmine\block\utils\SupportType;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\math\AxisAlignedBB;
|
||||
@ -36,7 +35,6 @@ use pocketmine\player\Player;
|
||||
|
||||
class EnderChest extends Transparent{
|
||||
use FacesOppositePlacingPlayerTrait;
|
||||
use HorizontalFacingTrait;
|
||||
|
||||
public function getLightLevel() : int{
|
||||
return 7;
|
||||
|
@ -26,6 +26,7 @@ namespace pocketmine\block;
|
||||
use pocketmine\data\runtime\RuntimeDataDescriber;
|
||||
use pocketmine\entity\Entity;
|
||||
use pocketmine\entity\Living;
|
||||
use pocketmine\event\block\FarmlandHydrationChangeEvent;
|
||||
use pocketmine\event\entity\EntityTrampleFarmlandEvent;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\math\AxisAlignedBB;
|
||||
@ -37,7 +38,7 @@ class Farmland extends Transparent{
|
||||
|
||||
protected int $wetness = 0; //"moisture" blockstate property in PC
|
||||
|
||||
protected function describeState(RuntimeDataDescriber $w) : void{
|
||||
protected function describeBlockOnlyState(RuntimeDataDescriber $w) : void{
|
||||
$w->boundedInt(3, 0, self::MAX_WETNESS, $this->wetness);
|
||||
}
|
||||
|
||||
@ -56,7 +57,7 @@ class Farmland extends Transparent{
|
||||
* @return AxisAlignedBB[]
|
||||
*/
|
||||
protected function recalculateCollisionBoxes() : array{
|
||||
return [AxisAlignedBB::one()]; //TODO: this should be trimmed at the top by 1/16, but MCPE currently treats them as a full block (https://bugs.mojang.com/browse/MCPE-12109)
|
||||
return [AxisAlignedBB::one()->trim(Facing::UP, 1 / 16)];
|
||||
}
|
||||
|
||||
public function onNearbyBlockChange() : void{
|
||||
@ -73,14 +74,22 @@ class Farmland extends Transparent{
|
||||
$world = $this->position->getWorld();
|
||||
if(!$this->canHydrate()){
|
||||
if($this->wetness > 0){
|
||||
$this->wetness--;
|
||||
$world->setBlock($this->position, $this, false);
|
||||
$event = new FarmlandHydrationChangeEvent($this, $this->wetness, $this->wetness - 1);
|
||||
$event->call();
|
||||
if(!$event->isCancelled()){
|
||||
$this->wetness = $event->getNewHydration();
|
||||
$world->setBlock($this->position, $this, false);
|
||||
}
|
||||
}else{
|
||||
$world->setBlock($this->position, VanillaBlocks::DIRT());
|
||||
}
|
||||
}elseif($this->wetness < self::MAX_WETNESS){
|
||||
$this->wetness = self::MAX_WETNESS;
|
||||
$world->setBlock($this->position, $this, false);
|
||||
$event = new FarmlandHydrationChangeEvent($this, $this->wetness, self::MAX_WETNESS);
|
||||
$event->call();
|
||||
if(!$event->isCancelled()){
|
||||
$this->wetness = $event->getNewHydration();
|
||||
$world->setBlock($this->position, $this, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -42,7 +42,7 @@ class Fence extends Transparent{
|
||||
|
||||
foreach(Facing::HORIZONTAL as $facing){
|
||||
$block = $this->getSide($facing);
|
||||
if($block instanceof static || $block instanceof FenceGate || ($block->isSolid() && !$block->isTransparent())){
|
||||
if($block instanceof static || $block instanceof FenceGate || $block->getSupportType(Facing::opposite($facing))->equals(SupportType::FULL())){
|
||||
$this->connections[$facing] = true;
|
||||
}else{
|
||||
unset($this->connections[$facing]);
|
||||
|
@ -42,7 +42,7 @@ class FenceGate extends Transparent{
|
||||
protected bool $open = false;
|
||||
protected bool $inWall = false;
|
||||
|
||||
protected function describeState(RuntimeDataDescriber $w) : void{
|
||||
protected function describeBlockOnlyState(RuntimeDataDescriber $w) : void{
|
||||
$w->horizontalFacing($this->facing);
|
||||
$w->bool($this->open);
|
||||
$w->bool($this->inWall);
|
||||
|
@ -37,7 +37,7 @@ abstract class FillableCauldron extends Transparent{
|
||||
|
||||
private int $fillLevel = self::MIN_FILL_LEVEL;
|
||||
|
||||
protected function describeState(RuntimeDataDescriber $w) : void{
|
||||
protected function describeBlockOnlyState(RuntimeDataDescriber $w) : void{
|
||||
$w->boundedInt(3, self::MIN_FILL_LEVEL, self::MAX_FILL_LEVEL, $this->fillLevel);
|
||||
}
|
||||
|
||||
|
@ -23,9 +23,10 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\block\utils\BlockEventHelper;
|
||||
use pocketmine\block\utils\SupportType;
|
||||
use pocketmine\data\runtime\RuntimeDataDescriber;
|
||||
use pocketmine\event\block\BlockBurnEvent;
|
||||
use pocketmine\event\block\BlockSpreadEvent;
|
||||
use pocketmine\math\Facing;
|
||||
use pocketmine\world\format\Chunk;
|
||||
use pocketmine\world\World;
|
||||
@ -39,7 +40,7 @@ class Fire extends BaseFire{
|
||||
|
||||
protected int $age = 0;
|
||||
|
||||
protected function describeState(RuntimeDataDescriber $w) : void{
|
||||
protected function describeBlockOnlyState(RuntimeDataDescriber $w) : void{
|
||||
$w->boundedInt(4, 0, self::MAX_AGE, $this->age);
|
||||
}
|
||||
|
||||
@ -58,12 +59,16 @@ class Fire extends BaseFire{
|
||||
return 1;
|
||||
}
|
||||
|
||||
private function canBeSupportedBy(Block $block) : bool{
|
||||
return $block->getSupportType(Facing::UP)->equals(SupportType::FULL());
|
||||
}
|
||||
|
||||
public function onNearbyBlockChange() : void{
|
||||
$world = $this->position->getWorld();
|
||||
$down = $this->getSide(Facing::DOWN);
|
||||
if(SoulFire::canBeSupportedBy($down)){
|
||||
$world->setBlock($this->position, VanillaBlocks::SOUL_FIRE());
|
||||
}elseif($down->isTransparent() && !$this->hasAdjacentFlammableBlocks()){
|
||||
}elseif(!$this->canBeSupportedBy($this->getSide(Facing::DOWN)) && !$this->hasAdjacentFlammableBlocks()){
|
||||
$world->setBlock($this->position, VanillaBlocks::AIR());
|
||||
}else{
|
||||
$world->scheduleDelayedBlockUpdate($this->position, mt_rand(30, 40));
|
||||
@ -140,9 +145,13 @@ class Fire extends BaseFire{
|
||||
|
||||
private function burnBlock(Block $block, int $chanceBound) : void{
|
||||
if(mt_rand(0, $chanceBound) < $block->getFlammability()){
|
||||
$ev = new BlockBurnEvent($block, $this);
|
||||
$ev->call();
|
||||
if(!$ev->isCancelled()){
|
||||
$cancelled = false;
|
||||
if(BlockBurnEvent::hasHandlers()){
|
||||
$ev = new BlockBurnEvent($block, $this);
|
||||
$ev->call();
|
||||
$cancelled = $ev->isCancelled();
|
||||
}
|
||||
if(!$cancelled){
|
||||
$block->onIncinerate();
|
||||
|
||||
$world = $this->position->getWorld();
|
||||
@ -220,13 +229,6 @@ class Fire extends BaseFire{
|
||||
}
|
||||
|
||||
private function spreadBlock(Block $block, Block $newState) : bool{
|
||||
$ev = new BlockSpreadEvent($block, $this, $newState);
|
||||
$ev->call();
|
||||
if(!$ev->isCancelled()){
|
||||
$block->position->getWorld()->setBlock($block->position, $ev->getNewState());
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
return BlockEventHelper::spread($block, $newState, $this);
|
||||
}
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ use function rad2deg;
|
||||
final class FloorCoralFan extends BaseCoral{
|
||||
private int $axis = Axis::X;
|
||||
|
||||
protected function describeState(RuntimeDataDescriber $w) : void{
|
||||
protected function describeBlockOnlyState(RuntimeDataDescriber $w) : void{
|
||||
$w->horizontalAxis($this->axis);
|
||||
}
|
||||
|
||||
@ -53,7 +53,7 @@ final class FloorCoralFan extends BaseCoral{
|
||||
}
|
||||
|
||||
public function place(BlockTransaction $tx, Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, ?Player $player = null) : bool{
|
||||
if(!$this->canBeSupportedBy($tx->fetchBlock($blockReplace->getPosition()->down()))){
|
||||
if(!$this->canBeSupportedAt($blockReplace)){
|
||||
return false;
|
||||
}
|
||||
if($player !== null){
|
||||
@ -75,15 +75,15 @@ final class FloorCoralFan extends BaseCoral{
|
||||
|
||||
public function onNearbyBlockChange() : void{
|
||||
$world = $this->position->getWorld();
|
||||
if(!$this->canBeSupportedBy($world->getBlock($this->position->down()))){
|
||||
if(!$this->canBeSupportedAt($this)){
|
||||
$world->useBreakOn($this->position);
|
||||
}else{
|
||||
parent::onNearbyBlockChange();
|
||||
}
|
||||
}
|
||||
|
||||
private function canBeSupportedBy(Block $block) : bool{
|
||||
return $block->getSupportType(Facing::UP)->hasCenterSupport();
|
||||
private function canBeSupportedAt(Block $block) : bool{
|
||||
return $block->getAdjacentSupportType(Facing::DOWN)->hasCenterSupport();
|
||||
}
|
||||
|
||||
public function asItem() : Item{
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user