diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md new file mode 100644 index 000000000..8086a2f44 --- /dev/null +++ b/CODE_OF_CONDUCT.md @@ -0,0 +1,128 @@ +# Contributor Covenant Code of Conduct + +## Our Pledge + +We as members, contributors, and leaders pledge to make participation in our +community a harassment-free experience for everyone, regardless of age, body +size, visible or invisible disability, ethnicity, sex characteristics, gender +identity and expression, level of experience, education, socio-economic status, +nationality, personal appearance, race, religion, or sexual identity +and orientation. + +We pledge to act and interact in ways that contribute to an open, welcoming, +diverse, inclusive, and healthy community. + +## Our Standards + +Examples of behavior that contributes to a positive environment for our +community include: + +* Demonstrating empathy and kindness toward other people +* Being respectful of differing opinions, viewpoints, and experiences +* Giving and gracefully accepting constructive feedback +* Accepting responsibility and apologizing to those affected by our mistakes, + and learning from the experience +* Focusing on what is best not just for us as individuals, but for the + overall community + +Examples of unacceptable behavior include: + +* The use of sexualized language or imagery, and sexual attention or + advances of any kind +* Trolling, insulting or derogatory comments, and personal or political attacks +* Public or private harassment +* Publishing others' private information, such as a physical or email + address, without their explicit permission +* Other conduct which could reasonably be considered inappropriate in a + professional setting + +## Enforcement Responsibilities + +Community leaders are responsible for clarifying and enforcing our standards of +acceptable behavior and will take appropriate and fair corrective action in +response to any behavior that they deem inappropriate, threatening, offensive, +or harmful. + +Community leaders have the right and responsibility to remove, edit, or reject +comments, commits, code, wiki edits, issues, and other contributions that are +not aligned to this Code of Conduct, and will communicate reasons for moderation +decisions when appropriate. + +## Scope + +This Code of Conduct applies within all community spaces, and also applies when +an individual is officially representing the community in public spaces. +Examples of representing our community include using an official e-mail address, +posting via an official social media account, or acting as an appointed +representative at an online or offline event. + +## Enforcement + +Instances of abusive, harassing, or otherwise unacceptable behavior may be +reported to the community leaders responsible for enforcement at +eliasfleckenstein@web.de. +All complaints will be reviewed and investigated promptly and fairly. + +All community leaders are obligated to respect the privacy and security of the +reporter of any incident. + +## Enforcement Guidelines + +Community leaders will follow these Community Impact Guidelines in determining +the consequences for any action they deem in violation of this Code of Conduct: + +### 1. Correction + +**Community Impact**: Use of inappropriate language or other behavior deemed +unprofessional or unwelcome in the community. + +**Consequence**: A private, written warning from community leaders, providing +clarity around the nature of the violation and an explanation of why the +behavior was inappropriate. A public apology may be requested. + +### 2. Warning + +**Community Impact**: A violation through a single incident or series +of actions. + +**Consequence**: A warning with consequences for continued behavior. No +interaction with the people involved, including unsolicited interaction with +those enforcing the Code of Conduct, for a specified period of time. This +includes avoiding interactions in community spaces as well as external channels +like social media. Violating these terms may lead to a temporary or +permanent ban. + +### 3. Temporary Ban + +**Community Impact**: A serious violation of community standards, including +sustained inappropriate behavior. + +**Consequence**: A temporary ban from any sort of interaction or public +communication with the community for a specified period of time. No public or +private interaction with the people involved, including unsolicited interaction +with those enforcing the Code of Conduct, is allowed during this period. +Violating these terms may lead to a permanent ban. + +### 4. Permanent Ban + +**Community Impact**: Demonstrating a pattern of violation of community +standards, including sustained inappropriate behavior, harassment of an +individual, or aggression toward or disparagement of classes of individuals. + +**Consequence**: A permanent ban from any sort of public interaction within +the community. + +## Attribution + +This Code of Conduct is adapted from the [Contributor Covenant][homepage], +version 2.0, available at +https://www.contributor-covenant.org/version/2/0/code_of_conduct.html. + +Community Impact Guidelines were inspired by [Mozilla's code of conduct +enforcement ladder](https://github.com/mozilla/diversity). + +[homepage]: https://www.contributor-covenant.org + +For answers to common questions about this code of conduct, see the FAQ at +https://www.contributor-covenant.org/faq. Translations are available at +https://www.contributor-covenant.org/translations. diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 1b5098a4f..a7383df79 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,105 +1,414 @@ -# Contributing to MineClone 2 -So you want to contribute to MineClone 2? +# Contributing to MineClone2 +So you want to contribute to MineClone2? Wow, thank you! :-) -But first, some things to note: +MineClone2 is maintained by Nicu and Fleckenstein. If you have any +problems or questions, contact us (See Links section below). -MineClone 2's development target is to make a free software clone of Minecraft, -***version 1.12***, ***PC edition***, *** + Optifine features supported by the Minetest Engine ***. +You can help with MineClone2's development in many different ways, +whether you're a programmer or not. -MineClone 2 is maintained by three persons. Namely, kay27, EliasFleckenstein and jordan4ibanez. You can find us -in the Minetest forums (forums.minetest.net), in IRC in the #mineclone2 -channel on irc.freenode.net. And finally, you can send e-mails to - or . +## MineClone2's development target is to... +- Crucially, create a stable, moddable, free/libre clone of Minecraft +based on the Minetest engine with polished features, usable in both +singleplayer and multiplayer. Currently, most of **Minecraft Java +Edition 1.12.2** features are already implemented and polishing existing +features are prioritized over new feature requests. +- With lessened priority yet strictly, implement features targetting +**Minecraft version 1.17 + OptiFine** (OptiFine only as far as supported +by the Minetest Engine). This means features in parity with the listed +Minecraft experiences are prioritized over those that don't fulfill this +scope. +- Optionally, create a performant experience that will run relatively +well on really low spec computers. Unfortunately, due to Minecraft's +mechanisms and Minetest engine's limitations along with a very small +playerbase on low spec computers, optimizations are hard to investigate. -By sending us patches or asking us to include your changes in this game, -you agree that they fall under the terms of the LGPLv2.1, which basically -means they will become part of a free software. +## Links +* [Mesehub](https://git.minetest.land/MineClone2/MineClone2) +* [Discord](https://discord.gg/xE4z8EEpDC) +* [YouTube](https://www.youtube.com/channel/UClI_YcsXMF3KNeJtoBfnk9A) +* [IRC](https://web.libera.chat/#mineclone2) +* [Matrix](https://app.element.io/#/room/#mc2:matrix.org) +* [Reddit](https://www.reddit.com/r/MineClone2/) +* [Minetest forums](https://forum.minetest.net/viewtopic.php?f=50&t=16407) +* [ContentDB](https://content.minetest.net/packages/wuzzy/mineclone2/) +* [OpenCollective](https://opencollective.com/mineclone2) -## The suggested workflow -We don't **dictate** your workflow, but in order to work with us in an efficient -way, you can follow these suggestions: +## Using git +MineClone2 is developed using the version control system +[git](https://git-scm.com/). If you want to contribute code to the +project, it is **highly recommended** that you learn the git basics. +For non-programmers and people who do not plan to contribute code to +MineClone2, git is not required. However, git is a tool that will be +referenced frequently because of its usefulness. As such, it is valuable +in learning how git works and its terminology. It can also help you +keeping your game updated, and easily test pull requests. -For small and medium changes: +## How you can help as a non-programmer -* Fork the repository +As someone who does not know how to write programs in Lua or does not +know how to use the Minetest API, you can still help us out a lot. For +example, by opening an issue in the +[Issue tracker](https://git.minetest.land/MineClone2/MineClone2/issues), +you can report a bug or request a feature. + +### Rules about both bugs and feature requests +* Stay polite towards the developers and anyone else involved in the +discussion. +* Choose a descriptive title (e.g. not just "crash", "bug" or "question" +). +* Please write in plain, understandable English. It will be easier to +communicate. +* Please start the issue title with a capital letter. +* Always check the currently opened issues before creating a new one. +Don't report bugs that have already been reported or request features +that already have been requested. +* If you know about Minetest's inner workings, please think about +whether the bug / the feature that you are reporting / requesting is +actually an issue with Minetest itself, and if it is, head to the +[Minetest issue tracker](https://github.com/minetest/minetest/issues) +instead. +* If you need any help regarding creating a Mesehub account or opening +an issue, feel free to ask on the Discord / Matrix server or the IRC +channel. + +### Reporting bugs +* A bug is an unintended behavior or, in the worst case, a crash. +However, it is not a bug if you believe something is missing in the +game. In this case, please read "Requesting features" +* If you report a crash, always include the error message. If you play +in singleplayer, post a screenshot of the message that Minetest showed +when the crash happened (or copy the message into your issue). If you +are a server admin, you can find error messages in the log file of the +server. +* Tell us which MineClone2 and Minetest versions you are using. +* Tell us how to reproduce the problem: What you were doing to trigger +the bug, e.g. before the crash happened or what causes the faulty +behavior. + +### Requesting features +* Ensure the requested feature fulfills our development targets and +goals. +* Begging or excessive attention seeking does not help us in the +slightest, and may very well disrupt MineClone2 development. It's better +to put that energy into helping or researching the feature in question. +After all, we're just volunteers working on our spare time. +* Ensure the requested feature has not been implemented in MineClone2 +latest or development versions. + +### Testing code +If you want to help us with speeding up MineClone2 development and +making the game more stable, a great way to do that is by testing out +new features from contributors. For most new things that get into the +game, a pull request is created. A pull request is essentially a +programmer saying "Look, I modified the game, please apply my changes +to the upstream version of the game". However, every programmer makes +mistakes sometimes, some of which are hard to spot. You can help by +downloading this modified version of the game and trying it out - then +tell us if the code works as expected without any issues. Ideally, you +would report issues will pull requests similar to when you were +reporting bugs that are the mainline (See Reporting bugs section). You +can find currently open pull requests here: +. Note that pull +requests that start with a `WIP:` are not done yet, and therefore might +not work, so it's not very useful to try them out yet. + +### Contributing assets +Due to license problems, MineClone2 unfortunately cannot use +Minecraft's assets, therefore we are always looking for asset +contributions. To contribute assets, it can be useful to learn git +basics and read the section for Programmers of this document, however +this is not required. It's also a good idea to join the Discord server +(or alternatively IRC or Matrix). + +#### Textures +For textures we use the Pixel Perfection texture pack. This is mostly +enough; however in some cases - e.g. for newer Minecraft features, it's +useful to have texture artists around. If you want to make such +contributions, join our Discord server. Demands for textures will be +communicated there. + +#### Sounds +MineClone2 currently does not have a consistent way to handle sounds. +The sounds in the game come from different sources, like the SnowZone +resource pack or minetest_game. Unfortunately, MineClone2 does not play +a sound in every situation you would get one in Minecraft. Any help with +sounds is greatly appreciated, however if you add new sounds you should +probably work together with a programmer, to write the code to actually +play these sounds in game. + +#### 3D Models +Most of the 3D Models in MineClone2 come from +[22i's repository](https://github.com/22i/minecraft-voxel-blender-models). +Similar to the textures, we need people that can make 3D Models with +Blender on demand. Many of the models have to be patched, some new +animations have to be added etc. + +#### Crediting +Asset contributions will be credited in their own respective sections in +CREDITS.md. If you have commited the results yourself, you will also be +credited in the Contributors section. + +### Contributing Translations + +#### Workflow +To add/update support for your language to MineClone2, you should take +the steps documented in the section for Programmers, add/update the +translation files of the mods that you want to update. You can add +support for all mods, just some of them or only one mod; you can update +the translation file entirely or only partly; basically any effort is +valued. If your changes are small, you can also send them to developers +via E-Mail, Discord, IRC or Matrix - they will credit you appropriately. + +#### Things to note +You can use the script at `tools/check_translate_files.py` to compare +the translation files for the language you are working on with the +template files, to see what is missing and what is out of date with +the template file. However, template files are often incomplete and/or +out of date, sometimes they don't match the code. You can update the +translation files if that is required, you can also modify the code in +your translation PR if it's related to translation. You can also work on +multiple languages at the same time in one PR. + +#### Crediting +Translation contributions will be credited in their own in CREDITS.md. +If you have commited the results yourself, you will also be credited in +the Contributors section. + +### Profiling +If you own a server, a great way to help us improve MineClone2's code +is by giving us profiler results. Profiler results give us detailed +information about the game's performance and let us know places to +investigate optimization issues. This way we can make the game faster. + +#### Using Minetest's profiler +Minetest has a built in profiler. Simply set `profiler.load = true` in +your configuration file and restart the server. After running the server +for some time, just run `/profiler save` in chat - then you will find a +file in the world directory containing the results. Open a new issue and +upload the file. You can name the issue " profiler +results". + +### Let us know your opinion +It is always encouraged to actively contribute to issue discussions on +MeseHub, let us know what you think about a topic and help us make +decisions. Also, note that a lot of discussion takes place on the +Discord server, so it's definitely worth checking it out. + +### Funding +You can help pay for our infrastructure (Mesehub) by donating to our +OpenCollective link (See Links section). + +### Crediting +If you opened or have contributed to an issue, you receive the +`Community` role on our Discord (after asking for it). +OpenCollective Funders are credited in their own section in +`CREDITS.md` and receive a special role "Funder" on our discord (unless +they have made their donation Incognito). + +## How you can help as a programmer +(Almost) all the MineClone2 development is done using pull requests. + +### Recommended workflow +* Fork the repository (in case you have not already) * Do your change in a new branch * Create a pull request to get your changes merged into master +* Keep your pull request up to date by regularly merging upstream. It is +imperative that conflicts are resolved prior to merging the pull +request. +* After the pull request got merged, you can delete the branch -For small changes, sending us a patch is also good. +### Discuss first +If you feel like a problem needs to fixed or you want to make a new +feature, you could start writing the code right away and notifying us +when you're done, but it never hurts to discuss things first. If there +is no issue on the topic, open one. If there is an issue, tell us that +you'd like to take care of it, to avoid duplicate work. -For big changes: Same as above, but consider notifying us first to avoid -duplicate work and possible tears of rejection. ;-) +### Don't hesitate to ask for help +We appreciate any contributing effort to MineClone2. If you are a +relatively new programmer, you can reach us on Discord, Matrix or IRC +for questions about git, Lua, Minetest API, MineClone2 codebase or +anything related to MineClone2. We can help you avoid writing code that +would be deemed inadequate, or help you become familiar with MineClone2 +better, or assist you use development tools. -For trusted people, we might give them direct commit access to this -repository. In this case, you obviously don't need to fork, but you still -need to show your contributions align with the project goals. We still -reserve the right to revert everything that we don't like. -For bigger changes, we strongly recommend to use feature branches and -discuss with me first. +### Maintain your own code, even if already got merged +Sometimes, your code may cause crashes or bugs - we try to avoid such +scenarios by testing every time before merging it, but if your merged +work causes problems, we ask you fix the issues as soon as possible. -If your code causes bugs and crashes, it is your responsibility to fix them as soon as possible. +### Changing Gameplay +Pull Requests that change gameplay have to be properly researched and +need to state their sources. These PRs also need Fleckenstein's approval +before they are merged. +You can use these sources: -We mostly use plain merging rather than rebasing or squash merging. +* Minecraft code (Name the source file and line, however DONT post any +proprietary code). You can use +[MCP](https://minecraft.fandom.com/wiki/Programs_and_editors/Mod_Coder_Pack) +to decompile Minecraft or look at +[Minestorm](https://github.com/Minestom/Minestom) code. +* Testing things inside of Minecraft (Attach screenshots / video footage +of the results) +* [Official Minecraft Wiki](https://minecraft.fandom.com/wiki/Minecraft_Wiki) +(Include a link to the specific page you used) -Your commit names should be relatively descriptive, e.g. when saying "Fix #issueid", the commit message should also contain the title of the issue. +### Stick to our guidelines -Contributors will be credited in `CREDITS.md`. +#### Git Guidelines +* We use merge rather than rebase or squash merge +* We don't use git submodules. +* Your commit names should be relatively descriptive, e.g. when saying +"Fix #issueid", the commit message should also contain the title of the +issue. +* Try to keep your commits as atomic as possible (advise, but completely +optional) -## Code Style +#### Code Guidelines +* Each mod must provide `mod.conf`. +* Mod names are snake case, and newly added mods start with `mcl_`, e.g. +`mcl_core`, `mcl_farming`, `mcl_monster_eggs`. Keep in mind Minetest +does not support capital letters in mod names. +* To export functions, store them inside a global table named like the +mod, e.g. -Each mod must provide `mod.conf`. -Each mod which add API functions should store functions inside a global table named like the mod. -Public functions should not use self references but rather just access the table directly. -Functions should be defined in this way: -``` -function mcl_xyz.stuff(param) end -``` -Insteed of this way: -``` -mcl_xyz.stuff = function(param) end -``` -Indentation must be unified, more likely with tabs. +```lua +mcl_example = {} + +function mcl_example.do_something() + -- ... +end -Time sensitive mods should make a local copy of most used API functions to improve performances. -``` -local vector = vector -local get_node = minetest.get_node ``` +* Public functions should not use self references but rather just access +the table directly, e.g. -## Features > 1.12 +```lua +-- bad +function mcl_example:do_something() +end -If you want to make a feature that was added in a Minecraft version later than 1.12, you should fork MineClone5 (mineclone5 branch in the repository) and add your changes to this. +-- good +function mcl_example.do_something() +end +``` -## What we accept +* Use modern Minetest API, e.g. no usage of `minetest.env` +* Tabs should be used for indent, spaces for alignment, e.g. -* Every MC features up to version 1.12 JE. -* Every already finished and working good features from versions above (only when making a MineClone5 PR / Contribution). -* Except features which couldn't be done easily and bugfree because of Minetest engine limitations. Eg. we CAN extend world boundaries by playing with map chunks, just teleporting player onto next layer after 31000 , but it would cost too much (time, code, bugs, performance, stability, etc). -* Some features, approved by the rest of the community, I mean maybe some voting and really missing any negative feedback. +```lua -## What we reject +-- use tabs for indent -* Any features which cause critical bugs, sending them to rework/fix or trying to fix immediately. -* Some small portions of big entirely missing features which just definitely break gamplay balance give nothing useful -* Controversial features, which some people support while others do not should be discussed well, with publishing forum announcements, at least during the week. In case if there are still doubts - send them into the mod. +for i = 1, 10 do + if i % 3 == 0 then + print(i) + end +end -## Reporting bugs -Report all bugs and missing Minecraft features here: +-- use tabs for indent and spaces to align things - +some_table = { + {"a string", 5}, + {"a very much longer string", 10}, +} +``` -## Direct discussion -We have an IRC channel! Join us on #mineclone2 in freenode.net. +* Use double quotes for strings, e.g. `"asdf"` rather than `'asdf'` +* Use snake_case rather than CamelCase, e.g. `my_function` rather than +`MyFunction` +* Don't declare functions as an assignment, e.g. - +```lua +-- bad +local some_local_func = function() + -- ... +end -## Creating releases +my_mod.some_func = function() + -- ... +end + +-- good +local function some_local_func() + -- ... +end + +function my_mod.some_func() + -- ... +end +``` + +### Developer status +Active and trusted contributors are often granted write access to the +MineClone2 repository. + +#### Developer responsibilities +- You should not push things directly to +MineClone2 master - rather, do your work on a branch on your private +repository, then create a pull request. This way other people can review +your changes and make sure they work before they get merged. +- Merge PRs only when they have recieved the necessary feedback and have +been tested by at least two different people (including the author of +the pull request), to avoid crashes or the introduction of new bugs. +- You may also be assigned to issues or pull +requests as a developer. In this case it is your responsibility to fix +the issue / review and merge the pull request when it is ready. You can +also unassign yourself from the issue / PR if you have no time or don't +want to take care of it for some other reason. After all, everyone is a +volunteer and we can't expect you to do work that you are not interested +in. **The important thing is that you make sure to inform us if you +won't take care of something that has been assigned to you.** +- Please assign yourself to something that you want to work on to avoid +duplicate work. +- As a developer, it should be easy to reach you about your work. You +should be in at least one of the public MineClone2 discussion rooms - +preferrably Discord, but if you really don't like Discord, Matrix +or IRC are fine too. + +### Maintainer status +Maintainers carry the main responsibility for the project. + +#### Maintainer responsibilities +- Making sure issues are addressed and pull requests are reviewed and +merged, by assigning either themselves or Developers to issues / PRs +- Making releases +- Making sure guidelines are kept +- Making project decisions based on community feedback +- Granting/revoking developer access +- Enforcing the code of conduct (See CODE_OF_CONDUCT.md) +- Moderating official community spaces (See Links section) +- Resolving conflicts and problems within the community + +#### Current maintainers +* Fleckenstein - responsible for gameplay review, publishing releases, +technical guidelines and issue/PR delegation +* Nicu - responsible for community related issues + +#### Release process +* Run `tools/generate_ingame_credits.lua` to update the ingame credits +from `CREDITS.md` and commit the result (if anything changed) * Launch MineClone2 to make sure it still runs * Update the version number in README.md -* Use `git tag ` to tag the latest commit with the version number -* Push to repo (don't forget `--tags`!) -* Update ContentDB (https://content.minetest.net/packages/Wuzzy/mineclone2/) -* Update first post in forum thread (https://forum.minetest.net/viewtopic.php?f=50&t=16407) +* Use `git tag ` to tag the latest commit with the +version number +* Push to repository (don't forget `--tags`!) +* Update ContentDB +(https://content.minetest.net/packages/Wuzzy/mineclone2/) +* Update first post in forum thread +(https://forum.minetest.net/viewtopic.php?f=50&t=16407) * Post release announcement and changelog in forums + +### Licensing +By asking us to include your changes in this game, you agree that they +fall under the terms of the GPLv3, which basically means they will +become part of a free/libre software. + +### Crediting +Contributors, Developers and Maintainers will be credited in +`CREDITS.md`. If you make your first time contribution, please add +yourself to this file. There are also Discord roles for Contributors, +Developers and Maintainers. diff --git a/CREDITS.md b/CREDITS.md index 296e7c23b..1381b1c37 100644 --- a/CREDITS.md +++ b/CREDITS.md @@ -8,8 +8,8 @@ ## Maintainers * Fleckenstein +* Nicu * kay27 -* jordan4ibanez ## Developers * bzoss @@ -19,10 +19,11 @@ * iliekprogrammar * MysticTempest * Rootyjr -* Nicu * aligator * Code-Sploit * NO11 +* cora +* jordan4ibanez ## Contributors * Laurent Rocher @@ -48,8 +49,25 @@ * dBeans * nickolas360 * yutyo -* ztianyang +* Tianyang Zhang * j45 +* Marcin Serwin +* erlehmann +* E +* Benjamin Schötz +* Doloment +* Sydney Gems +* talamh +* Emily2255 +* Emojigit +* FinishedFragment +* sfan5 +* Blue Blancmange +* Jared Moody +* SmallJoker +* Sven792 +* aldum +* Dieter44 ## MineClone5 * kay27 @@ -74,7 +92,6 @@ * Rochambeau * rubenwardy * stu -* jordan4ibanez * 4aiman * Kahrl * Krock @@ -103,6 +120,7 @@ * xMrVizzy * yutyo * NO11 +* kay27 ## Translations * Wuzzy @@ -110,6 +128,11 @@ * wuniversales * kay27 * pitchum +* todoporlalibertad +* Marcin Serwin + +## Funders +* 40W ## Special thanks * celeron55 for creating Minetest diff --git a/GROUPS.md b/GROUPS.md index 8c0c3563e..8286b29bc 100644 --- a/GROUPS.md +++ b/GROUPS.md @@ -149,7 +149,7 @@ These groups are used mostly for informational purposes * `trapdoor=2`: Open trapdoor * `glass=1`: Glass (full cubes only) * `rail=1`: Rail -* `music_record`: Music Disc (rating is track ID) +* `music_record`: Item is Music Disc * `tnt=1`: Block is TNT * `boat=1`: Boat * `minecart=1`: Minecart diff --git a/README.md b/README.md index aeab8ab1a..8f8f0b1e6 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,4 @@ -# (Currently in feature freeze) - -# MineClone 2 +# MineClone2 An unofficial Minecraft-like game for Minetest. Forked from MineClone by davedevils. Developed by many people. Not developed or endorsed by Mojang AB. @@ -71,36 +69,40 @@ an explanation. This game requires [Minetest](http://minetest.net) to run (version 5.3.0 or later). So you need to install Minetest first. Only stable versions of Minetest are officially supported. -There is no support for running MineClone 2 in development versions of Minetest. +There is no support for running MineClone2 in development versions of Minetest. -To install MineClone 2 (if you haven't already), move this directory into the +To install MineClone2 (if you haven't already), move this directory into the “games” directory of your Minetest data directory. Consult the help of Minetest to learn more. -## Reporting bugs -Please report all bugs and missing Minecraft features here: +## Useful links +The MineClone2 repository is hosted at Mesehub. To contribute or report issues, head there. - +* Mesehub: +* Discord: +* YouTube +* IRC: +* Matrix: +* Reddit: +* Minetest forums: +* ContentDB: +* OpenCollective: -## Chatting with the community -Join our discord server at: - - - -## Project description -The main goal of **MineClone 2** is to be a clone of Minecraft and to be released as free software. - -* **Target of development: Minecraft, PC Edition, version 1.12** (later known as “Java Edition”) -* MineClone2 also includes Optifine features supported by the Minetest -* In general, Minecraft is aimed to be cloned as good as possible -* Cloning the gameplay has highest priority -* MineClone 2 will use different assets, but with a similar style -* Limitations found in Minetest will be documented in the course of development -* Features of later Minecraft versions are collected in the mineclone5 branch - -## Using features from newer versions of Minecraft -For > 1.12 features, checkout MineClone5. It includes features from newer Minecraft versions. -Download it here: https://git.minetest.land/MineClone2/MineClone2/src/branch/mineclone5 +## Target +- Crucially, create a stable, moddable, free/libre clone of Minecraft +based on the Minetest engine with polished features, usable in both +singleplayer and multiplayer. Currently, most of **Minecraft Java +Edition 1.12.2** features are already implemented and polishing existing +features are prioritized over new feature requests. +- With lessened priority yet strictly, implement features targetting +**Minecraft version 1.17 + OptiFine** (OptiFine only as far as supported +by the Minetest Engine). This means features in parity with the listed +Minecraft experiences are prioritized over those that don't fulfill this +scope. +- Optionally, create a performant experience that will run relatively +well on really low spec computers. Unfortunately, due to Minecraft's +mechanisms and Minetest engine's limitations along with a very small +playerbase on low spec computers, optimizations are hard to investigate. ## Completion status This game is currently in **beta** stage. @@ -187,7 +189,7 @@ Technical differences from Minecraft: * Different engine (Minetest) * Different easter eggs -… and finally, MineClone 2 is free software (“free” as in “freedom”)! +… and finally, MineClone2 is free software (“free” as in “freedom”)! ## Other readme files diff --git a/mods/CORE/_mcl_autogroup/init.lua b/mods/CORE/_mcl_autogroup/init.lua index ba8b659c0..e04fb2eac 100644 --- a/mods/CORE/_mcl_autogroup/init.lua +++ b/mods/CORE/_mcl_autogroup/init.lua @@ -207,6 +207,10 @@ end function mcl_autogroup.can_harvest(nodename, toolname) local ndef = minetest.registered_nodes[nodename] + if not ndef then + return false + end + if minetest.get_item_group(nodename, "dig_immediate") >= 2 then return true end diff --git a/mods/CORE/mcl_loot/init.lua b/mods/CORE/mcl_loot/init.lua index 1b2c50807..b90cd4428 100644 --- a/mods/CORE/mcl_loot/init.lua +++ b/mods/CORE/mcl_loot/init.lua @@ -58,26 +58,27 @@ function mcl_loot.get_loot(loot_definitions, pr) end if item then local itemstring = item.itemstring - local itemstack = item.itemstack + if itemstring then + local stack = ItemStack(itemstring) + if item.amount_min and item.amount_max then - itemstring = itemstring .. " " .. pr:next(item.amount_min, item.amount_max) + stack:set_count(pr:next(item.amount_min, item.amount_max)) end + if item.wear_min and item.wear_max then -- Sadly, PseudoRandom only allows very narrow ranges, so we set wear in steps of 10 local wear_min = math.floor(item.wear_min / 10) local wear_max = math.floor(item.wear_max / 10) - local wear = pr:next(wear_min, wear_max) * 10 - if not item.amount_min and not item.amount_max then - itemstring = itemstring .. " 1" - end - - itemstring = itemstring .. " " .. tostring(wear) + stack:set_wear(pr:next(wear_min, wear_max) * 10) end - table.insert(items, itemstring) - elseif itemstack then - table.insert(items, itemstack) + + if item.func then + item.func(stack, pr) + end + + table.insert(items, stack) else minetest.log("error", "[mcl_loot] INTERNAL ERROR! Failed to select random loot item!") end diff --git a/mods/CORE/mcl_particles/textures/mcl_particles_totem1.png b/mods/CORE/mcl_particles/textures/mcl_particles_totem1.png new file mode 100644 index 000000000..15fe082e1 Binary files /dev/null and b/mods/CORE/mcl_particles/textures/mcl_particles_totem1.png differ diff --git a/mods/CORE/mcl_particles/textures/mcl_particles_totem2.png b/mods/CORE/mcl_particles/textures/mcl_particles_totem2.png new file mode 100644 index 000000000..2ab88983d Binary files /dev/null and b/mods/CORE/mcl_particles/textures/mcl_particles_totem2.png differ diff --git a/mods/CORE/mcl_particles/textures/mcl_particles_totem3.png b/mods/CORE/mcl_particles/textures/mcl_particles_totem3.png new file mode 100644 index 000000000..55d6f49d3 Binary files /dev/null and b/mods/CORE/mcl_particles/textures/mcl_particles_totem3.png differ diff --git a/mods/CORE/mcl_particles/textures/mcl_particles_totem4.png b/mods/CORE/mcl_particles/textures/mcl_particles_totem4.png new file mode 100644 index 000000000..d6e6502b7 Binary files /dev/null and b/mods/CORE/mcl_particles/textures/mcl_particles_totem4.png differ diff --git a/mods/CORE/mcl_util/init.lua b/mods/CORE/mcl_util/init.lua index a7504af08..d548f6cac 100644 --- a/mods/CORE/mcl_util/init.lua +++ b/mods/CORE/mcl_util/init.lua @@ -1,5 +1,27 @@ mcl_util = {} +-- Updates all values in t using values from to*. +function table.update(t, ...) + for _, to in ipairs{...} do + for k,v in pairs(to) do + t[k] = v + end + end + return t +end + +-- Updates nil values in t using values from to*. +function table.update_nil(t, ...) + for _, to in ipairs{...} do + for k,v in pairs(to) do + if t[k] == nil then + t[k] = v + end + end + end + return t +end + -- Based on minetest.rotate_and_place --[[ @@ -456,7 +478,9 @@ function mcl_util.calculate_durability(itemstack) end end end - uses = uses or (next(itemstack:get_tool_capabilities().groupcaps) or {}).uses + + local _, groupcap = next(itemstack:get_tool_capabilities().groupcaps) + uses = uses or (groupcap or {}).uses end return uses or 0 @@ -538,3 +562,12 @@ function mcl_util.get_object_name(object) return luaentity.nametag and luaentity.nametag ~= "" and luaentity.nametag or luaentity.description or luaentity.name end end + +function mcl_util.replace_mob(obj, mob) + local rot = obj:get_yaw() + local pos = obj:get_pos() + obj:remove() + obj = minetest.add_entity(pos, mob) + obj:set_yaw(rot) + return obj +end diff --git a/mods/CORE/mcl_worlds/API.md b/mods/CORE/mcl_worlds/API.md index dd96b01b5..69508e924 100644 --- a/mods/CORE/mcl_worlds/API.md +++ b/mods/CORE/mcl_worlds/API.md @@ -12,7 +12,7 @@ Params: * pos: position -## mcl_worlds.y_to_layer(y) +## mcl_worlds.y_to_layer(y) This function is used to calculate the minetest y layer and dimension of the given minecraft layer. Mainly used for ore generation. Takes an Y coordinate as input and returns: @@ -78,4 +78,4 @@ Table containing all function registered with mcl_worlds.register_on_dimension_c Notify this mod of a dimension change of to * player: player, player who changed the dimension -* dimension: string, new dimension ("overworld", "nether", "end", "void") \ No newline at end of file +* dimension: string, new dimension ("overworld", "nether", "end", "void") diff --git a/mods/CORE/tga_encoder/init.lua b/mods/CORE/tga_encoder/init.lua index 96afda5e1..39309c9c9 100644 --- a/mods/CORE/tga_encoder/init.lua +++ b/mods/CORE/tga_encoder/init.lua @@ -38,18 +38,32 @@ function image:encode_header() self.data = self.data .. string.char(0) -- image id .. string.char(0) -- color map type - .. string.char(2) -- image type (uncompressed true-color image = 2) + .. string.char(10) -- image type (RLE RGB = 10) self:encode_colormap_spec() -- color map specification self:encode_image_spec() -- image specification end function image:encode_data() + local current_pixel = '' + local previous_pixel = '' + local count = 1 + local packets = {} + local rle_packet = '' for _, row in ipairs(self.pixels) do for _, pixel in ipairs(row) do - self.data = self.data - .. string.char(pixel[3], pixel[2], pixel[1]) + current_pixel = string.char(pixel[3], pixel[2], pixel[1]) + if current_pixel ~= previous_pixel or count == 128 then + packets[#packets +1] = rle_packet + count = 1 + previous_pixel = current_pixel + else + count = count + 1 + end + rle_packet = string.char(128 + count - 1) .. current_pixel end end + packets[#packets +1] = rle_packet + self.data = self.data .. table.concat(packets) end function image:encode_footer() diff --git a/mods/ENTITIES/drippingwater/init.lua b/mods/ENTITIES/drippingwater/init.lua deleted file mode 100644 index e17bdda40..000000000 --- a/mods/ENTITIES/drippingwater/init.lua +++ /dev/null @@ -1,114 +0,0 @@ ---Dripping Water Mod ---by kddekadenz - -local math = math - --- License of code, textures & sounds: CC0 - ---Drop entities - ---water - -local water_tex = "default_water_source_animated.png^[verticalframe:16:0" -minetest.register_entity("drippingwater:drop_water", { - hp_max = 1, - physical = true, - collide_with_objects = false, - collisionbox = {-0.025,-0.05,-0.025,0.025,-0.01,0.025}, - pointable = false, - visual = "cube", - visual_size = {x=0.05, y=0.1}, - textures = {water_tex, water_tex, water_tex, water_tex, water_tex, water_tex}, - spritediv = {x=1, y=1}, - initial_sprite_basepos = {x=0, y=0}, - static_save = false, - on_activate = function(self, staticdata) - self.object:set_sprite({x=0,y=0}, 1, 1, true) - end, - on_step = function(self, dtime) - local k = math.random(1,222) - local ownpos = self.object:get_pos() - if k==1 then - self.object:set_acceleration({x=0, y=-5, z=0}) - end - if minetest.get_node({x=ownpos.x, y=ownpos.y +0.5, z=ownpos.z}).name == "air" then - self.object:set_acceleration({x=0, y=-5, z=0}) - end - if minetest.get_node({x=ownpos.x, y=ownpos.y -0.5, z=ownpos.z}).name ~= "air" then - self.object:remove() - minetest.sound_play({name="drippingwater_drip"}, {pos = ownpos, gain = 0.5, max_hear_distance = 8}, true) - end - end, -}) - - ---lava - -local lava_tex = "default_lava_source_animated.png^[verticalframe:16:0" -minetest.register_entity("drippingwater:drop_lava", { - hp_max = 1, - physical = true, - collide_with_objects = false, - collisionbox = {-0.025,-0.05,-0.025,0.025,-0.01,0.025}, - glow = math.max(7, minetest.registered_nodes["mcl_core:lava_source"].light_source - 3), - pointable = false, - visual = "cube", - visual_size = {x=0.05, y=0.1}, - textures = {lava_tex, lava_tex, lava_tex, lava_tex, lava_tex, lava_tex}, - spritediv = {x=1, y=1}, - initial_sprite_basepos = {x=0, y=0}, - static_save = false, - on_activate = function(self, staticdata) - self.object:set_sprite({x=0,y=0}, 1, 0, true) - end, - on_step = function(self, dtime) - local k = math.random(1,222) - local ownpos = self.object:get_pos() - if k == 1 then - self.object:set_acceleration({x=0, y=-5, z=0}) - end - if minetest.get_node({x=ownpos.x, y=ownpos.y +0.5, z=ownpos.z}).name == "air" then - self.object:set_acceleration({x=0, y=-5, z=0}) - end - if minetest.get_node({x=ownpos.x, y=ownpos.y -0.5, z=ownpos.z}).name ~= "air" then - self.object:remove() - minetest.sound_play({name="drippingwater_lavadrip"}, {pos = ownpos, gain = 0.5, max_hear_distance = 8}, true) - end - end, -}) - - - ---Create drop - -minetest.register_abm({ - label = "Create water drops", - nodenames = {"group:opaque", "group:leaves"}, - neighbors = {"group:water"}, - interval = 2, - chance = 22, - action = function(pos) - if minetest.get_item_group(minetest.get_node({x=pos.x, y=pos.y+1, z=pos.z}).name, "water") ~= 0 - and minetest.get_node({x=pos.x, y=pos.y-1, z=pos.z}).name == "air" then - local i = math.random(-45,45) / 100 - minetest.add_entity({x=pos.x + i, y=pos.y - 0.501, z=pos.z + i}, "drippingwater:drop_water") - end - end, -}) - ---Create lava drop - -minetest.register_abm({ - label = "Create lava drops", - nodenames = {"group:opaque"}, - neighbors = {"group:lava"}, - interval = 2, - chance = 22, - action = function(pos) - if minetest.get_item_group(minetest.get_node({x=pos.x, y=pos.y+1, z=pos.z}).name, "lava") ~= 0 - and minetest.get_node({x=pos.x, y=pos.y-1, z=pos.z}).name == "air" then - local i = math.random(-45,45) / 100 - minetest.add_entity({x=pos.x + i, y=pos.y - 0.501, z=pos.z + i}, "drippingwater:drop_lava") - end - end, -}) \ No newline at end of file diff --git a/mods/ENTITIES/mcl_boats/init.lua b/mods/ENTITIES/mcl_boats/init.lua index 76ace7a45..beff5fb52 100644 --- a/mods/ENTITIES/mcl_boats/init.lua +++ b/mods/ENTITIES/mcl_boats/init.lua @@ -84,7 +84,7 @@ local function attach_object(self, obj) end end, name) obj:set_look_horizontal(yaw) - mcl_tmp_message.message(obj, S("Sneak to dismount")) + mcl_title.set(obj, "actionbar", {text=S("Sneak to dismount"), color="white", stay=60}) else obj:get_luaentity()._old_visual_size = visual_size end @@ -115,7 +115,7 @@ local boat = { collisionbox = {-0.5, -0.35, -0.5, 0.5, 0.3, 0.5}, visual = "mesh", mesh = "mcl_boats_boat.b3d", - textures = {"mcl_boats_texture_oak_boat.png"}, + textures = {"mcl_boats_texture_oak_boat.png", "mcl_boats_texture_oak_boat.png", "mcl_boats_texture_oak_boat.png", "mcl_boats_texture_oak_boat.png", "mcl_boats_texture_oak_boat.png"}, visual_size = boat_visual_size, hp_max = boat_max_hp, damage_texture_modifier = "^[colorize:white:0", @@ -148,6 +148,11 @@ function boat.on_activate(self, staticdata, dtime_s) self._v = data.v self._last_v = self._v self._itemstring = data.itemstring + + while #data.textures < 5 do + table.insert(data.textures, data.textures[1]) + end + self.object:set_properties({textures = data.textures}) end end @@ -337,7 +342,8 @@ function boat.on_step(self, dtime, moveresult) self.object:get_velocity().y) else p.y = p.y + 1 - if is_water(p) then + local is_obsidian_boat = self.object:get_luaentity()._itemstring == "mcl_boats:boat_obsidian" + if is_water(p) or is_obsidian_boat then -- Inside water: Slowly sink local y = self.object:get_velocity().y y = y - 0.01 @@ -377,13 +383,13 @@ end -- Register one entity for all boat types minetest.register_entity("mcl_boats:boat", boat) -local boat_ids = { "boat", "boat_spruce", "boat_birch", "boat_jungle", "boat_acacia", "boat_dark_oak" } -local names = { S("Oak Boat"), S("Spruce Boat"), S("Birch Boat"), S("Jungle Boat"), S("Acacia Boat"), S("Dark Oak Boat") } +local boat_ids = { "boat", "boat_spruce", "boat_birch", "boat_jungle", "boat_acacia", "boat_dark_oak", "boat_obsidian" } +local names = { S("Oak Boat"), S("Spruce Boat"), S("Birch Boat"), S("Jungle Boat"), S("Acacia Boat"), S("Dark Oak Boat"), S("Obsidian Boat") } local craftstuffs = {} if minetest.get_modpath("mcl_core") then - craftstuffs = { "mcl_core:wood", "mcl_core:sprucewood", "mcl_core:birchwood", "mcl_core:junglewood", "mcl_core:acaciawood", "mcl_core:darkwood" } + craftstuffs = { "mcl_core:wood", "mcl_core:sprucewood", "mcl_core:birchwood", "mcl_core:junglewood", "mcl_core:acaciawood", "mcl_core:darkwood", "mcl_core:obsidian" } end -local images = { "oak", "spruce", "birch", "jungle", "acacia", "dark_oak" } +local images = { "oak", "spruce", "birch", "jungle", "acacia", "dark_oak", "obsidian" } for b=1, #boat_ids do local itemstring = "mcl_boats:"..boat_ids[b] @@ -434,8 +440,9 @@ for b=1, #boat_ids do pos = vector.add(pos, vector.multiply(dir, boat_y_offset_ground)) end local boat = minetest.add_entity(pos, "mcl_boats:boat") + local texture = "mcl_boats_texture_"..images[b].."_boat.png" boat:get_luaentity()._itemstring = itemstring - boat:set_properties({textures = { "mcl_boats_texture_"..images[b].."_boat.png" }}) + boat:set_properties({textures = { texture, texture, texture, texture, texture }}) boat:set_yaw(placer:get_look_horizontal()) if not minetest.is_creative_enabled(placer:get_player_name()) then itemstack:take_item() diff --git a/mods/ENTITIES/mcl_boats/locale/mcl_boats.fr.tr b/mods/ENTITIES/mcl_boats/locale/mcl_boats.fr.tr index 04d6d9da9..785d50146 100644 --- a/mods/ENTITIES/mcl_boats/locale/mcl_boats.fr.tr +++ b/mods/ENTITIES/mcl_boats/locale/mcl_boats.fr.tr @@ -6,6 +6,7 @@ Boats are used to travel on the surface of water.=Les bateaux sont utilisés pou Dark Oak Boat=Bateau en Chêne Noir Jungle Boat=Bateau en Acajou Oak Boat=Bateau en Chêne -Rightclick on a water source to place the boat. Rightclick the boat to enter it. Use [Left] and [Right] to steer, [Forwards] to speed up and [Backwards] to slow down or move backwards. Rightclick the boat again to leave it, punch the boat to make it drop as an item.=Faites un clic droit sur une source d'eau pour placer le bateau. Faites un clic droit sur le bateau pour y entrer. Utilisez [Gauche] et [Droite] pour diriger, [Avant] pour accélérer et [Arrière] pour ralentir ou reculer. Cliquez de nouveau avec le bouton droit sur le bateau pour le quitter, frappez le bateau pour le faire tomber en tant qu'objet. +Rightclick on a water source to place the boat. Rightclick the boat to enter it. Use [Left] and [Right] to steer, [Forwards] to speed up and [Backwards] to slow down or move backwards. Use [Sneak] to leave the boat, punch the boat to make it drop as an item.=Faites un clic droit sur une source d'eau pour placer le bateau. Faites un clic droit sur le bateau pour y entrer. Utilisez [Gauche] et [Droite] pour diriger, [Avant] pour accélérer et [Arrière] pour ralentir ou reculer. Utilisez [Sneak] pour le quitter, frappez le bateau pour le faire tomber en tant qu'objet. Spruce Boat=Bateau en Sapin -Water vehicle=Véhicule aquatique \ No newline at end of file +Water vehicle=Véhicule aquatique +Sneak to dismount= \ No newline at end of file diff --git a/mods/ENTITIES/mcl_boats/mod.conf b/mods/ENTITIES/mcl_boats/mod.conf index a5d6cc8cb..61463b6ec 100644 --- a/mods/ENTITIES/mcl_boats/mod.conf +++ b/mods/ENTITIES/mcl_boats/mod.conf @@ -1,7 +1,7 @@ name = mcl_boats author = PilzAdam description = Adds drivable boats. -depends = mcl_player, flowlib +depends = mcl_player, flowlib, mcl_title optional_depends = mcl_core, doc_identifier diff --git a/mods/ENTITIES/mcl_boats/textures/mcl_boats_obsidian_boat.png b/mods/ENTITIES/mcl_boats/textures/mcl_boats_obsidian_boat.png new file mode 100644 index 000000000..6ae10c0c4 Binary files /dev/null and b/mods/ENTITIES/mcl_boats/textures/mcl_boats_obsidian_boat.png differ diff --git a/mods/ENTITIES/mcl_boats/textures/mcl_boats_texture_obsidian_boat.png b/mods/ENTITIES/mcl_boats/textures/mcl_boats_texture_obsidian_boat.png new file mode 100644 index 000000000..af3c24b30 Binary files /dev/null and b/mods/ENTITIES/mcl_boats/textures/mcl_boats_texture_obsidian_boat.png differ diff --git a/mods/ENTITIES/mcl_burning/api.lua b/mods/ENTITIES/mcl_burning/api.lua index 4cb19cca1..969985205 100644 --- a/mods/ENTITIES/mcl_burning/api.lua +++ b/mods/ENTITIES/mcl_burning/api.lua @@ -67,14 +67,9 @@ function mcl_burning.set_on_fire(obj, burn_time) end if not storage.burn_time or burn_time >= storage.burn_time then - if obj:is_player() and not storage.fire_hud_id then - storage.fire_hud_id = obj:hud_add({ - hud_elem_type = "image", - position = {x = 0.5, y = 0.5}, - scale = {x = -100, y = -100}, - text = "mcl_burning_entity_flame_animated.png^[opacity:180^[verticalframe:" .. mcl_burning.animation_frames .. ":" .. 1, - z_index = 1000, - }) + if obj:is_player() then + mcl_burning.channels[obj]:send_all(tostring(mcl_burning.animation_frames)) + mcl_burning.channels[obj]:send_all("start") end storage.burn_time = burn_time storage.fire_damage_timer = 0 @@ -95,7 +90,6 @@ function mcl_burning.set_on_fire(obj, burn_time) fire_entity:set_properties({visual_size = size}) fire_entity:set_attach(obj, "", offset, {x = 0, y = 0, z = 0}) local fire_luaentity = fire_entity:get_luaentity() - fire_luaentity:update_frame(obj, storage) for _, other in pairs(minetest.get_objects_inside_radius(fire_entity:get_pos(), 0)) do local other_luaentity = other:get_luaentity() @@ -111,9 +105,7 @@ function mcl_burning.extinguish(obj) if mcl_burning.is_burning(obj) then local storage = mcl_burning.get_storage(obj) if obj:is_player() then - if storage.fire_hud_id then - obj:hud_remove(storage.fire_hud_id) - end + mcl_burning.channels[obj]:send_all("stop") mcl_burning.storage[obj] = {} else storage.burn_time = nil @@ -143,4 +135,4 @@ function mcl_burning.tick(obj, dtime, storage) end end end -end \ No newline at end of file +end diff --git a/mods/ENTITIES/mcl_burning/init.lua b/mods/ENTITIES/mcl_burning/init.lua index 34b7ca2d4..a47824537 100644 --- a/mods/ENTITIES/mcl_burning/init.lua +++ b/mods/ENTITIES/mcl_burning/init.lua @@ -7,6 +7,7 @@ local get_item_group = minetest.get_item_group mcl_burning = { storage = {}, + channels = {}, animation_frames = tonumber(minetest.settings:get("fire_animation_frames")) or 8 } @@ -43,23 +44,22 @@ minetest.register_on_respawnplayer(function(player) mcl_burning.extinguish(player) end) -minetest.register_on_joinplayer(function(player) - local storage - - local burn_data = player:get_meta():get_string("mcl_burning:data") - if burn_data == "" then - storage = {} - else - storage = minetest.deserialize(burn_data) +function mcl_burning.init_player(player) + local meta = player:get_meta() + -- NOTE: mcl_burning:data may be "return nil" (which deserialize into nil) for reasons unknown. + if meta:get_string("mcl_burning:data"):find("return nil", 1, true) then + minetest.log("warning", "[mcl_burning] 'mcl_burning:data' player meta field is invalid! Please report this bug") end + mcl_burning.storage[player] = meta:contains("mcl_burning:data") and minetest.deserialize(meta:get_string("mcl_burning:data")) or {} + mcl_burning.channels[player] = minetest.mod_channel_join("mcl_burning:" .. player:get_player_name()) +end - mcl_burning.storage[player] = storage +minetest.register_on_joinplayer(function(player) + mcl_burning.init_player(player) end) minetest.register_on_leaveplayer(function(player) - local storage = mcl_burning.storage[player] - storage.fire_hud_id = nil - player:get_meta():set_string("mcl_burning:data", minetest.serialize(storage)) + player:get_meta():set_string("mcl_burning:data", minetest.serialize(mcl_burning.storage[player])) mcl_burning.storage[player] = nil end) @@ -68,27 +68,28 @@ minetest.register_entity("mcl_burning:fire", { initial_properties = { physical = false, collisionbox = {0, 0, 0, 0, 0, 0}, - visual = "cube", + visual = "upright_sprite", + textures = { + name = "mcl_burning_entity_flame_animated.png", + animation = { + type = "vertical_frames", + aspect_w = 16, + aspect_h = 16, + length = 1.0, + }, + }, + spritediv = {x = 1, y = mcl_burning.animation_frames}, pointable = false, glow = -1, backface_culling = false, }, animation_frame = 0, animation_timer = 0, - on_step = function(self, dtime) - local parent, storage = self:sanity_check() - - if parent then - self.animation_timer = self.animation_timer + dtime - if self.animation_timer >= 0.1 then - self.animation_timer = 0 - self.animation_frame = self.animation_frame + 1 - if self.animation_frame > mcl_burning.animation_frames - 1 then - self.animation_frame = 0 - end - self:update_frame(parent, storage) - end - else + on_activate = function(self) + self.object:set_sprite({x = 0, y = 0}, mcl_burning.animation_frames, 1.0 / mcl_burning.animation_frames) + end, + on_step = function(self) + if not self:sanity_check() then self.object:remove() end end, @@ -96,23 +97,15 @@ minetest.register_entity("mcl_burning:fire", { local parent = self.object:get_attach() if not parent then - return + return false end local storage = mcl_burning.get_storage(parent) if not storage or not storage.burn_time then - return + return false end - return parent, storage - end, - update_frame = function(self, parent, storage) - local frame_overlay = "^[opacity:180^[verticalframe:" .. mcl_burning.animation_frames .. ":" .. self.animation_frame - local fire_texture = "mcl_burning_entity_flame_animated.png" .. frame_overlay - self.object:set_properties({textures = {"blank.png", "blank.png", fire_texture, fire_texture, fire_texture, fire_texture}}) - if parent:is_player() then - parent:hud_change(storage.fire_hud_id, "text", "mcl_burning_hud_flame_animated.png" .. frame_overlay) - end + return true end, }) diff --git a/mods/ENTITIES/mcl_dripping/init.lua b/mods/ENTITIES/mcl_dripping/init.lua new file mode 100644 index 000000000..57ba7ecfe --- /dev/null +++ b/mods/ENTITIES/mcl_dripping/init.lua @@ -0,0 +1,66 @@ +-- Dripping Water Mod +-- by kddekadenz + +local math = math + +-- License of code, textures & sounds: CC0 + +local function register_drop(liquid, glow, sound, nodes) + minetest.register_entity("mcl_dripping:drop_" .. liquid, { + hp_max = 1, + physical = true, + collide_with_objects = false, + collisionbox = {-0.01, 0.01, -0.01, 0.01, 0.01, 0.01}, + glow = glow, + pointable = false, + visual = "sprite", + visual_size = {x = 0.1, y = 0.1}, + textures = {""}, + spritediv = {x = 1, y = 1}, + initial_sprite_basepos = {x = 0, y = 0}, + static_save = false, + _dropped = false, + on_activate = function(self) + self.object:set_properties({ + textures = {"[combine:2x2:" .. -math.random(1, 16) .. "," .. -math.random(1, 16) .. "=default_" .. liquid .. "_source_animated.png"} + }) + end, + on_step = function(self, dtime) + local k = math.random(1, 222) + local ownpos = self.object:get_pos() + if k == 1 then + self.object:set_acceleration(vector.new(0, -5, 0)) + end + if minetest.get_node(vector.offset(ownpos, 0, 0.5, 0)).name == "air" then + self.object:set_acceleration(vector.new(0, -5, 0)) + end + if minetest.get_node(vector.offset(ownpos, 0, -0.1, 0)).name ~= "air" then + local ent = self.object:get_luaentity() + if not ent._dropped then + ent._dropped = true + minetest.sound_play({name = "drippingwater_" .. sound .. "drip"}, {pos = ownpos, gain = 0.5, max_hear_distance = 8}, true) + end + if k < 3 then + self.object:remove() + end + end + end, + }) + minetest.register_abm({ + label = "Create drops", + nodenames = nodes, + neighbors = {"group:" .. liquid}, + interval = 2, + chance = 22, + action = function(pos) + if minetest.get_item_group(minetest.get_node(vector.offset(pos, 0, 1, 0)).name, liquid) ~= 0 + and minetest.get_node(vector.offset(pos, 0, -1, 0)).name == "air" then + local x, z = math.random(-45, 45) / 100, math.random(-45, 45) / 100 + minetest.add_entity(vector.offset(pos, x, -0.520, z), "mcl_dripping:drop_" .. liquid) + end + end, + }) +end + +register_drop("water", 1, "", {"group:opaque", "group:leaves"}) +register_drop("lava", math.max(7, minetest.registered_nodes["mcl_core:lava_source"].light_source - 3), "lava", {"group:opaque"}) \ No newline at end of file diff --git a/mods/ENTITIES/drippingwater/mod.conf b/mods/ENTITIES/mcl_dripping/mod.conf similarity index 82% rename from mods/ENTITIES/drippingwater/mod.conf rename to mods/ENTITIES/mcl_dripping/mod.conf index 1de118f4c..921d5e59f 100644 --- a/mods/ENTITIES/drippingwater/mod.conf +++ b/mods/ENTITIES/mcl_dripping/mod.conf @@ -1,4 +1,4 @@ -name = drippingwater +name = mcl_dripping author = kddekadenz description = Drops are generated rarely under solid nodes depends = mcl_core diff --git a/mods/ENTITIES/drippingwater/readme.txt b/mods/ENTITIES/mcl_dripping/readme.txt similarity index 75% rename from mods/ENTITIES/drippingwater/readme.txt rename to mods/ENTITIES/mcl_dripping/readme.txt index f609163ed..afe35608e 100644 --- a/mods/ENTITIES/drippingwater/readme.txt +++ b/mods/ENTITIES/mcl_dripping/readme.txt @@ -1,12 +1,12 @@ -Dripping Water Mod +Dripping Mod by kddekadenz -modified for MineClone 2 by Wuzzy +modified for MineClone 2 by Wuzzy and NO11 Installing instructions: - 1. Copy the drippingwater mod folder into games/gamemode/mods + 1. Copy the mcl_dripping mod folder into games/gamemode/mods 2. Start game and enjoy :) diff --git a/mods/ENTITIES/drippingwater/sounds/drippingwater_drip.1.ogg b/mods/ENTITIES/mcl_dripping/sounds/drippingwater_drip.1.ogg similarity index 100% rename from mods/ENTITIES/drippingwater/sounds/drippingwater_drip.1.ogg rename to mods/ENTITIES/mcl_dripping/sounds/drippingwater_drip.1.ogg diff --git a/mods/ENTITIES/drippingwater/sounds/drippingwater_drip.2.ogg b/mods/ENTITIES/mcl_dripping/sounds/drippingwater_drip.2.ogg similarity index 100% rename from mods/ENTITIES/drippingwater/sounds/drippingwater_drip.2.ogg rename to mods/ENTITIES/mcl_dripping/sounds/drippingwater_drip.2.ogg diff --git a/mods/ENTITIES/drippingwater/sounds/drippingwater_drip.3.ogg b/mods/ENTITIES/mcl_dripping/sounds/drippingwater_drip.3.ogg similarity index 100% rename from mods/ENTITIES/drippingwater/sounds/drippingwater_drip.3.ogg rename to mods/ENTITIES/mcl_dripping/sounds/drippingwater_drip.3.ogg diff --git a/mods/ENTITIES/drippingwater/sounds/drippingwater_lavadrip.1.ogg b/mods/ENTITIES/mcl_dripping/sounds/drippingwater_lavadrip.1.ogg similarity index 100% rename from mods/ENTITIES/drippingwater/sounds/drippingwater_lavadrip.1.ogg rename to mods/ENTITIES/mcl_dripping/sounds/drippingwater_lavadrip.1.ogg diff --git a/mods/ENTITIES/drippingwater/sounds/drippingwater_lavadrip.2.ogg b/mods/ENTITIES/mcl_dripping/sounds/drippingwater_lavadrip.2.ogg similarity index 100% rename from mods/ENTITIES/drippingwater/sounds/drippingwater_lavadrip.2.ogg rename to mods/ENTITIES/mcl_dripping/sounds/drippingwater_lavadrip.2.ogg diff --git a/mods/ENTITIES/drippingwater/sounds/drippingwater_lavadrip.3.ogg b/mods/ENTITIES/mcl_dripping/sounds/drippingwater_lavadrip.3.ogg similarity index 100% rename from mods/ENTITIES/drippingwater/sounds/drippingwater_lavadrip.3.ogg rename to mods/ENTITIES/mcl_dripping/sounds/drippingwater_lavadrip.3.ogg diff --git a/mods/ENTITIES/mcl_falling_nodes/init.lua b/mods/ENTITIES/mcl_falling_nodes/init.lua index 01681a159..d527603de 100644 --- a/mods/ENTITIES/mcl_falling_nodes/init.lua +++ b/mods/ENTITIES/mcl_falling_nodes/init.lua @@ -19,7 +19,10 @@ local function deal_falling_damage(self, dtime) end self._hit = self._hit or {} for _, obj in ipairs(minetest.get_objects_inside_radius(pos, 1)) do - if mcl_util.get_hp(obj) > 0 and not self._hit[obj] then + local entity = obj:get_luaentity() + if entity and entity.name == "__builtin:item" then + obj:remove() + elseif mcl_util.get_hp(obj) > 0 and not self._hit[obj] then self._hit[obj] = true local way = self._startpos.y - pos.y local damage = (way - 1) * 2 diff --git a/mods/ENTITIES/mcl_item_entity/init.lua b/mods/ENTITIES/mcl_item_entity/init.lua index ab1ac5752..678f8e2b7 100644 --- a/mods/ENTITIES/mcl_item_entity/init.lua +++ b/mods/ENTITIES/mcl_item_entity/init.lua @@ -290,10 +290,10 @@ function minetest.handle_node_drops(pos, drops, digger) end end - if digger and mcl_experience.throw_experience and not silk_touch_drop then + if digger and mcl_experience.throw_xp and not silk_touch_drop then local experience_amount = minetest.get_item_group(dug_node.name,"xp") if experience_amount > 0 then - mcl_experience.throw_experience(pos, experience_amount) + mcl_experience.throw_xp(pos, experience_amount) end end @@ -480,7 +480,7 @@ minetest.register_entity(":__builtin:item", { end, get_staticdata = function(self) - return minetest.serialize({ + local data = minetest.serialize({ itemstring = self.itemstring, always_collect = self.always_collect, age = self.age, @@ -488,6 +488,39 @@ minetest.register_entity(":__builtin:item", { _flowing = self._flowing, _removed = self._removed, }) + -- sfan5 guessed that the biggest serializable item + -- entity would have a size of 65530 bytes. This has + -- been experimentally verified to be still too large. + -- + -- anon5 has calculated that the biggest serializable + -- item entity has a size of exactly 65487 bytes: + -- + -- 1. serializeString16 can handle max. 65535 bytes. + -- 2. The following engine metadata is always saved: + -- • 1 byte (version) + -- • 2 byte (length prefix) + -- • 14 byte “__builtin:item” + -- • 4 byte (length prefix) + -- • 2 byte (health) + -- • 3 × 4 byte = 12 byte (position) + -- • 4 byte (yaw) + -- • 1 byte (version 2) + -- • 2 × 4 byte = 8 byte (pitch and roll) + -- 3. This leaves 65487 bytes for the serialization. + if #data > 65487 then -- would crash the engine + local stack = ItemStack(self.itemstring) + stack:get_meta():from_table(nil) + self.itemstring = stack:to_string() + minetest.log( + "warning", + "Overlong item entity metadata removed: “" .. + self.itemstring .. + "” had serialized length of " .. + #data + ) + return self:get_staticdata() + end + return data end, on_activate = function(self, staticdata, dtime_s) @@ -575,7 +608,7 @@ minetest.register_entity(":__builtin:item", { return true end, - on_step = function(self, dtime) + on_step = function(self, dtime, moveresult) if self._removed then self.object:set_properties({ physical = false @@ -642,6 +675,18 @@ minetest.register_entity(":__builtin:item", { end end + -- Destroy item when it collides with a cactus + if moveresult and moveresult.collides then + for _, collision in pairs(moveresult.collisions) do + local pos = collision.node_pos + if collision.type == "node" and minetest.get_node(pos).name == "mcl_core:cactus" then + self._removed = true + self.object:remove() + return + end + end + end + -- Push item out when stuck inside solid opaque node if def and def.walkable and def.groups and def.groups.opaque == 1 then local shootdir diff --git a/mods/ENTITIES/mcl_minecarts/init.lua b/mods/ENTITIES/mcl_minecarts/init.lua index e33e120a1..119a13523 100644 --- a/mods/ENTITIES/mcl_minecarts/init.lua +++ b/mods/ENTITIES/mcl_minecarts/init.lua @@ -198,7 +198,20 @@ local function register_entity(entity_id, mesh, textures, drop, on_rightclick, o else self._last_float_check = self._last_float_check + dtime end - local pos, rou_pos, node + + local pos, rou_pos, node = self.object:get_pos() + local r = 0.6 + for _, node_pos in pairs({{r, 0}, {0, r}, {-r, 0}, {0, -r}}) do + if minetest.get_node(vector.offset(pos, node_pos[1], 0, node_pos[2])).name == "mcl_core:cactus" then + detach_driver(self) + for d = 1, #drop do + minetest.add_item(pos, drop[d]) + end + self.object:remove() + return + end + end + -- Drop minecart if it isn't on a rail anymore if self._last_float_check >= mcl_minecarts.check_float_time then pos = self.object:get_pos() @@ -646,7 +659,7 @@ register_minecart( if player then mcl_player.player_set_animation(player, "sit" , 30) player:set_eye_offset({x=0, y=-5.5, z=0},{x=0, y=-4, z=0}) - mcl_tmp_message.message(clicker, S("Sneak to dismount")) + mcl_title.set(clicker, "actionbar", {text=S("Sneak to dismount"), color="white", stay=60}) end end, name) end diff --git a/mods/ENTITIES/mcl_minecarts/locale/mcl_minecarts.fr.tr b/mods/ENTITIES/mcl_minecarts/locale/mcl_minecarts.fr.tr index 39cdfd013..67ed5eb1b 100644 --- a/mods/ENTITIES/mcl_minecarts/locale/mcl_minecarts.fr.tr +++ b/mods/ENTITIES/mcl_minecarts/locale/mcl_minecarts.fr.tr @@ -33,3 +33,4 @@ Activates minecarts when powered=Active les wagonnets lorsqu'il est alimenté Emits redstone power when a minecart is detected=Émet de l'énergie redstone lorsqu'un wagonnet est détecté Vehicle for fast travel on rails=Véhicule pour voyager rapidement sur rails Can be ignited by tools or powered activator rail=Peut être allumé par des outils ou un rail d'activation motorisé +Sneak to dismount= \ No newline at end of file diff --git a/mods/ENTITIES/mcl_minecarts/mod.conf b/mods/ENTITIES/mcl_minecarts/mod.conf index 9fff9175d..3b8ae5551 100644 --- a/mods/ENTITIES/mcl_minecarts/mod.conf +++ b/mods/ENTITIES/mcl_minecarts/mod.conf @@ -1,6 +1,6 @@ name = mcl_minecarts author = Krock description = Minecarts are vehicles to move players quickly on rails. -depends = mcl_explosions, mcl_core, mcl_sounds, mcl_player, mcl_achievements, mcl_chests, mcl_furnaces, mesecons_commandblock, mcl_hoppers, mcl_tnt, mesecons +depends = mcl_title, mcl_explosions, mcl_core, mcl_sounds, mcl_player, mcl_achievements, mcl_chests, mcl_furnaces, mesecons_commandblock, mcl_hoppers, mcl_tnt, mesecons optional_depends = doc_identifier, mcl_wip diff --git a/mods/ENTITIES/mcl_mobs/api/api.lua b/mods/ENTITIES/mcl_mobs/api/api.lua index d1840f671..639eb517d 100644 --- a/mods/ENTITIES/mcl_mobs/api/api.lua +++ b/mods/ENTITIES/mcl_mobs/api/api.lua @@ -129,6 +129,7 @@ end local api_path = minetest.get_modpath(minetest.get_current_modname()).."/api/mob_functions/" --ignite all parts of the api +dofile(api_path .. "flow_lib.lua") dofile(api_path .. "ai.lua") dofile(api_path .. "animation.lua") dofile(api_path .. "collision.lua") diff --git a/mods/ENTITIES/mcl_mobs/api/mob_functions/ai.lua b/mods/ENTITIES/mcl_mobs/api/mob_functions/ai.lua index d16d24929..88ce3274b 100644 --- a/mods/ENTITIES/mcl_mobs/api/mob_functions/ai.lua +++ b/mods/ENTITIES/mcl_mobs/api/mob_functions/ai.lua @@ -9,6 +9,8 @@ local minetest_get_item_group = minetest.get_item_group local minetest_get_node = minetest.get_node local minetest_line_of_sight = minetest.line_of_sight local minetest_get_node_light = minetest.get_node_light +local minetest_registered_nodes = minetest.registered_nodes +local flow = mobs.get_flowing_dir local DOUBLE_PI = math.pi * 2 local THIRTY_SECONDTH_PI = DOUBLE_PI * 0.03125 @@ -521,8 +523,8 @@ ______ _ | _| | | | | | | | | | |_| | \_| |_|\__, | - __/ | - |___/ + __/ | + |___/ ]]-- -- state switching logic (stand, walk, run, attacks) @@ -675,12 +677,12 @@ end --[[ ___ |_ | - | |_ _ _ __ ___ _ __ - | | | | | '_ ` _ \| '_ \ + | |_ _ _ __ ___ _ __ + | | | | | '_ ` _ \| '_ \ /\__/ / |_| | | | | | | |_) | \____/ \__,_|_| |_| |_| .__/ - | | - |_| + | | + |_| ]]-- @@ -787,8 +789,8 @@ ___ ___ _ _ _ | |\/| |/ _` | | '_ \ | | / _ \ / _` | |/ __| | | | | (_| | | | | | | |___| (_) | (_| | | (__ \_| |_/\__,_|_|_| |_| \_____/\___/ \__, |_|\___| - __/ | - |___/ + __/ | + |___/ ]]-- --the main loop @@ -1011,6 +1013,19 @@ function mobs.mob_step(self, dtime) end end + --mobs flow from Crafter + local pos = self.object:get_pos() + if pos then + local flow_dir = flow(pos) + if flow_dir then + flow_dir = vector.multiply(flow_dir,10) + local vel = self.object:get_velocity() + local acceleration = vector.new(flow_dir.x-vel.x,flow_dir.y-vel.y,flow_dir.z-vel.z) + acceleration = vector.multiply(acceleration, 0.01) + self.object:add_velocity(acceleration) + end + end + --mob is stunned after being hit if self.pause_timer > 0 then self.pause_timer = self.pause_timer - dtime diff --git a/mods/ENTITIES/mcl_mobs/api/mob_functions/death_logic.lua b/mods/ENTITIES/mcl_mobs/api/mob_functions/death_logic.lua index 45e46d3db..4e6b7ca46 100644 --- a/mods/ENTITIES/mcl_mobs/api/mob_functions/death_logic.lua +++ b/mods/ENTITIES/mcl_mobs/api/mob_functions/death_logic.lua @@ -122,7 +122,10 @@ mobs.death_logic = function(self, dtime) if self.death_animation_timer >= 1.25 then item_drop(self,false,1) mobs.death_effect(self) - mcl_experience.throw_experience(self.object:get_pos(), math_random(self.xp_min, self.xp_max)) + mcl_experience.throw_xp(self.object:get_pos(), math_random(self.xp_min, self.xp_max)) + if self.on_die then + self.on_die(self, self.object:get_pos()) + end self.object:remove() return end @@ -155,4 +158,4 @@ mobs.death_logic = function(self, dtime) if self.pause_timer <= 0 then mobs.set_velocity(self,0) end -end \ No newline at end of file +end diff --git a/mods/ENTITIES/mcl_mobs/api/mob_functions/flow_lib.lua b/mods/ENTITIES/mcl_mobs/api/mob_functions/flow_lib.lua new file mode 100644 index 000000000..aa64bfb4e --- /dev/null +++ b/mods/ENTITIES/mcl_mobs/api/mob_functions/flow_lib.lua @@ -0,0 +1,78 @@ +--this is from https://github.com/HybridDog/builtin_item/blob/e6dfd9dce86503b3cbd1474257eca5f6f6ca71c2/init.lua#L50 +local +minetest,vector,math,pairs,minetest_get_node,vector_subtract,minetest_registered_nodes += +minetest,vector,math,pairs,minetest.get_node,vector.subtract,minetest.registered_nodes + +local tab +local n +local function get_nodes(pos) + tab,n = {},1 + for i = -1,1,2 do + for _,p in pairs({ + {x=pos.x+i, y=pos.y, z=pos.z}, + {x=pos.x, y=pos.y, z=pos.z+i} + }) do + tab[n] = {p, minetest_get_node(p)} + n = n+1 + end + end + return tab +end + + +local data +local param2 +local nd +local par2 +local name +local tmp +local c_node +function mobs.get_flowing_dir(pos) + c_node = minetest_get_node(pos).name + if c_node ~= "mcl_core:water_flowing" and c_node ~= "mcl_core:water" then + return nil + end + data = get_nodes(pos) + param2 = minetest_get_node(pos).param2 + if param2 > 7 then + return nil + end + if c_node == "mcl_core:water" then + for _,i in pairs(data) do + nd = i[2] + name = nd.name + par2 = nd.param2 + if name == "mcl_core:water_flowing" and par2 == 7 then + return(vector_subtract(i[1],pos)) + end + end + end + for _,i in pairs(data) do + nd = i[2] + name = nd.name + par2 = nd.param2 + if name == "mcl_core:water_flowing" and par2 < param2 then + return(vector_subtract(i[1],pos)) + end + end + for _,i in pairs(data) do + nd = i[2] + name = nd.name + par2 = nd.param2 + if name == "mcl_core:water_flowing" and par2 >= 11 then + return(vector_subtract(i[1],pos)) + end + end + for _,i in pairs(data) do + nd = i[2] + name = nd.name + par2 = nd.param2 + tmp = minetest_registered_nodes[name] + if tmp and not tmp.walkable and name ~= "mcl_core:water_flowing" and name ~= "mcl_core:water" then + return(vector_subtract(i[1],pos)) + end + end + + return nil +end diff --git a/mods/ENTITIES/mcl_mobs/api/mob_functions/movement.lua b/mods/ENTITIES/mcl_mobs/api/mob_functions/movement.lua index 893f8eede..d9698a0a7 100644 --- a/mods/ENTITIES/mcl_mobs/api/mob_functions/movement.lua +++ b/mods/ENTITIES/mcl_mobs/api/mob_functions/movement.lua @@ -32,12 +32,15 @@ end mobs.float = function(self) local acceleration = self.object:get_acceleration() - if acceleration and acceleration.y ~= 0 then - self.object:set_acceleration(vector.new(0,0,0)) - else + + if not acceleration then return end + if acceleration.y ~= 0 then + self.object:set_acceleration({x=0, y=0, z=0}) + end + local current_velocity = self.object:get_velocity() local goal_velocity = { @@ -46,7 +49,7 @@ mobs.float = function(self) z = 0, } - local new_velocity_addition = vector.subtract(goal_velocity,current_velocity) + local new_velocity_addition = vector.subtract(goal_velocity, current_velocity) new_velocity_addition.x = 0 new_velocity_addition.z = 0 diff --git a/mods/ENTITIES/mobs_mc/creeper.lua b/mods/ENTITIES/mobs_mc/creeper.lua index 999cc5f2d..a7e33d1bd 100644 --- a/mods/ENTITIES/mobs_mc/creeper.lua +++ b/mods/ENTITIES/mobs_mc/creeper.lua @@ -37,7 +37,7 @@ mobs:register_mob("mobs_mc:creeper", { }, makes_footstep_sound = false, walk_velocity = 1.05, - run_velocity = 3.25, + run_velocity = 2.1, runaway_from = { "mobs_mc:ocelot", "mobs_mc:cat" }, attack_type = "explode", eye_height = 1.25, @@ -47,8 +47,8 @@ mobs:register_mob("mobs_mc:creeper", { --explosion_radius = 3, --explosion_damage_radius = 6, --explosiontimer_reset_radius = 6, - reach = 1.5, - defuse_reach = 4, + reach = 3, + defuse_reach = 5.2, explosion_timer = 0.3, allow_fuse_reset = true, stop_to_explode = true, @@ -95,7 +95,8 @@ mobs:register_mob("mobs_mc:creeper", { if self._forced_explosion_countdown_timer then self._forced_explosion_countdown_timer = self._forced_explosion_countdown_timer - dtime if self._forced_explosion_countdown_timer <= 0 then - mobs:boom(self, mcl_util.get_object_center(self.object), self.explosion_strength) + local mobs_griefing = minetest.settings:get_bool("mobs_griefing") ~= false + mcl_explosions.explode(mcl_util.get_object_center(self.object), self.explosion_strength, { griefing = mobs_griefing, drop_chance = 1.0}, self.object) end end end, @@ -151,6 +152,7 @@ mobs:register_mob("mobs_mc:creeper_charged", { description = S("Charged Creeper"), type = "monster", spawn_class = "hostile", + hostile = true, hp_min = 20, hp_max = 20, xp_min = 5, @@ -186,8 +188,8 @@ mobs:register_mob("mobs_mc:creeper_charged", { --explosion_radius = 3, --explosion_damage_radius = 6, --explosiontimer_reset_radius = 3, - reach = 1.5, - defuse_reach = 4, + reach = 3, + defuse_reach = 5.2, explosion_timer = 0.3, allow_fuse_reset = true, stop_to_explode = true, @@ -219,7 +221,8 @@ mobs:register_mob("mobs_mc:creeper_charged", { if self._forced_explosion_countdown_timer then self._forced_explosion_countdown_timer = self._forced_explosion_countdown_timer - dtime if self._forced_explosion_countdown_timer <= 0 then - mobs:boom(self, mcl_util.get_object_center(self.object), self.explosion_strength) + local mobs_griefing = minetest.settings:get_bool("mobs_griefing") ~= false + mcl_explosions.explode(mcl_util.get_object_center(self.object), self.explosion_strength, { griefing = mobs_griefing, drop_chance = 1.0}, self.object) end end end, diff --git a/mods/ENTITIES/mobs_mc/ender_dragon.lua b/mods/ENTITIES/mobs_mc/ender_dragon.lua index bafb3f84a..3634e20f4 100644 --- a/mods/ENTITIES/mobs_mc/ender_dragon.lua +++ b/mods/ENTITIES/mobs_mc/ender_dragon.lua @@ -103,7 +103,7 @@ mobs:register_mob("mobs_mc:enderdragon", { mcl_portals.spawn_gateway_portal() mcl_structures.call_struct(self._portal_pos, "end_exit_portal_open") if self._initial then - mcl_experience.throw_experience(pos, 11500) -- 500 + 11500 = 12000 + mcl_experience.throw_xp(pos, 11500) -- 500 + 11500 = 12000 minetest.set_node(vector.add(self._portal_pos, vector.new(3, 5, 3)), {name = mobs_mc.items.dragon_egg}) end end diff --git a/mods/ENTITIES/mobs_mc/locale/template.txt b/mods/ENTITIES/mobs_mc/locale/template.txt index 04ba9e465..7b55c1b89 100644 --- a/mods/ENTITIES/mobs_mc/locale/template.txt +++ b/mods/ENTITIES/mobs_mc/locale/template.txt @@ -28,6 +28,7 @@ Pig= Polar Bear= Rabbit= Killer Bunny= +The Killer Bunny= Sheep= Shulker= Silverfish= diff --git a/mods/ENTITIES/mobs_mc/rabbit.lua b/mods/ENTITIES/mobs_mc/rabbit.lua index 8c2675954..51235a3f9 100644 --- a/mods/ENTITIES/mobs_mc/rabbit.lua +++ b/mods/ENTITIES/mobs_mc/rabbit.lua @@ -233,4 +233,4 @@ mobs:spawn(spawn_grass) mobs:register_egg("mobs_mc:rabbit", S("Rabbit"), "mobs_mc_spawn_icon_rabbit.png", 0) -- Note: This spawn egg does not exist in Minecraft -mobs:register_egg("mobs_mc:killer_bunny", S("Killer Bunny"), "mobs_mc_spawn_icon_rabbit.png^[colorize:#FF0000:192", 0) -- TODO: Update inventory image +mobs:register_egg("mobs_mc:killer_bunny", S("Killer Bunny"), "mobs_mc_spawn_icon_rabbit_caerbannog.png", 0) diff --git a/mods/ENTITIES/mobs_mc/slime+magma_cube.lua b/mods/ENTITIES/mobs_mc/slime+magma_cube.lua index 48aacfcce..9236b255e 100644 --- a/mods/ENTITIES/mobs_mc/slime+magma_cube.lua +++ b/mods/ENTITIES/mobs_mc/slime+magma_cube.lua @@ -31,12 +31,14 @@ local spawn_children_on_die = function(child_mob, children_count, spawn_distance speed_penalty = 0.5 end local mob = minetest.add_entity(newpos, child_mob) - if (not mother_stuck) then - mob:set_velocity(vector.multiply(dir, eject_speed * speed_penalty)) + if mob then + if (not mother_stuck) then + mob:set_velocity(vector.multiply(dir, eject_speed * speed_penalty)) + end + mob:set_yaw(angle - math.pi/2) + table.insert(children, mob) + angle = angle + (math.pi*2)/children_count end - mob:set_yaw(angle - math.pi/2) - table.insert(children, mob) - angle = angle + (math.pi*2)/children_count end -- If mother was murdered, children attack the killer after 1 second if self.state == "attack" then diff --git a/mods/ENTITIES/mobs_mc/textures/mobs_mc_spawn_icon_rabbit_caerbannog.png b/mods/ENTITIES/mobs_mc/textures/mobs_mc_spawn_icon_rabbit_caerbannog.png new file mode 100644 index 000000000..4244a83c6 Binary files /dev/null and b/mods/ENTITIES/mobs_mc/textures/mobs_mc_spawn_icon_rabbit_caerbannog.png differ diff --git a/mods/ENTITIES/mobs_mc/villager.lua b/mods/ENTITIES/mobs_mc/villager.lua index 06cec9ed6..ce2e76575 100644 --- a/mods/ENTITIES/mobs_mc/villager.lua +++ b/mods/ENTITIES/mobs_mc/villager.lua @@ -409,7 +409,7 @@ local init_trades = function(self, inv) local offered_stack = ItemStack({name = offered_item, count = offered_count}) if mcl_enchanting.is_enchanted(offered_item) then if mcl_enchanting.is_book(offered_item) then - offered_stack = mcl_enchanting.get_uniform_randomly_enchanted_book({"soul_speed"}) + mcl_enchanting.enchant_uniform_randomly(offered_stack, {"soul_speed"}) else mcl_enchanting.enchant_randomly(offered_stack, math.random(5, 19), false, false, true) mcl_enchanting.unload_enchantments(offered_stack) diff --git a/mods/ENVIRONMENT/lightning/API.md b/mods/ENVIRONMENT/lightning/API.md new file mode 100644 index 000000000..ad4f0a3b4 --- /dev/null +++ b/mods/ENVIRONMENT/lightning/API.md @@ -0,0 +1,31 @@ +# lightning +Lightning mod for MineClone2 with the following API: + +## lightning.register_on_strike(function(pos, pos2, objects)) +Custom function called when a lightning strikes. + +* `pos`: impact position +* `pos2`: rounded node position where fire is placed +* `objects`: table with ObjectRefs of all objects within a radius of 3.5 around pos2 + +## lightning.strike(pos) +Let a lightning strike. + +* `pos`: optional, if not given a random pos will be chosen +* `returns`: bool - success if a strike happened + + +### Examples: + +``` +lightning.register_on_strike(function(pos, pos2, objects) + for _, obj in pairs(objects) do + obj:remove() + end + minetest.add_entity(pos, "mobs_mc:sheep") +end) + +minetest.register_on_respawnplayer(function(player) + lightning.strike(player:get_pos()) +end) +``` \ No newline at end of file diff --git a/mods/ENVIRONMENT/lightning/init.lua b/mods/ENVIRONMENT/lightning/init.lua index 3d5955d6e..3579316e8 100644 --- a/mods/ENVIRONMENT/lightning/init.lua +++ b/mods/ENVIRONMENT/lightning/init.lua @@ -24,13 +24,14 @@ local get_objects_inside_radius = minetest.get_objects_inside_radius local get_item_group = minetest.get_item_group lightning = { - interval_low = 17, - interval_high = 503, - range_h = 100, - range_v = 50, - size = 100, - -- disable this to stop lightning mod from striking - auto = true, + interval_low = 17, + interval_high = 503, + range_h = 100, + range_v = 50, + size = 100, + -- disable this to stop lightning mod from striking + auto = true, + on_strike_functions = {}, } local rng = PcgRandom(32321123312123) @@ -54,6 +55,18 @@ end minetest.register_globalstep(revertsky) +-- lightning strike API + +-- See API.md +--[[ + lightning.register_on_strike(function(pos, pos2, objects) + -- code + end) +]] +function lightning.register_on_strike(func) + table.insert(lightning.on_strike_functions, func) +end + -- select a random strike point, midpoint local function choose_pos(pos) if not pos then @@ -79,14 +92,14 @@ local function choose_pos(pos) pos.z = math.floor(pos.z - (lightning.range_h / 2) + rng:next(1, lightning.range_h)) end - local b, pos2 = line_of_sight(pos, {x = pos.x, y = pos.y - lightning.range_v, z = pos.z}, 1) + local b, pos2 = line_of_sight(pos, { x = pos.x, y = pos.y - lightning.range_v, z = pos.z }, 1) -- nothing but air found if b then return nil, nil end - local n = get_node({x = pos2.x, y = pos2.y - 1/2, z = pos2.z}) + local n = get_node({ x = pos2.x, y = pos2.y - 1/2, z = pos2.z }) if n.name == "air" or n.name == "ignore" then return nil, nil end @@ -94,7 +107,6 @@ local function choose_pos(pos) return pos, pos2 end --- lightning strike API -- * pos: optional, if not given a random pos will be chosen -- * returns: bool - success if a strike happened function lightning.strike(pos) @@ -108,21 +120,28 @@ function lightning.strike(pos) if not pos then return false end + local objects = get_objects_inside_radius(pos2, 3.5) + if lightning.on_strike_functions then + for _, func in pairs(lightning.on_strike_functions) do + func(pos, pos2, objects) + end + end +end +lightning.register_on_strike(function(pos, pos2, objects) + local particle_pos = vector.offset(pos2, 0, (lightning.size / 2) + 0.5, 0) + local particle_size = lightning.size * 10 + local time = 0.2 add_particlespawner({ amount = 1, - time = 0.2, + time = time, -- make it hit the top of a block exactly with the bottom - minpos = {x = pos2.x, y = pos2.y + (lightning.size / 2) + 1/2, z = pos2.z }, - maxpos = {x = pos2.x, y = pos2.y + (lightning.size / 2) + 1/2, z = pos2.z }, - minvel = {x = 0, y = 0, z = 0}, - maxvel = {x = 0, y = 0, z = 0}, - minacc = {x = 0, y = 0, z = 0}, - maxacc = {x = 0, y = 0, z = 0}, - minexptime = 0.2, - maxexptime = 0.2, - minsize = lightning.size * 10, - maxsize = lightning.size * 10, + minpos = particle_pos, + maxpos = particle_pos, + minexptime = time, + maxexptime = time, + minsize = particle_size, + maxsize = particle_size, collisiondetection = true, vertical = true, -- to make it appear hitting the node that will get set on fire, make sure @@ -135,44 +154,27 @@ function lightning.strike(pos) sound_play({ name = "lightning_thunder", gain = 10 }, { pos = pos, max_hear_distance = 500 }, true) -- damage nearby objects, transform mobs - -- TODO: use an API insteed of hardcoding this behaviour - local objs = get_objects_inside_radius(pos2, 3.5) - for o=1, #objs do - local obj = objs[o] + for _, obj in pairs(objects) do local lua = obj:get_luaentity() - -- pig → zombie pigman (no damage) + if lua and lua._on_strike then + lua._on_strike(lua, pos, pos2, objects) + end + -- remove this when mob API is done if lua and lua.name == "mobs_mc:pig" then - local rot = obj:get_yaw() - obj:remove() - obj = add_entity(pos2, "mobs_mc:pigman") - obj:set_yaw(rot) - -- mooshroom: toggle color red/brown (no damage) + mcl_util.replace_mob(obj, "mobs_mc:pigman") elseif lua and lua.name == "mobs_mc:mooshroom" then if lua.base_texture[1] == "mobs_mc_mooshroom.png" then lua.base_texture = { "mobs_mc_mooshroom_brown.png", "mobs_mc_mushroom_brown.png" } else lua.base_texture = { "mobs_mc_mooshroom.png", "mobs_mc_mushroom_red.png" } end - obj:set_properties({textures = lua.base_texture}) - -- villager → witch (no damage) - --elseif lua and lua.name == "mobs_mc:villager" then - -- Witches are incomplete, this code is unused - -- TODO: Enable this code when witches are working. - --[[ - local rot = obj:get_yaw() - obj:remove() - obj = minetest.add_entity(pos2, "mobs_mc:witch") - obj:set_yaw(rot) - ]] - -- charged creeper + obj:set_properties({ textures = lua.base_texture }) + elseif lua and lua.name == "mobs_mc:villager" then + mcl_util.replace_mob(obj, "mobs_mc:witch") elseif lua and lua.name == "mobs_mc:creeper" then - local rot = obj:get_yaw() - obj:remove() - obj = add_entity(pos2, "mobs_mc:creeper_charged") - obj:set_yaw(rot) - -- Other objects: Just damage + mcl_util.replace_mob(obj, "mobs_mc:creeper_charged") else - mcl_util.deal_damage(obj, 5, {type = "lightning_bolt"}) + mcl_util.deal_damage(obj, 5, { type = "lightning_bolt" }) end end @@ -186,7 +188,7 @@ function lightning.strike(pos) local name = player:get_player_name() if ps[name] == nil then ps[name] = {p = player, sky = sky} - mcl_weather.skycolor.add_layer("lightning", {{r=255,g=255,b=255}}, true) + mcl_weather.skycolor.add_layer("lightning", { { r = 255, g = 255, b = 255 } }, true) mcl_weather.skycolor.active = true end end @@ -201,7 +203,7 @@ function lightning.strike(pos) if rng:next(1,100) <= 3 then skeleton_lightning = true end - if get_item_group(get_node({x = pos2.x, y = pos2.y - 1, z = pos2.z}).name, "liquid") < 1 then + if get_item_group(get_node({ x = pos2.x, y = pos2.y - 1, z = pos2.z }).name, "liquid") < 1 then if get_node(pos2).name == "air" then -- Low chance for a lightning to spawn skeleton horse + skeletons if skeleton_lightning then @@ -210,21 +212,22 @@ function lightning.strike(pos) local angle, posadd angle = math.random(0, math.pi*2) for i=1,3 do - posadd = {x=math.cos(angle),y=0,z=math.sin(angle)} + posadd = { x=math.cos(angle),y=0,z=math.sin(angle) } posadd = vector.normalize(posadd) local mob = add_entity(vector.add(pos2, posadd), "mobs_mc:skeleton") - mob:set_yaw(angle-math.pi/2) + if mob then + mob:set_yaw(angle-math.pi/2) + end angle = angle + (math.pi*2) / 3 end -- Cause a fire else - set_node(pos2, {name = "mcl_fire:fire"}) + set_node(pos2, { name = "mcl_fire:fire" }) end end end - -end +end) -- if other mods disable auto lightning during initialization, don't trigger the first lightning. after(5, function(dtime) diff --git a/mods/HELP/doc/doc_items/locale/doc_items.fr.tr b/mods/HELP/doc/doc_items/locale/doc_items.fr.tr index 5d655404d..824ceeeba 100644 --- a/mods/HELP/doc/doc_items/locale/doc_items.fr.tr +++ b/mods/HELP/doc/doc_items/locale/doc_items.fr.tr @@ -2,7 +2,7 @@ Using it as fuel turns it into: @1.=L'utiliser comme combustible le transforme en : @1. @1 seconds=@1 secondes # Item count times item name -%@1×@2=%@1×@ +@1×@2=@1×@ # Itemname (25%) @1 (@2%)=@1 (@2%) # Itemname (<0.5%) diff --git a/mods/HELP/mcl_craftguide/init.lua b/mods/HELP/mcl_craftguide/init.lua index 378b420ff..3bc7b705a 100644 --- a/mods/HELP/mcl_craftguide/init.lua +++ b/mods/HELP/mcl_craftguide/init.lua @@ -155,7 +155,7 @@ end local custom_crafts, craft_types = {}, {} function mcl_craftguide.register_craft_type(name, def) - local func = "mcl_craftguide.register_craft_guide(): " + local func = "mcl_craftguide.register_craft_type(): " assert(name, func .. "'name' field missing") assert(def.description, func .. "'description' field missing") assert(def.icon, func .. "'icon' field missing") diff --git a/mods/HELP/mcl_item_id/API.md b/mods/HELP/mcl_item_id/API.md new file mode 100644 index 000000000..a2f244e0c --- /dev/null +++ b/mods/HELP/mcl_item_id/API.md @@ -0,0 +1,24 @@ +# mcl_item_id +Show the item ID of an item in the description. +With this API, you can register a different name space than "mineclone" for your mod. + +## mcl_item_id.set_mod_namespace(modname, namespace) +Set a name space for all items in a mod. + +* param1: the modname +* param2: (optional) string of the desired name space, if nil, it is the name of the mod + +## mcl_item_id.get_mod_namespace(modname) +Get the name space of a mod registered with mcl_item_id.set_mod_namespace(modname, namespace). + +* param1: the modname + +### Examples: + +The name of the mod is "mod" which registered an item called "mod:itemname". + +* mcl_item_id.set_mod_namespace("mod", "mymod") will show "mymod:itemname" in the description of "mod:itemname" +* mcl_item_id.set_mod_namespace(minetest.get_current_modname()) will show "mod:itemname" in the description of "mod:itemname" +* mcl_item_id.get_mod_namespace(minetest.get_current_modname()) will return "mod" + +(If no namespace is set by a mod, mcl_item_id.get_mod_namespace(minetest.get_current_modname()) will return "mineclone") diff --git a/mods/HELP/mcl_item_id/init.lua b/mods/HELP/mcl_item_id/init.lua new file mode 100644 index 000000000..f3e6d2735 --- /dev/null +++ b/mods/HELP/mcl_item_id/init.lua @@ -0,0 +1,62 @@ +mcl_item_id = { + mod_namespaces = {}, +} + +local game = "mineclone" + +function mcl_item_id.set_mod_namespace(modname, namespace) + local namespace = namespace or modname + mcl_item_id.mod_namespaces[modname] = namespace +end + +function mcl_item_id.get_mod_namespace(modname) + local namespace = mcl_item_id.mod_namespaces[modname] + if namespace then + return namespace + else + return game + end +end + +local same_id = { + enchanting = { "table" }, + experience = { "bottle" }, + heads = { "skeleton", "zombie", "creeper", "wither_skeleton" }, + mobitems = { "rabbit", "chicken" }, + walls = { + "andesite", "brick", "cobble", "diorite", "endbricks", + "granite", "mossycobble", "netherbrick", "prismarine", + "rednetherbrick", "redsandstone", "sandstone", + "stonebrick", "stonebrickmossy", + }, + wool = { + "black", "blue", "brown", "cyan", "green", + "grey", "light_blue", "lime", "magenta", "orange", + "pink", "purple", "red", "silver", "white", "yellow", + }, +} + +tt.register_snippet(function(itemstring) + local def = minetest.registered_items[itemstring] + local item_split = itemstring:find(":") + local id_string = itemstring:sub(item_split) + local id_modname = itemstring:sub(1, item_split - 1) + local new_id = game .. id_string + local mod_namespace = mcl_item_id.get_mod_namespace(id_modname) + for mod, ids in pairs(same_id) do + for _, id in pairs(ids) do + if itemstring == "mcl_" .. mod .. ":" .. id then + new_id = game .. ":" .. id .. "_" .. mod:gsub("s", "") + end + end + end + if mod_namespace ~= game then + new_id = mod_namespace .. id_string + end + if mod_namespace ~= id_modname then + minetest.register_alias_force(new_id, itemstring) + end + if minetest.settings:get_bool("mcl_item_id_debug", false) then + return new_id, "#555555" + end +end) \ No newline at end of file diff --git a/mods/HELP/mcl_item_id/mod.conf b/mods/HELP/mcl_item_id/mod.conf new file mode 100644 index 000000000..c45e17fd3 --- /dev/null +++ b/mods/HELP/mcl_item_id/mod.conf @@ -0,0 +1,3 @@ +name = mcl_item_id +author = NO11 +depends = tt \ No newline at end of file diff --git a/mods/HELP/mcl_tt/locale/mcl_tt.de.tr b/mods/HELP/mcl_tt/locale/mcl_tt.de.tr index 8f878afc7..54c376c3b 100644 --- a/mods/HELP/mcl_tt/locale/mcl_tt.de.tr +++ b/mods/HELP/mcl_tt/locale/mcl_tt.de.tr @@ -45,3 +45,4 @@ Mining durability: @1=Grabehaltbarkeit: @1 Block breaking strength: @1=Blockbruchstärke: @1 @1 uses=@1 Verwendungen Unlimited uses=Unbegrenzte Verwendungen +Durability: @1=Haltbarkeit: @1 diff --git a/mods/HELP/mcl_tt/locale/template.txt b/mods/HELP/mcl_tt/locale/template.txt index 1259216c7..6fb735b13 100644 --- a/mods/HELP/mcl_tt/locale/template.txt +++ b/mods/HELP/mcl_tt/locale/template.txt @@ -45,3 +45,4 @@ Mining durability: @1= Block breaking strength: @1= @1 uses= Unlimited uses= +Durability: @1= diff --git a/mods/HELP/mcl_tt/snippets_mcl.lua b/mods/HELP/mcl_tt/snippets_mcl.lua index 3c79f52e8..825776f5f 100644 --- a/mods/HELP/mcl_tt/snippets_mcl.lua +++ b/mods/HELP/mcl_tt/snippets_mcl.lua @@ -107,3 +107,8 @@ tt.register_snippet(function(itemstring) end end) +tt.register_snippet(function(itemstring, _, itemstack) + if itemstring:sub(1, 23) == "mcl_fishing:fishing_rod" or itemstring:sub(1, 12) == "mcl_bows:bow" then + return S("Durability: @1", S("@1 uses", mcl_util.calculate_durability(itemstack or ItemStack(itemstring)))) + end +end) diff --git a/mods/HUD/hudbars/init.lua b/mods/HUD/hudbars/init.lua index 08f1914ca..505ff403b 100644 --- a/mods/HUD/hudbars/init.lua +++ b/mods/HUD/hudbars/init.lua @@ -425,6 +425,7 @@ function hb.hide_hudbar(player, identifier) local name = player:get_player_name() local hudtable = hb.get_hudtable(identifier) if hudtable == nil then return false end + if hudtable.hudstate[name].hidden == true then return true end if hb.settings.bar_type == "progress_bar" then if hudtable.hudids[name].icon then player:hud_change(hudtable.hudids[name].icon, "scale", {x=0,y=0}) @@ -443,6 +444,7 @@ function hb.unhide_hudbar(player, identifier) local name = player:get_player_name() local hudtable = hb.get_hudtable(identifier) if hudtable == nil then return false end + if hudtable.hudstate[name].hidden == false then return true end local value = hudtable.hudstate[name].value local max = hudtable.hudstate[name].max if hb.settings.bar_type == "progress_bar" then diff --git a/mods/HUD/mcl_credits/init.lua b/mods/HUD/mcl_credits/init.lua index 294373875..db3ac8436 100644 --- a/mods/HUD/mcl_credits/init.lua +++ b/mods/HUD/mcl_credits/init.lua @@ -1,122 +1,10 @@ +local modname = minetest.get_current_modname() +local S = minetest.get_translator(modname) + mcl_credits = { players = {}, -} - -mcl_credits.description = "A faithful Open Source clone of Minecraft" - --- Sub-lists are sorted by number of commits, but the list should not be rearranged (-> new contributors are just added at the end of the list) -mcl_credits.people = { - {"Creator of MineClone", 0x0A9400, { - "davedevils", - }}, - {"Creator of MineClone2", 0xFBF837, { - "Wuzzy", - }}, - {"Maintainers", 0xFF51D5, { - "Fleckenstein", - "kay27", - "oilboi", - }}, - {"Developers", 0xF84355, { - "bzoss", - "AFCMS", - "epCode", - "ryvnf", - "iliekprogrammar", - "MysticTempest", - "Rootyjr", - "Nicu", - "aligator", - "Code-Sploit", - "NO11", - }}, - {"Contributors", 0x52FF00, { - "Laurent Rocher", - "HimbeerserverDE", - "TechDudie", - "Alexander Minges", - "ArTee3", - "ZeDique la Ruleta", - "pitchum", - "wuniversales", - "Bu-Gee", - "David McMackins II", - "Nicholas Niro", - "Wouters Dorian", - "Blue Blancmange", - "Jared Moody", - "Li0n", - "Midgard", - "Saku Laesvuori", - "Yukitty", - "ZedekThePD", - "aldum", - "dBeans", - "nickolas360", - "yutyo", - "ztianyang", - "j45", - }}, - {"MineClone5", 0xA60014, { - "kay27", - "Debiankaios", - "epCode", - "NO11", - "j45", - }}, - {"Original Mod Authors", 0x343434, { - "Wuzzy", - "Fleckenstein", - "BlockMen", - "TenPlus1", - "PilzAdam", - "ryvnf", - "stujones11", - "Arcelmi", - "celeron55", - "maikerumine", - "GunshipPenguin", - "Qwertymine3", - "Rochambeau", - "rubenwardy", - "stu", - "oilboi", - "4aiman", - "Kahrl", - "Krock", - "UgnilJoZ", - "lordfingle", - "22i", - "bzoss", - "kilbith", - "xeranas", - "kddekadenz", - "sofar", - "4Evergreen4", - "jordan4ibanez", - "paramat", - }}, - {"3D Models", 0x0019FF, { - "22i", - "tobyplowy", - "epCode", - }}, - {"Textures", 0xFF9705, { - "XSSheep", - "Wuzzy", - "kingoscargames", - "leorockway", - "xMrVizzy", - "yutyo", - "NO11", - }}, - {"Translations", 0x00FF60, { - "Wuzzy", - "Rocher Laurent", - "wuniversales", - "kay27", - "pitchum", - }}, + description = S("A faithful Open Source clone of Minecraft"), + people = dofile(minetest.get_modpath(modname) .. "/people.lua"), } local function add_hud_element(def, huds, y) @@ -142,7 +30,7 @@ function mcl_credits.show(player) ids = { player:hud_add({ hud_elem_type = "image", - text = "menu_bg.png", + text = "credits_bg.png", position = {x = 0, y = 0}, alignment = {x = 1, y = 1}, scale = {x = -100, y = -100}, @@ -150,13 +38,22 @@ function mcl_credits.show(player) }), player:hud_add({ hud_elem_type = "text", - text = "Sneak to skip", + text = S("Sneak to skip"), position = {x = 1, y = 1}, alignment = {x = -1, y = -1}, offset = {x = -5, y = -5}, z_index = 1001, number = 0xFFFFFF, - }) + }), + player:hud_add({ + hud_elem_type = "text", + text = " "..S("Jump to speed up (additionally sprint)"), + position = {x = 0, y = 1}, + alignment = {x = 1, y = -1}, + offset = {x = -5, y = -5}, + z_index = 1002, + number = 0xFFFFFF, + }), }, } add_hud_element({ @@ -216,13 +113,22 @@ end) minetest.register_globalstep(function(dtime) for _, huds in pairs(mcl_credits.players) do local player = huds.player - if not huds.new and player:get_player_control().sneak then + local control = player:get_player_control() + if not huds.new and control.sneak then mcl_credits.hide(player) else local moving = {} local any for id, y in pairs(huds.moving) do y = y - 1 + + if control.jump then + y = y - 2 + if control.aux1 then + y = y - 5 + end + end + if y > -100 then if id == huds.icon then y = math.max(400, y) diff --git a/mods/HUD/mcl_credits/locale/mcl_credits.de.tr b/mods/HUD/mcl_credits/locale/mcl_credits.de.tr new file mode 100644 index 000000000..fa26f5bc4 --- /dev/null +++ b/mods/HUD/mcl_credits/locale/mcl_credits.de.tr @@ -0,0 +1,14 @@ +# textdomain: mcl_credits +3D Models=3D Modelle +A faithful Open Source clone of Minecraft=Ein treuer Open-Source-Klon von Minecraft +Contributors=Mitwirkende +Creator of MineClone=Schöpfer von MineClone +Creator of MineClone2=Schöpfer von MineClone2 +Developers=Entwickler +Jump to speed up (additionally sprint)=Springen, um zu beschleunigen (zusätzlich sprinten) +Maintainers=Betreuer +MineClone5=MineClone5 +Original Mod Authors=Original-Mod-Autoren +Sneak to skip=Schleichen zum Überspringen +Textures=Texturen +Translations=Übersetzungen diff --git a/mods/HUD/mcl_credits/locale/mcl_credits.es.tr b/mods/HUD/mcl_credits/locale/mcl_credits.es.tr new file mode 100644 index 000000000..a8886286e --- /dev/null +++ b/mods/HUD/mcl_credits/locale/mcl_credits.es.tr @@ -0,0 +1,14 @@ +# textdomain: mcl_credits +3D Models= +A faithful Open Source clone of Minecraft= +Contributors= +Creator of MineClone= +Creator of MineClone2= +Developers= +Jump to speed up (additionally sprint)= +Maintainers= +MineClone5= +Original Mod Authors= +Sneak to skip= +Textures= +Translations= \ No newline at end of file diff --git a/mods/HUD/mcl_credits/locale/mcl_credits.fr.tr b/mods/HUD/mcl_credits/locale/mcl_credits.fr.tr new file mode 100644 index 000000000..b34249eff --- /dev/null +++ b/mods/HUD/mcl_credits/locale/mcl_credits.fr.tr @@ -0,0 +1,14 @@ +# textdomain: mcl_credits +3D Models=Modèles 3D +A faithful Open Source clone of Minecraft=Un clone open source de Minecraft +Contributors=Contributeurs +Creator of MineClone=Créateur de MineClone +Creator of MineClone2=Créateur de MineClone2 +Developers=Développeurs +Jump to speed up (additionally sprint)=Saut pour accélérer (peut être combiné avec sprint) +Maintainers=Mainteneurs +MineClone5=MineClone5 +Original Mod Authors=Auteurs des mods originaux +Sneak to skip=Shift pour passer +Textures=Textures +Translations=Traductions \ No newline at end of file diff --git a/mods/HUD/mcl_credits/locale/mcl_credits.pl.tr b/mods/HUD/mcl_credits/locale/mcl_credits.pl.tr new file mode 100644 index 000000000..a8886286e --- /dev/null +++ b/mods/HUD/mcl_credits/locale/mcl_credits.pl.tr @@ -0,0 +1,14 @@ +# textdomain: mcl_credits +3D Models= +A faithful Open Source clone of Minecraft= +Contributors= +Creator of MineClone= +Creator of MineClone2= +Developers= +Jump to speed up (additionally sprint)= +Maintainers= +MineClone5= +Original Mod Authors= +Sneak to skip= +Textures= +Translations= \ No newline at end of file diff --git a/mods/HUD/mcl_credits/locale/mcl_credits.ru.tr b/mods/HUD/mcl_credits/locale/mcl_credits.ru.tr new file mode 100644 index 000000000..a8886286e --- /dev/null +++ b/mods/HUD/mcl_credits/locale/mcl_credits.ru.tr @@ -0,0 +1,14 @@ +# textdomain: mcl_credits +3D Models= +A faithful Open Source clone of Minecraft= +Contributors= +Creator of MineClone= +Creator of MineClone2= +Developers= +Jump to speed up (additionally sprint)= +Maintainers= +MineClone5= +Original Mod Authors= +Sneak to skip= +Textures= +Translations= \ No newline at end of file diff --git a/mods/HUD/mcl_credits/locale/template.txt b/mods/HUD/mcl_credits/locale/template.txt new file mode 100644 index 000000000..3ee9fa56c --- /dev/null +++ b/mods/HUD/mcl_credits/locale/template.txt @@ -0,0 +1,14 @@ +# textdomain: mcl_credits +3D Models= +A faithful Open Source clone of Minecraft= +Contributors= +Creator of MineClone= +Creator of MineClone2= +Developers= +Jump to speed up (additionally sprint)= +Maintainers= +MineClone5= +Original Mod Authors= +Sneak to skip= +Textures= +Translations= diff --git a/mods/HUD/mcl_credits/people.lua b/mods/HUD/mcl_credits/people.lua new file mode 100644 index 000000000..8f1d4c2e9 --- /dev/null +++ b/mods/HUD/mcl_credits/people.lua @@ -0,0 +1,144 @@ +local modname = minetest.get_current_modname() +local S = minetest.get_translator(modname) + +return { + {S("Creator of MineClone"), 0x0A9400, { + "davedevils", + }}, + {S("Creator of MineClone2"), 0xFBF837, { + "Wuzzy", + }}, + {S("Maintainers"), 0xFF51D5, { + "Fleckenstein", + "Nicu", + "kay27", + }}, + {S("Developers"), 0xF84355, { + "bzoss", + "AFCMS", + "epCode", + "ryvnf", + "iliekprogrammar", + "MysticTempest", + "Rootyjr", + "aligator", + "Code-Sploit", + "NO11", + "cora", + "jordan4ibanez", + }}, + {S("Contributors"), 0x52FF00, { + "Laurent Rocher", + "HimbeerserverDE", + "TechDudie", + "Alexander Minges", + "ArTee3", + "ZeDique la Ruleta", + "pitchum", + "wuniversales", + "Bu-Gee", + "David McMackins II", + "Nicholas Niro", + "Wouters Dorian", + "Blue Blancmange", + "Jared Moody", + "Li0n", + "Midgard", + "Saku Laesvuori", + "Yukitty", + "ZedekThePD", + "aldum", + "dBeans", + "nickolas360", + "yutyo", + "Tianyang Zhang", + "j45", + "Marcin Serwin", + "erlehmann", + "E", + "Benjamin Schötz", + "Doloment", + "Sydney Gems", + "talamh", + "Emily2255", + "Emojigit", + "FinishedFragment", + "sfan5", + "Blue Blancmange", + "Jared Moody", + "SmallJoker", + "Sven792", + "aldum", + }}, + {S("MineClone5"), 0xA60014, { + "kay27", + "Debiankaios", + "epCode", + "NO11", + "j45", + }}, + {S("Original Mod Authors"), 0x343434, { + "Wuzzy", + "Fleckenstein", + "BlockMen", + "TenPlus1", + "PilzAdam", + "ryvnf", + "stujones11", + "Arcelmi", + "celeron55", + "maikerumine", + "GunshipPenguin", + "Qwertymine3", + "Rochambeau", + "rubenwardy", + "stu", + "4aiman", + "Kahrl", + "Krock", + "UgnilJoZ", + "lordfingle", + "22i", + "bzoss", + "kilbith", + "xeranas", + "kddekadenz", + "sofar", + "4Evergreen4", + "jordan4ibanez", + "paramat", + }}, + {S("3D Models"), 0x0019FF, { + "22i", + "tobyplowy", + "epCode", + }}, + {S("Textures"), 0xFF9705, { + "XSSheep", + "Wuzzy", + "kingoscargames", + "leorockway", + "xMrVizzy", + "yutyo", + "NO11", + "kay27", + }}, + {S("Translations"), 0x00FF60, { + "Wuzzy", + "Rocher Laurent", + "wuniversales", + "kay27", + "pitchum", + "todoporlalibertad", + "Marcin Serwin", + }}, + {S("Funders"), 0xF7FF00, { + "40W", + }}, + {S("Special thanks"), 0x00E9FF, { + "celeron55 for creating Minetest", + "Jordach for the jukebox music compilation from Big Freaking Dig", + "The workaholics who spent way too much time writing for the Minecraft Wiki. It's an invaluable resource for creating this game", + "Notch and Jeb for being the major forces behind Minecraft", + }}, +} diff --git a/mods/HUD/mcl_credits/textures/credits_bg.png b/mods/HUD/mcl_credits/textures/credits_bg.png new file mode 100644 index 000000000..ad74cbd30 Binary files /dev/null and b/mods/HUD/mcl_credits/textures/credits_bg.png differ diff --git a/mods/HUD/mcl_experience/bottle.lua b/mods/HUD/mcl_experience/bottle.lua new file mode 100644 index 000000000..10e42a57d --- /dev/null +++ b/mods/HUD/mcl_experience/bottle.lua @@ -0,0 +1,63 @@ +local S = minetest.get_translator(minetest.get_current_modname()) + +minetest.register_entity("mcl_experience:bottle",{ + textures = {"mcl_experience_bottle.png"}, + hp_max = 1, + visual_size = {x = 0.35, y = 0.35}, + collisionbox = {-0.1, -0.1, -0.1, 0.1, 0.1, 0.1}, + pointable = false, + on_step = function(self, dtime) + local pos = self.object:get_pos() + local node = minetest.get_node(pos) + local n = node.name + if n ~= "air" and n ~= "mcl_portals:portal" and n ~= "mcl_portals:portal_end" and minetest.get_item_group(n, "liquid") == 0 then + minetest.sound_play("mcl_potions_breaking_glass", {pos = pos, max_hear_distance = 16, gain = 1}) + mcl_experience.throw_xp(pos, math.random(3, 11)) + minetest.add_particlespawner({ + amount = 50, + time = 0.1, + minpos = vector.add(pos, vector.new(-0.1, 0.5, -0.1)), + maxpos = vector.add(pos, vector.new( 0.1, 0.6, 0.1)), + minvel = vector.new(-2, 0, -2), + maxvel = vector.new( 2, 2, 2), + minacc = vector.new(0, 0, 0), + maxacc = vector.new(0, 0, 0), + minexptime = 0.5, + maxexptime = 1.25, + minsize = 1, + maxsize = 2, + collisiondetection = true, + vertical = false, + texture = "mcl_particles_effect.png^[colorize:blue:127", + }) + self.object:remove() + end + end, +}) + +local function throw_xp_bottle(pos, dir, velocity) + minetest.sound_play("mcl_throwing_throw", {pos = pos, gain = 0.4, max_hear_distance = 16}, true) + local obj = minetest.add_entity(pos, "mcl_experience:bottle") + obj:set_velocity(vector.multiply(dir, velocity)) + local acceleration = vector.multiply(dir, -3) + acceleration.y = -9.81 + obj:set_acceleration(acceleration) +end + +minetest.register_craftitem("mcl_experience:bottle", { + description = "Bottle o' Enchanting", + inventory_image = "mcl_experience_bottle.png", + wield_image = "mcl_experience_bottle.png", + stack_max = 64, + on_use = function(itemstack, placer, pointed_thing) + throw_xp_bottle(vector.add(placer:get_pos(), vector.new(0, 1.5, 0)), placer:get_look_dir(), 10) + if not minetest.is_creative_enabled(placer:get_player_name()) then + itemstack:take_item() + end + return itemstack + end, + _on_dispense = function(_, pos, _, _, dir) + throw_xp_bottle(vector.add(pos, vector.multiply(dir, 0.51)), dir, 10) + end +}) + diff --git a/mods/HUD/mcl_experience/command.lua b/mods/HUD/mcl_experience/command.lua new file mode 100644 index 000000000..040031b5a --- /dev/null +++ b/mods/HUD/mcl_experience/command.lua @@ -0,0 +1,39 @@ +local S = minetest.get_translator(minetest.get_current_modname()) + +minetest.register_chatcommand("xp", { + params = S("[[] ]"), + description = S("Gives a player some XP"), + privs = {server=true}, + func = function(name, params) + local player, xp = nil, 1000 + local P, i = {}, 0 + for str in string.gmatch(params, "([^ ]+)") do + i = i + 1 + P[i] = str + end + if i > 2 then + return false, S("Error: Too many parameters!") + end + if i > 0 then + xp = tonumber(P[i]) + end + if i < 2 then + player = minetest.get_player_by_name(name) + end + if i == 2 then + player = minetest.get_player_by_name(P[1]) + end + + if not xp then + return false, S("Error: Incorrect value of XP") + end + + if not player then + return false, S("Error: Player not found") + end + + mcl_experience.add_xp(player, xp) + + return true, S("Added @1 XP to @2, total: @3, experience level: @4", tostring(xp), player:get_player_name(), tostring(mcl_experience.get_xp(player)), tostring(mcl_experience.get_level(player))) + end, +}) diff --git a/mods/HUD/mcl_experience/init.lua b/mods/HUD/mcl_experience/init.lua index e514ffc19..aea805fa2 100644 --- a/mods/HUD/mcl_experience/init.lua +++ b/mods/HUD/mcl_experience/init.lua @@ -1,641 +1,227 @@ -local S = minetest.get_translator(minetest.get_current_modname()) - -mcl_experience = {} - -local vector = vector -local math = math -local string = string - -local pool = {} -local registered_nodes -local max_xp = 2^31-1 -local max_orb_age = 300 -- seconds - -local gravity = {x = 0, y = -((tonumber(minetest.settings:get("movement_gravity"))) or 9.81), z = 0} -local size_min, size_max = 20, 59 -- percents -local delta_size = size_max - size_min -local size_to_xp = { - {-32768, 2}, -- 1 - { 3, 6}, -- 2 - { 7, 16}, -- 3 - { 17, 36}, -- 4 - { 37, 72}, -- 5 - { 73, 148}, -- 6 - { 149, 306}, -- 7 - { 307, 616}, -- 8 - { 617, 1236}, -- 9 - { 1237, 2476}, --10 - { 2477, 32767} --11 +mcl_experience = { + on_add_xp = {}, } -local function xp_to_size(xp) - local i, l = 1, #size_to_xp - while (xp > size_to_xp[i][1]) and (i < l) do - i = i + 1 - end - return ((i-1) / (l-1) * delta_size + size_min)/100 -end +local modpath = minetest.get_modpath(minetest.get_current_modname()) -minetest.register_on_mods_loaded(function() - registered_nodes = minetest.registered_nodes -end) +dofile(modpath .. "/command.lua") +dofile(modpath .. "/orb.lua") +dofile(modpath .. "/bottle.lua") -local function load_data(player) - local name = player:get_player_name() - pool[name] = {} - local temp_pool = pool[name] - local meta = player:get_meta() - temp_pool.xp = meta:get_int("xp") or 0 - temp_pool.level = mcl_experience.xp_to_level(temp_pool.xp) - temp_pool.bar, temp_pool.bar_step, temp_pool.xp_next_level = mcl_experience.xp_to_bar(temp_pool.xp, temp_pool.level) - temp_pool.last_time= minetest.get_us_time()/1000000 -end +-- local storage --- saves data to be utilized on next login -local function save_data(player) - local name = player:get_player_name() - local temp_pool = pool[name] - local meta = player:get_meta() - meta:set_int("xp", temp_pool.xp) - pool[name] = nil -end +local hud_bars = {} +local hud_levels = {} +local caches = {} -local player_huds = {} -- the list of players hud lists (3d array) -hud_manager = {} -- hud manager class +-- helpers --- terminate the player's list on leave -minetest.register_on_leaveplayer(function(player) - local name = player:get_player_name() - player_huds[name] = nil -end) - --- create instance of new hud -function hud_manager.add_hud(player,hud_name,def) - local name = player:get_player_name() - if minetest.is_creative_enabled(name) then - return - end - local local_hud = player:hud_add({ - hud_elem_type = def.hud_elem_type, - position = def.position, - text = def.text, - text2 = def.text2, - number = def.number, - item = def.item, - direction = def.direction, - size = def.size, - offset = def.offset, - z_index = def.z_index, - alignment = def.alignment, - scale = def.scale, - }) - -- create new 3d array here - -- depends.txt is not needed - -- with it here - if not player_huds[name] then - player_huds[name] = {} - end - - player_huds[name][hud_name] = local_hud -end - --- delete instance of hud -function hud_manager.remove_hud(player,hud_name) - local name = player:get_player_name() - if player_huds[name] and player_huds[name][hud_name] then - player:hud_remove(player_huds[name][hud_name]) - player_huds[name][hud_name] = nil - end -end - --- change element of hud -function hud_manager.change_hud(data) - local name = data.player:get_player_name() - if player_huds[name] and player_huds[name][data.hud_name] then - data.player:hud_change(player_huds[name][data.hud_name], data.element, data.data) - end -end - --- gets if hud exists -function hud_manager.hud_exists(player,hud_name) - local name = player:get_player_name() - if player_huds[name] and player_huds[name][hud_name] then - return true - else - return false - end -end -------------------- - --- saves specific users data for when they relog -minetest.register_on_leaveplayer(function(player) - save_data(player) -end) - --- is used for shutdowns to save all data -local function save_all() - for name,_ in pairs(pool) do - local player = minetest.get_player_by_name(name) - if player then - save_data(player) - end - end -end - --- save all data to mod storage on shutdown -minetest.register_on_shutdown(function() - save_all() -end) - - -function mcl_experience.get_player_xp_level(player) - local name = player:get_player_name() - return pool[name].level -end - -function mcl_experience.set_player_xp_level(player,level) - local name = player:get_player_name() - if level == pool[name].level then - return - end - pool[name].level = level - pool[name].xp, pool[name].bar_step, pool[name].xp_next_level = mcl_experience.bar_to_xp(pool[name].bar, level) - hud_manager.change_hud({player = player, hud_name = "xp_level", element = "text", data = tostring(level)}) - -- we may don't update the bar -end - -local name -local temp_pool -minetest.register_on_joinplayer(function(player) - - load_data(player) - - name = player:get_player_name() - temp_pool = pool[name] - - hud_manager.add_hud(player,"experience_bar", - { - hud_elem_type = "image", - name = "experience bar", - text = "experience_bar_background.png^[lowpart:" .. math.floor(temp_pool.bar / 36 * 100) .. ":experience_bar.png^[transformR270", - position = {x=0.5, y=1}, - offset = {x = (-9 * 28) - 3, y = -(48 + 24 + 16 - 5)}, - scale = {x = 2.8, y = 3.0}, - alignment = { x = 1, y = 1 }, - z_index = 11, - }) - - hud_manager.add_hud(player,"xp_level", - { - hud_elem_type = "text", position = {x=0.5, y=1}, - name = "xp_level", text = tostring(temp_pool.level), - number = 0x80FF20, - offset = {x = 0, y = -(48 + 24 + 24)}, - z_index = 12, - }) -end) - -function mcl_experience.xp_to_level(xp) +local function xp_to_level(xp) local xp = xp or 0 local a, b, c, D + if xp > 1507 then - a, b, c = 4.5, -162.5, 2220-xp + a, b, c = 4.5, -162.5, 2220 - xp elseif xp > 352 then - a, b, c = 2.5, -40.5, 360-xp + a, b, c = 2.5, -40.5, 360 - xp else a, b, c = 1, 6, -xp end - D = b*b-4*a*c + + D = b * b - 4 * a * c + if D == 0 then - return math.floor(-b/2/a) - elseif D > 0 then - local v1, v2 = -b/2/a, math.sqrt(D)/2/a - return math.floor((math.max(v1-v2, v1+v2))) + return math.floor(-b / 2 / a) + elseif D > 0 then + local v1, v2 = -b / 2 / a, math.sqrt(D) / 2 / a + return math.floor(math.max(v1 - v2, v1 + v2)) end + return 0 end -function mcl_experience.level_to_xp(level) - if (level >= 1 and level <= 16) then +local function level_to_xp(level) + if level >= 1 and level <= 16 then return math.floor(math.pow(level, 2) + 6 * level) - elseif (level >= 17 and level <= 31) then + elseif level >= 17 and level <= 31 then return math.floor(2.5 * math.pow(level, 2) - 40.5 * level + 360) elseif level >= 32 then - return math.floor(4.5 * math.pow(level, 2) - 162.5 * level + 2220); + return math.floor(4.5 * math.pow(level, 2) - 162.5 * level + 2220) end + return 0 end -function mcl_experience.xp_to_bar(xp, level) - local level = level or mcl_experience.xp_to_level(xp) - local xp_this_level = mcl_experience.level_to_xp(level) - local xp_next_level = mcl_experience.level_to_xp(level+1) - local bar_step = 36 / (xp_next_level-xp_this_level) - local bar = (xp-xp_this_level) * bar_step - return bar, bar_step, xp_next_level +local function calculate_bounds(level) + return level_to_xp(level), level_to_xp(level + 1) end -function mcl_experience.bar_to_xp(bar, level) - local xp_this_level = mcl_experience.level_to_xp(level) - local xp_next_level = mcl_experience.level_to_xp(level+1) - local bar_step = 36 / (xp_next_level-xp_this_level) - local xp = xp_this_level + math.floor(bar/36*(xp_next_level-xp_this_level)) - return xp, bar_step, xp_next_level +local function xp_to_bar(xp, level) + local xp_min, xp_max = calculate_bounds(level) + + return (xp - xp_min) / (xp_max - xp_min) end -function mcl_experience.add_experience(player, experience) - local name = player:get_player_name() - local temp_pool = pool[name] +local function bar_to_xp(bar, level) + local xp_min, xp_max = calculate_bounds(level) - local inv = player:get_inventory() - local candidates = { - {list = "main", index = player:get_wield_index()}, - {list = "armor", index = 2}, - {list = "armor", index = 3}, - {list = "armor", index = 4}, - {list = "armor", index = 5}, - } - local final_candidates = {} - for _, can in ipairs(candidates) do - local stack = inv:get_stack(can.list, can.index) - local wear = stack:get_wear() - if mcl_enchanting.has_enchantment(stack, "mending") and wear > 0 then - can.stack = stack - can.wear = wear - table.insert(final_candidates, can) - end - end - if #final_candidates > 0 then - local can = final_candidates[math.random(#final_candidates)] - local stack, list, index, wear = can.stack, can.list, can.index, can.wear - local uses = mcl_util.calculate_durability(stack) - local multiplier = 2 * 65535 / uses - local repair = experience * multiplier - local new_wear = wear - repair - if new_wear < 0 then - experience = math.floor(-new_wear / multiplier + 0.5) - new_wear = 0 - else - experience = 0 - end - stack:set_wear(math.floor(new_wear)) - inv:set_stack(list, index, stack) - end + return xp_min + bar * (xp_max - xp_min) +end - local old_bar, old_xp, old_level = temp_pool.bar, temp_pool.xp, temp_pool.level - temp_pool.xp = math.min(math.max(temp_pool.xp + experience, 0), max_xp) +local function get_time() + return minetest.get_us_time() / 1000000 +end - if (temp_pool.xp < temp_pool.xp_next_level) and (temp_pool.xp >= old_xp) then - temp_pool.bar = temp_pool.bar + temp_pool.bar_step * experience - else - temp_pool.level = mcl_experience.xp_to_level(temp_pool.xp) - temp_pool.bar, temp_pool.bar_step, temp_pool.xp_next_level = mcl_experience.xp_to_bar(temp_pool.xp, temp_pool.level) - end +-- api - if old_bar ~= temp_pool.bar then - hud_manager.change_hud({player = player, hud_name = "experience_bar", element = "text", data = "experience_bar_background.png^[lowpart:" .. math.floor(temp_pool.bar / 36 * 100) .. ":experience_bar.png^[transformR270",}) - end +function mcl_experience.get_level(player) + return caches[player].level +end - if experience > 0 and minetest.get_us_time()/1000000 - temp_pool.last_time > 0.01 then - if old_level ~= temp_pool.level then - minetest.sound_play("level_up",{gain=0.2,to_player = name}) - temp_pool.last_time = minetest.get_us_time()/1000000 + 0.2 - else - minetest.sound_play("experience",{gain=0.1,to_player = name,pitch=math.random(75,99)/100}) - temp_pool.last_time = minetest.get_us_time()/1000000 - end - end +function mcl_experience.set_level(player, level) + local cache = caches[player] - if old_level ~= temp_pool.level then - hud_manager.change_hud({player = player, hud_name = "xp_level", element = "text", data = tostring(temp_pool.level)}) + if level ~= cache.level then + mcl_experience.set_xp(player, math.floor(bar_to_xp(xp_to_bar(mcl_experience.get_xp(player), cache.level), level))) end end ---reset player level -local name -local temp_pool -local xp_amount -minetest.register_on_dieplayer(function(player) - if minetest.settings:get_bool("mcl_keepInventory", false) then - return - end +function mcl_experience.get_xp(player) + return player:get_meta():get_int("xp") +end - name = player:get_player_name() - temp_pool = pool[name] - xp_amount = temp_pool.xp +function mcl_experience.set_xp(player, xp) + player:get_meta():set_int("xp", xp) - temp_pool.xp = 0 - temp_pool.level = 0 - temp_pool.bar, temp_pool.bar_step, temp_pool.xp_next_level = mcl_experience.xp_to_bar(temp_pool.xp, temp_pool.level) + mcl_experience.update(player) +end - hud_manager.change_hud({player = player, hud_name = "xp_level", element = "text", data = tostring(temp_pool.level)}) - hud_manager.change_hud({player = player, hud_name = "experience_bar", element = "text", data = "experience_bar_background.png^[lowpart:" .. math.floor(temp_pool.bar / 36 * 100) .. ":experience_bar.png^[transformR270",}) +function mcl_experience.add_xp(player, xp) + for _, cb in ipairs(mcl_experience.on_add_xp) do + xp = cb.func(player, xp) or xp - mcl_experience.throw_experience(player:get_pos(), xp_amount) -end) - -local collector, pos, pos2 -local direction, distance, player_velocity, goal -local currentvel, acceleration, multiplier, velocity -local node, vel, def -local is_moving, is_slippery, slippery, slip_factor -local size -local function xp_step(self, dtime) - --if item set to be collected then only execute go to player - if self.collected == true then - if not self.collector then - self.collected = false - return - end - collector = minetest.get_player_by_name(self.collector) - if collector and collector:get_hp() > 0 and vector.distance(self.object:get_pos(),collector:get_pos()) < 7.25 then - self.object:set_acceleration(vector.new(0,0,0)) - self.disable_physics(self) - --get the variables - pos = self.object:get_pos() - pos2 = collector:get_pos() - - player_velocity = collector:get_velocity() or collector:get_player_velocity() - - pos2.y = pos2.y + 0.8 - - direction = vector.direction(pos,pos2) - distance = vector.distance(pos2,pos) - multiplier = distance - if multiplier < 1 then - multiplier = 1 - end - goal = vector.multiply(direction,multiplier) - currentvel = self.object:get_velocity() - - if distance > 1 then - multiplier = 20 - distance - velocity = vector.multiply(direction,multiplier) - goal = velocity - acceleration = vector.new(goal.x-currentvel.x,goal.y-currentvel.y,goal.z-currentvel.z) - self.object:add_velocity(vector.add(acceleration,player_velocity)) - elseif distance < 0.8 then - mcl_experience.add_experience(collector, self._xp) - self.object:remove() - end - return - else - self.collector = nil - self.enable_physics(self) + if xp == 0 then + break end end + local cache = caches[player] + local old_level = cache.level - self.age = self.age + dtime - if self.age > max_orb_age then - self.object:remove() - return - end + mcl_experience.set_xp(player, mcl_experience.get_xp(player) + xp) - pos = self.object:get_pos() + local current_time = get_time() - if pos then - node = minetest.get_node_or_nil({ - x = pos.x, - y = pos.y -0.25, - z = pos.z - }) - else - return - end + if current_time - cache.last_time > 0.01 then + local name = player:get_player_name() - -- Remove nodes in 'ignore' - if node and node.name == "ignore" then - self.object:remove() - return - end - - if not self.physical_state then - return -- Don't do anything - end - - -- Slide on slippery nodes - vel = self.object:get_velocity() - def = node and registered_nodes[node.name] - is_moving = (def and not def.walkable) or - vel.x ~= 0 or vel.y ~= 0 or vel.z ~= 0 - is_slippery = false - - if def and def.walkable then - slippery = minetest.get_item_group(node.name, "slippery") - is_slippery = slippery ~= 0 - if is_slippery and (math.abs(vel.x) > 0.2 or math.abs(vel.z) > 0.2) then - -- Horizontal deceleration - slip_factor = 4.0 / (slippery + 4) - self.object:set_acceleration({ - x = -vel.x * slip_factor, - y = 0, - z = -vel.z * slip_factor + if old_level == cache.level then + minetest.sound_play("mcl_experience", { + to_player = name, + gain = 0.1, + pitch = math.random(75, 99) / 100, }) - elseif vel.y == 0 then - is_moving = false + + cache.last_time = current_time + else + minetest.sound_play("mcl_experience_level_up", { + to_player = name, + gain = 0.2, + }) + + cache.last_time = current_time + 0.2 end end - - if self.moving_state == is_moving and self.slippery_state == is_slippery then - -- Do not update anything until the moving state changes - return - end - - self.moving_state = is_moving - self.slippery_state = is_slippery - - if is_moving then - self.object:set_acceleration(gravity) - else - self.object:set_acceleration({x = 0, y = 0, z = 0}) - self.object:set_velocity({x = 0, y = 0, z = 0}) - end end -minetest.register_entity("mcl_experience:orb", { - initial_properties = { - hp_max = 1, - physical = true, - collide_with_objects = false, - collisionbox = {-0.2, -0.2, -0.2, 0.2, 0.2, 0.2}, - visual = "sprite", - visual_size = {x = 0.4, y = 0.4}, - textures = {name="experience_orb.png", animation={type="vertical_frames", aspect_w=16, aspect_h=16, length=2.0}}, - spritediv = {x = 1, y = 14}, - initial_sprite_basepos = {x = 0, y = 0}, - is_visible = true, - pointable = false, - static_save = false, - }, - moving_state = true, - slippery_state = false, - physical_state = true, - -- Item expiry - age = 0, - -- Pushing item out of solid nodes - force_out = nil, - force_out_start = nil, - --Collection Variables - collectable = false, - try_timer = 0, - collected = false, - delete_timer = 0, - radius = 4, - - - on_activate = function(self, staticdata, dtime_s) - self.object:set_velocity(vector.new( - math.random(-2,2)*math.random(), - math.random(2,5), - math.random(-2,2)*math.random() - )) - self.object:set_armor_groups({immortal = 1}) - self.object:set_velocity({x = 0, y = 2, z = 0}) - self.object:set_acceleration(gravity) - local xp = tonumber(staticdata) - self._xp = xp - size = xp_to_size(xp) - self.object:set_properties({ - visual_size = {x = size, y = size}, - glow = 14, - }) - self.object:set_sprite({x=1,y=math.random(1,14)}, 14, 0.05, false) - end, - - enable_physics = function(self) - if not self.physical_state then - self.physical_state = true - self.object:set_properties({physical = true}) - self.object:set_velocity({x=0, y=0, z=0}) - self.object:set_acceleration(gravity) - end - end, - - disable_physics = function(self) - if self.physical_state then - self.physical_state = false - self.object:set_properties({physical = false}) - self.object:set_velocity({x=0, y=0, z=0}) - self.object:set_acceleration({x=0, y=0, z=0}) - end - end, - on_step = function(self, dtime) - xp_step(self, dtime) - end, -}) - -minetest.register_chatcommand("xp", { - params = S("[[] ]"), - description = S("Gives a player some XP"), - privs = {server=true}, - func = function(name, params) - local player, xp = nil, 1000 - local P, i = {}, 0 - for str in string.gmatch(params, "([^ ]+)") do - i = i + 1 - P[i] = str - end - if i > 2 then - return false, S("Error: Too many parameters!") - end - if i > 0 then - xp = tonumber(P[i]) - end - if i < 2 then - player = minetest.get_player_by_name(name) - end - if i == 2 then - player = minetest.get_player_by_name(P[1]) - end - if not xp then - return false, S("Error: Incorrect value of XP") - end - if not player then - return false, S("Error: Player not found") - end - mcl_experience.add_experience(player, xp) - local playername = player:get_player_name() - minetest.chat_send_player(name, S("Added @1 XP to @2, total: @3, experience level: @4", tostring(xp), playername, tostring(pool[playername].xp), tostring(pool[playername].level))) - end, -}) - -function mcl_experience.throw_experience(pos, amount) +function mcl_experience.throw_xp(pos, total_xp) local i, j = 0, 0 - local obj, xp - while i < amount and j < 100 do - xp = math.min(math.random(1, math.min(32767, amount-math.floor(i/2))), amount-i) - obj = minetest.add_entity(pos, "mcl_experience:orb", tostring(xp)) + + while i < total_xp and j < 100 do + local xp = math.min(math.random(1, math.min(32767, total_xp - math.floor(i / 2))), total_xp - i) + local obj = minetest.add_entity(pos, "mcl_experience:orb", tostring(xp)) + if not obj then return false end - obj:set_velocity({ - x=math.random(-2,2)*math.random(), - y=math.random(2,5), - z=math.random(-2,2)*math.random() - }) + + obj:set_velocity(vector.new( + math.random(-2, 2) * math.random(), + math.random( 2, 5), + math.random(-2, 2) * math.random() + )) + i = i + xp j = j + 1 end end -minetest.register_entity("mcl_experience:bottle",{ - textures = {"mcl_experience_bottle.png"}, - hp_max = 1, - visual_size = {x = 0.35, y = 0.35}, - collisionbox = {-0.1, -0.1, -0.1, 0.1, 0.1, 0.1}, - pointable = false, - on_step = function(self, dtime) - local pos = self.object:get_pos() - local node = minetest.get_node(pos) - local n = node.name - if n ~= "air" and n ~= "mcl_portals:portal" and n ~= "mcl_portals:portal_end" and minetest.get_item_group(n, "liquid") == 0 then - minetest.sound_play("mcl_potions_breaking_glass", {pos = pos, max_hear_distance = 16, gain = 1}) - mcl_experience.throw_experience(pos, math.random(3, 11)) - minetest.add_particlespawner({ - amount = 50, - time = 0.1, - minpos = vector.add(pos, vector.new(-0.1, 0.5, -0.1)), - maxpos = vector.add(pos, vector.new( 0.1, 0.6, 0.1)), - minvel = vector.new(-2, 0, -2), - maxvel = vector.new( 2, 2, 2), - minacc = vector.new(0, 0, 0), - maxacc = vector.new(0, 0, 0), - minexptime = 0.5, - maxexptime = 1.25, - minsize = 1, - maxsize = 2, - collisiondetection = true, - vertical = false, - texture = "mcl_particles_effect.png^[colorize:blue:127", - }) - self.object:remove() - end - end, -}) +function mcl_experience.update(player) + local xp = mcl_experience.get_xp(player) + local cache = caches[player] -local function throw_xp_bottle(pos, dir, velocity) - minetest.sound_play("mcl_throwing_throw", {pos = pos, gain = 0.4, max_hear_distance = 16}, true) - local obj = minetest.add_entity(pos, "mcl_experience:bottle") - obj:set_velocity(vector.multiply(dir, velocity)) - local acceleration = vector.multiply(dir, -3) - acceleration.y = -9.81 - obj:set_acceleration(acceleration) + cache.level = xp_to_level(xp) + + if not minetest.is_creative_enabled(player:get_player_name()) then + player:hud_change(hud_bars[player], "text", "mcl_experience_bar_background.png^[lowpart:" + .. math.floor(math.floor(xp_to_bar(xp, cache.level) * 18) / 18 * 100) + .. ":mcl_experience_bar.png^[transformR270" + ) + + if cache.level == 0 then + player:hud_change(hud_levels[player], "text", "") + else + player:hud_change(hud_levels[player], "text", tostring(cache.level)) + end + end end -minetest.register_craftitem("mcl_experience:bottle", { - description = "Bottle o' Enchanting", - inventory_image = "mcl_experience_bottle.png", - wield_image = "mcl_experience_bottle.png", - stack_max = 64, - on_use = function(itemstack, placer, pointed_thing) - throw_xp_bottle(vector.add(placer:get_pos(), vector.new(0, 1.5, 0)), placer:get_look_dir(), 10) - if not minetest.is_creative_enabled(placer:get_player_name()) then - itemstack:take_item() - end - return itemstack - end, - _on_dispense = function(_, pos, _, _, dir) - throw_xp_bottle(vector.add(pos, vector.multiply(dir, 0.51)), dir, 10) +function mcl_experience.register_on_add_xp(func, priority) + table.insert(mcl_experience.on_add_xp, {func = func, priority = priority or 0}) +end + +-- callbacks + +minetest.register_on_joinplayer(function(player) + caches[player] = { + last_time = get_time(), + } + + if not minetest.is_creative_enabled(player:get_player_name()) then + hud_bars[player] = player:hud_add({ + hud_elem_type = "image", + position = {x = 0.5, y = 1}, + offset = {x = (-9 * 28) - 3, y = -(48 + 24 + 16 - 5)}, + scale = {x = 2.8, y = 3.0}, + alignment = {x = 1, y = 1}, + z_index = 11, + }) + + hud_levels[player] = player:hud_add({ + hud_elem_type = "text", + position = {x = 0.5, y = 1}, + number = 0x80FF20, + offset = {x = 0, y = -(48 + 24 + 24)}, + z_index = 12, + }) end -}) + + mcl_experience.update(player) +end) + +minetest.register_on_leaveplayer(function(player) + hud_bars[player] = nil + hud_levels[player] = nil + caches[player] = nil +end) + +minetest.register_on_dieplayer(function(player) + if not minetest.settings:get_bool("mcl_keepInventory", false) then + mcl_experience.throw_xp(player:get_pos(), mcl_experience.get_xp(player)) + mcl_experience.set_xp(player, 0) + end +end) + +minetest.register_on_mods_loaded(function() + table.sort(mcl_experience.on_add_xp, function(a, b) return a.priority < b.priority end) +end) diff --git a/mods/HUD/mcl_experience/orb.lua b/mods/HUD/mcl_experience/orb.lua new file mode 100644 index 000000000..9aecce00d --- /dev/null +++ b/mods/HUD/mcl_experience/orb.lua @@ -0,0 +1,220 @@ +local size_min, size_max = 20, 59 +local delta_size = size_max - size_min + +local size_to_xp = { + {-32768, 2}, -- 1 + { 3, 6}, -- 2 + { 7, 16}, -- 3 + { 17, 36}, -- 4 + { 37, 72}, -- 5 + { 73, 148}, -- 6 + { 149, 306}, -- 7 + { 307, 616}, -- 8 + { 617, 1236}, -- 9 + { 1237, 2476}, -- 10 + { 2477, 32767} -- 11 +} + +local function xp_to_size(xp) + local i, l = 1, #size_to_xp + + while xp > size_to_xp[i][1] and i < l do + i = i + 1 + end + + return ((i - 1) / (l - 1) * delta_size + size_min) / 100 +end + +local max_orb_age = 300 -- seconds +local gravity = vector.new(0, -((tonumber(minetest.settings:get("movement_gravity"))) or 9.81), 0) + +local collector, pos, pos2 +local direction, distance, player_velocity, goal +local currentvel, acceleration, multiplier, velocity +local node, vel, def +local is_moving, is_slippery, slippery, slip_factor +local size +local function xp_step(self, dtime) + --if item set to be collected then only execute go to player + if self.collected == true then + if not self.collector then + self.collected = false + return + end + collector = minetest.get_player_by_name(self.collector) + if collector and collector:get_hp() > 0 and vector.distance(self.object:get_pos(),collector:get_pos()) < 7.25 then + self.object:set_acceleration(vector.new(0,0,0)) + self.disable_physics(self) + --get the variables + pos = self.object:get_pos() + pos2 = collector:get_pos() + + player_velocity = collector:get_velocity() or collector:get_player_velocity() + + pos2.y = pos2.y + 0.8 + + direction = vector.direction(pos,pos2) + distance = vector.distance(pos2,pos) + multiplier = distance + if multiplier < 1 then + multiplier = 1 + end + goal = vector.multiply(direction,multiplier) + currentvel = self.object:get_velocity() + + if distance > 1 then + multiplier = 20 - distance + velocity = vector.multiply(direction,multiplier) + goal = velocity + acceleration = vector.new(goal.x-currentvel.x,goal.y-currentvel.y,goal.z-currentvel.z) + self.object:add_velocity(vector.add(acceleration,player_velocity)) + elseif distance < 0.8 then + mcl_experience.add_xp(collector, self._xp) + self.object:remove() + end + return + else + self.collector = nil + self.enable_physics(self) + end + end + + + self.age = self.age + dtime + if self.age > max_orb_age then + self.object:remove() + return + end + + pos = self.object:get_pos() + + if pos then + node = minetest.get_node_or_nil({ + x = pos.x, + y = pos.y -0.25, + z = pos.z + }) + else + return + end + + -- Remove nodes in 'ignore' + if node and node.name == "ignore" then + self.object:remove() + return + end + + if not self.physical_state then + return -- Don't do anything + end + + -- Slide on slippery nodes + vel = self.object:get_velocity() + def = node and minetest.registered_nodes[node.name] + is_moving = (def and not def.walkable) or + vel.x ~= 0 or vel.y ~= 0 or vel.z ~= 0 + is_slippery = false + + if def and def.walkable then + slippery = minetest.get_item_group(node.name, "slippery") + is_slippery = slippery ~= 0 + if is_slippery and (math.abs(vel.x) > 0.2 or math.abs(vel.z) > 0.2) then + -- Horizontal deceleration + slip_factor = 4.0 / (slippery + 4) + self.object:set_acceleration({ + x = -vel.x * slip_factor, + y = 0, + z = -vel.z * slip_factor + }) + elseif vel.y == 0 then + is_moving = false + end + end + + if self.moving_state == is_moving and self.slippery_state == is_slippery then + -- Do not update anything until the moving state changes + return + end + + self.moving_state = is_moving + self.slippery_state = is_slippery + + if is_moving then + self.object:set_acceleration(gravity) + else + self.object:set_acceleration({x = 0, y = 0, z = 0}) + self.object:set_velocity({x = 0, y = 0, z = 0}) + end +end + +minetest.register_entity("mcl_experience:orb", { + initial_properties = { + hp_max = 1, + physical = true, + collide_with_objects = false, + collisionbox = {-0.2, -0.2, -0.2, 0.2, 0.2, 0.2}, + visual = "sprite", + visual_size = {x = 0.4, y = 0.4}, + textures = {name="mcl_experience_orb.png", animation={type="vertical_frames", aspect_w=16, aspect_h=16, length=2.0}}, + spritediv = {x = 1, y = 14}, + initial_sprite_basepos = {x = 0, y = 0}, + is_visible = true, + pointable = false, + static_save = false, + }, + moving_state = true, + slippery_state = false, + physical_state = true, + -- Item expiry + age = 0, + -- Pushing item out of solid nodes + force_out = nil, + force_out_start = nil, + --Collection Variables + collectable = false, + try_timer = 0, + collected = false, + delete_timer = 0, + radius = 4, + + + on_activate = function(self, staticdata, dtime_s) + self.object:set_velocity(vector.new( + math.random(-2,2)*math.random(), + math.random(2,5), + math.random(-2,2)*math.random() + )) + self.object:set_armor_groups({immortal = 1}) + self.object:set_velocity({x = 0, y = 2, z = 0}) + self.object:set_acceleration(gravity) + local xp = tonumber(staticdata) + self._xp = xp + size = xp_to_size(xp) + self.object:set_properties({ + visual_size = {x = size, y = size}, + glow = 14, + }) + self.object:set_sprite({x=1,y=math.random(1,14)}, 14, 0.05, false) + end, + + enable_physics = function(self) + if not self.physical_state then + self.physical_state = true + self.object:set_properties({physical = true}) + self.object:set_velocity({x=0, y=0, z=0}) + self.object:set_acceleration(gravity) + end + end, + + disable_physics = function(self) + if self.physical_state then + self.physical_state = false + self.object:set_properties({physical = false}) + self.object:set_velocity({x=0, y=0, z=0}) + self.object:set_acceleration({x=0, y=0, z=0}) + end + end, + on_step = function(self, dtime) + xp_step(self, dtime) + end, +}) diff --git a/mods/HUD/mcl_experience/sounds/experience.ogg b/mods/HUD/mcl_experience/sounds/mcl_experience.ogg similarity index 100% rename from mods/HUD/mcl_experience/sounds/experience.ogg rename to mods/HUD/mcl_experience/sounds/mcl_experience.ogg diff --git a/mods/HUD/mcl_experience/sounds/level_up.ogg b/mods/HUD/mcl_experience/sounds/mcl_experience_level_up.ogg similarity index 100% rename from mods/HUD/mcl_experience/sounds/level_up.ogg rename to mods/HUD/mcl_experience/sounds/mcl_experience_level_up.ogg diff --git a/mods/HUD/mcl_experience/textures/experience_bar.png b/mods/HUD/mcl_experience/textures/mcl_experience_bar.png similarity index 100% rename from mods/HUD/mcl_experience/textures/experience_bar.png rename to mods/HUD/mcl_experience/textures/mcl_experience_bar.png diff --git a/mods/HUD/mcl_experience/textures/experience_bar_background.png b/mods/HUD/mcl_experience/textures/mcl_experience_bar_background.png similarity index 100% rename from mods/HUD/mcl_experience/textures/experience_bar_background.png rename to mods/HUD/mcl_experience/textures/mcl_experience_bar_background.png diff --git a/mods/HUD/mcl_experience/textures/experience_orb.png b/mods/HUD/mcl_experience/textures/mcl_experience_orb.png similarity index 100% rename from mods/HUD/mcl_experience/textures/experience_orb.png rename to mods/HUD/mcl_experience/textures/mcl_experience_orb.png diff --git a/mods/HUD/mcl_inventory/creative.lua b/mods/HUD/mcl_inventory/creative.lua index 6eac1c329..f5a9574eb 100644 --- a/mods/HUD/mcl_inventory/creative.lua +++ b/mods/HUD/mcl_inventory/creative.lua @@ -1,671 +1,703 @@ -local S = minetest.get_translator(minetest.get_current_modname()) -local F = minetest.formspec_escape - --- Prepare player info table -local players = {} - --- Containing all the items for each Creative Mode tab -local inventory_lists = {} - ---local mod_player = minetest.get_modpath("mcl_player") - --- Create tables -local builtin_filter_ids = {"blocks","deco","redstone","rail","food","tools","combat","mobs","brew","matr","misc","all"} -for _, f in pairs(builtin_filter_ids) do - inventory_lists[f] = {} -end - -local function replace_enchanted_books(tbl) - for k, item in ipairs(tbl) do - if item:find("mcl_enchanting:book_enchanted") == 1 then - local _, enchantment, level = item:match("(%a+) ([_%w]+) (%d+)") - level = level and tonumber(level) - if enchantment and level then - tbl[k] = mcl_enchanting.enchant(ItemStack("mcl_enchanting:book_enchanted"), enchantment, level) - end - end - end -end - ---[[ Populate all the item tables. We only do this once. Note this mod must be -loaded after _mcl_autogroup for this to work, because it required certain -groups to be set. ]] -do - for name,def in pairs(minetest.registered_items) do - if (not def.groups.not_in_creative_inventory or def.groups.not_in_creative_inventory == 0) and def.description and def.description ~= "" then - local function is_redstone(def) - return def.mesecons or def.groups.mesecon or def.groups.mesecon_conductor_craftable or def.groups.mesecon_effecor_off - end - local function is_tool(def) - return def.groups.tool or (def.tool_capabilities and def.tool_capabilities.damage_groups == nil) - end - local function is_weapon_or_armor(def) - return def.groups.weapon or def.groups.weapon_ranged or def.groups.ammo or def.groups.combat_item or ((def.groups.armor_head or def.groups.armor_torso or def.groups.armor_legs or def.groups.armor_feet or def.groups.horse_armor) and def.groups.non_combat_armor ~= 1) - end - -- Is set to true if it was added in any category besides misc - local nonmisc = false - if def.groups.building_block then - table.insert(inventory_lists["blocks"], name) - nonmisc = true - end - if def.groups.deco_block then - table.insert(inventory_lists["deco"], name) - nonmisc = true - end - if is_redstone(def) then - table.insert(inventory_lists["redstone"], name) - nonmisc = true - end - if def.groups.transport then - table.insert(inventory_lists["rail"], name) - nonmisc = true - end - if (def.groups.food and not def.groups.brewitem) or def.groups.eatable then - table.insert(inventory_lists["food"], name) - nonmisc = true - end - if is_tool(def) then - table.insert(inventory_lists["tools"], name) - nonmisc = true - end - if is_weapon_or_armor(def) then - table.insert(inventory_lists["combat"], name) - nonmisc = true - end - if def.groups.spawn_egg == 1 then - table.insert(inventory_lists["mobs"], name) - nonmisc = true - end - if def.groups.brewitem then - table.insert(inventory_lists["brew"], name) - nonmisc = true - end - if def.groups.craftitem then - table.insert(inventory_lists["matr"], name) - nonmisc = true - end - -- Misc. category is for everything which is not in any other category - if not nonmisc then - table.insert(inventory_lists["misc"], name) - end - - table.insert(inventory_lists["all"], name) - end - end - - for ench, def in pairs(mcl_enchanting.enchantments) do - local str = "mcl_enchanting:book_enchanted " .. ench .. " " .. def.max_level - if def.inv_tool_tab then - table.insert(inventory_lists["tools"], str) - end - if def.inv_combat_tab then - table.insert(inventory_lists["combat"], str) - end - table.insert(inventory_lists["all"], str) - end - - for _, to_sort in pairs(inventory_lists) do - table.sort(to_sort) - replace_enchanted_books(to_sort) - end -end - -local function filter_item(name, description, lang, filter) - local desc - if not lang then - desc = string.lower(description) - else - desc = string.lower(minetest.get_translated_string(lang, description)) - end - return string.find(name, filter) or string.find(desc, filter) -end - -local function set_inv_search(filter, player) - local playername = player:get_player_name() - local inv = minetest.get_inventory({type="detached", name="creative_"..playername}) - local creative_list = {} - local lang = minetest.get_player_information(playername).lang_code - for name,def in pairs(minetest.registered_items) do - if (not def.groups.not_in_creative_inventory or def.groups.not_in_creative_inventory == 0) and def.description and def.description ~= "" then - if filter_item(string.lower(def.name), def.description, lang, filter) then - table.insert(creative_list, name) - end - end - end - for ench, def in pairs(mcl_enchanting.enchantments) do - for i = 1, def.max_level do - local stack = mcl_enchanting.enchant(ItemStack("mcl_enchanting:book_enchanted"), ench, i) - if filter_item("mcl_enchanting:book_enchanted", minetest.strip_colors(stack:get_description()), lang, filter) then - table.insert(creative_list, "mcl_enchanting:book_enchanted " .. ench .. " " .. i) - end - end - end - table.sort(creative_list) - replace_enchanted_books(creative_list) - - inv:set_size("main", #creative_list) - inv:set_list("main", creative_list) -end - -local function set_inv_page(page, player) - local playername = player:get_player_name() - local inv = minetest.get_inventory({type="detached", name="creative_"..playername}) - inv:set_size("main", 0) - local creative_list = {} - if inventory_lists[page] then -- Standard filter - creative_list = inventory_lists[page] - end - inv:set_size("main", #creative_list) - inv:set_list("main", creative_list) -end - -local function init(player) - local playername = player:get_player_name() - minetest.create_detached_inventory("creative_"..playername, { - allow_move = function(inv, from_list, from_index, to_list, to_index, count, player) - if minetest.is_creative_enabled(playername) then - return count - else - return 0 - end - end, - allow_put = function(inv, listname, index, stack, player) - return 0 - end, - allow_take = function(inv, listname, index, stack, player) - if minetest.is_creative_enabled(player:get_player_name()) then - return -1 - else - return 0 - end - end, - }, playername) - set_inv_page("all", player) -end - --- Create the trash field -local trash = minetest.create_detached_inventory("trash", { - allow_put = function(inv, listname, index, stack, player) - if minetest.is_creative_enabled(player:get_player_name()) then - return stack:get_count() - else - return 0 - end - end, - on_put = function(inv, listname, index, stack, player) - inv:set_stack(listname, index, "") - end, -}) -trash:set_size("main", 1) - -local noffset = {} -- numeric tab offset -local offset = {} -- string offset: -local boffset = {} -- -local hoch = {} -local filtername = {} ---local bg = {} - -local noffset_x_start = -0.24 -local noffset_x = noffset_x_start -local noffset_y = -0.25 -local function next_noffset(id, right) - if right then - noffset[id] = { 8.94, noffset_y } - else - noffset[id] = { noffset_x, noffset_y } - noffset_x = noffset_x + 1.25 - end -end - --- Upper row -next_noffset("blocks") -next_noffset("deco") -next_noffset("redstone") -next_noffset("rail") -next_noffset("brew") -next_noffset("misc") -next_noffset("nix", true) - -noffset_x = noffset_x_start -noffset_y = 8.12 - --- Lower row -next_noffset("food") -next_noffset("tools") -next_noffset("combat") -next_noffset("mobs") -next_noffset("matr") -next_noffset("inv", true) - -for k,v in pairs(noffset) do - offset[k] = tostring(v[1]) .. "," .. tostring(v[2]) - boffset[k] = tostring(v[1]+0.19) .. "," .. tostring(v[2]+0.25) -end - -hoch["blocks"] = "" -hoch["deco"] = "" -hoch["redstone"] = "" -hoch["rail"] = "" -hoch["brew"] = "" -hoch["misc"] = "" -hoch["nix"] = "" -hoch["default"] = "" -hoch["food"] = "_down" -hoch["tools"] = "_down" -hoch["combat"] = "_down" -hoch["mobs"] = "_down" -hoch["matr"] = "_down" -hoch["inv"] = "_down" - -filtername["blocks"] = S("Building Blocks") -filtername["deco"] = S("Decoration Blocks") -filtername["redstone"] = S("Redstone") -filtername["rail"] = S("Transportation") -filtername["misc"] = S("Miscellaneous") -filtername["nix"] = S("Search Items") -filtername["food"] = S("Foodstuffs") -filtername["tools"] = S("Tools") -filtername["combat"] = S("Combat") -filtername["mobs"] = S("Mobs") -filtername["brew"] = S("Brewing") -filtername["matr"] = S("Materials") -filtername["inv"] = S("Survival Inventory") - ---local dark_bg = "crafting_creative_bg_dark.png" - ---[[local function reset_menu_item_bg() - bg["blocks"] = dark_bg - bg["deco"] = dark_bg - bg["redstone"] = dark_bg - bg["rail"] = dark_bg - bg["misc"] = dark_bg - bg["nix"] = dark_bg - bg["food"] = dark_bg - bg["tools"] = dark_bg - bg["combat"] = dark_bg - bg["mobs"] = dark_bg - bg["brew"] = dark_bg - bg["matr"] = dark_bg - bg["inv"] = dark_bg - bg["default"] = dark_bg -end]] - - -function mcl_inventory.set_creative_formspec(player, start_i, pagenum, inv_size, show, page, filter) - --reset_menu_item_bg() - pagenum = math.floor(pagenum) or 1 - - local playername = player:get_player_name() - - if not inv_size then - if page == "nix" then - local inv = minetest.get_inventory({type="detached", name="creative_"..playername}) - inv_size = inv:get_size("main") - elseif page and page ~= "inv" then - inv_size = #(inventory_lists[page]) - else - inv_size = 0 - end - end - local pagemax = math.max(1, math.floor((inv_size-1) / (9*5) + 1)) - local name = "nix" - local main_list - local listrings = "listring[detached:creative_"..playername..";main]".. - "listring[current_player;main]".. - "listring[detached:trash;main]" - - if page then - name = page - if players[playername] then - players[playername].page = page - end - end - --bg[name] = "crafting_creative_bg.png" - - local inv_bg = "crafting_inventory_creative.png" - if name == "inv" then - inv_bg = "crafting_inventory_creative_survival.png" - - -- Show armor and player image - local player_preview - if minetest.settings:get_bool("3d_player_preview", true) then - player_preview = mcl_player.get_player_formspec_model(player, 3.9, 1.4, 1.2333, 2.4666, "") - else - player_preview = "image[3.9,1.4;1.2333,2.4666;"..mcl_player.player_get_preview(player).."]" - end - - -- Background images for armor slots (hide if occupied) - local armor_slot_imgs = "" - local inv = player:get_inventory() - if inv:get_stack("armor", 2):is_empty() then - armor_slot_imgs = armor_slot_imgs .. "image[2.5,1.3;1,1;mcl_inventory_empty_armor_slot_helmet.png]" - end - if inv:get_stack("armor", 3):is_empty() then - armor_slot_imgs = armor_slot_imgs .. "image[2.5,2.75;1,1;mcl_inventory_empty_armor_slot_chestplate.png]" - end - if inv:get_stack("armor", 4):is_empty() then - armor_slot_imgs = armor_slot_imgs .. "image[5.5,1.3;1,1;mcl_inventory_empty_armor_slot_leggings.png]" - end - if inv:get_stack("armor", 5):is_empty() then - armor_slot_imgs = armor_slot_imgs .. "image[5.5,2.75;1,1;mcl_inventory_empty_armor_slot_boots.png]" - end - - -- Survival inventory slots - main_list = "list[current_player;main;0,3.75;9,3;9]".. - mcl_formspec.get_itemslot_bg(0,3.75,9,3).. - -- armor - "list[current_player;armor;2.5,1.3;1,1;1]".. - "list[current_player;armor;2.5,2.75;1,1;2]".. - "list[current_player;armor;5.5,1.3;1,1;3]".. - "list[current_player;armor;5.5,2.75;1,1;4]".. - mcl_formspec.get_itemslot_bg(2.5,1.3,1,1).. - mcl_formspec.get_itemslot_bg(2.5,2.75,1,1).. - mcl_formspec.get_itemslot_bg(5.5,1.3,1,1).. - mcl_formspec.get_itemslot_bg(5.5,2.75,1,1).. - armor_slot_imgs.. - -- player preview - player_preview.. - -- crafting guide button - "image_button[9,1;1,1;craftguide_book.png;__mcl_craftguide;]".. - "tooltip[__mcl_craftguide;"..F(S("Recipe book")).."]".. - -- help button - "image_button[9,2;1,1;doc_button_icon_lores.png;__mcl_doc;]".. - "tooltip[__mcl_doc;"..F(S("Help")).."]".. - -- skins button - "image_button[9,3;1,1;mcl_skins_button.png;__mcl_skins;]".. - "tooltip[__mcl_skins;"..F(S("Select player skin")).."]".. - -- achievements button - "image_button[9,4;1,1;mcl_achievements_button.png;__mcl_achievements;]".. - --"style_type[image_button;border=;bgimg=;bgimg_pressed=]".. - "tooltip[__mcl_achievements;"..F(S("Achievements")).."]" - - -- For shortcuts - listrings = listrings .. - "listring[detached:"..playername.."_armor;armor]".. - "listring[current_player;main]" - else - -- Creative inventory slots - main_list = "list[detached:creative_"..playername..";main;0,1.75;9,5;"..tostring(start_i).."]".. - mcl_formspec.get_itemslot_bg(0,1.75,9,5).. - -- Page buttons - "label[9.0,5.5;"..F(S("@1/@2", pagenum, pagemax)).."]".. - "image_button[9.0,6.0;0.7,0.7;crafting_creative_prev.png;creative_prev;]".. - "image_button[9.5,6.0;0.7,0.7;crafting_creative_next.png;creative_next;]" - end - - local tab_icon = { - blocks = "mcl_core:brick_block", - deco = "mcl_flowers:peony", - redstone = "mesecons:redstone", - rail = "mcl_minecarts:golden_rail", - misc = "mcl_buckets:bucket_lava", - nix = "mcl_compass:compass", - food = "mcl_core:apple", - tools = "mcl_core:axe_iron", - combat = "mcl_core:sword_gold", - mobs = "mobs_mc:cow", - brew = "mcl_potions:dragon_breath", - matr = "mcl_core:stick", - inv = "mcl_chests:chest", - } - local function tab(current_tab, this_tab) - local bg_img - if current_tab == this_tab then - bg_img = "crafting_creative_active"..hoch[this_tab]..".png" - else - bg_img = "crafting_creative_inactive"..hoch[this_tab]..".png" - end - return - "style["..this_tab..";border=false;bgimg=;bgimg_pressed=]".. - "item_image_button[" .. boffset[this_tab] ..";1,1;"..tab_icon[this_tab]..";"..this_tab..";]".. - "image[" .. offset[this_tab] .. ";1.5,1.44;" .. bg_img .. "]" .. - "image[" .. boffset[this_tab] .. ";1,1;crafting_creative_marker.png]" - end - local caption = "" - if name ~= "inv" and filtername[name] then - caption = "label[0,1.2;"..F(minetest.colorize("#313131", filtername[name])).."]" - end - - local formspec = "size[10,9.3]".. - "no_prepend[]".. - mcl_vars.gui_nonbg..mcl_vars.gui_bg_color.. - "background[-0.19,-0.25;10.5,9.87;"..inv_bg.."]".. - "label[-5,-5;"..name.."]".. - tab(name, "blocks") .. - "tooltip[blocks;"..F(filtername["blocks"]).."]".. - tab(name, "deco") .. - "tooltip[deco;"..F(filtername["deco"]).."]".. - tab(name, "redstone") .. - "tooltip[redstone;"..F(filtername["redstone"]).."]".. - tab(name, "rail") .. - "tooltip[rail;"..F(filtername["rail"]).."]".. - tab(name, "misc") .. - "tooltip[misc;"..F(filtername["misc"]).."]".. - tab(name, "nix") .. - "tooltip[nix;"..F(filtername["nix"]).."]".. - caption.. - "list[current_player;main;0,7;9,1;]".. - mcl_formspec.get_itemslot_bg(0,7,9,1).. - main_list.. - tab(name, "food") .. - "tooltip[food;"..F(filtername["food"]).."]".. - tab(name, "tools") .. - "tooltip[tools;"..F(filtername["tools"]).."]".. - tab(name, "combat") .. - "tooltip[combat;"..F(filtername["combat"]).."]".. - tab(name, "mobs") .. - "tooltip[mobs;"..F(filtername["mobs"]).."]".. - tab(name, "brew") .. - "tooltip[brew;"..F(filtername["brew"]).."]".. - tab(name, "matr") .. - "tooltip[matr;"..F(filtername["matr"]).."]".. - tab(name, "inv") .. - "tooltip[inv;"..F(filtername["inv"]).."]".. - "list[detached:trash;main;9,7;1,1;]".. - mcl_formspec.get_itemslot_bg(9,7,1,1).. - "image[9,7;1,1;crafting_creative_trash.png]".. - listrings - - if name == "nix" then - if filter == nil then - filter = "" - end - formspec = formspec .. "field[5.3,1.34;4,0.75;search;;"..minetest.formspec_escape(filter).."]" - formspec = formspec .. "field_close_on_enter[search;false]" - end - if pagenum then formspec = formspec .. "p"..tostring(pagenum) end - player:set_inventory_formspec(formspec) -end - -minetest.register_on_player_receive_fields(function(player, formname, fields) - local page = nil - - if not minetest.is_creative_enabled(player:get_player_name()) then - return - end - if formname ~= "" or fields.quit == "true" then - -- No-op if formspec closed or not player inventory (formname == "") - return - end - - local name = player:get_player_name() - - if fields.blocks then - if players[name].page == "blocks" then return end - set_inv_page("blocks",player) - page = "blocks" - elseif fields.deco then - if players[name].page == "deco" then return end - set_inv_page("deco",player) - page = "deco" - elseif fields.redstone then - if players[name].page == "redstone" then return end - set_inv_page("redstone",player) - page = "redstone" - elseif fields.rail then - if players[name].page == "rail" then return end - set_inv_page("rail",player) - page = "rail" - elseif fields.misc then - if players[name].page == "misc" then return end - set_inv_page("misc",player) - page = "misc" - elseif fields.nix then - set_inv_page("all",player) - page = "nix" - elseif fields.food then - if players[name].page == "food" then return end - set_inv_page("food",player) - page = "food" - elseif fields.tools then - if players[name].page == "tools" then return end - set_inv_page("tools",player) - page = "tools" - elseif fields.combat then - if players[name].page == "combat" then return end - set_inv_page("combat",player) - page = "combat" - elseif fields.mobs then - if players[name].page == "mobs" then return end - set_inv_page("mobs",player) - page = "mobs" - elseif fields.brew then - if players[name].page == "brew" then return end - set_inv_page("brew",player) - page = "brew" - elseif fields.matr then - if players[name].page == "matr" then return end - set_inv_page("matr",player) - page = "matr" - elseif fields.inv then - if players[name].page == "inv" then return end - page = "inv" - elseif fields.search == "" and not fields.creative_next and not fields.creative_prev then - set_inv_page("all", player) - page = "nix" - elseif fields.search and not fields.creative_next and not fields.creative_prev then - set_inv_search(string.lower(fields.search),player) - page = "nix" - end - - if page then - players[name].page = page - end - if players[name].page then - page = players[name].page - end - - -- Figure out current scroll bar from formspec - --local formspec = player:get_inventory_formspec() - - local start_i = players[name].start_i - - if fields.creative_prev then - start_i = start_i - 9*5 - elseif fields.creative_next then - start_i = start_i + 9*5 - else - -- Reset scroll bar if not scrolled - start_i = 0 - end - if start_i < 0 then - start_i = start_i + 9*5 - end - - local inv_size - if page == "nix" then - local inv = minetest.get_inventory({type="detached", name="creative_"..name}) - inv_size = inv:get_size("main") - elseif page and page ~= "inv" then - inv_size = #(inventory_lists[page]) - else - inv_size = 0 - end - - if start_i >= inv_size then - start_i = start_i - 9*5 - end - if start_i < 0 or start_i >= inv_size then - start_i = 0 - end - players[name].start_i = start_i - - local filter = "" - if not fields.nix and fields.search and fields.search ~= "" then - filter = fields.search - players[name].filter = filter - end - - mcl_inventory.set_creative_formspec(player, start_i, start_i / (9*5) + 1, inv_size, false, page, filter) -end) - - -if minetest.is_creative_enabled("") then - minetest.register_on_placenode(function(pos, newnode, placer, oldnode, itemstack) - -- Place infinite nodes, except for shulker boxes - local group = minetest.get_item_group(itemstack:get_name(), "shulker_box") - return group == 0 or group == nil - end) - - function minetest.handle_node_drops(pos, drops, digger) - if not digger or not digger:is_player() then - for _,item in ipairs(drops) do - minetest.add_item(pos, item) - end - end - local inv = digger:get_inventory() - if inv then - for _,item in ipairs(drops) do - if not inv:contains_item("main", item, true) then - inv:add_item("main", item) - end - end - end - end - - mcl_inventory.update_inventory_formspec = function(player) - local page - - local name = player:get_player_name() - - if players[name].page then - page = players[name].page - else - page = "nix" - end - - -- Figure out current scroll bar from formspec - --local formspec = player:get_inventory_formspec() - local start_i = players[name].start_i - - local inv_size - if page == "nix" then - local inv = minetest.get_inventory({type="detached", name="creative_"..name}) - inv_size = inv:get_size("main") - elseif page and page ~= "inv" then - inv_size = #(inventory_lists[page]) - else - inv_size = 0 - end - - local filter = players[name].filter - if filter == nil then - filter = "" - end - - mcl_inventory.set_creative_formspec(player, start_i, start_i / (9*5) + 1, inv_size, false, page, filter) - end -end - -minetest.register_on_joinplayer(function(player) - -- Initialize variables and inventory - local name = player:get_player_name() - if not players[name] then - players[name] = {} - players[name].page = "nix" - players[name].filter = "" - players[name].start_i = 0 - end - init(player) - mcl_inventory.set_creative_formspec(player, 0, 1, nil, false, "nix", "") -end) +local S = minetest.get_translator(minetest.get_current_modname()) +local F = minetest.formspec_escape +local C = minetest.colorize + +-- Prepare player info table +local players = {} + +-- Containing all the items for each Creative Mode tab +local inventory_lists = {} + +--local mod_player = minetest.get_modpath("mcl_player") + +-- Create tables +local builtin_filter_ids = {"blocks","deco","redstone","rail","food","tools","combat","mobs","brew","matr","misc","all"} +for _, f in pairs(builtin_filter_ids) do + inventory_lists[f] = {} +end + +local function replace_enchanted_books(tbl) + for k, item in ipairs(tbl) do + if item:find("mcl_enchanting:book_enchanted") == 1 then + local _, enchantment, level = item:match("(%a+) ([_%w]+) (%d+)") + level = level and tonumber(level) + if enchantment and level then + tbl[k] = mcl_enchanting.enchant(ItemStack("mcl_enchanting:book_enchanted"), enchantment, level) + end + end + end +end + +--[[ Populate all the item tables. We only do this once. Note this code must be +executed after loading all the other mods in order to work. ]] +minetest.register_on_mods_loaded(function() + for name,def in pairs(minetest.registered_items) do + if (not def.groups.not_in_creative_inventory or def.groups.not_in_creative_inventory == 0) and def.description and def.description ~= "" then + local function is_redstone(def) + return def.mesecons or def.groups.mesecon or def.groups.mesecon_conductor_craftable or def.groups.mesecon_effecor_off + end + local function is_tool(def) + return def.groups.tool or (def.tool_capabilities and def.tool_capabilities.damage_groups == nil) + end + local function is_weapon_or_armor(def) + return def.groups.weapon or def.groups.weapon_ranged or def.groups.ammo or def.groups.combat_item or ((def.groups.armor_head or def.groups.armor_torso or def.groups.armor_legs or def.groups.armor_feet or def.groups.horse_armor) and def.groups.non_combat_armor ~= 1) + end + -- Is set to true if it was added in any category besides misc + local nonmisc = false + if def.groups.building_block then + table.insert(inventory_lists["blocks"], name) + nonmisc = true + end + if def.groups.deco_block then + table.insert(inventory_lists["deco"], name) + nonmisc = true + end + if is_redstone(def) then + table.insert(inventory_lists["redstone"], name) + nonmisc = true + end + if def.groups.transport then + table.insert(inventory_lists["rail"], name) + nonmisc = true + end + if (def.groups.food and not def.groups.brewitem) or def.groups.eatable then + table.insert(inventory_lists["food"], name) + nonmisc = true + end + if is_tool(def) then + table.insert(inventory_lists["tools"], name) + nonmisc = true + end + if is_weapon_or_armor(def) then + table.insert(inventory_lists["combat"], name) + nonmisc = true + end + if def.groups.spawn_egg == 1 then + table.insert(inventory_lists["mobs"], name) + nonmisc = true + end + if def.groups.brewitem then + table.insert(inventory_lists["brew"], name) + nonmisc = true + end + if def.groups.craftitem then + table.insert(inventory_lists["matr"], name) + nonmisc = true + end + -- Misc. category is for everything which is not in any other category + if not nonmisc then + table.insert(inventory_lists["misc"], name) + end + + table.insert(inventory_lists["all"], name) + end + end + + for ench, def in pairs(mcl_enchanting.enchantments) do + local str = "mcl_enchanting:book_enchanted " .. ench .. " " .. def.max_level + if def.inv_tool_tab then + table.insert(inventory_lists["tools"], str) + end + if def.inv_combat_tab then + table.insert(inventory_lists["combat"], str) + end + table.insert(inventory_lists["all"], str) + end + + for _, to_sort in pairs(inventory_lists) do + table.sort(to_sort) + replace_enchanted_books(to_sort) + end +end) + +local function filter_item(name, description, lang, filter) + local desc + if not lang then + desc = string.lower(description) + else + desc = string.lower(minetest.get_translated_string(lang, description)) + end + return string.find(name, filter) or string.find(desc, filter) +end + +local function set_inv_search(filter, player) + local playername = player:get_player_name() + local inv = minetest.get_inventory({type="detached", name="creative_"..playername}) + local creative_list = {} + local lang = minetest.get_player_information(playername).lang_code + for name,def in pairs(minetest.registered_items) do + if (not def.groups.not_in_creative_inventory or def.groups.not_in_creative_inventory == 0) and def.description and def.description ~= "" then + if filter_item(string.lower(def.name), def.description, lang, filter) then + table.insert(creative_list, name) + end + end + end + for ench, def in pairs(mcl_enchanting.enchantments) do + for i = 1, def.max_level do + local stack = mcl_enchanting.enchant(ItemStack("mcl_enchanting:book_enchanted"), ench, i) + if filter_item("mcl_enchanting:book_enchanted", minetest.strip_colors(stack:get_description()), lang, filter) then + table.insert(creative_list, "mcl_enchanting:book_enchanted " .. ench .. " " .. i) + end + end + end + table.sort(creative_list) + replace_enchanted_books(creative_list) + + inv:set_size("main", #creative_list) + inv:set_list("main", creative_list) +end + +local function set_inv_page(page, player) + local playername = player:get_player_name() + local inv = minetest.get_inventory({type="detached", name="creative_"..playername}) + inv:set_size("main", 0) + local creative_list = {} + if inventory_lists[page] then -- Standard filter + creative_list = inventory_lists[page] + end + inv:set_size("main", #creative_list) + inv:set_list("main", creative_list) +end + +local function init(player) + local playername = player:get_player_name() + minetest.create_detached_inventory("creative_"..playername, { + allow_move = function(inv, from_list, from_index, to_list, to_index, count, player) + if minetest.is_creative_enabled(playername) then + return count + else + return 0 + end + end, + allow_put = function(inv, listname, index, stack, player) + return 0 + end, + allow_take = function(inv, listname, index, stack, player) + if minetest.is_creative_enabled(player:get_player_name()) then + return -1 + else + return 0 + end + end, + }, playername) + set_inv_page("all", player) +end + +-- Create the trash field +local trash = minetest.create_detached_inventory("trash", { + allow_put = function(inv, listname, index, stack, player) + if minetest.is_creative_enabled(player:get_player_name()) then + return stack:get_count() + else + return 0 + end + end, + on_put = function(inv, listname, index, stack, player) + inv:set_stack(listname, index, "") + end, +}) +trash:set_size("main", 1) + +local noffset = {} -- numeric tab offset +local offset = {} -- string offset: +local boffset = {} -- +local hoch = {} +local filtername = {} +--local bg = {} + +local noffset_x_start = -0.24 +local noffset_x = noffset_x_start +local noffset_y = -0.25 +local function next_noffset(id, right) + if right then + noffset[id] = { 8.94, noffset_y } + else + noffset[id] = { noffset_x, noffset_y } + noffset_x = noffset_x + 1.25 + end +end + +-- Upper row +next_noffset("blocks") +next_noffset("deco") +next_noffset("redstone") +next_noffset("rail") +next_noffset("brew") +next_noffset("misc") +next_noffset("nix", true) + +noffset_x = noffset_x_start +noffset_y = 8.12 + +-- Lower row +next_noffset("food") +next_noffset("tools") +next_noffset("combat") +next_noffset("mobs") +next_noffset("matr") +next_noffset("inv", true) + +for k,v in pairs(noffset) do + offset[k] = tostring(v[1]) .. "," .. tostring(v[2]) + boffset[k] = tostring(v[1]+0.19) .. "," .. tostring(v[2]+0.25) +end + +hoch["blocks"] = "" +hoch["deco"] = "" +hoch["redstone"] = "" +hoch["rail"] = "" +hoch["brew"] = "" +hoch["misc"] = "" +hoch["nix"] = "" +hoch["default"] = "" +hoch["food"] = "_down" +hoch["tools"] = "_down" +hoch["combat"] = "_down" +hoch["mobs"] = "_down" +hoch["matr"] = "_down" +hoch["inv"] = "_down" + +filtername["blocks"] = S("Building Blocks") +filtername["deco"] = S("Decoration Blocks") +filtername["redstone"] = S("Redstone") +filtername["rail"] = S("Transportation") +filtername["misc"] = S("Miscellaneous") +filtername["nix"] = S("Search Items") +filtername["food"] = S("Foodstuffs") +filtername["tools"] = S("Tools") +filtername["combat"] = S("Combat") +filtername["mobs"] = S("Mobs") +filtername["brew"] = S("Brewing") +filtername["matr"] = S("Materials") +filtername["inv"] = S("Survival Inventory") + +--local dark_bg = "crafting_creative_bg_dark.png" + +--[[local function reset_menu_item_bg() + bg["blocks"] = dark_bg + bg["deco"] = dark_bg + bg["redstone"] = dark_bg + bg["rail"] = dark_bg + bg["misc"] = dark_bg + bg["nix"] = dark_bg + bg["food"] = dark_bg + bg["tools"] = dark_bg + bg["combat"] = dark_bg + bg["mobs"] = dark_bg + bg["brew"] = dark_bg + bg["matr"] = dark_bg + bg["inv"] = dark_bg + bg["default"] = dark_bg +end]] + +local function get_stack_size(player) + return player:get_meta():get_int("mcl_inventory:switch_stack") +end + +local function set_stack_size(player, n) + player:get_meta():set_int("mcl_inventory:switch_stack", n) +end + +minetest.register_on_joinplayer(function (player) + if get_stack_size(player) == 0 then + set_stack_size(player, 64) + end +end) + +function mcl_inventory.set_creative_formspec(player, start_i, pagenum, inv_size, show, page, filter) + --reset_menu_item_bg() + pagenum = math.floor(pagenum) or 1 + + local playername = player:get_player_name() + + if not inv_size then + if page == "nix" then + local inv = minetest.get_inventory({type="detached", name="creative_"..playername}) + inv_size = inv:get_size("main") + elseif page and page ~= "inv" then + inv_size = #(inventory_lists[page]) + else + inv_size = 0 + end + end + local pagemax = math.max(1, math.floor((inv_size-1) / (9*5) + 1)) + local name = "nix" + local main_list + local listrings = "listring[detached:creative_"..playername..";main]".. + "listring[current_player;main]".. + "listring[detached:trash;main]" + + if page then + name = page + if players[playername] then + players[playername].page = page + end + end + --bg[name] = "crafting_creative_bg.png" + + local inv_bg = "crafting_inventory_creative.png" + if name == "inv" then + inv_bg = "crafting_inventory_creative_survival.png" + + -- Show armor and player image + local player_preview + if minetest.settings:get_bool("3d_player_preview", true) then + player_preview = mcl_player.get_player_formspec_model(player, 3.9, 1.4, 1.2333, 2.4666, "") + else + player_preview = "image[3.9,1.4;1.2333,2.4666;"..mcl_player.player_get_preview(player).."]" + end + + -- Background images for armor slots (hide if occupied) + local armor_slot_imgs = "" + local inv = player:get_inventory() + if inv:get_stack("armor", 2):is_empty() then + armor_slot_imgs = armor_slot_imgs .. "image[2.5,1.3;1,1;mcl_inventory_empty_armor_slot_helmet.png]" + end + if inv:get_stack("armor", 3):is_empty() then + armor_slot_imgs = armor_slot_imgs .. "image[2.5,2.75;1,1;mcl_inventory_empty_armor_slot_chestplate.png]" + end + if inv:get_stack("armor", 4):is_empty() then + armor_slot_imgs = armor_slot_imgs .. "image[5.5,1.3;1,1;mcl_inventory_empty_armor_slot_leggings.png]" + end + if inv:get_stack("armor", 5):is_empty() then + armor_slot_imgs = armor_slot_imgs .. "image[5.5,2.75;1,1;mcl_inventory_empty_armor_slot_boots.png]" + end + + local stack_size = get_stack_size(player) + + -- Survival inventory slots + main_list = "list[current_player;main;0,3.75;9,3;9]".. + mcl_formspec.get_itemslot_bg(0,3.75,9,3).. + -- armor + "list[current_player;armor;2.5,1.3;1,1;1]".. + "list[current_player;armor;2.5,2.75;1,1;2]".. + "list[current_player;armor;5.5,1.3;1,1;3]".. + "list[current_player;armor;5.5,2.75;1,1;4]".. + mcl_formspec.get_itemslot_bg(2.5,1.3,1,1).. + mcl_formspec.get_itemslot_bg(2.5,2.75,1,1).. + mcl_formspec.get_itemslot_bg(5.5,1.3,1,1).. + mcl_formspec.get_itemslot_bg(5.5,2.75,1,1).. + armor_slot_imgs.. + -- player preview + player_preview.. + -- crafting guide button + "image_button[9,1;1,1;craftguide_book.png;__mcl_craftguide;]".. + "tooltip[__mcl_craftguide;"..F(S("Recipe book")).."]".. + -- help button + "image_button[9,2;1,1;doc_button_icon_lores.png;__mcl_doc;]".. + "tooltip[__mcl_doc;"..F(S("Help")).."]".. + -- skins button + "image_button[9,3;1,1;mcl_skins_button.png;__mcl_skins;]".. + "tooltip[__mcl_skins;"..F(S("Select player skin")).."]".. + -- achievements button + "image_button[9,4;1,1;mcl_achievements_button.png;__mcl_achievements;]".. + --"style_type[image_button;border=;bgimg=;bgimg_pressed=]".. + "tooltip[__mcl_achievements;"..F(S("Achievements")).."]".. + -- switch stack size button + "image_button[9,5;1,1;default_apple.png;__switch_stack;]".. + "label[9.4,5.4;".. F(C("#FFFFFF", stack_size ~= 1 and stack_size or "")) .."]".. + "tooltip[__switch_stack;"..F(S("Switch stack size")).."]" + + -- For shortcuts + listrings = listrings .. + "listring[detached:"..playername.."_armor;armor]".. + "listring[current_player;main]" + else + -- Creative inventory slots + main_list = "list[detached:creative_"..playername..";main;0,1.75;9,5;"..tostring(start_i).."]".. + mcl_formspec.get_itemslot_bg(0,1.75,9,5).. + -- Page buttons + "label[9.0,5.5;"..F(S("@1/@2", pagenum, pagemax)).."]".. + "image_button[9.0,6.0;0.7,0.7;crafting_creative_prev.png;creative_prev;]".. + "image_button[9.5,6.0;0.7,0.7;crafting_creative_next.png;creative_next;]" + end + + local tab_icon = { + blocks = "mcl_core:brick_block", + deco = "mcl_flowers:peony", + redstone = "mesecons:redstone", + rail = "mcl_minecarts:golden_rail", + misc = "mcl_buckets:bucket_lava", + nix = "mcl_compass:compass", + food = "mcl_core:apple", + tools = "mcl_core:axe_iron", + combat = "mcl_core:sword_gold", + mobs = "mobs_mc:cow", + brew = "mcl_potions:dragon_breath", + matr = "mcl_core:stick", + inv = "mcl_chests:chest", + } + local function tab(current_tab, this_tab) + local bg_img + if current_tab == this_tab then + bg_img = "crafting_creative_active"..hoch[this_tab]..".png" + else + bg_img = "crafting_creative_inactive"..hoch[this_tab]..".png" + end + return + "style["..this_tab..";border=false;bgimg=;bgimg_pressed=]".. + "item_image_button[" .. boffset[this_tab] ..";1,1;"..tab_icon[this_tab]..";"..this_tab..";]".. + "image[" .. offset[this_tab] .. ";1.5,1.44;" .. bg_img .. "]" + end + local caption = "" + if name ~= "inv" and filtername[name] then + caption = "label[0,1.2;"..F(minetest.colorize("#313131", filtername[name])).."]" + end + + local formspec = "size[10,9.3]".. + "no_prepend[]".. + mcl_vars.gui_nonbg..mcl_vars.gui_bg_color.. + "background[-0.19,-0.25;10.5,9.87;"..inv_bg.."]".. + "label[-5,-5;"..name.."]".. + tab(name, "blocks") .. + "tooltip[blocks;"..F(filtername["blocks"]).."]".. + tab(name, "deco") .. + "tooltip[deco;"..F(filtername["deco"]).."]".. + tab(name, "redstone") .. + "tooltip[redstone;"..F(filtername["redstone"]).."]".. + tab(name, "rail") .. + "tooltip[rail;"..F(filtername["rail"]).."]".. + tab(name, "misc") .. + "tooltip[misc;"..F(filtername["misc"]).."]".. + tab(name, "nix") .. + "tooltip[nix;"..F(filtername["nix"]).."]".. + caption.. + "list[current_player;main;0,7;9,1;]".. + mcl_formspec.get_itemslot_bg(0,7,9,1).. + main_list.. + tab(name, "food") .. + "tooltip[food;"..F(filtername["food"]).."]".. + tab(name, "tools") .. + "tooltip[tools;"..F(filtername["tools"]).."]".. + tab(name, "combat") .. + "tooltip[combat;"..F(filtername["combat"]).."]".. + tab(name, "mobs") .. + "tooltip[mobs;"..F(filtername["mobs"]).."]".. + tab(name, "brew") .. + "tooltip[brew;"..F(filtername["brew"]).."]".. + tab(name, "matr") .. + "tooltip[matr;"..F(filtername["matr"]).."]".. + tab(name, "inv") .. + "tooltip[inv;"..F(filtername["inv"]).."]".. + "list[detached:trash;main;9,7;1,1;]".. + mcl_formspec.get_itemslot_bg(9,7,1,1).. + "image[9,7;1,1;crafting_creative_trash.png]".. + listrings + + if name == "nix" then + if filter == nil then + filter = "" + end + formspec = formspec .. "field[5.3,1.34;4,0.75;search;;"..minetest.formspec_escape(filter).."]" + formspec = formspec .. "field_close_on_enter[search;false]" + end + if pagenum then formspec = formspec .. "p"..tostring(pagenum) end + player:set_inventory_formspec(formspec) +end + +minetest.register_on_player_receive_fields(function(player, formname, fields) + local page = nil + + if not minetest.is_creative_enabled(player:get_player_name()) then + return + end + if formname ~= "" or fields.quit == "true" then + -- No-op if formspec closed or not player inventory (formname == "") + return + end + + local name = player:get_player_name() + + if fields.blocks then + if players[name].page == "blocks" then return end + set_inv_page("blocks",player) + page = "blocks" + elseif fields.deco then + if players[name].page == "deco" then return end + set_inv_page("deco",player) + page = "deco" + elseif fields.redstone then + if players[name].page == "redstone" then return end + set_inv_page("redstone",player) + page = "redstone" + elseif fields.rail then + if players[name].page == "rail" then return end + set_inv_page("rail",player) + page = "rail" + elseif fields.misc then + if players[name].page == "misc" then return end + set_inv_page("misc",player) + page = "misc" + elseif fields.nix then + set_inv_page("all",player) + page = "nix" + elseif fields.food then + if players[name].page == "food" then return end + set_inv_page("food",player) + page = "food" + elseif fields.tools then + if players[name].page == "tools" then return end + set_inv_page("tools",player) + page = "tools" + elseif fields.combat then + if players[name].page == "combat" then return end + set_inv_page("combat",player) + page = "combat" + elseif fields.mobs then + if players[name].page == "mobs" then return end + set_inv_page("mobs",player) + page = "mobs" + elseif fields.brew then + if players[name].page == "brew" then return end + set_inv_page("brew",player) + page = "brew" + elseif fields.matr then + if players[name].page == "matr" then return end + set_inv_page("matr",player) + page = "matr" + elseif fields.inv then + if players[name].page == "inv" then return end + page = "inv" + elseif fields.search == "" and not fields.creative_next and not fields.creative_prev then + set_inv_page("all", player) + page = "nix" + elseif fields.search and not fields.creative_next and not fields.creative_prev then + set_inv_search(string.lower(fields.search),player) + page = "nix" + elseif fields.__switch_stack then + local switch = 1 + if get_stack_size(player) == 1 then + switch = 64 + end + set_stack_size(player, switch) + end + + if page then + players[name].page = page + end + if players[name].page then + page = players[name].page + end + + -- Figure out current scroll bar from formspec + --local formspec = player:get_inventory_formspec() + + local start_i = players[name].start_i + + if fields.creative_prev then + start_i = start_i - 9*5 + elseif fields.creative_next then + start_i = start_i + 9*5 + else + -- Reset scroll bar if not scrolled + start_i = 0 + end + if start_i < 0 then + start_i = start_i + 9*5 + end + + local inv_size + if page == "nix" then + local inv = minetest.get_inventory({type="detached", name="creative_"..name}) + inv_size = inv:get_size("main") + elseif page and page ~= "inv" then + inv_size = #(inventory_lists[page]) + else + inv_size = 0 + end + + if start_i >= inv_size then + start_i = start_i - 9*5 + end + if start_i < 0 or start_i >= inv_size then + start_i = 0 + end + players[name].start_i = start_i + + local filter = "" + if not fields.nix and fields.search and fields.search ~= "" then + filter = fields.search + players[name].filter = filter + end + + mcl_inventory.set_creative_formspec(player, start_i, start_i / (9*5) + 1, inv_size, false, page, filter) +end) + + +if minetest.is_creative_enabled("") then + minetest.register_on_placenode(function(pos, newnode, placer, oldnode, itemstack) + -- Place infinite nodes, except for shulker boxes + local group = minetest.get_item_group(itemstack:get_name(), "shulker_box") + return group == 0 or group == nil + end) + + function minetest.handle_node_drops(pos, drops, digger) + if not digger or not digger:is_player() then + for _,item in ipairs(drops) do + minetest.add_item(pos, item) + end + end + local inv = digger:get_inventory() + if inv then + for _,item in ipairs(drops) do + if not inv:contains_item("main", item, true) then + inv:add_item("main", item) + end + end + end + end + + mcl_inventory.update_inventory_formspec = function(player) + local page + + local name = player:get_player_name() + + if players[name].page then + page = players[name].page + else + page = "nix" + end + + -- Figure out current scroll bar from formspec + --local formspec = player:get_inventory_formspec() + local start_i = players[name].start_i + + local inv_size + if page == "nix" then + local inv = minetest.get_inventory({type="detached", name="creative_"..name}) + inv_size = inv:get_size("main") + elseif page and page ~= "inv" then + inv_size = #(inventory_lists[page]) + else + inv_size = 0 + end + + local filter = players[name].filter + if filter == nil then + filter = "" + end + + mcl_inventory.set_creative_formspec(player, start_i, start_i / (9*5) + 1, inv_size, false, page, filter) + end +end + +minetest.register_on_joinplayer(function(player) + -- Initialize variables and inventory + local name = player:get_player_name() + if not players[name] then + players[name] = {} + players[name].page = "nix" + players[name].filter = "" + players[name].start_i = 0 + end + init(player) + mcl_inventory.set_creative_formspec(player, 0, 1, nil, false, "nix", "") +end) + +minetest.register_on_player_inventory_action(function(player, action, inventory, inventory_info) + if minetest.is_creative_enabled(player:get_player_name()) and get_stack_size(player) == 64 and action == "put" and inventory_info.listname == "main" then + local stack = inventory_info.stack + stack:set_count(stack:get_stack_max()) + player:get_inventory():set_stack("main", inventory_info.index, stack) + end +end) diff --git a/mods/HUD/mcl_inventory/mod.conf b/mods/HUD/mcl_inventory/mod.conf index 7585d9f70..10e669265 100644 --- a/mods/HUD/mcl_inventory/mod.conf +++ b/mods/HUD/mcl_inventory/mod.conf @@ -1,6 +1,5 @@ name = mcl_inventory author = BlockMen description = Adds the player inventory and creative inventory. -depends = mcl_init, mcl_formspec, mcl_player -optional_depends = _mcl_autogroup, mcl_armor, mcl_brewing, mcl_potions, mcl_enchanting, mcl_craftguide - +depends = mcl_init, mcl_formspec, mcl_enchanting +optional_depends = mcl_armor, mcl_brewing, mcl_potions, mcl_enchanting, mcl_craftguide, mcl_player diff --git a/mods/HUD/mcl_title/API.md b/mods/HUD/mcl_title/API.md new file mode 100644 index 000000000..37f1c279f --- /dev/null +++ b/mods/HUD/mcl_title/API.md @@ -0,0 +1,50 @@ +# mcl_title + +Allow mods to show messages in the hud of players. + +## mcl_title.set(player, type, data) + +Show a hud message of `type` to player `player` with `data` as params. + +The element will stay for the per-player param `stay` or `data.stay` (in gametick which is 1/20 second). + +Here is a usage exemple: + +```lua +--show a title in the HUD with minecraft color "gold" +mcl_title.set(player, "title", {text="dummy text", color="gold"}) + +--show a subtitle in the HUD with hex color "#612D2D" +mcl_title.set(player, "subtitle", {text="dummy subtitle", color="#612D2D"}) + +--show an actionbar in the HUD (above the hotbar) with minecraft color "red" +mcl_title.set(player, "subtitle", {text="dummy actionbar", color="red"}) + +--show a title in the HUD with minecraft color "gold" staying for 3 seconds (override stay setting) +mcl_title.set(player, "title", {text="dummy text", color="gold", stay=60}) +``` + +## mcl_title.remove(player, type) + +Hide HUD element of type `type` for player `player`. + +## mcl_title.clear(player) + +Remove every title/subtitle/actionbar from a player. +Basicaly run `mcl_title.remove(player, type)` for every type. + +## mcl_title.params_set(player, params) + +Allow mods to set `stay` and upcomming `fadeIn`/`fadeOut` params. + +```lua +mcl_title.params_set(player, {stay = 600}) --elements with no 'data.stay' field will stay during 30s (600/20) +``` + +## mcl_title.params_get(player) + +Get `stay` and upcomming `fadeIn` and `fadeOut` params of a player as a table. + +```lua +mcl_title.params_get(player) +``` \ No newline at end of file diff --git a/mods/HUD/mcl_title/init.lua b/mods/HUD/mcl_title/init.lua new file mode 100644 index 000000000..2ea1571c8 --- /dev/null +++ b/mods/HUD/mcl_title/init.lua @@ -0,0 +1,236 @@ +--Based on: +--https://www.digminecraft.com/game_commands/title_command.php +--https://youtu.be/oVrtQRO2hpY + +--TODO: use SSCSM to reduce lag and network trafic (just send modchannel messages) +--TODO: fadeIn and fadeOut animation (needs engine change: SSCSM or native support) +--TODO: allow obfuscating text (needs engine change: SSCSM or native support) +--TODO: allow colorizing and styling of part of the text (NEEDS ENGINE CHANGE!!!) +--TODO: exactly mc like layout + +--Note that the table storing timeouts use playername as index insteed of player objects (faster) +--This is intended in order to speedup the process of removing HUD elements the the timeout is up + +local huds_idx = {} + +local hud_hide_timeouts = {} + +hud_hide_timeouts.title = {} +hud_hide_timeouts.subtitle = {} +hud_hide_timeouts.actionbar = {} + +huds_idx.title = {} +huds_idx.subtitle = {} +huds_idx.actionbar = {} + +mcl_title = {} +mcl_title.defaults = {fadein = 10, stay = 70, fadeout = 20} +mcl_title.layout = {} +mcl_title.layout.title = {position = {x = 0.5, y = 0.5}, alignment = {x = 0, y = -1.3}, size = 7} +mcl_title.layout.subtitle = {position = {x = 0.5, y = 0.5}, alignment = {x = 0, y = 1.7}, size = 4} +mcl_title.layout.actionbar = {position = {x = 0.5, y = 1}, alignment = {x = 0, y = 0}, size = 1} + +local get_color = mcl_util.get_color + +--local string = string +local pairs = pairs + +local function gametick_to_secondes(gametick) + if gametick then + return gametick / 20 + else + return nil + end +end + +--https://github.com/minetest/minetest/blob/b3b075ea02034306256b486dd45410aa765f035a/doc/lua_api.txt#L8477 +--[[ +local function style_to_bits(bold, italic) + if bold then + if italic then + return 3 + else + return 1 + end + else + if italic then + return 2 + else + return 0 + end + end +end +]] + +--PARAMS SYSTEM +local player_params = {} + +minetest.register_on_joinplayer(function(player) + --local playername = player:get_player_name() + player_params[player] = { + stay = mcl_title.defaults.stay, + --fadeIn = mcl_title.defaults.fadein, + --fadeOut = mcl_title.defaults.fadeout, + } + local _, hex_color = get_color("white") + huds_idx.title[player] = player:hud_add({ + hud_elem_type = "text", + position = mcl_title.layout.title.position, + alignment = mcl_title.layout.title.alignment, + text = "", + --style = 0, + size = {x = mcl_title.layout.title.size}, + number = hex_color, + z_index = 100, + }) + huds_idx.subtitle[player] = player:hud_add({ + hud_elem_type = "text", + position = mcl_title.layout.subtitle.position, + alignment = mcl_title.layout.subtitle.alignment, + text = "", + --style = 0, + size = {x = mcl_title.layout.subtitle.size}, + number = hex_color, + z_index = 100, + }) + huds_idx.actionbar[player] = player:hud_add({ + hud_elem_type = "text", + position = mcl_title.layout.actionbar.position, + offset = {x = 0, y = -210}, + alignment = mcl_title.layout.actionbar.alignment, + --style = 0, + text = "", + size = {x = mcl_title.layout.actionbar.size}, + number = hex_color, + z_index = 100, + }) +end) + +minetest.register_on_leaveplayer(function(player) + local playername = player:get_player_name() + + --remove player params from the list + player_params[player] = nil + + --remove HUD idx from the list (HUD elements are removed by the engine) + huds_idx.title[player] = nil + huds_idx.subtitle[player] = nil + huds_idx.actionbar[player] = nil + + --remove timers from list + hud_hide_timeouts.title[playername] = nil + hud_hide_timeouts.subtitle[playername] = nil + hud_hide_timeouts.actionbar[playername] = nil +end) + +function mcl_title.params_set(player, data) + player_params[player] = { + stay = data.stay or mcl_title.defaults.stay, + --fadeIn = data.fadeIn or mcl_title.defaults.fadein, + --fadeOut = data.fadeOut or mcl_title.defaults.fadeout, + } +end + +function mcl_title.params_get(player) + return player_params[player] +end + +--API FUNCTIONS + +function mcl_title.set(player, type, data) + if not data.color then + data.color = "white" + end + local _, hex_color = get_color(data.color) + if not hex_color then + return false + end + + player:hud_change(huds_idx[type][player], "text", data.text) + player:hud_change(huds_idx[type][player], "number", hex_color) + + --apply bold and italic + --player:hud_change(huds_idx[type][player], "style", style_to_bits(data.bold, data.italic)) + + hud_hide_timeouts[type][player:get_player_name()] = gametick_to_secondes(data.stay) or gametick_to_secondes(mcl_title.params_get(player).stay) + return true +end + +function mcl_title.remove(player, type) + if player then + player:hud_change(huds_idx[type][player], "text", "") + --player:hud_change(huds_idx[type][player], "style", 0) --no styling + end +end + +function mcl_title.clear(player) + mcl_title.remove(player, "title") + mcl_title.remove(player, "subtitle") + mcl_title.remove(player, "actionbar") +end + +minetest.register_on_dieplayer(function(player) + mcl_title.clear(player) +end) + +minetest.register_globalstep(function(dtime) + local new_timeouts = { + title = {}, + subtitle = {}, + actionbar = {}, + } + for element, content in pairs(hud_hide_timeouts) do + for name, timeout in pairs(content) do + timeout = timeout - dtime + if timeout <= 0 then + local player = minetest.get_player_by_name(name) + mcl_title.remove(player, element) + else + new_timeouts[element][name] = timeout + end + end + end + hud_hide_timeouts = new_timeouts +end) + + +--DEBUG STUFF!! +--[[ +minetest.register_chatcommand("title", { + func = function(name, param) + local player = minetest.get_player_by_name(name) + mcl_title.set(player, "title", {text=param, color="gold", bold=true, italic=true}) + end, +}) + +minetest.register_chatcommand("subtitle", { + func = function(name, param) + local player = minetest.get_player_by_name(name) + mcl_title.set(player, "subtitle", {text=param, color="gold"}) + end, +}) + +minetest.register_chatcommand("actionbar", { + func = function(name, param) + local player = minetest.get_player_by_name(name) + mcl_title.set(player, "actionbar", {text=param, color="gold"}) + end, +}) + +minetest.register_chatcommand("timeout", { + func = function(name, param) + local player = minetest.get_player_by_name(name) + mcl_title.params_set(player, {stay = 600}) + end, +}) + +minetest.register_chatcommand("all", { + func = function(name, param) + local player = minetest.get_player_by_name(name) + mcl_title.params_set(player, {stay = 600}) + mcl_title.set(player, "title", {text=param, color="gold"}) + mcl_title.set(player, "subtitle", {text=param, color="gold"}) + mcl_title.set(player, "actionbar", {text=param, color="gold"}) + end, +}) +]] \ No newline at end of file diff --git a/mods/HUD/mcl_title/mod.conf b/mods/HUD/mcl_title/mod.conf new file mode 100644 index 000000000..0f29a8118 --- /dev/null +++ b/mods/HUD/mcl_title/mod.conf @@ -0,0 +1,4 @@ +name = mcl_title +description = Add an API to add in HUD title +depends = mcl_colors +author = AFCMS \ No newline at end of file diff --git a/mods/HUD/mcl_tmp_message/API.md b/mods/HUD/mcl_tmp_message/API.md deleted file mode 100644 index 0a3fc06a3..000000000 --- a/mods/HUD/mcl_tmp_message/API.md +++ /dev/null @@ -1,7 +0,0 @@ -# mcl_temp_message - -Allow mods to show short messages in the hud of players. - -## mcl_tmp_message.message(player, message) - -Show above the hotbar a hud message to player . \ No newline at end of file diff --git a/mods/HUD/mcl_tmp_message/init.lua b/mods/HUD/mcl_tmp_message/init.lua deleted file mode 100644 index 1456cd592..000000000 --- a/mods/HUD/mcl_tmp_message/init.lua +++ /dev/null @@ -1,44 +0,0 @@ -mcl_tmp_message = {} - -local huds = {} -local hud_hide_timeouts = {} - -function mcl_tmp_message.message(player, message) - local name = player:get_player_name() - player:hud_change(huds[name], "text", message) - hud_hide_timeouts[name] = 3 -end - -minetest.register_on_joinplayer(function(player) - huds[player:get_player_name()] = player:hud_add({ - hud_elem_type = "text", - position = {x=0.5, y=1}, - offset = {x = 0, y = -210}, - alignment = {x=0, y=0}, - number = 0xFFFFFF , - text = "", - z_index = 100, - }) -end) - -minetest.register_on_leaveplayer(function(player) - local name = player:get_player_name() - huds[name] = nil - hud_hide_timeouts[name] = nil -end) - -minetest.register_globalstep(function(dtime) - local new_timeouts = {} - for name, timeout in pairs(hud_hide_timeouts) do - timeout = timeout - dtime - if timeout <= 0 then - local player = minetest.get_player_by_name(name) - if player then - player:hud_change(huds[name], "text", "") - end - else - new_timeouts[name] = timeout - end - end - hud_hide_timeouts = new_timeouts -end) diff --git a/mods/HUD/mcl_tmp_message/mod.conf b/mods/HUD/mcl_tmp_message/mod.conf deleted file mode 100644 index ad453643e..000000000 --- a/mods/HUD/mcl_tmp_message/mod.conf +++ /dev/null @@ -1,3 +0,0 @@ -name = mcl_tmp_message -author = Fleckenstein -description = A simple API to show a temporary message to a player diff --git a/mods/ITEMS/REDSTONE/mcl_dispensers/init.lua b/mods/ITEMS/REDSTONE/mcl_dispensers/init.lua index ee7f29016..0cd0608c4 100644 --- a/mods/ITEMS/REDSTONE/mcl_dispensers/init.lua +++ b/mods/ITEMS/REDSTONE/mcl_dispensers/init.lua @@ -82,7 +82,7 @@ local dispenserdef = { end, after_dig_node = function(pos, oldnode, oldmetadata, digger) local meta = minetest.get_meta(pos) - local meta2 = meta + local meta2 = meta:to_table() meta:from_table(oldmetadata) local inv = meta:get_inventory() for i=1, inv:get_size("main") do @@ -92,7 +92,7 @@ local dispenserdef = { minetest.add_item(p, stack) end end - meta:from_table(meta2:to_table()) + meta:from_table(meta2) end, _mcl_blast_resistance = 3.5, _mcl_hardness = 3.5, @@ -129,8 +129,13 @@ local dispenserdef = { dropitem:set_count(1) local stack_id = stacks[r].stackpos local stackdef = stack:get_definition() + + if not stackdef then + return + end + local iname = stack:get_name() - local igroups = minetest.registered_items[iname].groups + local igroups = stackdef.groups --[===[ Dispense item ]===] @@ -163,6 +168,56 @@ local dispenserdef = { end inv:set_stack("main", stack_id, stack) + + -- Use shears on sheeps + elseif igroups.shears then + for _, obj in pairs(minetest.get_objects_inside_radius(droppos, 1)) do + local entity = obj:get_luaentity() + if entity and not entity.child and not entity.gotten then + local entname = entity.name + local pos = obj:get_pos() + local used, texture = false + if entname == "mobs_mc:sheep" then + minetest.add_item(pos, entity.drops[2].name .. " " .. math.random(1, 3)) + if not entity.color then + entity.color = "unicolor_white" + end + entity.base_texture = { "blank.png", "mobs_mc_sheep.png" } + texture = entity.base_texture + entity.drops = { + { name = mobs_mc.items.mutton_raw, chance = 1, min = 1, max = 2 }, + } + used = true + elseif entname == "mobs_mc:snowman" then + texture = { + "mobs_mc_snowman.png", + "blank.png", "blank.png", + "blank.png", "blank.png", + "blank.png", "blank.png", + } + used = true + elseif entname == "mobs_mc:mooshroom" then + local droppos = vector.offset(pos, 0, 1.4, 0) + if entity.base_texture[1] == "mobs_mc_mooshroom_brown.png" then + minetest.add_item(droppos, mobs_mc.items.mushroom_brown .. " 5") + else + minetest.add_item(droppos, mobs_mc.items.mushroom_red .. " 5") + end + obj = mcl_util.replace_mob(obj, "mobs_mc:cow") + entity = obj:get_luaentity() + used = true + end + if used then + obj:set_properties({ textures = texture }) + entity.gotten = true + minetest.sound_play("mcl_tools_shears_cut", { pos = pos }, true) + stack:add_wear(65535 / stackdef._mcl_diggroups.shearsy.uses) + inv:set_stack("main", stack_id, stack) + break + end + end + end + -- Spawn Egg elseif igroups.spawn_egg then -- Spawn mob diff --git a/mods/ITEMS/REDSTONE/mcl_droppers/init.lua b/mods/ITEMS/REDSTONE/mcl_droppers/init.lua index b5bcc1d08..abb351091 100644 --- a/mods/ITEMS/REDSTONE/mcl_droppers/init.lua +++ b/mods/ITEMS/REDSTONE/mcl_droppers/init.lua @@ -55,7 +55,7 @@ local dropperdef = { sounds = mcl_sounds.node_sound_stone_defaults(), after_dig_node = function(pos, oldnode, oldmetadata, digger) local meta = minetest.get_meta(pos) - local meta2 = meta + local meta2 = meta:to_table() meta:from_table(oldmetadata) local inv = meta:get_inventory() for i=1, inv:get_size("main") do @@ -65,7 +65,7 @@ local dropperdef = { minetest.add_item(p, stack) end end - meta:from_table(meta2:to_table()) + meta:from_table(meta2) end, allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player) local name = player:get_player_name() diff --git a/mods/ITEMS/REDSTONE/mcl_droppers/init_new.lua b/mods/ITEMS/REDSTONE/mcl_droppers/init_new.lua index 5409e6abc..bd8c0a3c3 100644 --- a/mods/ITEMS/REDSTONE/mcl_droppers/init_new.lua +++ b/mods/ITEMS/REDSTONE/mcl_droppers/init_new.lua @@ -53,7 +53,7 @@ local dropperdef = { sounds = mcl_sounds.node_sound_stone_defaults(), after_dig_node = function(pos, oldnode, oldmetadata, digger) local meta = minetest.get_meta(pos) - local meta2 = meta + local meta2 = meta:to_table() meta:from_table(oldmetadata) local inv = meta:get_inventory() for i=1, inv:get_size("main") do @@ -63,7 +63,7 @@ local dropperdef = { minetest.add_item(p, stack) end end - meta:from_table(meta2:to_table()) + meta:from_table(meta2) end, allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player) local name = player:get_player_name() diff --git a/mods/ITEMS/mcl_anvils/init.lua b/mods/ITEMS/mcl_anvils/init.lua index fbf6fb751..d3b32b844 100644 --- a/mods/ITEMS/mcl_anvils/init.lua +++ b/mods/ITEMS/mcl_anvils/init.lua @@ -53,6 +53,15 @@ local function get_consumed_materials(tool, material) return materials_used end +local function contains(table, value) + for _, i in pairs(table) do + if i == value then + return true + end + end + return false +end + -- Given 2 input stacks, tells you which is the tool and which is the material. -- Returns ("tool", input1, input2) if input1 is tool and input2 is material. -- Returns ("material", input2, input1) if input1 is material and input2 is tool. @@ -60,9 +69,15 @@ end local function distinguish_tool_and_material(input1, input2) local def1 = input1:get_definition() local def2 = input2:get_definition() - if def1.type == "tool" and def1._repair_material then + local r1 = def1._repair_material + local r2 = def2._repair_material + if def1.type == "tool" and r1 and type(r1) == "table" and contains(r1, input2) then return "tool", input1, input2 - elseif def2.type == "tool" and def2._repair_material then + elseif def2.type == "tool" and r2 and type(r2) == "table" and contains(r2, input1) then + return "material", input2, input1 + elseif def1.type == "tool" and r1 then + return "tool", input1, input2 + elseif def2.type == "tool" and r2 then return "material", input2, input1 else return nil @@ -121,11 +136,28 @@ local function update_anvil_slots(meta) local distinguished, tool, material = distinguish_tool_and_material(input1, input2) if distinguished then local tooldef = tool:get_definition() + local repair = tooldef._repair_material local has_correct_material = false - if string.sub(tooldef._repair_material, 1, 6) == "group:" then - has_correct_material = minetest.get_item_group(material:get_name(), string.sub(tooldef._repair_material, 7)) ~= 0 - elseif material:get_name() == tooldef._repair_material then - has_correct_material = true + local material_name = material:get_name() + if type(repair) == "string" then + if string.sub(repair, 1, 6) == "group:" then + has_correct_material = minetest.get_item_group(material_name, string.sub(repair, 7)) ~= 0 + elseif material_name == repair then + has_correct_material = true + end + else + if contains(repair, material_name) then + has_correct_material = true + else + for _, r in pairs(repair) do + if string.sub(r, 1, 6) == "group:" then + if minetest.get_item_group(material_name, string.sub(r, 7)) ~= 0 then + has_correct_material = true + end + + end + end + end end if has_correct_material and tool:get_wear() > 0 then local materials_used = get_consumed_materials(tool, material) @@ -284,6 +316,12 @@ local function damage_anvil_by_falling(pos, distance) end end +local anvilbox = { + type = "fixed", + fixed = { + { -8 / 16, -8 / 16, -6 / 16, 8 / 16, 8 / 16, 6 / 16 }, + }, +} local anvildef = { groups = {pickaxey=1, falling_node=1, falling_node_damage=1, crush_after_fall=1, deco_block=1, anvil=1}, tiles = {"mcl_anvils_anvil_top_damaged_0.png^[transformR90", "mcl_anvils_anvil_base.png", "mcl_anvils_anvil_side.png"}, @@ -297,11 +335,14 @@ local anvildef = { node_box = { type = "fixed", fixed = { - {-8/16, 2/16, -5/16, 8/16, 8/16, 5/16}, -- top - {-5/16, -4/16, -2/16, 5/16, 5/16, 2/16}, -- middle - {-8/16, -8/16, -5/16, 8/16, -4/16, 5/16}, -- base + { -6 / 16, -8 / 16, -6 / 16, 6 / 16, -4 / 16, 6 / 16 }, + { -5 / 16, -4 / 16, -4 / 16, 5 / 16, -3 / 16, 4 / 16 }, + { -4 / 16, -3 / 16, -2 / 16, 4 / 16, 2 / 16, 2 / 16 }, + { -8 / 16, 2 / 16, -5 / 16, 8 / 16, 8 / 16, 5 / 16 }, } }, + selection_box = anvilbox, + collision_box = anvilbox, sounds = mcl_sounds.node_sound_metal_defaults(), _mcl_blast_resistance = 1200, _mcl_hardness = 5, diff --git a/mods/ITEMS/mcl_anvils/textures/mcl_anvils_anvil_top_damaged_0.png b/mods/ITEMS/mcl_anvils/textures/mcl_anvils_anvil_top_damaged_0.png index 84c64e915..43938aa72 100644 Binary files a/mods/ITEMS/mcl_anvils/textures/mcl_anvils_anvil_top_damaged_0.png and b/mods/ITEMS/mcl_anvils/textures/mcl_anvils_anvil_top_damaged_0.png differ diff --git a/mods/ITEMS/mcl_anvils/textures/mcl_anvils_anvil_top_damaged_1.png b/mods/ITEMS/mcl_anvils/textures/mcl_anvils_anvil_top_damaged_1.png index 61c2ac6ab..e8cfbe5b7 100644 Binary files a/mods/ITEMS/mcl_anvils/textures/mcl_anvils_anvil_top_damaged_1.png and b/mods/ITEMS/mcl_anvils/textures/mcl_anvils_anvil_top_damaged_1.png differ diff --git a/mods/ITEMS/mcl_anvils/textures/mcl_anvils_anvil_top_damaged_2.png b/mods/ITEMS/mcl_anvils/textures/mcl_anvils_anvil_top_damaged_2.png index 5f5cfbffa..096f65eac 100644 Binary files a/mods/ITEMS/mcl_anvils/textures/mcl_anvils_anvil_top_damaged_2.png and b/mods/ITEMS/mcl_anvils/textures/mcl_anvils_anvil_top_damaged_2.png differ diff --git a/mods/ITEMS/mcl_armor/mod.conf b/mods/ITEMS/mcl_armor/mod.conf index 9264e8362..fad2e494c 100644 --- a/mods/ITEMS/mcl_armor/mod.conf +++ b/mods/ITEMS/mcl_armor/mod.conf @@ -1,5 +1,5 @@ name = mcl_armor author = stu description = Adds craftable armor that is visible to other players. -depends = mcl_core, mcl_player, mcl_enchanting +depends = mcl_core, mcl_player, mcl_enchanting, mcl_damage optional_depends = mcl_fire, ethereal, bakedclay diff --git a/mods/ITEMS/mcl_armor/models/mcl_armor_character.b3d b/mods/ITEMS/mcl_armor/models/mcl_armor_character.b3d index 95f763eab..b3a943f46 100644 Binary files a/mods/ITEMS/mcl_armor/models/mcl_armor_character.b3d and b/mods/ITEMS/mcl_armor/models/mcl_armor_character.b3d differ diff --git a/mods/ITEMS/mcl_armor/models/mcl_armor_character.blend b/mods/ITEMS/mcl_armor/models/mcl_armor_character.blend index a5626aacc..a613eef89 100644 Binary files a/mods/ITEMS/mcl_armor/models/mcl_armor_character.blend and b/mods/ITEMS/mcl_armor/models/mcl_armor_character.blend differ diff --git a/mods/ITEMS/mcl_armor/models/mcl_armor_character_female.b3d b/mods/ITEMS/mcl_armor/models/mcl_armor_character_female.b3d index 1b4205344..4e17ee341 100644 Binary files a/mods/ITEMS/mcl_armor/models/mcl_armor_character_female.b3d and b/mods/ITEMS/mcl_armor/models/mcl_armor_character_female.b3d differ diff --git a/mods/ITEMS/mcl_armor/models/mcl_armor_character_female.blend b/mods/ITEMS/mcl_armor/models/mcl_armor_character_female.blend index 828cd942c..b0494efbf 100644 Binary files a/mods/ITEMS/mcl_armor/models/mcl_armor_character_female.blend and b/mods/ITEMS/mcl_armor/models/mcl_armor_character_female.blend differ diff --git a/mods/ITEMS/mcl_armor/player.lua b/mods/ITEMS/mcl_armor/player.lua index 9dba0773c..48fdb381f 100644 --- a/mods/ITEMS/mcl_armor/player.lua +++ b/mods/ITEMS/mcl_armor/player.lua @@ -25,6 +25,8 @@ mcl_player.player_register_model("mcl_armor_character.b3d", { sit_mount = {x=484, y=484}, die = {x=498, y=498}, fly = {x=502, y=581}, + bow_walk = {x=650, y=670}, + bow_sneak = {x=675, y=695}, }, }) @@ -55,6 +57,8 @@ mcl_player.player_register_model("mcl_armor_character_female.b3d", { sit_mount = {x=484, y=484}, die = {x=498, y=498}, fly = {x=502, y=581}, + bow_walk = {x=650, y=670}, + bow_sneak = {x=675, y=695}, }, }) diff --git a/mods/ITEMS/mcl_armor/textures/mcl_armor_inv_boots_gold.png b/mods/ITEMS/mcl_armor/textures/mcl_armor_inv_boots_gold.png index dc452d413..ef1f9fa87 100644 Binary files a/mods/ITEMS/mcl_armor/textures/mcl_armor_inv_boots_gold.png and b/mods/ITEMS/mcl_armor/textures/mcl_armor_inv_boots_gold.png differ diff --git a/mods/ITEMS/mcl_banners/init.lua b/mods/ITEMS/mcl_banners/init.lua index 490e22643..a396caf7d 100644 --- a/mods/ITEMS/mcl_banners/init.lua +++ b/mods/ITEMS/mcl_banners/init.lua @@ -573,7 +573,7 @@ for colorid, colortab in pairs(mcl_banners.colors) do end, }) - if mod_mcl_core and minetest.get_modpath("mcl_wool") then + if mod_mcl_core and minetest.get_modpath("mcl_wool") and pattern_name == "" then minetest.register_craft({ output = itemstring, recipe = { diff --git a/mods/ITEMS/mcl_banners/patterncraft.lua b/mods/ITEMS/mcl_banners/patterncraft.lua index bc2771fee..767235b1e 100644 --- a/mods/ITEMS/mcl_banners/patterncraft.lua +++ b/mods/ITEMS/mcl_banners/patterncraft.lua @@ -8,9 +8,6 @@ local N = function(s) return s end -- Maximum number of layers which can be put on a banner by crafting. local max_layers_crafting = 12 --- Maximum number of layers when banner includes a gradient (workaround, see below). -local max_layers_gradient = 3 - -- Max. number lines in the descriptions for the banner layers. -- This is done to avoid huge tooltips. local max_layer_lines = 6 @@ -122,8 +119,7 @@ local patterns = { name = N("@1 Thing Charge"), type = "shapeless", - -- TODO: Replace with enchanted golden apple - { e, "mcl_core:apple_gold", d }, + { e, "mcl_core:apple_gold_enchanted", d }, }, ["rhombus"] = { name = N("@1 Lozenge"), @@ -398,16 +394,6 @@ local function banner_pattern_craft(itemstack, player, old_craft_grid, craft_inv if #layers >= max_layers_crafting then return ItemStack("") end - -- Lower layer limit when banner includes any gradient. - -- Workaround to circumvent Minetest bug (https://github.com/minetest/minetest/issues/6210) - -- TODO: Remove this restriction when bug #6210 is fixed. - if #layers >= max_layers_gradient then - for l=1, #layers do - if layers[l].pattern == "gradient" or layers[l].pattern == "gradient_up" then - return ItemStack("") - end - end - end local matching_pattern local max_i = player:get_inventory():get_size("craft") diff --git a/mods/ITEMS/mcl_beds/README.txt b/mods/ITEMS/mcl_beds/README.txt index cda6ebd92..34b493702 100644 --- a/mods/ITEMS/mcl_beds/README.txt +++ b/mods/ITEMS/mcl_beds/README.txt @@ -12,15 +12,7 @@ Authors of media (textures) BlockMen (CC BY-SA 3.0) This mod adds a bed to Minetest which allows to skip the night. -To sleep, rightclick the bed. If playing in singleplayer mode the night gets skipped -immediately. If playing multiplayer you get shown how many other players are in bed too, -if all players are sleeping the night gets skipped. The night skip can be forced if more -than 50% of the players are lying in bed and use this option. - -Another feature is a controlled respawning. If you have slept in bed (not just lying in -it) your respawn point is set to the beds location and you will respawn there after +To sleep, rightclick the bed. +Another feature is a controlled respawning. If you have slept in bed your respawn point is set to the beds location and you will respawn there after death. -You can disable the respawn at beds by setting "enable_bed_respawn = false" in -minetest.conf. -You can disable the night skip feature by setting "enable_bed_night_skip = false" in -minetest.conf or by using the /set command in-game. +Use the mcl_playersSleepingPercentage setting to enable/disable night skipping or set a percentage of how many players need to sleep to skip the night. \ No newline at end of file diff --git a/mods/ITEMS/mcl_beds/functions.lua b/mods/ITEMS/mcl_beds/functions.lua index dc9afe2ba..b8478fc1f 100644 --- a/mods/ITEMS/mcl_beds/functions.lua +++ b/mods/ITEMS/mcl_beds/functions.lua @@ -14,39 +14,34 @@ local worlds_mod = minetest.get_modpath("mcl_worlds") local function get_look_yaw(pos) local n = minetest.get_node(pos) - if n.param2 == 1 then - return math.pi / 2, n.param2 - elseif n.param2 == 3 then - return -math.pi / 2, n.param2 - elseif n.param2 == 0 then - return math.pi, n.param2 + local param = n.param2 + if param == 1 then + return math.pi / 2, param + elseif param == 3 then + return -math.pi / 2, param + elseif param == 0 then + return math.pi, param else - return 0, n.param2 + return 0, param end end +local function players_in_bed_setting() + return tonumber(minetest.settings:get("mcl_playersSleepingPercentage")) or 100 +end + local function is_night_skip_enabled() - local enable_night_skip = minetest.settings:get_bool("enable_bed_night_skip") - if enable_night_skip == nil then - enable_night_skip = true - end - return enable_night_skip + return players_in_bed_setting() <= 100 end local function check_in_beds(players) - local in_bed = mcl_beds.player if not players then players = minetest.get_connected_players() end - - for n, player in pairs(players) do - local name = player:get_player_name() - if not in_bed[name] then - return false - end + if player_in_bed <= 0 then + return false end - - return #players > 0 + return players_in_bed_setting() <= (player_in_bed * 100) / #players end -- These monsters do not prevent sleep @@ -198,7 +193,7 @@ end local function update_formspecs(finished, ges) local ges = ges or #minetest.get_connected_players() local form_n = "size[12,5;true]" - local all_in_bed = ges == player_in_bed + local all_in_bed = players_in_bed_setting() <= (player_in_bed * 100) / ges local night_skip = is_night_skip_enabled() local button_leave = "button_exit[4,3;4,0.75;leave;"..F(S("Leave bed")).."]" local button_abort = "button_exit[4,3;4,0.75;leave;"..F(S("Abort sleep")).."]" @@ -221,7 +216,13 @@ local function update_formspecs(finished, ges) form_n = form_n .. bg_sleep form_n = form_n .. button_abort else - text = text .. "\n" .. S("You will fall asleep when all players are in bed.") + local comment = "You will fall asleep when " + if players_in_bed_setting() == 100 then + comment = S(comment .. "all players are in bed.") + else + comment = S(comment .. "@1% of all players are in bed.", players_in_bed_setting()) + end + text = text .. "\n" .. comment form_n = form_n .. bg_presleep form_n = form_n .. button_leave end @@ -330,7 +331,7 @@ function mcl_beds.on_rightclick(pos, player, is_top) message = select(2, lay_down(player, ppos, other)) end if message then - mcl_tmp_message.message(player, message) + mcl_title.set(player, "actionbar", {text=message, color="white", stay=60}) end else lay_down(player, nil, nil, false) @@ -349,7 +350,6 @@ function mcl_beds.on_rightclick(pos, player, is_top) end end - -- Callbacks minetest.register_on_joinplayer(function(player) local meta = player:get_meta() diff --git a/mods/ITEMS/mcl_beds/locale/mcl_beds.de.tr b/mods/ITEMS/mcl_beds/locale/mcl_beds.de.tr index 16592115e..eb6967941 100644 --- a/mods/ITEMS/mcl_beds/locale/mcl_beds.de.tr +++ b/mods/ITEMS/mcl_beds/locale/mcl_beds.de.tr @@ -37,5 +37,6 @@ Players in bed: @1/@2=Spieler im Bett: @1/@2 Note: Night skip is disabled.=Anmerkung: Überspringen der Nacht deaktiviert. You're sleeping.=Sie schlafen. You will fall asleep when all players are in bed.=Sie werden einschlafen, wenn alle Spieler im Bett sind. +You will fall asleep when @1% of all players are in bed.=Sie werden einschlafen, wenn @1% der Spieler im Bett sind. You're in bed.=Sie sind im Bett. Allows you to sleep=Zum Einschafen diff --git a/mods/ITEMS/mcl_beds/locale/template.txt b/mods/ITEMS/mcl_beds/locale/template.txt index 8301dfa33..5525bd91b 100644 --- a/mods/ITEMS/mcl_beds/locale/template.txt +++ b/mods/ITEMS/mcl_beds/locale/template.txt @@ -37,5 +37,6 @@ Players in bed: @1/@2= Note: Night skip is disabled.= You're sleeping.= You will fall asleep when all players are in bed.= +You will fall asleep when @1% of all players are in bed.= You're in bed.= Allows you to sleep= diff --git a/mods/ITEMS/mcl_bows/arrow.lua b/mods/ITEMS/mcl_bows/arrow.lua index 9a22ee622..343707617 100644 --- a/mods/ITEMS/mcl_bows/arrow.lua +++ b/mods/ITEMS/mcl_bows/arrow.lua @@ -43,7 +43,7 @@ S("An arrow fired from a bow has a regular damage of 1-9. At full charge, there' S("Arrows might get stuck on solid blocks and can be retrieved again. They are also capable of pushing wooden buttons."), _doc_items_usagehelp = S("To use arrows as ammunition for a bow, just put them anywhere in your inventory, they will be used up automatically. To use arrows as ammunition for a dispenser, place them in the dispenser's inventory. To retrieve an arrow that sticks in a block, simply walk close to it."), inventory_image = "mcl_bows_arrow_inv.png", - groups = { ammo=1, ammo_bow=1, ammo_bow_regular=1 }, + groups = { ammo=1, ammo_bow=1, ammo_bow_regular=1, ammo_crossbow=1 }, _on_dispense = function(itemstack, dispenserpos, droppos, dropnode, dropdir) -- Shoot arrow local shootpos = vector.add(dispenserpos, vector.multiply(dropdir, 0.51)) @@ -324,7 +324,9 @@ function ARROW_ENTITY.on_step(self, dtime) end if not obj:is_player() then mcl_burning.extinguish(self.object) - self.object:remove() + if self._piercing == 0 then + self.object:remove() + end end return end diff --git a/mods/ITEMS/mcl_bows/crossbow.lua b/mods/ITEMS/mcl_bows/crossbow.lua new file mode 100644 index 000000000..5ae21a1f3 --- /dev/null +++ b/mods/ITEMS/mcl_bows/crossbow.lua @@ -0,0 +1,454 @@ +local S = minetest.get_translator(minetest.get_current_modname()) + +mcl_bows_s = {} + +-- local arrows = { +-- ["mcl_bows:arrow"] = "mcl_bows:arrow_entity", +-- } + +local GRAVITY = 9.81 +local BOW_DURABILITY = 385 + +-- Charging time in microseconds +local _BOW_CHARGE_TIME_HALF = 350000 -- bow level 1 +local _BOW_CHARGE_TIME_FULL = 900000 -- bow level 2 (full charge) + +local BOW_CHARGE_TIME_HALF = 350000 -- bow level 1 +local BOW_CHARGE_TIME_FULL = 900000 -- bow level 2 (full charge) + +-- Factor to multiply with player speed while player uses bow +-- This emulates the sneak speed. +local PLAYER_USE_CROSSBOW_SPEED = tonumber(minetest.settings:get("movement_speed_crouch")) / tonumber(minetest.settings:get("movement_speed_walk")) + +-- TODO: Use Minecraft speed (ca. 53 m/s) +-- Currently nerfed because at full speed the arrow would easily get out of the range of the loaded map. +local BOW_MAX_SPEED = 68 + +local function play_load_sound(id, pos) + minetest.sound_play("mcl_bows_crossbow_drawback_"..id, {pos=pos, max_hear_distance=12}, true) +end + +--[[ Store the charging state of each player. +keys: player name +value: +nil = not charging or player not existing +number: currently charging, the number is the time from minetest.get_us_time + in which the charging has started +]] +local bow_load = {} + +-- Another player table, this one stores the wield index of the bow being charged +local bow_index = {} + +function mcl_bows_s.shoot_arrow_crossbow(arrow_item, pos, dir, yaw, shooter, power, damage, is_critical, crossbow_stack, collectable) + local obj = minetest.add_entity({x=pos.x,y=pos.y,z=pos.z}, arrow_item.."_entity") + if power == nil then + power = BOW_MAX_SPEED --19 + end + if damage == nil then + damage = 3 + end + local knockback + if crossbow_stack then + local enchantments = mcl_enchanting.get_enchantments(crossbow_stack) + if enchantments.piercing then + obj:get_luaentity()._piercing = 1 * enchantments.piercing + else + obj:get_luaentity()._piercing = 0 + end + end + obj:set_velocity({x=dir.x*power, y=dir.y*power, z=dir.z*power}) + obj:set_acceleration({x=0, y=-GRAVITY, z=0}) + obj:set_yaw(yaw-math.pi/2) + local le = obj:get_luaentity() + le._shooter = shooter + le._source_object = shooter + le._damage = damage + le._is_critical = is_critical + le._startpos = pos + le._knockback = knockback + le._collectable = collectable + minetest.sound_play("mcl_bows_crossbow_shoot", {pos=pos, max_hear_distance=16}, true) + if shooter and shooter:is_player() then + if obj:get_luaentity().player == "" then + obj:get_luaentity().player = shooter + end + obj:get_luaentity().node = shooter:get_inventory():get_stack("main", 1):get_name() + end + return obj +end + +local function get_arrow(player) + local inv = player:get_inventory() + local arrow_stack, arrow_stack_id + for i=1, inv:get_size("main") do + local it = inv:get_stack("main", i) + if not it:is_empty() and minetest.get_item_group(it:get_name(), "ammo_crossbow") ~= 0 then + arrow_stack = it + arrow_stack_id = i + break + end + end + return arrow_stack, arrow_stack_id +end + +local function player_shoot_arrow(wielditem, player, power, damage, is_critical) + local has_multishot_enchantment = mcl_enchanting.has_enchantment(player:get_wielded_item(), "multishot") + local arrow_itemstring = wielditem:get_meta():get("arrow") + + if not arrow_itemstring then + return false + end + + local playerpos = player:get_pos() + local dir = player:get_look_dir() + local yaw = player:get_look_horizontal() + + if has_multishot_enchantment then + mcl_bows_s.shoot_arrow_crossbow(arrow_itemstring, {x=playerpos.x,y=playerpos.y+1.5,z=playerpos.z}, {x=dir.x, y=dir.y, z=dir.z + .2}, yaw, player, power, damage, is_critical, player:get_wielded_item(), false) + mcl_bows_s.shoot_arrow_crossbow(arrow_itemstring, {x=playerpos.x,y=playerpos.y+1.5,z=playerpos.z}, {x=dir.x, y=dir.y, z=dir.z - .2}, yaw, player, power, damage, is_critical, player:get_wielded_item(), false) + mcl_bows_s.shoot_arrow_crossbow(arrow_itemstring, {x=playerpos.x,y=playerpos.y+1.5,z=playerpos.z}, dir, yaw, player, power, damage, is_critical, player:get_wielded_item(), true) + else + mcl_bows_s.shoot_arrow_crossbow(arrow_itemstring, {x=playerpos.x,y=playerpos.y+1.5,z=playerpos.z}, dir, yaw, player, power, damage, is_critical, player:get_wielded_item(), true) + end + return true +end + +-- Bow item, uncharged state +minetest.register_tool("mcl_bows:crossbow", { + description = S("Corssbow"), + _tt_help = S("Launches arrows"), + _doc_items_longdesc = S("Bows are ranged weapons to shoot arrows at your foes.").."\n".. +S("The speed and damage of the arrow increases the longer you charge. The regular damage of the arrow is between 1 and 9. At full charge, there's also a 20% of a critical hit, dealing 10 damage instead."), + _doc_items_usagehelp = S("To use the bow, you first need to have at least one arrow anywhere in your inventory (unless in Creative Mode). Hold down the right mouse button to charge, release to shoot."), + _doc_items_durability = BOW_DURABILITY, + inventory_image = "mcl_bows_crossbow.png", + wield_scale = mcl_vars.tool_wield_scale, + stack_max = 1, + range = 4, + -- Trick to disable digging as well + on_use = function() return end, + on_place = function(itemstack, player, pointed_thing) + if pointed_thing and pointed_thing.type == "node" then + -- Call on_rightclick if the pointed node defines it + local node = minetest.get_node(pointed_thing.under) + if player and not player:get_player_control().sneak then + if minetest.registered_nodes[node.name] and minetest.registered_nodes[node.name].on_rightclick then + return minetest.registered_nodes[node.name].on_rightclick(pointed_thing.under, node, player, itemstack) or itemstack + end + end + end + + itemstack:get_meta():set_string("active", "true") + return itemstack + end, + on_secondary_use = function(itemstack) + itemstack:get_meta():set_string("active", "true") + return itemstack + end, + groups = {weapon=1,weapon_ranged=1,crossbow=1,enchantability=1}, + _mcl_uses = 326, +}) + +minetest.register_tool("mcl_bows:crossbow_loaded", { + description = S("Corssbow"), + _tt_help = S("Launches arrows"), + _doc_items_longdesc = S("Corssbow are ranged weapons to shoot arrows at your foes.").."\n".. +S("The speed and damage of the arrow increases the longer you charge. The regular damage of the arrow is between 1 and 9. At full charge, there's also a 20% of a critical hit, dealing 10 damage instead."), + _doc_items_usagehelp = S("To use the corssbow, you first need to have at least one arrow anywhere in your inventory (unless in Creative Mode). Hold down the right mouse button to charge, release to load an arrow into the chamber, then to shoot press left mouse."), + _doc_items_durability = BOW_DURABILITY, + inventory_image = "mcl_bows_crossbow_3.png", + wield_scale = mcl_vars.tool_wield_scale, + stack_max = 1, + range = 4, + -- Trick to disable digging as well + on_use = function() return end, + on_place = function(itemstack, player, pointed_thing) + if pointed_thing and pointed_thing.type == "node" then + -- Call on_rightclick if the pointed node defines it + local node = minetest.get_node(pointed_thing.under) + if player and not player:get_player_control().sneak then + if minetest.registered_nodes[node.name] and minetest.registered_nodes[node.name].on_rightclick then + return minetest.registered_nodes[node.name].on_rightclick(pointed_thing.under, node, player, itemstack) or itemstack + end + end + end + + itemstack:get_meta():set_string("active", "true") + return itemstack + end, + on_secondary_use = function(itemstack) + itemstack:get_meta():set_string("active", "true") + return itemstack + end, + groups = {weapon=1,weapon_ranged=1,crossbow=1,enchantability=1}, + _mcl_uses = 326, +}) + +-- Iterates through player inventory and resets all the bows in "charging" state back to their original stage +local function reset_bows(player) + local inv = player:get_inventory() + local list = inv:get_list("main") + for place, stack in pairs(list) do + if stack:get_name() == "mcl_bows:crossbow" or stack:get_name() == "mcl_bows:crossbow_enchanted" then + stack:get_meta():set_string("active", "") + elseif stack:get_name()=="mcl_bows:crossbow_0" or stack:get_name()=="mcl_bows:crossbow_1" or stack:get_name()=="mcl_bows:crossbow_2" then + stack:set_name("mcl_bows:crossbow") + stack:get_meta():set_string("active", "") + list[place] = stack + elseif stack:get_name()=="mcl_bows:crossbow_0_enchanted" or stack:get_name()=="mcl_bows:crossbow_1_enchanted" or stack:get_name()=="mcl_bows:crossbow_2_enchanted" then + stack:set_name("mcl_bows:crossbow_enchanted") + stack:get_meta():set_string("active", "") + list[place] = stack + end + end + inv:set_list("main", list) +end + +-- Resets the bow charging state and player speed. To be used when the player is no longer charging the bow +local function reset_bow_state(player, also_reset_bows) + bow_load[player:get_player_name()] = nil + bow_index[player:get_player_name()] = nil + if minetest.get_modpath("playerphysics") then + playerphysics.remove_physics_factor(player, "speed", "mcl_bows:use_crossbow") + end + if also_reset_bows then + reset_bows(player) + end +end + +-- Bow in charging state +for level=0, 2 do + minetest.register_tool("mcl_bows:crossbow_"..level, { + description = S("Crossbow"), + _doc_items_create_entry = false, + inventory_image = "mcl_bows_crossbow_"..level..".png", + wield_scale = mcl_vars.tool_wield_scale, + stack_max = 1, + range = 0, -- Pointing range to 0 to prevent punching with bow :D + groups = {not_in_creative_inventory=1, not_in_craft_guide=1, bow=1, enchantability=1}, + -- Trick to disable digging as well + on_use = function() return end, + on_drop = function(itemstack, dropper, pos) + reset_bow_state(dropper) + itemstack:get_meta():set_string("active", "") + if mcl_enchanting.is_enchanted(itemstack:get_name()) then + itemstack:set_name("mcl_bows:crossbow_enchanted") + else + itemstack:set_name("mcl_bows:crossbow") + end + minetest.item_drop(itemstack, dropper, pos) + itemstack:take_item() + return itemstack + end, + -- Prevent accidental interaction with itemframes and other nodes + on_place = function(itemstack) + return itemstack + end, + _mcl_uses = 385, + }) +end + + +controls.register_on_release(function(player, key, time) + if key~="RMB" then return end + --local inv = minetest.get_inventory({type="player", name=player:get_player_name()}) + local wielditem = player:get_wielded_item() + if wielditem:get_name()=="mcl_bows:crossbow_2" and get_arrow(player) or wielditem:get_name()=="mcl_bows:crossbow_2" and minetest.is_creative_enabled(player:get_player_name()) or wielditem:get_name()=="mcl_bows:crossbow_2_enchanted" and get_arrow(player) or wielditem:get_name()=="mcl_bows:crossbow_2_enchanted" and minetest.is_creative_enabled(player:get_player_name()) then + local arrow_stack, arrow_stack_id = get_arrow(player) + local arrow_itemstring + + if minetest.is_creative_enabled(player:get_player_name()) then + if arrow_stack then + arrow_itemstring = arrow_stack:get_name() + else + arrow_itemstring = "mcl_bows:arrow" + end + else + arrow_itemstring = arrow_stack:get_name() + arrow_stack:take_item() + player:get_inventory():set_stack("main", arrow_stack_id, arrow_stack) + end + + wielditem:get_meta():set_string("arrow", arrow_itemstring) + + if wielditem:get_name()=="mcl_bows:crossbow_2" then + wielditem:set_name("mcl_bows:crossbow_loaded") + else + wielditem:set_name("mcl_bows:crossbow_loaded_enchanted") + end + player:set_wielded_item(wielditem) + minetest.sound_play("mcl_bows_crossbow_load", {pos=player:get_pos(), max_hear_distance=16}, true) + else + reset_bow_state(player, true) + end +end) + +controls.register_on_press(function(player, key, time) + if key~="LMB" then return end + local wielditem = player:get_wielded_item() + if wielditem:get_name()=="mcl_bows:crossbow_loaded" or wielditem:get_name()=="mcl_bows:crossbow_loaded_enchanted" then + local enchanted = mcl_enchanting.is_enchanted(wielditem:get_name()) + local speed, damage + local p_load = bow_load[player:get_player_name()] + local charge + -- Type sanity check + if type(p_load) == "number" then + charge = minetest.get_us_time() - p_load + else + -- In case something goes wrong ... + -- Just assume minimum charge. + charge = 0 + minetest.log("warning", "[mcl_bows] Player "..player:get_player_name().." fires arrow with non-numeric bow_load!") + end + charge = math.max(math.min(charge, BOW_CHARGE_TIME_FULL), 0) + + local charge_ratio = charge / BOW_CHARGE_TIME_FULL + charge_ratio = math.max(math.min(charge_ratio, 1), 0) + + -- Calculate damage and speed + -- Fully charged + local is_critical = false + speed = BOW_MAX_SPEED + local r = math.random(1,5) + if r == 1 then + -- 20% chance for critical hit + damage = 10 + is_critical = true + else + damage = 9 + end + + local has_shot = player_shoot_arrow(wielditem, player, speed, damage, is_critical) + + if enchanted then + wielditem:set_name("mcl_bows:crossbow_enchanted") + else + wielditem:set_name("mcl_bows:crossbow") + end + + if has_shot and not minetest.is_creative_enabled(player:get_player_name()) then + local durability = BOW_DURABILITY + local unbreaking = mcl_enchanting.get_enchantment(wielditem, "unbreaking") + local multishot = mcl_enchanting.get_enchantment(wielditem, "multishot") + if unbreaking > 0 then + durability = durability * (unbreaking + 1) + end + if multishot then + durability = durability / 3 + end + wielditem:add_wear(65535/durability) + end + player:set_wielded_item(wielditem) + reset_bow_state(player, true) + end +end) + +controls.register_on_hold(function(player, key, time) + local name = player:get_player_name() + local creative = minetest.is_creative_enabled(name) + if key ~= "RMB" then + return + end + --local inv = minetest.get_inventory({type="player", name=name}) + local wielditem = player:get_wielded_item() + local enchantments = mcl_enchanting.get_enchantments(wielditem) + if enchantments.quick_charge then + BOW_CHARGE_TIME_HALF = _BOW_CHARGE_TIME_HALF - (enchantments.quick_charge * 0.13 * 1000000 * .5) + BOW_CHARGE_TIME_FULL = _BOW_CHARGE_TIME_FULL - (enchantments.quick_charge * 0.13 * 1000000) + else + BOW_CHARGE_TIME_HALF = _BOW_CHARGE_TIME_HALF + BOW_CHARGE_TIME_FULL = _BOW_CHARGE_TIME_FULL + end + + if bow_load[name] == nil and (wielditem:get_name()=="mcl_bows:crossbow" or wielditem:get_name()=="mcl_bows:crossbow_enchanted") and wielditem:get_meta():get("active") and (creative or get_arrow(player)) then + local enchanted = mcl_enchanting.is_enchanted(wielditem:get_name()) + if enchanted then + wielditem:set_name("mcl_bows:crossbow_0_enchanted") + play_load_sound(0, player:get_pos()) + else + wielditem:set_name("mcl_bows:crossbow_0") + play_load_sound(0, player:get_pos()) + end + player:set_wielded_item(wielditem) + if minetest.get_modpath("playerphysics") then + -- Slow player down when using bow + playerphysics.add_physics_factor(player, "speed", "mcl_bows:use_crossbow", PLAYER_USE_CROSSBOW_SPEED) + end + bow_load[name] = minetest.get_us_time() + bow_index[name] = player:get_wield_index() + else + if player:get_wield_index() == bow_index[name] then + if type(bow_load[name]) == "number" then + if wielditem:get_name() == "mcl_bows:crossbow_0" and minetest.get_us_time() - bow_load[name] >= BOW_CHARGE_TIME_HALF then + wielditem:set_name("mcl_bows:crossbow_1") + play_load_sound(1, player:get_pos()) + elseif wielditem:get_name() == "mcl_bows:crossbow_0_enchanted" and minetest.get_us_time() - bow_load[name] >= BOW_CHARGE_TIME_HALF then + wielditem:set_name("mcl_bows:crossbow_1_enchanted") + play_load_sound(1, player:get_pos()) + elseif wielditem:get_name() == "mcl_bows:crossbow_1" and minetest.get_us_time() - bow_load[name] >= BOW_CHARGE_TIME_FULL then + wielditem:set_name("mcl_bows:crossbow_2") + play_load_sound(2, player:get_pos()) + elseif wielditem:get_name() == "mcl_bows:crossbow_1_enchanted" and minetest.get_us_time() - bow_load[name] >= BOW_CHARGE_TIME_FULL then + wielditem:set_name("mcl_bows:crossbow_2_enchanted") + play_load_sound(2, player:get_pos()) + end + else + if wielditem:get_name() == "mcl_bows:crossbow_0" or wielditem:get_name() == "mcl_bows:crossbow_1" or wielditem:get_name() == "mcl_bows:crossbow_2" then + wielditem:set_name("mcl_bows:crossbow") + play_load_sound(1, player:get_pos()) + elseif wielditem:get_name() == "mcl_bows:crossbow_0_enchanted" or wielditem:get_name() == "mcl_bows:crossbow_1_enchanted" or wielditem:get_name() == "mcl_bows:crossbow_2_enchanted" then + wielditem:set_name("mcl_bows:crossbow_enchanted") + play_load_sound(1, player:get_pos()) + end + end + player:set_wielded_item(wielditem) + else + reset_bow_state(player, true) + end + end +end) + +minetest.register_globalstep(function(dtime) + for _, player in pairs(minetest.get_connected_players()) do + local name = player:get_player_name() + local wielditem = player:get_wielded_item() + local wieldindex = player:get_wield_index() + --local controls = player:get_player_control() + if type(bow_load[name]) == "number" and ((wielditem:get_name()~="mcl_bows:crossbow_0" and wielditem:get_name()~="mcl_bows:crossbow_1" and wielditem:get_name()~="mcl_bows:crossbow_2" and wielditem:get_name()~="mcl_bows:crossbow_0_enchanted" and wielditem:get_name()~="mcl_bows:crossbow_1_enchanted" and wielditem:get_name()~="mcl_bows:crossbow_2_enchanted") or wieldindex ~= bow_index[name]) then + reset_bow_state(player, true) + end + end +end) + +minetest.register_on_joinplayer(function(player) + reset_bows(player) +end) + +minetest.register_on_leaveplayer(function(player) + reset_bow_state(player, true) +end) + +if minetest.get_modpath("mcl_core") and minetest.get_modpath("mcl_mobitems") then + minetest.register_craft({ + output = "mcl_bows:crossbow", + recipe = { + {"mcl_core:stick", "mcl_core:iron_ingot", "mcl_core:stick"}, + {"mcl_mobitems:string", "mcl_bows:arrow", "mcl_mobitems:string"}, + {"", "mcl_core:stick", ""}, + } + }) +end + +minetest.register_craft({ + type = "fuel", + recipe = "group:bow", + burntime = 15, +}) + +-- Add entry aliases for the Help +if minetest.get_modpath("doc") then + doc.add_entry_alias("tools", "mcl_bows:crossbow", "tools", "mcl_bows:crossbow_0") + doc.add_entry_alias("tools", "mcl_bows:crossbow", "tools", "mcl_bows:crossbow_1") + doc.add_entry_alias("tools", "mcl_bows:crossbow", "tools", "mcl_bows:crossbow_2") +end diff --git a/mods/ITEMS/mcl_bows/init.lua b/mods/ITEMS/mcl_bows/init.lua index a2745d950..d5b06dac7 100644 --- a/mods/ITEMS/mcl_bows/init.lua +++ b/mods/ITEMS/mcl_bows/init.lua @@ -1,5 +1,11 @@ +--Bow dofile(minetest.get_modpath("mcl_bows") .. "/arrow.lua") dofile(minetest.get_modpath("mcl_bows") .. "/bow.lua") +dofile(minetest.get_modpath("mcl_bows") .. "/rocket.lua") +--Crossbow +dofile(minetest.get_modpath("mcl_bows") .. "/crossbow.lua") + +--Compatiblility with older MineClone worlds minetest.register_alias("mcl_throwing:bow", "mcl_bows:bow") minetest.register_alias("mcl_throwing:arrow", "mcl_bows:arrow") diff --git a/mods/ITEMS/mcl_bows/models/mcl_bows_rocket.b3d b/mods/ITEMS/mcl_bows/models/mcl_bows_rocket.b3d new file mode 100644 index 000000000..0a34f1eaa Binary files /dev/null and b/mods/ITEMS/mcl_bows/models/mcl_bows_rocket.b3d differ diff --git a/mods/ITEMS/mcl_bows/models/mcl_bows_rocket.mtl b/mods/ITEMS/mcl_bows/models/mcl_bows_rocket.mtl new file mode 100644 index 000000000..f231bdf4c --- /dev/null +++ b/mods/ITEMS/mcl_bows/models/mcl_bows_rocket.mtl @@ -0,0 +1,10 @@ +# Blender MTL File: 'None' +# Material Count: 1 + +newmtl None +Ns 500 +Ka 0.8 0.8 0.8 +Kd 0.8 0.8 0.8 +Ks 0.8 0.8 0.8 +d 1 +illum 2 diff --git a/mods/ITEMS/mcl_bows/models/mcl_bows_rocket.obj b/mods/ITEMS/mcl_bows/models/mcl_bows_rocket.obj new file mode 100644 index 000000000..e2bd11d34 --- /dev/null +++ b/mods/ITEMS/mcl_bows/models/mcl_bows_rocket.obj @@ -0,0 +1,1016 @@ +# Blender v3.0.0 Alpha OBJ File: '' +# www.blender.org +mtllib mcl_bows_rocket.mtl +o Plane +v -1.414214 -0.063116 0.000000 +v 0.000000 -0.063116 1.414214 +v -0.000000 -0.063116 -1.414214 +v 1.414214 -0.063116 -0.000000 +v -1.414214 -0.062205 0.000000 +v 0.000000 -0.062205 1.414214 +v -0.000000 -0.062205 -1.414214 +v 1.414214 -0.062205 -0.000000 +v -1.414214 -0.060838 0.000000 +v 0.000000 -0.060838 1.414214 +v -0.000000 -0.060838 -1.414214 +v 1.414214 -0.060838 -0.000000 +v -1.414214 -0.059926 0.000000 +v 0.000000 -0.059926 1.414214 +v -0.000000 -0.059926 -1.414214 +v 1.414214 -0.059926 -0.000000 +v -1.414214 -0.058559 0.000000 +v 0.000000 -0.058559 1.414214 +v -0.000000 -0.058559 -1.414214 +v 1.414214 -0.058559 -0.000000 +v -1.414214 -0.057648 0.000000 +v 0.000000 -0.057648 1.414214 +v -0.000000 -0.057648 -1.414214 +v 1.414214 -0.057648 -0.000000 +v -1.414214 -0.056281 0.000000 +v 0.000000 -0.056281 1.414214 +v -0.000000 -0.056281 -1.414214 +v 1.414214 -0.056281 -0.000000 +v -1.414214 -0.055369 0.000000 +v 0.000000 -0.055369 1.414214 +v -0.000000 -0.055369 -1.414214 +v 1.414214 -0.055369 -0.000000 +v -1.414214 -0.054002 0.000000 +v 0.000000 -0.054002 1.414214 +v -0.000000 -0.054002 -1.414214 +v 1.414214 -0.054002 -0.000000 +v -1.414214 -0.053091 0.000000 +v 0.000000 -0.053091 1.414214 +v -0.000000 -0.053091 -1.414214 +v 1.414214 -0.053091 -0.000000 +v -1.414214 -0.051723 0.000000 +v 0.000000 -0.051723 1.414214 +v -0.000000 -0.051723 -1.414214 +v 1.414214 -0.051723 -0.000000 +v -1.414214 -0.050812 0.000000 +v 0.000000 -0.050812 1.414214 +v -0.000000 -0.050812 -1.414214 +v 1.414214 -0.050812 -0.000000 +v -1.414214 -0.049445 0.000000 +v 0.000000 -0.049445 1.414214 +v -0.000000 -0.049445 -1.414214 +v 1.414214 -0.049445 -0.000000 +v -1.414214 -0.048533 0.000000 +v 0.000000 -0.048533 1.414214 +v -0.000000 -0.048533 -1.414214 +v 1.414214 -0.048533 -0.000000 +v -1.414214 -0.047166 0.000000 +v 0.000000 -0.047166 1.414214 +v -0.000000 -0.047166 -1.414214 +v 1.414214 -0.047166 -0.000000 +v -1.414214 -0.046255 0.000000 +v 0.000000 -0.046255 1.414214 +v -0.000000 -0.046255 -1.414214 +v 1.414214 -0.046255 -0.000000 +v -1.414214 -0.044888 0.000000 +v 0.000000 -0.044888 1.414214 +v -0.000000 -0.044888 -1.414214 +v 1.414214 -0.044888 -0.000000 +v -1.414214 -0.043976 0.000000 +v 0.000000 -0.043976 1.414214 +v -0.000000 -0.043976 -1.414214 +v 1.414214 -0.043976 -0.000000 +v -1.414214 -0.042609 0.000000 +v 0.000000 -0.042609 1.414214 +v -0.000000 -0.042609 -1.414214 +v 1.414214 -0.042609 -0.000000 +v -1.414214 -0.041698 0.000000 +v 0.000000 -0.041698 1.414214 +v -0.000000 -0.041698 -1.414214 +v 1.414214 -0.041698 -0.000000 +v -1.414214 -0.040331 0.000000 +v 0.000000 -0.040331 1.414214 +v -0.000000 -0.040331 -1.414214 +v 1.414214 -0.040331 -0.000000 +v -1.414214 -0.039419 0.000000 +v 0.000000 -0.039419 1.414214 +v -0.000000 -0.039419 -1.414214 +v 1.414214 -0.039419 -0.000000 +v -1.414214 -0.038052 0.000000 +v 0.000000 -0.038052 1.414214 +v -0.000000 -0.038052 -1.414214 +v 1.414214 -0.038052 -0.000000 +v -1.414214 -0.037141 0.000000 +v 0.000000 -0.037141 1.414214 +v -0.000000 -0.037141 -1.414214 +v 1.414214 -0.037141 -0.000000 +v -1.414214 -0.035773 0.000000 +v 0.000000 -0.035773 1.414214 +v -0.000000 -0.035773 -1.414214 +v 1.414214 -0.035773 -0.000000 +v -1.414214 -0.034862 0.000000 +v 0.000000 -0.034862 1.414214 +v -0.000000 -0.034862 -1.414214 +v 1.414214 -0.034862 -0.000000 +v -1.414214 -0.033495 0.000000 +v 0.000000 -0.033495 1.414214 +v -0.000000 -0.033495 -1.414214 +v 1.414214 -0.033495 -0.000000 +v -1.414214 -0.032583 0.000000 +v 0.000000 -0.032583 1.414214 +v -0.000000 -0.032583 -1.414214 +v 1.414214 -0.032583 -0.000000 +v -1.414214 -0.031216 0.000000 +v 0.000000 -0.031216 1.414214 +v -0.000000 -0.031216 -1.414214 +v 1.414214 -0.031216 -0.000000 +v -1.414214 -0.030305 0.000000 +v 0.000000 -0.030305 1.414214 +v -0.000000 -0.030305 -1.414214 +v 1.414214 -0.030305 -0.000000 +v -1.414214 -0.028938 0.000000 +v 0.000000 -0.028938 1.414214 +v -0.000000 -0.028938 -1.414214 +v 1.414214 -0.028938 -0.000000 +v -1.414214 -0.028026 0.000000 +v 0.000000 -0.028026 1.414214 +v -0.000000 -0.028026 -1.414214 +v 1.414214 -0.028026 -0.000000 +v -1.414214 -0.026659 0.000000 +v 0.000000 -0.026659 1.414214 +v -0.000000 -0.026659 -1.414214 +v 1.414214 -0.026659 -0.000000 +v -1.414214 -0.025748 0.000000 +v 0.000000 -0.025748 1.414214 +v -0.000000 -0.025748 -1.414214 +v 1.414214 -0.025748 -0.000000 +v -1.414214 -0.024381 0.000000 +v 0.000000 -0.024381 1.414214 +v -0.000000 -0.024381 -1.414214 +v 1.414214 -0.024381 -0.000000 +v -1.414214 -0.023469 0.000000 +v 0.000000 -0.023469 1.414214 +v -0.000000 -0.023469 -1.414214 +v 1.414214 -0.023469 -0.000000 +v -1.414214 -0.022102 0.000000 +v 0.000000 -0.022102 1.414214 +v -0.000000 -0.022102 -1.414214 +v 1.414214 -0.022102 -0.000000 +v -1.414214 -0.021191 0.000000 +v 0.000000 -0.021191 1.414214 +v -0.000000 -0.021191 -1.414214 +v 1.414214 -0.021191 -0.000000 +v -1.414214 -0.019824 0.000000 +v 0.000000 -0.019824 1.414214 +v -0.000000 -0.019824 -1.414214 +v 1.414214 -0.019824 -0.000000 +v -1.414214 -0.018912 0.000000 +v 0.000000 -0.018912 1.414214 +v -0.000000 -0.018912 -1.414214 +v 1.414214 -0.018912 -0.000000 +v -1.414214 -0.017545 0.000000 +v 0.000000 -0.017545 1.414214 +v -0.000000 -0.017545 -1.414214 +v 1.414214 -0.017545 -0.000000 +v -1.414214 -0.016634 0.000000 +v 0.000000 -0.016634 1.414214 +v -0.000000 -0.016634 -1.414214 +v 1.414214 -0.016634 -0.000000 +v -1.414214 -0.015266 0.000000 +v 0.000000 -0.015266 1.414214 +v -0.000000 -0.015266 -1.414214 +v 1.414214 -0.015266 -0.000000 +v -1.414214 -0.014355 0.000000 +v 0.000000 -0.014355 1.414214 +v -0.000000 -0.014355 -1.414214 +v 1.414214 -0.014355 -0.000000 +v -1.414214 -0.012988 0.000000 +v 0.000000 -0.012988 1.414214 +v -0.000000 -0.012988 -1.414214 +v 1.414214 -0.012988 -0.000000 +v -1.414214 -0.012076 0.000000 +v 0.000000 -0.012076 1.414214 +v -0.000000 -0.012076 -1.414214 +v 1.414214 -0.012076 -0.000000 +v -1.414214 -0.010709 0.000000 +v 0.000000 -0.010709 1.414214 +v -0.000000 -0.010709 -1.414214 +v 1.414214 -0.010709 -0.000000 +v -1.414214 -0.009798 0.000000 +v 0.000000 -0.009798 1.414214 +v -0.000000 -0.009798 -1.414214 +v 1.414214 -0.009798 -0.000000 +v -1.414214 -0.008431 0.000000 +v 0.000000 -0.008431 1.414214 +v -0.000000 -0.008431 -1.414214 +v 1.414214 -0.008431 -0.000000 +v -1.414214 -0.007519 0.000000 +v 0.000000 -0.007519 1.414214 +v -0.000000 -0.007519 -1.414214 +v 1.414214 -0.007519 -0.000000 +v -1.414214 -0.006152 0.000000 +v 0.000000 -0.006152 1.414214 +v -0.000000 -0.006152 -1.414214 +v 1.414214 -0.006152 -0.000000 +v -1.414214 -0.005241 0.000000 +v 0.000000 -0.005241 1.414214 +v -0.000000 -0.005241 -1.414214 +v 1.414214 -0.005241 -0.000000 +v -1.414214 -0.003874 0.000000 +v 0.000000 -0.003874 1.414214 +v -0.000000 -0.003874 -1.414214 +v 1.414214 -0.003874 -0.000000 +v -1.414214 -0.002962 0.000000 +v 0.000000 -0.002962 1.414214 +v -0.000000 -0.002962 -1.414214 +v 1.414214 -0.002962 -0.000000 +v -1.414214 -0.001595 0.000000 +v 0.000000 -0.001595 1.414214 +v -0.000000 -0.001595 -1.414214 +v 1.414214 -0.001595 -0.000000 +v -1.414214 -0.000684 0.000000 +v 0.000000 -0.000684 1.414214 +v -0.000000 -0.000684 -1.414214 +v 1.414214 -0.000684 -0.000000 +v -1.414214 0.000684 0.000000 +v 0.000000 0.000684 1.414214 +v -0.000000 0.000684 -1.414214 +v 1.414214 0.000684 -0.000000 +v -1.414214 0.001595 0.000000 +v 0.000000 0.001595 1.414214 +v -0.000000 0.001595 -1.414214 +v 1.414214 0.001595 -0.000000 +v -1.414214 0.002962 0.000000 +v 0.000000 0.002962 1.414214 +v -0.000000 0.002962 -1.414214 +v 1.414214 0.002962 -0.000000 +v -1.414214 0.003874 0.000000 +v 0.000000 0.003874 1.414214 +v -0.000000 0.003874 -1.414214 +v 1.414214 0.003874 -0.000000 +v -1.414214 0.005241 0.000000 +v 0.000000 0.005241 1.414214 +v -0.000000 0.005241 -1.414214 +v 1.414214 0.005241 -0.000000 +v -1.414214 0.006152 0.000000 +v 0.000000 0.006152 1.414214 +v -0.000000 0.006152 -1.414214 +v 1.414214 0.006152 -0.000000 +v -1.414214 0.007519 0.000000 +v 0.000000 0.007519 1.414214 +v -0.000000 0.007519 -1.414214 +v 1.414214 0.007519 -0.000000 +v -1.414214 0.008431 0.000000 +v 0.000000 0.008431 1.414214 +v -0.000000 0.008431 -1.414214 +v 1.414214 0.008431 -0.000000 +v -1.414214 0.009798 0.000000 +v 0.000000 0.009798 1.414214 +v -0.000000 0.009798 -1.414214 +v 1.414214 0.009798 -0.000000 +v -1.414214 0.010709 0.000000 +v 0.000000 0.010709 1.414214 +v -0.000000 0.010709 -1.414214 +v 1.414214 0.010709 -0.000000 +v -1.414214 0.012076 0.000000 +v 0.000000 0.012076 1.414214 +v -0.000000 0.012076 -1.414214 +v 1.414214 0.012076 -0.000000 +v -1.414214 0.012988 0.000000 +v 0.000000 0.012988 1.414214 +v -0.000000 0.012988 -1.414214 +v 1.414214 0.012988 -0.000000 +v -1.414214 0.014355 0.000000 +v 0.000000 0.014355 1.414214 +v -0.000000 0.014355 -1.414214 +v 1.414214 0.014355 -0.000000 +v -1.414214 0.015266 0.000000 +v 0.000000 0.015266 1.414214 +v -0.000000 0.015266 -1.414214 +v 1.414214 0.015266 -0.000000 +v -1.414214 0.016634 0.000000 +v 0.000000 0.016634 1.414214 +v -0.000000 0.016634 -1.414214 +v 1.414214 0.016634 -0.000000 +v -1.414214 0.017545 0.000000 +v 0.000000 0.017545 1.414214 +v -0.000000 0.017545 -1.414214 +v 1.414214 0.017545 -0.000000 +v -1.414214 0.018912 0.000000 +v 0.000000 0.018912 1.414214 +v -0.000000 0.018912 -1.414214 +v 1.414214 0.018912 -0.000000 +v -1.414214 0.019824 0.000000 +v 0.000000 0.019824 1.414214 +v -0.000000 0.019824 -1.414214 +v 1.414214 0.019824 -0.000000 +v -1.414214 0.021191 0.000000 +v 0.000000 0.021191 1.414214 +v -0.000000 0.021191 -1.414214 +v 1.414214 0.021191 -0.000000 +v -1.414214 0.022102 0.000000 +v 0.000000 0.022102 1.414214 +v -0.000000 0.022102 -1.414214 +v 1.414214 0.022102 -0.000000 +v -1.414214 0.023469 0.000000 +v 0.000000 0.023469 1.414214 +v -0.000000 0.023469 -1.414214 +v 1.414214 0.023469 -0.000000 +v -1.414214 0.024381 0.000000 +v 0.000000 0.024381 1.414214 +v -0.000000 0.024381 -1.414214 +v 1.414214 0.024381 -0.000000 +v -1.414214 0.025748 0.000000 +v 0.000000 0.025748 1.414214 +v -0.000000 0.025748 -1.414214 +v 1.414214 0.025748 -0.000000 +v -1.414214 0.026659 0.000000 +v 0.000000 0.026659 1.414214 +v -0.000000 0.026659 -1.414214 +v 1.414214 0.026659 -0.000000 +v -1.414214 0.028026 0.000000 +v 0.000000 0.028026 1.414214 +v -0.000000 0.028026 -1.414214 +v 1.414214 0.028026 -0.000000 +v -1.414214 0.028938 0.000000 +v 0.000000 0.028938 1.414214 +v -0.000000 0.028938 -1.414214 +v 1.414214 0.028938 -0.000000 +v -1.414214 0.030305 0.000000 +v 0.000000 0.030305 1.414214 +v -0.000000 0.030305 -1.414214 +v 1.414214 0.030305 -0.000000 +v -1.414214 0.031216 0.000000 +v 0.000000 0.031216 1.414214 +v -0.000000 0.031216 -1.414214 +v 1.414214 0.031216 -0.000000 +v -1.414214 0.032584 0.000000 +v 0.000000 0.032584 1.414214 +v -0.000000 0.032584 -1.414214 +v 1.414214 0.032584 -0.000000 +v -1.414214 0.033495 0.000000 +v 0.000000 0.033495 1.414214 +v -0.000000 0.033495 -1.414214 +v 1.414214 0.033495 -0.000000 +v -1.414214 0.034862 0.000000 +v 0.000000 0.034862 1.414214 +v -0.000000 0.034862 -1.414214 +v 1.414214 0.034862 -0.000000 +v -1.414214 0.035774 0.000000 +v 0.000000 0.035774 1.414214 +v -0.000000 0.035774 -1.414214 +v 1.414214 0.035774 -0.000000 +v -1.414214 0.037141 0.000000 +v 0.000000 0.037141 1.414214 +v -0.000000 0.037141 -1.414214 +v 1.414214 0.037141 -0.000000 +v -1.414214 0.038052 0.000000 +v 0.000000 0.038052 1.414214 +v -0.000000 0.038052 -1.414214 +v 1.414214 0.038052 -0.000000 +v -1.414214 0.039419 0.000000 +v 0.000000 0.039419 1.414214 +v -0.000000 0.039419 -1.414214 +v 1.414214 0.039419 -0.000000 +v -1.414214 0.040331 0.000000 +v 0.000000 0.040331 1.414214 +v -0.000000 0.040331 -1.414214 +v 1.414214 0.040331 -0.000000 +v -1.414214 0.041698 0.000000 +v 0.000000 0.041698 1.414214 +v -0.000000 0.041698 -1.414214 +v 1.414214 0.041698 -0.000000 +v -1.414214 0.042609 0.000000 +v 0.000000 0.042609 1.414214 +v -0.000000 0.042609 -1.414214 +v 1.414214 0.042609 -0.000000 +v -1.414214 0.043976 0.000000 +v 0.000000 0.043976 1.414214 +v -0.000000 0.043976 -1.414214 +v 1.414214 0.043976 -0.000000 +v -1.414214 0.044888 0.000000 +v 0.000000 0.044888 1.414214 +v -0.000000 0.044888 -1.414214 +v 1.414214 0.044888 -0.000000 +v -1.414214 0.046255 0.000000 +v 0.000000 0.046255 1.414214 +v -0.000000 0.046255 -1.414214 +v 1.414214 0.046255 -0.000000 +v -1.414214 0.047166 0.000000 +v 0.000000 0.047166 1.414214 +v -0.000000 0.047166 -1.414214 +v 1.414214 0.047166 -0.000000 +v -1.414214 0.048533 0.000000 +v 0.000000 0.048533 1.414214 +v -0.000000 0.048533 -1.414214 +v 1.414214 0.048533 -0.000000 +v -1.414214 0.049445 0.000000 +v 0.000000 0.049445 1.414214 +v -0.000000 0.049445 -1.414214 +v 1.414214 0.049445 -0.000000 +v -1.414214 0.050812 0.000000 +v 0.000000 0.050812 1.414214 +v -0.000000 0.050812 -1.414214 +v 1.414214 0.050812 -0.000000 +v -1.414214 0.051723 0.000000 +v 0.000000 0.051723 1.414214 +v -0.000000 0.051723 -1.414214 +v 1.414214 0.051723 -0.000000 +v -1.414214 0.053091 0.000000 +v 0.000000 0.053091 1.414214 +v -0.000000 0.053091 -1.414214 +v 1.414214 0.053091 -0.000000 +v -1.414214 0.054002 0.000000 +v 0.000000 0.054002 1.414214 +v -0.000000 0.054002 -1.414214 +v 1.414214 0.054002 -0.000000 +v -1.414214 0.055369 0.000000 +v 0.000000 0.055369 1.414214 +v -0.000000 0.055369 -1.414214 +v 1.414214 0.055369 -0.000000 +v -1.414214 0.056281 0.000000 +v 0.000000 0.056281 1.414214 +v -0.000000 0.056281 -1.414214 +v 1.414214 0.056281 -0.000000 +v -1.414214 0.057648 0.000000 +v 0.000000 0.057648 1.414214 +v -0.000000 0.057648 -1.414214 +v 1.414214 0.057648 -0.000000 +v -1.414214 0.058559 0.000000 +v 0.000000 0.058559 1.414214 +v -0.000000 0.058559 -1.414214 +v 1.414214 0.058559 -0.000000 +v -1.414214 0.059926 0.000000 +v 0.000000 0.059926 1.414214 +v -0.000000 0.059926 -1.414214 +v 1.414214 0.059926 -0.000000 +v -1.414214 0.060838 0.000000 +v 0.000000 0.060838 1.414214 +v -0.000000 0.060838 -1.414214 +v 1.414214 0.060838 -0.000000 +v -1.414214 0.062205 0.000000 +v 0.000000 0.062205 1.414214 +v -0.000000 0.062205 -1.414214 +v 1.414214 0.062205 -0.000000 +v -1.414214 0.063116 0.000000 +v 0.000000 0.063116 1.414214 +v -0.000000 0.063116 -1.414214 +v 1.414214 0.063116 -0.000000 +vt 0.000000 0.000000 +vt 0.000000 1.000000 +vt 1.000000 1.000000 +vt 1.000000 0.000000 +vt 0.000000 0.000000 +vt 1.000000 0.000000 +vt 1.000000 1.000000 +vt 0.000000 1.000000 +vt 0.000000 0.000000 +vt 0.000000 1.000000 +vt 1.000000 1.000000 +vt 1.000000 0.000000 +vt 0.000000 0.000000 +vt 1.000000 0.000000 +vt 1.000000 1.000000 +vt 0.000000 1.000000 +vt 0.000000 0.000000 +vt 0.000000 1.000000 +vt 1.000000 1.000000 +vt 1.000000 0.000000 +vt 0.000000 0.000000 +vt 1.000000 0.000000 +vt 1.000000 1.000000 +vt 0.000000 1.000000 +vt 0.000000 0.000000 +vt 0.000000 1.000000 +vt 1.000000 1.000000 +vt 1.000000 0.000000 +vt 0.000000 0.000000 +vt 1.000000 0.000000 +vt 1.000000 1.000000 +vt 0.000000 1.000000 +vt 0.000000 0.000000 +vt 0.000000 1.000000 +vt 1.000000 1.000000 +vt 1.000000 0.000000 +vt 0.000000 0.000000 +vt 1.000000 0.000000 +vt 1.000000 1.000000 +vt 0.000000 1.000000 +vt 0.000000 0.000000 +vt 0.000000 1.000000 +vt 1.000000 1.000000 +vt 1.000000 0.000000 +vt 0.000000 0.000000 +vt 1.000000 0.000000 +vt 1.000000 1.000000 +vt 0.000000 1.000000 +vt 0.000000 0.000000 +vt 0.000000 1.000000 +vt 1.000000 1.000000 +vt 1.000000 0.000000 +vt 0.000000 0.000000 +vt 1.000000 0.000000 +vt 1.000000 1.000000 +vt 0.000000 1.000000 +vt 0.000000 0.000000 +vt 0.000000 1.000000 +vt 1.000000 1.000000 +vt 1.000000 0.000000 +vt 0.000000 0.000000 +vt 1.000000 0.000000 +vt 1.000000 1.000000 +vt 0.000000 1.000000 +vt 0.000000 0.000000 +vt 0.000000 1.000000 +vt 1.000000 1.000000 +vt 1.000000 0.000000 +vt 0.000000 0.000000 +vt 1.000000 0.000000 +vt 1.000000 1.000000 +vt 0.000000 1.000000 +vt 0.000000 0.000000 +vt 0.000000 1.000000 +vt 1.000000 1.000000 +vt 1.000000 0.000000 +vt 0.000000 0.000000 +vt 1.000000 0.000000 +vt 1.000000 1.000000 +vt 0.000000 1.000000 +vt 0.000000 0.000000 +vt 0.000000 1.000000 +vt 1.000000 1.000000 +vt 1.000000 0.000000 +vt 0.000000 0.000000 +vt 1.000000 0.000000 +vt 1.000000 1.000000 +vt 0.000000 1.000000 +vt 0.000000 0.000000 +vt 0.000000 1.000000 +vt 1.000000 1.000000 +vt 1.000000 0.000000 +vt 0.000000 0.000000 +vt 1.000000 0.000000 +vt 1.000000 1.000000 +vt 0.000000 1.000000 +vt 0.000000 0.000000 +vt 0.000000 1.000000 +vt 1.000000 1.000000 +vt 1.000000 0.000000 +vt 0.000000 0.000000 +vt 1.000000 0.000000 +vt 1.000000 1.000000 +vt 0.000000 1.000000 +vt 0.000000 0.000000 +vt 0.000000 1.000000 +vt 1.000000 1.000000 +vt 1.000000 0.000000 +vt 0.000000 0.000000 +vt 1.000000 0.000000 +vt 1.000000 1.000000 +vt 0.000000 1.000000 +vt 0.000000 0.000000 +vt 0.000000 1.000000 +vt 1.000000 1.000000 +vt 1.000000 0.000000 +vt 0.000000 0.000000 +vt 1.000000 0.000000 +vt 1.000000 1.000000 +vt 0.000000 1.000000 +vt 0.000000 0.000000 +vt 0.000000 1.000000 +vt 1.000000 1.000000 +vt 1.000000 0.000000 +vt 0.000000 0.000000 +vt 1.000000 0.000000 +vt 1.000000 1.000000 +vt 0.000000 1.000000 +vt 0.000000 0.000000 +vt 0.000000 1.000000 +vt 1.000000 1.000000 +vt 1.000000 0.000000 +vt 0.000000 0.000000 +vt 1.000000 0.000000 +vt 1.000000 1.000000 +vt 0.000000 1.000000 +vt 0.000000 0.000000 +vt 0.000000 1.000000 +vt 1.000000 1.000000 +vt 1.000000 0.000000 +vt 0.000000 0.000000 +vt 1.000000 0.000000 +vt 1.000000 1.000000 +vt 0.000000 1.000000 +vt 0.000000 0.000000 +vt 0.000000 1.000000 +vt 1.000000 1.000000 +vt 1.000000 0.000000 +vt 0.000000 0.000000 +vt 1.000000 0.000000 +vt 1.000000 1.000000 +vt 0.000000 1.000000 +vt 0.000000 0.000000 +vt 0.000000 1.000000 +vt 1.000000 1.000000 +vt 1.000000 0.000000 +vt 0.000000 0.000000 +vt 1.000000 0.000000 +vt 1.000000 1.000000 +vt 0.000000 1.000000 +vt 0.000000 0.000000 +vt 0.000000 1.000000 +vt 1.000000 1.000000 +vt 1.000000 0.000000 +vt 0.000000 0.000000 +vt 1.000000 0.000000 +vt 1.000000 1.000000 +vt 0.000000 1.000000 +vt 0.000000 0.000000 +vt 0.000000 1.000000 +vt 1.000000 1.000000 +vt 1.000000 0.000000 +vt 0.000000 0.000000 +vt 1.000000 0.000000 +vt 1.000000 1.000000 +vt 0.000000 1.000000 +vt 0.000000 0.000000 +vt 0.000000 1.000000 +vt 1.000000 1.000000 +vt 1.000000 0.000000 +vt 0.000000 0.000000 +vt 1.000000 0.000000 +vt 1.000000 1.000000 +vt 0.000000 1.000000 +vt 0.000000 0.000000 +vt 0.000000 1.000000 +vt 1.000000 1.000000 +vt 1.000000 0.000000 +vt 0.000000 0.000000 +vt 1.000000 0.000000 +vt 1.000000 1.000000 +vt 0.000000 1.000000 +vt 0.000000 0.000000 +vt 0.000000 1.000000 +vt 1.000000 1.000000 +vt 1.000000 0.000000 +vt 0.000000 0.000000 +vt 1.000000 0.000000 +vt 1.000000 1.000000 +vt 0.000000 1.000000 +vt 0.000000 0.000000 +vt 0.000000 1.000000 +vt 1.000000 1.000000 +vt 1.000000 0.000000 +vt 0.000000 0.000000 +vt 1.000000 0.000000 +vt 1.000000 1.000000 +vt 0.000000 1.000000 +vt 0.000000 0.000000 +vt 0.000000 1.000000 +vt 1.000000 1.000000 +vt 1.000000 0.000000 +vt 0.000000 0.000000 +vt 1.000000 0.000000 +vt 1.000000 1.000000 +vt 0.000000 1.000000 +vt 0.000000 0.000000 +vt 0.000000 1.000000 +vt 1.000000 1.000000 +vt 1.000000 0.000000 +vt 0.000000 0.000000 +vt 1.000000 0.000000 +vt 1.000000 1.000000 +vt 0.000000 1.000000 +vt 0.000000 0.000000 +vt 0.000000 1.000000 +vt 1.000000 1.000000 +vt 1.000000 0.000000 +vt 0.000000 0.000000 +vt 1.000000 0.000000 +vt 1.000000 1.000000 +vt 0.000000 1.000000 +vt 0.000000 0.000000 +vt 0.000000 1.000000 +vt 1.000000 1.000000 +vt 1.000000 0.000000 +vt 0.000000 0.000000 +vt 1.000000 0.000000 +vt 1.000000 1.000000 +vt 0.000000 1.000000 +vt 0.000000 0.000000 +vt 0.000000 1.000000 +vt 1.000000 1.000000 +vt 1.000000 0.000000 +vt 0.000000 0.000000 +vt 1.000000 0.000000 +vt 1.000000 1.000000 +vt 0.000000 1.000000 +vt 0.000000 0.000000 +vt 0.000000 1.000000 +vt 1.000000 1.000000 +vt 1.000000 0.000000 +vt 0.000000 0.000000 +vt 1.000000 0.000000 +vt 1.000000 1.000000 +vt 0.000000 1.000000 +vt 0.000000 0.000000 +vt 0.000000 1.000000 +vt 1.000000 1.000000 +vt 1.000000 0.000000 +vt 0.000000 0.000000 +vt 1.000000 0.000000 +vt 1.000000 1.000000 +vt 0.000000 1.000000 +vt 0.000000 0.000000 +vt 0.000000 1.000000 +vt 1.000000 1.000000 +vt 1.000000 0.000000 +vt 0.000000 0.000000 +vt 1.000000 0.000000 +vt 1.000000 1.000000 +vt 0.000000 1.000000 +vt 0.000000 0.000000 +vt 0.000000 1.000000 +vt 1.000000 1.000000 +vt 1.000000 0.000000 +vt 0.000000 0.000000 +vt 1.000000 0.000000 +vt 1.000000 1.000000 +vt 0.000000 1.000000 +vt 0.000000 0.000000 +vt 0.000000 1.000000 +vt 1.000000 1.000000 +vt 1.000000 0.000000 +vt 0.000000 0.000000 +vt 1.000000 0.000000 +vt 1.000000 1.000000 +vt 0.000000 1.000000 +vt 0.000000 0.000000 +vt 0.000000 1.000000 +vt 1.000000 1.000000 +vt 1.000000 0.000000 +vt 0.000000 0.000000 +vt 1.000000 0.000000 +vt 1.000000 1.000000 +vt 0.000000 1.000000 +vt 0.000000 0.000000 +vt 0.000000 1.000000 +vt 1.000000 1.000000 +vt 1.000000 0.000000 +vt 0.000000 0.000000 +vt 1.000000 0.000000 +vt 1.000000 1.000000 +vt 0.000000 1.000000 +vt 0.000000 0.000000 +vt 0.000000 1.000000 +vt 1.000000 1.000000 +vt 1.000000 0.000000 +vt 0.000000 0.000000 +vt 1.000000 0.000000 +vt 1.000000 1.000000 +vt 0.000000 1.000000 +vt 0.000000 0.000000 +vt 0.000000 1.000000 +vt 1.000000 1.000000 +vt 1.000000 0.000000 +vt 0.000000 0.000000 +vt 1.000000 0.000000 +vt 1.000000 1.000000 +vt 0.000000 1.000000 +vt 0.000000 0.000000 +vt 0.000000 1.000000 +vt 1.000000 1.000000 +vt 1.000000 0.000000 +vt 0.000000 0.000000 +vt 1.000000 0.000000 +vt 1.000000 1.000000 +vt 0.000000 1.000000 +vt 0.000000 0.000000 +vt 0.000000 1.000000 +vt 1.000000 1.000000 +vt 1.000000 0.000000 +vt 0.000000 0.000000 +vt 1.000000 0.000000 +vt 1.000000 1.000000 +vt 0.000000 1.000000 +vt 0.000000 0.000000 +vt 0.000000 1.000000 +vt 1.000000 1.000000 +vt 1.000000 0.000000 +vt 0.000000 0.000000 +vt 1.000000 0.000000 +vt 1.000000 1.000000 +vt 0.000000 1.000000 +vt 0.000000 0.000000 +vt 0.000000 1.000000 +vt 1.000000 1.000000 +vt 1.000000 0.000000 +vt 0.000000 0.000000 +vt 1.000000 0.000000 +vt 1.000000 1.000000 +vt 0.000000 1.000000 +vt 0.000000 0.000000 +vt 0.000000 1.000000 +vt 1.000000 1.000000 +vt 1.000000 0.000000 +vt 0.000000 0.000000 +vt 1.000000 0.000000 +vt 1.000000 1.000000 +vt 0.000000 1.000000 +vt 0.000000 0.000000 +vt 0.000000 1.000000 +vt 1.000000 1.000000 +vt 1.000000 0.000000 +vt 0.000000 0.000000 +vt 1.000000 0.000000 +vt 1.000000 1.000000 +vt 0.000000 1.000000 +vt 0.000000 0.000000 +vt 0.000000 1.000000 +vt 1.000000 1.000000 +vt 1.000000 0.000000 +vt 0.000000 0.000000 +vt 1.000000 0.000000 +vt 1.000000 1.000000 +vt 0.000000 1.000000 +vt 0.000000 0.000000 +vt 0.000000 1.000000 +vt 1.000000 1.000000 +vt 1.000000 0.000000 +vt 0.000000 0.000000 +vt 1.000000 0.000000 +vt 1.000000 1.000000 +vt 0.000000 1.000000 +vt 0.000000 0.000000 +vt 0.000000 1.000000 +vt 1.000000 1.000000 +vt 1.000000 0.000000 +vt 0.000000 0.000000 +vt 1.000000 0.000000 +vt 1.000000 1.000000 +vt 0.000000 1.000000 +vt 0.000000 0.000000 +vt 0.000000 1.000000 +vt 1.000000 1.000000 +vt 1.000000 0.000000 +vt 0.000000 0.000000 +vt 1.000000 0.000000 +vt 1.000000 1.000000 +vt 0.000000 1.000000 +vt 0.000000 0.000000 +vt 0.000000 1.000000 +vt 1.000000 1.000000 +vt 1.000000 0.000000 +vt 0.000000 0.000000 +vt 1.000000 0.000000 +vt 1.000000 1.000000 +vt 0.000000 1.000000 +vt 0.000000 0.000000 +vt 0.000000 1.000000 +vt 1.000000 1.000000 +vt 1.000000 0.000000 +vt 0.000000 0.000000 +vt 1.000000 0.000000 +vt 1.000000 1.000000 +vt 0.000000 1.000000 +vt 0.000000 0.000000 +vt 0.000000 1.000000 +vt 1.000000 1.000000 +vt 1.000000 0.000000 +vt 0.000000 0.000000 +vt 1.000000 0.000000 +vt 1.000000 1.000000 +vt 0.000000 1.000000 +vt 0.000000 0.000000 +vt 0.000000 1.000000 +vt 1.000000 1.000000 +vt 1.000000 0.000000 +vt 0.000000 0.000000 +vt 1.000000 0.000000 +vt 1.000000 1.000000 +vt 0.000000 1.000000 +vt 0.000000 0.000000 +vt 0.000000 1.000000 +vt 1.000000 1.000000 +vt 1.000000 0.000000 +vt 0.000000 0.000000 +vt 1.000000 0.000000 +vt 1.000000 1.000000 +vt 0.000000 1.000000 +vt 0.000000 0.000000 +vt 0.000000 1.000000 +vt 1.000000 1.000000 +vt 1.000000 0.000000 +vt 0.000000 0.000000 +vt 1.000000 0.000000 +vt 1.000000 1.000000 +vt 0.000000 1.000000 +vn 0.0000 -1.0000 0.0000 +vn 0.0000 1.0000 0.0000 +usemtl None +s off +f 1/1/1 3/2/1 4/3/1 2/4/1 +f 5/5/2 6/6/2 8/7/2 7/8/2 +f 9/9/1 11/10/1 12/11/1 10/12/1 +f 13/13/2 14/14/2 16/15/2 15/16/2 +f 17/17/1 19/18/1 20/19/1 18/20/1 +f 21/21/2 22/22/2 24/23/2 23/24/2 +f 25/25/1 27/26/1 28/27/1 26/28/1 +f 29/29/2 30/30/2 32/31/2 31/32/2 +f 33/33/1 35/34/1 36/35/1 34/36/1 +f 37/37/2 38/38/2 40/39/2 39/40/2 +f 41/41/1 43/42/1 44/43/1 42/44/1 +f 45/45/2 46/46/2 48/47/2 47/48/2 +f 49/49/1 51/50/1 52/51/1 50/52/1 +f 53/53/2 54/54/2 56/55/2 55/56/2 +f 57/57/1 59/58/1 60/59/1 58/60/1 +f 61/61/2 62/62/2 64/63/2 63/64/2 +f 65/65/1 67/66/1 68/67/1 66/68/1 +f 69/69/2 70/70/2 72/71/2 71/72/2 +f 73/73/1 75/74/1 76/75/1 74/76/1 +f 77/77/2 78/78/2 80/79/2 79/80/2 +f 81/81/1 83/82/1 84/83/1 82/84/1 +f 85/85/2 86/86/2 88/87/2 87/88/2 +f 89/89/1 91/90/1 92/91/1 90/92/1 +f 93/93/2 94/94/2 96/95/2 95/96/2 +f 97/97/1 99/98/1 100/99/1 98/100/1 +f 101/101/2 102/102/2 104/103/2 103/104/2 +f 105/105/1 107/106/1 108/107/1 106/108/1 +f 109/109/2 110/110/2 112/111/2 111/112/2 +f 113/113/1 115/114/1 116/115/1 114/116/1 +f 117/117/2 118/118/2 120/119/2 119/120/2 +f 121/121/1 123/122/1 124/123/1 122/124/1 +f 125/125/2 126/126/2 128/127/2 127/128/2 +f 129/129/1 131/130/1 132/131/1 130/132/1 +f 133/133/2 134/134/2 136/135/2 135/136/2 +f 137/137/1 139/138/1 140/139/1 138/140/1 +f 141/141/2 142/142/2 144/143/2 143/144/2 +f 145/145/1 147/146/1 148/147/1 146/148/1 +f 149/149/2 150/150/2 152/151/2 151/152/2 +f 153/153/1 155/154/1 156/155/1 154/156/1 +f 157/157/2 158/158/2 160/159/2 159/160/2 +f 161/161/1 163/162/1 164/163/1 162/164/1 +f 165/165/2 166/166/2 168/167/2 167/168/2 +f 169/169/1 171/170/1 172/171/1 170/172/1 +f 173/173/2 174/174/2 176/175/2 175/176/2 +f 177/177/1 179/178/1 180/179/1 178/180/1 +f 181/181/2 182/182/2 184/183/2 183/184/2 +f 185/185/1 187/186/1 188/187/1 186/188/1 +f 189/189/2 190/190/2 192/191/2 191/192/2 +f 193/193/1 195/194/1 196/195/1 194/196/1 +f 197/197/2 198/198/2 200/199/2 199/200/2 +f 201/201/1 203/202/1 204/203/1 202/204/1 +f 205/205/2 206/206/2 208/207/2 207/208/2 +f 209/209/1 211/210/1 212/211/1 210/212/1 +f 213/213/2 214/214/2 216/215/2 215/216/2 +f 217/217/1 219/218/1 220/219/1 218/220/1 +f 221/221/2 222/222/2 224/223/2 223/224/2 +f 225/225/1 227/226/1 228/227/1 226/228/1 +f 229/229/2 230/230/2 232/231/2 231/232/2 +f 233/233/1 235/234/1 236/235/1 234/236/1 +f 237/237/2 238/238/2 240/239/2 239/240/2 +f 241/241/1 243/242/1 244/243/1 242/244/1 +f 245/245/2 246/246/2 248/247/2 247/248/2 +f 249/249/1 251/250/1 252/251/1 250/252/1 +f 253/253/2 254/254/2 256/255/2 255/256/2 +f 257/257/1 259/258/1 260/259/1 258/260/1 +f 261/261/2 262/262/2 264/263/2 263/264/2 +f 265/265/1 267/266/1 268/267/1 266/268/1 +f 269/269/2 270/270/2 272/271/2 271/272/2 +f 273/273/1 275/274/1 276/275/1 274/276/1 +f 277/277/2 278/278/2 280/279/2 279/280/2 +f 281/281/1 283/282/1 284/283/1 282/284/1 +f 285/285/2 286/286/2 288/287/2 287/288/2 +f 289/289/1 291/290/1 292/291/1 290/292/1 +f 293/293/2 294/294/2 296/295/2 295/296/2 +f 297/297/1 299/298/1 300/299/1 298/300/1 +f 301/301/2 302/302/2 304/303/2 303/304/2 +f 305/305/1 307/306/1 308/307/1 306/308/1 +f 309/309/2 310/310/2 312/311/2 311/312/2 +f 313/313/1 315/314/1 316/315/1 314/316/1 +f 317/317/2 318/318/2 320/319/2 319/320/2 +f 321/321/1 323/322/1 324/323/1 322/324/1 +f 325/325/2 326/326/2 328/327/2 327/328/2 +f 329/329/1 331/330/1 332/331/1 330/332/1 +f 333/333/2 334/334/2 336/335/2 335/336/2 +f 337/337/1 339/338/1 340/339/1 338/340/1 +f 341/341/2 342/342/2 344/343/2 343/344/2 +f 345/345/1 347/346/1 348/347/1 346/348/1 +f 349/349/2 350/350/2 352/351/2 351/352/2 +f 353/353/1 355/354/1 356/355/1 354/356/1 +f 357/357/2 358/358/2 360/359/2 359/360/2 +f 361/361/1 363/362/1 364/363/1 362/364/1 +f 365/365/2 366/366/2 368/367/2 367/368/2 +f 369/369/1 371/370/1 372/371/1 370/372/1 +f 373/373/2 374/374/2 376/375/2 375/376/2 +f 377/377/1 379/378/1 380/379/1 378/380/1 +f 381/381/2 382/382/2 384/383/2 383/384/2 +f 385/385/1 387/386/1 388/387/1 386/388/1 +f 389/389/2 390/390/2 392/391/2 391/392/2 +f 393/393/1 395/394/1 396/395/1 394/396/1 +f 397/397/2 398/398/2 400/399/2 399/400/2 +f 401/401/1 403/402/1 404/403/1 402/404/1 +f 405/405/2 406/406/2 408/407/2 407/408/2 +f 409/409/1 411/410/1 412/411/1 410/412/1 +f 413/413/2 414/414/2 416/415/2 415/416/2 +f 417/417/1 419/418/1 420/419/1 418/420/1 +f 421/421/2 422/422/2 424/423/2 423/424/2 +f 425/425/1 427/426/1 428/427/1 426/428/1 +f 429/429/2 430/430/2 432/431/2 431/432/2 +f 433/433/1 435/434/1 436/435/1 434/436/1 +f 437/437/2 438/438/2 440/439/2 439/440/2 +f 441/441/1 443/442/1 444/443/1 442/444/1 +f 445/445/2 446/446/2 448/447/2 447/448/2 diff --git a/mods/ITEMS/mcl_bows/rocket.lua b/mods/ITEMS/mcl_bows/rocket.lua new file mode 100644 index 000000000..678aba4d4 --- /dev/null +++ b/mods/ITEMS/mcl_bows/rocket.lua @@ -0,0 +1,706 @@ +local S = minetest.get_translator(minetest.get_current_modname()) + +local math = math +local vector = vector + +-- Time in seconds after which a stuck arrow is deleted +local ARROW_TIMEOUT = 1 +-- Time after which stuck arrow is rechecked for being stuck +local STUCK_RECHECK_TIME = 0.1 + +--local GRAVITY = 9.81 + +local YAW_OFFSET = -math.pi/2 + +local function dir_to_pitch(dir) + --local dir2 = vector.normalize(dir) + local xz = math.abs(dir.x) + math.abs(dir.z) + return -math.atan2(-dir.y, xz) +end + +local function random_arrow_positions(positions, placement) + if positions == "x" then + return math.random(-4, 4) + elseif positions == "y" then + return math.random(0, 10) + end + if placement == "front" and positions == "z" then + return 3 + elseif placement == "back" and positions == "z" then + return -3 + end + return 0 +end + +local function damage_explosion(self, damagemulitplier) + mcl_explosions.explode(self.object:get_pos(), 3, {}) + local objects = minetest.get_objects_inside_radius(self.object:get_pos(), 8) + for _,obj in pairs(objects) do + if obj:is_player() then + mcl_util.deal_damage(obj, damagemulitplier - vector.distance(self.object:get_pos(), obj:get_pos()), {type = "explosion"}) + elseif obj:get_luaentity()._cmi_is_mob then + obj:punch(self.object, 1.0, { + full_punch_interval=1.0, + damage_groups={fleshy=damagemulitplier - vector.distance(self.object:get_pos(), obj:get_pos())}, + }, self.object:get_velocity()) + end + end +end + +local function particle_explosion(self) + local particle_pattern = math.random(1, 3) + local fpitch = 0 + local true_type = "" + local type = math.random(1,2) + local size = math.random(1,3) + local colors = {"red", "yellow", "blue", "green", "white"} + local this_colors = {colors[math.random(#colors)], colors[math.random(#colors)], colors[math.random(#colors)]} + + if size == 1 then + fpitch = math.random(200, 300) + elseif size == 2 then + fpitch = math.random(100, 130) + else + fpitch = math.random(60, 70) + end + + if type == 1 then + true_type = "Popper" + else + true_type = "Floof" + end + + if type == 1 then + minetest.sound_play("mcl_bows_firework", { + pos = self.object:get_pos(), + max_hear_distance = 100, + gain = 3.0, + pitch = fpitch/100 + }, true) + else + minetest.sound_play("mcl_bows_firework_soft", { + pos = self.object:get_pos(), + max_hear_distance = 100, + gain = 4.0, + pitch = fpitch/100 + }, true) + end + + if particle_pattern == 1 then + minetest.add_particlespawner({ + amount = 400 * size, + time = 0.0001, + minpos = self.object:get_pos(), + maxpos = self.object:get_pos(), + minvel = vector.new(-7 * size,-7 * size,-7 * size), + maxvel = vector.new(7 * size,7 * size,7 * size), + minexptime = .6 * size / 2, + maxexptime = .9 * size / 2, + minsize = 2 * size, + maxsize = 3 * size, + collisiondetection = false, + vertical = false, + texture = "mcl_bows_firework_"..this_colors[1]..".png", + glow = 14, + }) + minetest.add_particlespawner({ + amount = 400 * size, + time = 0.0001, + minpos = self.object:get_pos(), + maxpos = self.object:get_pos(), + minvel = vector.new(-2 * size,-2 * size,-2 * size), + maxvel = vector.new(2 * size,2 * size,2 * size), + minexptime = .6 * size / 2, + maxexptime = .9 * size / 2, + minsize = 2 * size, + maxsize = 3 * size, + collisiondetection = false, + vertical = false, + texture = "mcl_bows_firework_"..this_colors[2]..".png", + glow = 14, + }) + minetest.add_particlespawner({ + amount = 100 * size, + time = 0.0001, + minpos = self.object:get_pos(), + maxpos = self.object:get_pos(), + minvel = vector.new(-14 * size,-14 * size,-14 * size), + maxvel = vector.new(14 * size,14 * size,14 * size), + minexptime = .6 * size / 2, + maxexptime = .9 * size / 2, + minsize = 2 * size, + maxsize = 3 * size, + collisiondetection = false, + vertical = false, + texture = "mcl_bows_firework_"..this_colors[3]..".png", + glow = 14, + }) + elseif particle_pattern == 2 then + + minetest.add_particlespawner({ + amount = 240 * size, + time = 0.0001, + minpos = self.object:get_pos(), + maxpos = self.object:get_pos(), + minvel = vector.new(-5 * size,-5 * size,-5 * size), + maxvel = vector.new(5 * size,5 * size,5 * size), + minexptime = .6 * size / 2, + maxexptime = .9 * size / 2, + minsize = 2 * size, + maxsize = 3 * size, + collisiondetection = false, + vertical = false, + texture = "mcl_bows_firework_"..this_colors[1]..".png", + glow = 14, + }) + minetest.add_particlespawner({ + amount = 500 * size, + time = 0.0001, + minpos = self.object:get_pos(), + maxpos = self.object:get_pos(), + minvel = vector.new(-2 * size,-2 * size,-2 * size), + maxvel = vector.new(2 * size,2 * size,2 * size), + minexptime = .6 * size / 2, + maxexptime = .9 * size / 2, + minsize = 2 * size, + maxsize = 3 * size, + collisiondetection = false, + vertical = false, + texture = "mcl_bows_firework_"..this_colors[2]..".png", + glow = 14, + }) + minetest.add_particlespawner({ + amount = 350 * size, + time = 0.0001, + minpos = self.object:get_pos(), + maxpos = self.object:get_pos(), + minvel = vector.new(-3 * size,-3 * size,-3 * size), + maxvel = vector.new(3 * size,3 * size,3 * size), + minexptime = .6 * size / 2, + maxexptime = .9 * size / 2, + minsize = 2 * size, + maxsize = 3 * size, + collisiondetection = false, + vertical = false, + texture = "mcl_bows_firework_"..this_colors[3]..".png", + glow = 14, + }) + elseif particle_pattern == 3 then + + minetest.add_particlespawner({ + amount = 400 * size, + time = 0.0001, + minpos = self.object:get_pos(), + maxpos = self.object:get_pos(), + minvel = vector.new(-6 * size,-4 * size,-6 * size), + maxvel = vector.new(6 * size,4 * size,6 * size), + minexptime = .6 * size, + maxexptime = .9 * size, + minsize = 2 * size, + maxsize = 3 * size, + collisiondetection = false, + vertical = false, + texture = "mcl_bows_firework_"..this_colors[1]..".png", + glow = 14, + }) + minetest.add_particlespawner({ + amount = 120 * size, + time = 0.0001, + minpos = self.object:get_pos(), + maxpos = self.object:get_pos(), + minvel = vector.new(-8 * size,6 * size,-8 * size), + maxvel = vector.new(8 * size,6 * size,8 * size), + minexptime = .6 * size, + maxexptime = .9 * size, + minsize = 2 * size, + maxsize = 3 * size, + collisiondetection = false, + vertical = false, + texture = "mcl_bows_firework_"..this_colors[2]..".png", + glow = 14, + }) + minetest.add_particlespawner({ + amount = 130 * size, + time = 0.0001, + minpos = self.object:get_pos(), + maxpos = self.object:get_pos(), + minvel = vector.new(-3 * size,3 * size,-3 * size), + maxvel = vector.new(3 * size,3 * size,3 * size), + minexptime = .6 * size, + maxexptime = .9 * size, + minsize = 2 * size, + maxsize = 3 * size, + collisiondetection = false, + vertical = false, + texture = "mcl_bows_firework_"..this_colors[3]..".png", + glow = 14, + }) + end + + return size + +end + +local mod_awards = minetest.get_modpath("awards") and minetest.get_modpath("mcl_achievements") +local mod_button = minetest.get_modpath("mesecons_button") + +minetest.register_craftitem("mcl_bows:rocket", { + description = S("Arrow"), + _tt_help = S("Ammunition").."\n"..S("Damage from bow: 1-10").."\n"..S("Damage from dispenser: 3"), + _doc_items_longdesc = S("Arrows are ammunition for bows and dispensers.").."\n".. +S("An arrow fired from a bow has a regular damage of 1-9. At full charge, there's a 20% chance of a critical hit dealing 10 damage instead. An arrow fired from a dispenser always deals 3 damage.").."\n".. +S("Arrows might get stuck on solid blocks and can be retrieved again. They are also capable of pushing wooden buttons."), + _doc_items_usagehelp = S("To use arrows as ammunition for a bow, just put them anywhere in your inventory, they will be used up automatically. To use arrows as ammunition for a dispenser, place them in the dispenser's inventory. To retrieve an arrow that sticks in a block, simply walk close to it."), + inventory_image = "mcl_bows_rocket.png", + groups = { ammo=1, ammo_crossbow=1, ammo_bow_regular=1 }, + _on_dispense = function(itemstack, dispenserpos, droppos, dropnode, dropdir) + -- Shoot arrow + local shootpos = vector.add(dispenserpos, vector.multiply(dropdir, 0.51)) + local yaw = math.atan2(dropdir.z, dropdir.x) + YAW_OFFSET + mcl_bows.shoot_arrow(itemstack:get_name(), shootpos, dropdir, yaw, nil, 19, 3) + end, +}) + + + +local ARROW_ENTITY={ + physical = true, + pointable = false, + visual = "mesh", + mesh = "mcl_bows_rocket.obj", + visual_size = {x=2.5, y=2.5}, + textures = {"mcl_bows_rocket.png"}, + collisionbox = {-0.19, -0.125, -0.19, 0.19, 0.125, 0.19}, + collide_with_objects = false, + _fire_damage_resistant = true, + + _lastpos={}, + _startpos=nil, + _damage=1, -- Damage on impact + _is_critical=false, -- Whether this arrow would deal critical damage + _stuck=false, -- Whether arrow is stuck + _fuse=nil,-- Amount of time (in seconds) the arrow has been stuck so far + _fuserechecktimer=nil,-- An additional timer for periodically re-checking the stuck status of an arrow + _stuckin=nil, --Position of node in which arow is stuck. + _shooter=nil, -- ObjectRef of player or mob who shot it + _is_arrow = true, + + _viscosity=0, -- Viscosity of node the arrow is currently in + _deflection_cooloff=0, -- Cooloff timer after an arrow deflection, to prevent many deflections in quick succession +} + +-- Destroy arrow entity self at pos and drops it as an item +local function spawn_item(self, pos) + if not minetest.is_creative_enabled("") then + local item = minetest.add_item(pos, "mcl_bows:rocket") + item:set_velocity({x=0, y=0, z=0}) + item:set_yaw(self.object:get_yaw()) + end + mcl_burning.extinguish(self.object) + self.object:remove() +end + +local function damage_particles(pos, is_critical) + if is_critical then + minetest.add_particlespawner({ + amount = 15, + time = 0.1, + minpos = {x=pos.x-0.5, y=pos.y-0.5, z=pos.z-0.5}, + maxpos = {x=pos.x+0.5, y=pos.y+0.5, z=pos.z+0.5}, + minvel = {x=-0.1, y=-0.1, z=-0.1}, + maxvel = {x=0.1, y=0.1, z=0.1}, + minacc = {x=0, y=0, z=0}, + maxacc = {x=0, y=0, z=0}, + minexptime = 1, + maxexptime = 2, + minsize = 1.5, + maxsize = 1.5, + collisiondetection = false, + vertical = false, + texture = "mcl_particles_crit.png^[colorize:#bc7a57:127", + }) + end +end + +function ARROW_ENTITY.on_step(self, dtime) + mcl_burning.tick(self.object, dtime, self) + + self._time_in_air = self._time_in_air + .001 + + + local pos = self.object:get_pos() + local dpos = table.copy(pos) -- digital pos + dpos = vector.round(dpos) + local node = minetest.get_node(dpos) + + if not self._fuse then + self._fuse = 0 + end + if not self._fuserechecktimer then + self._fuserechecktimer = 0 + end + + self._fuse = self._fuse + dtime + self._fuserechecktimer = self._fuserechecktimer + dtime + + if self._fuse > ARROW_TIMEOUT then + self._stuck = true + end + if self._stuck then + if self._fuse > ARROW_TIMEOUT then + local eploded_particle = particle_explosion(self) + damage_explosion(self, eploded_particle * 17) + mcl_burning.extinguish(self.object) + self.object:remove() + return + end + -- Drop arrow as item when it is no longer stuck + -- FIXME: Arrows are a bit slow to react and continue to float in mid air for a few seconds. + if self._fuserechecktimer > STUCK_RECHECK_TIME then + local stuckin_def + if self._stuckin then + stuckin_def = minetest.registered_nodes[minetest.get_node(self._stuckin).name] + end + -- TODO: In MC, arrow just falls down without turning into an item + if stuckin_def and stuckin_def.walkable == false then + spawn_item(self, pos) + return + end + self._fuserechecktimer = 0 + end + -- Pickup arrow if player is nearby (not in Creative Mode) + local objects = minetest.get_objects_inside_radius(pos, 1) + for _,obj in ipairs(objects) do + if obj:is_player() then + if self._collectable and not minetest.is_creative_enabled(obj:get_player_name()) then + if obj:get_inventory():room_for_item("main", "mcl_bows:rocket") then + obj:get_inventory():add_item("main", "mcl_bows:rocket") + minetest.sound_play("item_drop_pickup", { + pos = pos, + max_hear_distance = 16, + gain = 1.0, + }, true) + end + end + mcl_burning.extinguish(self.object) + self.object:remove() + return + end + end + + -- Check for object "collision". Done every tick (hopefully this is not too stressing) + else + + if self._in_player == false then + minetest.add_particlespawner({ + amount = 1, + time = .0001, + minpos = pos, + maxpos = pos, + minvel = vector.new(-0.1,-0.1,-0.1), + maxvel = vector.new(0.1,0.1,0.1), + minexptime = 0.5, + maxexptime = 0.5, + minsize = 2, + maxsize = 2, + collisiondetection = false, + vertical = false, + texture = "mcl_bows_rocket_particle.png", + glow = 1, + }) + end + -- We just check for any hurtable objects nearby. + -- The radius of 3 is fairly liberal, but anything lower than than will cause + -- arrow to hilariously go through mobs often. + -- TODO: Implement an ACTUAL collision detection (engine support needed). + local objs = minetest.get_objects_inside_radius(pos, 1.5) + local closest_object + local closest_distance + + if self._deflection_cooloff > 0 then + self._deflection_cooloff = self._deflection_cooloff - dtime + end + + -- Iterate through all objects and remember the closest attackable object + for k, obj in pairs(objs) do + local ok = false + -- Arrows can only damage players and mobs + if obj:is_player() then + ok = true + elseif obj:get_luaentity() then + if (obj:get_luaentity()._cmi_is_mob or obj:get_luaentity()._hittable_by_projectile) then + ok = true + end + end + + if ok then + local dist = vector.distance(pos, obj:get_pos()) + if not closest_object or not closest_distance then + closest_object = obj + closest_distance = dist + elseif dist < closest_distance then + closest_object = obj + closest_distance = dist + end + end + end + + -- If an attackable object was found, we will damage the closest one only + + if closest_object then + local obj = closest_object + local is_player = obj:is_player() + local lua = obj:get_luaentity() + if obj == self._shooter and self._time_in_air > 1.02 or obj ~= self._shooter and (is_player or (lua and (lua._cmi_is_mob or lua._hittable_by_projectile))) then + if obj:get_hp() > 0 then + -- Check if there is no solid node between arrow and object + local ray = minetest.raycast(self.object:get_pos(), obj:get_pos(), true) + for pointed_thing in ray do + if pointed_thing.type == "object" and pointed_thing.ref == closest_object then + -- Target reached! We can proceed now. + break + elseif pointed_thing.type == "node" then + local nn = minetest.get_node(minetest.get_pointed_thing_position(pointed_thing)).name + local def = minetest.registered_nodes[nn] + if (not def) or def.walkable then + -- There's a node in the way. Delete arrow without damage + mcl_burning.extinguish(self.object) + self.object:remove() + return + end + end + end + + -- Punch target object but avoid hurting enderman. + if not lua or lua.name ~= "mobs_mc:enderman" then + if self._in_player == false then + damage_particles(self.object:get_pos(), self._is_critical) + end + if mcl_burning.is_burning(self.object) then + mcl_burning.set_on_fire(obj, 5) + end + if self._in_player == false then + obj:punch(self.object, 1.0, { + full_punch_interval=1.0, + damage_groups={fleshy=self._damage}, + }, self.object:get_velocity()) + if obj:is_player() then + local eploded_particle = particle_explosion(self) + damage_explosion(self, eploded_particle * 17) + mcl_burning.extinguish(self.object) + self.object:remove() + end + end + end + + + if is_player then + if self._shooter and self._shooter:is_player() and self._in_player == false then + -- “Ding” sound for hitting another player + minetest.sound_play({name="mcl_bows_hit_player", gain=0.1}, {to_player=self._shooter:get_player_name()}, true) + end + end + + if lua then + local entity_name = lua.name + -- Achievement for hitting skeleton, wither skeleton or stray (TODO) with an arrow at least 50 meters away + -- NOTE: Range has been reduced because mobs unload much earlier than that ... >_> + -- TODO: This achievement should be given for the kill, not just a hit + if self._shooter and self._shooter:is_player() and vector.distance(pos, self._startpos) >= 20 then + if mod_awards and (entity_name == "mobs_mc:skeleton" or entity_name == "mobs_mc:stray" or entity_name == "mobs_mc:witherskeleton") then + awards.unlock(self._shooter:get_player_name(), "mcl:snipeSkeleton") + end + end + end + if self._in_player == false then + minetest.sound_play({name="mcl_bows_hit_other", gain=0.3}, {pos=self.object:get_pos(), max_hear_distance=16}, true) + end + end + if not obj:is_player() then + mcl_burning.extinguish(self.object) + if self._piercing == 0 then + local eploded_particle = particle_explosion(self) + damage_explosion(self, eploded_particle * 17) + self.object:remove() + end + end + return + end + end + end + + -- Check for node collision + if self._lastpos.x~=nil and not self._stuck then + local def = minetest.registered_nodes[node.name] + local vel = self.object:get_velocity() + -- Arrow has stopped in one axis, so it probably hit something. + -- This detection is a bit clunky, but sadly, MT does not offer a direct collision detection for us. :-( + if (math.abs(vel.x) < 0.0001) or (math.abs(vel.z) < 0.0001) or (math.abs(vel.y) < 0.00001) then + -- Check for the node to which the arrow is pointing + local dir + if math.abs(vel.y) < 0.00001 then + if self._lastpos.y < pos.y then + dir = {x=0, y=1, z=0} + else + dir = {x=0, y=-1, z=0} + end + else + dir = minetest.facedir_to_dir(minetest.dir_to_facedir(minetest.yaw_to_dir(self.object:get_yaw()-YAW_OFFSET))) + end + self._stuckin = vector.add(dpos, dir) + local snode = minetest.get_node(self._stuckin) + local sdef = minetest.registered_nodes[snode.name] + + -- If node is non-walkable, unknown or ignore, don't make arrow stuck. + -- This causes a deflection in the engine. + if not sdef or sdef.walkable == false or snode.name == "ignore" then + self._stuckin = nil + if self._deflection_cooloff <= 0 then + -- Lose 1/3 of velocity on deflection + local newvel = vector.multiply(vel, 0.6667) + + self.object:set_velocity(newvel) + -- Reset deflection cooloff timer to prevent many deflections happening in quick succession + self._deflection_cooloff = 1.0 + end + else + + -- Node was walkable, make arrow stuck + self._stuck = true + self._fuserechecktimer = 0 + + self.object:set_velocity({x=0, y=0, z=0}) + self.object:set_acceleration({x=0, y=0, z=0}) + + minetest.sound_play({name="mcl_bows_hit_other", gain=0.3}, {pos=self.object:get_pos(), max_hear_distance=16}, true) + + if mcl_burning.is_burning(self.object) and snode.name == "mcl_tnt:tnt" then + tnt.ignite(self._stuckin) + end + + -- Push the button! Push, push, push the button! + if mod_button and minetest.get_item_group(node.name, "button") > 0 and minetest.get_item_group(node.name, "button_push_by_arrow") == 1 then + local bdir = minetest.wallmounted_to_dir(node.param2) + -- Check the button orientation + if vector.equals(vector.add(dpos, bdir), self._stuckin) then + mesecon.push_button(dpos, node) + end + end + end + elseif (def and def.liquidtype ~= "none") then + -- Slow down arrow in liquids + local v = def.liquid_viscosity + if not v then + v = 0 + end + --local old_v = self._viscosity + self._viscosity = v + local vpenalty = math.max(0.1, 0.98 - 0.1 * v) + if math.abs(vel.x) > 0.001 then + vel.x = vel.x * vpenalty + end + if math.abs(vel.z) > 0.001 then + vel.z = vel.z * vpenalty + end + self.object:set_velocity(vel) + end + end + + -- Update yaw + if not self._stuck then + local vel = self.object:get_velocity() + local yaw = minetest.dir_to_yaw(vel)+YAW_OFFSET + local pitch = dir_to_pitch(vel) + self.object:set_rotation({ x = 0, y = yaw, z = pitch }) + end + + -- Update internal variable + self._lastpos={x=pos.x, y=pos.y, z=pos.z} +end + +-- Force recheck of stuck arrows when punched. +-- Otherwise, punching has no effect. +function ARROW_ENTITY.on_punch(self) + if self._stuck then + self._fuserechecktimer = STUCK_RECHECK_TIME + end +end + +function ARROW_ENTITY.get_staticdata(self) + local out = { + lastpos = self._lastpos, + startpos = self._startpos, + damage = self._damage, + is_critical = self._is_critical, + stuck = self._stuck, + stuckin = self._stuckin, + } + if self._stuck then + -- If _fuse is missing for some reason, assume the maximum + if not self._fuse then + self._fuse = ARROW_TIMEOUT + end + out.stuckstarttime = minetest.get_gametime() - self._fuse + end + if self._shooter and self._shooter:is_player() then + out.shootername = self._shooter:get_player_name() + end + return minetest.serialize(out) +end + +function ARROW_ENTITY.on_activate(self, staticdata, dtime_s) + self._time_in_air = 1.0 + self._in_player = false + local data = minetest.deserialize(staticdata) + if data then + self._stuck = data.stuck + if data.stuck then + if data.stuckstarttime then + -- First, check if the stuck arrow is aleady past its life timer. + -- If yes, delete it. + self._fuse = minetest.get_gametime() - data.stuckstarttime + if self._fuse > ARROW_TIMEOUT then + mcl_burning.extinguish(self.object) + self.object:remove() + return + end + end + + self._fuse = 2 + -- Perform a stuck recheck on the next step. + self._fuserechecktimer = STUCK_RECHECK_TIME + + self._stuckin = data.stuckin + end + + -- Get the remaining arrow state + self._lastpos = data.lastpos + self._startpos = data.startpos + self._damage = data.damage + self._is_critical = data.is_critical + if data.shootername then + local shooter = minetest.get_player_by_name(data.shootername) + if shooter and shooter:is_player() then + self._shooter = shooter + end + end + end + self.object:set_armor_groups({ immortal = 1 }) +end + +minetest.register_entity("mcl_bows:rocket_entity", ARROW_ENTITY) + +if minetest.get_modpath("mcl_core") and minetest.get_modpath("mcl_mobitems") then + minetest.register_craft({ + output = "mcl_bows:rocket 1", + recipe = { + {"mcl_core:paper"}, + {"mcl_fireworks:rocket_2"}, + {"mcl_bows:arrow"}, + } + }) +end + +if minetest.get_modpath("doc_identifier") then + doc.sub.identifier.register_object("mcl_bows:rocket_entity", "craftitems", "mcl_bows:rocket") +end diff --git a/mods/ITEMS/mcl_bows/sounds/mcl_bows_crossbow_drawback_0.ogg b/mods/ITEMS/mcl_bows/sounds/mcl_bows_crossbow_drawback_0.ogg new file mode 100644 index 000000000..f4f81b307 Binary files /dev/null and b/mods/ITEMS/mcl_bows/sounds/mcl_bows_crossbow_drawback_0.ogg differ diff --git a/mods/ITEMS/mcl_bows/sounds/mcl_bows_crossbow_drawback_1.ogg b/mods/ITEMS/mcl_bows/sounds/mcl_bows_crossbow_drawback_1.ogg new file mode 100644 index 000000000..c8c06b4fa Binary files /dev/null and b/mods/ITEMS/mcl_bows/sounds/mcl_bows_crossbow_drawback_1.ogg differ diff --git a/mods/ITEMS/mcl_bows/sounds/mcl_bows_crossbow_drawback_2.ogg b/mods/ITEMS/mcl_bows/sounds/mcl_bows_crossbow_drawback_2.ogg new file mode 100644 index 000000000..4ddd20c42 Binary files /dev/null and b/mods/ITEMS/mcl_bows/sounds/mcl_bows_crossbow_drawback_2.ogg differ diff --git a/mods/ITEMS/mcl_bows/sounds/mcl_bows_crossbow_load.ogg b/mods/ITEMS/mcl_bows/sounds/mcl_bows_crossbow_load.ogg new file mode 100644 index 000000000..02d2fd1af Binary files /dev/null and b/mods/ITEMS/mcl_bows/sounds/mcl_bows_crossbow_load.ogg differ diff --git a/mods/ITEMS/mcl_bows/sounds/mcl_bows_crossbow_shoot.ogg b/mods/ITEMS/mcl_bows/sounds/mcl_bows_crossbow_shoot.ogg new file mode 100644 index 000000000..a7d7b69d1 Binary files /dev/null and b/mods/ITEMS/mcl_bows/sounds/mcl_bows_crossbow_shoot.ogg differ diff --git a/mods/ITEMS/mcl_bows/sounds/mcl_bows_firework.ogg b/mods/ITEMS/mcl_bows/sounds/mcl_bows_firework.ogg new file mode 100644 index 000000000..ea9a4c4be Binary files /dev/null and b/mods/ITEMS/mcl_bows/sounds/mcl_bows_firework.ogg differ diff --git a/mods/ITEMS/mcl_bows/sounds/mcl_bows_firework_soft.ogg b/mods/ITEMS/mcl_bows/sounds/mcl_bows_firework_soft.ogg new file mode 100644 index 000000000..8b2e7bc5b Binary files /dev/null and b/mods/ITEMS/mcl_bows/sounds/mcl_bows_firework_soft.ogg differ diff --git a/mods/ITEMS/mcl_bows/textures/mcl_bows_crossbow.png b/mods/ITEMS/mcl_bows/textures/mcl_bows_crossbow.png new file mode 100644 index 000000000..b688dab94 Binary files /dev/null and b/mods/ITEMS/mcl_bows/textures/mcl_bows_crossbow.png differ diff --git a/mods/ITEMS/mcl_bows/textures/mcl_bows_crossbow_0.png b/mods/ITEMS/mcl_bows/textures/mcl_bows_crossbow_0.png new file mode 100644 index 000000000..41daad6d8 Binary files /dev/null and b/mods/ITEMS/mcl_bows/textures/mcl_bows_crossbow_0.png differ diff --git a/mods/ITEMS/mcl_bows/textures/mcl_bows_crossbow_1.png b/mods/ITEMS/mcl_bows/textures/mcl_bows_crossbow_1.png new file mode 100644 index 000000000..3769f2967 Binary files /dev/null and b/mods/ITEMS/mcl_bows/textures/mcl_bows_crossbow_1.png differ diff --git a/mods/ITEMS/mcl_bows/textures/mcl_bows_crossbow_2.png b/mods/ITEMS/mcl_bows/textures/mcl_bows_crossbow_2.png new file mode 100644 index 000000000..b1bb50feb Binary files /dev/null and b/mods/ITEMS/mcl_bows/textures/mcl_bows_crossbow_2.png differ diff --git a/mods/ITEMS/mcl_bows/textures/mcl_bows_crossbow_3.png b/mods/ITEMS/mcl_bows/textures/mcl_bows_crossbow_3.png new file mode 100644 index 000000000..8a8f1b03f Binary files /dev/null and b/mods/ITEMS/mcl_bows/textures/mcl_bows_crossbow_3.png differ diff --git a/mods/ITEMS/mcl_bows/textures/mcl_bows_firework_blue.png b/mods/ITEMS/mcl_bows/textures/mcl_bows_firework_blue.png new file mode 100644 index 000000000..608dbe0d0 Binary files /dev/null and b/mods/ITEMS/mcl_bows/textures/mcl_bows_firework_blue.png differ diff --git a/mods/ITEMS/mcl_bows/textures/mcl_bows_firework_green.png b/mods/ITEMS/mcl_bows/textures/mcl_bows_firework_green.png new file mode 100644 index 000000000..acd74d6d1 Binary files /dev/null and b/mods/ITEMS/mcl_bows/textures/mcl_bows_firework_green.png differ diff --git a/mods/ITEMS/mcl_bows/textures/mcl_bows_firework_red.png b/mods/ITEMS/mcl_bows/textures/mcl_bows_firework_red.png new file mode 100644 index 000000000..4d7355c57 Binary files /dev/null and b/mods/ITEMS/mcl_bows/textures/mcl_bows_firework_red.png differ diff --git a/mods/ITEMS/mcl_bows/textures/mcl_bows_firework_white.png b/mods/ITEMS/mcl_bows/textures/mcl_bows_firework_white.png new file mode 100644 index 000000000..1860ee53c Binary files /dev/null and b/mods/ITEMS/mcl_bows/textures/mcl_bows_firework_white.png differ diff --git a/mods/ITEMS/mcl_bows/textures/mcl_bows_firework_yellow.png b/mods/ITEMS/mcl_bows/textures/mcl_bows_firework_yellow.png new file mode 100644 index 000000000..c2b745def Binary files /dev/null and b/mods/ITEMS/mcl_bows/textures/mcl_bows_firework_yellow.png differ diff --git a/mods/ITEMS/mcl_bows/textures/mcl_bows_rocket.png b/mods/ITEMS/mcl_bows/textures/mcl_bows_rocket.png new file mode 100644 index 000000000..800185ce0 Binary files /dev/null and b/mods/ITEMS/mcl_bows/textures/mcl_bows_rocket.png differ diff --git a/mods/ITEMS/mcl_bows/textures/mcl_bows_rocket_particle.png b/mods/ITEMS/mcl_bows/textures/mcl_bows_rocket_particle.png new file mode 100644 index 000000000..12a894c72 Binary files /dev/null and b/mods/ITEMS/mcl_bows/textures/mcl_bows_rocket_particle.png differ diff --git a/mods/ITEMS/mcl_brewing/mod.conf b/mods/ITEMS/mcl_brewing/mod.conf index 2c27c979e..0f6217f09 100644 --- a/mods/ITEMS/mcl_brewing/mod.conf +++ b/mods/ITEMS/mcl_brewing/mod.conf @@ -1,4 +1,4 @@ name = mcl_brewing author = bzoss depends = mcl_init, mcl_formspec, mcl_sounds, mcl_potions, mcl_mobitems -optional_depends = mcl_core, doc, screwdriver +optional_depends = mcl_core, doc, screwdriver, mesecons_mvps diff --git a/mods/ITEMS/mcl_buckets/API.md b/mods/ITEMS/mcl_buckets/API.md index 53f7d3698..94ec48de5 100644 --- a/mods/ITEMS/mcl_buckets/API.md +++ b/mods/ITEMS/mcl_buckets/API.md @@ -9,13 +9,46 @@ Accept folowing params: * string: name of the node to place * function(pos): will returns name of the node to place with pos being the placement position * source_take: table of liquid source node names to take -* itemname: itemstring of the new bucket item (or nil if liquid is not takeable) +* bucketname: itemstring of the new bucket item * inventory_image: texture of the new bucket item (ignored if itemname == nil) * name: user-visible bucket description * longdesc: long explanatory description (for help) * usagehelp: short usage explanation (for help) * tt_help: very short tooltip help -* extra_check(pos, placer): (optional) function(pos) which can returns false to avoid placing the liquid. Placer is object/player who is placing the liquid, can be nil. +* extra_check(pos, placer): (optional) function(pos) * groups: optional list of item groups -This function can be called from any mod (which depends on this one) \ No newline at end of file + +**Usage exemple:** +```lua +mcl_buckets.register_liquid({ + bucketname = "dummy:bucket_dummy", + --source_place = "dummy:dummy_source", + source_place = function(pos) + if condition then + return "dummy:dummy_source" + else + return "dummy:dummy_source_nether" + end + end, + source_take = {"dummy:dummy_source"}, + inventory_image = "bucket_dummy.png", + name = S("Dummy liquid Bucket"), + longdesc = S("This bucket is filled with a dummy liquid."), + usagehelp = S("Place it to empty the bucket and create a dummy liquid source."), + tt_help = S("Places a dummy liquid source"), + extra_check = function(pos, placer) + --pos = pos where the liquid should be placed + --placer people who tried to place the bucket (can be nil) + + --no liquid node will be placed + --the bucket will not be emptied + --return false, false + + --liquid node will be placed + --the bucket will be emptied + return true, true + end, + groups = { dummy_group = 123 }, +}) +``` \ No newline at end of file diff --git a/mods/ITEMS/mcl_buckets/README.txt b/mods/ITEMS/mcl_buckets/README.md similarity index 67% rename from mods/ITEMS/mcl_buckets/README.txt rename to mods/ITEMS/mcl_buckets/README.md index 06862d589..b783cc133 100644 --- a/mods/ITEMS/mcl_buckets/README.txt +++ b/mods/ITEMS/mcl_buckets/README.md @@ -1,9 +1,12 @@ -Bucket mod. -Originally taken from Minetest Game, adapted for MineClone 2. +# MineClone2 Bucket (`mcl_bucket`) +Originally taken from Minetest Game, adapted for MineClone2. + +This mod add buckets to the game, including an API to register your own (see `API.md`). + +## License -License of source code: ------------------------ Copyright (C) 2011-2012 Kahrl + Copyright (C) 2011-2012 celeron55, Perttu Ahola This program is free software; you can redistribute it and/or modify diff --git a/mods/ITEMS/mcl_buckets/init.lua b/mods/ITEMS/mcl_buckets/init.lua index 90ccec636..931214b95 100644 --- a/mods/ITEMS/mcl_buckets/init.lua +++ b/mods/ITEMS/mcl_buckets/init.lua @@ -3,6 +3,7 @@ local modname = minetest.get_current_modname() local S = minetest.get_translator(modname) local modpath = minetest.get_modpath(modname) +-- Compatibility with old bucket mod minetest.register_alias("bucket:bucket_empty", "mcl_buckets:bucket_empty") minetest.register_alias("bucket:bucket_water", "mcl_buckets:bucket_water") minetest.register_alias("bucket:bucket_lava", "mcl_buckets:bucket_lava") @@ -11,13 +12,24 @@ local mod_doc = minetest.get_modpath("doc") local mod_mcl_core = minetest.get_modpath("mcl_core") --local mod_mclx_core = minetest.get_modpath("mclx_core") +-- Localize some functions for faster access +local vector = vector +local math = math +local string = string + +local raycast = minetest.raycast +local get_node = minetest.get_node +local add_node = minetest.add_node +local add_item = minetest.add_item + + if mod_mcl_core then minetest.register_craft({ output = "mcl_buckets:bucket_empty 1", recipe = { {"mcl_core:iron_ingot", "", "mcl_core:iron_ingot"}, {"", "mcl_core:iron_ingot", ""}, - } + }, }) end @@ -25,147 +37,218 @@ mcl_buckets = {} mcl_buckets.liquids = {} -- Sound helper functions for placing and taking liquids -local sound_place = function(itemname, pos) +local function sound_place(itemname, pos) local def = minetest.registered_nodes[itemname] if def and def.sounds and def.sounds.place then minetest.sound_play(def.sounds.place, {gain=1.0, pos = pos, pitch = 1 + math.random(-10, 10)*0.005}, true) end end -local sound_take = function(itemname, pos) +local function sound_take(itemname, pos) local def = minetest.registered_nodes[itemname] if def and def.sounds and def.sounds.dug then minetest.sound_play(def.sounds.dug, {gain=1.0, pos = pos, pitch = 1 + math.random(-10, 10)*0.005}, true) end end -local place_liquid = function(pos, itemstring) +local function place_liquid(pos, itemstring) local fullness = minetest.registered_nodes[itemstring].liquid_range sound_place(itemstring, pos) minetest.add_node(pos, {name=itemstring, param2=fullness}) end +local function give_bucket(new_bucket, itemstack, user) + local inv = user:get_inventory() + if minetest.is_creative_enabled(user:get_player_name()) then + --TODO: is a full bucket added if inv doesn't contain one? + return itemstack + else + if itemstack:get_count() == 1 then + return new_bucket + else + if inv:room_for_item("main", new_bucket) then + inv:add_item("main", new_bucket) + else + add_item(user:get_pos(), new_bucket) + end + itemstack:take_item() + return itemstack + end + end +end + +local pointable_sources = {} + +local function bucket_raycast(user) + --local pos = user:get_pos() + local pos = user:get_pos() + --local pos = vector.add(user:get_pos(), user:get_bone_position("Head_Control")) + pos.y = pos.y + user:get_properties().eye_height + local look_dir = user:get_look_dir() + look_dir = vector.multiply(look_dir, 5) + local pos2 = vector.add(pos, look_dir) + + local ray = raycast(pos, pos2, false, true) + if ray then + for pointed_thing in ray do + if pointed_thing and pointable_sources[get_node(pointed_thing.above).name] then + --minetest.chat_send_all("found!") + return {under=pointed_thing.under,above=pointed_thing.above} + end + end + end + return nil +end + +local function get_node_place(source_place, place_pos) + local node_place + if type(source_place) == "function" then + node_place = source_place(place_pos) + else + node_place = source_place + end + return node_place +end + +local function get_extra_check(check, pos, user) + local result + local take_bucket + if check then + result, take_bucket = check(pos, user) + if result == nil then result = true end + if take_bucket == nil then take_bucket = true end + else + result = true + take_bucket = true + end + return result, take_bucket +end + +local function get_bucket_drop(itemstack, user, take_bucket) + -- Handle bucket item and inventory stuff + if take_bucket and not minetest.is_creative_enabled(user:get_player_name()) then + -- Add empty bucket and put it into inventory, if possible. + -- Drop empty bucket otherwise. + local new_bucket = ItemStack("mcl_buckets:bucket_empty") + if itemstack:get_count() == 1 then + return new_bucket + else + local inv = user:get_inventory() + if inv:room_for_item("main", new_bucket) then + inv:add_item("main", new_bucket) + else + add_item(user:get_pos(), new_bucket) + end + itemstack:take_item() + return itemstack + end + else + return itemstack + end +end + function mcl_buckets.register_liquid(def) - for i=1, #def.source_take do - mcl_buckets.liquids[def.source_take[i]] = { + for _,source in ipairs(def.source_take) do + mcl_buckets.liquids[source] = { source_place = def.source_place, - source_take = def.source_take[i], + source_take = source, on_take = def.on_take, - itemname = def.itemname, + bucketname = def.bucketname, } + pointable_sources[source] = true if type(def.source_place) == "string" then - mcl_buckets.liquids[def.source_place] = mcl_buckets.liquids[def.source_take[i]] + mcl_buckets.liquids[def.source_place] = mcl_buckets.liquids[source] end end - if def.itemname then - minetest.register_craftitem(def.itemname, { - description = def.name, - _doc_items_longdesc = def.longdesc, - _doc_items_usagehelp = def.usagehelp, - _tt_help = def.tt_help, - inventory_image = def.inventory_image, - stack_max = 1, - groups = def.groups, - on_place = function(itemstack, user, pointed_thing) - -- Must be pointing to node - if pointed_thing.type ~= "node" then - return - end + if def.bucketname == nil or def.bucketname == "" then + error(string.format("[mcl_bucket] Invalid itemname then registering [%s]!", def.name)) + end - local node = minetest.get_node(pointed_thing.under) - local place_pos = pointed_thing.under - local nn = node.name - local nodedef = minetest.registered_nodes[nn] - -- Call on_rightclick if the pointed node defines it - if user and not user:get_player_control().sneak then - if nodedef and nodedef.on_rightclick then - return nodedef.on_rightclick(place_pos, node, user, itemstack) or itemstack - end - end + minetest.register_craftitem(def.bucketname, { + description = def.name, + _doc_items_longdesc = def.longdesc, + _doc_items_usagehelp = def.usagehelp, + _tt_help = def.tt_help, + inventory_image = def.inventory_image, + stack_max = 1, + groups = def.groups, + on_place = function(itemstack, user, pointed_thing) + -- Must be pointing to node + if pointed_thing.type ~= "node" then + return + end + -- Call on_rightclick if the pointed node defines it + local new_stack = mcl_util.call_on_rightclick(itemstack, user, pointed_thing) + if new_stack then + return new_stack + end - local node_place - if type(def.source_place) == "function" then - node_place = def.source_place(place_pos) - else - node_place = def.source_place - end - -- Check if pointing to a buildable node - --local item = itemstack:get_name() + local undernode = get_node(pointed_thing.under) + local abovenode = get_node(pointed_thing.above) + local buildable1 = minetest.registered_nodes[undernode.name] and minetest.registered_nodes[undernode.name].buildable_to + local buildable2 = minetest.registered_nodes[abovenode.name] and minetest.registered_nodes[abovenode.name].buildable_to + if not buildable1 and not buildable2 then return itemstack end --if both nodes aren't buildable_to, skip - if def.extra_check and def.extra_check(place_pos, user) == true and nodedef and nodedef.buildable_to then - -- buildable; replace the node + if buildable1 then + local result, take_bucket = get_extra_check(def.extra_check, pointed_thing.under, user) + if result then + local node_place = get_node_place(def.source_place, pointed_thing.under) local pns = user:get_player_name() - if minetest.is_protected(place_pos, pns) then - minetest.record_protection_violation(place_pos, pns) + + -- Check protection + if minetest.is_protected(pointed_thing.under, pns) then + minetest.record_protection_violation(pointed_thing.under, pns) return itemstack end - place_liquid(place_pos, node_place) + + -- Place liquid + place_liquid(pointed_thing.under, node_place) + + -- Update doc mod if mod_doc and doc.entry_exists("nodes", node_place) then doc.mark_entry_as_revealed(user:get_player_name(), "nodes", node_place) end - else - -- not buildable to; place the liquid above - -- check if the node above can be replaced - local abovenode = minetest.get_node(pointed_thing.above) - if minetest.registered_nodes[abovenode.name] and minetest.registered_nodes[abovenode.name].buildable_to then - local pn = user:get_player_name() - if minetest.is_protected(pointed_thing.above, pn) then - minetest.record_protection_violation(pointed_thing.above, pn) - return itemstack - end - place_liquid(pointed_thing.above, node_place) - if mod_doc and doc.entry_exists("nodes", node_place) then - doc.mark_entry_as_revealed(user:get_player_name(), "nodes", node_place) - end - else - -- do not remove the bucket with the liquid - return - end end + return get_bucket_drop(itemstack, user, take_bucket) + elseif buildable2 then + local result, take_bucket = get_extra_check(def.extra_check, pointed_thing.above, user) + if result then + local node_place = get_node_place(def.source_place, pointed_thing.above) + local pns = user:get_player_name() - -- Handle bucket item and inventory stuff - if not minetest.is_creative_enabled(user:get_player_name()) then - -- Add empty bucket and put it into inventory, if possible. - -- Drop empty bucket otherwise. - local new_bucket = ItemStack("mcl_buckets:bucket_empty") - if itemstack:get_count() == 1 then - return new_bucket - else - local inv = user:get_inventory() - if inv:room_for_item("main", new_bucket) then - inv:add_item("main", new_bucket) - else - minetest.add_item(user:get_pos(), new_bucket) - end - itemstack:take_item() + -- Check protection + if minetest.is_protected(pointed_thing.above, pns) then + minetest.record_protection_violation(pointed_thing.above, pns) return itemstack end - else - return - end - end, - _on_dispense = function(stack, pos, droppos, dropnode, dropdir) - --local iname = stack:get_name() - local buildable = minetest.registered_nodes[dropnode.name].buildable_to or dropnode.name == "mcl_portals:portal" - --if def.extra_check and def.extra_check(droppos, nil) == false then - -- Fail placement of liquid - if def.extra_check and def.extra_check(droppos, nil) == true and buildable then - -- buildable; replace the node - local node_place - if type(def.source_place) == "function" then - node_place = def.source_place(droppos) - else - node_place = def.source_place + -- Place liquid + place_liquid(pointed_thing.above, node_place) + + -- Update doc mod + if mod_doc and doc.entry_exists("nodes", node_place) then + doc.mark_entry_as_revealed(user:get_player_name(), "nodes", node_place) end - place_liquid(droppos, node_place) - stack:set_name("mcl_buckets:bucket_empty") end - return stack - end, - }) - end + return get_bucket_drop(itemstack, user, take_bucket) + else + return itemstack + end + end, + _on_dispense = function(stack, pos, droppos, dropnode, dropdir) + local buildable = minetest.registered_nodes[dropnode.name].buildable_to or dropnode.name == "mcl_portals:portal" + if not buildable then return stack end + local result, take_bucket = get_extra_check(def.extra_check, droppos, nil) + if result then -- Fail placement of liquid if result is false + place_liquid(droppos, get_node_place(def.source_place, droppos)) + end + if take_bucket then + stack:set_name("mcl_buckets:bucket_empty") + end + return stack + end, + }) end minetest.register_craftitem("mcl_buckets:bucket_empty", { @@ -173,8 +256,7 @@ minetest.register_craftitem("mcl_buckets:bucket_empty", { _doc_items_longdesc = S("A bucket can be used to collect and release liquids."), _doc_items_usagehelp = S("Punch a liquid source to collect it. You can then use the filled bucket to place the liquid somewhere else."), _tt_help = S("Collects liquids"), - - liquids_pointable = true, + --liquids_pointable = true, inventory_image = "bucket.png", stack_max = 16, on_place = function(itemstack, user, pointed_thing) @@ -184,74 +266,70 @@ minetest.register_craftitem("mcl_buckets:bucket_empty", { end -- Call on_rightclick if the pointed node defines it + local new_stack = mcl_util.call_on_rightclick(itemstack, user, pointed_thing) + if new_stack then + return new_stack + end + local node = minetest.get_node(pointed_thing.under) local nn = node.name - if user and not user:get_player_control().sneak then - if minetest.registered_nodes[nn] and minetest.registered_nodes[nn].on_rightclick then - return minetest.registered_nodes[nn].on_rightclick(pointed_thing.under, node, user, itemstack) or itemstack - end - end - -- Can't steal liquids - if minetest.is_protected(pointed_thing.above, user:get_player_name()) then - minetest.record_protection_violation(pointed_thing.under, user:get_player_name()) - return itemstack - end - - -- Check if pointing to a liquid source - local liquiddef = mcl_buckets.liquids[nn] local new_bucket - if liquiddef and liquiddef.itemname and (nn == liquiddef.source_take) then - - -- Fill bucket, but not in Creative Mode - if not minetest.is_creative_enabled(user:get_player_name()) then - new_bucket = ItemStack({name = liquiddef.itemname}) - if liquiddef.on_take then - liquiddef.on_take(user) - end + local liquid_node = bucket_raycast(user) + if liquid_node then + if minetest.is_protected(liquid_node.above, user:get_player_name()) then + minetest.record_protection_violation(liquid_node.above, user:get_player_name()) end + local liquid_name = get_node(liquid_node.above).name + if liquid_name then + local liquid_def = mcl_buckets.liquids[liquid_name] + if liquid_def then + --minetest.chat_send_all("test") + -- Fill bucket, but not in Creative Mode + -- FIXME: remove this line + --if not minetest.is_creative_enabled(user:get_player_name()) then + if not false then + new_bucket = ItemStack({name = liquid_def.bucketname}) + if liquid_def.on_take then + liquid_def.on_take(user) + end + end + add_node(liquid_node.above, {name="air"}) + sound_take(nn, liquid_node.above) - minetest.add_node(pointed_thing.under, {name="air"}) - sound_take(nn, pointed_thing.under) - - if mod_doc and doc.entry_exists("nodes", nn) then - doc.mark_entry_as_revealed(user:get_player_name(), "nodes", nn) - end - - elseif nn == "mcl_cauldrons:cauldron_3" then - -- Take water out of full cauldron - minetest.set_node(pointed_thing.under, {name="mcl_cauldrons:cauldron"}) - if not minetest.is_creative_enabled(user:get_player_name()) then - new_bucket = ItemStack("mcl_buckets:bucket_water") - end - sound_take("mcl_core:water_source", pointed_thing.under) - elseif nn == "mcl_cauldrons:cauldron_3r" then - -- Take river water out of full cauldron - minetest.set_node(pointed_thing.under, {name="mcl_cauldrons:cauldron"}) - if not minetest.is_creative_enabled(user:get_player_name()) then - new_bucket = ItemStack("mcl_buckets:bucket_river_water") - end - sound_take("mclx_core:river_water_source", pointed_thing.under) - end - - -- Add liquid bucket and put it into inventory, if possible. - -- Drop new bucket otherwise. - if new_bucket then - if itemstack:get_count() == 1 then - return new_bucket - else - local inv = user:get_inventory() - if inv:room_for_item("main", new_bucket) then - inv:add_item("main", new_bucket) + if mod_doc and doc.entry_exists("nodes", liquid_name) then + doc.mark_entry_as_revealed(user:get_player_name(), "nodes", liquid_name) + end + if new_bucket then + return give_bucket(new_bucket, itemstack, user) + end else - minetest.add_item(user:get_pos(), new_bucket) + minetest.log("error", string.format("[mcl_buckets] Node [%s] has invalid group [_mcl_bucket_pointable]!", liquid_name)) end - if not minetest.is_creative_enabled(user:get_player_name()) then - itemstack:take_item() - end - return itemstack end - end + return itemstack + else + -- FIXME: replace this ugly code by cauldrons API + if nn == "mcl_cauldrons:cauldron_3" then + -- Take water out of full cauldron + minetest.set_node(pointed_thing.under, {name="mcl_cauldrons:cauldron"}) + if not minetest.is_creative_enabled(user:get_player_name()) then + new_bucket = ItemStack("mcl_buckets:bucket_water") + end + sound_take("mcl_core:water_source", pointed_thing.under) + elseif nn == "mcl_cauldrons:cauldron_3r" then + -- Take river water out of full cauldron + minetest.set_node(pointed_thing.under, {name="mcl_cauldrons:cauldron"}) + if not minetest.is_creative_enabled(user:get_player_name()) then + new_bucket = ItemStack("mcl_buckets:bucket_river_water") + end + sound_take("mclx_core:river_water_source", pointed_thing.under) + end + if new_bucket then + return give_bucket(new_bucket, itemstack, user) + end + end + return itemstack end, _on_dispense = function(stack, pos, droppos, dropnode, dropdir) -- Fill empty bucket with liquid or drop bucket if no liquid @@ -259,9 +337,9 @@ minetest.register_craftitem("mcl_buckets:bucket_empty", { local liquiddef = mcl_buckets.liquids[dropnode.name] local new_bucket - if liquiddef and liquiddef.itemname and (dropnode.name == liquiddef.source_take) then + if liquiddef and liquiddef.bucketname and (dropnode.name == liquiddef.source_take) then -- Fill bucket - new_bucket = ItemStack({name = liquiddef.itemname}) + new_bucket = ItemStack({name = liquiddef.bucketname}) sound_take(dropnode.name, droppos) collect_liquid = true end diff --git a/mods/ITEMS/mcl_buckets/mod.conf b/mods/ITEMS/mcl_buckets/mod.conf index 5a78e70ad..0d7b764b8 100644 --- a/mods/ITEMS/mcl_buckets/mod.conf +++ b/mods/ITEMS/mcl_buckets/mod.conf @@ -1,6 +1,6 @@ name = mcl_buckets author = Kahrl description = -depends = mcl_worlds +depends = mcl_worlds, mcl_util optional_depends = mcl_core, mclx_core, doc diff --git a/mods/ITEMS/mcl_buckets/register.lua b/mods/ITEMS/mcl_buckets/register.lua index 863aa074c..1a7c8fe14 100644 --- a/mods/ITEMS/mcl_buckets/register.lua +++ b/mods/ITEMS/mcl_buckets/register.lua @@ -3,7 +3,7 @@ local mod_mcl_core = minetest.get_modpath("mcl_core") local mod_mclx_core = minetest.get_modpath("mclx_core") local has_awards = minetest.get_modpath("awards") -local sound_place = function(itemname, pos) +local function sound_place(itemname, pos) local def = minetest.registered_nodes[itemname] if def and def.sounds and def.sounds.place then minetest.sound_play(def.sounds.place, {gain=1.0, pos = pos, pitch = 1 + math.random(-10, 10)*0.005}, true) @@ -34,7 +34,7 @@ if mod_mcl_core then awards.unlock(user:get_player_name(), "mcl:hotStuff") end end, - itemname = "mcl_buckets:bucket_lava", + bucketname = "mcl_buckets:bucket_lava", inventory_image = "bucket_lava.png", name = S("Lava Bucket"), longdesc = S("A bucket can be used to collect and release liquids. This one is filled with hot lava, safely contained inside. Use with caution."), @@ -46,22 +46,13 @@ if mod_mcl_core then mcl_buckets.register_liquid({ source_place = "mcl_core:water_source", source_take = {"mcl_core:water_source"}, - itemname = "mcl_buckets:bucket_water", + bucketname = "mcl_buckets:bucket_water", inventory_image = "bucket_water.png", name = S("Water Bucket"), longdesc = S("A bucket can be used to collect and release liquids. This one is filled with water."), usagehelp = S("Place it to empty the bucket and create a water source."), tt_help = S("Places a water source"), extra_check = function(pos, placer) - -- Check protection - local placer_name = "" - if placer then - placer_name = placer:get_player_name() - end - if placer and minetest.is_protected(pos, placer_name) then - minetest.record_protection_violation(pos, placer_name) - return false - end local nn = minetest.get_node(pos).name -- Pour water into cauldron if minetest.get_item_group(nn, "cauldron") ~= 0 then @@ -70,13 +61,13 @@ if mod_mcl_core then minetest.set_node(pos, {name="mcl_cauldrons:cauldron_3"}) end sound_place("mcl_core:water_source", pos) - return false + return false, true -- Evaporate water if used in Nether (except on cauldron) else local dim = mcl_worlds.pos_to_dimension(pos) if dim == "nether" then minetest.sound_play("fire_extinguish_flame", {pos = pos, gain = 0.25, max_hear_distance = 16}, true) - return false + return false, true end end end, @@ -89,22 +80,13 @@ if mod_mclx_core then mcl_buckets.register_liquid({ source_place = "mclx_core:river_water_source", source_take = {"mclx_core:river_water_source"}, - itemname = "mcl_buckets:bucket_river_water", + bucketname = "mcl_buckets:bucket_river_water", inventory_image = "bucket_river_water.png", name = S("River Water Bucket"), longdesc = S("A bucket can be used to collect and release liquids. This one is filled with river water."), usagehelp = S("Place it to empty the bucket and create a river water source."), tt_help = S("Places a river water source"), extra_check = function(pos, placer) - -- Check protection - local placer_name = "" - if placer then - placer_name = placer:get_player_name() - end - if placer and minetest.is_protected(pos, placer_name) then - minetest.record_protection_violation(pos, placer_name) - return false - end local nn = minetest.get_node(pos).name -- Pour into cauldron if minetest.get_item_group(nn, "cauldron") ~= 0 then @@ -113,13 +95,13 @@ if mod_mclx_core then minetest.set_node(pos, {name="mcl_cauldrons:cauldron_3r"}) end sound_place("mcl_core:water_source", pos) - return false + return false, true else -- Evaporate water if used in Nether (except on cauldron) local dim = mcl_worlds.pos_to_dimension(pos) if dim == "nether" then minetest.sound_play("fire_extinguish_flame", {pos = pos, gain = 0.25, max_hear_distance = 16}, true) - return false + return false, true end end end, diff --git a/mods/ITEMS/mcl_chests/init.lua b/mods/ITEMS/mcl_chests/init.lua index cd66c3fc4..ad5c781f7 100644 --- a/mods/ITEMS/mcl_chests/init.lua +++ b/mods/ITEMS/mcl_chests/init.lua @@ -293,7 +293,7 @@ local function register_chest(basename, desc, longdesc, usagehelp, tt_help, tile local function drop_items_chest(pos, oldnode, oldmetadata) local meta = minetest.get_meta(pos) - local meta2 = meta + local meta2 = meta:to_table() if oldmetadata then meta:from_table(oldmetadata) end @@ -305,7 +305,7 @@ local function register_chest(basename, desc, longdesc, usagehelp, tt_help, tile minetest.add_item(p, stack) end end - meta:from_table(meta2:to_table()) + meta:from_table(meta2) end local function on_chest_blast(pos) @@ -608,10 +608,12 @@ local function register_chest(basename, desc, longdesc, usagehelp, tt_help, tile on_rightclick = function(pos, node, clicker) local pos_other = mcl_util.get_double_container_neighbor_pos(pos, node.param2, "left") - if minetest.registered_nodes[minetest.get_node({x = pos.x, y = pos.y + 1, z = pos.z}).name].groups.opaque == 1 - or minetest.registered_nodes[minetest.get_node({x = pos_other.x, y = pos_other.y + 1, z = pos_other.z}).name].groups.opaque == 1 then - -- won't open if there is no space from the top - return false + local above_def = minetest.registered_nodes[minetest.get_node({x = pos.x, y = pos.y + 1, z = pos.z}).name] + local above_def_other = minetest.registered_nodes[minetest.get_node({x = pos_other.x, y = pos_other.y + 1, z = pos_other.z}).name] + + if not above_def or above_def.groups.opaque == 1 or not above_def_other or above_def_other.groups.opaque == 1 then + -- won't open if there is no space from the top + return false end local name = minetest.get_meta(pos):get_string("name") @@ -1053,6 +1055,20 @@ minetest.register_on_joinplayer(function(player) inv:set_size("enderchest", 9*3) end) +minetest.register_allow_player_inventory_action(function(player, action, inv, info) + if inv:get_location().type == "player" and ( + action == "move" and (info.from_list == "enderchest" or info.to_list == "enderchest") + or action == "put" and info.listname == "enderchest" + or action == "take" and info.listname == "enderchest" + ) then + local def = player:get_wielded_item():get_definition() + + if not minetest.find_node_near(player:get_pos(), def and def.range or ItemStack():get_definition().range, "mcl_chests:ender_chest_small", true) then + return 0 + end + end +end) + minetest.register_craft({ output = "mcl_chests:ender_chest", recipe = { @@ -1133,7 +1149,7 @@ for color, desc in pairs(boxtypes) do if mod_doc then if is_canonical then longdesc = S("A shulker box is a portable container which provides 27 inventory slots for any item except shulker boxes. Shulker boxes keep their inventory when broken, so shulker boxes as well as their contents can be taken as a single item. Shulker boxes come in many different colors.") - usagehelp = S("To access the inventory of a shulker box, place and right-click it. To take a shulker box and its contents with you, just break and collect it, the items will not fall out.") + usagehelp = S("To access the inventory of a shulker box, place and right-click it. To take a shulker box and its contents with you, just break and collect it, the items will not fall out. Place the shulker box again to be able to retrieve its contents.") entry_name = S("Shulker Box") else create_entry = false diff --git a/mods/ITEMS/mcl_chests/locale/template.txt b/mods/ITEMS/mcl_chests/locale/template.txt index 1d947184b..d680c24c9 100644 --- a/mods/ITEMS/mcl_chests/locale/template.txt +++ b/mods/ITEMS/mcl_chests/locale/template.txt @@ -24,7 +24,7 @@ Red Shulker Box= Grey Shulker Box= Black Shulker Box= A shulker box is a portable container which provides 27 inventory slots for any item except shulker boxes. Shulker boxes keep their inventory when broken, so shulker boxes as well as their contents can be taken as a single item. Shulker boxes come in many different colors.= -To access the inventory of a shulker box, place and right-click it. To take a shulker box and its contents with you, just break and collect it, the items will not fall out.= +To access the inventory of a shulker box, place and right-click it. To take a shulker box and its contents with you, just break and collect it, the items will not fall out. Place the shulker box again to be able to retrieve its contents.= Shulker Box= Large Chest= Inventory= diff --git a/mods/ITEMS/mcl_core/craftitems.lua b/mods/ITEMS/mcl_core/craftitems.lua index 03f30b7b9..85a078766 100644 --- a/mods/ITEMS/mcl_core/craftitems.lua +++ b/mods/ITEMS/mcl_core/craftitems.lua @@ -93,7 +93,7 @@ minetest.register_craftitem("mcl_core:gold_ingot", { minetest.register_craftitem("mcl_core:emerald", { description = S("Emerald"), - _doc_items_longdesc = S("Emeralds are not very useful on their own, but they can exchanged for gold ingots by crafting."), + _doc_items_longdesc = S("Emeralds are used in villager trades as currency."), inventory_image = "mcl_core_emerald.png", stack_max = 64, groups = { craftitem=1 }, diff --git a/mods/ITEMS/mcl_core/functions.lua b/mods/ITEMS/mcl_core/functions.lua index 6e1a977d9..d2ff3690a 100644 --- a/mods/ITEMS/mcl_core/functions.lua +++ b/mods/ITEMS/mcl_core/functions.lua @@ -184,6 +184,7 @@ minetest.register_abm({ end, }) +-- Cactus mechanisms minetest.register_abm({ label = "Cactus growth", nodenames = {"mcl_core:cactus"}, @@ -195,18 +196,31 @@ minetest.register_abm({ end, }) --- Make cactus destroy items minetest.register_abm({ - label = "Cactus destroy items", + label = "Cactus mechanisms", nodenames = {"mcl_core:cactus"}, interval = 1, chance = 1, action = function(pos, node, active_object_count, active_object_count_wider) - for _,object in pairs(minetest.get_objects_inside_radius(pos, 0.9)) do - if not object:is_player() and object:get_luaentity() and object:get_luaentity().name == "__builtin:item" then + for _, object in pairs(minetest.get_objects_inside_radius(pos, 0.9)) do + local entity = object:get_luaentity() + if entity and entity.name == "__builtin:item" then object:remove() end end + local posses = { { 1, 0 }, { -1, 0 }, { 0, 1 }, { 0, -1 } } + for _, p in pairs(posses) do + if minetest.registered_nodes[minetest.get_node(vector.new(pos.x + p[1], pos.y, pos.z + p[2])).name].walkable then + local posy = pos.y + while minetest.get_node(vector.new(pos.x, posy, pos.z)).name == "mcl_core:cactus" do + local pos = vector.new(pos.x, posy, pos.z) + minetest.remove_node(pos) + minetest.add_item(vector.offset(pos, math.random(-0.5, 0.5), 0, math.random(-0.5, 0.5)), "mcl_core:cactus") + posy = posy + 1 + end + break + end + end end, }) @@ -759,8 +773,7 @@ end local grass_spread_randomizer = PseudoRandom(minetest.get_mapgen_setting("seed")) --- Return appropriate grass block node for pos -function mcl_core.get_grass_block_type(pos) +function mcl_core.get_grass_palette_index(pos) local biome_data = minetest.get_biome_data(pos) local index = 0 if biome_data then @@ -771,7 +784,12 @@ function mcl_core.get_grass_block_type(pos) index = reg_biome._mcl_palette_index end end - return {name="mcl_core:dirt_with_grass", param2=index} + return index +end + +-- Return appropriate grass block node for pos +function mcl_core.get_grass_block_type(pos) + return {name = "mcl_core:dirt_with_grass", param2 = mcl_core.get_grass_palette_index(pos)} end ------------------------------ diff --git a/mods/ITEMS/mcl_core/locale/mcl_core.de.tr b/mods/ITEMS/mcl_core/locale/mcl_core.de.tr index 0a1cbad37..b064cebbe 100644 --- a/mods/ITEMS/mcl_core/locale/mcl_core.de.tr +++ b/mods/ITEMS/mcl_core/locale/mcl_core.de.tr @@ -95,7 +95,7 @@ Dirt acts as a soil for a few plants. When in light, this block may grow a grass Emerald=Smaragd Emerald Ore=Smaragderz Emerald ore is the ore of emeralds. It is very rare and can be found alone, not in clusters.=Smaragderz ist das Erz von Smaragden. Es ist sehr selten und kann nur einzeln gefunden werden, nicht in Ansammlungen. -Emeralds are not very useful on their own, but they can exchanged for gold ingots by crafting.=Smaragde sind nicht besonders nützlich, aber man kann sie in der Fertigung durch Goldbarren eintauschen. +Emeralds are used in villager trades as currency.= Flint=Feuerstein Flint is a raw material.=Feuerstein ist ein Rohstoff. Flowing Lava=Fließende Lava diff --git a/mods/ITEMS/mcl_core/locale/mcl_core.es.tr b/mods/ITEMS/mcl_core/locale/mcl_core.es.tr index 1e1029c0f..1937babd3 100644 --- a/mods/ITEMS/mcl_core/locale/mcl_core.es.tr +++ b/mods/ITEMS/mcl_core/locale/mcl_core.es.tr @@ -95,7 +95,7 @@ Dirt acts as a soil for a few plants. When in light, this block may grow a grass Emerald=Esmeralda Emerald Ore=Mena de esmeralda Emerald ore is the ore of emeralds. It is very rare and can be found alone, not in clusters.=El mineral esmeralda es el mineral de las esmeraldas. Es muy raro y se puede encontrar solo, no en grupos. -Emeralds are not very useful on their own, but they can exchanged for gold ingots by crafting.=Las esmeraldas no son muy útiles por sí mismas, pero pueden cambiarse por lingotes de oro haciendo artesanías. +Emeralds are used in villager trades as currency.= Flint=Pedernal Flint is a raw material.=El pedernal es una materia prima. Flowing Lava=Lava que fluye diff --git a/mods/ITEMS/mcl_core/locale/mcl_core.fr.tr b/mods/ITEMS/mcl_core/locale/mcl_core.fr.tr index 725025e48..64aadd6db 100644 --- a/mods/ITEMS/mcl_core/locale/mcl_core.fr.tr +++ b/mods/ITEMS/mcl_core/locale/mcl_core.fr.tr @@ -95,7 +95,7 @@ Dirt acts as a soil for a few plants. When in light, this block may grow a grass Emerald=Emeraude Emerald Ore=Minerai d'Emeraude Emerald ore is the ore of emeralds. It is very rare and can be found alone, not in clusters.=Le minerai d'émeraude produit des émeraudes. Il est très rare et peut être trouvé seul, pas en filons. -Emeralds are not very useful on their own, but they can exchanged for gold ingots by crafting.=Les émeraudes ne sont pas très utiles seules, mais elles peuvent être échangées contre des lingots d'or. +Emeralds are used in villager trades as currency.=Les émeraudes sont utilisées pour faire des échanges avec les villageois. Flint=Silex Flint is a raw material.=Le silex est une matière première. Flowing Lava=Lave qui coule diff --git a/mods/ITEMS/mcl_core/locale/mcl_core.pl.tr b/mods/ITEMS/mcl_core/locale/mcl_core.pl.tr index 832a47830..68dfbd3d0 100644 --- a/mods/ITEMS/mcl_core/locale/mcl_core.pl.tr +++ b/mods/ITEMS/mcl_core/locale/mcl_core.pl.tr @@ -95,7 +95,7 @@ Dirt acts as a soil for a few plants. When in light, this block may grow a grass Emerald=Szmaragd Emerald Ore=Ruda szmaragdu Emerald ore is the ore of emeralds. It is very rare and can be found alone, not in clusters.=Ruda szmaragdu jest bardzo rzadka i występuje samotnie, nie w grupach. -Emeralds are not very useful on their own, but they can exchanged for gold ingots by crafting.=Szmaragdy nie są zbyt użyteczne same w sobie, ale można z nich wytworzyć sztabki złota. +Emeralds are used in villager trades as currency.= Flint=Krzemień Flint is a raw material.=Krzemień jest surowym materiałem. Flowing Lava=Płynąca lawa diff --git a/mods/ITEMS/mcl_core/locale/mcl_core.ru.tr b/mods/ITEMS/mcl_core/locale/mcl_core.ru.tr index f93db7c2c..2d5b5462c 100644 --- a/mods/ITEMS/mcl_core/locale/mcl_core.ru.tr +++ b/mods/ITEMS/mcl_core/locale/mcl_core.ru.tr @@ -95,7 +95,7 @@ Dirt acts as a soil for a few plants. When in light, this block may grow a grass Emerald=Изумруд Emerald Ore=Изумрудная руда Emerald ore is the ore of emeralds. It is very rare and can be found alone, not in clusters.=Изумрудная руда встречается очень редко и всегда по одному блоку. -Emeralds are not very useful on their own, but they can exchanged for gold ingots by crafting.=Изумруды не очень полезны сами по себе, но их можно обменять на золотые слитки. +Emeralds are used in villager trades as currency.= Flint=Кремень Flint is a raw material.=Кремень это необработанный материал. Flowing Lava=Текущая лава diff --git a/mods/ITEMS/mcl_core/locale/template.txt b/mods/ITEMS/mcl_core/locale/template.txt index 2cb74f5d1..19d156711 100644 --- a/mods/ITEMS/mcl_core/locale/template.txt +++ b/mods/ITEMS/mcl_core/locale/template.txt @@ -95,7 +95,7 @@ Dirt acts as a soil for a few plants. When in light, this block may grow a grass Emerald= Emerald Ore= Emerald ore is the ore of emeralds. It is very rare and can be found alone, not in clusters.= -Emeralds are not very useful on their own, but they can exchanged for gold ingots by crafting.= +Emeralds are used in villager trades as currency.= Flint= Flint is a raw material.= Flowing Lava= diff --git a/mods/ITEMS/mcl_core/nodes_base.lua b/mods/ITEMS/mcl_core/nodes_base.lua index d4bfd7636..fe1ee58c2 100644 --- a/mods/ITEMS/mcl_core/nodes_base.lua +++ b/mods/ITEMS/mcl_core/nodes_base.lua @@ -365,7 +365,7 @@ minetest.register_node("mcl_core:dirt_with_grass", { overlay_tiles = {"mcl_core_grass_block_top.png", "", {name="mcl_core_grass_block_side_overlay.png", tileable_vertical=false}}, palette = "mcl_core_palette_grass.png", palette_index = 0, - color = "#55aa60", + color = "#8EB971", is_ground_content = true, stack_max = 64, groups = {handy=1,shovely=1,dirt=2,grass_block=1, grass_block_no_snow=1, soil=1, soil_sapling=2, soil_sugarcane=1, cultivatable=2, spreading_dirt_type=1, enderman_takable=1, building_block=1}, @@ -1041,7 +1041,7 @@ for i=1,8 do drop = "mcl_throwing:snowball "..(i+1), _mcl_blast_resistance = 0.1, _mcl_hardness = 0.1, - _mcl_silk_touch_drop = {"mcl_core:snow " .. (i+1)}, + _mcl_silk_touch_drop = {"mcl_core:snow " .. i}, }) end diff --git a/mods/ITEMS/mcl_core/nodes_cactuscane.lua b/mods/ITEMS/mcl_core/nodes_cactuscane.lua index 839102534..e61d6df80 100644 --- a/mods/ITEMS/mcl_core/nodes_cactuscane.lua +++ b/mods/ITEMS/mcl_core/nodes_cactuscane.lua @@ -53,7 +53,10 @@ minetest.register_node("mcl_core:reeds", { _doc_items_longdesc = S("Sugar canes are a plant which has some uses in crafting. Sugar canes will slowly grow up to 3 blocks when they are next to water and are placed on a grass block, dirt, sand, red sand, podzol or coarse dirt. When a sugar cane is broken, all sugar canes connected above will break as well."), _doc_items_usagehelp = S("Sugar canes can only be placed top of other sugar canes and on top of blocks on which they would grow."), drawtype = "plantlike", + paramtype2 = "color", tiles = {"default_papyrus.png"}, + palette = "mcl_core_palette_grass.png", + palette_index = 0, inventory_image = "mcl_core_reeds.png", wield_image = "mcl_core_reeds.png", paramtype = "light", @@ -79,6 +82,7 @@ minetest.register_node("mcl_core:reeds", { groups = {dig_immediate=3, craftitem=1, deco_block=1, plant=1, non_mycelium_plant=1, dig_by_piston=1}, sounds = mcl_sounds.node_sound_leaves_defaults(), node_placement_prediction = "", + drop = "mcl_core:reeds", -- to prevent color inheritation on_place = mcl_util.generate_on_place_plant_function(function(place_pos, place_node) local soil_pos = {x=place_pos.x, y=place_pos.y-1, z=place_pos.z} local soil_node = minetest.get_node_or_nil(soil_pos) @@ -114,6 +118,15 @@ minetest.register_node("mcl_core:reeds", { return false end), + on_construct = function(pos) + local node = minetest.get_node(pos) + if node.param2 == 0 then + node.param2 = mcl_core.get_grass_palette_index(pos) + if node.param2 ~= 0 then + minetest.set_node(pos, node) + end + end + end, _mcl_blast_resistance = 0, _mcl_hardness = 0, }) diff --git a/mods/ITEMS/mcl_core/textures/default_papyrus.png b/mods/ITEMS/mcl_core/textures/default_papyrus.png index b6e2062ec..c928402f9 100644 Binary files a/mods/ITEMS/mcl_core/textures/default_papyrus.png and b/mods/ITEMS/mcl_core/textures/default_papyrus.png differ diff --git a/mods/ITEMS/mcl_crafting_table/init.lua b/mods/ITEMS/mcl_crafting_table/init.lua index 58b46d668..eae503eeb 100644 --- a/mods/ITEMS/mcl_crafting_table/init.lua +++ b/mods/ITEMS/mcl_crafting_table/init.lua @@ -6,6 +6,7 @@ local text_color = "#313131" local itemslot_bg = mcl_formspec.get_itemslot_bg mcl_crafting_table = {} + function mcl_crafting_table.show_crafting_form(player) player:get_inventory():set_width("craft", 3) player:get_inventory():set_size("craft", 9) @@ -30,7 +31,6 @@ function mcl_crafting_table.show_crafting_form(player) ) end -local show_crafting_form = mcl_crafting_table.show_crafting_form --cache function for better performances minetest.register_node("mcl_crafting_table:crafting_table", { description = S("Crafting Table"), _tt_help = S("3×3 crafting grid"), @@ -43,7 +43,9 @@ minetest.register_node("mcl_crafting_table:crafting_table", { paramtype2 = "facedir", groups = {handy=1,axey=1, deco_block=1, material_wood=1,flammable=-1}, on_rightclick = function(pos, node, player, itemstack) - show_crafting_form(player) + if not player:get_player_control().sneak then + mcl_crafting_table.show_crafting_form(player) + end end, sounds = mcl_sounds.node_sound_wood_defaults(), _mcl_blast_resistance = 2.5, diff --git a/mods/ITEMS/mcl_dye/API.md b/mods/ITEMS/mcl_dye/API.md new file mode 100644 index 000000000..04169f966 --- /dev/null +++ b/mods/ITEMS/mcl_dye/API.md @@ -0,0 +1,14 @@ +# mcl_dye + +# Bone meal API +Callback and particle functions. + +## mcl_dye.add_bone_meal_particle(pos, def) +Spawns standard or custom bone meal particles. +* `pos`: position, is ignored if you define def.minpos and def.maxpos +* `def`: (optional) particle definition + +## mcl_dye.register_on_bone_meal_apply(function(pointed_thing, user)) +Called when the bone meal is applied anywhere. +* `pointed_thing`: exact pointing location (see Minetest API), where the bone meal is applied +* `user`: ObjectRef of the player who aplied the bone meal, can be nil! \ No newline at end of file diff --git a/mods/ITEMS/mcl_dye/init.lua b/mods/ITEMS/mcl_dye/init.lua index b9b5d92ac..dfb962446 100644 --- a/mods/ITEMS/mcl_dye/init.lua +++ b/mods/ITEMS/mcl_dye/init.lua @@ -128,26 +128,35 @@ for _, row in ipairs(dyelocal.dyes) do end -- Bone Meal -local function bone_meal_particle(pos) +function mcl_dye.add_bone_meal_particle(pos, def) + if not def then + def = {} + end minetest.add_particlespawner({ - amount = 10, - time = 0.1, - minpos = { x = pos.x - 0.5, y = pos.y - 0.5, z = pos.z - 0.5 }, - maxpos = { x = pos.x + 0.5, y = pos.y + 0.5, z = pos.z + 0.5 }, - minvel = { x = 0, y = 0, z = 0}, - maxvel = { x = 0, y = 0, z = 0}, - minacc = { x = 0, y = 0, z = 0}, - maxacc = { x = 0, y = 0, z = 0}, - minexptime = 1, - maxexptime = 4, - minsize = 0.7, - maxsize = 2.4, + amount = def.amount or 10, + time = def.time or 0.1, + minpos = def.minpos or vector.subtract(pos, 0.5), + maxpos = def.maxpos or vector.add(pos, 0.5), + minvel = def.minvel or vector.new(-0.01, 0.01, -0.01), + maxvel = def.maxvel or vector.new(0.01, 0.01, 0.01), + minacc = def.minacc or vector.new(0, 0, 0), + maxacc = def.maxacc or vector.new(0, 0, 0), + minexptime = def.minexptime or 1, + maxexptime = def.maxexptime or 4, + minsize = def.minsize or 0.7, + maxsize = def.maxsize or 2.4, texture = "mcl_particles_bonemeal.png^[colorize:#00EE00:125", -- TODO: real MC color - glow = 5, + glow = def.glow or 1, }) end -function mcl_dye.apply_bone_meal(pointed_thing) +mcl_dye.bone_meal_callbacks = {} + +function mcl_dye.register_on_bone_meal_apply(func) + table.insert(mcl_dye.bone_meal_callbacks, func) +end + +local function apply_bone_meal(pointed_thing) -- Bone meal currently spawns all flowers found in the plains. local flowers_table_plains = { "mcl_flowers:dandelion", @@ -183,14 +192,21 @@ function mcl_dye.apply_bone_meal(pointed_thing) local pos = pointed_thing.under local n = minetest.get_node(pos) if n.name == "" then return false end + + for _, func in pairs(mcl_dye.bone_meal_callbacks) do + if func(pointed_thing, user) then + return true + end + end + if minetest.get_item_group(n.name, "sapling") >= 1 then - bone_meal_particle(pos) + mcl_dye.add_bone_meal_particle(pos) -- Saplings: 45% chance to advance growth stage if math.random(1,100) <= 45 then return mcl_core.grow_sapling(pos, n) end elseif minetest.get_item_group(n.name, "mushroom") == 1 then - bone_meal_particle(pos) + mcl_dye.add_bone_meal_particle(pos) -- Try to grow huge mushroom -- Must be on a dirt-type block @@ -240,71 +256,71 @@ function mcl_dye.apply_bone_meal(pointed_thing) return false -- Wheat, Potato, Carrot, Pumpkin Stem, Melon Stem: Advance by 2-5 stages elseif string.find(n.name, "mcl_farming:wheat_") then - bone_meal_particle(pos) + mcl_dye.add_bone_meal_particle(pos) local stages = math.random(2, 5) return mcl_farming:grow_plant("plant_wheat", pos, n, stages, true) elseif string.find(n.name, "mcl_farming:potato_") then - bone_meal_particle(pos) + mcl_dye.add_bone_meal_particle(pos) local stages = math.random(2, 5) return mcl_farming:grow_plant("plant_potato", pos, n, stages, true) elseif string.find(n.name, "mcl_farming:carrot_") then - bone_meal_particle(pos) + mcl_dye.add_bone_meal_particle(pos) local stages = math.random(2, 5) return mcl_farming:grow_plant("plant_carrot", pos, n, stages, true) elseif string.find(n.name, "mcl_farming:pumpkin_") then - bone_meal_particle(pos) + mcl_dye.add_bone_meal_particle(pos) local stages = math.random(2, 5) return mcl_farming:grow_plant("plant_pumpkin_stem", pos, n, stages, true) elseif string.find(n.name, "mcl_farming:melontige_") then - bone_meal_particle(pos) + mcl_dye.add_bone_meal_particle(pos) local stages = math.random(2, 5) return mcl_farming:grow_plant("plant_melon_stem", pos, n, stages, true) elseif string.find(n.name, "mcl_farming:beetroot_") then - bone_meal_particle(pos) + mcl_dye.add_bone_meal_particle(pos) -- Beetroot: 75% chance to advance to next stage if math.random(1, 100) <= 75 then return mcl_farming:grow_plant("plant_beetroot", pos, n, 1, true) end elseif n.name == "mcl_cocoas:cocoa_1" or n.name == "mcl_cocoas:cocoa_2" then - bone_meal_particle(pos) + mcl_dye.add_bone_meal_particle(pos) -- Cocoa: Advance by 1 stage mcl_cocoas.grow(pos) return true elseif minetest.get_item_group(n.name, "grass_block") == 1 then - local grass_block_pos = {x = pos.x, y = pos.y + 1, z = pos.z} - bone_meal_particle(grass_block_pos) -- Grass Block: Generate tall grass and random flowers all over the place - for i = -2, 2 do - for j = -2, 2 do - pos = pointed_thing.above - pos = {x=pos.x+i, y=pos.y, z=pos.z+j} - n = minetest.get_node(pos) - local n2 = minetest.get_node({x=pos.x, y=pos.y-1, z=pos.z}) + for i = -7, 7 do + for j = -7, 7 do + for y = -1, 1 do + pos = vector.offset(pointed_thing.above, i, y, j) + n = minetest.get_node(pos) + local n2 = minetest.get_node(vector.offset(pos, 0, -1, 0)) - if n.name ~= "" and n.name == "air" and (minetest.get_item_group(n2.name, "grass_block_no_snow") == 1) then - -- Randomly generate flowers, tall grass or nothing - if math.random(1,100) <= 90 then - -- 90% tall grass, 10% flower - if math.random(1,100) <= 90 then - local col = n2.param2 - minetest.add_node(pos, {name="mcl_flowers:tallgrass", param2=col}) - else - local flowers_table - if mg_name == "v6" then - flowers_table = flowers_table_plains + if n.name ~= "" and n.name == "air" and (minetest.get_item_group(n2.name, "grass_block_no_snow") == 1) then + -- Randomly generate flowers, tall grass or nothing + if math.random(1, 100) <= 90 / ((math.abs(i) + math.abs(j)) / 2)then + -- 90% tall grass, 10% flower + mcl_dye.add_bone_meal_particle(pos, {amount = 4}) + if math.random(1,100) <= 90 then + local col = n2.param2 + minetest.add_node(pos, {name="mcl_flowers:tallgrass", param2=col}) else - local biome = minetest.get_biome_name(minetest.get_biome_data(pos).biome) - if biome == "Swampland" or biome == "Swampland_shore" or biome == "Swampland_ocean" or biome == "Swampland_deep_ocean" or biome == "Swampland_underground" then - flowers_table = flowers_table_swampland - elseif biome == "FlowerForest" or biome == "FlowerForest_beach" or biome == "FlowerForest_ocean" or biome == "FlowerForest_deep_ocean" or biome == "FlowerForest_underground" then - flowers_table = flowers_table_flower_forest - elseif biome == "Plains" or biome == "Plains_beach" or biome == "Plains_ocean" or biome == "Plains_deep_ocean" or biome == "Plains_underground" or biome == "SunflowerPlains" or biome == "SunflowerPlains_ocean" or biome == "SunflowerPlains_deep_ocean" or biome == "SunflowerPlains_underground" then + local flowers_table + if mg_name == "v6" then flowers_table = flowers_table_plains else - flowers_table = flowers_table_simple + local biome = minetest.get_biome_name(minetest.get_biome_data(pos).biome) + if biome == "Swampland" or biome == "Swampland_shore" or biome == "Swampland_ocean" or biome == "Swampland_deep_ocean" or biome == "Swampland_underground" then + flowers_table = flowers_table_swampland + elseif biome == "FlowerForest" or biome == "FlowerForest_beach" or biome == "FlowerForest_ocean" or biome == "FlowerForest_deep_ocean" or biome == "FlowerForest_underground" then + flowers_table = flowers_table_flower_forest + elseif biome == "Plains" or biome == "Plains_beach" or biome == "Plains_ocean" or biome == "Plains_deep_ocean" or biome == "Plains_underground" or biome == "SunflowerPlains" or biome == "SunflowerPlains_ocean" or biome == "SunflowerPlains_deep_ocean" or biome == "SunflowerPlains_underground" then + flowers_table = flowers_table_plains + else + flowers_table = flowers_table_simple + end end + minetest.add_node(pos, {name=flowers_table[math.random(1, #flowers_table)]}) end - minetest.add_node(pos, {name=flowers_table[math.random(1, #flowers_table)]}) end end end @@ -314,24 +330,24 @@ function mcl_dye.apply_bone_meal(pointed_thing) -- Double flowers: Drop corresponding item elseif n.name == "mcl_flowers:rose_bush" or n.name == "mcl_flowers:rose_bush_top" then - bone_meal_particle(pos) + mcl_dye.add_bone_meal_particle(pos) minetest.add_item(pos, "mcl_flowers:rose_bush") return true elseif n.name == "mcl_flowers:peony" or n.name == "mcl_flowers:peony_top" then - bone_meal_particle(pos) + mcl_dye.add_bone_meal_particle(pos) minetest.add_item(pos, "mcl_flowers:peony") return true elseif n.name == "mcl_flowers:lilac" or n.name == "mcl_flowers:lilac_top" then - bone_meal_particle(pos) + mcl_dye.add_bone_meal_particle(pos) minetest.add_item(pos, "mcl_flowers:lilac") return true elseif n.name == "mcl_flowers:sunflower" or n.name == "mcl_flowers:sunflower_top" then - bone_meal_particle(pos) + mcl_dye.add_bone_meal_particle(pos) minetest.add_item(pos, "mcl_flowers:sunflower") return true elseif n.name == "mcl_flowers:tallgrass" then - bone_meal_particle(pos) + mcl_dye.add_bone_meal_particle(pos) -- Tall Grass: Grow into double tallgrass local toppos = { x=pos.x, y=pos.y+1, z=pos.z } local topnode = minetest.get_node(toppos) @@ -342,7 +358,7 @@ function mcl_dye.apply_bone_meal(pointed_thing) end elseif n.name == "mcl_flowers:fern" then - bone_meal_particle(pos) + mcl_dye.add_bone_meal_particle(pos) -- Fern: Grow into large fern local toppos = { x=pos.x, y=pos.y+1, z=pos.z } local topnode = minetest.get_node(toppos) @@ -374,7 +390,7 @@ minetest.register_craftitem("mcl_dye:white", { end -- Use the bone meal on the ground - if(mcl_dye.apply_bone_meal(pointed_thing) and (not minetest.is_creative_enabled(user:get_player_name()))) then + if (apply_bone_meal(pointed_thing, user) and (not minetest.is_creative_enabled(user:get_player_name()))) then itemstack:take_item() end return itemstack @@ -387,7 +403,7 @@ minetest.register_craftitem("mcl_dye:white", { else pointed_thing = { above = pos, under = droppos } end - local success = mcl_dye.apply_bone_meal(pointed_thing) + local success = apply_bone_meal(pointed_thing, nil) if success then stack:take_item() end diff --git a/mods/ITEMS/mcl_enchanting/enchantments.lua b/mods/ITEMS/mcl_enchanting/enchantments.lua index ecc9fe113..e876baf31 100644 --- a/mods/ITEMS/mcl_enchanting/enchantments.lua +++ b/mods/ITEMS/mcl_enchanting/enchantments.lua @@ -379,8 +379,51 @@ mcl_enchanting.enchantments.mending = { inv_tool_tab = true, } --- requires missing MineClone2 feature ---[[mcl_enchanting.enchantments.multishot = { +mcl_experience.register_on_add_xp(function(player, xp) + local inv = player:get_inventory() + + local candidates = { + {list = "main", index = player:get_wield_index()}, + {list = "armor", index = 2}, + {list = "armor", index = 3}, + {list = "armor", index = 4}, + {list = "armor", index = 5}, + } + + local final_candidates = {} + for _, can in ipairs(candidates) do + local stack = inv:get_stack(can.list, can.index) + local wear = stack:get_wear() + if mcl_enchanting.has_enchantment(stack, "mending") and wear > 0 then + can.stack = stack + can.wear = wear + table.insert(final_candidates, can) + end + end + + if #final_candidates > 0 then + local can = final_candidates[math.random(#final_candidates)] + local stack, list, index, wear = can.stack, can.list, can.index, can.wear + local uses = mcl_util.calculate_durability(stack) + local multiplier = 2 * 65535 / uses + local repair = xp * multiplier + local new_wear = wear - repair + + if new_wear < 0 then + xp = math.floor(-new_wear / multiplier + 0.5) + new_wear = 0 + else + xp = 0 + end + + stack:set_wear(math.floor(new_wear)) + inv:set_stack(list, index, stack) + end + + return xp +end, 0) + +mcl_enchanting.enchantments.multishot = { name = S("Multishot"), max_level = 1, primary = {crossbow = true}, @@ -396,10 +439,10 @@ mcl_enchanting.enchantments.mending = { power_range_table = {{20, 50}}, inv_combat_tab = true, inv_tool_tab = false, -}]]-- +} -- requires missing MineClone2 feature ---[[mcl_enchanting.enchantments.piercing = { +mcl_enchanting.enchantments.piercing = { name = S("Piercing"), max_level = 4, primary = {crossbow = true}, @@ -415,7 +458,7 @@ mcl_enchanting.enchantments.mending = { power_range_table = {{1, 50}, {11, 50}, {21, 50}, {31, 50}}, inv_combat_tab = true, inv_tool_tab = false, -}]]-- +} -- implemented in mcl_bows mcl_enchanting.enchantments.power = { @@ -456,7 +499,7 @@ mcl_enchanting.enchantments.punch = { } -- requires missing MineClone2 feature ---[[mcl_enchanting.enchantments.quick_charge = { +mcl_enchanting.enchantments.quick_charge = { name = S("Quick Charge"), max_level = 3, primary = {crossbow = true}, @@ -472,7 +515,7 @@ mcl_enchanting.enchantments.punch = { power_range_table = {{12, 50}, {32, 50}, {52, 50}}, inv_combat_tab = true, inv_tool_tab = false, -}]]-- +} -- unimplemented --[[mcl_enchanting.enchantments.respiration = { diff --git a/mods/ITEMS/mcl_enchanting/engine.lua b/mods/ITEMS/mcl_enchanting/engine.lua index d2a749947..97a176b97 100644 --- a/mods/ITEMS/mcl_enchanting/engine.lua +++ b/mods/ITEMS/mcl_enchanting/engine.lua @@ -123,7 +123,7 @@ function mcl_enchanting.can_enchant(itemstack, enchantment, level) if itemname == "" then return false, "item missing" end - local supported, primary = mcl_enchanting.item_supports_enchantment(itemstack:get_name(), enchantment) + local supported, primary = mcl_enchanting.item_supports_enchantment(itemname, enchantment) if not supported then return false, "item not supported" end @@ -132,7 +132,7 @@ function mcl_enchanting.can_enchant(itemstack, enchantment, level) end if level > enchantment_def.max_level then return false, "level too high", enchantment_def.max_level - elseif level < 1 then + elseif level < 1 then return false, "level too small", 1 end local item_enchantments = mcl_enchanting.get_enchantments(itemstack) @@ -270,8 +270,14 @@ function mcl_enchanting.initialize() new_def.groups.not_in_creative_inventory = 1 new_def.groups.not_in_craft_guide = 1 new_def.groups.enchanted = 1 - new_def._mcl_armor_texture = new_def._mcl_armor_texture and new_def._mcl_armor_texture .. mcl_enchanting.overlay - new_def._mcl_armor_preview = new_def._mcl_armor_preview and new_def._mcl_armor_preview .. mcl_enchanting.overlay + + if new_def._mcl_armor_texture and not type(new_def._mcl_armor_texture) == "function" then + new_def._mcl_armor_texture = new_def._mcl_armor_texture .. mcl_enchanting.overlay + end + if new_def._mcl_armor_preview and not type(new_def._mcl_armor_preview) == "function" then + new_def._mcl_armor_preview = new_def._mcl_armor_preview .. mcl_enchanting.overlay + end + new_def._mcl_enchanting_enchanted_tool = new_name new_def.after_use = get_after_use_callback(itemdef) local register_list = register_item_list @@ -289,115 +295,125 @@ function mcl_enchanting.initialize() end end -function mcl_enchanting.get_possible_enchantments(itemstack, enchantment_level, treasure) - local possible_enchantments, weights, accum_weight = {}, {}, 0 - for enchantment, enchantment_def in pairs(mcl_enchanting.enchantments) do - local _, _, _, primary = mcl_enchanting.can_enchant(itemstack, enchantment, 1) - if primary or treasure then - table.insert(possible_enchantments, enchantment) - accum_weight = accum_weight + enchantment_def.weight - weights[enchantment] = accum_weight - end +function mcl_enchanting.random(pr, ...) + local r = pr and pr:next(...) or math.random(...) + + if pr and not ({...})[1] then + r = r / 32767 end - return possible_enchantments, weights, accum_weight + + return r end -function mcl_enchanting.generate_random_enchantments(itemstack, enchantment_level, treasure, no_reduced_bonus_chance, ignore_already_enchanted) +function mcl_enchanting.get_random_enchantment(itemstack, treasure, weighted, exclude, pr) + local possible = {} + + for enchantment, enchantment_def in pairs(mcl_enchanting.enchantments) do + local can_enchant, _, _, primary = mcl_enchanting.can_enchant(itemstack, enchantment, 1) + + if can_enchant and (primary or treasure) and (not exclude or table.indexof(exclude, enchantment) == -1) then + local weight = weighted and enchantment_def.weight or 1 + + for i = 1, weight do + table.insert(possible, enchantment) + end + end + end + + return #possible > 0 and possible[mcl_enchanting.random(pr, 1, #possible)] +end + +function mcl_enchanting.generate_random_enchantments(itemstack, enchantment_level, treasure, no_reduced_bonus_chance, ignore_already_enchanted, pr) local itemname = itemstack:get_name() + if not mcl_enchanting.can_enchant_freshly(itemname) and not ignore_already_enchanted then return end + itemstack = ItemStack(itemstack) + local enchantability = minetest.get_item_group(itemname, "enchantability") - enchantability = 1 + math.random(0, math.floor(enchantability / 4)) + math.random(0, math.floor(enchantability / 4)) + enchantability = 1 + mcl_enchanting.random(pr, 0, math.floor(enchantability / 4)) + mcl_enchanting.random(pr, 0, math.floor(enchantability / 4)) + enchantment_level = enchantment_level + enchantability - enchantment_level = enchantment_level + enchantment_level * (math.random() + math.random() - 1) * 0.15 + enchantment_level = enchantment_level + enchantment_level * (mcl_enchanting.random(pr) + mcl_enchanting.random(pr) - 1) * 0.15 enchantment_level = math.max(math.floor(enchantment_level + 0.5), 1) + local enchantments = {} local description + enchantment_level = enchantment_level * 2 + repeat enchantment_level = math.floor(enchantment_level / 2) + if enchantment_level == 0 then break end - local possible, weights, accum_weight = mcl_enchanting.get_possible_enchantments(itemstack, enchantment_level, treasure) - local selected_enchantment, enchantment_power - if #possible > 0 then - local r = math.random(accum_weight) - for _, enchantment in ipairs(possible) do - if weights[enchantment] >= r then - selected_enchantment = enchantment - break - end - end - local enchantment_def = mcl_enchanting.enchantments[selected_enchantment] - local power_range_table = enchantment_def.power_range_table - for i = enchantment_def.max_level, 1, -1 do - local power_range = power_range_table[i] - if enchantment_level >= power_range[1] and enchantment_level <= power_range[2] then - enchantment_power = i - break - end - end - if not description then - if not enchantment_power then - return - end - description = mcl_enchanting.get_enchantment_description(selected_enchantment, enchantment_power) - end - if enchantment_power then - enchantments[selected_enchantment] = enchantment_power - mcl_enchanting.enchant(itemstack, selected_enchantment, enchantment_power) - end - else + + local selected_enchantment = mcl_enchanting.get_random_enchantment(itemstack, treasure, true, nil, pr) + + if not selected_enchantment then break end - until not no_reduced_bonus_chance and math.random() >= (enchantment_level + 1) / 50 + + local enchantment_def = mcl_enchanting.enchantments[selected_enchantment] + local power_range_table = enchantment_def.power_range_table + + local enchantment_power + + for i = enchantment_def.max_level, 1, -1 do + local power_range = power_range_table[i] + if enchantment_level >= power_range[1] and enchantment_level <= power_range[2] then + enchantment_power = i + break + end + end + + if not description then + if not enchantment_power then + return + end + + description = mcl_enchanting.get_enchantment_description(selected_enchantment, enchantment_power) + end + + if enchantment_power then + enchantments[selected_enchantment] = enchantment_power + mcl_enchanting.enchant(itemstack, selected_enchantment, enchantment_power) + end + + until not no_reduced_bonus_chance and mcl_enchanting.random(pr) >= (enchantment_level + 1) / 50 + return enchantments, description end -function mcl_enchanting.generate_random_enchantments_reliable(itemstack, enchantment_level, treasure, no_reduced_bonus_chance, ignore_already_enchanted) +function mcl_enchanting.generate_random_enchantments_reliable(itemstack, enchantment_level, treasure, no_reduced_bonus_chance, ignore_already_enchanted, pr) local enchantments + repeat - enchantments = mcl_enchanting.generate_random_enchantments(itemstack, enchantment_level, treasure, no_reduced_bonus_chance, ignore_already_enchanted) + enchantments = mcl_enchanting.generate_random_enchantments(itemstack, enchantment_level, treasure, no_reduced_bonus_chance, ignore_already_enchanted, pr) until enchantments + return enchantments end -function mcl_enchanting.enchant_randomly(itemstack, enchantment_level, treasure, no_reduced_bonus_chance, ignore_already_enchanted) +function mcl_enchanting.enchant_randomly(itemstack, enchantment_level, treasure, no_reduced_bonus_chance, ignore_already_enchanted, pr) + local enchantments = mcl_enchanting.generate_random_enchantments_reliable(itemstack, enchantment_level, treasure, no_reduced_bonus_chance, ignore_already_enchanted, pr) + mcl_enchanting.set_enchanted_itemstring(itemstack) - mcl_enchanting.set_enchantments(itemstack, mcl_enchanting.generate_random_enchantments_reliable(itemstack, enchantment_level, treasure, no_reduced_bonus_chance, ignore_already_enchanted)) + mcl_enchanting.set_enchantments(itemstack, enchantments) + return itemstack end -function mcl_enchanting.get_randomly_enchanted_book(enchantment_level, treasure, no_reduced_bonus_chance) - return mcl_enchanting.enchant_randomly(ItemStack("mcl_books:book"), enchantment_level, treasure, no_reduced_bonus_chance, true) -end +function mcl_enchanting.enchant_uniform_randomly(stack, exclude, pr) + local enchantment = mcl_enchanting.get_random_enchantment(stack, true, false, exclude, pr) -function mcl_enchanting.get_uniform_randomly_enchanted_book(except, pr) - except = except or except - local stack = ItemStack("mcl_enchanting:book_enchanted") - local list = {} - for enchantment in pairs(mcl_enchanting.enchantments) do - if table.indexof(except, enchantment) == -1 then - table.insert(list, enchantment) - end + if enchantment then + mcl_enchanting.enchant(stack, enchantment, mcl_enchanting.random(pr, 1, mcl_enchanting.enchantments[enchantment].max_level)) end - local index, level - if pr then - index = pr:next(1,#list) - else - index = math.random(#list) - end - local enchantment = list[index] - local enchantment_def = mcl_enchanting.enchantments[enchantment] - if pr then - level = pr:next(1, enchantment_def.max_level) - else - level = math.random(enchantment_def.max_level) - end - mcl_enchanting.enchant(stack, enchantment, level) + return stack end @@ -493,7 +509,7 @@ function mcl_enchanting.show_enchanting_formspec(player) .. "real_coordinates[true]" .. "image[3.15,0.6;7.6,4.1;mcl_enchanting_button_background.png]" local itemstack = inv:get_stack("enchanting_item", 1) - local player_levels = mcl_experience.get_player_xp_level(player) + local player_levels = mcl_experience.get_level(player) local y = 0.65 local any_enchantment = false local table_slots = mcl_enchanting.get_table_slots(player, itemstack, num_bookshelves) @@ -543,11 +559,11 @@ function mcl_enchanting.handle_formspec_fields(player, formname, fields) if not slot then return end - local player_level = mcl_experience.get_player_xp_level(player) + local player_level = mcl_experience.get_level(player) if player_level < slot.level_requirement then return end - mcl_experience.set_player_xp_level(player, player_level - button_pressed) + mcl_experience.set_level(player, player_level - button_pressed) inv:remove_item("enchanting_lapis", cost) mcl_enchanting.set_enchanted_itemstring(itemstack) mcl_enchanting.set_enchantments(itemstack, slot.enchantments) diff --git a/mods/ITEMS/mcl_enchanting/init.lua b/mods/ITEMS/mcl_enchanting/init.lua index 5aec1ced6..9f9fbd271 100644 --- a/mods/ITEMS/mcl_enchanting/init.lua +++ b/mods/ITEMS/mcl_enchanting/init.lua @@ -183,7 +183,7 @@ minetest.register_entity("mcl_enchanting:book", { collisionbox = {0, 0, 0}, pointable = false, physical = false, - textures = {"mcl_enchanting_book_entity.png"}, + textures = {"mcl_enchanting_book_entity.png", "mcl_enchanting_book_entity.png", "mcl_enchanting_book_entity.png", "mcl_enchanting_book_entity.png", "mcl_enchanting_book_entity.png"}, static_save = false, }, _player_near = false, diff --git a/mods/ITEMS/mcl_enchanting/locale/mcl_enchanting.es.tr b/mods/ITEMS/mcl_enchanting/locale/mcl_enchanting.es.tr new file mode 100644 index 000000000..a977e8fe6 --- /dev/null +++ b/mods/ITEMS/mcl_enchanting/locale/mcl_enchanting.es.tr @@ -0,0 +1,123 @@ +# textdomain: mcl_enchanting + + +### enchantments.lua ### + +Arrows passes through multiple objects.=Las flechas atraviesan multiples enemigos. +Arrows set target on fire.=Las flechas prenderan los enemigos. +Bane of Arthropods=Perdición de los Artrópodos +Channeling=Conductividad + +Channels a bolt of lightning toward a target. Works only during thunderstorms and if target is unobstructed with opaque blocks.=Canaliza los rayos de una tormenta hacia el enemigo. + +Curse of Vanishing=Maldición de Desaparición +Decreases crossbow charging time.=Disminuye el tiempo de carga de las ballestas. +Decreases time until rod catches something.=Disminuye el tiempo que tardan en picar los cebos en la pesca. +Depth Strider=Agilidad acuática +Efficiency=Eficiencia +Extends underwater breathing time.=Aumenta el tiempo de mantener la respiración. +Fire Aspect=Aspecto Ígneo +Flame=Fuego +Fortune=Fortuna +Frost Walker=Paso Helado +Impaling=Empalamiento +Increases arrow damage.=Incrementa el daño de las flechas. +Increases arrow knockback.=Incrementa el empuje de las flechas. +Increases certain block drops.=Incrementa la cantidad de objetos que sueltan los bloques. + +Increases damage and applies Slowness IV to arthropod mobs (spiders, cave spiders, silverfish and endermites).=Incrementa el daño y ralentiza a los artrópodos. (arañas, lepismas, endermitas, etc) + +Increases damage to undead mobs.=Incrementa el daño contra no-muertos. +Increases damage.=Incrementa el daño. +Increases item durability.=Incrementa la durabilidad de una herramienta. +Increases knockback.=Incrementa el empuje. +Increases mining speed.=Incrementa la velocidad de picado. +Increases mob loot.=Incrementa el botín de los enemigos. +Increases rate of good loot (enchanting books, etc.)=Incrementa la probabilidad de encontrar tesoros. +Increases sweeping attack damage.=Incrementa el daño de efecto area. +Increases underwater movement speed.=Incrementa la velocidad de nado bajo el agua. +Increases walking speed on soul sand.=Incrementa la velocidad al caminar sobre arena de Almas. +Infinity=Infinidad +Item destroyed on death.=El objeto se destruye tras tu muerte. +Knockback=Empuje +Looting=Botín +Loyalty=Lealtad +Luck of the Sea=Suerte Marina +Lure=Atracción +Mending=Reparación +Mined blocks drop themselves.=Los bloques se minarán enteros. +Multishot=Multidisparo +Piercing=Perforación +Power=Poder +Punch=Retroceso +Quick Charge=Carga Rápida +Repair the item while gaining XP orbs.=Repara los objetos portados al recibir orbes de experiencia. +Respiration=Respiración +Riptide=Propulsión acuática +Sets target on fire.=Incencia al enemigo. +Sharpness=Filo +Shoot 3 arrows at the cost of one.=Dispara 3 flechas al precio de una. +Shooting consumes no regular arrows.=No se consumiran las flechas lanzadas. +Silk Touch=Toque de Seda +Smite=Golpeo +Soul Speed=Velocidad de Almas +Sweeping Edge=Filo Arrasador +Trident deals additional damage to ocean mobs.=Incrementa el daño del tridente sobre criaturas acuáticas. + +Trident launches player with itself when thrown. Works only in water or rain.=El tridente impulsa al portador dentro del agua o bajo la lluvia. + +Trident returns after being thrown. Higher levels reduce return time.=El tridente regresa al portador tras lanzarlo. + +Turns water beneath the player into frosted ice and prevents the damage from magma blocks.=Congela el agua bajo tus pies y evita el daño de los bloques de magma. + +Unbreaking=Irrompibilidad + +### engine.lua ### + +@1 Enchantment Levels=Nivel de encantamiento: @1 +@1 Lapis Lazuli=@1 Lapis Lázuli +Inventory=Inventario +Level requirement: @1=Nivel requerido: @1 + +### init.lua ### + +'@1' is not a valid number='@1' no es un número válido +'@1' is not a valid number.='@1' no es un número válido + []= [] +@1 can't be combined with @2.=@1 no se puede combinar con @2 + +After finally selecting your enchantment; left-click on the selection, and you will see both the lapis lazuli and your experience levels consumed. And, an enchanted item left in its place.=Despues elige tu encantamiento, los niveles de experiencia y el lapis lázuli seran consumidos y el encantamiento aplicado al objeto. + +After placing your items in the slots, the enchanting options will be shown. Hover over the options to read what is available to you.=Coloca el objeto en su ranura yse mostraran los encantamientos a elegir. + +Enchant=Encantamiento +Enchant an item=Encantar objeto +Enchanted Book=Libro Encantado +Enchanting Table=Mesa de Encantamientos + +Enchanting Tables will let you enchant armors, tools, weapons, and books with various abilities. But, at the cost of some experience, and lapis lazuli.=La mesa de Encantamientos dara a tus herramientas, armas o armadura algunas habilidades magicas. Pero a coste de algo de experiencia y lapis lázuli. + +Enchanting succeded.=Encantado correctamente. +Forcefully enchant an item=Encantar objeto a la fuerza. + +Place a tool, armor, weapon or book into the top left slot, and then place 1-3 Lapis Lazuli in the slot to the right.=Coloca una herramienta, arma, armadura o libro sobre la ranura izquierda, coloca de 1 a 3 Lapis lázulis en la ranura derecha. + +Player '@1' cannot be found.=Jugador @1 no encontrado. +Rightclick the Enchanting Table to open the enchanting menu.=Clic derecho sobre la mesa de encantamientos para abrir la interfaz. +Spend experience, and lapis to enchant various items.=Experiencia y Lapis para encantar varios objetos. + +The number you have entered (@1) is too big, it must be at most @2.=@1 es muy grande, debe ser menor que @2 + +The number you have entered (@1) is too small, it must be at least @2.=@1 es muy pequeño, debe ser mayor a @2 + +The selected enchantment can't be added to the target item.=El encantamiento seleccionado no puede añadirse a ese objeto. +The target doesn't hold an item.=El jugador no sujeta un objeto. +The target item is not enchantable.=El objeto del jugador no se puede encantar. +There is no such enchantment '@1'.=@1 no es un encantamiento. + +These options are randomized, and dependent on experience level; but the enchantment strength can be increased.=Las opciones seran aleatorias dependiendo del nivel de experiencia, los niveles de encantamiento pueden ser aumentados. + +To increase the enchantment strength, place bookshelves around the enchanting table. However, you will need to keep 1 air node between the table, & the bookshelves to empower the enchanting table.=Para aumentar los niveles de encantamientos, coloca librerias alrededor y cerca de la mesa de encantamientos. + +Usage: /enchant []=Usa: /enchant [] +Usage: /forceenchant []=Usa /forceenchant [] diff --git a/mods/ITEMS/mcl_enchanting/locale/mcl_enchanting.fr.tr b/mods/ITEMS/mcl_enchanting/locale/mcl_enchanting.fr.tr index e1178e782..985499964 100644 --- a/mods/ITEMS/mcl_enchanting/locale/mcl_enchanting.fr.tr +++ b/mods/ITEMS/mcl_enchanting/locale/mcl_enchanting.fr.tr @@ -7,7 +7,7 @@ Blast Protection=Protection contre les explosions Reduces explosion damage and knockback.=Réduit les dégâts d'explosion et de recul. Channeling=Canalisation Channels a bolt of lightning toward a target. Works only during thunderstorms and if target is unobstructed with opaque blocks.=Canalise un éclair vers une cible. Fonctionne uniquement pendant les orages et si la cible n'est pas obstruée par des blocs opaques. -Curse of Binding=Malédiction du lien éterne +Curse of Binding=Malédiction du lien éternel Item cannot be removed from armor slots except due to death, breaking or in Creative Mode.=L'objet ne peut pas être retiré des emplacements d'armure sauf en cas de mort, de rupture ou en mode créatif. Curse of Vanishing=Malédiction de disparition Item destroyed on death.=Objet détruit à la mort. diff --git a/mods/ITEMS/mcl_enchanting/locale/template.txt b/mods/ITEMS/mcl_enchanting/locale/template.txt index 08fa82097..1f540d6d3 100644 --- a/mods/ITEMS/mcl_enchanting/locale/template.txt +++ b/mods/ITEMS/mcl_enchanting/locale/template.txt @@ -1,100 +1,129 @@ # textdomain: mcl_enchanting -Aqua Affinity= -Increases underwater mining speed.= -Bane of Arthropods= -Increases damage and applies Slowness IV to arthropod mobs (spiders, cave spiders, silverfish and endermites).= -Blast Protection= -Reduces explosion damage and knockback.= -Channeling= -Channels a bolt of lightning toward a target. Works only during thunderstorms and if target is unobstructed with opaque blocks.= -Curse of Binding= -Item cannot be removed from armor slots except due to death, breaking or in Creative Mode.= -Curse of Vanishing= -Item destroyed on death.= -Depth Strider= -Increases underwater movement speed.= -Efficiency= -Increases mining speed.= -Feather Falling= -Reduces fall damage.= -Fire Aspect= -Sets target on fire.= -Fire Protection= -Reduces fire damage.= -Flame= -Arrows set target on fire.= -Fortune= -Increases certain block drops.= -Frost Walker= -Turns water beneath the player into frosted ice and prevents the damage from magma blocks.= -Impaling= -Trident deals additional damage to ocean mobs.= -Infinity= -Shooting consumes no regular arrows.= -Knockback= -Increases knockback.= -Looting= -Increases mob loot.= -Loyalty= -Trident returns after being thrown. Higher levels reduce return time.= -Luck of the Sea= -Increases rate of good loot (enchanting books, etc.)= -Lure= -Decreases time until rod catches something.= -Mending= -Repair the item while gaining XP orbs.= -Multishot= -Shoot 3 arrows at the cost of one.= -Piercing= + + +### enchantments.lua ### + Arrows passes through multiple objects.= -Power= -Increases arrow damage.= -Projectile Protection= -Reduces projectile damage.= -Protection= -Reduces most types of damage by 4% for each level.= -Punch= -Increases arrow knockback.= -Quick Charge= +Arrows set target on fire.= +Bane of Arthropods= +Channeling= + +Channels a bolt of lightning toward a target. Works only during thunderstorms and if target is unobstructed with opaque blocks.= + +Curse of Vanishing= Decreases crossbow charging time.= -Respiration= +Decreases time until rod catches something.= +Depth Strider= +Efficiency= Extends underwater breathing time.= -Riptide= -Trident launches player with itself when thrown. Works only in water or rain.= -Sharpness= -Increases damage.= -Silk Touch= -Mined blocks drop themselves.= -Smite= +Fire Aspect= +Flame= +Fortune= +Frost Walker= +Impaling= +Increases arrow damage.= +Increases arrow knockback.= +Increases certain block drops.= + +Increases damage and applies Slowness IV to arthropod mobs (spiders, cave spiders, silverfish and endermites).= + Increases damage to undead mobs.= -Soul Speed= -Increases walking speed on soul sand.= -Sweeping Edge= -Increases sweeping attack damage.= -Thorns= -Reflects some of the damage taken when hit, at the cost of reducing durability with each proc.= -Unbreaking= +Increases damage.= Increases item durability.= -Inventory= -@1 Lapis Lazuli= +Increases knockback.= +Increases mining speed.= +Increases mob loot.= +Increases rate of good loot (enchanting books, etc.)= +Increases sweeping attack damage.= +Increases underwater movement speed.= +Increases walking speed on soul sand.= +Infinity= +Item destroyed on death.= +Knockback= +Looting= +Loyalty= +Luck of the Sea= +Lure= +Mending= +Mined blocks drop themselves.= +Multishot= +Piercing= +Power= +Punch= +Quick Charge= +Repair the item while gaining XP orbs.= +Respiration= +Riptide= +Sets target on fire.= +Sharpness= +Shoot 3 arrows at the cost of one.= +Shooting consumes no regular arrows.= +Silk Touch= +Smite= +Soul Speed= +Sweeping Edge= +Trident deals additional damage to ocean mobs.= + +Trident launches player with itself when thrown. Works only in water or rain.= + +Trident returns after being thrown. Higher levels reduce return time.= + +Turns water beneath the player into frosted ice and prevents the damage from magma blocks.= + +Unbreaking= + +### engine.lua ### + @1 Enchantment Levels= +@1 Lapis Lazuli= +Inventory= Level requirement: @1= -Enchant an item= - []= -Usage: /enchant []= -Player '@1' cannot be found.= -There is no such enchantment '@1'.= -The target doesn't hold an item.= -The selected enchantment can't be added to the target item.= + +### init.lua ### + '@1' is not a valid number= -The number you have entered (@1) is too big, it must be at most @2.= -The number you have entered (@1) is too small, it must be at least @2.= -@1 can't be combined with @2.= -Enchanting succeded.= -Forcefully enchant an item= -Usage: /forceenchant []= -The target item is not enchantable.= '@1' is not a valid number.= + []= +@1 can't be combined with @2.= + +After finally selecting your enchantment; left-click on the selection, and you will see both the lapis lazuli and your experience levels consumed. And, an enchanted item left in its place.= + +After placing your items in the slots, the enchanting options will be shown. Hover over the options to read what is available to you.= + +Enchant= +Enchant an item= Enchanted Book= Enchanting Table= -Enchant= + +Enchanting Tables will let you enchant armors, tools, weapons, and books with various abilities. But, at the cost of some experience, and lapis lazuli.= + +Enchanting succeded.= +Forcefully enchant an item= + +Place a tool, armor, weapon or book into the top left slot, and then place 1-3 Lapis Lazuli in the slot to the right.= + +Player '@1' cannot be found.= +Rightclick the Enchanting Table to open the enchanting menu.= +Spend experience, and lapis to enchant various items.= + +The number you have entered (@1) is too big, it must be at most @2.= + +The number you have entered (@1) is too small, it must be at least @2.= + +The selected enchantment can't be added to the target item.= +The target doesn't hold an item.= +The target item is not enchantable.= +There is no such enchantment '@1'.= + +These options are randomized, and dependent on experience level; but the enchantment strength can be increased.= + +To increase the enchantment strength, place bookshelves around the enchanting table. However, you will need to keep 1 air node between the table, & the bookshelves to empower the enchanting table.= + +Usage: /enchant []= +Usage: /forceenchant []= + + +##### not used anymore ##### + +# textdomain: mcl_enchanting +Aqua Affinity= diff --git a/mods/ITEMS/mcl_end/chorus_plant.lua b/mods/ITEMS/mcl_end/chorus_plant.lua index 24307b5ed..4dc54db18 100644 --- a/mods/ITEMS/mcl_end/chorus_plant.lua +++ b/mods/ITEMS/mcl_end/chorus_plant.lua @@ -453,7 +453,7 @@ function mcl_end.grow_chorus_plant_step(pos, node, pr) end --- ABM --- -local seed = minetest.get_mapgen_params().seed +local seed = minetest.get_mapgen_setting("seed") local pr = PseudoRandom(seed) minetest.register_abm({ label = "Chorus plant growth", diff --git a/mods/ITEMS/mcl_fireworks/locale/mcl_fireworks.es.tr b/mods/ITEMS/mcl_fireworks/locale/mcl_fireworks.es.tr new file mode 100644 index 000000000..e66eb06a5 --- /dev/null +++ b/mods/ITEMS/mcl_fireworks/locale/mcl_fireworks.es.tr @@ -0,0 +1,3 @@ +# textdomain: mcl_fireworks +Firework Rocket= +Flight Duration:= \ No newline at end of file diff --git a/mods/ITEMS/mcl_fireworks/locale/mcl_fireworks.fr.tr b/mods/ITEMS/mcl_fireworks/locale/mcl_fireworks.fr.tr new file mode 100644 index 000000000..b02faa428 --- /dev/null +++ b/mods/ITEMS/mcl_fireworks/locale/mcl_fireworks.fr.tr @@ -0,0 +1,3 @@ +# textdomain: mcl_fireworks +Firework Rocket=Fusée +Flight Duration:=Durée de vol : \ No newline at end of file diff --git a/mods/ITEMS/mcl_fireworks/locale/mcl_fireworks.ru.tr b/mods/ITEMS/mcl_fireworks/locale/mcl_fireworks.ru.tr new file mode 100644 index 000000000..e66eb06a5 --- /dev/null +++ b/mods/ITEMS/mcl_fireworks/locale/mcl_fireworks.ru.tr @@ -0,0 +1,3 @@ +# textdomain: mcl_fireworks +Firework Rocket= +Flight Duration:= \ No newline at end of file diff --git a/mods/ITEMS/mcl_fishing/init.lua b/mods/ITEMS/mcl_fishing/init.lua index e0c78832f..788e591dc 100644 --- a/mods/ITEMS/mcl_fishing/init.lua +++ b/mods/ITEMS/mcl_fishing/init.lua @@ -37,7 +37,7 @@ local fish = function(itemstack, player, pointed_thing) local num = 0 local ent = nil local noent = true - + local durability = 65 local unbreaking = mcl_enchanting.get_enchantment(itemstack, "unbreaking") if unbreaking > 0 then @@ -71,7 +71,9 @@ local fish = function(itemstack, player, pointed_thing) { itemstring = "mcl_fishing:salmon_raw", weight = 25 }, { itemstring = "mcl_fishing:clownfish_raw", weight = 2 }, { itemstring = "mcl_fishing:pufferfish_raw", weight = 13 }, - } + }, + stacks_min = 1, + stacks_max = 1, }, pr) elseif r <= junk_value then -- Junk @@ -88,21 +90,29 @@ local fish = function(itemstack, player, pointed_thing) { itemstring = "mcl_mobitems:bone", weight = 10 }, { itemstring = "mcl_dye:black", weight = 1, amount_min = 10, amount_max = 10 }, { itemstring = "mcl_mobitems:string", weight = 10 }, -- TODO: Tripwire Hook - } + }, + stacks_min = 1, + stacks_max = 1, }, pr) else -- Treasure items = mcl_loot.get_loot({ items = { - -- TODO: Enchanted Bow - { itemstring = "mcl_bows:bow", wear_min = 49144, wear_max = 65535 }, -- 75%-100% damage - { itemstack = mcl_enchanting.get_randomly_enchanted_book(30, true, true)}, - -- TODO: Enchanted Fishing Rod - { itemstring = "mcl_fishing:fishing_rod", wear_min = 49144, wear_max = 65535 }, -- 75%-100% damage + { itemstring = "mcl_bows:bow", wear_min = 49144, wear_max = 65535, func = function(stack, pr) + mcl_enchanting.enchant_randomly(stack, 30, true, false, false, pr) + end }, -- 75%-100% damage + { itemstring = "mcl_books:book", func = function(stack, pr) + mcl_enchanting.enchant_randomly(stack, 30, true, true, false, pr) + end }, + { itemstring = "mcl_fishing:fishing_rod", wear_min = 49144, wear_max = 65535, func = function(stack, pr) + mcl_enchanting.enchant_randomly(stack, 30, true, false, false, pr) + end }, -- 75%-100% damage { itemstring = "mcl_mobs:nametag", }, { itemstring = "mcl_mobitems:saddle", }, { itemstring = "mcl_flowers:waterlily", }, - } + }, + stacks_min = 1, + stacks_max = 1, }, pr) end local item @@ -117,8 +127,8 @@ local fish = function(itemstack, player, pointed_thing) else minetest.add_item(pos, item) end - if mcl_experience.throw_experience then - mcl_experience.throw_experience(pos, math.random(1,6)) + if mcl_experience.throw_xp then + mcl_experience.throw_xp(pos, math.random(1,6)) end if not minetest.is_creative_enabled(player:get_player_name()) then diff --git a/mods/ITEMS/mcl_furnaces/init.lua b/mods/ITEMS/mcl_furnaces/init.lua index ca43b275a..9f836d161 100644 --- a/mods/ITEMS/mcl_furnaces/init.lua +++ b/mods/ITEMS/mcl_furnaces/init.lua @@ -75,9 +75,9 @@ local function give_xp(pos, player) local xp = meta:get_int("xp") if xp > 0 then if player then - mcl_experience.add_experience(player, xp) + mcl_experience.add_xp(player, xp) else - mcl_experience.throw_experience(vector.add(pos, dir), xp) + mcl_experience.throw_xp(vector.add(pos, dir), xp) end meta:set_int("xp", 0) end @@ -461,7 +461,7 @@ minetest.register_node("mcl_furnaces:furnace", { on_timer = furnace_node_timer, after_dig_node = function(pos, oldnode, oldmetadata, digger) local meta = minetest.get_meta(pos) - local meta2 = meta + local meta2 = meta:to_table() meta:from_table(oldmetadata) local inv = meta:get_inventory() for _, listname in ipairs({"src", "dst", "fuel"}) do @@ -471,7 +471,7 @@ minetest.register_node("mcl_furnaces:furnace", { minetest.add_item(p, stack) end end - meta:from_table(meta2:to_table()) + meta:from_table(meta2) end, on_construct = function(pos) diff --git a/mods/ITEMS/mcl_hoppers/init.lua b/mods/ITEMS/mcl_hoppers/init.lua index 9defa26ca..36a21ad95 100644 --- a/mods/ITEMS/mcl_hoppers/init.lua +++ b/mods/ITEMS/mcl_hoppers/init.lua @@ -61,7 +61,7 @@ local def_hopper = { after_dig_node = function(pos, oldnode, oldmetadata, digger) local meta = minetest.get_meta(pos) - local meta2 = meta + local meta2 = meta:to_table() meta:from_table(oldmetadata) local inv = meta:get_inventory() for i=1,inv:get_size("main") do @@ -71,7 +71,7 @@ local def_hopper = { minetest.add_item(p, stack) end end - meta:from_table(meta2:to_table()) + meta:from_table(meta2) end, allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player) local name = player:get_player_name() @@ -350,7 +350,7 @@ minetest.register_abm({ local inv = meta:get_inventory() for _,object in pairs(minetest.get_objects_inside_radius(pos, 2)) do - if not object:is_player() and object:get_luaentity() and object:get_luaentity().name == "__builtin:item" then + if not object:is_player() and object:get_luaentity() and object:get_luaentity().name == "__builtin:item" and not object:get_luaentity()._removed then if inv and inv:room_for_item("main", ItemStack(object:get_luaentity().itemstring)) then -- Item must get sucked in when the item just TOUCHES the block above the hopper -- This is the reason for the Y calculation. diff --git a/mods/ITEMS/mcl_jukebox/init.lua b/mods/ITEMS/mcl_jukebox/init.lua index 2c9fef689..6c51a6c94 100644 --- a/mods/ITEMS/mcl_jukebox/init.lua +++ b/mods/ITEMS/mcl_jukebox/init.lua @@ -94,7 +94,9 @@ minetest.register_craft({ }) local function play_record(pos, itemstack, player) - local name = itemstack:get_name() + local item_name = itemstack:get_name() + -- ensure the jukebox uses the new record names for old records + local name = minetest.registered_aliases[item_name] or item_name if mcl_jukebox.registered_records[name] then local cname = player:get_player_name() if active_tracks[cname] then @@ -239,25 +241,10 @@ mcl_jukebox.register_record("The Clueless Frog (Jordach's Mix)", "SoundHelix", " --add backward compatibility minetest.register_alias("mcl_jukebox:record_1", "mcl_jukebox:record_13") -mcl_jukebox.registered_records["mcl_jukebox:record_1"] = mcl_jukebox.registered_records["mcl_jukebox:record_13"] - minetest.register_alias("mcl_jukebox:record_2", "mcl_jukebox:record_wait") -mcl_jukebox.registered_records["mcl_jukebox:record_2"] = mcl_jukebox.registered_records["mcl_jukebox:record_wait"] - minetest.register_alias("mcl_jukebox:record_3", "mcl_jukebox:record_blocks") -mcl_jukebox.registered_records["mcl_jukebox:record_3"] = mcl_jukebox.registered_records["mcl_jukebox:record_blocks"] - minetest.register_alias("mcl_jukebox:record_4", "mcl_jukebox:record_far") -mcl_jukebox.registered_records["mcl_jukebox:record_4"] = mcl_jukebox.registered_records["mcl_jukebox:record_far"] - minetest.register_alias("mcl_jukebox:record_5", "mcl_jukebox:record_chirp") -mcl_jukebox.registered_records["mcl_jukebox:record_5"] = mcl_jukebox.registered_records["mcl_jukebox:record_chirp"] - minetest.register_alias("mcl_jukebox:record_6", "mcl_jukebox:record_strad") -mcl_jukebox.registered_records["mcl_jukebox:record_6"] = mcl_jukebox.registered_records["mcl_jukebox:record_strad"] - minetest.register_alias("mcl_jukebox:record_7", "mcl_jukebox:record_mellohi") -mcl_jukebox.registered_records["mcl_jukebox:record_7"] = mcl_jukebox.registered_records["mcl_jukebox:record_mellohi"] - -minetest.register_alias("mcl_jukebox:record_8", "mcl_jukebox:record_mall") -mcl_jukebox.registered_records["mcl_jukebox:record_8"] = mcl_jukebox.registered_records["mcl_jukebox:record_mall"] \ No newline at end of file +minetest.register_alias("mcl_jukebox:record_8", "mcl_jukebox:record_mall") \ No newline at end of file diff --git a/mods/ITEMS/mcl_maps/locale/mcl_maps.fr.tr b/mods/ITEMS/mcl_maps/locale/mcl_maps.fr.tr index 9ef7cd5c5..1808e839d 100644 --- a/mods/ITEMS/mcl_maps/locale/mcl_maps.fr.tr +++ b/mods/ITEMS/mcl_maps/locale/mcl_maps.fr.tr @@ -1,5 +1,8 @@ # textdomain: mcl_maps Empty Map=Carte Vierge Empty maps are not useful as maps, but they can be stacked and turned to maps which can be used.=Les cartes vierges ne sont pas utiles en tant que cartes, mais elles peuvent être empilées et transformées en cartes utilisables. -Rightclick to start using the map (which can't be stacked anymore).=Clic droit pour commencer à utiliser la carte (qui ne peut plus être empilée). +Rightclick to create a filled map (which can't be stacked anymore).=Clic droit pour créer une carte remplie (qui ne peut plus être empilée). Map=Carte +Shows a map image.=Affiche une carte. +When created, the map saves the nearby area as an image that can be viewed any time by holding the map.=Lors de sa création, la carte sauvegarde le terrain proche sous forme d'image qui peut être consultée n'importe quand en tenant la carte dans la main. +Hold the map in your hand. This will display a map on your screen.=Tenez la carte dans votre main. Cela affichera la carte à l'écran. diff --git a/mods/ITEMS/mcl_mobspawners/init.lua b/mods/ITEMS/mcl_mobspawners/init.lua index 6c5d7f6e4..0795fb611 100644 --- a/mods/ITEMS/mcl_mobspawners/init.lua +++ b/mods/ITEMS/mcl_mobspawners/init.lua @@ -317,7 +317,7 @@ minetest.register_node("mcl_mobspawners:spawner", { if obj then obj:remove() end - mcl_experience.throw_experience(pos, math.random(15, 43)) + mcl_experience.throw_xp(pos, math.random(15, 43)) end, on_punch = function(pos) @@ -387,4 +387,3 @@ minetest.register_lbm({ respawn_doll(pos) end, }) - diff --git a/mods/ITEMS/mcl_portals/mod.conf b/mods/ITEMS/mcl_portals/mod.conf index d99344a76..610b590c6 100644 --- a/mods/ITEMS/mcl_portals/mod.conf +++ b/mods/ITEMS/mcl_portals/mod.conf @@ -1,4 +1,4 @@ name = mcl_portals description = Adds buildable portals to the Nether and End dimensions. -depends = mcl_nether, mcl_end, mcl_particles, mcl_spawn +depends = mcl_nether, mcl_end, mcl_particles, mcl_spawn, mcl_credits optional_depends = awards, doc diff --git a/mods/ITEMS/mcl_portals/portal_end.lua b/mods/ITEMS/mcl_portals/portal_end.lua index d591537e1..e4982c39b 100644 --- a/mods/ITEMS/mcl_portals/portal_end.lua +++ b/mods/ITEMS/mcl_portals/portal_end.lua @@ -4,6 +4,8 @@ local table = table local vector = vector local math = math +local has_doc = minetest.get_modpath("doc") + -- Parameters --local SPAWN_MIN = mcl_vars.mg_end_min+70 --local SPAWN_MAX = mcl_vars.mg_end_min+98 @@ -339,7 +341,7 @@ minetest.register_node("mcl_portals:end_portal_frame_eye", { _mcl_hardness = -1, }) -if minetest.get_modpath("doc") then +if has_doc then doc.add_entry_alias("nodes", "mcl_portals:end_portal_frame", "nodes", "mcl_portals:end_portal_frame_eye") end @@ -366,7 +368,7 @@ minetest.override_item("mcl_end:ender_eye", { end minetest.set_node(pointed_thing.under, { name = "mcl_portals:end_portal_frame_eye", param2 = node.param2 }) - if minetest.get_modpath("doc") then + if has_doc then doc.mark_entry_as_revealed(user:get_player_name(), "nodes", "mcl_portals:end_portal_frame") end minetest.sound_play( @@ -381,7 +383,7 @@ minetest.override_item("mcl_end:ender_eye", { -- Epic 'portal open' sound effect that can be heard everywhere minetest.sound_play("mcl_portals_open_end_portal", {gain=0.8}, true) end_portal_area(ppos) - if minetest.get_modpath("doc") then + if has_doc then doc.mark_entry_as_revealed(user:get_player_name(), "nodes", "mcl_portals:portal_end") end end @@ -389,7 +391,3 @@ minetest.override_item("mcl_end:ender_eye", { return itemstack end, }) -minetest.override_item("mcl_core:bedrock", { - after_destruct = destroy_portal, -}) - diff --git a/mods/ITEMS/mcl_portals/portal_nether.lua b/mods/ITEMS/mcl_portals/portal_nether.lua index 3f15a134d..46025619c 100644 --- a/mods/ITEMS/mcl_portals/portal_nether.lua +++ b/mods/ITEMS/mcl_portals/portal_nether.lua @@ -237,6 +237,11 @@ local function destroy_nether_portal(pos, node) check_remove({x = pos.x, y = pos.y + 1, z = pos.z}) end +local on_rotate +if minetest.get_modpath("screwdriver") then + on_rotate = screwdriver.disallow +end + minetest.register_node(PORTAL, { description = S("Nether Portal"), _doc_items_longdesc = S("A Nether portal teleports creatures and objects to the hot and dangerous Nether dimension (and back!). Enter at your own risk!"), @@ -286,6 +291,7 @@ minetest.register_node(PORTAL, { groups = { creative_breakable = 1, portal = 1, not_in_creative_inventory = 1 }, sounds = mcl_sounds.node_sound_glass_defaults(), after_destruct = destroy_nether_portal, + on_rotate = on_rotate, _mcl_hardness = -1, _mcl_blast_resistance = 0, diff --git a/mods/ITEMS/mcl_potions/functions.lua b/mods/ITEMS/mcl_potions/functions.lua index 09b95115a..c3b034b66 100644 --- a/mods/ITEMS/mcl_potions/functions.lua +++ b/mods/ITEMS/mcl_potions/functions.lua @@ -35,13 +35,13 @@ local function potions_init_icons(player) local name = player:get_player_name() icon_ids[name] = {} for e=1, EFFECT_TYPES do - local x = -7 + -38 * e + local x = -52 * e - 2 local id = player:hud_add({ hud_elem_type = "image", text = "blank.png", position = { x = 1, y = 0 }, - offset = { x = x, y = 272 }, - scale = { x = 2, y = 2 }, + offset = { x = x, y = 3 }, + scale = { x = 3, y = 3 }, alignment = { x = 1, y = 1 }, z_index = 100, }) diff --git a/mods/ITEMS/mcl_potions/tipped_arrow.lua b/mods/ITEMS/mcl_potions/tipped_arrow.lua index ab55cb72a..1717533a8 100644 --- a/mods/ITEMS/mcl_potions/tipped_arrow.lua +++ b/mods/ITEMS/mcl_potions/tipped_arrow.lua @@ -463,4 +463,4 @@ function mcl_potions.register_arrow(name, desc, color, def) if minetest.get_modpath("doc_identifier") then doc.sub.identifier.register_object("mcl_bows:arrow_entity", "craftitems", "mcl_bows:arrow") end -end \ No newline at end of file +end diff --git a/mods/ITEMS/mcl_sponges/init.lua b/mods/ITEMS/mcl_sponges/init.lua index a1998ecb0..e9755479b 100644 --- a/mods/ITEMS/mcl_sponges/init.lua +++ b/mods/ITEMS/mcl_sponges/init.lua @@ -115,16 +115,22 @@ function place_wet_sponge(itemstack, placer, pointed_thing) if mcl_worlds.pos_to_dimension(pointed_thing.above) == "nether" then minetest.item_place_node(ItemStack("mcl_sponges:sponge"), placer, pointed_thing) local pos = pointed_thing.above - for n = 0, 25 do - minetest.add_particle({ - pos = {x = pos.x + math.random(-1, 1)*math.random()/2, y = pos.y + 0.6, z = pos.z + math.random(-1, 1)*math.random()/2}, - velocity = {x = 0, y = math.random(), z = 0}, - acceleration = {x=0, y=0, z=0}, - expirationtime = math.random(), + + for n = 1, 5 do + minetest.add_particlespawner({ + amount = 5, + time = 0.1, + minpos = vector.offset(pos, -0.5, 0.6, -0.5), + maxpos = vector.offset(pos, 0.5, 0.6, 0.5), + minvel = vector.new(0, 0.1, 0), + maxvel = vector.new(0, 1, 0), + minexptime = 0.1, + maxexptime = 1, + minsize = 2, + maxsize = 5, collisiondetection = false, vertical = false, - size = math.random(2, 5), - texture = "mcl_particles_sponge"..math.random(1, 5)..".png", + texture = "mcl_particles_sponge" .. n .. ".png", }) end if not minetest.is_creative_enabled(name) then diff --git a/mods/ITEMS/mcl_totems/init.lua b/mods/ITEMS/mcl_totems/init.lua index 499d7362d..b11e68df7 100644 --- a/mods/ITEMS/mcl_totems/init.lua +++ b/mods/ITEMS/mcl_totems/init.lua @@ -4,6 +4,8 @@ minetest.register_on_leaveplayer(function(player) hud_totem[player] = nil end) +local particle_colors = {"98BF22", "C49E09", "337D0B", "B0B021", "1E9200"} -- TODO: real MC colors + -- Save the player from death when holding totem of undying in hand mcl_damage.register_modifier(function(obj, damage, reason) if obj:is_player() then @@ -14,7 +16,7 @@ mcl_damage.register_modifier(function(obj, damage, reason) local ppos = obj:get_pos() local pnname = minetest.get_node(ppos).name -- Some exceptions when _not_ to save the player - for n=1, #mobs_mc.misc.totem_fail_nodes do + for n = 1, #mobs_mc.misc.totem_fail_nodes do if pnname == mobs_mc.misc.totem_fail_nodes[n] then return end @@ -30,16 +32,41 @@ mcl_damage.register_modifier(function(obj, damage, reason) end -- Effects - minetest.sound_play({name = "mcl_totems_totem", gain=1}, {pos=ppos, max_hear_distance=16}, true) + minetest.sound_play({name = "mcl_totems_totem", gain = 1}, {pos=ppos, max_hear_distance = 16}, true) + + for i = 1, 4 do + for c = 1, #particle_colors do + minetest.add_particlespawner({ + amount = math.floor(100 / (4 * #particle_colors)), + time = 1, + minpos = vector.offset(ppos, 0, -1, 0), + maxpos = vector.offset(ppos, 0, 1, 0), + minvel = vector.new(-1.5, 0, -1.5), + maxvel = vector.new(1.5, 1.5, 1.5), + minacc = vector.new(0, -0.1, 0), + maxacc = vector.new(0, -1, 0), + minexptime = 1, + maxexptime = 3, + minsize = 1, + maxsize = 2, + collisiondetection = true, + collision_removal = true, + object_collision = false, + vertical = false, + texture = "mcl_particles_totem" .. i .. ".png^[colorize:#" .. particle_colors[c], + glow = 10, + }) + end + end -- Big totem overlay if not hud_totem[obj] then hud_totem[obj] = obj:hud_add({ hud_elem_type = "image", text = "mcl_totems_totem.png", - position = { x=0.5, y=1 }, - scale = { x=17, y=17 }, - offset = { x=0, y=-178 }, + position = {x = 0.5, y = 1}, + scale = {x = 17, y = 17}, + offset = {x = 0, y = -178}, z_index = 100, }) minetest.after(3, function() diff --git a/mods/MAPGEN/mcl_biomes/init.lua b/mods/MAPGEN/mcl_biomes/init.lua index a630dba04..a04822439 100644 --- a/mods/MAPGEN/mcl_biomes/init.lua +++ b/mods/MAPGEN/mcl_biomes/init.lua @@ -1496,7 +1496,7 @@ local function register_dimension_biomes() heat_point = 100, humidity_point = 0, _mcl_biome_type = "hot", - _mcl_palette_index = 19, + _mcl_palette_index = 17, }) --[[ THE END ]] diff --git a/mods/MAPGEN/mcl_dungeons/init.lua b/mods/MAPGEN/mcl_dungeons/init.lua index 58e23b12e..905e26396 100644 --- a/mods/MAPGEN/mcl_dungeons/init.lua +++ b/mods/MAPGEN/mcl_dungeons/init.lua @@ -63,6 +63,67 @@ local surround_vectors = { { x=0, y=0, z=1 }, } +local loottable = +{ + { + stacks_min = 1, + stacks_max = 3, + items = { + { itemstring = "mcl_mobs:nametag", weight = 20 }, + { itemstring = "mcl_mobitems:saddle", weight = 20 }, + { itemstring = "mcl_jukebox:record_1", weight = 15 }, + { itemstring = "mcl_jukebox:record_4", weight = 15 }, + { itemstring = "mobs_mc:iron_horse_armor", weight = 15 }, + { itemstring = "mcl_core:apple_gold", weight = 15 }, + { itemstring = "mcl_books:book", weight = 10, func = function(stack, pr) + mcl_enchanting.enchant_uniform_randomly(stack, {"soul_speed"}, pr) + end }, + { itemstring = "mobs_mc:gold_horse_armor", weight = 10 }, + { itemstring = "mobs_mc:diamond_horse_armor", weight = 5 }, + { itemstring = "mcl_core:apple_gold_enchanted", weight = 2 }, + } + }, + { + stacks_min = 1, + stacks_max = 4, + items = { + { itemstring = "mcl_farming:wheat_item", weight = 20, amount_min = 1, amount_max = 4 }, + { itemstring = "mcl_farming:bread", weight = 20 }, + { itemstring = "mcl_core:coal_lump", weight = 15, amount_min = 1, amount_max = 4 }, + { itemstring = "mesecons:redstone", weight = 15, amount_min = 1, amount_max = 4 }, + { itemstring = "mcl_farming:beetroot_seeds", weight = 10, amount_min = 2, amount_max = 4 }, + { itemstring = "mcl_farming:melon_seeds", weight = 10, amount_min = 2, amount_max = 4 }, + { itemstring = "mcl_farming:pumpkin_seeds", weight = 10, amount_min = 2, amount_max = 4 }, + { itemstring = "mcl_core:iron_ingot", weight = 10, amount_min = 1, amount_max = 4 }, + { itemstring = "mcl_buckets:bucket_empty", weight = 10 }, + { itemstring = "mcl_core:gold_ingot", weight = 5, amount_min = 1, amount_max = 4 }, + }, + }, + { + stacks_min = 3, + stacks_max = 3, + items = { + { itemstring = "mcl_mobitems:bone", weight = 10, amount_min = 1, amount_max = 8 }, + { itemstring = "mcl_mobitems:gunpowder", weight = 10, amount_min = 1, amount_max = 8 }, + { itemstring = "mcl_mobitems:rotten_flesh", weight = 10, amount_min = 1, amount_max = 8 }, + { itemstring = "mcl_mobitems:string", weight = 10, amount_min = 1, amount_max = 8 }, + }, + } +} + +-- Bonus loot for v6 mapgen: Otherwise unobtainable saplings. +if mg_name == "v6" then + table.insert(loottable, { + stacks_min = 1, + stacks_max = 3, + items = { + { itemstring = "mcl_core:birchsapling", weight = 1, amount_min = 1, amount_max = 2 }, + { itemstring = "mcl_core:acaciasapling", weight = 1, amount_min = 1, amount_max = 2 }, + { itemstring = "", weight = 6 }, + }, + }) +end + local function ecb_spawn_dungeon(blockpos, action, calls_remaining, param) if calls_remaining >= 1 then return end @@ -310,66 +371,6 @@ local function ecb_spawn_dungeon(blockpos, action, calls_remaining, param) set_node(pos, {name="mcl_chests:chest", param2=facedir}) local meta = get_meta(pos) - - local loottable = - { - { - stacks_min = 1, - stacks_max = 3, - items = { - { itemstring = "mcl_mobs:nametag", weight = 20 }, - { itemstring = "mcl_mobitems:saddle", weight = 20 }, - { itemstring = "mcl_jukebox:record_1", weight = 15 }, - { itemstring = "mcl_jukebox:record_4", weight = 15 }, - { itemstring = "mobs_mc:iron_horse_armor", weight = 15 }, - { itemstring = "mcl_core:apple_gold", weight = 15 }, - { itemstack = mcl_enchanting.get_uniform_randomly_enchanted_book({"soul_speed"}, pr), weight = 10 }, - { itemstring = "mobs_mc:gold_horse_armor", weight = 10 }, - { itemstring = "mobs_mc:diamond_horse_armor", weight = 5 }, - { itemstring = "mcl_core:apple_gold_enchanted", weight = 2 }, - } - }, - { - stacks_min = 1, - stacks_max = 4, - items = { - { itemstring = "mcl_farming:wheat_item", weight = 20, amount_min = 1, amount_max = 4 }, - { itemstring = "mcl_farming:bread", weight = 20 }, - { itemstring = "mcl_core:coal_lump", weight = 15, amount_min = 1, amount_max = 4 }, - { itemstring = "mesecons:redstone", weight = 15, amount_min = 1, amount_max = 4 }, - { itemstring = "mcl_farming:beetroot_seeds", weight = 10, amount_min = 2, amount_max = 4 }, - { itemstring = "mcl_farming:melon_seeds", weight = 10, amount_min = 2, amount_max = 4 }, - { itemstring = "mcl_farming:pumpkin_seeds", weight = 10, amount_min = 2, amount_max = 4 }, - { itemstring = "mcl_core:iron_ingot", weight = 10, amount_min = 1, amount_max = 4 }, - { itemstring = "mcl_buckets:bucket_empty", weight = 10 }, - { itemstring = "mcl_core:gold_ingot", weight = 5, amount_min = 1, amount_max = 4 }, - }, - }, - { - stacks_min = 3, - stacks_max = 3, - items = { - { itemstring = "mcl_mobitems:bone", weight = 10, amount_min = 1, amount_max = 8 }, - { itemstring = "mcl_mobitems:gunpowder", weight = 10, amount_min = 1, amount_max = 8 }, - { itemstring = "mcl_mobitems:rotten_flesh", weight = 10, amount_min = 1, amount_max = 8 }, - { itemstring = "mcl_mobitems:string", weight = 10, amount_min = 1, amount_max = 8 }, - }, - } - } - - -- Bonus loot for v6 mapgen: Otherwise unobtainable saplings. - if mg_name == "v6" then - table_insert(loottable, { - stacks_min = 1, - stacks_max = 3, - items = { - { itemstring = "mcl_core:birchsapling", weight = 1, amount_min = 1, amount_max = 2 }, - { itemstring = "mcl_core:acaciasapling", weight = 1, amount_min = 1, amount_max = 2 }, - { itemstring = "", weight = 6 }, - }, - }) - end - minetest.log("action", "[mcl_dungeons] Filling chest " .. tostring(c) .. " at " .. minetest.pos_to_string(pos)) mcl_loot.fill_inventory(meta:get_inventory(), "main", mcl_loot.get_multi_loot(loottable, pr), pr) end diff --git a/mods/MAPGEN/mcl_structures/init.lua b/mods/MAPGEN/mcl_structures/init.lua index 8efdd91b1..be1be0f67 100644 --- a/mods/MAPGEN/mcl_structures/init.lua +++ b/mods/MAPGEN/mcl_structures/init.lua @@ -187,8 +187,6 @@ function mcl_structures.generate_igloo(pos, rotation, pr) if real_depth <= 6 then return success end - -- Place hidden trapdoor - minetest.set_node(tpos, {name="mcl_doors:trapdoor", param2=20+minetest.dir_to_facedir(dir)}) -- TODO: more reliable param2 -- Generate ladder to basement for y=1, real_depth-1 do set_brick({x=tpos.x-1,y=tpos.y-y,z=tpos.z }) @@ -199,6 +197,10 @@ function mcl_structures.generate_igloo(pos, rotation, pr) end -- Place basement mcl_structures.generate_igloo_basement(bpos, rotation, pr) + -- Place hidden trapdoor + minetest.after(5, function(tpos, dir) + minetest.set_node(tpos, {name="mcl_doors:trapdoor", param2=20+minetest.dir_to_facedir(dir)}) -- TODO: more reliable param2 + end, tpos, dir) end return success end @@ -452,7 +454,9 @@ local function temple_placement_callback(p1, p2, size, rotation, pr) { itemstring = "mcl_mobitems:bone", weight = 25, amount_min = 4, amount_max=6 }, { itemstring = "mcl_mobitems:rotten_flesh", weight = 25, amount_min = 3, amount_max=7 }, { itemstring = "mcl_mobitems:spider_eye", weight = 25, amount_min = 1, amount_max=3 }, - { itemstack = mcl_enchanting.get_uniform_randomly_enchanted_book({"soul_speed"}, pr), weight = 20, }, + { itemstring = "mcl_books:book", weight = 20, func = function(stack, pr) + mcl_enchanting.enchant_uniform_randomly(stack, {"soul_speed"}, pr) + end }, { itemstring = "mcl_mobitems:saddle", weight = 20, }, { itemstring = "mcl_core:apple_gold", weight = 20, }, { itemstring = "mcl_core:gold_ingot", weight = 15, amount_min = 2, amount_max = 7 }, diff --git a/mods/MAPGEN/tsm_railcorridors/gameconfig.lua b/mods/MAPGEN/tsm_railcorridors/gameconfig.lua index 168ecf535..de4b18119 100644 --- a/mods/MAPGEN/tsm_railcorridors/gameconfig.lua +++ b/mods/MAPGEN/tsm_railcorridors/gameconfig.lua @@ -66,7 +66,9 @@ function tsm_railcorridors.get_treasures(pr) items = { { itemstring = "mcl_mobs:nametag", weight = 30 }, { itemstring = "mcl_core:apple_gold", weight = 20 }, - { itemstack = mcl_enchanting.get_uniform_randomly_enchanted_book({"soul_speed"}, pr), weight = 10 }, + { itemstring = "mcl_books:book", weight = 10, func = function(stack, pr) + mcl_enchanting.enchant_uniform_randomly(stack, {"soul_speed"}, pr) + end }, { itemstring = "", weight = 5}, { itemstring = "mcl_core:pick_iron", weight = 5 }, { itemstring = "mcl_core:apple_gold_enchanted", weight = 1 }, diff --git a/mods/MISC/mcl_privs/init.lua b/mods/MISC/mcl_privs/init.lua index 63694ab11..f06ff3582 100644 --- a/mods/MISC/mcl_privs/init.lua +++ b/mods/MISC/mcl_privs/init.lua @@ -3,3 +3,27 @@ local S = minetest.get_translator(minetest.get_current_modname()) minetest.register_privilege("maphack", { description = S("Can place and use advanced blocks like mob spawners, command blocks and barriers."), }) + +minetest.register_on_joinplayer(function(player) + local name = player:get_player_name() + local meta = player:get_meta() + if meta:get_int("fly_changed") == 1 then return end + + local fly = nil + if minetest.is_creative_enabled(name) then + fly = true + end + local player_privs = minetest.get_player_privs(name) + player_privs.fly = fly + minetest.set_player_privs(name, player_privs) +end) + +for _, action in pairs({"grant", "revoke"}) do + minetest["register_on_priv_" .. action](function(name, _, priv) + if priv == "fly" then + local player = minetest.get_player_by_name(name) + local meta = player:get_meta() + meta:set_int("fly_changed", 1) + end + end) +end \ No newline at end of file diff --git a/mods/MISC/mcl_temp_helper_recipes/init.lua b/mods/MISC/mcl_temp_helper_recipes/init.lua index 420cd6c2e..b7607946d 100644 --- a/mods/MISC/mcl_temp_helper_recipes/init.lua +++ b/mods/MISC/mcl_temp_helper_recipes/init.lua @@ -35,40 +35,6 @@ minetest.register_craft({ }, }) -minetest.register_craft({ - output = "mcl_armor:helmet_chain", - recipe = { - { "xpanes:bar_flat", "mcl_core:iron_ingot", "xpanes:bar_flat" }, - { "xpanes:bar_flat", "", "xpanes:bar_flat" }, - } -}) - -minetest.register_craft({ - output = "mcl_armor:leggings_chain", - recipe = { - { "xpanes:bar_flat", "mcl_core:iron_ingot", "xpanes:bar_flat" }, - { "xpanes:bar_flat", "", "xpanes:bar_flat" }, - { "xpanes:bar_flat", "", "xpanes:bar_flat" }, - } -}) - -minetest.register_craft({ - output = "mcl_armor:boots_chain", - recipe = { - { "xpanes:bar_flat", "", "xpanes:bar_flat" }, - { "xpanes:bar_flat", "", "xpanes:bar_flat" }, - } -}) - -minetest.register_craft({ - output = "mcl_armor:chestplate_chain", - recipe = { - { "xpanes:bar_flat", "", "xpanes:bar_flat" }, - { "xpanes:bar_flat", "mcl_core:iron_ingot", "xpanes:bar_flat" }, - { "xpanes:bar_flat", "xpanes:bar_flat", "xpanes:bar_flat" }, - } -}) - -- Make red sand, red sandstone and more craftable in v6 -- NOTE: When you change these, also update mcl_craftguide for the "v6" icon in -- the craft guide! diff --git a/mods/PLAYER/mcl_hunger/hunger.lua b/mods/PLAYER/mcl_hunger/hunger.lua index 5dec8b1b0..d9a6fd5fe 100644 --- a/mods/PLAYER/mcl_hunger/hunger.lua +++ b/mods/PLAYER/mcl_hunger/hunger.lua @@ -152,26 +152,18 @@ function mcl_hunger.item_eat(hunger_change, replace_with_item, poisontime, poiso -- If false, force item to not spawn any food partiles when eaten if def._food_particles ~= false and texture and texture ~= "" then local v = user:get_velocity() or user:get_player_velocity() - local minvel = vector.add(v, {x=-1, y=1, z=-1}) - local maxvel = vector.add(v, {x=1, y=2, z=1}) - - minetest.add_particlespawner({ - amount = math.min(math.max(8, hunger_change*2), 25), - time = 0.1, - minpos = {x=pos.x, y=pos.y, z=pos.z}, - maxpos = {x=pos.x, y=pos.y, z=pos.z}, - minvel = minvel, - maxvel = maxvel, - minacc = {x=0, y=-5, z=0}, - maxacc = {x=0, y=-9, z=0}, - minexptime = 1, - maxexptime = 1, - minsize = 1, - maxsize = 2, - collisiondetection = true, - vertical = false, - texture = texture, - }) + for i = 0, math.min(math.max(8, hunger_change*2), 25) do + minetest.add_particle({ + pos = { x = pos.x, y = pos.y, z = pos.z }, + velocity = vector.add(v, { x = math.random(-1, 1), y = math.random(1, 2), z = math.random(-1, 1) }), + acceleration = { x = 0, y = math.random(-9, -5), z = 0 }, + expirationtime = 1, + size = math.random(1, 2), + collisiondetection = true, + vertical = false, + texture = "[combine:3x3:" .. -i .. "," .. -i .. "=" .. texture, + }) + end end minetest.sound_play("mcl_hunger_bite", { max_hear_distance = 12, diff --git a/mods/PLAYER/mcl_hunger/init.lua b/mods/PLAYER/mcl_hunger/init.lua index 8c154700a..21c1e0860 100644 --- a/mods/PLAYER/mcl_hunger/init.lua +++ b/mods/PLAYER/mcl_hunger/init.lua @@ -91,8 +91,8 @@ end -- register saturation hudbar hb.register_hudbar("hunger", 0xFFFFFF, S("Food"), { icon = "hbhunger_icon.png", bgicon = "hbhunger_bgicon.png", bar = "hbhunger_bar.png" }, 1, 20, 20, false) if mcl_hunger.debug then - hb.register_hudbar("saturation", 0xFFFFFF, S("Saturation"), { icon = "mcl_hunger_icon_saturation.png", bgicon = "mcl_hunger_bgicon_saturation.png", bar = "mcl_hunger_bar_saturation.png" }, 1, mcl_hunger.SATURATION_INIT, 200, false, S("%s: %.1f/%d")) - hb.register_hudbar("exhaustion", 0xFFFFFF, S("Exhaust."), { icon = "mcl_hunger_icon_exhaustion.png", bgicon = "mcl_hunger_bgicon_exhaustion.png", bar = "mcl_hunger_bar_exhaustion.png" }, 1, 0, mcl_hunger.EXHAUST_LVL, false, S("%s: %d/%d")) + hb.register_hudbar("saturation", 0xFFFFFF, S("Saturation"), { icon = "mcl_hunger_icon_saturation.png", bgicon = "mcl_hunger_bgicon_saturation.png", bar = "mcl_hunger_bar_saturation.png" }, 1, mcl_hunger.SATURATION_INIT, 200, false) + hb.register_hudbar("exhaustion", 0xFFFFFF, S("Exhaust."), { icon = "mcl_hunger_icon_exhaustion.png", bgicon = "mcl_hunger_bgicon_exhaustion.png", bar = "mcl_hunger_bar_exhaustion.png" }, 1, 0, mcl_hunger.EXHAUST_LVL, false) end minetest.register_on_joinplayer(function(player) @@ -134,47 +134,46 @@ minetest.register_on_player_hpchange(function(player, hp_change) end end) -local main_timer = 0 -local timer = 0 -- Half second timer -local timerMult = 1 -- Cycles from 0 to 7, each time when timer hits half a second +local food_tick_timers = {} -- one food_tick_timer per player, keys are the player-objects minetest.register_globalstep(function(dtime) - main_timer = main_timer + dtime - timer = timer + dtime - if main_timer > mcl_hunger.HUD_TICK or timer > 0.25 then - if main_timer > mcl_hunger.HUD_TICK then main_timer = 0 end - for _,player in pairs(minetest.get_connected_players()) do - local name = player:get_player_name() + for _,player in pairs(minetest.get_connected_players()) do - local h = tonumber(mcl_hunger.get_hunger(player)) - local hp = player:get_hp() - if timer > 0.25 then - -- Slow health regeneration, and hunger damage (every 4s). - -- Regeneration rate based on tutorial video . - -- Minecraft Wiki seems to be wrong in claiming that full hunger gives 0.5s regen rate. - if timerMult == 0 then - if h >= 18 and hp > 0 and hp < 20 then - -- +1 HP, +exhaustion - player:set_hp(hp+1) - mcl_hunger.exhaust(name, mcl_hunger.EXHAUST_REGEN) + local food_tick_timer = food_tick_timers[player] and food_tick_timers[player] + dtime or 0 + local player_name = player:get_player_name() + local food_level = mcl_hunger.get_hunger(player) + local food_saturation_level = mcl_hunger.get_saturation(player) + local player_health = player:get_hp() + + if food_tick_timer > 4.0 then + food_tick_timer = 0 + + if food_level >= 18 then -- slow regenration + if player_health > 0 and player_health < 20 then + player:set_hp(player_health+1) + mcl_hunger.exhaust(player_name, mcl_hunger.EXHAUST_REGEN) mcl_hunger.update_exhaustion_hud(player, mcl_hunger.get_exhaustion(player)) - elseif h == 0 then - -- Damage hungry player down to 1 HP - -- TODO: Allow starvation at higher difficulty levels - if hp-1 > 0 then - mcl_util.deal_damage(player, 1, {type = "starve"}) - end + end + + elseif food_level == 0 then -- starvation + -- the amount of health at which a player will stop to get + -- harmed by starvation (10 for Easy, 1 for Normal, 0 for Hard) + local maximum_starvation = 1 + -- TODO: implement Minecraft-like difficulty modes and the update maximumStarvation here + if player_health > maximum_starvation then + mcl_util.deal_damage(player, 1, {type = "starve"}) end end + elseif food_tick_timer > 0.5 and food_level == 20 and food_saturation_level >= 6 then -- fast regeneration + if player_health > 0 and player_health < 20 then + food_tick_timer = 0 + player:set_hp(player_health+1) + mcl_hunger.exhaust(player_name, mcl_hunger.EXHAUST_REGEN) + mcl_hunger.update_exhaustion_hud(player, mcl_hunger.get_exhaustion(player)) + end end - end - end - if timer > 0.25 then - timer = 0 - timerMult = timerMult + 2 - if timerMult > 7 then - timerMult = 0 - end + + food_tick_timers[player] = food_tick_timer -- update food_tick_timer table end end) diff --git a/mods/PLAYER/mcl_player/init.lua b/mods/PLAYER/mcl_player/init.lua index 6cf2f0014..2a4c25c34 100644 --- a/mods/PLAYER/mcl_player/init.lua +++ b/mods/PLAYER/mcl_player/init.lua @@ -9,7 +9,7 @@ local animation_blend = 0 local function get_mouse_button(player) local controls = player:get_player_control() local get_wielded_item_name = player:get_wielded_item():get_name() - if controls.RMB and not string.find(get_wielded_item_name, "mcl_bows:bow") or controls.LMB then + if controls.RMB and not string.find(get_wielded_item_name, "mcl_bows:bow") and not string.find(get_wielded_item_name, "mcl_bows:crossbow") or controls.LMB then return true else return false @@ -212,6 +212,10 @@ minetest.register_globalstep(function(dtime) player_set_animation(player, "swim_walk_mine", animation_speed_mod) elseif not controls.sneak and head_in_water and is_sprinting == true then player_set_animation(player, "swim_walk", animation_speed_mod) + elseif string.find(player:get_wielded_item():get_name(), "mcl_bows:bow") and controls.RMB and controls.sneak or string.find(player:get_wielded_item():get_name(), "mcl_bows:crossbow_") and controls.sneak then + player_set_animation(player, "bow_sneak", animation_speed_mod) + elseif string.find(player:get_wielded_item():get_name(), "mcl_bows:bow") and controls.RMB or string.find(player:get_wielded_item():get_name(), "mcl_bows:crossbow_") then + player_set_animation(player, "bow_walk", animation_speed_mod) elseif is_sprinting == true and get_mouse_button(player) == true and not controls.sneak and not head_in_water then player_set_animation(player, "run_walk_mine", animation_speed_mod) elseif get_mouse_button(player) == true and not controls.sneak then diff --git a/mods/PLAYER/mcl_playerplus/init.lua b/mods/PLAYER/mcl_playerplus/init.lua index 1e1354ae0..50fec2bd6 100644 --- a/mods/PLAYER/mcl_playerplus/init.lua +++ b/mods/PLAYER/mcl_playerplus/init.lua @@ -51,6 +51,15 @@ local function player_collision(player) return {x,z} end +local function walking_player(player, control) + if control.up or control.down or control.left or control.right then + return true + else + return false + end +end + + -- converts yaw to degrees local function degrees(rad) return rad * 180.0 / math.pi @@ -118,6 +127,7 @@ minetest.register_globalstep(function(dtime) for _,player in pairs(get_connected_players()) do --[[ + _ _ _ __ _ _ __ (_)_ __ ___ __ _| |_(_) ___ _ __ ___ / _` | '_ \| | '_ ` _ \ / _` | __| |/ _ \| '_ \/ __| @@ -211,16 +221,29 @@ minetest.register_globalstep(function(dtime) player:set_bone_position("Wield_Item", vector.new(0,3.9,1.3), vector.new(90,0,0)) elseif string.find(wielded:get_name(), "mcl_bows:bow") then player:set_bone_position("Wield_Item", vector.new(.5,4.5,-1.6), vector.new(90,0,20)) + elseif string.find(wielded:get_name(), "mcl_bows:crossbow_loaded") then + player:set_bone_position("Wield_Item", vector.new(-1.5,5.7,1.8), vector.new(64,90,0)) + elseif string.find(wielded:get_name(), "mcl_bows:crossbow") then + player:set_bone_position("Wield_Item", vector.new(-1.5,5.7,1.8), vector.new(90,90,0)) else player:set_bone_position("Wield_Item", vector.new(-1.5,4.9,1.8), vector.new(135,0,90)) end player_velocity_old = player:get_velocity() or player:get_player_velocity() + -- controls right and left arms pitch when shooting a bow - if string.find(wielded:get_name(), "mcl_bows:bow") and control.RMB and not control.LMB and not control.up and not control.down and not control.left and not control.right then + if string.find(wielded:get_name(), "mcl_bows:bow") and control.RMB then player:set_bone_position("Arm_Right_Pitch_Control", vector.new(-3,5.785,0), vector.new(pitch+90,-30,pitch * -1 * .35)) player:set_bone_position("Arm_Left_Pitch_Control", vector.new(3.5,5.785,0), vector.new(pitch+90,43,pitch * .35)) + -- controls right and left arms pitch when holing a loaded crossbow + elseif string.find(wielded:get_name(), "mcl_bows:crossbow_loaded") then + player:set_bone_position("Arm_Right_Pitch_Control", vector.new(-3,5.785,0), vector.new(pitch+90,-30,pitch * -1 * .35)) + player:set_bone_position("Arm_Left_Pitch_Control", vector.new(3.5,5.785,0), vector.new(pitch+90,43,pitch * .35)) + -- controls right and left arms pitch when loading a crossbow + elseif string.find(wielded:get_name(), "mcl_bows:crossbow_") then + player:set_bone_position("Arm_Right_Pitch_Control", vector.new(-3,5.785,0), vector.new(45,-20,25)) + player:set_bone_position("Arm_Left_Pitch_Control", vector.new(3,5.785,0), vector.new(55,20,-45)) -- when punching elseif control.LMB and not parent then player:set_bone_position("Arm_Right_Pitch_Control", vector.new(-3,5.785,0), vector.new(pitch,0,0)) @@ -527,7 +550,8 @@ mcl_damage.register_modifier(function(obj, damage, reason) node = minetest.get_node(pos) end if node then - if minetest.registered_nodes[node.name].walkable then + local def = minetest.registered_nodes[node.name] + if not def or def.walkable then return end if minetest.get_item_group(node.name, "water") ~= 0 then diff --git a/mods/PLAYER/mcl_playerplus/mod.conf b/mods/PLAYER/mcl_playerplus/mod.conf index 6989957d7..b77c9e2e5 100644 --- a/mods/PLAYER/mcl_playerplus/mod.conf +++ b/mods/PLAYER/mcl_playerplus/mod.conf @@ -1,5 +1,5 @@ name = mcl_playerplus author = TenPlus1 description = Adds some simple player-related gameplay effects: Hurt by touching a cactus, suffocation and more. -depends = mcl_init, mcl_core, mcl_particles, mcl_hunger, playerphysics, mcl_playerinfo, mcl_weather, mcl_spawn, mcl_enchanting, mcl_damage +depends = mcl_init, mcl_core, mcl_particles, mcl_hunger, playerphysics, mcl_playerinfo, mcl_weather, mcl_spawn, mcl_enchanting, mcl_damage, mcl_sprint diff --git a/mods/PLAYER/mcl_sprint/init.lua b/mods/PLAYER/mcl_sprint/init.lua index 73a518c42..4c0d609c9 100644 --- a/mods/PLAYER/mcl_sprint/init.lua +++ b/mods/PLAYER/mcl_sprint/init.lua @@ -69,18 +69,19 @@ local function setSprinting(playerName, sprinting) --Sets the state of a player local controls = player:get_player_control() if players[playerName] then players[playerName].sprinting = sprinting + local fov_old = players[playerName].fov + local fov_new = fov_old + local fade_time = .15 if sprinting == true or controls.RMB and string.find(player:get_wielded_item():get_name(), "mcl_bows:bow") and player:get_wielded_item():get_name() ~= "mcl_bows:bow" then if sprinting == true then - players[playerName].fov = math.min(players[playerName].fov + 0.05, 1.2) - players[playerName].fade_time = .15 + fov_new = math.min(players[playerName].fov + 0.05, 1.2) else - players[playerName].fov = .7 + fov_new = .7 players[playerName].fade_time = .3 end - player:set_fov(players[playerName].fov, true, players[playerName].fade_time) if sprinting == true then playerphysics.add_physics_factor(player, "speed", "mcl_sprint:sprint", mcl_sprint.SPEED) end @@ -88,12 +89,15 @@ local function setSprinting(playerName, sprinting) --Sets the state of a player and player:get_wielded_item():get_name() ~= "mcl_bows:bow_0" and player:get_wielded_item():get_name() ~= "mcl_bows:bow_1" and player:get_wielded_item():get_name() ~= "mcl_bows:bow_2" then - players[playerName].fov = math.max(players[playerName].fov - 0.05, 1.0) - player:set_fov(players[playerName].fov, true, 0.15) + fov_new = math.max(players[playerName].fov - 0.05, 1.0) if sprinting == false then playerphysics.remove_physics_factor(player, "speed", "mcl_sprint:sprint") end end + if fov_new ~= fov_old then + players[playerName].fov = fov_new + player:set_fov(fov_new, true, fade_time) + end return true end return false diff --git a/settingtypes.txt b/settingtypes.txt index ea1c1a50a..542711675 100644 --- a/settingtypes.txt +++ b/settingtypes.txt @@ -33,9 +33,12 @@ mcl_tnt_griefing (TNT destroys blocks) bool true # This setting is only read at startup. enable_bed_respawn (Respawn at bed) bool true -# If enabled, the night can be skipped if all players are in bed. -# This setting is only read at startup. -enable_bed_night_skip (Skip night when sleeping) bool true +# How many players have to sleep to skip the night, in percent. +# Setting to 0 will mean 1 player is always enough to skip the night. Setting above 100 will prevent skipping the night. +# 100 by default. +# The setting can be changed ingame using `/set mcl_playersSleepingPercentage ` +mcl_playersSleepingPercentage (Players Sleeping Percentage) int 100 + # Normally, players drop all their items when they die. Enable this # setting, so players always keep their inventory on death. mcl_keepInventory (Keep inventory on death) bool false @@ -153,3 +156,7 @@ fix_doubleplants (Mcimport double plant fixes) bool true # Allow players to create Minecraft-like maps. enable_real_maps (Enable Real Maps) bool true + +[Debugging] +# If enabled, this will show the itemstring of an item in the description. +mcl_item_id_debug (Item ID Debug) bool false \ No newline at end of file diff --git a/tools/Texture_Converter.py b/tools/Texture_Converter.py index 820fa9c08..bdf249113 100755 --- a/tools/Texture_Converter.py +++ b/tools/Texture_Converter.py @@ -118,17 +118,6 @@ def colorize_alpha(colormap, source, colormap_pixel, texture_size, destination): colorize(colormap, source, colormap_pixel, texture_size, tempfile2.name) os.system("composite -compose Dst_In "+source+" "+tempfile2.name+" -alpha Set "+destination) -# This function is unused atm. -# TODO: Implemnt colormap extraction -def extract_colormap(colormap, colormap_pixel, positions): - os.system("convert -size 16x16 canvas:black "+tempfile1.name) - x=0 - y=0 - for p in positions: - os.system("convert "+colormap+" -crop 1x1+"+colormap_pixel+" -depth 8 "+tempfile2.name) - os.system("composite -geometry 16x16+"+x+"+"+y+" "+tempfile2.name) - x = x+1 - def target_dir(directory): if make_texture_pack: return output_dir + "/" + output_dir_name @@ -397,20 +386,60 @@ def convert_textures(): colorize_alpha(FOLIAG, tex_dir+"/blocks/vine.png", "16+39", str(PXSIZE), target_dir("/mods/ITEMS/mcl_core/textures")+"/mcl_core_vine.png") # Tall grass, fern (inventory images) - pcol = "49+172" # Plains grass color + pcol = "50+173" # Plains grass color colorize_alpha(GRASS, tex_dir+"/blocks/tallgrass.png", pcol, str(PXSIZE), target_dir("/mods/ITEMS/mcl_flowers/textures")+"/mcl_flowers_tallgrass_inv.png") colorize_alpha(GRASS, tex_dir+"/blocks/fern.png", pcol, str(PXSIZE), target_dir("/mods/ITEMS/mcl_flowers/textures")+"/mcl_flowers_fern_inv.png") colorize_alpha(GRASS, tex_dir+"/blocks/double_plant_fern_top.png", pcol, str(PXSIZE), target_dir("/mods/ITEMS/mcl_flowers/textures")+"/mcl_flowers_double_plant_fern_inv.png") colorize_alpha(GRASS, tex_dir+"/blocks/double_plant_grass_top.png", pcol, str(PXSIZE), target_dir("/mods/ITEMS/mcl_flowers/textures")+"/mcl_flowers_double_plant_grass_inv.png") - # TODO: Convert grass palette - - offset = [ - [ pcol, "", "grass" ], # Default grass: Plains + # Convert grass palette: https://minecraft.fandom.com/wiki/Tint + grass_colors = [ + # [Coords or #Color, AdditionalTint], # Index - Minecraft biome name (MineClone2 biome names) + ["50+173"], # 0 - Plains (flat, Plains, Plains_beach, Plains_ocean, End) + ["0+255"], # 1 - Savanna (Savanna, Savanna_beach, Savanna_ocean) + ["255+255"], # 2 - Ice Spikes (IcePlainsSpikes, IcePlainsSpikes_ocean) + ["255+255"], # 3 - Snowy Taiga (ColdTaiga, ColdTaiga_beach, ColdTaiga_beach_water, ColdTaiga_ocean) + ["178+193"], # 4 - Giant Tree Taiga (MegaTaiga, MegaTaiga_ocean) + ["178+193"], # 5 - Giant Tree Taiga (MegaSpruceTaiga, MegaSpruceTaiga_ocean) + ["203+239"], # 6 - Montains (ExtremeHills, ExtremeHills_beach, ExtremeHills_ocean) + ["203+239"], # 7 - Montains (ExtremeHillsM, ExtremeHillsM_ocean) + ["203+239"], # 8 - Montains (ExtremeHills+, ExtremeHills+_snowtop, ExtremeHills+_ocean) + ["50+173"], # 9 - Beach (StoneBeach, StoneBeach_ocean) + ["255+255"], # 10 - Snowy Tundra (IcePlains, IcePlains_ocean) + ["50+173"], # 11 - Sunflower Plains (SunflowerPlains, SunflowerPlains_ocean) + ["191+203"], # 12 - Taiga (Taiga, Taiga_beach, Taiga_ocean) + ["76+112"], # 13 - Forest (Forest, Forest_beach, Forest_ocean) + ["76+112"], # 14 - Flower Forest (FlowerForest, FlowerForest_beach, FlowerForest_ocean) + ["101+163"], # 15 - Birch Forest (BirchForest, BirchForest_ocean) + ["101+163"], # 16 - Birch Forest Hills (BirchForestM, BirchForestM_ocean) + ["0+255"], # 17 - Desert and Nether (Desert, Desert_ocean, Nether) + ["76+112", "#28340A"], # 18 - Dark Forest (RoofedForest, RoofedForest_ocean) + ["#90814d"], # 19 - Mesa (Mesa, Mesa_sandlevel, Mesa_ocean, ) + ["#90814d"], # 20 - Mesa (MesaBryce, MesaBryce_sandlevel, MesaBryce_ocean) + ["#90814d"], # 21 - Mesa (MesaPlateauF, MesaPlateauF_grasstop, MesaPlateauF_sandlevel, MesaPlateauF_ocean) + ["#90814d"], # 22 - Mesa (MesaPlateauFM, MesaPlateauFM_grasstop, MesaPlateauFM_sandlevel, MesaPlateauFM_ocean) + ["0+255"], # 23 - Shattered Savanna (or Savanna Plateau ?) (SavannaM, SavannaM_ocean) + ["12+36"], # 24 - Jungle (Jungle, Jungle_shore, Jungle_ocean) + ["12+36"], # 25 - Modified Jungle (JungleM, JungleM_shore, JungleM_ocean) + ["12+61"], # 26 - Jungle Edge (JungleEdge, JungleEdge_ocean) + ["12+61"], # 27 - Modified Jungle Edge (JungleEdgeM, JungleEdgeM_ocean) + ["#6A7039"], # 28 - Swamp (Swampland, Swampland_shore, Swampland_ocean) + ["25+25"], # 29 - Mushroom Fields and Mushroom Field Shore (MushroomIsland, MushroomIslandShore, MushroomIsland_ocean) ] - for o in offset: - colorize(GRASS, tex_dir+"/blocks/grass_top.png", o[0], str(PXSIZE), target_dir("/mods/ITEMS/mcl_core/textures")+"/default_"+o[2]+".png") - colorize_alpha(GRASS, tex_dir+"/blocks/grass_side_overlay.png", o[0], str(PXSIZE), target_dir("/mods/ITEMS/mcl_core/textures")+"/default_"+o[2]+"_side.png") + + grass_palette_file = target_dir("/mods/ITEMS/mcl_core/textures") + "/mcl_core_palette_grass.png" + os.system("convert -size 16x16 canvas:transparent " + grass_palette_file) + + for i, color in enumerate(grass_colors): + if color[0][0] == "#": + os.system("convert -size 1x1 xc:\"" + color[0] + "\" " + tempfile1.name + ".png") + else: + os.system("convert " + GRASS + " -crop 1x1+" + color[0] + " " + tempfile1.name + ".png") + + if len(color) > 1: + os.system("convert " + tempfile1.name + ".png \\( -size 1x1 xc:\"" + color[1] + "\" \\) -compose blend -define compose:args=50,50 -composite " + tempfile1.name + ".png") + + os.system("convert " + grass_palette_file + " \\( " + tempfile1.name + ".png -geometry +" + str(i % 16) + "+" + str(int(i / 16)) + " \\) -composite " + grass_palette_file) # Metadata if make_texture_pack: diff --git a/tools/analyze-packet-spam b/tools/analyze-packet-spam new file mode 100755 index 000000000..310616fd9 --- /dev/null +++ b/tools/analyze-packet-spam @@ -0,0 +1,60 @@ +#!/bin/sh -eu +# analyze-packet-spam – show minetest client packet count per second +# Copyright © 2021 Nils Dagsson Moskopp (erlehmann) + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. + +# Dieses Programm hat das Ziel, die Medienkompetenz der Leser zu +# steigern. Gelegentlich packe ich sogar einen handfesten Buffer +# Overflow oder eine Format String Vulnerability zwischen die anderen +# Codezeilen und schreibe das auch nicht dran. + +# This script takes a minetest log with at least INFO log level and +# outputs the MINETEST network protocol packet count per second. + +# To collect such a log file of minetest running for 10 minutes, run: +# timeout 600 minetest --info >log.txt 2>&1 >/dev/null + +# To get packet counts from that file, run: +# ./analyze-packet-spam "${TEMPFILE}" + +TIMESTAMP_START=$( <"${TEMPFILE}" head -n1 |cut -d' ' -f1 ) +TIMESTAMP_END=$( <"${TEMPFILE}" tail -n1 |cut -d' ' -f1 ) +DURATION=$(( 30 + ${TIMESTAMP_END} - ${TIMESTAMP_START} )) + +PACKET_NAME_SEEN='' +<"${TEMPFILE}" tac \ + |while read _ PACKET_NAME PACKET_COUNT; do + case "${PACKET_NAME_SEEN}" in + *"${PACKET_NAME}"*) + ;; + *) + PACKET_COUNT_PER_SECOND=$( + printf '1k %s %s /p' "${PACKET_COUNT}" "${DURATION}" \ + |dc + ) + printf '%s\t%s\n' "${PACKET_COUNT_PER_SECOND}" "${PACKET_NAME}" + PACKET_NAME_SEEN="${PACKET_NAME_SEEN} ${PACKET_NAME}" + ;; + esac + done + +unlink "${TEMPFILE}" diff --git a/tools/generate_ingame_credits.lua b/tools/generate_ingame_credits.lua new file mode 100755 index 000000000..db124aaf6 --- /dev/null +++ b/tools/generate_ingame_credits.lua @@ -0,0 +1,50 @@ +#! /usr/bin/env lua +-- Script to automatically generate mods/HUD/mcl_credits/people.lua from CREDITS.md +-- Run from MCL2 root folder + +local colors = { + ["Creator of MineClone"] = "0x0A9400", + ["Creator of MineClone2"] = "0xFBF837", + ["Maintainers"] = "0xFF51D5", + ["Developers"] = "0xF84355", + ["Contributors"] = "0x52FF00", + ["MineClone5"] = "0xA60014", + ["Original Mod Authors"] = "0x343434", + ["3D Models"] = "0x0019FF", + ["Textures"] = "0xFF9705", + ["Translations"] = "0x00FF60", + ["Funders"] = "0xF7FF00", + ["Special thanks"] = "0x00E9FF", +} + +local from = io.open("CREDITS.md", "r") +local to = io.open("mods/HUD/mcl_credits/people.lua", "w") + +to:write([[ +local modname = minetest.get_current_modname() +local S = minetest.get_translator(modname) + +]]) + +to:write("return {\n") + +local started_block = false + +for line in from:lines() do + if line:find("## ") == 1 then + if started_block then + to:write("\t}},\n") + end + local title = line:sub(4, #line) + to:write("\t{S(\"" .. title .. "\"), " .. (colors[title] or "0xFFFFFF") .. ", {\n") + started_block = true + elseif line:find("*") == 1 then + to:write("\t\t\"" .. line:sub(3, #line) .. "\",\n") + end +end + +if started_block then + to:write("\t}},\n") +end + +to:write("}\n")