Compare commits

...

27 commits

Author SHA1 Message Date
b2f0207148 Adding fyvekatz to contributors 2018-07-15 14:11:05 -04:00
ce05c1c269
Merge pull request #47 from fyvekatz/ALPHA12
Alpha12
2018-07-15 18:08:59 +00:00
fyvekatz
1cc8c924af Fixed typo which results in creash when "delBio" option is specified during level generation. 2018-06-28 21:48:35 -04:00
fyvekatz
1a76db0b59 Updated API version to ALPHA12 2018-06-28 21:45:25 -04:00
2b7566315d
Merge pull request #43 from zyware/patch-1
API version bump for 3.0.0-ALPHA11
2018-02-09 22:44:42 +00:00
Mikhail N
0342a6bd39
Update plugin.yml 2018-02-10 00:25:23 +03:00
b1fce28b47
Fixing startup warning when folders were already created 2018-01-28 19:08:23 +00:00
082a8060f9
Quick fix #40 2018-01-28 16:07:55 +00:00
40a6206409
Fixing #39 2018-01-26 20:54:08 +00:00
6d636e7443 Fixing folder related bugs 2017-11-14 22:58:36 +01:00
4b5cdeed6e Dungeons! 2017-11-13 19:49:01 +01:00
2a9c440d10 Merge branch 'master' of https://github.com/Ad5001/BetterGen 2017-10-31 23:27:35 +01:00
a671c0c29c Continuing on dungeons 2017-10-31 23:27:33 +01:00
e7ef5620d1
Merge pull request #34 from wyt3dr4g0n/master
Updated code for 3.0.0ALPHA9
2017-10-31 18:14:27 +01:00
Robb Jones
bdb77f6e81 Corrected variable in conversion code 2017-10-31 16:42:14 +00:00
Robb Jones
8387366191 Updated for 3.0.0ALPHA9 2017-10-31 16:20:17 +00:00
Robb Jones
946ff01874 Updated code for converting seed to int 2017-10-31 16:17:18 +00:00
Robb Jones
db96352150 Updated for 3.0.0ALPHA9 2017-10-31 14:57:05 +00:00
4512f5dfcd
New banner ! 2017-06-18 15:22:39 +02:00
512ac47f70 Adding dugeons 2017-05-22 19:08:00 +02:00
8f933a8c12 Well #23 2017-05-15 17:27:55 +02:00
b5fb3c21ae Fixing a level error 2017-05-14 22:18:21 +02:00
1f6416d02e Documented EVERY SINGLE FUNCTIONS... 2017-05-14 21:03:47 +02:00
920fd82b6e Changing file headers 2017-05-14 20:13:15 +02:00
becff0ca47 Fixing mineshaft going too up 2017-05-14 19:44:11 +02:00
c7bbc37d8d Fixing namespaces issues. 2017-05-14 19:27:03 +02:00
015967050d Changing private properties to protected
This is made to allow people to extend and use these properties.
2017-05-14 19:23:44 +02:00
44 changed files with 1292 additions and 775 deletions

191
LICENSE
View file

@ -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.
--------------------------------------------------------------------------------------------------------------------------------------
The License: refers to the BoxOfDevs International Software License 1.1.2
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:
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.
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.
1. Both The User & The Author Can:
a. Modify private copies of The Software and use in any way they wish.
I. Definitions:
- "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:
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.
Section II. Scope.
3. The Author Can:
a. Change or update The Software in any way they wish, ensuring they follow the other terms of The License.
b. Change which license The Software/The Modification is licensed under.
c. Grant extra rights to The User who has requested them.
d. Reserve the right to request The User to take down their instance of The Software/The Modification/The Redistribution.
1. License grant.
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:
A. reproduce and Distribute the Software, in whole or in part, for NonCommercial purposes only; and
B. produce, reproduce, and Distribute Modification for NonCommercial purposes only.
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:
1. Both The User & The Author Cannot:
a. Introduce any malicious code into The Software/The Modification.
b. Sell any part of The Software/The Modification for profit.
Section III. License Conditions.
Your exercise of the Licensed Rights is expressly made subject to the following conditions.
2. The User Cannot:
a. Hold The Author responsible for any unknown errors.
b. Claim The Software/The Modification/The Redistribution as entirely The User's product.
c. Use the software without crediting the Author.
1. Attribution.
a. If You Distribute the Software (including in modified, or based form), You must:
A. retain the following if it is supplied by the Author with the Software:
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;
iii. a notice that refers to the NTOS License;
iv. a notice that refers to the disclaimer of warranties;
v. 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 the Software is licensed under the NTOS License, and include the text of, or the URI or hyperlink to, the NTOS License.
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.
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.
3. The Author Cannot:
a. Restrict The User in any way not specified by The License.
b. Distribute any form of The Software without proper documentation.
2. Distribute ALike
In addition to the conditions in Section III(1), if You Distribute the Modification You produce, the following conditions also apply.
A. The Modification Author's License You apply must be the NTOS License
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.
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
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.
3. Distribution of code
In addition to the conditions in Section III(1), if You Distribute a Based Software, the following conditions also apply:
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.
B. You must also include Section III(1)(a)(A)(ii-v) in the the Based Software Code.
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 Adapters 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).
Section IV. Sui Generis Database Rights.
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.
Where the Licensed Rights include Sui Generis Database Rights that apply to Your use of the Software:
Section 3 License Conditions.
Your exercise of the Licensed Rights is expressly made subject to the following conditions.
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.
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 the Software is licensed under this License, and include the text of, or the URI or hyperlink to, this 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.
If requested by the Author, You must remove any of the information required by Section 3(a)(1)(A) to the extent reasonably practicable.
b) ShareAlike.
In addition to the conditions in Section 3(a), if You Share the Modification You produce, the following conditions also apply.
The Adapters License You apply must be a BoxOfDevs General License with the same License Elements, this version or later, or a BY-SA Compatible 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.
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) Forever Open Source.
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.
The Adapted work must have an open source existing repertory, accessible by anyone anytime linked in the Redistribution Description/Documentation.
You may not restrict anyone from accessing the source code, use it, and redistribute it under anything not explicily specified by the License.
d) Free.
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.
You may not impose fees to anyone that gets the Modification/The Software.
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.
Where the Licensed Rights include Sui Generis Database Rights that apply to Your use of the Software:
Section V Disclaimer of Warranties and Limitation of Liability.
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;
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
You must comply with the conditions in Section 3(a) if You 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.
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.
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.
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.
Section VI Term and Termination.
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:
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.
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 the NTOS License.
Sections I, V, VI, VII, and VI survive termination of the NTOS License.
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
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, 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.
Sections 1, 5, 6, 7, and 8 survive termination of this License.
Section VII Other Terms and Conditions.
Section 7 Other Terms and Conditions.
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 the NTOS License.
The Author 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.
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 VIII Interpretation.
Section 8 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.
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.
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.
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.
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.
No term or condition of this License will be waived and no failure to comply consented to unless expressly agreed to by the Author.
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.
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.

View file

@ -46,4 +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.
<img src="https://raw.githubusercontent.com/Ad5001/BetterGen/master/imgs/bushes.png" style="width: 500px"></img>
All content here is copyrighted (C) Ad5001 2017. Infos about this copyright can be found in the license file.
# Contributors:
BetterGen wouldn't be here today without the following guys who have made this plugin possible to get where it is now:
Ad5001
thebigsmileXD
wyt3dr4g0n
fyvekatz

BIN
imgs/Render.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 516 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 MiB

After

Width:  |  Height:  |  Size: 823 KiB

View file

@ -1,4 +1,5 @@
---
# ____ __ __ ____
# /\ _`\ /\ \__ /\ \__ /\ _`\
# \ \ \L\ \ __ \ \ ,_\\ \ ,_\ __ _ __ \ \ \L\_\ __ ___
@ -7,14 +8,19 @@
# \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\
# \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/
# Tomorrow's pocketmine generator.
# @author Ad5001
# @category World Generator
# @api 3.0.0
# @link https://github.com/Ad5001/BetterGen
# @version 1.1
name: BetterGen
author: Ad5001
contributors:
- thebigsmileXD (XenialDan)
- wyt3dr4g0n
main: Ad5001\BetterGen\Main
version: 1.1
load: STARTUP
api: [3.0.1, 3.0.0-ALPHA3]
api: [3.0.0-ALPHA12]
commands:
createworld:
description: Generates a new world.

View file

@ -1 +0,0 @@
[]

View file

@ -8,8 +8,11 @@
* \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\
* \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/
* Tomorrow's pocketmine generator.
* @author Ad5001
* @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;
@ -43,36 +46,38 @@ class Main extends PluginBase implements Listener {
const PREFIX = "§l§o§b[§r§l§2Better§aGen§o§b]§r§f ";
const SAKURA_FOREST = 100; // Letting some place for future biomes.
/*
* Called when the plugin enables
/**
* Regisetrs a biome to betternormal
*
* @param int $id
* @param Biome $biome
* @return void
*/
public static function registerBiome(int $id, Biome $biome) {
BetterNormal::registerBiome($biome);
}
/*
* Called when the plugin disables
/**
* Called when the plugin enales
*
* @return void
*/
public function onEnable() {
$this->getServer()->getPluginManager()->registerEvents($this, $this);
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");
@mkdir($this->getDataFolder());
@mkdir(LootTable::getPluginFolder());
@mkdir(LootTable::getPluginFolder() . "loots");
if (!file_exists(LootTable::getPluginFolder() . "processingLoots.json"))
file_put_contents(LootTable::getPluginFolder() . "processingLoots.json", "{}");
}
/*
* 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
*/
/**
* Checks for tesseract like namespaces. Returns true if thats the case
*
* @return boolean
*/
public static function isOtherNS() {
try {
return @class_exists("pocketmine\\level\\generator\\normal\\object\\OakTree");
@ -81,24 +86,15 @@ class Main extends PluginBase implements Listener {
}
}
/*
* Registers a forest type.
* @param $name string
* @param $treeClass string
* @params $infos Array(temperature, rainfall)
/**
* Called when a command executes
*
* @param CommandSender $sender
* @param Command $cmd
* @param int $label
* @param array $args
* @return bool
*/
public function onDisable() {
}
/*
* Registers a biome for the normal generator. Normal means(Biome::register) doesn't allow biome to be generated
* @param $id int
* @param $biome Biome
* @return void
*/
public function onCommand(CommandSender $sender, Command $cmd, $label, array $args): bool {
switch ($cmd->getName()) {
case "createworld": // /createworld <name> [generator = betternormal] [seed = rand()] [options(json)]
@ -132,15 +128,13 @@ class Main extends PluginBase implements Listener {
return true;
}
$generatorName = strtolower($args[1]);
if (preg_match("[^\d]", $args[2]) !== false) {
$parts = str_split($args[2]);
foreach ($parts as $key => $str) {
$parts[$key] = ord($str);
}
$seed = implode("", $parts);
} else {
$seed = $args[2];
}
$parts = str_split($args[2]);
foreach ($parts as $key=>$str) {
if(is_numeric($str) == false && $str <> '-'){
$parts[$key] = ord($str);
}
}
$seed = (int)implode("", $parts);
$options = [];
break;
default : // /createworld <name> [generator = betternormal] [seed = rand()] [options(json)]
@ -152,15 +146,13 @@ class Main extends PluginBase implements Listener {
}
$generatorName = strtolower($args[1]);
if ($args[2] == "rand") $args[2] = $this->generateRandomSeed();
if (preg_match("[^\d]", $args[2]) !== false) {
$parts = str_split($args[2]);
foreach ($parts as $key => $str) {
$parts[$key] = ord($str);
}
$seed = implode("", $parts);
} else {
$seed = $args[2];
}
$parts = str_split($args[2]);
foreach ($parts as $key=>$str) {
if(is_numeric($str) == false && $str <> '-'){
$parts[$key] = ord($str);
}
}
$seed = (int)implode("", $parts);
unset($args[0], $args[1], $args[2]);
$options = json_decode($args[3], true);
if (!is_array($options)) {
@ -187,7 +179,7 @@ class Main extends PluginBase implements Listener {
return false;
}
}
$sender->teleport(\pocketmine\level\Position::fromObject($player, $this->getServer()->getLevelByName($args[0])));
$sender->teleport(\pocketmine\level\Position::fromObject($sender, $this->getServer()->getLevelByName($args[0])));
$sender->sendMessage("§aTeleporting to {$args[0]}...");
return true;
} else {
@ -205,23 +197,22 @@ class Main extends PluginBase implements Listener {
return false;
}
/*
* Generates a(semi) random seed.
/**
* Generates a (semi) random seed.
* @return int
*/
public function generateRandomSeed(): int {
return (int)round(rand(0, round(time()) / memory_get_usage(true)) * (int)str_shuffle("127469453645108") / (int)str_shuffle("12746945364"));
}
// Listener
/*
* Checks after a chunk populates so we an add tiles and loot tables
* @param $event pocketmine\event\level\ChunkPopulateEvent
* @return int
/**
* Registers a forest from a tree class
*
* @param string $name
* @param string $treeClass
* @param array $infos
* @return bool
*/
public function registerForest(string $name, string $treeClass, array $infos): bool {
if (!@class_exists($treeClass))
return false;
@ -233,10 +224,12 @@ class Main extends PluginBase implements Listener {
}
/*
* Checks when a player interacts with a loot chest to create it.
/**
* 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) {
@ -251,10 +244,12 @@ class Main extends PluginBase implements Listener {
}
/*
* Checks when a player breaks a loot chest which is not created to create it
/**
* Checks when a player touches an ungenerated chest to generate it.
*
* @param PlayerInteractEvent $event
* @return void
*/
public function onInteract(PlayerInteractEvent $event) {
$cfg = new Config(LootTable::getPluginFolder() . "processingLoots.json", Config::JSON);
if ($event->getBlock()->getId() !== Block::CHEST) return;
@ -272,11 +267,12 @@ class Main extends PluginBase implements Listener {
LootTable::fillChest($chest->getInventory(), $event->getBlock());
}
/*
* Check if it's a Tesseract like namespace
* @return bool
*/
/**
* Checks when a players breaks an ungenerated chest to generate it.
*
* @param BlockBreakEvent $event
* @return void
*/
public function onBlockBreak(BlockBreakEvent $event) {
$cfg = new Config(LootTable::getPluginFolder() . "processingLoots.json", Config::JSON);
if ($event->getBlock()->getId() !== Block::CHEST) return;
@ -292,6 +288,5 @@ class Main extends PluginBase implements Listener {
$chest = Tile::createTile(Tile::CHEST, $event->getBlock()->getLevel(), $nbt);
$chest->setName("§k(Fake)§r Minecart chest");
LootTable::fillChest($chest->getInventory(), $event->getBlock());
// $event->setCancelled(); //i think nope. You want to break it with items
}
}

View file

@ -8,8 +8,11 @@
* \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\
* \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/
* Tomorrow's pocketmine generator.
* @author Ad5001
* @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\biome;
@ -24,6 +27,10 @@ use pocketmine\level\generator\biome\Biome;
use pocketmine\level\generator\normal\biome\SandyBiome;
class BetterDesert extends SandyBiome implements Mountainable {
/**
* Constructs the class
*/
public function __construct() {
parent::__construct();
$deadBush = new DeadbushPopulator ();
@ -73,14 +80,22 @@ class BetterDesert extends SandyBiome implements Mountainable {
Block::get(Block::SANDSTONE, 0)
]);
}
/**
* Constructs the class
*
* @return string
*/
public function getName(): string {
return "BetterDesert";
}
/*
/**
* Returns biome id
*
* @return int
*/
public function getId() {
public function getId(): int {
return Biome::DESERT;
}
}

View file

@ -9,8 +9,11 @@
* \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\
* \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/
* Tomorrow's pocketmine generator.
* @author Ad5001
* @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\biome;
@ -19,21 +22,31 @@ use Ad5001\BetterGen\Main;
use Ad5001\BetterGen\populator\BushPopulator;
use Ad5001\BetterGen\populator\FallenTreePopulator;
use Ad5001\BetterGen\populator\TreePopulator;
use Ad5001\BetterGen\generator\BetterNormal;
use pocketmine\level\generator\biome\Biome;
use pocketmine\level\generator\normal\biome\ForestBiome;
class BetterForest extends ForestBiome implements Mountainable {
/** @var string[] **/
static $types = [
"Oak Forest",
"Birch Forest",
"Sakura Forest"
];
/** @var int[] **/
static $ids = [
Biome::FOREST,
Biome::BIRCH_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]) {
parent::__construct($type);
$this->clearPopulators ();
@ -63,18 +76,21 @@ class BetterForest extends ForestBiome implements Mountainable {
$this->temperature = $infos[0];
$this->rainfall = $infos[1];
}
public function getName() {
public function getName(): string {
return str_ireplace(" ", "", self::$types[$this->type]);
}
/**
* Returns the ID relatively.
*
* @return int
*/
public function getId() {
public function getId(): int {
return self::$ids[$this->type];
}
/**
* Registers a forest
*
* @param string $name
* @param string $treeClass
* @param array $infos

View file

@ -8,19 +8,27 @@
* \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\
* \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/
* Tomorrow's pocketmine generator.
* @author Ad5001
* @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\biome;
use Ad5001\BetterGen\Main;
use Ad5001\BetterGen\populator\IglooPopulator;
use Ad5001\BetterGen\generator\BetterNormal;
use pocketmine\block\Block;
use pocketmine\level\generator\biome\Biome;
use pocketmine\level\generator\normal\biome\SnowyBiome;
class BetterIcePlains extends SnowyBiome implements Mountainable {
/**
* Constructs the class
*/
public function __construct() {
parent::__construct ();
$this->setGroundCover([
@ -42,15 +50,22 @@ class BetterIcePlains extends SnowyBiome implements Mountainable {
$this->temperature = 0.05;
$this->rainfall = 0.8;
}
public function getName() {
/**
* Returns the biome name
*
* @return string
*/
public function getName(): string {
return "BetterIcePlains";
}
/**
* Returns the biomes' id.
*
* @return int biome id
*/
public function getId() {
public function getId(): int {
return Biome::ICE_PLAINS;
}
}

View file

@ -8,8 +8,11 @@
* \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\
* \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/
* Tomorrow's pocketmine generator.
* @author Ad5001
* @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\biome;
@ -19,11 +22,16 @@ use Ad5001\BetterGen\populator\CactusPopulator;
use Ad5001\BetterGen\populator\DeadbushPopulator;
use Ad5001\BetterGen\populator\SugarCanePopulator;
use Ad5001\BetterGen\populator\TreePopulator;
use Ad5001\BetterGen\generator\BetterNormal;
use pocketmine\block\Block;
use pocketmine\block\GoldOre;
use pocketmine\level\generator\normal\biome\SandyBiome;
class BetterMesa extends SandyBiome {
/**
* Constructs the class
*/
public function __construct() {
parent::__construct();
$deadBush = new DeadbushPopulator ();
@ -104,14 +112,22 @@ class BetterMesa extends SandyBiome {
Block::get(Block::RED_SANDSTONE, 0)
]);
}
/**
* Returns the biome name
*
* @return string
*/
public function getName(): string {
return "BetterMesa";
}
/*
/**
* Returns biome id
*
* @return int
*/
public function getId() {
public function getId(): int {
return 39;
}
}

View file

@ -8,8 +8,11 @@
* \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\
* \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/
* Tomorrow's pocketmine generator.
* @author Ad5001
* @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\biome;
@ -18,11 +21,15 @@ use Ad5001\BetterGen\Main;
use Ad5001\BetterGen\populator\CactusPopulator;
use Ad5001\BetterGen\populator\DeadbushPopulator;
use Ad5001\BetterGen\populator\SugarCanePopulator;
use Ad5001\BetterGen\generator\BetterNormal;
use pocketmine\block\Block;
use pocketmine\block\GoldOre;
use pocketmine\level\generator\normal\biome\SandyBiome;
class BetterMesaPlains extends SandyBiome {
/**
* Constructs the class
*/
public function __construct() {
parent::__construct();
$deadBush = new DeadbushPopulator ();
@ -100,14 +107,22 @@ class BetterMesaPlains extends SandyBiome {
Block::get(Block::RED_SANDSTONE, 0)
]);
}
/**
* Returns the name of th biome
*
* @return string
*/
public function getName(): string {
return "BetterMesaPlains";
}
/*
/**
* Returns biome id
*
* @return int
*/
public function getId() {
public function getId(): int {
return 40;
}
}

View file

@ -8,8 +8,11 @@
* \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\
* \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/
* Tomorrow's pocketmine generator.
* @author Ad5001
* @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\biome;
@ -18,6 +21,9 @@ use pocketmine\block\Block;
use pocketmine\level\generator\biome\Biome;
class BetterRiver extends Biome {
/**
* Constructs the class
*/
public function __construct() {
$this->clearPopulators ();
@ -40,14 +46,22 @@ class BetterRiver extends Biome {
$this->temperature = 0.5;
$this->rainfall = 0.7;
}
public function getName() {
/**
* Returns the biome name
*
* @return string
*/
public function getName(): string {
return "BetterRiver";
}
/*
* Returns the ID relatively.
/**
* Returns the biome id
*
* @return int
*/
public function getId() {
public function getId(): int {
return Biome::RIVER;
}
}

View file

@ -8,8 +8,11 @@
* \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\
* \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/
* Tomorrow's pocketmine generator.
* @author Ad5001
* @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\biome;

View file

@ -8,9 +8,12 @@
* \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\
* \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/
* Tomorrow's pocketmine generator.
* @author Ad5001
* @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\generator;
use pocketmine\level\generator\biome\Biome;
@ -21,16 +24,26 @@ use pocketmine\utils\Random;
class BetterBiomeSelector extends BiomeSelector {
/** @var Biome */
private $fallback;
protected $fallback;
/** @var Simplex */
private $temperature;
protected $temperature;
/** @var Simplex */
private $rainfall;
protected $rainfall;
/** @var Biome[] */
private $biomes = [ ];
private $lookup;
protected $biomes = [ ];
/** @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) {
parent::__construct($random, $lookup, $fallback);
$this->fallback = $fallback;
@ -38,28 +51,57 @@ class BetterBiomeSelector extends BiomeSelector {
$this->temperature = 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() {
} // 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) {
$this->biomes[$biome->getId ()] = $biome;
}
/**
* Returns the temperature from a location
*
* @param int $x
* @param int $z
* @return void
*/
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
* $x
* @param
* $z
* @param int $x
* @param int $z
*
* @return Biome
*/
public function pickBiome($x, $z) {
public function pickBiome($x, $z): Biome {
$temperature = ($this->getTemperature($x, $z));
$rainfall = ($this->getRainfall($x, $z));

View file

@ -8,9 +8,12 @@
* \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\
* \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/
* Tomorrow's pocketmine generator.
* @author Ad5001
* @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\generator;
@ -26,6 +29,7 @@ use Ad5001\BetterGen\populator\CavePopulator;
use Ad5001\BetterGen\populator\FloatingIslandPopulator;
use Ad5001\BetterGen\populator\MineshaftPopulator;
use Ad5001\BetterGen\populator\RavinePopulator;
use Ad5001\BetterGen\populator\DungeonPopulator;
use pocketmine\block\Block;
use pocketmine\block\CoalOre;
use pocketmine\block\DiamondOre;
@ -65,31 +69,40 @@ class BetterNormal extends Generator {
protected $level;
/** @var Random */
protected $random;
/** @var Populator[] */
protected $populators = [ ];
/** @var Populator[] */
protected $generationPopulators = [ ];
/** @var Biome[][] */
public static $biomes = [ ];
/** @var Biome[] */
public static $biomeById = [ ];
/** @var Level[] */
public static $levels = [ ];
/** @var int[][] */
protected static $GAUSSIAN_KERNEL = null; // From main class
/** @var int */
protected static $SMOOTH_SIZE = 2;
protected static $options = [
/** @var mixed[][] */
public static $options = [
"delBio" => [
],
"delStruct" => [
"Lakes"
]
];
/** @var int */
protected $waterHeight = 63;
private $noiseBase;
protected $noiseBase;
/*
/**
* Picks a biome by X and Z
*
* @param $x int
* @param $z int
* @return Biome
*/
public function pickBiome($x, $z) {
public function pickBiome($x, $z): Biome {
$hash = $x * 2345803 ^ $z * 9236449 ^ $this->level->getSeed ();
$hash *= $hash + 223;
$xNoise = $hash >> 20 & 3;
@ -198,6 +211,13 @@ class BetterNormal extends Generator {
$this->populators[] = $fisl;
}
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();
if(Main::isOtherNS()) $ores->setOreTypes([
@ -242,8 +262,9 @@ class BetterNormal extends Generator {
return true;
}
/*
/**
* Returns a biome by temperature
*
* @param $temperature float
* @param $rainfall float
*/
@ -263,7 +284,7 @@ class BetterNormal extends Generator {
}
$b = self::$biomes[( string) round($rainfall, 1)];
foreach($b as $t => $biome) {
if ($temperature <=(float) $t) {
if ($temperature <= (float) $t) {
$ret = $biome;
break;
}
@ -274,20 +295,22 @@ class BetterNormal extends Generator {
return $ret;
}
/*
/**
* Returns a biome by its id
* @param $id int
*
* @param int $id
* @return Biome
*/
public function getBiomeById(int $id): Biome {
return self::$biomeById[$id] ?? self::$biomeById[Biome::OCEAN];
}
/*
/**
* Generates a chunk.
*
* Cloning method to make it work with new methods.
* @param $chunkX int
* @param $chunkZ int
* @param int $chunkX
* @param int $chunkZ
*/
public function generateChunk($chunkX, $chunkZ) {
@ -356,10 +379,12 @@ class BetterNormal extends Generator {
}
}
/*
* Populates a chunk.
* @param $chunkX int
* @param $chunk2 int
/**
* Populates a chunk
*
* @param int $chunkX
* @param int $chunkZ
* @return void
*/
public function populateChunk($chunkX, $chunkZ) {
$this->random->setSeed(0xdeadbeef ^ ($chunkX << 8) ^ $chunkZ ^ $this->level->getSeed ());
@ -380,15 +405,16 @@ class BetterNormal extends Generator {
$biome->populateChunk($this->level, $chunkX, $chunkZ, $this->random);
}
/*
/**
* Constructs the class
* @param $options array
*
* @param array $options
*/
public function __construct(array $options = []) {
self::$options["preset"] = $options["preset"];
$options = (array) json_decode($options["preset"]);
if(isset($options["delBio"])) {
if(is_string($options["de"])) $options["delBio"] = explode(",", $options["delBio"]);
if(is_string($options["delBio"])) $options["delBio"] = explode(",", $options["delBio"]);
if(count($options["delBio"]) !== 0) {
self::$options["delBio"] = $options["delBio"];
}
@ -404,10 +430,10 @@ class BetterNormal extends Generator {
}
}
/*
/**
* Generates the generation kernel based on smooth size (here 2)
*/
private static function generateKernel() {
protected static function generateKernel() {
self::$GAUSSIAN_KERNEL = [ ];
$bellSize = 1 / self::$SMOOTH_SIZE;
@ -424,24 +450,37 @@ class BetterNormal extends Generator {
}
}
//  Returns the name of the generator
public function getName() {
/**
* Return the name of the generator
*
* @return string
*/
public function getName(): string {
return "betternormal";
}
/*
/**
* Gives the generators settings.
*
* @return array
*/
public function getSettings(): array {
return self::$options;
}
public function getSpawn() {
/**
* Returns spawn location
*
* @return Vector3
*/
public function getSpawn(): Vector3 {
return new Vector3(127.5, 128, 127.5);
}
/*
/**
* Returns a safe spawn location
*
* @return Vector3
*/
public function getSafeSpawn() {
return new Vector3(127.5, $this->getHighestWorkableBlock(127, 127), 127.5);

View file

@ -8,8 +8,11 @@
* \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\
* \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/
* Tomorrow's pocketmine generator.
* @author Ad5001
* @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\loot;
@ -54,11 +57,12 @@ class LootTable {
const LOOT_IGLOO = 1;
const LOOT_MINESHAFT = 2;
/*
* Asynchronous loot table choosing
* @param $place pocketmine\math\Vector3
* @param $type int
* @param $random pocketmine\utils\Random
/**
* Asynchronous method to build a loot table
*
* @param Vector3 $place
* @param int $type
* @param Random $random
* @return void
*/
public static function buildLootTable(Vector3 $place, int $type, Random $random) {
@ -79,10 +83,11 @@ class LootTable {
$cfg->save();
}
/*
* Synchronous inventory filling with loot table.
* @param $inv pocketmine\inventory\BaseInventory
* @param $pos pocketmine\math\Vector3
/**
* Synchronous inventory filling method
*
* @param BaseInventory $inv
* @param Vector3 $pos
* @return void
*/
public static function fillChest(BaseInventory $inv, Vector3 $pos) {
@ -105,25 +110,19 @@ class LootTable {
}
}
/*
/**
* Returns the plugins folder.
* @return string
*/
public static function getPluginFolder(): string {
$dir = explode(DIRECTORY_SEPARATOR, __DIR__);
$c = count($dir);
unset($dir[$c - 1], $dir[$c - 2], $dir[$c - 3], $dir[$c - 4], $dir[$c - 5]);
return str_ireplace("phar://", "", implode(DIRECTORY_SEPARATOR, $dir)) . DIRECTORY_SEPARATOR . "BetterGen" . DIRECTORY_SEPARATOR;
return getcwd() . DIRECTORY_SEPARATOR . "plugins" . DIRECTORY_SEPARATOR . "BetterGen" . DIRECTORY_SEPARATOR;
}
/*
/**
* Returns the resources folder.
* @return string
*/
public static function getResourcesFolder(): string {
$dir = explode(DIRECTORY_SEPARATOR, __DIR__);
$c = count($dir);
unset($dir[$c - 1], $dir[$c - 2], $dir[$c - 3], $dir[$c - 4]);
return str_ireplace("phar://", "", implode(DIRECTORY_SEPARATOR, $dir)) . DIRECTORY_SEPARATOR . "resources" . DIRECTORY_SEPARATOR;
return self::getPluginFolder() . "resources" . DIRECTORY_SEPARATOR;
}
}

View file

@ -8,8 +8,9 @@
* \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\
* \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/
* Tomorrow's pocketmine generator.
* @author Ad5001
* @author Ad5001 <mail@ad5001.eu>, XenialDan <https://github.com/thebigsmileXD>
* @link https://github.com/Ad5001/BetterGen
* @version 1.1
*/
namespace Ad5001\BetterGen\populator;
@ -21,11 +22,11 @@ abstract class AmountPopulator extends Populator {
protected $baseAmount = 0;
protected $randomAmount = 0;
/*
/**
* Crosssoftware class for random amount
*/
/*
/**
* Sets the random addition amount
* @param $amount int
*/
@ -33,7 +34,7 @@ abstract class AmountPopulator extends Populator {
$this->randomAmount = $amount;
}
/*
/**
* Sets the base addition amount
* @param $amount int
*/
@ -41,24 +42,28 @@ abstract class AmountPopulator extends Populator {
$this->baseAmount = $amount;
}
/*
/**
* Returns the amount based on random
* @param $random Random
*
* @param Random $random
* @return int
*/
public function getAmount(Random $random) {
return $this->baseAmount + $random->nextRange(0, $this->randomAmount + 1);
}
/*
* Returns the base amount
/**
* Returns base amount
*
* @return int
*/
public function getBaseAmount(): int {
return $this->baseAmount;
}
/*
/**
* Returns the random additional amount
*
* @return int
*/
public function getRandomAmount(): int {

View file

@ -8,8 +8,11 @@
* \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\
* \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/
* Tomorrow's pocketmine generator.
* @author Ad5001
* @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;
@ -23,22 +26,26 @@ use pocketmine\utils\Random;
class BushPopulator extends AmountPopulator {
/** @var ChunkManager */
protected $level;
/** @var int */
protected $type;
/*
/**
* Constructs the class
* @param $type int
*
* @param int $type
*/
public function __construct($type = 0) {
$this->type = $type;
}
/*
* Populate the chunk
* @param $level pocketmine\level\ChunkManager
* @param $chunkX int
* @param $chunkZ int
* @param $random pocketmine\utils\Random
/**
* 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;
@ -56,10 +63,12 @@ class BushPopulator extends AmountPopulator {
}
}
/*
* Gets the top block (y) on an x and z axes
* @param $x int
* @param $z int
/**
* Gets the highest workable block
*
* @param int $x
* @param int $z
* @return void
*/
protected function getHighestWorkableBlock($x, $z) {
for($y = Level::Y_MAX - 1; $y > 0; -- $y) {

View file

@ -8,8 +8,11 @@
* \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\
* \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/
* Tomorrow's pocketmine generator.
* @author Ad5001
* @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
*/
@ -24,7 +27,7 @@ use pocketmine\utils\Random;
class CactusPopulator extends AmountPopulator {
/** @var ChunkManager */
protected $level;
/*
/**
* Constructs the class
*/
public function __construct() {
@ -32,12 +35,14 @@ class CactusPopulator extends AmountPopulator {
$this->setRandomAmount(2);
}
/*
* Populate the chunk
* @param $level pocketmine\level\ChunkManager
* @param $chunkX int
* @param $chunkZ int
* @param $random pocketmine\utils\Random
/**
* 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;
@ -53,10 +58,13 @@ class CactusPopulator extends AmountPopulator {
}
}
/*
* Gets the top block (y) on an x and z axes
* @param $x int
* @param $z int
/**
* Gets the highest workable block
*
* @param int $x
* @param int $z
* @return void
*/
protected function getHighestWorkableBlock($x, $z) {
for($y = Level::Y_MAX - 1; $y >= 0; -- $y) {

View file

@ -8,8 +8,11 @@
* \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\
* \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/
* Tomorrow's pocketmine generator.
* @author Ad5001
* @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;
@ -27,12 +30,14 @@ class CavePopulator extends AmountPopulator {
const STOP = false;
const CONTINUE = true;
/*
* Populate the chunk
* @param $level pocketmine\level\ChunkManager
* @param $chunkX int
* @param $chunkZ int
* @param $random pocketmine\utils\Random
/**
* 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;
@ -60,10 +65,10 @@ class CavePopulator extends AmountPopulator {
}
}
/*
/**
* Gets the top block (y) on an x and z axes
* @param $x int
* @param $z int
* @param int $x
* @param int $z
*/
protected function getHighestWorkableBlock($x, $z) {
for($y = Level::Y_MAX - 1; $y > 0; -- $y) {
@ -78,12 +83,13 @@ class CavePopulator extends AmountPopulator {
return ++$y;
}
/*
/**
* Generates a cave
* @param $x int
* @param $y int
* @param $z int
* @param $random pocketmine\utils\Random
*
* @param int $x
* @param int $y
* @param int $z
* @param Random $random
* @return void
*/
public function generateCave($x, $y, $z, Random $random) {
@ -97,16 +103,18 @@ class CavePopulator extends AmountPopulator {
}
}
}
/*
* Generates a cave branch.
* @param $x int
* @param $y int
* @param $z int
* @param $length int
* @param $height int
* @param $depth int
* @param $random pocketmine\utils\Random
* @yield int
/**
* Generates a cave branch
*
* @param int $x
* @param int $y
* @param int $z
* @param int $length
* @param int $height
* @param int $depth
* @param Random $random
* @yield Vector3
* @return void
*/
public function generateBranch($x, $y, $z, $length, $height, $depth, Random $random) {

View file

@ -8,8 +8,11 @@
* \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\
* \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/
* Tomorrow's pocketmine generator.
* @author Ad5001
* @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;
@ -25,12 +28,14 @@ class DeadbushPopulator extends AmountPopulator {
/** @var ChunkManager */
protected $level;
/*
* Populate the chunk
* @param $level pocketmine\level\ChunkManager
* @param $chunkX int
* @param $chunkZ int
* @param $random pocketmine\utils\Random
/**
* 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;
@ -53,7 +58,7 @@ class DeadbushPopulator extends AmountPopulator {
* @param $z
* @return int
*/
private function getHighestWorkableBlock($x, $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::SAND or $b === Block::SANDSTONE or $b === Block::HARDENED_CLAY or $b === Block::STAINED_HARDENED_CLAY){

View 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;
}
}

View file

@ -8,8 +8,11 @@
* \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\
* \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/
* Tomorrow's pocketmine generator.
* @author Ad5001
* @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;
@ -25,9 +28,9 @@ class FallenTreePopulator extends AmountPopulator {
/** @var ChunkManager */
protected $level;
protected $type;
/*
/**
* Constructs the class
* @param $type int
* @param int $type
*/
public function __construct(int $type = 0) {
$this->type = $type;
@ -35,12 +38,14 @@ class FallenTreePopulator extends AmountPopulator {
$this->setRandomAmount(2);
}
/*
* Populate the chunk
* @param $level pocketmine\level\ChunkManager
* @param $chunkX int
* @param $chunkZ int
* @param $random pocketmine\utils\Random
/**
* 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;
@ -66,7 +71,7 @@ class FallenTreePopulator extends AmountPopulator {
* @param $z
* @return int
*/
private function getHighestWorkableBlock($x, $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){

View file

@ -8,8 +8,11 @@
* \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\
* \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/
* Tomorrow's pocketmine generator.
* @author Ad5001
* @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;
@ -32,17 +35,18 @@ use pocketmine\utils\Random;
class FloatingIslandPopulator extends AmountPopulator {
/*
* Populate the chunk
* @param $level pocketmine\level\ChunkManager
* @param $chunkX int
* @param $chunkZ int
* @param $random pocketmine\utils\Random
*/
/** @var ChunkManager */
private $level;
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;
if($this->getAmount($random) > 130) {
@ -63,10 +67,10 @@ class FloatingIslandPopulator extends AmountPopulator {
/*
/**
* Gets the top block (y) on an x and z axes
* @param $x int
* @param $z int
* @param int $x
* @param int $z
*/
protected function getHighestWorkableBlock($x, $z) {
for($y = Level::Y_MAX - 1; $y > 0; -- $y) {
@ -83,13 +87,14 @@ class FloatingIslandPopulator extends AmountPopulator {
/*
* Builds a an island shape
* @param $level pocketmine\level\ChunkManager
* @param $pos pocketmine\math\Vector3
* @param $radius int
* @param $random pocketmine\utils\Random
* @return int lowest ore point
/**
* Builds an island bottom shape
*
* @param ChunkManager $level
* @param Vector3 $pos
* @param int $radius
* @param Random $random
* @return int Bottom place of the island
*/
public function buildIslandBottomShape(ChunkManager $level, Vector3 $pos, int $radius, Random $random) {
$pos = $pos->round();
@ -134,14 +139,15 @@ class FloatingIslandPopulator extends AmountPopulator {
/*
* BPopulate the island with ores
* @param $level pocketmine\level\ChunkManager
* @param $pos pocketmine\math\Vector3
* @param $width int
* @param $height int
* @param $random pocketmine\utils\Random
* @return void
/**
* Populates the island with ores
*
* @param ChunkManager $level
* @param Vector3 $pos
* @param int $width
* @param int $height
* @param Random $random
* @return void
*/
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();

View file

@ -8,8 +8,9 @@
* \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\
* \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/
* Tomorrow's pocketmine generator.
* @author Ad5001
* @author Ad5001 <mail@ad5001.eu>, XenialDan <https://github.com/thebigsmileXD>
* @link https://github.com/Ad5001/BetterGen
* @version 1.1
*/
namespace Ad5001\BetterGen\populator;
@ -24,12 +25,15 @@ class IglooPopulator extends AmountPopulator {
/** @var ChunkManager */
protected $level;
/*
* Populate the chunk
* @param $level pocketmine\level\ChunkManager
* @param $chunkX int
* @param $chunkZ int
* @param $random pocketmine\utils\Random
/**
* 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;
@ -43,10 +47,10 @@ class IglooPopulator extends AmountPopulator {
$igloo->placeObject($level, $x, $y, $z, $random);
}
/*
/**
* Gets the top block (y) on an x and z axes
* @param $x int
* @param $z int
* @param int $x
* @param int $z
*/
protected function getHighestWorkableBlock($x, $z) {
for($y = Level::Y_MAX - 1; $y > 0; -- $y) {

View file

@ -8,8 +8,11 @@
* \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\
* \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/
* Tomorrow's pocketmine generator.
* @author Ad5001
* @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;
@ -25,12 +28,15 @@ class LakePopulator extends AmountPopulator {
/** @var ChunkManager */
protected $level;
/*
* Populate the chunk
* @param $level pocketmine\level\ChunkManager
* @param $chunkX int
* @param $chunkZ int
* @param $random pocketmine\utils\Random
/**
* 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;
@ -52,10 +58,10 @@ class LakePopulator extends AmountPopulator {
$level->setBlockIdAt($xx, $yy, $zz, Block::AIR);
}
/*
/**
* Gets the top block (y) on an x and z axes
* @param $x int
* @param $z int
* @param int $x
* @param int $z
*/
protected function getHighestWorkableBlock($x, $z) {
for($y = Level::Y_MAX - 1; $y > 0; -- $y) {

View file

@ -8,8 +8,11 @@
* \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\
* \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/
* Tomorrow's pocketmine generator.
* @author Ad5001
* @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;
@ -20,8 +23,10 @@ use pocketmine\block\Block;
use pocketmine\level\ChunkManager;
use pocketmine\math\Vector3;
use pocketmine\utils\Random;
use pocketmine\level\Level;
class MineshaftPopulator extends AmountPopulator {
/** var int */
protected $maxPath;
/** @var ChunkManager */
protected $level;
@ -33,12 +38,14 @@ class MineshaftPopulator extends AmountPopulator {
const TYPE_CROSSPATH = 1;
const TYPE_STAIRS = 2;
/*
* Populate the chunk
* @param $level pocketmine\level\ChunkManager
* @param $chunkX int
* @param $chunkZ int
* @param $random pocketmine\utils\Random
/**
* 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) {
if ($this->getAmount($random) < 100)
@ -80,7 +87,7 @@ class MineshaftPopulator extends AmountPopulator {
* @param 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;
$type = $random->nextBoundedInt(3);
$level = $this->level;
@ -93,7 +100,7 @@ class MineshaftPopulator extends AmountPopulator {
// 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) {
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);
// Putting rails
BuildingUtils::fillCallback(new Vector3($x, $y, $z), new Vector3($x + 4, $y, $z), function ($v3, ChunkManager $level, Random $random) {
@ -107,9 +114,9 @@ class MineshaftPopulator extends AmountPopulator {
$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 + 2, $z - 1, Block::PLANK);
$level->setBlockIdAt($x, $y + 2, $z, Block::PLANK);
$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::PLANKS);
$level->setBlockIdAt($x, $y + 2, $z + 1, Block::PLANKS);
$level->setBlockIdAt($x + 1, $y + 2, $z, Block::TORCH);
$level->setBlockDataAt($x + 1, $y + 2, $z, 2);
// Generating chest
@ -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) {
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);
// Putting rails
BuildingUtils::fillCallback(new Vector3($x, $y, $z), new Vector3($x - 4, $y, $z), function ($v3, ChunkManager $level, Random $random) {
@ -148,9 +155,9 @@ class MineshaftPopulator extends AmountPopulator {
$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 + 2, $z - 1, Block::PLANK);
$level->setBlockIdAt($x, $y + 2, $z, Block::PLANK);
$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::PLANKS);
$level->setBlockIdAt($x, $y + 2, $z + 1, Block::PLANKS);
$level->setBlockIdAt($x - 1, $y + 2, $z, Block::TORCH);
$level->setBlockDataAt($x - 1, $y + 2, $z, 1);
// Generating chest
@ -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) {
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);
// Putting rails
BuildingUtils::fillCallback(new Vector3($x, $y, $z), new Vector3($x, $y, $z + 4), function ($v3, ChunkManager $level, Random $random) {
@ -189,9 +196,9 @@ class MineshaftPopulator extends AmountPopulator {
$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 + 2, $z, Block::PLANK);
$level->setBlockIdAt($x, $y + 2, $z, Block::PLANK);
$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::PLANKS);
$level->setBlockIdAt($x + 1, $y + 2, $z, Block::PLANKS);
$level->setBlockIdAt($x, $y + 2, $z - 1, Block::TORCH);
$level->setBlockDataAt($x, $y + 2, $z - 1, 4);
// Generating chest
@ -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) {
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);
// Putting rails
BuildingUtils::fillCallback(new Vector3($x, $y, $z), new Vector3($x, $y, $z - 4), function ($v3, ChunkManager $level, Random $random) {
@ -230,9 +237,9 @@ class MineshaftPopulator extends AmountPopulator {
$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 + 2, $z, Block::PLANK);
$level->setBlockIdAt($x, $y + 2, $z, Block::PLANK);
$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::PLANKS);
$level->setBlockIdAt($x + 1, $y + 2, $z, Block::PLANKS);
$level->setBlockIdAt($x, $y + 2, $z - 1, Block::TORCH);
$level->setBlockDataAt($x, $y + 2, $z - 1, 3);
// Generating chest
@ -291,13 +298,13 @@ 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) {
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);
// 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::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 ();
$numberFloor = $random->nextBoundedInt(4 + ($newFloor ? 5 : 0));
@ -371,7 +378,7 @@ class MineshaftPopulator extends AmountPopulator {
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) {
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);
break;
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) {
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);
break;
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) {
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);
break;
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) {
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);
break;
}
@ -419,5 +426,21 @@ class MineshaftPopulator extends AmountPopulator {
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;
}
}
?>

View file

@ -8,8 +8,11 @@
* \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\
* \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/
* Tomorrow's pocketmine generator.
* @author Ad5001
* @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;
@ -25,12 +28,14 @@ class RavinePopulator extends AmountPopulator {
protected $level;
const NOISE = 250;
/*
* Populate the chunk
* @param $level pocketmine\level\ChunkManager
* @param $chunkX int
* @param $chunkZ int
* @param $random pocketmine\utils\Random
/**
* 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;
@ -87,14 +92,16 @@ class RavinePopulator extends AmountPopulator {
return ++$y;
}
/*
* Builds a ravine part
* @param $x int
* @param $y int
* @param $z int
* @param $height int
* @param $length int
* @param $random pocketmine\utils\Random
/**
* Buidls a ravine part
*
* @param int $x
* @param int $y
* @param int $z
* @param int $height
* @param int $length
* @param Random $random
* @return void
*/
protected function buildRavinePart($x, $y, $z, $height, $length, Random $random) {
$xBounded = 0;

View file

@ -8,8 +8,11 @@
* \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\
* \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/
* Tomorrow's pocketmine generator.
* @author Ad5001
* @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;
@ -23,7 +26,8 @@ use pocketmine\utils\Random;
class SugarCanePopulator extends AmountPopulator {
/** @var ChunkManager */
protected $level;
/*
/**
* Constructs the class
*/
public function __construct() {
@ -31,12 +35,14 @@ class SugarCanePopulator extends AmountPopulator {
$this->setRandomAmount(2);
}
/*
* Populate the chunk
* @param $level pocketmine\level\ChunkManager
* @param $chunkX int
* @param $chunkZ int
* @param $random pocketmine\utils\Random
/**
* 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;
@ -52,10 +58,11 @@ class SugarCanePopulator extends AmountPopulator {
}
}
/*
/**
* Gets the top block (y) on an x and z axes
* @param $x int
* @param $z int
* @return int
*/
protected function getHighestWorkableBlock($x, $z) {
for($y = Level::Y_MAX - 1; $y >= 0; -- $y) {

View file

@ -8,8 +8,11 @@
* \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\
* \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/
* Tomorrow's pocketmine generator.
* @author Ad5001
* @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;
@ -24,12 +27,14 @@ class TemplePopulator extends AmountPopulator {
/** @var Level */
protected $level;
/*
* Populate the chunk
* @param $level pocketmine\level\ChunkManager
* @param $chunkX int
* @param $chunkZ int
* @param $random pocketmine\utils\Random
/**
* 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;
@ -43,10 +48,10 @@ class TemplePopulator extends AmountPopulator {
$temple->placeObject($level, $x, $y - 1, $z, $random);
}
/*
/**
* Gets the top block (y) on an x and z axes
* @param $x int
* @param $z int
* @param int $x
* @param int $z
*/
protected function getHighestWorkableBlock($x, $z) {
for($y = Level::Y_MAX - 1; $y > 0; -- $y) {

View file

@ -8,8 +8,11 @@
* \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\
* \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/
* Tomorrow's pocketmine generator.
* @author Ad5001
* @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;
@ -31,9 +34,10 @@ class TreePopulator extends AmountPopulator {
];
/** @var ChunkManager */
protected $level;
/** @var int */
protected $type;
/*
/**
* Constructs the class
*/
public function __construct($type = 0) {
@ -47,12 +51,15 @@ class TreePopulator extends AmountPopulator {
}
}
/*
* Populate the chunk
* @param $level pocketmine\level\ChunkManager
* @param $chunkX int
* @param $chunkZ int
* @param $random pocketmine\utils\Random
/**
* 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;
@ -71,10 +78,10 @@ class TreePopulator extends AmountPopulator {
}
}
/*
/**
* Gets the top block (y) on an x and z axes
* @param $x int
* @param $z int
* @param int $x
* @param int $z
*/
protected function getHighestWorkableBlock($x, $z) {
for($y = Level::Y_MAX - 1; $y > 0; -- $y) {

View file

@ -8,8 +8,11 @@
* \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\
* \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/
* Tomorrow's pocketmine generator.
* @author Ad5001
* @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;
@ -24,12 +27,15 @@ class WellPopulator extends AmountPopulator {
/** @var ChunkManager */
protected $level;
/*
* Populate the chunk
* @param $level pocketmine\level\ChunkManager
* @param $chunkX int
* @param $chunkZ int
* @param $random pocketmine\utils\Random
/**
* 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;
@ -43,10 +49,10 @@ class WellPopulator extends AmountPopulator {
$well->placeObject($level, $x, $y, $z, $random);
}
/*
/**
* Gets the top block (y) on an x and z axes
* @param $x int
* @param $z int
* @param int $x
* @param int $z
*/
protected function getHighestWorkableBlock($x, $z) {
for($y = Level::Y_MAX - 1; $y > 0; -- $y) {

View file

@ -8,32 +8,38 @@
* \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\
* \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/
* Tomorrow's pocketmine generator.
* @author Ad5001
* @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 pocketmine\block\Block;
use pocketmine\level\ChunkManager;
use pocketmine\level\generator\object\Object;
use pocketmine\level\generator\object\PopulatorObject;
use pocketmine\math\Vector3;
use pocketmine\utils\Random;
class Bush extends Object {
class Bush extends PopulatorObject {
public $overridable = [
Block::AIR => true,
17 => true,
Block::SNOW_LAYER => true,
Block::LOG2 => true
];
/** @var int[] */
protected $leaf;
/** @var int */
protected $height;
/*
/**
* Constructs the class
* @param $leafId int
* @param $leafData int
*
* @param int $leafId
* @param int $leafData
*/
public function __construct($leafId = Block::LEAVES, $leafData = 0) {
$this->leaf = [
@ -42,13 +48,15 @@ class Bush extends Object {
];
}
/*
/**
* Places a bush
* @param $level pocketmine\level\ChunkManager
* @param $x int
* @param $y int
* @param $z int
* @param $random pocketmine\utils\Random
*
* @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) {
$number = $random->nextBoundedInt(6);
@ -64,12 +72,14 @@ class Bush extends Object {
}
}
/*
/**
* Places a leaf
* @param $x int
* @param $y int
* @param $z int
* @param $level pocketmine\level\ChunkManager
*
* @param int $x
* @param int $y
* @param int $z
* @param ChunkManager $level
* @return void
*/
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)])) {

View file

@ -8,29 +8,34 @@
* \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\
* \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/
* Tomorrow's pocketmine generator.
* @author Ad5001
* @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 pocketmine\block\Block;
use pocketmine\level\ChunkManager;
use pocketmine\level\generator\object\Object;
use pocketmine\level\generator\object\PopulatorObject;
use pocketmine\utils\Random;
class Cactus extends Object {
class Cactus extends PopulatorObject {
/*
protected $totalHeight;
/**
* Checks if a cactus is placeable
* @param $level pocketmine\level\ChunkManager
* @param $x int
* @param $y int
* @param $z int
* @param $random pocketmine\utils\Random
*
* @param ChunkManager $level
* @param int $x
* @param int $y
* @param int $z
* @param Random $random
* @return bool
*/
private $totalHeight;
public function canPlaceObject(ChunkManager $level, int $x, int $y, int $z, Random $random): bool {
$this->totalHeight = 1 + $random->nextBoundedInt(3);
$below = $level->getBlockIdAt($x, $y - 1, $z);
@ -42,12 +47,14 @@ class Cactus extends Object {
return true;
}
/*
/**
* Places a cactus
* @param $level pocketmine\level\ChunkManager
* @param $x int
* @param $y int
* @param $z int
*
* @param ChunkManager $level
* @param int $x
* @param int $y
* @param int $z
* @return void
*/
public function placeObject(ChunkManager $level, int $x, int $y, int $z) {
for($yy = 0; $yy < $this->totalHeight; $yy ++) {

View 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);
}
}

View file

@ -8,8 +8,11 @@
* \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\
* \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/
* Tomorrow's pocketmine generator.
* @author Ad5001
* @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;
@ -17,13 +20,13 @@ namespace Ad5001\BetterGen\structure;
use Ad5001\BetterGen\utils\BuildingUtils;
use pocketmine\block\Block;
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\math\Vector3;
use pocketmine\utils\Random;
class FallenTree extends Object {
class FallenTree extends PopulatorObject {
public static $overridable = [
Block::AIR => true,
6 => true,
@ -34,34 +37,39 @@ class FallenTree extends Object {
Block::SNOW_LAYER => true,
Block::LOG2 => true,
Block::LEAVES2 => true,
Block::CACTUS => true
];
Block::CACTUS => true];
/** @var Tree */
protected $tree;
/** @var int */
protected $direction;
/** @var Random */
protected $random;
private $length = 0;
/** @var int */
protected $length = 0;
/*
/**
* Constructs the class
* @param $tree ObjectTree
* @throws Exeption
*
* @param ObjectTree $tree
*/
public function __construct(ObjectTree $tree) {
$this->tree = $tree;
}
/*
* Places a fallen tree
* @param $level pocketmine\level\ChunkManager
* @param $x int
* @param $y int
* @param $z int
* @param $random pocketmine\utils\Random
/**
* Checks the placement a fallen tree
*
* @param ChunkManager $level
* @param int $x
* @param int $y
* @param int $z
* @param Random $random
* @return void
*/
public function canPlaceObject(ChunkManager $level, $x, $y, $z, Random $random) {
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));
$this->length = ($this->tree->trunkHeight ?? 5) + $randomHeight;
//echo "Checking at $x $y $z FallenTree\n";
$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->treeHeight ?? 5) + $randomHeight;
$this->direction = $random->nextBoundedInt(4);
$this->random = $random;
switch ($this->direction) {
@ -69,12 +77,12 @@ class FallenTree extends Object {
case 1:// Z+
$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)])) {
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;
}
}, $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)])) {
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;
}
}, $level));
@ -86,12 +94,12 @@ class FallenTree extends Object {
case 3: // X+
$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)])) {
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;
}
}, $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)])) {
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;
}
}, $level));
@ -103,15 +111,17 @@ class FallenTree extends Object {
return true;
}
/*
/**
* Places a fallen tree
* @param $level pocketmine\level\ChunkManager
* @param $x int
* @param $y int
* @param $z int
*
* @param ChunkManager $level
* @param int $x
* @param int $y
* @param int $z
* @return void
*/
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) {
case 0:
$level->setBlockIdAt($x, $y, $z, $this->tree->trunkBlock);
@ -147,12 +157,14 @@ class FallenTree extends Object {
}
}
/*
* Places a Block
* @param $x int
* @param $y int
* @param $z int
* @param $level pocketmine\level\ChunkManager
/**
* Places a block
*
* @param int $x
* @param int $y
* @param int $z
* @param ChunkManager $level
* @return void
*/
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)])) {

View file

@ -8,18 +8,21 @@
* \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\
* \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/
* Tomorrow's pocketmine generator.
* @author Ad5001
* @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 pocketmine\block\Block;
use pocketmine\level\ChunkManager;
use pocketmine\level\generator\object\Object;
use pocketmine\level\generator\object\PopulatorObject;
use pocketmine\utils\Random;
class Igloo extends Object {
class Igloo extends PopulatorObject {
public $overridable = [
Block::AIR => true,
6 => true,
@ -31,16 +34,18 @@ class Igloo extends Object {
Block::LOG2 => true,
Block::LEAVES2 => true
];
/** @var int */
protected $direction;
/*
* Checks if an igloo is placeable
* @param $level pocketmine\level\ChunkManager
* @param $x int
* @param $y int
* @param $z int
* @param $random pocketmine\utils\Random
* @return bool
/**
* Checks if an igloo is placable
*
* @param ChunkManager $level
* @param int $x
* @param int $y
* @param int $z
* @param Random $random
* @return void
*/
public function canPlaceObject(ChunkManager $level, $x, $y, $z, Random $random) {
$this->direction = $random->nextBoundedInt(4);
@ -77,14 +82,15 @@ class Igloo extends Object {
return true;
}
/*
/**
* Places an igloo
* @param $level pocketmine\level\ChunkManager
* @param $x int
* @param $y int
* @param $z int
* @param $random pocketmine\utils\Random
* @return bool placed
*
* @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) {
if (! isset($this->direction) && ! $this->canPlaceObject($level, $x, $y, $z, $random))

View file

@ -8,8 +8,11 @@
* \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\
* \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/
* Tomorrow's pocketmine generator.
* @author Ad5001
* @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;
@ -440,12 +443,14 @@ class SakuraTree extends Tree {
];
const maxPerChunk = 2;
/** @var int */
public $trunkHeight = 11;
/** @var int */
public $leafType;
/** @var int */
public $leaf2Type;
/*
/**
* Constructs the class
*/
public function __construct() {
@ -457,15 +462,18 @@ class SakuraTree extends Tree {
$this->type = Wood::OAK;
}
/*
* Builds the tree.
* @param $level \pocketmine\level\ChunkManager
* @param $x int
* @param $y int
* @param $z int
* @param $random $random
/**
* Builds a tree
*
* @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) {
$this->random = $random;
$percentage = $random->nextBoundedInt(100);
if ($percentage > 10) {
return;
@ -569,9 +577,7 @@ class SakuraTree extends Tree {
$totalLength = $stickLen + $stickLen2; // Length of the stick
$sideLen = $totalLength ** 2; // Side length
//TODO CHECK WHAT THIS IS SUPPOSED TO BE
$numForward = ($totalLength % 2 == 0) ? $totalLength - 1 : $totalLength;
//TODO END
$lX1 = $lZ1 = $lX = $lZ = 0;
// First branch part + first leave part
@ -621,8 +627,6 @@ class SakuraTree extends Tree {
}
}
// continue;
switch ($dir + 1) {
case 4 :
$xd2 = 0;
@ -656,25 +660,35 @@ class SakuraTree extends Tree {
}
}
/*
* Fills a log at.
* @param $level pocketmine\level\ChunkManager
* @param $x int
* @param $y int
* @param $z int
/**
* Fills a log
*
* @param ChunkManager $level
* @param int $x
* @param int $y
* @param int $z
* @return void
*/
public function setLog(ChunkManager $level, $x, $y, $z) {
$level->setBlockIdAt($x, $y, $z, $this->trunkBlock);
$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.
* @param $level pocketmine\level\ChunkManager
* @param $x int
* @param $y int
* @param $z int
* @param $random pocketmine\utils\Random
/**
* Fills leaves
*
* @param ChunkManager $level
* @param int $x
* @param int $y
* @param int $z
* @param Random $random
* @return void
*/
public function setLeave(ChunkManager $level, $x, $y, $z, Random $random) {
$data = [

View file

@ -8,8 +8,11 @@
* \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\
* \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/
* Tomorrow's pocketmine generator.
* @author Ad5001
* @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
*/
@ -17,21 +20,23 @@ namespace Ad5001\BetterGen\structure;
use pocketmine\block\Block;
use pocketmine\level\ChunkManager;
use pocketmine\level\generator\object\Object;
use pocketmine\level\generator\object\PopulatorObject;
use pocketmine\utils\Random;
class SugarCane extends Object {
class SugarCane extends PopulatorObject {
/*
* Checks if a cactus is placeable
* @param $level pocketmine\level\ChunkManager
* @param $x int
* @param $y int
* @param $z int
* @param $random pocketmine\utils\Random
protected $totalHeight;
/**
* Checks if a sugarcane is placable
*
* @param ChunkManager $level
* @param int $x
* @param int $y
* @param int $z
* @param Random $random
* @return bool
*/
private $totalHeight;
public function canPlaceObject(ChunkManager $level, int $x, int $y, int $z, Random $random): bool {
$this->totalHeight = 1 + $random->nextBoundedInt(3);
$below = $level->getBlockIdAt($x, $y - 1, $z);
@ -41,12 +46,14 @@ class SugarCane extends Object {
return false;
}
/*
* Places a cactus
* @param $level pocketmine\level\ChunkManager
* @param $x int
* @param $y int
* @param $z int
/**
* Places a sugar cane
*
* @param ChunkManager $level
* @param int $x
* @param int $y
* @param int $z
* @return void
*/
public function placeObject(ChunkManager $level, int $x, int $y, int $z) {
for($yy = 0; $yy < $this->totalHeight; $yy ++) {

View file

@ -8,8 +8,11 @@
* \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\
* \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/
* Tomorrow's pocketmine generator.
* @author Ad5001
* @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;
@ -17,11 +20,11 @@ namespace Ad5001\BetterGen\structure;
use Ad5001\BetterGen\utils\BuildingUtils;
use pocketmine\block\Block;
use pocketmine\level\ChunkManager;
use pocketmine\level\generator\object\Object;
use pocketmine\level\generator\object\PopulatorObject;
use pocketmine\math\Vector3;
use pocketmine\utils\Random;
class Temple extends Object {
class Temple extends PopulatorObject {
const DIRECTION_PLUSX = 0;
const DIRECTION_MINX = 1;
const DIRECTION_PLUSZ = 2;
@ -108,19 +111,20 @@ class Temple extends Object {
]
];
/** @var ChunkManager */
private $level;
private $direction = 0;
protected $level;
protected $direction = 0;
/*
* Checks if a temple is placeable
* @param $level pocketmine\level\ChunkManager
* @param $x int
* @param $y int
* @param $z int
* @param $random pocketmine\utils\Random
* @return bool
/**
* Checks if a temple is placable
*
* @param ChunkManager $level
* @param int $x
* @param int $y
* @param int $z
* @param Random $random
* @return void
*/
public function canPlaceObject(ChunkManager $level, $x, $y, $z, Random $random) {
$this->level = $level;
$this->direction = $random->nextBoundedInt(4);
@ -132,13 +136,15 @@ class Temple extends Object {
return true;
}
/*
* Places a temple
* @param $level pocketmine\level\ChunkManager
* @param $x int
* @param $y int
* @param $z int
* @param $random pocketmine\utils\Random
/**
* Builds a temple
*
* @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) {
// Clearing space...
@ -154,26 +160,13 @@ class Temple extends Object {
// 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));
#for ($xx = $x + 5; $xx >= $x - 5; $xx--)
# for ($zz = $z + 5; $zz >= $z - 5; $zz--)
# $this->placeBlock($xx, $y + 4, $zz);
// 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));
#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
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
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
for ($i = -2; $i <= 1; $i++) {//straight
$xextra = ($i + 1) % 2;

View file

@ -8,8 +8,11 @@
* \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\
* \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/
* Tomorrow's pocketmine generator.
* @author Ad5001
* @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
*/
@ -17,11 +20,11 @@ namespace Ad5001\BetterGen\structure;
use pocketmine\block\Block;
use pocketmine\level\ChunkManager;
use pocketmine\level\generator\object\Object;
use pocketmine\level\generator\object\PopulatorObject;
use pocketmine\utils\Random;
class Well extends Object {
class Well extends PopulatorObject {
/** @var ChunkManager */
protected $level;
public $overridable = [
@ -55,14 +58,15 @@ class Well extends Object {
]
];
/*
* Checks if a well is placeable
* @param $level ChunkManager
* @param $x int
* @param $y int
* @param $z int
* @param $random Random
* @return bool
/**
* Checks if a Well is placable
*
* @param ChunkManager $level
* @param int $x
* @param int $y
* @param int $z
* @param Random $random
* @return void
*/
public function canPlaceObject(ChunkManager $level, $x, $y, $z, Random $random) {
$this->level = $level;
@ -74,13 +78,15 @@ class Well extends Object {
return true;
}
/*
/**
* Places a well
* @param $level ChunkManager
* @param $x int
* @param $y int
* @param $z int
* @param $random Random
*
* @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) {
$this->level = $level;
@ -111,12 +117,14 @@ class Well extends Object {
$this->placeBlock($x, $y, $z, Block::WATER);
}
/*
* Places a slab
* @param $x int
* @param $y int
* @param $z int
* @param $id int
/**
* Places a block
*
* @param int $x
* @param int $y
* @param int $z
* @param int $id
* @param int $meta
* @return void
*/
public function placeBlock($x, $y, $z, $id = 0, $meta = 0) {

View file

@ -8,8 +8,11 @@
* \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\
* \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/
* Tomorrow's pocketmine generator.
* @author Ad5001
* @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\utils;
@ -27,179 +30,187 @@ class BuildingUtils {
Block::LAVA,
Block::BEDROCK,
Block::CACTUS,
Block::PLANK
];
Block::PLANKS];
/*
/**
* Fills an area
* @param $level pocketmine\level\ChunkManager
* @param $pos1 pocketmine\math\Vector3
* @param $pos2 pocketmine\math\Vector3
* @param $block pocketmine\block\Block
*
* @param ChunkManager $level
* @param Vector3 $pos1
* @param Vector3 $pos2
* @param Block $block
* @return void
*/
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);
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->setBlockDataAt($x, $y, $z, $block->getDamage ());
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->setBlockDataAt($x, $y, $z, $block->getDamage());
}
}
/*
/**
* Fills an area randomly
* @param $level pocketmine\level\ChunkManager
* @param $pos1 pocketmine\math\Vector3
* @param $pos2 pocketmine\math\Vector3
* @param $block pocketmine\block\Block
* @param $random pocketmine\utils
* @param $randMax pocketmine\utils
*
* @param ChunkManager $level
* @param Vector3 $pos1
* @param Vector3 $pos2
* @param Block $block
* @param Random $random
* @param int $randMax
* @return void
*/
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);
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->setBlockDataAt($x, $y, $z, $block->getDamage ());
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->setBlockDataAt($x, $y, $z, $block->getDamage());
}
}
/*
* Fills an area by custom filling
* @param $pos1 pocketmine\math\Vector3
* @param $pos2 pocketmine\math\Vector3
* @param $call callback
* @param $params array
/**
* Custom area filling
*
* @param Vector3 $pos1
* @param Vector3 $pos2
* @param callable $call
* @param array $params
* @return array
*/
public static function fillCallback(Vector3 $pos1, Vector3 $pos2, callable $call, ...$params) : array {
list($pos1, $pos2) = self::minmax($pos1, $pos2);
$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 --) {
$return[] = call_user_func($call, new Vector3($x, $y, $z), ...$params);
}
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 $return;
}
/*
/**
* Creates walls
* @param $level pocketmine\level\ChunkManager
* @param $pos1 pocketmine\math\Vector3
* @param $pos2 pocketmine\math\Vector3
* @param $block pocketmine\block\Block
*
* @param ChunkManager $level
* @param Vector3 $pos1
* @param Vector3 $pos2
* @param Block $block
* @return void
*/
public static function walls(ChunkManager $level, Vector3 $pos1, Vector3 $pos2, Block $block) {
list($pos1, $pos2) = self::minmax($pos1, $pos2);
for($y = $pos1->y; $y >= $pos2->y; $y --) {
for($x = $pos1->x; $x >= $pos2->x; $x --) {
$level->setBlockIdAt($x, $y, $pos1->z, $block->getId ());
$level->setBlockDataAt($x, $y, $pos1->z, $block->getDamage ());
$level->setBlockIdAt($x, $y, $pos2->z, $block->getId ());
$level->setBlockDataAt($x, $y, $pos2->z, $block->getDamage ());
for($y = $pos1->y; $y >= $pos2->y; $y--) {
for($x = $pos1->x; $x >= $pos2->x; $x--) {
$level->setBlockIdAt($x, $y, $pos1->z, $block->getId());
$level->setBlockDataAt($x, $y, $pos1->z, $block->getDamage());
$level->setBlockIdAt($x, $y, $pos2->z, $block->getId());
$level->setBlockDataAt($x, $y, $pos2->z, $block->getDamage());
}
for($z = $pos1->z; $z >= $pos2->z; $z --) {
$level->setBlockIdAt($pos1->x, $y, $z, $block->getId ());
$level->setBlockDataAt($pos1->x, $y, $z, $block->getDamage ());
$level->setBlockIdAt($pos2->x, $y, $z, $block->getId ());
$level->setBlockDataAt($pos2->x, $y, $z, $block->getDamage ());
for($z = $pos1->z; $z >= $pos2->z; $z--) {
$level->setBlockIdAt($pos1->x, $y, $z, $block->getId());
$level->setBlockDataAt($pos1->x, $y, $z, $block->getDamage());
$level->setBlockIdAt($pos2->x, $y, $z, $block->getId());
$level->setBlockDataAt($pos2->x, $y, $z, $block->getDamage());
}
}
}
/*
/**
* Creates the top of a structure
* @param $level pocketmine\level\ChunkManager
* @param $pos1 pocketmine\math\Vector3
* @param $pos2 pocketmine\math\Vector3
* @param $block pocketmine\block\Block
*
* @param ChunkManager $level
* @param Vector3 $pos1
* @param Vector3 $pos2
* @param Block $block
* @return void
*/
public static function top(ChunkManager $level, Vector3 $pos1, Vector3 $pos2, Block $block) {
list($pos1, $pos2) = self::minmax($pos1, $pos2);
for($x = $pos1->x; $x >= $pos2->x; $x --)
for($z = $pos1->z; $z >= $pos2->z; $z --) {
$level->setBlockIdAt($x, $pos1->y, $z, $block->getId ());
$level->setBlockDataAt($x, $pos1->y, $z, $block->getDamage ());
for($x = $pos1->x; $x >= $pos2->x; $x--)
for($z = $pos1->z; $z >= $pos2->z; $z--) {
$level->setBlockIdAt($x, $pos1->y, $z, $block->getId());
$level->setBlockDataAt($x, $pos1->y, $z, $block->getDamage());
}
}
/*
* Creates all corners from positions. Used for Mineshaft.
* @param $level pocketmine\level\ChunkManager
* @param $pos1 pocketmine\math\Vector3
* @param $pos2 pocketmine\math\Vector3
* @param $block pocketmine\block\Block
/**
* Creates the corners of the structures. Used for mineshaft "towers"
*
* @param ChunkManager $level
* @param Vector3 $pos1
* @param Vector3 $pos2
* @param Block $block
* @return void
*/
public static function corners(ChunkManager $level, Vector3 $pos1, Vector3 $pos2, Block $block) {
list($pos1, $pos2) = self::minmax($pos1, $pos2);
for($y = $pos1->y; $y >= $pos2->y; $y --) {
$level->setBlockIdAt($pos1->x, $y, $pos1->z, $block->getId ());
$level->setBlockDataAt($pos1->x, $y, $pos1->z, $block->getDamage ());
$level->setBlockIdAt($pos2->x, $y, $pos1->z, $block->getId ());
$level->setBlockDataAt($pos2->x, $y, $pos1->z, $block->getDamage ());
$level->setBlockIdAt($pos1->x, $y, $pos2->z, $block->getId ());
$level->setBlockDataAt($pos1->x, $y, $pos2->z, $block->getDamage ());
$level->setBlockIdAt($pos2->x, $y, $pos2->z, $block->getId ());
$level->setBlockDataAt($pos2->x, $y, $pos2->z, $block->getDamage ());
for($y = $pos1->y; $y >= $pos2->y; $y--) {
$level->setBlockIdAt($pos1->x, $y, $pos1->z, $block->getId());
$level->setBlockDataAt($pos1->x, $y, $pos1->z, $block->getDamage());
$level->setBlockIdAt($pos2->x, $y, $pos1->z, $block->getId());
$level->setBlockDataAt($pos2->x, $y, $pos1->z, $block->getDamage());
$level->setBlockIdAt($pos1->x, $y, $pos2->z, $block->getId());
$level->setBlockDataAt($pos1->x, $y, $pos2->z, $block->getDamage());
$level->setBlockIdAt($pos2->x, $y, $pos2->z, $block->getId());
$level->setBlockDataAt($pos2->x, $y, $pos2->z, $block->getDamage());
}
}
/*
* Creates the bottom of a structure
* @param $level pocketmine\level\ChunkManager
* @param $pos1 pocketmine\math\Vector3
* @param $pos2 pocketmine\math\Vector3
* @param $block pocketmine\block\Block
/**
* Fills the bottom of a structure
*
* @param ChunkManager $level
* @param Vector3 $pos1
* @param Vector3 $pos2
* @param Block $block
* @return void
*/
public static function bottom(ChunkManager $level, Vector3 $pos1, Vector3 $pos2, Block $block) {
list($pos1, $pos2) = self::minmax($pos1, $pos2);
for($x = $pos1->x; $x >= $pos2->x; $x --)
for($z = $pos1->z; $z >= $pos2->z; $z --) {
$level->setBlockIdAt($x, $pos2->y, $z, $block->getId ());
$level->setBlockDataAt($x, $pos2->y, $z, $block->getDamage ());
for($x = $pos1->x; $x >= $pos2->x; $x--)
for($z = $pos1->z; $z >= $pos2->z; $z--) {
$level->setBlockIdAt($x, $pos2->y, $z, $block->getId());
$level->setBlockDataAt($x, $pos2->y, $z, $block->getDamage());
}
}
/*
* Builds a random structure depending of length, height, depth and random
* @param $level pocketmine\level\ChunkManager
* @param $pos pocketmine\math\Vector3
* @param $infos pocketmine\math\Vector3
* @param $random pocketmine\utils\Random
* @param $block pocketmine\block\Block
/**
* Builds a structure randomly based on a circle algorithm. Used in caves and lakes.
*
* @param ChunkManager $level
* @param Vector3 $pos
* @param Vector3 $infos
* @param Random $random
* @param Block $block
* @return void
*/
public static function buildRandom(ChunkManager $level, Vector3 $pos, Vector3 $infos, Random $random, Block $block) {
$xBounded = $random->nextBoundedInt(3) - 1;
$yBounded = $random->nextBoundedInt(3) - 1;
$zBounded = $random->nextBoundedInt(3) - 1;
$pos = $pos->round ();
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($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) < ((($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->setBlockDataAt($x, $y, $z, $block->getDamage ());
$pos = $pos->round();
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($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) <((($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->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
/**
* Returns two Vector three, the biggest and lowest ones based on two provided vectors
*
* @param Vector3 $pos1
* @param Vector3 $pos2
* @return array
*/
protected static function minmax(Vector3 $pos1, Vector3 $pos2): 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 [

View file

@ -8,8 +8,11 @@
* \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\
* \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/
* Tomorrow's pocketmine generator.
* @author Ad5001
* @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\utils;