forked from Ad5001/BetterGen
Compare commits
27 commits
loottables
...
master
Author | SHA1 | Date | |
---|---|---|---|
b2f0207148 | |||
ce05c1c269 | |||
|
1cc8c924af | ||
|
1a76db0b59 | ||
2b7566315d | |||
|
0342a6bd39 | ||
b1fce28b47 | |||
082a8060f9 | |||
40a6206409 | |||
6d636e7443 | |||
4b5cdeed6e | |||
2a9c440d10 | |||
a671c0c29c | |||
e7ef5620d1 | |||
|
bdb77f6e81 | ||
|
8387366191 | ||
|
946ff01874 | ||
|
db96352150 | ||
4512f5dfcd | |||
512ac47f70 | |||
8f933a8c12 | |||
b5fb3c21ae | |||
1f6416d02e | |||
920fd82b6e | |||
becff0ca47 | |||
c7bbc37d8d | |||
015967050d |
46 changed files with 2735 additions and 2003 deletions
189
LICENSE
189
LICENSE
|
@ -1,128 +1,113 @@
|
||||||
BoxOfDevs General Software License 1.1.4
|
Not Truly Open Source License
|
||||||
=========================================
|
=========================================
|
||||||
This license is designed to be used with any software which would like to have no selling for profits, nor any public redistribution without giving the original author credits.
|
This license is an adaption of the Creative Commons Licenses for softwares.
|
||||||
--------------------------------------------------------------------------------------------------------------------------------------
|
Any user using and, or Distributing the Software (defined in I) exerces the Licensed Rights.
|
||||||
The License: refers to the BoxOfDevs International Software License 1.1.2
|
By exercising the Licenced Rights (defined below), You accept and agree to be bound by the terms and conditions of this Not Truly Open Source ("NTOS License"). To the extent the NTOS License may be interpreted as a contract, You are granted the Licenced Rights in consideration of Your acceptance of these terms and conditions, and the Author grants You such rights in consideration of benefits the Author receives from making the Software available under these terms and conditions.
|
||||||
The Software: refers to any works licensed under The License.
|
|
||||||
The Modification: refers to any modified version of The Software.
|
|
||||||
The Redistribution: refers to any redistributions of The Software/The Modification.
|
|
||||||
The User: refers to any user of The Software licensed under The License.
|
|
||||||
The Author: refers to any developer, organisation, legal owner, or creator of The Software that has been licensed under the The License.
|
|
||||||
--------------------------------------------------------------------------------------------------------------------------------------
|
|
||||||
Section 1 - Allowances:
|
|
||||||
|
|
||||||
1. Both The User & The Author Can:
|
I. Definitions:
|
||||||
a. Modify private copies of The Software and use in any way they wish.
|
- "NTOS License" refers to the legal terms of this license, described here.
|
||||||
|
- "Licensed Rights" refers the rights granted to You subject to the terms and conditions of the NTOS License, which are limited to all Copyright and Similar Rights that apply to Your use of the Software and that the Author has authority to license.
|
||||||
|
- "The Software" refers to any work, code and software binaries licensed under the NTOS License.
|
||||||
|
- "The Author" refers the orginal author of the Software, the one that licenced the Software under the NTOS License.
|
||||||
|
- "the User", "User", "You", and "Your" refers the individual or entity exercising the Licenced Rights under the NTOS License.
|
||||||
|
- "the Modification" refers to based of the Software.
|
||||||
|
- "the Modification's Author" refers to an User that Distributes the Modificaction including more than 10% of the Software's code.
|
||||||
|
- "Code" refers to any part of the code located in the Software.
|
||||||
|
- "the Based Software" refers to work other than the Software using the Code. The used Code must not be larger than 10% of the code of the Software. Otherwise, the work is a Modification.
|
||||||
|
- "the Based Software's Author" refers to an User that created the
|
||||||
|
- "The End User" refers to the individual person accessing and, or using the Software. The End User may be or not the same as the User.
|
||||||
|
- "Exceptions and Limitations" refers to the fair use, fair dealing, and/or any other exception or limitation to Copyright and Similar Rights that applies to Your use of the Software.
|
||||||
|
- "Copyright and Similar Rights" refers to the copyright and/or similar rights closely related to copyright including, without limitation, performance, broadcast, sound recording, and Sui Generis Database Rights, without regard to how the Licenced Rights are labeled or categorized. For purposes of the NTOS License, the Licenced Rights specified in II(2)(a)-(b) are not Copyright and Similar Rights.
|
||||||
|
- "Distribute" refers to any way of providing The End User an access to the Software either by a downloading Platform or from any internet connected process allowing the user to access the Software content.
|
||||||
|
- "NonCommercial" means not primarily intended for or directed towards commercial advantage or monetary compensation. For purposes of the NTOS License, the exchange of the Software for other material subject to Copyright and Similar Rights by digital file-sharing or similar means is NonCommercial provided there is no payment of monetary compensation in connection with the exchange.
|
||||||
|
- "Sui Generis Database Rights" refers to the Licenced Rights other than copyright resulting from Directive 96/9/EC of the European Parliament and of the Council of 11 March 1996 on the legal protection of databases, as amended and/or succeeded, as well as other essentially equivalent rights anywhere in the world.
|
||||||
|
|
||||||
2. The User Can:
|
Section II. Scope.
|
||||||
a. Request new features, support, or more rights from The Author.
|
|
||||||
b. Redistribute The Software/The Modification, ensuring The User gives all appropriate credit to The Author and alerting The Author to The Redistribution.
|
|
||||||
|
|
||||||
3. The Author Can:
|
1. License grant.
|
||||||
a. Change or update The Software in any way they wish, ensuring they follow the other terms of The License.
|
a. Subject to the terms and conditions of the NTOS License, the Author hereby grants You a worldwide, royalty-free, non-sublicensable, non-exclusive, irrevocable license to exercise the Licenced Rights in the Software to:
|
||||||
b. Change which license The Software/The Modification is licensed under.
|
A. reproduce and Distribute the Software, in whole or in part, for NonCommercial purposes only; and
|
||||||
c. Grant extra rights to The User who has requested them.
|
B. produce, reproduce, and Distribute Modification for NonCommercial purposes only.
|
||||||
d. Reserve the right to request The User to take down their instance of The Software/The Modification/The Redistribution.
|
b. Exceptions and Limitations. For the avoidance of doubt, where Exceptions and Limitations apply to Your use, the NTOS License does not apply, and You do not need to comply with its terms and conditions.
|
||||||
|
c. Term. The term of the NTOS License is specified in Section VI(1).
|
||||||
|
d. Downstream recipients.
|
||||||
|
Offer from the Author – Software. Every recipient of the Software automatically receives an offer from the Author to exercise the Licenced Rights under the terms and conditions of the NTOS License.
|
||||||
|
Additional offer from the Author – Modification. Every recipient of Modification from You automatically receives an offer from the Author to exercise the Licenced Rights in the Modification under the conditions of the the Modification's Author's License You apply.
|
||||||
|
No downstream restrictions. You may not offer or impose any additional or different terms or conditions on, or apply any Effective Technological Measures to, the Software if doing so restricts exercise of the Licenced Rights by any recipient of the Software.
|
||||||
|
e. No endorsement. Nothing in the NTOS License constitutes or may be construed as permission to assert or imply that You are, or that Your use of the Software is, connected with, or sponsored, endorsed, or granted official status by, the Author or others designated to receive attribution as provided in Section III(1)(a)(A)(i).
|
||||||
|
2. Other rights.
|
||||||
|
a. Moral rights, such as the right of integrity, are not licensed under the NTOS License, nor are publicity, privacy, and/or other similar personality rights; however, to the extent possible, the Author waives and/or agrees not to assert any such rights held by the Author to the limited extent necessary to allow You to exercise the Licenced Rights, but not otherwise.
|
||||||
|
b. Patent and trademark rights are not licensed under the NTOS License.
|
||||||
|
c. To the extent possible, the Author waives any right to collect royalties from You for the exercise of the Licenced Rights, whether directly or through a collecting society under any voluntary or waivable statutory or compulsory licensing scheme. In all other cases the Author expressly reserves any right to collect such royalties, including when the Software is used other than for NonCommercial purposes.
|
||||||
|
|
||||||
Section 2 - Restrictions:
|
Section III. License Conditions.
|
||||||
1. Both The User & The Author Cannot:
|
Your exercise of the Licensed Rights is expressly made subject to the following conditions.
|
||||||
a. Introduce any malicious code into The Software/The Modification.
|
|
||||||
b. Sell any part of The Software/The Modification for profit.
|
|
||||||
|
|
||||||
2. The User Cannot:
|
1. Attribution.
|
||||||
a. Hold The Author responsible for any unknown errors.
|
a. If You Distribute the Software (including in modified, or based form), You must:
|
||||||
b. Claim The Software/The Modification/The Redistribution as entirely The User's product.
|
A. retain the following if it is supplied by the Author with the Software:
|
||||||
c. Use the software without crediting the Author.
|
i. identification of the creator(s) of the Software and any others designated to receive attribution, in any reasonable manner requested by the Author (including by pseudonym if designated);
|
||||||
|
ii. a copyright notice;
|
||||||
3. The Author Cannot:
|
iii. a notice that refers to the NTOS License;
|
||||||
a. Restrict The User in any way not specified by The License.
|
iv. a notice that refers to the disclaimer of warranties;
|
||||||
b. Distribute any form of The Software without proper documentation.
|
v. a URI or hyperlink to the Software to the extent reasonably practicable;
|
||||||
|
|
||||||
Term. The term of this License is specified in Section 6(a).
|
|
||||||
Media and formats; technical modifications allowed. The Author authorizes You to exercise the Licensed Rights in all media and formats whether now known or hereafter created, and to make technical modifications necessary to do so. The Author waives and/or agrees not to assert any right or authority to forbid You from making technical modifications necessary to exercise the Licensed Rights, including technical modifications necessary to circumvent Effective Technological Measures. For purposes of this License, simply making modifications authorized by this Section 2(a)(4) never produces Modification.
|
|
||||||
|
|
||||||
Downstream recipients.
|
|
||||||
Offer from the Author – Software. Every recipient of the Software automatically receives an offer from the Author to exercise the Licensed Rights under the terms and conditions of this License.
|
|
||||||
Additional offer from the Author – the Modification. Every recipient of the Modification from You automatically receives an offer from the Author to exercise the Licensed Rights in the Modification under the conditions of the Adapter’s License You apply.
|
|
||||||
No downstream restrictions. You may not offer or impose any additional or different terms or conditions on, or apply any Effective Technological Measures to, the Software if doing so restricts exercise of the Licensed Rights by any recipient of the Software.
|
|
||||||
No endorsement. Nothing in this License constitutes or may be construed as permission to assert or imply that You are, or that Your use of the Software is, connected with, or sponsored, endorsed, or granted official status by, the Author or others designated to receive attribution as provided in Section 3(a)(1)(A)(i).
|
|
||||||
|
|
||||||
Other rights.
|
|
||||||
Moral rights, such as the right of integrity, are not licensed under this License, nor are publicity, privacy, and/or other similar personality rights; however, to the extent possible, the Author waives and/or agrees not to assert any such rights held by the Author to the limited extent necessary to allow You to exercise the Licensed Rights, but not otherwise.
|
|
||||||
Patent and trademark rights are not licensed under this License.
|
|
||||||
To the extent possible, the Author waives any right to collect royalties from You for the exercise of the Licensed Rights, whether directly or through a collecting society under any voluntary or waivable statutory or compulsory licensing scheme. In all other cases the Author expressly reserves any right to collect such royalties.
|
|
||||||
|
|
||||||
Section 3 – License Conditions.
|
|
||||||
Your exercise of the Licensed Rights is expressly made subject to the following conditions.
|
|
||||||
|
|
||||||
a) Attribution.
|
|
||||||
If You Share the Software (including in modified form), You must:
|
|
||||||
retain the following if it is supplied by the Author with the Software:
|
|
||||||
identification of the creator(s) of the Software and any others designated to receive attribution, in any reasonable manner requested by the Author (including by pseudonym if designated);
|
|
||||||
a copyright notice;
|
|
||||||
a notice that refers to this License;
|
|
||||||
a notice that refers to the disclaimer of warranties;
|
|
||||||
a URI or hyperlink to the Software to the extent reasonably practicable;
|
|
||||||
indicate if You modified the Software and retain an indication of any previous modifications; and
|
indicate if You modified the Software and retain an indication of any previous modifications; and
|
||||||
indicate the Software is licensed under this License, and include the text of, or the URI or hyperlink to, this License.
|
indicate the Software is licensed under the NTOS License, and include the text of, or the URI or hyperlink to, the NTOS License.
|
||||||
You may satisfy the conditions in Section 3(a)(1) in any reasonable manner based on the medium, means, and context in which You Share the Software. For example, it may be reasonable to satisfy the conditions by providing a URI or hyperlink to a resource that includes the required information.
|
b. You may satisfy the conditions in Section III(1)(a) in any reasonable manner based on the medium, means, and context in which You Distribute the Software. For example, it may be reasonable to satisfy the conditions by providing a URI or hyperlink to a resource that includes the required information.
|
||||||
If requested by the Author, You must remove any of the information required by Section 3(a)(1)(A) to the extent reasonably practicable.
|
c. If requested by the Author, You must remove any of the information required by Section III(1)(a)(A) to the extent reasonably practicable.
|
||||||
|
|
||||||
b) ShareAlike.
|
2. Distribute ALike
|
||||||
In addition to the conditions in Section 3(a), if You Share the Modification You produce, the following conditions also apply.
|
In addition to the conditions in Section III(1), if You Distribute the Modification You produce, the following conditions also apply.
|
||||||
The Adapter’s License You apply must be a BoxOfDevs General License with the same License Elements, this version or later, or a BY-SA Compatible License.
|
A. The Modification Author's License You apply must be the NTOS License
|
||||||
You must include the text of, or the URI or hyperlink to, the Adapter's License You apply. You may satisfy this condition in any reasonable manner based on the medium, means, and context in which You Share the Modification.
|
B. You must include the text of, or the URI or hyperlink to, the Modification's Author's License You apply. You may satisfy this condition in any reasonable manner based on the medium, means, and context in which You Distribute the Modification.
|
||||||
You may not offer or impose any additional or different terms or conditions on, or apply any Effective Technological Measures to, Modification that restrict exercise of the rights granted under the Adapter's License You apply.
|
C. You may not offer or impose any additional or different terms or conditions on, or apply any Effective Technological Measures to, the Modification that restrict exercise of the rights granted under the Modification's Author's License You apply.
|
||||||
|
D. You may not apply any fee to access the Modification
|
||||||
|
|
||||||
c) Forever Open Source.
|
3. Distribution of code
|
||||||
In addition to the conditions in Section 3(a) and Section 3(b), if You Share the Modification You produce, the following conditions also apply.
|
In addition to the conditions in Section III(1), if You Distribute a Based Software, the following conditions also apply:
|
||||||
The Adapted work must have an open source existing repertory, accessible by anyone anytime linked in the Redistribution Description/Documentation.
|
A. You must include the text of, or the URI or hyperlink to, refering to this License. You may satisfy this condition in any reasonable manner based on the medium, means, and context in which You Distribute the Based Software.
|
||||||
You may not restrict anyone from accessing the source code, use it, and redistribute it under anything not explicily specified by the License.
|
B. You must also include Section III(1)(a)(A)(ii-v) in the the Based Software Code.
|
||||||
|
|
||||||
d) Free.
|
Section IV. Sui Generis Database Rights.
|
||||||
In addition to the conditions in Section 3(a), Section 3(b) and Section 3(c), if You Share by any way Modification and/or the Software You produce, the following conditions also apply.
|
|
||||||
The Work must be redistributed entirely free, under this license.
|
Where the Licensed Rights include Sui Generis Database Rights that apply to Your use of the Software:
|
||||||
You may not impose fees to anyone that gets the Modification/The Software.
|
|
||||||
|
for the avoidance of doubt, Section II(1)(a) grants You the right to extract, reuse, reproduce, and Dstribute all or a substantial portion of the contents of the database for NonCommercial purposes only;
|
||||||
|
if You include all or a substantial portion of the database contents in a database in which You have Sui Generis Database Rights, then the database in which You have Sui Generis Database Rights (but not its individual contents) is the Modification, including for purposes of Section III(2); and
|
||||||
|
You must comply with the conditions in Section III(1) if You Distribute all or a substantial portion of the contents of the database.
|
||||||
|
|
||||||
|
For the avoidance of doubt, this Section IV supplements and does not replace Your obligations under the NTOS License where the Licensed Rights include other Copyright and Similar Rights.
|
||||||
|
|
||||||
|
|
||||||
Section 4 – Sui Generis Database Rights.
|
Section V – Disclaimer of Warranties and Limitation of Liability.
|
||||||
Where the Licensed Rights include Sui Generis Database Rights that apply to Your use of the Software:
|
|
||||||
|
|
||||||
for the avoidance of doubt, Section 2(a)(1) grants You the right to extract, reuse, reproduce, and Share all or a substantial portion of the contents of the database;
|
1. Unless otherwise separately undertaken by the Author, to the extent possible, the Author offers the Software as-is and as-available, and makes no representations or warranties of any kind concerning the Software, whether express, implied, statutory, or other. This includes, without limitation, warranties of title, merchantability, fitness for a particular purpose, non-infringement, absence of latent or other defects, accuracy, or the presence or absence of errors, whether or not known or discoverable. Where disclaimers of warranties are not allowed in full or in part, this disclaimer may not apply to You.
|
||||||
if You include all or a substantial portion of the database contents in a database in which You have Sui Generis Database Rights, then the database in which You have Sui Generis Database Rights (but not its individual contents) is Modification, including for purposes of Section 3(b); and
|
2. To the extent possible, in no event will the Author be liable to You on any legal theory (including, without limitation, negligence) or otherwise for any direct, special, indirect, incidental, consequential, punitive, exemplary, or other losses, costs, expenses, or damages arising out of the NTOS License or use of the Software, even if the Author has been advised of the possibility of such losses, costs, expenses, or damages. Where a limitation of liability is not allowed in full or in part, this limitation may not apply to You.
|
||||||
You must comply with the conditions in Section 3(a) if You Share all or a substantial portion of the contents of the database.
|
|
||||||
|
|
||||||
For the avoidance of doubt, this Section 4 supplements and does not replace Your obligations under this License where the Licensed Rights include other Copyright and Similar Rights.
|
3. The disclaimer of warranties and limitation of liability provided above shall be interpreted in a manner that, to the extent possible, most closely approximates an absolute disclaimer and waiver of all liability.
|
||||||
|
|
||||||
Section 5 – Disclaimer of Warranties and Limitation of Liability.
|
|
||||||
|
|
||||||
Unless otherwise separately undertaken by the Author, to the extent possible, the Author offers the Software as-is and as-available, and makes no representations or warranties of any kind concerning the Software, whether express, implied, statutory, or other. This includes, without limitation, warranties of title, merchantability, fitness for a particular purpose, non-infringement, absence of latent or other defects, accuracy, or the presence or absence of errors, whether or not known or discoverable. Where disclaimers of warranties are not allowed in full or in part, this disclaimer may not apply to You.
|
Section VI – Term and Termination.
|
||||||
To the extent possible, in no event will the Author be liable to You on any legal theory (including, without limitation, negligence) or otherwise for any direct, special, indirect, incidental, consequential, punitive, exemplary, or other losses, costs, expenses, or damages arising out of this License or use of the Software, even if the Author has been advised of the possibility of such losses, costs, expenses, or damages. Where a limitation of liability is not allowed in full or in part, this limitation may not apply to You.
|
|
||||||
|
|
||||||
The disclaimer of warranties and limitation of liability provided above shall be interpreted in a manner that, to the extent possible, most closely approximates an absolute disclaimer and waiver of all liability.
|
The NTOS License applies for the term of the Copyright and Similar Rights licensed here. However, if You fail to comply with the NTOS License, then Your rights under the NTOS License terminate automatically.
|
||||||
|
|
||||||
Section 6 – Term and Termination.
|
|
||||||
This License applies for the term of the Copyright and Similar Rights licensed here. However, if You fail to comply with this License, then Your rights under this License terminate automatically.
|
|
||||||
|
|
||||||
Where Your right to use the Software has terminated under Section 6(a), it reinstates:
|
Where Your right to use the Software has terminated under Section 6(a), it reinstates:
|
||||||
automatically as of the date the violation is cured, provided it is cured within 30 days of Your discovery of the violation; or
|
automatically as of the date the violation is cured, provided it is cured within 30 days of Your discovery of the violation; or
|
||||||
upon express reinstatement by the Author.
|
upon express reinstatement by the Author.
|
||||||
For the avoidance of doubt, this Section 6(b) does not affect any right the Author may have to seek remedies for Your violations of this License.
|
For the avoidance of doubt, this Section 6(b) does not affect any right the Author may have to seek remedies for Your violations of the NTOS License.
|
||||||
For the avoidance of doubt, the Author may also offer the Software under separate terms or conditions or stop distributing the Software at any time; however, doing so will not terminate this License.
|
For the avoidance of doubt, the Author may also offer the Software under separate terms or conditions or stop distributing the Software at any time; however, doing so will not terminate the NTOS License.
|
||||||
Sections 1, 5, 6, 7, and 8 survive termination of this License.
|
Sections I, V, VI, VII, and VI survive termination of the NTOS License.
|
||||||
|
|
||||||
Section 7 – Other Terms and Conditions.
|
Section VII – Other Terms and Conditions.
|
||||||
|
|
||||||
The Author shall not be bound by any additional or different terms or conditions communicated by You unless expressly agreed.
|
The Licensor shall not be bound by any additional or different terms or conditions communicated by You unless expressly agreed.
|
||||||
Any arrangements, understandings, or agreements regarding the Software not stated herein are separate from and independent of the terms and conditions of this License.
|
Any arrangements, understandings, or agreements regarding the Software not stated herein are separate from and independent of the terms and conditions of the NTOS License.
|
||||||
In the event that The License is updated/changed on the official github repository/on the official website, you automatically agree.
|
|
||||||
The Author is not required to notify The User that The License has been updated/changed.
|
|
||||||
|
|
||||||
Section 8 – Interpretation.
|
Section VIII – Interpretation.
|
||||||
For the avoidance of doubt, this License does not, and shall not be interpreted to, reduce, limit, restrict, or impose conditions on any use of the Software that could lawfully be made without permission under this License.
|
|
||||||
|
|
||||||
To the extent possible, if any provision of this License is deemed unenforceable, it shall be automatically reformed to the minimum extent necessary to make it enforceable. If the provision cannot be reformed, it shall be severed from this License without affecting the enforceability of the remaining terms and conditions.
|
For the avoidance of doubt, the NTOS License does not, and shall not be interpreted to, reduce, limit, restrict, or impose conditions on any use of the Software that could lawfully be made without permission under the NTOS License.
|
||||||
No term or condition of this License will be waived and no failure to comply consented to unless expressly agreed to by the Author.
|
To the extent possible, if any provision of the NTOS License is deemed unenforceable, it shall be automatically reformed to the minimum extent necessary to make it enforceable. If the provision cannot be reformed, it shall be severed from the NTOS License without affecting the enforceability of the remaining terms and conditions.
|
||||||
Nothing in this License constitutes or may be interpreted as a limitation upon, or waiver of, any privileges and immunities that apply to the Author or You, including from the legal processes of any jurisdiction or authority.
|
No term or condition of the NTOS License will be waived and no failure to comply consented to unless expressly agreed to by the Author.
|
||||||
|
Nothing in the NTOS License constitutes or may be interpreted as a limitation upon, or waiver of, any privileges and immunities that apply to the Author or You, including from the legal processes of any jurisdiction or authority.
|
||||||
|
|
||||||
Copyright (C) Ad5001 2017
|
In case of a specific issue not specified in the NTOSL, Berne Convention for the Protection of Literary and Artistic Works, which reserves all rights to the Author applies. You can find Berne Convention for the Protection of Literary and Artistic Works at http://www.wipo.int/treaties/en/text.jsp?file_id=283698.
|
17
README.md
17
README.md
|
@ -46,14 +46,9 @@ Welcome user to the home of a new PocketMine World Generator which features 9 ne
|
||||||
### These two biomes now are a bit better by the additions of bushes.
|
### These two biomes now are a bit better by the additions of bushes.
|
||||||
<img src="https://raw.githubusercontent.com/Ad5001/BetterGen/master/imgs/bushes.png" style="width: 500px"></img>
|
<img src="https://raw.githubusercontent.com/Ad5001/BetterGen/master/imgs/bushes.png" style="width: 500px"></img>
|
||||||
|
|
||||||
-----
|
# Contributors:
|
||||||
|
BetterGen wouldn't be here today without the following guys who have made this plugin possible to get where it is now:
|
||||||
# Notice:
|
Ad5001
|
||||||
|
thebigsmileXD
|
||||||
### To generate loot like in vanilla MCPE, you have to put the default behaviour pack contents of the game into the "addon" folder.
|
wyt3dr4g0n
|
||||||
### Due to legal issues we are not able to include these directly into the repository.
|
fyvekatz
|
||||||
### You can get them here: https://aka.ms/behaviorpacktemplate or here https://github.com/dktapps/mcpe-default-addon for an optimised version
|
|
||||||
### The folder has to look like this:
|
|
||||||
<img src="https://raw.githubusercontent.com/Ad5001/BetterGen/master/imgs/addon_setup.png" style="width: 500px"></img>
|
|
||||||
|
|
||||||
All content here is copyrighted (C) Ad5001 2017. Infos about this copyright can be found in the license file.
|
|
BIN
imgs/Render.png
Normal file
BIN
imgs/Render.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 516 KiB |
Binary file not shown.
Before Width: | Height: | Size: 6.8 KiB |
BIN
imgs/banner.png
BIN
imgs/banner.png
Binary file not shown.
Before Width: | Height: | Size: 1.7 MiB After Width: | Height: | Size: 823 KiB |
20
plugin.yml
20
plugin.yml
|
@ -1,4 +1,5 @@
|
||||||
---
|
---
|
||||||
|
|
||||||
# ____ __ __ ____
|
# ____ __ __ ____
|
||||||
# /\ _`\ /\ \__ /\ \__ /\ _`\
|
# /\ _`\ /\ \__ /\ \__ /\ _`\
|
||||||
# \ \ \L\ \ __ \ \ ,_\\ \ ,_\ __ _ __ \ \ \L\_\ __ ___
|
# \ \ \L\ \ __ \ \ ,_\\ \ ,_\ __ _ __ \ \ \L\_\ __ ___
|
||||||
|
@ -7,14 +8,19 @@
|
||||||
# \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\
|
# \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\
|
||||||
# \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/
|
# \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/
|
||||||
# Tomorrow's pocketmine generator.
|
# Tomorrow's pocketmine generator.
|
||||||
# @author Ad5001
|
# @category World Generator
|
||||||
|
# @api 3.0.0
|
||||||
# @link https://github.com/Ad5001/BetterGen
|
# @link https://github.com/Ad5001/BetterGen
|
||||||
|
# @version 1.1
|
||||||
name: BetterGen
|
name: BetterGen
|
||||||
authors: Ad5001, XenialDan
|
author: Ad5001
|
||||||
|
contributors:
|
||||||
|
- thebigsmileXD (XenialDan)
|
||||||
|
- wyt3dr4g0n
|
||||||
main: Ad5001\BetterGen\Main
|
main: Ad5001\BetterGen\Main
|
||||||
version: 2.0
|
version: 1.1
|
||||||
load: STARTUP
|
load: STARTUP
|
||||||
api: [3.0.0-ALPHA3, 3.0.0-ALPHA5]
|
api: [3.0.0-ALPHA12]
|
||||||
commands:
|
commands:
|
||||||
createworld:
|
createworld:
|
||||||
description: Generates a new world.
|
description: Generates a new world.
|
||||||
|
@ -24,9 +30,9 @@ commands:
|
||||||
description: Teleports you to an another world
|
description: Teleports you to an another world
|
||||||
usage: "/worldtp <world name>"
|
usage: "/worldtp <world name>"
|
||||||
permission: bettergen.cmd.worldtp
|
permission: bettergen.cmd.worldtp
|
||||||
structure:
|
temple:
|
||||||
description: Spawns a structure for debugging
|
description: Spawns a temple for debugging
|
||||||
usage: "/structure <type>"
|
usage: "/temple"
|
||||||
permission: bettergen.cmd.debug
|
permission: bettergen.cmd.debug
|
||||||
permissions:
|
permissions:
|
||||||
bettergen.cmd.createworld:
|
bettergen.cmd.createworld:
|
||||||
|
|
183
resources/loots/mineshaft.json
Normal file
183
resources/loots/mineshaft.json
Normal file
|
@ -0,0 +1,183 @@
|
||||||
|
{
|
||||||
|
"max": 27,
|
||||||
|
"rail": {
|
||||||
|
"percentage": 79,
|
||||||
|
"minCount": 4,
|
||||||
|
"maxCount": 8,
|
||||||
|
"minStacks": 3,
|
||||||
|
"maxStacks": 3,
|
||||||
|
"id": 66,
|
||||||
|
"data": 0
|
||||||
|
},
|
||||||
|
"torch": {
|
||||||
|
"percentage": 66,
|
||||||
|
"minCount": 1,
|
||||||
|
"maxCount": 16,
|
||||||
|
"minStacks": 3,
|
||||||
|
"maxStacks": 3,
|
||||||
|
"id": 50,
|
||||||
|
"data": 0
|
||||||
|
},
|
||||||
|
"bread": {
|
||||||
|
"percentage": 45,
|
||||||
|
"minCount": 1,
|
||||||
|
"maxCount": 3,
|
||||||
|
"minStacks": 2,
|
||||||
|
"maxStacks": 4,
|
||||||
|
"id": 297,
|
||||||
|
"data": 0
|
||||||
|
},
|
||||||
|
"name tag": {
|
||||||
|
"percentage": 42,
|
||||||
|
"minCount": 1,
|
||||||
|
"maxCount": 1,
|
||||||
|
"minStacks": 2,
|
||||||
|
"maxStacks": 4,
|
||||||
|
"id": 297,
|
||||||
|
"data": 0
|
||||||
|
},
|
||||||
|
"coal": {
|
||||||
|
"percentage": 32,
|
||||||
|
"minCount": 3,
|
||||||
|
"maxCount": 8,
|
||||||
|
"minStacks": 2,
|
||||||
|
"maxStacks": 4,
|
||||||
|
"id": 263,
|
||||||
|
"data": 0
|
||||||
|
},
|
||||||
|
"beetroot seeds": {
|
||||||
|
"percentage": 32,
|
||||||
|
"minCount": 2,
|
||||||
|
"maxCount": 4,
|
||||||
|
"minStacks": 2,
|
||||||
|
"maxStacks": 4,
|
||||||
|
"id": 458,
|
||||||
|
"data": 0
|
||||||
|
},
|
||||||
|
"melon seeds": {
|
||||||
|
"percentage": 32,
|
||||||
|
"minCount": 2,
|
||||||
|
"maxCount": 4,
|
||||||
|
"minStacks": 2,
|
||||||
|
"maxStacks": 4,
|
||||||
|
"id": 362,
|
||||||
|
"data": 0
|
||||||
|
},
|
||||||
|
"pumpkin seeds": {
|
||||||
|
"percentage": 32,
|
||||||
|
"minCount": 2,
|
||||||
|
"maxCount": 4,
|
||||||
|
"minStacks": 2,
|
||||||
|
"maxStacks": 4,
|
||||||
|
"id": 361,
|
||||||
|
"data": 0
|
||||||
|
},
|
||||||
|
"iron ingot": {
|
||||||
|
"percentage": 32,
|
||||||
|
"minCount": 1,
|
||||||
|
"maxCount": 5,
|
||||||
|
"minStacks": 2,
|
||||||
|
"maxStacks": 4,
|
||||||
|
"id": 365,
|
||||||
|
"data": 0
|
||||||
|
},
|
||||||
|
"golden apple": {
|
||||||
|
"percentage": 28,
|
||||||
|
"minCount": 1,
|
||||||
|
"maxCount": 1,
|
||||||
|
"minStacks": 1,
|
||||||
|
"maxStacks": 1,
|
||||||
|
"id": 322,
|
||||||
|
"data": 0
|
||||||
|
},
|
||||||
|
"activator rail": {
|
||||||
|
"percentage": 27,
|
||||||
|
"minCount": 1,
|
||||||
|
"maxCount": 4,
|
||||||
|
"minStacks": 3,
|
||||||
|
"maxStacks": 3,
|
||||||
|
"id": 126,
|
||||||
|
"data": 0
|
||||||
|
},
|
||||||
|
"detector rail": {
|
||||||
|
"percentage": 27,
|
||||||
|
"minCount": 1,
|
||||||
|
"maxCount": 4,
|
||||||
|
"minStacks": 3,
|
||||||
|
"maxStacks": 3,
|
||||||
|
"id": 28,
|
||||||
|
"data": 0
|
||||||
|
},
|
||||||
|
"powered rail": {
|
||||||
|
"percentage": 27,
|
||||||
|
"minCount": 1,
|
||||||
|
"maxCount": 4,
|
||||||
|
"minStacks": 3,
|
||||||
|
"maxStacks": 3,
|
||||||
|
"id": 27,
|
||||||
|
"data": 0
|
||||||
|
},
|
||||||
|
"lapis lazuli": {
|
||||||
|
"percentage": 17,
|
||||||
|
"minCount": 4,
|
||||||
|
"maxCount": 9,
|
||||||
|
"minStacks": 2,
|
||||||
|
"maxStacks": 4,
|
||||||
|
"id": 351,
|
||||||
|
"data": 4
|
||||||
|
},
|
||||||
|
"redstone": {
|
||||||
|
"percentage": 17,
|
||||||
|
"minCount": 4,
|
||||||
|
"maxCount": 9,
|
||||||
|
"minStacks": 2,
|
||||||
|
"maxStacks": 4,
|
||||||
|
"id": 331,
|
||||||
|
"data": 0
|
||||||
|
},
|
||||||
|
"gold ingot": {
|
||||||
|
"percentage": 17,
|
||||||
|
"minCount": 1,
|
||||||
|
"maxCount": 3,
|
||||||
|
"minStacks": 2,
|
||||||
|
"maxStacks": 4,
|
||||||
|
"id": 366,
|
||||||
|
"data": 0
|
||||||
|
},
|
||||||
|
"enchanted book": {
|
||||||
|
"percentage": 14,
|
||||||
|
"minCount": 1,
|
||||||
|
"maxCount": 1,
|
||||||
|
"minStacks": 1,
|
||||||
|
"maxStacks": 1,
|
||||||
|
"id": 403,
|
||||||
|
"data": 0
|
||||||
|
},
|
||||||
|
"diamond": {
|
||||||
|
"percentage": 11,
|
||||||
|
"minCount": 1,
|
||||||
|
"maxCount": 2,
|
||||||
|
"minStacks": 2,
|
||||||
|
"maxStacks": 4,
|
||||||
|
"id": 264,
|
||||||
|
"data": 0
|
||||||
|
},
|
||||||
|
"iron pickaxe": {
|
||||||
|
"percentage": 7,
|
||||||
|
"minCount": 1,
|
||||||
|
"maxCount": 1,
|
||||||
|
"minStacks": 1,
|
||||||
|
"maxStacks": 1,
|
||||||
|
"id": 257,
|
||||||
|
"data": 0
|
||||||
|
},
|
||||||
|
"enchanted golden apple": {
|
||||||
|
"percentage": 1,
|
||||||
|
"minCount": 1,
|
||||||
|
"maxCount": 1,
|
||||||
|
"minStacks": 1,
|
||||||
|
"maxStacks": 1,
|
||||||
|
"id": 466,
|
||||||
|
"data": 0
|
||||||
|
}
|
||||||
|
}
|
154
resources/loots/temple.json
Normal file
154
resources/loots/temple.json
Normal file
|
@ -0,0 +1,154 @@
|
||||||
|
{
|
||||||
|
"max": 27,
|
||||||
|
"bone": {
|
||||||
|
"percentage": 71,
|
||||||
|
"minCount": 4,
|
||||||
|
"maxCount": 6,
|
||||||
|
"minStacks": 2,
|
||||||
|
"maxStacks": 4,
|
||||||
|
"id": 352,
|
||||||
|
"data": 0
|
||||||
|
},
|
||||||
|
"rotten_flesh": {
|
||||||
|
"percentage": 71,
|
||||||
|
"minCount": 3,
|
||||||
|
"maxCount": 7,
|
||||||
|
"minStacks": 2,
|
||||||
|
"maxStacks": 4,
|
||||||
|
"id": 367,
|
||||||
|
"data": 0
|
||||||
|
},
|
||||||
|
"gunpowder": {
|
||||||
|
"percentage": 59,
|
||||||
|
"minCount": 1,
|
||||||
|
"maxCount": 8,
|
||||||
|
"minStacks": 4,
|
||||||
|
"maxStacks": 4,
|
||||||
|
"id": 289,
|
||||||
|
"data": 0
|
||||||
|
},
|
||||||
|
"sand": {
|
||||||
|
"percentage": 59,
|
||||||
|
"minCount": 1,
|
||||||
|
"maxCount": 8,
|
||||||
|
"minStacks": 4,
|
||||||
|
"maxStacks": 4,
|
||||||
|
"id": 12,
|
||||||
|
"data": 0
|
||||||
|
},
|
||||||
|
"string": {
|
||||||
|
"percentage": 59,
|
||||||
|
"minCount": 1,
|
||||||
|
"maxCount": 8,
|
||||||
|
"minStacks": 4,
|
||||||
|
"maxStacks": 4,
|
||||||
|
"id": 287,
|
||||||
|
"data": 0
|
||||||
|
},
|
||||||
|
"spider_eye": {
|
||||||
|
"percentage": 29,
|
||||||
|
"minCount": 1,
|
||||||
|
"maxCount": 3,
|
||||||
|
"minStacks": 2,
|
||||||
|
"maxStacks": 4,
|
||||||
|
"id": 375,
|
||||||
|
"data": 0
|
||||||
|
},
|
||||||
|
"enchanted_book": {
|
||||||
|
"percentage": 24,
|
||||||
|
"minCount": 1,
|
||||||
|
"maxCount": 1,
|
||||||
|
"id": 403,
|
||||||
|
"data": 0
|
||||||
|
},
|
||||||
|
"saddle": {
|
||||||
|
"percentage": 24,
|
||||||
|
"minCount": 1,
|
||||||
|
"maxCount": 1,
|
||||||
|
"minStacks": 2,
|
||||||
|
"maxStacks": 4,
|
||||||
|
"id": 329,
|
||||||
|
"data": 0
|
||||||
|
},
|
||||||
|
"golden_apple": {
|
||||||
|
"percentage": 24,
|
||||||
|
"minCount": 1,
|
||||||
|
"maxCount": 1,
|
||||||
|
"minStacks": 1,
|
||||||
|
"maxStacks": 1,
|
||||||
|
"id": 322,
|
||||||
|
"data": 0
|
||||||
|
},
|
||||||
|
"gold_ingot": {
|
||||||
|
"percentage": 18,
|
||||||
|
"minCount": 2,
|
||||||
|
"maxCount": 7,
|
||||||
|
"minStacks": 2,
|
||||||
|
"maxStacks": 4,
|
||||||
|
"id": 266,
|
||||||
|
"data": 0
|
||||||
|
},
|
||||||
|
"iron_ingot": {
|
||||||
|
"percentage": 18,
|
||||||
|
"minCount": 1,
|
||||||
|
"maxCount": 5,
|
||||||
|
"minStacks": 2,
|
||||||
|
"maxStacks": 4,
|
||||||
|
"id": 265,
|
||||||
|
"data": 0
|
||||||
|
},
|
||||||
|
"emerald": {
|
||||||
|
"percentage": 18,
|
||||||
|
"minCount": 1,
|
||||||
|
"maxCount": 3,
|
||||||
|
"minStacks": 2,
|
||||||
|
"maxStacks": 4,
|
||||||
|
"id": 388,
|
||||||
|
"data": 0
|
||||||
|
},
|
||||||
|
"iron_horse_armor": {
|
||||||
|
"percentage": 18,
|
||||||
|
"minCount": 1,
|
||||||
|
"maxCount": 1,
|
||||||
|
"minStacks": 2,
|
||||||
|
"maxStacks": 4,
|
||||||
|
"id": 417,
|
||||||
|
"data": 0
|
||||||
|
},
|
||||||
|
"gold_horse_armor": {
|
||||||
|
"percentage": 12,
|
||||||
|
"minCount": 1,
|
||||||
|
"maxCount": 1,
|
||||||
|
"minStacks": 2,
|
||||||
|
"maxStacks": 4,
|
||||||
|
"id": 418,
|
||||||
|
"data": 0
|
||||||
|
},
|
||||||
|
"diamond": {
|
||||||
|
"percentage": 6,
|
||||||
|
"minCount": 1,
|
||||||
|
"maxCount": 3,
|
||||||
|
"minStacks": 2,
|
||||||
|
"maxStacks": 4,
|
||||||
|
"id": 264,
|
||||||
|
"data": 0
|
||||||
|
},
|
||||||
|
"diamond_horse_armor": {
|
||||||
|
"percentage": 6,
|
||||||
|
"minCount": 1,
|
||||||
|
"maxCount": 1,
|
||||||
|
"minStacks": 2,
|
||||||
|
"maxStacks": 4,
|
||||||
|
"id": 419,
|
||||||
|
"data": 0
|
||||||
|
},
|
||||||
|
"enchanted_golden_apple": {
|
||||||
|
"percentage": 3,
|
||||||
|
"minCount": 1,
|
||||||
|
"maxCount": 1,
|
||||||
|
"minStacks": 2,
|
||||||
|
"maxStacks": 4,
|
||||||
|
"id": 466,
|
||||||
|
"data": 0
|
||||||
|
}
|
||||||
|
}
|
|
@ -8,8 +8,11 @@
|
||||||
* \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\
|
* \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\
|
||||||
* \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/
|
* \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/
|
||||||
* Tomorrow's pocketmine generator.
|
* Tomorrow's pocketmine generator.
|
||||||
* @author Ad5001
|
* @author Ad5001 <mail@ad5001.eu>, XenialDan <https://github.com/thebigsmileXD>
|
||||||
* @link https://github.com/Ad5001/BetterGen
|
* @link https://github.com/Ad5001/BetterGen
|
||||||
|
* @category World Generator
|
||||||
|
* @api 3.0.0
|
||||||
|
* @version 1.1
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Ad5001\BetterGen;
|
namespace Ad5001\BetterGen;
|
||||||
|
@ -17,44 +20,37 @@ namespace Ad5001\BetterGen;
|
||||||
use Ad5001\BetterGen\biome\BetterForest;
|
use Ad5001\BetterGen\biome\BetterForest;
|
||||||
use Ad5001\BetterGen\generator\BetterNormal;
|
use Ad5001\BetterGen\generator\BetterNormal;
|
||||||
use Ad5001\BetterGen\loot\LootTable;
|
use Ad5001\BetterGen\loot\LootTable;
|
||||||
use Ad5001\BetterGen\structure\FallenTree;
|
|
||||||
use Ad5001\BetterGen\structure\Igloo;
|
|
||||||
use Ad5001\BetterGen\structure\SakuraTree;
|
|
||||||
use Ad5001\BetterGen\structure\Temple;
|
use Ad5001\BetterGen\structure\Temple;
|
||||||
use Ad5001\BetterGen\structure\Well;
|
|
||||||
use pocketmine\block\Block;
|
use pocketmine\block\Block;
|
||||||
use pocketmine\block\Chest;
|
|
||||||
use pocketmine\command\Command;
|
use pocketmine\command\Command;
|
||||||
use pocketmine\command\CommandSender;
|
use pocketmine\command\CommandSender;
|
||||||
|
use pocketmine\command\ConsoleCommandSender;
|
||||||
use pocketmine\event\block\BlockBreakEvent;
|
use pocketmine\event\block\BlockBreakEvent;
|
||||||
|
use pocketmine\event\level\ChunkPopulateEvent;
|
||||||
use pocketmine\event\Listener;
|
use pocketmine\event\Listener;
|
||||||
use pocketmine\event\player\PlayerInteractEvent;
|
use pocketmine\event\player\PlayerInteractEvent;
|
||||||
use pocketmine\item\Item;
|
|
||||||
use pocketmine\level\generator\biome\Biome;
|
use pocketmine\level\generator\biome\Biome;
|
||||||
use pocketmine\level\generator\Generator;
|
use pocketmine\level\generator\Generator;
|
||||||
use pocketmine\level\generator\object\OakTree;
|
|
||||||
use pocketmine\level\Position;
|
|
||||||
use pocketmine\nbt\tag\CompoundTag;
|
use pocketmine\nbt\tag\CompoundTag;
|
||||||
use pocketmine\nbt\tag\IntTag;
|
use pocketmine\nbt\tag\IntTag;
|
||||||
|
use pocketmine\nbt\tag\ListTag;
|
||||||
use pocketmine\nbt\tag\StringTag;
|
use pocketmine\nbt\tag\StringTag;
|
||||||
use pocketmine\Player;
|
use pocketmine\Player;
|
||||||
use pocketmine\plugin\PluginBase;
|
use pocketmine\plugin\PluginBase;
|
||||||
use pocketmine\tile\Chest as TileChest;
|
use pocketmine\tile\Chest;
|
||||||
use pocketmine\tile\Tile;
|
use pocketmine\tile\Tile;
|
||||||
use pocketmine\utils\Config;
|
use pocketmine\utils\Config;
|
||||||
use pocketmine\utils\Random;
|
use pocketmine\utils\Random;
|
||||||
use pocketmine\utils\TextFormat;
|
|
||||||
|
|
||||||
class Main extends PluginBase implements Listener {
|
class Main extends PluginBase implements Listener {
|
||||||
const PREFIX = "§l§o§b[§r§l§2Better§aGen§o§b]§r§f ";
|
const PREFIX = "§l§o§b[§r§l§2Better§aGen§o§b]§r§f ";
|
||||||
const SAKURA_FOREST = 100; // Letting some place for future biomes.
|
const SAKURA_FOREST = 100; // Letting some place for future biomes.
|
||||||
private static $instance;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Registers a biome for the normal generator. Normal means(Biome::register) doesn't allow biome to be generated
|
* Regisetrs a biome to betternormal
|
||||||
* @param $id int
|
*
|
||||||
* @param $biome Biome
|
* @param int $id
|
||||||
|
* @param Biome $biome
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public static function registerBiome(int $id, Biome $biome) {
|
public static function registerBiome(int $id, Biome $biome) {
|
||||||
|
@ -62,39 +58,25 @@ class Main extends PluginBase implements Listener {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Places a looting chest block and creates the corresponding tile
|
* Called when the plugin enales
|
||||||
* @param Block $block
|
*
|
||||||
* @param $lootfile
|
* @return void
|
||||||
*/
|
|
||||||
static public function placeLootChest(Block $block, $lootfile) {
|
|
||||||
$block->getLevel()->setBlock($block, $block, true);
|
|
||||||
$nbt = new CompoundTag("", [
|
|
||||||
new StringTag("id", Tile::CHEST),
|
|
||||||
new IntTag("x", (int)$block->x),
|
|
||||||
new IntTag("y", (int)$block->y),
|
|
||||||
new IntTag("z", (int)$block->z),
|
|
||||||
new StringTag("generateLoot", $lootfile)
|
|
||||||
]);
|
|
||||||
$tile = new TileChest($block->getLevel(), $nbt);
|
|
||||||
$tile->spawnToAll();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Called when the plugin enables
|
|
||||||
*/
|
*/
|
||||||
public function onEnable() {
|
public function onEnable() {
|
||||||
self::$instance = $this;
|
|
||||||
$this->getServer()->getPluginManager()->registerEvents($this, $this);
|
$this->getServer()->getPluginManager()->registerEvents($this, $this);
|
||||||
Generator::addGenerator(BetterNormal::class, "betternormal");
|
Generator::addGenerator(BetterNormal::class, "betternormal");
|
||||||
if ($this->isOtherNS()) $this->getLogger()->warning("Tesseract detected. Note that Tesseract is not up to date with the generation structure and some generation features may be limited or not working");
|
if ($this->isOtherNS()) $this->getLogger()->warning("Tesseract detected. Note that Tesseract is not up to date with the generation structure and some generation features may be limited or not working");
|
||||||
@mkdir($this->getDataFolder());
|
@mkdir(LootTable::getPluginFolder());
|
||||||
@mkdir($this->getDataFolder() . 'addon');
|
@mkdir(LootTable::getPluginFolder() . "loots");
|
||||||
if ((($files = @scandir($this->getDataFolder() . 'addon')) && count($files) <= 2)) $this->getLogger()->alert('The loot files are missing, this means no loot will generate! You can get them here: https://aka.ms/behaviorpacktemplate or here https://github.com/dktapps/mcpe-default-addon for an optimised version');
|
if (!file_exists(LootTable::getPluginFolder() . "processingLoots.json"))
|
||||||
|
file_put_contents(LootTable::getPluginFolder() . "processingLoots.json", "{}");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if it's a Tesseract like namespace
|
* Checks for tesseract like namespaces. Returns true if thats the case
|
||||||
* @return bool
|
*
|
||||||
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public static function isOtherNS() {
|
public static function isOtherNS() {
|
||||||
try {
|
try {
|
||||||
|
@ -105,17 +87,12 @@ class Main extends PluginBase implements Listener {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when the plugin disables
|
* Called when a command executes
|
||||||
*/
|
*
|
||||||
public function onDisable() {
|
* @param CommandSender $sender
|
||||||
}
|
* @param Command $cmd
|
||||||
|
* @param int $label
|
||||||
/**
|
* @param array $args
|
||||||
* Called when one of the defined commands of the plugin has been called
|
|
||||||
* @param $sender \pocketmine\command\CommandSender
|
|
||||||
* @param $cmd \pocketmine\command\Command
|
|
||||||
* @param $label mixed
|
|
||||||
* @param $args array
|
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function onCommand(CommandSender $sender, Command $cmd, $label, array $args): bool {
|
public function onCommand(CommandSender $sender, Command $cmd, $label, array $args): bool {
|
||||||
|
@ -151,15 +128,13 @@ class Main extends PluginBase implements Listener {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
$generatorName = strtolower($args[1]);
|
$generatorName = strtolower($args[1]);
|
||||||
if (preg_match("[^\d]", $args[2]) !== false) {
|
|
||||||
$parts = str_split($args[2]);
|
$parts = str_split($args[2]);
|
||||||
foreach ($parts as $key => $str) {
|
foreach ($parts as $key=>$str) {
|
||||||
|
if(is_numeric($str) == false && $str <> '-'){
|
||||||
$parts[$key] = ord($str);
|
$parts[$key] = ord($str);
|
||||||
}
|
}
|
||||||
$seed = implode("", $parts);
|
|
||||||
} else {
|
|
||||||
$seed = $args[2];
|
|
||||||
}
|
}
|
||||||
|
$seed = (int)implode("", $parts);
|
||||||
$options = [];
|
$options = [];
|
||||||
break;
|
break;
|
||||||
default : // /createworld <name> [generator = betternormal] [seed = rand()] [options(json)]
|
default : // /createworld <name> [generator = betternormal] [seed = rand()] [options(json)]
|
||||||
|
@ -171,15 +146,13 @@ class Main extends PluginBase implements Listener {
|
||||||
}
|
}
|
||||||
$generatorName = strtolower($args[1]);
|
$generatorName = strtolower($args[1]);
|
||||||
if ($args[2] == "rand") $args[2] = $this->generateRandomSeed();
|
if ($args[2] == "rand") $args[2] = $this->generateRandomSeed();
|
||||||
if (preg_match("[^\d]", $args[2]) !== false) {
|
|
||||||
$parts = str_split($args[2]);
|
$parts = str_split($args[2]);
|
||||||
foreach ($parts as $key => $str) {
|
foreach ($parts as $key=>$str) {
|
||||||
|
if(is_numeric($str) == false && $str <> '-'){
|
||||||
$parts[$key] = ord($str);
|
$parts[$key] = ord($str);
|
||||||
}
|
}
|
||||||
$seed = implode("", $parts);
|
|
||||||
} else {
|
|
||||||
$seed = $args[2];
|
|
||||||
}
|
}
|
||||||
|
$seed = (int)implode("", $parts);
|
||||||
unset($args[0], $args[1], $args[2]);
|
unset($args[0], $args[1], $args[2]);
|
||||||
$options = json_decode($args[3], true);
|
$options = json_decode($args[3], true);
|
||||||
if (!is_array($options)) {
|
if (!is_array($options)) {
|
||||||
|
@ -198,77 +171,34 @@ class Main extends PluginBase implements Listener {
|
||||||
return true;
|
return true;
|
||||||
break;
|
break;
|
||||||
case "worldtp":
|
case "worldtp":
|
||||||
if (!$sender instanceof Player) {
|
if(isset($args[0])) {
|
||||||
$sender->sendMessage(TextFormat::RED . 'You can\'t use this command');
|
if(is_null($this->getServer()->getLevelByName($args[0]))) {
|
||||||
return true;
|
|
||||||
}
|
|
||||||
/** @var Player $sender */
|
|
||||||
if (isset($args[0])) {
|
|
||||||
if (is_null($this->getServer()->getLevelByName($args[0]))) {
|
|
||||||
$this->getServer()->loadLevel($args[0]);
|
$this->getServer()->loadLevel($args[0]);
|
||||||
if (is_null($this->getServer()->getLevelByName($args[0]))) {
|
if(is_null($this->getServer()->getLevelByName($args[0]))) {
|
||||||
$sender->sendMessage("Could not find level {$args[0]}.");
|
$sender->sendMessage("Could not find level {$args[0]}.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$sender->teleport(Position::fromObject($sender, $this->getServer()->getLevelByName($args[0])));
|
$sender->teleport(\pocketmine\level\Position::fromObject($sender, $this->getServer()->getLevelByName($args[0])));
|
||||||
$sender->sendMessage("§aTeleporting to {$args[0]}...");
|
$sender->sendMessage("§aTeleporting to {$args[0]}...");
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'structure': {
|
case 'temple':{
|
||||||
if (!$sender instanceof Player) {
|
if($sender instanceof ConsoleCommandSender) return false;
|
||||||
$sender->sendMessage(TextFormat::RED . 'You can\'t use this command');
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
/** @var Player $sender */
|
/** @var Player $sender */
|
||||||
if (isset($args[0])) {
|
|
||||||
switch ($args[0]) {
|
|
||||||
case 'temple': {
|
|
||||||
$temple = new Temple();
|
$temple = new Temple();
|
||||||
$temple->placeObject($sender->getLevel(), $sender->x, $sender->y, $sender->z, new Random(microtime()));
|
$temple->placeObject($sender->getLevel(), $sender->x, $sender->y, $sender->z, new Random(microtime()));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
case 'fallen': {
|
|
||||||
$temple = new FallenTree(new OakTree());
|
|
||||||
$temple->placeObject($sender->getLevel(), $sender->x, $sender->y, $sender->z);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 'igloo': {
|
|
||||||
$temple = new Igloo();
|
|
||||||
$temple->placeObject($sender->getLevel(), $sender->x, $sender->y, $sender->z, new Random(microtime()));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 'well': {
|
|
||||||
$temple = new Well();
|
|
||||||
$temple->placeObject($sender->getLevel(), $sender->x, $sender->y, $sender->z, new Random(microtime()));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 'sakura': {
|
|
||||||
$temple = new SakuraTree();
|
|
||||||
$temple->placeObject($sender->getLevel(), $sender->x, $sender->y, $sender->z, new Random(microtime()));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default: {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$sender->sendMessage(implode(', ', ['temple', 'fallen', 'igloo', 'well', 'sakura']));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generates a(semi) random seed.
|
* Generates a (semi) random seed.
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
public function generateRandomSeed(): int {
|
public function generateRandomSeed(): int {
|
||||||
|
@ -276,12 +206,12 @@ class Main extends PluginBase implements Listener {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Registers a forest type.
|
* Registers a forest from a tree class
|
||||||
* @param $name string
|
*
|
||||||
* @param $treeClass string
|
* @param string $name
|
||||||
|
* @param string $treeClass
|
||||||
* @param array $infos
|
* @param array $infos
|
||||||
* @return bool
|
* @return bool
|
||||||
* @params $infos Array(temperature, rainfall)
|
|
||||||
*/
|
*/
|
||||||
public function registerForest(string $name, string $treeClass, array $infos): bool {
|
public function registerForest(string $name, string $treeClass, array $infos): bool {
|
||||||
if (!@class_exists($treeClass))
|
if (!@class_exists($treeClass))
|
||||||
|
@ -293,60 +223,70 @@ class Main extends PluginBase implements Listener {
|
||||||
return BetterForest::registerForest($name, $treeClass, $infos);
|
return BetterForest::registerForest($name, $treeClass, $infos);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks when a player attempts to open a loot chest which is not created yet
|
* Checks when a chunk populates to populate chests back
|
||||||
|
*
|
||||||
|
* @param ChunkPopulateEvent $event
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function onChunkPopulate(ChunkPopulateEvent $event) {
|
||||||
|
$cfg = new Config(LootTable::getPluginFolder() . "processingLoots.json", Config::JSON);
|
||||||
|
foreach ($cfg->getAll() as $key => $value) {
|
||||||
|
list($x, $y, $z) = explode(";", $key);
|
||||||
|
if ($value["saveAs"] == "chest" && $event->getLevel()->getBlockIdAt($x, $y, $z) == Block::AIR) {
|
||||||
|
$event->getLevel()->setBlockIdAt($x, $y, $z, Block::CHEST);
|
||||||
|
} else {
|
||||||
|
$cfg->remove($key);
|
||||||
|
$cfg->save();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks when a player touches an ungenerated chest to generate it.
|
||||||
|
*
|
||||||
* @param PlayerInteractEvent $event
|
* @param PlayerInteractEvent $event
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function onInteract(PlayerInteractEvent $event) {
|
public function onInteract(PlayerInteractEvent $event) {
|
||||||
if (($block = $event->getBlock())->getId() !== Block::CHEST || $event->getAction() !== PlayerInteractEvent::RIGHT_CLICK_BLOCK) return;
|
$cfg = new Config(LootTable::getPluginFolder() . "processingLoots.json", Config::JSON);
|
||||||
$this->generateLootChest($block);
|
if ($event->getBlock()->getId() !== Block::CHEST) return;
|
||||||
}
|
if (!$cfg->exists($event->getBlock()->getX() . ";" . $event->getBlock()->getY() . ";" . $event->getBlock()->getZ())) return;
|
||||||
|
|
||||||
/**
|
|
||||||
* Fills a chest with loot
|
|
||||||
* @param Block $block
|
|
||||||
* @param Random|null $random
|
|
||||||
*/
|
|
||||||
static public function generateLootChest(Block $block, Random $random = null) {
|
|
||||||
if (!$block instanceof Chest) return;
|
|
||||||
$tile = $block->getLevel()->getTile($block);
|
|
||||||
if (is_null($tile)) {
|
|
||||||
//TODO new tile, but no loot, because we don't know which type of loot chest this is
|
|
||||||
$nbt = new CompoundTag("", [
|
$nbt = new CompoundTag("", [
|
||||||
|
new ListTag("Items", []),
|
||||||
new StringTag("id", Tile::CHEST),
|
new StringTag("id", Tile::CHEST),
|
||||||
new IntTag("x", (int)$block->x),
|
new IntTag("x", $event->getBlock()->x),
|
||||||
new IntTag("y", (int)$block->y),
|
new IntTag("y", $event->getBlock()->y),
|
||||||
new IntTag("z", (int)$block->z)
|
new IntTag("z", $event->getBlock()->z)
|
||||||
]);
|
]);
|
||||||
$tile = new TileChest($block->getLevel(), $nbt);
|
/** @var Chest $chest */
|
||||||
$tile->spawnToAll();
|
$chest = Tile::createTile(Tile::CHEST, $event->getBlock()->getLevel(), $nbt);
|
||||||
return;
|
$chest->setName("§k(Fake)§r Minecart chest");
|
||||||
}
|
LootTable::fillChest($chest->getInventory(), $event->getBlock());
|
||||||
if (!$tile instanceof TileChest) return;
|
|
||||||
//Check if lootchest (or already generated loot)
|
|
||||||
if (!isset($tile->namedtag->generateLoot)) return;
|
|
||||||
$table = new LootTable($config = new Config(self::getInstance()->getDataFolder() . 'addon\\' . $tile->namedtag->generateLoot . '.json', Config::DETECT, []));
|
|
||||||
$size = $tile->getInventory()->getSize();
|
|
||||||
$loot = $table->getRandomLoot($random);
|
|
||||||
$items = array_pad($loot, $size, Item::get(0));
|
|
||||||
shuffle($items);
|
|
||||||
$tile->getInventory()->setContents($items);
|
|
||||||
unset($tile->namedtag->generateLoot);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Main
|
* Checks when a players breaks an ungenerated chest to generate it.
|
||||||
*/
|
*
|
||||||
static public function getInstance() {
|
|
||||||
return self::$instance;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Checks when a player breaks a loot chest which is not created yet
|
|
||||||
* @param BlockBreakEvent $event
|
* @param BlockBreakEvent $event
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function onBlockBreak(BlockBreakEvent $event) {
|
public function onBlockBreak(BlockBreakEvent $event) {
|
||||||
if (($block = $event->getBlock())->getId() !== Block::CHEST) return;
|
$cfg = new Config(LootTable::getPluginFolder() . "processingLoots.json", Config::JSON);
|
||||||
$this->generateLootChest($block);
|
if ($event->getBlock()->getId() !== Block::CHEST) return;
|
||||||
|
if (!$cfg->exists($event->getBlock()->getX() . ";" . $event->getBlock()->getY() . ";" . $event->getBlock()->getZ())) return;
|
||||||
|
$nbt = new CompoundTag("", [
|
||||||
|
new ListTag("Items", []),
|
||||||
|
new StringTag("id", Tile::CHEST),
|
||||||
|
new IntTag("x", $event->getBlock()->x),
|
||||||
|
new IntTag("y", $event->getBlock()->y),
|
||||||
|
new IntTag("z", $event->getBlock()->z)
|
||||||
|
]);
|
||||||
|
/** @var Chest $chest */
|
||||||
|
$chest = Tile::createTile(Tile::CHEST, $event->getBlock()->getLevel(), $nbt);
|
||||||
|
$chest->setName("§k(Fake)§r Minecart chest");
|
||||||
|
LootTable::fillChest($chest->getInventory(), $event->getBlock());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,23 +8,29 @@
|
||||||
* \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\
|
* \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\
|
||||||
* \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/
|
* \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/
|
||||||
* Tomorrow's pocketmine generator.
|
* Tomorrow's pocketmine generator.
|
||||||
* @author Ad5001
|
* @author Ad5001 <mail@ad5001.eu>, XenialDan <https://github.com/thebigsmileXD>
|
||||||
* @link https://github.com/Ad5001/BetterGen
|
* @link https://github.com/Ad5001/BetterGen
|
||||||
|
* @category World Generator
|
||||||
|
* @api 3.0.0
|
||||||
|
* @version 1.1
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Ad5001\BetterGen\biome;
|
namespace Ad5001\BetterGen\biome;
|
||||||
|
|
||||||
use Ad5001\BetterGen\generator\BetterNormal;
|
|
||||||
use Ad5001\BetterGen\populator\CactusPopulator;
|
use Ad5001\BetterGen\populator\CactusPopulator;
|
||||||
use Ad5001\BetterGen\populator\DeadbushPopulator;
|
use Ad5001\BetterGen\populator\DeadbushPopulator;
|
||||||
use Ad5001\BetterGen\populator\SugarCanePopulator;
|
use Ad5001\BetterGen\populator\SugarCanePopulator;
|
||||||
use Ad5001\BetterGen\populator\TemplePopulator;
|
use Ad5001\BetterGen\populator\TemplePopulator;
|
||||||
use Ad5001\BetterGen\populator\WellPopulator;
|
use Ad5001\BetterGen\populator\WellPopulator;
|
||||||
|
use Ad5001\BetterGen\generator\BetterNormal;
|
||||||
use pocketmine\block\Block;
|
use pocketmine\block\Block;
|
||||||
use pocketmine\level\generator\biome\Biome;
|
use pocketmine\level\generator\biome\Biome;
|
||||||
use pocketmine\level\generator\normal\biome\SandyBiome;
|
use pocketmine\level\generator\normal\biome\SandyBiome;
|
||||||
|
|
||||||
class BetterDesert extends SandyBiome implements Mountainable {
|
class BetterDesert extends SandyBiome implements Mountainable {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructs the class
|
||||||
|
*/
|
||||||
public function __construct() {
|
public function __construct() {
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
$deadBush = new DeadbushPopulator ();
|
$deadBush = new DeadbushPopulator ();
|
||||||
|
@ -43,11 +49,11 @@ class BetterDesert extends SandyBiome implements Mountainable {
|
||||||
|
|
||||||
$well = new WellPopulator ();
|
$well = new WellPopulator ();
|
||||||
|
|
||||||
if (!\Ad5001\BetterGen\utils\CommonUtils::in_arrayi("Cactus", BetterNormal::$options["delStruct"])) $this->addPopulator($cactus);
|
if(!\Ad5001\BetterGen\utils\CommonUtils::in_arrayi("Cactus", BetterNormal::$options["delStruct"])) $this->addPopulator($cactus);
|
||||||
if (!\Ad5001\BetterGen\utils\CommonUtils::in_arrayi("Deadbush", BetterNormal::$options["delStruct"])) $this->addPopulator($deadBush);
|
if(!\Ad5001\BetterGen\utils\CommonUtils::in_arrayi("Deadbush", BetterNormal::$options["delStruct"])) $this->addPopulator($deadBush);
|
||||||
if (!\Ad5001\BetterGen\utils\CommonUtils::in_arrayi("SugarCane", BetterNormal::$options["delStruct"])) $this->addPopulator($sugarCane);
|
if(!\Ad5001\BetterGen\utils\CommonUtils::in_arrayi("SugarCane", BetterNormal::$options["delStruct"])) $this->addPopulator($sugarCane);
|
||||||
if (!\Ad5001\BetterGen\utils\CommonUtils::in_arrayi("Temples", BetterNormal::$options["delStruct"])) $this->addPopulator($temple);
|
if(!\Ad5001\BetterGen\utils\CommonUtils::in_arrayi("Temples", BetterNormal::$options["delStruct"])) $this->addPopulator($temple);
|
||||||
if (!\Ad5001\BetterGen\utils\CommonUtils::in_arrayi("Wells", BetterNormal::$options["delStruct"])) $this->addPopulator($well);
|
if(!\Ad5001\BetterGen\utils\CommonUtils::in_arrayi("Wells", BetterNormal::$options["delStruct"])) $this->addPopulator($well);
|
||||||
|
|
||||||
$this->setElevation(63, 70);
|
$this->setElevation(63, 70);
|
||||||
// $this->setElevation(66, 70);
|
// $this->setElevation(66, 70);
|
||||||
|
@ -75,14 +81,21 @@ class BetterDesert extends SandyBiome implements Mountainable {
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructs the class
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
public function getName(): string {
|
public function getName(): string {
|
||||||
return "BetterDesert";
|
return "BetterDesert";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns biome id
|
* Returns biome id
|
||||||
|
*
|
||||||
|
* @return int
|
||||||
*/
|
*/
|
||||||
public function getId() {
|
public function getId(): int {
|
||||||
return Biome::DESERT;
|
return Biome::DESERT;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -9,8 +9,11 @@
|
||||||
* \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\
|
* \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\
|
||||||
* \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/
|
* \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/
|
||||||
* Tomorrow's pocketmine generator.
|
* Tomorrow's pocketmine generator.
|
||||||
* @author Ad5001
|
* @author Ad5001 <mail@ad5001.eu>, XenialDan <https://github.com/thebigsmileXD>
|
||||||
* @link https://github.com/Ad5001/BetterGen
|
* @link https://github.com/Ad5001/BetterGen
|
||||||
|
* @category World Generator
|
||||||
|
* @api 3.0.0
|
||||||
|
* @version 1.1
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Ad5001\BetterGen\biome;
|
namespace Ad5001\BetterGen\biome;
|
||||||
|
@ -19,53 +22,75 @@ use Ad5001\BetterGen\Main;
|
||||||
use Ad5001\BetterGen\populator\BushPopulator;
|
use Ad5001\BetterGen\populator\BushPopulator;
|
||||||
use Ad5001\BetterGen\populator\FallenTreePopulator;
|
use Ad5001\BetterGen\populator\FallenTreePopulator;
|
||||||
use Ad5001\BetterGen\populator\TreePopulator;
|
use Ad5001\BetterGen\populator\TreePopulator;
|
||||||
|
use Ad5001\BetterGen\generator\BetterNormal;
|
||||||
use pocketmine\level\generator\biome\Biome;
|
use pocketmine\level\generator\biome\Biome;
|
||||||
use pocketmine\level\generator\normal\biome\ForestBiome;
|
use pocketmine\level\generator\normal\biome\ForestBiome;
|
||||||
|
|
||||||
|
|
||||||
class BetterForest extends ForestBiome implements Mountainable {
|
class BetterForest extends ForestBiome implements Mountainable {
|
||||||
|
/** @var string[] **/
|
||||||
static $types = [
|
static $types = [
|
||||||
"Oak Forest",
|
"Oak Forest",
|
||||||
"Birch Forest",
|
"Birch Forest",
|
||||||
"Sakura Forest"
|
"Sakura Forest"
|
||||||
];
|
];
|
||||||
|
/** @var int[] **/
|
||||||
static $ids = [
|
static $ids = [
|
||||||
Biome::FOREST,
|
Biome::FOREST,
|
||||||
Biome::BIRCH_FOREST,
|
Biome::BIRCH_FOREST,
|
||||||
Main::SAKURA_FOREST
|
Main::SAKURA_FOREST
|
||||||
];
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructs the class
|
||||||
|
*
|
||||||
|
* @param int $type = 0
|
||||||
|
* @param array $infos
|
||||||
|
*/
|
||||||
public function __construct($type = 0, array $infos = [0.6, 0.5]) {
|
public function __construct($type = 0, array $infos = [0.6, 0.5]) {
|
||||||
parent::__construct($type);
|
parent::__construct($type);
|
||||||
$this->clearPopulators();
|
$this->clearPopulators ();
|
||||||
|
|
||||||
$this->type = $type;
|
$this->type = $type;
|
||||||
|
|
||||||
$bush = new BushPopulator($type);
|
$bush = new BushPopulator($type);
|
||||||
$bush->setBaseAmount(10);
|
$bush->setBaseAmount(10);
|
||||||
if (!\Ad5001\BetterGen\utils\CommonUtils::in_arrayi("Bushes", BetterNormal::$options["delStruct"])) $this->addPopulator($bush);
|
if(!\Ad5001\BetterGen\utils\CommonUtils::in_arrayi("Bushes", BetterNormal::$options["delStruct"])) $this->addPopulator($bush);
|
||||||
|
|
||||||
$ft = new FallenTreePopulator($type);
|
$ft = new FallenTreePopulator($type);
|
||||||
$ft->setBaseAmount(0);
|
$ft->setBaseAmount(0);
|
||||||
$ft->setRandomAmount(4);
|
$ft->setRandomAmount(4);
|
||||||
if (!\Ad5001\BetterGen\utils\CommonUtils::in_arrayi("FallenTrees", BetterNormal::$options["delStruct"])) $this->addPopulator($ft);
|
if(!\Ad5001\BetterGen\utils\CommonUtils::in_arrayi("FallenTrees", BetterNormal::$options["delStruct"])) $this->addPopulator($ft);
|
||||||
|
|
||||||
$trees = new TreePopulator($type);
|
$trees = new TreePopulator($type);
|
||||||
$trees->setBaseAmount((null !== @constant(TreePopulator::$types[$type] . "::maxPerChunk")) ? constant(TreePopulator::$types[$type] . "::maxPerChunk") : 5);
|
$trees->setBaseAmount((null !== @constant(TreePopulator::$types[$type] . "::maxPerChunk")) ? constant(TreePopulator::$types[$type] . "::maxPerChunk") : 5);
|
||||||
if (!\Ad5001\BetterGen\utils\CommonUtils::in_arrayi("Trees", BetterNormal::$options["delStruct"])) $this->addPopulator($trees);
|
if(!\Ad5001\BetterGen\utils\CommonUtils::in_arrayi("Trees", BetterNormal::$options["delStruct"])) $this->addPopulator($trees);
|
||||||
|
|
||||||
$tallGrass = Main::isOtherNS() ? new \pocketmine\level\generator\normal\populator\TallGrass () : new \pocketmine\level\generator\populator\TallGrass();
|
$tallGrass = Main::isOtherNS() ? new \pocketmine\level\generator\normal\populator\TallGrass () : new \pocketmine\level\generator\populator\TallGrass();
|
||||||
$tallGrass->setBaseAmount(3);
|
$tallGrass->setBaseAmount(3);
|
||||||
|
|
||||||
if (!\Ad5001\BetterGen\utils\CommonUtils::in_arrayi("TallGrass", BetterNormal::$options["delStruct"])) $this->addPopulator($tallGrass);
|
if(!\Ad5001\BetterGen\utils\CommonUtils::in_arrayi("TallGrass", BetterNormal::$options["delStruct"])) $this->addPopulator($tallGrass);
|
||||||
|
|
||||||
$this->setElevation(63, 69);
|
$this->setElevation(63, 69);
|
||||||
|
|
||||||
$this->temperature = $infos[0];
|
$this->temperature = $infos[0];
|
||||||
$this->rainfall = $infos[1];
|
$this->rainfall = $infos[1];
|
||||||
}
|
}
|
||||||
|
public function getName(): string {
|
||||||
|
return str_ireplace(" ", "", self::$types[$this->type]);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Returns the ID relatively.
|
||||||
|
*
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
public function getId(): int {
|
||||||
|
return self::$ids[$this->type];
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Registers a forest
|
||||||
|
*
|
||||||
* @param string $name
|
* @param string $name
|
||||||
* @param string $treeClass
|
* @param string $treeClass
|
||||||
* @param array $infos
|
* @param array $infos
|
||||||
|
@ -78,16 +103,4 @@ class BetterForest extends ForestBiome implements Mountainable {
|
||||||
Main::register(Main::SAKURA_FOREST + (count(self::$types) - 2), new BetterForest(count(self::$types) - 1, $infos));
|
Main::register(Main::SAKURA_FOREST + (count(self::$types) - 2), new BetterForest(count(self::$types) - 1, $infos));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getName() {
|
|
||||||
return str_ireplace(" ", "", self::$types[$this->type]);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the ID relatively.
|
|
||||||
* @return int
|
|
||||||
*/
|
|
||||||
public function getId() {
|
|
||||||
return self::$ids[$this->type];
|
|
||||||
}
|
|
||||||
}
|
}
|
|
@ -8,21 +8,29 @@
|
||||||
* \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\
|
* \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\
|
||||||
* \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/
|
* \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/
|
||||||
* Tomorrow's pocketmine generator.
|
* Tomorrow's pocketmine generator.
|
||||||
* @author Ad5001
|
* @author Ad5001 <mail@ad5001.eu>, XenialDan <https://github.com/thebigsmileXD>
|
||||||
* @link https://github.com/Ad5001/BetterGen
|
* @link https://github.com/Ad5001/BetterGen
|
||||||
|
* @category World Generator
|
||||||
|
* @api 3.0.0
|
||||||
|
* @version 1.1
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Ad5001\BetterGen\biome;
|
namespace Ad5001\BetterGen\biome;
|
||||||
|
|
||||||
use Ad5001\BetterGen\Main;
|
use Ad5001\BetterGen\Main;
|
||||||
use Ad5001\BetterGen\populator\IglooPopulator;
|
use Ad5001\BetterGen\populator\IglooPopulator;
|
||||||
|
use Ad5001\BetterGen\generator\BetterNormal;
|
||||||
use pocketmine\block\Block;
|
use pocketmine\block\Block;
|
||||||
use pocketmine\level\generator\biome\Biome;
|
use pocketmine\level\generator\biome\Biome;
|
||||||
use pocketmine\level\generator\normal\biome\SnowyBiome;
|
use pocketmine\level\generator\normal\biome\SnowyBiome;
|
||||||
|
|
||||||
class BetterIcePlains extends SnowyBiome implements Mountainable {
|
class BetterIcePlains extends SnowyBiome implements Mountainable {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructs the class
|
||||||
|
*/
|
||||||
public function __construct() {
|
public function __construct() {
|
||||||
parent::__construct();
|
parent::__construct ();
|
||||||
$this->setGroundCover([
|
$this->setGroundCover([
|
||||||
Block::get(Block::SNOW, 0),
|
Block::get(Block::SNOW, 0),
|
||||||
Block::get(Block::GRASS, 0),
|
Block::get(Block::GRASS, 0),
|
||||||
|
@ -30,12 +38,12 @@ class BetterIcePlains extends SnowyBiome implements Mountainable {
|
||||||
Block::get(Block::DIRT, 0),
|
Block::get(Block::DIRT, 0),
|
||||||
Block::get(Block::DIRT, 0)
|
Block::get(Block::DIRT, 0)
|
||||||
]);
|
]);
|
||||||
if (!\Ad5001\BetterGen\utils\CommonUtils::in_arrayi("Igloos", BetterNormal::$options["delStruct"])) $this->addPopulator(new IglooPopulator ());
|
if(!\Ad5001\BetterGen\utils\CommonUtils::in_arrayi("Igloos", BetterNormal::$options["delStruct"])) $this->addPopulator(new IglooPopulator ());
|
||||||
|
|
||||||
$tallGrass = Main::isOtherNS() ? new \pocketmine\level\generator\normal\populator\TallGrass() : new \pocketmine\level\generator\populator\TallGrass();
|
$tallGrass = Main::isOtherNS() ? new \pocketmine\level\generator\normal\populator\TallGrass() : new \pocketmine\level\generator\populator\TallGrass();
|
||||||
$tallGrass->setBaseAmount(3);
|
$tallGrass->setBaseAmount(3);
|
||||||
|
|
||||||
if (!\Ad5001\BetterGen\utils\CommonUtils::in_arrayi("TallGrass", BetterNormal::$options["delStruct"])) $this->addPopulator($tallGrass);
|
if(!\Ad5001\BetterGen\utils\CommonUtils::in_arrayi("TallGrass", BetterNormal::$options["delStruct"])) $this->addPopulator($tallGrass);
|
||||||
|
|
||||||
$this->setElevation(63, 74);
|
$this->setElevation(63, 74);
|
||||||
|
|
||||||
|
@ -43,15 +51,21 @@ class BetterIcePlains extends SnowyBiome implements Mountainable {
|
||||||
$this->rainfall = 0.8;
|
$this->rainfall = 0.8;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getName() {
|
/**
|
||||||
|
* Returns the biome name
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getName(): string {
|
||||||
return "BetterIcePlains";
|
return "BetterIcePlains";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the biomes' id.
|
* Returns the biomes' id.
|
||||||
|
*
|
||||||
* @return int biome id
|
* @return int biome id
|
||||||
*/
|
*/
|
||||||
public function getId() {
|
public function getId(): int {
|
||||||
return Biome::ICE_PLAINS;
|
return Biome::ICE_PLAINS;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -8,8 +8,11 @@
|
||||||
* \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\
|
* \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\
|
||||||
* \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/
|
* \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/
|
||||||
* Tomorrow's pocketmine generator.
|
* Tomorrow's pocketmine generator.
|
||||||
* @author Ad5001
|
* @author Ad5001 <mail@ad5001.eu>, XenialDan <https://github.com/thebigsmileXD>
|
||||||
* @link https://github.com/Ad5001/BetterGen
|
* @link https://github.com/Ad5001/BetterGen
|
||||||
|
* @category World Generator
|
||||||
|
* @api 3.0.0
|
||||||
|
* @version 1.1
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Ad5001\BetterGen\biome;
|
namespace Ad5001\BetterGen\biome;
|
||||||
|
@ -19,11 +22,16 @@ use Ad5001\BetterGen\populator\CactusPopulator;
|
||||||
use Ad5001\BetterGen\populator\DeadbushPopulator;
|
use Ad5001\BetterGen\populator\DeadbushPopulator;
|
||||||
use Ad5001\BetterGen\populator\SugarCanePopulator;
|
use Ad5001\BetterGen\populator\SugarCanePopulator;
|
||||||
use Ad5001\BetterGen\populator\TreePopulator;
|
use Ad5001\BetterGen\populator\TreePopulator;
|
||||||
|
use Ad5001\BetterGen\generator\BetterNormal;
|
||||||
use pocketmine\block\Block;
|
use pocketmine\block\Block;
|
||||||
use pocketmine\block\GoldOre;
|
use pocketmine\block\GoldOre;
|
||||||
use pocketmine\level\generator\normal\biome\SandyBiome;
|
use pocketmine\level\generator\normal\biome\SandyBiome;
|
||||||
|
|
||||||
class BetterMesa extends SandyBiome {
|
class BetterMesa extends SandyBiome {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructs the class
|
||||||
|
*/
|
||||||
public function __construct() {
|
public function __construct() {
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
$deadBush = new DeadbushPopulator ();
|
$deadBush = new DeadbushPopulator ();
|
||||||
|
@ -47,10 +55,10 @@ class BetterMesa extends SandyBiome {
|
||||||
Main::isOtherNS() ? new \pocketmine\level\generator\normal\object\OreType(new GoldOre (), 2, 8, 0, 32) : new \pocketmine\level\generator\object\OreType(new GoldOre (), 2, 8, 0, 32)
|
Main::isOtherNS() ? new \pocketmine\level\generator\normal\object\OreType(new GoldOre (), 2, 8, 0, 32) : new \pocketmine\level\generator\object\OreType(new GoldOre (), 2, 8, 0, 32)
|
||||||
]);
|
]);
|
||||||
|
|
||||||
if (!\Ad5001\BetterGen\utils\CommonUtils::in_arrayi("Cactus", BetterNormal::$options["delStruct"])) $this->addPopulator($cactus);
|
if(!\Ad5001\BetterGen\utils\CommonUtils::in_arrayi("Cactus", BetterNormal::$options["delStruct"])) $this->addPopulator($cactus);
|
||||||
if (!\Ad5001\BetterGen\utils\CommonUtils::in_arrayi("DeadBush", BetterNormal::$options["delStruct"])) $this->addPopulator($deadBush);
|
if(!\Ad5001\BetterGen\utils\CommonUtils::in_arrayi("DeadBush", BetterNormal::$options["delStruct"])) $this->addPopulator($deadBush);
|
||||||
if (!\Ad5001\BetterGen\utils\CommonUtils::in_arrayi("SugarCane", BetterNormal::$options["delStruct"])) $this->addPopulator($sugarCane);
|
if(!\Ad5001\BetterGen\utils\CommonUtils::in_arrayi("SugarCane", BetterNormal::$options["delStruct"])) $this->addPopulator($sugarCane);
|
||||||
if (!\Ad5001\BetterGen\utils\CommonUtils::in_arrayi("Ores", BetterNormal::$options["delStruct"])) $this->addPopulator($ores);
|
if(!\Ad5001\BetterGen\utils\CommonUtils::in_arrayi("Ores", BetterNormal::$options["delStruct"])) $this->addPopulator($ores);
|
||||||
|
|
||||||
$this->setElevation(80, 83);
|
$this->setElevation(80, 83);
|
||||||
// $this->setElevation(66, 70);
|
// $this->setElevation(66, 70);
|
||||||
|
@ -105,14 +113,21 @@ class BetterMesa extends SandyBiome {
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the biome name
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
public function getName(): string {
|
public function getName(): string {
|
||||||
return "BetterMesa";
|
return "BetterMesa";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns biome id
|
* Returns biome id
|
||||||
|
*
|
||||||
|
* @return int
|
||||||
*/
|
*/
|
||||||
public function getId() {
|
public function getId(): int {
|
||||||
return 39;
|
return 39;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -8,8 +8,11 @@
|
||||||
* \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\
|
* \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\
|
||||||
* \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/
|
* \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/
|
||||||
* Tomorrow's pocketmine generator.
|
* Tomorrow's pocketmine generator.
|
||||||
* @author Ad5001
|
* @author Ad5001 <mail@ad5001.eu>, XenialDan <https://github.com/thebigsmileXD>
|
||||||
* @link https://github.com/Ad5001/BetterGen
|
* @link https://github.com/Ad5001/BetterGen
|
||||||
|
* @category World Generator
|
||||||
|
* @api 3.0.0
|
||||||
|
* @version 1.1
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Ad5001\BetterGen\biome;
|
namespace Ad5001\BetterGen\biome;
|
||||||
|
@ -18,11 +21,15 @@ use Ad5001\BetterGen\Main;
|
||||||
use Ad5001\BetterGen\populator\CactusPopulator;
|
use Ad5001\BetterGen\populator\CactusPopulator;
|
||||||
use Ad5001\BetterGen\populator\DeadbushPopulator;
|
use Ad5001\BetterGen\populator\DeadbushPopulator;
|
||||||
use Ad5001\BetterGen\populator\SugarCanePopulator;
|
use Ad5001\BetterGen\populator\SugarCanePopulator;
|
||||||
|
use Ad5001\BetterGen\generator\BetterNormal;
|
||||||
use pocketmine\block\Block;
|
use pocketmine\block\Block;
|
||||||
use pocketmine\block\GoldOre;
|
use pocketmine\block\GoldOre;
|
||||||
use pocketmine\level\generator\normal\biome\SandyBiome;
|
use pocketmine\level\generator\normal\biome\SandyBiome;
|
||||||
|
|
||||||
class BetterMesaPlains extends SandyBiome {
|
class BetterMesaPlains extends SandyBiome {
|
||||||
|
/**
|
||||||
|
* Constructs the class
|
||||||
|
*/
|
||||||
public function __construct() {
|
public function __construct() {
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
$deadBush = new DeadbushPopulator ();
|
$deadBush = new DeadbushPopulator ();
|
||||||
|
@ -42,10 +49,10 @@ class BetterMesaPlains extends SandyBiome {
|
||||||
Main::isOtherNS() ? new \pocketmine\level\generator\normal\object\OreType(new GoldOre (), 2, 8, 0, 32) : new \pocketmine\level\generator\object\OreType(new GoldOre (), 2, 8, 0, 32)
|
Main::isOtherNS() ? new \pocketmine\level\generator\normal\object\OreType(new GoldOre (), 2, 8, 0, 32) : new \pocketmine\level\generator\object\OreType(new GoldOre (), 2, 8, 0, 32)
|
||||||
]);
|
]);
|
||||||
|
|
||||||
if (!\Ad5001\BetterGen\utils\CommonUtils::in_arrayi("Cactus", BetterNormal::$options["delStruct"])) $this->addPopulator($cactus);
|
if(!\Ad5001\BetterGen\utils\CommonUtils::in_arrayi("Cactus", BetterNormal::$options["delStruct"])) $this->addPopulator($cactus);
|
||||||
if (!\Ad5001\BetterGen\utils\CommonUtils::in_arrayi("DeadBush", BetterNormal::$options["delStruct"])) $this->addPopulator($deadBush);
|
if(!\Ad5001\BetterGen\utils\CommonUtils::in_arrayi("DeadBush", BetterNormal::$options["delStruct"])) $this->addPopulator($deadBush);
|
||||||
if (!\Ad5001\BetterGen\utils\CommonUtils::in_arrayi("SugarCane", BetterNormal::$options["delStruct"])) $this->addPopulator($sugarCane);
|
if(!\Ad5001\BetterGen\utils\CommonUtils::in_arrayi("SugarCane", BetterNormal::$options["delStruct"])) $this->addPopulator($sugarCane);
|
||||||
if (!\Ad5001\BetterGen\utils\CommonUtils::in_arrayi("Ores", BetterNormal::$options["delStruct"])) $this->addPopulator($ores);
|
if(!\Ad5001\BetterGen\utils\CommonUtils::in_arrayi("Ores", BetterNormal::$options["delStruct"])) $this->addPopulator($ores);
|
||||||
|
|
||||||
$this->setElevation(62, 67);
|
$this->setElevation(62, 67);
|
||||||
// $this->setElevation(66, 70);
|
// $this->setElevation(66, 70);
|
||||||
|
@ -101,14 +108,21 @@ class BetterMesaPlains extends SandyBiome {
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the name of th biome
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
public function getName(): string {
|
public function getName(): string {
|
||||||
return "BetterMesaPlains";
|
return "BetterMesaPlains";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns biome id
|
* Returns biome id
|
||||||
|
*
|
||||||
|
* @return int
|
||||||
*/
|
*/
|
||||||
public function getId() {
|
public function getId(): int {
|
||||||
return 40;
|
return 40;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -8,8 +8,11 @@
|
||||||
* \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\
|
* \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\
|
||||||
* \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/
|
* \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/
|
||||||
* Tomorrow's pocketmine generator.
|
* Tomorrow's pocketmine generator.
|
||||||
* @author Ad5001
|
* @author Ad5001 <mail@ad5001.eu>, XenialDan <https://github.com/thebigsmileXD>
|
||||||
* @link https://github.com/Ad5001/BetterGen
|
* @link https://github.com/Ad5001/BetterGen
|
||||||
|
* @category World Generator
|
||||||
|
* @api 3.0.0
|
||||||
|
* @version 1.1
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Ad5001\BetterGen\biome;
|
namespace Ad5001\BetterGen\biome;
|
||||||
|
@ -18,8 +21,11 @@ use pocketmine\block\Block;
|
||||||
use pocketmine\level\generator\biome\Biome;
|
use pocketmine\level\generator\biome\Biome;
|
||||||
|
|
||||||
class BetterRiver extends Biome {
|
class BetterRiver extends Biome {
|
||||||
|
/**
|
||||||
|
* Constructs the class
|
||||||
|
*/
|
||||||
public function __construct() {
|
public function __construct() {
|
||||||
$this->clearPopulators();
|
$this->clearPopulators ();
|
||||||
|
|
||||||
$this->setGroundCover([
|
$this->setGroundCover([
|
||||||
Block::get(Block::SAND, 0),
|
Block::get(Block::SAND, 0),
|
||||||
|
@ -41,14 +47,21 @@ class BetterRiver extends Biome {
|
||||||
$this->rainfall = 0.7;
|
$this->rainfall = 0.7;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getName() {
|
/**
|
||||||
|
* Returns the biome name
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getName(): string {
|
||||||
return "BetterRiver";
|
return "BetterRiver";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the ID relatively.
|
* Returns the biome id
|
||||||
|
*
|
||||||
|
* @return int
|
||||||
*/
|
*/
|
||||||
public function getId() {
|
public function getId(): int {
|
||||||
return Biome::RIVER;
|
return Biome::RIVER;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -8,8 +8,11 @@
|
||||||
* \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\
|
* \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\
|
||||||
* \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/
|
* \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/
|
||||||
* Tomorrow's pocketmine generator.
|
* Tomorrow's pocketmine generator.
|
||||||
* @author Ad5001
|
* @author Ad5001 <mail@ad5001.eu>, XenialDan <https://github.com/thebigsmileXD>
|
||||||
* @link https://github.com/Ad5001/BetterGen
|
* @link https://github.com/Ad5001/BetterGen
|
||||||
|
* @category World Generator
|
||||||
|
* @api 3.0.0
|
||||||
|
* @version 1.1
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Ad5001\BetterGen\biome;
|
namespace Ad5001\BetterGen\biome;
|
||||||
|
|
|
@ -8,10 +8,12 @@
|
||||||
* \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\
|
* \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\
|
||||||
* \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/
|
* \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/
|
||||||
* Tomorrow's pocketmine generator.
|
* Tomorrow's pocketmine generator.
|
||||||
* @author Ad5001
|
* @author Ad5001 <mail@ad5001.eu>, XenialDan <https://github.com/thebigsmileXD>
|
||||||
* @link https://github.com/Ad5001/BetterGen
|
* @link https://github.com/Ad5001/BetterGen
|
||||||
|
* @category World Generator
|
||||||
|
* @api 3.0.0
|
||||||
|
* @version 1.1
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Ad5001\BetterGen\generator;
|
namespace Ad5001\BetterGen\generator;
|
||||||
|
|
||||||
use pocketmine\level\generator\biome\Biome;
|
use pocketmine\level\generator\biome\Biome;
|
||||||
|
@ -22,17 +24,26 @@ use pocketmine\utils\Random;
|
||||||
class BetterBiomeSelector extends BiomeSelector {
|
class BetterBiomeSelector extends BiomeSelector {
|
||||||
|
|
||||||
/** @var Biome */
|
/** @var Biome */
|
||||||
private $fallback;
|
protected $fallback;
|
||||||
|
|
||||||
/** @var Simplex */
|
/** @var Simplex */
|
||||||
private $temperature;
|
protected $temperature;
|
||||||
/** @var Simplex */
|
/** @var Simplex */
|
||||||
private $rainfall;
|
protected $rainfall;
|
||||||
|
|
||||||
/** @var Biome[] */
|
/** @var Biome[] */
|
||||||
private $biomes = [];
|
protected $biomes = [ ];
|
||||||
private $lookup;
|
|
||||||
|
|
||||||
|
/** @var callable */
|
||||||
|
protected $lookup;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructs the class
|
||||||
|
*
|
||||||
|
* @param Random $random
|
||||||
|
* @param callable $lookup
|
||||||
|
* @param Biome $fallback
|
||||||
|
*/
|
||||||
public function __construct(Random $random, callable $lookup, Biome $fallback) {
|
public function __construct(Random $random, callable $lookup, Biome $fallback) {
|
||||||
parent::__construct($random, $lookup, $fallback);
|
parent::__construct($random, $lookup, $fallback);
|
||||||
$this->fallback = $fallback;
|
$this->fallback = $fallback;
|
||||||
|
@ -41,23 +52,56 @@ class BetterBiomeSelector extends BiomeSelector {
|
||||||
$this->rainfall = new Simplex($random, 2, 1 / 16, 1 / 512);
|
$this->rainfall = new Simplex($random, 2, 1 / 16, 1 / 512);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Inherited function
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
public function recalculate() {
|
public function recalculate() {
|
||||||
} // Using our own system, No need for that
|
} // Using our own system, No need for that
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds a biome to the selector. Don't do this directly. Use BetterNormal::registerBiome
|
||||||
|
*
|
||||||
|
* @internal This method is called by BetterNormal::registerBiome
|
||||||
|
* @param Biome $biome
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
public function addBiome(Biome $biome) {
|
public function addBiome(Biome $biome) {
|
||||||
$this->biomes[$biome->getId()] = $biome;
|
$this->biomes[$biome->getId ()] = $biome;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Returns the temperature from a location
|
||||||
*
|
*
|
||||||
* @param
|
* @param int $x
|
||||||
* $x
|
* @param int $z
|
||||||
* @param
|
* @return void
|
||||||
* $z
|
*/
|
||||||
|
public function getTemperature($x, $z) {
|
||||||
|
return ($this->temperature->noise2D($x, $z, true) + 1) / 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the rainfall from a location
|
||||||
|
*
|
||||||
|
* @param int $x
|
||||||
|
* @param int $z
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function getRainfall($x, $z) {
|
||||||
|
return ($this->rainfall->noise2D($x, $z, true) + 1) / 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Picks a biome relative to $x and $z
|
||||||
|
*
|
||||||
|
* @param int $x
|
||||||
|
* @param int $z
|
||||||
*
|
*
|
||||||
* @return Biome
|
* @return Biome
|
||||||
*/
|
*/
|
||||||
public function pickBiome($x, $z) {
|
public function pickBiome($x, $z): Biome {
|
||||||
$temperature = ($this->getTemperature($x, $z));
|
$temperature = ($this->getTemperature($x, $z));
|
||||||
$rainfall = ($this->getRainfall($x, $z));
|
$rainfall = ($this->getRainfall($x, $z));
|
||||||
|
|
||||||
|
@ -65,12 +109,4 @@ class BetterBiomeSelector extends BiomeSelector {
|
||||||
$b = (($biomeId instanceof Biome) ? $biomeId : ($this->biomes[$biomeId] ?? $this->fallback));
|
$b = (($biomeId instanceof Biome) ? $biomeId : ($this->biomes[$biomeId] ?? $this->fallback));
|
||||||
return $b;
|
return $b;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getTemperature($x, $z) {
|
|
||||||
return ($this->temperature->noise2D($x, $z, true) + 1) / 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getRainfall($x, $z) {
|
|
||||||
return ($this->rainfall->noise2D($x, $z, true) + 1) / 2;
|
|
||||||
}
|
|
||||||
}
|
}
|
|
@ -8,8 +8,11 @@
|
||||||
* \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\
|
* \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\
|
||||||
* \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/
|
* \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/
|
||||||
* Tomorrow's pocketmine generator.
|
* Tomorrow's pocketmine generator.
|
||||||
* @author Ad5001
|
* @author Ad5001 <mail@ad5001.eu>, XenialDan <https://github.com/thebigsmileXD>
|
||||||
* @link https://github.com/Ad5001/BetterGen
|
* @link https://github.com/Ad5001/BetterGen
|
||||||
|
* @category World Generator
|
||||||
|
* @api 3.0.0
|
||||||
|
* @version 1.1
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Ad5001\BetterGen\generator;
|
namespace Ad5001\BetterGen\generator;
|
||||||
|
@ -26,6 +29,7 @@ use Ad5001\BetterGen\populator\CavePopulator;
|
||||||
use Ad5001\BetterGen\populator\FloatingIslandPopulator;
|
use Ad5001\BetterGen\populator\FloatingIslandPopulator;
|
||||||
use Ad5001\BetterGen\populator\MineshaftPopulator;
|
use Ad5001\BetterGen\populator\MineshaftPopulator;
|
||||||
use Ad5001\BetterGen\populator\RavinePopulator;
|
use Ad5001\BetterGen\populator\RavinePopulator;
|
||||||
|
use Ad5001\BetterGen\populator\DungeonPopulator;
|
||||||
use pocketmine\block\Block;
|
use pocketmine\block\Block;
|
||||||
use pocketmine\block\CoalOre;
|
use pocketmine\block\CoalOre;
|
||||||
use pocketmine\block\DiamondOre;
|
use pocketmine\block\DiamondOre;
|
||||||
|
@ -59,72 +63,63 @@ class BetterNormal extends Generator {
|
||||||
Block::WATER,
|
Block::WATER,
|
||||||
Block::STILL_WATER
|
Block::STILL_WATER
|
||||||
];
|
];
|
||||||
public static $biomes = [];
|
/** @var BetterBiomeSelector */
|
||||||
|
protected $selector;
|
||||||
|
/** @var Level */
|
||||||
|
protected $level;
|
||||||
|
/** @var Random */
|
||||||
|
protected $random;
|
||||||
|
/** @var Populator[] */
|
||||||
|
protected $populators = [ ];
|
||||||
|
/** @var Populator[] */
|
||||||
|
protected $generationPopulators = [ ];
|
||||||
|
/** @var Biome[][] */
|
||||||
|
public static $biomes = [ ];
|
||||||
/** @var Biome[] */
|
/** @var Biome[] */
|
||||||
public static $biomeById = [];
|
public static $biomeById = [ ];
|
||||||
public static $levels = [];
|
/** @var Level[] */
|
||||||
protected static $GAUSSIAN_KERNEL = null;
|
public static $levels = [ ];
|
||||||
|
/** @var int[][] */
|
||||||
|
protected static $GAUSSIAN_KERNEL = null; // From main class
|
||||||
|
/** @var int */
|
||||||
protected static $SMOOTH_SIZE = 2;
|
protected static $SMOOTH_SIZE = 2;
|
||||||
protected static $options = [
|
/** @var mixed[][] */
|
||||||
|
public static $options = [
|
||||||
"delBio" => [
|
"delBio" => [
|
||||||
],
|
],
|
||||||
"delStruct" => [
|
"delStruct" => [
|
||||||
"Lakes"
|
"Lakes"
|
||||||
]
|
]
|
||||||
];
|
];
|
||||||
/** @var BetterBiomeSelector */
|
/** @var int */
|
||||||
protected $selector;
|
|
||||||
/** @var Level */
|
|
||||||
protected $level;
|
|
||||||
/** @var Random */
|
|
||||||
protected $random; // From main class
|
|
||||||
protected $populators = [];
|
|
||||||
protected $generationPopulators = [];
|
|
||||||
protected $waterHeight = 63;
|
protected $waterHeight = 63;
|
||||||
private $noiseBase;
|
protected $noiseBase;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs the class
|
* Picks a biome by X and Z
|
||||||
* @param $options array
|
*
|
||||||
|
* @param $x int
|
||||||
|
* @param $z int
|
||||||
|
* @return Biome
|
||||||
*/
|
*/
|
||||||
public function __construct(array $options = []) {
|
public function pickBiome($x, $z): Biome {
|
||||||
self::$options["preset"] = $options["preset"];
|
$hash = $x * 2345803 ^ $z * 9236449 ^ $this->level->getSeed ();
|
||||||
$options = (array)json_decode($options["preset"]);
|
$hash *= $hash + 223;
|
||||||
if (isset($options["delBio"])) {
|
$xNoise = $hash >> 20 & 3;
|
||||||
if (is_string($options["de"])) $options["delBio"] = explode(",", $options["delBio"]);
|
$zNoise = $hash >> 22 & 3;
|
||||||
if (count($options["delBio"]) !== 0) {
|
if ($xNoise == 3) {
|
||||||
self::$options["delBio"] = $options["delBio"];
|
$xNoise = 1;
|
||||||
}
|
|
||||||
}
|
|
||||||
if (isset($options["delStruct"])) {
|
|
||||||
if (is_string($options["delStruct"])) $options["delStruct"] = explode(",", $options["delStruct"]);
|
|
||||||
if (count($options["delStruct"]) !== 0) {
|
|
||||||
self::$options["delStruct"] = $options["delStruct"];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (self::$GAUSSIAN_KERNEL === null) {
|
|
||||||
self::generateKernel();
|
|
||||||
}
|
}
|
||||||
|
if ($zNoise == 3) {
|
||||||
|
$zNoise = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
$b = $this->selector->pickBiome($x + $xNoise - 1, $z + $zNoise - 1);
|
||||||
* Generates the generation kernel based on smooth size (here 2)
|
if ($b instanceof Mountainable && $this->random->nextBoundedInt(1000) < 3) {
|
||||||
*/
|
$b = clone $b;
|
||||||
private static function generateKernel() {
|
// $b->setElevation($b->getMinElevation () + (50 * $b->getMinElevation () / 100), $b->getMaxElevation () + (50 * $b->getMinElevation () / 100));
|
||||||
self::$GAUSSIAN_KERNEL = [];
|
|
||||||
|
|
||||||
$bellSize = 1 / self::$SMOOTH_SIZE;
|
|
||||||
$bellHeight = 2 * self::$SMOOTH_SIZE;
|
|
||||||
|
|
||||||
for ($sx = -self::$SMOOTH_SIZE; $sx <= self::$SMOOTH_SIZE; $sx++) {
|
|
||||||
self::$GAUSSIAN_KERNEL[$sx + self::$SMOOTH_SIZE] = [];
|
|
||||||
|
|
||||||
for ($sz = -self::$SMOOTH_SIZE; $sz <= self::$SMOOTH_SIZE; $sz++) {
|
|
||||||
$bx = $bellSize * $sx;
|
|
||||||
$bz = $bellSize * $sz;
|
|
||||||
self::$GAUSSIAN_KERNEL[$sx + self::$SMOOTH_SIZE] [$sz + self::$SMOOTH_SIZE] = $bellHeight * exp(-($bx * $bx + $bz * $bz) / 2);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
return $b;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -139,9 +134,9 @@ protected static $GAUSSIAN_KERNEL = null;
|
||||||
|
|
||||||
self::$levels[] = $level;
|
self::$levels[] = $level;
|
||||||
|
|
||||||
$this->random->setSeed($this->level->getSeed());
|
$this->random->setSeed($this->level->getSeed ());
|
||||||
$this->noiseBase = new Simplex($this->random, 4, 1 / 4, 1 / 32);
|
$this->noiseBase = new Simplex($this->random, 4, 1 / 4, 1 / 32);
|
||||||
$this->random->setSeed($this->level->getSeed());
|
$this->random->setSeed($this->level->getSeed ());
|
||||||
|
|
||||||
$this->registerBiome(Biome::getBiome(Biome::OCEAN));
|
$this->registerBiome(Biome::getBiome(Biome::OCEAN));
|
||||||
$this->registerBiome(Biome::getBiome(Biome::PLAINS));
|
$this->registerBiome(Biome::getBiome(Biome::PLAINS));
|
||||||
|
@ -170,55 +165,62 @@ protected static $GAUSSIAN_KERNEL = null;
|
||||||
"getBiome"
|
"getBiome"
|
||||||
], self::getBiome(0, 0));
|
], self::getBiome(0, 0));
|
||||||
|
|
||||||
foreach (self::$biomes as $rain) {
|
foreach(self::$biomes as $rain) {
|
||||||
foreach ($rain as $biome) {
|
foreach($rain as $biome) {
|
||||||
$this->selector->addBiome($biome);
|
$this->selector->addBiome($biome);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->selector->recalculate();
|
$this->selector->recalculate ();
|
||||||
|
|
||||||
$cover = Main::isOtherNS() ? new \pocketmine\level\generator\normal\populator\GroundCover() : new \pocketmine\level\generator\populator\GroundCover();
|
$cover = Main::isOtherNS() ? new \pocketmine\level\generator\normal\populator\GroundCover() : new \pocketmine\level\generator\populator\GroundCover();
|
||||||
$this->generationPopulators[] = $cover;
|
$this->generationPopulators[] = $cover;
|
||||||
|
|
||||||
if (!\Ad5001\BetterGen\utils\CommonUtils::in_arrayi("Lakes", self::$options["delStruct"])) {
|
if(!\Ad5001\BetterGen\utils\CommonUtils::in_arrayi("Lakes", self::$options["delStruct"])) {
|
||||||
$lake = new LakePopulator();
|
$lake = new LakePopulator();
|
||||||
$lake->setBaseAmount(0);
|
$lake->setBaseAmount(0);
|
||||||
$lake->setRandomAmount(1);
|
$lake->setRandomAmount(1);
|
||||||
$this->generationPopulators[] = $lake;
|
$this->generationPopulators[] = $lake;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!\Ad5001\BetterGen\utils\CommonUtils::in_arrayi("Caves", self::$options["delStruct"])) {
|
if(!\Ad5001\BetterGen\utils\CommonUtils::in_arrayi("Caves", self::$options["delStruct"])) {
|
||||||
$cave = new CavePopulator ();
|
$cave = new CavePopulator ();
|
||||||
$cave->setBaseAmount(0);
|
$cave->setBaseAmount(0);
|
||||||
$cave->setRandomAmount(2);
|
$cave->setRandomAmount(2);
|
||||||
$this->generationPopulators[] = $cave;
|
$this->generationPopulators[] = $cave;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!\Ad5001\BetterGen\utils\CommonUtils::in_arrayi("Ravines", self::$options["delStruct"])) {
|
if(!\Ad5001\BetterGen\utils\CommonUtils::in_arrayi("Ravines", self::$options["delStruct"])) {
|
||||||
$ravine = new RavinePopulator ();
|
$ravine = new RavinePopulator ();
|
||||||
$ravine->setBaseAmount(0);
|
$ravine->setBaseAmount(0);
|
||||||
$ravine->setRandomAmount(51);
|
$ravine->setRandomAmount(51);
|
||||||
$this->generationPopulators[] = $ravine;
|
$this->generationPopulators[] = $ravine;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!\Ad5001\BetterGen\utils\CommonUtils::in_arrayi("Mineshafts", self::$options["delStruct"])) {
|
if(!\Ad5001\BetterGen\utils\CommonUtils::in_arrayi("Mineshafts", self::$options["delStruct"])) {
|
||||||
$mineshaft = new MineshaftPopulator ();
|
$mineshaft = new MineshaftPopulator ();
|
||||||
$mineshaft->setBaseAmount(0);
|
$mineshaft->setBaseAmount(0);
|
||||||
$mineshaft->setRandomAmount(102);
|
$mineshaft->setRandomAmount(102);
|
||||||
$this->populators[] = $mineshaft;
|
$this->populators[] = $mineshaft;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!\Ad5001\BetterGen\utils\CommonUtils::in_arrayi("FloatingIslands", self::$options["delStruct"])) {
|
if(!\Ad5001\BetterGen\utils\CommonUtils::in_arrayi("FloatingIslands", self::$options["delStruct"])) {
|
||||||
$fisl = new FloatingIslandPopulator();
|
$fisl = new FloatingIslandPopulator();
|
||||||
$fisl->setBaseAmount(0);
|
$fisl->setBaseAmount(0);
|
||||||
$fisl->setRandomAmount(132);
|
$fisl->setRandomAmount(132);
|
||||||
$this->populators[] = $fisl;
|
$this->populators[] = $fisl;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!\Ad5001\BetterGen\utils\CommonUtils::in_arrayi("Ores", self::$options["delStruct"])) {
|
if(!\Ad5001\BetterGen\utils\CommonUtils::in_arrayi("Dungeons", self::$options["delStruct"])) {
|
||||||
|
$dungeon = new DungeonPopulator();
|
||||||
|
$dungeon->setBaseAmount(0);
|
||||||
|
$dungeon->setRandomAmount(20);
|
||||||
|
$this->populators[] = $dungeon;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!\Ad5001\BetterGen\utils\CommonUtils::in_arrayi("Ores", self::$options["delStruct"])) {
|
||||||
$ores = Main::isOtherNS() ? new \pocketmine\level\generator\normal\populator\Ore() : new \pocketmine\level\generator\populator\Ore();
|
$ores = Main::isOtherNS() ? new \pocketmine\level\generator\normal\populator\Ore() : new \pocketmine\level\generator\populator\Ore();
|
||||||
if (Main::isOtherNS()) $ores->setOreTypes([
|
if(Main::isOtherNS()) $ores->setOreTypes([
|
||||||
new OreType2(new CoalOre (), 20, 16, 0, 128),
|
new OreType2(new CoalOre (), 20, 16, 0, 128),
|
||||||
new OreType2(new IronOre (), 20, 8, 0, 64),
|
new OreType2(new IronOre (), 20, 8, 0, 64),
|
||||||
new OreType2(new RedstoneOre (), 8, 7, 0, 16),
|
new OreType2(new RedstoneOre (), 8, 7, 0, 16),
|
||||||
|
@ -228,7 +230,7 @@ protected static $GAUSSIAN_KERNEL = null;
|
||||||
new OreType2(new Dirt (), 20, 32, 0, 128),
|
new OreType2(new Dirt (), 20, 32, 0, 128),
|
||||||
new OreType2(new Gravel (), 10, 16, 0, 128)
|
new OreType2(new Gravel (), 10, 16, 0, 128)
|
||||||
]);
|
]);
|
||||||
if (!Main::isOtherNS()) $ores->setOreTypes([
|
if(!Main::isOtherNS()) $ores->setOreTypes([
|
||||||
new OreType(new CoalOre (), 20, 16, 0, 128),
|
new OreType(new CoalOre (), 20, 16, 0, 128),
|
||||||
new OreType(new IronOre (), 20, 8, 0, 64),
|
new OreType(new IronOre (), 20, 8, 0, 64),
|
||||||
new OreType(new RedstoneOre (), 8, 7, 0, 16),
|
new OreType(new RedstoneOre (), 8, 7, 0, 16),
|
||||||
|
@ -242,19 +244,19 @@ protected static $GAUSSIAN_KERNEL = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* Adds a biome to the selector. Do not use this method directly use Main::registerBiome which registers it properly
|
* Adds a biome to the selector. Do not use this method directly use Main::registerBiome which registers it properly
|
||||||
* @param $biome Biome
|
* @param $biome Biome
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public static function registerBiome(Biome $biome): bool {
|
public static function registerBiome(Biome $biome): bool {
|
||||||
if (\Ad5001\BetterGen\utils\CommonUtils::in_arrayi($biome->getName(), self::$options["delBio"])) {
|
if(\Ad5001\BetterGen\utils\CommonUtils::in_arrayi($biome->getName(), self::$options["delBio"])) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
foreach (self::$levels as $lvl) if (isset($lvl->selector)) $lvl->selector->addBiome($biome); // If no selector created, it would cause errors. These will be added when selectoes
|
foreach(self::$levels as $lvl) if(isset($lvl->selector)) $lvl->selector->addBiome($biome); // If no selector created, it would cause errors. These will be added when selectoes
|
||||||
if (!isset(self::$biomes[(string)$biome->getRainfall()])) self::$biomes[( string)$biome->getRainfall()] = [];
|
if (! isset(self::$biomes[(string) $biome->getRainfall ()])) self::$biomes[( string) $biome->getRainfall ()] = [ ];
|
||||||
self::$biomes[( string)$biome->getRainfall()] [( string)$biome->getTemperature()] = $biome;
|
self::$biomes[( string) $biome->getRainfall ()] [( string) $biome->getTemperature ()] = $biome;
|
||||||
ksort(self::$biomes[( string)$biome->getRainfall()]);
|
ksort(self::$biomes[( string) $biome->getRainfall ()]);
|
||||||
ksort(self::$biomes);
|
ksort(self::$biomes);
|
||||||
self::$biomeById[$biome->getId()] = $biome;
|
self::$biomeById[$biome->getId()] = $biome;
|
||||||
return true;
|
return true;
|
||||||
|
@ -262,13 +264,14 @@ protected static $GAUSSIAN_KERNEL = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a biome by temperature
|
* Returns a biome by temperature
|
||||||
|
*
|
||||||
* @param $temperature float
|
* @param $temperature float
|
||||||
* @param $rainfall float
|
* @param $rainfall float
|
||||||
*/
|
*/
|
||||||
public static function getBiome($temperature, $rainfall) {
|
public static function getBiome($temperature, $rainfall) {
|
||||||
$ret = null;
|
$ret = null;
|
||||||
if (!isset(self::$biomes[( string)round($rainfall, 1)])) {
|
if (! isset(self::$biomes[( string) round($rainfall, 1)])) {
|
||||||
while (!isset(self::$biomes[( string)round($rainfall, 1)])) {
|
while(! isset(self::$biomes[( string) round($rainfall, 1)])) {
|
||||||
if (abs($rainfall - round($rainfall, 1)) >= 0.05)
|
if (abs($rainfall - round($rainfall, 1)) >= 0.05)
|
||||||
$rainfall += 0.1;
|
$rainfall += 0.1;
|
||||||
if (abs($rainfall - round($rainfall, 1)) < 0.05)
|
if (abs($rainfall - round($rainfall, 1)) < 0.05)
|
||||||
|
@ -279,9 +282,9 @@ protected static $GAUSSIAN_KERNEL = null;
|
||||||
$rainfall = 0.9;
|
$rainfall = 0.9;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$b = self::$biomes[( string)round($rainfall, 1)];
|
$b = self::$biomes[( string) round($rainfall, 1)];
|
||||||
foreach ($b as $t => $biome) {
|
foreach($b as $t => $biome) {
|
||||||
if ($temperature <= (float)$t) {
|
if ($temperature <= (float) $t) {
|
||||||
$ret = $biome;
|
$ret = $biome;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -292,33 +295,44 @@ protected static $GAUSSIAN_KERNEL = null;
|
||||||
return $ret;
|
return $ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a biome by its id
|
||||||
|
*
|
||||||
|
* @param int $id
|
||||||
|
* @return Biome
|
||||||
|
*/
|
||||||
|
public function getBiomeById(int $id): Biome {
|
||||||
|
return self::$biomeById[$id] ?? self::$biomeById[Biome::OCEAN];
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generates a chunk.
|
* Generates a chunk.
|
||||||
|
*
|
||||||
* Cloning method to make it work with new methods.
|
* Cloning method to make it work with new methods.
|
||||||
* @param $chunkX int
|
* @param int $chunkX
|
||||||
* @param $chunkZ int
|
* @param int $chunkZ
|
||||||
*/
|
*/
|
||||||
public function generateChunk($chunkX, $chunkZ) {
|
public function generateChunk($chunkX, $chunkZ) {
|
||||||
|
|
||||||
$this->random->setSeed(0xdeadbeef ^ ($chunkX << 8) ^ $chunkZ ^ $this->level->getSeed());
|
$this->random->setSeed(0xdeadbeef ^ ($chunkX << 8) ^ $chunkZ ^ $this->level->getSeed ());
|
||||||
|
|
||||||
$noise = Generator::getFastNoise3D($this->noiseBase, 16, 128, 16, 4, 8, 4, $chunkX * 16, 0, $chunkZ * 16);
|
$noise = Generator::getFastNoise3D($this->noiseBase, 16, 128, 16, 4, 8, 4, $chunkX * 16, 0, $chunkZ * 16);
|
||||||
|
|
||||||
$chunk = $this->level->getChunk($chunkX, $chunkZ);
|
$chunk = $this->level->getChunk($chunkX, $chunkZ);
|
||||||
|
|
||||||
$biomeCache = [];
|
$biomeCache = [ ];
|
||||||
|
|
||||||
for ($x = 0; $x < 16; $x++) {
|
for($x = 0; $x < 16; $x++) {
|
||||||
for ($z = 0; $z < 16; $z++) {
|
for($z = 0; $z < 16; $z++) {
|
||||||
$minSum = 0;
|
$minSum = 0;
|
||||||
$maxSum = 0;
|
$maxSum = 0;
|
||||||
$weightSum = 0;
|
$weightSum = 0;
|
||||||
|
|
||||||
$biome = $this->pickBiome($chunkX * 16 + $x, $chunkZ * 16 + $z);
|
$biome = $this->pickBiome($chunkX * 16 + $x, $chunkZ * 16 + $z);
|
||||||
$chunk->setBiomeId($x, $z, $biome->getId());
|
$chunk->setBiomeId($x, $z, $biome->getId ());
|
||||||
|
|
||||||
for ($sx = -self::$SMOOTH_SIZE; $sx <= self::$SMOOTH_SIZE; $sx++) {
|
for($sx = - self::$SMOOTH_SIZE; $sx <= self::$SMOOTH_SIZE; $sx++) {
|
||||||
for ($sz = -self::$SMOOTH_SIZE; $sz <= self::$SMOOTH_SIZE; $sz++) {
|
for($sz = - self::$SMOOTH_SIZE; $sz <= self::$SMOOTH_SIZE; $sz++) {
|
||||||
|
|
||||||
$weight = self::$GAUSSIAN_KERNEL[$sx + self::$SMOOTH_SIZE] [$sz + self::$SMOOTH_SIZE];
|
$weight = self::$GAUSSIAN_KERNEL[$sx + self::$SMOOTH_SIZE] [$sz + self::$SMOOTH_SIZE];
|
||||||
|
|
||||||
|
@ -332,8 +346,8 @@ protected static $GAUSSIAN_KERNEL = null;
|
||||||
$biomeCache[$index] = $adjacent = $this->pickBiome($chunkX * 16 + $x + $sx, $chunkZ * 16 + $z + $sz);
|
$biomeCache[$index] = $adjacent = $this->pickBiome($chunkX * 16 + $x + $sx, $chunkZ * 16 + $z + $sz);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$minSum += ($adjacent->getMinElevation() - 1) * $weight;
|
$minSum += ($adjacent->getMinElevation () - 1) * $weight;
|
||||||
$maxSum += $adjacent->getMaxElevation() * $weight;
|
$maxSum += $adjacent->getMaxElevation () * $weight;
|
||||||
|
|
||||||
$weightSum += $weight;
|
$weightSum += $weight;
|
||||||
}
|
}
|
||||||
|
@ -344,8 +358,8 @@ protected static $GAUSSIAN_KERNEL = null;
|
||||||
|
|
||||||
$smoothHeight = ($maxSum - $minSum) / 2;
|
$smoothHeight = ($maxSum - $minSum) / 2;
|
||||||
|
|
||||||
for ($y = 0; $y < 128; $y++) {
|
for($y = 0; $y < 128; $y++) {
|
||||||
if ($y < 3 || ($y < 5 && $this->random->nextBoolean())) {
|
if ($y < 3 || ($y < 5 && $this->random->nextBoolean ())) {
|
||||||
$chunk->setBlockId($x, $y, $z, Block::BEDROCK);
|
$chunk->setBlockId($x, $y, $z, Block::BEDROCK);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -360,53 +374,29 @@ protected static $GAUSSIAN_KERNEL = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($this->generationPopulators as $populator) {
|
foreach($this->generationPopulators as $populator) {
|
||||||
$populator->populate($this->level, $chunkX, $chunkZ, $this->random);
|
$populator->populate($this->level, $chunkX, $chunkZ, $this->random);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Picks a biome by X and Z
|
* Populates a chunk
|
||||||
* @param $x int
|
*
|
||||||
* @param $z int
|
* @param int $chunkX
|
||||||
* @return Biome
|
* @param int $chunkZ
|
||||||
*/
|
* @return void
|
||||||
public function pickBiome($x, $z) {
|
|
||||||
$hash = $x * 2345803 ^ $z * 9236449 ^ $this->level->getSeed();
|
|
||||||
$hash *= $hash + 223;
|
|
||||||
$xNoise = $hash >> 20 & 3;
|
|
||||||
$zNoise = $hash >> 22 & 3;
|
|
||||||
if ($xNoise == 3) {
|
|
||||||
$xNoise = 1;
|
|
||||||
}
|
|
||||||
if ($zNoise == 3) {
|
|
||||||
$zNoise = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
$b = $this->selector->pickBiome($x + $xNoise - 1, $z + $zNoise - 1);
|
|
||||||
if ($b instanceof Mountainable && $this->random->nextBoundedInt(1000) < 3) {
|
|
||||||
$b = clone $b;
|
|
||||||
// $b->setElevation($b->getMinElevation () + (50 * $b->getMinElevation () / 100), $b->getMaxElevation () + (50 * $b->getMinElevation () / 100));
|
|
||||||
}
|
|
||||||
return $b;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Populates a chunk.
|
|
||||||
* @param $chunkX int
|
|
||||||
* @param $chunk2 int
|
|
||||||
*/
|
*/
|
||||||
public function populateChunk($chunkX, $chunkZ) {
|
public function populateChunk($chunkX, $chunkZ) {
|
||||||
$this->random->setSeed(0xdeadbeef ^ ($chunkX << 8) ^ $chunkZ ^ $this->level->getSeed());
|
$this->random->setSeed(0xdeadbeef ^ ($chunkX << 8) ^ $chunkZ ^ $this->level->getSeed ());
|
||||||
foreach ($this->populators as $populator) {
|
foreach($this->populators as $populator) {
|
||||||
$populator->populate($this->level, $chunkX, $chunkZ, $this->random);
|
$populator->populate($this->level, $chunkX, $chunkZ, $this->random);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Filling lava (lakes & rivers underground)...
|
// Filling lava (lakes & rivers underground)...
|
||||||
for ($x = $chunkX; $x < $chunkX + 16; $x++)
|
for($x = $chunkX; $x < $chunkX + 16; $x ++)
|
||||||
for ($z = $chunkZ; $z < $chunkZ + 16; $z++)
|
for($z = $chunkZ; $z < $chunkZ + 16; $z ++)
|
||||||
for ($y = 1; $y < 11; $y++) {
|
for($y = 1; $y < 11; $y ++) {
|
||||||
if (!in_array($this->level->getBlockIdAt($x, $y, $z), self::NOT_OVERWRITABLE))
|
if (! in_array($this->level->getBlockIdAt($x, $y, $z), self::NOT_OVERWRITABLE))
|
||||||
$this->level->setBlockIdAt($x, $y, $z, Block::LAVA);
|
$this->level->setBlockIdAt($x, $y, $z, Block::LAVA);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -416,51 +406,98 @@ protected static $GAUSSIAN_KERNEL = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a biome by its id
|
* Constructs the class
|
||||||
* @param $id int
|
*
|
||||||
* @return Biome
|
* @param array $options
|
||||||
*/
|
*/
|
||||||
public function getBiomeById(int $id): Biome {
|
public function __construct(array $options = []) {
|
||||||
return self::$biomeById[$id] ?? self::$biomeById[Biome::OCEAN];
|
self::$options["preset"] = $options["preset"];
|
||||||
|
$options = (array) json_decode($options["preset"]);
|
||||||
|
if(isset($options["delBio"])) {
|
||||||
|
if(is_string($options["delBio"])) $options["delBio"] = explode(",", $options["delBio"]);
|
||||||
|
if(count($options["delBio"]) !== 0) {
|
||||||
|
self::$options["delBio"] = $options["delBio"];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(isset($options["delStruct"])) {
|
||||||
|
if(is_string($options["delStruct"])) $options["delStruct"] = explode(",", $options["delStruct"]);
|
||||||
|
if(count($options["delStruct"]) !== 0) {
|
||||||
|
self::$options["delStruct"] = $options["delStruct"];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (self::$GAUSSIAN_KERNEL === null) {
|
||||||
|
self::generateKernel ();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns the name of the generator
|
/**
|
||||||
|
* Generates the generation kernel based on smooth size (here 2)
|
||||||
|
*/
|
||||||
|
protected static function generateKernel() {
|
||||||
|
self::$GAUSSIAN_KERNEL = [ ];
|
||||||
|
|
||||||
public function getName() {
|
$bellSize = 1 / self::$SMOOTH_SIZE;
|
||||||
|
$bellHeight = 2 * self::$SMOOTH_SIZE;
|
||||||
|
|
||||||
|
for($sx = - self::$SMOOTH_SIZE; $sx <= self::$SMOOTH_SIZE; $sx++) {
|
||||||
|
self::$GAUSSIAN_KERNEL[$sx + self::$SMOOTH_SIZE] = [ ];
|
||||||
|
|
||||||
|
for($sz = - self::$SMOOTH_SIZE; $sz <= self::$SMOOTH_SIZE; $sz++) {
|
||||||
|
$bx = $bellSize * $sx;
|
||||||
|
$bz = $bellSize * $sz;
|
||||||
|
self::$GAUSSIAN_KERNEL[$sx + self::$SMOOTH_SIZE] [$sz + self::$SMOOTH_SIZE] = $bellHeight * exp(- ($bx * $bx + $bz * $bz) / 2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the name of the generator
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getName(): string {
|
||||||
return "betternormal";
|
return "betternormal";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gives the generators settings.
|
* Gives the generators settings.
|
||||||
|
*
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function getSettings(): array {
|
public function getSettings(): array {
|
||||||
return self::$options;
|
return self::$options;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getSpawn() {
|
/**
|
||||||
|
* Returns spawn location
|
||||||
|
*
|
||||||
|
* @return Vector3
|
||||||
|
*/
|
||||||
|
public function getSpawn(): Vector3 {
|
||||||
return new Vector3(127.5, 128, 127.5);
|
return new Vector3(127.5, 128, 127.5);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a safe spawn location
|
* Returns a safe spawn location
|
||||||
|
*
|
||||||
|
* @return Vector3
|
||||||
*/
|
*/
|
||||||
public function getSafeSpawn() {
|
public function getSafeSpawn() {
|
||||||
return new Vector3(127.5, $this->getHighestWorkableBlock(127, 127), 127.5);
|
return new Vector3(127.5, $this->getHighestWorkableBlock(127, 127), 127.5);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* Gets the top block (y) on an x and z axes
|
* Gets the top block (y) on an x and z axes
|
||||||
* @param $x int
|
* @param $x int
|
||||||
* @param $z int
|
* @param $z int
|
||||||
*/
|
*/
|
||||||
protected function getHighestWorkableBlock($x, $z) {
|
protected function getHighestWorkableBlock($x, $z) {
|
||||||
for ($y = Level::Y_MAX - 1; $y > 0; --$y) {
|
for($y = Level::Y_MAX - 1; $y > 0; -- $y) {
|
||||||
$b = $this->level->getBlockIdAt($x, $y, $z);
|
$b = $this->level->getBlockIdAt($x, $y, $z);
|
||||||
if ($b === Block::DIRT or $b === Block::GRASS or $b === Block::PODZOL) {
|
if ($b === Block::DIRT or $b === Block::GRASS or $b === Block::PODZOL) {
|
||||||
break;
|
break;
|
||||||
} elseif ($b !== 0 and $b !== Block::SNOW_LAYER) {
|
} elseif ($b !== 0 and $b !== Block::SNOW_LAYER) {
|
||||||
return -1;
|
return - 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,163 +8,121 @@
|
||||||
* \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\
|
* \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\
|
||||||
* \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/
|
* \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/
|
||||||
* Tomorrow's pocketmine generator.
|
* Tomorrow's pocketmine generator.
|
||||||
* @author Ad5001
|
* @author Ad5001 <mail@ad5001.eu>, XenialDan <https://github.com/thebigsmileXD>
|
||||||
* @link https://github.com/Ad5001/BetterGen
|
* @link https://github.com/Ad5001/BetterGen
|
||||||
|
* @category World Generator
|
||||||
|
* @api 3.0.0
|
||||||
|
* @version 1.1
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Ad5001\BetterGen\loot;
|
namespace Ad5001\BetterGen\loot;
|
||||||
|
|
||||||
use Ad5001\BetterGen\Main;
|
use pocketmine\inventory\BaseInventory;
|
||||||
use pocketmine\item\Item;
|
use pocketmine\item\Item;
|
||||||
use pocketmine\item\Tool;
|
use pocketmine\math\Vector3;
|
||||||
|
use pocketmine\nbt\NBT;
|
||||||
use pocketmine\utils\Config;
|
use pocketmine\utils\Config;
|
||||||
use pocketmine\utils\Random;
|
use pocketmine\utils\Random;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This class is used for loot setting.
|
||||||
|
* Please note that they AREN'T as powerful as PC ones due to some implementations limitations.
|
||||||
|
* Loot table format:
|
||||||
|
* {
|
||||||
|
* "max": Max number of loots (storable amount)
|
||||||
|
* "example": {
|
||||||
|
* "percentage": Chance of appearing(in percent)
|
||||||
|
* "minCount": Minimal count
|
||||||
|
* "maxCount": Maximal count
|
||||||
|
* "id": Id of the item
|
||||||
|
* "data": Item damage
|
||||||
|
* "tags": {"display": {"Name": "Example NBT data"}}. This parameter is optional
|
||||||
|
* "minStacks": If chosen, the minimum amount of stacks that can be found
|
||||||
|
* "maxStacks": If chosen the maximum number of stacks that can be chosen
|
||||||
|
* }
|
||||||
|
* }
|
||||||
|
*/
|
||||||
class LootTable {
|
class LootTable {
|
||||||
|
const LOOT_NAMES = [
|
||||||
|
"temple",
|
||||||
|
"igloo",
|
||||||
|
"mineshaft"
|
||||||
|
];
|
||||||
|
const LOOT_SAVE = [
|
||||||
|
"chest",
|
||||||
|
"chest",
|
||||||
|
"chest"
|
||||||
|
];
|
||||||
|
const LOOT_DESERT_TEMPLE = 0;
|
||||||
|
const LOOT_IGLOO = 1;
|
||||||
|
const LOOT_MINESHAFT = 2;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var null|Config The lootfile (.json) thats used
|
* Asynchronous method to build a loot table
|
||||||
|
*
|
||||||
|
* @param Vector3 $place
|
||||||
|
* @param int $type
|
||||||
|
* @param Random $random
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
private $lootFile = null;
|
public static function buildLootTable(Vector3 $place, int $type, Random $random) {
|
||||||
|
if($place->y < 1) return; // Making sure sometimes that it doesn't write for nothing
|
||||||
/**
|
$cfg = new Config(self::getPluginFolder() . "processingLoots.json", Config::JSON);
|
||||||
* LootTable constructor.
|
$lootsFromJson = json_decode(file_get_contents(self::getResourcesFolder() . "loots/" . self::LOOT_NAMES[$type] . ".json"), true);
|
||||||
* @param Config $lootFile
|
$loots =[];
|
||||||
*/
|
foreach($lootsFromJson as $loot) {
|
||||||
public function __construct(Config $lootFile) {
|
if(is_array($loot) && $random->nextBoundedInt(101) < $loot["percentage"])
|
||||||
$this->lootFile = $lootFile;
|
$loots[] = $loot;
|
||||||
|
}
|
||||||
|
if($lootsFromJson["max"] < count($loots)) {
|
||||||
|
while($lootsFromJson["max"] < count($loots))
|
||||||
|
unset($loots[array_rand($loots)]);
|
||||||
|
}
|
||||||
|
$loots["saveAs"] = self::LOOT_SAVE[$type];
|
||||||
|
$cfg->set($place->x . ";" . $place->y . ";" . $place->z, $loots);
|
||||||
|
$cfg->save();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Public function to generate loot. A {@link: \pocketmine\utils\Random} can be passed. Serves as file reader + sub-table loader
|
* Synchronous inventory filling method
|
||||||
* Do _NOT_ use this in the source, use LootTable::createLoot instead
|
*
|
||||||
* @param Random|null $random
|
* @param BaseInventory $inv
|
||||||
* @return Item[]
|
* @param Vector3 $pos
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function getRandomLoot(Random $random = null) {
|
public static function fillChest(BaseInventory $inv, Vector3 $pos) {
|
||||||
if (is_null($random)) $random = new Random();
|
$cfg = new Config(self::getPluginFolder() . "processingLoots.json", Config::JSON);
|
||||||
|
if($cfg->exists($pos->x . ";" . $pos->y . ";" . $pos->z)) {
|
||||||
|
$loots = $cfg->get($pos->x . ";" . $pos->y . ";" . $pos->z);
|
||||||
$items = [];
|
$items = [];
|
||||||
foreach ($this->lootFile->get("pools") as $rolls) {
|
foreach($loots as $loot) {
|
||||||
if (isset($rolls["rolls"]["min"]) && isset($rolls["rolls"]["max"])) $maxrolls = $random->nextRange($rolls["rolls"]["min"], $rolls["rolls"]["max"]);
|
if(!is_array($loot)) continue;
|
||||||
else $maxrolls = $rolls["rolls"];//TODO: $rolls["conditions"] //Example: looting swords
|
$randCount = rand($loot["minStacks"], $loot["maxStacks"]);
|
||||||
while ($maxrolls > 0) {
|
for($i = 0; $i <= $randCount; $i++) {
|
||||||
$array = [];
|
$rand = rand(0, count($loots));
|
||||||
$maxrolls--;
|
$items[$rand] = Item::get($loot["id"], $loot["data"], rand($loot["minCount"], $loot["maxCount"]));
|
||||||
foreach ($rolls["entries"] as $index => $entries) {
|
if(isset($loot["tags"])) $items[$rand]->setCompoundTag(NBT::parseJSON($loot["tags"]));
|
||||||
$array[] = $entries["weight"]??1;
|
|
||||||
}
|
|
||||||
$val = $rolls["entries"][$this->getRandomWeightedElement($array)];
|
|
||||||
//typecheck
|
|
||||||
if ($val["type"] == "loot_table") {
|
|
||||||
$loottable = new LootTable(new Config(Main::getInstance()->getDataFolder() . 'addon\\' . $val["name"] . ".json", Config::DETECT, []));
|
|
||||||
$items = array_merge($items, $loottable->getRandomLoot($random));
|
|
||||||
unset($loottable);
|
|
||||||
} elseif ($val["type"] == "item") {
|
|
||||||
//name fix
|
|
||||||
$val["name"] = self::fixItemName($val["name"]);
|
|
||||||
$item = Item::fromString($val["name"]);
|
|
||||||
if (isset($val["functions"])) {
|
|
||||||
foreach ($val["functions"] as $function) {
|
|
||||||
switch ($functionname = $function["function"]) {
|
|
||||||
case "set_damage": {
|
|
||||||
if ($item instanceof Tool) $item->setDamage($random->nextRange($function["damage"]["min"] * $item->getMaxDurability(), $function["damage"]["max"] * $item->getMaxDurability()));
|
|
||||||
else $item->setDamage($random->nextRange($function["damage"]["min"], $function["damage"]["max"]));
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case "set_data": {
|
|
||||||
//fish fix, blame mojang
|
|
||||||
if ($item->getId() == Item::RAW_FISH) {
|
|
||||||
switch ($function["data"]) {
|
|
||||||
case 1:
|
|
||||||
$item = Item::get(Item::RAW_SALMON, $item->getDamage(), $item->getCount(), $item->getCompoundTag());
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
$item = Item::get(Item::CLOWN_FISH, $item->getDamage(), $item->getCount(), $item->getCompoundTag());
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
$item = Item::get(Item::PUFFER_FISH, $item->getDamage(), $item->getCount(), $item->getCompoundTag());
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
} else $item->setDamage($function["data"]);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case "set_count": {
|
|
||||||
$item->setCount($random->nextRange($function["count"]["min"], $function["count"]["max"]));
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case "furnace_smelt": {
|
|
||||||
/* TODO
|
|
||||||
Mostly bound to conditions (burning)
|
|
||||||
"conditions": [
|
|
||||||
{
|
|
||||||
"condition": "entity_properties",
|
|
||||||
"entity": "this",
|
|
||||||
"properties": {
|
|
||||||
"on_fire": true
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
$inv->setContents($items);
|
||||||
*/
|
$cfg->remove($pos->x . ";" . $pos->y . ";" . $pos->z);
|
||||||
|
$cfg->save();
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
case "enchant_randomly": {
|
|
||||||
//TODO
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case "enchant_with_levels": {
|
|
||||||
//TODO
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case "looting_enchant": {
|
|
||||||
//TODO
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
assert("Unknown looting table function $functionname, skipping");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$items[] = $item;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return $items;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TODO: Make Random::class actually useful here.
|
* Returns the plugins folder.
|
||||||
* @param array $weightedValues
|
* @return string
|
||||||
* @return mixed
|
|
||||||
*/
|
*/
|
||||||
private function getRandomWeightedElement(array $weightedValues) {
|
public static function getPluginFolder(): string {
|
||||||
$array = array();
|
return getcwd() . DIRECTORY_SEPARATOR . "plugins" . DIRECTORY_SEPARATOR . "BetterGen" . DIRECTORY_SEPARATOR;
|
||||||
foreach ($weightedValues as $key => $weight) {
|
|
||||||
$array = array_merge(array_fill(0, $weight, $key), $array);
|
|
||||||
}
|
|
||||||
return $array[array_rand($array)];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fixes the item names because #BlameMojang for not changing the id's from PC -> PE
|
* Returns the resources folder.
|
||||||
* @param $name
|
* @return string
|
||||||
* @return mixed
|
|
||||||
*/
|
*/
|
||||||
private static function fixItemName($name) {
|
public static function getResourcesFolder(): string {
|
||||||
switch ($name) {
|
return self::getPluginFolder() . "resources" . DIRECTORY_SEPARATOR;
|
||||||
case 'minecraft:horsearmoriron':
|
|
||||||
$name = 'minecraft:iron_horse_armor';
|
|
||||||
break;
|
|
||||||
case 'minecraft:horsearmorgold':
|
|
||||||
$name = 'minecraft:gold_horse_armor';
|
|
||||||
break;
|
|
||||||
case 'minecraft:horsearmordiamond':
|
|
||||||
$name = 'minecraft:diamond_horse_armor';
|
|
||||||
break;
|
|
||||||
default: {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return $name;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -8,8 +8,9 @@
|
||||||
* \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\
|
* \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\
|
||||||
* \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/
|
* \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/
|
||||||
* Tomorrow's pocketmine generator.
|
* Tomorrow's pocketmine generator.
|
||||||
* @author Ad5001
|
* @author Ad5001 <mail@ad5001.eu>, XenialDan <https://github.com/thebigsmileXD>
|
||||||
* @link https://github.com/Ad5001/BetterGen
|
* @link https://github.com/Ad5001/BetterGen
|
||||||
|
* @version 1.1
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Ad5001\BetterGen\populator;
|
namespace Ad5001\BetterGen\populator;
|
||||||
|
@ -26,19 +27,11 @@ abstract class AmountPopulator extends Populator {
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the amount based on random
|
* Sets the random addition amount
|
||||||
* @param $random Random
|
* @param $amount int
|
||||||
*/
|
*/
|
||||||
public function getAmount(Random $random) {
|
public function setRandomAmount(int $amount) {
|
||||||
return $this->baseAmount + $random->nextRange(0, $this->randomAmount + 1);
|
$this->randomAmount = $amount;
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the base amount
|
|
||||||
* @return int
|
|
||||||
*/
|
|
||||||
public function getBaseAmount(): int {
|
|
||||||
return $this->baseAmount;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -49,19 +42,31 @@ abstract class AmountPopulator extends Populator {
|
||||||
$this->baseAmount = $amount;
|
$this->baseAmount = $amount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the amount based on random
|
||||||
|
*
|
||||||
|
* @param Random $random
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
public function getAmount(Random $random) {
|
||||||
|
return $this->baseAmount + $random->nextRange(0, $this->randomAmount + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns base amount
|
||||||
|
*
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
public function getBaseAmount(): int {
|
||||||
|
return $this->baseAmount;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the random additional amount
|
* Returns the random additional amount
|
||||||
|
*
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
public function getRandomAmount(): int {
|
public function getRandomAmount(): int {
|
||||||
return $this->randomAmount;
|
return $this->randomAmount;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the random addition amount
|
|
||||||
* @param $amount int
|
|
||||||
*/
|
|
||||||
public function setRandomAmount(int $amount) {
|
|
||||||
$this->randomAmount = $amount;
|
|
||||||
}
|
|
||||||
}
|
}
|
|
@ -8,8 +8,11 @@
|
||||||
* \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\
|
* \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\
|
||||||
* \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/
|
* \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/
|
||||||
* Tomorrow's pocketmine generator.
|
* Tomorrow's pocketmine generator.
|
||||||
* @author Ad5001
|
* @author Ad5001 <mail@ad5001.eu>, XenialDan <https://github.com/thebigsmileXD>
|
||||||
* @link https://github.com/Ad5001/BetterGen
|
* @link https://github.com/Ad5001/BetterGen
|
||||||
|
* @category World Generator
|
||||||
|
* @api 3.0.0
|
||||||
|
* @version 1.1
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Ad5001\BetterGen\populator;
|
namespace Ad5001\BetterGen\populator;
|
||||||
|
@ -23,27 +26,31 @@ use pocketmine\utils\Random;
|
||||||
class BushPopulator extends AmountPopulator {
|
class BushPopulator extends AmountPopulator {
|
||||||
/** @var ChunkManager */
|
/** @var ChunkManager */
|
||||||
protected $level;
|
protected $level;
|
||||||
|
/** @var int */
|
||||||
protected $type;
|
protected $type;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs the class
|
* Constructs the class
|
||||||
* @param $type int
|
*
|
||||||
|
* @param int $type
|
||||||
*/
|
*/
|
||||||
public function __construct($type = 0) {
|
public function __construct($type = 0) {
|
||||||
$this->type = $type;
|
$this->type = $type;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Populate the chunk
|
* Populates the chunk
|
||||||
* @param $level pocketmine\level\ChunkManager
|
*
|
||||||
* @param $chunkX int
|
* @param ChunkManager $level
|
||||||
* @param $chunkZ int
|
* @param int $chunkX
|
||||||
* @param $random pocketmine\utils\Random
|
* @param int $chunkZ
|
||||||
|
* @param Random $random
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function populate(ChunkManager $level, $chunkX, $chunkZ, Random $random) {
|
public function populate(ChunkManager $level, $chunkX, $chunkZ, Random $random) {
|
||||||
$this->level = $level;
|
$this->level = $level;
|
||||||
$amount = $this->getAmount($random);
|
$amount = $this->getAmount($random);
|
||||||
for ($i = 0; $i < $amount; $i++) {
|
for($i = 0; $i < $amount; $i++) {
|
||||||
$x = $random->nextRange($chunkX << 4, ($chunkX << 4) + 15);
|
$x = $random->nextRange($chunkX << 4, ($chunkX << 4) + 15);
|
||||||
$z = $random->nextRange($chunkZ << 4, ($chunkZ << 4) + 15);
|
$z = $random->nextRange($chunkZ << 4, ($chunkZ << 4) + 15);
|
||||||
$y = $this->getHighestWorkableBlock($x, $z);
|
$y = $this->getHighestWorkableBlock($x, $z);
|
||||||
|
@ -57,17 +64,19 @@ class BushPopulator extends AmountPopulator {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the top block (y) on an x and z axes
|
* Gets the highest workable block
|
||||||
* @param $x int
|
*
|
||||||
* @param $z int
|
* @param int $x
|
||||||
|
* @param int $z
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
protected function getHighestWorkableBlock($x, $z) {
|
protected function getHighestWorkableBlock($x, $z) {
|
||||||
for ($y = Level::Y_MAX - 1; $y > 0; --$y) {
|
for($y = Level::Y_MAX - 1; $y > 0; -- $y) {
|
||||||
$b = $this->level->getBlockIdAt($x, $y, $z);
|
$b = $this->level->getBlockIdAt($x, $y, $z);
|
||||||
if ($b === Block::DIRT or $b === Block::GRASS or $b === Block::PODZOL) {
|
if ($b === Block::DIRT or $b === Block::GRASS or $b === Block::PODZOL) {
|
||||||
break;
|
break;
|
||||||
} elseif ($b !== 0 and $b !== Block::SNOW_LAYER) {
|
} elseif ($b !== 0 and $b !== Block::SNOW_LAYER) {
|
||||||
return -1;
|
return - 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,8 +8,11 @@
|
||||||
* \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\
|
* \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\
|
||||||
* \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/
|
* \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/
|
||||||
* Tomorrow's pocketmine generator.
|
* Tomorrow's pocketmine generator.
|
||||||
* @author Ad5001
|
* @author Ad5001 <mail@ad5001.eu>, XenialDan <https://github.com/thebigsmileXD>
|
||||||
* @link https://github.com/Ad5001/BetterGen
|
* @link https://github.com/Ad5001/BetterGen
|
||||||
|
* @category World Generator
|
||||||
|
* @api 3.0.0
|
||||||
|
* @version 1.1
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
@ -24,7 +27,6 @@ use pocketmine\utils\Random;
|
||||||
class CactusPopulator extends AmountPopulator {
|
class CactusPopulator extends AmountPopulator {
|
||||||
/** @var ChunkManager */
|
/** @var ChunkManager */
|
||||||
protected $level;
|
protected $level;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs the class
|
* Constructs the class
|
||||||
*/
|
*/
|
||||||
|
@ -34,17 +36,19 @@ class CactusPopulator extends AmountPopulator {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Populate the chunk
|
* Populates the chunk
|
||||||
* @param $level pocketmine\level\ChunkManager
|
*
|
||||||
* @param $chunkX int
|
* @param ChunkManager $level
|
||||||
* @param $chunkZ int
|
* @param int $chunkX
|
||||||
* @param $random pocketmine\utils\Random
|
* @param int $chunkZ
|
||||||
|
* @param Random $random
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function populate(ChunkManager $level, $chunkX, $chunkZ, Random $random) {
|
public function populate(ChunkManager $level, $chunkX, $chunkZ, Random $random) {
|
||||||
$this->level = $level;
|
$this->level = $level;
|
||||||
$amount = $this->getAmount($random);
|
$amount = $this->getAmount($random);
|
||||||
$cactus = new Cactus ();
|
$cactus = new Cactus ();
|
||||||
for ($i = 0; $i < $amount; $i++) {
|
for($i = 0; $i < $amount; $i++) {
|
||||||
$x = $random->nextRange($chunkX * 16, $chunkX * 16 + 15);
|
$x = $random->nextRange($chunkX * 16, $chunkX * 16 + 15);
|
||||||
$z = $random->nextRange($chunkZ * 16, $chunkZ * 16 + 15);
|
$z = $random->nextRange($chunkZ * 16, $chunkZ * 16 + 15);
|
||||||
$y = $this->getHighestWorkableBlock($x, $z);
|
$y = $this->getHighestWorkableBlock($x, $z);
|
||||||
|
@ -54,18 +58,21 @@ class CactusPopulator extends AmountPopulator {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the top block (y) on an x and z axes
|
* Gets the highest workable block
|
||||||
* @param $x int
|
*
|
||||||
* @param $z int
|
* @param int $x
|
||||||
|
* @param int $z
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
protected function getHighestWorkableBlock($x, $z) {
|
protected function getHighestWorkableBlock($x, $z) {
|
||||||
for ($y = Level::Y_MAX - 1; $y >= 0; --$y) {
|
for($y = Level::Y_MAX - 1; $y >= 0; -- $y) {
|
||||||
$b = $this->level->getBlockIdAt($x, $y, $z);
|
$b = $this->level->getBlockIdAt($x, $y, $z);
|
||||||
if ($b !== Block::AIR and $b !== Block::LEAVES and $b !== Block::LEAVES2) {
|
if ($b !== Block::AIR and $b !== Block::LEAVES and $b !== Block::LEAVES2) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $y === 0 ? -1 : ++$y;
|
return $y === 0 ? - 1 : ++$y;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -8,8 +8,11 @@
|
||||||
* \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\
|
* \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\
|
||||||
* \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/
|
* \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/
|
||||||
* Tomorrow's pocketmine generator.
|
* Tomorrow's pocketmine generator.
|
||||||
* @author Ad5001
|
* @author Ad5001 <mail@ad5001.eu>, XenialDan <https://github.com/thebigsmileXD>
|
||||||
* @link https://github.com/Ad5001/BetterGen
|
* @link https://github.com/Ad5001/BetterGen
|
||||||
|
* @category World Generator
|
||||||
|
* @api 3.0.0
|
||||||
|
* @version 1.1
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Ad5001\BetterGen\populator;
|
namespace Ad5001\BetterGen\populator;
|
||||||
|
@ -22,22 +25,24 @@ use pocketmine\math\Vector3;
|
||||||
use pocketmine\utils\Random;
|
use pocketmine\utils\Random;
|
||||||
|
|
||||||
class CavePopulator extends AmountPopulator {
|
class CavePopulator extends AmountPopulator {
|
||||||
const STOP = false;
|
|
||||||
const CONTINUE = true;
|
|
||||||
/** @var ChunkManager */
|
/** @var ChunkManager */
|
||||||
protected $level;
|
protected $level;
|
||||||
|
const STOP = false;
|
||||||
|
const CONTINUE = true;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Populate the chunk
|
* Populates the chunk
|
||||||
* @param $level pocketmine\level\ChunkManager
|
*
|
||||||
* @param $chunkX int
|
* @param ChunkManager $level
|
||||||
* @param $chunkZ int
|
* @param int $chunkX
|
||||||
* @param $random pocketmine\utils\Random
|
* @param int $chunkZ
|
||||||
|
* @param Random $random
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function populate(ChunkManager $level, $chunkX, $chunkZ, Random $random) {
|
public function populate(ChunkManager $level, $chunkX, $chunkZ, Random $random) {
|
||||||
$this->level = $level;
|
$this->level = $level;
|
||||||
$amount = $this->getAmount($random);
|
$amount = $this->getAmount($random);
|
||||||
for ($i = 0; $i < $amount; $i++) {
|
for($i = 0; $i < $amount; $i++) {
|
||||||
$x = $random->nextRange($chunkX << 4, ($chunkX << 4) + 15);
|
$x = $random->nextRange($chunkX << 4, ($chunkX << 4) + 15);
|
||||||
$z = $random->nextRange($chunkZ << 4, ($chunkZ << 4) + 15);
|
$z = $random->nextRange($chunkZ << 4, ($chunkZ << 4) + 15);
|
||||||
$y = $random->nextRange(10, $this->getHighestWorkableBlock($x, $z));
|
$y = $random->nextRange(10, $this->getHighestWorkableBlock($x, $z));
|
||||||
|
@ -46,12 +51,12 @@ class CavePopulator extends AmountPopulator {
|
||||||
}
|
}
|
||||||
// echo "Finished Populating chunk $chunkX, $chunkZ !" . PHP_EOL;
|
// echo "Finished Populating chunk $chunkX, $chunkZ !" . PHP_EOL;
|
||||||
// Filling water & lava sources randomly
|
// Filling water & lava sources randomly
|
||||||
for ($i = 0; $i < $random->nextBoundedInt(5) + 3; $i++) {
|
for($i = 0; $i < $random->nextBoundedInt(5) + 3; $i ++) {
|
||||||
$x = $random->nextRange($chunkX << 4, ($chunkX << 4) + 15);
|
$x = $random->nextRange($chunkX << 4, ($chunkX << 4) + 15);
|
||||||
$z = $random->nextRange($chunkZ << 4, ($chunkZ << 4) + 15);
|
$z = $random->nextRange($chunkZ << 4, ($chunkZ << 4) + 15);
|
||||||
$y = $random->nextRange(10, $this->getHighestWorkableBlock($x, $z));
|
$y = $random->nextRange(10, $this->getHighestWorkableBlock($x, $z));
|
||||||
if ($level->getBlockIdAt($x, $y, $z) == Block::STONE && ($level->getBlockIdAt($x + 1, $y, $z) == Block::AIR || $level->getBlockIdAt($x - 1, $y, $z) == Block::AIR || $level->getBlockIdAt($x, $y, $z + 1) == Block::AIR || $level->getBlockIdAt($x, $y, $z - 1) == Block::AIR) && $level->getBlockIdAt($x, $y - 1, $z) !== Block::AIR && $level->getBlockIdAt($x, $y + 1, $z) !== Block::AIR) {
|
if ($level->getBlockIdAt($x, $y, $z) == Block::STONE && ($level->getBlockIdAt($x + 1, $y, $z) == Block::AIR || $level->getBlockIdAt($x - 1, $y, $z) == Block::AIR || $level->getBlockIdAt($x, $y, $z + 1) == Block::AIR || $level->getBlockIdAt($x, $y, $z - 1) == Block::AIR) && $level->getBlockIdAt($x, $y - 1, $z) !== Block::AIR && $level->getBlockIdAt($x, $y + 1, $z) !== Block::AIR) {
|
||||||
if ($y < 40 && $random->nextBoolean()) {
|
if ($y < 40 && $random->nextBoolean ()) {
|
||||||
$level->setBlockIdAt($x, $y, $z, Block::LAVA);
|
$level->setBlockIdAt($x, $y, $z, Block::LAVA);
|
||||||
} else {
|
} else {
|
||||||
$level->setBlockIdAt($x, $y, $z, Block::WATER);
|
$level->setBlockIdAt($x, $y, $z, Block::WATER);
|
||||||
|
@ -62,16 +67,16 @@ class CavePopulator extends AmountPopulator {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the top block (y) on an x and z axes
|
* Gets the top block (y) on an x and z axes
|
||||||
* @param $x int
|
* @param int $x
|
||||||
* @param $z int
|
* @param int $z
|
||||||
*/
|
*/
|
||||||
protected function getHighestWorkableBlock($x, $z) {
|
protected function getHighestWorkableBlock($x, $z) {
|
||||||
for ($y = Level::Y_MAX - 1; $y > 0; --$y) {
|
for($y = Level::Y_MAX - 1; $y > 0; -- $y) {
|
||||||
$b = $this->level->getBlockIdAt($x, $y, $z);
|
$b = $this->level->getBlockIdAt($x, $y, $z);
|
||||||
if ($b === Block::DIRT or $b === Block::GRASS or $b === Block::PODZOL or $b === Block::SAND or $b === Block::SNOW_BLOCK or $b === Block::SANDSTONE) {
|
if ($b === Block::DIRT or $b === Block::GRASS or $b === Block::PODZOL or $b === Block::SAND or $b === Block::SNOW_BLOCK or $b === Block::SANDSTONE) {
|
||||||
break;
|
break;
|
||||||
} elseif ($b !== 0 and $b !== Block::SNOW_LAYER and $b !== Block::WATER) {
|
} elseif ($b !== 0 and $b !== Block::SNOW_LAYER and $b !== Block::WATER) {
|
||||||
return -1;
|
return - 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -80,16 +85,17 @@ class CavePopulator extends AmountPopulator {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generates a cave
|
* Generates a cave
|
||||||
* @param $x int
|
*
|
||||||
* @param $y int
|
* @param int $x
|
||||||
* @param $z int
|
* @param int $y
|
||||||
* @param $random pocketmine\utils\Random
|
* @param int $z
|
||||||
|
* @param Random $random
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function generateCave($x, $y, $z, Random $random) {
|
public function generateCave($x, $y, $z, Random $random) {
|
||||||
$generatedBranches = $random->nextBoundedInt(10) + 1;
|
$generatedBranches = $random->nextBoundedInt(10) + 1;
|
||||||
foreach ($gen = $this->generateBranch($x, $y, $z, 5, 3, 5, $random) as $v3) {
|
foreach($gen = $this->generateBranch($x, $y, $z, 5, 3, 5, $random) as $v3) {
|
||||||
$generatedBranches--;
|
$generatedBranches --;
|
||||||
if ($generatedBranches <= 0) {
|
if ($generatedBranches <= 0) {
|
||||||
$gen->send(self::STOP);
|
$gen->send(self::STOP);
|
||||||
} else {
|
} else {
|
||||||
|
@ -99,41 +105,42 @@ class CavePopulator extends AmountPopulator {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generates a cave branch.
|
* Generates a cave branch
|
||||||
* @param $x int
|
*
|
||||||
* @param $y int
|
* @param int $x
|
||||||
* @param $z int
|
* @param int $y
|
||||||
* @param $length int
|
* @param int $z
|
||||||
* @param $height int
|
* @param int $length
|
||||||
* @param $depth int
|
* @param int $height
|
||||||
* @param $random pocketmine\utils\Random
|
* @param int $depth
|
||||||
* @yield int
|
* @param Random $random
|
||||||
|
* @yield Vector3
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function generateBranch($x, $y, $z, $length, $height, $depth, Random $random) {
|
public function generateBranch($x, $y, $z, $length, $height, $depth, Random $random) {
|
||||||
if (!(yield new Vector3($x, $y, $z))) {
|
if (! (yield new Vector3($x, $y, $z))) {
|
||||||
for ($i = 0; $i <= 4; $i++) {
|
for($i = 0; $i <= 4; $i ++) {
|
||||||
BuildingUtils::buildRandom($this->level, new Vector3($x, $y, $z), new Vector3($length - $i, $height - $i, $depth - $i), $random, Block::get(Block::AIR));
|
BuildingUtils::buildRandom($this->level, new Vector3($x, $y, $z), new Vector3($length - $i, $height - $i, $depth - $i), $random, Block::get(Block::AIR));
|
||||||
$x += round(($random->nextBoundedInt(round(30 * ($length / 10)) + 1) / 10 - 2));
|
$x += round(($random->nextBoundedInt(round(30 * ($length / 10)) + 1) / 10 - 2));
|
||||||
$yP = $random->nextRange(-14, 14);
|
$yP = $random->nextRange(-14, 14);
|
||||||
if ($yP > 12) {
|
if ($yP > 12) {
|
||||||
$y++;
|
$y ++;
|
||||||
} elseif ($yP < -12) {
|
} elseif ($yP < - 12) {
|
||||||
$y--;
|
$y --;
|
||||||
}
|
}
|
||||||
$z += round(($random->nextBoundedInt(round(30 * ($depth / 10)) + 1) / 10 - 1));
|
$z += round(($random->nextBoundedInt(round(30 * ($depth / 10)) + 1) / 10 - 1));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$repeat = $random->nextBoundedInt(25) + 15;
|
$repeat = $random->nextBoundedInt(25) + 15;
|
||||||
while ($repeat-- > 0) {
|
while($repeat-- > 0) {
|
||||||
BuildingUtils::buildRandom($this->level, new Vector3($x, $y, $z), new Vector3($length, $height, $depth), $random, Block::get(Block::AIR));
|
BuildingUtils::buildRandom($this->level, new Vector3($x, $y, $z), new Vector3($length, $height, $depth), $random, Block::get(Block::AIR));
|
||||||
$x += round(($random->nextBoundedInt(round(30 * ($length / 10)) + 1) / 10 - 2));
|
$x += round(($random->nextBoundedInt(round(30 * ($length / 10)) + 1) / 10 - 2));
|
||||||
$yP = $random->nextRange(-14, 14);
|
$yP = $random->nextRange(- 14, 14);
|
||||||
if ($yP > 12) {
|
if ($yP > 12) {
|
||||||
$y++;
|
$y ++;
|
||||||
} elseif ($yP < -12) {
|
} elseif ($yP < - 12) {
|
||||||
$y--;
|
$y --;
|
||||||
}
|
}
|
||||||
$z += round(($random->nextBoundedInt(round(30 * ($depth / 10)) + 1) / 10 - 1));
|
$z += round(($random->nextBoundedInt(round(30 * ($depth / 10)) + 1) / 10 - 1));
|
||||||
$height += $random->nextBoundedInt(3) - 1;
|
$height += $random->nextBoundedInt(3) - 1;
|
||||||
|
@ -152,8 +159,8 @@ class CavePopulator extends AmountPopulator {
|
||||||
if ($height < 7)
|
if ($height < 7)
|
||||||
$height = 7;
|
$height = 7;
|
||||||
if ($random->nextBoundedInt(10) == 0) {
|
if ($random->nextBoundedInt(10) == 0) {
|
||||||
foreach ($generator = $this->generateBranch($x, $y, $z, $length, $height, $depth, $random) as $gen) {
|
foreach($generator = $this->generateBranch($x, $y, $z, $length, $height, $depth, $random) as $gen) {
|
||||||
if (!(yield $gen))
|
if (! (yield $gen))
|
||||||
$generator->send(self::STOP);
|
$generator->send(self::STOP);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,12 +8,16 @@
|
||||||
* \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\
|
* \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\
|
||||||
* \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/
|
* \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/
|
||||||
* Tomorrow's pocketmine generator.
|
* Tomorrow's pocketmine generator.
|
||||||
* @author Ad5001
|
* @author Ad5001 <mail@ad5001.eu>, XenialDan <https://github.com/thebigsmileXD>
|
||||||
* @link https://github.com/Ad5001/BetterGen
|
* @link https://github.com/Ad5001/BetterGen
|
||||||
|
* @category World Generator
|
||||||
|
* @api 3.0.0
|
||||||
|
* @version 1.1
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Ad5001\BetterGen\populator;
|
namespace Ad5001\BetterGen\populator;
|
||||||
|
|
||||||
|
use Ad5001\BetterGen\generator\BetterBiomeSelector;
|
||||||
use pocketmine\block\Block;
|
use pocketmine\block\Block;
|
||||||
use pocketmine\level\ChunkManager;
|
use pocketmine\level\ChunkManager;
|
||||||
use pocketmine\level\generator\biome\Biome;
|
use pocketmine\level\generator\biome\Biome;
|
||||||
|
@ -25,19 +29,21 @@ class DeadbushPopulator extends AmountPopulator {
|
||||||
protected $level;
|
protected $level;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Populate the chunk
|
* Populates the chunk
|
||||||
* @param $level pocketmine\level\ChunkManager
|
*
|
||||||
* @param $chunkX int
|
* @param ChunkManager $level
|
||||||
* @param $chunkZ int
|
* @param int $chunkX
|
||||||
* @param $random pocketmine\utils\Random
|
* @param int $chunkZ
|
||||||
|
* @param Random $random
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function populate(ChunkManager $level, $chunkX, $chunkZ, Random $random) {
|
public function populate(ChunkManager $level, $chunkX, $chunkZ, Random $random) {
|
||||||
$this->level = $level;
|
$this->level = $level;
|
||||||
$amount = $this->getAmount($random);
|
$amount = $this->getAmount($random);
|
||||||
for ($i = 0; $i < $amount; $i++) {
|
for($i = 0; $i < $amount; $i++) {
|
||||||
$x = $random->nextRange($chunkX * 16, $chunkX * 16 + 15);
|
$x = $random->nextRange($chunkX * 16, $chunkX * 16 + 15);
|
||||||
$z = $random->nextRange($chunkZ * 16, $chunkZ * 16 + 15);
|
$z = $random->nextRange($chunkZ * 16, $chunkZ * 16 + 15);
|
||||||
if (!in_array($level->getChunk($chunkX, $chunkZ)->getBiomeId(abs($x % 16), ($z % 16)), [40, 39, Biome::DESERT])) continue;
|
if(!in_array($level->getChunk($chunkX, $chunkZ)->getBiomeId(abs($x % 16), ($z % 16)), [40, 39, Biome::DESERT])) continue;
|
||||||
$y = $this->getHighestWorkableBlock($x, $z);
|
$y = $this->getHighestWorkableBlock($x, $z);
|
||||||
if ($y !== -1 && $level->getBlockIdAt($x, $y - 1, $z) == Block::SAND) {
|
if ($y !== -1 && $level->getBlockIdAt($x, $y - 1, $z) == Block::SAND) {
|
||||||
$level->setBlockIdAt($x, $y, $z, Block::DEAD_BUSH);
|
$level->setBlockIdAt($x, $y, $z, Block::DEAD_BUSH);
|
||||||
|
@ -52,12 +58,12 @@ class DeadbushPopulator extends AmountPopulator {
|
||||||
* @param $z
|
* @param $z
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
private function getHighestWorkableBlock($x, $z) {
|
protected function getHighestWorkableBlock($x, $z){
|
||||||
for ($y = Level::Y_MAX - 1; $y > 0; --$y) {
|
for($y = Level::Y_MAX - 1; $y > 0; --$y){
|
||||||
$b = $this->level->getBlockIdAt($x, $y, $z);
|
$b = $this->level->getBlockIdAt($x, $y, $z);
|
||||||
if ($b === Block::DIRT or $b === Block::GRASS or $b === Block::SAND or $b === Block::SANDSTONE or $b === Block::HARDENED_CLAY or $b === Block::STAINED_HARDENED_CLAY) {
|
if($b === Block::DIRT or $b === Block::GRASS or $b === Block::SAND or $b === Block::SANDSTONE or $b === Block::HARDENED_CLAY or $b === Block::STAINED_HARDENED_CLAY){
|
||||||
break;
|
break;
|
||||||
} elseif ($b !== Block::AIR) {
|
}elseif($b !== Block::AIR){
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
70
src/Ad5001/BetterGen/populator/DungeonPopulator.php
Normal file
70
src/Ad5001/BetterGen/populator/DungeonPopulator.php
Normal file
|
@ -0,0 +1,70 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* ____ __ __ ____
|
||||||
|
* /\ _`\ /\ \__ /\ \__ /\ _`\
|
||||||
|
* \ \ \L\ \ __ \ \ ,_\\ \ ,_\ __ _ __ \ \ \L\_\ __ ___
|
||||||
|
* \ \ _ <' /'__`\\ \ \/ \ \ \/ /'__`\/\`'__\\ \ \L_L /'__`\ /' _ `\
|
||||||
|
* \ \ \L\ \/\ __/ \ \ \_ \ \ \_ /\ __/\ \ \/ \ \ \/, \/\ __/ /\ \/\ \
|
||||||
|
* \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\
|
||||||
|
* \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/
|
||||||
|
* Tomorrow's pocketmine generator.
|
||||||
|
* @author Ad5001 <mail@ad5001.eu>, XenialDan <https://github.com/thebigsmileXD>
|
||||||
|
* @link https://github.com/Ad5001/BetterGen
|
||||||
|
* @category World Generator
|
||||||
|
* @api 3.0.0
|
||||||
|
* @version 1.1
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Ad5001\BetterGen\populator;
|
||||||
|
|
||||||
|
use Ad5001\BetterGen\utils\BuildingUtils;
|
||||||
|
use Ad5001\BetterGen\structure\Dungeons;
|
||||||
|
use pocketmine\block\Block;
|
||||||
|
use pocketmine\level\ChunkManager;
|
||||||
|
use pocketmine\level\Level;
|
||||||
|
use pocketmine\math\Vector3;
|
||||||
|
use pocketmine\utils\Random;
|
||||||
|
|
||||||
|
class DungeonPopulator extends AmountPopulator {
|
||||||
|
/** @var ChunkManager */
|
||||||
|
protected $level;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Populates the chunk
|
||||||
|
*
|
||||||
|
* @param ChunkManager $level
|
||||||
|
* @param int $chunkX
|
||||||
|
* @param int $chunkZ
|
||||||
|
* @param Random $random
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function populate(ChunkManager $level, $chunkX, $chunkZ, Random $random) {
|
||||||
|
$this->level = $level;
|
||||||
|
$amount = $this->getAmount($random);
|
||||||
|
if($amount == 5) { // 1 out of 10 chunks
|
||||||
|
$x = $random->nextRange($chunkX << 4, ($chunkX << 4) + 15);
|
||||||
|
$z = $random->nextRange($chunkZ << 4, ($chunkZ << 4) + 15);
|
||||||
|
$y = $random->nextRange(10, $this->getHighestWorkableBlock($x, $z) - 6);
|
||||||
|
$d = new Dungeons();
|
||||||
|
$d->placeObject($level, $x, $y, $z, $random);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the top block (y) on an x and z axes
|
||||||
|
* @param int $x
|
||||||
|
* @param int $z
|
||||||
|
*/
|
||||||
|
protected function getHighestWorkableBlock($x, $z) {
|
||||||
|
for($y = Level::Y_MAX - 1; $y > 0; -- $y) {
|
||||||
|
$b = $this->level->getBlockIdAt($x, $y, $z);
|
||||||
|
if ($b === Block::DIRT or $b === Block::GRASS or $b === Block::PODZOL or $b === Block::SAND or $b === Block::SNOW_BLOCK or $b === Block::SANDSTONE) {
|
||||||
|
break;
|
||||||
|
} elseif ($b !== 0 and $b !== Block::SNOW_LAYER and $b !== Block::WATER) {
|
||||||
|
return - 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return ++$y;
|
||||||
|
}
|
||||||
|
}
|
|
@ -8,8 +8,11 @@
|
||||||
* \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\
|
* \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\
|
||||||
* \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/
|
* \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/
|
||||||
* Tomorrow's pocketmine generator.
|
* Tomorrow's pocketmine generator.
|
||||||
* @author Ad5001
|
* @author Ad5001 <mail@ad5001.eu>, XenialDan <https://github.com/thebigsmileXD>
|
||||||
* @link https://github.com/Ad5001/BetterGen
|
* @link https://github.com/Ad5001/BetterGen
|
||||||
|
* @category World Generator
|
||||||
|
* @api 3.0.0
|
||||||
|
* @version 1.1
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Ad5001\BetterGen\populator;
|
namespace Ad5001\BetterGen\populator;
|
||||||
|
@ -25,10 +28,9 @@ class FallenTreePopulator extends AmountPopulator {
|
||||||
/** @var ChunkManager */
|
/** @var ChunkManager */
|
||||||
protected $level;
|
protected $level;
|
||||||
protected $type;
|
protected $type;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs the class
|
* Constructs the class
|
||||||
* @param $type int
|
* @param int $type
|
||||||
*/
|
*/
|
||||||
public function __construct(int $type = 0) {
|
public function __construct(int $type = 0) {
|
||||||
$this->type = $type;
|
$this->type = $type;
|
||||||
|
@ -37,11 +39,13 @@ class FallenTreePopulator extends AmountPopulator {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Populate the chunk
|
* Populates the chunk
|
||||||
* @param $level pocketmine\level\ChunkManager
|
*
|
||||||
* @param $chunkX int
|
* @param ChunkManager $level
|
||||||
* @param $chunkZ int
|
* @param int $chunkX
|
||||||
* @param $random pocketmine\utils\Random
|
* @param int $chunkZ
|
||||||
|
* @param Random $random
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function populate(ChunkManager $level, $chunkX, $chunkZ, Random $random) {
|
public function populate(ChunkManager $level, $chunkX, $chunkZ, Random $random) {
|
||||||
$this->level = $level;
|
$this->level = $level;
|
||||||
|
@ -50,11 +54,11 @@ class FallenTreePopulator extends AmountPopulator {
|
||||||
$fallenTree = new \Ad5001\BetterGen\structure\FallenTree(
|
$fallenTree = new \Ad5001\BetterGen\structure\FallenTree(
|
||||||
new $tree()
|
new $tree()
|
||||||
);
|
);
|
||||||
for ($i = 0; $i < $amount; $i++) {
|
for($i = 0; $i < $amount; $i++) {
|
||||||
$x = $random->nextRange($chunkX * 16, $chunkX * 16 + 15);
|
$x = $random->nextRange($chunkX * 16, $chunkX * 16 + 15);
|
||||||
$z = $random->nextRange($chunkZ * 16, $chunkZ * 16 + 15);
|
$z = $random->nextRange($chunkZ * 16, $chunkZ * 16 + 15);
|
||||||
$y = $this->getHighestWorkableBlock($x, $z);
|
$y = $this->getHighestWorkableBlock($x, $z);
|
||||||
if (isset(FallenTree::$overridable[$level->getBlockIdAt($x, $y, $z)])) $y--; // Changing $y if 1 block to high.
|
if(isset(FallenTree::$overridable[$level->getBlockIdAt($x, $y, $z)])) $y--; // Changing $y if 1 block to high.
|
||||||
if ($y !== -1 and $fallenTree->canPlaceObject($level, $x, $y + 1, $z, $random)) {
|
if ($y !== -1 and $fallenTree->canPlaceObject($level, $x, $y + 1, $z, $random)) {
|
||||||
$fallenTree->placeObject($level, $x, $y + 1, $z);
|
$fallenTree->placeObject($level, $x, $y + 1, $z);
|
||||||
}
|
}
|
||||||
|
@ -67,12 +71,12 @@ class FallenTreePopulator extends AmountPopulator {
|
||||||
* @param $z
|
* @param $z
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
private function getHighestWorkableBlock($x, $z) {
|
protected function getHighestWorkableBlock($x, $z){
|
||||||
for ($y = Level::Y_MAX - 1; $y > 0; --$y) {
|
for($y = Level::Y_MAX - 1; $y > 0; --$y){
|
||||||
$b = $this->level->getBlockIdAt($x, $y, $z);
|
$b = $this->level->getBlockIdAt($x, $y, $z);
|
||||||
if ($b === Block::DIRT or $b === Block::GRASS) {
|
if($b === Block::DIRT or $b === Block::GRASS){
|
||||||
break;
|
break;
|
||||||
} elseif ($b !== Block::AIR and $b !== Block::SNOW_LAYER) {
|
}elseif($b !== Block::AIR and $b !== Block::SNOW_LAYER){
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,8 +8,11 @@
|
||||||
* \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\
|
* \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\
|
||||||
* \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/
|
* \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/
|
||||||
* Tomorrow's pocketmine generator.
|
* Tomorrow's pocketmine generator.
|
||||||
* @author Ad5001
|
* @author Ad5001 <mail@ad5001.eu>, XenialDan <https://github.com/thebigsmileXD>
|
||||||
* @link https://github.com/Ad5001/BetterGen
|
* @link https://github.com/Ad5001/BetterGen
|
||||||
|
* @category World Generator
|
||||||
|
* @api 3.0.0
|
||||||
|
* @version 1.1
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Ad5001\BetterGen\populator;
|
namespace Ad5001\BetterGen\populator;
|
||||||
|
@ -32,20 +35,21 @@ use pocketmine\utils\Random;
|
||||||
|
|
||||||
|
|
||||||
class FloatingIslandPopulator extends AmountPopulator {
|
class FloatingIslandPopulator extends AmountPopulator {
|
||||||
|
/** @var ChunkManager */
|
||||||
|
protected $level;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Populate the chunk
|
* Populates the chunk
|
||||||
* @param $level pocketmine\level\ChunkManager
|
*
|
||||||
* @param $chunkX int
|
* @param ChunkManager $level
|
||||||
* @param $chunkZ int
|
* @param int $chunkX
|
||||||
* @param $random pocketmine\utils\Random
|
* @param int $chunkZ
|
||||||
|
* @param Random $random
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
/** @var ChunkManager */
|
|
||||||
private $level;
|
|
||||||
|
|
||||||
public function populate(ChunkManager $level, $chunkX, $chunkZ, Random $random) {
|
public function populate(ChunkManager $level, $chunkX, $chunkZ, Random $random) {
|
||||||
$this->level = $level;
|
$this->level = $level;
|
||||||
if ($this->getAmount($random) > 130) {
|
if($this->getAmount($random) > 130) {
|
||||||
$x = $random->nextRange(($chunkX << 4), ($chunkX << 4) + 15);
|
$x = $random->nextRange(($chunkX << 4), ($chunkX << 4) + 15);
|
||||||
$z = $random->nextRange(($chunkX << 4), ($chunkX << 4) + 15);
|
$z = $random->nextRange(($chunkX << 4), ($chunkX << 4) + 15);
|
||||||
$y = $random->nextRange($this->getHighestWorkableBlock($x, $z) < 96 ? $this->getHighestWorkableBlock($x, $z) + 20 : $this->getHighestWorkableBlock($x, $z), 126);
|
$y = $random->nextRange($this->getHighestWorkableBlock($x, $z) < 96 ? $this->getHighestWorkableBlock($x, $z) + 20 : $this->getHighestWorkableBlock($x, $z), 126);
|
||||||
|
@ -55,20 +59,21 @@ class FloatingIslandPopulator extends AmountPopulator {
|
||||||
$chunk = $level->getChunk($chunkX, $chunkZ);
|
$chunk = $level->getChunk($chunkX, $chunkZ);
|
||||||
$biome = BetterNormal::$biomeById[$chunk->getBiomeId($x % 16, $z % 16)];
|
$biome = BetterNormal::$biomeById[$chunk->getBiomeId($x % 16, $z % 16)];
|
||||||
$populators = $biome->getPopulators();
|
$populators = $biome->getPopulators();
|
||||||
foreach ($populators as $populator) {
|
foreach($populators as $populator) {
|
||||||
$populator->populate($level, $chunkX, $chunkZ, $random);
|
$populator->populate($level, $chunkX, $chunkZ, $random);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the top block (y) on an x and z axes
|
* Gets the top block (y) on an x and z axes
|
||||||
* @param $x int
|
* @param int $x
|
||||||
* @param $z int
|
* @param int $z
|
||||||
*/
|
*/
|
||||||
protected function getHighestWorkableBlock($x, $z) {
|
protected function getHighestWorkableBlock($x, $z) {
|
||||||
for ($y = Level::Y_MAX - 1; $y > 0; --$y) {
|
for($y = Level::Y_MAX - 1; $y > 0; -- $y) {
|
||||||
$b = $this->level->getBlockIdAt($x, $y, $z);
|
$b = $this->level->getBlockIdAt($x, $y, $z);
|
||||||
if ($b === Block::DIRT or $b === Block::GRASS or $b === Block::PODZOL or $b === Block::SAND) {
|
if ($b === Block::DIRT or $b === Block::GRASS or $b === Block::PODZOL or $b === Block::SAND) {
|
||||||
break;
|
break;
|
||||||
|
@ -81,33 +86,35 @@ class FloatingIslandPopulator extends AmountPopulator {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Builds a an island shape
|
* Builds an island bottom shape
|
||||||
* @param $level pocketmine\level\ChunkManager
|
*
|
||||||
* @param $pos pocketmine\math\Vector3
|
* @param ChunkManager $level
|
||||||
* @param $radius int
|
* @param Vector3 $pos
|
||||||
* @param $random pocketmine\utils\Random
|
* @param int $radius
|
||||||
* @return int lowest ore point
|
* @param Random $random
|
||||||
|
* @return int Bottom place of the island
|
||||||
*/
|
*/
|
||||||
public function buildIslandBottomShape(ChunkManager $level, Vector3 $pos, int $radius, Random $random) {
|
public function buildIslandBottomShape(ChunkManager $level, Vector3 $pos, int $radius, Random $random) {
|
||||||
$pos = $pos->round();
|
$pos = $pos->round();
|
||||||
$currentLen = 1;
|
$currentLen = 1;
|
||||||
$hBound = 0;
|
$hBound = 0;
|
||||||
$current = 0;
|
$current = 0;
|
||||||
for ($y = $pos->y - 1; $radius > 0; $y--) {
|
for($y = $pos->y - 1; $radius > 0; $y--) {
|
||||||
for ($x = $pos->x - $radius; $x <= $pos->x + $radius; $x++) {
|
for($x = $pos->x - $radius; $x <= $pos->x + $radius; $x++) {
|
||||||
for ($z = $pos->z - $radius; $z <= $pos->z + $radius; $z++) {
|
for($z = $pos->z - $radius; $z <= $pos->z + $radius; $z ++) {
|
||||||
if (abs(abs($x - $pos->x) ** 2) + abs(abs($z - $pos->z) ** 2) == ($radius ** 2) * 0.67) {
|
if(abs(abs($x - $pos->x) ** 2) + abs(abs($z - $pos->z) ** 2) == ($radius ** 2) * 0.67) {
|
||||||
$isEdge = true;
|
$isEdge = true;
|
||||||
} else {
|
} else {
|
||||||
$isEdge = false;
|
$isEdge = false;
|
||||||
}
|
}
|
||||||
if (abs(abs($x - $pos->x) ** 2) + abs(abs($z - $pos->z) ** 2) <= ($radius ** 2) * 0.67 && $y < 128) {
|
if(abs(abs($x - $pos->x) ** 2) + abs(abs($z - $pos->z) ** 2) <= ($radius ** 2) * 0.67 && $y < 128) {
|
||||||
if ($chunk = $level->getChunk($x >> 4, $z >> 4)) {
|
if($chunk = $level->getChunk($x >> 4, $z >> 4)) {
|
||||||
$biome = BetterNormal::$biomeById[$chunk->getBiomeId($x % 16, $z % 16)];
|
$biome = BetterNormal::$biomeById[$chunk->getBiomeId($x % 16, $z % 16)];
|
||||||
$block = $biome->getGroundCover()[$pos->y - $y - 1] ?? Block::get(Block::STONE);
|
$block = $biome->getGroundCover()[$pos->y - $y - 1] ?? Block::get(Block::STONE);
|
||||||
$block = $block->getId();
|
$block = $block->getId();
|
||||||
} elseif ($random->nextBoundedInt(5) == 0 && $isEdge) {
|
} elseif($random->nextBoundedInt(5) == 0 && $isEdge) {
|
||||||
$block = Block::AIR;
|
$block = Block::AIR;
|
||||||
} else {
|
} else {
|
||||||
$block = Block::STONE;
|
$block = Block::STONE;
|
||||||
|
@ -119,8 +126,8 @@ class FloatingIslandPopulator extends AmountPopulator {
|
||||||
$current++;
|
$current++;
|
||||||
$oldHB = $hBound;
|
$oldHB = $hBound;
|
||||||
$hBound = $random->nextFloat();
|
$hBound = $random->nextFloat();
|
||||||
if ($current >= $currentLen + $hBound) {
|
if($current >= $currentLen + $hBound) {
|
||||||
if ($radius == 0) return $pos->y;
|
if($radius == 0) return $pos->y;
|
||||||
$current = 0;
|
$current = 0;
|
||||||
$currentLen += 0.3 * ($random->nextFloat() + 0.5);
|
$currentLen += 0.3 * ($random->nextFloat() + 0.5);
|
||||||
$radius--;
|
$radius--;
|
||||||
|
@ -130,18 +137,21 @@ class FloatingIslandPopulator extends AmountPopulator {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* BPopulate the island with ores
|
* Populates the island with ores
|
||||||
* @param $level pocketmine\level\ChunkManager
|
*
|
||||||
* @param $pos pocketmine\math\Vector3
|
* @param ChunkManager $level
|
||||||
* @param $width int
|
* @param Vector3 $pos
|
||||||
* @param $height int
|
* @param int $width
|
||||||
* @param $random pocketmine\utils\Random
|
* @param int $height
|
||||||
|
* @param Random $random
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function populateOres(ChunkManager $level, Vector3 $pos, int $width, int $height, Random $random) {
|
public function populateOres(ChunkManager $level, Vector3 $pos, int $width, int $height, Random $random) {
|
||||||
$ores = Main::isOtherNS() ? new \pocketmine\level\generator\normal\populator\Ore() : new \pocketmine\level\generator\populator\Ore();
|
$ores = Main::isOtherNS() ? new \pocketmine\level\generator\normal\populator\Ore() : new \pocketmine\level\generator\populator\Ore();
|
||||||
if (Main::isOtherNS()) $ores->setOreTypes([
|
if(Main::isOtherNS()) $ores->setOreTypes([
|
||||||
new OreType2(new CoalOre (), 20, 16, $pos->y - $height, $pos->y),
|
new OreType2(new CoalOre (), 20, 16, $pos->y - $height, $pos->y),
|
||||||
new OreType2(new IronOre (), 20, 8, $pos->y - $height, $pos->y - round($height * 0.75)),
|
new OreType2(new IronOre (), 20, 8, $pos->y - $height, $pos->y - round($height * 0.75)),
|
||||||
new OreType2(new RedstoneOre (), 8, 7, $pos->y - $height, $pos->y - round($height / 2)),
|
new OreType2(new RedstoneOre (), 8, 7, $pos->y - $height, $pos->y - round($height / 2)),
|
||||||
|
@ -149,7 +159,7 @@ class FloatingIslandPopulator extends AmountPopulator {
|
||||||
new OreType2(new GoldOre (), 2, 8, $pos->y - $height, $pos->y - round($height / 2)),
|
new OreType2(new GoldOre (), 2, 8, $pos->y - $height, $pos->y - round($height / 2)),
|
||||||
new OreType2(new DiamondOre (), 1, 7, $pos->y - $height, $pos->y - round($height / 4))
|
new OreType2(new DiamondOre (), 1, 7, $pos->y - $height, $pos->y - round($height / 4))
|
||||||
]);
|
]);
|
||||||
if (!Main::isOtherNS()) $ores->setOreTypes([
|
if(!Main::isOtherNS()) $ores->setOreTypes([
|
||||||
new OreType(new CoalOre (), 20, 16, $pos->y - $height, $pos->y),
|
new OreType(new CoalOre (), 20, 16, $pos->y - $height, $pos->y),
|
||||||
new OreType(new IronOre (), 20, 8, $pos->y - $height, $pos->y - round($height * 0.75)),
|
new OreType(new IronOre (), 20, 8, $pos->y - $height, $pos->y - round($height * 0.75)),
|
||||||
new OreType(new RedstoneOre (), 8, 7, $pos->y - $height, $pos->y - round($height / 2)),
|
new OreType(new RedstoneOre (), 8, 7, $pos->y - $height, $pos->y - round($height / 2)),
|
||||||
|
|
|
@ -8,8 +8,9 @@
|
||||||
* \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\
|
* \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\
|
||||||
* \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/
|
* \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/
|
||||||
* Tomorrow's pocketmine generator.
|
* Tomorrow's pocketmine generator.
|
||||||
* @author Ad5001
|
* @author Ad5001 <mail@ad5001.eu>, XenialDan <https://github.com/thebigsmileXD>
|
||||||
* @link https://github.com/Ad5001/BetterGen
|
* @link https://github.com/Ad5001/BetterGen
|
||||||
|
* @version 1.1
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Ad5001\BetterGen\populator;
|
namespace Ad5001\BetterGen\populator;
|
||||||
|
@ -24,12 +25,15 @@ class IglooPopulator extends AmountPopulator {
|
||||||
/** @var ChunkManager */
|
/** @var ChunkManager */
|
||||||
protected $level;
|
protected $level;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Populate the chunk
|
* Populates the chunk
|
||||||
* @param $level pocketmine\level\ChunkManager
|
*
|
||||||
* @param $chunkX int
|
* @param ChunkManager $level
|
||||||
* @param $chunkZ int
|
* @param int $chunkX
|
||||||
* @param $random pocketmine\utils\Random
|
* @param int $chunkZ
|
||||||
|
* @param Random $random
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function populate(ChunkManager $level, $chunkX, $chunkZ, Random $random) {
|
public function populate(ChunkManager $level, $chunkX, $chunkZ, Random $random) {
|
||||||
$this->level = $level;
|
$this->level = $level;
|
||||||
|
@ -45,16 +49,16 @@ class IglooPopulator extends AmountPopulator {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the top block (y) on an x and z axes
|
* Gets the top block (y) on an x and z axes
|
||||||
* @param $x int
|
* @param int $x
|
||||||
* @param $z int
|
* @param int $z
|
||||||
*/
|
*/
|
||||||
protected function getHighestWorkableBlock($x, $z) {
|
protected function getHighestWorkableBlock($x, $z) {
|
||||||
for ($y = Level::Y_MAX - 1; $y > 0; --$y) {
|
for($y = Level::Y_MAX - 1; $y > 0; -- $y) {
|
||||||
$b = $this->level->getBlockIdAt($x, $y, $z);
|
$b = $this->level->getBlockIdAt($x, $y, $z);
|
||||||
if ($b === Block::DIRT or $b === Block::GRASS or $b === Block::PODZOL) {
|
if ($b === Block::DIRT or $b === Block::GRASS or $b === Block::PODZOL) {
|
||||||
break;
|
break;
|
||||||
} elseif ($b !== 0 and $b !== Block::SNOW_LAYER) {
|
} elseif ($b !== 0 and $b !== Block::SNOW_LAYER) {
|
||||||
return -1;
|
return - 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,8 +8,11 @@
|
||||||
* \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\
|
* \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\
|
||||||
* \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/
|
* \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/
|
||||||
* Tomorrow's pocketmine generator.
|
* Tomorrow's pocketmine generator.
|
||||||
* @author Ad5001
|
* @author Ad5001 <mail@ad5001.eu>, XenialDan <https://github.com/thebigsmileXD>
|
||||||
* @link https://github.com/Ad5001/BetterGen
|
* @link https://github.com/Ad5001/BetterGen
|
||||||
|
* @category World Generator
|
||||||
|
* @api 3.0.0
|
||||||
|
* @version 1.1
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Ad5001\BetterGen\populator;
|
namespace Ad5001\BetterGen\populator;
|
||||||
|
@ -25,12 +28,15 @@ class LakePopulator extends AmountPopulator {
|
||||||
/** @var ChunkManager */
|
/** @var ChunkManager */
|
||||||
protected $level;
|
protected $level;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Populate the chunk
|
* Populates the chunk
|
||||||
* @param $level pocketmine\level\ChunkManager
|
*
|
||||||
* @param $chunkX int
|
* @param ChunkManager $level
|
||||||
* @param $chunkZ int
|
* @param int $chunkX
|
||||||
* @param $random pocketmine\utils\Random
|
* @param int $chunkZ
|
||||||
|
* @param Random $random
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function populate(ChunkManager $level, $chunkX, $chunkZ, Random $random) {
|
public function populate(ChunkManager $level, $chunkX, $chunkZ, Random $random) {
|
||||||
$this->level = $level;
|
$this->level = $level;
|
||||||
|
@ -38,32 +44,32 @@ class LakePopulator extends AmountPopulator {
|
||||||
$z = $random->nextRange($chunkZ << 4, ($chunkZ << 4) + 15);
|
$z = $random->nextRange($chunkZ << 4, ($chunkZ << 4) + 15);
|
||||||
$ory = $random->nextRange(20, 63); // Water level
|
$ory = $random->nextRange(20, 63); // Water level
|
||||||
$y = $ory;
|
$y = $ory;
|
||||||
for ($i = 0; $i < 4; $i++) {
|
for($i = 0; $i < 4; $i ++) {
|
||||||
$x += $random->nextRange(-1, 1);
|
$x += $random->nextRange(- 1, 1);
|
||||||
$y += $random->nextRange(-1, 1);
|
$y += $random->nextRange(- 1, 1);
|
||||||
$z += $random->nextRange(-1, 1);
|
$z += $random->nextRange(- 1, 1);
|
||||||
if ($level->getBlockIdAt($x, $y, $z) !== Block::AIR)
|
if ($level->getBlockIdAt($x, $y, $z) !== Block::AIR)
|
||||||
BuildingUtils::buildRandom($this->level, new Vector3($x, $y, $z), new Vector3(5, 5, 5), $random, Block::get(Block::WATER));
|
BuildingUtils::buildRandom($this->level, new Vector3($x, $y, $z), new Vector3(5, 5, 5), $random, Block::get(Block::WATER));
|
||||||
}
|
}
|
||||||
for ($xx = $x - 8; $xx <= $x + 8; $xx++)
|
for($xx = $x - 8; $xx <= $x + 8; $xx ++)
|
||||||
for ($zz = $z - 8; $zz <= $z + 8; $zz++)
|
for($zz = $z - 8; $zz <= $z + 8; $zz ++)
|
||||||
for ($yy = $ory + 1; $yy <= $y + 3; $yy++)
|
for($yy = $ory + 1; $yy <= $y + 3; $yy ++)
|
||||||
if ($level->getBlockIdAt($xx, $yy, $zz) == Block::WATER)
|
if ($level->getBlockIdAt($xx, $yy, $zz) == Block::WATER)
|
||||||
$level->setBlockIdAt($xx, $yy, $zz, Block::AIR);
|
$level->setBlockIdAt($xx, $yy, $zz, Block::AIR);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the top block (y) on an x and z axes
|
* Gets the top block (y) on an x and z axes
|
||||||
* @param $x int
|
* @param int $x
|
||||||
* @param $z int
|
* @param int $z
|
||||||
*/
|
*/
|
||||||
protected function getHighestWorkableBlock($x, $z) {
|
protected function getHighestWorkableBlock($x, $z) {
|
||||||
for ($y = Level::Y_MAX - 1; $y > 0; --$y) {
|
for($y = Level::Y_MAX - 1; $y > 0; -- $y) {
|
||||||
$b = $this->level->getBlockIdAt($x, $y, $z);
|
$b = $this->level->getBlockIdAt($x, $y, $z);
|
||||||
if ($b === Block::DIRT or $b === Block::GRASS or $b === Block::PODZOL) {
|
if ($b === Block::DIRT or $b === Block::GRASS or $b === Block::PODZOL) {
|
||||||
break;
|
break;
|
||||||
} elseif ($b !== 0 and $b !== Block::SNOW_LAYER) {
|
} elseif ($b !== 0 and $b !== Block::SNOW_LAYER) {
|
||||||
return -1;
|
return - 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,8 +8,11 @@
|
||||||
* \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\
|
* \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\
|
||||||
* \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/
|
* \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/
|
||||||
* Tomorrow's pocketmine generator.
|
* Tomorrow's pocketmine generator.
|
||||||
* @author Ad5001
|
* @author Ad5001 <mail@ad5001.eu>, XenialDan <https://github.com/thebigsmileXD>
|
||||||
* @link https://github.com/Ad5001/BetterGen
|
* @link https://github.com/Ad5001/BetterGen
|
||||||
|
* @category World Generator
|
||||||
|
* @api 3.0.0
|
||||||
|
* @version 1.1
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Ad5001\BetterGen\populator;
|
namespace Ad5001\BetterGen\populator;
|
||||||
|
@ -20,8 +23,13 @@ use pocketmine\block\Block;
|
||||||
use pocketmine\level\ChunkManager;
|
use pocketmine\level\ChunkManager;
|
||||||
use pocketmine\math\Vector3;
|
use pocketmine\math\Vector3;
|
||||||
use pocketmine\utils\Random;
|
use pocketmine\utils\Random;
|
||||||
|
use pocketmine\level\Level;
|
||||||
|
|
||||||
class MineshaftPopulator extends AmountPopulator {
|
class MineshaftPopulator extends AmountPopulator {
|
||||||
|
/** var int */
|
||||||
|
protected $maxPath;
|
||||||
|
/** @var ChunkManager */
|
||||||
|
protected $level;
|
||||||
const DIR_XPLUS = 0;
|
const DIR_XPLUS = 0;
|
||||||
const DIR_XMIN = 1;
|
const DIR_XMIN = 1;
|
||||||
const DIR_ZPLUS = 2;
|
const DIR_ZPLUS = 2;
|
||||||
|
@ -29,16 +37,15 @@ class MineshaftPopulator extends AmountPopulator {
|
||||||
const TYPE_FORWARD = 0;
|
const TYPE_FORWARD = 0;
|
||||||
const TYPE_CROSSPATH = 1;
|
const TYPE_CROSSPATH = 1;
|
||||||
const TYPE_STAIRS = 2;
|
const TYPE_STAIRS = 2;
|
||||||
protected $maxPath;
|
|
||||||
/** @var ChunkManager */
|
|
||||||
protected $level;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Populate the chunk
|
* Populates the chunk
|
||||||
* @param $level pocketmine\level\ChunkManager
|
*
|
||||||
* @param $chunkX int
|
* @param ChunkManager $level
|
||||||
* @param $chunkZ int
|
* @param int $chunkX
|
||||||
* @param $random pocketmine\utils\Random
|
* @param int $chunkZ
|
||||||
|
* @param Random $random
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function populate(ChunkManager $level, $chunkX, $chunkZ, Random $random) {
|
public function populate(ChunkManager $level, $chunkX, $chunkZ, Random $random) {
|
||||||
if ($this->getAmount($random) < 100)
|
if ($this->getAmount($random) < 100)
|
||||||
|
@ -52,7 +59,7 @@ class MineshaftPopulator extends AmountPopulator {
|
||||||
BuildingUtils::fill($level, new Vector3($x - 6, $y, $x - 6), new Vector3($x + 6, $y, $z + 6), Block::get(Block::DIRT));
|
BuildingUtils::fill($level, new Vector3($x - 6, $y, $x - 6), new Vector3($x + 6, $y, $z + 6), Block::get(Block::DIRT));
|
||||||
$startingPath = $random->nextBoundedInt(4);
|
$startingPath = $random->nextBoundedInt(4);
|
||||||
$this->maxPath = $random->nextBoundedInt(100) + 50;
|
$this->maxPath = $random->nextBoundedInt(100) + 50;
|
||||||
foreach (array_fill(0, $startingPath, 1) as $hey) {
|
foreach(array_fill(0, $startingPath, 1) as $hey) {
|
||||||
$dir = $random->nextBoundedInt(4);
|
$dir = $random->nextBoundedInt(4);
|
||||||
switch ($dir) {
|
switch ($dir) {
|
||||||
case self::DIR_XPLUS :
|
case self::DIR_XPLUS :
|
||||||
|
@ -80,7 +87,7 @@ class MineshaftPopulator extends AmountPopulator {
|
||||||
* @param Random $random
|
* @param Random $random
|
||||||
*/
|
*/
|
||||||
public function generateMineshaftPart(int $x, int $y, int $z, int $dir, Random $random) {
|
public function generateMineshaftPart(int $x, int $y, int $z, int $dir, Random $random) {
|
||||||
if ($this->maxPath-- < 1)
|
if ($this->maxPath -- < 1 || $y >= $this->getHighestWorkableBlock($x, $z) - 10)
|
||||||
return;
|
return;
|
||||||
$type = $random->nextBoundedInt(3);
|
$type = $random->nextBoundedInt(3);
|
||||||
$level = $this->level;
|
$level = $this->level;
|
||||||
|
@ -93,7 +100,7 @@ class MineshaftPopulator extends AmountPopulator {
|
||||||
// Then, making sure the floor is solid.
|
// Then, making sure the floor is solid.
|
||||||
BuildingUtils::fillCallback(new Vector3($x, $y - 1, $z - 1), new Vector3($x + 4, $y - 1, $z + 1), function ($v3, ChunkManager $level) {
|
BuildingUtils::fillCallback(new Vector3($x, $y - 1, $z - 1), new Vector3($x + 4, $y - 1, $z + 1), function ($v3, ChunkManager $level) {
|
||||||
if ($level->getBlockIdAt($v3->x, $v3->y, $v3->z) == Block::AIR)
|
if ($level->getBlockIdAt($v3->x, $v3->y, $v3->z) == Block::AIR)
|
||||||
$level->setBlockIdAt($v3->x, $v3->y, $v3->z, Block::PLANK);
|
$level->setBlockIdAt($v3->x, $v3->y, $v3->z, Block::PLANKS);
|
||||||
}, $this->level);
|
}, $this->level);
|
||||||
// Putting rails
|
// Putting rails
|
||||||
BuildingUtils::fillCallback(new Vector3($x, $y, $z), new Vector3($x + 4, $y, $z), function ($v3, ChunkManager $level, Random $random) {
|
BuildingUtils::fillCallback(new Vector3($x, $y, $z), new Vector3($x + 4, $y, $z), function ($v3, ChunkManager $level, Random $random) {
|
||||||
|
@ -107,17 +114,17 @@ class MineshaftPopulator extends AmountPopulator {
|
||||||
$level->setBlockIdAt($x, $y, $z + 1, Block::FENCE);
|
$level->setBlockIdAt($x, $y, $z + 1, Block::FENCE);
|
||||||
$level->setBlockIdAt($x, $y + 1, $z - 1, Block::FENCE);
|
$level->setBlockIdAt($x, $y + 1, $z - 1, Block::FENCE);
|
||||||
$level->setBlockIdAt($x, $y + 1, $z + 1, Block::FENCE);
|
$level->setBlockIdAt($x, $y + 1, $z + 1, Block::FENCE);
|
||||||
$level->setBlockIdAt($x, $y + 2, $z - 1, Block::PLANK);
|
$level->setBlockIdAt($x, $y + 2, $z - 1, Block::PLANKS);
|
||||||
$level->setBlockIdAt($x, $y + 2, $z, Block::PLANK);
|
$level->setBlockIdAt($x, $y + 2, $z, Block::PLANKS);
|
||||||
$level->setBlockIdAt($x, $y + 2, $z + 1, Block::PLANK);
|
$level->setBlockIdAt($x, $y + 2, $z + 1, Block::PLANKS);
|
||||||
$level->setBlockIdAt($x + 1, $y + 2, $z, Block::TORCH);
|
$level->setBlockIdAt($x + 1, $y + 2, $z, Block::TORCH);
|
||||||
$level->setBlockDataAt($x + 1, $y + 2, $z, 2);
|
$level->setBlockDataAt($x + 1, $y + 2, $z, 2);
|
||||||
// Generating chest
|
// Generating chest
|
||||||
if ($random->nextBoundedInt(30) == 0) {
|
if ($random->nextBoundedInt(30) == 0) {
|
||||||
$direction = (int)$random->nextBoolean();
|
$direction =(int) $random->nextBoolean ();
|
||||||
if ($direction == 0)
|
if ($direction == 0)
|
||||||
$direction = -1; // Choosing the part of the rail.
|
$direction = -1; // Choosing the part of the rail.
|
||||||
$direction2 = (int)$random->nextBoolean();
|
$direction2 =(int) $random->nextBoolean ();
|
||||||
if ($direction2 == 0)
|
if ($direction2 == 0)
|
||||||
$direction2 = 2;
|
$direction2 = 2;
|
||||||
if ($direction2 == 1)
|
if ($direction2 == 1)
|
||||||
|
@ -134,7 +141,7 @@ class MineshaftPopulator extends AmountPopulator {
|
||||||
BuildingUtils::fillCallback(new Vector3($x, $y - 1, $z - 1), new Vector3($x - 4, $y - 1, $z + 1), function ($v3, ChunkManager $level) {
|
BuildingUtils::fillCallback(new Vector3($x, $y - 1, $z - 1), new Vector3($x - 4, $y - 1, $z + 1), function ($v3, ChunkManager $level) {
|
||||||
|
|
||||||
if ($level->getBlockIdAt($v3->x, $v3->y, $v3->z) == Block::AIR)
|
if ($level->getBlockIdAt($v3->x, $v3->y, $v3->z) == Block::AIR)
|
||||||
$level->setBlockIdAt($v3->x, $v3->y, $v3->z, Block::PLANK);
|
$level->setBlockIdAt($v3->x, $v3->y, $v3->z, Block::PLANKS);
|
||||||
}, $this->level);
|
}, $this->level);
|
||||||
// Putting rails
|
// Putting rails
|
||||||
BuildingUtils::fillCallback(new Vector3($x, $y, $z), new Vector3($x - 4, $y, $z), function ($v3, ChunkManager $level, Random $random) {
|
BuildingUtils::fillCallback(new Vector3($x, $y, $z), new Vector3($x - 4, $y, $z), function ($v3, ChunkManager $level, Random $random) {
|
||||||
|
@ -148,17 +155,17 @@ class MineshaftPopulator extends AmountPopulator {
|
||||||
$level->setBlockIdAt($x, $y, $z + 1, Block::FENCE);
|
$level->setBlockIdAt($x, $y, $z + 1, Block::FENCE);
|
||||||
$level->setBlockIdAt($x, $y + 1, $z - 1, Block::FENCE);
|
$level->setBlockIdAt($x, $y + 1, $z - 1, Block::FENCE);
|
||||||
$level->setBlockIdAt($x, $y + 1, $z + 1, Block::FENCE);
|
$level->setBlockIdAt($x, $y + 1, $z + 1, Block::FENCE);
|
||||||
$level->setBlockIdAt($x, $y + 2, $z - 1, Block::PLANK);
|
$level->setBlockIdAt($x, $y + 2, $z - 1, Block::PLANKS);
|
||||||
$level->setBlockIdAt($x, $y + 2, $z, Block::PLANK);
|
$level->setBlockIdAt($x, $y + 2, $z, Block::PLANKS);
|
||||||
$level->setBlockIdAt($x, $y + 2, $z + 1, Block::PLANK);
|
$level->setBlockIdAt($x, $y + 2, $z + 1, Block::PLANKS);
|
||||||
$level->setBlockIdAt($x - 1, $y + 2, $z, Block::TORCH);
|
$level->setBlockIdAt($x - 1, $y + 2, $z, Block::TORCH);
|
||||||
$level->setBlockDataAt($x - 1, $y + 2, $z, 1);
|
$level->setBlockDataAt($x - 1, $y + 2, $z, 1);
|
||||||
// Generating chest
|
// Generating chest
|
||||||
if ($random->nextBoundedInt(30) == 0) {
|
if ($random->nextBoundedInt(30) == 0) {
|
||||||
$direction = (int)$random->nextBoolean();
|
$direction =(int) $random->nextBoolean ();
|
||||||
if ($direction == 0)
|
if ($direction == 0)
|
||||||
$direction = -1; // Choosing the part of the rail.
|
$direction = -1; // Choosing the part of the rail.
|
||||||
$direction2 = (int)$random->nextBoolean();
|
$direction2 =(int) $random->nextBoolean ();
|
||||||
if ($direction2 == 0)
|
if ($direction2 == 0)
|
||||||
$direction2 = 2;
|
$direction2 = 2;
|
||||||
if ($direction2 == 1)
|
if ($direction2 == 1)
|
||||||
|
@ -175,7 +182,7 @@ class MineshaftPopulator extends AmountPopulator {
|
||||||
BuildingUtils::fillCallback(new Vector3($x - 1, $y - 1, $z), new Vector3($x + 1, $y - 1, $z + 4), function ($v3, ChunkManager $level) {
|
BuildingUtils::fillCallback(new Vector3($x - 1, $y - 1, $z), new Vector3($x + 1, $y - 1, $z + 4), function ($v3, ChunkManager $level) {
|
||||||
|
|
||||||
if ($level->getBlockIdAt($v3->x, $v3->y, $v3->z) == Block::AIR)
|
if ($level->getBlockIdAt($v3->x, $v3->y, $v3->z) == Block::AIR)
|
||||||
$level->setBlockIdAt($v3->x, $v3->y, $v3->z, Block::PLANK);
|
$level->setBlockIdAt($v3->x, $v3->y, $v3->z, Block::PLANKS);
|
||||||
}, $this->level);
|
}, $this->level);
|
||||||
// Putting rails
|
// Putting rails
|
||||||
BuildingUtils::fillCallback(new Vector3($x, $y, $z), new Vector3($x, $y, $z + 4), function ($v3, ChunkManager $level, Random $random) {
|
BuildingUtils::fillCallback(new Vector3($x, $y, $z), new Vector3($x, $y, $z + 4), function ($v3, ChunkManager $level, Random $random) {
|
||||||
|
@ -189,17 +196,17 @@ class MineshaftPopulator extends AmountPopulator {
|
||||||
$level->setBlockIdAt($x + 1, $y, $z, Block::FENCE);
|
$level->setBlockIdAt($x + 1, $y, $z, Block::FENCE);
|
||||||
$level->setBlockIdAt($x - 1, $y + 1, $z, Block::FENCE);
|
$level->setBlockIdAt($x - 1, $y + 1, $z, Block::FENCE);
|
||||||
$level->setBlockIdAt($x + 1, $y + 1, $z, Block::FENCE);
|
$level->setBlockIdAt($x + 1, $y + 1, $z, Block::FENCE);
|
||||||
$level->setBlockIdAt($x - 1, $y + 2, $z, Block::PLANK);
|
$level->setBlockIdAt($x - 1, $y + 2, $z, Block::PLANKS);
|
||||||
$level->setBlockIdAt($x, $y + 2, $z, Block::PLANK);
|
$level->setBlockIdAt($x, $y + 2, $z, Block::PLANKS);
|
||||||
$level->setBlockIdAt($x + 1, $y + 2, $z, Block::PLANK);
|
$level->setBlockIdAt($x + 1, $y + 2, $z, Block::PLANKS);
|
||||||
$level->setBlockIdAt($x, $y + 2, $z - 1, Block::TORCH);
|
$level->setBlockIdAt($x, $y + 2, $z - 1, Block::TORCH);
|
||||||
$level->setBlockDataAt($x, $y + 2, $z - 1, 4);
|
$level->setBlockDataAt($x, $y + 2, $z - 1, 4);
|
||||||
// Generating chest
|
// Generating chest
|
||||||
if ($random->nextBoundedInt(30) == 0) {
|
if ($random->nextBoundedInt(30) == 0) {
|
||||||
$direction = (int)$random->nextBoolean();
|
$direction =(int) $random->nextBoolean ();
|
||||||
if ($direction == 0)
|
if ($direction == 0)
|
||||||
$direction = -1; // Choosing the part of the rail.
|
$direction = -1; // Choosing the part of the rail.
|
||||||
$direction2 = (int)$random->nextBoolean();
|
$direction2 =(int) $random->nextBoolean ();
|
||||||
if ($direction2 == 0)
|
if ($direction2 == 0)
|
||||||
$direction2 = 2;
|
$direction2 = 2;
|
||||||
if ($direction2 == 1)
|
if ($direction2 == 1)
|
||||||
|
@ -216,7 +223,7 @@ class MineshaftPopulator extends AmountPopulator {
|
||||||
BuildingUtils::fillCallback(new Vector3($x - 1, $y - 1, $z), new Vector3($x + 1, $y - 1, $z - 4), function ($v3, ChunkManager $level) {
|
BuildingUtils::fillCallback(new Vector3($x - 1, $y - 1, $z), new Vector3($x + 1, $y - 1, $z - 4), function ($v3, ChunkManager $level) {
|
||||||
|
|
||||||
if ($level->getBlockIdAt($v3->x, $v3->y, $v3->z) == Block::AIR)
|
if ($level->getBlockIdAt($v3->x, $v3->y, $v3->z) == Block::AIR)
|
||||||
$level->setBlockIdAt($v3->x, $v3->y, $v3->z, Block::PLANK);
|
$level->setBlockIdAt($v3->x, $v3->y, $v3->z, Block::PLANKS);
|
||||||
}, $this->level);
|
}, $this->level);
|
||||||
// Putting rails
|
// Putting rails
|
||||||
BuildingUtils::fillCallback(new Vector3($x, $y, $z), new Vector3($x, $y, $z - 4), function ($v3, ChunkManager $level, Random $random) {
|
BuildingUtils::fillCallback(new Vector3($x, $y, $z), new Vector3($x, $y, $z - 4), function ($v3, ChunkManager $level, Random $random) {
|
||||||
|
@ -230,17 +237,17 @@ class MineshaftPopulator extends AmountPopulator {
|
||||||
$level->setBlockIdAt($x + 1, $y, $z, Block::FENCE);
|
$level->setBlockIdAt($x + 1, $y, $z, Block::FENCE);
|
||||||
$level->setBlockIdAt($x - 1, $y + 1, $z, Block::FENCE);
|
$level->setBlockIdAt($x - 1, $y + 1, $z, Block::FENCE);
|
||||||
$level->setBlockIdAt($x + 1, $y + 1, $z, Block::FENCE);
|
$level->setBlockIdAt($x + 1, $y + 1, $z, Block::FENCE);
|
||||||
$level->setBlockIdAt($x - 1, $y + 2, $z, Block::PLANK);
|
$level->setBlockIdAt($x - 1, $y + 2, $z, Block::PLANKS);
|
||||||
$level->setBlockIdAt($x, $y + 2, $z, Block::PLANK);
|
$level->setBlockIdAt($x, $y + 2, $z, Block::PLANKS);
|
||||||
$level->setBlockIdAt($x + 1, $y + 2, $z, Block::PLANK);
|
$level->setBlockIdAt($x + 1, $y + 2, $z, Block::PLANKS);
|
||||||
$level->setBlockIdAt($x, $y + 2, $z - 1, Block::TORCH);
|
$level->setBlockIdAt($x, $y + 2, $z - 1, Block::TORCH);
|
||||||
$level->setBlockDataAt($x, $y + 2, $z - 1, 3);
|
$level->setBlockDataAt($x, $y + 2, $z - 1, 3);
|
||||||
// Generating chest
|
// Generating chest
|
||||||
if ($random->nextBoundedInt(30) == 0) {
|
if ($random->nextBoundedInt(30) == 0) {
|
||||||
$direction = (int)$random->nextBoolean();
|
$direction =(int) $random->nextBoolean ();
|
||||||
if ($direction == 0)
|
if ($direction == 0)
|
||||||
$direction = -1; // Choosing the part of the rail.
|
$direction = -1; // Choosing the part of the rail.
|
||||||
$direction2 = (int)$random->nextBoolean();
|
$direction2 =(int) $random->nextBoolean ();
|
||||||
if ($direction2 == 0)
|
if ($direction2 == 0)
|
||||||
$direction2 = 2;
|
$direction2 = 2;
|
||||||
if ($direction2 == 1)
|
if ($direction2 == 1)
|
||||||
|
@ -253,7 +260,7 @@ class MineshaftPopulator extends AmountPopulator {
|
||||||
}
|
}
|
||||||
// Doing cobwebs
|
// Doing cobwebs
|
||||||
$webNum = $random->nextBoundedInt(5) + 2;
|
$webNum = $random->nextBoundedInt(5) + 2;
|
||||||
for ($i = 0; $i < $webNum; $i++) {
|
for($i = 0; $i < $webNum; $i ++) {
|
||||||
$xx = $x + $random->nextBoundedInt(5) - 2;
|
$xx = $x + $random->nextBoundedInt(5) - 2;
|
||||||
$yy = $y + $random->nextBoundedInt(3);
|
$yy = $y + $random->nextBoundedInt(3);
|
||||||
$zz = $z + $random->nextBoundedInt(5) - 2;
|
$zz = $z + $random->nextBoundedInt(5) - 2;
|
||||||
|
@ -270,19 +277,19 @@ class MineshaftPopulator extends AmountPopulator {
|
||||||
];
|
];
|
||||||
switch ($dir) {
|
switch ($dir) {
|
||||||
case self::DIR_XPLUS :
|
case self::DIR_XPLUS :
|
||||||
$x++;
|
$x ++;
|
||||||
unset($possiblePathes[0]);
|
unset($possiblePathes[0]);
|
||||||
break;
|
break;
|
||||||
case self::DIR_XMIN :
|
case self::DIR_XMIN :
|
||||||
$x--;
|
$x --;
|
||||||
unset($possiblePathes[1]);
|
unset($possiblePathes[1]);
|
||||||
break;
|
break;
|
||||||
case self::DIR_ZPLUS :
|
case self::DIR_ZPLUS :
|
||||||
$z++;
|
$z ++;
|
||||||
unset($possiblePathes[2]);
|
unset($possiblePathes[2]);
|
||||||
break;
|
break;
|
||||||
case self::DIR_ZMIN :
|
case self::DIR_ZMIN :
|
||||||
$z--;
|
$z --;
|
||||||
unset($possiblePathes[3]);
|
unset($possiblePathes[3]);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -291,32 +298,32 @@ class MineshaftPopulator extends AmountPopulator {
|
||||||
BuildingUtils::fillCallback(new Vector3($x + 1, $y - 1, $z - 1), new Vector3($x - 1, $y - 1, $z + 1), function ($v3, ChunkManager $level) {
|
BuildingUtils::fillCallback(new Vector3($x + 1, $y - 1, $z - 1), new Vector3($x - 1, $y - 1, $z + 1), function ($v3, ChunkManager $level) {
|
||||||
|
|
||||||
if ($level->getBlockIdAt($v3->x, $v3->y, $v3->z) == Block::AIR)
|
if ($level->getBlockIdAt($v3->x, $v3->y, $v3->z) == Block::AIR)
|
||||||
$level->setBlockIdAt($v3->x, $v3->y, $v3->z, Block::PLANK);
|
$level->setBlockIdAt($v3->x, $v3->y, $v3->z, Block::PLANKS);
|
||||||
}, $this->level);
|
}, $this->level);
|
||||||
// Putting rails
|
// Putting rails
|
||||||
|
|
||||||
BuildingUtils::fill($this->level, new Vector3($x - 1, $y, $z - 1), new Vector3($x + 1, $y + 6, $z + 1), Block::get(Block::AIR));
|
BuildingUtils::fill($this->level, new Vector3($x - 1, $y, $z - 1), new Vector3($x + 1, $y + 6, $z + 1), Block::get(Block::AIR));
|
||||||
|
|
||||||
BuildingUtils::corners($this->level, new Vector3($x - 1, $y, $z - 1), new Vector3($x + 1, $y + 6, $z + 1), Block::get(Block::PLANK));
|
BuildingUtils::corners($this->level, new Vector3($x - 1, $y, $z - 1), new Vector3($x + 1, $y + 6, $z + 1), Block::get(Block::PLANKS));
|
||||||
|
|
||||||
$newFloor = $random->nextBoolean();
|
$newFloor = $random->nextBoolean ();
|
||||||
$numberFloor = $random->nextBoundedInt(4 + ($newFloor ? 5 : 0));
|
$numberFloor = $random->nextBoundedInt(4 + ($newFloor ? 5 : 0));
|
||||||
$possiblePathes = [
|
$possiblePathes = [
|
||||||
$possiblePathes,
|
$possiblePathes,
|
||||||
($newFloor ? [
|
($newFloor ?[
|
||||||
self::DIR_XPLUS,
|
self::DIR_XPLUS,
|
||||||
self::DIR_XMIN,
|
self::DIR_XMIN,
|
||||||
self::DIR_ZPLUS,
|
self::DIR_ZPLUS,
|
||||||
self::DIR_ZMIN
|
self::DIR_ZMIN
|
||||||
] : [])
|
] : [ ])
|
||||||
];
|
];
|
||||||
for ($i = 7; $i > $newFloor; $i--) {
|
for($i = 7; $i > $newFloor; $i --) {
|
||||||
$chooseNew = (int)$newFloor && $random->nextBoolean();
|
$chooseNew =(int) $newFloor && $random->nextBoolean ();
|
||||||
$choose = $random->nextBoundedInt(4);
|
$choose = $random->nextBoundedInt(4);
|
||||||
unset($possiblePathes[$chooseNew] [$choose]);
|
unset($possiblePathes[$chooseNew] [$choose]);
|
||||||
}
|
}
|
||||||
// Building pathes
|
// Building pathes
|
||||||
foreach ($possiblePathes[0] as $path) {
|
foreach($possiblePathes[0] as $path) {
|
||||||
switch ($path) {
|
switch ($path) {
|
||||||
case self::DIR_XPLUS :
|
case self::DIR_XPLUS :
|
||||||
$this->generateMineshaftPart($x + 2, $y, $z, self::DIR_XPLUS, $random);
|
$this->generateMineshaftPart($x + 2, $y, $z, self::DIR_XPLUS, $random);
|
||||||
|
@ -332,7 +339,7 @@ class MineshaftPopulator extends AmountPopulator {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
foreach ($possiblePathes[1] as $path) {
|
foreach($possiblePathes[1] as $path) {
|
||||||
switch ($path) {
|
switch ($path) {
|
||||||
case self::DIR_XPLUS :
|
case self::DIR_XPLUS :
|
||||||
$this->generateMineshaftPart($x + 2, $y + 4, $z, self::DIR_XPLUS, $random);
|
$this->generateMineshaftPart($x + 2, $y + 4, $z, self::DIR_XPLUS, $random);
|
||||||
|
@ -351,7 +358,7 @@ class MineshaftPopulator extends AmountPopulator {
|
||||||
|
|
||||||
// Doing cobwebs
|
// Doing cobwebs
|
||||||
$webNum = $random->nextBoundedInt(5) + 2;
|
$webNum = $random->nextBoundedInt(5) + 2;
|
||||||
for ($i = 0; $i < $webNum; $i++) {
|
for($i = 0; $i < $webNum; $i ++) {
|
||||||
$xx = $x + $random->nextBoundedInt(3) - 1;
|
$xx = $x + $random->nextBoundedInt(3) - 1;
|
||||||
$yy = $y + $random->nextBoundedInt(6);
|
$yy = $y + $random->nextBoundedInt(6);
|
||||||
$zz = $z + $random->nextBoundedInt(3) - 1;
|
$zz = $z + $random->nextBoundedInt(3) - 1;
|
||||||
|
@ -360,18 +367,18 @@ class MineshaftPopulator extends AmountPopulator {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case self::TYPE_STAIRS :
|
case self::TYPE_STAIRS :
|
||||||
if ($y <= 5) {
|
if($y <= 5) {
|
||||||
$this->generateMineshaftPart($x, $y, $z, $dir, $random);
|
$this->generateMineshaftPart($x, $y, $z, $dir, $random);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Building stairs
|
// Building stairs
|
||||||
for ($i = 0; $i < 4; $i++) {
|
for($i = 0; $i < 4; $i ++) {
|
||||||
switch ($i) {
|
switch ($i) {
|
||||||
case self::DIR_XPLUS :
|
case self::DIR_XPLUS :
|
||||||
BuildingUtils::fill($this->level, new Vector3($x + $i, $y - $i - 1, $z - 2), new Vector3($x + $i, $y - $i + 3, $z + 2), Block::get(Block::AIR));
|
BuildingUtils::fill($this->level, new Vector3($x + $i, $y - $i - 1, $z - 2), new Vector3($x + $i, $y - $i + 3, $z + 2), Block::get(Block::AIR));
|
||||||
BuildingUtils::fillCallback(new Vector3($x + $i, $y - $i - 2, $z - 2), new Vector3($x + $i, $y - $i - 2, $z + 2), function ($v3, ChunkManager $level) {
|
BuildingUtils::fillCallback(new Vector3($x + $i, $y - $i - 2, $z - 2), new Vector3($x + $i, $y - $i - 2, $z + 2), function ($v3, ChunkManager $level) {
|
||||||
if ($level->getBlockIdAt($v3->x, $v3->y, $v3->z) == Block::AIR)
|
if ($level->getBlockIdAt($v3->x, $v3->y, $v3->z) == Block::AIR)
|
||||||
$level->setBlockIdAt($v3->x, $v3->y, $v3->z, Block::PLANK);
|
$level->setBlockIdAt($v3->x, $v3->y, $v3->z, Block::PLANKS);
|
||||||
}, $this->level);
|
}, $this->level);
|
||||||
break;
|
break;
|
||||||
case self::DIR_XMIN :
|
case self::DIR_XMIN :
|
||||||
|
@ -379,7 +386,7 @@ class MineshaftPopulator extends AmountPopulator {
|
||||||
BuildingUtils::fillCallback(new Vector3($x - $i, $y - $i - 2, $z - 2), new Vector3($x - $i, $y - $i - 2, $z + 2), function ($v3, ChunkManager $level) {
|
BuildingUtils::fillCallback(new Vector3($x - $i, $y - $i - 2, $z - 2), new Vector3($x - $i, $y - $i - 2, $z + 2), function ($v3, ChunkManager $level) {
|
||||||
|
|
||||||
if ($level->getBlockIdAt($v3->x, $v3->y, $v3->z) == Block::AIR)
|
if ($level->getBlockIdAt($v3->x, $v3->y, $v3->z) == Block::AIR)
|
||||||
$level->setBlockIdAt($v3->x, $v3->y, $v3->z, Block::PLANK);
|
$level->setBlockIdAt($v3->x, $v3->y, $v3->z, Block::PLANKS);
|
||||||
}, $this->level);
|
}, $this->level);
|
||||||
break;
|
break;
|
||||||
case self::DIR_ZPLUS :
|
case self::DIR_ZPLUS :
|
||||||
|
@ -387,7 +394,7 @@ class MineshaftPopulator extends AmountPopulator {
|
||||||
BuildingUtils::fillCallback(new Vector3($x - 2, $y - $i - 2, $z + $i), new Vector3($x + 2, $y - $i - 2, $z + $i), function ($v3, ChunkManager $level) {
|
BuildingUtils::fillCallback(new Vector3($x - 2, $y - $i - 2, $z + $i), new Vector3($x + 2, $y - $i - 2, $z + $i), function ($v3, ChunkManager $level) {
|
||||||
|
|
||||||
if ($level->getBlockIdAt($v3->x, $v3->y, $v3->z) == Block::AIR)
|
if ($level->getBlockIdAt($v3->x, $v3->y, $v3->z) == Block::AIR)
|
||||||
$level->setBlockIdAt($v3->x, $v3->y, $v3->z, Block::PLANK);
|
$level->setBlockIdAt($v3->x, $v3->y, $v3->z, Block::PLANKS);
|
||||||
}, $this->level);
|
}, $this->level);
|
||||||
break;
|
break;
|
||||||
case self::DIR_ZMIN :
|
case self::DIR_ZMIN :
|
||||||
|
@ -395,7 +402,7 @@ class MineshaftPopulator extends AmountPopulator {
|
||||||
BuildingUtils::fillCallback(new Vector3($x - 2, $y - $i - 2, $z - $i), new Vector3($x + 2, $y - $i - 2, $z - $i), function ($v3, ChunkManager $level) {
|
BuildingUtils::fillCallback(new Vector3($x - 2, $y - $i - 2, $z - $i), new Vector3($x + 2, $y - $i - 2, $z - $i), function ($v3, ChunkManager $level) {
|
||||||
|
|
||||||
if ($level->getBlockIdAt($v3->x, $v3->y, $v3->z) == Block::AIR)
|
if ($level->getBlockIdAt($v3->x, $v3->y, $v3->z) == Block::AIR)
|
||||||
$level->setBlockIdAt($v3->x, $v3->y, $v3->z, Block::PLANK);
|
$level->setBlockIdAt($v3->x, $v3->y, $v3->z, Block::PLANKS);
|
||||||
}, $this->level);
|
}, $this->level);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -419,6 +426,21 @@ class MineshaftPopulator extends AmountPopulator {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the top block (y) on an x and z axes
|
||||||
|
* @param int $x
|
||||||
|
* @param int $z
|
||||||
|
*/
|
||||||
|
protected function getHighestWorkableBlock($x, $z) {
|
||||||
|
for($y = Level::Y_MAX - 1; $y > 0; -- $y) {
|
||||||
|
$b = $this->level->getBlockIdAt($x, $y, $z);
|
||||||
|
if ($b === Block::SAND) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return ++$y;
|
||||||
|
}
|
||||||
|
}
|
||||||
?>
|
?>
|
|
@ -8,8 +8,11 @@
|
||||||
* \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\
|
* \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\
|
||||||
* \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/
|
* \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/
|
||||||
* Tomorrow's pocketmine generator.
|
* Tomorrow's pocketmine generator.
|
||||||
* @author Ad5001
|
* @author Ad5001 <mail@ad5001.eu>, XenialDan <https://github.com/thebigsmileXD>
|
||||||
* @link https://github.com/Ad5001/BetterGen
|
* @link https://github.com/Ad5001/BetterGen
|
||||||
|
* @category World Generator
|
||||||
|
* @api 3.0.0
|
||||||
|
* @version 1.1
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Ad5001\BetterGen\populator;
|
namespace Ad5001\BetterGen\populator;
|
||||||
|
@ -21,16 +24,18 @@ use pocketmine\level\Level;
|
||||||
use pocketmine\utils\Random;
|
use pocketmine\utils\Random;
|
||||||
|
|
||||||
class RavinePopulator extends AmountPopulator {
|
class RavinePopulator extends AmountPopulator {
|
||||||
const NOISE = 250;
|
|
||||||
/** @var ChunkManager */
|
/** @var ChunkManager */
|
||||||
protected $level;
|
protected $level;
|
||||||
|
const NOISE = 250;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Populate the chunk
|
* Populates the chunk
|
||||||
* @param $level pocketmine\level\ChunkManager
|
*
|
||||||
* @param $chunkX int
|
* @param ChunkManager $level
|
||||||
* @param $chunkZ int
|
* @param int $chunkX
|
||||||
* @param $random pocketmine\utils\Random
|
* @param int $chunkZ
|
||||||
|
* @param Random $random
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function populate(ChunkManager $level, $chunkX, $chunkZ, Random $random) {
|
public function populate(ChunkManager $level, $chunkX, $chunkZ, Random $random) {
|
||||||
$this->level = $level;
|
$this->level = $level;
|
||||||
|
@ -44,18 +49,18 @@ class RavinePopulator extends AmountPopulator {
|
||||||
$deffZ = $z;
|
$deffZ = $z;
|
||||||
$height = $random->nextRange(15, 30);
|
$height = $random->nextRange(15, 30);
|
||||||
$length = $random->nextRange(5, 12);
|
$length = $random->nextRange(5, 12);
|
||||||
for ($i = 0; $i < $depth; $i++) {
|
for($i = 0; $i < $depth; $i ++) {
|
||||||
$this->buildRavinePart($x, $y, $z, $height, $length, $random);
|
$this->buildRavinePart($x, $y, $z, $height, $length, $random);
|
||||||
$diffX = $x - $deffX;
|
$diffX = $x - $deffX;
|
||||||
$diffZ = $z - $deffZ;
|
$diffZ = $z - $deffZ;
|
||||||
if ($diffX > $length / 2)
|
if ($diffX > $length / 2)
|
||||||
$diffX = $length / 2;
|
$diffX = $length / 2;
|
||||||
if ($diffX < -$length / 2)
|
if ($diffX < - $length / 2)
|
||||||
$diffX = -$length / 2;
|
$diffX = - $length / 2;
|
||||||
if ($diffZ > $length / 2)
|
if ($diffZ > $length / 2)
|
||||||
$diffZ = $length / 2;
|
$diffZ = $length / 2;
|
||||||
if ($diffZ < -$length / 2)
|
if ($diffZ < - $length / 2)
|
||||||
$diffZ = -$length / 2;
|
$diffZ = - $length / 2;
|
||||||
if ($length > 10)
|
if ($length > 10)
|
||||||
$length = 10;
|
$length = 10;
|
||||||
if ($length < 5)
|
if ($length < 5)
|
||||||
|
@ -69,18 +74,18 @@ class RavinePopulator extends AmountPopulator {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* Gets the top block (y) on an x and z axes
|
* Gets the top block (y) on an x and z axes
|
||||||
* @param $x int
|
* @param $x int
|
||||||
* @param $z int
|
* @param $z int
|
||||||
*/
|
*/
|
||||||
protected function getHighestWorkableBlock($x, $z) {
|
protected function getHighestWorkableBlock($x, $z) {
|
||||||
for ($y = Level::Y_MAX - 1; $y > 0; --$y) {
|
for($y = Level::Y_MAX - 1; $y > 0; -- $y) {
|
||||||
$b = $this->level->getBlockIdAt($x, $y, $z);
|
$b = $this->level->getBlockIdAt($x, $y, $z);
|
||||||
if ($b === Block::DIRT or $b === Block::GRASS or $b === Block::PODZOL or $b === Block::SAND or $b === Block::SNOW_BLOCK or $b === Block::SANDSTONE) {
|
if ($b === Block::DIRT or $b === Block::GRASS or $b === Block::PODZOL or $b === Block::SAND or $b === Block::SNOW_BLOCK or $b === Block::SANDSTONE) {
|
||||||
break;
|
break;
|
||||||
} elseif ($b !== 0 and $b !== Block::SNOW_LAYER and $b !== Block::WATER) {
|
} elseif ($b !== 0 and $b !== Block::SNOW_LAYER and $b !== Block::WATER) {
|
||||||
return -1;
|
return - 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -88,40 +93,42 @@ class RavinePopulator extends AmountPopulator {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Builds a ravine part
|
* Buidls a ravine part
|
||||||
* @param $x int
|
*
|
||||||
* @param $y int
|
* @param int $x
|
||||||
* @param $z int
|
* @param int $y
|
||||||
* @param $height int
|
* @param int $z
|
||||||
* @param $length int
|
* @param int $height
|
||||||
* @param $random pocketmine\utils\Random
|
* @param int $length
|
||||||
|
* @param Random $random
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
protected function buildRavinePart($x, $y, $z, $height, $length, Random $random) {
|
protected function buildRavinePart($x, $y, $z, $height, $length, Random $random) {
|
||||||
$xBounded = 0;
|
$xBounded = 0;
|
||||||
$zBounded = 0;
|
$zBounded = 0;
|
||||||
for ($xx = $x - $length; $xx <= $x + $length; $xx++) {
|
for($xx = $x - $length; $xx <= $x + $length; $xx ++) {
|
||||||
for ($yy = $y; $yy <= $y + $height; $yy++) {
|
for($yy = $y; $yy <= $y + $height; $yy ++) {
|
||||||
for ($zz = $z - $length; $zz <= $z + $length; $zz++) {
|
for($zz = $z - $length; $zz <= $z + $length; $zz ++) {
|
||||||
$oldXB = $xBounded;
|
$oldXB = $xBounded;
|
||||||
$xBounded = $random->nextBoundedInt(self::NOISE * 2) - self::NOISE;
|
$xBounded = $random->nextBoundedInt(self::NOISE * 2) - self::NOISE;
|
||||||
$oldZB = $zBounded;
|
$oldZB = $zBounded;
|
||||||
$zBounded = $random->nextBoundedInt(self::NOISE * 2) - self::NOISE;
|
$zBounded = $random->nextBoundedInt(self::NOISE * 2) - self::NOISE;
|
||||||
if ($xBounded > self::NOISE - 2) {
|
if ($xBounded > self::NOISE - 2) {
|
||||||
$xBounded = 1;
|
$xBounded = 1;
|
||||||
} elseif ($xBounded < -self::NOISE + 2) {
|
} elseif ($xBounded < - self::NOISE + 2) {
|
||||||
$xBounded = -1;
|
$xBounded = -1;
|
||||||
} else {
|
} else {
|
||||||
$xBounded = $oldXB;
|
$xBounded = $oldXB;
|
||||||
}
|
}
|
||||||
if ($zBounded > self::NOISE - 2) {
|
if ($zBounded > self::NOISE - 2) {
|
||||||
$zBounded = 1;
|
$zBounded = 1;
|
||||||
} elseif ($zBounded < -self::NOISE + 2) {
|
} elseif ($zBounded < - self::NOISE + 2) {
|
||||||
$zBounded = -1;
|
$zBounded = -1;
|
||||||
} else {
|
} else {
|
||||||
$zBounded = $oldZB;
|
$zBounded = $oldZB;
|
||||||
}
|
}
|
||||||
if (abs((abs($xx) - abs($x)) ** 2 + (abs($zz) - abs($z)) ** 2) < ((($length / 2 - $xBounded) + ($length / 2 - $zBounded)) / 2) ** 2 && $y > 0 && !in_array($this->level->getBlockIdAt(( int)round($xx), (int)round($yy), (int)round($zz)), BuildingUtils::TO_NOT_OVERWRITE) && !in_array($this->level->getBlockIdAt(( int)round($xx), (int)round($yy + 1), (int)round($zz)), BuildingUtils::TO_NOT_OVERWRITE)) {
|
if (abs((abs($xx) - abs($x)) ** 2 + (abs($zz) - abs($z)) ** 2) < ((($length / 2 - $xBounded) + ($length / 2 - $zBounded)) / 2) ** 2 && $y > 0 && ! in_array($this->level->getBlockIdAt(( int) round($xx),(int) round($yy),(int) round($zz)), BuildingUtils::TO_NOT_OVERWRITE) && ! in_array($this->level->getBlockIdAt(( int) round($xx),(int) round($yy + 1),(int) round($zz)), BuildingUtils::TO_NOT_OVERWRITE)) {
|
||||||
$this->level->setBlockIdAt(( int)round($xx), (int)round($yy), (int)round($zz), Block::AIR);
|
$this->level->setBlockIdAt(( int) round($xx),(int) round($yy),(int) round($zz), Block::AIR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,8 +8,11 @@
|
||||||
* \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\
|
* \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\
|
||||||
* \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/
|
* \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/
|
||||||
* Tomorrow's pocketmine generator.
|
* Tomorrow's pocketmine generator.
|
||||||
* @author Ad5001
|
* @author Ad5001 <mail@ad5001.eu>, XenialDan <https://github.com/thebigsmileXD>
|
||||||
* @link https://github.com/Ad5001/BetterGen
|
* @link https://github.com/Ad5001/BetterGen
|
||||||
|
* @category World Generator
|
||||||
|
* @api 3.0.0
|
||||||
|
* @version 1.1
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Ad5001\BetterGen\populator;
|
namespace Ad5001\BetterGen\populator;
|
||||||
|
@ -33,17 +36,19 @@ class SugarCanePopulator extends AmountPopulator {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Populate the chunk
|
* Populates the chunk
|
||||||
* @param $level pocketmine\level\ChunkManager
|
*
|
||||||
* @param $chunkX int
|
* @param ChunkManager $level
|
||||||
* @param $chunkZ int
|
* @param int $chunkX
|
||||||
* @param $random pocketmine\utils\Random
|
* @param int $chunkZ
|
||||||
|
* @param Random $random
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function populate(ChunkManager $level, $chunkX, $chunkZ, Random $random) {
|
public function populate(ChunkManager $level, $chunkX, $chunkZ, Random $random) {
|
||||||
$this->level = $level;
|
$this->level = $level;
|
||||||
$amount = $this->getAmount($random);
|
$amount = $this->getAmount($random);
|
||||||
$sugarcane = new SugarCane ();
|
$sugarcane = new SugarCane ();
|
||||||
for ($i = 0; $i < $amount; $i++) {
|
for($i = 0; $i < $amount; $i++) {
|
||||||
$x = $random->nextRange($chunkX * 16, $chunkX * 16 + 15);
|
$x = $random->nextRange($chunkX * 16, $chunkX * 16 + 15);
|
||||||
$z = $random->nextRange($chunkZ * 16, $chunkZ * 16 + 15);
|
$z = $random->nextRange($chunkZ * 16, $chunkZ * 16 + 15);
|
||||||
$y = $this->getHighestWorkableBlock($x, $z);
|
$y = $this->getHighestWorkableBlock($x, $z);
|
||||||
|
@ -57,14 +62,15 @@ class SugarCanePopulator extends AmountPopulator {
|
||||||
* Gets the top block (y) on an x and z axes
|
* Gets the top block (y) on an x and z axes
|
||||||
* @param $x int
|
* @param $x int
|
||||||
* @param $z int
|
* @param $z int
|
||||||
|
* @return int
|
||||||
*/
|
*/
|
||||||
protected function getHighestWorkableBlock($x, $z) {
|
protected function getHighestWorkableBlock($x, $z) {
|
||||||
for ($y = Level::Y_MAX - 1; $y >= 0; --$y) {
|
for($y = Level::Y_MAX - 1; $y >= 0; -- $y) {
|
||||||
$b = $this->level->getBlockIdAt($x, $y, $z);
|
$b = $this->level->getBlockIdAt($x, $y, $z);
|
||||||
if ($b !== Block::AIR and $b !== Block::LEAVES and $b !== Block::LEAVES2) {
|
if ($b !== Block::AIR and $b !== Block::LEAVES and $b !== Block::LEAVES2) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $y === 0 ? -1 : ++$y;
|
return $y === 0 ? - 1 : ++$y;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -8,8 +8,11 @@
|
||||||
* \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\
|
* \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\
|
||||||
* \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/
|
* \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/
|
||||||
* Tomorrow's pocketmine generator.
|
* Tomorrow's pocketmine generator.
|
||||||
* @author Ad5001
|
* @author Ad5001 <mail@ad5001.eu>, XenialDan <https://github.com/thebigsmileXD>
|
||||||
* @link https://github.com/Ad5001/BetterGen
|
* @link https://github.com/Ad5001/BetterGen
|
||||||
|
* @category World Generator
|
||||||
|
* @api 3.0.0
|
||||||
|
* @version 1.1
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Ad5001\BetterGen\populator;
|
namespace Ad5001\BetterGen\populator;
|
||||||
|
@ -25,11 +28,13 @@ class TemplePopulator extends AmountPopulator {
|
||||||
protected $level;
|
protected $level;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Populate the chunk
|
* Populates the chunk
|
||||||
* @param $level pocketmine\level\ChunkManager
|
*
|
||||||
* @param $chunkX int
|
* @param ChunkManager $level
|
||||||
* @param $chunkZ int
|
* @param int $chunkX
|
||||||
* @param $random pocketmine\utils\Random
|
* @param int $chunkZ
|
||||||
|
* @param Random $random
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function populate(ChunkManager $level, $chunkX, $chunkZ, Random $random) {
|
public function populate(ChunkManager $level, $chunkX, $chunkZ, Random $random) {
|
||||||
$this->level = $level;
|
$this->level = $level;
|
||||||
|
@ -45,11 +50,11 @@ class TemplePopulator extends AmountPopulator {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the top block (y) on an x and z axes
|
* Gets the top block (y) on an x and z axes
|
||||||
* @param $x int
|
* @param int $x
|
||||||
* @param $z int
|
* @param int $z
|
||||||
*/
|
*/
|
||||||
protected function getHighestWorkableBlock($x, $z) {
|
protected function getHighestWorkableBlock($x, $z) {
|
||||||
for ($y = Level::Y_MAX - 1; $y > 0; --$y) {
|
for($y = Level::Y_MAX - 1; $y > 0; -- $y) {
|
||||||
$b = $this->level->getBlockIdAt($x, $y, $z);
|
$b = $this->level->getBlockIdAt($x, $y, $z);
|
||||||
if ($b === Block::SAND) {
|
if ($b === Block::SAND) {
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -8,8 +8,11 @@
|
||||||
* \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\
|
* \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\
|
||||||
* \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/
|
* \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/
|
||||||
* Tomorrow's pocketmine generator.
|
* Tomorrow's pocketmine generator.
|
||||||
* @author Ad5001
|
* @author Ad5001 <mail@ad5001.eu>, XenialDan <https://github.com/thebigsmileXD>
|
||||||
* @link https://github.com/Ad5001/BetterGen
|
* @link https://github.com/Ad5001/BetterGen
|
||||||
|
* @category World Generator
|
||||||
|
* @api 3.0.0
|
||||||
|
* @version 1.1
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Ad5001\BetterGen\populator;
|
namespace Ad5001\BetterGen\populator;
|
||||||
|
@ -31,6 +34,7 @@ class TreePopulator extends AmountPopulator {
|
||||||
];
|
];
|
||||||
/** @var ChunkManager */
|
/** @var ChunkManager */
|
||||||
protected $level;
|
protected $level;
|
||||||
|
/** @var int */
|
||||||
protected $type;
|
protected $type;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -38,7 +42,7 @@ class TreePopulator extends AmountPopulator {
|
||||||
*/
|
*/
|
||||||
public function __construct($type = 0) {
|
public function __construct($type = 0) {
|
||||||
$this->type = $type;
|
$this->type = $type;
|
||||||
if (Main::isOtherNS()) {
|
if(Main::isOtherNS()) {
|
||||||
self::$types = [
|
self::$types = [
|
||||||
"pocketmine\\level\\generator\\normal\\object\\OakTree",
|
"pocketmine\\level\\generator\\normal\\object\\OakTree",
|
||||||
"pocketmine\\level\\generator\\normal\\object\\BirchTree",
|
"pocketmine\\level\\generator\\normal\\object\\BirchTree",
|
||||||
|
@ -47,17 +51,20 @@ class TreePopulator extends AmountPopulator {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Populate the chunk
|
* Populates the chunk
|
||||||
* @param $level pocketmine\level\ChunkManager
|
*
|
||||||
* @param $chunkX int
|
* @param ChunkManager $level
|
||||||
* @param $chunkZ int
|
* @param int $chunkX
|
||||||
* @param $random pocketmine\utils\Random
|
* @param int $chunkZ
|
||||||
|
* @param Random $random
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function populate(ChunkManager $level, $chunkX, $chunkZ, Random $random) {
|
public function populate(ChunkManager $level, $chunkX, $chunkZ, Random $random) {
|
||||||
$this->level = $level;
|
$this->level = $level;
|
||||||
$amount = $this->getAmount($random);
|
$amount = $this->getAmount($random);
|
||||||
for ($i = 0; $i < $amount; $i++) {
|
for($i = 0; $i < $amount; $i++) {
|
||||||
$x = $random->nextRange($chunkX << 4, ($chunkX << 4) + 15);
|
$x = $random->nextRange($chunkX << 4, ($chunkX << 4) + 15);
|
||||||
$z = $random->nextRange($chunkZ << 4, ($chunkZ << 4) + 15);
|
$z = $random->nextRange($chunkZ << 4, ($chunkZ << 4) + 15);
|
||||||
$y = $this->getHighestWorkableBlock($x, $z);
|
$y = $this->getHighestWorkableBlock($x, $z);
|
||||||
|
@ -73,16 +80,16 @@ class TreePopulator extends AmountPopulator {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the top block (y) on an x and z axes
|
* Gets the top block (y) on an x and z axes
|
||||||
* @param $x int
|
* @param int $x
|
||||||
* @param $z int
|
* @param int $z
|
||||||
*/
|
*/
|
||||||
protected function getHighestWorkableBlock($x, $z) {
|
protected function getHighestWorkableBlock($x, $z) {
|
||||||
for ($y = Level::Y_MAX - 1; $y > 0; --$y) {
|
for($y = Level::Y_MAX - 1; $y > 0; -- $y) {
|
||||||
$b = $this->level->getBlockIdAt($x, $y, $z);
|
$b = $this->level->getBlockIdAt($x, $y, $z);
|
||||||
if ($b === Block::DIRT or $b === Block::GRASS or $b === Block::PODZOL) {
|
if ($b === Block::DIRT or $b === Block::GRASS or $b === Block::PODZOL) {
|
||||||
break;
|
break;
|
||||||
} elseif ($b !== 0 and $b !== Block::SNOW_LAYER) {
|
} elseif ($b !== 0 and $b !== Block::SNOW_LAYER) {
|
||||||
return -1;
|
return - 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,8 +8,11 @@
|
||||||
* \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\
|
* \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\
|
||||||
* \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/
|
* \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/
|
||||||
* Tomorrow's pocketmine generator.
|
* Tomorrow's pocketmine generator.
|
||||||
* @author Ad5001
|
* @author Ad5001 <mail@ad5001.eu>, XenialDan <https://github.com/thebigsmileXD>
|
||||||
* @link https://github.com/Ad5001/BetterGen
|
* @link https://github.com/Ad5001/BetterGen
|
||||||
|
* @category World Generator
|
||||||
|
* @api 3.0.0
|
||||||
|
* @version 1.1
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Ad5001\BetterGen\populator;
|
namespace Ad5001\BetterGen\populator;
|
||||||
|
@ -24,12 +27,15 @@ class WellPopulator extends AmountPopulator {
|
||||||
/** @var ChunkManager */
|
/** @var ChunkManager */
|
||||||
protected $level;
|
protected $level;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Populate the chunk
|
* Populates the chunk
|
||||||
* @param $level pocketmine\level\ChunkManager
|
*
|
||||||
* @param $chunkX int
|
* @param ChunkManager $level
|
||||||
* @param $chunkZ int
|
* @param int $chunkX
|
||||||
* @param $random pocketmine\utils\Random
|
* @param int $chunkZ
|
||||||
|
* @param Random $random
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function populate(ChunkManager $level, $chunkX, $chunkZ, Random $random) {
|
public function populate(ChunkManager $level, $chunkX, $chunkZ, Random $random) {
|
||||||
$this->level = $level;
|
$this->level = $level;
|
||||||
|
@ -45,11 +51,11 @@ class WellPopulator extends AmountPopulator {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the top block (y) on an x and z axes
|
* Gets the top block (y) on an x and z axes
|
||||||
* @param $x int
|
* @param int $x
|
||||||
* @param $z int
|
* @param int $z
|
||||||
*/
|
*/
|
||||||
protected function getHighestWorkableBlock($x, $z) {
|
protected function getHighestWorkableBlock($x, $z) {
|
||||||
for ($y = Level::Y_MAX - 1; $y > 0; --$y) {
|
for($y = Level::Y_MAX - 1; $y > 0; -- $y) {
|
||||||
$b = $this->level->getBlockIdAt($x, $y, $z);
|
$b = $this->level->getBlockIdAt($x, $y, $z);
|
||||||
if ($b === Block::SAND) {
|
if ($b === Block::SAND) {
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -8,32 +8,38 @@
|
||||||
* \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\
|
* \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\
|
||||||
* \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/
|
* \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/
|
||||||
* Tomorrow's pocketmine generator.
|
* Tomorrow's pocketmine generator.
|
||||||
* @author Ad5001
|
* @author Ad5001 <mail@ad5001.eu>, XenialDan <https://github.com/thebigsmileXD>
|
||||||
* @link https://github.com/Ad5001/BetterGen
|
* @link https://github.com/Ad5001/BetterGen
|
||||||
|
* @category World Generator
|
||||||
|
* @api 3.0.0
|
||||||
|
* @version 1.1
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Ad5001\BetterGen\structure;
|
namespace Ad5001\BetterGen\structure;
|
||||||
|
|
||||||
use pocketmine\block\Block;
|
use pocketmine\block\Block;
|
||||||
use pocketmine\level\ChunkManager;
|
use pocketmine\level\ChunkManager;
|
||||||
use pocketmine\level\generator\object\Object;
|
use pocketmine\level\generator\object\PopulatorObject;
|
||||||
use pocketmine\math\Vector3;
|
use pocketmine\math\Vector3;
|
||||||
use pocketmine\utils\Random;
|
use pocketmine\utils\Random;
|
||||||
|
|
||||||
class Bush extends Object {
|
class Bush extends PopulatorObject {
|
||||||
public $overridable = [
|
public $overridable = [
|
||||||
Block::AIR => true,
|
Block::AIR => true,
|
||||||
17 => true,
|
17 => true,
|
||||||
Block::SNOW_LAYER => true,
|
Block::SNOW_LAYER => true,
|
||||||
Block::LOG2 => true
|
Block::LOG2 => true
|
||||||
];
|
];
|
||||||
|
/** @var int[] */
|
||||||
protected $leaf;
|
protected $leaf;
|
||||||
|
/** @var int */
|
||||||
protected $height;
|
protected $height;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs the class
|
* Constructs the class
|
||||||
* @param $leafId int
|
*
|
||||||
* @param $leafData int
|
* @param int $leafId
|
||||||
|
* @param int $leafData
|
||||||
*/
|
*/
|
||||||
public function __construct($leafId = Block::LEAVES, $leafData = 0) {
|
public function __construct($leafId = Block::LEAVES, $leafData = 0) {
|
||||||
$this->leaf = [
|
$this->leaf = [
|
||||||
|
@ -44,18 +50,20 @@ class Bush extends Object {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Places a bush
|
* Places a bush
|
||||||
* @param $level pocketmine\level\ChunkManager
|
*
|
||||||
* @param $x int
|
* @param ChunkManager $level
|
||||||
* @param $y int
|
* @param int $x
|
||||||
* @param $z int
|
* @param int $y
|
||||||
* @param $random pocketmine\utils\Random
|
* @param int $z
|
||||||
|
* @param Random $random
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function placeObject(ChunkManager $level, $x, $y, $z, Random $random) {
|
public function placeObject(ChunkManager $level, $x, $y, $z, Random $random) {
|
||||||
$number = $random->nextBoundedInt(6);
|
$number = $random->nextBoundedInt(6);
|
||||||
$pos = new Vector3($x, $y, $z);
|
$pos = new Vector3($x, $y, $z);
|
||||||
$this->placeLeaf($pos->x, $pos->y, $pos->z, $level);
|
$this->placeLeaf($pos->x, $pos->y, $pos->z, $level);
|
||||||
for ($i = 0; $i < $number; $i++) {
|
for($i = 0; $i < $number; $i ++) {
|
||||||
$transfer = $random->nextBoolean();
|
$transfer = $random->nextBoolean ();
|
||||||
$direction = $random->nextBoundedInt(6);
|
$direction = $random->nextBoundedInt(6);
|
||||||
$newPos = $pos->getSide($direction);
|
$newPos = $pos->getSide($direction);
|
||||||
if ($transfer)
|
if ($transfer)
|
||||||
|
@ -66,13 +74,15 @@ class Bush extends Object {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Places a leaf
|
* Places a leaf
|
||||||
* @param $x int
|
*
|
||||||
* @param $y int
|
* @param int $x
|
||||||
* @param $z int
|
* @param int $y
|
||||||
* @param $level pocketmine\level\ChunkManager
|
* @param int $z
|
||||||
|
* @param ChunkManager $level
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function placeLeaf($x, $y, $z, ChunkManager $level) {
|
public function placeLeaf($x, $y, $z, ChunkManager $level) {
|
||||||
if (isset($this->overridable[$level->getBlockIdAt($x, $y, $z)]) && !isset($this->overridable[$level->getBlockIdAt($x, $y - 1, $z)])) {
|
if (isset($this->overridable[$level->getBlockIdAt($x, $y, $z)]) && ! isset($this->overridable[$level->getBlockIdAt($x, $y - 1, $z)])) {
|
||||||
$level->setBlockIdAt($x, $y, $z, $this->leaf[0]);
|
$level->setBlockIdAt($x, $y, $z, $this->leaf[0]);
|
||||||
$level->setBlockDataAt($x, $y, $z, $this->leaf[1]);
|
$level->setBlockDataAt($x, $y, $z, $this->leaf[1]);
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,33 +8,38 @@
|
||||||
* \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\
|
* \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\
|
||||||
* \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/
|
* \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/
|
||||||
* Tomorrow's pocketmine generator.
|
* Tomorrow's pocketmine generator.
|
||||||
* @author Ad5001
|
* @author Ad5001 <mail@ad5001.eu>, XenialDan <https://github.com/thebigsmileXD>
|
||||||
* @link https://github.com/Ad5001/BetterGen
|
* @link https://github.com/Ad5001/BetterGen
|
||||||
|
* @category World Generator
|
||||||
|
* @api 3.0.0
|
||||||
|
* @version 1.1
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Ad5001\BetterGen\structure;
|
namespace Ad5001\BetterGen\structure;
|
||||||
|
|
||||||
use pocketmine\block\Block;
|
use pocketmine\block\Block;
|
||||||
use pocketmine\level\ChunkManager;
|
use pocketmine\level\ChunkManager;
|
||||||
use pocketmine\level\generator\object\Object;
|
use pocketmine\level\generator\object\PopulatorObject;
|
||||||
use pocketmine\utils\Random;
|
use pocketmine\utils\Random;
|
||||||
|
|
||||||
class Cactus extends Object {
|
class Cactus extends PopulatorObject {
|
||||||
|
|
||||||
|
protected $totalHeight;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if a cactus is placeable
|
* Checks if a cactus is placeable
|
||||||
* @param $level pocketmine\level\ChunkManager
|
*
|
||||||
* @param $x int
|
* @param ChunkManager $level
|
||||||
* @param $y int
|
* @param int $x
|
||||||
* @param $z int
|
* @param int $y
|
||||||
* @param $random pocketmine\utils\Random
|
* @param int $z
|
||||||
|
* @param Random $random
|
||||||
|
* @return bool
|
||||||
*/
|
*/
|
||||||
private $totalHeight;
|
|
||||||
|
|
||||||
public function canPlaceObject(ChunkManager $level, int $x, int $y, int $z, Random $random): bool {
|
public function canPlaceObject(ChunkManager $level, int $x, int $y, int $z, Random $random): bool {
|
||||||
$this->totalHeight = 1 + $random->nextBoundedInt(3);
|
$this->totalHeight = 1 + $random->nextBoundedInt(3);
|
||||||
$below = $level->getBlockIdAt($x, $y - 1, $z);
|
$below = $level->getBlockIdAt($x, $y - 1, $z);
|
||||||
for ($yy = $y; $yy <= $y + $this->totalHeight; $yy++) {
|
for($yy = $y; $yy <= $y + $this->totalHeight; $yy ++) {
|
||||||
if ($level->getBlockIdAt($x, $yy, $z) !== Block::AIR || ($below !== Block::SAND && $below !== Block::CACTUS) || ($level->getBlockIdAt($x - 1, $yy, $z) !== Block::AIR || $level->getBlockIdAt($x + 1, $yy, $z) !== Block::AIR || $level->getBlockIdAt($x, $yy, $z - 1) !== Block::AIR || $level->getBlockIdAt($x, $yy, $z + 1) !== Block::AIR)) {
|
if ($level->getBlockIdAt($x, $yy, $z) !== Block::AIR || ($below !== Block::SAND && $below !== Block::CACTUS) || ($level->getBlockIdAt($x - 1, $yy, $z) !== Block::AIR || $level->getBlockIdAt($x + 1, $yy, $z) !== Block::AIR || $level->getBlockIdAt($x, $yy, $z - 1) !== Block::AIR || $level->getBlockIdAt($x, $yy, $z + 1) !== Block::AIR)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -44,13 +49,15 @@ class Cactus extends Object {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Places a cactus
|
* Places a cactus
|
||||||
* @param $level pocketmine\level\ChunkManager
|
*
|
||||||
* @param $x int
|
* @param ChunkManager $level
|
||||||
* @param $y int
|
* @param int $x
|
||||||
* @param $z int
|
* @param int $y
|
||||||
|
* @param int $z
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function placeObject(ChunkManager $level, int $x, int $y, int $z) {
|
public function placeObject(ChunkManager $level, int $x, int $y, int $z) {
|
||||||
for ($yy = 0; $yy < $this->totalHeight; $yy++) {
|
for($yy = 0; $yy < $this->totalHeight; $yy ++) {
|
||||||
if ($level->getBlockIdAt($x, $y + $yy, $z) != Block::AIR) {
|
if ($level->getBlockIdAt($x, $y + $yy, $z) != Block::AIR) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
101
src/Ad5001/BetterGen/structure/Dungeons.php
Normal file
101
src/Ad5001/BetterGen/structure/Dungeons.php
Normal file
|
@ -0,0 +1,101 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* ____ __ __ ____
|
||||||
|
* /\ _`\ /\ \__ /\ \__ /\ _`\
|
||||||
|
* \ \ \L\ \ __ \ \ ,_\\ \ ,_\ __ _ __ \ \ \L\_\ __ ___
|
||||||
|
* \ \ _ <' /'__`\\ \ \/ \ \ \/ /'__`\/\`'__\\ \ \L_L /'__`\ /' _ `\
|
||||||
|
* \ \ \L\ \/\ __/ \ \ \_ \ \ \_ /\ __/\ \ \/ \ \ \/, \/\ __/ /\ \/\ \
|
||||||
|
* \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\
|
||||||
|
* \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/
|
||||||
|
* Tomorrow's pocketmine generator.
|
||||||
|
* @author Ad5001 <mail@ad5001.eu>, XenialDan <https://github.com/thebigsmileXD>
|
||||||
|
* @link https://github.com/Ad5001/BetterGen
|
||||||
|
* @category World Generator
|
||||||
|
* @api 3.0.0
|
||||||
|
* @version 1.1
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Ad5001\BetterGen\structure;
|
||||||
|
|
||||||
|
use Ad5001\BetterGen\utils\BuildingUtils;
|
||||||
|
use pocketmine\block\Block;
|
||||||
|
use pocketmine\level\ChunkManager;
|
||||||
|
use pocketmine\level\generator\object\PopulatorObject;
|
||||||
|
use pocketmine\math\Vector3;
|
||||||
|
use pocketmine\utils\Random;
|
||||||
|
|
||||||
|
class Dungeons extends PopulatorObject {
|
||||||
|
public $overridable = [
|
||||||
|
Block::AIR => true,
|
||||||
|
17 => true,
|
||||||
|
Block::SNOW_LAYER => true,
|
||||||
|
Block::LOG2 => true
|
||||||
|
];
|
||||||
|
/** @var int */
|
||||||
|
protected $height;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Places a bush
|
||||||
|
*
|
||||||
|
* @param ChunkManager $level
|
||||||
|
* @param int $x
|
||||||
|
* @param int $y
|
||||||
|
* @param int $z
|
||||||
|
* @param Random $random
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function placeObject(ChunkManager $level, $x, $y, $z, Random $random) {
|
||||||
|
$xDepth = 3 + $random->nextBoundedInt(3);
|
||||||
|
$zDepth = 3 + $random->nextBoundedInt(3);
|
||||||
|
// echo "Building dungeon at $x, $y, $z\n";
|
||||||
|
// Building walls
|
||||||
|
list($pos1, $pos2) = BuildingUtils::minmax(new Vector3($x + $xDepth, $y, $z + $zDepth), new Vector3($x - $xDepth, $y + 5, $z - $zDepth));
|
||||||
|
for($y = $pos1->y; $y >= $pos2->y; $y--) {
|
||||||
|
for($x = $pos1->x; $x >= $pos2->x; $x--) {
|
||||||
|
for($z = $pos1->z; $z >= $pos2->z; $z--) { // Cleaning the area first
|
||||||
|
$level->setBlockIdAt($x, $y, $z, Block::AIR);
|
||||||
|
}
|
||||||
|
// Starting random walls.
|
||||||
|
if($random->nextBoolean()) {
|
||||||
|
$level->setBlockIdAt($x, $y, $pos1->z, Block::MOSS_STONE);
|
||||||
|
} else {
|
||||||
|
$level->setBlockIdAt($x, $y, $pos1->z, Block::COBBLESTONE);
|
||||||
|
}
|
||||||
|
if($random->nextBoolean()) {
|
||||||
|
$level->setBlockIdAt($x, $y, $pos2->z, Block::MOSS_STONE);
|
||||||
|
} else {
|
||||||
|
$level->setBlockIdAt($x, $y, $pos2->z, Block::COBBLESTONE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for($z = $pos1->z; $z >= $pos2->z; $z--) {
|
||||||
|
if($random->nextBoolean()) {
|
||||||
|
$level->setBlockIdAt($pos1->x, $y, $z, Block::MOSS_STONE);
|
||||||
|
} else {
|
||||||
|
$level->setBlockIdAt($pos1->x, $y, $z, Block::COBBLESTONE);
|
||||||
|
}
|
||||||
|
if($random->nextBoolean()) {
|
||||||
|
$level->setBlockIdAt($pos2->x, $y, $z, Block::MOSS_STONE);
|
||||||
|
} else {
|
||||||
|
$level->setBlockIdAt($pos2->x, $y, $z, Block::COBBLESTONE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Bottom & top
|
||||||
|
for($x = $pos1->x; $x >= $pos2->x; $x--) {
|
||||||
|
for($z = $pos1->z; $z >= $pos2->z; $z--) {
|
||||||
|
if($random->nextBoolean()) {
|
||||||
|
$level->setBlockIdAt($x, $pos1->y, $z, Block::MOSS_STONE);
|
||||||
|
} else {
|
||||||
|
$level->setBlockIdAt($x, $pos1->y, $z, Block::COBBLESTONE);
|
||||||
|
}
|
||||||
|
if($random->nextBoolean()) {
|
||||||
|
$level->setBlockIdAt($x, $pos2->y, $z, Block::MOSS_STONE);
|
||||||
|
} else {
|
||||||
|
$level->setBlockIdAt($x, $pos2->y, $z, Block::COBBLESTONE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Setting the spawner
|
||||||
|
$level->setBlockIdAt($x, $y + 1, $z, Block::MOB_SPAWNER);
|
||||||
|
}
|
||||||
|
}
|
|
@ -8,8 +8,11 @@
|
||||||
* \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\
|
* \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\
|
||||||
* \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/
|
* \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/
|
||||||
* Tomorrow's pocketmine generator.
|
* Tomorrow's pocketmine generator.
|
||||||
* @author Ad5001
|
* @author Ad5001 <mail@ad5001.eu>, XenialDan <https://github.com/thebigsmileXD>
|
||||||
* @link https://github.com/Ad5001/BetterGen
|
* @link https://github.com/Ad5001/BetterGen
|
||||||
|
* @category World Generator
|
||||||
|
* @api 3.0.0
|
||||||
|
* @version 1.1
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Ad5001\BetterGen\structure;
|
namespace Ad5001\BetterGen\structure;
|
||||||
|
@ -17,13 +20,13 @@ namespace Ad5001\BetterGen\structure;
|
||||||
use Ad5001\BetterGen\utils\BuildingUtils;
|
use Ad5001\BetterGen\utils\BuildingUtils;
|
||||||
use pocketmine\block\Block;
|
use pocketmine\block\Block;
|
||||||
use pocketmine\level\ChunkManager;
|
use pocketmine\level\ChunkManager;
|
||||||
use pocketmine\level\generator\object\Object;
|
use pocketmine\level\generator\object\PopulatorObject;
|
||||||
use pocketmine\level\generator\object\Tree as ObjectTree;
|
use pocketmine\level\generator\object\Tree as ObjectTree;
|
||||||
use pocketmine\math\Vector3;
|
use pocketmine\math\Vector3;
|
||||||
use pocketmine\utils\Random;
|
use pocketmine\utils\Random;
|
||||||
|
|
||||||
|
|
||||||
class FallenTree extends Object {
|
class FallenTree extends PopulatorObject {
|
||||||
public static $overridable = [
|
public static $overridable = [
|
||||||
Block::AIR => true,
|
Block::AIR => true,
|
||||||
6 => true,
|
6 => true,
|
||||||
|
@ -34,68 +37,73 @@ class FallenTree extends Object {
|
||||||
Block::SNOW_LAYER => true,
|
Block::SNOW_LAYER => true,
|
||||||
Block::LOG2 => true,
|
Block::LOG2 => true,
|
||||||
Block::LEAVES2 => true,
|
Block::LEAVES2 => true,
|
||||||
Block::CACTUS => true
|
Block::CACTUS => true];
|
||||||
];
|
/** @var Tree */
|
||||||
protected $tree;
|
protected $tree;
|
||||||
|
/** @var int */
|
||||||
protected $direction;
|
protected $direction;
|
||||||
|
/** @var Random */
|
||||||
protected $random;
|
protected $random;
|
||||||
private $length = 0;
|
/** @var int */
|
||||||
|
protected $length = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs the class
|
* Constructs the class
|
||||||
* @param $tree ObjectTree
|
*
|
||||||
* @throws Exeption
|
* @param ObjectTree $tree
|
||||||
*/
|
*/
|
||||||
public function __construct(ObjectTree $tree) {
|
public function __construct(ObjectTree $tree) {
|
||||||
$this->tree = $tree;
|
$this->tree = $tree;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Places a fallen tree
|
* Checks the placement a fallen tree
|
||||||
* @param $level pocketmine\level\ChunkManager
|
*
|
||||||
* @param $x int
|
* @param ChunkManager $level
|
||||||
* @param $y int
|
* @param int $x
|
||||||
* @param $z int
|
* @param int $y
|
||||||
* @param $random pocketmine\utils\Random
|
* @param int $z
|
||||||
|
* @param Random $random
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function canPlaceObject(ChunkManager $level, $x, $y, $z, Random $random) {
|
public function canPlaceObject(ChunkManager $level, $x, $y, $z, Random $random) {
|
||||||
echo "Checking at $x $y $z FallenTree\n";
|
//echo "Checking at $x $y $z FallenTree\n";
|
||||||
$randomHeight = round($random->nextBoundedInt($this->tree->trunkHeight < 6 ? 6 : $this->tree->trunkHeight) - ($this->tree->trunkHeight < 6 ? 3 : $this->tree->trunkHeight / 2));
|
$randomHeight = round($random->nextBoundedInt($this->tree->treeHeight < 6 ? 6 : $this->tree->treeHeight) - ($this->tree->treeHeight < 6 ? 3 : $this->tree->treeHeight / 2));
|
||||||
$this->length = ($this->tree->trunkHeight ?? 5) + $randomHeight;
|
$this->length = ($this->tree->treeHeight ?? 5) + $randomHeight;
|
||||||
$this->direction = $random->nextBoundedInt(4);
|
$this->direction = $random->nextBoundedInt(4);
|
||||||
$this->random = $random;
|
$this->random = $random;
|
||||||
switch ($this->direction) {
|
switch ($this->direction) {
|
||||||
case 0:
|
case 0:
|
||||||
case 1:// Z+
|
case 1:// Z+
|
||||||
$return = array_merge(BuildingUtils::fillCallback(new Vector3($x, $y, $z), new Vector3($x, $y, $z + $this->length), function ($v3, $level) {
|
$return = array_merge(BuildingUtils::fillCallback(new Vector3($x, $y, $z), new Vector3($x, $y, $z + $this->length), function($v3, $level) {
|
||||||
if (!isset(\Ad5001\BetterGen\structure\FallenTree::$overridable[$level->getBlockIdAt($v3->x, $v3->y, $v3->z)])) {
|
if(!isset(\Ad5001\BetterGen\structure\FallenTree::$overridable[$level->getBlockIdAt($v3->x, $v3->y, $v3->z)])) {
|
||||||
echo "$v3 is not overwritable (" . $level->getBlockIdAt($v3->x, $v3->y, $v3->z) . ").\n";
|
//echo "$v3 is not overwritable (" . $level->getBlockIdAt($v3->x, $v3->y, $v3->z) . ").\n";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}, $level), BuildingUtils::fillCallback(new Vector3($x, $y - 1, $z), new Vector3($x, $y - 1, $z + $this->length), function ($v3, $level) {
|
}, $level), BuildingUtils::fillCallback(new Vector3($x, $y - 1, $z), new Vector3($x, $y - 1, $z + $this->length), function($v3, $level) {
|
||||||
if (isset(\Ad5001\BetterGen\structure\FallenTree::$overridable[$level->getBlockIdAt($v3->x, $v3->y, $v3->z)])) {
|
if(isset(\Ad5001\BetterGen\structure\FallenTree::$overridable[$level->getBlockIdAt($v3->x, $v3->y, $v3->z)])) {
|
||||||
echo "$v3 is overwritable (" . $level->getBlockIdAt($v3->x, $v3->y, $v3->z) . ").\n";
|
//echo "$v3 is overwritable (" . $level->getBlockIdAt($v3->x, $v3->y, $v3->z) . ").\n";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}, $level));
|
}, $level));
|
||||||
if (in_array(false, $return, true)) {
|
if(in_array(false, $return, true)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
case 3: // X+
|
case 3: // X+
|
||||||
$return = array_merge(BuildingUtils::fillCallback(new Vector3($x, $y, $z), new Vector3($x + $this->length, $y, $z), function ($v3, $level) {
|
$return = array_merge(BuildingUtils::fillCallback(new Vector3($x, $y, $z), new Vector3($x + $this->length, $y, $z), function($v3, $level) {
|
||||||
if (!isset(\Ad5001\BetterGen\structure\FallenTree::$overridable[$level->getBlockIdAt($v3->x, $v3->y, $v3->z)])) {
|
if(!isset(\Ad5001\BetterGen\structure\FallenTree::$overridable[$level->getBlockIdAt($v3->x, $v3->y, $v3->z)])) {
|
||||||
echo "$v3 is not overwritable (" . $level->getBlockIdAt($v3->x, $v3->y, $v3->z) . ").\n";
|
//echo "$v3 is not overwritable (" . $level->getBlockIdAt($v3->x, $v3->y, $v3->z) . ").\n";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}, $level), BuildingUtils::fillCallback(new Vector3($x, $y - 1, $z), new Vector3($x + $this->length, $y - 1, $z), function ($v3, $level) {
|
}, $level), BuildingUtils::fillCallback(new Vector3($x, $y - 1, $z), new Vector3($x + $this->length, $y - 1, $z), function($v3, $level) {
|
||||||
if (isset(\Ad5001\BetterGen\structure\FallenTree::$overridable[$level->getBlockIdAt($v3->x, $v3->y, $v3->z)])) {
|
if(isset(\Ad5001\BetterGen\structure\FallenTree::$overridable[$level->getBlockIdAt($v3->x, $v3->y, $v3->z)])) {
|
||||||
echo "$v3 is overwritable (" . $level->getBlockIdAt($v3->x, $v3->y, $v3->z) . ").\n";
|
//echo "$v3 is overwritable (" . $level->getBlockIdAt($v3->x, $v3->y, $v3->z) . ").\n";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}, $level));
|
}, $level));
|
||||||
if (in_array(false, $return, true)) {
|
if(in_array(false, $return, true)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -105,13 +113,15 @@ class FallenTree extends Object {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Places a fallen tree
|
* Places a fallen tree
|
||||||
* @param $level pocketmine\level\ChunkManager
|
*
|
||||||
* @param $x int
|
* @param ChunkManager $level
|
||||||
* @param $y int
|
* @param int $x
|
||||||
* @param $z int
|
* @param int $y
|
||||||
|
* @param int $z
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function placeObject(ChunkManager $level, $x, $y, $z) {
|
public function placeObject(ChunkManager $level, $x, $y, $z) {
|
||||||
echo "Placing at $x $y $z FallenTree D: $this->direction, L: $this->length\n";
|
//echo "Placing at $x $y $z FallenTree D: $this->direction, L: $this->length\n";
|
||||||
switch ($this->direction) {
|
switch ($this->direction) {
|
||||||
case 0:
|
case 0:
|
||||||
$level->setBlockIdAt($x, $y, $z, $this->tree->trunkBlock);
|
$level->setBlockIdAt($x, $y, $z, $this->tree->trunkBlock);
|
||||||
|
@ -148,14 +158,16 @@ class FallenTree extends Object {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Places a Block
|
* Places a block
|
||||||
* @param $x int
|
*
|
||||||
* @param $y int
|
* @param int $x
|
||||||
* @param $z int
|
* @param int $y
|
||||||
* @param $level pocketmine\level\ChunkManager
|
* @param int $z
|
||||||
|
* @param ChunkManager $level
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function placeBlock($x, $y, $z, ChunkManager $level) {
|
public function placeBlock($x, $y, $z, ChunkManager $level) {
|
||||||
if (isset(self::$overridable[$level->getBlockIdAt($x, $y, $z)]) && !isset(self::$overridable[$level->getBlockIdAt($x, $y - 1, $z)])) {
|
if (isset(self::$overridable[$level->getBlockIdAt($x, $y, $z)]) && ! isset(self::$overridable[$level->getBlockIdAt($x, $y - 1, $z)])) {
|
||||||
$level->setBlockIdAt($x, $y, $z, $this->trunk[0]);
|
$level->setBlockIdAt($x, $y, $z, $this->trunk[0]);
|
||||||
$level->setBlockDataAt($x, $y, $z, $this->trunk[1]);
|
$level->setBlockDataAt($x, $y, $z, $this->trunk[1]);
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,18 +8,21 @@
|
||||||
* \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\
|
* \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\
|
||||||
* \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/
|
* \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/
|
||||||
* Tomorrow's pocketmine generator.
|
* Tomorrow's pocketmine generator.
|
||||||
* @author Ad5001
|
* @author Ad5001 <mail@ad5001.eu>, XenialDan <https://github.com/thebigsmileXD>
|
||||||
* @link https://github.com/Ad5001/BetterGen
|
* @link https://github.com/Ad5001/BetterGen
|
||||||
|
* @category World Generator
|
||||||
|
* @api 3.0.0
|
||||||
|
* @version 1.1
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Ad5001\BetterGen\structure;
|
namespace Ad5001\BetterGen\structure;
|
||||||
|
|
||||||
use pocketmine\block\Block;
|
use pocketmine\block\Block;
|
||||||
use pocketmine\level\ChunkManager;
|
use pocketmine\level\ChunkManager;
|
||||||
use pocketmine\level\generator\object\Object;
|
use pocketmine\level\generator\object\PopulatorObject;
|
||||||
use pocketmine\utils\Random;
|
use pocketmine\utils\Random;
|
||||||
|
|
||||||
class Igloo extends Object {
|
class Igloo extends PopulatorObject {
|
||||||
public $overridable = [
|
public $overridable = [
|
||||||
Block::AIR => true,
|
Block::AIR => true,
|
||||||
6 => true,
|
6 => true,
|
||||||
|
@ -31,29 +34,76 @@ class Igloo extends Object {
|
||||||
Block::LOG2 => true,
|
Block::LOG2 => true,
|
||||||
Block::LEAVES2 => true
|
Block::LEAVES2 => true
|
||||||
];
|
];
|
||||||
|
/** @var int */
|
||||||
protected $direction;
|
protected $direction;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Places an igloo
|
* Checks if an igloo is placable
|
||||||
|
*
|
||||||
* @param ChunkManager $level
|
* @param ChunkManager $level
|
||||||
* @param $x
|
* @param int $x
|
||||||
* @param $y
|
* @param int $y
|
||||||
* @param $z
|
* @param int $z
|
||||||
* @param Random $random
|
* @param Random $random
|
||||||
* @return bool placed
|
* @return void
|
||||||
|
*/
|
||||||
|
public function canPlaceObject(ChunkManager $level, $x, $y, $z, Random $random) {
|
||||||
|
$this->direction = $random->nextBoundedInt(4);
|
||||||
|
switch ($this->direction) {
|
||||||
|
case 0 : // Entrance is x+
|
||||||
|
for($xx = $x - 3; $xx <= $x + 4; $xx ++)
|
||||||
|
for($yy = $y + 1; $yy <= $y + 4; $yy ++)
|
||||||
|
for($zz = $z - 3; $zz <= $z + 3; $zz ++)
|
||||||
|
if (! isset($this->overridable[$level->getBlockIdAt($xx, $yy, $zz)]))
|
||||||
|
return false;
|
||||||
|
break;
|
||||||
|
case 1 : // Entrance is x-
|
||||||
|
for($xx = $x - 4; $xx <= $x + 3; $xx ++)
|
||||||
|
for($yy = $y + 1; $yy <= $y + 4; $yy ++)
|
||||||
|
for($zz = $z - 3; $zz <= $z + 3; $zz ++)
|
||||||
|
if (! isset($this->overridable[$level->getBlockIdAt($xx, $yy, $zz)]))
|
||||||
|
return false;
|
||||||
|
break;
|
||||||
|
case 2 : // Entrance is z+
|
||||||
|
for($xx = $x - 3; $xx <= $x + 3; $xx ++)
|
||||||
|
for($yy = $y + 1; $yy <= $y + 4; $yy ++)
|
||||||
|
for($zz = $z - 3; $zz <= $z + 4; $zz ++)
|
||||||
|
if (! isset($this->overridable[$level->getBlockIdAt($xx, $yy, $zz)]))
|
||||||
|
return false;
|
||||||
|
break;
|
||||||
|
case 3 : // Entrance is z-
|
||||||
|
for($xx = $x - 3; $xx <= $x + 3; $xx ++)
|
||||||
|
for($yy = $y + 1; $yy <= $y + 4; $yy ++)
|
||||||
|
for($zz = $z - 4; $zz <= $z + 3; $zz ++)
|
||||||
|
if (! isset($this->overridable[$level->getBlockIdAt($xx, $yy, $zz)]))
|
||||||
|
return false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Places an igloo
|
||||||
|
*
|
||||||
|
* @param ChunkManager $level
|
||||||
|
* @param int $x
|
||||||
|
* @param int $y
|
||||||
|
* @param int $z
|
||||||
|
* @param Random $random
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function placeObject(ChunkManager $level, $x, $y, $z, Random $random) {
|
public function placeObject(ChunkManager $level, $x, $y, $z, Random $random) {
|
||||||
if (!isset($this->direction) && !$this->canPlaceObject($level, $x, $y, $z, $random))
|
if (! isset($this->direction) && ! $this->canPlaceObject($level, $x, $y, $z, $random))
|
||||||
return false;
|
return false;
|
||||||
switch ($this->direction) {
|
switch ($this->direction) {
|
||||||
case 0 : // Entrance is x+
|
case 0 : // Entrance is x+
|
||||||
// Ground
|
// Ground
|
||||||
for ($xx = $x - 3; $xx <= $x + 4; $xx++)
|
for($xx = $x - 3; $xx <= $x + 4; $xx ++)
|
||||||
for ($zz = $z - 3; $zz <= $z + 3; $zz++)
|
for($zz = $z - 3; $zz <= $z + 3; $zz ++)
|
||||||
if (!isset($this->overridable[$level->getBlockIdAt($xx, $y, $zz)]))
|
if (! isset($this->overridable[$level->getBlockIdAt($xx, $y, $zz)]))
|
||||||
$level->setBlockIdAt($xx, $y, $zz, Block::SNOW_BLOCK);
|
$level->setBlockIdAt($xx, $y, $zz, Block::SNOW_BLOCK);
|
||||||
// Entrance
|
// Entrance
|
||||||
for ($i = 0; $i < 2; $i++) {
|
for($i = 0; $i < 2; $i ++) {
|
||||||
$level->setBlockIdAt($x + 3 + $i, $y, $z, Block::SNOW_BLOCK);
|
$level->setBlockIdAt($x + 3 + $i, $y, $z, Block::SNOW_BLOCK);
|
||||||
$level->setBlockIdAt($x + 3 + $i, $y + 3, $z, Block::SNOW_BLOCK);
|
$level->setBlockIdAt($x + 3 + $i, $y + 3, $z, Block::SNOW_BLOCK);
|
||||||
$level->setBlockIdAt($x + 3 + $i, $y + 1, $z + 1, Block::SNOW_BLOCK);
|
$level->setBlockIdAt($x + 3 + $i, $y + 1, $z + 1, Block::SNOW_BLOCK);
|
||||||
|
@ -63,13 +113,13 @@ class Igloo extends Object {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Back
|
// Back
|
||||||
for ($zz = $z - 1; $zz <= $z + 1; $zz++) {
|
for($zz = $z - 1; $zz <= $z + 1; $zz ++) {
|
||||||
$level->setBlockIdAt($x - 3, $y + 1, $zz, Block::SNOW_BLOCK);
|
$level->setBlockIdAt($x - 3, $y + 1, $zz, Block::SNOW_BLOCK);
|
||||||
$level->setBlockIdAt($x - 3, $y + 2, $zz, Block::SNOW_BLOCK);
|
$level->setBlockIdAt($x - 3, $y + 2, $zz, Block::SNOW_BLOCK);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sides
|
// Sides
|
||||||
for ($xx = $x - 1; $xx <= $x + 1; $xx++) {
|
for($xx = $x - 1; $xx <= $x + 1; $xx ++) {
|
||||||
$level->setBlockIdAt($xx, $y + 1, $z - 3, Block::SNOW_BLOCK);
|
$level->setBlockIdAt($xx, $y + 1, $z - 3, Block::SNOW_BLOCK);
|
||||||
$level->setBlockIdAt($xx, $y + 2, $z - 3, Block::SNOW_BLOCK);
|
$level->setBlockIdAt($xx, $y + 2, $z - 3, Block::SNOW_BLOCK);
|
||||||
$level->setBlockIdAt($xx, $y + 1, $z + 3, Block::SNOW_BLOCK);
|
$level->setBlockIdAt($xx, $y + 1, $z + 3, Block::SNOW_BLOCK);
|
||||||
|
@ -79,7 +129,7 @@ class Igloo extends Object {
|
||||||
$level->setBlockIdAt($x, $y + 1, $z - 3, Block::ICE);
|
$level->setBlockIdAt($x, $y + 1, $z - 3, Block::ICE);
|
||||||
|
|
||||||
// Diags
|
// Diags
|
||||||
for ($i = 1; $i <= 2; $i++) {
|
for($i = 1; $i <= 2; $i ++) {
|
||||||
$level->setBlockIdAt($x + 2, $y + $i, $z + 2, Block::SNOW_BLOCK);
|
$level->setBlockIdAt($x + 2, $y + $i, $z + 2, Block::SNOW_BLOCK);
|
||||||
$level->setBlockIdAt($x - 2, $y + $i, $z + 2, Block::SNOW_BLOCK);
|
$level->setBlockIdAt($x - 2, $y + $i, $z + 2, Block::SNOW_BLOCK);
|
||||||
$level->setBlockIdAt($x - 2, $y + $i, $z - 2, Block::SNOW_BLOCK);
|
$level->setBlockIdAt($x - 2, $y + $i, $z - 2, Block::SNOW_BLOCK);
|
||||||
|
@ -87,7 +137,7 @@ class Igloo extends Object {
|
||||||
}
|
}
|
||||||
|
|
||||||
// 2nd layer
|
// 2nd layer
|
||||||
for ($i = 0; $i < 3; $i++) {
|
for($i = 0; $i < 3; $i ++) {
|
||||||
$level->setBlockIdAt($x - 1 + $i, $y + 3, $z + 2, Block::SNOW_BLOCK);
|
$level->setBlockIdAt($x - 1 + $i, $y + 3, $z + 2, Block::SNOW_BLOCK);
|
||||||
$level->setBlockIdAt($x - 1 + $i, $y + 3, $z - 2, Block::SNOW_BLOCK);
|
$level->setBlockIdAt($x - 1 + $i, $y + 3, $z - 2, Block::SNOW_BLOCK);
|
||||||
$level->setBlockIdAt($x + 2, $y + 3, $z - 1 + $i, Block::SNOW_BLOCK);
|
$level->setBlockIdAt($x + 2, $y + 3, $z - 1 + $i, Block::SNOW_BLOCK);
|
||||||
|
@ -95,15 +145,15 @@ class Igloo extends Object {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Top
|
// Top
|
||||||
for ($xx = $x - 1; $xx <= $x + 1; $xx++)
|
for($xx = $x - 1; $xx <= $x + 1; $xx ++)
|
||||||
for ($zz = $z - 1; $zz <= $z + 1; $zz++) {
|
for($zz = $z - 1; $zz <= $z + 1; $zz ++) {
|
||||||
$level->setBlockIdAt($xx, $y + 4, $zz, Block::SNOW_BLOCK);
|
$level->setBlockIdAt($xx, $y + 4, $zz, Block::SNOW_BLOCK);
|
||||||
$level->setBlockIdAt($xx, $y, $zz, Block::SNOW_BLOCK);
|
$level->setBlockIdAt($xx, $y, $zz, Block::SNOW_BLOCK);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Carpets
|
// Carpets
|
||||||
for ($xx = $x - 2; $xx <= $x + 1; $xx++)
|
for($xx = $x - 2; $xx <= $x + 1; $xx ++)
|
||||||
for ($zz = $z - 1; $zz <= $z + 1; $zz++) {
|
for($zz = $z - 1; $zz <= $z + 1; $zz ++) {
|
||||||
$level->setBlockIdAt($xx, $y + 1, $zz, Block::CARPET);
|
$level->setBlockIdAt($xx, $y + 1, $zz, Block::CARPET);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -123,12 +173,12 @@ class Igloo extends Object {
|
||||||
// Second direction
|
// Second direction
|
||||||
case 1 : // Entrance is x-
|
case 1 : // Entrance is x-
|
||||||
// Ground
|
// Ground
|
||||||
for ($xx = $x - 4; $xx <= $x + 3; $xx++)
|
for($xx = $x - 4; $xx <= $x + 3; $xx ++)
|
||||||
for ($zz = $z - 3; $zz <= $z + 3; $zz++)
|
for($zz = $z - 3; $zz <= $z + 3; $zz ++)
|
||||||
if (!isset($this->overridable[$level->getBlockIdAt($xx, $y, $zz)]))
|
if (! isset($this->overridable[$level->getBlockIdAt($xx, $y, $zz)]))
|
||||||
$level->setBlockIdAt($xx, $y, $zz, Block::SNOW_BLOCK);
|
$level->setBlockIdAt($xx, $y, $zz, Block::SNOW_BLOCK);
|
||||||
// Entrance
|
// Entrance
|
||||||
for ($i = 0; $i < 2; $i++) {
|
for($i = 0; $i < 2; $i ++) {
|
||||||
$level->setBlockIdAt($x - 3 - $i, $y, $z, Block::SNOW_BLOCK);
|
$level->setBlockIdAt($x - 3 - $i, $y, $z, Block::SNOW_BLOCK);
|
||||||
$level->setBlockIdAt($x - 3 - $i, $y + 3, $z, Block::SNOW_BLOCK);
|
$level->setBlockIdAt($x - 3 - $i, $y + 3, $z, Block::SNOW_BLOCK);
|
||||||
$level->setBlockIdAt($x - 3 - $i, $y + 1, $z + 1, Block::SNOW_BLOCK);
|
$level->setBlockIdAt($x - 3 - $i, $y + 1, $z + 1, Block::SNOW_BLOCK);
|
||||||
|
@ -138,13 +188,13 @@ class Igloo extends Object {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Back
|
// Back
|
||||||
for ($zz = $z - 1; $zz <= $z + 1; $zz++) {
|
for($zz = $z - 1; $zz <= $z + 1; $zz ++) {
|
||||||
$level->setBlockIdAt($x + 3, $y + 1, $zz, Block::SNOW_BLOCK);
|
$level->setBlockIdAt($x + 3, $y + 1, $zz, Block::SNOW_BLOCK);
|
||||||
$level->setBlockIdAt($x + 3, $y + 2, $zz, Block::SNOW_BLOCK);
|
$level->setBlockIdAt($x + 3, $y + 2, $zz, Block::SNOW_BLOCK);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sides
|
// Sides
|
||||||
for ($xx = $x - 1; $xx <= $x + 1; $xx++) {
|
for($xx = $x - 1; $xx <= $x + 1; $xx ++) {
|
||||||
$level->setBlockIdAt($xx, $y + 1, $z - 3, Block::SNOW_BLOCK);
|
$level->setBlockIdAt($xx, $y + 1, $z - 3, Block::SNOW_BLOCK);
|
||||||
$level->setBlockIdAt($xx, $y + 2, $z - 3, Block::SNOW_BLOCK);
|
$level->setBlockIdAt($xx, $y + 2, $z - 3, Block::SNOW_BLOCK);
|
||||||
$level->setBlockIdAt($xx, $y + 1, $z + 3, Block::SNOW_BLOCK);
|
$level->setBlockIdAt($xx, $y + 1, $z + 3, Block::SNOW_BLOCK);
|
||||||
|
@ -154,7 +204,7 @@ class Igloo extends Object {
|
||||||
$level->setBlockIdAt($x, $y + 1, $z - 3, Block::ICE);
|
$level->setBlockIdAt($x, $y + 1, $z - 3, Block::ICE);
|
||||||
|
|
||||||
// Diags
|
// Diags
|
||||||
for ($i = 1; $i <= 2; $i++) {
|
for($i = 1; $i <= 2; $i ++) {
|
||||||
$level->setBlockIdAt($x + 2, $y + $i, $z + 2, Block::SNOW_BLOCK);
|
$level->setBlockIdAt($x + 2, $y + $i, $z + 2, Block::SNOW_BLOCK);
|
||||||
$level->setBlockIdAt($x - 2, $y + $i, $z + 2, Block::SNOW_BLOCK);
|
$level->setBlockIdAt($x - 2, $y + $i, $z + 2, Block::SNOW_BLOCK);
|
||||||
$level->setBlockIdAt($x - 2, $y + $i, $z - 2, Block::SNOW_BLOCK);
|
$level->setBlockIdAt($x - 2, $y + $i, $z - 2, Block::SNOW_BLOCK);
|
||||||
|
@ -162,7 +212,7 @@ class Igloo extends Object {
|
||||||
}
|
}
|
||||||
|
|
||||||
// 2nd layer
|
// 2nd layer
|
||||||
for ($i = 0; $i < 3; $i++) {
|
for($i = 0; $i < 3; $i ++) {
|
||||||
$level->setBlockIdAt($x - 1 + $i, $y + 3, $z + 2, Block::SNOW_BLOCK);
|
$level->setBlockIdAt($x - 1 + $i, $y + 3, $z + 2, Block::SNOW_BLOCK);
|
||||||
$level->setBlockIdAt($x - 1 + $i, $y + 3, $z - 2, Block::SNOW_BLOCK);
|
$level->setBlockIdAt($x - 1 + $i, $y + 3, $z - 2, Block::SNOW_BLOCK);
|
||||||
$level->setBlockIdAt($x + 2, $y + 3, $z - 1 + $i, Block::SNOW_BLOCK);
|
$level->setBlockIdAt($x + 2, $y + 3, $z - 1 + $i, Block::SNOW_BLOCK);
|
||||||
|
@ -170,15 +220,15 @@ class Igloo extends Object {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Top
|
// Top
|
||||||
for ($xx = $x - 1; $xx <= $x + 1; $xx++)
|
for($xx = $x - 1; $xx <= $x + 1; $xx ++)
|
||||||
for ($zz = $z - 1; $zz <= $z + 1; $zz++) {
|
for($zz = $z - 1; $zz <= $z + 1; $zz ++) {
|
||||||
$level->setBlockIdAt($xx, $y + 4, $zz, Block::SNOW_BLOCK);
|
$level->setBlockIdAt($xx, $y + 4, $zz, Block::SNOW_BLOCK);
|
||||||
$level->setBlockIdAt($xx, $y, $zz, Block::SNOW_BLOCK);
|
$level->setBlockIdAt($xx, $y, $zz, Block::SNOW_BLOCK);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Carpets
|
// Carpets
|
||||||
for ($xx = $x - 1; $xx <= $x + 2; $xx++)
|
for($xx = $x - 1; $xx <= $x + 2; $xx ++)
|
||||||
for ($zz = $z - 1; $zz <= $z + 1; $zz++) {
|
for($zz = $z - 1; $zz <= $z + 1; $zz ++) {
|
||||||
$level->setBlockIdAt($xx, $y + 1, $zz, Block::CARPET);
|
$level->setBlockIdAt($xx, $y + 1, $zz, Block::CARPET);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -197,12 +247,12 @@ class Igloo extends Object {
|
||||||
// Third direction
|
// Third direction
|
||||||
case 2 : // Entrance is z+
|
case 2 : // Entrance is z+
|
||||||
// Ground
|
// Ground
|
||||||
for ($xx = $x - 3; $xx <= $x + 3; $xx++)
|
for($xx = $x - 3; $xx <= $x + 3; $xx ++)
|
||||||
for ($zz = $z - 3; $zz <= $z + 4; $zz++)
|
for($zz = $z - 3; $zz <= $z + 4; $zz ++)
|
||||||
if (!isset($this->overridable[$level->getBlockIdAt($xx, $y, $zz)]))
|
if (! isset($this->overridable[$level->getBlockIdAt($xx, $y, $zz)]))
|
||||||
$level->setBlockIdAt($xx, $y, $zz, Block::SNOW_BLOCK);
|
$level->setBlockIdAt($xx, $y, $zz, Block::SNOW_BLOCK);
|
||||||
// Entrance
|
// Entrance
|
||||||
for ($i = 0; $i < 2; $i++) {
|
for($i = 0; $i < 2; $i ++) {
|
||||||
$level->setBlockIdAt($x, $y, $z + 3 + $i, Block::SNOW_BLOCK);
|
$level->setBlockIdAt($x, $y, $z + 3 + $i, Block::SNOW_BLOCK);
|
||||||
$level->setBlockIdAt($x, $y + 3, $z + 3 + $i, Block::SNOW_BLOCK);
|
$level->setBlockIdAt($x, $y + 3, $z + 3 + $i, Block::SNOW_BLOCK);
|
||||||
$level->setBlockIdAt($x + 1, $y + 1, $z + 3 + $i, Block::SNOW_BLOCK);
|
$level->setBlockIdAt($x + 1, $y + 1, $z + 3 + $i, Block::SNOW_BLOCK);
|
||||||
|
@ -212,13 +262,13 @@ class Igloo extends Object {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Back
|
// Back
|
||||||
for ($xx = $x - 1; $xx <= $x + 1; $xx++) {
|
for($xx = $x - 1; $xx <= $x + 1; $xx ++) {
|
||||||
$level->setBlockIdAt($xx, $y + 1, $z - 3, Block::SNOW_BLOCK);
|
$level->setBlockIdAt($xx, $y + 1, $z - 3, Block::SNOW_BLOCK);
|
||||||
$level->setBlockIdAt($xx, $y + 2, $z - 3, Block::SNOW_BLOCK);
|
$level->setBlockIdAt($xx, $y + 2, $z - 3, Block::SNOW_BLOCK);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sides
|
// Sides
|
||||||
for ($zz = $z - 1; $zz <= $z + 1; $zz++) {
|
for($zz = $z - 1; $zz <= $z + 1; $zz ++) {
|
||||||
$level->setBlockIdAt($x - 3, $y + 1, $zz, Block::SNOW_BLOCK);
|
$level->setBlockIdAt($x - 3, $y + 1, $zz, Block::SNOW_BLOCK);
|
||||||
$level->setBlockIdAt($x - 3, $y + 2, $zz, Block::SNOW_BLOCK);
|
$level->setBlockIdAt($x - 3, $y + 2, $zz, Block::SNOW_BLOCK);
|
||||||
$level->setBlockIdAt($x + 3, $y + 1, $zz, Block::SNOW_BLOCK);
|
$level->setBlockIdAt($x + 3, $y + 1, $zz, Block::SNOW_BLOCK);
|
||||||
|
@ -228,7 +278,7 @@ class Igloo extends Object {
|
||||||
$level->setBlockIdAt($x - 3, $y + 1, $z, Block::ICE);
|
$level->setBlockIdAt($x - 3, $y + 1, $z, Block::ICE);
|
||||||
|
|
||||||
// Diags
|
// Diags
|
||||||
for ($i = 1; $i <= 2; $i++) {
|
for($i = 1; $i <= 2; $i ++) {
|
||||||
$level->setBlockIdAt($x + 2, $y + $i, $z + 2, Block::SNOW_BLOCK);
|
$level->setBlockIdAt($x + 2, $y + $i, $z + 2, Block::SNOW_BLOCK);
|
||||||
$level->setBlockIdAt($x - 2, $y + $i, $z + 2, Block::SNOW_BLOCK);
|
$level->setBlockIdAt($x - 2, $y + $i, $z + 2, Block::SNOW_BLOCK);
|
||||||
$level->setBlockIdAt($x - 2, $y + $i, $z - 2, Block::SNOW_BLOCK);
|
$level->setBlockIdAt($x - 2, $y + $i, $z - 2, Block::SNOW_BLOCK);
|
||||||
|
@ -236,7 +286,7 @@ class Igloo extends Object {
|
||||||
}
|
}
|
||||||
|
|
||||||
// 2nd layer
|
// 2nd layer
|
||||||
for ($i = 0; $i < 3; $i++) {
|
for($i = 0; $i < 3; $i ++) {
|
||||||
$level->setBlockIdAt($x - 1 + $i, $y + 3, $z + 2, Block::SNOW_BLOCK);
|
$level->setBlockIdAt($x - 1 + $i, $y + 3, $z + 2, Block::SNOW_BLOCK);
|
||||||
$level->setBlockIdAt($x - 1 + $i, $y + 3, $z - 2, Block::SNOW_BLOCK);
|
$level->setBlockIdAt($x - 1 + $i, $y + 3, $z - 2, Block::SNOW_BLOCK);
|
||||||
$level->setBlockIdAt($x + 2, $y + 3, $z - 1 + $i, Block::SNOW_BLOCK);
|
$level->setBlockIdAt($x + 2, $y + 3, $z - 1 + $i, Block::SNOW_BLOCK);
|
||||||
|
@ -244,15 +294,15 @@ class Igloo extends Object {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Top
|
// Top
|
||||||
for ($xx = $x - 1; $xx <= $x + 1; $xx++)
|
for($xx = $x - 1; $xx <= $x + 1; $xx ++)
|
||||||
for ($zz = $z - 1; $zz <= $z + 1; $zz++) {
|
for($zz = $z - 1; $zz <= $z + 1; $zz ++) {
|
||||||
$level->setBlockIdAt($xx, $y + 4, $zz, Block::SNOW_BLOCK);
|
$level->setBlockIdAt($xx, $y + 4, $zz, Block::SNOW_BLOCK);
|
||||||
$level->setBlockIdAt($xx, $y, $zz, Block::SNOW_BLOCK);
|
$level->setBlockIdAt($xx, $y, $zz, Block::SNOW_BLOCK);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Carpets
|
// Carpets
|
||||||
for ($xx = $x - 1; $xx <= $x + 1; $xx++)
|
for($xx = $x - 1; $xx <= $x + 1; $xx ++)
|
||||||
for ($zz = $z - 2; $zz <= $z + 1; $zz++) {
|
for($zz = $z - 2; $zz <= $z + 1; $zz ++) {
|
||||||
$level->setBlockIdAt($xx, $y + 1, $zz, Block::CARPET);
|
$level->setBlockIdAt($xx, $y + 1, $zz, Block::CARPET);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -271,12 +321,12 @@ class Igloo extends Object {
|
||||||
// Fourth direction
|
// Fourth direction
|
||||||
case 3 : // Entrance is z-
|
case 3 : // Entrance is z-
|
||||||
// Ground
|
// Ground
|
||||||
for ($xx = $x - 3; $xx <= $x + 3; $xx++)
|
for($xx = $x - 3; $xx <= $x + 3; $xx ++)
|
||||||
for ($zz = $z - 4; $zz <= $z + 3; $zz++)
|
for($zz = $z - 4; $zz <= $z + 3; $zz ++)
|
||||||
if (!isset($this->overridable[$level->getBlockIdAt($xx, $y, $zz)]))
|
if (! isset($this->overridable[$level->getBlockIdAt($xx, $y, $zz)]))
|
||||||
$level->setBlockIdAt($xx, $y, $zz, Block::SNOW_BLOCK);
|
$level->setBlockIdAt($xx, $y, $zz, Block::SNOW_BLOCK);
|
||||||
// Entrance
|
// Entrance
|
||||||
for ($i = 0; $i < 2; $i++) {
|
for($i = 0; $i < 2; $i ++) {
|
||||||
$level->setBlockIdAt($x, $y, $z - 3 - $i, Block::SNOW_BLOCK);
|
$level->setBlockIdAt($x, $y, $z - 3 - $i, Block::SNOW_BLOCK);
|
||||||
$level->setBlockIdAt($x, $y + 3, $z - 3 - $i, Block::SNOW_BLOCK);
|
$level->setBlockIdAt($x, $y + 3, $z - 3 - $i, Block::SNOW_BLOCK);
|
||||||
$level->setBlockIdAt($x + 1, $y + 1, $z - 3 - $i, Block::SNOW_BLOCK);
|
$level->setBlockIdAt($x + 1, $y + 1, $z - 3 - $i, Block::SNOW_BLOCK);
|
||||||
|
@ -286,13 +336,13 @@ class Igloo extends Object {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Back
|
// Back
|
||||||
for ($xx = $x - 1; $xx <= $x + 1; $xx++) {
|
for($xx = $x - 1; $xx <= $x + 1; $xx ++) {
|
||||||
$level->setBlockIdAt($xx, $y + 1, $z + 3, Block::SNOW_BLOCK);
|
$level->setBlockIdAt($xx, $y + 1, $z + 3, Block::SNOW_BLOCK);
|
||||||
$level->setBlockIdAt($xx, $y + 2, $z + 3, Block::SNOW_BLOCK);
|
$level->setBlockIdAt($xx, $y + 2, $z + 3, Block::SNOW_BLOCK);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sides
|
// Sides
|
||||||
for ($zz = $z - 1; $zz <= $z + 1; $zz++) {
|
for($zz = $z - 1; $zz <= $z + 1; $zz ++) {
|
||||||
$level->setBlockIdAt($x - 3, $y + 1, $zz, Block::SNOW_BLOCK);
|
$level->setBlockIdAt($x - 3, $y + 1, $zz, Block::SNOW_BLOCK);
|
||||||
$level->setBlockIdAt($x - 3, $y + 2, $zz, Block::SNOW_BLOCK);
|
$level->setBlockIdAt($x - 3, $y + 2, $zz, Block::SNOW_BLOCK);
|
||||||
$level->setBlockIdAt($x + 3, $y + 1, $zz, Block::SNOW_BLOCK);
|
$level->setBlockIdAt($x + 3, $y + 1, $zz, Block::SNOW_BLOCK);
|
||||||
|
@ -302,7 +352,7 @@ class Igloo extends Object {
|
||||||
$level->setBlockIdAt($x - 3, $y + 1, $z, Block::ICE);
|
$level->setBlockIdAt($x - 3, $y + 1, $z, Block::ICE);
|
||||||
|
|
||||||
// Diags
|
// Diags
|
||||||
for ($i = 1; $i <= 2; $i++) {
|
for($i = 1; $i <= 2; $i ++) {
|
||||||
$level->setBlockIdAt($x + 2, $y + $i, $z + 2, Block::SNOW_BLOCK);
|
$level->setBlockIdAt($x + 2, $y + $i, $z + 2, Block::SNOW_BLOCK);
|
||||||
$level->setBlockIdAt($x - 2, $y + $i, $z + 2, Block::SNOW_BLOCK);
|
$level->setBlockIdAt($x - 2, $y + $i, $z + 2, Block::SNOW_BLOCK);
|
||||||
$level->setBlockIdAt($x - 2, $y + $i, $z - 2, Block::SNOW_BLOCK);
|
$level->setBlockIdAt($x - 2, $y + $i, $z - 2, Block::SNOW_BLOCK);
|
||||||
|
@ -310,7 +360,7 @@ class Igloo extends Object {
|
||||||
}
|
}
|
||||||
|
|
||||||
// 2nd layer
|
// 2nd layer
|
||||||
for ($i = 0; $i < 3; $i++) {
|
for($i = 0; $i < 3; $i ++) {
|
||||||
$level->setBlockIdAt($x - 1 + $i, $y + 3, $z + 2, Block::SNOW_BLOCK);
|
$level->setBlockIdAt($x - 1 + $i, $y + 3, $z + 2, Block::SNOW_BLOCK);
|
||||||
$level->setBlockIdAt($x - 1 + $i, $y + 3, $z - 2, Block::SNOW_BLOCK);
|
$level->setBlockIdAt($x - 1 + $i, $y + 3, $z - 2, Block::SNOW_BLOCK);
|
||||||
$level->setBlockIdAt($x + 2, $y + 3, $z - 1 + $i, Block::SNOW_BLOCK);
|
$level->setBlockIdAt($x + 2, $y + 3, $z - 1 + $i, Block::SNOW_BLOCK);
|
||||||
|
@ -318,15 +368,15 @@ class Igloo extends Object {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Top
|
// Top
|
||||||
for ($xx = $x - 1; $xx <= $x + 1; $xx++)
|
for($xx = $x - 1; $xx <= $x + 1; $xx ++)
|
||||||
for ($zz = $z - 1; $zz <= $z + 1; $zz++) {
|
for($zz = $z - 1; $zz <= $z + 1; $zz ++) {
|
||||||
$level->setBlockIdAt($xx, $y + 4, $zz, Block::SNOW_BLOCK);
|
$level->setBlockIdAt($xx, $y + 4, $zz, Block::SNOW_BLOCK);
|
||||||
$level->setBlockIdAt($xx, $y, $zz, Block::SNOW_BLOCK);
|
$level->setBlockIdAt($xx, $y, $zz, Block::SNOW_BLOCK);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Carpets
|
// Carpets
|
||||||
for ($xx = $x - 1; $xx <= $x + 1; $xx++)
|
for($xx = $x - 1; $xx <= $x + 1; $xx ++)
|
||||||
for ($zz = $z - 1; $zz <= $z + 2; $zz++) {
|
for($zz = $z - 1; $zz <= $z + 2; $zz ++) {
|
||||||
$level->setBlockIdAt($xx, $y + 1, $zz, Block::CARPET);
|
$level->setBlockIdAt($xx, $y + 1, $zz, Block::CARPET);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -344,48 +394,4 @@ class Igloo extends Object {
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Checks if an igloo is placeable
|
|
||||||
* @param ChunkManager $level
|
|
||||||
* @param $x
|
|
||||||
* @param $y
|
|
||||||
* @param $z
|
|
||||||
* @param Random $random
|
|
||||||
* @return bool
|
|
||||||
*/
|
|
||||||
public function canPlaceObject(ChunkManager $level, $x, $y, $z, Random $random) {
|
|
||||||
$this->direction = $random->nextBoundedInt(4);
|
|
||||||
switch ($this->direction) {
|
|
||||||
case 0 : // Entrance is x+
|
|
||||||
for ($xx = $x - 3; $xx <= $x + 4; $xx++)
|
|
||||||
for ($yy = $y + 1; $yy <= $y + 4; $yy++)
|
|
||||||
for ($zz = $z - 3; $zz <= $z + 3; $zz++)
|
|
||||||
if (!isset($this->overridable[$level->getBlockIdAt($xx, $yy, $zz)]))
|
|
||||||
return false;
|
|
||||||
break;
|
|
||||||
case 1 : // Entrance is x-
|
|
||||||
for ($xx = $x - 4; $xx <= $x + 3; $xx++)
|
|
||||||
for ($yy = $y + 1; $yy <= $y + 4; $yy++)
|
|
||||||
for ($zz = $z - 3; $zz <= $z + 3; $zz++)
|
|
||||||
if (!isset($this->overridable[$level->getBlockIdAt($xx, $yy, $zz)]))
|
|
||||||
return false;
|
|
||||||
break;
|
|
||||||
case 2 : // Entrance is z+
|
|
||||||
for ($xx = $x - 3; $xx <= $x + 3; $xx++)
|
|
||||||
for ($yy = $y + 1; $yy <= $y + 4; $yy++)
|
|
||||||
for ($zz = $z - 3; $zz <= $z + 4; $zz++)
|
|
||||||
if (!isset($this->overridable[$level->getBlockIdAt($xx, $yy, $zz)]))
|
|
||||||
return false;
|
|
||||||
break;
|
|
||||||
case 3 : // Entrance is z-
|
|
||||||
for ($xx = $x - 3; $xx <= $x + 3; $xx++)
|
|
||||||
for ($yy = $y + 1; $yy <= $y + 4; $yy++)
|
|
||||||
for ($zz = $z - 4; $zz <= $z + 3; $zz++)
|
|
||||||
if (!isset($this->overridable[$level->getBlockIdAt($xx, $yy, $zz)]))
|
|
||||||
return false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
|
@ -8,8 +8,11 @@
|
||||||
* \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\
|
* \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\
|
||||||
* \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/
|
* \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/
|
||||||
* Tomorrow's pocketmine generator.
|
* Tomorrow's pocketmine generator.
|
||||||
* @author Ad5001
|
* @author Ad5001 <mail@ad5001.eu>, XenialDan <https://github.com/thebigsmileXD>
|
||||||
* @link https://github.com/Ad5001/BetterGen
|
* @link https://github.com/Ad5001/BetterGen
|
||||||
|
* @category World Generator
|
||||||
|
* @api 3.0.0
|
||||||
|
* @version 1.1
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Ad5001\BetterGen\structure;
|
namespace Ad5001\BetterGen\structure;
|
||||||
|
@ -440,9 +443,11 @@ class SakuraTree extends Tree {
|
||||||
];
|
];
|
||||||
const maxPerChunk = 2;
|
const maxPerChunk = 2;
|
||||||
|
|
||||||
|
/** @var int */
|
||||||
public $trunkHeight = 11;
|
public $trunkHeight = 11;
|
||||||
|
/** @var int */
|
||||||
public $leafType;
|
public $leafType;
|
||||||
|
/** @var int */
|
||||||
public $leaf2Type;
|
public $leaf2Type;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -458,14 +463,17 @@ class SakuraTree extends Tree {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Builds the tree.
|
* Builds a tree
|
||||||
* @param $level \pocketmine\level\ChunkManager
|
*
|
||||||
* @param $x int
|
* @param ChunkManager $level
|
||||||
* @param $y int
|
* @param int $x
|
||||||
* @param $z int
|
* @param int $y
|
||||||
* @param $random $random
|
* @param int $z
|
||||||
|
* @param Random $random
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function placeObject(ChunkManager $level, $x, $y, $z, Random $random) {
|
public function placeObject(ChunkManager $level, $x, $y, $z, Random $random) {
|
||||||
|
$this->random = $random;
|
||||||
$percentage = $random->nextBoundedInt(100);
|
$percentage = $random->nextBoundedInt(100);
|
||||||
if ($percentage > 10) {
|
if ($percentage > 10) {
|
||||||
return;
|
return;
|
||||||
|
@ -569,9 +577,7 @@ class SakuraTree extends Tree {
|
||||||
$totalLength = $stickLen + $stickLen2; // Length of the stick
|
$totalLength = $stickLen + $stickLen2; // Length of the stick
|
||||||
$sideLen = $totalLength ** 2; // Side length
|
$sideLen = $totalLength ** 2; // Side length
|
||||||
|
|
||||||
//TODO CHECK WHAT THIS IS SUPPOSED TO BE
|
|
||||||
$numForward = ($totalLength % 2 == 0) ? $totalLength - 1 : $totalLength;
|
$numForward = ($totalLength % 2 == 0) ? $totalLength - 1 : $totalLength;
|
||||||
//TODO END
|
|
||||||
$lX1 = $lZ1 = $lX = $lZ = 0;
|
$lX1 = $lZ1 = $lX = $lZ = 0;
|
||||||
|
|
||||||
// First branch part + first leave part
|
// First branch part + first leave part
|
||||||
|
@ -621,8 +627,6 @@ class SakuraTree extends Tree {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// continue;
|
|
||||||
|
|
||||||
switch ($dir + 1) {
|
switch ($dir + 1) {
|
||||||
case 4 :
|
case 4 :
|
||||||
$xd2 = 0;
|
$xd2 = 0;
|
||||||
|
@ -657,24 +661,34 @@ class SakuraTree extends Tree {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fills a log at.
|
* Fills a log
|
||||||
* @param $level pocketmine\level\ChunkManager
|
*
|
||||||
* @param $x int
|
* @param ChunkManager $level
|
||||||
* @param $y int
|
* @param int $x
|
||||||
* @param $z int
|
* @param int $y
|
||||||
|
* @param int $z
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function setLog(ChunkManager $level, $x, $y, $z) {
|
public function setLog(ChunkManager $level, $x, $y, $z) {
|
||||||
$level->setBlockIdAt($x, $y, $z, $this->trunkBlock);
|
$level->setBlockIdAt($x, $y, $z, $this->trunkBlock);
|
||||||
$level->setBlockDataAt($x, $y, $z, $this->type);
|
$level->setBlockDataAt($x, $y, $z, $this->type);
|
||||||
|
if($this->random->nextBoundedInt(3) == 0){ // Setting a log near.
|
||||||
|
$x += $this->random->nextBoundedInt(3) - 1;
|
||||||
|
$z += $this->random->nextBoundedInt(3) - 1;
|
||||||
|
$level->setBlockIdAt($x, $y, $z, $this->trunkBlock);
|
||||||
|
$level->setBlockDataAt($x, $y, $z, $this->type);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fills a leave at.
|
* Fills leaves
|
||||||
* @param $level pocketmine\level\ChunkManager
|
*
|
||||||
* @param $x int
|
* @param ChunkManager $level
|
||||||
* @param $y int
|
* @param int $x
|
||||||
* @param $z int
|
* @param int $y
|
||||||
* @param $random pocketmine\utils\Random
|
* @param int $z
|
||||||
|
* @param Random $random
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function setLeave(ChunkManager $level, $x, $y, $z, Random $random) {
|
public function setLeave(ChunkManager $level, $x, $y, $z, Random $random) {
|
||||||
$data = [
|
$data = [
|
||||||
|
|
|
@ -8,8 +8,11 @@
|
||||||
* \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\
|
* \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\
|
||||||
* \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/
|
* \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/
|
||||||
* Tomorrow's pocketmine generator.
|
* Tomorrow's pocketmine generator.
|
||||||
* @author Ad5001
|
* @author Ad5001 <mail@ad5001.eu>, XenialDan <https://github.com/thebigsmileXD>
|
||||||
* @link https://github.com/Ad5001/BetterGen
|
* @link https://github.com/Ad5001/BetterGen
|
||||||
|
* @category World Generator
|
||||||
|
* @api 3.0.0
|
||||||
|
* @version 1.1
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
@ -17,21 +20,23 @@ namespace Ad5001\BetterGen\structure;
|
||||||
|
|
||||||
use pocketmine\block\Block;
|
use pocketmine\block\Block;
|
||||||
use pocketmine\level\ChunkManager;
|
use pocketmine\level\ChunkManager;
|
||||||
use pocketmine\level\generator\object\Object;
|
use pocketmine\level\generator\object\PopulatorObject;
|
||||||
use pocketmine\utils\Random;
|
use pocketmine\utils\Random;
|
||||||
|
|
||||||
class SugarCane extends Object {
|
class SugarCane extends PopulatorObject {
|
||||||
|
|
||||||
|
protected $totalHeight;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if a cactus is placeable
|
* Checks if a sugarcane is placable
|
||||||
* @param $level pocketmine\level\ChunkManager
|
*
|
||||||
* @param $x int
|
* @param ChunkManager $level
|
||||||
* @param $y int
|
* @param int $x
|
||||||
* @param $z int
|
* @param int $y
|
||||||
* @param $random pocketmine\utils\Random
|
* @param int $z
|
||||||
|
* @param Random $random
|
||||||
|
* @return bool
|
||||||
*/
|
*/
|
||||||
private $totalHeight;
|
|
||||||
|
|
||||||
public function canPlaceObject(ChunkManager $level, int $x, int $y, int $z, Random $random): bool {
|
public function canPlaceObject(ChunkManager $level, int $x, int $y, int $z, Random $random): bool {
|
||||||
$this->totalHeight = 1 + $random->nextBoundedInt(3);
|
$this->totalHeight = 1 + $random->nextBoundedInt(3);
|
||||||
$below = $level->getBlockIdAt($x, $y - 1, $z);
|
$below = $level->getBlockIdAt($x, $y - 1, $z);
|
||||||
|
@ -42,14 +47,16 @@ class SugarCane extends Object {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Places a cactus
|
* Places a sugar cane
|
||||||
* @param $level pocketmine\level\ChunkManager
|
*
|
||||||
* @param $x int
|
* @param ChunkManager $level
|
||||||
* @param $y int
|
* @param int $x
|
||||||
* @param $z int
|
* @param int $y
|
||||||
|
* @param int $z
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function placeObject(ChunkManager $level, int $x, int $y, int $z) {
|
public function placeObject(ChunkManager $level, int $x, int $y, int $z) {
|
||||||
for ($yy = 0; $yy < $this->totalHeight; $yy++) {
|
for($yy = 0; $yy < $this->totalHeight; $yy ++) {
|
||||||
if ($level->getBlockIdAt($x, $y + $yy, $z) != Block::AIR) {
|
if ($level->getBlockIdAt($x, $y + $yy, $z) != Block::AIR) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,22 +8,23 @@
|
||||||
* \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\
|
* \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\
|
||||||
* \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/
|
* \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/
|
||||||
* Tomorrow's pocketmine generator.
|
* Tomorrow's pocketmine generator.
|
||||||
* @author Ad5001
|
* @author Ad5001 <mail@ad5001.eu>, XenialDan <https://github.com/thebigsmileXD>
|
||||||
* @link https://github.com/Ad5001/BetterGen
|
* @link https://github.com/Ad5001/BetterGen
|
||||||
|
* @category World Generator
|
||||||
|
* @api 3.0.0
|
||||||
|
* @version 1.1
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Ad5001\BetterGen\structure;
|
namespace Ad5001\BetterGen\structure;
|
||||||
|
|
||||||
use Ad5001\BetterGen\Main;
|
|
||||||
use Ad5001\BetterGen\utils\BuildingUtils;
|
use Ad5001\BetterGen\utils\BuildingUtils;
|
||||||
use pocketmine\block\Block;
|
use pocketmine\block\Block;
|
||||||
use pocketmine\level\ChunkManager;
|
use pocketmine\level\ChunkManager;
|
||||||
use pocketmine\level\generator\object\Object;
|
use pocketmine\level\generator\object\PopulatorObject;
|
||||||
use pocketmine\level\Position;
|
|
||||||
use pocketmine\math\Vector3;
|
use pocketmine\math\Vector3;
|
||||||
use pocketmine\utils\Random;
|
use pocketmine\utils\Random;
|
||||||
|
|
||||||
class Temple extends Object {
|
class Temple extends PopulatorObject {
|
||||||
const DIRECTION_PLUSX = 0;
|
const DIRECTION_PLUSX = 0;
|
||||||
const DIRECTION_MINX = 1;
|
const DIRECTION_MINX = 1;
|
||||||
const DIRECTION_PLUSZ = 2;
|
const DIRECTION_PLUSZ = 2;
|
||||||
|
@ -110,17 +111,19 @@ class Temple extends Object {
|
||||||
]
|
]
|
||||||
];
|
];
|
||||||
/** @var ChunkManager */
|
/** @var ChunkManager */
|
||||||
private $level;
|
protected $level;
|
||||||
private $direction = 0;
|
protected $direction = 0;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if a temple is placeable
|
* Checks if a temple is placable
|
||||||
|
*
|
||||||
* @param ChunkManager $level
|
* @param ChunkManager $level
|
||||||
* @param $x
|
* @param int $x
|
||||||
* @param $y
|
* @param int $y
|
||||||
* @param $z
|
* @param int $z
|
||||||
* @param Random $random
|
* @param Random $random
|
||||||
* @return bool
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function canPlaceObject(ChunkManager $level, $x, $y, $z, Random $random) {
|
public function canPlaceObject(ChunkManager $level, $x, $y, $z, Random $random) {
|
||||||
$this->level = $level;
|
$this->level = $level;
|
||||||
|
@ -134,12 +137,14 @@ class Temple extends Object {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Places a temple
|
* Builds a temple
|
||||||
|
*
|
||||||
* @param ChunkManager $level
|
* @param ChunkManager $level
|
||||||
* @param $x
|
* @param int $x
|
||||||
* @param $y
|
* @param int $y
|
||||||
* @param $z
|
* @param int $z
|
||||||
* @param Random $random
|
* @param Random $random
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function placeObject(ChunkManager $level, $x, $y, $z, Random $random) {
|
public function placeObject(ChunkManager $level, $x, $y, $z, Random $random) {
|
||||||
// Clearing space...
|
// Clearing space...
|
||||||
|
@ -155,26 +160,13 @@ class Temple extends Object {
|
||||||
|
|
||||||
// Floor top
|
// Floor top
|
||||||
BuildingUtils::fill($level, new Vector3($x - 5, $y + 4, $z - 5), new Vector3($x + 5, $y + 4, $z + 5), Block::get(Block::SANDSTONE));
|
BuildingUtils::fill($level, new Vector3($x - 5, $y + 4, $z - 5), new Vector3($x + 5, $y + 4, $z + 5), Block::get(Block::SANDSTONE));
|
||||||
#for ($xx = $x + 5; $xx >= $x - 5; $xx--)
|
|
||||||
# for ($zz = $z + 5; $zz >= $z - 5; $zz--)
|
|
||||||
# $this->placeBlock($xx, $y + 4, $zz);
|
|
||||||
|
|
||||||
// Creating hole
|
// Creating hole
|
||||||
BuildingUtils::fill($level, new Vector3($x - 1, $y - 11, $z - 1), new Vector3($x + 1, $y + 4, $z + 1), Block::get(Block::AIR));
|
BuildingUtils::fill($level, new Vector3($x - 1, $y - 11, $z - 1), new Vector3($x + 1, $y + 4, $z + 1), Block::get(Block::AIR));
|
||||||
#for ($xx = $x - 1; $xx <= $x + 1; $xx++)
|
|
||||||
# for ($yy = $y - 11; $yy <= $y + 4; $yy++)
|
|
||||||
# for ($zz = $z - 1; $zz <= $z + 1; $zz++)
|
|
||||||
# $this->placeBlock($xx, $yy, $zz, Block::AIR);
|
|
||||||
|
|
||||||
// Hole walls
|
// Hole walls
|
||||||
BuildingUtils::walls($level, new Vector3($x - 2, $y - 1, $z - 2), new Vector3($x + 2, $y - 8, $z + 2), Block::get(Block::SANDSTONE));
|
BuildingUtils::walls($level, new Vector3($x - 2, $y - 1, $z - 2), new Vector3($x + 2, $y - 8, $z + 2), Block::get(Block::SANDSTONE));
|
||||||
|
|
||||||
//Floor bottom
|
//Floor bottom
|
||||||
BuildingUtils::fill($level, new Vector3($x - 9, $y, $z - 9), new Vector3($x + 9, $y, $z + 9), Block::get(Block::SANDSTONE));
|
BuildingUtils::fill($level, new Vector3($x - 9, $y, $z - 9), new Vector3($x + 9, $y, $z + 9), Block::get(Block::SANDSTONE));
|
||||||
#for ($xx = $x + 9; $xx >= $x - 9; $xx--)
|
|
||||||
# for ($zz = $z + 9; $zz >= $z - 9; $zz--)
|
|
||||||
# $this->placeBlock($xx, $y, $zz);
|
|
||||||
|
|
||||||
// Floor pattern
|
// Floor pattern
|
||||||
for ($i = -2; $i <= 1; $i++) {//straight
|
for ($i = -2; $i <= 1; $i++) {//straight
|
||||||
$xextra = ($i + 1) % 2;
|
$xextra = ($i + 1) % 2;
|
||||||
|
@ -217,19 +209,20 @@ class Temple extends Object {
|
||||||
$this->placeBlock($xx, $y - 13, $zz, Block::TNT);
|
$this->placeBlock($xx, $y - 13, $zz, Block::TNT);
|
||||||
$this->placeBlock($x, $y - 11, $z, Block::STONE_PRESSURE_PLATE);
|
$this->placeBlock($x, $y - 11, $z, Block::STONE_PRESSURE_PLATE);
|
||||||
|
|
||||||
|
//TODO TILES
|
||||||
|
$this->placeBlock($x, $y - 11, $z + 2, Block::CHEST, 4);
|
||||||
|
$this->placeBlock($x, $y - 11, $z - 2, Block::CHEST, 2);
|
||||||
|
$this->placeBlock($x + 2, $y - 11, $z, Block::CHEST, 5);
|
||||||
|
$this->placeBlock($x - 2, $y - 11, $z, Block::CHEST, 3);
|
||||||
$this->placeBlock($x, $y - 10, $z + 2, Block::AIR);
|
$this->placeBlock($x, $y - 10, $z + 2, Block::AIR);
|
||||||
$this->placeBlock($x, $y - 10, $z - 2, Block::AIR);
|
$this->placeBlock($x, $y - 10, $z - 2, Block::AIR);
|
||||||
$this->placeBlock($x + 2, $y - 10, $z, Block::AIR);
|
$this->placeBlock($x + 2, $y - 10, $z, Block::AIR);
|
||||||
$this->placeBlock($x - 2, $y - 10, $z, Block::AIR);
|
$this->placeBlock($x - 2, $y - 10, $z, Block::AIR);
|
||||||
// Chests
|
// Chests
|
||||||
#$this->placeBlock($x, $y - 11, $z + 2, Block::CHEST, 4);
|
/*LootTable::buildLootTable(new Vector3($x, $y - 11, $z + 2), LootTable::LOOT_DESERT_TEMPLE, $random);//TODO: Improve using addon
|
||||||
#$this->placeBlock($x, $y - 11, $z - 2, Block::CHEST, 2);
|
LootTable::buildLootTable(new Vector3($x, $y - 11, $z - 2), LootTable::LOOT_DESERT_TEMPLE, $random);
|
||||||
#$this->placeBlock($x + 2, $y - 11, $z, Block::CHEST, 5);
|
LootTable::buildLootTable(new Vector3($x + 2, $y - 11, $z), LootTable::LOOT_DESERT_TEMPLE, $random);
|
||||||
#$this->placeBlock($x - 2, $y - 11, $z, Block::CHEST, 3);
|
LootTable::buildLootTable(new Vector3($x - 2, $y - 11, $z), LootTable::LOOT_DESERT_TEMPLE, $random);*/
|
||||||
Main::placeLootChest(Block::get(Block::CHEST, 2, new Position($x, $y - 11, $z + 2, $this->level)), 'loot_tables\\chests\\desert_pyramid');
|
|
||||||
Main::placeLootChest(Block::get(Block::CHEST, 3, new Position($x, $y - 11, $z - 2, $this->level)), 'loot_tables\\chests\\desert_pyramid');
|
|
||||||
Main::placeLootChest(Block::get(Block::CHEST, 4, new Position($x + 2, $y - 11, $z, $this->level)), 'loot_tables\\chests\\desert_pyramid');
|
|
||||||
Main::placeLootChest(Block::get(Block::CHEST, 5, new Position($x - 2, $y - 11, $z, $this->level)), 'loot_tables\\chests\\desert_pyramid');
|
|
||||||
|
|
||||||
// Entrance is a rectangular parallelepiped
|
// Entrance is a rectangular parallelepiped
|
||||||
switch ($this->direction) {
|
switch ($this->direction) {
|
||||||
|
@ -896,7 +889,6 @@ class Temple extends Object {
|
||||||
* @param $z int
|
* @param $z int
|
||||||
* @param $id int
|
* @param $id int
|
||||||
* @param $meta int
|
* @param $meta int
|
||||||
* @param bool $top
|
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
protected function placeSlab($x, $y, $z, $id = 44, $meta = 1, $top = false) {
|
protected function placeSlab($x, $y, $z, $id = 44, $meta = 1, $top = false) {
|
||||||
|
|
|
@ -8,8 +8,11 @@
|
||||||
* \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\
|
* \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\
|
||||||
* \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/
|
* \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/
|
||||||
* Tomorrow's pocketmine generator.
|
* Tomorrow's pocketmine generator.
|
||||||
* @author Ad5001
|
* @author Ad5001 <mail@ad5001.eu>, XenialDan <https://github.com/thebigsmileXD>
|
||||||
* @link https://github.com/Ad5001/BetterGen
|
* @link https://github.com/Ad5001/BetterGen
|
||||||
|
* @category World Generator
|
||||||
|
* @api 3.0.0
|
||||||
|
* @version 1.1
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
@ -17,11 +20,13 @@ namespace Ad5001\BetterGen\structure;
|
||||||
|
|
||||||
use pocketmine\block\Block;
|
use pocketmine\block\Block;
|
||||||
use pocketmine\level\ChunkManager;
|
use pocketmine\level\ChunkManager;
|
||||||
use pocketmine\level\generator\object\Object;
|
use pocketmine\level\generator\object\PopulatorObject;
|
||||||
use pocketmine\utils\Random;
|
use pocketmine\utils\Random;
|
||||||
|
|
||||||
|
|
||||||
class Well extends Object {
|
class Well extends PopulatorObject {
|
||||||
|
/** @var ChunkManager */
|
||||||
|
protected $level;
|
||||||
public $overridable = [
|
public $overridable = [
|
||||||
Block::AIR => true,
|
Block::AIR => true,
|
||||||
6 => true,
|
6 => true,
|
||||||
|
@ -34,8 +39,6 @@ class Well extends Object {
|
||||||
Block::LEAVES2 => true,
|
Block::LEAVES2 => true,
|
||||||
Block::CACTUS => true
|
Block::CACTUS => true
|
||||||
];
|
];
|
||||||
/** @var ChunkManager */
|
|
||||||
protected $level;
|
|
||||||
protected $directions = [
|
protected $directions = [
|
||||||
[
|
[
|
||||||
1,
|
1,
|
||||||
|
@ -43,50 +46,53 @@ class Well extends Object {
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
1,
|
1,
|
||||||
-1
|
- 1
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
-1,
|
- 1,
|
||||||
-1
|
- 1
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
-1,
|
- 1,
|
||||||
1
|
1
|
||||||
]
|
]
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if a well is placeable
|
* Checks if a Well is placable
|
||||||
* @param $level ChunkManager
|
*
|
||||||
* @param $x int
|
* @param ChunkManager $level
|
||||||
* @param $y int
|
* @param int $x
|
||||||
* @param $z int
|
* @param int $y
|
||||||
* @param $random Random
|
* @param int $z
|
||||||
* @return bool
|
* @param Random $random
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function canPlaceObject(ChunkManager $level, $x, $y, $z, Random $random) {
|
public function canPlaceObject(ChunkManager $level, $x, $y, $z, Random $random) {
|
||||||
$this->level = $level;
|
$this->level = $level;
|
||||||
for ($xx = $x - 2; $xx <= $x + 2; $xx++)
|
for($xx = $x - 2; $xx <= $x + 2; $xx ++)
|
||||||
for ($yy = $y; $yy <= $y + 3; $yy++)
|
for($yy = $y; $yy <= $y + 3; $yy ++)
|
||||||
for ($zz = $z - 2; $zz <= $z + 2; $zz++)
|
for($zz = $z - 2; $zz <= $z + 2; $zz ++)
|
||||||
if (!isset($this->overridable[$level->getBlockIdAt($xx, $yy, $zz)]))
|
if (! isset($this->overridable[$level->getBlockIdAt($xx, $yy, $zz)]))
|
||||||
return false;
|
return false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Places a well
|
* Places a well
|
||||||
* @param $level ChunkManager
|
*
|
||||||
* @param $x int
|
* @param ChunkManager $level
|
||||||
* @param $y int
|
* @param int $x
|
||||||
* @param $z int
|
* @param int $y
|
||||||
* @param $random Random
|
* @param int $z
|
||||||
|
* @param Random $random
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function placeObject(ChunkManager $level, $x, $y, $z, Random $random) {
|
public function placeObject(ChunkManager $level, $x, $y, $z, Random $random) {
|
||||||
$this->level = $level;
|
$this->level = $level;
|
||||||
foreach ($this->directions as $direction) {
|
foreach($this->directions as $direction) {
|
||||||
// Building pillars
|
// Building pillars
|
||||||
for ($yy = $y; $yy < $y + 3; $yy++)
|
for($yy = $y; $yy < $y + 3; $yy ++)
|
||||||
$this->placeBlock($x + $direction [0], $yy, $z + $direction [1], Block::SANDSTONE);
|
$this->placeBlock($x + $direction [0], $yy, $z + $direction [1], Block::SANDSTONE);
|
||||||
|
|
||||||
// Building corners
|
// Building corners
|
||||||
|
@ -104,19 +110,21 @@ class Well extends Object {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Final things
|
// Final things
|
||||||
for ($xx = $x - 1; $xx <= $x + 1; $xx++)
|
for($xx = $x - 1; $xx <= $x + 1; $xx ++)
|
||||||
for ($zz = $z - 1; $zz <= $z + 1; $zz++)
|
for($zz = $z - 1; $zz <= $z + 1; $zz ++)
|
||||||
$this->placeBlock($xx, $y + 3, $zz);
|
$this->placeBlock($xx, $y + 3, $zz);
|
||||||
$this->placeBlock($x, $y + 3, $z, Block::SANDSTONE, 1);
|
$this->placeBlock($x, $y + 3, $z, Block::SANDSTONE, 1);
|
||||||
$this->placeBlock($x, $y, $z, Block::WATER);
|
$this->placeBlock($x, $y, $z, Block::WATER);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Places a slab
|
* Places a block
|
||||||
* @param $x int
|
*
|
||||||
* @param $y int
|
* @param int $x
|
||||||
* @param $z int
|
* @param int $y
|
||||||
* @param $id int
|
* @param int $z
|
||||||
|
* @param int $id
|
||||||
|
* @param int $meta
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function placeBlock($x, $y, $z, $id = 0, $meta = 0) {
|
public function placeBlock($x, $y, $z, $id = 0, $meta = 0) {
|
||||||
|
|
|
@ -8,9 +8,12 @@
|
||||||
* \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\
|
* \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\
|
||||||
* \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/
|
* \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/
|
||||||
* Tomorrow's pocketmine generator.
|
* Tomorrow's pocketmine generator.
|
||||||
* @author Ad5001
|
* @author Ad5001 <mail@ad5001.eu>, XenialDan <https://github.com/thebigsmileXD>
|
||||||
* @link https://github.com/Ad5001/BetterGen
|
* @link https://github.com/Ad5001/BetterGen
|
||||||
*/
|
* @category World Generator
|
||||||
|
* @api 3.0.0
|
||||||
|
* @version 1.1
|
||||||
|
*/
|
||||||
|
|
||||||
namespace Ad5001\BetterGen\utils;
|
namespace Ad5001\BetterGen\utils;
|
||||||
|
|
||||||
|
@ -27,72 +30,60 @@ class BuildingUtils {
|
||||||
Block::LAVA,
|
Block::LAVA,
|
||||||
Block::BEDROCK,
|
Block::BEDROCK,
|
||||||
Block::CACTUS,
|
Block::CACTUS,
|
||||||
Block::PLANK
|
Block::PLANKS];
|
||||||
];
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fills an area
|
* Fills an area
|
||||||
* @param $level pocketmine\level\ChunkManager
|
*
|
||||||
* @param $pos1 pocketmine\math\Vector3
|
* @param ChunkManager $level
|
||||||
* @param $pos2 pocketmine\math\Vector3
|
* @param Vector3 $pos1
|
||||||
* @param $block pocketmine\block\Block
|
* @param Vector3 $pos2
|
||||||
|
* @param Block $block
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public static function fill(ChunkManager $level, Vector3 $pos1, Vector3 $pos2, Block $block = null) {
|
public static function fill(ChunkManager $level, Vector3 $pos1, Vector3 $pos2, Block $block = null) {
|
||||||
if ($block == null) $block = Block::get(Block::AIR);
|
if($block == null) $block = Block::get(Block::AIR);
|
||||||
list($pos1, $pos2) = self::minmax($pos1, $pos2);
|
list($pos1, $pos2) = self::minmax($pos1, $pos2);
|
||||||
for ($x = $pos1->x; $x >= $pos2->x; $x--) for ($y = $pos1->y; $y >= $pos2->y; $y--) for ($z = $pos1->z; $z >= $pos2->z; $z--) {
|
for($x = $pos1->x; $x >= $pos2->x; $x--) for($y = $pos1->y; $y >= $pos2->y; $y--) for($z = $pos1->z; $z >= $pos2->z; $z--) {
|
||||||
$level->setBlockIdAt($x, $y, $z, $block->getId());
|
$level->setBlockIdAt($x, $y, $z, $block->getId());
|
||||||
$level->setBlockDataAt($x, $y, $z, $block->getDamage());
|
$level->setBlockDataAt($x, $y, $z, $block->getDamage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns 2 vector3, one with minimal values, one with max values of the provided ones.
|
|
||||||
* @param $pos1 pocketmine\math\Vector3
|
|
||||||
* @param $pos2 pocketmine\math\Vector3
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
protected static function minmax(Vector3 $pos1, Vector3 $pos2): array {
|
|
||||||
$v1 = new Vector3(max($pos1->x, $pos2->x), max($pos1->y, $pos2->y), max($pos1->z, $pos2->z));
|
|
||||||
$v2 = new Vector3(min($pos1->x, $pos2->x), min($pos1->y, $pos2->y), min($pos1->z, $pos2->z));
|
|
||||||
return [
|
|
||||||
$v1,
|
|
||||||
$v2
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fills an area randomly
|
* Fills an area randomly
|
||||||
* @param $level pocketmine\level\ChunkManager
|
*
|
||||||
* @param $pos1 pocketmine\math\Vector3
|
* @param ChunkManager $level
|
||||||
* @param $pos2 pocketmine\math\Vector3
|
* @param Vector3 $pos1
|
||||||
* @param $block pocketmine\block\Block
|
* @param Vector3 $pos2
|
||||||
* @param $random pocketmine\utils
|
* @param Block $block
|
||||||
* @param $randMax pocketmine\utils
|
* @param Random $random
|
||||||
|
* @param int $randMax
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public static function fillRandom(ChunkManager $level, Vector3 $pos1, Vector3 $pos2, Block $block = null, Random $random = null, $randMax = 3) {
|
public static function fillRandom(ChunkManager $level, Vector3 $pos1, Vector3 $pos2, Block $block = null, Random $random = null, $randMax = 3) {
|
||||||
if ($block == null) $block = Block::get(Block::AIR);
|
if($block == null) $block = Block::get(Block::AIR);
|
||||||
list($pos1, $pos2) = self::minmax($pos1, $pos2);
|
list($pos1, $pos2) = self::minmax($pos1, $pos2);
|
||||||
for ($x = $pos1->x; $x >= $pos2->x; $x--) for ($y = $pos1->y; $y >= $pos2->y; $y--) for ($z = $pos1->z; $z >= $pos2->z; $z--) if ($random !== null ? $random->nextBoundedInt($randMax) == 0 : rand(0, $randMax) == 0) {
|
for($x = $pos1->x; $x >= $pos2->x; $x--) for($y = $pos1->y; $y >= $pos2->y; $y--) for($z = $pos1->z; $z >= $pos2->z; $z--) if($random !== null ? $random->nextBoundedInt($randMax) == 0 : rand(0, $randMax) == 0) {
|
||||||
$level->setBlockIdAt($x, $y, $z, $block->getId());
|
$level->setBlockIdAt($x, $y, $z, $block->getId());
|
||||||
$level->setBlockDataAt($x, $y, $z, $block->getDamage());
|
$level->setBlockDataAt($x, $y, $z, $block->getDamage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fills an area by custom filling
|
* Custom area filling
|
||||||
* @param $pos1 pocketmine\math\Vector3
|
*
|
||||||
* @param $pos2 pocketmine\math\Vector3
|
* @param Vector3 $pos1
|
||||||
* @param $call callback
|
* @param Vector3 $pos2
|
||||||
* @param $params array
|
* @param callable $call
|
||||||
|
* @param array $params
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public static function fillCallback(Vector3 $pos1, Vector3 $pos2, callable $call, ...$params): array {
|
public static function fillCallback(Vector3 $pos1, Vector3 $pos2, callable $call, ...$params) : array {
|
||||||
list($pos1, $pos2) = self::minmax($pos1, $pos2);
|
list($pos1, $pos2) = self::minmax($pos1, $pos2);
|
||||||
$return = [];
|
$return = [];
|
||||||
for ($x = $pos1->x; $x >= $pos2->x; $x--) for ($y = $pos1->y; $y >= $pos2->y; $y--) for ($z = $pos1->z; $z >= $pos2->z; $z--) {
|
for($x = $pos1->x; $x >= $pos2->x; $x--) for($y = $pos1->y; $y >= $pos2->y; $y--) for($z = $pos1->z; $z >= $pos2->z; $z--) {
|
||||||
$return[] = call_user_func($call, new Vector3($x, $y, $z), ...$params);
|
$return[] = call_user_func($call, new Vector3($x, $y, $z), ...$params);
|
||||||
}
|
}
|
||||||
return $return;
|
return $return;
|
||||||
|
@ -100,22 +91,23 @@ class BuildingUtils {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates walls
|
* Creates walls
|
||||||
* @param $level pocketmine\level\ChunkManager
|
*
|
||||||
* @param $pos1 pocketmine\math\Vector3
|
* @param ChunkManager $level
|
||||||
* @param $pos2 pocketmine\math\Vector3
|
* @param Vector3 $pos1
|
||||||
* @param $block pocketmine\block\Block
|
* @param Vector3 $pos2
|
||||||
|
* @param Block $block
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public static function walls(ChunkManager $level, Vector3 $pos1, Vector3 $pos2, Block $block) {
|
public static function walls(ChunkManager $level, Vector3 $pos1, Vector3 $pos2, Block $block) {
|
||||||
list($pos1, $pos2) = self::minmax($pos1, $pos2);
|
list($pos1, $pos2) = self::minmax($pos1, $pos2);
|
||||||
for ($y = $pos1->y; $y >= $pos2->y; $y--) {
|
for($y = $pos1->y; $y >= $pos2->y; $y--) {
|
||||||
for ($x = $pos1->x; $x >= $pos2->x; $x--) {
|
for($x = $pos1->x; $x >= $pos2->x; $x--) {
|
||||||
$level->setBlockIdAt($x, $y, $pos1->z, $block->getId());
|
$level->setBlockIdAt($x, $y, $pos1->z, $block->getId());
|
||||||
$level->setBlockDataAt($x, $y, $pos1->z, $block->getDamage());
|
$level->setBlockDataAt($x, $y, $pos1->z, $block->getDamage());
|
||||||
$level->setBlockIdAt($x, $y, $pos2->z, $block->getId());
|
$level->setBlockIdAt($x, $y, $pos2->z, $block->getId());
|
||||||
$level->setBlockDataAt($x, $y, $pos2->z, $block->getDamage());
|
$level->setBlockDataAt($x, $y, $pos2->z, $block->getDamage());
|
||||||
}
|
}
|
||||||
for ($z = $pos1->z; $z >= $pos2->z; $z--) {
|
for($z = $pos1->z; $z >= $pos2->z; $z--) {
|
||||||
$level->setBlockIdAt($pos1->x, $y, $z, $block->getId());
|
$level->setBlockIdAt($pos1->x, $y, $z, $block->getId());
|
||||||
$level->setBlockDataAt($pos1->x, $y, $z, $block->getDamage());
|
$level->setBlockDataAt($pos1->x, $y, $z, $block->getDamage());
|
||||||
$level->setBlockIdAt($pos2->x, $y, $z, $block->getId());
|
$level->setBlockIdAt($pos2->x, $y, $z, $block->getId());
|
||||||
|
@ -126,32 +118,34 @@ class BuildingUtils {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates the top of a structure
|
* Creates the top of a structure
|
||||||
* @param $level pocketmine\level\ChunkManager
|
*
|
||||||
* @param $pos1 pocketmine\math\Vector3
|
* @param ChunkManager $level
|
||||||
* @param $pos2 pocketmine\math\Vector3
|
* @param Vector3 $pos1
|
||||||
* @param $block pocketmine\block\Block
|
* @param Vector3 $pos2
|
||||||
|
* @param Block $block
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public static function top(ChunkManager $level, Vector3 $pos1, Vector3 $pos2, Block $block) {
|
public static function top(ChunkManager $level, Vector3 $pos1, Vector3 $pos2, Block $block) {
|
||||||
list($pos1, $pos2) = self::minmax($pos1, $pos2);
|
list($pos1, $pos2) = self::minmax($pos1, $pos2);
|
||||||
for ($x = $pos1->x; $x >= $pos2->x; $x--)
|
for($x = $pos1->x; $x >= $pos2->x; $x--)
|
||||||
for ($z = $pos1->z; $z >= $pos2->z; $z--) {
|
for($z = $pos1->z; $z >= $pos2->z; $z--) {
|
||||||
$level->setBlockIdAt($x, $pos1->y, $z, $block->getId());
|
$level->setBlockIdAt($x, $pos1->y, $z, $block->getId());
|
||||||
$level->setBlockDataAt($x, $pos1->y, $z, $block->getDamage());
|
$level->setBlockDataAt($x, $pos1->y, $z, $block->getDamage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates all corners from positions. Used for Mineshaft.
|
* Creates the corners of the structures. Used for mineshaft "towers"
|
||||||
* @param $level pocketmine\level\ChunkManager
|
*
|
||||||
* @param $pos1 pocketmine\math\Vector3
|
* @param ChunkManager $level
|
||||||
* @param $pos2 pocketmine\math\Vector3
|
* @param Vector3 $pos1
|
||||||
* @param $block pocketmine\block\Block
|
* @param Vector3 $pos2
|
||||||
|
* @param Block $block
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public static function corners(ChunkManager $level, Vector3 $pos1, Vector3 $pos2, Block $block) {
|
public static function corners(ChunkManager $level, Vector3 $pos1, Vector3 $pos2, Block $block) {
|
||||||
list($pos1, $pos2) = self::minmax($pos1, $pos2);
|
list($pos1, $pos2) = self::minmax($pos1, $pos2);
|
||||||
for ($y = $pos1->y; $y >= $pos2->y; $y--) {
|
for($y = $pos1->y; $y >= $pos2->y; $y--) {
|
||||||
$level->setBlockIdAt($pos1->x, $y, $pos1->z, $block->getId());
|
$level->setBlockIdAt($pos1->x, $y, $pos1->z, $block->getId());
|
||||||
$level->setBlockDataAt($pos1->x, $y, $pos1->z, $block->getDamage());
|
$level->setBlockDataAt($pos1->x, $y, $pos1->z, $block->getDamage());
|
||||||
$level->setBlockIdAt($pos2->x, $y, $pos1->z, $block->getId());
|
$level->setBlockIdAt($pos2->x, $y, $pos1->z, $block->getId());
|
||||||
|
@ -164,29 +158,31 @@ class BuildingUtils {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates the bottom of a structure
|
* Fills the bottom of a structure
|
||||||
* @param $level pocketmine\level\ChunkManager
|
*
|
||||||
* @param $pos1 pocketmine\math\Vector3
|
* @param ChunkManager $level
|
||||||
* @param $pos2 pocketmine\math\Vector3
|
* @param Vector3 $pos1
|
||||||
* @param $block pocketmine\block\Block
|
* @param Vector3 $pos2
|
||||||
|
* @param Block $block
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public static function bottom(ChunkManager $level, Vector3 $pos1, Vector3 $pos2, Block $block) {
|
public static function bottom(ChunkManager $level, Vector3 $pos1, Vector3 $pos2, Block $block) {
|
||||||
list($pos1, $pos2) = self::minmax($pos1, $pos2);
|
list($pos1, $pos2) = self::minmax($pos1, $pos2);
|
||||||
for ($x = $pos1->x; $x >= $pos2->x; $x--)
|
for($x = $pos1->x; $x >= $pos2->x; $x--)
|
||||||
for ($z = $pos1->z; $z >= $pos2->z; $z--) {
|
for($z = $pos1->z; $z >= $pos2->z; $z--) {
|
||||||
$level->setBlockIdAt($x, $pos2->y, $z, $block->getId());
|
$level->setBlockIdAt($x, $pos2->y, $z, $block->getId());
|
||||||
$level->setBlockDataAt($x, $pos2->y, $z, $block->getDamage());
|
$level->setBlockDataAt($x, $pos2->y, $z, $block->getDamage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Builds a random structure depending of length, height, depth and random
|
* Builds a structure randomly based on a circle algorithm. Used in caves and lakes.
|
||||||
* @param $level pocketmine\level\ChunkManager
|
*
|
||||||
* @param $pos pocketmine\math\Vector3
|
* @param ChunkManager $level
|
||||||
* @param $infos pocketmine\math\Vector3
|
* @param Vector3 $pos
|
||||||
* @param $random pocketmine\utils\Random
|
* @param Vector3 $infos
|
||||||
* @param $block pocketmine\block\Block
|
* @param Random $random
|
||||||
|
* @param Block $block
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public static function buildRandom(ChunkManager $level, Vector3 $pos, Vector3 $infos, Random $random, Block $block) {
|
public static function buildRandom(ChunkManager $level, Vector3 $pos, Vector3 $infos, Random $random, Block $block) {
|
||||||
|
@ -194,11 +190,11 @@ class BuildingUtils {
|
||||||
$yBounded = $random->nextBoundedInt(3) - 1;
|
$yBounded = $random->nextBoundedInt(3) - 1;
|
||||||
$zBounded = $random->nextBoundedInt(3) - 1;
|
$zBounded = $random->nextBoundedInt(3) - 1;
|
||||||
$pos = $pos->round();
|
$pos = $pos->round();
|
||||||
for ($x = $pos->x - ($infos->x / 2); $x <= $pos->x + ($infos->x / 2); $x++) {
|
for($x = $pos->x -($infos->x / 2); $x <= $pos->x +($infos->x / 2); $x++) {
|
||||||
for ($y = $pos->y - ($infos->y / 2); $y <= $pos->y + ($infos->y / 2); $y++) {
|
for($y = $pos->y -($infos->y / 2); $y <= $pos->y +($infos->y / 2); $y++) {
|
||||||
for ($z = $pos->z - ($infos->z / 2); $z <= $pos->z + ($infos->z / 2); $z++) {
|
for($z = $pos->z -($infos->z / 2); $z <= $pos->z +($infos->z / 2); $z++) {
|
||||||
// if(abs((abs($x) - abs($pos->x)) ** 2 + ($y - $pos->y) ** 2 + (abs($z) - abs($pos->z)) ** 2) < (abs($infos->x / 2 + $xBounded) + abs($infos->y / 2 + $yBounded) + abs($infos->z / 2 + $zBounded)) ** 2
|
// if(abs((abs($x) - abs($pos->x)) ** 2 +($y - $pos->y) ** 2 +(abs($z) - abs($pos->z)) ** 2) <(abs($infos->x / 2 + $xBounded) + abs($infos->y / 2 + $yBounded) + abs($infos->z / 2 + $zBounded)) ** 2
|
||||||
if (abs((abs($x) - abs($pos->x)) ** 2 + ($y - $pos->y) ** 2 + (abs($z) - abs($pos->z)) ** 2) < ((($infos->x / 2 - $xBounded) + ($infos->y / 2 - $yBounded) + ($infos->z / 2 - $zBounded)) / 3) ** 2 && $y > 0 && !in_array($level->getBlockIdAt($x, $y, $z), self::TO_NOT_OVERWRITE) && !in_array($level->getBlockIdAt($x, $y + 1, $z), self::TO_NOT_OVERWRITE)) {
|
if(abs((abs($x) - abs($pos->x)) ** 2 +($y - $pos->y) ** 2 +(abs($z) - abs($pos->z)) ** 2) <((($infos->x / 2 - $xBounded) +($infos->y / 2 - $yBounded) +($infos->z / 2 - $zBounded)) / 3) ** 2 && $y > 0 && ! in_array($level->getBlockIdAt($x, $y, $z), self::TO_NOT_OVERWRITE) && ! in_array($level->getBlockIdAt($x, $y + 1, $z), self::TO_NOT_OVERWRITE)) {
|
||||||
$level->setBlockIdAt($x, $y, $z, $block->getId());
|
$level->setBlockIdAt($x, $y, $z, $block->getId());
|
||||||
$level->setBlockDataAt($x, $y, $z, $block->getDamage());
|
$level->setBlockDataAt($x, $y, $z, $block->getDamage());
|
||||||
}
|
}
|
||||||
|
@ -206,4 +202,20 @@ class BuildingUtils {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns two Vector three, the biggest and lowest ones based on two provided vectors
|
||||||
|
*
|
||||||
|
* @param Vector3 $pos1
|
||||||
|
* @param Vector3 $pos2
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public static function minmax(Vector3 $pos1, Vector3 $pos2): array {
|
||||||
|
$v1 = new Vector3(max($pos1->x, $pos2->x), max($pos1->y, $pos2->y), max($pos1->z, $pos2->z));
|
||||||
|
$v2 = new Vector3(min($pos1->x, $pos2->x), min($pos1->y, $pos2->y), min($pos1->z, $pos2->z));
|
||||||
|
return [
|
||||||
|
$v1,
|
||||||
|
$v2
|
||||||
|
];
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -8,12 +8,15 @@
|
||||||
* \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\
|
* \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\
|
||||||
* \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/
|
* \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/
|
||||||
* Tomorrow's pocketmine generator.
|
* Tomorrow's pocketmine generator.
|
||||||
* @author Ad5001
|
* @author Ad5001 <mail@ad5001.eu>, XenialDan <https://github.com/thebigsmileXD>
|
||||||
* @link https://github.com/Ad5001/BetterGen
|
* @link https://github.com/Ad5001/BetterGen
|
||||||
|
* @category World Generator
|
||||||
|
* @api 3.0.0
|
||||||
|
* @version 1.1
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Ad5001\BetterGen\utils;
|
namespace Ad5001\BetterGen\utils;
|
||||||
# Common utils under no namespace made for a specific usage
|
# Common utils under no namespace made for a specific usage
|
||||||
|
|
||||||
class CommonUtils {
|
class CommonUtils {
|
||||||
/**
|
/**
|
||||||
|
@ -23,7 +26,7 @@ class CommonUtils {
|
||||||
* @param array $haystack
|
* @param array $haystack
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
static function in_arrayi($needle, array $haystack): bool {
|
static function in_arrayi($needle, array $haystack) :bool {
|
||||||
return in_array(strtolower($needle), array_map('strtolower', $haystack));
|
return in_array(strtolower($needle), array_map('strtolower', $haystack));
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in a new issue